From 4586b332bfd7024d82b2ac7584aeb101f6a9a02a Mon Sep 17 00:00:00 2001 From: neurolabusc Date: Fri, 3 May 2024 12:10:57 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20demo=20from=20@=20niivue/niivu?= =?UTF-8?q?e-brainchop@85a8ffee624d71162d929bcb4db8b039ca52a294=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...RBQ.js => brainchop-webworker-CBK43U_A.js} | 2294 ++++++++--------- .../{index-D8WZGP6y.js => index-C04JT-qQ.js} | 18 +- index.html | 4 +- 3 files changed, 1159 insertions(+), 1157 deletions(-) rename assets/{brainchop-webworker-IyBSiRBQ.js => brainchop-webworker-CBK43U_A.js} (85%) rename assets/{index-D8WZGP6y.js => index-C04JT-qQ.js} (97%) diff --git a/assets/brainchop-webworker-IyBSiRBQ.js b/assets/brainchop-webworker-CBK43U_A.js similarity index 85% rename from assets/brainchop-webworker-IyBSiRBQ.js rename to assets/brainchop-webworker-CBK43U_A.js index dad3b7c..b4054e2 100644 --- a/assets/brainchop-webworker-IyBSiRBQ.js +++ b/assets/brainchop-webworker-CBK43U_A.js @@ -1,4 +1,4 @@ -(function(){"use strict";function gw(n,e){return e.forEach(function(t){t&&typeof t!="string"&&!Array.isArray(t)&&Object.keys(t).forEach(function(s){if(s!=="default"&&!(s in n)){var o=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:function(){return t[s]}})}})}),Object.freeze(n)}/** +(function(){"use strict";function yw(n,e){return e.forEach(function(t){t&&typeof t!="string"&&!Array.isArray(t)&&Object.keys(t).forEach(function(s){if(s!=="default"&&!(s in n)){var o=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:function(){return t[s]}})}})}),Object.freeze(n)}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const xw=1e-7,bw=1e-4;class Op{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}}class Fc{refCount(e){return qt("refCount")}incRef(e){return qt("incRef")}timerAvailable(){return!0}time(e){return qt("time")}read(e){return qt("read")}readSync(e){return qt("readSync")}readToGPU(e,t){return qt("readToGPU")}numDataIds(){return qt("numDataIds")}disposeData(e,t){return qt("disposeData")}write(e,t,s){return qt("write")}move(e,t,s,o,r){return qt("move")}createTensorFromGPUData(e,t,s){return qt("createTensorFromGPUData")}memory(){return qt("memory")}floatPrecision(){return qt("floatPrecision")}epsilon(){return this.floatPrecision()===32?xw:bw}dispose(){return qt("dispose")}}function qt(n){throw new Error(`'${n}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}/** + */const ww=1e-7,Cw=1e-4;class Op{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}}class _c{refCount(e){return jt("refCount")}incRef(e){return jt("incRef")}timerAvailable(){return!0}time(e){return jt("time")}read(e){return jt("read")}readSync(e){return jt("readSync")}readToGPU(e,t){return jt("readToGPU")}numDataIds(){return jt("numDataIds")}disposeData(e,t){return jt("disposeData")}write(e,t,s){return jt("write")}move(e,t,s,o,r){return jt("move")}createTensorFromGPUData(e,t,s){return jt("createTensorFromGPUData")}memory(){return jt("memory")}floatPrecision(){return jt("floatPrecision")}epsilon(){return this.floatPrecision()===32?ww:Cw}dispose(){return jt("dispose")}}function jt(n){throw new Error(`'${n}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,7 +28,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function yw(n){let e=n.length,t=0;for(;e>0;)t=Math.random()*e|0,e--,Ro(n,e,t)}function Us(n,e,t){return Math.max(n,Math.min(e,t))}function _c(n){return n%2===0?n:n+1}function Ro(n,e,t){const s=n[e];n[e]=n[t],n[t]=s}function ww(n){let e=0;for(let t=0;tt+` Shapes ${n} and ${e} must match`)}function Lp(n){$(n!=null,()=>"The input to the tensor constructor must be a non-null value.")}function H(n){if(n.length===0)return 1;let e=n[0];for(let t=1;t0,t,s){return new Promise((o,r)=>{let i=0;const a=()=>{if(n()){o();return}i++;const l=e(i);if(t!=null&&i>=t){r();return}s!=null?s(a,l):setTimeout(a,l)};a()})}function Pp(n,e){let t=1,s=-1;for(let r=0;r=0)t*=n[r];else if(n[r]===-1){if(s!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${s} and dim ${r}`);s=r}else if(n[r]<0)throw Error(`Shapes can not be < 0. Found ${n[r]} at dim ${r}`);if(s===-1){if(e>0&&e!==t)throw Error(`Size(${e}) must match the product of shape ${n}`);return n}if(t===0)throw Error(`Cannot infer the missing size in [${n}] when there are 0 elements`);if(e%t!==0)throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${t}`);const o=n.slice();return o[s]=e/t,o}function $e(n,e){const t=e.length;return n=n==null?e.map((s,o)=>o):[].concat(n),$(n.every(s=>s>=-t&&s`All values in axis param must be in range [-${t}, ${t}) but got axis ${n}`),$(n.every(s=>Ao(s)),()=>`All values in axis param must be integers but got axis ${n}`),n.map(s=>s<0?t+s:s)}function ms(n,e){const t=[],s=[],o=e!=null&&Array.isArray(e)&&e.length===0,r=e==null||o?null:$e(e,n).sort();let i=0;for(let a=0;aa)&&n[a]===1&&(t.push(n[a]),s.push(a)),r[i]<=a&&i++}n[a]!==1&&(t.push(n[a]),s.push(a))}return{newShape:t,keptDims:s}}function Tt(n,e){return Je(n,e)}function Je(n,e){let t=null;if(n==null||n==="float32")t=new Float32Array(e);else if(n==="int32")t=new Int32Array(e);else if(n==="bool")t=new Uint8Array(e);else if(n==="string")t=new Array(e);else throw new Error(`Unknown data type ${n}`);return t}function Cw(n,e){for(let t=0;te+=t.length),e}function br(n){return typeof n=="string"||n instanceof String}function vw(n){return typeof n=="boolean"}function Mc(n){return typeof n=="number"}function Fo(n){return Array.isArray(n)?Fo(n[0]):n instanceof Float32Array?"float32":n instanceof Int32Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray?"int32":Mc(n)?"float32":br(n)?"string":vw(n)?"bool":"float32"}function Pc(n){return!!(n&&n.constructor&&n.call&&n.apply)}function Bc(n,e){for(let t=e;t=0;--s)t[s]=t[s+1]*n[s+1];return t}function zp(n,e,t,s=!1){const o=new Array;if(e.length===1){const r=e[0]*(s?2:1);for(let i=0;il*c)*(s?2:1);for(let l=0;lo*r)*(t?2:1);if(s===0)return[];if(s!==e.length)throw new Error(`[${n}] does not match the input size ${e.length}${t?" for a complex tensor":""}.`);return zp(0,n,e,t)}function kw(n,e){if(Array.isArray(n))return n;if(e==="float32")return n instanceof Float32Array?n:new Float32Array(n);if(e==="int32")return n instanceof Int32Array?n:new Int32Array(n);if(e==="bool"||e==="string")return Uint8Array.from(new Int32Array(n));throw new Error(`Unknown dtype ${e}`)}function zc(n,e){const t=Nt(n,e);for(let s=0;ss*o,1);if(e==null||e==="float32")return $n(n,new Float32Array(t));if(e==="int32")return $n(n,new Int32Array(t));if(e==="bool")return $n(n,new Uint8Array(t));throw new Error(`Unknown data type ${e}`)}function ns(n){n.forEach(e=>{$(Number.isInteger(e)&&e>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${n}].`)})}function Pn(n,e,t){if(e===0)return 0;if(e===1)return n[0];let s=n[n.length-1];for(let o=0;o0;)t=Math.random()*e|0,e--,Ao(n,e,t)}function Us(n,e,t){return Math.max(n,Math.min(e,t))}function Oc(n){return n%2===0?n:n+1}function Ao(n,e,t){const s=n[e];n[e]=n[t],n[t]=s}function $w(n){let e=0;for(let t=0;tt+` Shapes ${n} and ${e} must match`)}function Lp(n){$(n!=null,()=>"The input to the tensor constructor must be a non-null value.")}function H(n){if(n.length===0)return 1;let e=n[0];for(let t=1;t0,t,s){return new Promise((o,r)=>{let i=0;const a=()=>{if(n()){o();return}i++;const l=e(i);if(t!=null&&i>=t){r();return}s!=null?s(a,l):setTimeout(a,l)};a()})}function Pp(n,e){let t=1,s=-1;for(let r=0;r=0)t*=n[r];else if(n[r]===-1){if(s!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${s} and dim ${r}`);s=r}else if(n[r]<0)throw Error(`Shapes can not be < 0. Found ${n[r]} at dim ${r}`);if(s===-1){if(e>0&&e!==t)throw Error(`Size(${e}) must match the product of shape ${n}`);return n}if(t===0)throw Error(`Cannot infer the missing size in [${n}] when there are 0 elements`);if(e%t!==0)throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${t}`);const o=n.slice();return o[s]=e/t,o}function $e(n,e){const t=e.length;return n=n==null?e.map((s,o)=>o):[].concat(n),$(n.every(s=>s>=-t&&s`All values in axis param must be in range [-${t}, ${t}) but got axis ${n}`),$(n.every(s=>Do(s)),()=>`All values in axis param must be integers but got axis ${n}`),n.map(s=>s<0?t+s:s)}function ms(n,e){const t=[],s=[],o=e!=null&&Array.isArray(e)&&e.length===0,r=e==null||o?null:$e(e,n).sort();let i=0;for(let a=0;aa)&&n[a]===1&&(t.push(n[a]),s.push(a)),r[i]<=a&&i++}n[a]!==1&&(t.push(n[a]),s.push(a))}return{newShape:t,keptDims:s}}function Tt(n,e){return Je(n,e)}function Je(n,e){let t=null;if(n==null||n==="float32")t=new Float32Array(e);else if(n==="int32")t=new Int32Array(e);else if(n==="bool")t=new Uint8Array(e);else if(n==="string")t=new Array(e);else throw new Error(`Unknown data type ${n}`);return t}function vw(n,e){for(let t=0;te+=t.length),e}function br(n){return typeof n=="string"||n instanceof String}function Tw(n){return typeof n=="boolean"}function Pc(n){return typeof n=="number"}function _o(n){return Array.isArray(n)?_o(n[0]):n instanceof Float32Array?"float32":n instanceof Int32Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray?"int32":Pc(n)?"float32":br(n)?"string":Tw(n)?"bool":"float32"}function Bc(n){return!!(n&&n.constructor&&n.call&&n.apply)}function zc(n,e){for(let t=e;t=0;--s)t[s]=t[s+1]*n[s+1];return t}function zp(n,e,t,s=!1){const o=new Array;if(e.length===1){const r=e[0]*(s?2:1);for(let i=0;il*c)*(s?2:1);for(let l=0;lo*r)*(t?2:1);if(s===0)return[];if(s!==e.length)throw new Error(`[${n}] does not match the input size ${e.length}${t?" for a complex tensor":""}.`);return zp(0,n,e,t)}function Nw(n,e){if(Array.isArray(n))return n;if(e==="float32")return n instanceof Float32Array?n:new Float32Array(n);if(e==="int32")return n instanceof Int32Array?n:new Int32Array(n);if(e==="bool"||e==="string")return Uint8Array.from(new Int32Array(n));throw new Error(`Unknown dtype ${e}`)}function Vc(n,e){const t=Nt(n,e);for(let s=0;ss*o,1);if(e==null||e==="float32")return $n(n,new Float32Array(t));if(e==="int32")return $n(n,new Int32Array(t));if(e==="bool")return $n(n,new Uint8Array(t));throw new Error(`Unknown data type ${e}`)}function ns(n){n.forEach(e=>{$(Number.isInteger(e)&&e>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${n}].`)})}function Pn(n,e,t){if(e===0)return 0;if(e===1)return n[0];let s=n[n.length-1];for(let o=0;o"u"||typeof this.global.location>"u"||typeof this.global.location.search>"u")return;const e=this.getQueryParams(this.global.location.search);Wp in e&&e[Wp].split(",").forEach(s=>{const[o,r]=s.split(":");this.urlFlags[o]=Ew(o,r)})}}function Tw(n){const e={};return n.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(t,...s)=>(Nw(e,s[0],s[1]),s.join("="))),e}function Nw(n,e,t){n[decodeURIComponent(e)]=decodeURIComponent(t||"")}function Ew(n,e){const t=e.toLowerCase();return t==="true"||t==="false"?t==="true":`${+t}`===t?+t:e}function W(){return yr}let yr=null;function Rw(n){yr=n}/** + */const Wp="tfjsflags";class Ew{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=Rw,this.populateURLFlags()}setPlatform(e,t){this.platform!=null&&(W().getBool("IS_TEST")||W().getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)),this.platformName=e,this.platform=t}registerFlag(e,t,s){if(this.flagRegistry[e]={evaluationFn:t,setHook:s},this.urlFlags[e]!=null){const o=this.urlFlags[e];W().getBool("IS_TEST")||W().getBool("PROD")||console.warn(`Setting feature override from URL ${e}: ${o}.`),this.set(e,o)}}async getAsync(e){return e in this.flags?this.flags[e]:(this.flags[e]=await this.evaluateFlag(e),this.flags[e])}get(e){if(e in this.flags)return this.flags[e];const t=this.evaluateFlag(e);if(Wc(t))throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=t,this.flags[e]}getNumber(e){return this.get(e)}getBool(e){return this.get(e)}getString(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(this.flagRegistry[e]==null)throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,this.flagRegistry[e].setHook!=null&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(this.flagRegistry[e]==null)throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(typeof this.global>"u"||typeof this.global.location>"u"||typeof this.global.location.search>"u")return;const e=this.getQueryParams(this.global.location.search);Wp in e&&e[Wp].split(",").forEach(s=>{const[o,r]=s.split(":");this.urlFlags[o]=Dw(o,r)})}}function Rw(n){const e={};return n.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(t,...s)=>(Aw(e,s[0],s[1]),s.join("="))),e}function Aw(n,e,t){n[decodeURIComponent(e)]=decodeURIComponent(t||"")}function Dw(n,e){const t=e.toLowerCase();return t==="true"||t==="false"?t==="true":`${+t}`===t?+t:e}function W(){return yr}let yr=null;function Fw(n){yr=n}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -58,7 +58,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */let Wc;function Up(){if(Wc==null){let n;if(typeof window<"u")n=window;else if(typeof global<"u")n=global;else if(typeof process<"u")n=process;else if(typeof self<"u")n=self;else throw new Error("Could not find a global object");Wc=n}return Wc}function Aw(){const n=Up();return n._tfGlobals==null&&(n._tfGlobals=new Map),n._tfGlobals}function Uc(n,e){const t=Aw();if(t.has(n))return t.get(n);{const s=e();return t.set(n,s),t.get(n)}}const ca="Abs",wr="Acos",Cr="Acosh",Oo="Add",Gc="AddN",Hc="All",jc="Any",ua="ArgMax",ha="ArgMin",Ir="Asin",$r="Asinh",vr="Atan",kr="Atanh",Sr="Atan2",da="AvgPool",qc="AvgPoolGrad",pa="AvgPool3D",Kc="AvgPool3DGrad",fa="BatchMatMul",ma="BatchToSpaceND",Xc="Bincount",Yc="BitwiseAnd",Dw="BroadcastTo",Gp="BroadcastArgs",Tr="Cast",Nr="Ceil",Er="ClipByValue",Zc="Complex",ga="ComplexAbs",xa="Concat",ba="Conv2D",Qc="Conv2DBackpropFilter",ya="Conv2DBackpropInput",wa="Conv3D",Jc="Conv3DBackpropFilterV2",eu="Conv3DBackpropInputV2",Rr="Cos",Ar="Cosh",tu="Cumprod",Ca="Cumsum",nu="CropAndResize",su="DenseBincount",ou="DepthToSpace",Ia="DepthwiseConv2dNative",ru="DepthwiseConv2dNativeBackpropFilter",iu="DepthwiseConv2dNativeBackpropInput",Hp="Diag",$a="Dilation2D",au="Dilation2DBackpropInput",lu="Dilation2DBackpropFilter",Fw="Draw",Dr="RealDiv",cu="Einsum",Fr="Elu",uu="EluGrad",_r="Erf",va="Equal",Or="Exp",ka="ExpandDims",Lr="Expm1",hu="FFT",du="Fill",pu="FlipLeftRight",Mr="Floor",Pr="FloorDiv",Sa="FusedBatchNorm",Ta="GatherV2",jp="GatherNd",Na="Greater",Br="GreaterEqual",zr="Identity",fu="IFFT",mu="Imag",Vr="IsFinite",Wr="IsInf",Ur="IsNan",Ea="LeakyRelu",Ra="Less",Aa="LessEqual",qp="LinSpace",Gr="Log",Hr="Log1p",Da="LogicalAnd",Fa="LogicalNot",_a="LogicalOr",_w="LogSoftmax",Oa="LRN",gu="LRNGrad",La="Max",jr="Maximum",Ma="MaxPool",xu="MaxPoolGrad",Pa="MaxPool3D",bu="MaxPool3DGrad",Kp="MaxPoolWithArgmax",Ba="Mean",za="Min",qr="Minimum",Va="MirrorPad",Kr="Mod",Xp="Multinomial",Xr="Multiply",Wa="Neg",Ua="NotEqual",yu="NonMaxSuppressionV3",wu="NonMaxSuppressionV4",Cu="NonMaxSuppressionV5",Ga="OnesLike",Ha="OneHot",ja="Pack",qa="PadV2",Yr="Pow",Ka="Prelu",Xa="Prod",Yp="RaggedGather",Zp="RaggedRange",Qp="RaggedTensorToTensor",Iu="Range",$u="Real",Zr="Reciprocal",Qr="Relu",Ya="Reshape",Za="ResizeNearestNeighbor",vu="ResizeNearestNeighborGrad",Qa="ResizeBilinear",ku="ResizeBilinearGrad",Jr="Relu6",Ja="Reverse",ei="Round",ti="Rsqrt",Jp="ScatterNd",ef="TensorScatterUpdate",tf="SearchSorted",el="Select",ni="Selu",tl="Slice",si="Sin",oi="Sinh",ri="Sign",ii="Sigmoid",ai="Softplus",li="Sqrt",nl="Sum",sl="SpaceToBatchND",ol="SplitV",rl="Softmax",nf="SparseFillEmptyRows",sf="SparseReshape",of="SparseSegmentMean",rf="SparseSegmentSum",af="SparseToDense",ci="SquaredDifference",Su="Square",Tu="StaticRegexReplace",Nu="StridedSlice",lf="StringNGrams",cf="StringSplit",uf="StringToHashBucketFast",ui="Sub",hi="Tan",di="Tanh",pi="Tile",Eu="TopK",Ru="Transform",Lo="Transpose",Au="Unique",il="Unpack",al="UnsortedSegmentSum",ll="ZerosLike",fi="Step",Ow="FromPixels",Du="RotateWithOffset",cl="_FusedMatMul",ul="FusedConv2D",hf="FusedDepthwiseConv2D";/** + */let Uc;function Up(){if(Uc==null){let n;if(typeof window<"u")n=window;else if(typeof global<"u")n=global;else if(typeof process<"u")n=process;else if(typeof self<"u")n=self;else throw new Error("Could not find a global object");Uc=n}return Uc}function _w(){const n=Up();return n._tfGlobals==null&&(n._tfGlobals=new Map),n._tfGlobals}function Gc(n,e){const t=_w();if(t.has(n))return t.get(n);{const s=e();return t.set(n,s),t.get(n)}}const ca="Abs",wr="Acos",Cr="Acosh",Lo="Add",Hc="AddN",qc="All",jc="Any",ua="ArgMax",ha="ArgMin",Ir="Asin",$r="Asinh",vr="Atan",kr="Atanh",Sr="Atan2",da="AvgPool",Kc="AvgPoolGrad",pa="AvgPool3D",Xc="AvgPool3DGrad",fa="BatchMatMul",ma="BatchToSpaceND",Yc="Bincount",Zc="BitwiseAnd",Ow="BroadcastTo",Gp="BroadcastArgs",Tr="Cast",Nr="Ceil",Er="ClipByValue",Qc="Complex",ga="ComplexAbs",xa="Concat",ba="Conv2D",Jc="Conv2DBackpropFilter",ya="Conv2DBackpropInput",wa="Conv3D",eu="Conv3DBackpropFilterV2",tu="Conv3DBackpropInputV2",Rr="Cos",Ar="Cosh",nu="Cumprod",Ca="Cumsum",su="CropAndResize",ou="DenseBincount",ru="DepthToSpace",Ia="DepthwiseConv2dNative",iu="DepthwiseConv2dNativeBackpropFilter",au="DepthwiseConv2dNativeBackpropInput",Hp="Diag",$a="Dilation2D",lu="Dilation2DBackpropInput",cu="Dilation2DBackpropFilter",Lw="Draw",Dr="RealDiv",uu="Einsum",Fr="Elu",hu="EluGrad",_r="Erf",va="Equal",Or="Exp",ka="ExpandDims",Lr="Expm1",du="FFT",pu="Fill",fu="FlipLeftRight",Mr="Floor",Pr="FloorDiv",Sa="FusedBatchNorm",Ta="GatherV2",qp="GatherNd",Na="Greater",Br="GreaterEqual",zr="Identity",mu="IFFT",gu="Imag",Vr="IsFinite",Wr="IsInf",Ur="IsNan",Ea="LeakyRelu",Ra="Less",Aa="LessEqual",jp="LinSpace",Gr="Log",Hr="Log1p",Da="LogicalAnd",Fa="LogicalNot",_a="LogicalOr",Mw="LogSoftmax",Oa="LRN",xu="LRNGrad",La="Max",qr="Maximum",Ma="MaxPool",bu="MaxPoolGrad",Pa="MaxPool3D",yu="MaxPool3DGrad",Kp="MaxPoolWithArgmax",Ba="Mean",za="Min",jr="Minimum",Va="MirrorPad",Kr="Mod",Xp="Multinomial",Xr="Multiply",Wa="Neg",Ua="NotEqual",wu="NonMaxSuppressionV3",Cu="NonMaxSuppressionV4",Iu="NonMaxSuppressionV5",Ga="OnesLike",Ha="OneHot",qa="Pack",ja="PadV2",Yr="Pow",Ka="Prelu",Xa="Prod",Yp="RaggedGather",Zp="RaggedRange",Qp="RaggedTensorToTensor",$u="Range",vu="Real",Zr="Reciprocal",Qr="Relu",Ya="Reshape",Za="ResizeNearestNeighbor",ku="ResizeNearestNeighborGrad",Qa="ResizeBilinear",Su="ResizeBilinearGrad",Jr="Relu6",Ja="Reverse",ei="Round",ti="Rsqrt",Jp="ScatterNd",ef="TensorScatterUpdate",tf="SearchSorted",el="Select",ni="Selu",tl="Slice",si="Sin",oi="Sinh",ri="Sign",ii="Sigmoid",ai="Softplus",li="Sqrt",nl="Sum",sl="SpaceToBatchND",ol="SplitV",rl="Softmax",nf="SparseFillEmptyRows",sf="SparseReshape",of="SparseSegmentMean",rf="SparseSegmentSum",af="SparseToDense",ci="SquaredDifference",Tu="Square",Nu="StaticRegexReplace",Eu="StridedSlice",lf="StringNGrams",cf="StringSplit",uf="StringToHashBucketFast",ui="Sub",hi="Tan",di="Tanh",pi="Tile",Ru="TopK",Au="Transform",Mo="Transpose",Du="Unique",il="Unpack",al="UnsortedSegmentSum",ll="ZerosLike",fi="Step",Pw="FromPixels",Fu="RotateWithOffset",cl="_FusedMatMul",ul="FusedConv2D",hf="FusedDepthwiseConv2D";/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -73,7 +73,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function tn(...n){W().getBool("IS_TEST")||W().getBool("PROD")||console.warn(...n)}function Lw(...n){W().getBool("IS_TEST")||W().getBool("PROD")||console.log(...n)}/** + */function tn(...n){W().getBool("IS_TEST")||W().getBool("PROD")||console.warn(...n)}function Bw(...n){W().getBool("IS_TEST")||W().getBool("PROD")||console.log(...n)}/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -88,7 +88,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const hl=Uc("kernelRegistry",()=>new Map),Fu=Uc("gradRegistry",()=>new Map);function df(n,e){const t=gf(n,e);return hl.get(t)}function pf(n){return Fu.get(n)}function ff(n){const e=hl.entries(),t=[];for(;;){const{done:s,value:o}=e.next();if(s)break;const[r,i]=o,[a]=r.split("_");a===n&&t.push(i)}return t}function mf(n){const{kernelName:e,backendName:t}=n,s=gf(e,t);hl.has(s)&&tn(`The kernel '${e}' for backend '${t}' is already registered`),hl.set(s,n)}function Mw(n){const{kernelName:e}=n;Fu.has(e)&&W().getBool("DEBUG")&&tn(`Overriding the gradient for '${e}'`),Fu.set(e,n)}function gf(n,e){return`${e}_${n}`}/** + */const hl=Gc("kernelRegistry",()=>new Map),_u=Gc("gradRegistry",()=>new Map);function df(n,e){const t=gf(n,e);return hl.get(t)}function pf(n){return _u.get(n)}function ff(n){const e=hl.entries(),t=[];for(;;){const{done:s,value:o}=e.next();if(s)break;const[r,i]=o,[a]=r.split("_");a===n&&t.push(i)}return t}function mf(n){const{kernelName:e,backendName:t}=n,s=gf(e,t);hl.has(s)&&tn(`The kernel '${e}' for backend '${t}' is already registered`),hl.set(s,n)}function zw(n){const{kernelName:e}=n;_u.has(e)&&W().getBool("DEBUG")&&tn(`Overriding the gradient for '${e}'`),_u.set(e,n)}function gf(n,e){return`${e}_${n}`}/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -103,7 +103,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xf(n){return n instanceof Float32Array||n instanceof Int32Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray}var Gs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pw(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Bw(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function s(){return this instanceof s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(s){var o=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:function(){return n[s]}})}),t}var bf=Ge,ln=null;try{ln=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{}function Ge(n,e,t){this.low=n|0,this.high=e|0,this.unsigned=!!t}Ge.prototype.__isLong__,Object.defineProperty(Ge.prototype,"__isLong__",{value:!0});function Kt(n){return(n&&n.__isLong__)===!0}Ge.isLong=Kt;var yf={},wf={};function Hs(n,e){var t,s,o;return e?(n>>>=0,(o=0<=n&&n<256)&&(s=wf[n],s)?s:(t=He(n,(n|0)<0?-1:0,!0),o&&(wf[n]=t),t)):(n|=0,(o=-128<=n&&n<128)&&(s=yf[n],s)?s:(t=He(n,n<0?-1:0,!1),o&&(yf[n]=t),t))}Ge.fromInt=Hs;function cn(n,e){if(isNaN(n))return e?js:un;if(e){if(n<0)return js;if(n>=If)return Tf}else{if(n<=-$f)return Xt;if(n+1>=$f)return Sf}return n<0?cn(-n,e).neg():He(n%Mo|0,n/Mo|0,e)}Ge.fromNumber=cn;function He(n,e,t){return new Ge(n,e,t)}Ge.fromBits=He;var dl=Math.pow;function _u(n,e,t){if(n.length===0)throw Error("empty string");if(n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return un;if(typeof e=="number"?(t=e,e=!1):e=!!e,t=t||10,t<2||360)throw Error("interior hyphen");if(s===0)return _u(n.substring(1),e,t).neg();for(var o=cn(dl(t,8)),r=un,i=0;i>>0:this.low},se.toNumber=function(){return this.unsigned?(this.high>>>0)*Mo+(this.low>>>0):this.high*Mo+(this.low>>>0)},se.toString=function(e){if(e=e||10,e<2||36>>0,u=c.toString(e);if(i=l,i.isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}},se.getHighBits=function(){return this.high},se.getHighBitsUnsigned=function(){return this.high>>>0},se.getLowBits=function(){return this.low},se.getLowBitsUnsigned=function(){return this.low>>>0},se.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Xt)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,t=31;t>0&&!(e&1<=0},se.isOdd=function(){return(this.low&1)===1},se.isEven=function(){return(this.low&1)===0},se.equals=function(e){return Kt(e)||(e=vn(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low},se.eq=se.equals,se.notEquals=function(e){return!this.eq(e)},se.neq=se.notEquals,se.ne=se.notEquals,se.lessThan=function(e){return this.comp(e)<0},se.lt=se.lessThan,se.lessThanOrEqual=function(e){return this.comp(e)<=0},se.lte=se.lessThanOrEqual,se.le=se.lessThanOrEqual,se.greaterThan=function(e){return this.comp(e)>0},se.gt=se.greaterThan,se.greaterThanOrEqual=function(e){return this.comp(e)>=0},se.gte=se.greaterThanOrEqual,se.ge=se.greaterThanOrEqual,se.compare=function(e){if(Kt(e)||(e=vn(e)),this.eq(e))return 0;var t=this.isNegative(),s=e.isNegative();return t&&!s?-1:!t&&s?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},se.comp=se.compare,se.negate=function(){return!this.unsigned&&this.eq(Xt)?Xt:this.not().add(Po)},se.neg=se.negate,se.add=function(e){Kt(e)||(e=vn(e));var t=this.high>>>16,s=this.high&65535,o=this.low>>>16,r=this.low&65535,i=e.high>>>16,a=e.high&65535,l=e.low>>>16,c=e.low&65535,u=0,h=0,d=0,p=0;return p+=r+c,d+=p>>>16,p&=65535,d+=o+l,h+=d>>>16,d&=65535,h+=s+a,u+=h>>>16,h&=65535,u+=t+i,u&=65535,He(d<<16|p,u<<16|h,this.unsigned)},se.subtract=function(e){return Kt(e)||(e=vn(e)),this.add(e.neg())},se.sub=se.subtract,se.multiply=function(e){if(this.isZero())return un;if(Kt(e)||(e=vn(e)),ln){var t=ln.mul(this.low,this.high,e.low,e.high);return He(t,ln.get_high(),this.unsigned)}if(e.isZero())return un;if(this.eq(Xt))return e.isOdd()?Xt:un;if(e.eq(Xt))return this.isOdd()?Xt:un;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(vf)&&e.lt(vf))return cn(this.toNumber()*e.toNumber(),this.unsigned);var s=this.high>>>16,o=this.high&65535,r=this.low>>>16,i=this.low&65535,a=e.high>>>16,l=e.high&65535,c=e.low>>>16,u=e.low&65535,h=0,d=0,p=0,f=0;return f+=i*u,p+=f>>>16,f&=65535,p+=r*u,d+=p>>>16,p&=65535,p+=i*c,d+=p>>>16,p&=65535,d+=o*u,h+=d>>>16,d&=65535,d+=r*c,h+=d>>>16,d&=65535,d+=i*l,h+=d>>>16,d&=65535,h+=s*u+o*c+r*l+i*a,h&=65535,He(p<<16|f,h<<16|d,this.unsigned)},se.mul=se.multiply,se.divide=function(e){if(Kt(e)||(e=vn(e)),e.isZero())throw Error("division by zero");if(ln){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var t=(this.unsigned?ln.div_u:ln.div_s)(this.low,this.high,e.low,e.high);return He(t,ln.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?js:un;var s,o,r;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return js;if(e.gt(this.shru(1)))return kf;r=js}else{if(this.eq(Xt)){if(e.eq(Po)||e.eq(Ou))return Xt;if(e.eq(Xt))return Po;var i=this.shr(1);return s=i.div(e).shl(1),s.eq(un)?e.isNegative()?Po:Ou:(o=this.sub(e.mul(s)),r=s.add(o.div(e)),r)}else if(e.eq(Xt))return this.unsigned?js:un;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();r=un}for(o=this;o.gte(e);){s=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(s)/Math.LN2),l=a<=48?1:dl(2,a-48),c=cn(s),u=c.mul(e);u.isNegative()||u.gt(o);)s-=l,c=cn(s,this.unsigned),u=c.mul(e);c.isZero()&&(c=Po),r=r.add(c),o=o.sub(u)}return r},se.div=se.divide,se.modulo=function(e){if(Kt(e)||(e=vn(e)),ln){var t=(this.unsigned?ln.rem_u:ln.rem_s)(this.low,this.high,e.low,e.high);return He(t,ln.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},se.mod=se.modulo,se.rem=se.modulo,se.not=function(){return He(~this.low,~this.high,this.unsigned)},se.and=function(e){return Kt(e)||(e=vn(e)),He(this.low&e.low,this.high&e.high,this.unsigned)},se.or=function(e){return Kt(e)||(e=vn(e)),He(this.low|e.low,this.high|e.high,this.unsigned)},se.xor=function(e){return Kt(e)||(e=vn(e)),He(this.low^e.low,this.high^e.high,this.unsigned)},se.shiftLeft=function(e){return Kt(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?He(this.low<>>32-e,this.unsigned):He(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):He(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},se.shr=se.shiftRight,se.shiftRightUnsigned=function(e){if(Kt(e)&&(e=e.toInt()),e&=63,e===0)return this;var t=this.high;if(e<32){var s=this.low;return He(s>>>e|t<<32-e,t>>>e,this.unsigned)}else return e===32?He(t,0,this.unsigned):He(t>>>e-32,0,this.unsigned)},se.shru=se.shiftRightUnsigned,se.shr_u=se.shiftRightUnsigned,se.toSigned=function(){return this.unsigned?He(this.low,this.high,!1):this},se.toUnsigned=function(){return this.unsigned?this:He(this.low,this.high,!0)},se.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},se.toBytesLE=function(){var e=this.high,t=this.low;return[t&255,t>>>8&255,t>>>16&255,t>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]},se.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,t>>>24,t>>>16&255,t>>>8&255,t&255]},Ge.fromBytes=function(e,t,s){return s?Ge.fromBytesLE(e,t):Ge.fromBytesBE(e,t)},Ge.fromBytesLE=function(e,t){return new Ge(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},Ge.fromBytesBE=function(e,t){return new Ge(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var Nf=Pw(bf),Vw=gw({__proto__:null,default:Nf},[bf]);/** + */function xf(n){return n instanceof Float32Array||n instanceof Int32Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray}var Gs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vw(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Ww(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function s(){return this instanceof s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(s){var o=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:function(){return n[s]}})}),t}var bf=Ge,ln=null;try{ln=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{}function Ge(n,e,t){this.low=n|0,this.high=e|0,this.unsigned=!!t}Ge.prototype.__isLong__,Object.defineProperty(Ge.prototype,"__isLong__",{value:!0});function Kt(n){return(n&&n.__isLong__)===!0}Ge.isLong=Kt;var yf={},wf={};function Hs(n,e){var t,s,o;return e?(n>>>=0,(o=0<=n&&n<256)&&(s=wf[n],s)?s:(t=He(n,(n|0)<0?-1:0,!0),o&&(wf[n]=t),t)):(n|=0,(o=-128<=n&&n<128)&&(s=yf[n],s)?s:(t=He(n,n<0?-1:0,!1),o&&(yf[n]=t),t))}Ge.fromInt=Hs;function cn(n,e){if(isNaN(n))return e?qs:un;if(e){if(n<0)return qs;if(n>=If)return Tf}else{if(n<=-$f)return Xt;if(n+1>=$f)return Sf}return n<0?cn(-n,e).neg():He(n%Po|0,n/Po|0,e)}Ge.fromNumber=cn;function He(n,e,t){return new Ge(n,e,t)}Ge.fromBits=He;var dl=Math.pow;function Ou(n,e,t){if(n.length===0)throw Error("empty string");if(n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return un;if(typeof e=="number"?(t=e,e=!1):e=!!e,t=t||10,t<2||360)throw Error("interior hyphen");if(s===0)return Ou(n.substring(1),e,t).neg();for(var o=cn(dl(t,8)),r=un,i=0;i>>0:this.low},se.toNumber=function(){return this.unsigned?(this.high>>>0)*Po+(this.low>>>0):this.high*Po+(this.low>>>0)},se.toString=function(e){if(e=e||10,e<2||36>>0,u=c.toString(e);if(i=l,i.isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}},se.getHighBits=function(){return this.high},se.getHighBitsUnsigned=function(){return this.high>>>0},se.getLowBits=function(){return this.low},se.getLowBitsUnsigned=function(){return this.low>>>0},se.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Xt)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,t=31;t>0&&!(e&1<=0},se.isOdd=function(){return(this.low&1)===1},se.isEven=function(){return(this.low&1)===0},se.equals=function(e){return Kt(e)||(e=vn(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low},se.eq=se.equals,se.notEquals=function(e){return!this.eq(e)},se.neq=se.notEquals,se.ne=se.notEquals,se.lessThan=function(e){return this.comp(e)<0},se.lt=se.lessThan,se.lessThanOrEqual=function(e){return this.comp(e)<=0},se.lte=se.lessThanOrEqual,se.le=se.lessThanOrEqual,se.greaterThan=function(e){return this.comp(e)>0},se.gt=se.greaterThan,se.greaterThanOrEqual=function(e){return this.comp(e)>=0},se.gte=se.greaterThanOrEqual,se.ge=se.greaterThanOrEqual,se.compare=function(e){if(Kt(e)||(e=vn(e)),this.eq(e))return 0;var t=this.isNegative(),s=e.isNegative();return t&&!s?-1:!t&&s?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},se.comp=se.compare,se.negate=function(){return!this.unsigned&&this.eq(Xt)?Xt:this.not().add(Bo)},se.neg=se.negate,se.add=function(e){Kt(e)||(e=vn(e));var t=this.high>>>16,s=this.high&65535,o=this.low>>>16,r=this.low&65535,i=e.high>>>16,a=e.high&65535,l=e.low>>>16,c=e.low&65535,u=0,h=0,d=0,p=0;return p+=r+c,d+=p>>>16,p&=65535,d+=o+l,h+=d>>>16,d&=65535,h+=s+a,u+=h>>>16,h&=65535,u+=t+i,u&=65535,He(d<<16|p,u<<16|h,this.unsigned)},se.subtract=function(e){return Kt(e)||(e=vn(e)),this.add(e.neg())},se.sub=se.subtract,se.multiply=function(e){if(this.isZero())return un;if(Kt(e)||(e=vn(e)),ln){var t=ln.mul(this.low,this.high,e.low,e.high);return He(t,ln.get_high(),this.unsigned)}if(e.isZero())return un;if(this.eq(Xt))return e.isOdd()?Xt:un;if(e.eq(Xt))return this.isOdd()?Xt:un;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(vf)&&e.lt(vf))return cn(this.toNumber()*e.toNumber(),this.unsigned);var s=this.high>>>16,o=this.high&65535,r=this.low>>>16,i=this.low&65535,a=e.high>>>16,l=e.high&65535,c=e.low>>>16,u=e.low&65535,h=0,d=0,p=0,f=0;return f+=i*u,p+=f>>>16,f&=65535,p+=r*u,d+=p>>>16,p&=65535,p+=i*c,d+=p>>>16,p&=65535,d+=o*u,h+=d>>>16,d&=65535,d+=r*c,h+=d>>>16,d&=65535,d+=i*l,h+=d>>>16,d&=65535,h+=s*u+o*c+r*l+i*a,h&=65535,He(p<<16|f,h<<16|d,this.unsigned)},se.mul=se.multiply,se.divide=function(e){if(Kt(e)||(e=vn(e)),e.isZero())throw Error("division by zero");if(ln){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var t=(this.unsigned?ln.div_u:ln.div_s)(this.low,this.high,e.low,e.high);return He(t,ln.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?qs:un;var s,o,r;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return qs;if(e.gt(this.shru(1)))return kf;r=qs}else{if(this.eq(Xt)){if(e.eq(Bo)||e.eq(Lu))return Xt;if(e.eq(Xt))return Bo;var i=this.shr(1);return s=i.div(e).shl(1),s.eq(un)?e.isNegative()?Bo:Lu:(o=this.sub(e.mul(s)),r=s.add(o.div(e)),r)}else if(e.eq(Xt))return this.unsigned?qs:un;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();r=un}for(o=this;o.gte(e);){s=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(s)/Math.LN2),l=a<=48?1:dl(2,a-48),c=cn(s),u=c.mul(e);u.isNegative()||u.gt(o);)s-=l,c=cn(s,this.unsigned),u=c.mul(e);c.isZero()&&(c=Bo),r=r.add(c),o=o.sub(u)}return r},se.div=se.divide,se.modulo=function(e){if(Kt(e)||(e=vn(e)),ln){var t=(this.unsigned?ln.rem_u:ln.rem_s)(this.low,this.high,e.low,e.high);return He(t,ln.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},se.mod=se.modulo,se.rem=se.modulo,se.not=function(){return He(~this.low,~this.high,this.unsigned)},se.and=function(e){return Kt(e)||(e=vn(e)),He(this.low&e.low,this.high&e.high,this.unsigned)},se.or=function(e){return Kt(e)||(e=vn(e)),He(this.low|e.low,this.high|e.high,this.unsigned)},se.xor=function(e){return Kt(e)||(e=vn(e)),He(this.low^e.low,this.high^e.high,this.unsigned)},se.shiftLeft=function(e){return Kt(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?He(this.low<>>32-e,this.unsigned):He(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):He(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},se.shr=se.shiftRight,se.shiftRightUnsigned=function(e){if(Kt(e)&&(e=e.toInt()),e&=63,e===0)return this;var t=this.high;if(e<32){var s=this.low;return He(s>>>e|t<<32-e,t>>>e,this.unsigned)}else return e===32?He(t,0,this.unsigned):He(t>>>e-32,0,this.unsigned)},se.shru=se.shiftRightUnsigned,se.shr_u=se.shiftRightUnsigned,se.toSigned=function(){return this.unsigned?He(this.low,this.high,!1):this},se.toUnsigned=function(){return this.unsigned?this:He(this.low,this.high,!0)},se.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},se.toBytesLE=function(){var e=this.high,t=this.low;return[t&255,t>>>8&255,t>>>16&255,t>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]},se.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,t>>>24,t>>>16&255,t>>>8&255,t&255]},Ge.fromBytes=function(e,t,s){return s?Ge.fromBytesLE(e,t):Ge.fromBytesBE(e,t)},Ge.fromBytesLE=function(e,t){return new Ge(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},Ge.fromBytesBE=function(e,t){return new Ge(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var Nf=Vw(bf),Gw=yw({__proto__:null,default:Nf},[bf]);/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -118,7 +118,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const qs=Nf||Vw;function pl(n){return qs.fromString(n,!0,16)}const Ef=pl("c3a5c85c97cb3127"),Ks=pl("b492b66fbe98f273"),Dt=pl("9ae16a3b2f90404f");function Lu(n){return n.xor(n.shru(47))}function Rf(n,e,t){const s=n.slice(e,e+t);return qs.fromBytes(Array.from(s),!0,!0)}function Ve(n,e){return Rf(n,e,8)}function Af(n,e){return Rf(n,e,4)}function mt(n,e){return e===0?n:n.shru(e).or(n.shl(64-e))}function gs(n,e,t=pl("9ddfea08eb382d69")){let s=n.xor(e).mul(t);s=s.xor(s.shru(47));let o=e.xor(s).mul(t);return o=o.xor(o.shru(47)),o=o.mul(t),o}function Ww(n,e,t,s,o,r){o=o.add(n),r=mt(r.add(o).add(s),21);const i=o;return o=o.add(e),o=o.add(t),r=r.add(mt(o,44)),[o.add(s),r.add(i)]}function fl(n,e,t,s){return Ww(Ve(n,e),Ve(n,e+8),Ve(n,e+16),Ve(n,e+24),t,s)}function Uw(n,e=n.length){if(e>=8){const t=Dt.add(e*2),s=Ve(n,0).add(Dt),o=Ve(n,e-8),r=mt(o,37).mul(t).add(s),i=mt(s,25).add(o).mul(t);return gs(r,i,t)}if(e>=4){const t=Dt.add(e*2),s=Af(n,0);return gs(s.shl(3).add(e),Af(n,e-4),t)}if(e>0){const t=n[0],s=n[e>>1],o=n[e-1],r=t+(s<<8),i=e+(o<<2);return Lu(Dt.mul(r).xor(Ef.mul(i))).mul(Dt)}return Dt}function Gw(n,e=n.length){const t=Dt.add(e*2),s=Ve(n,0).mul(Ks),o=Ve(n,8),r=Ve(n,e-8).mul(t),i=Ve(n,e-16).mul(Dt);return gs(mt(s.add(o),43).add(mt(r,30)).add(i),s.add(mt(o.add(Dt),18)).add(r),t)}function Hw(n,e=n.length){const t=Dt.add(e*2),s=Ve(n,0).mul(Dt),o=Ve(n,8),r=Ve(n,e-8).mul(t),i=Ve(n,e-16).mul(Dt),a=mt(s.add(o),43).add(mt(r,30)).add(i),l=gs(a,s.add(mt(o.add(Dt),18)).add(r),t),c=Ve(n,16).mul(t),u=Ve(n,24),h=a.add(Ve(n,e-32)).mul(t),d=l.add(Ve(n,e-24)).mul(t);return gs(mt(c.add(u),43).add(mt(h,30)).add(d),c.add(mt(u.add(s),18)).add(h),t)}function jw(n,e=n.length){const t=qs.fromNumber(81,!0);if(e<=32)return e<=16?Uw(n,e):Gw(n,e);if(e<=64)return Hw(n,e);let s=t,o=t.mul(Ks).add(113),r=Lu(o.mul(Dt).add(113)).mul(Dt),i=[qs.UZERO,qs.UZERO],a=[qs.UZERO,qs.UZERO];s=s.mul(Dt).add(Ve(n,0));let l=0;const c=(e-1>>6)*64,u=c+(e-1&63)-63;do s=mt(s.add(o).add(i[0]).add(Ve(n,l+8)),37).mul(Ks),o=mt(o.add(i[1]).add(Ve(n,l+48)),42).mul(Ks),s=s.xor(a[1]),o=o.add(i[0]).add(Ve(n,l+40)),r=mt(r.add(a[0]),33).mul(Ks),i=fl(n,l,i[1].mul(Ks),s.add(a[0])),a=fl(n,l+32,r.add(a[1]),o.add(Ve(n,l+16))),[r,s]=[s,r],l+=64;while(l!==c);const h=Ks.add(r.and(255).shl(1));return l=u,a[0]=a[0].add(e-1&63),i[0]=i[0].add(a[0]),a[0]=a[0].add(i[0]),s=mt(s.add(o).add(i[0]).add(Ve(n,l+8)),37).mul(h),o=mt(o.add(i[1]).add(Ve(n,l+48)),42).mul(h),s=s.xor(a[1].mul(9)),o=o.add(i[0].mul(9).add(Ve(n,l+40))),r=mt(r.add(a[0]),33).mul(h),i=fl(n,l,i[1].mul(h),s.add(a[0])),a=fl(n,l+32,r.add(a[1]),o.add(Ve(n,l+16))),[r,s]=[s,r],gs(gs(i[0],a[0],h).add(Lu(o).mul(Ef)).add(r),gs(i[1],a[1],h).add(s),h)}/** + */const js=Nf||Gw;function pl(n){return js.fromString(n,!0,16)}const Ef=pl("c3a5c85c97cb3127"),Ks=pl("b492b66fbe98f273"),_t=pl("9ae16a3b2f90404f");function Mu(n){return n.xor(n.shru(47))}function Rf(n,e,t){const s=n.slice(e,e+t);return js.fromBytes(Array.from(s),!0,!0)}function Ve(n,e){return Rf(n,e,8)}function Af(n,e){return Rf(n,e,4)}function mt(n,e){return e===0?n:n.shru(e).or(n.shl(64-e))}function gs(n,e,t=pl("9ddfea08eb382d69")){let s=n.xor(e).mul(t);s=s.xor(s.shru(47));let o=e.xor(s).mul(t);return o=o.xor(o.shru(47)),o=o.mul(t),o}function Hw(n,e,t,s,o,r){o=o.add(n),r=mt(r.add(o).add(s),21);const i=o;return o=o.add(e),o=o.add(t),r=r.add(mt(o,44)),[o.add(s),r.add(i)]}function fl(n,e,t,s){return Hw(Ve(n,e),Ve(n,e+8),Ve(n,e+16),Ve(n,e+24),t,s)}function qw(n,e=n.length){if(e>=8){const t=_t.add(e*2),s=Ve(n,0).add(_t),o=Ve(n,e-8),r=mt(o,37).mul(t).add(s),i=mt(s,25).add(o).mul(t);return gs(r,i,t)}if(e>=4){const t=_t.add(e*2),s=Af(n,0);return gs(s.shl(3).add(e),Af(n,e-4),t)}if(e>0){const t=n[0],s=n[e>>1],o=n[e-1],r=t+(s<<8),i=e+(o<<2);return Mu(_t.mul(r).xor(Ef.mul(i))).mul(_t)}return _t}function jw(n,e=n.length){const t=_t.add(e*2),s=Ve(n,0).mul(Ks),o=Ve(n,8),r=Ve(n,e-8).mul(t),i=Ve(n,e-16).mul(_t);return gs(mt(s.add(o),43).add(mt(r,30)).add(i),s.add(mt(o.add(_t),18)).add(r),t)}function Kw(n,e=n.length){const t=_t.add(e*2),s=Ve(n,0).mul(_t),o=Ve(n,8),r=Ve(n,e-8).mul(t),i=Ve(n,e-16).mul(_t),a=mt(s.add(o),43).add(mt(r,30)).add(i),l=gs(a,s.add(mt(o.add(_t),18)).add(r),t),c=Ve(n,16).mul(t),u=Ve(n,24),h=a.add(Ve(n,e-32)).mul(t),d=l.add(Ve(n,e-24)).mul(t);return gs(mt(c.add(u),43).add(mt(h,30)).add(d),c.add(mt(u.add(s),18)).add(h),t)}function Xw(n,e=n.length){const t=js.fromNumber(81,!0);if(e<=32)return e<=16?qw(n,e):jw(n,e);if(e<=64)return Kw(n,e);let s=t,o=t.mul(Ks).add(113),r=Mu(o.mul(_t).add(113)).mul(_t),i=[js.UZERO,js.UZERO],a=[js.UZERO,js.UZERO];s=s.mul(_t).add(Ve(n,0));let l=0;const c=(e-1>>6)*64,u=c+(e-1&63)-63;do s=mt(s.add(o).add(i[0]).add(Ve(n,l+8)),37).mul(Ks),o=mt(o.add(i[1]).add(Ve(n,l+48)),42).mul(Ks),s=s.xor(a[1]),o=o.add(i[0]).add(Ve(n,l+40)),r=mt(r.add(a[0]),33).mul(Ks),i=fl(n,l,i[1].mul(Ks),s.add(a[0])),a=fl(n,l+32,r.add(a[1]),o.add(Ve(n,l+16))),[r,s]=[s,r],l+=64;while(l!==c);const h=Ks.add(r.and(255).shl(1));return l=u,a[0]=a[0].add(e-1&63),i[0]=i[0].add(a[0]),a[0]=a[0].add(i[0]),s=mt(s.add(o).add(i[0]).add(Ve(n,l+8)),37).mul(h),o=mt(o.add(i[1]).add(Ve(n,l+48)),42).mul(h),s=s.xor(a[1].mul(9)),o=o.add(i[0].mul(9).add(Ve(n,l+40))),r=mt(r.add(a[0]),33).mul(h),i=fl(n,l,i[1].mul(h),s.add(a[0])),a=fl(n,l+32,r.add(a[1]),o.add(Ve(n,l+16))),[r,s]=[s,r],gs(gs(i[0],a[0],h).add(Mu(o).mul(Ef)).add(r),gs(i[1],a[1],h).add(s),h)}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -133,7 +133,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xs(n,e){return e==="string"?bs(n):Xs([n],e)}function qw(n,e){return n instanceof Float32Array&&e==="float32"||n instanceof Int32Array&&e==="int32"||n instanceof Uint8Array&&e==="bool"}function Xs(n,e){if(e==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(n)&&(n=Ys(n)),W().getBool("DEBUG")&&Cw(n,e),qw(n,e))return n;if(e==null||e==="float32"||e==="complex64")return new Float32Array(n);if(e==="int32")return new Int32Array(n);if(e==="bool"){const t=new Uint8Array(n.length);for(let s=0;s{o=s()};let i;const a=zt();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(r);else{r();for(const c of o)c.dataSync();i=Promise.resolve({kernelMs:zt()-a})}if(W().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let c=0;c{Xw(h,u.dtype,e)})}return{kernelName:e,outputs:o,inputs:t,timeMs:i.then(c=>c.kernelMs),extraInfo:i.then(c=>c.getExtraProfileInfo!=null?c.getExtraProfileInfo():"")}}logKernelProfile(e){const{kernelName:t,outputs:s,timeMs:o,inputs:r,extraInfo:i}=e;s.forEach(a=>{Promise.all([a.data(),o,i]).then(l=>{this.logger.logKernelProfile(t,a,l[0],l[1],r,l[2])})})}}function Xw(n,e,t){if(e!=="float32")return!1;for(let s=0;s0?g:""} `}}console.log(`%c${l} %c${a} %c${c}D ${h} %c${u} %c${d} %c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}/** + */class Zw{constructor(e,t){this.backendTimer=e,this.logger=t,t==null&&(this.logger=new Jw)}profileKernel(e,t,s){let o;const r=()=>{o=s()};let i;const a=Vt();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(r);else{r();for(const c of o)c.dataSync();i=Promise.resolve({kernelMs:Vt()-a})}if(W().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let c=0;c{Qw(h,u.dtype,e)})}return{kernelName:e,outputs:o,inputs:t,timeMs:i.then(c=>c.kernelMs),extraInfo:i.then(c=>c.getExtraProfileInfo!=null?c.getExtraProfileInfo():"")}}logKernelProfile(e){const{kernelName:t,outputs:s,timeMs:o,inputs:r,extraInfo:i}=e;s.forEach(a=>{Promise.all([a.data(),o,i]).then(l=>{this.logger.logKernelProfile(t,a,l[0],l[1],r,l[2])})})}}function Qw(n,e,t){if(e!=="float32")return!1;for(let s=0;s0?g:""} `}}console.log(`%c${l} %c${a} %c${c}D ${h} %c${u} %c${d} %c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -163,7 +163,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Zw(n,e,t){const s={},o={};for(let l=0;ls[g.id]=!0),p=!0,o[c.id]=!0;break}if(p)break}}const r={};r[t.id]=!0;const i={};for(let l=n.length-1;l>=0;l--){const c=n[l],u=c.inputs;for(let h=0;h=0;o--){const r=e[o],i=[];if(r.outputs.forEach(l=>{const c=n[l.id];c!=null?i.push(c):i.push(null)}),r.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${r.kernelName}.`);const a=r.gradient(i);for(const l in r.inputs){if(!(l in a))throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(a)}.`);const c=t(()=>a[l]());if(c.dtype!=="float32")throw new Error(`Error in gradient for op ${r.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${c.dtype}'`);const u=r.inputs[l];if(!Oe(c.shape,u.shape))throw new Error(`Error in gradient for op ${r.kernelName}. The gradient of input '${l}' has shape '${c.shape}', which does not match the shape of the input '${u.shape}'`);if(n[u.id]==null)n[u.id]=c;else{const h=n[u.id];n[u.id]=s(h,c),h.dispose()}}}}/** + */function eC(n,e,t){const s={},o={};for(let l=0;ls[g.id]=!0),p=!0,o[c.id]=!0;break}if(p)break}}const r={};r[t.id]=!0;const i={};for(let l=n.length-1;l>=0;l--){const c=n[l],u=c.inputs;for(let h=0;h=0;o--){const r=e[o],i=[];if(r.outputs.forEach(l=>{const c=n[l.id];c!=null?i.push(c):i.push(null)}),r.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${r.kernelName}.`);const a=r.gradient(i);for(const l in r.inputs){if(!(l in a))throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(a)}.`);const c=t(()=>a[l]());if(c.dtype!=="float32")throw new Error(`Error in gradient for op ${r.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${c.dtype}'`);const u=r.inputs[l];if(!Oe(c.shape,u.shape))throw new Error(`Error in gradient for op ${r.kernelName}. The gradient of input '${l}' has shape '${c.shape}', which does not match the shape of the input '${u.shape}'`);if(n[u.id]==null)n[u.id]=c;else{const h=n[u.id];n[u.id]=s(h,c),h.dispose()}}}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -178,9 +178,9 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Df=20,mi=3,Mu=7;function Jw(n,e,t,s){const o=de(e),r=eC(n,e,t,o),i=e.length,a=ml(n,e,t,o,r),l=["Tensor"];return s&&(l.push(` dtype: ${t}`),l.push(` rank: ${i}`),l.push(` shape: [${e}]`),l.push(" values:")),l.push(a.map(c=>" "+c).join(` + */const Df=20,mi=3,Pu=7;function nC(n,e,t,s){const o=de(e),r=sC(n,e,t,o),i=e.length,a=ml(n,e,t,o,r),l=["Tensor"];return s&&(l.push(` dtype: ${t}`),l.push(` rank: ${i}`),l.push(` shape: [${e}]`),l.push(" values:")),l.push(a.map(c=>" "+c).join(` `)),l.join(` -`)}function eC(n,e,t,s){const o=H(e),r=s[s.length-1],i=new Array(r).fill(0),a=e.length,l=t==="complex64"?xi(n):n;if(a>1)for(let c=0;cDf){const m=mi*i;let x=Array.from(n.slice(0,m)),b=Array.from(n.slice((a-mi)*i,a*i));return t==="complex64"&&(x=xi(x),b=xi(b)),["["+x.map((w,y)=>gi(w,o[y],t)).join(", ")+", ..., "+b.map((w,y)=>gi(w,o[a-mi+y],t)).join(", ")+"]"]}return["["+(t==="complex64"?xi(n):Array.from(n)).map((m,x)=>gi(m,o[x],t)).join(", ")+"]"]}const c=e.slice(1),u=s.slice(1),h=s[0]*i,d=[];if(a>Df){for(let g=0;g0?d[0]+p:"");for(let g=1;g1)for(let c=0;cDf){const m=mi*i;let x=Array.from(n.slice(0,m)),b=Array.from(n.slice((a-mi)*i,a*i));return t==="complex64"&&(x=xi(x),b=xi(b)),["["+x.map((w,y)=>gi(w,o[y],t)).join(", ")+", ..., "+b.map((w,y)=>gi(w,o[a-mi+y],t)).join(", ")+"]"]}return["["+(t==="complex64"?xi(n):Array.from(n)).map((m,x)=>gi(m,o[x],t)).join(", ")+"]"]}const c=e.slice(1),u=s.slice(1),h=s[0]*i,d=[];if(a>Df){for(let g=0;g0?d[0]+p:"");for(let g=1;g`Length of values '${o}' does not match the size inferred by the shape '${this.size}'.`)}if(t==="complex64")throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=s||Je(t,this.size),this.strides=de(e)}set(e,...t){t.length===0&&(t=[0]),$(t.length===this.rank,()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`);const s=this.locToIndex(t);this.values[s]=e}get(...e){e.length===0&&(e=[0]);let t=0;for(const o of e){if(o<0||o>=this.shape[t]){const r=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(r)}t++}let s=e[e.length-1];for(let o=0;oys(s))}catch{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(),kn().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=kn().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>ys(t))}catch{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();const e=await kn().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(this.kerasMask&&this.kerasMask.dispose(),kn().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Bo.print(this,e)}clone(){return this.throwIfDisposed(),Bo.clone(this)}toString(e=!1){const t=this.dataSync();return Jw(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Bo.cast(this,e)}variable(e=!0,t,s){return this.throwIfDisposed(),kn().makeVariable(this,e,t,s)}}Object.defineProperty(lt,Symbol.hasInstance,{value:n=>!!n&&n.data!=null&&n.dataSync!=null&&n.throwIfDisposed!=null});function U(){return Uc("Tensor",()=>lt)}U();class gl extends lt{constructor(e,t,s,o){super(e.shape,e.dtype,e.dataId,o),this.trainable=t,this.name=s}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(!Oe(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);kn().disposeTensor(this),this.dataId=e.dataId,kn().incRef(this,null)}dispose(){kn().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(gl,Symbol.hasInstance,{value:n=>n instanceof lt&&n.assign!=null&&n.assign instanceof Function});/** + */class yt{constructor(e,t,s){if(this.dtype=t,this.shape=e.slice(),this.size=H(e),s!=null){const o=s.length;$(o===this.size,()=>`Length of values '${o}' does not match the size inferred by the shape '${this.size}'.`)}if(t==="complex64")throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=s||Je(t,this.size),this.strides=de(e)}set(e,...t){t.length===0&&(t=[0]),$(t.length===this.rank,()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`);const s=this.locToIndex(t);this.values[s]=e}get(...e){e.length===0&&(e=[0]);let t=0;for(const o of e){if(o<0||o>=this.shape[t]){const r=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(r)}t++}let s=e[e.length-1];for(let o=0;oys(s))}catch{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(),kn().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=kn().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>ys(t))}catch{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();const e=await kn().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(this.kerasMask&&this.kerasMask.dispose(),kn().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return zo.print(this,e)}clone(){return this.throwIfDisposed(),zo.clone(this)}toString(e=!1){const t=this.dataSync();return nC(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),zo.cast(this,e)}variable(e=!0,t,s){return this.throwIfDisposed(),kn().makeVariable(this,e,t,s)}}Object.defineProperty(lt,Symbol.hasInstance,{value:n=>!!n&&n.data!=null&&n.dataSync!=null&&n.throwIfDisposed!=null});function U(){return Gc("Tensor",()=>lt)}U();class gl extends lt{constructor(e,t,s,o){super(e.shape,e.dtype,e.dataId,o),this.trainable=t,this.name=s}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(!Oe(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);kn().disposeTensor(this),this.dataId=e.dataId,kn().incRef(this,null)}dispose(){kn().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(gl,Symbol.hasInstance,{value:n=>n instanceof lt&&n.assign!=null&&n.assign instanceof Function});/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -212,7 +212,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */var _f;(function(n){n.R0="R0",n.R1="R1",n.R2="R2",n.R3="R3",n.R4="R4",n.R5="R5",n.R6="R6"})(_f||(_f={}));var Pu;(function(n){n.float32="float32",n.int32="int32",n.bool="int32",n.complex64="complex64"})(Pu||(Pu={}));var Bu;(function(n){n.float32="float32",n.int32="int32",n.bool="bool",n.complex64="complex64"})(Bu||(Bu={}));var zu;(function(n){n.float32="float32",n.int32="float32",n.bool="float32",n.complex64="complex64"})(zu||(zu={}));var Vu;(function(n){n.float32="complex64",n.int32="complex64",n.bool="complex64",n.complex64="complex64"})(Vu||(Vu={}));const sC={float32:zu,int32:Pu,bool:Bu,complex64:Vu};function Yt(n,e){if(n==="string"||e==="string"){if(n==="string"&&e==="string")return"string";throw new Error(`Can not upcast ${n} with ${e}`)}return sC[n][e]}function Wu(n){return Yt(n,"int32")}function Of(n){return n!=null&&typeof n=="object"&&"texture"in n&&n.texture instanceof WebGLTexture}function Lf(n){return typeof GPUBuffer<"u"&&n!=null&&typeof n=="object"&&"buffer"in n&&n.buffer instanceof GPUBuffer}/** + */var _f;(function(n){n.R0="R0",n.R1="R1",n.R2="R2",n.R3="R3",n.R4="R4",n.R5="R5",n.R6="R6"})(_f||(_f={}));var Bu;(function(n){n.float32="float32",n.int32="int32",n.bool="int32",n.complex64="complex64"})(Bu||(Bu={}));var zu;(function(n){n.float32="float32",n.int32="int32",n.bool="bool",n.complex64="complex64"})(zu||(zu={}));var Vu;(function(n){n.float32="float32",n.int32="float32",n.bool="float32",n.complex64="complex64"})(Vu||(Vu={}));var Wu;(function(n){n.float32="complex64",n.int32="complex64",n.bool="complex64",n.complex64="complex64"})(Wu||(Wu={}));const iC={float32:Vu,int32:Bu,bool:zu,complex64:Wu};function Yt(n,e){if(n==="string"||e==="string"){if(n==="string"&&e==="string")return"string";throw new Error(`Can not upcast ${n} with ${e}`)}return iC[n][e]}function Uu(n){return Yt(n,"int32")}function Of(n){return n!=null&&typeof n=="object"&&"texture"in n&&n.texture instanceof WebGLTexture}function Lf(n){return typeof GPUBuffer<"u"&&n!=null&&typeof n=="object"&&"buffer"in n&&n.buffer instanceof GPUBuffer}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -227,7 +227,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function et(n,e){if(n.dtype===e.dtype)return[n,e];const t=Yt(n.dtype,e.dtype);return[n.cast(t),e.cast(t)]}function Mf(n){const e=[];return Pf(n,e,new Set),e}function Pf(n,e,t){if(n==null)return;if(n instanceof lt){e.push(n);return}if(!oC(n))return;const s=n;for(const o in s){const r=s[o];t.has(r)||(t.add(r),Pf(r,e,t))}}function oC(n){return Array.isArray(n)||typeof n=="object"}/** + */function et(n,e){if(n.dtype===e.dtype)return[n,e];const t=Yt(n.dtype,e.dtype);return[n.cast(t),e.cast(t)]}function Mf(n){const e=[];return Pf(n,e,new Set),e}function Pf(n,e,t){if(n==null)return;if(n instanceof lt){e.push(n);return}if(!aC(n))return;const s=n;for(const o in s){const r=s[o];t.has(r)||(t.add(r),Pf(r,e,t))}}function aC(n){return Array.isArray(n)||typeof n=="object"}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -242,7 +242,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Uu(n){return n.kernelName!=null}class Bf{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(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class zo{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Bf}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;const e=this.getSortedBackends();for(let t=0;t{t.setupFunc!=null&&t.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){ff(e).forEach(s=>{s.disposeFunc!=null&&s.disposeFunc(this.registry[e])})}initializeBackend(e){const t=this.registryFactory[e];if(t==null)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const s=t.factory();if(s&&!(s instanceof Fc)&&typeof s.then=="function"){const o=++this.pendingBackendInitId,r=s.then(i=>o(othis.registryFactory[t].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;tthis.startScope(s),()=>this.endScope(o),()=>(o=t(),o instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),o))}scopedRun(e,t,s){e();try{const o=s();return t(),o}catch(o){throw t(),o}}nextTensorId(){return zo.nextTensorId++}nextVariableId(){return zo.nextVariableId++}clone(e){const t=D.runKernel(zr,{x:e}),s={x:e},o=i=>({x:()=>{const a="float32",l={x:i},c={dtype:a};return D.runKernel(Tr,l,c)}}),r=[];return this.addTapeNode(this.state.activeScope.name,s,[t],o,r,{}),t}runKernel(e,t,s){if(this.backendName==null&&this.backend,!(df(e,this.backendName)!=null))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:s})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,s){const o=this.backend.numDataIds();let r=0;s.forEach(l=>{r+=l.dtype==="complex64"?3:1});const i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],a=o-t-r-i;if(a>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${a} data ids) after running '${e}'`)}runKernelFunc(e){let t,s=[];const o=this.isTapeOn(),r=this.state.numBytes,i=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let a;this.backendName==null&&this.backend;let l;const c=Uu(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(Uu(e)){const{kernelName:f,inputs:g,attrs:m}=e;this.backendName==null&&this.backend;const x=df(f,this.backendName);$(x!=null,()=>`Cannot find registered kernel '${f}' for backend '${this.backendName}'`),a=()=>{const b=this.backend.numDataIds();l=x.kernelFunc({inputs:g,attrs:m,backend:this.backend});const w=Array.isArray(l)?l:[l];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(f,b,w);const y=w.map(C=>C.rank!=null?C:this.makeTensorFromTensorInfo(C));if(o){const C=this.getTensorsForGradient(f,g,y);s=this.saveTensorsForBackwardMode(C)}return y}}else{const{forwardFunc:f}=e,g=m=>{o&&(s=m.map(x=>this.keep(this.clone(x))))};a=()=>{const m=this.backend.numDataIds();l=this.tidy(()=>f(this.backend,g));const x=Array.isArray(l)?l:[l];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(c,m,x),x}}const{inputs:u,attrs:h}=e,d=Uu(e)?null:e.backwardsFunc;let p;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=a():(p=this.profiler.profileKernel(c,u,()=>a()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(p),t=p.outputs)}),o&&this.addTapeNode(c,u,t,d,s,h),this.state.profiling&&this.state.activeProfile.kernels.push({name:c,bytesAdded:this.state.numBytes-r,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map(f=>u[f]!=null?u[f].shape:null),outputShapes:t.map(f=>f.shape),kernelTimeMs:p.timeMs,extraInfo:p.extraInfo}),Array.isArray(l)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(s=>this.keep(this.clone(s)))}getTensorsForGradient(e,t,s){const o=pf(e);if(o!=null){const r=o.inputsToSave||[],i=o.outputsToSave||[];let a;o.saveAllInputs?($(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),a=Object.keys(t).map(c=>t[c])):a=r.map(c=>t[c]);const l=s.filter((c,u)=>i[u]);return a.concat(l)}return[]}makeTensor(e,t,s,o){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");s=s||"float32",o=o||this.backend;let r=e;s==="string"&&br(e[0])&&(r=e.map(l=>bs(l)));const i=o.write(r,t,s),a=new lt(t,s,i,this.nextTensorId());if(this.trackTensor(a,o),s==="string"){const l=this.state.tensorInfo.get(i),c=$w(r);this.state.numBytes+=c-l.bytes,l.bytes=c}return a}makeTensorFromDataId(e,t,s,o){s=s||"float32";const r={dataId:e,shape:t,dtype:s};return this.makeTensorFromTensorInfo(r,o)}makeTensorFromTensorInfo(e,t){const{dataId:s,shape:o,dtype:r}=e,i=new lt(o,r,s,this.nextTensorId());return this.trackTensor(i,t),i}makeVariable(e,t=!0,s,o){s=s||this.nextVariableId().toString(),o!=null&&o!==e.dtype&&(e=e.cast(o));const r=new gl(e,t,s,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 s=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(s=e.size*la(e.dtype)),this.state.numBytes+=s,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:s})),e instanceof gl||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;const 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"){const s=e.size*la(e.dtype);this.state.numBytes-=s}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const 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(){const 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;const t=this.state.numBytes,s=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(o=>o.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-s;for(const o of this.state.activeProfile.kernels)o.kernelTimeMs=await o.kernelTimeMs,o.extraInfo=await o.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,s,o,r,i){const a={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:s,saved:r},l=pf(e);l!=null&&(o=l.gradFunc),o!=null&&(a.gradient=c=>(c=c.map((u,h)=>{if(u==null){const d=s[h],p=Nt(d.size,d.dtype);return this.makeTensor(p,d.shape,d.dtype)}return u}),o(c.length>1?c:c[0],r,i))),this.state.activeTape.push(a)}keep(e){return e.kept=!0,e}startTape(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=Mf(e),s=new Set(t.map(r=>r.id));for(let r=0;r{!r.kept&&r.scopeId===o.id&&this.track(r)})}gradients(e,t,s,o=!1){if($(t.length>0,()=>"gradients() received an empty list of xs."),s!=null&&s.dtype!=="float32")throw new Error(`dy must have 'float32' dtype, but has '${s.dtype}'`);const r=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));$(r instanceof lt,()=>"The result y returned by f() must be a tensor.");const i=Zw(this.state.activeTape,t,r);if(!o&&i.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",()=>{const a={};a[r.id]=s??rC(r.shape),Qw(a,i,c=>this.tidy(c),iC);const l=t.map(c=>a[c.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(c=>{for(const u of c.saved)u.dispose()}),this.state.activeTape=null),{value:r,grads:l}})}customGrad(e){return $(Pc(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{$(t.every(a=>a instanceof lt),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let s;const o={};t.forEach((a,l)=>{o[l]=a});const r=(a,l)=>(s=e(...t,l),$(s.value instanceof lt,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),$(Pc(s.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),s.value),i=(a,l)=>{const c=s.gradFunc(a,l),u=Array.isArray(c)?c:[c];$(u.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(...)."),$(u.every(d=>d instanceof lt),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");const h={};return u.forEach((d,p)=>{h[p]=()=>d}),h};return this.runKernelFunc({forwardFunc:r,backwardsFunc:i,inputs:o})}}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){const t=zt(),s=await this.backend.time(e);return s.wallMs=zt()-t,s}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 Bf;for(const e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}zo.nextTensorId=0,zo.nextVariableId=0;function rC(n){const e=zc(H(n),"float32");return D.makeTensor(e,n,"float32")}function zf(){const n=Up();if(n._tfengine==null){const e=new Sw(n);n._tfengine=new zo(e)}return Rw(n._tfengine.ENV),tC(()=>n._tfengine),n._tfengine}const D=zf();function iC(n,e){const t={a:n,b:e};return D.runKernel(Oo,t)}/** + */function Gu(n){return n.kernelName!=null}class Bf{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(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class Vo{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Bf}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;const e=this.getSortedBackends();for(let t=0;t{t.setupFunc!=null&&t.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){ff(e).forEach(s=>{s.disposeFunc!=null&&s.disposeFunc(this.registry[e])})}initializeBackend(e){const t=this.registryFactory[e];if(t==null)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const s=t.factory();if(s&&!(s instanceof _c)&&typeof s.then=="function"){const o=++this.pendingBackendInitId,r=s.then(i=>o(othis.registryFactory[t].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;tthis.startScope(s),()=>this.endScope(o),()=>(o=t(),o instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),o))}scopedRun(e,t,s){e();try{const o=s();return t(),o}catch(o){throw t(),o}}nextTensorId(){return Vo.nextTensorId++}nextVariableId(){return Vo.nextVariableId++}clone(e){const t=F.runKernel(zr,{x:e}),s={x:e},o=i=>({x:()=>{const a="float32",l={x:i},c={dtype:a};return F.runKernel(Tr,l,c)}}),r=[];return this.addTapeNode(this.state.activeScope.name,s,[t],o,r,{}),t}runKernel(e,t,s){if(this.backendName==null&&this.backend,!(df(e,this.backendName)!=null))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:s})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,s){const o=this.backend.numDataIds();let r=0;s.forEach(l=>{r+=l.dtype==="complex64"?3:1});const i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],a=o-t-r-i;if(a>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${a} data ids) after running '${e}'`)}runKernelFunc(e){let t,s=[];const o=this.isTapeOn(),r=this.state.numBytes,i=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let a;this.backendName==null&&this.backend;let l;const c=Gu(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(Gu(e)){const{kernelName:f,inputs:g,attrs:m}=e;this.backendName==null&&this.backend;const x=df(f,this.backendName);$(x!=null,()=>`Cannot find registered kernel '${f}' for backend '${this.backendName}'`),a=()=>{const b=this.backend.numDataIds();l=x.kernelFunc({inputs:g,attrs:m,backend:this.backend});const w=Array.isArray(l)?l:[l];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(f,b,w);const y=w.map(C=>C.rank!=null?C:this.makeTensorFromTensorInfo(C));if(o){const C=this.getTensorsForGradient(f,g,y);s=this.saveTensorsForBackwardMode(C)}return y}}else{const{forwardFunc:f}=e,g=m=>{o&&(s=m.map(x=>this.keep(this.clone(x))))};a=()=>{const m=this.backend.numDataIds();l=this.tidy(()=>f(this.backend,g));const x=Array.isArray(l)?l:[l];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(c,m,x),x}}const{inputs:u,attrs:h}=e,d=Gu(e)?null:e.backwardsFunc;let p;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=a():(p=this.profiler.profileKernel(c,u,()=>a()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(p),t=p.outputs)}),o&&this.addTapeNode(c,u,t,d,s,h),this.state.profiling&&this.state.activeProfile.kernels.push({name:c,bytesAdded:this.state.numBytes-r,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map(f=>u[f]!=null?u[f].shape:null),outputShapes:t.map(f=>f.shape),kernelTimeMs:p.timeMs,extraInfo:p.extraInfo}),Array.isArray(l)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(s=>this.keep(this.clone(s)))}getTensorsForGradient(e,t,s){const o=pf(e);if(o!=null){const r=o.inputsToSave||[],i=o.outputsToSave||[];let a;o.saveAllInputs?($(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),a=Object.keys(t).map(c=>t[c])):a=r.map(c=>t[c]);const l=s.filter((c,u)=>i[u]);return a.concat(l)}return[]}makeTensor(e,t,s,o){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");s=s||"float32",o=o||this.backend;let r=e;s==="string"&&br(e[0])&&(r=e.map(l=>bs(l)));const i=o.write(r,t,s),a=new lt(t,s,i,this.nextTensorId());if(this.trackTensor(a,o),s==="string"){const l=this.state.tensorInfo.get(i),c=Sw(r);this.state.numBytes+=c-l.bytes,l.bytes=c}return a}makeTensorFromDataId(e,t,s,o){s=s||"float32";const r={dataId:e,shape:t,dtype:s};return this.makeTensorFromTensorInfo(r,o)}makeTensorFromTensorInfo(e,t){const{dataId:s,shape:o,dtype:r}=e,i=new lt(o,r,s,this.nextTensorId());return this.trackTensor(i,t),i}makeVariable(e,t=!0,s,o){s=s||this.nextVariableId().toString(),o!=null&&o!==e.dtype&&(e=e.cast(o));const r=new gl(e,t,s,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 s=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(s=e.size*la(e.dtype)),this.state.numBytes+=s,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:s})),e instanceof gl||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;const 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"){const s=e.size*la(e.dtype);this.state.numBytes-=s}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const 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(){const 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;const t=this.state.numBytes,s=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(o=>o.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-s;for(const o of this.state.activeProfile.kernels)o.kernelTimeMs=await o.kernelTimeMs,o.extraInfo=await o.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,s,o,r,i){const a={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:s,saved:r},l=pf(e);l!=null&&(o=l.gradFunc),o!=null&&(a.gradient=c=>(c=c.map((u,h)=>{if(u==null){const d=s[h],p=Nt(d.size,d.dtype);return this.makeTensor(p,d.shape,d.dtype)}return u}),o(c.length>1?c:c[0],r,i))),this.state.activeTape.push(a)}keep(e){return e.kept=!0,e}startTape(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=Mf(e),s=new Set(t.map(r=>r.id));for(let r=0;r{!r.kept&&r.scopeId===o.id&&this.track(r)})}gradients(e,t,s,o=!1){if($(t.length>0,()=>"gradients() received an empty list of xs."),s!=null&&s.dtype!=="float32")throw new Error(`dy must have 'float32' dtype, but has '${s.dtype}'`);const r=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));$(r instanceof lt,()=>"The result y returned by f() must be a tensor.");const i=eC(this.state.activeTape,t,r);if(!o&&i.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",()=>{const a={};a[r.id]=s??lC(r.shape),tC(a,i,c=>this.tidy(c),cC);const l=t.map(c=>a[c.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(c=>{for(const u of c.saved)u.dispose()}),this.state.activeTape=null),{value:r,grads:l}})}customGrad(e){return $(Bc(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{$(t.every(a=>a instanceof lt),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let s;const o={};t.forEach((a,l)=>{o[l]=a});const r=(a,l)=>(s=e(...t,l),$(s.value instanceof lt,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),$(Bc(s.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),s.value),i=(a,l)=>{const c=s.gradFunc(a,l),u=Array.isArray(c)?c:[c];$(u.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(...)."),$(u.every(d=>d instanceof lt),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");const h={};return u.forEach((d,p)=>{h[p]=()=>d}),h};return this.runKernelFunc({forwardFunc:r,backwardsFunc:i,inputs:o})}}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){const t=Vt(),s=await this.backend.time(e);return s.wallMs=Vt()-t,s}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 Bf;for(const e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}Vo.nextTensorId=0,Vo.nextVariableId=0;function lC(n){const e=Vc(H(n),"float32");return F.makeTensor(e,n,"float32")}function zf(){const n=Up();if(n._tfengine==null){const e=new Ew(n);n._tfengine=new Vo(e)}return Fw(n._tfengine.ENV),oC(()=>n._tfengine),n._tfengine}const F=zf();function cC(n,e){const t={a:n,b:e};return F.runKernel(Lo,t)}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -257,7 +257,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function aC(){return typeof navigator<"u"&&navigator!=null}function Vf(n){if(n||aC()){if(n||(n=navigator),n.product==="ReactNative")return!0;const e=n.userAgent||n.vendor||(typeof window<"u"?window.opera:"");if(!e){const t=n;return t.userAgentData&&t.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4))}return!1}function Wf(){return typeof window<"u"&&window.document!=null||typeof WorkerGlobalScope<"u"}/** + */function uC(){return typeof navigator<"u"&&navigator!=null}function Vf(n){if(n||uC()){if(n||(n=navigator),n.product==="ReactNative")return!0;const e=n.userAgent||n.vendor||(typeof window<"u"?window.opera:"");if(!e){const t=n;return t.userAgentData&&t.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4))}return!1}function Wf(){return typeof window<"u"&&window.document!=null||typeof WorkerGlobalScope<"u"}/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -272,7 +272,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Vt=W();Vt.registerFlag("DEBUG",()=>!1,n=>{n&&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.")}),Vt.registerFlag("IS_BROWSER",()=>Wf()),Vt.registerFlag("IS_NODE",()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"),Vt.registerFlag("IS_CHROME",()=>typeof navigator<"u"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)),Vt.registerFlag("IS_SAFARI",()=>typeof navigator<"u"&&navigator!=null&&navigator.userAgent!=null&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor)),Vt.registerFlag("PROD",()=>!1),Vt.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>Vt.getBool("DEBUG")),Vt.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0),Vt.registerFlag("IS_TEST",()=>!1),Vt.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>Vt.getBool("DEBUG")),Vt.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1),Vt.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",()=>!1),Vt.registerFlag("USE_SETTIMEOUTCUSTOM",()=>!1);/** + */const Wt=W();Wt.registerFlag("DEBUG",()=>!1,n=>{n&&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.")}),Wt.registerFlag("IS_BROWSER",()=>Wf()),Wt.registerFlag("IS_NODE",()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"),Wt.registerFlag("IS_CHROME",()=>typeof navigator<"u"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)),Wt.registerFlag("IS_SAFARI",()=>typeof navigator<"u"&&navigator!=null&&navigator.userAgent!=null&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor)),Wt.registerFlag("PROD",()=>!1),Wt.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>Wt.getBool("DEBUG")),Wt.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0),Wt.registerFlag("IS_TEST",()=>!1),Wt.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>Wt.getBool("DEBUG")),Wt.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1),Wt.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",()=>!1),Wt.registerFlag("USE_SETTIMEOUTCUSTOM",()=>!1);/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -287,7 +287,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xl(n,e){let t=n;if(hn(n))return e==="string"?[]:[n.length];if(Of(n)){const o=n.channels||"RGBA";return[n.height,n.width*o.length]}else if(Lf(n))return[n.buffer.size/(e==null?4:la(e))];if(!Array.isArray(n))return[];const s=[];for(;Array.isArray(t)||hn(t)&&e!=="string";)s.push(t.length),t=t[0];return Array.isArray(n)&&W().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&Uf(n,s,[]),s}function Uf(n,e,t){if(t=t||[],!Array.isArray(n)&&!hn(n)){$(e.length===0,()=>`Element arr[${t.join("][")}] is a primitive, but should be an array/TypedArray of ${e[0]} elements`);return}$(e.length>0,()=>`Element arr[${t.join("][")}] should be a primitive, but is an array of ${n.length} elements`),$(n.length===e[0],()=>`Element arr[${t.join("][")}] should have ${e[0]} elements, but has ${n.length} elements`);const s=e.slice(1);for(let o=0;o=0&&(o=s),Gf(s,o,e,t),n==null||!hn(n)&&!Array.isArray(n)&&typeof n!="number"&&typeof n!="boolean"&&typeof n!="string"){const l=n==null?"null":n.constructor.name;throw new Error(`Argument '${e}' passed to '${t}' must be a Tensor or TensorLike, but got '${l}'`)}const r=xl(n,o);!hn(n)&&!Array.isArray(n)&&(n=[n]);const a=o!=="string"?Xs(n,o):Ys(n,[],!0);return D.makeTensor(a,r,o)}function Hf(n,e,t,s="numeric"){if(!Array.isArray(n))throw new Error(`Argument ${e} passed to ${t} must be a \`Tensor[]\` or \`TensorLike[]\``);return n.map((r,i)=>N(r,`${e}[${i}]`,t,s))}/** + */function xl(n,e){let t=n;if(hn(n))return e==="string"?[]:[n.length];if(Of(n)){const o=n.channels||"RGBA";return[n.height,n.width*o.length]}else if(Lf(n))return[n.buffer.size/(e==null?4:la(e))];if(!Array.isArray(n))return[];const s=[];for(;Array.isArray(t)||hn(t)&&e!=="string";)s.push(t.length),t=t[0];return Array.isArray(n)&&W().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&Uf(n,s,[]),s}function Uf(n,e,t){if(t=t||[],!Array.isArray(n)&&!hn(n)){$(e.length===0,()=>`Element arr[${t.join("][")}] is a primitive, but should be an array/TypedArray of ${e[0]} elements`);return}$(e.length>0,()=>`Element arr[${t.join("][")}] should be a primitive, but is an array of ${n.length} elements`),$(n.length===e[0],()=>`Element arr[${t.join("][")}] should have ${e[0]} elements, but has ${n.length} elements`);const s=e.slice(1);for(let o=0;o=0&&(o=s),Gf(s,o,e,t),n==null||!hn(n)&&!Array.isArray(n)&&typeof n!="number"&&typeof n!="boolean"&&typeof n!="string"){const l=n==null?"null":n.constructor.name;throw new Error(`Argument '${e}' passed to '${t}' must be a Tensor or TensorLike, but got '${l}'`)}const r=xl(n,o);!hn(n)&&!Array.isArray(n)&&(n=[n]);const a=o!=="string"?Xs(n,o):Ys(n,[],!0);return F.makeTensor(a,r,o)}function Hf(n,e,t,s="numeric"){if(!Array.isArray(n))throw new Error(`Argument ${e} passed to ${t} must be a \`Tensor[]\` or \`TensorLike[]\``);return n.map((r,i)=>N(r,`${e}[${i}]`,t,s))}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -302,7 +302,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const lC="__op";function O(n){const e=Object.keys(n);if(e.length!==1)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${e.length} keys.`);let t=e[0];const s=n[t];t.endsWith("_")&&(t=t.substring(0,t.length-1)),t=t+lC;const o=(...r)=>{D.startScope(t);try{const i=s(...r);return Vc(i)&&console.error("Cannot return a Promise inside of tidy."),D.endScope(i),i}catch(i){throw D.endScope(null),i}};return Object.defineProperty(o,"name",{value:t,configurable:!0}),o}/** + */const hC="__op";function O(n){const e=Object.keys(n);if(e.length!==1)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${e.length} keys.`);let t=e[0];const s=n[t];t.endsWith("_")&&(t=t.substring(0,t.length-1)),t=t+hC;const o=(...r)=>{F.startScope(t);try{const i=s(...r);return Wc(i)&&console.error("Cannot return a Promise inside of tidy."),F.endScope(i),i}catch(i){throw F.endScope(null),i}};return Object.defineProperty(o,"name",{value:t,configurable:!0}),o}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -317,7 +317,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function cC(n,e){const t=N(n,"real","complex"),s=N(e,"imag","complex");Oc(t.shape,s.shape,`real and imag shapes, ${t.shape} and ${s.shape}, must match in call to tf.complex().`);const o={real:t,imag:s};return D.runKernel(Zc,o)}const Zs=O({complex_:cC});/** + */function dC(n,e){const t=N(n,"real","complex"),s=N(e,"imag","complex");Lc(t.shape,s.shape,`real and imag shapes, ${t.shape} and ${s.shape}, must match in call to tf.complex().`);const o={real:t,imag:s};return F.runKernel(Qc,o)}const Zs=O({complex_:dC});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -332,7 +332,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function bl(n,e,t,s){if(s==null)s=Fo(n);else if(s==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(Lf(n)||Of(n)){if(s!=="float32"&&s!=="int32")throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${s}.`);return D.backend.createTensorFromGPUData(n,e||t,s)}if(!hn(n)&&!Array.isArray(n)&&typeof n!="number"&&typeof n!="boolean"&&typeof n!="string")throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(e!=null){ns(e);const o=H(e),r=H(t);$(o===r,()=>`Based on the provided shape, [${e}], the tensor should have ${o} values but has ${r}`);for(let i=0;i`Error creating a new Tensor. Inferred shape (${t}) does not match the provided shape (${e}). `)}}return!hn(n)&&!Array.isArray(n)&&(n=[n]),e=e||t,n=s!=="string"?Xs(n,s):Ys(n,[],!0),D.makeTensor(n,e,s)}/** + */function bl(n,e,t,s){if(s==null)s=_o(n);else if(s==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(Lf(n)||Of(n)){if(s!=="float32"&&s!=="int32")throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${s}.`);return F.backend.createTensorFromGPUData(n,e||t,s)}if(!hn(n)&&!Array.isArray(n)&&typeof n!="number"&&typeof n!="boolean"&&typeof n!="string")throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(e!=null){ns(e);const o=H(e),r=H(t);$(o===r,()=>`Based on the provided shape, [${e}], the tensor should have ${o} values but has ${r}`);for(let i=0;i`Error creating a new Tensor. Inferred shape (${t}) does not match the provided shape (${e}). `)}}return!hn(n)&&!Array.isArray(n)&&(n=[n]),e=e||t,n=s!=="string"?Xs(n,s):Ys(n,[],!0),F.makeTensor(n,e,s)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -362,7 +362,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const yl={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};class ws{static join(e){return new ws(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,e==null||(e instanceof Array||(e=[e]),e=e.map(s=>hn(s)?s.buffer:s),e.length===0))return;this.bufferUniformSize=e[0].byteLength;let t=0;for(let s=0;s=this.byteLength)return-1;if(this.bufferUniformSize!=null)return this.previousShardIndex=Math.floor(e/this.bufferUniformSize),this.previousShardIndex;function t(o){return e=o.end?1:0}if(t(this.shards[this.previousShardIndex])===0)return this.previousShardIndex;const s=uC(this.shards,t);return s===-1?-1:(this.previousShardIndex=s,this.previousShardIndex)}}function uC(n,e){let t=0,s=n.length;for(;t<=s;){const o=Math.floor((s-t)/2)+t,r=e(n[o]);if(r===0)return o;r<0?s=o:t=o+1}return-1}/** + */const yl={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};class ws{static join(e){return new ws(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,e==null||(e instanceof Array||(e=[e]),e=e.map(s=>hn(s)?s.buffer:s),e.length===0))return;this.bufferUniformSize=e[0].byteLength;let t=0;for(let s=0;s=this.byteLength)return-1;if(this.bufferUniformSize!=null)return this.previousShardIndex=Math.floor(e/this.bufferUniformSize),this.previousShardIndex;function t(o){return e=o.end?1:0}if(t(this.shards[this.previousShardIndex])===0)return this.previousShardIndex;const s=pC(this.shards,t);return s===-1?-1:(this.previousShardIndex=s,this.previousShardIndex)}}function pC(n,e){let t=0,s=n.length;for(;t<=s;){const o=Math.floor((s-t)/2)+t,r=e(n[o]);if(r===0)return o;r<0?s=o:t=o+1}return-1}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -377,7 +377,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hC(){W().set("PROD",!0)}function Te(){return D}function Ft(){return D.memory()}function dC(n){return D.profile(n)}function z(n,e){return D.tidy(n,e)}function fe(n){Mf(n).forEach(t=>t.dispose())}function dn(n){return D.keep(n)}function pC(n){return D.setBackend(n)}function fC(){return D.ready()}function jf(){return D.backendName}function qf(n,e,t=1){return D.registerBackend(n,e,t)}function mC(){return D.backend}/** + */function fC(){W().set("PROD",!0)}function Te(){return F}function Ot(){return F.memory()}function mC(n){return F.profile(n)}function P(n,e){return F.tidy(n,e)}function fe(n){Mf(n).forEach(t=>t.dispose())}function dn(n){return F.keep(n)}function gC(n){return F.setBackend(n)}function xC(){return F.ready()}function qf(){return F.backendName}function jf(n,e,t=1){return F.registerBackend(n,e,t)}function bC(){return F.backend}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -392,7 +392,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Vo=4;async function Kf(n,e){const t=[],s=[],o=Array.isArray(n)?n.map(i=>i.name):Object.keys(n);for(let i=0;i{const d=await l.bytes(),p=d.reduce((m,x)=>m+x.length,0)+Vo*d.length,f=new Uint8Array(p);let g=0;for(let m=0;mt.slice(o+a,o+l));s[r.name]=bC(r,t.slice(o,o+i)),o+=i}return s}function xC(n,e){const t=H(n.shape);let s;if("quantization"in n){const o=n.quantization;s=yl[o.dtype]}else if(n.dtype==="string"){let o=0;for(let r=0;r{if(e+=r.byteLength,t.push(r.byteLength===r.buffer.byteLength?r:new r.constructor(r)),!(r instanceof Float32Array||r instanceof Int32Array||r instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${r.constructor.name}`)});const s=new Uint8Array(e);let o=0;return t.forEach(r=>{s.set(new Uint8Array(r.buffer),o),o+=r.byteLength}),s.buffer}const Gu=typeof Buffer<"u"&&(typeof Blob>"u"||typeof atob>"u"||typeof btoa>"u");function Xf(n){return Gu?Buffer.byteLength(n,"utf8"):new Blob([n]).size}function wC(n){if(Gu)return Buffer.from(n).toString("base64");const e=new Uint8Array(n);let t="";for(let s=0,o=e.length;s{let s=t<<13,o=0;for(;!(s&8388608);)o-=8388608,s<<=1;return s&=-8388609,o+=947912704,s|o},e=new Uint32Array(2048);e[0]=0;for(let t=1;t<1024;t++)e[t]=n(t);for(let t=1024;t<2048;t++)e[t]=939524096+(t-1024<<13);return e}function TC(){const n=new Uint32Array(64);n[0]=0,n[31]=1199570944,n[32]=2147483648,n[63]=3347054592;for(let e=1;e<31;e++)n[e]=e<<23;for(let e=33;e<63;e++)n[e]=2147483648+(e-32<<23);return n}function NC(){const n=new Uint32Array(64);for(let e=0;e<64;e++)n[e]=1024;return n[0]=n[32]=0,n}function EC(){const n=SC(),e=TC(),t=NC();return s=>{const o=new ArrayBuffer(4*s.length),r=new Uint32Array(o);for(let i=0;i>10]+(a&1023)]+e[a>>10];r[i]=l}return new Float32Array(o)}}/** + */const Wo=4;async function Kf(n,e){const t=[],s=[],o=Array.isArray(n)?n.map(i=>i.name):Object.keys(n);for(let i=0;i{const d=await l.bytes(),p=d.reduce((m,x)=>m+x.length,0)+Wo*d.length,f=new Uint8Array(p);let g=0;for(let m=0;mt.slice(o+a,o+l));s[r.name]=CC(r,t.slice(o,o+i)),o+=i}return s}function wC(n,e){const t=H(n.shape);let s;if("quantization"in n){const o=n.quantization;s=yl[o.dtype]}else if(n.dtype==="string"){let o=0;for(let r=0;r{if(e+=r.byteLength,t.push(r.byteLength===r.buffer.byteLength?r:new r.constructor(r)),!(r instanceof Float32Array||r instanceof Int32Array||r instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${r.constructor.name}`)});const s=new Uint8Array(e);let o=0;return t.forEach(r=>{s.set(new Uint8Array(r.buffer),o),o+=r.byteLength}),s.buffer}const Hu=typeof Buffer<"u"&&(typeof Blob>"u"||typeof atob>"u"||typeof btoa>"u");function Xf(n){return Hu?Buffer.byteLength(n,"utf8"):new Blob([n]).size}function $C(n){if(Hu)return Buffer.from(n).toString("base64");const e=new Uint8Array(n);let t="";for(let s=0,o=e.length;s{let s=t<<13,o=0;for(;!(s&8388608);)o-=8388608,s<<=1;return s&=-8388609,o+=947912704,s|o},e=new Uint32Array(2048);e[0]=0;for(let t=1;t<1024;t++)e[t]=n(t);for(let t=1024;t<2048;t++)e[t]=939524096+(t-1024<<13);return e}function RC(){const n=new Uint32Array(64);n[0]=0,n[31]=1199570944,n[32]=2147483648,n[63]=3347054592;for(let e=1;e<31;e++)n[e]=e<<23;for(let e=33;e<63;e++)n[e]=2147483648+(e-32<<23);return n}function AC(){const n=new Uint32Array(64);for(let e=0;e<64;e++)n[e]=1024;return n[0]=n[32]=0,n}function DC(){const n=EC(),e=RC(),t=AC();return s=>{const o=new ArrayBuffer(4*s.length),r=new Uint32Array(o);for(let i=0;i>10]+(a&1023)]+e[a>>10];r[i]=l}return new Float32Array(o)}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -407,7 +407,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class gt{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return gt.instance==null&&(gt.instance=new gt),gt.instance}static registerSaveRouter(e){gt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){gt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return gt.getHandlers(e,"save")}static getLoadHandlers(e,t){return gt.getHandlers(e,"load",t)}static getHandlers(e,t,s){const o=[];return(t==="load"?gt.getInstance().loadRouters:gt.getInstance().saveRouters).forEach(i=>{const a=i(e,s);a!==null&&o.push(a)}),o}}const RC=n=>gt.getSaveHandlers(n),AC=(n,e)=>gt.getLoadHandlers(n,e);/** + */class gt{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return gt.instance==null&&(gt.instance=new gt),gt.instance}static registerSaveRouter(e){gt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){gt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return gt.getHandlers(e,"save")}static getLoadHandlers(e,t){return gt.getHandlers(e,"load",t)}static getHandlers(e,t,s){const o=[];return(t==="load"?gt.getInstance().loadRouters:gt.getInstance().saveRouters).forEach(i=>{const a=i(e,s);a!==null&&o.push(a)}),o}}const FC=n=>gt.getSaveHandlers(n),_C=(n,e)=>gt.getLoadHandlers(n,e);/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -422,7 +422,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ju="tensorflowjs",qu=1,Qs="models_store",Cs="model_info_store";function Zf(){if(!W().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const n=typeof window>"u"?self:window,e=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB||n.shimIndexedDB;if(e==null)throw new Error("The current browser does not appear to support IndexedDB.");return e}function Ku(n){const e=n.result;e.createObjectStore(Qs,{keyPath:"modelPath"}),e.createObjectStore(Cs,{keyPath:"modelPath"})}class Js{constructor(e){if(this.indexedDB=Zf(),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((s,o)=>{const r=this.indexedDB.open(ju,qu);r.onupgradeneeded=()=>Ku(r),r.onsuccess=()=>{const i=r.result;if(t==null){const a=i.transaction(Qs,"readonly"),c=a.objectStore(Qs).get(this.modelPath);c.onsuccess=()=>{if(c.result==null)return i.close(),o(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));s(c.result.modelArtifacts)},c.onerror=u=>(i.close(),o(c.error)),a.oncomplete=()=>i.close()}else{t.weightData=ws.join(t.weightData);const a=Hu(t),l=i.transaction(Cs,"readwrite");let c=l.objectStore(Cs),u;try{u=c.put({modelPath:this.modelPath,modelArtifactsInfo:a})}catch(d){return o(d)}let h;u.onsuccess=()=>{h=i.transaction(Qs,"readwrite");const d=h.objectStore(Qs);let p;try{p=d.put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:a})}catch(f){return o(f)}p.onsuccess=()=>s({modelArtifactsInfo:a}),p.onerror=f=>{c=l.objectStore(Cs);const g=c.delete(this.modelPath);g.onsuccess=()=>(i.close(),o(p.error)),g.onerror=m=>(i.close(),o(p.error))}},u.onerror=d=>(i.close(),o(u.error)),l.oncomplete=()=>{h==null?i.close():h.oncomplete=()=>i.close()}}},r.onerror=i=>o(r.error)})}}Js.URL_SCHEME="indexeddb://";const Qf=n=>W().getBool("IS_BROWSER")&&!Array.isArray(n)&&n.startsWith(Js.URL_SCHEME)?DC(n.slice(Js.URL_SCHEME.length)):null;gt.registerSaveRouter(Qf),gt.registerLoadRouter(Qf);function DC(n){return new Js(n)}function FC(n){return n.startsWith(Js.URL_SCHEME)?n.slice(Js.URL_SCHEME.length):n}class _C{constructor(){this.indexedDB=Zf()}async listModels(){return new Promise((e,t)=>{const s=this.indexedDB.open(ju,qu);s.onupgradeneeded=()=>Ku(s),s.onsuccess=()=>{const o=s.result,r=o.transaction(Cs,"readonly"),a=r.objectStore(Cs).getAll();a.onsuccess=()=>{const l={};for(const c of a.result)l[c.modelPath]=c.modelArtifactsInfo;e(l)},a.onerror=l=>(o.close(),t(a.error)),r.oncomplete=()=>o.close()},s.onerror=o=>t(s.error)})}async removeModel(e){return e=FC(e),new Promise((t,s)=>{const o=this.indexedDB.open(ju,qu);o.onupgradeneeded=()=>Ku(o),o.onsuccess=()=>{const r=o.result,i=r.transaction(Cs,"readwrite"),a=i.objectStore(Cs),l=a.get(e);let c;l.onsuccess=()=>{if(l.result==null)return r.close(),s(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const u=a.delete(e),h=()=>{c=r.transaction(Qs,"readwrite");const p=c.objectStore(Qs).delete(e);p.onsuccess=()=>t(l.result.modelArtifactsInfo),p.onerror=f=>s(l.error)};u.onsuccess=h,u.onerror=d=>(h(),r.close(),s(l.error))}},l.onerror=u=>(r.close(),s(l.error)),i.oncomplete=()=>{c==null?r.close():c.oncomplete=()=>r.close()}},o.onerror=r=>s(o.error)})}}/** + */const ju="tensorflowjs",Ku=1,Qs="models_store",Cs="model_info_store";function Zf(){if(!W().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const n=typeof window>"u"?self:window,e=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB||n.shimIndexedDB;if(e==null)throw new Error("The current browser does not appear to support IndexedDB.");return e}function Xu(n){const e=n.result;e.createObjectStore(Qs,{keyPath:"modelPath"}),e.createObjectStore(Cs,{keyPath:"modelPath"})}class Js{constructor(e){if(this.indexedDB=Zf(),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((s,o)=>{const r=this.indexedDB.open(ju,Ku);r.onupgradeneeded=()=>Xu(r),r.onsuccess=()=>{const i=r.result;if(t==null){const a=i.transaction(Qs,"readonly"),c=a.objectStore(Qs).get(this.modelPath);c.onsuccess=()=>{if(c.result==null)return i.close(),o(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));s(c.result.modelArtifacts)},c.onerror=u=>(i.close(),o(c.error)),a.oncomplete=()=>i.close()}else{t.weightData=ws.join(t.weightData);const a=qu(t),l=i.transaction(Cs,"readwrite");let c=l.objectStore(Cs),u;try{u=c.put({modelPath:this.modelPath,modelArtifactsInfo:a})}catch(d){return o(d)}let h;u.onsuccess=()=>{h=i.transaction(Qs,"readwrite");const d=h.objectStore(Qs);let p;try{p=d.put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:a})}catch(f){return o(f)}p.onsuccess=()=>s({modelArtifactsInfo:a}),p.onerror=f=>{c=l.objectStore(Cs);const g=c.delete(this.modelPath);g.onsuccess=()=>(i.close(),o(p.error)),g.onerror=m=>(i.close(),o(p.error))}},u.onerror=d=>(i.close(),o(u.error)),l.oncomplete=()=>{h==null?i.close():h.oncomplete=()=>i.close()}}},r.onerror=i=>o(r.error)})}}Js.URL_SCHEME="indexeddb://";const Qf=n=>W().getBool("IS_BROWSER")&&!Array.isArray(n)&&n.startsWith(Js.URL_SCHEME)?OC(n.slice(Js.URL_SCHEME.length)):null;gt.registerSaveRouter(Qf),gt.registerLoadRouter(Qf);function OC(n){return new Js(n)}function LC(n){return n.startsWith(Js.URL_SCHEME)?n.slice(Js.URL_SCHEME.length):n}class MC{constructor(){this.indexedDB=Zf()}async listModels(){return new Promise((e,t)=>{const s=this.indexedDB.open(ju,Ku);s.onupgradeneeded=()=>Xu(s),s.onsuccess=()=>{const o=s.result,r=o.transaction(Cs,"readonly"),a=r.objectStore(Cs).getAll();a.onsuccess=()=>{const l={};for(const c of a.result)l[c.modelPath]=c.modelArtifactsInfo;e(l)},a.onerror=l=>(o.close(),t(a.error)),r.oncomplete=()=>o.close()},s.onerror=o=>t(s.error)})}async removeModel(e){return e=LC(e),new Promise((t,s)=>{const o=this.indexedDB.open(ju,Ku);o.onupgradeneeded=()=>Xu(o),o.onsuccess=()=>{const r=o.result,i=r.transaction(Cs,"readwrite"),a=i.objectStore(Cs),l=a.get(e);let c;l.onsuccess=()=>{if(l.result==null)return r.close(),s(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const u=a.delete(e),h=()=>{c=r.transaction(Qs,"readwrite");const p=c.objectStore(Qs).delete(e);p.onsuccess=()=>t(l.result.modelArtifactsInfo),p.onerror=f=>s(l.error)};u.onsuccess=h,u.onerror=d=>(h(),r.close(),s(l.error))}},l.onerror=u=>(r.close(),s(l.error)),i.oncomplete=()=>{c==null?r.close():c.oncomplete=()=>r.close()}},o.onerror=r=>s(o.error)})}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -437,7 +437,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const os="/",Wo="tensorflowjs_models",Jf="info",OC="model_topology",LC="weight_specs",MC="weight_data",PC="model_metadata";function em(n){return{info:[Wo,n,Jf].join(os),topology:[Wo,n,OC].join(os),weightSpecs:[Wo,n,LC].join(os),weightData:[Wo,n,MC].join(os),modelMetadata:[Wo,n,PC].join(os)}}function tm(n){for(const e of Object.values(n))window.localStorage.removeItem(e)}function BC(n){const e=n.split(os);if(e.length<3)throw new Error(`Invalid key format: ${n}`);return e.slice(1,e.length-1).join(os)}function zC(n){return n.startsWith(eo.URL_SCHEME)?n.slice(eo.URL_SCHEME.length):n}class eo{constructor(e){if(!W().getBool("IS_BROWSER")||typeof window>"u"||typeof window.localStorage>"u")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=em(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.");{const t=JSON.stringify(e.modelTopology),s=JSON.stringify(e.weightSpecs),o=Hu(e),r=ws.join(e.weightData);try{this.LS.setItem(this.keys.info,JSON.stringify(o)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,s),this.LS.setItem(this.keys.weightData,wC(r));const i={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,initializerSignature:e.initializerSignature!=null?e.initializerSignature:void 0,trainingConfig:e.trainingConfig!=null?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(i)),{modelArtifactsInfo:o}}catch{throw tm(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${o.modelTopologyBytes}, weightSpecsBytes=${o.weightSpecsBytes}, weightDataBytes=${o.weightDataBytes}.`)}}}async load(){const 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.");const t={},s=JSON.parse(this.LS.getItem(this.keys.topology));if(s==null)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=s;const o=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(o==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=o;const r=this.LS.getItem(this.keys.modelMetadata);if(r!=null){const a=JSON.parse(r);t.format=a.format,t.generatedBy=a.generatedBy,t.convertedBy=a.convertedBy,a.signature!=null&&(t.signature=a.signature),a.userDefinedMetadata!=null&&(t.userDefinedMetadata=a.userDefinedMetadata),a.modelInitializer!=null&&(t.modelInitializer=a.modelInitializer),a.initializerSignature!=null&&(t.initializerSignature=a.initializerSignature),a.trainingConfig!=null&&(t.trainingConfig=a.trainingConfig)}const i=this.LS.getItem(this.keys.weightData);if(i==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=CC(i),t}}eo.URL_SCHEME="localstorage://";const nm=n=>W().getBool("IS_BROWSER")&&!Array.isArray(n)&&n.startsWith(eo.URL_SCHEME)?VC(n.slice(eo.URL_SCHEME.length)):null;gt.registerSaveRouter(nm),gt.registerLoadRouter(nm);function VC(n){return new eo(n)}class WC{constructor(){$(W().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),$(typeof window>"u"||typeof window.localStorage<"u",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){const e={},t=Wo+os,s=os+Jf;for(let o=0;o"u"||typeof window.localStorage>"u")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=em(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.");{const t=JSON.stringify(e.modelTopology),s=JSON.stringify(e.weightSpecs),o=qu(e),r=ws.join(e.weightData);try{this.LS.setItem(this.keys.info,JSON.stringify(o)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,s),this.LS.setItem(this.keys.weightData,$C(r));const i={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,initializerSignature:e.initializerSignature!=null?e.initializerSignature:void 0,trainingConfig:e.trainingConfig!=null?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(i)),{modelArtifactsInfo:o}}catch{throw tm(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${o.modelTopologyBytes}, weightSpecsBytes=${o.weightSpecsBytes}, weightDataBytes=${o.weightDataBytes}.`)}}}async load(){const 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.");const t={},s=JSON.parse(this.LS.getItem(this.keys.topology));if(s==null)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=s;const o=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(o==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=o;const r=this.LS.getItem(this.keys.modelMetadata);if(r!=null){const a=JSON.parse(r);t.format=a.format,t.generatedBy=a.generatedBy,t.convertedBy=a.convertedBy,a.signature!=null&&(t.signature=a.signature),a.userDefinedMetadata!=null&&(t.userDefinedMetadata=a.userDefinedMetadata),a.modelInitializer!=null&&(t.modelInitializer=a.modelInitializer),a.initializerSignature!=null&&(t.initializerSignature=a.initializerSignature),a.trainingConfig!=null&&(t.trainingConfig=a.trainingConfig)}const i=this.LS.getItem(this.keys.weightData);if(i==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=vC(i),t}}eo.URL_SCHEME="localstorage://";const nm=n=>W().getBool("IS_BROWSER")&&!Array.isArray(n)&&n.startsWith(eo.URL_SCHEME)?GC(n.slice(eo.URL_SCHEME.length)):null;gt.registerSaveRouter(nm),gt.registerLoadRouter(nm);function GC(n){return new eo(n)}class HC{constructor(){$(W().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),$(typeof window>"u"||typeof window.localStorage<"u",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){const e={},t=Uo+os,s=os+Jf;for(let o=0;o"u"||!W().getBool("USE_SETTIMEOUTCUSTOM")){setTimeout(e,t);return}this.functionRefs.push(e),setTimeout(()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")},t),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",s=>{if(s.source===window&&s.data.name===this.messageName){s.stopPropagation();const o=this.functionRefs[s.data.index];o(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0)}},!0))}isTypedArray(e){return xf(e)}}if(W().get("IS_BROWSER")){W().setPlatform("browser",new UC);try{Bn.registerManager(eo.URL_SCHEME,new WC)}catch{}try{Bn.registerManager(Js.URL_SCHEME,new _C)}catch{}}/** + */class qC{constructor(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}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)}setTimeoutCustom(e,t){if(typeof window>"u"||!W().getBool("USE_SETTIMEOUTCUSTOM")){setTimeout(e,t);return}this.functionRefs.push(e),setTimeout(()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")},t),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",s=>{if(s.source===window&&s.data.name===this.messageName){s.stopPropagation();const o=this.functionRefs[s.data.index];o(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0)}},!0))}isTypedArray(e){return xf(e)}}if(W().get("IS_BROWSER")){W().setPlatform("browser",new qC);try{Bn.registerManager(eo.URL_SCHEME,new HC)}catch{}try{Bn.registerManager(Js.URL_SCHEME,new MC)}catch{}}/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -482,7 +482,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const GC={importFetch:()=>require("node-fetch")};let Xu;class HC{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return W().global.fetch!=null?W().global.fetch(e,t):(Xu==null&&(Xu=GC.importFetch()),Xu(e,t))}now(){const 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)}isTypedArray(e){return this.util.types.isFloat32Array(e)||this.util.types.isInt32Array(e)||this.util.types.isUint8Array(e)||this.util.types.isUint8ClampedArray(e)}}W().get("IS_NODE")&&!W().get("IS_BROWSER")&&W().setPlatform("node",new HC);/** + */const jC={importFetch:()=>require("node-fetch")};let Yu;class KC{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return W().global.fetch!=null?W().global.fetch(e,t):(Yu==null&&(Yu=jC.importFetch()),Yu(e,t))}now(){const 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)}isTypedArray(e){return this.util.types.isFloat32Array(e)||this.util.types.isInt32Array(e)||this.util.types.isUint8Array(e)||this.util.types.isUint8ClampedArray(e)}}W().get("IS_NODE")&&!W().get("IS_BROWSER")&&W().setPlatform("node",new KC);/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -512,7 +512,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function jC(n,e){const t=N(n,"x","cast");if(!Iw(e))throw new Error(`Failed to cast to unknown dtype ${e}`);if(e==="string"&&t.dtype!=="string"||e!=="string"&&t.dtype==="string")throw new Error("Only strings can be casted to strings");const s={x:t},o={dtype:e};return D.runKernel(Tr,s,o)}const oe=O({cast_:jC});/** + */function XC(n,e){const t=N(n,"x","cast");if(!kw(e))throw new Error(`Failed to cast to unknown dtype ${e}`);if(e==="string"&&t.dtype!=="string"||e!=="string"&&t.dtype==="string")throw new Error("Only strings can be casted to strings");const s={x:t},o={dtype:e};return F.runKernel(Tr,s,o)}const oe=O({cast_:XC});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -527,7 +527,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function qC(n){const t={x:N(n,"x","clone","string_or_numeric")};return D.runKernel(zr,t)}const to=O({clone_:qC});/** + */function YC(n){const t={x:N(n,"x","clone","string_or_numeric")};return F.runKernel(zr,t)}const to=O({clone_:YC});/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -542,7 +542,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function KC(n,e=!1){console.log(n.toString(e))}/** + */function ZC(n,e=!1){console.log(n.toString(e))}/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -557,7 +557,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */zf(),nC({buffer:ve,cast:oe,clone:to,print:KC});/** + */zf(),rC({buffer:ve,cast:oe,clone:to,print:ZC});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -572,7 +572,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function XC(n,e){let t=N(n,"a","add"),s=N(e,"b","add");[t,s]=et(t,s);const o={a:t,b:s};return D.runKernel(Oo,o)}const ee=O({add_:XC});/** + */function QC(n,e){let t=N(n,"a","add"),s=N(e,"b","add");[t,s]=et(t,s);const o={a:t,b:s};return F.runKernel(Lo,o)}const ee=O({add_:QC});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -587,7 +587,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function YC(n,e){let t=N(n,"a","floorDiv"),s=N(e,"b","floorDiv");[t,s]=et(t,s);const o={a:t,b:s};return D.runKernel(Pr,o)}const om=O({floorDiv_:YC});/** + */function JC(n,e){let t=N(n,"a","floorDiv"),s=N(e,"b","floorDiv");[t,s]=et(t,s);const o={a:t,b:s};return F.runKernel(Pr,o)}const om=O({floorDiv_:JC});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -602,7 +602,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ZC(n,e){let t=N(n,"a","div"),s=N(e,"b","div");if([t,s]=et(t,s),t.dtype==="int32"&&s.dtype==="int32")return om(t,s);const o={a:t,b:s},r={};return D.runKernel(Dr,o,r)}const me=O({div_:ZC});/** + */function eI(n,e){let t=N(n,"a","div"),s=N(e,"b","div");if([t,s]=et(t,s),t.dtype==="int32"&&s.dtype==="int32")return om(t,s);const o={a:t,b:s},r={};return F.runKernel(Dr,o,r)}const me=O({div_:eI});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -617,7 +617,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function QC(n,e){let t=N(n,"a","mul"),s=N(e,"b","mul");[t,s]=et(t,s);const o={a:t,b:s};return D.runKernel(Xr,o)}const F=O({mul_:QC});/** + */function tI(n,e){let t=N(n,"a","mul"),s=N(e,"b","mul");[t,s]=et(t,s);const o={a:t,b:s};return F.runKernel(Xr,o)}const D=O({mul_:tI});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -632,7 +632,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function JC(n){const e=N(n,"x","abs");if(e.dtype==="complex64"){const t={x:e};return D.runKernel(ga,t)}else{const t={x:e};return D.runKernel(ca,t)}}const _t=O({abs_:JC});/** + */function nI(n){const e=N(n,"x","abs");if(e.dtype==="complex64"){const t={x:e};return F.runKernel(ga,t)}else{const t={x:e};return F.runKernel(ca,t)}}const Lt=O({abs_:nI});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -647,7 +647,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function eI(n){const t={x:N(n,"x","acos")};return D.runKernel(wr,t)}const tI=O({acos_:eI});/** + */function sI(n){const t={x:N(n,"x","acos")};return F.runKernel(wr,t)}const oI=O({acos_:sI});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -662,7 +662,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function nI(n){const t={x:N(n,"x","acosh")};return D.runKernel(Cr,t)}const sI=O({acosh_:nI});/** + */function rI(n){const t={x:N(n,"x","acosh")};return F.runKernel(Cr,t)}const iI=O({acosh_:rI});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -677,7 +677,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function oI(n,e=null,t=!1){const o={x:N(n,"x","all","bool")},r={axis:e,keepDims:t};return D.runKernel(Hc,o,r)}const rm=O({all_:oI});/** + */function aI(n,e=null,t=!1){const o={x:N(n,"x","all","bool")},r={axis:e,keepDims:t};return F.runKernel(qc,o,r)}const rm=O({all_:aI});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -692,7 +692,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function rI(n,e=null,t=!1){const o={x:N(n,"x","any","bool")},r={axis:e,keepDims:t};return D.runKernel(jc,o,r)}const Yu=O({any_:rI});/** + */function lI(n,e=null,t=!1){const o={x:N(n,"x","any","bool")},r={axis:e,keepDims:t};return F.runKernel(jc,o,r)}const Zu=O({any_:lI});/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -707,7 +707,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function iI(n,e=0){const s={x:N(n,"x","argMax")},o={axis:e};return D.runKernel(ua,s,o)}const no=O({argMax_:iI});/** + */function cI(n,e=0){const s={x:N(n,"x","argMax")},o={axis:e};return F.runKernel(ua,s,o)}const no=O({argMax_:cI});/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -722,7 +722,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function aI(n,e=0){const s={x:N(n,"x","argMin")},o={axis:e};return D.runKernel(ha,s,o)}const lI=O({argMin_:aI});/** + */function uI(n,e=0){const s={x:N(n,"x","argMin")},o={axis:e};return F.runKernel(ha,s,o)}const hI=O({argMin_:uI});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -737,7 +737,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function cI(n){const t={x:N(n,"x","asin")};return D.runKernel(Ir,t)}const uI=O({asin_:cI});/** + */function dI(n){const t={x:N(n,"x","asin")};return F.runKernel(Ir,t)}const pI=O({asin_:dI});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -752,7 +752,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hI(n){const t={x:N(n,"x","asinh")};return D.runKernel($r,t)}const dI=O({asinh_:hI});/** + */function fI(n){const t={x:N(n,"x","asinh")};return F.runKernel($r,t)}const mI=O({asinh_:fI});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -767,7 +767,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function pI(n){const t={x:N(n,"x","atan")};return D.runKernel(vr,t)}const fI=O({atan_:pI});/** + */function gI(n){const t={x:N(n,"x","atan")};return F.runKernel(vr,t)}const xI=O({atan_:gI});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -782,7 +782,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function mI(n,e){let t=N(n,"a","atan2"),s=N(e,"b","atan2");[t,s]=et(t,s);const o={a:t,b:s};return D.runKernel(Sr,o)}const gI=O({atan2_:mI});/** + */function bI(n,e){let t=N(n,"a","atan2"),s=N(e,"b","atan2");[t,s]=et(t,s);const o={a:t,b:s};return F.runKernel(Sr,o)}const yI=O({atan2_:bI});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -797,7 +797,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xI(n){const t={x:N(n,"x","atanh")};return D.runKernel(kr,t)}const bI=O({atanh_:xI});/** + */function wI(n){const t={x:N(n,"x","atanh")};return F.runKernel(kr,t)}const CI=O({atanh_:wI});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -812,7 +812,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function bi(n,e,t,s,o="NHWC",r){const i=n[3],a=[...e,i],l=is(o);return wt(n,a,t,r,s,null,null,l)}function pn(n,e,t,s,o,r,i="channelsLast"){const[a,l]=yi(e);let c;if(i==="channelsLast")c=[a,l,n[3],n[3]];else if(i==="channelsFirst")c=[a,l,n[1],n[1]];else throw new Error(`Unknown dataFormat ${i}`);return wt(n,c,t,s,o,r,!1,i)}function rs(n,e,t,s,o,r,i="NDHWC"){const[a,l,c]=Qu(e);let u,h;if(i==="NDHWC")h="channelsLast",u=[a,l,c,n[4],n[4]];else if(i==="NCDHW")h="channelsFirst",u=[a,l,c,n[1],n[1]];else throw new Error(`Unknown dataFormat ${i}`);return Is(n,u,t,s,o,!1,h,r)}function wt(n,e,t,s,o,r,i=!1,a="channelsLast"){let[l,c,u,h]=[-1,-1,-1,-1];if(a==="channelsLast")[l,c,u,h]=n;else if(a==="channelsFirst")[l,h,c,u]=n;else throw new Error(`Unknown dataFormat ${a}`);const[d,p,,f]=e,[g,m]=yi(t),[x,b]=yi(s),w=Uo(d,x),y=Uo(p,b),{padInfo:C,outHeight:I,outWidth:v}=CI(o,c,u,g,m,w,y,r,a),k=i?f*h:f;let S;return a==="channelsFirst"?S=[l,k,I,v]:a==="channelsLast"&&(S=[l,I,v,k]),{batchSize:l,dataFormat:a,inHeight:c,inWidth:u,inChannels:h,outHeight:I,outWidth:v,outChannels:k,padInfo:C,strideHeight:g,strideWidth:m,filterHeight:d,filterWidth:p,effectiveFilterHeight:w,effectiveFilterWidth:y,dilationHeight:x,dilationWidth:b,inShape:n,outShape:S,filterShape:e}}function Is(n,e,t,s,o,r=!1,i="channelsLast",a){let[l,c,u,h,d]=[-1,-1,-1,-1,-1];if(i==="channelsLast")[l,c,u,h,d]=n;else if(i==="channelsFirst")[l,d,c,u,h]=n;else throw new Error(`Unknown dataFormat ${i}`);const[p,f,g,,m]=e,[x,b,w]=Qu(t),[y,C,I]=Qu(s),v=Uo(p,y),k=Uo(f,C),S=Uo(g,I),{padInfo:T,outDepth:E,outHeight:V,outWidth:M}=II(o,c,u,h,x,b,w,v,k,S,a),L=r?m*d:m;let R;return i==="channelsFirst"?R=[l,L,E,V,M]:i==="channelsLast"&&(R=[l,E,V,M,L]),{batchSize:l,dataFormat:i,inDepth:c,inHeight:u,inWidth:h,inChannels:d,outDepth:E,outHeight:V,outWidth:M,outChannels:L,padInfo:T,strideDepth:x,strideHeight:b,strideWidth:w,filterDepth:p,filterHeight:f,filterWidth:g,effectiveFilterDepth:v,effectiveFilterHeight:k,effectiveFilterWidth:S,dilationDepth:y,dilationHeight:C,dilationWidth:I,inShape:n,outShape:R,filterShape:e}}function yI(n,e,t,s,o){s==null&&(s=Zu(n,e,t));const r=n[0],i=n[1],a=wi((r-e+2*s)/t+1,o),l=wi((i-e+2*s)/t+1,o);return[a,l]}function wI(n,e,t,s,o,r){o==null&&(o=Zu(n,e[0],s[0]));const i=[0,0,0,t];for(let a=0;a<3;a++)n[a]+2*o>=e[a]&&(i[a]=wi((n[a]-e[a]+2*o)/s[a]+1,r));return i}function Zu(n,e,t,s=1){const o=Uo(e,s);return Math.floor((n[0]*(t-1)-t+o)/2)}function yi(n){return typeof n=="number"?[n,n,n]:n.length===2?[n[0],n[1],1]:n}function Qu(n){return typeof n=="number"?[n,n,n]:n}function Uo(n,e){return e<=1?n:n+(n-1)*(e-1)}function CI(n,e,t,s,o,r,i,a,l){let c,u,h;if(typeof n=="number"){c={top:n,bottom:n,left:n,right:n,type:n===0?"VALID":"NUMBER"};const p=yI([e,t],r,s,n,a);u=p[0],h=p[1]}else if(n==="same"){u=Math.ceil(e/s),h=Math.ceil(t/o);const d=Math.max(0,(u-1)*s+r-e),p=Math.max(0,(h-1)*o+i-t),f=Math.floor(d/2),g=d-f,m=Math.floor(p/2),x=p-m;c={top:f,bottom:g,left:m,right:x,type:"SAME"}}else if(n==="valid")c={top:0,bottom:0,left:0,right:0,type:"VALID"},u=Math.ceil((e-r+1)/s),h=Math.ceil((t-i+1)/o);else if(typeof n=="object"){const d=l==="channelsLast"?n[1][0]:n[2][0],p=l==="channelsLast"?n[1][1]:n[2][1],f=l==="channelsLast"?n[2][0]:n[3][0],g=l==="channelsLast"?n[2][1]:n[3][1];c={top:d,bottom:p,left:f,right:g,type:d===0&&p===0&&f===0&&g===0?"VALID":"EXPLICIT"},u=wi((e-r+d+p)/s+1,a),h=wi((t-i+f+g)/o+1,a)}else throw Error(`Unknown padding parameter: ${n}`);return{padInfo:c,outHeight:u,outWidth:h}}function II(n,e,t,s,o,r,i,a,l,c,u){let h,d,p,f;if(n==="valid"&&(n=0),typeof n=="number"){h={top:n,bottom:n,left:n,right:n,front:n,back:n,type:n===0?"VALID":"NUMBER"};const m=wI([e,t,s,1],[a,l,c],1,[o,r,i],n,u);d=m[0],p=m[1],f=m[2]}else if(n==="same"){d=Math.ceil(e/o),p=Math.ceil(t/r),f=Math.ceil(s/i);const g=(d-1)*o+a-e,m=(p-1)*r+l-t,x=(f-1)*i+c-s,b=Math.floor(g/2),w=g-b,y=Math.floor(m/2),C=m-y,I=Math.floor(x/2),v=x-I;h={top:y,bottom:C,left:I,right:v,front:b,back:w,type:"SAME"}}else throw Error(`Unknown padding parameter: ${n}`);return{padInfo:h,outDepth:d,outHeight:p,outWidth:f}}function wi(n,e){if(!e)return Math.trunc(n);switch(e){case"round":return Math.round(n);case"ceil":return Math.ceil(n);case"floor":return Math.floor(n);default:throw new Error(`Unknown roundingMode ${e}`)}}function so(n){const[e,t,s]=yi(n);return e===1&&t===1&&s===1}function Et(n,e){return so(n)||so(e)}function oo(n){return yi(n).every(e=>e>0)}function is(n){if(n==="NHWC")return"channelsLast";if(n==="NCHW")return"channelsFirst";throw new Error(`Unknown dataFormat ${n}`)}function Wt(n,e,t){if(t!=null){if(typeof e=="string")throw Error(`Error in ${n}: pad must be an integer when using dimRoundingMode ${t} but got pad ${e}.`);if(typeof e=="number")$(Ao(e),()=>`Error in ${n}: pad must be an integer when using dimRoundingMode ${t} but got pad ${e}.`);else if(typeof e=="object")e.forEach(s=>{s.forEach(o=>{$(Ao(o),()=>`Error in ${n}: pad must be an integer when using dimRoundingMode ${t} but got pad ${o}.`)})});else throw Error(`Error in ${n}: Unknown padding parameter: ${e}`)}}/** + */function bi(n,e,t,s,o="NHWC",r){const i=n[3],a=[...e,i],l=is(o);return wt(n,a,t,r,s,null,null,l)}function pn(n,e,t,s,o,r,i="channelsLast"){const[a,l]=yi(e);let c;if(i==="channelsLast")c=[a,l,n[3],n[3]];else if(i==="channelsFirst")c=[a,l,n[1],n[1]];else throw new Error(`Unknown dataFormat ${i}`);return wt(n,c,t,s,o,r,!1,i)}function rs(n,e,t,s,o,r,i="NDHWC"){const[a,l,c]=Ju(e);let u,h;if(i==="NDHWC")h="channelsLast",u=[a,l,c,n[4],n[4]];else if(i==="NCDHW")h="channelsFirst",u=[a,l,c,n[1],n[1]];else throw new Error(`Unknown dataFormat ${i}`);return Is(n,u,t,s,o,!1,h,r)}function wt(n,e,t,s,o,r,i=!1,a="channelsLast"){let[l,c,u,h]=[-1,-1,-1,-1];if(a==="channelsLast")[l,c,u,h]=n;else if(a==="channelsFirst")[l,h,c,u]=n;else throw new Error(`Unknown dataFormat ${a}`);const[d,p,,f]=e,[g,m]=yi(t),[x,b]=yi(s),w=Go(d,x),y=Go(p,b),{padInfo:C,outHeight:I,outWidth:v}=vI(o,c,u,g,m,w,y,r,a),k=i?f*h:f;let S;return a==="channelsFirst"?S=[l,k,I,v]:a==="channelsLast"&&(S=[l,I,v,k]),{batchSize:l,dataFormat:a,inHeight:c,inWidth:u,inChannels:h,outHeight:I,outWidth:v,outChannels:k,padInfo:C,strideHeight:g,strideWidth:m,filterHeight:d,filterWidth:p,effectiveFilterHeight:w,effectiveFilterWidth:y,dilationHeight:x,dilationWidth:b,inShape:n,outShape:S,filterShape:e}}function Is(n,e,t,s,o,r=!1,i="channelsLast",a){let[l,c,u,h,d]=[-1,-1,-1,-1,-1];if(i==="channelsLast")[l,c,u,h,d]=n;else if(i==="channelsFirst")[l,d,c,u,h]=n;else throw new Error(`Unknown dataFormat ${i}`);const[p,f,g,,m]=e,[x,b,w]=Ju(t),[y,C,I]=Ju(s),v=Go(p,y),k=Go(f,C),S=Go(g,I),{padInfo:T,outDepth:E,outHeight:V,outWidth:M}=kI(o,c,u,h,x,b,w,v,k,S,a),L=r?m*d:m;let R;return i==="channelsFirst"?R=[l,L,E,V,M]:i==="channelsLast"&&(R=[l,E,V,M,L]),{batchSize:l,dataFormat:i,inDepth:c,inHeight:u,inWidth:h,inChannels:d,outDepth:E,outHeight:V,outWidth:M,outChannels:L,padInfo:T,strideDepth:x,strideHeight:b,strideWidth:w,filterDepth:p,filterHeight:f,filterWidth:g,effectiveFilterDepth:v,effectiveFilterHeight:k,effectiveFilterWidth:S,dilationDepth:y,dilationHeight:C,dilationWidth:I,inShape:n,outShape:R,filterShape:e}}function II(n,e,t,s,o){s==null&&(s=Qu(n,e,t));const r=n[0],i=n[1],a=wi((r-e+2*s)/t+1,o),l=wi((i-e+2*s)/t+1,o);return[a,l]}function $I(n,e,t,s,o,r){o==null&&(o=Qu(n,e[0],s[0]));const i=[0,0,0,t];for(let a=0;a<3;a++)n[a]+2*o>=e[a]&&(i[a]=wi((n[a]-e[a]+2*o)/s[a]+1,r));return i}function Qu(n,e,t,s=1){const o=Go(e,s);return Math.floor((n[0]*(t-1)-t+o)/2)}function yi(n){return typeof n=="number"?[n,n,n]:n.length===2?[n[0],n[1],1]:n}function Ju(n){return typeof n=="number"?[n,n,n]:n}function Go(n,e){return e<=1?n:n+(n-1)*(e-1)}function vI(n,e,t,s,o,r,i,a,l){let c,u,h;if(typeof n=="number"){c={top:n,bottom:n,left:n,right:n,type:n===0?"VALID":"NUMBER"};const p=II([e,t],r,s,n,a);u=p[0],h=p[1]}else if(n==="same"){u=Math.ceil(e/s),h=Math.ceil(t/o);const d=Math.max(0,(u-1)*s+r-e),p=Math.max(0,(h-1)*o+i-t),f=Math.floor(d/2),g=d-f,m=Math.floor(p/2),x=p-m;c={top:f,bottom:g,left:m,right:x,type:"SAME"}}else if(n==="valid")c={top:0,bottom:0,left:0,right:0,type:"VALID"},u=Math.ceil((e-r+1)/s),h=Math.ceil((t-i+1)/o);else if(typeof n=="object"){const d=l==="channelsLast"?n[1][0]:n[2][0],p=l==="channelsLast"?n[1][1]:n[2][1],f=l==="channelsLast"?n[2][0]:n[3][0],g=l==="channelsLast"?n[2][1]:n[3][1];c={top:d,bottom:p,left:f,right:g,type:d===0&&p===0&&f===0&&g===0?"VALID":"EXPLICIT"},u=wi((e-r+d+p)/s+1,a),h=wi((t-i+f+g)/o+1,a)}else throw Error(`Unknown padding parameter: ${n}`);return{padInfo:c,outHeight:u,outWidth:h}}function kI(n,e,t,s,o,r,i,a,l,c,u){let h,d,p,f;if(n==="valid"&&(n=0),typeof n=="number"){h={top:n,bottom:n,left:n,right:n,front:n,back:n,type:n===0?"VALID":"NUMBER"};const m=$I([e,t,s,1],[a,l,c],1,[o,r,i],n,u);d=m[0],p=m[1],f=m[2]}else if(n==="same"){d=Math.ceil(e/o),p=Math.ceil(t/r),f=Math.ceil(s/i);const g=(d-1)*o+a-e,m=(p-1)*r+l-t,x=(f-1)*i+c-s,b=Math.floor(g/2),w=g-b,y=Math.floor(m/2),C=m-y,I=Math.floor(x/2),v=x-I;h={top:y,bottom:C,left:I,right:v,front:b,back:w,type:"SAME"}}else throw Error(`Unknown padding parameter: ${n}`);return{padInfo:h,outDepth:d,outHeight:p,outWidth:f}}function wi(n,e){if(!e)return Math.trunc(n);switch(e){case"round":return Math.round(n);case"ceil":return Math.ceil(n);case"floor":return Math.floor(n);default:throw new Error(`Unknown roundingMode ${e}`)}}function so(n){const[e,t,s]=yi(n);return e===1&&t===1&&s===1}function Et(n,e){return so(n)||so(e)}function oo(n){return yi(n).every(e=>e>0)}function is(n){if(n==="NHWC")return"channelsLast";if(n==="NCHW")return"channelsFirst";throw new Error(`Unknown dataFormat ${n}`)}function Ut(n,e,t){if(t!=null){if(typeof e=="string")throw Error(`Error in ${n}: pad must be an integer when using dimRoundingMode ${t} but got pad ${e}.`);if(typeof e=="number")$(Do(e),()=>`Error in ${n}: pad must be an integer when using dimRoundingMode ${t} but got pad ${e}.`);else if(typeof e=="object")e.forEach(s=>{s.forEach(o=>{$(Do(o),()=>`Error in ${n}: pad must be an integer when using dimRoundingMode ${t} but got pad ${o}.`)})});else throw Error(`Error in ${n}: Unknown padding parameter: ${e}`)}}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -827,7 +827,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $I(n,e){const s={x:N(n,"x","reshape","string_or_numeric")},o={shape:e};return D.runKernel(Ya,s,o)}const _=O({reshape_:$I});/** + */function SI(n,e){const s={x:N(n,"x","reshape","string_or_numeric")},o={shape:e};return F.runKernel(Ya,s,o)}const _=O({reshape_:SI});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -842,7 +842,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function vI(n,e,t,s,o){const r=N(n,"x","avgPool","float32"),i=1;$(Et(t,i),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${t} and dilations '${i}'`);let a=r,l=!1;r.rank===3&&(l=!0,a=_(r,[1,r.shape[0],r.shape[1],r.shape[2]])),$(a.rank===4,()=>`Error in avgPool: x must be rank 4 but got rank ${a.rank}.`),Wt("avgPool",s,o);const c={x:a},u={filterSize:e,strides:t,pad:s,dimRoundingMode:o};let h=D.runKernel(da,c,u);return h=oe(h,r.dtype),l?_(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const Ju=O({avgPool_:vI});/** + */function TI(n,e,t,s,o){const r=N(n,"x","avgPool","float32"),i=1;$(Et(t,i),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${t} and dilations '${i}'`);let a=r,l=!1;r.rank===3&&(l=!0,a=_(r,[1,r.shape[0],r.shape[1],r.shape[2]])),$(a.rank===4,()=>`Error in avgPool: x must be rank 4 but got rank ${a.rank}.`),Ut("avgPool",s,o);const c={x:a},u={filterSize:e,strides:t,pad:s,dimRoundingMode:o};let h=F.runKernel(da,c,u);return h=oe(h,r.dtype),l?_(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const eh=O({avgPool_:TI});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -857,7 +857,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function kI(n,e,t,s,o,r="NDHWC"){const i=N(n,"x","avgPool3d","float32");let a=i,l=!1;i.rank===4&&(l=!0,a=_(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),$(a.rank===5,()=>`Error in avgPool3d: x must be rank 5 but got rank ${a.rank}.`),$(r==="NDHWC",()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${r}`),$(typeof t=="number"&&t>0||Array.isArray(t)&&t[0]>0&&t[1]>0&&t[2]>0,()=>`Error in avgPool3d: Stride must be > 0, but got '${t}'`),Wt("avgPool3d",s,o);const c={x:a},u={filterSize:e,strides:t,pad:s,dimRoundingMode:o,dataFormat:r};let h=D.runKernel(pa,c,u);return h=oe(h,a.dtype),l?_(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}const SI=O({avgPool3d_:kI});/** + */function NI(n,e,t,s,o,r="NDHWC"){const i=N(n,"x","avgPool3d","float32");let a=i,l=!1;i.rank===4&&(l=!0,a=_(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),$(a.rank===5,()=>`Error in avgPool3d: x must be rank 5 but got rank ${a.rank}.`),$(r==="NDHWC",()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${r}`),$(typeof t=="number"&&t>0||Array.isArray(t)&&t[0]>0&&t[1]>0&&t[2]>0,()=>`Error in avgPool3d: Stride must be > 0, but got '${t}'`),Ut("avgPool3d",s,o);const c={x:a},u={filterSize:e,strides:t,pad:s,dimRoundingMode:o,dataFormat:r};let h=F.runKernel(pa,c,u);return h=oe(h,a.dtype),l?_(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}const EI=O({avgPool3d_:NI});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -872,8 +872,8 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function TI(n,e=0){$(n.length>=1,()=>"Pass at least one tensor to concat");const t=Hf(n,"tensors","concat","string_or_numeric");if(t[0].dtype==="complex64"&&t.forEach(r=>{if(r.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor - with dtype ${r.dtype}. `)}),t.length===1)return to(t[0]);const s=t,o={axis:e};return D.runKernel(xa,s,o)}const Ot=O({concat_:TI});/** + */function RI(n,e=0){$(n.length>=1,()=>"Pass at least one tensor to concat");const t=Hf(n,"tensors","concat","string_or_numeric");if(t[0].dtype==="complex64"&&t.forEach(r=>{if(r.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor + with dtype ${r.dtype}. `)}),t.length===1)return to(t[0]);const s=t,o={axis:e};return F.runKernel(xa,s,o)}const Mt=O({concat_:RI});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -888,7 +888,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function NI(n,e,t=!1,s=!1){let o=N(n,"a","matMul"),r=N(e,"b","matMul");[o,r]=et(o,r);const i={a:o,b:r},a={transposeA:t,transposeB:s};return D.runKernel(fa,i,a)}const De=O({matMul_:NI});/** + */function AI(n,e,t=!1,s=!1){let o=N(n,"a","matMul"),r=N(e,"b","matMul");[o,r]=et(o,r);const i={a:o,b:r},a={transposeA:t,transposeB:s};return F.runKernel(fa,i,a)}const De=O({matMul_:AI});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -903,7 +903,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function EI(n){const t={x:N(n,"x","sigmoid","float32")};return D.runKernel(ii,t)}const Go=O({sigmoid_:EI});/** + */function DI(n){const t={x:N(n,"x","sigmoid","float32")};return F.runKernel(ii,t)}const Ho=O({sigmoid_:DI});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -918,7 +918,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function RI(n,e,t){const s=N(n,"x","slice","string_or_numeric");if(s.rank===0)throw new Error("Slicing scalar is not possible");const o={x:s},r={begin:e,size:t};return D.runKernel(tl,o,r)}const We=O({slice_:RI});/** + */function FI(n,e,t){const s=N(n,"x","slice","string_or_numeric");if(s.rank===0)throw new Error("Slicing scalar is not possible");const o={x:s},r={begin:e,size:t};return F.runKernel(tl,o,r)}const We=O({slice_:FI});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -933,7 +933,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function AI(n){const t={x:N(n,"x","tanh","float32")};return D.runKernel(di,t)}const eh=O({tanh_:AI});/** + */function _I(n){const t={x:N(n,"x","tanh","float32")};return F.runKernel(di,t)}const wl=O({tanh_:_I});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -948,7 +948,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function DI(n,e,t){const s=N(n,"x","batchToSpaceND"),o=e.reduce((a,l)=>a*l);$(s.rank>=1+e.length,()=>`input rank is ${s.rank} but should be > than blockShape.length ${e.length}`),$(t.length===e.length,()=>`crops.length is ${t.length} but should be equal to blockShape.length ${e.length}`),$(s.shape[0]%o===0,()=>`input tensor batch is ${s.shape[0]} but is not divisible by the product of the elements of blockShape ${e.join(" * ")} === ${o}`);const r={x:s},i={blockShape:e,crops:t};return D.runKernel(ma,r,i)}const th=O({batchToSpaceND_:DI});function FI(n){let e;return n.rank===0||n.rank===1?e=_(n,[1,1,1,n.size]):n.rank===2?e=_(n,[1,1,n.shape[0],n.shape[1]]):n.rank===3?e=_(n,[1,n.shape[0],n.shape[1],n.shape[2]]):e=n,e}/** + */function OI(n,e,t){const s=N(n,"x","batchToSpaceND"),o=e.reduce((a,l)=>a*l);$(s.rank>=1+e.length,()=>`input rank is ${s.rank} but should be > than blockShape.length ${e.length}`),$(t.length===e.length,()=>`crops.length is ${t.length} but should be equal to blockShape.length ${e.length}`),$(s.shape[0]%o===0,()=>`input tensor batch is ${s.shape[0]} but is not divisible by the product of the elements of blockShape ${e.join(" * ")} === ${o}`);const r={x:s},i={blockShape:e,crops:t};return F.runKernel(ma,r,i)}const th=O({batchToSpaceND_:OI});function LI(n){let e;return n.rank===0||n.rank===1?e=_(n,[1,1,1,n.size]):n.rank===2?e=_(n,[1,1,n.shape[0],n.shape[1]]):n.rank===3?e=_(n,[1,n.shape[0],n.shape[1],n.shape[2]]):e=n,e}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -963,7 +963,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _I(n,e,t,s,o,r){r==null&&(r=.001);const i=N(n,"x","batchNorm"),a=N(e,"mean","batchNorm"),l=N(t,"variance","batchNorm");let c;o!=null&&(c=N(o,"scale","batchNorm"));let u;s!=null&&(u=N(s,"offset","batchNorm")),$(a.rank===l.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),$(u==null||a.rank===u.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),$(c==null||a.rank===c.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");const d={x:FI(i),scale:c,offset:u,mean:a,variance:l},p={varianceEpsilon:r},f=D.runKernel(Sa,d,p);return _(f,i.shape)}const wl=O({batchNorm_:_I});function OI(n,e,t,s,o,r){const i=N(n,"x","batchNorm"),a=N(e,"mean","batchNorm"),l=N(t,"variance","batchNorm");let c;o!=null&&(c=N(o,"scale","batchNorm"));let u;return s!=null&&(u=N(s,"offset","batchNorm")),$(i.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${i.rank}.`),$(a.rank===2||a.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${a.rank}.`),$(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`),c!=null&&$(c.rank===2||c.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${c.rank}.`),u!=null&&$(u.rank===2||u.rank===1,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${u.rank}.`),wl(i,a,l,u,c,r)}const LI=O({batchNorm2d_:OI});function MI(n,e,t,s,o,r){const i=N(n,"x","batchNorm"),a=N(e,"mean","batchNorm"),l=N(t,"variance","batchNorm");let c;o!=null&&(c=N(o,"scale","batchNorm"));let u;return s!=null&&(u=N(s,"offset","batchNorm")),$(i.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${i.rank}.`),$(a.rank===3||a.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${a.rank}.`),$(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`),c!=null&&$(c.rank===3||c.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${c.rank}.`),u!=null&&$(u.rank===3||u.rank===1,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${u.rank}.`),wl(i,a,l,u,c,r)}const PI=O({batchNorm3d_:MI});function BI(n,e,t,s,o,r){const i=N(n,"x","batchNorm"),a=N(e,"mean","batchNorm"),l=N(t,"variance","batchNorm");let c;o!=null&&(c=N(o,"scale","batchNorm"));let u;return s!=null&&(u=N(s,"offset","batchNorm")),$(i.rank===4,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${i.rank}.`),$(a.rank===4||a.rank===1,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${a.rank}.`),$(l.rank===4||l.rank===1,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${l.rank}.`),c!=null&&$(c.rank===4||c.rank===1,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${c.rank}.`),u!=null&&$(u.rank===4||u.rank===1,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${u.rank}.`),wl(i,a,l,u,c,r)}const zI=O({batchNorm4d_:BI});/** + */function MI(n,e,t,s,o,r){r==null&&(r=.001);const i=N(n,"x","batchNorm"),a=N(e,"mean","batchNorm"),l=N(t,"variance","batchNorm");let c;o!=null&&(c=N(o,"scale","batchNorm"));let u;s!=null&&(u=N(s,"offset","batchNorm")),$(a.rank===l.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),$(u==null||a.rank===u.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),$(c==null||a.rank===c.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");const d={x:LI(i),scale:c,offset:u,mean:a,variance:l},p={varianceEpsilon:r},f=F.runKernel(Sa,d,p);return _(f,i.shape)}const Cl=O({batchNorm_:MI});function PI(n,e,t,s,o,r){const i=N(n,"x","batchNorm"),a=N(e,"mean","batchNorm"),l=N(t,"variance","batchNorm");let c;o!=null&&(c=N(o,"scale","batchNorm"));let u;return s!=null&&(u=N(s,"offset","batchNorm")),$(i.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${i.rank}.`),$(a.rank===2||a.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${a.rank}.`),$(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`),c!=null&&$(c.rank===2||c.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${c.rank}.`),u!=null&&$(u.rank===2||u.rank===1,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${u.rank}.`),Cl(i,a,l,u,c,r)}const BI=O({batchNorm2d_:PI});function zI(n,e,t,s,o,r){const i=N(n,"x","batchNorm"),a=N(e,"mean","batchNorm"),l=N(t,"variance","batchNorm");let c;o!=null&&(c=N(o,"scale","batchNorm"));let u;return s!=null&&(u=N(s,"offset","batchNorm")),$(i.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${i.rank}.`),$(a.rank===3||a.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${a.rank}.`),$(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`),c!=null&&$(c.rank===3||c.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${c.rank}.`),u!=null&&$(u.rank===3||u.rank===1,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${u.rank}.`),Cl(i,a,l,u,c,r)}const VI=O({batchNorm3d_:zI});function WI(n,e,t,s,o,r){const i=N(n,"x","batchNorm"),a=N(e,"mean","batchNorm"),l=N(t,"variance","batchNorm");let c;o!=null&&(c=N(o,"scale","batchNorm"));let u;return s!=null&&(u=N(s,"offset","batchNorm")),$(i.rank===4,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${i.rank}.`),$(a.rank===4||a.rank===1,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${a.rank}.`),$(l.rank===4||l.rank===1,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${l.rank}.`),c!=null&&$(c.rank===4||c.rank===1,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${c.rank}.`),u!=null&&$(u.rank===4||u.rank===1,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${u.rank}.`),Cl(i,a,l,u,c,r)}const UI=O({batchNorm4d_:WI});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -978,7 +978,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function VI(n,e,t){const s=N(n,"x","bincount"),o=N(e,"weights","bincount");$(s.dtype==="int32",()=>`Error in bincount: input dtype must be int32, but got ${s.dtype}`),$(t>=0,()=>`size must be non-negative, but got ${t}.`),$(o.size===s.size||o.size===0,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${s.shape}, weights shape: ${o.shape}.`);const r={x:s,weights:o},i={size:t};return D.runKernel(Xc,r,i)}const WI=O({bincount_:VI});/** + */function GI(n,e,t){const s=N(n,"x","bincount"),o=N(e,"weights","bincount");$(s.dtype==="int32",()=>`Error in bincount: input dtype must be int32, but got ${s.dtype}`),$(t>=0,()=>`size must be non-negative, but got ${t}.`),$(o.size===s.size||o.size===0,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${s.shape}, weights shape: ${o.shape}.`);const r={x:s,weights:o},i={size:t};return F.runKernel(Yc,r,i)}const HI=O({bincount_:GI});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -993,7 +993,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function UI(n,e){let t=N(n,"broadcastTo","x");const s=t.shape;if(ns(e),e.lengtht.rank){const c=t.shape.slice();for(;c.length=0;c--)if(o[c]===e[c])r[c]=1;else if(t.shape[c]!==1)throw new Error(`broadcastTo(): [${s}] cannot be broadcast to [${e}].`);if(r.map((c,u)=>c>1?u:-1).filter(c=>c>=0).length===0)return to(t);const a={x:t},l={reps:r};return D.runKernel(pi,a,l)}const Ci=O({broadcastTo_:UI});/** + */function qI(n,e){let t=N(n,"broadcastTo","x");const s=t.shape;if(ns(e),e.lengtht.rank){const c=t.shape.slice();for(;c.length=0;c--)if(o[c]===e[c])r[c]=1;else if(t.shape[c]!==1)throw new Error(`broadcastTo(): [${s}] cannot be broadcast to [${e}].`);if(r.map((c,u)=>c>1?u:-1).filter(c=>c>=0).length===0)return to(t);const a={x:t},l={reps:r};return F.runKernel(pi,a,l)}const Ci=O({broadcastTo_:qI});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1008,7 +1008,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function GI(n){const t={x:N(n,"x","ceil","float32")};return D.runKernel(Nr,t)}const HI=O({ceil_:GI});/** + */function jI(n){const t={x:N(n,"x","ceil","float32")};return F.runKernel(Nr,t)}const KI=O({ceil_:jI});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1023,7 +1023,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ii(n,e,t){ns(n),t=t||Fo(e);const s={shape:n,value:e,dtype:t};return D.runKernel(du,{},s)}/** + */function Ii(n,e,t){ns(n),t=t||_o(e);const s={shape:n,value:e,dtype:t};return F.runKernel(pu,{},s)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1038,7 +1038,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function jI(n,e,t){const s=N(n,"x","clipByValue");if($(e<=t,()=>`Error in clip: min (${e}) must be less than or equal to max (${t}).`),e===t)return Ii(s.shape,e,s.dtype);const o={x:s},r={clipValueMin:e,clipValueMax:t};return D.runKernel(Er,o,r)}const nn=O({clipByValue_:jI});function qI(n){return Ot(n,0)}const KI=O({concat1d_:qI});function XI(n,e){return Ot(n,e)}const YI=O({concat2d_:XI});function ZI(n,e){return Ot(n,e)}const QI=O({concat3d_:ZI});function JI(n,e){return Ot(n,e)}const e$=O({concat4d_:JI});/** + */function XI(n,e,t){const s=N(n,"x","clipByValue");if($(e<=t,()=>`Error in clip: min (${e}) must be less than or equal to max (${t}).`),e===t)return Ii(s.shape,e,s.dtype);const o={x:s},r={clipValueMin:e,clipValueMax:t};return F.runKernel(Er,o,r)}const nn=O({clipByValue_:XI});function YI(n){return Mt(n,0)}const ZI=O({concat1d_:YI});function QI(n,e){return Mt(n,e)}const JI=O({concat2d_:QI});function e$(n,e){return Mt(n,e)}const t$=O({concat3d_:e$});function n$(n,e){return Mt(n,e)}const s$=O({concat4d_:n$});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1053,7 +1053,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function t$(n,e,t,s,o="NHWC",r=[1,1],i){const a=N(n,"x","conv2d","float32"),l=N(e,"filter","conv2d","float32");let c=a,u=!1;a.rank===3&&(u=!0,c=_(a,[1,a.shape[0],a.shape[1],a.shape[2]])),$(c.rank===4,()=>`Error in conv2d: input must be rank 4, but got rank ${c.rank}.`),$(l.rank===4,()=>`Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`),Wt("conv2d",s,i);const h=o==="NHWC"?c.shape[3]:c.shape[1];$(h===l.shape[2],()=>`Error in conv2d: depth of input (${h}) must match input depth for filter ${l.shape[2]}.`),$(Et(t,r),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${t} and dilations '${r}'`),$(oo(r),()=>"Error in conv2D: Dilated rates should be larger than 0."),$(oo(t),()=>"Error in conv2D: Strides should be larger than 0.");const d={x:c,filter:l},p={strides:t,pad:s,dataFormat:o,dilations:r,dimRoundingMode:i},f=D.runKernel(ba,d,p);return u?_(f,[f.shape[1],f.shape[2],f.shape[3]]):f}const ro=O({conv2d_:t$});function n$(n,e,t,s,o="NWC",r=1,i){const a=N(n,"x","conv1d"),l=N(e,"filter","conv1d");let c=a,u=!1;a.rank===2&&(u=!0,c=_(a,[1,a.shape[0],a.shape[1]])),$(c.rank===3,()=>`Error in conv1d: input must be rank 3, but got rank ${c.rank}.`),$(l.rank===3,()=>`Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`),Wt("conv1d",s,i),$(c.shape[2]===l.shape[1],()=>`Error in conv1d: depth of input (${c.shape[2]}) must match input depth for filter ${l.shape[1]}.`),$(Et(t,r),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${t} and dilation '${r}'`),$(oo(r),()=>"Error in conv1D: Dilated rates should be larger than 0."),$(oo(t),()=>"Error in conv1D: Stride should be larger than 0."),$(o==="NWC",()=>`Error in conv1d: got dataFormat of ${o} but only NWC is currently supported.`);const h=_(l,[1,l.shape[0],l.shape[1],l.shape[2]]),d=_(c,[c.shape[0],1,c.shape[1],c.shape[2]]),m=ro(d,h,[1,t],s,"NHWC",[1,r],i);return u?_(m,[m.shape[2],m.shape[3]]):_(m,[m.shape[0],m.shape[2],m.shape[3]])}const im=O({conv1d_:n$});/** + */function o$(n,e,t,s,o="NHWC",r=[1,1],i){const a=N(n,"x","conv2d","float32"),l=N(e,"filter","conv2d","float32");let c=a,u=!1;a.rank===3&&(u=!0,c=_(a,[1,a.shape[0],a.shape[1],a.shape[2]])),$(c.rank===4,()=>`Error in conv2d: input must be rank 4, but got rank ${c.rank}.`),$(l.rank===4,()=>`Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`),Ut("conv2d",s,i);const h=o==="NHWC"?c.shape[3]:c.shape[1];$(h===l.shape[2],()=>`Error in conv2d: depth of input (${h}) must match input depth for filter ${l.shape[2]}.`),$(Et(t,r),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${t} and dilations '${r}'`),$(oo(r),()=>"Error in conv2D: Dilated rates should be larger than 0."),$(oo(t),()=>"Error in conv2D: Strides should be larger than 0.");const d={x:c,filter:l},p={strides:t,pad:s,dataFormat:o,dilations:r,dimRoundingMode:i},f=F.runKernel(ba,d,p);return u?_(f,[f.shape[1],f.shape[2],f.shape[3]]):f}const ro=O({conv2d_:o$});function r$(n,e,t,s,o="NWC",r=1,i){const a=N(n,"x","conv1d"),l=N(e,"filter","conv1d");let c=a,u=!1;a.rank===2&&(u=!0,c=_(a,[1,a.shape[0],a.shape[1]])),$(c.rank===3,()=>`Error in conv1d: input must be rank 3, but got rank ${c.rank}.`),$(l.rank===3,()=>`Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`),Ut("conv1d",s,i),$(c.shape[2]===l.shape[1],()=>`Error in conv1d: depth of input (${c.shape[2]}) must match input depth for filter ${l.shape[1]}.`),$(Et(t,r),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${t} and dilation '${r}'`),$(oo(r),()=>"Error in conv1D: Dilated rates should be larger than 0."),$(oo(t),()=>"Error in conv1D: Stride should be larger than 0."),$(o==="NWC",()=>`Error in conv1d: got dataFormat of ${o} but only NWC is currently supported.`);const h=_(l,[1,l.shape[0],l.shape[1],l.shape[2]]),d=_(c,[c.shape[0],1,c.shape[1],c.shape[2]]),m=ro(d,h,[1,t],s,"NHWC",[1,r],i);return u?_(m,[m.shape[2],m.shape[3]]):_(m,[m.shape[0],m.shape[2],m.shape[3]])}const im=O({conv1d_:r$});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1068,7 +1068,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function s$(n,e,t,s,o,r="NHWC",i){$(n.length===e.rank,()=>`Length of inShape (${n.length}) and rank of dy (${e.rank}) must match`);let a=n,l=e,c=!1;e.rank===3&&(c=!0,l=_(e,[1,e.shape[0],e.shape[1],e.shape[2]]),a=[1,n[0],n[1],n[2]]),$(a.length===4,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${a.length}.`),$(l.rank===4,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`),$(t.rank===4,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${t.rank}`);const u=r==="NHWC"?a[3]:a[1],h=r==="NHWC"?l.shape[3]:l.shape[1];$(u===t.shape[2],()=>`Error in conv2dDerInput: depth of input (${u}) must match input depth for filter ${t.shape[2]}.`),$(h===t.shape[3],()=>`Error in conv2dDerInput: depth of output (${h}) must match output depth for filter ${t.shape[3]}.`),Wt("conv2dDerInput",o,i);const d={dy:l,filter:t},p={strides:s,pad:o,dataFormat:r,dimRoundingMode:i,inputShape:a},f=D.runKernel(ya,d,p);return c?_(f,[f.shape[1],f.shape[2],f.shape[3]]):f}const nh=O({conv2DBackpropInput_:s$});function o$(n,e,t,s,o,r){const i=N(n,"x","conv2dTranspose"),a=N(e,"filter","conv2dTranspose");return nh(t,i,a,s,o,"NHWC",r)}const am=O({conv2dTranspose_:o$});/** + */function i$(n,e,t,s,o,r="NHWC",i){$(n.length===e.rank,()=>`Length of inShape (${n.length}) and rank of dy (${e.rank}) must match`);let a=n,l=e,c=!1;e.rank===3&&(c=!0,l=_(e,[1,e.shape[0],e.shape[1],e.shape[2]]),a=[1,n[0],n[1],n[2]]),$(a.length===4,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${a.length}.`),$(l.rank===4,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`),$(t.rank===4,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${t.rank}`);const u=r==="NHWC"?a[3]:a[1],h=r==="NHWC"?l.shape[3]:l.shape[1];$(u===t.shape[2],()=>`Error in conv2dDerInput: depth of input (${u}) must match input depth for filter ${t.shape[2]}.`),$(h===t.shape[3],()=>`Error in conv2dDerInput: depth of output (${h}) must match output depth for filter ${t.shape[3]}.`),Ut("conv2dDerInput",o,i);const d={dy:l,filter:t},p={strides:s,pad:o,dataFormat:r,dimRoundingMode:i,inputShape:a},f=F.runKernel(ya,d,p);return c?_(f,[f.shape[1],f.shape[2],f.shape[3]]):f}const nh=O({conv2DBackpropInput_:i$});function a$(n,e,t,s,o,r){const i=N(n,"x","conv2dTranspose"),a=N(e,"filter","conv2dTranspose");return nh(t,i,a,s,o,"NHWC",r)}const am=O({conv2dTranspose_:a$});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1083,7 +1083,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function r$(n,e,t,s,o="NDHWC",r=[1,1,1]){const i=N(n,"x","conv3d"),a=N(e,"filter","conv3d");let l=i,c=!1;i.rank===4&&(c=!0,l=_(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),$(l.rank===5,()=>`Error in conv3d: input must be rank 5, but got rank ${l.rank}.`),$(a.rank===5,()=>`Error in conv3d: filter must be rank 5, but got rank ${a.rank}.`),$(l.shape[4]===a.shape[3],()=>`Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${a.shape[3]}.`),$(Et(t,r),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${t} and dilations '${r}'`),$(o==="NDHWC",()=>`Error in conv3d: got dataFormat of ${o} but only NDHWC is currently supported.`),$(oo(r),()=>"Error in conv3D: Dilated rates should be larger than 0."),$(oo(t),()=>"Error in conv3D: Strides should be larger than 0.");const u={x:l,filter:a},h={strides:t,pad:s,dataFormat:o,dilations:r},d=D.runKernel(wa,u,h);return c?_(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}const sh=O({conv3d_:r$});/** + */function l$(n,e,t,s,o="NDHWC",r=[1,1,1]){const i=N(n,"x","conv3d"),a=N(e,"filter","conv3d");let l=i,c=!1;i.rank===4&&(c=!0,l=_(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),$(l.rank===5,()=>`Error in conv3d: input must be rank 5, but got rank ${l.rank}.`),$(a.rank===5,()=>`Error in conv3d: filter must be rank 5, but got rank ${a.rank}.`),$(l.shape[4]===a.shape[3],()=>`Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${a.shape[3]}.`),$(Et(t,r),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${t} and dilations '${r}'`),$(o==="NDHWC",()=>`Error in conv3d: got dataFormat of ${o} but only NDHWC is currently supported.`),$(oo(r),()=>"Error in conv3D: Dilated rates should be larger than 0."),$(oo(t),()=>"Error in conv3D: Strides should be larger than 0.");const u={x:l,filter:a},h={strides:t,pad:s,dataFormat:o,dilations:r},d=F.runKernel(wa,u,h);return c?_(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}const sh=O({conv3d_:l$});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1098,7 +1098,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function i$(n,e,t,s,o){$(n.length===e.rank,()=>`Length of inShape (${n.length}) and rank of dy (${e.rank}) must match`);let r=n,i=e,a=!1;e.rank===4&&(a=!0,i=_(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]),r=[1,n[0],n[1],n[2],n[3]]);const l=r[4],c=i.shape[4];$(r.length===5,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${r.length}.`),$(i.rank===5,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${i.rank}`),$(t.rank===5,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${t.rank}`),$(l===t.shape[3],()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${t.shape[3]}.`),$(c===t.shape[4],()=>`Error in conv3dDerInput: depth of output (${c}) must match output depth for filter ${t.shape[4]}.`);const u={dy:i,filter:t},h={pad:o,strides:s,inputShape:r},d=D.runKernel(eu,u,h);return a?_(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}const lm=O({conv3DBackpropInput_:i$});function a$(n,e,t,s,o){const r=N(n,"x","conv3dTranspose"),i=N(e,"filter","conv3dTranspose");return lm(t,r,i,s,o)}const l$=O({conv3dTranspose_:a$});/** + */function c$(n,e,t,s,o){$(n.length===e.rank,()=>`Length of inShape (${n.length}) and rank of dy (${e.rank}) must match`);let r=n,i=e,a=!1;e.rank===4&&(a=!0,i=_(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]),r=[1,n[0],n[1],n[2],n[3]]);const l=r[4],c=i.shape[4];$(r.length===5,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${r.length}.`),$(i.rank===5,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${i.rank}`),$(t.rank===5,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${t.rank}`),$(l===t.shape[3],()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${t.shape[3]}.`),$(c===t.shape[4],()=>`Error in conv3dDerInput: depth of output (${c}) must match output depth for filter ${t.shape[4]}.`);const u={dy:i,filter:t},h={pad:o,strides:s,inputShape:r},d=F.runKernel(tu,u,h);return a?_(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}const lm=O({conv3DBackpropInput_:c$});function u$(n,e,t,s,o){const r=N(n,"x","conv3dTranspose"),i=N(e,"filter","conv3dTranspose");return lm(t,r,i,s,o)}const h$=O({conv3dTranspose_:u$});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1113,7 +1113,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function c$(n){const t={x:N(n,"x","cos","float32")};return D.runKernel(Rr,t)}const oh=O({cos_:c$});/** + */function d$(n){const t={x:N(n,"x","cos","float32")};return F.runKernel(Rr,t)}const oh=O({cos_:d$});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1128,7 +1128,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function u$(n){const t={x:N(n,"x","cosh","float32")};return D.runKernel(Ar,t)}const cm=O({cosh_:u$});/** + */function p$(n){const t={x:N(n,"x","cosh","float32")};return F.runKernel(Ar,t)}const cm=O({cosh_:p$});/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the 'License'); @@ -1143,7 +1143,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function h$(n,e=0,t=!1,s=!1){const r={x:N(n,"x","cumprod")},i={axis:e,exclusive:t,reverse:s};return D.runKernel(tu,r,i)}const rh=O({cumprod_:h$});/** + */function f$(n,e=0,t=!1,s=!1){const r={x:N(n,"x","cumprod")},i={axis:e,exclusive:t,reverse:s};return F.runKernel(nu,r,i)}const rh=O({cumprod_:f$});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1158,7 +1158,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function d$(n,e=0,t=!1,s=!1){const r={x:N(n,"x","cumsum")},i={axis:e,exclusive:t,reverse:s};return D.runKernel(Ca,r,i)}const um=O({cumsum_:d$});/** + */function m$(n,e=0,t=!1,s=!1){const r={x:N(n,"x","cumsum")},i={axis:e,exclusive:t,reverse:s};return F.runKernel(Ca,r,i)}const um=O({cumsum_:m$});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1173,7 +1173,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function p$(n,e,t,s=!1){const o=N(n,"x","denseBincount"),r=N(e,"weights","denseBincount");$(o.dtype==="int32",()=>`Error in denseBincount: input dtype must be int32, but got ${o.dtype}`),$(o.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${o.rank}.`),$(t>=0,()=>`size must be non-negative, but got ${t}.`),$(r.size===o.size||r.size===0,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${o.shape}, weights shape: ${r.shape}.`);const i={x:o,weights:r},a={size:t,binaryOutput:s};return D.runKernel(su,i,a)}const hm=O({denseBincount_:p$});/** + */function g$(n,e,t,s=!1){const o=N(n,"x","denseBincount"),r=N(e,"weights","denseBincount");$(o.dtype==="int32",()=>`Error in denseBincount: input dtype must be int32, but got ${o.dtype}`),$(o.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${o.rank}.`),$(t>=0,()=>`size must be non-negative, but got ${t}.`),$(r.size===o.size||r.size===0,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${o.shape}, weights shape: ${r.shape}.`);const i={x:o,weights:r},a={size:t,binaryOutput:s};return F.runKernel(ou,i,a)}const hm=O({denseBincount_:g$});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1188,11 +1188,11 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function f$(n,e,t="NHWC"){const s=N(n,"x","depthToSpace","float32"),o=t==="NHWC"?s.shape[1]:s.shape[2],r=t==="NHWC"?s.shape[2]:s.shape[3],i=t==="NHWC"?s.shape[3]:s.shape[1];$(e>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${e}`),$(o*e>=0,()=>`Negative dimension size caused by overflow when multiplying + */function x$(n,e,t="NHWC"){const s=N(n,"x","depthToSpace","float32"),o=t==="NHWC"?s.shape[1]:s.shape[2],r=t==="NHWC"?s.shape[2]:s.shape[3],i=t==="NHWC"?s.shape[3]:s.shape[1];$(e>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${e}`),$(o*e>=0,()=>`Negative dimension size caused by overflow when multiplying ${o} and ${e} for depthToSpace with input shape ${s.shape}`),$(r*e>=0,()=>`Negative dimension size caused by overflow when multiplying ${r} and ${e} for depthToSpace with input shape - ${s.shape}`),$(i%(e*e)===0,()=>`Dimension size must be evenly divisible by ${e*e} but is ${i} for depthToSpace with input shape ${s.shape}`);const a={x:s},l={blockSize:e,dataFormat:t};return D.runKernel(ou,a,l)}const m$=O({depthToSpace_:f$});/** + ${s.shape}`),$(i%(e*e)===0,()=>`Dimension size must be evenly divisible by ${e*e} but is ${i} for depthToSpace with input shape ${s.shape}`);const a={x:s},l={blockSize:e,dataFormat:t};return F.runKernel(ru,a,l)}const b$=O({depthToSpace_:x$});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1207,7 +1207,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function g$(n,e,t,s,o="NHWC",r=[1,1],i){const a=N(n,"x","depthwiseConv2d","float32"),l=N(e,"filter","depthwiseConv2d","float32");let c=a,u=!1;a.rank===3&&(u=!0,c=_(a,[1,a.shape[0],a.shape[1],a.shape[2]])),$(c.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${c.rank}.`),$(l.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`);const h=o==="NHWC"?c.shape[3]:c.shape[1];$(h===l.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${h}) must match the inChannels dimension in filter ${l.shape[2]}.`),Wt("depthwiseConv2d",s,i);const d={x:c,filter:l},p={strides:t,pad:s,dataFormat:o,dilations:r,dimRoundingMode:i},f=D.runKernel(Ia,d,p);return u?_(f,[f.shape[1],f.shape[2],f.shape[3]]):f}const ih=O({depthwiseConv2d_:g$});/** + */function y$(n,e,t,s,o="NHWC",r=[1,1],i){const a=N(n,"x","depthwiseConv2d","float32"),l=N(e,"filter","depthwiseConv2d","float32");let c=a,u=!1;a.rank===3&&(u=!0,c=_(a,[1,a.shape[0],a.shape[1],a.shape[2]])),$(c.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${c.rank}.`),$(l.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`);const h=o==="NHWC"?c.shape[3]:c.shape[1];$(h===l.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${h}) must match the inChannels dimension in filter ${l.shape[2]}.`),Ut("depthwiseConv2d",s,i);const d={x:c,filter:l},p={strides:t,pad:s,dataFormat:o,dilations:r,dimRoundingMode:i},f=F.runKernel(Ia,d,p);return u?_(f,[f.shape[1],f.shape[2],f.shape[3]]):f}const ih=O({depthwiseConv2d_:y$});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1222,7 +1222,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function x$(n,e,t,s,o=[1,1],r="NHWC"){const i=N(n,"x","dilation2d"),a=N(e,"filter","dilation2d");$(i.rank===3||i.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${i.rank}.`),$(a.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${a.rank}.`),$(r==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${r}`);let l=i,c=!1;i.rank===3&&(l=_(i,[1,i.shape[0],i.shape[1],i.shape[2]]),c=!0),$(l.shape[3]===a.shape[2],()=>`Error in dilation2d: input and filter must have the same depth: ${l.shape[3]} vs ${a.shape[2]}`);const u={x:l,filter:a},h={strides:t,pad:s,dilations:o},d=D.runKernel($a,u,h);return c?_(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const b$=O({dilation2d_:x$});/** + */function w$(n,e,t,s,o=[1,1],r="NHWC"){const i=N(n,"x","dilation2d"),a=N(e,"filter","dilation2d");$(i.rank===3||i.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${i.rank}.`),$(a.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${a.rank}.`),$(r==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${r}`);let l=i,c=!1;i.rank===3&&(l=_(i,[1,i.shape[0],i.shape[1],i.shape[2]]),c=!0),$(l.shape[3]===a.shape[2],()=>`Error in dilation2d: input and filter must have the same depth: ${l.shape[3]} vs ${a.shape[2]}`);const u={x:l,filter:a},h={strides:t,pad:s,dilations:o},d=F.runKernel($a,u,h);return c?_(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const C$=O({dilation2d_:w$});/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1237,7 +1237,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ho(n,e){const t=n.length,s=[];for(let o=0;o1&&i===1&&s.unshift(r)}return s}function ct(n,e){const t=[];for(let s=0;s1)&&t.unshift(r)}return t}function we(n,e){const t=Math.max(n.length,e.length),s=new Array(t);for(let o=0;o1&&i===1&&s.unshift(r)}return s}function ct(n,e){const t=[];for(let s=0;s1)&&t.unshift(r)}return t}function we(n,e){const t=Math.max(n.length,e.length),s=new Array(t);for(let o=0;o`Error in dot: inputs must all be rank 1 or 2, but got ranks ${t.rank} and ${s.rank}.`);const o=t.rank===1?t.size:t.shape[1],r=s.rank===1?s.size:s.shape[0];if($(o===r,()=>`Error in dot: inner dimensions of inputs must match, but got ${o} and ${r}.`),t.rank===1&&s.rank===1){const i=_(t,[1,-1]),a=_(s,[-1,1]),l=De(i,a);return _(l,[])}else if(t.rank===1&&s.rank===2){const i=_(t,[1,-1]),a=_(s,[s.shape[0],s.shape[1]]),l=De(i,a);return _(l,[l.size])}else if(t.rank===2&&s.rank===1){const i=_(s,[-1,1]),a=De(t,i);return _(a,[a.size])}else{const i=_(s,[s.shape[0],s.shape[1]]);return De(t,i)}}const k$=O({dot_:v$});/** + */function T$(n,e){const t=N(n,"t1","dot"),s=N(e,"t2","dot");$((t.rank===1||t.rank===2)&&(s.rank===1||s.rank===2),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${t.rank} and ${s.rank}.`);const o=t.rank===1?t.size:t.shape[1],r=s.rank===1?s.size:s.shape[0];if($(o===r,()=>`Error in dot: inner dimensions of inputs must match, but got ${o} and ${r}.`),t.rank===1&&s.rank===1){const i=_(t,[1,-1]),a=_(s,[-1,1]),l=De(i,a);return _(l,[])}else if(t.rank===1&&s.rank===2){const i=_(t,[1,-1]),a=_(s,[s.shape[0],s.shape[1]]),l=De(i,a);return _(l,[l.size])}else if(t.rank===2&&s.rank===1){const i=_(s,[-1,1]),a=De(t,i);return _(a,[a.size])}else{const i=_(s,[s.shape[0],s.shape[1]]);return De(t,i)}}const N$=O({dot_:T$});/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1327,7 +1327,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function S$(n,...e){const t=e.map((o,r)=>N(o,`tensors${r}`,"einsum")),s={equation:n};return D.runKernel(cu,t,s)}const $i=O({einsum_:S$});/** + */function E$(n,...e){const t=e.map((o,r)=>N(o,`tensors${r}`,"einsum")),s={equation:n};return F.runKernel(uu,t,s)}const $i=O({einsum_:E$});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1342,7 +1342,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function T$(n){const t={x:N(n,"x","elu","float32")};return D.runKernel(Fr,t)}const Cl=O({elu_:T$});/** + */function R$(n){const t={x:N(n,"x","elu","float32")};return F.runKernel(Fr,t)}const Il=O({elu_:R$});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1357,7 +1357,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function N$(n){let e=N(n,"x","erf");$(e.dtype==="int32"||e.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),e.dtype==="int32"&&(e=oe(e,"float32"));const t={x:e};return D.runKernel(_r,t)}const E$=O({erf_:N$});/** + */function A$(n){let e=N(n,"x","erf");$(e.dtype==="int32"||e.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),e.dtype==="int32"&&(e=oe(e,"float32"));const t={x:e};return F.runKernel(_r,t)}const dm=O({erf_:A$});/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1372,7 +1372,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ah(n,e){for(let t=0;tn[r]);return[t,o]}function it(n,e){const t=e.map(s=>1);return dm(n,t,e)}function It(n,e,t){$(ah(e,t),()=>`${n} supports only inner-most axes for now. Got axes ${e} and rank-${t} input.`)}function Ye(n,e){if(ah(n,e))return null;const t=[];for(let s=0;st.push(s)),t}function $s(n){return n.map((e,t)=>[t,e]).sort((e,t)=>e[1]-t[1]).map(e=>e[0])}function tt(n,e){const t=[];for(let s=e-n;sn[r]);return[t,o]}function it(n,e){const t=e.map(s=>1);return pm(n,t,e)}function It(n,e,t){$(ah(e,t),()=>`${n} supports only inner-most axes for now. Got axes ${e} and rank-${t} input.`)}function Ye(n,e){if(ah(n,e))return null;const t=[];for(let s=0;st.push(s)),t}function $s(n){return n.map((e,t)=>[t,e]).sort((e,t)=>e[1]-t[1]).map(e=>e[0])}function tt(n,e){const t=[];for(let s=e-n;s"Axis must be <= rank of the tensor");const s={input:t},o={dim:e};return D.runKernel(ka,s,o)}const Ut=O({expandDims_:z$});/** + */function W$(n,e=0){const t=N(n,"x","expandDims","string_or_numeric");$(e<=t.rank,()=>"Axis must be <= rank of the tensor");const s={input:t},o={dim:e};return F.runKernel(ka,s,o)}const Gt=O({expandDims_:W$});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1552,7 +1552,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function V$(n){const t={x:N(n,"x","expm1")};return D.runKernel(Lr,t)}const W$=O({expm1_:V$});/** + */function U$(n){const t={x:N(n,"x","expm1")};return F.runKernel(Lr,t)}const G$=O({expm1_:U$});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1567,7 +1567,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function U$(n,e){const t=N(n,"x","tile","string_or_numeric");$(t.rank===e.length,()=>`Error in transpose: rank of input ${t.rank} must match length of reps ${e}.`);const s={x:t},o={reps:e};return D.runKernel(pi,s,o)}const Tn=O({tile_:U$});/** + */function H$(n,e){const t=N(n,"x","tile","string_or_numeric");$(t.rank===e.length,()=>`Error in transpose: rank of input ${t.rank} must match length of reps ${e}.`);const s={x:t},o={reps:e};return F.runKernel(pi,s,o)}const Tn=O({tile_:H$});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1582,7 +1582,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function G$(n,e,t,s="float32"){e==null&&(e=n);const o=ve([n,e],s),r=n<=e?n:e;for(let a=0;a`Error in localResponseNormalization: x must be rank 3 or 4 but got - rank ${r.rank}.`),$(Ao(e),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`);let i=r,a=!1;r.rank===3&&(a=!0,i=_(r,[1,r.shape[0],r.shape[1],r.shape[2]]));const l={x:i},c={depthRadius:e,bias:t,alpha:s,beta:o},u=D.runKernel(Oa,l,c);return a?_(u,[u.shape[1],u.shape[2],u.shape[3]]):u}const iv=O({localResponseNormalization_:rv});/** + */function av(n,e=5,t=1,s=1,o=.5){const r=N(n,"x","localResponseNormalization");$(r.rank===4||r.rank===3,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got + rank ${r.rank}.`),$(Do(e),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`);let i=r,a=!1;r.rank===3&&(a=!0,i=_(r,[1,r.shape[0],r.shape[1],r.shape[2]]));const l={x:i},c={depthRadius:e,bias:t,alpha:s,beta:o},u=F.runKernel(Oa,l,c);return a?_(u,[u.shape[1],u.shape[2],u.shape[3]]):u}const lv=O({localResponseNormalization_:av});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1778,7 +1778,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function av(n){const t={x:N(n,"x","log","float32")};return D.runKernel(Gr,t)}const Wn=O({log_:av});/** + */function cv(n){const t={x:N(n,"x","log","float32")};return F.runKernel(Gr,t)}const Wn=O({log_:cv});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1793,7 +1793,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function lv(n){const t={x:N(n,"x","log1p")};return D.runKernel(Hr,t)}const mm=O({log1p_:lv});/** + */function uv(n){const t={x:N(n,"x","log1p")};return F.runKernel(Hr,t)}const gm=O({log1p_:uv});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1808,7 +1808,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function cv(n,e){$(Pc(n),()=>"The f passed in variableGrads(f) must be a function"),$(e==null||Array.isArray(e)&&e.every(c=>c instanceof gl),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");const t=e!=null;if(!t){e=[];for(const c in D.registeredVariables)e.push(D.registeredVariables[c])}const s=t?e.filter(c=>!c.trainable):null,o=e.length;e=e.filter(c=>c.trainable),$(e.length>0,()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${o} variables is trainable.`);const r=!0,{value:i,grads:a}=D.gradients(n,e,null,r);$(a.some(c=>c!=null),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),$(i.rank===0,()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${i.rank} tensor`);const l={};return e.forEach((c,u)=>{a[u]!=null&&(l[c.name]=a[u])}),s!=null&&s.forEach(c=>l[c.name]=null),{value:i,grads:l}}function Ko(n){return D.customGrad(n)}/** + */function hv(n,e){$(Bc(n),()=>"The f passed in variableGrads(f) must be a function"),$(e==null||Array.isArray(e)&&e.every(c=>c instanceof gl),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");const t=e!=null;if(!t){e=[];for(const c in F.registeredVariables)e.push(F.registeredVariables[c])}const s=t?e.filter(c=>!c.trainable):null,o=e.length;e=e.filter(c=>c.trainable),$(e.length>0,()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${o} variables is trainable.`);const r=!0,{value:i,grads:a}=F.gradients(n,e,null,r);$(a.some(c=>c!=null),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),$(i.rank===0,()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${i.rank} tensor`);const l={};return e.forEach((c,u)=>{a[u]!=null&&(l[c.name]=a[u])}),s!=null&&s.forEach(c=>l[c.name]=null),{value:i,grads:l}}function Ko(n){return F.customGrad(n)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1823,7 +1823,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function uv(n){const t={x:N(n,"x","neg")};return D.runKernel(Wa,t)}const nt=O({neg_:uv});/** + */function dv(n){const t={x:N(n,"x","neg")};return F.runKernel(Wa,t)}const nt=O({neg_:dv});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1838,7 +1838,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hv(n){const t={x:N(n,"x","softplus")};return D.runKernel(ai,t)}const vi=O({softplus_:hv});/** + */function pv(n){const t={x:N(n,"x","softplus")};return F.runKernel(ai,t)}const vi=O({softplus_:pv});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1853,7 +1853,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function dv(n){const e=N(n,"x","logSigmoid");return Ko(s=>({value:nt(vi(nt(s))),gradFunc:i=>F(i,Go(nt(s)))}))(e)}const pv=O({logSigmoid_:dv});/** + */function fv(n){const e=N(n,"x","logSigmoid");return Ko(s=>({value:nt(vi(nt(s))),gradFunc:i=>D(i,Ho(nt(s)))}))(e)}const mv=O({logSigmoid_:fv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1868,7 +1868,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function fv(n,e){let t=N(n,"a","sub"),s=N(e,"b","sub");[t,s]=et(t,s);const o={a:t,b:s};return D.runKernel(ui,o)}const ge=O({sub_:fv});/** + */function gv(n,e){let t=N(n,"a","sub"),s=N(e,"b","sub");[t,s]=et(t,s);const o={a:t,b:s};return F.runKernel(ui,o)}const ge=O({sub_:gv});/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1883,7 +1883,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function mv(n,e=-1){const t=N(n,"logits","logSoftmax");if(e===-1&&(e=t.rank-1),e!==t.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and axis was ${e}`);return Ko((o,r)=>{const a=Sn(o,e,!0),l=ge(o,a),c=ge(oe(l,"float32"),Wn(pe(Vn(l),e,!0)));return r([c]),{value:c,gradFunc:(h,d)=>{const[p]=d,f=!0,g=Vn(p);return ge(h,F(pe(h,e,f),g))}}})(t)}const gm=O({logSoftmax_:mv});/** + */function xv(n,e=-1){const t=N(n,"logits","logSoftmax");if(e===-1&&(e=t.rank-1),e!==t.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and axis was ${e}`);return Ko((o,r)=>{const a=Sn(o,e,!0),l=ge(o,a),c=ge(oe(l,"float32"),Wn(pe(Vn(l),e,!0)));return r([c]),{value:c,gradFunc:(h,d)=>{const[p]=d,f=!0,g=Vn(p);return ge(h,D(pe(h,e,f),g))}}})(t)}const xm=O({logSoftmax_:xv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1898,7 +1898,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function gv(n,e=null,t=!1){const s=N(n,"x","logSumExp"),o=$e(e,s.shape),r=Sn(s,o,!0),i=ge(s,r),a=Vn(i),l=pe(a,o),c=Wn(l),u=ee(_(r,c.shape),c);if(t){const h=it(u.shape,o);return _(u,h)}return u}const xm=O({logSumExp_:gv});/** + */function bv(n,e=null,t=!1){const s=N(n,"x","logSumExp"),o=$e(e,s.shape),r=Sn(s,o,!0),i=ge(s,r),a=Vn(i),l=pe(a,o),c=Wn(l),u=ee(_(r,c.shape),c);if(t){const h=it(u.shape,o);return _(u,h)}return u}const bm=O({logSumExp_:bv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1913,7 +1913,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xv(n,e){const t=N(n,"a","logicalAnd","bool"),s=N(e,"b","logicalAnd","bool");we(t.shape,s.shape);const o={a:t,b:s};return D.runKernel(Da,o)}const as=O({logicalAnd_:xv});/** + */function yv(n,e){const t=N(n,"a","logicalAnd","bool"),s=N(e,"b","logicalAnd","bool");we(t.shape,s.shape);const o={a:t,b:s};return F.runKernel(Da,o)}const as=O({logicalAnd_:yv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1928,7 +1928,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function bv(n){const t={x:N(n,"x","logicalNot","bool")};return D.runKernel(Fa,t)}const hh=O({logicalNot_:bv});/** + */function wv(n){const t={x:N(n,"x","logicalNot","bool")};return F.runKernel(Fa,t)}const hh=O({logicalNot_:wv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1943,7 +1943,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function yv(n,e){const t=N(n,"a","logicalOr","bool"),s=N(e,"b","logicalOr","bool");we(t.shape,s.shape);const o={a:t,b:s};return D.runKernel(_a,o)}const bm=O({logicalOr_:yv});/** + */function Cv(n,e){const t=N(n,"a","logicalOr","bool"),s=N(e,"b","logicalOr","bool");we(t.shape,s.shape);const o={a:t,b:s};return F.runKernel(_a,o)}const ym=O({logicalOr_:Cv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1958,7 +1958,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function wv(n,e){const t=N(n,"a","logicalXor","bool"),s=N(e,"b","logicalXor","bool");return we(t.shape,s.shape),as(bm(n,e),hh(as(n,e)))}const Cv=O({logicalXor_:wv});/** + */function Iv(n,e){const t=N(n,"a","logicalXor","bool"),s=N(e,"b","logicalXor","bool");return we(t.shape,s.shape),as(ym(n,e),hh(as(n,e)))}const $v=O({logicalXor_:Iv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1973,7 +1973,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Iv(n,e,t,s,o){const r=N(n,"x","maxPool"),i=1;let a=r,l=!1;r.rank===3&&(l=!0,a=_(r,[1,r.shape[0],r.shape[1],r.shape[2]])),$(a.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${a.rank}.`),$(Et(t,i),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${t} and dilations '${i}'`),Wt("maxPool",s,o);const c={x:a},u={filterSize:e,strides:t,pad:s,dimRoundingMode:o},h=D.runKernel(Ma,c,u);return l?_(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const dh=O({maxPool_:Iv});/** + */function vv(n,e,t,s,o){const r=N(n,"x","maxPool"),i=1;let a=r,l=!1;r.rank===3&&(l=!0,a=_(r,[1,r.shape[0],r.shape[1],r.shape[2]])),$(a.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${a.rank}.`),$(Et(t,i),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${t} and dilations '${i}'`),Ut("maxPool",s,o);const c={x:a},u={filterSize:e,strides:t,pad:s,dimRoundingMode:o},h=F.runKernel(Ma,c,u);return l?_(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const dh=O({maxPool_:vv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1988,7 +1988,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $v(n,e=[1,1,1],t,s,o,r="NDHWC"){const i=N(n,"x","maxPool3d");let a=i,l=!1;i.rank===4&&(l=!0,a=_(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),$(a.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${a.rank}.`),$(r==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${r}`),Wt("maxPool3d",s,o);const c={x:a},u={filterSize:e,strides:t,pad:s,dimRoundingMode:o,dataFormat:r},h=D.runKernel(Pa,c,u);return l?_(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}const vv=O({maxPool3d_:$v});/** + */function kv(n,e=[1,1,1],t,s,o,r="NDHWC"){const i=N(n,"x","maxPool3d");let a=i,l=!1;i.rank===4&&(l=!0,a=_(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),$(a.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${a.rank}.`),$(r==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${r}`),Ut("maxPool3d",s,o);const c={x:a},u={filterSize:e,strides:t,pad:s,dimRoundingMode:o,dataFormat:r},h=F.runKernel(Pa,c,u);return l?_(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}const Sv=O({maxPool3d_:kv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2003,7 +2003,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function kv(n,e){let t=N(n,"a","maximum"),s=N(e,"b","maximum");[t,s]=et(t,s),t.dtype==="bool"&&(t=oe(t,"int32"),s=oe(s,"int32")),we(t.shape,s.shape);const o={a:t,b:s};return D.runKernel(jr,o)}const vs=O({maximum_:kv});/** + */function Tv(n,e){let t=N(n,"a","maximum"),s=N(e,"b","maximum");[t,s]=et(t,s),t.dtype==="bool"&&(t=oe(t,"int32"),s=oe(s,"int32")),we(t.shape,s.shape);const o={a:t,b:s};return F.runKernel(qr,o)}const vs=O({maximum_:Tv});/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2018,7 +2018,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Sv(n,e=null,t=!1){const o={x:N(n,"x","mean")},r={axis:e,keepDims:t};return D.runKernel(Ba,o,r)}const at=O({mean_:Sv});/** + */function Nv(n,e=null,t=!1){const o={x:N(n,"x","mean")},r={axis:e,keepDims:t};return F.runKernel(Ba,o,r)}const at=O({mean_:Nv});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2033,7 +2033,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function st(n,e="float32"){if(ns(n),e==="complex64"){const s=st(n,"float32"),o=st(n,"float32");return Zs(s,o)}const t=Nt(H(n),e);return D.makeTensor(t,n,e)}/** + */function st(n,e="float32"){if(ns(n),e==="complex64"){const s=st(n,"float32"),o=st(n,"float32");return Zs(s,o)}const t=Nt(H(n),e);return F.makeTensor(t,n,e)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2048,7 +2048,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Nn(n,e="float32"){if(ns(n),e==="complex64"){const s=Nn(n,"float32"),o=st(n,"float32");return Zs(s,o)}const t=zc(H(n),e);return D.makeTensor(t,n,e)}/** + */function Nn(n,e="float32"){if(ns(n),e==="complex64"){const s=Nn(n,"float32"),o=st(n,"float32");return Zs(s,o)}const t=Vc(H(n),e);return F.makeTensor(t,n,e)}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2063,7 +2063,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Tv(n,e){let t=N(n,"a","minimum"),s=N(e,"b","minimum");[t,s]=et(t,s),t.dtype==="bool"&&(t=oe(t,"int32"),s=oe(s,"int32")),we(t.shape,s.shape);const o={a:t,b:s};return D.runKernel(qr,o)}const ki=O({minimum_:Tv});/** + */function Ev(n,e){let t=N(n,"a","minimum"),s=N(e,"b","minimum");[t,s]=et(t,s),t.dtype==="bool"&&(t=oe(t,"int32"),s=oe(s,"int32")),we(t.shape,s.shape);const o={a:t,b:s};return F.runKernel(jr,o)}const ki=O({minimum_:Ev});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2078,7 +2078,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Nv(n,e,t){$(t==="reflect"||t==="symmetric",()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${t}.`);const s=N(n,"x","mirrorPad");if(s.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");$(e.length===s.rank,()=>`Padding doesn't match input. Must be ${s.rank}. Got ${e.length}.`);const o=t==="reflect"?1:0;for(let a=0;a"Invalid number of paddings. Must be length of 2 each."),$(e[a][0]>=0&&e[a][0]<=s.shape[a]-o&&e[a][1]>=0&&e[a][1]<=s.shape[a]-o,()=>`Padding in dimension ${a} cannot be greater than or equal to ${s.shape[a]-o} or less than 0 for input of shape ${s.shape}`);const r={paddings:e,mode:t},i={x:s};return D.runKernel(Va,i,r)}const Ev=O({mirrorPad_:Nv});/** + */function Rv(n,e,t){$(t==="reflect"||t==="symmetric",()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${t}.`);const s=N(n,"x","mirrorPad");if(s.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");$(e.length===s.rank,()=>`Padding doesn't match input. Must be ${s.rank}. Got ${e.length}.`);const o=t==="reflect"?1:0;for(let a=0;a"Invalid number of paddings. Must be length of 2 each."),$(e[a][0]>=0&&e[a][0]<=s.shape[a]-o&&e[a][1]>=0&&e[a][1]<=s.shape[a]-o,()=>`Padding in dimension ${a} cannot be greater than or equal to ${s.shape[a]-o} or less than 0 for input of shape ${s.shape}`);const r={paddings:e,mode:t},i={x:s};return F.runKernel(Va,i,r)}const Av=O({mirrorPad_:Rv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2093,7 +2093,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Rv(n,e){let t=N(n,"a","mod"),s=N(e,"b","mod");[t,s]=et(t,s);const o={a:t,b:s};return D.runKernel(Kr,o)}const Av=O({mod_:Rv});/** + */function Dv(n,e){let t=N(n,"a","mod"),s=N(e,"b","mod");[t,s]=et(t,s);const o={a:t,b:s};return F.runKernel(Kr,o)}const Fv=O({mod_:Dv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2108,7 +2108,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Dv(n,e=null,t=!1){n=N(n,"x","moments");const s=$e(e,n.shape),o=at(n,s,t);let r=o.shape;t||(r=it(o.shape,s));const i=je(ge(oe(n,"float32"),_(o,r))),a=at(i,s,t);return{mean:o,variance:a}}const ph=O({moments_:Dv});/** + */function _v(n,e=null,t=!1){n=N(n,"x","moments");const s=$e(e,n.shape),o=at(n,s,t);let r=o.shape;t||(r=it(o.shape,s));const i=qe(ge(oe(n,"float32"),_(o,r))),a=at(i,s,t);return{mean:o,variance:a}}const ph=O({moments_:_v});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2123,7 +2123,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Fv(n,e){let t=N(n,"a","notEqual","string_or_numeric"),s=N(e,"b","notEqual","string_or_numeric");[t,s]=et(t,s),we(t.shape,s.shape);const o={a:t,b:s};return D.runKernel(Ua,o)}const Sl=O({notEqual_:Fv});/** + */function Ov(n,e){let t=N(n,"a","notEqual","string_or_numeric"),s=N(e,"b","notEqual","string_or_numeric");[t,s]=et(t,s),we(t.shape,s.shape);const o={a:t,b:s};return F.runKernel(Ua,o)}const Tl=O({notEqual_:Ov});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2138,7 +2138,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _v(n,e,t=1,s=0,o="int32"){if(e<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${e}`);const i={indices:N(n,"indices","oneHot","int32")},a={dtype:o,depth:e,onValue:t,offValue:s};return D.runKernel(Ha,i,a)}const ym=O({oneHot_:_v});/** + */function Lv(n,e,t=1,s=0,o="int32"){if(e<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${e}`);const i={indices:N(n,"indices","oneHot","int32")},a={dtype:o,depth:e,onValue:t,offValue:s};return F.runKernel(Ha,i,a)}const wm=O({oneHot_:Lv});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2153,7 +2153,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ov(n){const t={x:N(n,"x","onesLike")};return D.runKernel(Ga,t)}const fn=O({onesLike_:Ov});/** + */function Mv(n){const t={x:N(n,"x","onesLike")};return F.runKernel(Ga,t)}const fn=O({onesLike_:Mv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2168,7 +2168,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Lv(n,e,t=0){const s=N(n,"x","pad");if(s.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const o={paddings:e,constantValue:t},r={x:s};return D.runKernel(qa,r,o)}const fh=O({pad_:Lv});/** + */function Pv(n,e,t=0){const s=N(n,"x","pad");if(s.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const o={paddings:e,constantValue:t},r={x:s};return F.runKernel(ja,r,o)}const fh=O({pad_:Pv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2183,7 +2183,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Mv(n,e,t){const s=N(n,"x","spaceToBatchND");$(s.rank>=1+e.length,()=>`input rank ${s.rank} should be > than [blockShape] ${e.length}`),$(t.length===e.length,()=>`paddings.shape[0] ${t.length} must be equal to [blockShape] ${e.length}`),$(s.shape.reduce((i,a,l)=>l>0&&l<=e.length?i&&(a+t[l-1][0]+t[l-1][1])%e[l-1]===0:i,!0),()=>`input spatial dimensions ${s.shape.slice(1)} with paddings ${t.toString()} must be divisible by blockShapes ${e.toString()}`);const o={x:s},r={blockShape:e,paddings:t};return D.runKernel(sl,o,r)}const mh=O({spaceToBatchND_:Mv});/** + */function Bv(n,e,t){const s=N(n,"x","spaceToBatchND");$(s.rank>=1+e.length,()=>`input rank ${s.rank} should be > than [blockShape] ${e.length}`),$(t.length===e.length,()=>`paddings.shape[0] ${t.length} must be equal to [blockShape] ${e.length}`),$(s.shape.reduce((i,a,l)=>l>0&&l<=e.length?i&&(a+t[l-1][0]+t[l-1][1])%e[l-1]===0:i,!0),()=>`input spatial dimensions ${s.shape.slice(1)} with paddings ${t.toString()} must be divisible by blockShapes ${e.toString()}`);const o={x:s},r={blockShape:e,paddings:t};return F.runKernel(sl,o,r)}const mh=O({spaceToBatchND_:Bv});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2198,7 +2198,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Pv(n,e,t,s,o,r,i){o==null&&(o=[1,1]),r==null&&(r=1),s===0&&(s="valid");const a=N(n,"x","maxPool");let l=a,c=!1;a.rank===3&&(c=!0,l=_(a,[1,a.shape[0],a.shape[1],a.shape[2]])),$(Et(r,o),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${r} and dilations '${o}'`);const u=pn(l.shape,e,r,o,s),h=[u.dilationHeight,u.dilationWidth];let d;s==="same"?d=zv([u.filterHeight,u.filterWidth],h):d=[[0,0],[0,0]];const p=h[0]===1&&h[1]===1,[f,g]=Bv([u.inHeight,u.inWidth],h,d),m=p?s:"valid",x=p?l:mh(l,h,f),w=(t==="avg"?()=>Ju(x,e,r,m,i):()=>dh(x,e,r,m,i))(),y=p?w:th(w,h,g);return c?_(y,[y.shape[1],y.shape[2],y.shape[3]]):y}function Bv(n,e,t){const s=t.map(u=>u[0]),o=t.map(u=>u[1]),r=n.concat(s,o),i=e.map((u,h)=>(u-r[h]%u)%u),a=o.map((u,h)=>u+i[h]),l=e.map((u,h)=>[s[h],a[h]]),c=e.map((u,h)=>[0,i[h]]);return[l,c]}function zv(n,e){const s=n.map((i,a)=>i+(i-1)*(e[a]-1)).map(i=>i-1),o=s.map(i=>Math.floor(i/2)),r=s.map((i,a)=>i-o[a]);return s.map((i,a)=>[o[a],r[a]])}const Vv=O({pool_:Pv});/** + */function zv(n,e,t,s,o,r,i){o==null&&(o=[1,1]),r==null&&(r=1),s===0&&(s="valid");const a=N(n,"x","maxPool");let l=a,c=!1;a.rank===3&&(c=!0,l=_(a,[1,a.shape[0],a.shape[1],a.shape[2]])),$(Et(r,o),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${r} and dilations '${o}'`);const u=pn(l.shape,e,r,o,s),h=[u.dilationHeight,u.dilationWidth];let d;s==="same"?d=Wv([u.filterHeight,u.filterWidth],h):d=[[0,0],[0,0]];const p=h[0]===1&&h[1]===1,[f,g]=Vv([u.inHeight,u.inWidth],h,d),m=p?s:"valid",x=p?l:mh(l,h,f),w=(t==="avg"?()=>eh(x,e,r,m,i):()=>dh(x,e,r,m,i))(),y=p?w:th(w,h,g);return c?_(y,[y.shape[1],y.shape[2],y.shape[3]]):y}function Vv(n,e,t){const s=t.map(u=>u[0]),o=t.map(u=>u[1]),r=n.concat(s,o),i=e.map((u,h)=>(u-r[h]%u)%u),a=o.map((u,h)=>u+i[h]),l=e.map((u,h)=>[s[h],a[h]]),c=e.map((u,h)=>[0,i[h]]);return[l,c]}function Wv(n,e){const s=n.map((i,a)=>i+(i-1)*(e[a]-1)).map(i=>i-1),o=s.map(i=>Math.floor(i/2)),r=s.map((i,a)=>i-o[a]);return s.map((i,a)=>[o[a],r[a]])}const Uv=O({pool_:zv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2213,7 +2213,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Wv(n,e){const t=N(n,"x","prelu"),s=N(e,"alpha","prelu"),o={x:t,alpha:s};return D.runKernel(Ka,o)}const gh=O({prelu_:Wv});/** + */function Gv(n,e){const t=N(n,"x","prelu"),s=N(e,"alpha","prelu"),o={x:t,alpha:s};return F.runKernel(Ka,o)}const gh=O({prelu_:Gv});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2228,7 +2228,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Uv(n,e=null,t=!1){let s=N(n,"x","prod");s.dtype==="bool"&&(s=oe(s,"int32"));const o={x:s},r={axis:e,keepDims:t};return D.runKernel(Xa,o,r)}const Gv=O({prod_:Uv});var xh={exports:{}};xh.exports,function(n){(function(e,t,s){function o(l){var c=this,u=a();c.next=function(){var h=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=h-(c.c=h|0)},c.c=1,c.s0=u(" "),c.s1=u(" "),c.s2=u(" "),c.s0-=u(l),c.s0<0&&(c.s0+=1),c.s1-=u(l),c.s1<0&&(c.s1+=1),c.s2-=u(l),c.s2<0&&(c.s2+=1),u=null}function r(l,c){return c.c=l.c,c.s0=l.s0,c.s1=l.s1,c.s2=l.s2,c}function i(l,c){var u=new o(l),h=c&&c.state,d=u.next;return d.int32=function(){return u.next()*4294967296|0},d.double=function(){return d()+(d()*2097152|0)*11102230246251565e-32},d.quick=d,h&&(typeof h=="object"&&r(h,u),d.state=function(){return r(u,{})}),d}function a(){var l=4022871197,c=function(u){u=String(u);for(var h=0;h>>0,d-=l,d*=l,l=d>>>0,d-=l,l+=d*4294967296}return(l>>>0)*23283064365386963e-26};return c}t&&t.exports?t.exports=i:s&&s.amd?s(function(){return i}):this.alea=i})(Gs,n,!1)}(xh);var Hv=xh.exports,bh={exports:{}};bh.exports,function(n){(function(e,t,s){function o(a){var l=this,c="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var h=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^h^h>>>8},a===(a|0)?l.x=a:c+=a;for(var u=0;u>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,p=(c.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&r(u,c),h.state=function(){return r(c,{})}),h}t&&t.exports?t.exports=i:s&&s.amd?s(function(){return i}):this.xor128=i})(Gs,n,!1)}(bh);var jv=bh.exports,yh={exports:{}};yh.exports,function(n){(function(e,t,s){function o(a){var l=this,c="";l.next=function(){var h=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^(h^h<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,a===(a|0)?l.x=a:c+=a;for(var u=0;u>>4),l.next()}function r(a,l){return l.x=a.x,l.y=a.y,l.z=a.z,l.w=a.w,l.v=a.v,l.d=a.d,l}function i(a,l){var c=new o(a),u=l&&l.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,p=(c.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&r(u,c),h.state=function(){return r(c,{})}),h}t&&t.exports?t.exports=i:s&&s.amd?s(function(){return i}):this.xorwow=i})(Gs,n,!1)}(yh);var qv=yh.exports,wh={exports:{}};wh.exports,function(n){(function(e,t,s){function o(a){var l=this;l.next=function(){var u=l.x,h=l.i,d,p;return d=u[h],d^=d>>>7,p=d^d<<24,d=u[h+1&7],p^=d^d>>>10,d=u[h+3&7],p^=d^d>>>3,d=u[h+4&7],p^=d^d<<7,d=u[h+7&7],d=d^d<<13,p^=d^d<<9,u[h]=p,l.i=h+1&7,p};function c(u,h){var d,p=[];if(h===(h|0))p[0]=h;else for(h=""+h,d=0;d0;--d)u.next()}c(l,a)}function r(a,l){return l.x=a.x.slice(),l.i=a.i,l}function i(a,l){a==null&&(a=+new Date);var c=new o(a),u=l&&l.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,p=(c.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=c.next,h.quick=h,u&&(u.x&&r(u,c),h.state=function(){return r(c,{})}),h}t&&t.exports?t.exports=i:s&&s.amd?s(function(){return i}):this.xorshift7=i})(Gs,n,!1)}(wh);var Kv=wh.exports,Ch={exports:{}};Ch.exports,function(n){(function(e,t,s){function o(a){var l=this;l.next=function(){var u=l.w,h=l.X,d=l.i,p,f;return l.w=u=u+1640531527|0,f=h[d+34&127],p=h[d=d+1&127],f^=f<<13,p^=p<<17,f^=f>>>15,p^=p>>>12,f=h[d]=f^p,l.i=d,f+(u^u>>>16)|0};function c(u,h){var d,p,f,g,m,x=[],b=128;for(h===(h|0)?(p=h,h=null):(h=h+"\0",p=0,b=Math.max(b,h.length)),f=0,g=-32;g>>15,p^=p<<4,p^=p>>>13,g>=0&&(m=m+1640531527|0,d=x[g&127]^=p+m,f=d==0?f+1:0);for(f>=128&&(x[(h&&h.length||0)&127]=-1),f=127,g=4*128;g>0;--g)p=x[f+34&127],d=x[f=f+1&127],p^=p<<13,d^=d<<17,p^=p>>>15,d^=d>>>12,x[f]=p^d;u.w=m,u.X=x,u.i=f}c(l,a)}function r(a,l){return l.i=a.i,l.w=a.w,l.X=a.X.slice(),l}function i(a,l){a==null&&(a=+new Date);var c=new o(a),u=l&&l.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,p=(c.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=c.next,h.quick=h,u&&(u.X&&r(u,c),h.state=function(){return r(c,{})}),h}t&&t.exports?t.exports=i:s&&s.amd?s(function(){return i}):this.xor4096=i})(Gs,n,!1)}(Ch);var Xv=Ch.exports,Ih={exports:{}};Ih.exports,function(n){(function(e,t,s){function o(a){var l=this,c="";l.next=function(){var h=l.b,d=l.c,p=l.d,f=l.a;return h=h<<25^h>>>7^d,d=d-p|0,p=p<<24^p>>>8^f,f=f-h|0,l.b=h=h<<20^h>>>12^d,l.c=d=d-p|0,l.d=p<<16^d>>>16^f,l.a=f-h|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,a===Math.floor(a)?(l.a=a/4294967296|0,l.b=a|0):c+=a;for(var u=0;u>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,p=(c.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&r(u,c),h.state=function(){return r(c,{})}),h}t&&t.exports?t.exports=i:s&&s.amd?s(function(){return i}):this.tychei=i})(Gs,n,!1)}(Ih);var Yv=Ih.exports,wm={exports:{}},Zv={},Qv=Object.freeze({__proto__:null,default:Zv}),Jv=Bw(Qv);(function(n){(function(e,t,s){var o=256,r=6,i=52,a="random",l=s.pow(o,r),c=s.pow(2,i),u=c*2,h=o-1,d;function p(y,C,I){var v=[];C=C==!0?{entropy:!0}:C||{};var k=x(m(C.entropy?[y,w(t)]:y??b(),3),v),S=new f(v),T=function(){for(var E=S.g(r),V=l,M=0;E=u;)E/=2,V/=2,M>>>=1;return(E+M)/V};return T.int32=function(){return S.g(4)|0},T.quick=function(){return S.g(4)/4294967296},T.double=T,x(w(S.S),t),(C.pass||I||function(E,V,M,L){return L&&(L.S&&g(L,S),E.state=function(){return g(S,{})}),M?(s[a]=E,V):E})(T,k,"global"in C?C.global:this==s,C.state)}function f(y){var C,I=y.length,v=this,k=0,S=v.i=v.j=0,T=v.S=[];for(I||(y=[I++]);k>>0,d-=l,d*=l,l=d>>>0,d-=l,l+=d*4294967296}return(l>>>0)*23283064365386963e-26};return c}t&&t.exports?t.exports=i:s&&s.amd?s(function(){return i}):this.alea=i})(Gs,n,!1)}(xh);var jv=xh.exports,bh={exports:{}};bh.exports,function(n){(function(e,t,s){function o(a){var l=this,c="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var h=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^h^h>>>8},a===(a|0)?l.x=a:c+=a;for(var u=0;u>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,p=(c.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&r(u,c),h.state=function(){return r(c,{})}),h}t&&t.exports?t.exports=i:s&&s.amd?s(function(){return i}):this.xor128=i})(Gs,n,!1)}(bh);var Kv=bh.exports,yh={exports:{}};yh.exports,function(n){(function(e,t,s){function o(a){var l=this,c="";l.next=function(){var h=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^(h^h<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,a===(a|0)?l.x=a:c+=a;for(var u=0;u>>4),l.next()}function r(a,l){return l.x=a.x,l.y=a.y,l.z=a.z,l.w=a.w,l.v=a.v,l.d=a.d,l}function i(a,l){var c=new o(a),u=l&&l.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,p=(c.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&r(u,c),h.state=function(){return r(c,{})}),h}t&&t.exports?t.exports=i:s&&s.amd?s(function(){return i}):this.xorwow=i})(Gs,n,!1)}(yh);var Xv=yh.exports,wh={exports:{}};wh.exports,function(n){(function(e,t,s){function o(a){var l=this;l.next=function(){var u=l.x,h=l.i,d,p;return d=u[h],d^=d>>>7,p=d^d<<24,d=u[h+1&7],p^=d^d>>>10,d=u[h+3&7],p^=d^d>>>3,d=u[h+4&7],p^=d^d<<7,d=u[h+7&7],d=d^d<<13,p^=d^d<<9,u[h]=p,l.i=h+1&7,p};function c(u,h){var d,p=[];if(h===(h|0))p[0]=h;else for(h=""+h,d=0;d0;--d)u.next()}c(l,a)}function r(a,l){return l.x=a.x.slice(),l.i=a.i,l}function i(a,l){a==null&&(a=+new Date);var c=new o(a),u=l&&l.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,p=(c.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=c.next,h.quick=h,u&&(u.x&&r(u,c),h.state=function(){return r(c,{})}),h}t&&t.exports?t.exports=i:s&&s.amd?s(function(){return i}):this.xorshift7=i})(Gs,n,!1)}(wh);var Yv=wh.exports,Ch={exports:{}};Ch.exports,function(n){(function(e,t,s){function o(a){var l=this;l.next=function(){var u=l.w,h=l.X,d=l.i,p,f;return l.w=u=u+1640531527|0,f=h[d+34&127],p=h[d=d+1&127],f^=f<<13,p^=p<<17,f^=f>>>15,p^=p>>>12,f=h[d]=f^p,l.i=d,f+(u^u>>>16)|0};function c(u,h){var d,p,f,g,m,x=[],b=128;for(h===(h|0)?(p=h,h=null):(h=h+"\0",p=0,b=Math.max(b,h.length)),f=0,g=-32;g>>15,p^=p<<4,p^=p>>>13,g>=0&&(m=m+1640531527|0,d=x[g&127]^=p+m,f=d==0?f+1:0);for(f>=128&&(x[(h&&h.length||0)&127]=-1),f=127,g=4*128;g>0;--g)p=x[f+34&127],d=x[f=f+1&127],p^=p<<13,d^=d<<17,p^=p>>>15,d^=d>>>12,x[f]=p^d;u.w=m,u.X=x,u.i=f}c(l,a)}function r(a,l){return l.i=a.i,l.w=a.w,l.X=a.X.slice(),l}function i(a,l){a==null&&(a=+new Date);var c=new o(a),u=l&&l.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,p=(c.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=c.next,h.quick=h,u&&(u.X&&r(u,c),h.state=function(){return r(c,{})}),h}t&&t.exports?t.exports=i:s&&s.amd?s(function(){return i}):this.xor4096=i})(Gs,n,!1)}(Ch);var Zv=Ch.exports,Ih={exports:{}};Ih.exports,function(n){(function(e,t,s){function o(a){var l=this,c="";l.next=function(){var h=l.b,d=l.c,p=l.d,f=l.a;return h=h<<25^h>>>7^d,d=d-p|0,p=p<<24^p>>>8^f,f=f-h|0,l.b=h=h<<20^h>>>12^d,l.c=d=d-p|0,l.d=p<<16^d>>>16^f,l.a=f-h|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,a===Math.floor(a)?(l.a=a/4294967296|0,l.b=a|0):c+=a;for(var u=0;u>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,p=(c.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&r(u,c),h.state=function(){return r(c,{})}),h}t&&t.exports?t.exports=i:s&&s.amd?s(function(){return i}):this.tychei=i})(Gs,n,!1)}(Ih);var Qv=Ih.exports,Cm={exports:{}},Jv={},ek=Object.freeze({__proto__:null,default:Jv}),tk=Ww(ek);(function(n){(function(e,t,s){var o=256,r=6,i=52,a="random",l=s.pow(o,r),c=s.pow(2,i),u=c*2,h=o-1,d;function p(y,C,I){var v=[];C=C==!0?{entropy:!0}:C||{};var k=x(m(C.entropy?[y,w(t)]:y??b(),3),v),S=new f(v),T=function(){for(var E=S.g(r),V=l,M=0;E=u;)E/=2,V/=2,M>>>=1;return(E+M)/V};return T.int32=function(){return S.g(4)|0},T.quick=function(){return S.g(4)/4294967296},T.double=T,x(w(S.S),t),(C.pass||I||function(E,V,M,L){return L&&(L.S&&g(L,S),E.state=function(){return g(S,{})}),M?(s[a]=E,V):E})(T,k,"global"in C?C.global:this==s,C.state)}function f(y){var C,I=y.length,v=this,k=0,S=v.i=v.j=0,T=v.S=[];for(I||(y=[I++]);k=1||i===0);const a=Math.sqrt(-2*Math.log(i)/i);e=this.mean+this.stdDev*o*a,t=this.mean+this.stdDev*r*a,(!this.truncated||this.isValidTruncated(e))&&(s=!0)}return(!this.truncated||this.isValidTruncated(t))&&(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return this.dtype==null||this.dtype==="float32"?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class ak{constructor(e=0,t=1,s,o){if(this.canReturnFloat=()=>this.dtype==null||this.dtype==="float32",this.min=e,this.range=t-e,this.dtype=s,o==null&&(o=Math.random()),typeof o=="number"&&(o=o.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=$h.alea(o)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}/** + */class Im{constructor(e,t,s,o,r){this.mean=e,this.stdDev=t,this.dtype=s,this.nextVal=NaN,this.truncated=o,this.truncated&&(this.upper=this.mean+this.stdDev*2,this.lower=this.mean-this.stdDev*2);const i=r||Math.random();this.random=$h.alea(i.toString())}nextValue(){if(!isNaN(this.nextVal)){const o=this.nextVal;return this.nextVal=NaN,o}let e,t,s=!1;for(;!s;){let o,r,i;do o=2*this.random()-1,r=2*this.random()-1,i=o*o+r*r;while(i>=1||i===0);const a=Math.sqrt(-2*Math.log(i)/i);e=this.mean+this.stdDev*o*a,t=this.mean+this.stdDev*r*a,(!this.truncated||this.isValidTruncated(e))&&(s=!0)}return(!this.truncated||this.isValidTruncated(t))&&(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return this.dtype==null||this.dtype==="float32"?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class ck{constructor(e=0,t=1,s,o){if(this.canReturnFloat=()=>this.dtype==null||this.dtype==="float32",this.min=e,this.range=t-e,this.dtype=s,o==null&&(o=Math.random()),typeof o=="number"&&(o=o.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=$h.alea(o)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2258,7 +2258,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function lk(n,e=0,t=1,s,o){if(ns(n),s!=null&&s==="bool")throw new Error(`Unsupported data type ${s}`);const r=new Cm(e,t,s,!1,o),i=ve(n,s);for(let a=0;a`Error in separableConv2d: input must be rank 4, but got rank ${u.rank}.`),$(l.rank===4,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${l.rank}.`),$(c.rank===4,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${l.rank}.`),$(c.shape[0]===1,()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${c.shape[0]}.`),$(c.shape[1]===1,()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${c.shape[1]}.`);const d=l.shape[2],p=l.shape[3];$(c.shape[2]===d*p,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${d*p}, but got ${c.shape[2]}.`);const f=ih(u,l,s,o,i,r),m=ro(f,c,1,"valid",i);return h?_(m,[m.shape[1],m.shape[2],m.shape[3]]):m}const Sm=O({separableConv2d_:wk});/** + */function Ck(n){const t={x:N(n,"x","selu")};return F.runKernel(ni,t)}const Sm=O({selu_:Ck});function Ik(n,e,t,s,o,r=[1,1],i="NHWC"){const a=N(n,"x","separableConv2d"),l=N(e,"depthwiseFilter","separableConv2d"),c=N(t,"pointwiseFilter","separableConv2d");let u=a,h=!1;if(a.rank===3&&(h=!0,u=_(a,[1,a.shape[0],a.shape[1],a.shape[2]])),i==="NCHW")throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");$(u.rank===4,()=>`Error in separableConv2d: input must be rank 4, but got rank ${u.rank}.`),$(l.rank===4,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${l.rank}.`),$(c.rank===4,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${l.rank}.`),$(c.shape[0]===1,()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${c.shape[0]}.`),$(c.shape[1]===1,()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${c.shape[1]}.`);const d=l.shape[2],p=l.shape[3];$(c.shape[2]===d*p,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${d*p}, but got ${c.shape[2]}.`);const f=ih(u,l,s,o,i,r),m=ro(f,c,1,"valid",i);return h?_(m,[m.shape[1],m.shape[2],m.shape[3]]):m}const Tm=O({separableConv2d_:Ik});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2423,7 +2423,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ck(n){const t={x:N(n,"x","sign")};return D.runKernel(ri,t)}const Ik=O({sign_:Ck});/** + */function $k(n){const t={x:N(n,"x","sign")};return F.runKernel(ri,t)}const vk=O({sign_:$k});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2438,7 +2438,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $k(n){const t={x:N(n,"x","sin","float32")};return D.runKernel(si,t)}const Tm=O({sin_:$k});/** + */function kk(n){const t={x:N(n,"x","sin","float32")};return F.runKernel(si,t)}const Nm=O({sin_:kk});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2453,7 +2453,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function vk(n){const t={x:N(n,"x","sinh")};return D.runKernel(oi,t)}const Nm=O({sinh_:vk});/** + */function Sk(n){const t={x:N(n,"x","sinh")};return F.runKernel(oi,t)}const Em=O({sinh_:Sk});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2468,7 +2468,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function kk(n,e,t){const s=N(n,"x","slice1d");return $(s.rank===1,()=>`slice1d expects a rank-1 tensor, but got a rank-${s.rank} tensor`),We(s,[e],[t])}const vh=O({slice1d_:kk});/** + */function Tk(n,e,t){const s=N(n,"x","slice1d");return $(s.rank===1,()=>`slice1d expects a rank-1 tensor, but got a rank-${s.rank} tensor`),We(s,[e],[t])}const vh=O({slice1d_:Tk});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2483,7 +2483,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Sk(n,e,t){const s=N(n,"x","slice2d");return $(s.rank===2,()=>`slice2d expects a rank-2 tensor, but got a rank-${s.rank} tensor`),We(s,e,t)}const Em=O({slice2d_:Sk});/** + */function Nk(n,e,t){const s=N(n,"x","slice2d");return $(s.rank===2,()=>`slice2d expects a rank-2 tensor, but got a rank-${s.rank} tensor`),We(s,e,t)}const Rm=O({slice2d_:Nk});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2498,7 +2498,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Tk(n,e,t){const s=N(n,"x","slice3d");return $(s.rank===3,()=>`slice3d expects a rank-3 tensor, but got a rank-${s.rank} tensor`),We(s,e,t)}const kh=O({slice3d_:Tk});/** + */function Ek(n,e,t){const s=N(n,"x","slice3d");return $(s.rank===3,()=>`slice3d expects a rank-3 tensor, but got a rank-${s.rank} tensor`),We(s,e,t)}const kh=O({slice3d_:Ek});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2513,7 +2513,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Nk(n,e,t){const s=N(n,"x","slice4d");return $(s.rank===4,()=>`slice4d expects a rank-4 tensor, but got a rank-${s.rank} tensor`),We(s,e,t)}const Nl=O({slice4d_:Nk});/** + */function Rk(n,e,t){const s=N(n,"x","slice4d");return $(s.rank===4,()=>`slice4d expects a rank-4 tensor, but got a rank-${s.rank} tensor`),We(s,e,t)}const El=O({slice4d_:Rk});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2528,7 +2528,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ek(n,e=-1){const t=N(n,"logits","softmax","float32");if(e===-1&&(e=t.rank-1),e!==t.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and dim was ${e}`);const s={logits:t},o={dim:e};return D.runKernel(rl,s,o)}const Sh=O({softmax_:Ek});/** + */function Ak(n,e=-1){const t=N(n,"logits","softmax","float32");if(e===-1&&(e=t.rank-1),e!==t.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and dim was ${e}`);const s={logits:t},o={dim:e};return F.runKernel(rl,s,o)}const Sh=O({softmax_:Ak});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2543,7 +2543,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Rk(n){$(n.dtype==="complex64",()=>`The dtype for tf.spectral.fft() must be complex64 but got ${n.dtype}.`);const e={input:n};return D.runKernel(hu,e)}const Rm=O({fft_:Rk});/** + */function Dk(n){$(n.dtype==="complex64",()=>`The dtype for tf.spectral.fft() must be complex64 but got ${n.dtype}.`);const e={input:n};return F.runKernel(du,e)}const Am=O({fft_:Dk});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2558,7 +2558,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ak(n){$(n.dtype==="complex64",()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${n.dtype}.`);const e={input:n};return D.runKernel(fu,e)}const Th=O({ifft_:Ak});/** + */function Fk(n){$(n.dtype==="complex64",()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${n.dtype}.`);const e={input:n};return F.runKernel(mu,e)}const Th=O({ifft_:Fk});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2573,7 +2573,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Dk(n){const e=n.shape[n.shape.length-1],t=n.size/e;let s;if(e<=2){const o=_(n,[t,e]);s=Th(o)}else{const o=[t,2*(e-1)],r=_(Tl(n),[t,e]),i=_(ch(n),[t,e]),a=co(We(r,[0,1],[t,e-2]),1),l=F(co(We(i,[0,1],[t,e-2]),1),Fe(-1)),c=Ot([r,a],1),u=Ot([i,l],1),h=_(Zs(c,u),[o[0],o[1]]);s=Th(h)}if(s=Tl(s),n.rank===3&&n.shape[0]!==0){const o=s,r=n.shape[0];s=_(s,[r,s.shape[0]/r,s.shape[1]]),o.dispose()}return s}const Fk=O({irfft_:Dk});/** + */function _k(n){const e=n.shape[n.shape.length-1],t=n.size/e;let s;if(e<=2){const o=_(n,[t,e]);s=Th(o)}else{const o=[t,2*(e-1)],r=_(Nl(n),[t,e]),i=_(ch(n),[t,e]),a=uo(We(r,[0,1],[t,e-2]),1),l=D(uo(We(i,[0,1],[t,e-2]),1),Fe(-1)),c=Mt([r,a],1),u=Mt([i,l],1),h=_(Zs(c,u),[o[0],o[1]]);s=Th(h)}if(s=Nl(s),n.rank===3&&n.shape[0]!==0){const o=s,r=n.shape[0];s=_(s,[r,s.shape[0]/r,s.shape[1]]),o.dispose()}return s}const Ok=O({irfft_:_k});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2588,7 +2588,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _k(n,e,t=0){const o={x:N(n,"x","split")},r={numOrSizeSplits:e,axis:t};return D.runKernel(ol,o,r)}const sn=O({split_:_k});/** + */function Lk(n,e,t=0){const o={x:N(n,"x","split")},r={numOrSizeSplits:e,axis:t};return F.runKernel(ol,o,r)}const sn=O({split_:Lk});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2603,7 +2603,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ok(n,e){$(n.dtype==="float32",()=>`The dtype for rfft() must be real value but got ${n.dtype}`);let t=n.shape[n.shape.length-1];const s=n.size/t;let o;if(e!=null&&e0),g=n.shape.map(m=>m);g[n.shape.length-1]=e,o=We(n,f,g),t=e}else if(e!=null&&e>t){const f=n.shape.map(g=>g);f[n.shape.length-1]=e-t,o=Ot([n,st(f)],n.shape.length-1),t=e}else o=n;const r=Ne(o),i=_(Zs(o,r),[s,t]),a=Rm(i),l=Math.floor(t/2)+1,c=Tl(a),u=ch(a),h=sn(c,[l,t-l],c.shape.length-1),d=sn(u,[l,t-l],u.shape.length-1),p=o.shape.slice();return p[o.shape.length-1]=l,_(Zs(h[0],d[0]),p)}const Lk=O({rfft_:Ok});/** + */function Mk(n,e){$(n.dtype==="float32",()=>`The dtype for rfft() must be real value but got ${n.dtype}`);let t=n.shape[n.shape.length-1];const s=n.size/t;let o;if(e!=null&&e0),g=n.shape.map(m=>m);g[n.shape.length-1]=e,o=We(n,f,g),t=e}else if(e!=null&&e>t){const f=n.shape.map(g=>g);f[n.shape.length-1]=e-t,o=Mt([n,st(f)],n.shape.length-1),t=e}else o=n;const r=Ne(o),i=_(Zs(o,r),[s,t]),a=Am(i),l=Math.floor(t/2)+1,c=Nl(a),u=ch(a),h=sn(c,[l,t-l],c.shape.length-1),d=sn(u,[l,t-l],u.shape.length-1),p=o.shape.slice();return p[o.shape.length-1]=l,_(Zs(h[0],d[0]),p)}const Pk=O({rfft_:Mk});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2618,7 +2618,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Mk(n,e){let t=N(n,"a","squaredDifference"),s=N(e,"b","squaredDifference");[t,s]=et(t,s),we(t.shape,s.shape);const o={a:t,b:s},r={};return D.runKernel(ci,o,r)}const Pk=O({squaredDifference_:Mk});/** + */function Bk(n,e){let t=N(n,"a","squaredDifference"),s=N(e,"b","squaredDifference");[t,s]=et(t,s),we(t.shape,s.shape);const o={a:t,b:s},r={};return F.runKernel(ci,o,r)}const zk=O({squaredDifference_:Bk});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2633,7 +2633,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Bk(n,e){const t=N(n,"x","squeeze","string_or_numeric");return _(t,ms(t.shape,e).newShape)}const Xo=O({squeeze_:Bk});/** + */function Vk(n,e){const t=N(n,"x","squeeze","string_or_numeric");return _(t,ms(t.shape,e).newShape)}const Xo=O({squeeze_:Vk});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2648,7 +2648,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function zk(n,e=0){const t=Hf(n,"tensors","stack","string_or_numeric");$(t.length>=1,()=>"Pass at least one tensor to tf.stack"),t.length>0&&$(e<=t[0].rank,()=>"Axis must be <= rank of the tensor");const s=t,o={axis:e};return D.runKernel(ja,s,o)}const Un=O({stack_:zk});/** + */function Wk(n,e=0){const t=Hf(n,"tensors","stack","string_or_numeric");$(t.length>=1,()=>"Pass at least one tensor to tf.stack"),t.length>0&&$(e<=t[0].rank,()=>"Axis must be <= rank of the tensor");const s=t,o={axis:e};return F.runKernel(qa,s,o)}const Un=O({stack_:Wk});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2663,7 +2663,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Vk(n,e=0){const s={x:N(n,"x","step")},o={alpha:e};return D.runKernel(fi,s,o)}const Ni=O({step_:Vk});/** + */function Uk(n,e=0){const s={x:N(n,"x","step")},o={alpha:e};return F.runKernel(fi,s,o)}const Ni=O({step_:Uk});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2678,7 +2678,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Wk(n,e,t,s,o=0,r=0,i=0,a=0,l=0){const u={x:N(n,"x","stridedSlice","string_or_numeric")},h={begin:e,end:t,strides:s,beginMask:o,endMask:r,ellipsisMask:i,newAxisMask:a,shrinkAxisMask:l};return D.runKernel(Nu,u,h)}const Uk=O({stridedSlice_:Wk});/** + */function Gk(n,e,t,s,o=0,r=0,i=0,a=0,l=0){const u={x:N(n,"x","stridedSlice","string_or_numeric")},h={begin:e,end:t,strides:s,beginMask:o,endMask:r,ellipsisMask:i,newAxisMask:a,shrinkAxisMask:l};return F.runKernel(Eu,u,h)}const Hk=O({stridedSlice_:Gk});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2693,7 +2693,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Gk(n){const t={x:N(n,"x","tan","float32")};return D.runKernel(hi,t)}const Hk=O({tan_:Gk});/** + */function qk(n){const t={x:N(n,"x","tan","float32")};return F.runKernel(hi,t)}const jk=O({tan_:qk});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2708,7 +2708,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Rt(n,e){Lp(n);const t=xl(n,e);if(t.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");return bl(n,null,t,e)}/** + */function At(n,e){Lp(n);const t=xl(n,e);if(t.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");return bl(n,null,t,e)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2723,7 +2723,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Nh(n,e,t){if(Lp(n),e!=null&&e.length!==2)throw new Error("tensor2d() requires shape to have two numbers");const s=xl(n,t);if(s.length!==2&&s.length!==1)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(s.length===1&&e==null)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return bl(n,e,s,t)}function Am(n,e,t){const s=e.rank>1?e.shape[e.rank-1]:1,o=e.rank>1?e.rank-1:1,r=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${t.shape}, indices.shape: ${e.shape}, shape: ${n}, sliceDim: ${s}, and batchDim: ${o}.`;if(t.rank1?e.shape[s-1]:1,r=t.length;let i=1;for(let h=o;h1?e.shape[e.rank-1]:1,o=e.rank>1?e.rank-1:1,r=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${t.shape}, indices.shape: ${e.shape}, shape: ${n}, sliceDim: ${s}, and batchDim: ${o}.`;if(t.rank1?e.shape[s-1]:1,r=t.length;let i=1;for(let h=o;h= 0 but got ${e}`);if(e>o)throw new Error(`'k' passed to topk() must be <= the last dimension (${o}) but got ${e}`);const r={x:s},i={k:e,sorted:t},[a,l]=D.runKernel(Eu,r,i);return{values:a,indices:l}}const Kk=O({topk_:qk});/** + */function Xk(n,e=1,t=!0){const s=N(n,"x","topk");if(s.rank===0)throw new Error("topk() expects the input to be of rank 1 or higher");const o=s.shape[s.shape.length-1];if(e<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${e}`);if(e>o)throw new Error(`'k' passed to topk() must be <= the last dimension (${o}) but got ${e}`);const r={x:s},i={k:e,sorted:t},[a,l]=F.runKernel(Ru,r,i);return{values:a,indices:l}}const Yk=O({topk_:Xk});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2753,7 +2753,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Xk(n,e=0,t=1,s,o){if(ns(n),s!=null&&s==="bool")throw new Error("Unsupported data type $ { dtype }");const r=new Cm(e,t,s,!0,o),i=ve(n,s);for(let a=0;a0,()=>"The input tensor must be at least 1D");const s={x:t},o={axis:e},[r,i]=D.runKernel(Au,s,o);return{values:r,indices:i}}const Zk=O({unique_:Yk});/** + */function Qk(n,e=0){const t=N(n,"x","unique","string_or_numeric");$(t.rank>0,()=>"The input tensor must be at least 1D");const s={x:t},o={axis:e},[r,i]=F.runKernel(Du,s,o);return{values:r,indices:i}}const Jk=O({unique_:Qk});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2783,7 +2783,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Qk(n,e,t){const s=N(n,"x","unsortedSegmentSum"),o=N(e,"segmentIds","unsortedSegmentSum","int32");$(Ao(t),()=>"numSegments must be of dtype int");const r={x:s,segmentIds:o},i={numSegments:t};return D.runKernel(al,r,i)}const Fm=O({unsortedSegmentSum_:Qk});/** + */function eS(n,e,t){const s=N(n,"x","unsortedSegmentSum"),o=N(e,"segmentIds","unsortedSegmentSum","int32");$(Do(t),()=>"numSegments must be of dtype int");const r={x:s,segmentIds:o},i={numSegments:t};return F.runKernel(al,r,i)}const _m=O({unsortedSegmentSum_:eS});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2798,7 +2798,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Jk(n,e=0){const t=N(n,"x","unstack","string_or_numeric");$(e>=-t.shape.length&&e`Axis = ${e} is not in [-${t.shape.length}, ${t.shape.length})`);const s={value:t},o={axis:e};return D.runKernel(il,s,o)}const Gn=O({unstack_:Jk});/** + */function tS(n,e=0){const t=N(n,"x","unstack","string_or_numeric");$(e>=-t.shape.length&&e`Axis = ${e} is not in [-${t.shape.length}, ${t.shape.length})`);const s={value:t},o={axis:e};return F.runKernel(il,s,o)}const Gn=O({unstack_:tS});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2813,7 +2813,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function eS(n,e=!0,t,s){return D.makeVariable(n,e,t,s)}/** + */function nS(n,e=!0,t,s){return F.makeVariable(n,e,t,s)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2843,7 +2843,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */async function tS(n){const e=N(n,"condition","whereAsync","bool"),t=await e.data(),s=Eh(e.shape,t);return n!==e&&e.dispose(),s}const _m=tS;/** + */async function sS(n){const e=N(n,"condition","whereAsync","bool"),t=await e.data(),s=Eh(e.shape,t);return n!==e&&e.dispose(),s}const Om=sS;/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2858,7 +2858,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function nS(n,e,t){const s=N(n,"x","transpose");if(e==null&&(e=s.shape.map((i,a)=>a).reverse()),$(s.rank===e.length,()=>`Error in transpose: rank of input ${s.rank} must match length of perm ${e}.`),e.forEach(i=>{$(i>=0&&i`All entries in 'perm' must be between 0 and ${s.rank-1} but got ${e}`)}),s.rank<=1)return s.clone();const o={x:s},r={perm:e};return s.dtype==="complex64"?z(()=>{let i=Tl(s),a=ch(s);return i=D.runKernel(Lo,{x:i},r),a=D.runKernel(Lo,{x:a},r),t&&(a=nt(a)),Zs(i,a)}):D.runKernel(Lo,o,r)}const Ee=O({transpose_:nS});/** + */function oS(n,e,t){const s=N(n,"x","transpose");if(e==null&&(e=s.shape.map((i,a)=>a).reverse()),$(s.rank===e.length,()=>`Error in transpose: rank of input ${s.rank} must match length of perm ${e}.`),e.forEach(i=>{$(i>=0&&i`All entries in 'perm' must be between 0 and ${s.rank-1} but got ${e}`)}),s.rank<=1)return s.clone();const o={x:s},r={perm:e};return s.dtype==="complex64"?P(()=>{let i=Nl(s),a=ch(s);return i=F.runKernel(Mo,{x:i},r),a=F.runKernel(Mo,{x:a},r),t&&(a=nt(a)),Zs(i,a)}):F.runKernel(Mo,o,r)}const Ee=O({transpose_:oS});/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2873,7 +2873,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function sS(n,e){if(e==null)return n.shape.slice();if(Oe(n.shape,e))return e;if(n.shape.length===e.length){const t=[];for(let s=0;s`x has to be a floating point tensor since it's going to be scaled, but got a ${o.dtype} tensor instead.`),$(e>=0&&e<1,()=>`rate must be a float in the range [0, 1), but got ${e}.`),e===0)return n instanceof lt?o.clone():o;const r=sS(o,t),i=1-e,a=me(vl(ee(Si(r,0,1,"float32",s),i)),i);return F(o,a)}const rS=O({dropout_:oS});/** + */function iS(n,e,t,s){const o=N(n,"x","dropout");if($(o.dtype==="float32",()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${o.dtype} tensor instead.`),$(e>=0&&e<1,()=>`rate must be a float in the range [0, 1), but got ${e}.`),e===0)return n instanceof lt?o.clone():o;const r=rS(o,t),i=1-e,a=me(kl(ee(Si(r,0,1,"float32",s),i)),i);return D(o,a)}const aS=O({dropout_:iS});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2903,7 +2903,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function iS(n,e,t,s,o,r="NHWC",i){let a=n;n.rank===3&&(a=_(n,[1,n.shape[0],n.shape[1],n.shape[2]]));let l=e;l.rank===3&&(l=_(e,[1,e.shape[0],e.shape[1],e.shape[2]])),$(a.rank===4,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${a.shape}.`),$(l.rank===4,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`),$(t.length===4,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${t}.`);const c=r==="NHWC"?a.shape[3]:a.shape[1],u=r==="NHWC"?l.shape[3]:l.shape[1];$(c===t[2],()=>`Error in conv2dDerFilter: depth of input ${c}) must match input depth in filter (${t[2]}.`),$(u===t[3],()=>`Error in conv2dDerFilter: depth of dy (${u}) must match output depth for filter (${t[3]}).`),Wt("conv2dDerFilter",o,i);const h={x:a,dy:l},d={strides:s,pad:o,dataFormat:r,dimRoundingMode:i,filterShape:t};return D.runKernel(Qc,h,d)}const Rh=O({conv2DBackpropFilter_:iS});/** + */function lS(n,e,t,s,o,r="NHWC",i){let a=n;n.rank===3&&(a=_(n,[1,n.shape[0],n.shape[1],n.shape[2]]));let l=e;l.rank===3&&(l=_(e,[1,e.shape[0],e.shape[1],e.shape[2]])),$(a.rank===4,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${a.shape}.`),$(l.rank===4,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`),$(t.length===4,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${t}.`);const c=r==="NHWC"?a.shape[3]:a.shape[1],u=r==="NHWC"?l.shape[3]:l.shape[1];$(c===t[2],()=>`Error in conv2dDerFilter: depth of input ${c}) must match input depth in filter (${t[2]}.`),$(u===t[3],()=>`Error in conv2dDerFilter: depth of dy (${u}) must match output depth for filter (${t[3]}).`),Ut("conv2dDerFilter",o,i);const h={x:a,dy:l},d={strides:s,pad:o,dataFormat:r,dimRoundingMode:i,filterShape:t};return F.runKernel(Jc,h,d)}const Rh=O({conv2DBackpropFilter_:lS});/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2918,7 +2918,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ah(n,e,t){if(t==null||t==="linear")return n;if(t==="relu")return F(n,Ni(e));throw new Error(`Cannot compute gradient for fused activation ${t}.`)}function Dh(n,e){let t=e;const s=ct(n.shape,e.shape);return s.length>0&&(t=pe(t,s)),_(t,n.shape)}function Fh(n,e,t,s){if(e==="linear")return n;if(e==="relu")return lo(n);if(e==="elu")return Cl(n);if(e==="relu6")return Im(n);if(e==="prelu")return gh(n,t);if(e==="leakyrelu")return uh(n,s);if(e==="sigmoid")return Go(n);throw new Error(`Unknown fused activation ${e}.`)}const _h=(n,e)=>!(n>0)||e==="linear";/** + */function Ah(n,e,t){if(t==null||t==="linear")return n;if(t==="relu")return D(n,Ni(e));throw new Error(`Cannot compute gradient for fused activation ${t}.`)}function Dh(n,e){let t=e;const s=ct(n.shape,e.shape);return s.length>0&&(t=pe(t,s)),_(t,n.shape)}function Fh(n,e,t,s){if(e==="linear")return n;if(e==="relu")return co(n);if(e==="elu")return Il(n);if(e==="relu6")return $m(n);if(e==="prelu")return gh(n,t);if(e==="leakyrelu")return uh(n,s);if(e==="sigmoid")return Ho(n);throw new Error(`Unknown fused activation ${e}.`)}const _h=(n,e)=>!(n>0)||e==="linear";/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2933,7 +2933,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function aS({x:n,filter:e,strides:t,pad:s,dataFormat:o="NHWC",dilations:r=[1,1],dimRoundingMode:i,bias:a,activation:l="linear",preluActivationWeights:c,leakyreluAlpha:u}){if(l=l||"linear",_h(D.state.gradientDepth,l)===!1){$(o==="NHWC",()=>`Error in fused conv2d: got dataFormat of ${o} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`);let I=ro(n,e,t,s,o,r,i);return a!=null&&(I=ee(I,a)),Fh(I,l,c,u)}const h=N(n,"x","conv2d","float32"),d=N(e,"filter","conv2d","float32");let p=h,f=!1;h.rank===3&&(f=!0,p=_(h,[1,h.shape[0],h.shape[1],h.shape[2]])),$(p.rank===4,()=>`Error in fused conv2d: input must be rank 4, but got rank ${p.rank}.`),$(d.rank===4,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${d.rank}.`),Wt("fused conv2d",s,i);const g=o==="NHWC"?p.shape[3]:p.shape[1];$(d.shape[2]===g,()=>`Error in conv2d: depth of input (${g}) must match input depth for filter ${d.shape[2]}.`),$(Et(t,r),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${t} and dilations '${r}'`);const m=wt(p.shape,d.shape,t,r,s,i);let x;a!=null&&(x=N(a,"bias","fused conv2d"),[x]=et(x,h),o==="NHWC"?we(m.outShape,x.shape):($(x.shape.length<=1,()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${x.shape.length}.`),$(x.shape.length===0||x.shape[0]===m.outChannels||x.shape[0]===1,()=>`Error in fused conv2d: bias shape (${x.shape}) is not compatible with the number of output channels (${m.outChannels})`)));let b;if(c!=null){const I=c.shape;if($(I.length<=1||I.length===3,()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${I.length}.`),I.length===1)$(I[0]===1||I[0]===m.outChannels,()=>`Error in fused conv2d: PReLU activation weights (${I}) is not compatible with the number of output channels (${m.outChannels}).`);else if(I.length===3)try{we(I,m.outShape)}catch{const k=`Error in fused conv2d: PReLU activation weights (${I}) is not compatible with the output shape of the conv2d (${m.outShape}).`;throw Error(k)}b=N(c,"prelu weights","fused conv2d")}const w=(I,v)=>{$(o==="NHWC",()=>`Error in gradient of fused conv2D: got dataFormat of ${o} but only NHWC is currently supported.`);const[k,S,T,E]=v,V=Ah(I,T,l);$(so(r),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`);const M=nh(S.shape,V,k,t,s),L=Rh(S,V,k.shape,t,s),R=[M,L];if(E!=null){const P=Dh(E,V);R.push(P)}return R},y={x:p,filter:d,bias:x,preluActivationWeights:b},C={strides:t,pad:s,dataFormat:o,dilations:r,dimRoundingMode:i,activation:l,leakyreluAlpha:u};return a==null?Ko((v,k,S)=>{let T=D.runKernel(ul,y,C);return S([k,v,T]),f&&(T=_(T,[T.shape[1],T.shape[2],T.shape[3]])),{value:T,gradFunc:w}})(p,d):Ko((v,k,S,T)=>{let E=D.runKernel(ul,y,C);return T([k,v,E,S]),f&&(E=_(E,[E.shape[1],E.shape[2],E.shape[3]])),{value:E,gradFunc:w}})(p,d,x)}const lS=O({fusedConv2d_:aS});/** + */function cS({x:n,filter:e,strides:t,pad:s,dataFormat:o="NHWC",dilations:r=[1,1],dimRoundingMode:i,bias:a,activation:l="linear",preluActivationWeights:c,leakyreluAlpha:u}){if(l=l||"linear",_h(F.state.gradientDepth,l)===!1){$(o==="NHWC",()=>`Error in fused conv2d: got dataFormat of ${o} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`);let I=ro(n,e,t,s,o,r,i);return a!=null&&(I=ee(I,a)),Fh(I,l,c,u)}const h=N(n,"x","conv2d","float32"),d=N(e,"filter","conv2d","float32");let p=h,f=!1;h.rank===3&&(f=!0,p=_(h,[1,h.shape[0],h.shape[1],h.shape[2]])),$(p.rank===4,()=>`Error in fused conv2d: input must be rank 4, but got rank ${p.rank}.`),$(d.rank===4,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${d.rank}.`),Ut("fused conv2d",s,i);const g=o==="NHWC"?p.shape[3]:p.shape[1];$(d.shape[2]===g,()=>`Error in conv2d: depth of input (${g}) must match input depth for filter ${d.shape[2]}.`),$(Et(t,r),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${t} and dilations '${r}'`);const m=wt(p.shape,d.shape,t,r,s,i);let x;a!=null&&(x=N(a,"bias","fused conv2d"),[x]=et(x,h),o==="NHWC"?we(m.outShape,x.shape):($(x.shape.length<=1,()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${x.shape.length}.`),$(x.shape.length===0||x.shape[0]===m.outChannels||x.shape[0]===1,()=>`Error in fused conv2d: bias shape (${x.shape}) is not compatible with the number of output channels (${m.outChannels})`)));let b;if(c!=null){const I=c.shape;if($(I.length<=1||I.length===3,()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${I.length}.`),I.length===1)$(I[0]===1||I[0]===m.outChannels,()=>`Error in fused conv2d: PReLU activation weights (${I}) is not compatible with the number of output channels (${m.outChannels}).`);else if(I.length===3)try{we(I,m.outShape)}catch{const k=`Error in fused conv2d: PReLU activation weights (${I}) is not compatible with the output shape of the conv2d (${m.outShape}).`;throw Error(k)}b=N(c,"prelu weights","fused conv2d")}const w=(I,v)=>{$(o==="NHWC",()=>`Error in gradient of fused conv2D: got dataFormat of ${o} but only NHWC is currently supported.`);const[k,S,T,E]=v,V=Ah(I,T,l);$(so(r),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`);const M=nh(S.shape,V,k,t,s),L=Rh(S,V,k.shape,t,s),R=[M,L];if(E!=null){const B=Dh(E,V);R.push(B)}return R},y={x:p,filter:d,bias:x,preluActivationWeights:b},C={strides:t,pad:s,dataFormat:o,dilations:r,dimRoundingMode:i,activation:l,leakyreluAlpha:u};return a==null?Ko((v,k,S)=>{let T=F.runKernel(ul,y,C);return S([k,v,T]),f&&(T=_(T,[T.shape[1],T.shape[2],T.shape[3]])),{value:T,gradFunc:w}})(p,d):Ko((v,k,S,T)=>{let E=F.runKernel(ul,y,C);return T([k,v,E,S]),f&&(E=_(E,[E.shape[1],E.shape[2],E.shape[3]])),{value:E,gradFunc:w}})(p,d,x)}const uS=O({fusedConv2d_:cS});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2948,7 +2948,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function cS(n,e,t,s,o,r=[1,1],i){let a=n;n.rank===3&&(a=_(n,[1,n.shape[0],n.shape[1],n.shape[2]]));let l=e;l.rank===3&&(l=_(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const c={x:a,dy:l},u={strides:s,pad:o,dimRoundingMode:i,dilations:r,filterShape:t};return D.runKernel(ru,c,u)}const uS=O({depthwiseConv2dNativeBackpropFilter_:cS});/** + */function hS(n,e,t,s,o,r=[1,1],i){let a=n;n.rank===3&&(a=_(n,[1,n.shape[0],n.shape[1],n.shape[2]]));let l=e;l.rank===3&&(l=_(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const c={x:a,dy:l},u={strides:s,pad:o,dimRoundingMode:i,dilations:r,filterShape:t};return F.runKernel(iu,c,u)}const dS=O({depthwiseConv2dNativeBackpropFilter_:hS});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2963,7 +2963,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hS(n,e,t,s,o,r=[1,1],i){let a=e,l=!1;e.rank===3&&(l=!0,a=_(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const c={dy:a,filter:t},u={strides:s,pad:o,dimRoundingMode:i,dilations:r,inputShape:n},h=D.runKernel(iu,c,u);return l?_(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const dS=O({depthwiseConv2dNativeBackpropInput_:hS});/** + */function pS(n,e,t,s,o,r=[1,1],i){let a=e,l=!1;e.rank===3&&(l=!0,a=_(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const c={dy:a,filter:t},u={strides:s,pad:o,dimRoundingMode:i,dilations:r,inputShape:n},h=F.runKernel(au,c,u);return l?_(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const fS=O({depthwiseConv2dNativeBackpropInput_:pS});/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2978,7 +2978,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function pS({a:n,b:e,transposeA:t=!1,transposeB:s=!1,bias:o,activation:r="linear",preluActivationWeights:i,leakyreluAlpha:a=.2}){if(_h(D.state.gradientDepth,r)===!1){let E=De(n,e,t,s);return o!=null&&(E=ee(E,o)),Fh(E,r,i,a)}let l=N(n,"a","fused matMul"),c=N(e,"b","fused matMul");[l,c]=et(l,c);const u=t?l.shape[l.rank-2]:l.shape[l.rank-1],h=s?c.shape[c.rank-1]:c.shape[c.rank-2],d=t?l.shape[l.rank-1]:l.shape[l.rank-2],p=s?c.shape[c.rank-2]:c.shape[c.rank-1],f=l.shape.slice(0,-2),g=c.shape.slice(0,-2),m=H(f),x=H(g);$(u===h,()=>`Error in fused matMul: inner shapes (${u}) and (${h}) of Tensors with shapes ${l.shape} and ${c.shape} and transposeA=${t} and transposeB=${s} must match.`);const w=we(l.shape.slice(0,-2),c.shape.slice(0,-2)).concat([d,p]),y=t?_(l,[m,u,d]):_(l,[m,d,u]),C=s?_(c,[x,p,h]):_(c,[x,h,p]);let I;o!=null&&(I=N(o,"bias","fused matMul"),[I]=et(I,l),we(w,I.shape));let v;i!=null&&(v=N(i,"prelu weights","fused matMul"));const k=(E,V)=>{const[M,L,R,P]=V,G=Ah(_(E,R.shape),R,r);let B,j;if(!t&&!s?(B=De(G,L,!1,!0),j=De(M,G,!0,!1)):!t&&s?(B=De(G,L,!1,!1),j=De(G,M,!0,!1)):t&&!s?(B=De(L,G,!1,!0),j=De(M,G,!1,!1)):(B=De(L,G,!0,!0),j=De(G,M,!0,!0)),o!=null){const K=Dh(P,G);return[B,j,K]}else return[B,j]},S={a:y,b:C,bias:I,preluActivationWeights:v},T={transposeA:t,transposeB:s,activation:r,leakyreluAlpha:a};return o==null?Ko((V,M,L)=>{const R=D.runKernel(cl,S,T);return L([V,M,R]),{value:_(R,w),gradFunc:k}})(y,C):Ko((V,M,L,R)=>{const P=D.runKernel(cl,S,T);return R([V,M,P,L]),{value:_(P,w),gradFunc:k}})(y,C,I)}const Om=O({fusedMatMul_:pS});/** + */function mS({a:n,b:e,transposeA:t=!1,transposeB:s=!1,bias:o,activation:r="linear",preluActivationWeights:i,leakyreluAlpha:a=.2}){if(_h(F.state.gradientDepth,r)===!1){let E=De(n,e,t,s);return o!=null&&(E=ee(E,o)),Fh(E,r,i,a)}let l=N(n,"a","fused matMul"),c=N(e,"b","fused matMul");[l,c]=et(l,c);const u=t?l.shape[l.rank-2]:l.shape[l.rank-1],h=s?c.shape[c.rank-1]:c.shape[c.rank-2],d=t?l.shape[l.rank-1]:l.shape[l.rank-2],p=s?c.shape[c.rank-2]:c.shape[c.rank-1],f=l.shape.slice(0,-2),g=c.shape.slice(0,-2),m=H(f),x=H(g);$(u===h,()=>`Error in fused matMul: inner shapes (${u}) and (${h}) of Tensors with shapes ${l.shape} and ${c.shape} and transposeA=${t} and transposeB=${s} must match.`);const w=we(l.shape.slice(0,-2),c.shape.slice(0,-2)).concat([d,p]),y=t?_(l,[m,u,d]):_(l,[m,d,u]),C=s?_(c,[x,p,h]):_(c,[x,h,p]);let I;o!=null&&(I=N(o,"bias","fused matMul"),[I]=et(I,l),we(w,I.shape));let v;i!=null&&(v=N(i,"prelu weights","fused matMul"));const k=(E,V)=>{const[M,L,R,B]=V,G=Ah(_(E,R.shape),R,r);let z,q;if(!t&&!s?(z=De(G,L,!1,!0),q=De(M,G,!0,!1)):!t&&s?(z=De(G,L,!1,!1),q=De(G,M,!0,!1)):t&&!s?(z=De(L,G,!1,!0),q=De(M,G,!1,!1)):(z=De(L,G,!0,!0),q=De(G,M,!0,!0)),o!=null){const K=Dh(B,G);return[z,q,K]}else return[z,q]},S={a:y,b:C,bias:I,preluActivationWeights:v},T={transposeA:t,transposeB:s,activation:r,leakyreluAlpha:a};return o==null?Ko((V,M,L)=>{const R=F.runKernel(cl,S,T);return L([V,M,R]),{value:_(R,w),gradFunc:k}})(y,C):Ko((V,M,L,R)=>{const B=F.runKernel(cl,S,T);return R([V,M,B,L]),{value:_(B,w),gradFunc:k}})(y,C,I)}const Lm=O({fusedMatMul_:mS});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2993,7 +2993,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function fS(n,e,t,s,o="bilinear",r=0){const i=N(n,"image","cropAndResize"),a=N(e,"boxes","cropAndResize","float32"),l=N(t,"boxInd","cropAndResize","int32"),c=a.shape[0];$(i.rank===4,()=>`Error in cropAndResize: image must be rank 4,but got rank ${i.rank}.`),$(a.rank===2&&a.shape[1]===4,()=>`Error in cropAndResize: boxes must be have size [${c},4] but had shape ${a.shape}.`),$(l.rank===1&&l.shape[0]===c,()=>`Error in cropAndResize: boxInd must be have size [${c}] but had shape ${a.shape}.`),$(s.length===2,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${s.length}.`),$(s[0]>=1&&s[1]>=1,()=>`cropSize must be atleast [1,1], but was ${s}`),$(o==="bilinear"||o==="nearest",()=>`method must be bilinear or nearest, but was ${o}`);const u={image:i,boxes:a,boxInd:l},h={method:o,extrapolationValue:r,cropSize:s};return D.runKernel(nu,u,h)}const mS=O({cropAndResize_:fS});/** + */function gS(n,e,t,s,o="bilinear",r=0){const i=N(n,"image","cropAndResize"),a=N(e,"boxes","cropAndResize","float32"),l=N(t,"boxInd","cropAndResize","int32"),c=a.shape[0];$(i.rank===4,()=>`Error in cropAndResize: image must be rank 4,but got rank ${i.rank}.`),$(a.rank===2&&a.shape[1]===4,()=>`Error in cropAndResize: boxes must be have size [${c},4] but had shape ${a.shape}.`),$(l.rank===1&&l.shape[0]===c,()=>`Error in cropAndResize: boxInd must be have size [${c}] but had shape ${a.shape}.`),$(s.length===2,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${s.length}.`),$(s[0]>=1&&s[1]>=1,()=>`cropSize must be atleast [1,1], but was ${s}`),$(o==="bilinear"||o==="nearest",()=>`method must be bilinear or nearest, but was ${o}`);const u={image:i,boxes:a,boxInd:l},h={method:o,extrapolationValue:r,cropSize:s};return F.runKernel(su,u,h)}const xS=O({cropAndResize_:gS});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3008,7 +3008,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function gS(n){const e=N(n,"image","flipLeftRight","float32");$(e.rank===4,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`);const t={image:e};return D.runKernel(pu,t,{})}const xS=O({flipLeftRight_:gS});/** + */function bS(n){const e=N(n,"image","flipLeftRight","float32");$(e.rank===4,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`);const t={image:e};return F.runKernel(fu,t,{})}const yS=O({flipLeftRight_:bS});/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3023,7 +3023,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function bS(n){const e=N(n,"image","grayscaleToRGB"),t=e.rank-1,s=e.shape[t];$(e.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`),$(s===1,()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${s}.`);const o=new Array(e.rank);return o.fill(1,0,t),o[t]=3,Tn(e,o)}const yS=O({grayscaleToRGB_:bS});/** + */function wS(n){const e=N(n,"image","grayscaleToRGB"),t=e.rank-1,s=e.shape[t];$(e.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`),$(s===1,()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${s}.`);const o=new Array(e.rank);return o.fill(1,0,t),o[t]=3,Tn(e,o)}const CS=O({grayscaleToRGB_:wS});/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3038,7 +3038,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function wS(n){const e=N(n,"image","RGBToGrayscale"),t=e.rank-1,s=e.shape[t];$(e.rank>=2,()=>`Error in RGBToGrayscale: images must be at least rank 2, but got rank ${e.rank}.`),$(s===3,()=>`Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${s}.`);const o=e.dtype,r=oe(e,"float32"),i=Rt([.2989,.587,.114]);let a;switch(e.rank){case 2:a=$i("ij,j->i",r,i);break;case 3:a=$i("ijk,k->ij",r,i);break;case 4:a=$i("ijkl,l->ijk",r,i);break;case 5:a=$i("ijklm,m->ijkl",r,i);break;case 6:a=$i("ijklmn,n->ijklm",r,i);break;default:throw new Error("Not a valid tensor rank.")}return a=Ut(a,-1),oe(a,o)}const CS=O({rgbToGrayscale_:wS});/** + */function IS(n){const e=N(n,"image","RGBToGrayscale"),t=e.rank-1,s=e.shape[t];$(e.rank>=2,()=>`Error in RGBToGrayscale: images must be at least rank 2, but got rank ${e.rank}.`),$(s===3,()=>`Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${s}.`);const o=e.dtype,r=oe(e,"float32"),i=At([.2989,.587,.114]);let a;switch(e.rank){case 2:a=$i("ij,j->i",r,i);break;case 3:a=$i("ijk,k->ij",r,i);break;case 4:a=$i("ijkl,l->ijk",r,i);break;case 5:a=$i("ijklm,m->ijkl",r,i);break;case 6:a=$i("ijklmn,n->ijklm",r,i);break;default:throw new Error("Not a valid tensor rank.")}return a=Gt(a,-1),oe(a,o)}const $S=O({rgbToGrayscale_:IS});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3053,7 +3053,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function IS(n,e,t=0,s=.5){const o=N(n,"image","rotateWithOffset","float32");$(o.rank===4,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${o.rank}.`);const r={image:o},i={radians:e,fillValue:t,center:s};return D.runKernel(Du,r,i)}const $S=O({rotateWithOffset_:IS});/** + */function vS(n,e,t=0,s=.5){const o=N(n,"image","rotateWithOffset","float32");$(o.rank===4,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${o.rank}.`);const r={image:o},i={radians:e,fillValue:t,center:s};return F.runKernel(Fu,r,i)}const kS=O({rotateWithOffset_:vS});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3083,7 +3083,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function vS(n,e,t,s=.5,o=Number.NEGATIVE_INFINITY){const r=N(n,"boxes","nonMaxSuppression","float32"),i=N(e,"scores","nonMaxSuppression","float32"),a=Yo(r,i,t,s,o);t=a.maxOutputSize,s=a.iouThreshold,o=a.scoreThreshold;const l={maxOutputSize:t,iouThreshold:s,scoreThreshold:o};return D.runKernel(yu,{boxes:r,scores:i},l)}const kS=O({nonMaxSuppression_:vS});/** + */function SS(n,e,t,s=.5,o=Number.NEGATIVE_INFINITY){const r=N(n,"boxes","nonMaxSuppression","float32"),i=N(e,"scores","nonMaxSuppression","float32"),a=Yo(r,i,t,s,o);t=a.maxOutputSize,s=a.iouThreshold,o=a.scoreThreshold;const l={maxOutputSize:t,iouThreshold:s,scoreThreshold:o};return F.runKernel(wu,{boxes:r,scores:i},l)}const TS=O({nonMaxSuppression_:SS});/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3098,7 +3098,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function SS(n,e,t){const s=TS(n,e,t),o=s<0?-(s+1):s;n.splice(o,0,e)}function TS(n,e,t){return ES(n,e,t||NS)}function NS(n,e){return n>e?1:n>>1);const a=t(e,n[r]);a>0?s=r+1:(o=r,i=!a)}return i?s:-s-1}/** + */function NS(n,e,t){const s=ES(n,e,t),o=s<0?-(s+1):s;n.splice(o,0,e)}function ES(n,e,t){return AS(n,e,t||RS)}function RS(n,e){return n>e?1:n>>1);const a=t(e,n[r]);a>0?s=r+1:(o=r,i=!a)}return i?s:-s-1}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3113,7 +3113,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Oh(n,e,t,s,o){return Ph(n,e,t,s,o,0)}function Lh(n,e,t,s,o,r){return Ph(n,e,t,s,o,0,!1,r,!0)}function Mh(n,e,t,s,o,r){return Ph(n,e,t,s,o,r,!0)}function Ph(n,e,t,s,o,r,i=!1,a=!1,l=!1){const c=[];for(let m=0;mo&&c.push({score:e[m],boxIndex:m,suppressBeginIndex:0});c.sort(Lm);const u=r>0?-.5/r:0,h=[],d=[];for(;h.length0;){const m=c.pop(),{score:x,boxIndex:b,suppressBeginIndex:w}=m;if(x=w;--C){const I=RS(n,b,h[C]);if(I>=s){y=!0;break}if(m.score=m.score*AS(s,u,I),m.score<=o)break}m.suppressBeginIndex=h.length,y||(m.score===x?(h.push(b),d.push(m.score)):m.score>o&&SS(c,m,Lm))}const p=h.length,f=t-p;a&&f>0&&(h.push(...new Array(f).fill(0)),d.push(...new Array(f).fill(0)));const g={selectedIndices:h};return i&&(g.selectedScores=d),l&&(g.validOutputs=p),g}function RS(n,e,t){const s=n.subarray(e*4,e*4+4),o=n.subarray(t*4,t*4+4),r=Math.min(s[0],s[2]),i=Math.min(s[1],s[3]),a=Math.max(s[0],s[2]),l=Math.max(s[1],s[3]),c=Math.min(o[0],o[2]),u=Math.min(o[1],o[3]),h=Math.max(o[0],o[2]),d=Math.max(o[1],o[3]),p=(a-r)*(l-i),f=(h-c)*(d-u);if(p<=0||f<=0)return 0;const g=Math.max(r,c),m=Math.max(i,u),x=Math.min(a,h),b=Math.min(l,d),w=Math.max(x-g,0)*Math.max(b-m,0);return w/(p+f-w)}function AS(n,e,t){const s=Math.exp(e*t*t);return t<=n?s:0}function Lm(n,e){return n.score-e.score||n.score===e.score&&e.boxIndex-n.boxIndex}/** + */function Oh(n,e,t,s,o){return Ph(n,e,t,s,o,0)}function Lh(n,e,t,s,o,r){return Ph(n,e,t,s,o,0,!1,r,!0)}function Mh(n,e,t,s,o,r){return Ph(n,e,t,s,o,r,!0)}function Ph(n,e,t,s,o,r,i=!1,a=!1,l=!1){const c=[];for(let m=0;mo&&c.push({score:e[m],boxIndex:m,suppressBeginIndex:0});c.sort(Mm);const u=r>0?-.5/r:0,h=[],d=[];for(;h.length0;){const m=c.pop(),{score:x,boxIndex:b,suppressBeginIndex:w}=m;if(x=w;--C){const I=DS(n,b,h[C]);if(I>=s){y=!0;break}if(m.score=m.score*FS(s,u,I),m.score<=o)break}m.suppressBeginIndex=h.length,y||(m.score===x?(h.push(b),d.push(m.score)):m.score>o&&NS(c,m,Mm))}const p=h.length,f=t-p;a&&f>0&&(h.push(...new Array(f).fill(0)),d.push(...new Array(f).fill(0)));const g={selectedIndices:h};return i&&(g.selectedScores=d),l&&(g.validOutputs=p),g}function DS(n,e,t){const s=n.subarray(e*4,e*4+4),o=n.subarray(t*4,t*4+4),r=Math.min(s[0],s[2]),i=Math.min(s[1],s[3]),a=Math.max(s[0],s[2]),l=Math.max(s[1],s[3]),c=Math.min(o[0],o[2]),u=Math.min(o[1],o[3]),h=Math.max(o[0],o[2]),d=Math.max(o[1],o[3]),p=(a-r)*(l-i),f=(h-c)*(d-u);if(p<=0||f<=0)return 0;const g=Math.max(r,c),m=Math.max(i,u),x=Math.min(a,h),b=Math.min(l,d),w=Math.max(x-g,0)*Math.max(b-m,0);return w/(p+f-w)}function FS(n,e,t){const s=Math.exp(e*t*t);return t<=n?s:0}function Mm(n,e){return n.score-e.score||n.score===e.score&&e.boxIndex-n.boxIndex}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3128,7 +3128,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */async function DS(n,e,t,s=.5,o=Number.NEGATIVE_INFINITY){const r=N(n,"boxes","nonMaxSuppressionAsync"),i=N(e,"scores","nonMaxSuppressionAsync"),a=Yo(r,i,t,s,o);t=a.maxOutputSize,s=a.iouThreshold,o=a.scoreThreshold;const l=await Promise.all([r.data(),i.data()]),c=l[0],u=l[1],{selectedIndices:h}=Oh(c,u,t,s,o);return r!==n&&r.dispose(),i!==e&&i.dispose(),Rt(h,"int32")}const FS=DS;/** + */async function _S(n,e,t,s=.5,o=Number.NEGATIVE_INFINITY){const r=N(n,"boxes","nonMaxSuppressionAsync"),i=N(e,"scores","nonMaxSuppressionAsync"),a=Yo(r,i,t,s,o);t=a.maxOutputSize,s=a.iouThreshold,o=a.scoreThreshold;const l=await Promise.all([r.data(),i.data()]),c=l[0],u=l[1],{selectedIndices:h}=Oh(c,u,t,s,o);return r!==n&&r.dispose(),i!==e&&i.dispose(),At(h,"int32")}const OS=_S;/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3143,7 +3143,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _S(n,e,t,s=.5,o=Number.NEGATIVE_INFINITY,r=0){const i=N(n,"boxes","nonMaxSuppression"),a=N(e,"scores","nonMaxSuppression"),l=Yo(i,a,t,s,o,r);t=l.maxOutputSize,s=l.iouThreshold,o=l.scoreThreshold,r=l.softNmsSigma;const c={boxes:i,scores:a},u={maxOutputSize:t,iouThreshold:s,scoreThreshold:o,softNmsSigma:r},h=D.runKernel(Cu,c,u);return{selectedIndices:h[0],selectedScores:h[1]}}const OS=O({nonMaxSuppressionWithScore_:_S});/** + */function LS(n,e,t,s=.5,o=Number.NEGATIVE_INFINITY,r=0){const i=N(n,"boxes","nonMaxSuppression"),a=N(e,"scores","nonMaxSuppression"),l=Yo(i,a,t,s,o,r);t=l.maxOutputSize,s=l.iouThreshold,o=l.scoreThreshold,r=l.softNmsSigma;const c={boxes:i,scores:a},u={maxOutputSize:t,iouThreshold:s,scoreThreshold:o,softNmsSigma:r},h=F.runKernel(Iu,c,u);return{selectedIndices:h[0],selectedScores:h[1]}}const MS=O({nonMaxSuppressionWithScore_:LS});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3158,7 +3158,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */async function LS(n,e,t,s=.5,o=Number.NEGATIVE_INFINITY,r=0){const i=N(n,"boxes","nonMaxSuppressionAsync"),a=N(e,"scores","nonMaxSuppressionAsync"),l=Yo(i,a,t,s,o,r);t=l.maxOutputSize,s=l.iouThreshold,o=l.scoreThreshold,r=l.softNmsSigma;const c=await Promise.all([i.data(),a.data()]),u=c[0],h=c[1],{selectedIndices:d,selectedScores:p}=Mh(u,h,t,s,o,r);return i!==n&&i.dispose(),a!==e&&a.dispose(),{selectedIndices:Rt(d,"int32"),selectedScores:Rt(p)}}const MS=LS;/** + */async function PS(n,e,t,s=.5,o=Number.NEGATIVE_INFINITY,r=0){const i=N(n,"boxes","nonMaxSuppressionAsync"),a=N(e,"scores","nonMaxSuppressionAsync"),l=Yo(i,a,t,s,o,r);t=l.maxOutputSize,s=l.iouThreshold,o=l.scoreThreshold,r=l.softNmsSigma;const c=await Promise.all([i.data(),a.data()]),u=c[0],h=c[1],{selectedIndices:d,selectedScores:p}=Mh(u,h,t,s,o,r);return i!==n&&i.dispose(),a!==e&&a.dispose(),{selectedIndices:At(d,"int32"),selectedScores:At(p)}}const BS=PS;/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3173,7 +3173,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function PS(n,e,t,s=.5,o=Number.NEGATIVE_INFINITY,r=!1){const i=N(n,"boxes","nonMaxSuppression"),a=N(e,"scores","nonMaxSuppression"),l=Yo(i,a,t,s,o,null),c=l.maxOutputSize,u=l.iouThreshold,h=l.scoreThreshold,d={boxes:i,scores:a},p={maxOutputSize:c,iouThreshold:u,scoreThreshold:h,padToMaxOutputSize:r},f=D.runKernel(wu,d,p);return{selectedIndices:f[0],validOutputs:f[1]}}const BS=O({nonMaxSuppressionPadded_:PS});/** + */function zS(n,e,t,s=.5,o=Number.NEGATIVE_INFINITY,r=!1){const i=N(n,"boxes","nonMaxSuppression"),a=N(e,"scores","nonMaxSuppression"),l=Yo(i,a,t,s,o,null),c=l.maxOutputSize,u=l.iouThreshold,h=l.scoreThreshold,d={boxes:i,scores:a},p={maxOutputSize:c,iouThreshold:u,scoreThreshold:h,padToMaxOutputSize:r},f=F.runKernel(Cu,d,p);return{selectedIndices:f[0],validOutputs:f[1]}}const VS=O({nonMaxSuppressionPadded_:zS});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3188,7 +3188,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */async function zS(n,e,t,s=.5,o=Number.NEGATIVE_INFINITY,r=!1){const i=N(n,"boxes","nonMaxSuppressionAsync"),a=N(e,"scores","nonMaxSuppressionAsync"),l=Yo(i,a,t,s,o,null),c=l.maxOutputSize,u=l.iouThreshold,h=l.scoreThreshold,[d,p]=await Promise.all([i.data(),a.data()]),{selectedIndices:f,validOutputs:g}=Lh(d,p,c,u,h,r);return i!==n&&i.dispose(),a!==e&&a.dispose(),{selectedIndices:Rt(f,"int32"),validOutputs:Fe(g,"int32")}}const VS=zS;/** + */async function WS(n,e,t,s=.5,o=Number.NEGATIVE_INFINITY,r=!1){const i=N(n,"boxes","nonMaxSuppressionAsync"),a=N(e,"scores","nonMaxSuppressionAsync"),l=Yo(i,a,t,s,o,null),c=l.maxOutputSize,u=l.iouThreshold,h=l.scoreThreshold,[d,p]=await Promise.all([i.data(),a.data()]),{selectedIndices:f,validOutputs:g}=Lh(d,p,c,u,h,r);return i!==n&&i.dispose(),a!==e&&a.dispose(),{selectedIndices:At(f,"int32"),validOutputs:Fe(g,"int32")}}const US=WS;/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3203,7 +3203,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function WS(n,e,t=!1,s=!1){const o=N(n,"images","resizeBilinear");$(o.rank===3||o.rank===4,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${o.rank}.`),$(e.length===2,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${e}.`),$(s===!1||t===!1,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let r=o,i=!1;o.rank===3&&(i=!0,r=_(o,[1,o.shape[0],o.shape[1],o.shape[2]]));const a={images:r},l={alignCorners:t,halfPixelCenters:s,size:e},c=D.runKernel(Qa,a,l);return i?_(c,[c.shape[1],c.shape[2],c.shape[3]]):c}const Mm=O({resizeBilinear_:WS});/** + */function GS(n,e,t=!1,s=!1){const o=N(n,"images","resizeBilinear");$(o.rank===3||o.rank===4,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${o.rank}.`),$(e.length===2,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${e}.`),$(s===!1||t===!1,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let r=o,i=!1;o.rank===3&&(i=!0,r=_(o,[1,o.shape[0],o.shape[1],o.shape[2]]));const a={images:r},l={alignCorners:t,halfPixelCenters:s,size:e},c=F.runKernel(Qa,a,l);return i?_(c,[c.shape[1],c.shape[2],c.shape[3]]):c}const Pm=O({resizeBilinear_:GS});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3218,7 +3218,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function US(n,e,t=!1,s=!1){const o=N(n,"images","resizeNearestNeighbor");$(o.rank===3||o.rank===4,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${o.rank}.`),$(e.length===2,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`),$(o.dtype==="float32"||o.dtype==="int32",()=>"`images` must have `int32` or `float32` as dtype"),$(s===!1||t===!1,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let r=o,i=!1;o.rank===3&&(i=!0,r=_(o,[1,o.shape[0],o.shape[1],o.shape[2]]));const a={images:r},l={alignCorners:t,halfPixelCenters:s,size:e},c=D.runKernel(Za,a,l);return i?_(c,[c.shape[1],c.shape[2],c.shape[3]]):c}const Pm=O({resizeNearestNeighbor_:US});/** + */function HS(n,e,t=!1,s=!1){const o=N(n,"images","resizeNearestNeighbor");$(o.rank===3||o.rank===4,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${o.rank}.`),$(e.length===2,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`),$(o.dtype==="float32"||o.dtype==="int32",()=>"`images` must have `int32` or `float32` as dtype"),$(s===!1||t===!1,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let r=o,i=!1;o.rank===3&&(i=!0,r=_(o,[1,o.shape[0],o.shape[1],o.shape[2]]));const a={images:r},l={alignCorners:t,halfPixelCenters:s,size:e},c=F.runKernel(Za,a,l);return i?_(c,[c.shape[1],c.shape[2],c.shape[3]]):c}const Bm=O({resizeNearestNeighbor_:HS});/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3233,7 +3233,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function GS(n,e="binary",t=!1,s=.5){const o=N(n,"image","threshold"),r=.2989,i=.587,a=.114,l=o.shape[0]*o.shape[1];let c=F(Rt([s]),255),u,h,d,p;if($(o.rank===3,()=>`Error in threshold: image must be rank 3,but got rank ${o.rank}.`),$(o.shape[2]===3||o.shape[2]===1,()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${o.shape[2]}.`),$(o.dtype==="int32"||o.dtype==="float32",()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${o.dtype}.`),$(e==="otsu"||e==="binary",()=>`Method must be binary or otsu, but was ${e}`),o.shape[2]===3){[u,h,d]=sn(o,[1,1,1],-1);const m=F(u,r),x=F(h,i),b=F(d,a);p=ee(ee(m,x),b)}else p=n;if(e==="otsu"){const m=WI(oe($m(p),"int32"),ss([]),256);c=HS(m,l)}const f=t?qo(p,c):Zt(p,c);return oe(F(f,255),"int32")}function HS(n,e){let t=Rt([-1]),s=Rt([0]),o=Rt([0]),r,i,a,l,c,u;for(let h=0;h`Error in threshold: image must be rank 3,but got rank ${o.rank}.`),$(o.shape[2]===3||o.shape[2]===1,()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${o.shape[2]}.`),$(o.dtype==="int32"||o.dtype==="float32",()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${o.dtype}.`),$(e==="otsu"||e==="binary",()=>`Method must be binary or otsu, but was ${e}`),o.shape[2]===3){[u,h,d]=sn(o,[1,1,1],-1);const m=D(u,r),x=D(h,i),b=D(d,a);p=ee(ee(m,x),b)}else p=n;if(e==="otsu"){const m=HI(oe(vm(p),"int32"),ss([]),256);c=jS(m,l)}const f=t?jo(p,c):Zt(p,c);return oe(D(f,255),"int32")}function jS(n,e){let t=At([-1]),s=At([0]),o=At([0]),r,i,a,l,c,u;for(let h=0;h`Error in transform: image must be rank 4,but got rank ${i.rank}.`),$(a.rank===2&&(a.shape[0]===i.shape[0]||a.shape[0]===1)&&a.shape[1]===8,()=>"Error in transform: Input transform should be batch x 8 or 1 x 8"),$(r==null||r.length===2,()=>`Error in transform: outputShape must be [height, width] or null, but got ${r}.`);const l={image:i,transforms:a},c={interpolation:t,fillMode:s,fillValue:o,outputShape:r};return D.runKernel(Ru,l,c)}const KS=O({transform_:qS});/** + */function XS(n,e,t="nearest",s="constant",o=0,r){const i=N(n,"image","transform","float32"),a=N(e,"transforms","transform","float32");$(i.rank===4,()=>`Error in transform: image must be rank 4,but got rank ${i.rank}.`),$(a.rank===2&&(a.shape[0]===i.shape[0]||a.shape[0]===1)&&a.shape[1]===8,()=>"Error in transform: Input transform should be batch x 8 or 1 x 8"),$(r==null||r.length===2,()=>`Error in transform: outputShape must be [height, width] or null, but got ${r}.`);const l={image:i,transforms:a},c={interpolation:t,fillMode:s,fillValue:o,outputShape:r};return F.runKernel(Au,l,c)}const YS=O({transform_:XS});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3263,7 +3263,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function XS(n,e,t){const s=N(n,"a","bandPart");$(s.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${s.rank}.`);const o=s.shape,[r,i]=s.shape.slice(-2);let a,l;typeof e=="number"?($(e%1===0,()=>`bandPart(): numLower must be an integer, got ${e}.`),$(e<=r,()=>`bandPart(): numLower (${e}) must not be greater than the number of rows (${r}).`),a=N(e<0?r:e,"numLower","bandPart")):($(e.dtype==="int32",()=>"bandPart(): numLower's dtype must be an int32."),a=Ct(kl(e,0),r,ki(e,r))),typeof t=="number"?($(t%1===0,()=>`bandPart(): numUpper must be an integer, got ${t}.`),$(t<=i,()=>`bandPart(): numUpper (${t}) must not be greater than the number of columns (${i}).`),l=N(t<0?i:t,"numUpper","bandPart")):($(t.dtype==="int32",()=>"bandPart(): numUpper's dtype must be an int32."),l=Ct(kl(t,0),i,ki(t,i)));const c=_(Ti(0,r,1,"int32"),[-1,1]),u=Ti(0,i,1,"int32"),h=ge(c,u),d=as(qo(h,a),io(h,nt(l))),p=st([r,i],s.dtype);return _(Un(Gn(_(s,[-1,r,i])).map(f=>Ct(d,f,p))),o)}const YS=O({bandPart_:XS});/** + */function ZS(n,e,t){const s=N(n,"a","bandPart");$(s.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${s.rank}.`);const o=s.shape,[r,i]=s.shape.slice(-2);let a,l;typeof e=="number"?($(e%1===0,()=>`bandPart(): numLower must be an integer, got ${e}.`),$(e<=r,()=>`bandPart(): numLower (${e}) must not be greater than the number of rows (${r}).`),a=N(e<0?r:e,"numLower","bandPart")):($(e.dtype==="int32",()=>"bandPart(): numLower's dtype must be an int32."),a=Ct(Sl(e,0),r,ki(e,r))),typeof t=="number"?($(t%1===0,()=>`bandPart(): numUpper must be an integer, got ${t}.`),$(t<=i,()=>`bandPart(): numUpper (${t}) must not be greater than the number of columns (${i}).`),l=N(t<0?i:t,"numUpper","bandPart")):($(t.dtype==="int32",()=>"bandPart(): numUpper's dtype must be an int32."),l=Ct(Sl(t,0),i,ki(t,i)));const c=_(Ti(0,r,1,"int32"),[-1,1]),u=Ti(0,i,1,"int32"),h=ge(c,u),d=as(jo(h,a),ao(h,nt(l))),p=st([r,i],s.dtype);return _(Un(Gn(_(s,[-1,r,i])).map(f=>Ct(d,f,p))),o)}const QS=O({bandPart_:ZS});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3278,7 +3278,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ZS(n){let e;if(Array.isArray(n)){e=!1,$(n!=null&&n.length>0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");const o=n[0].shape[0];for(let r=1;r`Gram-Schmidt: Non-unique lengths found in the input vectors: (${n[r].shape[0]} vs. ${o})`)}else e=!0,n=sn(n,n.shape[0],0).map(o=>Xo(o,[0]));$(n.length<=n[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${n.length}) exceeds number of dimensions (${n[0].shape[0]}).`);const t=[],s=n;for(let o=0;o{let r=s[o];if(o>0)for(let i=0;i0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");const o=n[0].shape[0];for(let r=1;r`Gram-Schmidt: Non-unique lengths found in the input vectors: (${n[r].shape[0]} vs. ${o})`)}else e=!0,n=sn(n,n.shape[0],0).map(o=>Xo(o,[0]));$(n.length<=n[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${n.length}) exceeds number of dimensions (${n[0].shape[0]}).`);const t=[],s=n;for(let o=0;o{let r=s[o];if(o>0)for(let i=0;i=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${n.rank}`),n.rank===2)return Bm(n,e);{const t=n.shape.slice(0,n.shape.length-2).reduce((l,c)=>l*c),s=Gn(_(n,[t,n.shape[n.shape.length-2],n.shape[n.shape.length-1]]),0),o=[],r=[];s.forEach(l=>{const[c,u]=Bm(l,e);o.push(c),r.push(u)});const i=_(Un(o,0),n.shape),a=_(Un(r,0),n.shape);return[i,a]}}function Bm(n,e=!1){return D.tidy(()=>{$(n.shape.length===2,()=>`qr2d() requires a 2D Tensor, but got a ${n.shape.length}D Tensor.`);const t=n.shape[0],s=n.shape[1];let o=fm(t),r=to(n);const i=Nh([[1]],[1,1]);let a=to(i);const l=t>=s?s:t;for(let c=0;c{const p=We(r,[c,c],[t-c,1]),f=$l(p),g=We(r,[c,c],[1,1]),m=Ct(Zt(g,0),Nh([[-1]]),Nh([[1]])),x=ge(g,F(m,f)),b=me(p,x);b.shape[0]===1?a=to(i):a=Ot([i,We(b,[1,0],[b.shape[0]-1,b.shape[1]])],0);const w=nt(me(De(m,x),f)),y=We(r,[c,0],[t-c,s]),C=F(w,a),I=Ee(a);if(c===0)r=ge(y,De(C,De(I,y)));else{const S=ge(y,De(C,De(I,y)));r=Ot([We(r,[0,0],[c,s]),S],0)}const v=Ee(C),k=We(o,[0,c],[t,o.shape[1]-c]);if(c===0)o=ge(k,De(De(k,a),v));else{const S=ge(k,De(De(k,a),v));o=Ot([We(o,[0,0],[t,c]),S],1)}return[a,r,o]}),fe([u,h,d])}return!e&&t>s&&(o=We(o,[0,0],[t,s]),r=We(r,[0,0],[s,s])),[o,r]})}const e2=O({qr_:JS});/** + */function t2(n,e=!1){if($(n.rank>=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${n.rank}`),n.rank===2)return zm(n,e);{const t=n.shape.slice(0,n.shape.length-2).reduce((l,c)=>l*c),s=Gn(_(n,[t,n.shape[n.shape.length-2],n.shape[n.shape.length-1]]),0),o=[],r=[];s.forEach(l=>{const[c,u]=zm(l,e);o.push(c),r.push(u)});const i=_(Un(o,0),n.shape),a=_(Un(r,0),n.shape);return[i,a]}}function zm(n,e=!1){return F.tidy(()=>{$(n.shape.length===2,()=>`qr2d() requires a 2D Tensor, but got a ${n.shape.length}D Tensor.`);const t=n.shape[0],s=n.shape[1];let o=mm(t),r=to(n);const i=Nh([[1]],[1,1]);let a=to(i);const l=t>=s?s:t;for(let c=0;c{const p=We(r,[c,c],[t-c,1]),f=vl(p),g=We(r,[c,c],[1,1]),m=Ct(Zt(g,0),Nh([[-1]]),Nh([[1]])),x=ge(g,D(m,f)),b=me(p,x);b.shape[0]===1?a=to(i):a=Mt([i,We(b,[1,0],[b.shape[0]-1,b.shape[1]])],0);const w=nt(me(De(m,x),f)),y=We(r,[c,0],[t-c,s]),C=D(w,a),I=Ee(a);if(c===0)r=ge(y,De(C,De(I,y)));else{const S=ge(y,De(C,De(I,y)));r=Mt([We(r,[0,0],[c,s]),S],0)}const v=Ee(C),k=We(o,[0,c],[t,o.shape[1]-c]);if(c===0)o=ge(k,De(De(k,a),v));else{const S=ge(k,De(De(k,a),v));o=Mt([We(o,[0,0],[t,c]),S],1)}return[a,r,o]}),fe([u,h,d])}return!e&&t>s&&(o=We(o,[0,0],[t,s]),r=We(r,[0,0],[s,s])),[o,r]})}const n2=O({qr_:t2});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3308,7 +3308,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ls={flipLeftRight:xS,grayscaleToRGB:yS,resizeNearestNeighbor:Pm,resizeBilinear:Mm,rgbToGrayscale:CS,rotateWithOffset:$S,cropAndResize:mS,nonMaxSuppression:kS,nonMaxSuppressionAsync:FS,nonMaxSuppressionWithScore:OS,nonMaxSuppressionWithScoreAsync:MS,nonMaxSuppressionPadded:BS,nonMaxSuppressionPaddedAsync:VS,threshold:jS,transform:KS},t2={bandPart:YS,gramSchmidt:QS,qr:e2};/** + */const ls={flipLeftRight:yS,grayscaleToRGB:CS,resizeNearestNeighbor:Bm,resizeBilinear:Pm,rgbToGrayscale:$S,rotateWithOffset:kS,cropAndResize:xS,nonMaxSuppression:TS,nonMaxSuppressionAsync:OS,nonMaxSuppressionWithScore:MS,nonMaxSuppressionWithScoreAsync:BS,nonMaxSuppressionPadded:VS,nonMaxSuppressionPaddedAsync:US,threshold:KS,transform:YS},s2={bandPart:QS,gramSchmidt:e2,qr:n2};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3323,7 +3323,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const n2=new Map,s2=new Map;class Zo{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class mn{constructor(){this.classNameMap={}}static getMap(){return mn.instance==null&&(mn.instance=new mn),mn.instance}static register(e){mn.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function Z(n,e,t){$(n.className!=null,()=>"Class being registered does not have the static className property defined."),$(typeof n.className=="string",()=>"className is required to be a string, but got type "+typeof n.className),$(n.className.length>0,()=>"Class being registered has an empty-string as its className, which is disallowed."),typeof e>"u"&&(e="Custom"),typeof t>"u"&&(t=n.className);const s=t,o=e+">"+s;return mn.register(n),n2.set(o,n),s2.set(n,o),n}/** + */const o2=new Map,r2=new Map;class Zo{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class mn{constructor(){this.classNameMap={}}static getMap(){return mn.instance==null&&(mn.instance=new mn),mn.instance}static register(e){mn.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function Y(n,e,t){$(n.className!=null,()=>"Class being registered does not have the static className property defined."),$(typeof n.className=="string",()=>"className is required to be a string, but got type "+typeof n.className),$(n.className.length>0,()=>"Class being registered has an empty-string as its className, which is disallowed."),typeof e>"u"&&(e="Custom"),typeof t>"u"&&(t=n.className);const s=t,o=e+">"+s;return mn.register(n),o2.set(o,n),r2.set(n,o),n}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3338,7 +3338,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class ks extends Zo{minimize(e,t=!1,s){const{value:o,grads:r}=this.computeGradients(e,s);if(s!=null){const i=s.map(a=>({name:a.name,tensor:r[a.name]}));this.applyGradients(i)}else this.applyGradients(r);return fe(r),t?o:(o.dispose(),null)}get iterations(){return this.iterations_==null&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return cv(e,t)}dispose(){this.iterations_!=null&&fe(this.iterations_)}async saveIterations(){return this.iterations_==null&&(this.iterations_=0),{name:"iter",tensor:Fe(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(e){throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`)}async extractIterations(e){return this.iterations_=(await e[0].tensor.data())[0],e.slice(1)}}Object.defineProperty(ks,Symbol.hasInstance,{value:n=>n.minimize!=null&&n.computeGradients!=null&&n.applyGradients!=null});/** + */class ks extends Zo{minimize(e,t=!1,s){const{value:o,grads:r}=this.computeGradients(e,s);if(s!=null){const i=s.map(a=>({name:a.name,tensor:r[a.name]}));this.applyGradients(i)}else this.applyGradients(r);return fe(r),t?o:(o.dispose(),null)}get iterations(){return this.iterations_==null&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return hv(e,t)}dispose(){this.iterations_!=null&&fe(this.iterations_)}async saveIterations(){return this.iterations_==null&&(this.iterations_=0),{name:"iter",tensor:Fe(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(e){throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`)}async extractIterations(e){return this.iterations_=(await e[0].tensor.data())[0],e.slice(1)}}Object.defineProperty(ks,Symbol.hasInstance,{value:n=>n.minimize!=null&&n.computeGradients!=null&&n.applyGradients!=null});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3353,7 +3353,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class zm extends ks{static get className(){return"Adadelta"}constructor(e,t,s=null){super(),this.learningRate=e,this.rho=t,this.epsilon=s,this.accumulatedGrads=[],this.accumulatedUpdates=[],s==null&&(this.epsilon=D.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map(s=>s.name):Object.keys(e)).forEach((s,o)=>{const r=D.registeredVariables[s],i=!1;this.accumulatedGrads[o]==null&&(this.accumulatedGrads[o]={originalName:`${s}/accum_grad`,variable:z(()=>Ne(r).variable(i))}),this.accumulatedUpdates[o]==null&&(this.accumulatedUpdates[o]={originalName:`${s}/accum_var`,variable:z(()=>Ne(r).variable(i))});const a=Array.isArray(e)?e[o].tensor:e[s];if(a==null)return;const l=this.accumulatedGrads[o].variable,c=this.accumulatedUpdates[o].variable;z(()=>{const u=ee(F(l,this.rho),F(je(a),1-this.rho)),h=F(me(Lt(ee(c,this.epsilon)),Lt(ee(l,this.epsilon))),a),d=ee(F(c,this.rho),F(je(h),1-this.rho));l.assign(u),c.assign(d);const p=ee(F(h,-this.learningRate),r);r.assign(p)})}),this.incrementIterations()}dispose(){this.accumulatedUpdates!=null&&(fe(this.accumulatedGrads.map(e=>e.variable)),fe(this.accumulatedUpdates.map(e=>e.variable)))}async getWeights(){const e=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=e.length/2,s=!1;this.accumulatedGrads=e.slice(0,t).map(o=>({originalName:o.name,variable:o.tensor.variable(s)})),this.accumulatedUpdates=e.slice(t,t*2).map(o=>({originalName:o.name,variable:o.tensor.variable(s)}))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}}/** + */class Vm extends ks{static get className(){return"Adadelta"}constructor(e,t,s=null){super(),this.learningRate=e,this.rho=t,this.epsilon=s,this.accumulatedGrads=[],this.accumulatedUpdates=[],s==null&&(this.epsilon=F.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map(s=>s.name):Object.keys(e)).forEach((s,o)=>{const r=F.registeredVariables[s],i=!1;this.accumulatedGrads[o]==null&&(this.accumulatedGrads[o]={originalName:`${s}/accum_grad`,variable:P(()=>Ne(r).variable(i))}),this.accumulatedUpdates[o]==null&&(this.accumulatedUpdates[o]={originalName:`${s}/accum_var`,variable:P(()=>Ne(r).variable(i))});const a=Array.isArray(e)?e[o].tensor:e[s];if(a==null)return;const l=this.accumulatedGrads[o].variable,c=this.accumulatedUpdates[o].variable;P(()=>{const u=ee(D(l,this.rho),D(qe(a),1-this.rho)),h=D(me(Rt(ee(c,this.epsilon)),Rt(ee(l,this.epsilon))),a),d=ee(D(c,this.rho),D(qe(h),1-this.rho));l.assign(u),c.assign(d);const p=ee(D(h,-this.learningRate),r);r.assign(p)})}),this.incrementIterations()}dispose(){this.accumulatedUpdates!=null&&(fe(this.accumulatedGrads.map(e=>e.variable)),fe(this.accumulatedUpdates.map(e=>e.variable)))}async getWeights(){const e=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=e.length/2,s=!1;this.accumulatedGrads=e.slice(0,t).map(o=>({originalName:o.name,variable:o.tensor.variable(s)})),this.accumulatedUpdates=e.slice(t,t*2).map(o=>({originalName:o.name,variable:o.tensor.variable(s)}))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3368,7 +3368,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Vm extends ks{static get className(){return"Adagrad"}constructor(e,t=.1){super(),this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map(s=>s.name):Object.keys(e)).forEach((s,o)=>{const r=D.registeredVariables[s];this.accumulatedGrads[o]==null&&(this.accumulatedGrads[o]={originalName:`${s}/accumulator`,variable:z(()=>Ii(r.shape,this.initialAccumulatorValue).variable(!1))});const i=Array.isArray(e)?e[o].tensor:e[s];if(i==null)return;const a=this.accumulatedGrads[o].variable;z(()=>{const l=ee(a,je(i));a.assign(l);const c=ee(F(me(i,Lt(ee(l,D.backend.epsilon()))),-this.learningRate),r);r.assign(c)})}),this.incrementIterations()}dispose(){this.accumulatedGrads!=null&&fe(this.accumulatedGrads.map(e=>e.variable))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=!1;this.accumulatedGrads=e.map(s=>({originalName:s.name,variable:s.tensor.variable(t)}))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}}/** + */class Wm extends ks{static get className(){return"Adagrad"}constructor(e,t=.1){super(),this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map(s=>s.name):Object.keys(e)).forEach((s,o)=>{const r=F.registeredVariables[s];this.accumulatedGrads[o]==null&&(this.accumulatedGrads[o]={originalName:`${s}/accumulator`,variable:P(()=>Ii(r.shape,this.initialAccumulatorValue).variable(!1))});const i=Array.isArray(e)?e[o].tensor:e[s];if(i==null)return;const a=this.accumulatedGrads[o].variable;P(()=>{const l=ee(a,qe(i));a.assign(l);const c=ee(D(me(i,Rt(ee(l,F.backend.epsilon()))),-this.learningRate),r);r.assign(c)})}),this.incrementIterations()}dispose(){this.accumulatedGrads!=null&&fe(this.accumulatedGrads.map(e=>e.variable))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=!1;this.accumulatedGrads=e.map(s=>({originalName:s.name,variable:s.tensor.variable(t)}))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3383,7 +3383,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Wm extends ks{static get className(){return"Adam"}constructor(e,t,s,o=null){super(),this.learningRate=e,this.beta1=t,this.beta2=s,this.epsilon=o,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],z(()=>{this.accBeta1=Fe(t).variable(),this.accBeta2=Fe(s).variable()}),o==null&&(this.epsilon=D.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map(s=>s.name):Object.keys(e);z(()=>{const s=ge(1,this.accBeta1),o=ge(1,this.accBeta2);t.forEach((r,i)=>{const a=D.registeredVariables[r],l=!1;this.accumulatedFirstMoment[i]==null&&(this.accumulatedFirstMoment[i]={originalName:`${r}/m`,variable:z(()=>Ne(a).variable(l))}),this.accumulatedSecondMoment[i]==null&&(this.accumulatedSecondMoment[i]={originalName:`${r}/v`,variable:z(()=>Ne(a).variable(l))});const c=Array.isArray(e)?e[i].tensor:e[r];if(c==null)return;const u=this.accumulatedFirstMoment[i].variable,h=this.accumulatedSecondMoment[i].variable,d=ee(F(u,this.beta1),F(c,1-this.beta1)),p=ee(F(h,this.beta2),F(je(c),1-this.beta2)),f=me(d,s),g=me(p,o);u.assign(d),h.assign(p);const m=ee(F(me(f,ee(Lt(g),this.epsilon)),-this.learningRate),a);a.assign(m)}),this.accBeta1.assign(F(this.accBeta1,this.beta1)),this.accBeta2.assign(F(this.accBeta2,this.beta2))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),this.accumulatedFirstMoment!=null&&fe(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedSecondMoment!=null&&fe(this.accumulatedSecondMoment.map(e=>e.variable))}async getWeights(){const e=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(e){e=await this.extractIterations(e),z(()=>{this.accBeta1.assign(jo(this.beta1,this.iterations_+1)),this.accBeta2.assign(jo(this.beta2,this.iterations_+1))});const t=e.length/2,s=!1;this.accumulatedFirstMoment=e.slice(0,t).map(o=>({originalName:o.name,variable:o.tensor.variable(s)})),this.accumulatedSecondMoment=e.slice(t,t*2).map(o=>({originalName:o.name,variable:o.tensor.variable(s)}))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)}}/** + */class Um extends ks{static get className(){return"Adam"}constructor(e,t,s,o=null){super(),this.learningRate=e,this.beta1=t,this.beta2=s,this.epsilon=o,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],P(()=>{this.accBeta1=Fe(t).variable(),this.accBeta2=Fe(s).variable()}),o==null&&(this.epsilon=F.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map(s=>s.name):Object.keys(e);P(()=>{const s=ge(1,this.accBeta1),o=ge(1,this.accBeta2);t.forEach((r,i)=>{const a=F.registeredVariables[r],l=!1;this.accumulatedFirstMoment[i]==null&&(this.accumulatedFirstMoment[i]={originalName:`${r}/m`,variable:P(()=>Ne(a).variable(l))}),this.accumulatedSecondMoment[i]==null&&(this.accumulatedSecondMoment[i]={originalName:`${r}/v`,variable:P(()=>Ne(a).variable(l))});const c=Array.isArray(e)?e[i].tensor:e[r];if(c==null)return;const u=this.accumulatedFirstMoment[i].variable,h=this.accumulatedSecondMoment[i].variable,d=ee(D(u,this.beta1),D(c,1-this.beta1)),p=ee(D(h,this.beta2),D(qe(c),1-this.beta2)),f=me(d,s),g=me(p,o);u.assign(d),h.assign(p);const m=ee(D(me(f,ee(Rt(g),this.epsilon)),-this.learningRate),a);a.assign(m)}),this.accBeta1.assign(D(this.accBeta1,this.beta1)),this.accBeta2.assign(D(this.accBeta2,this.beta2))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),this.accumulatedFirstMoment!=null&&fe(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedSecondMoment!=null&&fe(this.accumulatedSecondMoment.map(e=>e.variable))}async getWeights(){const e=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(e){e=await this.extractIterations(e),P(()=>{this.accBeta1.assign(io(this.beta1,this.iterations_+1)),this.accBeta2.assign(io(this.beta2,this.iterations_+1))});const t=e.length/2,s=!1;this.accumulatedFirstMoment=e.slice(0,t).map(o=>({originalName:o.name,variable:o.tensor.variable(s)})),this.accumulatedSecondMoment=e.slice(t,t*2).map(o=>({originalName:o.name,variable:o.tensor.variable(s)}))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3398,7 +3398,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Um extends ks{static get className(){return"Adamax"}constructor(e,t,s,o=null,r=0){super(),this.learningRate=e,this.beta1=t,this.beta2=s,this.epsilon=o,this.decay=r,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],z(()=>{this.iteration=Fe(0).variable(),this.accBeta1=Fe(t).variable()}),o==null&&(this.epsilon=D.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map(s=>s.name):Object.keys(e);z(()=>{const s=ge(1,this.accBeta1),o=me(-this.learningRate,ee(F(this.iteration,this.decay),1));t.forEach((r,i)=>{const a=D.registeredVariables[r],l=!1;this.accumulatedFirstMoment[i]==null&&(this.accumulatedFirstMoment[i]={originalName:`${r}/m`,variable:Ne(a).variable(l)}),this.accumulatedWeightedInfNorm[i]==null&&(this.accumulatedWeightedInfNorm[i]={originalName:`${r}/v`,variable:Ne(a).variable(l)});const c=Array.isArray(e)?e[i].tensor:e[r];if(c==null)return;const u=this.accumulatedFirstMoment[i].variable,h=this.accumulatedWeightedInfNorm[i].variable,d=ee(F(u,this.beta1),F(c,1-this.beta1)),p=F(h,this.beta2),f=_t(c),g=vs(p,f);u.assign(d),h.assign(g);const m=ee(F(me(o,s),me(d,ee(g,this.epsilon))),a);a.assign(m)}),this.iteration.assign(ee(this.iteration,1)),this.accBeta1.assign(F(this.accBeta1,this.beta1))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),this.accumulatedFirstMoment!=null&&fe(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedWeightedInfNorm!=null&&fe(this.accumulatedWeightedInfNorm.map(e=>e.variable))}async getWeights(){throw new Error("getWeights() is not implemented for Adamax yet.")}async setWeights(e){throw new Error("setWeights() is not implemented for Adamax yet.")}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)}}/** + */class Gm extends ks{static get className(){return"Adamax"}constructor(e,t,s,o=null,r=0){super(),this.learningRate=e,this.beta1=t,this.beta2=s,this.epsilon=o,this.decay=r,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],P(()=>{this.iteration=Fe(0).variable(),this.accBeta1=Fe(t).variable()}),o==null&&(this.epsilon=F.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map(s=>s.name):Object.keys(e);P(()=>{const s=ge(1,this.accBeta1),o=me(-this.learningRate,ee(D(this.iteration,this.decay),1));t.forEach((r,i)=>{const a=F.registeredVariables[r],l=!1;this.accumulatedFirstMoment[i]==null&&(this.accumulatedFirstMoment[i]={originalName:`${r}/m`,variable:Ne(a).variable(l)}),this.accumulatedWeightedInfNorm[i]==null&&(this.accumulatedWeightedInfNorm[i]={originalName:`${r}/v`,variable:Ne(a).variable(l)});const c=Array.isArray(e)?e[i].tensor:e[r];if(c==null)return;const u=this.accumulatedFirstMoment[i].variable,h=this.accumulatedWeightedInfNorm[i].variable,d=ee(D(u,this.beta1),D(c,1-this.beta1)),p=D(h,this.beta2),f=Lt(c),g=vs(p,f);u.assign(d),h.assign(g);const m=ee(D(me(o,s),me(d,ee(g,this.epsilon))),a);a.assign(m)}),this.iteration.assign(ee(this.iteration,1)),this.accBeta1.assign(D(this.accBeta1,this.beta1))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),this.accumulatedFirstMoment!=null&&fe(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedWeightedInfNorm!=null&&fe(this.accumulatedWeightedInfNorm.map(e=>e.variable))}async getWeights(){throw new Error("getWeights() is not implemented for Adamax yet.")}async setWeights(e){throw new Error("setWeights() is not implemented for Adamax yet.")}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3413,7 +3413,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Bh extends ks{static get className(){return"SGD"}constructor(e){super(),this.learningRate=e,this.setLearningRate(e)}applyGradients(e){(Array.isArray(e)?e.map(s=>s.name):Object.keys(e)).forEach((s,o)=>{const r=Array.isArray(e)?e[o].tensor:e[s];if(r==null)return;const i=D.registeredVariables[s];z(()=>{const a=ee(F(this.c,r),i);i.assign(a)})}),this.incrementIterations()}setLearningRate(e){this.learningRate=e,this.c!=null&&this.c.dispose(),this.c=dn(Fe(-e))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(e=await this.extractIterations(e),e.length!==0)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}}/** + */class Bh extends ks{static get className(){return"SGD"}constructor(e){super(),this.learningRate=e,this.setLearningRate(e)}applyGradients(e){(Array.isArray(e)?e.map(s=>s.name):Object.keys(e)).forEach((s,o)=>{const r=Array.isArray(e)?e[o].tensor:e[s];if(r==null)return;const i=F.registeredVariables[s];P(()=>{const a=ee(D(this.c,r),i);i.assign(a)})}),this.incrementIterations()}setLearningRate(e){this.learningRate=e,this.c!=null&&this.c.dispose(),this.c=dn(Fe(-e))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(e=await this.extractIterations(e),e.length!==0)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3428,7 +3428,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Gm extends Bh{static get className(){return"Momentum"}constructor(e,t,s=!1){super(e),this.learningRate=e,this.momentum=t,this.useNesterov=s,this.accumulations=[],this.m=Fe(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map(s=>s.name):Object.keys(e)).forEach((s,o)=>{const r=D.registeredVariables[s];this.accumulations[o]==null&&(this.accumulations[o]={originalName:`${s}/momentum`,variable:z(()=>Ne(r).variable(!1))});const i=this.accumulations[o].variable,a=Array.isArray(e)?e[o].tensor:e[s];a!=null&&z(()=>{let l;const c=ee(F(this.m,i),a);this.useNesterov?l=ee(F(this.c,ee(a,F(c,this.m))),r):l=ee(F(this.c,c),r),i.assign(c),r.assign(l)})}),this.incrementIterations()}dispose(){this.m.dispose(),this.accumulations!=null&&fe(this.accumulations.map(e=>e.variable))}setMomentum(e){this.momentum=e}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=!1;this.accumulations=e.map(s=>({originalName:s.name,variable:s.tensor.variable(t)}))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}}/** + */class Hm extends Bh{static get className(){return"Momentum"}constructor(e,t,s=!1){super(e),this.learningRate=e,this.momentum=t,this.useNesterov=s,this.accumulations=[],this.m=Fe(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map(s=>s.name):Object.keys(e)).forEach((s,o)=>{const r=F.registeredVariables[s];this.accumulations[o]==null&&(this.accumulations[o]={originalName:`${s}/momentum`,variable:P(()=>Ne(r).variable(!1))});const i=this.accumulations[o].variable,a=Array.isArray(e)?e[o].tensor:e[s];a!=null&&P(()=>{let l;const c=ee(D(this.m,i),a);this.useNesterov?l=ee(D(this.c,ee(a,D(c,this.m))),r):l=ee(D(this.c,c),r),i.assign(c),r.assign(l)})}),this.incrementIterations()}dispose(){this.m.dispose(),this.accumulations!=null&&fe(this.accumulations.map(e=>e.variable))}setMomentum(e){this.momentum=e}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=!1;this.accumulations=e.map(s=>({originalName:s.name,variable:s.tensor.variable(t)}))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3443,7 +3443,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Hm extends ks{static get className(){return"RMSProp"}constructor(e,t=.9,s=0,o=null,r=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=s,this.epsilon=o,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=r,o==null&&(this.epsilon=D.backend.epsilon()),e==null)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map(s=>s.name):Object.keys(e)).forEach((s,o)=>{const r=D.registeredVariables[s],i=!1;this.accumulatedMeanSquares[o]==null&&(this.accumulatedMeanSquares[o]={originalName:`${s}/rms`,variable:z(()=>Ne(r).variable(i))}),this.accumulatedMoments[o]==null&&(this.accumulatedMoments[o]={originalName:`${s}/momentum`,variable:z(()=>Ne(r).variable(i))}),this.accumulatedMeanGrads[o]==null&&this.centered&&(this.accumulatedMeanGrads[o]={originalName:`${s}/mg`,variable:z(()=>Ne(r).variable(i))});const a=Array.isArray(e)?e[o].tensor:e[s];if(a==null)return;const l=this.accumulatedMeanSquares[o].variable,c=this.accumulatedMoments[o].variable;z(()=>{const u=ee(F(l,this.decay),F(je(a),1-this.decay));if(this.centered){const h=this.accumulatedMeanGrads[o].variable,d=ee(F(h,this.decay),F(a,1-this.decay)),p=me(F(a,this.learningRate),Lt(ge(u,ee(je(d),this.epsilon)))),f=ee(F(c,this.momentum),p);l.assign(u),h.assign(d),c.assign(f);const g=ge(r,f);r.assign(g)}else{const h=ee(F(l,this.decay),F(je(a),1-this.decay)),d=ee(F(c,this.momentum),me(F(a,this.learningRate),Lt(ee(h,this.epsilon))));l.assign(h),c.assign(d);const p=ge(r,d);r.assign(p)}})}),this.incrementIterations()}dispose(){this.accumulatedMeanSquares!=null&&fe(this.accumulatedMeanSquares.map(e=>e.variable)),this.accumulatedMeanGrads!=null&&this.centered&&fe(this.accumulatedMeanGrads.map(e=>e.variable)),this.accumulatedMoments!=null&&fe(this.accumulatedMoments.map(e=>e.variable))}async getWeights(){const e=[...this.accumulatedMeanSquares,...this.accumulatedMoments];return this.centered&&e.push(...this.accumulatedMeanGrads),[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=this.centered?e.length/3:e.length/2,s=!1;this.accumulatedMeanSquares=e.slice(0,t).map(o=>({originalName:o.name,variable:o.tensor.variable(s)})),this.accumulatedMoments=e.slice(t,t*2).map(o=>({originalName:o.name,variable:o.tensor.variable(s)})),this.centered&&(this.accumulatedMeanGrads=e.slice(t*2,t*3).map(o=>({originalName:o.name,variable:o.tensor.variable(s)})))}getConfig(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}static fromConfig(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)}}/** + */class qm extends ks{static get className(){return"RMSProp"}constructor(e,t=.9,s=0,o=null,r=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=s,this.epsilon=o,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=r,o==null&&(this.epsilon=F.backend.epsilon()),e==null)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map(s=>s.name):Object.keys(e)).forEach((s,o)=>{const r=F.registeredVariables[s],i=!1;this.accumulatedMeanSquares[o]==null&&(this.accumulatedMeanSquares[o]={originalName:`${s}/rms`,variable:P(()=>Ne(r).variable(i))}),this.accumulatedMoments[o]==null&&(this.accumulatedMoments[o]={originalName:`${s}/momentum`,variable:P(()=>Ne(r).variable(i))}),this.accumulatedMeanGrads[o]==null&&this.centered&&(this.accumulatedMeanGrads[o]={originalName:`${s}/mg`,variable:P(()=>Ne(r).variable(i))});const a=Array.isArray(e)?e[o].tensor:e[s];if(a==null)return;const l=this.accumulatedMeanSquares[o].variable,c=this.accumulatedMoments[o].variable;P(()=>{const u=ee(D(l,this.decay),D(qe(a),1-this.decay));if(this.centered){const h=this.accumulatedMeanGrads[o].variable,d=ee(D(h,this.decay),D(a,1-this.decay)),p=me(D(a,this.learningRate),Rt(ge(u,ee(qe(d),this.epsilon)))),f=ee(D(c,this.momentum),p);l.assign(u),h.assign(d),c.assign(f);const g=ge(r,f);r.assign(g)}else{const h=ee(D(l,this.decay),D(qe(a),1-this.decay)),d=ee(D(c,this.momentum),me(D(a,this.learningRate),Rt(ee(h,this.epsilon))));l.assign(h),c.assign(d);const p=ge(r,d);r.assign(p)}})}),this.incrementIterations()}dispose(){this.accumulatedMeanSquares!=null&&fe(this.accumulatedMeanSquares.map(e=>e.variable)),this.accumulatedMeanGrads!=null&&this.centered&&fe(this.accumulatedMeanGrads.map(e=>e.variable)),this.accumulatedMoments!=null&&fe(this.accumulatedMoments.map(e=>e.variable))}async getWeights(){const e=[...this.accumulatedMeanSquares,...this.accumulatedMoments];return this.centered&&e.push(...this.accumulatedMeanGrads),[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=this.centered?e.length/3:e.length/2,s=!1;this.accumulatedMeanSquares=e.slice(0,t).map(o=>({originalName:o.name,variable:o.tensor.variable(s)})),this.accumulatedMoments=e.slice(t,t*2).map(o=>({originalName:o.name,variable:o.tensor.variable(s)})),this.centered&&(this.accumulatedMeanGrads=e.slice(t*2,t*3).map(o=>({originalName:o.name,variable:o.tensor.variable(s)})))}getConfig(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}static fromConfig(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)}}/** * @license * Copyright 2022 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3458,7 +3458,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const o2=[zm,Vm,Wm,Um,Gm,Hm,Bh];function r2(){for(const n of o2)Z(n)}/** + */const i2=[Vm,Wm,Um,Gm,Hm,qm,Bh];function a2(){for(const n of i2)Y(n)}/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3488,7 +3488,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */async function i2(n,e){e==null&&(e={});const t=e.fetchFunc==null?W().platform.fetch:e.fetchFunc,s=n.map(h=>t(h,e.requestInit,{isBinary:!0})),a=(e.onProgress==null?await Promise.all(s):await jm(s,e.onProgress,0,.5)).map(h=>h.arrayBuffer());return e.onProgress==null?await Promise.all(a):await jm(a,e.onProgress,.5,1)}function a2(n,e){var t;const s=e.fetchFunc==null?W().platform.fetch:e.fetchFunc;let o=0,r;return(t=e.onProgress)===null||t===void 0||t.call(e,0),new ReadableStream({pull:async i=>{for(var a;ot(h,e.requestInit,{isBinary:!0})),a=(e.onProgress==null?await Promise.all(s):await jm(s,e.onProgress,0,.5)).map(h=>h.arrayBuffer());return e.onProgress==null?await Promise.all(a):await jm(a,e.onProgress,.5,1)}function c2(n,e){var t;const s=e.fetchFunc==null?W().platform.fetch:e.fetchFunc;let o=0,r;return(t=e.onProgress)===null||t===void 0||t.call(e,0),new ReadableStream({pull:async i=>{for(var a;o"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=W().platform.fetch,$(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&$(e.length===2,()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`),this.path=e,t.requestInit!=null&&t.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{},this.loadOptions=t}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;const s=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],o=$C(e,s);if(t.body.append("model.json",new Blob([JSON.stringify(o)],{type:c2}),"model.json"),e.weightData!=null){const i=ws.join(e.weightData);t.body.append("model.weights.bin",new Blob([i],{type:l2}),"model.weights.bin")}const r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Hu(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async loadModelJSON(){const 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{let i=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?i+=" 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.":i+=" Please make sure the server is serving valid JSON for this request.",new Error(i)}const s=t.modelTopology,o=t.weightsManifest;if(s==null&&o==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return t}async load(){if(this.loadOptions.streamWeights)return this.loadStream();const e=await this.loadModelJSON();return kC(e,t=>this.loadWeights(t))}async loadStream(){const e=await this.loadModelJSON(),t=await this.getWeightUrls(e.weightsManifest),s=Yf(e.weightsManifest),o=()=>a2(t,this.loadOptions);return Object.assign(Object.assign({},e),{weightSpecs:s,getWeightStream:o})}async getWeightUrls(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[s,o]=u2(t),r=this.weightPathPrefix||s,i=[],a=[];for(const l of e)for(const c of l.paths)this.weightUrlConverter!=null?a.push(this.weightUrlConverter(c)):i.push(r+c+o);return this.weightUrlConverter&&i.push(...await Promise.all(a)),i}async loadWeights(e){const t=await this.getWeightUrls(e),s=Yf(e),o=await i2(t,this.loadOptions);return[s,o]}}zh.URL_SCHEME_REGEX=/^https?:\/\//;function u2(n){const e=n.lastIndexOf("/"),t=n.lastIndexOf("?"),s=n.substring(0,e),o=t>e?n.substring(t):"";return[s+"/",o]}function qm(n){return n.match(zh.URL_SCHEME_REGEX)!=null}const Km=(n,e)=>{if(typeof fetch>"u"&&(e==null||e.fetchFunc==null))return null;{let t=!0;if(Array.isArray(n)?t=n.every(s=>qm(s)):t=qm(n),t)return Xm(n,e)}return null};gt.registerSaveRouter(Km),gt.registerLoadRouter(Km);function Xm(n,e){return new zh(n,e)}function h2(n,e){return Xm(n,e)}function Vh(n,e){const t=n.shape.length,s=e.shape.length;if(t<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${t}.`);if(s<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${s}.`);if(e.dtype!=="int32")throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.shape[s-1]>t)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${e.shape[s-1]} vs. ${t}`);if(H(n.shape)===0)throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${n.shape}.`);const o=e.shape,r=o[o.length-1];let i=1;for(let h=0;hh/c),1].slice(0,r);return[l,i,c,u]}/** + */const u2="application/octet-stream",h2="application/json";class zh{constructor(e,t){if(this.DEFAULT_METHOD="POST",t==null&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.weightUrlConverter=t.weightUrlConverter,t.fetchFunc!=null?($(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=W().platform.fetch,$(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&$(e.length===2,()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`),this.path=e,t.requestInit!=null&&t.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{},this.loadOptions=t}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;const s=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],o=SC(e,s);if(t.body.append("model.json",new Blob([JSON.stringify(o)],{type:h2}),"model.json"),e.weightData!=null){const i=ws.join(e.weightData);t.body.append("model.weights.bin",new Blob([i],{type:u2}),"model.weights.bin")}const r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:qu(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async loadModelJSON(){const 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{let i=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?i+=" 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.":i+=" Please make sure the server is serving valid JSON for this request.",new Error(i)}const s=t.modelTopology,o=t.weightsManifest;if(s==null&&o==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return t}async load(){if(this.loadOptions.streamWeights)return this.loadStream();const e=await this.loadModelJSON();return NC(e,t=>this.loadWeights(t))}async loadStream(){const e=await this.loadModelJSON(),t=await this.getWeightUrls(e.weightsManifest),s=Yf(e.weightsManifest),o=()=>c2(t,this.loadOptions);return Object.assign(Object.assign({},e),{weightSpecs:s,getWeightStream:o})}async getWeightUrls(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[s,o]=d2(t),r=this.weightPathPrefix||s,i=[],a=[];for(const l of e)for(const c of l.paths)this.weightUrlConverter!=null?a.push(this.weightUrlConverter(c)):i.push(r+c+o);return this.weightUrlConverter&&i.push(...await Promise.all(a)),i}async loadWeights(e){const t=await this.getWeightUrls(e),s=Yf(e),o=await l2(t,this.loadOptions);return[s,o]}}zh.URL_SCHEME_REGEX=/^https?:\/\//;function d2(n){const e=n.lastIndexOf("/"),t=n.lastIndexOf("?"),s=n.substring(0,e),o=t>e?n.substring(t):"";return[s+"/",o]}function Km(n){return n.match(zh.URL_SCHEME_REGEX)!=null}const Xm=(n,e)=>{if(typeof fetch>"u"&&(e==null||e.fetchFunc==null))return null;{let t=!0;if(Array.isArray(n)?t=n.every(s=>Km(s)):t=Km(n),t)return Ym(n,e)}return null};gt.registerSaveRouter(Xm),gt.registerLoadRouter(Xm);function Ym(n,e){return new zh(n,e)}function p2(n,e){return Ym(n,e)}function Vh(n,e){const t=n.shape.length,s=e.shape.length;if(t<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${t}.`);if(s<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${s}.`);if(e.dtype!=="int32")throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.shape[s-1]>t)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${e.shape[s-1]} vs. ${t}`);if(H(n.shape)===0)throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${n.shape}.`);const o=e.shape,r=o[o.length-1];let i=1;for(let h=0;hh/c),1].slice(0,r);return[l,i,c,u]}/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3518,7 +3518,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Wh=-2,d2=-1;function Uh(n,e,t){const s=n.shape.length;$(s===e.length,()=>`Error in slice${s}D: Length of begin ${e} must match the rank of the array (${s}).`),$(s===t.length,()=>`Error in slice${s}D: Length of size ${t} must match the rank of the array (${s}).`);for(let o=0;o`Error in slice${s}D: begin[${o}] + size[${o}] (${e[o]+t[o]}) would overflow input.shape[${o}] (${n.shape[o]})`)}function p2(n){const e=[];let t=0;for(;n>0;)n&1&&e.push(t),n/=2,t++;return e}function Gh(n,e,t){const s=[];for(let o=0;o0){const p=e[0],f=t+1;u=Jm(i,p,f,s,n),h=eg(a,p,f,o,n),d=Ym(r,p,f,n)}else for(let p=0;p-1)r[a]=0;else{const l=Zm(e,t,a);let c=s[l];n&1<-1)r[a]=Number.MAX_SAFE_INTEGER;else{const l=Zm(e,t,a);let c=s[l];n&1<0?i=Number.MIN_SAFE_INTEGER:i=Number.MAX_SAFE_INTEGER);const l=s[o];return i<0&&(i+=l),i=Us(0,i,l-1),i}function sg(n,e,t,s,o,r){let i=e[o];const a=t[o]||1;(n&1<0?i=Number.MAX_SAFE_INTEGER:i=Number.MIN_SAFE_INTEGER);const l=s[o];return i<0&&(i+=l),a>0?i=Us(0,i,l):i=Us(-1,i,l-1),i}function Hh(n,e,t){let s=t.length;for(let o=0;o1){s=o;break}for(let o=s+1;o0||t[o]!==n[o])return!1;return!0}function jh(n,e){let t=n.length>0?n[n.length-1]:1;for(let s=0;s{$(i!==-1,()=>"slice() does not support negative begin indexing.")});let r;return t==null?r=new Array(o).fill(-1):typeof t=="number"?r=[t,...new Array(o-1).fill(-1)]:t.lengthi>=0?i:($(i===-1,()=>`Negative size values should be exactly -1 but got ${i} for the slice() size at index ${a}.`),n.shape[a]-s[a])),[s,r]}function qh(n,e,t,s,o,r,i,a,l){let c;if(s==null?(c=new Array(e.length),c.fill(1)):c=s,i!=null&&i&i-1)throw new Error("Multiple ellipses in slice is not allowed.");let u=!1;const h={dims:c.length,numAddAxisAfterEllipsis:0,begin:e.slice(),end:t.slice(),strides:c.slice(),beginMask:o,endMask:r,ellipsisMask:i,newAxisMask:a,shrinkAxisMask:l};for(let w=0;w0?0:-1,d.strides[w]>0?C:C-1];if(y&&d.strides[w]<=0)throw Error("only stride 1 allowed on non-range indexing.");g=g&&d.strides[w]===1;const k=!!(d.beginMask&1<=C)throw Error(`slice index ${d.begin[w]} of dimension ${w} out of bounds.`)}else d.begin[w]=og(d.begin[w],0,d.strides[w],C,I,v),d.end[w]=og(d.end[w],1,d.strides[w],C,I,v);const E=d.strides[w]===1&&d.begin[w]===0&&d.end[w]===C;p=p&&E,f=f&&(w===0&&d.strides[w]===1||E)}else p=p&&d.strides[w]===1&&k,f=f&&(w===0&&d.strides[w]===1||k);let S,T=!1;if(d.beginValid&&d.endValid?(S=d.end[w]-d.begin[w],T=!0):y?(S=1,T=!0):k&&C>=0&&(d.strides[w]<0?S=-C:S=C,T=!0),T){let E;S===0||S<0!=d.strides[w]<0?E=0:E=Math.trunc(S/d.strides[w])+(S%d.strides[w]!==0?1:0),m.push(E)}else m.push(-1)}for(let w=0;w=0?x.push(m[y]):y===Wh&&x.push(1)}return{finalShapeSparse:x.filter((w,y)=>d.finalShapeGatherIndices[y]!==Wh),finalShape:x,isIdentity:p,sliceDim0:f,isSimpleSlice:g,begin:d.begin,end:d.end,strides:d.strides}}function m2(n,e){e.beginMask=0,e.endMask=0,e.shrinkAxisMask=0;let t=0;e.beginValid=n.begin!=null,e.endValid=n.end!=null,e.begin=new Array(e.dims),e.end=new Array(e.dims),e.strides=new Array(e.dims),e.finalShapeGatherIndices=[],e.finalShapeGatherIndicesSparse=[],e.inputShapeGatherIndicesSparse=new Array(e.dims);for(let s=0;s0?r[e]:r[e+1&1];{const i=n<0?s+n:n;return ir[1]?r[1]:i}}var g2=Object.freeze({__proto__:null,assertParamsValid:Uh,computeFlatOffset:jh,computeOutShape:Gh,getNormalizedAxes:f2,isSliceContinous:Hh,maskToAxes:p2,parseSliceParams:El,sliceInfo:qh,startForAxis:ng,startIndicesWithElidedDims:Jm,stopForAxis:sg,stopIndicesWithElidedDims:eg,stridesForAxis:tg,stridesWithElidedDims:Ym});/** + */const Wh=-2,f2=-1;function Uh(n,e,t){const s=n.shape.length;$(s===e.length,()=>`Error in slice${s}D: Length of begin ${e} must match the rank of the array (${s}).`),$(s===t.length,()=>`Error in slice${s}D: Length of size ${t} must match the rank of the array (${s}).`);for(let o=0;o`Error in slice${s}D: begin[${o}] + size[${o}] (${e[o]+t[o]}) would overflow input.shape[${o}] (${n.shape[o]})`)}function m2(n){const e=[];let t=0;for(;n>0;)n&1&&e.push(t),n/=2,t++;return e}function Gh(n,e,t){const s=[];for(let o=0;o0){const p=e[0],f=t+1;u=eg(i,p,f,s,n),h=tg(a,p,f,o,n),d=Zm(r,p,f,n)}else for(let p=0;p-1)r[a]=0;else{const l=Qm(e,t,a);let c=s[l];n&1<-1)r[a]=Number.MAX_SAFE_INTEGER;else{const l=Qm(e,t,a);let c=s[l];n&1<0?i=Number.MIN_SAFE_INTEGER:i=Number.MAX_SAFE_INTEGER);const l=s[o];return i<0&&(i+=l),i=Us(0,i,l-1),i}function og(n,e,t,s,o,r){let i=e[o];const a=t[o]||1;(n&1<0?i=Number.MAX_SAFE_INTEGER:i=Number.MIN_SAFE_INTEGER);const l=s[o];return i<0&&(i+=l),a>0?i=Us(0,i,l):i=Us(-1,i,l-1),i}function Hh(n,e,t){let s=t.length;for(let o=0;o1){s=o;break}for(let o=s+1;o0||t[o]!==n[o])return!1;return!0}function qh(n,e){let t=n.length>0?n[n.length-1]:1;for(let s=0;s{$(i!==-1,()=>"slice() does not support negative begin indexing.")});let r;return t==null?r=new Array(o).fill(-1):typeof t=="number"?r=[t,...new Array(o-1).fill(-1)]:t.lengthi>=0?i:($(i===-1,()=>`Negative size values should be exactly -1 but got ${i} for the slice() size at index ${a}.`),n.shape[a]-s[a])),[s,r]}function jh(n,e,t,s,o,r,i,a,l){let c;if(s==null?(c=new Array(e.length),c.fill(1)):c=s,i!=null&&i&i-1)throw new Error("Multiple ellipses in slice is not allowed.");let u=!1;const h={dims:c.length,numAddAxisAfterEllipsis:0,begin:e.slice(),end:t.slice(),strides:c.slice(),beginMask:o,endMask:r,ellipsisMask:i,newAxisMask:a,shrinkAxisMask:l};for(let w=0;w0?0:-1,d.strides[w]>0?C:C-1];if(y&&d.strides[w]<=0)throw Error("only stride 1 allowed on non-range indexing.");g=g&&d.strides[w]===1;const k=!!(d.beginMask&1<=C)throw Error(`slice index ${d.begin[w]} of dimension ${w} out of bounds.`)}else d.begin[w]=rg(d.begin[w],0,d.strides[w],C,I,v),d.end[w]=rg(d.end[w],1,d.strides[w],C,I,v);const E=d.strides[w]===1&&d.begin[w]===0&&d.end[w]===C;p=p&&E,f=f&&(w===0&&d.strides[w]===1||E)}else p=p&&d.strides[w]===1&&k,f=f&&(w===0&&d.strides[w]===1||k);let S,T=!1;if(d.beginValid&&d.endValid?(S=d.end[w]-d.begin[w],T=!0):y?(S=1,T=!0):k&&C>=0&&(d.strides[w]<0?S=-C:S=C,T=!0),T){let E;S===0||S<0!=d.strides[w]<0?E=0:E=Math.trunc(S/d.strides[w])+(S%d.strides[w]!==0?1:0),m.push(E)}else m.push(-1)}for(let w=0;w=0?x.push(m[y]):y===Wh&&x.push(1)}return{finalShapeSparse:x.filter((w,y)=>d.finalShapeGatherIndices[y]!==Wh),finalShape:x,isIdentity:p,sliceDim0:f,isSimpleSlice:g,begin:d.begin,end:d.end,strides:d.strides}}function x2(n,e){e.beginMask=0,e.endMask=0,e.shrinkAxisMask=0;let t=0;e.beginValid=n.begin!=null,e.endValid=n.end!=null,e.begin=new Array(e.dims),e.end=new Array(e.dims),e.strides=new Array(e.dims),e.finalShapeGatherIndices=[],e.finalShapeGatherIndicesSparse=[],e.inputShapeGatherIndicesSparse=new Array(e.dims);for(let s=0;s0?r[e]:r[e+1&1];{const i=n<0?s+n:n;return ir[1]?r[1]:i}}var b2=Object.freeze({__proto__:null,assertParamsValid:Uh,computeFlatOffset:qh,computeOutShape:Gh,getNormalizedAxes:g2,isSliceContinous:Hh,maskToAxes:m2,parseSliceParams:Rl,sliceInfo:jh,startForAxis:sg,startIndicesWithElidedDims:eg,stopForAxis:og,stopIndicesWithElidedDims:tg,stridesForAxis:ng,stridesWithElidedDims:Zm});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3533,7 +3533,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class x2{static sgd(e){return new Bh(e)}static momentum(e,t,s=!1){return new Gm(e,t,s)}static rmsprop(e,t=.9,s=0,o=null,r=!1){return new Hm(e,t,s,o,r)}static adam(e=.001,t=.9,s=.999,o=null){return new Wm(e,t,s,o)}static adadelta(e=.001,t=.95,s=null){return new zm(e,t,s)}static adamax(e=.002,t=.9,s=.999,o=null,r=0){return new Um(e,t,s,o,r)}static adagrad(e,t=.1){return new Vm(e,t)}}/** + */class y2{static sgd(e){return new Bh(e)}static momentum(e,t,s=!1){return new Hm(e,t,s)}static rmsprop(e,t=.9,s=0,o=null,r=!1){return new qm(e,t,s,o,r)}static adam(e=.001,t=.9,s=.999,o=null){return new Um(e,t,s,o)}static adadelta(e=.001,t=.95,s=null){return new Vm(e,t,s)}static adamax(e=.002,t=.9,s=.999,o=null,r=0){return new Gm(e,t,s,o,r)}static adagrad(e,t=.1){return new Wm(e,t)}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3548,7 +3548,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Qo=x2;/** + */const Qo=y2;/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3563,7 +3563,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const b2=typeof requestAnimationFrame<"u"?requestAnimationFrame:typeof setImmediate<"u"?setImmediate:n=>n();function rg(){return new Promise(n=>b2(()=>n()))}/** + */const w2=typeof requestAnimationFrame<"u"?requestAnimationFrame:typeof setImmediate<"u"?setImmediate:n=>n();function ig(){return new Promise(n=>w2(()=>n()))}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3593,7 +3593,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */var En;(function(n){n[n.FIRST_DIM_SIZE=0]="FIRST_DIM_SIZE",n[n.VALUE_ROWIDS=1]="VALUE_ROWIDS",n[n.ROW_LENGTHS=2]="ROW_LENGTHS",n[n.ROW_SPLITS=3]="ROW_SPLITS",n[n.ROW_LIMITS=4]="ROW_LIMITS",n[n.ROW_STARTS=5]="ROW_STARTS"})(En||(En={}));function ig(n,e,t){let s=new Array;if(t==null&&e==null)return s;if(e==null)for(;s.length=0)if(a>=0){if(a!==r)throw new Error(`rt input.shape and shape=${e} are incompatible: rt input.shape[${o+n}] = ${r} but shape[${o+n}] = ${a}`)}else s[i]=r}return s}function ag(n){const e={FIRST_DIM_SIZE:En.FIRST_DIM_SIZE,VALUE_ROWIDS:En.VALUE_ROWIDS,ROW_LENGTHS:En.ROW_LENGTHS,ROW_SPLITS:En.ROW_SPLITS,ROW_LIMITS:En.ROW_LIMITS,ROW_STARTS:En.ROW_STARTS},t=[];for(const s of n)if(s in e)t.push(e[s]);else break;return t}function lg(n){return n.length===0?0:n[0]===En.FIRST_DIM_SIZE?n.length-1:n.length}function cg(n,e){if(n==null||e==null)return;const t=n.length,s=e.length;if(t>=s)throw new Error(`defaultValue.shape=${n} and ragged tensor flatValues.shape=${e}, are incompatible: defaultValue.rank = ${t} must be less than ragged tensor input flatValues.rank = ${s})`);for(let o=0;o=0&&i>=0&&r!==1&&r!==i)throw new Error(`defaultValue.shape=${n}, and ragged tensor input flatValues.shape=${e} are incompatible: defaultValue.shape[${o-n.length}] = ${r} but ragged tensor input.flatValues.shape[${o-n.length}] = ${i}`)}}/** + */var En;(function(n){n[n.FIRST_DIM_SIZE=0]="FIRST_DIM_SIZE",n[n.VALUE_ROWIDS=1]="VALUE_ROWIDS",n[n.ROW_LENGTHS=2]="ROW_LENGTHS",n[n.ROW_SPLITS=3]="ROW_SPLITS",n[n.ROW_LIMITS=4]="ROW_LIMITS",n[n.ROW_STARTS=5]="ROW_STARTS"})(En||(En={}));function ag(n,e,t){let s=new Array;if(t==null&&e==null)return s;if(e==null)for(;s.length=0)if(a>=0){if(a!==r)throw new Error(`rt input.shape and shape=${e} are incompatible: rt input.shape[${o+n}] = ${r} but shape[${o+n}] = ${a}`)}else s[i]=r}return s}function lg(n){const e={FIRST_DIM_SIZE:En.FIRST_DIM_SIZE,VALUE_ROWIDS:En.VALUE_ROWIDS,ROW_LENGTHS:En.ROW_LENGTHS,ROW_SPLITS:En.ROW_SPLITS,ROW_LIMITS:En.ROW_LIMITS,ROW_STARTS:En.ROW_STARTS},t=[];for(const s of n)if(s in e)t.push(e[s]);else break;return t}function cg(n){return n.length===0?0:n[0]===En.FIRST_DIM_SIZE?n.length-1:n.length}function ug(n,e){if(n==null||e==null)return;const t=n.length,s=e.length;if(t>=s)throw new Error(`defaultValue.shape=${n} and ragged tensor flatValues.shape=${e}, are incompatible: defaultValue.rank = ${t} must be less than ragged tensor input flatValues.rank = ${s})`);for(let o=0;o=0&&i>=0&&r!==1&&r!==i)throw new Error(`defaultValue.shape=${n}, and ragged tensor input flatValues.shape=${e} are incompatible: defaultValue.shape[${o-n.length}] = ${r} but ragged tensor input.flatValues.shape[${o-n.length}] = ${i}`)}}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3608,7 +3608,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Xh=30;function Rl(n){return n<=Xh?n:Bc(n,Math.floor(Math.sqrt(n)))}/** + */const Xh=30;function Al(n){return n<=Xh?n:zc(n,Math.floor(Math.sqrt(n)))}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3653,7 +3653,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Al=1.7580993408473768,Dl=1.0507009873554805;/** + */const Dl=1.7580993408473768,Fl=1.0507009873554805;/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3683,7 +3683,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function cs(n,e){if(n.length!==e.length)throw new Error(`Cannot merge real and imag arrays of different lengths. real:${n.length}, imag: ${e.length}.`);const t=new Float32Array(n.length*2);for(let s=0;s/g,gg=",",xg="...";function ad(n,e){n=n.replace(/\s/g,"");const t=(n.length-n.replace(y2,"").length)/id.length;if(t<1)throw new Error("Equations without an arrow are not supported.");if(t>1)throw new Error(`Equation must contain exactly one arrow ("${id}").`);const[s,o]=n.split(id);$(s.indexOf(xg)===-1,()=>`The ellipsis notation ("${xg}") is not supported yet.`);const r=s.split(gg),i=r.length;if(e!==i)throw new Error(`Expected ${i} input tensors, received ${e}`);if(i>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const a=[];for(let d=0;df.indexOf(p)!==-1))throw new Error(`Output subscripts contain the label ${p} not present in the input subscripts.`);a.indexOf(p)===-1&&a.push(p)}for(let d=0;do!==-1),{permutationIndices:t,expandDims:s}}function cd(n,e,t){const s=new Array(n);for(let o=0;o`Expected dimension ${s[e[o][i]]} at axis ${i} of input shaped ${JSON.stringify(r)}, but got dimension ${r[i]}`)}}function ud(n,e){const t=n,s=[];let o=0;n.length===0&&t.push(-1),o=n.length+1;for(let i=0;ie===t)}function w2(n,e){const t=[];for(let s=0;s"Number of splits must evenly divide the axis."),s=new Array(e).fill(n.shape[t]/e);else{const o=e.reduce((i,a)=>(a===-1&&(i+=1),i),0);$(o<=1,()=>"There should be only one negative value in split array.");const r=e.indexOf(-1);if(r!==-1){const i=e.reduce((a,l)=>l>0?a+l:a);e[r]=n.shape[t]-i}$(n.shape[t]===e.reduce((i,a)=>i+a),()=>"The sum of sizes must match the size of the axis dimension."),s=e}return s}/** + */const id="->",C2=/->/g,xg=",",bg="...";function ad(n,e){n=n.replace(/\s/g,"");const t=(n.length-n.replace(C2,"").length)/id.length;if(t<1)throw new Error("Equations without an arrow are not supported.");if(t>1)throw new Error(`Equation must contain exactly one arrow ("${id}").`);const[s,o]=n.split(id);$(s.indexOf(bg)===-1,()=>`The ellipsis notation ("${bg}") is not supported yet.`);const r=s.split(xg),i=r.length;if(e!==i)throw new Error(`Expected ${i} input tensors, received ${e}`);if(i>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const a=[];for(let d=0;df.indexOf(p)!==-1))throw new Error(`Output subscripts contain the label ${p} not present in the input subscripts.`);a.indexOf(p)===-1&&a.push(p)}for(let d=0;do!==-1),{permutationIndices:t,expandDims:s}}function cd(n,e,t){const s=new Array(n);for(let o=0;o`Expected dimension ${s[e[o][i]]} at axis ${i} of input shaped ${JSON.stringify(r)}, but got dimension ${r[i]}`)}}function ud(n,e){const t=n,s=[];let o=0;n.length===0&&t.push(-1),o=n.length+1;for(let i=0;ie===t)}function I2(n,e){const t=[];for(let s=0;s"Number of splits must evenly divide the axis."),s=new Array(e).fill(n.shape[t]/e);else{const o=e.reduce((i,a)=>(a===-1&&(i+=1),i),0);$(o<=1,()=>"There should be only one negative value in split array.");const r=e.indexOf(-1);if(r!==-1){const i=e.reduce((a,l)=>l>0?a+l:a);e[r]=n.shape[t]-i}$(n.shape[t]===e.reduce((i,a)=>i+a),()=>"The sum of sizes must match the size of the axis dimension."),s=e}return s}/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3713,8 +3713,8 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function bg(n){return`Received SparseTensor with denseShape[0] = 0 but - indices.shape[0] = ${n}`}function yg(n,e){return`indices(${n}, 0) is invalid: ${e} < 0`}function wg(n,e,t){return`indices(${n}, 0) is invalid: ${e} >= ${t}`}/** + */function yg(n){return`Received SparseTensor with denseShape[0] = 0 but + indices.shape[0] = ${n}`}function wg(n,e){return`indices(${n}, 0) is invalid: ${e} < 0`}function Cg(n,e,t){return`indices(${n}, 0) is invalid: ${e} >= ${t}`}/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3729,8 +3729,8 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Cg(n,e){return`only one output dimension may be -1, not both ${n} and ${e}`}function Ig(n,e){return`size ${n} must be non-negative, not ${e}`}function $g(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function vg(n,e){const t=H(n),s=H(e);return`Input to reshape is a SparseTensor with ${t} - dense values, but the requested shape requires a multiple of ${s}. inputShape=${n} outputShape= ${e}`}function kg(n,e){const t=H(n),s=H(e);return`Input to reshape is a tensor with ${t} dense values, but the requested shape has ${s}. inputShape=${n} outputShape=${e}`}/** + */function Ig(n,e){return`only one output dimension may be -1, not both ${n} and ${e}`}function $g(n,e){return`size ${n} must be non-negative, not ${e}`}function vg(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function kg(n,e){const t=H(n),s=H(e);return`Input to reshape is a SparseTensor with ${t} + dense values, but the requested shape requires a multiple of ${s}. inputShape=${n} outputShape= ${e}`}function Sg(n,e){const t=H(n),s=H(e);return`Input to reshape is a tensor with ${t} dense values, but the requested shape has ${s}. inputShape=${n} outputShape=${e}`}/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3745,7 +3745,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function pd(){return"segment ids must be >= 0"}function Sg(){return"segment ids are not increasing"}function Tg(n,e){return`Segment id ${n} out of range [0, ${e}), possibly because segmentIds input is not sorted.`}function Ng(n,e,t){return`Bad: indices[${n}] == ${e} out of range [0, ${t})`}/** + */function pd(){return"segment ids must be >= 0"}function Tg(){return"segment ids are not increasing"}function Ng(n,e){return`Segment id ${n} out of range [0, ${e}), possibly because segmentIds input is not sorted.`}function Eg(n,e,t){return`Bad: indices[${n}] == ${e} out of range [0, ${t})`}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3760,8 +3760,8 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Eg(n,e){let t=!1,s;for(n<=Xh?(s=n,t=!0):s=Bc(n,Math.floor(Math.sqrt(n)));!t;)s>e||s===n?t=!0:s=Bc(n,s+1);return s}function Rg(n,e,t){const s=[],o=n.length;for(let r=0;ro))throw new Error(`Expect batchDims in the range of [-${o}, ${o}], but got ${s}`);if(s<0&&(s+=o),s>r)throw new Error(`batchDims (${s}) must be less than rank(x) ( - ${r}).`);if(te||s===n?t=!0:s=zc(n,s+1);return s}function Ag(n,e,t){const s=[],o=n.length;for(let r=0;ro))throw new Error(`Expect batchDims in the range of [-${o}, ${o}], but got ${s}`);if(s<0&&(s+=o),s>r)throw new Error(`batchDims (${s}) must be less than rank(x) ( + ${r}).`);if(tys(e))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function Ag(n){return n.map(e=>bs(e))}var I2=Object.freeze({__proto__:null,ERF_A1:ed,ERF_A2:td,ERF_A3:nd,ERF_A4:sd,ERF_A5:od,ERF_P:Jh,PARALLELIZE_THRESHOLD:Xh,get RowPartitionType(){return En},SELU_SCALE:Dl,SELU_SCALEALPHA:Al,applyActivation:Fh,assertAndGetBroadcastShape:we,assertAxesAreInnerMostDims:It,assertParamsConsistent:Kh,assignToTypedArray:pg,axesAreInnerMostDims:ah,calculateShapes:uo,checkEinsumDimSizes:cd,checkPadOnDimRoundingMode:Wt,combineLocations:dm,combineRaggedTensorToTensorShapes:ig,complexWithEvenIndex:hg,complexWithOddIndex:dg,computeConv2DInfo:wt,computeConv3DInfo:Is,computeDefaultPad:Zu,computeDilation2DInfo:bi,computeOptimalWindowSize:Rl,computeOutAndReduceShapes:xt,computeOutShape:Hn,computePool2DInfo:pn,computePool3DInfo:rs,convertConv2DDataFormat:is,decodeEinsumEquation:ad,eitherStridesOrDilationsAreOne:Et,expandShapeToKeepDim:it,exponent:mg,exponents:fg,fromStringArrayToUint8:Ag,fromUint8ToStringArray:us,getAxesPermutation:Ye,getBroadcastDims:Ho,getComplexWithIndex:rd,getEinsumComputePath:ud,getEinsumPermutation:ld,getFusedBiasGradient:Dh,getFusedDyActivation:Ah,getImageCenter:Yh,getInnerMostAxes:tt,getPermuted:Ri,getRaggedRank:lg,getReductionAxes:ct,getReshaped:Ei,getReshapedPermuted:Ai,getRowPartitionTypesHelper:ag,getSliceBeginCoords:Zh,getSliceSize:Qh,getSparseFillEmptyRowsIndicesDenseShapeMismatch:bg,getSparseFillEmptyRowsNegativeIndexErrorMessage:yg,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:wg,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:$g,getSparseReshapeInputOutputMismatchErrorMessage:kg,getSparseReshapeInputOutputMultipleErrorMessage:vg,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:Cg,getSparseReshapeNegativeOutputDimErrorMessage:Ig,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:Ng,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:pd,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:Sg,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:Tg,getUndoAxesPermutation:$s,isIdentityPermutation:hd,log:Lw,mergeRealAndImagArrays:cs,prepareAndValidate:Vh,prepareSplitSize:dd,segment_util:C2,shouldFuse:_h,slice_util:g2,splitRealAndImagArrays:ug,stridesOrDilationsArePositive:oo,tupleValuesAreOne:so,upcastType:Yt,validateDefaultValueShape:cg,validateInput:jk,validateUpdateShape:Am,warn:tn});/** + */function us(n){try{return n.map(e=>ys(e))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function Dg(n){return n.map(e=>bs(e))}var v2=Object.freeze({__proto__:null,ERF_A1:ed,ERF_A2:td,ERF_A3:nd,ERF_A4:sd,ERF_A5:od,ERF_P:Jh,PARALLELIZE_THRESHOLD:Xh,get RowPartitionType(){return En},SELU_SCALE:Fl,SELU_SCALEALPHA:Dl,applyActivation:Fh,assertAndGetBroadcastShape:we,assertAxesAreInnerMostDims:It,assertParamsConsistent:Kh,assignToTypedArray:fg,axesAreInnerMostDims:ah,calculateShapes:ho,checkEinsumDimSizes:cd,checkPadOnDimRoundingMode:Ut,combineLocations:pm,combineRaggedTensorToTensorShapes:ag,complexWithEvenIndex:dg,complexWithOddIndex:pg,computeConv2DInfo:wt,computeConv3DInfo:Is,computeDefaultPad:Qu,computeDilation2DInfo:bi,computeOptimalWindowSize:Al,computeOutAndReduceShapes:xt,computeOutShape:Hn,computePool2DInfo:pn,computePool3DInfo:rs,convertConv2DDataFormat:is,decodeEinsumEquation:ad,eitherStridesOrDilationsAreOne:Et,expandShapeToKeepDim:it,exponent:gg,exponents:mg,fromStringArrayToUint8:Dg,fromUint8ToStringArray:us,getAxesPermutation:Ye,getBroadcastDims:qo,getComplexWithIndex:rd,getEinsumComputePath:ud,getEinsumPermutation:ld,getFusedBiasGradient:Dh,getFusedDyActivation:Ah,getImageCenter:Yh,getInnerMostAxes:tt,getPermuted:Ri,getRaggedRank:cg,getReductionAxes:ct,getReshaped:Ei,getReshapedPermuted:Ai,getRowPartitionTypesHelper:lg,getSliceBeginCoords:Zh,getSliceSize:Qh,getSparseFillEmptyRowsIndicesDenseShapeMismatch:yg,getSparseFillEmptyRowsNegativeIndexErrorMessage:wg,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:Cg,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:vg,getSparseReshapeInputOutputMismatchErrorMessage:Sg,getSparseReshapeInputOutputMultipleErrorMessage:kg,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:Ig,getSparseReshapeNegativeOutputDimErrorMessage:$g,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:Eg,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:pd,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:Tg,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:Ng,getUndoAxesPermutation:$s,isIdentityPermutation:hd,log:Bw,mergeRealAndImagArrays:cs,prepareAndValidate:Vh,prepareSplitSize:dd,segment_util:$2,shouldFuse:_h,slice_util:b2,splitRealAndImagArrays:hg,stridesOrDilationsArePositive:oo,tupleValuesAreOne:so,upcastType:Yt,validateDefaultValueShape:ug,validateInput:Kk,validateUpdateShape:Dm,warn:tn});/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3791,7 +3791,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */r2();/** + */a2();/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3806,7 +3806,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Dg={kernelName:ca,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>F(n,Ni(oe(t,"float32"),-1))}}};/** + */const Fg={kernelName:ca,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>D(n,Ni(oe(t,"float32"),-1))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3821,7 +3821,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const $2={kernelName:wr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const s=je(oe(t,"float32")),o=Lt(ge(Fe(1),s));return nt(me(n,o))}}}};/** + */const k2={kernelName:wr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const s=qe(oe(t,"float32")),o=Rt(ge(Fe(1),s));return nt(me(n,o))}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3836,7 +3836,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const v2={kernelName:Cr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const s=Lt(ge(je(oe(t,"float32")),1));return me(n,s)}}}};/** + */const S2={kernelName:Cr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const s=Rt(ge(qe(oe(t,"float32")),1));return me(n,s)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3851,7 +3851,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const k2={kernelName:Oo,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{let a=n;const l=ct(t.shape,o);return l.length>0&&(a=pe(a,l)),_(a,t.shape)},b:()=>{let a=n;const l=ct(s.shape,o);return l.length>0&&(a=pe(a,l)),_(a,s.shape)}}}};/** + */const T2={kernelName:Lo,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{let a=n;const l=ct(t.shape,o);return l.length>0&&(a=pe(a,l)),_(a,t.shape)},b:()=>{let a=n;const l=ct(s.shape,o);return l.length>0&&(a=pe(a,l)),_(a,s.shape)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3866,7 +3866,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const S2={kernelName:Gc,saveAllInputs:!0,gradFunc:(n,e)=>{const t={};return e.forEach((s,o)=>{t[o]=()=>n.clone()}),t}};/** + */const N2={kernelName:Hc,saveAllInputs:!0,gradFunc:(n,e)=>{const t={};return e.forEach((s,o)=>{t[o]=()=>n.clone()}),t}};/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3881,7 +3881,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const T2={kernelName:ua,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>Ne(t)}}};/** + */const E2={kernelName:ua,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>Ne(t)}}};/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3896,7 +3896,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const N2={kernelName:ha,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>Ne(t)}}};/** + */const R2={kernelName:ha,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>Ne(t)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3911,7 +3911,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const E2={kernelName:Ir,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,Lt(ge(Fe(1),je(oe(t,"float32")))))}}};/** + */const A2={kernelName:Ir,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,Rt(ge(Fe(1),qe(oe(t,"float32")))))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3926,7 +3926,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const R2={kernelName:$r,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const s=Lt(ee(Fe(1),je(oe(t,"float32"))));return me(n,s)}}}};/** + */const D2={kernelName:$r,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const s=Rt(ee(Fe(1),qe(oe(t,"float32"))));return me(n,s)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3941,7 +3941,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const A2={kernelName:Sr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{const a=ee(je(t),je(s));let l=F(n,me(s,a));const c=ct(t.shape,o);return c.length>0&&(l=pe(l,c)),_(l,t.shape)},b:()=>{const a=ee(je(t),je(s));let l=nt(F(n,me(t,a)));const c=ct(s.shape,o);return c.length>0&&(l=pe(l,c)),_(l,s.shape)}}}};/** + */const F2={kernelName:Sr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{const a=ee(qe(t),qe(s));let l=D(n,me(s,a));const c=ct(t.shape,o);return c.length>0&&(l=pe(l,c)),_(l,t.shape)},b:()=>{const a=ee(qe(t),qe(s));let l=nt(D(n,me(t,a)));const c=ct(s.shape,o);return c.length>0&&(l=pe(l,c)),_(l,s.shape)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3956,7 +3956,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const D2={kernelName:vr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,ee(je(oe(t,"float32")),1))}}};/** + */const _2={kernelName:vr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,ee(qe(oe(t,"float32")),1))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3971,7 +3971,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const F2={kernelName:kr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,ge(Fe(1),je(oe(t,"float32"))))}}};/** + */const O2={kernelName:kr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,ge(Fe(1),qe(oe(t,"float32"))))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3986,7 +3986,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _2(n,e,t,s,o,r){const i=N(n,"dy","avgPool3dGrad"),a=N(e,"input","avgPool3dGrad");let l=i,c=a,u=!1;a.rank===4&&(u=!0,l=_(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]]),c=_(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]])),$(l.rank===5,()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`),$(c.rank===5,()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${c.rank}.`),Wt("avgPool3dGrad",o,r);const h={dy:l,input:c},d={filterSize:t,strides:s,pad:o,dimRoundingMode:r},p=D.runKernel(Kc,h,d);return u?_(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}const O2=O({avgPool3dGrad_:_2});/** + */function L2(n,e,t,s,o,r){const i=N(n,"dy","avgPool3dGrad"),a=N(e,"input","avgPool3dGrad");let l=i,c=a,u=!1;a.rank===4&&(u=!0,l=_(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]]),c=_(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]])),$(l.rank===5,()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`),$(c.rank===5,()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${c.rank}.`),Ut("avgPool3dGrad",o,r);const h={dy:l,input:c},d={filterSize:t,strides:s,pad:o,dimRoundingMode:r},p=F.runKernel(Xc,h,d);return u?_(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}const M2=O({avgPool3dGrad_:L2});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4001,7 +4001,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const L2={kernelName:pa,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{filterSize:o,strides:r,pad:i,dimRoundingMode:a}=t;return{x:()=>O2(n,s,o,r,i,a)}}};/** + */const P2={kernelName:pa,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{filterSize:o,strides:r,pad:i,dimRoundingMode:a}=t;return{x:()=>M2(n,s,o,r,i,a)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4016,7 +4016,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function M2(n,e,t,s,o){const r=N(n,"dy","avgPoolGrad"),i=N(e,"input","avgPoolGrad");$(i.rank===r.rank,()=>`Rank of input (${i.rank}) does not match rank of dy (${r.rank})`);let a=i,l=r,c=!1;i.rank===3&&(c=!0,a=_(i,[1,i.shape[0],i.shape[1],i.shape[2]]),l=_(r,[1,r.shape[0],r.shape[1],r.shape[2]])),$(l.rank===4,()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`),$(a.rank===4,()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${a.rank}.`);const u={dy:l,input:a},h={filterSize:t,strides:s,pad:o},d=D.runKernel(qc,u,h);return c?_(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const P2=O({avgPoolGrad_:M2});/** + */function B2(n,e,t,s,o){const r=N(n,"dy","avgPoolGrad"),i=N(e,"input","avgPoolGrad");$(i.rank===r.rank,()=>`Rank of input (${i.rank}) does not match rank of dy (${r.rank})`);let a=i,l=r,c=!1;i.rank===3&&(c=!0,a=_(i,[1,i.shape[0],i.shape[1],i.shape[2]]),l=_(r,[1,r.shape[0],r.shape[1],r.shape[2]])),$(l.rank===4,()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`),$(a.rank===4,()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${a.rank}.`);const u={dy:l,input:a},h={filterSize:t,strides:s,pad:o},d=F.runKernel(Kc,u,h);return c?_(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const z2=O({avgPoolGrad_:B2});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4031,7 +4031,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const B2={kernelName:da,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{filterSize:o,strides:r,pad:i}=t;return{x:()=>P2(n,s,o,r,i)}}};/** + */const V2={kernelName:da,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{filterSize:o,strides:r,pad:i}=t;return{x:()=>z2(n,s,o,r,i)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4046,7 +4046,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const z2={kernelName:fa,inputsToSave:["a","b"],gradFunc:(n,e,t)=>{const[s,o]=e,{transposeA:r,transposeB:i}=t;return!r&&!i?{a:()=>De(n,o,!1,!0),b:()=>De(s,n,!0,!1)}:!r&&i?{a:()=>De(n,o,!1,!1),b:()=>De(n,s,!0,!1)}:r&&!i?{a:()=>De(o,n,!1,!0),b:()=>De(s,n,!1,!1)}:{a:()=>De(o,n,!0,!0),b:()=>De(n,s,!0,!0)}}};/** + */const W2={kernelName:fa,inputsToSave:["a","b"],gradFunc:(n,e,t)=>{const[s,o]=e,{transposeA:r,transposeB:i}=t;return!r&&!i?{a:()=>De(n,o,!1,!0),b:()=>De(s,n,!0,!1)}:!r&&i?{a:()=>De(n,o,!1,!1),b:()=>De(n,s,!0,!1)}:r&&!i?{a:()=>De(o,n,!1,!0),b:()=>De(s,n,!1,!1)}:{a:()=>De(o,n,!0,!0),b:()=>De(n,s,!0,!0)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4061,7 +4061,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const V2={kernelName:ma,gradFunc:(n,e,t)=>{const{blockShape:s,crops:o}=t;return{x:()=>mh(n,s,o)}}};/** + */const U2={kernelName:ma,gradFunc:(n,e,t)=>{const{blockShape:s,crops:o}=t;return{x:()=>mh(n,s,o)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4076,7 +4076,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const W2={kernelName:Dw,gradFunc:(n,e,t)=>{const s=t,o=s.inputShape,r=s.shape,i=Array.from(r);for(let l=o.length-1;l>=0;l--)if(o[l]===r[l])i[l]=1;else if(o[l]!==1)throw new Error(`broadcastTo(): [${o}] cannot be broadcast to [${r}].`);const a=[];for(let l=0;l1&&a.push(l);return{x:()=>pe(n,a,!0)}}};/** + */const G2={kernelName:Ow,gradFunc:(n,e,t)=>{const s=t,o=s.inputShape,r=s.shape,i=Array.from(r);for(let l=o.length-1;l>=0;l--)if(o[l]===r[l])i[l]=1;else if(o[l]!==1)throw new Error(`broadcastTo(): [${o}] cannot be broadcast to [${r}].`);const a=[];for(let l=0;l1&&a.push(l);return{x:()=>pe(n,a,!0)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4091,7 +4091,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const U2={kernelName:Tr,gradFunc:n=>({x:()=>n.clone()})};/** + */const H2={kernelName:Tr,gradFunc:n=>({x:()=>n.clone()})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4106,7 +4106,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const G2={kernelName:Nr,gradFunc:n=>({x:()=>Ne(n)})};/** + */const q2={kernelName:Nr,gradFunc:n=>({x:()=>Ne(n)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4121,7 +4121,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const H2={kernelName:Er,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{clipValueMin:o,clipValueMax:r}=t;return{x:()=>Ct(as(io(s,o),qo(s,r)),n,Ne(n))}}};/** + */const j2={kernelName:Er,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{clipValueMin:o,clipValueMax:r}=t;return{x:()=>Ct(as(ao(s,o),jo(s,r)),n,Ne(n))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4136,7 +4136,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const j2={kernelName:ga,inputsToSave:["x"],gradFunc:Dg.gradFunc};/** + */const K2={kernelName:ga,inputsToSave:["x"],gradFunc:Fg.gradFunc};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4151,7 +4151,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const q2={kernelName:xa,saveAllInputs:!0,gradFunc:(n,e,t)=>{const s=e.map(l=>l.shape),{axis:o}=t,r=$e(o,e[0].shape)[0],i=s.map(l=>l[r]);return sn(n,i,r).map(l=>()=>l)}};/** + */const X2={kernelName:xa,saveAllInputs:!0,gradFunc:(n,e,t)=>{const s=e.map(l=>l.shape),{axis:o}=t,r=$e(o,e[0].shape)[0],i=s.map(l=>l[r]);return sn(n,i,r).map(l=>()=>l)}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4166,7 +4166,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const K2={kernelName:ba,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const[s,o]=e,{dilations:r,strides:i,pad:a,dataFormat:l}=t;return $(so(r),()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`),{x:()=>nh(s.shape,n,o,i,a,l),filter:()=>Rh(s,n,o.shape,i,a,l)}}};/** + */const Y2={kernelName:ba,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const[s,o]=e,{dilations:r,strides:i,pad:a,dataFormat:l}=t;return $(so(r),()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`),{x:()=>nh(s.shape,n,o,i,a,l),filter:()=>Rh(s,n,o.shape,i,a,l)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4181,7 +4181,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const X2={kernelName:ya,inputsToSave:["dy","filter"],gradFunc:(n,e,t)=>{const[s,o]=e,{strides:r,pad:i,dataFormat:a,dimRoundingMode:l}=t;return{dy:()=>ro(n,o,r,i,a,1,l),filter:()=>Rh(n,s,o.shape,r,i,a,l)}}};/** + */const Z2={kernelName:ya,inputsToSave:["dy","filter"],gradFunc:(n,e,t)=>{const[s,o]=e,{strides:r,pad:i,dataFormat:a,dimRoundingMode:l}=t;return{dy:()=>ro(n,o,r,i,a,1,l),filter:()=>Rh(n,s,o.shape,r,i,a,l)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4196,7 +4196,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Y2(n,e,t,s,o){let r=n;n.rank===4&&(r=_(n,[1,n.shape[0],n.shape[1],n.shape[2],n.shape[3]]));let i=e;i.rank===4&&(i=_(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]])),$(r.rank===5,()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${r.shape}.`),$(i.rank===5,()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${i.shape}.`),$(t.length===5,()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${t}.`),$(r.shape[4]===t[3],()=>`Error in conv3dDerFilter: depth of input ${r.shape[4]}) must match input depth in filter (${t[3]}.`),$(i.shape[4]===t[4],()=>`Error in conv3dDerFilter: depth of dy (${i.shape[4]}) must match output depth for filter (${t[4]}).`);const a={x:r,dy:i},l={strides:s,pad:o,filterShape:t};return D.runKernel(Jc,a,l)}const Z2=O({conv3DBackpropFilter_:Y2});/** + */function Q2(n,e,t,s,o){let r=n;n.rank===4&&(r=_(n,[1,n.shape[0],n.shape[1],n.shape[2],n.shape[3]]));let i=e;i.rank===4&&(i=_(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]])),$(r.rank===5,()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${r.shape}.`),$(i.rank===5,()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${i.shape}.`),$(t.length===5,()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${t}.`),$(r.shape[4]===t[3],()=>`Error in conv3dDerFilter: depth of input ${r.shape[4]}) must match input depth in filter (${t[3]}.`),$(i.shape[4]===t[4],()=>`Error in conv3dDerFilter: depth of dy (${i.shape[4]}) must match output depth for filter (${t[4]}).`);const a={x:r,dy:i},l={strides:s,pad:o,filterShape:t};return F.runKernel(eu,a,l)}const J2=O({conv3DBackpropFilter_:Q2});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4211,7 +4211,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Q2={kernelName:wa,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const{dilations:s,strides:o,pad:r}=t;$(so(s),()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);const[i,a]=e;return{x:()=>lm(i.shape,n,a,o,r),filter:()=>Z2(i,n,a.shape,o,r)}}};/** + */const eT={kernelName:wa,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const{dilations:s,strides:o,pad:r}=t;$(so(s),()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);const[i,a]=e;return{x:()=>lm(i.shape,n,a,o,r),filter:()=>J2(i,n,a.shape,o,r)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4226,7 +4226,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const J2={kernelName:Rr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>F(nt(Tm(oe(t,"float32"))),n)}}};/** + */const tT={kernelName:Rr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>D(nt(Nm(oe(t,"float32"))),n)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4241,7 +4241,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const eT={kernelName:Ar,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>F(Nm(oe(t,"float32")),n)}}};/** + */const nT={kernelName:Ar,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>D(Em(oe(t,"float32")),n)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4256,7 +4256,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const tT={kernelName:Ca,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{axis:o,exclusive:r,reverse:i}=t;return{x:()=>{const a=Ye([o],s.rank);let l=um(n,o,r,!i);return a!=null&&(l=Ee(l,a)),l}}}};/** + */const sT={kernelName:Ca,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{axis:o,exclusive:r,reverse:i}=t;return{x:()=>{const a=Ye([o],s.rank);let l=um(n,o,r,!i);return a!=null&&(l=Ee(l,a)),l}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4271,7 +4271,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const nT={kernelName:Ia,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const{dilations:s,strides:o,pad:r,dimRoundingMode:i}=t,a=s??[1,1];$(so(a),()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${a}'`);const[l,c]=e;return $(l.rank===4,()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`),$(c.rank===4,()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${c.rank}.`),$(l.shape[3]===c.shape[2],()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${c.shape[2]}.`),$(Et(o,a),()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${a}'.`),Wt("depthwiseConv2d",r,i),{x:()=>dS(l.shape,n,c,o,r,a,i),filter:()=>uS(l,n,c.shape,o,r,a,i)}}};/** + */const oT={kernelName:Ia,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const{dilations:s,strides:o,pad:r,dimRoundingMode:i}=t,a=s??[1,1];$(so(a),()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${a}'`);const[l,c]=e;return $(l.rank===4,()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`),$(c.rank===4,()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${c.rank}.`),$(l.shape[3]===c.shape[2],()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${c.shape[2]}.`),$(Et(o,a),()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${a}'.`),Ut("depthwiseConv2d",r,i),{x:()=>fS(l.shape,n,c,o,r,a,i),filter:()=>dS(l,n,c.shape,o,r,a,i)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4286,7 +4286,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const sT={kernelName:$a,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const[s,o]=e,r={x:s,filter:o,dy:n},i={x:s,filter:o,dy:n};return{x:()=>D.runKernel(au,r,t),filter:()=>D.runKernel(lu,i,t)}}};/** + */const rT={kernelName:$a,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const[s,o]=e,r={x:s,filter:o,dy:n},i={x:s,filter:o,dy:n};return{x:()=>F.runKernel(lu,r,t),filter:()=>F.runKernel(cu,i,t)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4301,7 +4301,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const oT={kernelName:Fr,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e,s={dy:n,y:t};return{x:()=>D.runKernel(uu,s)}}};/** + */const iT={kernelName:Fr,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e,s={dy:n,y:t};return{x:()=>F.runKernel(hu,s)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4316,7 +4316,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const rT={kernelName:_r,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e,s=F(Vn(nt(je(t))),2/Math.sqrt(Math.PI));return{x:()=>F(n,s)}}};/** + */const aT={kernelName:_r,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e,s=D(Vn(nt(qe(t))),2/Math.sqrt(Math.PI));return{x:()=>D(n,s)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4331,7 +4331,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const iT={kernelName:Or,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e;return{x:()=>F(n,t)}}};/** + */const lT={kernelName:Or,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e;return{x:()=>D(n,t)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4346,7 +4346,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const aT={kernelName:ka,inputsToSave:["input"],gradFunc:(n,e)=>{const[t]=e;return{input:()=>_(n,t.shape)}}};/** + */const cT={kernelName:ka,inputsToSave:["input"],gradFunc:(n,e)=>{const[t]=e;return{input:()=>_(n,t.shape)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4361,7 +4361,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const lT={kernelName:Lr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>F(n,Vn(t))}}};/** + */const uT={kernelName:Lr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>D(n,Vn(t))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4376,7 +4376,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const cT={kernelName:Mr,gradFunc:n=>({x:()=>Ne(n)})};/** + */const hT={kernelName:Mr,gradFunc:n=>({x:()=>Ne(n)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4391,7 +4391,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const uT={kernelName:Pr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{const a=me(n,oe(s,"float32")),l=ct(t.shape,o);return l.length>0?_(pe(a,l),t.shape):a},b:()=>{let a=F(n,oe(t,"float32"));const l=ct(s.shape,o);l.length>0&&(a=_(pe(a,l),s.shape));const c=je(s);return nt(me(a,oe(c,"float32")))}}}};/** + */const dT={kernelName:Pr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{const a=me(n,oe(s,"float32")),l=ct(t.shape,o);return l.length>0?_(pe(a,l),t.shape):a},b:()=>{let a=D(n,oe(t,"float32"));const l=ct(s.shape,o);l.length>0&&(a=_(pe(a,l),s.shape));const c=qe(s);return nt(me(a,oe(c,"float32")))}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4406,7 +4406,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const hT={kernelName:Sa,inputsToSave:["x","mean","variance","scale"],gradFunc:(n,e,t)=>{const{varianceEpsilon:s}=t,[o,r,i,a]=e,l=a??Fe(1),c=ct(r.shape,o.shape),u=[];if(r.rank===1){for(let y=0;yr.rank===1?_(F(F(n,Tn(_(p,[1,1,1,r.shape[0]]),u)),l),o.shape):_(F(F(n,p),l),o.shape),mean:()=>{let y=F(F(p,Fe(-1)),d);return r.rank===1&&(y=pe(y,c)),_(y,r.shape)},variance:()=>{let y=F(F(f,h),d);return r.rank===1&&(y=pe(y,c)),_(y,r.shape)},scale:()=>{const y=F(h,p);let C=F(n,y);return r.rank===1&&(C=pe(C,c)),_(C,r.shape)},offset:()=>{let y=n;return r.rank===1&&(y=pe(y,c)),_(y,r.shape)}}}};/** + */const pT={kernelName:Sa,inputsToSave:["x","mean","variance","scale"],gradFunc:(n,e,t)=>{const{varianceEpsilon:s}=t,[o,r,i,a]=e,l=a??Fe(1),c=ct(r.shape,o.shape),u=[];if(r.rank===1){for(let y=0;yr.rank===1?_(D(D(n,Tn(_(p,[1,1,1,r.shape[0]]),u)),l),o.shape):_(D(D(n,p),l),o.shape),mean:()=>{let y=D(D(p,Fe(-1)),d);return r.rank===1&&(y=pe(y,c)),_(y,r.shape)},variance:()=>{let y=D(D(f,h),d);return r.rank===1&&(y=pe(y,c)),_(y,r.shape)},scale:()=>{const y=D(h,p);let C=D(n,y);return r.rank===1&&(C=pe(C,c)),_(C,r.shape)},offset:()=>{let y=n;return r.rank===1&&(y=pe(y,c)),_(y,r.shape)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4421,7 +4421,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const dT={kernelName:Ta,inputsToSave:["x","indices"],gradFunc:(n,e,t)=>{const[s,o]=e,{axis:r,batchDims:i}=t,a=$e(r,s.shape)[0],l=(c,u,h)=>()=>{const d=c.shape,p=u.size,f=d.slice(0,a),g=f.length,m=d.slice(r,d.length).slice(1),x=m.length,b=Fg(0,g),w=Fg(g+1,g+1+x),y=_g([f,[p],m]),C=_(h,y),I=_(u,[p]),v=_g([[g],b,w]),k=Ee(C,v);let S=Fm(k,I,c.shape[a]);const T=$s(v);return S=Ee(S,T),S};if(i===1){const c=s.shape[0],u=s.split(c,0);return{x:()=>Un(u.map((p,f)=>l(p,o.slice(f,1),n.slice(f,1))())).reshape(s.shape),indices:()=>o}}else return{x:l(s,o,n),indices:()=>o}}};function Fg(n,e){const t=[];for(let s=n;s{const[s,o]=e,{axis:r,batchDims:i}=t,a=$e(r,s.shape)[0],l=(c,u,h)=>()=>{const d=c.shape,p=u.size,f=d.slice(0,a),g=f.length,m=d.slice(r,d.length).slice(1),x=m.length,b=_g(0,g),w=_g(g+1,g+1+x),y=Og([f,[p],m]),C=_(h,y),I=_(u,[p]),v=Og([[g],b,w]),k=Ee(C,v);let S=_m(k,I,c.shape[a]);const T=$s(v);return S=Ee(S,T),S};if(i===1){const c=s.shape[0],u=s.split(c,0);return{x:()=>Un(u.map((p,f)=>l(p,o.slice(f,1),n.slice(f,1))())).reshape(s.shape),indices:()=>o}}else return{x:l(s,o,n),indices:()=>o}}};function _g(n,e){const t=[];for(let s=n;s{const[t,s]=e;return{a:()=>Ne(t),b:()=>Ne(s)}}};/** + */const mT={kernelName:Br,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e;return{a:()=>Ne(t),b:()=>Ne(s)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4451,7 +4451,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const fT={kernelName:zr,gradFunc:n=>({x:()=>oe(n,"float32")})};/** + */const gT={kernelName:zr,gradFunc:n=>({x:()=>oe(n,"float32")})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4466,7 +4466,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const mT={kernelName:Vr,gradFunc:n=>({x:()=>Ne(n)})};/** + */const xT={kernelName:Vr,gradFunc:n=>({x:()=>Ne(n)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4481,7 +4481,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const gT={kernelName:Wr,gradFunc:n=>({x:()=>Ne(n)})};/** + */const bT={kernelName:Wr,gradFunc:n=>({x:()=>Ne(n)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4496,7 +4496,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const xT={kernelName:Ur,gradFunc:n=>({x:()=>Ne(n)})};/** + */const yT={kernelName:Ur,gradFunc:n=>({x:()=>Ne(n)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4511,7 +4511,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const bT={kernelName:Ea,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{alpha:o}=t,r=Zt(s,0);return{x:()=>Ct(r,n,F(n,o))}}};/** + */const wT={kernelName:Ea,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{alpha:o}=t,r=Zt(s,0);return{x:()=>Ct(r,n,D(n,o))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4526,7 +4526,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const yT={kernelName:Hr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,ee(t,1))}}};/** + */const CT={kernelName:Hr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,ee(t,1))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4541,7 +4541,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const wT={kernelName:Gr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,oe(t,"float32"))}}};/** + */const IT={kernelName:Gr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,oe(t,"float32"))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4556,7 +4556,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const CT={kernelName:_w,inputsToSave:[],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s]=e,{axis:o}=t;return{logits:()=>{const i=Vn(s);return ge(n,F(pe(n,o,!0),i))}}}};/** + */const $T={kernelName:Mw,inputsToSave:[],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s]=e,{axis:o}=t;return{logits:()=>{const i=Vn(s);return ge(n,D(pe(n,o,!0),i))}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4571,7 +4571,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function IT(n,e,t,s=5,o=1,r=1,i=.5){const a={x:n,y:e,dy:t},l={depthRadius:s,bias:o,alpha:r,beta:i};return D.runKernel(gu,a,l)}const $T=O({localResponseNormalizationBackprop_:IT});/** + */function vT(n,e,t,s=5,o=1,r=1,i=.5){const a={x:n,y:e,dy:t},l={depthRadius:s,bias:o,alpha:r,beta:i};return F.runKernel(xu,a,l)}const kT=O({localResponseNormalizationBackprop_:vT});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4586,7 +4586,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const vT={kernelName:Oa,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s,o]=e,{depthRadius:r,bias:i,alpha:a,beta:l}=t;return{x:()=>$T(s,o,n,r,i,a,l)}}};/** + */const ST={kernelName:Oa,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s,o]=e,{depthRadius:r,bias:i,alpha:a,beta:l}=t;return{x:()=>kT(s,o,n,r,i,a,l)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4601,7 +4601,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Og(n,e,t,s){return e.rankF(n,oe(zn(t,e),n.dtype))}}/** + */function Lg(n,e,t,s){return e.rankD(n,oe(zn(t,e),n.dtype))}}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4616,7 +4616,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Lg={kernelName:La,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const s=t,{reductionIndices:o}=s,r=e[0],i=e[1],a=$e(o,r.shape),l=Og(n,i,r,a);return{x:()=>l.x()}}};/** + */const Mg={kernelName:La,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const s=t,{reductionIndices:o}=s,r=e[0],i=e[1],a=$e(o,r.shape),l=Lg(n,i,r,a);return{x:()=>l.x()}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4631,7 +4631,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const kT={kernelName:jr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e;return{a:()=>F(n,oe(io(t,s),"float32")),b:()=>F(n,oe(kl(t,s),"float32"))}}};/** + */const TT={kernelName:qr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e;return{a:()=>D(n,oe(ao(t,s),"float32")),b:()=>D(n,oe(Sl(t,s),"float32"))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4646,7 +4646,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ST(n,e,t,s,o,r,i){const a=N(n,"dy","maxPool3dGrad"),l=N(e,"input","maxPool3dGrad"),c=N(t,"output","maxPool3dGrad");let u=a,h=l,d=c,p=!1;l.rank===4&&(p=!0,u=_(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]]),h=_(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),d=_(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),$(u.rank===5,()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`),$(h.rank===5,()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${h.rank}.`),$(d.rank===5,()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${d.rank}.`),Wt("maxPool3dGrad",r,i);const f={dy:u,input:h,output:d},g={filterSize:s,strides:o,pad:r,dimRoundingMode:i},m=D.runKernel(bu,f,g);return p?_(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}const TT=O({maxPool3dGrad_:ST});/** + */function NT(n,e,t,s,o,r,i){const a=N(n,"dy","maxPool3dGrad"),l=N(e,"input","maxPool3dGrad"),c=N(t,"output","maxPool3dGrad");let u=a,h=l,d=c,p=!1;l.rank===4&&(p=!0,u=_(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]]),h=_(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),d=_(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),$(u.rank===5,()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`),$(h.rank===5,()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${h.rank}.`),$(d.rank===5,()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${d.rank}.`),Ut("maxPool3dGrad",r,i);const f={dy:u,input:h,output:d},g={filterSize:s,strides:o,pad:r,dimRoundingMode:i},m=F.runKernel(yu,f,g);return p?_(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}const ET=O({maxPool3dGrad_:NT});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4661,7 +4661,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const NT={kernelName:Pa,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s,o]=e,{filterSize:r,strides:i,pad:a,dimRoundingMode:l}=t;return{x:()=>TT(n,s,o,r,i,a,l)}}};/** + */const RT={kernelName:Pa,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s,o]=e,{filterSize:r,strides:i,pad:a,dimRoundingMode:l}=t;return{x:()=>ET(n,s,o,r,i,a,l)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4676,7 +4676,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ET(n,e,t,s,o,r,i){const a=N(n,"dy","maxPoolGrad"),l=N(e,"input","maxPoolGrad"),c=N(t,"output","maxPoolGrad");$(l.rank===a.rank,()=>`Rank of input (${l.rank}) does not match rank of dy (${a.rank})`),$(a.rank===4,()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${a.rank}.`),$(l.rank===4,()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`),Wt("maxPoolGrad",r,i);const u={dy:a,input:l,output:c},h={filterSize:s,strides:o,pad:r,dimRoundingMode:i};return D.runKernel(xu,u,h)}const RT=O({maxPoolGrad_:ET});/** + */function AT(n,e,t,s,o,r,i){const a=N(n,"dy","maxPoolGrad"),l=N(e,"input","maxPoolGrad"),c=N(t,"output","maxPoolGrad");$(l.rank===a.rank,()=>`Rank of input (${l.rank}) does not match rank of dy (${a.rank})`),$(a.rank===4,()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${a.rank}.`),$(l.rank===4,()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`),Ut("maxPoolGrad",r,i);const u={dy:a,input:l,output:c},h={filterSize:s,strides:o,pad:r,dimRoundingMode:i};return F.runKernel(bu,u,h)}const DT=O({maxPoolGrad_:AT});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4691,7 +4691,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const AT={kernelName:Ma,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s,o]=e,{filterSize:r,strides:i,pad:a}=t;return{x:()=>RT(n,s,o,r,i,a)}}};/** + */const FT={kernelName:Ma,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s,o]=e,{filterSize:r,strides:i,pad:a}=t;return{x:()=>DT(n,s,o,r,i,a)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4706,7 +4706,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const DT={kernelName:Ba,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{axis:o}=t,r=$e(o,s.shape),a=xt(s.shape,r)[1],l=H(a);return{x:()=>{const u=s.shape.slice();r.forEach(p=>{u[p]=1});const h=_(n,u);return me(F(h,Nn(s.shape,"float32")),l)}}}};/** + */const _T={kernelName:Ba,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{axis:o}=t,r=$e(o,s.shape),a=xt(s.shape,r)[1],l=H(a);return{x:()=>{const u=s.shape.slice();r.forEach(p=>{u[p]=1});const h=_(n,u);return me(D(h,Nn(s.shape,"float32")),l)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4721,7 +4721,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const FT={kernelName:za,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const s=t,{axis:o}=s,[r,i]=e,a=$e(o,r.shape),l=Og(n,i,r,a);return{x:()=>l.x()}}};/** + */const OT={kernelName:za,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const s=t,{axis:o}=s,[r,i]=e,a=$e(o,r.shape),l=Lg(n,i,r,a);return{x:()=>l.x()}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4736,7 +4736,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const _T={kernelName:qr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e;return{a:()=>F(n,oe(qo(t,s),"float32")),b:()=>F(n,oe(Zt(t,s),"float32"))}}};/** + */const LT={kernelName:jr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e;return{a:()=>D(n,oe(jo(t,s),"float32")),b:()=>D(n,oe(Zt(t,s),"float32"))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4751,7 +4751,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const OT={kernelName:Va,inputsToSave:["x"],gradFunc:(n,e,t)=>{const s=e[0],{paddings:o}=t,r=o.map(i=>i[0]);return{x:()=>We(n,r,s.shape)}}};/** + */const MT={kernelName:Va,inputsToSave:["x"],gradFunc:(n,e,t)=>{const s=e[0],{paddings:o}=t,r=o.map(i=>i[0]);return{x:()=>We(n,r,s.shape)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4766,7 +4766,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const LT={kernelName:Kr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{const a=ct(t.shape,o);return a.length>0?_(pe(n,a),t.shape):n},b:()=>{const a=F(n,nt(vl(me(t,s)))),l=ct(s.shape,o);return l.length>0?_(pe(a,l),s.shape):a}}}};/** + */const PT={kernelName:Kr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{const a=ct(t.shape,o);return a.length>0?_(pe(n,a),t.shape):n},b:()=>{const a=D(n,nt(kl(me(t,s)))),l=ct(s.shape,o);return l.length>0?_(pe(a,l),s.shape):a}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4781,7 +4781,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const MT={kernelName:Xr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{const a=F(n,oe(s,"float32")),l=ct(t.shape,o);return l.length>0?_(pe(a,l),t.shape):a},b:()=>{const a=F(n,oe(t,"float32")),l=ct(s.shape,o);return l.length>0?_(pe(a,l),s.shape):a}}}};/** + */const BT={kernelName:Xr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{const a=D(n,oe(s,"float32")),l=ct(t.shape,o);return l.length>0?_(pe(a,l),t.shape):a},b:()=>{const a=D(n,oe(t,"float32")),l=ct(s.shape,o);return l.length>0?_(pe(a,l),s.shape):a}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4796,7 +4796,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const PT={kernelName:Wa,gradFunc:n=>({x:()=>nt(n)})};/** + */const zT={kernelName:Wa,gradFunc:n=>({x:()=>nt(n)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4811,7 +4811,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const BT={kernelName:Ha,inputsToSave:["indices"],gradFunc:(n,e)=>{const t=e[0];return{indices:()=>st(t.shape,"float32")}}};/** + */const VT={kernelName:Ha,inputsToSave:["indices"],gradFunc:(n,e)=>{const t=e[0];return{indices:()=>st(t.shape,"float32")}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4826,7 +4826,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const zT={kernelName:Ga,gradFunc:n=>({x:()=>Ne(n)})};/** + */const WT={kernelName:Ga,gradFunc:n=>({x:()=>Ne(n)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4841,7 +4841,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const VT={kernelName:ja,saveAllInputs:!0,gradFunc:(n,e,t)=>{const{axis:s}=t;return Gn(n,s).map(r=>()=>r)}};/** + */const UT={kernelName:qa,saveAllInputs:!0,gradFunc:(n,e,t)=>{const{axis:s}=t;return Gn(n,s).map(r=>()=>r)}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4856,7 +4856,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Mg={kernelName:qa,inputsToSave:["x"],gradFunc:(n,e,t)=>{const s=e[0],{paddings:o}=t,r=o.map(i=>i[0]);return{x:()=>We(n,r,s.shape)}}};/** + */const Pg={kernelName:ja,inputsToSave:["x"],gradFunc:(n,e,t)=>{const s=e[0],{paddings:o}=t,r=o.map(i=>i[0]);return{x:()=>We(n,r,s.shape)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4871,7 +4871,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const WT={kernelName:Yr,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(n,e)=>{const[t,s,o]=e,r=t,i=s,a=we(r.shape,i.shape);return{a:()=>{const u=oe(i,"float32");let h=F(n,F(u,jo(r,ge(u,Fe(1)))));const d=ct(r.shape,a);return d.length>0&&(h=pe(h,d)),_(h,r.shape)},b:()=>{const u=Zt(r,0),h=Ct(u,Wn(r),Ne(r));let d=F(n,F(o,h));const p=ct(i.shape,a);return p.length>0&&(d=pe(d,p)),_(d,i.shape)}}}};/** + */const GT={kernelName:Yr,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(n,e)=>{const[t,s,o]=e,r=t,i=s,a=we(r.shape,i.shape);return{a:()=>{const u=oe(i,"float32");let h=D(n,D(u,io(r,ge(u,Fe(1)))));const d=ct(r.shape,a);return d.length>0&&(h=pe(h,d)),_(h,r.shape)},b:()=>{const u=Zt(r,0),h=Ct(u,Wn(r),Ne(r));let d=D(n,D(o,h));const p=ct(i.shape,a);return p.length>0&&(d=pe(d,p)),_(d,i.shape)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4886,7 +4886,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const UT={kernelName:Ka,inputsToSave:["x","alpha"],gradFunc:(n,e)=>{const[t,s]=e,o=Zt(t,0);return{x:()=>Ct(o,n,F(n,s)),alpha:()=>{let r=Ct(o,Ne(n),F(n,t));const i=ct(s.shape,n.shape);return i.length>0&&(r=pe(r,i)),_(r,s.shape)}}}};/** + */const HT={kernelName:Ka,inputsToSave:["x","alpha"],gradFunc:(n,e)=>{const[t,s]=e,o=Zt(t,0);return{x:()=>Ct(o,n,D(n,s)),alpha:()=>{let r=Ct(o,Ne(n),D(n,t));const i=ct(s.shape,n.shape);return i.length>0&&(r=pe(r,i)),_(r,s.shape)}}}};/** * @license * Copyright 2022 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4901,7 +4901,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function GT(n,e,t){const s=n.shape.slice();s[t]=1;const o=_(e,s),r=rh(n,t,!0,!1),i=rh(n,t,!0,!0),a=F(r,i);return F(o,a)}function HT(n,e,t){const s=n.shape.length,o=s-t.length,r=Ye(t,s);let i=n;r!=null&&(i=Ee(n,r));const a=i.shape.slice(),c=a.splice(s-t.length,t.length).reduce((d,p)=>d*p,1);a.push(c);const u=i.reshape(a);let h=GT(u,e,o);if(h=h.reshape(i.shape),r!=null){const d=$s(r);h=Ee(h,d)}return h}const jT={kernelName:Xa,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{axis:o}=t;let r=[];return o==null?r=s.shape.map((i,a)=>a):typeof o=="number"?r=[o]:r=o,{x:()=>HT(s,n,r)}}};/** + */function qT(n,e,t){const s=n.shape.slice();s[t]=1;const o=_(e,s),r=rh(n,t,!0,!1),i=rh(n,t,!0,!0),a=D(r,i);return D(o,a)}function jT(n,e,t){const s=n.shape.length,o=s-t.length,r=Ye(t,s);let i=n;r!=null&&(i=Ee(n,r));const a=i.shape.slice(),c=a.splice(s-t.length,t.length).reduce((d,p)=>d*p,1);a.push(c);const u=i.reshape(a);let h=qT(u,e,o);if(h=h.reshape(i.shape),r!=null){const d=$s(r);h=Ee(h,d)}return h}const KT={kernelName:Xa,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{axis:o}=t;let r=[];return o==null?r=s.shape.map((i,a)=>a):typeof o=="number"?r=[o]:r=o,{x:()=>jT(s,n,r)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4916,7 +4916,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const qT={kernelName:Dr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{const a=me(n,oe(s,"float32")),l=ct(t.shape,o);return l.length>0?_(pe(a,l),t.shape):a},b:()=>{let a=F(n,oe(t,"float32"));const l=ct(s.shape,o);l.length>0&&(a=_(pe(a,l),s.shape));const c=je(s);return nt(me(a,oe(c,"float32")))}}}};/** + */const XT={kernelName:Dr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{const a=me(n,oe(s,"float32")),l=ct(t.shape,o);return l.length>0?_(pe(a,l),t.shape):a},b:()=>{let a=D(n,oe(t,"float32"));const l=ct(s.shape,o);l.length>0&&(a=_(pe(a,l),s.shape));const c=qe(s);return nt(me(a,oe(c,"float32")))}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4931,7 +4931,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const KT={kernelName:Zr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,nt(je(t)))}}};/** + */const YT={kernelName:Zr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,nt(qe(t)))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4946,7 +4946,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const XT={kernelName:Jr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e,s=F(qo(t,6),Ni(t));return{x:()=>F(n,oe(s,"float32"))}}};/** + */const ZT={kernelName:Jr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e,s=D(jo(t,6),Ni(t));return{x:()=>D(n,oe(s,"float32"))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4961,7 +4961,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const YT={kernelName:Qr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>F(n,oe(Ni(t),"float32"))}}};/** + */const QT={kernelName:Qr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>D(n,oe(Ni(t),"float32"))}}};/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4976,7 +4976,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ZT={kernelName:Ya,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>_(n,t.shape)}}};/** + */const JT={kernelName:Ya,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>_(n,t.shape)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4991,7 +4991,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const QT={kernelName:Qa,inputsToSave:["images"],gradFunc:(n,e,t)=>{const[s]=e,o={dy:n,images:s};return{images:()=>D.runKernel(ku,o,t)}}};/** + */const eN={kernelName:Qa,inputsToSave:["images"],gradFunc:(n,e,t)=>{const[s]=e,o={dy:n,images:s};return{images:()=>F.runKernel(Su,o,t)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5006,7 +5006,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const JT={kernelName:Za,inputsToSave:["images"],gradFunc:(n,e,t)=>{const[s]=e,o={dy:n,images:s};return{images:()=>D.runKernel(vu,o,t)}}};/** + */const tN={kernelName:Za,inputsToSave:["images"],gradFunc:(n,e,t)=>{const[s]=e,o={dy:n,images:s};return{images:()=>F.runKernel(ku,o,t)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5021,7 +5021,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const eN={kernelName:Ja,gradFunc:(n,e,t)=>{const{dims:s}=t,o=$e(s,n.shape);return{x:()=>co(n,o)}}};/** + */const nN={kernelName:Ja,gradFunc:(n,e,t)=>{const{dims:s}=t,o=$e(s,n.shape);return{x:()=>uo(n,o)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5036,7 +5036,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const tN={kernelName:ei,gradFunc:n=>({x:()=>Ne(n)})};/** + */const sN={kernelName:ei,gradFunc:n=>({x:()=>Ne(n)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5051,7 +5051,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const nN={kernelName:ti,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>nt(me(n,F(jo(t,1.5),2)))}}};/** + */const oN={kernelName:ti,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>nt(me(n,D(io(t,1.5),2)))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5066,7 +5066,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const sN={kernelName:el,inputsToSave:["condition"],gradFunc:(n,e)=>{const[t]=e;return{condition:()=>oe(Ne(t),"float32"),t:()=>F(n,oe(t,n.dtype)),e:()=>F(n,oe(hh(t),n.dtype))}}};/** + */const rN={kernelName:el,inputsToSave:["condition"],gradFunc:(n,e)=>{const[t]=e;return{condition:()=>oe(Ne(t),"float32"),t:()=>D(n,oe(t,n.dtype)),e:()=>D(n,oe(hh(t),n.dtype))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5081,7 +5081,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const oN={kernelName:ni,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const s=Zt(t,Fe(0)),o=Fe(Al),r=Fe(Dl),i=F(n,r),a=F(F(n,o),Vn(oe(t,"float32")));return Ct(s,i,a)}}}};/** + */const iN={kernelName:ni,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const s=Zt(t,Fe(0)),o=Fe(Dl),r=Fe(Fl),i=D(n,r),a=D(D(n,o),Vn(oe(t,"float32")));return Ct(s,i,a)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5096,7 +5096,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const rN={kernelName:ii,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e;return{x:()=>F(n,F(t,ge(Fe(1),t)))}}};/** + */const aN={kernelName:ii,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e;return{x:()=>D(n,D(t,ge(Fe(1),t)))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5111,7 +5111,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const iN={kernelName:ri,gradFunc:n=>({x:()=>Ne(n)})};/** + */const lN={kernelName:ri,gradFunc:n=>({x:()=>Ne(n)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5126,7 +5126,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const aN={kernelName:si,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>F(oh(oe(t,"float32")),n)}}};/** + */const cN={kernelName:si,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>D(oh(oe(t,"float32")),n)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5141,7 +5141,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const lN={kernelName:oi,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>F(cm(oe(t,"float32")),n)}}};/** + */const uN={kernelName:oi,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>D(cm(oe(t,"float32")),n)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5156,7 +5156,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const cN={kernelName:tl,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{begin:o,size:r}=t,i=s.shape,[a,l]=El(s,o,r),c=[];for(let u=0;ufh(n,c)}}};/** + */const hN={kernelName:tl,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{begin:o,size:r}=t,i=s.shape,[a,l]=Rl(s,o,r),c=[];for(let u=0;ufh(n,c)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5171,7 +5171,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const uN={kernelName:rl,outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s]=e,{dim:o}=t,r=!0,i=F(n,s);return{logits:()=>ge(i,F(pe(i,[o],r),s))}}};/** + */const dN={kernelName:rl,outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s]=e,{dim:o}=t,r=!0,i=D(n,s);return{logits:()=>ge(i,D(pe(i,[o],r),s))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5186,7 +5186,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const hN={kernelName:ai,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>F(n,Go(t))}}};/** + */const pN={kernelName:ai,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>D(n,Ho(t))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5201,7 +5201,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Pg={kernelName:sl,gradFunc:(n,e,t)=>{const{blockShape:s,paddings:o}=t;return{x:()=>th(n,s,o)}}};/** + */const Bg={kernelName:sl,gradFunc:(n,e,t)=>{const{blockShape:s,paddings:o}=t;return{x:()=>th(n,s,o)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5216,7 +5216,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Bg={kernelName:ol,gradFunc:(n,e,t)=>{const{axis:s}=t;return{x:()=>Ot(n,s)}}};/** + */const zg={kernelName:ol,gradFunc:(n,e,t)=>{const{axis:s}=t;return{x:()=>Mt(n,s)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5231,7 +5231,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const dN={kernelName:li,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,F(Lt(oe(t,"float32")),2))}}};/** + */const fN={kernelName:li,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,D(Rt(oe(t,"float32")),2))}}};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5246,7 +5246,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const pN={kernelName:Su,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>F(n,F(oe(t,"float32"),2))}}};/** + */const mN={kernelName:Tu,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>D(n,D(oe(t,"float32"),2))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5261,7 +5261,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const fN={kernelName:ci,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=Fe(2);return{a:()=>F(n,F(o,ge(t,s))),b:()=>F(n,F(o,ge(s,t)))}}};/** + */const gN={kernelName:ci,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=Fe(2);return{a:()=>D(n,D(o,ge(t,s))),b:()=>D(n,D(o,ge(s,t)))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5276,7 +5276,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const mN={kernelName:fi,gradFunc:n=>({x:()=>Ne(n)})};/** + */const xN={kernelName:fi,gradFunc:n=>({x:()=>Ne(n)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5291,7 +5291,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const gN={kernelName:ui,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{let a=n;const l=ct(t.shape,o);return l.length>0&&(a=pe(a,l)),_(a,t.shape)},b:()=>{let a=n;const l=ct(s.shape,o);return l.length>0&&(a=pe(a,l)),_(nt(a),s.shape)}}}};/** + */const bN={kernelName:ui,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,o=we(t.shape,s.shape);return{a:()=>{let a=n;const l=ct(t.shape,o);return l.length>0&&(a=pe(a,l)),_(a,t.shape)},b:()=>{let a=n;const l=ct(s.shape,o);return l.length>0&&(a=pe(a,l)),_(nt(a),s.shape)}}}};/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5306,7 +5306,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const xN={kernelName:nl,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,o=s.shape.slice(),{axis:r}=t;$e(r,s.shape).forEach(c=>{o[c]=1});const a=_(n,o),l=F(a,Nn(s.shape,"float32"));return{x:()=>l}}};/** + */const yN={kernelName:nl,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,o=s.shape.slice(),{axis:r}=t;$e(r,s.shape).forEach(c=>{o[c]=1});const a=_(n,o),l=D(a,Nn(s.shape,"float32"));return{x:()=>l}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5321,7 +5321,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const bN={kernelName:hi,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,je(oh(t)))}}};/** + */const wN={kernelName:hi,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>me(n,qe(oh(t)))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5336,7 +5336,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const yN={kernelName:di,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e;return{x:()=>F(ge(Fe(1),je(t)),n)}}};/** + */const CN={kernelName:di,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e;return{x:()=>D(ge(Fe(1),qe(t)),n)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5351,7 +5351,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const wN={kernelName:pi,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{reps:o}=t;return{x:()=>{let i=Ne(s);if(s.rank===1)for(let a=0;a{const[s]=e,{reps:o}=t;return{x:()=>{let i=Ne(s);if(s.rank===1)for(let a=0;a{const s=t,{perm:o}=s,r=$s(o);return{x:()=>Ee(n,r)}}};/** + */const $N={kernelName:Mo,gradFunc:(n,e,t)=>{const s=t,{perm:o}=s,r=$s(o);return{x:()=>Ee(n,r)}}};/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5381,7 +5381,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const IN={kernelName:il,gradFunc:(n,e,t)=>{const s=t,{axis:o}=s;return{value:()=>Un(n,o)}}};/** + */const vN={kernelName:il,gradFunc:(n,e,t)=>{const s=t,{axis:o}=s;return{value:()=>Un(n,o)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5396,7 +5396,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const $N={kernelName:al,inputsToSave:["segmentIds"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>vN(n,t)}}};function vN(n,e){const t=vs(e,Ne(e)),s=lh(n,t);let o=io(e,Fe(0,"int32"));const r=s.rank-o.rank;for(let a=0;a{const[t]=e;return{x:()=>SN(n,t)}}};function SN(n,e){const t=vs(e,Ne(e)),s=lh(n,t);let o=ao(e,Fe(0,"int32"));const r=s.rank-o.rank;for(let a=0;a({x:()=>Ne(n)})};/** + */const TN={kernelName:ll,gradFunc:n=>({x:()=>Ne(n)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5426,7 +5426,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const SN=[Dg,$2,v2,k2,S2,T2,N2,E2,R2,A2,D2,F2,L2,B2,z2,V2,W2,U2,G2,H2,j2,q2,X2,K2,Q2,J2,eT,tT,nT,sT,qT,oT,rT,iT,aT,lT,uT,cT,hT,dT,pT,fT,mT,gT,xT,bT,yT,wT,CT,vT,Lg,Lg,kT,NT,AT,DT,FT,_T,OT,LT,MT,PT,BT,zT,VT,Mg,Mg,WT,UT,jT,KT,XT,YT,ZT,QT,JT,eN,tN,nN,sN,oN,rN,iN,aN,lN,cN,uN,hN,Pg,Pg,Bg,Bg,dN,fN,pN,mN,gN,xN,bN,yN,wN,CN,IN,$N,kN];for(const n of SN)Mw(n);/** + */const NN=[Fg,k2,S2,T2,N2,E2,R2,A2,D2,F2,_2,O2,P2,V2,W2,U2,G2,H2,q2,j2,K2,X2,Z2,Y2,eT,tT,nT,sT,oT,rT,XT,iT,aT,lT,cT,uT,dT,hT,pT,fT,mT,gT,xT,bT,yT,wT,CT,IT,$T,ST,Mg,Mg,TT,RT,FT,_T,OT,LT,MT,PT,BT,zT,VT,WT,UT,Pg,Pg,GT,HT,KT,YT,ZT,QT,JT,eN,tN,nN,sN,oN,rN,iN,aN,lN,cN,uN,hN,dN,pN,Bg,Bg,zg,zg,fN,gN,mN,xN,bN,yN,wN,CN,IN,$N,vN,kN,TN];for(const n of NN)zw(n);/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5441,7 +5441,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.abs=function(){return this.throwIfDisposed(),_t(this)};/** + */U().prototype.abs=function(){return this.throwIfDisposed(),Lt(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5456,7 +5456,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.acos=function(){return this.throwIfDisposed(),tI(this)};/** + */U().prototype.acos=function(){return this.throwIfDisposed(),oI(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5471,7 +5471,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.acosh=function(){return this.throwIfDisposed(),sI(this)};/** + */U().prototype.acosh=function(){return this.throwIfDisposed(),iI(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5516,7 +5516,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.any=function(n,e){return this.throwIfDisposed(),Yu(this,n,e)};/** + */U().prototype.any=function(n,e){return this.throwIfDisposed(),Zu(this,n,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5546,7 +5546,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.argMin=function(n){return this.throwIfDisposed(),lI(this,n)};/** + */U().prototype.argMin=function(n){return this.throwIfDisposed(),hI(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5666,7 +5666,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.asin=function(){return this.throwIfDisposed(),uI(this)};/** + */U().prototype.asin=function(){return this.throwIfDisposed(),pI(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5681,7 +5681,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.asinh=function(){return this.throwIfDisposed(),dI(this)};/** + */U().prototype.asinh=function(){return this.throwIfDisposed(),mI(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5696,7 +5696,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.atan=function(){return this.throwIfDisposed(),fI(this)};/** + */U().prototype.atan=function(){return this.throwIfDisposed(),xI(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5711,7 +5711,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.atan2=function(n){return this.throwIfDisposed(),gI(this,n)};/** + */U().prototype.atan2=function(n){return this.throwIfDisposed(),yI(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5726,7 +5726,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.atanh=function(){return this.throwIfDisposed(),bI(this)},U().prototype.avgPool=function(n,e,t,s){return this.throwIfDisposed(),Ju(this,n,e,t,s)};/** + */U().prototype.atanh=function(){return this.throwIfDisposed(),CI(this)},U().prototype.avgPool=function(n,e,t,s){return this.throwIfDisposed(),eh(this,n,e,t,s)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5756,7 +5756,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.batchNorm=function(n,e,t,s,o){return this.throwIfDisposed(),wl(this,n,e,t,s,o)};/** + */U().prototype.batchNorm=function(n,e,t,s,o){return this.throwIfDisposed(),Cl(this,n,e,t,s,o)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5801,7 +5801,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.ceil=function(){return this.throwIfDisposed(),HI(this)};/** + */U().prototype.ceil=function(){return this.throwIfDisposed(),KI(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5831,7 +5831,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.concat=function(n,e){return this.throwIfDisposed(),n instanceof lt&&(n=[n]),Ot([this,...n],e)};/** + */U().prototype.concat=function(n,e){return this.throwIfDisposed(),n instanceof lt&&(n=[n]),Mt([this,...n],e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5951,7 +5951,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.depthToSpace=function(n,e){return this.throwIfDisposed(),m$(this,n,e)};/** + */U().prototype.depthToSpace=function(n,e){return this.throwIfDisposed(),b$(this,n,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5981,7 +5981,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.dilation2d=function(n,e,t,s,o){return this.throwIfDisposed(),b$(this,n,e,t,s,o)};/** + */U().prototype.dilation2d=function(n,e,t,s,o){return this.throwIfDisposed(),C$(this,n,e,t,s,o)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5996,7 +5996,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.divNoNan=function(n){return this.throwIfDisposed(),$$(this,n)};/** + */U().prototype.divNoNan=function(n){return this.throwIfDisposed(),S$(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6026,7 +6026,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.dot=function(n){return this.throwIfDisposed(),k$(this,n)};/** + */U().prototype.dot=function(n){return this.throwIfDisposed(),N$(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6041,7 +6041,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.elu=function(){return this.throwIfDisposed(),Cl(this)};/** + */U().prototype.elu=function(){return this.throwIfDisposed(),Il(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6071,7 +6071,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.erf=function(){return this.throwIfDisposed(),E$(this)};/** + */U().prototype.erf=function(){return this.throwIfDisposed(),dm(this)};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6086,7 +6086,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.euclideanNorm=function(n,e){return this.throwIfDisposed(),P$(this,n,e)};/** + */U().prototype.euclideanNorm=function(n,e){return this.throwIfDisposed(),z$(this,n,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6116,7 +6116,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.expandDims=function(n){return this.throwIfDisposed(),Ut(this,n)};/** + */U().prototype.expandDims=function(n){return this.throwIfDisposed(),Gt(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6131,7 +6131,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.expm1=function(){return this.throwIfDisposed(),W$(this)};/** + */U().prototype.expm1=function(){return this.throwIfDisposed(),G$(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6146,7 +6146,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.fft=function(){return this.throwIfDisposed(),Rm(this)};/** + */U().prototype.fft=function(){return this.throwIfDisposed(),Am(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6176,7 +6176,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.floor=function(){return this.throwIfDisposed(),vl(this)};/** + */U().prototype.floor=function(){return this.throwIfDisposed(),kl(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6221,7 +6221,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.greaterEqual=function(n){return this.throwIfDisposed(),io(this,n)};/** + */U().prototype.greaterEqual=function(n){return this.throwIfDisposed(),ao(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6266,7 +6266,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.irfft=function(){return this.throwIfDisposed(),Fk(this)};/** + */U().prototype.irfft=function(){return this.throwIfDisposed(),Ok(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6281,7 +6281,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.isFinite=function(){return this.throwIfDisposed(),Z$(this)};/** + */U().prototype.isFinite=function(){return this.throwIfDisposed(),J$(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6296,7 +6296,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.isInf=function(){return this.throwIfDisposed(),J$(this)};/** + */U().prototype.isInf=function(){return this.throwIfDisposed(),tv(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6311,7 +6311,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.isNaN=function(){return this.throwIfDisposed(),tv(this)};/** + */U().prototype.isNaN=function(){return this.throwIfDisposed(),sv(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6341,7 +6341,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.lessEqual=function(n){return this.throwIfDisposed(),qo(this,n)};/** + */U().prototype.lessEqual=function(n){return this.throwIfDisposed(),jo(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6356,7 +6356,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.less=function(n){return this.throwIfDisposed(),kl(this,n)};/** + */U().prototype.less=function(n){return this.throwIfDisposed(),Sl(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6371,7 +6371,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.localResponseNormalization=function(n,e,t,s){return this.throwIfDisposed(),iv(this,n,e,t,s)};/** + */U().prototype.localResponseNormalization=function(n,e,t,s){return this.throwIfDisposed(),lv(this,n,e,t,s)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6386,7 +6386,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.logSigmoid=function(){return this.throwIfDisposed(),pv(this)};/** + */U().prototype.logSigmoid=function(){return this.throwIfDisposed(),mv(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6401,7 +6401,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.logSoftmax=function(n){return this.throwIfDisposed(),gm(this,n)};/** + */U().prototype.logSoftmax=function(n){return this.throwIfDisposed(),xm(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6416,7 +6416,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.logSumExp=function(n,e){return this.throwIfDisposed(),xm(this,n,e)};/** + */U().prototype.logSumExp=function(n,e){return this.throwIfDisposed(),bm(this,n,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6446,7 +6446,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.log1p=function(){return this.throwIfDisposed(),mm(this)};/** + */U().prototype.log1p=function(){return this.throwIfDisposed(),gm(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6491,7 +6491,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.logicalOr=function(n){return this.throwIfDisposed(),bm(this,n)};/** + */U().prototype.logicalOr=function(n){return this.throwIfDisposed(),ym(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6506,7 +6506,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.logicalXor=function(n){return this.throwIfDisposed(),Cv(this,n)};/** + */U().prototype.logicalXor=function(n){return this.throwIfDisposed(),$v(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6581,7 +6581,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.min=function(n,e){return this.throwIfDisposed(),Il(this,n,e)};/** + */U().prototype.min=function(n,e){return this.throwIfDisposed(),$l(this,n,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6611,7 +6611,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.mirrorPad=function(n,e){return this.throwIfDisposed(),Ev(this,n,e)};/** + */U().prototype.mirrorPad=function(n,e){return this.throwIfDisposed(),Av(this,n,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6626,7 +6626,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.mod=function(n){return this.throwIfDisposed(),Av(this,n)};/** + */U().prototype.mod=function(n){return this.throwIfDisposed(),Fv(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6641,7 +6641,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.mul=function(n){return this.throwIfDisposed(),F(this,n)};/** + */U().prototype.mul=function(n){return this.throwIfDisposed(),D(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6671,7 +6671,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.norm=function(n,e,t){return this.throwIfDisposed(),$l(this,n,e,t)};/** + */U().prototype.norm=function(n,e,t){return this.throwIfDisposed(),vl(this,n,e,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6686,7 +6686,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.notEqual=function(n){return this.throwIfDisposed(),Sl(this,n)};/** + */U().prototype.notEqual=function(n){return this.throwIfDisposed(),Tl(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6701,7 +6701,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.oneHot=function(n,e=1,t=0){return this.throwIfDisposed(),ym(this,n,e,t)};/** + */U().prototype.oneHot=function(n,e=1,t=0){return this.throwIfDisposed(),wm(this,n,e,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6731,7 +6731,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.pad=function(n,e){return this.throwIfDisposed(),fh(this,n,e)},U().prototype.pool=function(n,e,t,s,o,r){return this.throwIfDisposed(),Vv(this,n,e,t,s,o,r)};/** + */U().prototype.pad=function(n,e){return this.throwIfDisposed(),fh(this,n,e)},U().prototype.pool=function(n,e,t,s,o,r){return this.throwIfDisposed(),Uv(this,n,e,t,s,o,r)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6746,7 +6746,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.pow=function(n){return this.throwIfDisposed(),jo(this,n)};/** + */U().prototype.pow=function(n){return this.throwIfDisposed(),io(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6776,7 +6776,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.prod=function(n,e){return this.throwIfDisposed(),Gv(this,n,e)};/** + */U().prototype.prod=function(n,e){return this.throwIfDisposed(),qv(this,n,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6791,7 +6791,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.reciprocal=function(){return this.throwIfDisposed(),pk(this)};/** + */U().prototype.reciprocal=function(){return this.throwIfDisposed(),mk(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6806,7 +6806,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.relu=function(){return this.throwIfDisposed(),lo(this)};/** + */U().prototype.relu=function(){return this.throwIfDisposed(),co(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6821,7 +6821,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.relu6=function(){return this.throwIfDisposed(),Im(this)};/** + */U().prototype.relu6=function(){return this.throwIfDisposed(),$m(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6866,7 +6866,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.resizeBilinear=function(n,e,t){return this.throwIfDisposed(),Mm(this,n,e,t)};/** + */U().prototype.resizeBilinear=function(n,e,t){return this.throwIfDisposed(),Pm(this,n,e,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6881,7 +6881,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.resizeNearestNeighbor=function(n,e,t){return this.throwIfDisposed(),Pm(this,n,e,t)};/** + */U().prototype.resizeNearestNeighbor=function(n,e,t){return this.throwIfDisposed(),Bm(this,n,e,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6896,7 +6896,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.reverse=function(n){return this.throwIfDisposed(),co(this,n)};/** + */U().prototype.reverse=function(n){return this.throwIfDisposed(),uo(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6911,7 +6911,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.rfft=function(){return this.throwIfDisposed(),Lk(this)};/** + */U().prototype.rfft=function(){return this.throwIfDisposed(),Pk(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6926,7 +6926,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.round=function(){return this.throwIfDisposed(),$m(this)};/** + */U().prototype.round=function(){return this.throwIfDisposed(),vm(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6941,7 +6941,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.rsqrt=function(){return this.throwIfDisposed(),vm(this)};/** + */U().prototype.rsqrt=function(){return this.throwIfDisposed(),km(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6956,7 +6956,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.selu=function(){return this.throwIfDisposed(),km(this)};/** + */U().prototype.selu=function(){return this.throwIfDisposed(),Sm(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6971,7 +6971,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.separableConv2d=function(n,e,t,s,o,r){return this.throwIfDisposed(),Sm(this,n,e,t,s,o,r)};/** + */U().prototype.separableConv2d=function(n,e,t,s,o,r){return this.throwIfDisposed(),Tm(this,n,e,t,s,o,r)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6986,7 +6986,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.sigmoid=function(){return this.throwIfDisposed(),Go(this)};/** + */U().prototype.sigmoid=function(){return this.throwIfDisposed(),Ho(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7001,7 +7001,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.sign=function(){return this.throwIfDisposed(),Ik(this)};/** + */U().prototype.sign=function(){return this.throwIfDisposed(),vk(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7016,7 +7016,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.sin=function(){return this.throwIfDisposed(),Tm(this)};/** + */U().prototype.sin=function(){return this.throwIfDisposed(),Nm(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7031,7 +7031,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.sinh=function(){return this.throwIfDisposed(),Nm(this)};/** + */U().prototype.sinh=function(){return this.throwIfDisposed(),Em(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7121,7 +7121,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.sqrt=function(){return this.throwIfDisposed(),Lt(this)};/** + */U().prototype.sqrt=function(){return this.throwIfDisposed(),Rt(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7136,7 +7136,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.square=function(){return this.throwIfDisposed(),je(this)};/** + */U().prototype.square=function(){return this.throwIfDisposed(),qe(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7151,7 +7151,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.squaredDifference=function(n){return this.throwIfDisposed(),Pk(this,n)};/** + */U().prototype.squaredDifference=function(n){return this.throwIfDisposed(),zk(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7211,7 +7211,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.stridedSlice=function(n,e,t,s,o,r,i,a){return this.throwIfDisposed(),Uk(this,n,e,t,s,o,r,i,a)};/** + */U().prototype.stridedSlice=function(n,e,t,s,o,r,i,a){return this.throwIfDisposed(),Hk(this,n,e,t,s,o,r,i,a)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7256,7 +7256,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.tan=function(){return this.throwIfDisposed(),Hk(this)};/** + */U().prototype.tan=function(){return this.throwIfDisposed(),jk(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7271,7 +7271,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.tanh=function(){return this.throwIfDisposed(),eh(this)};/** + */U().prototype.tanh=function(){return this.throwIfDisposed(),wl(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7346,7 +7346,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.topk=function(n,e){return this.throwIfDisposed(),Kk(this,n,e)};/** + */U().prototype.topk=function(n,e){return this.throwIfDisposed(),Yk(this,n,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7376,7 +7376,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.unique=function(n){return this.throwIfDisposed(),Zk(this,n)};/** + */U().prototype.unique=function(n){return this.throwIfDisposed(),Jk(this,n)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7391,7 +7391,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */U().prototype.unsortedSegmentSum=function(n,e){return this.throwIfDisposed(),Fm(this,n,e)};/** + */U().prototype.unsortedSegmentSum=function(n,e){return this.throwIfDisposed(),_m(this,n,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7444,7 +7444,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class jn extends Error{constructor(e){super(e),Object.setPrototypeOf(this,jn.prototype)}}class gn extends Error{constructor(e){super(e),Object.setPrototypeOf(this,gn.prototype)}}class A extends Error{constructor(e){super(e),Object.setPrototypeOf(this,A.prototype)}}class Ce extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Ce.prototype)}}class md extends Error{constructor(e){super(e),Object.setPrototypeOf(this,md.prototype)}}/** + */class qn extends Error{constructor(e){super(e),Object.setPrototypeOf(this,qn.prototype)}}class gn extends Error{constructor(e){super(e),Object.setPrototypeOf(this,gn.prototype)}}class A extends Error{constructor(e){super(e),Object.setPrototypeOf(this,A.prototype)}}class Ce extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Ce.prototype)}}class md extends Error{constructor(e){super(e),Object.setPrototypeOf(this,md.prototype)}}/** * @license * Copyright 2022 Google LLC * @@ -7452,7 +7452,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class zg{constructor(e){this.maxEntries=e||100,this.cache=new Map}get(e){let t;return this.cache.has(e)&&(t=this.cache.get(e),this.cache.delete(e),this.cache.set(e,t)),t}put(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxEntries){const s=this.cache.keys().next().value;this.cache.delete(s)}this.cache.set(e,t)}getMaxEntries(){return this.maxEntries}setMaxEntries(e){if(e<0)throw new Error(`The maxEntries of LRU caches must be at least 0, but got ${e}.`);if(this.maxEntries>e)for(let t=0;t=this.maxEntries){const s=this.cache.keys().next().value;this.cache.delete(s)}this.cache.set(e,t)}getMaxEntries(){return this.maxEntries}setMaxEntries(e){if(e<0)throw new Error(`The maxEntries of LRU caches must be at least 0, but got ${e}.`);if(this.maxEntries>e)for(let t=0;tt.toUpperCase())}let xn={};function gd(n){if(n==null)return null;const e={};return e.className=n.getClassName(),e.config=n.getConfig(),e}function xd(n){if(!(n==null||typeof n!="object"))if(Array.isArray(n))n.forEach(e=>xd(e));else{const e=Object.keys(n);for(const t of e){const s=n[t];s!=null&&typeof s=="object"&&(!Array.isArray(s)&&s.type==="ndarray"&&typeof s.value=="number"?n[t]=s.value:xd(s))}}}function Di(n,e={},t={},s="object",o=!1){if(typeof n=="string"){const r=n;let i;if(r in t)i=t[r];else if(r in xn)i=xn[r];else if(i=e[r],i==null)throw new A(`Unknown ${s}: ${n}. This may be due to one of the following reasons: + */function po(n,e){if(Array.isArray(n)){let t=[];for(let s=0;st.toUpperCase())}let xn={};function gd(n){if(n==null)return null;const e={};return e.className=n.getClassName(),e.config=n.getConfig(),e}function xd(n){if(!(n==null||typeof n!="object"))if(Array.isArray(n))n.forEach(e=>xd(e));else{const e=Object.keys(n);for(const t of e){const s=n[t];s!=null&&typeof s=="object"&&(!Array.isArray(s)&&s.type==="ndarray"&&typeof s.value=="number"?n[t]=s.value:xd(s))}}}function Di(n,e={},t={},s="object",o=!1){if(typeof n=="string"){const r=n;let i;if(r in t)i=t[r];else if(r in xn)i=xn[r];else if(i=e[r],i==null)throw new A(`Unknown ${s}: ${n}. This may be due to one of the following reasons: 1. The ${s} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code. 2. The custom ${s} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return i}else{const r=n;if(r.className==null||r.config==null)throw new A(`${s}: Improper config format: ${JSON.stringify(r)}. 'className' and 'config' must set.`);const i=r.className;let a,l;if(i in t?[a,l]=t[i]:i in xn?[a,l]=xn.className:i in e&&([a,l]=e[i]),a==null)throw new A(`Unknown ${s}: ${i}. This may be due to one of the following reasons: 1. The ${s} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code. -2. The custom ${s} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(l!=null){const c={};for(const p of Object.keys(xn))c[p]=xn[p];for(const p of Object.keys(t))c[p]=t[p];const u=r.config;u.customObjects=c;const h=Object.assign({},xn);for(const p of Object.keys(t))xn[p]=t[p];xd(r.config);const d=l(a,r.config,t,o);return xn=Object.assign({},h),d}else{const c=Object.assign({},xn);for(const h of Object.keys(t))xn[h]=t[h];const u=new a(r.config);return xn=Object.assign({},c),u}}}function TN(n,e){return ne?1:0}function Fl(n,e){return-1*TN(n,e)}function Ss(n){if(n==null)return n;const e=[];for(const t of n)e.indexOf(t)===-1&&e.push(t);return e}function NN(n){if(n==null)throw new A(`Invalid value in obj: ${JSON.stringify(n)}`);for(const e in n)if(n.hasOwnProperty(e))return!1;return!0}function fo(n,e,t){if(t!=null&&n.indexOf(t)<0)throw new A(`${t} is not a valid ${e}. Valid values are ${n} or null/undefined.`)}function bd(n,e,t=0,s=1/0){return qn(t>=0),qn(s>=t),Array.isArray(n)&&n.length>=t&&n.length<=s&&n.every(o=>typeof o===e)}function bt(n,e){Array.isArray(n)?($(n.length>0,()=>`${e} is unexpectedly an empty array.`),n.forEach((t,s)=>bt(t,`element ${s+1} of ${e}`))):$(Number.isInteger(n)&&n>0,()=>`Expected ${e} to be a positive integer, but got ${Wg(n)}.`)}function Wg(n){return n===null?"null":Array.isArray(n)?"["+n.map(e=>Wg(e)).join(",")+"]":typeof n=="string"?`"${n}"`:`${n}`}function EN(n,e,t){let s=t!=null?t():zt(),o;return(...i)=>{const a=t!=null?t():zt();return a-se?1:0}function _l(n,e){return-1*EN(n,e)}function Ss(n){if(n==null)return n;const e=[];for(const t of n)e.indexOf(t)===-1&&e.push(t);return e}function RN(n){if(n==null)throw new A(`Invalid value in obj: ${JSON.stringify(n)}`);for(const e in n)if(n.hasOwnProperty(e))return!1;return!0}function mo(n,e,t){if(t!=null&&n.indexOf(t)<0)throw new A(`${t} is not a valid ${e}. Valid values are ${n} or null/undefined.`)}function bd(n,e,t=0,s=1/0){return jn(t>=0),jn(s>=t),Array.isArray(n)&&n.length>=t&&n.length<=s&&n.every(o=>typeof o===e)}function bt(n,e){Array.isArray(n)?($(n.length>0,()=>`${e} is unexpectedly an empty array.`),n.forEach((t,s)=>bt(t,`element ${s+1} of ${e}`))):$(Number.isInteger(n)&&n>0,()=>`Expected ${e} to be a positive integer, but got ${Ug(n)}.`)}function Ug(n){return n===null?"null":Array.isArray(n)?"["+n.map(e=>Ug(e)).join(",")+"]":typeof n=="string"?`"${n}"`:`${n}`}function AN(n,e,t){let s=t!=null?t():Vt(),o;return(...i)=>{const a=t!=null?t():Vt();return a-s0){const t=`${n}_${e}`;return Jo.set(t,1),t}else return n}const PN=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function Xg(n){return!!n.match(PN)}/** + */const Jo=new Map;function ot(n){mo(FN,"DataFormat",n)}function PN(n){mo(_N,"InterpolationFormat",n)}function on(n){mo(ON,"PaddingMode",n)}function qg(n){mo(LN,"PoolMode",n)}const Fi=[],jg="/";function go(n,e){Fi.push(n);try{const t=e();return Fi.pop(),t}catch(t){throw Fi.pop(),t}}function BN(){return Fi.length===0?"":Fi.join(jg)+jg}function Kg(n){if(!Yg(n))throw new Error("Not a valid tensor name: '"+n+"'");return BN()+n}function Xg(n){if(!Yg(n))throw new Error("Not a valid tensor name: '"+n+"'");Jo.has(n)||Jo.set(n,0);const e=Jo.get(n);if(Jo.set(n,Jo.get(n)+1),e>0){const t=`${n}_${e}`;return Jo.set(t,1),t}else return n}const zN=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function Yg(n){return!!n.match(zN)}/** * @license * Copyright 2018 Google LLC * @@ -7497,7 +7497,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function BN(n){return n===parseInt(n.toString(),10)}function Ts(n,e,t){e==null&&(e=0),t==null&&(t=n.length);let s=1;for(let o=e;oe&&(e=s)}return e}function Rn(n,e){if(ee&&(e=s)}return e}function Rn(n,e){if(e{if(n.shape.length!==2)throw new A(`repeat() expects a rank-2 tensor, but received a rank-${n.shape.length} tensor.`);const t=_i(n,1);return Id(t,[1,e,1])})}function VN(n){const e=[Ts(n.shape)];return _(n,e)}function WN(n){if(n.rank<=1)throw new A(`batchFlatten requires a minimum rank of 2. Got rank: ${n.rank}.`);const e=[n.shape[0],Ts(n.shape,1)];return _(n,e)}function go(n,e,t){return z(()=>{switch(n.rank){case 1:return vh(n,e,t);case 2:return Em(n,[e,0],[t,n.shape[1]]);case 3:return kh(n,[e,0,0],[t,n.shape[1],n.shape[2]]);case 4:return Nl(n,[e,0,0,0],[t,n.shape[1],n.shape[2],n.shape[3]]);case 5:return We(n,[e,0,0,0,0],[t,n.shape[1],n.shape[2],n.shape[3],n.shape[4]]);case 6:return We(n,[e,0,0,0,0,0],[t,n.shape[1],n.shape[2],n.shape[3],n.shape[4],n.shape[5]]);default:throw new A(`sliceAlongFirstAxis() received an unsupported tensor rank: ${n.rank}`)}})}function wd(n,e,t){return z(()=>{switch(n.rank){case 1:return vh(n,e,t);case 2:return Em(n,[0,e],[n.shape[0],t]);case 3:return kh(n,[0,0,e],[n.shape[0],n.shape[1],t]);case 4:return Nl(n,[0,0,0,e],[n.shape[0],n.shape[1],n.shape[2],t]);default:throw new A(`sliceAlongLastAxis() received an unsupported tensor rank: ${n.rank}`)}})}function Ll(n,e,t,s){return z(()=>{switch(n.rank){case 1:return vh(n,e,t);case 2:switch(s){case 1:return go(n,e,t);case 2:return wd(n,e,t);default:throw new A(`The axis is not within the rank of the tensor ${s}`)}case 3:switch(s){case 1:return go(n,e,t);case 2:return kh(n,[0,e,0],[n.shape[0],t,n.shape[2]]);case 3:return wd(n,e,t);default:throw new A(`The axis is not within the rank of the tensor ${s}`)}case 4:switch(s){case 1:return go(n,e,t);case 2:return Nl(n,[0,e,0,0],[n.shape[0],t,n.shape[2],n.shape[3]]);case 3:return Nl(n,[0,0,e,0],[n.shape[0],n.shape[1],t,n.shape[3]]);case 4:return wd(n,e,t);default:throw new A(`The axis is not within the rank of the tensor ${s}`)}default:throw new A(`sliceAlongLastAxis() received an unsupported tensor rank: ${n.rank}`)}})}function Cd(n,e=-1){let t;return e<0&&(t=n[0].rank,t!==0?e=t:e=0),e===n[0].rank&&(e=-1),Ot(n,e)}function Yg(n,e){switch(n.rank){case 1:return KI([n,e]);case 2:return YI([n,e],0);case 3:return QI([n,e],0);case 4:return e$([n,e],0);default:throw new A(`concatAlongFirstAxis() received an unsupported tensor rank: ${n.rank}`)}}function Id(n,e){if(Array.isArray(e)||(e=[e]),n.rank!==e.length)throw new A(`The length of input n (${e.length}) does not match the number of dimensions in input x (${n.rank})`);return Tn(n,e)}function Ml(n,e=0,t=1,s,o){return ck(n,e,t,s,o)}function Xn(n,e,t,s){if(n.rank<2||e.rank<2)throw new Ce(`dot requires both inputs to be rank >= 2 but got x shape = ${n.shape} and y shape = ${e.shape}`);if(e.rank>=3){const o=n.shape.slice(-1)[0],r=e.shape.slice(-2)[0];if(o!==r)throw new Ce(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${n.shape} and y shape = ${e.shape}`)}if(n.rank===2&&e.rank===2)return Om({a:n,b:e,transposeA:!1,transposeB:!1,bias:s?$d(n.rank,s,An()):null,activation:t});{const o=n.shape.slice(),r=o.pop();n=_(n,[-1,r]);const i=e.shape.slice(),a=i.pop(),l=i.pop(),c=[...i,a],u=Array.from({length:e.rank},(f,g)=>g===0?e.rank-2:g<=e.rank-2?g-1:g);e=_(Ee(e,u),[l,-1]);const h=[...o,...c];return _(Om({a:n,b:e,transposeA:!1,transposeB:!1,bias:s?$d(n.rank,s,An()):null,activation:t}),h)}}function Zg(n,e,t){return z(()=>(Array.isArray(e)?e=Rt(e,"int32"):e=oe(e,"int32"),lh(n,e,t)))}function Oi(n){return F(n,n)}function $d(n,e,t){const s=e.shape;if(e.rank!==1&&e.rank!==n)throw new A(`Unexpected bias dimensions: ${e.rank}; expected it to be 1 or ${n}`);if(n===5){if(t==="channelsFirst")return s.length===1?_(e,[1,s[0],1,1,1]):_(e,[1,s[3],s[0],s[1],s[2]]);if(t==="channelsLast")return s.length===1?_(e,[1,1,1,1,s[0]]):_(e,[1].concat(s))}else if(n===4){if(t==="channelsFirst")return s.length===1?_(e,[1,s[0],1,1]):_(e,[1,s[2],s[0],s[1]]);if(t==="channelsLast")return s.length===1?_(e,[1,1,1,s[0]]):_(e,[1].concat(s))}else if(n===3){if(t==="channelsFirst")return s.length===1?_(e,[1,s[0],1]):_(e,[1,s[1],s[0]]);if(t==="channelsLast")return s.length===1?_(e,[1,1,s[0]]):_(e,[1].concat(s))}else if(n<3)return e;throw new A(`Unsupported input rank by biasAdd: ${e.rank}`)}function Dn(n,e,t){return z(()=>(t==null&&(t=An()),ot(t),ee(n,$d(n.rank,e,t))))}function UN(n,e=1){if(e!==1)throw new Ce(`Support for alpha values other than 1 (${e}) is not implemented yet.`);return Cl(n)}function GN(n){return z(()=>me(n,ee(_t(n),1)))}function Qg(n,e,t,s){return z(()=>rS(n,e,t,s))}function HN(n){return z(()=>{const e=ee(.5,F(.2,n));return nn(e,0,1)})}function Li(n,e,t=!1){return t?n():e()}/** + */function Kn(n,e){return oe(n,e)}function _i(n,e=-1){const t=n.shape.slice();return e<0&&(e=t.length+e+1),t.splice(e,0,1),_(n,t)}function WN(n,e){return P(()=>{if(n.shape.length!==2)throw new A(`repeat() expects a rank-2 tensor, but received a rank-${n.shape.length} tensor.`);const t=_i(n,1);return Id(t,[1,e,1])})}function UN(n){const e=[Ts(n.shape)];return _(n,e)}function GN(n){if(n.rank<=1)throw new A(`batchFlatten requires a minimum rank of 2. Got rank: ${n.rank}.`);const e=[n.shape[0],Ts(n.shape,1)];return _(n,e)}function xo(n,e,t){return P(()=>{switch(n.rank){case 1:return vh(n,e,t);case 2:return Rm(n,[e,0],[t,n.shape[1]]);case 3:return kh(n,[e,0,0],[t,n.shape[1],n.shape[2]]);case 4:return El(n,[e,0,0,0],[t,n.shape[1],n.shape[2],n.shape[3]]);case 5:return We(n,[e,0,0,0,0],[t,n.shape[1],n.shape[2],n.shape[3],n.shape[4]]);case 6:return We(n,[e,0,0,0,0,0],[t,n.shape[1],n.shape[2],n.shape[3],n.shape[4],n.shape[5]]);default:throw new A(`sliceAlongFirstAxis() received an unsupported tensor rank: ${n.rank}`)}})}function wd(n,e,t){return P(()=>{switch(n.rank){case 1:return vh(n,e,t);case 2:return Rm(n,[0,e],[n.shape[0],t]);case 3:return kh(n,[0,0,e],[n.shape[0],n.shape[1],t]);case 4:return El(n,[0,0,0,e],[n.shape[0],n.shape[1],n.shape[2],t]);default:throw new A(`sliceAlongLastAxis() received an unsupported tensor rank: ${n.rank}`)}})}function Ml(n,e,t,s){return P(()=>{switch(n.rank){case 1:return vh(n,e,t);case 2:switch(s){case 1:return xo(n,e,t);case 2:return wd(n,e,t);default:throw new A(`The axis is not within the rank of the tensor ${s}`)}case 3:switch(s){case 1:return xo(n,e,t);case 2:return kh(n,[0,e,0],[n.shape[0],t,n.shape[2]]);case 3:return wd(n,e,t);default:throw new A(`The axis is not within the rank of the tensor ${s}`)}case 4:switch(s){case 1:return xo(n,e,t);case 2:return El(n,[0,e,0,0],[n.shape[0],t,n.shape[2],n.shape[3]]);case 3:return El(n,[0,0,e,0],[n.shape[0],n.shape[1],t,n.shape[3]]);case 4:return wd(n,e,t);default:throw new A(`The axis is not within the rank of the tensor ${s}`)}default:throw new A(`sliceAlongLastAxis() received an unsupported tensor rank: ${n.rank}`)}})}function Cd(n,e=-1){let t;return e<0&&(t=n[0].rank,t!==0?e=t:e=0),e===n[0].rank&&(e=-1),Mt(n,e)}function Zg(n,e){switch(n.rank){case 1:return ZI([n,e]);case 2:return JI([n,e],0);case 3:return t$([n,e],0);case 4:return s$([n,e],0);default:throw new A(`concatAlongFirstAxis() received an unsupported tensor rank: ${n.rank}`)}}function Id(n,e){if(Array.isArray(e)||(e=[e]),n.rank!==e.length)throw new A(`The length of input n (${e.length}) does not match the number of dimensions in input x (${n.rank})`);return Tn(n,e)}function Pl(n,e=0,t=1,s,o){return hk(n,e,t,s,o)}function Xn(n,e,t,s){if(n.rank<2||e.rank<2)throw new Ce(`dot requires both inputs to be rank >= 2 but got x shape = ${n.shape} and y shape = ${e.shape}`);if(e.rank>=3){const o=n.shape.slice(-1)[0],r=e.shape.slice(-2)[0];if(o!==r)throw new Ce(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${n.shape} and y shape = ${e.shape}`)}if(n.rank===2&&e.rank===2)return Lm({a:n,b:e,transposeA:!1,transposeB:!1,bias:s?$d(n.rank,s,An()):null,activation:t});{const o=n.shape.slice(),r=o.pop();n=_(n,[-1,r]);const i=e.shape.slice(),a=i.pop(),l=i.pop(),c=[...i,a],u=Array.from({length:e.rank},(f,g)=>g===0?e.rank-2:g<=e.rank-2?g-1:g);e=_(Ee(e,u),[l,-1]);const h=[...o,...c];return _(Lm({a:n,b:e,transposeA:!1,transposeB:!1,bias:s?$d(n.rank,s,An()):null,activation:t}),h)}}function Qg(n,e,t){return P(()=>(Array.isArray(e)?e=At(e,"int32"):e=oe(e,"int32"),lh(n,e,t)))}function Oi(n){return D(n,n)}function $d(n,e,t){const s=e.shape;if(e.rank!==1&&e.rank!==n)throw new A(`Unexpected bias dimensions: ${e.rank}; expected it to be 1 or ${n}`);if(n===5){if(t==="channelsFirst")return s.length===1?_(e,[1,s[0],1,1,1]):_(e,[1,s[3],s[0],s[1],s[2]]);if(t==="channelsLast")return s.length===1?_(e,[1,1,1,1,s[0]]):_(e,[1].concat(s))}else if(n===4){if(t==="channelsFirst")return s.length===1?_(e,[1,s[0],1,1]):_(e,[1,s[2],s[0],s[1]]);if(t==="channelsLast")return s.length===1?_(e,[1,1,1,s[0]]):_(e,[1].concat(s))}else if(n===3){if(t==="channelsFirst")return s.length===1?_(e,[1,s[0],1]):_(e,[1,s[1],s[0]]);if(t==="channelsLast")return s.length===1?_(e,[1,1,s[0]]):_(e,[1].concat(s))}else if(n<3)return e;throw new A(`Unsupported input rank by biasAdd: ${e.rank}`)}function Dn(n,e,t){return P(()=>(t==null&&(t=An()),ot(t),ee(n,$d(n.rank,e,t))))}function HN(n,e=1){if(e!==1)throw new Ce(`Support for alpha values other than 1 (${e}) is not implemented yet.`);return Il(n)}function qN(n){return P(()=>me(n,ee(Lt(n),1)))}function Jg(n,e,t,s){return P(()=>aS(n,e,t,s))}function jN(n){return P(()=>{const e=ee(.5,D(.2,n));return nn(e,0,1)})}function Li(n,e,t=!1){return t?n():e()}/** * @license * Copyright 2018 Google LLC * @@ -7521,7 +7521,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */const jN=["fanIn","fanOut","fanAvg"],qN=["normal","uniform","truncatedNormal"];/** + */const KN=["fanIn","fanOut","fanAvg"],XN=["normal","uniform","truncatedNormal"];/** * @license * Copyright 2018 Google LLC * @@ -7529,7 +7529,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function KN(n){fo(jN,"FanMode",n)}function XN(n){fo(qN,"Distribution",n)}class bn extends Zo{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}}class Jg extends bn{apply(e,t){return st(e,t)}}Jg.className="Zeros",Z(Jg);class vd extends bn{apply(e,t){return Nn(e,t)}}vd.className="Ones",Z(vd);class ex extends bn{constructor(e){if(super(),typeof e!="object")throw new A(`Expected argument of type ConstantConfig but got ${e}`);if(e.value===void 0)throw new A(`config must have value set but got ${e}`);this.value=e.value}apply(e,t){return z(()=>F(Fe(this.value),Nn(e,t)))}getConfig(){return{value:this.value}}}ex.className="Constant",Z(ex);class tx extends bn{constructor(e){super(),this.DEFAULT_MINVAL=-.05,this.DEFAULT_MAXVAL=.05,this.minval=e.minval||this.DEFAULT_MINVAL,this.maxval=e.maxval||this.DEFAULT_MAXVAL,this.seed=e.seed}apply(e,t){return Si(e,this.minval,this.maxval,t,this.seed)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}tx.className="RandomUniform",Z(tx);class nx extends bn{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if(t=t||"float32",t!=="float32"&&t!=="int32")throw new Ce(`randomNormal does not support dType ${t}.`);return Ml(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}nx.className="RandomNormal",Z(nx);class sx extends bn{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if(t=t||"float32",t!=="float32"&&t!=="int32")throw new Ce(`truncatedNormal does not support dType ${t}.`);return Dm(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}sx.className="TruncatedNormal",Z(sx);class ox extends bn{constructor(e){super(),this.gain=e.gain!=null?e.gain:1}apply(e,t){return z(()=>{if(e.length!==2||e[0]!==e[1])throw new A("Identity matrix initializer can only be used for 2D square matrices.");return F(this.gain,fm(e[0]))})}getConfig(){return{gain:this.gain}}}ox.className="Identity",Z(ox);function YN(n,e="channelsLast"){let t,s;if(ot(e),n.length===2)t=n[0],s=n[1];else if([3,4,5].indexOf(n.length)!==-1){if(e==="channelsFirst"){const o=Ts(n,2);t=n[1]*o,s=n[0]*o}else if(e==="channelsLast"){const o=Ts(n,0,n.length-2);t=n[n.length-2]*o,s=n[n.length-1]*o}}else{const o=Ts(n);t=Math.sqrt(o),s=Math.sqrt(o)}return[t,s]}class Qt extends bn{constructor(e){if(super(),e.scale<0)throw new A(`scale must be a positive float. Got: ${e.scale}`);this.scale=e.scale==null?1:e.scale,this.mode=e.mode==null?"fanIn":e.mode,KN(this.mode),this.distribution=e.distribution==null?"normal":e.distribution,XN(this.distribution),this.seed=e.seed}apply(e,t){const s=YN(e),o=s[0],r=s[1];let i=this.scale;if(this.mode==="fanIn"?i/=Math.max(1,o):this.mode==="fanOut"?i/=Math.max(1,r):i/=Math.max(1,(o+r)/2),this.distribution==="normal"){const a=Math.sqrt(i);if(t=t||"float32",t!=="float32"&&t!=="int32")throw new Ce(`${this.getClassName()} does not support dType ${t}.`);return Dm(e,0,a,t,this.seed)}else{const a=Math.sqrt(3*i);return Si(e,-a,a,t,this.seed)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}Qt.className="VarianceScaling",Z(Qt);class kd extends Qt{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qt.className}}kd.className="GlorotUniform",Z(kd);class Sd extends Qt{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qt.className}}Sd.className="GlorotNormal",Z(Sd);class Td extends Qt{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qt.className}}Td.className="HeNormal",Z(Td);class Nd extends Qt{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qt.className}}Nd.className="HeUniform",Z(Nd);class Ed extends Qt{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qt.className}}Ed.className="LeCunNormal",Z(Ed);class Rd extends Qt{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qt.className}}Rd.className="LeCunUniform",Z(Rd);class rx extends bn{constructor(e){super(),this.DEFAULT_GAIN=1,this.ELEMENTS_WARN_SLOW=2e3,this.gain=e.gain==null?this.DEFAULT_GAIN:e.gain,this.seed=e.seed}apply(e,t){return z(()=>{if(e.length<2)throw new Ce("Shape must be at least 2D.");if(t!=="int32"&&t!=="float32"&&t!==void 0)throw new TypeError(`Unsupported data type ${t}.`);t=t;const s=H(e.slice(0,-1)),o=e[e.length-1],r=s*o;r>this.ELEMENTS_WARN_SLOW&&console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${r}) elements: Slowness may result.`);const i=[Math.max(o,s),Math.min(o,s)],a=Ml(i,0,1,t,this.seed),l=t2.qr(a,!1);let c=l[0];const h=l[1].flatten().stridedSlice([0],[Math.min(o,s)*Math.min(o,s)],[Math.min(o,s)+1]);return c=F(c,h.sign()),sD(Fe(this.value),Nn(e,t)))}getConfig(){return{value:this.value}}}tx.className="Constant",Y(tx);class nx extends bn{constructor(e){super(),this.DEFAULT_MINVAL=-.05,this.DEFAULT_MAXVAL=.05,this.minval=e.minval||this.DEFAULT_MINVAL,this.maxval=e.maxval||this.DEFAULT_MAXVAL,this.seed=e.seed}apply(e,t){return Si(e,this.minval,this.maxval,t,this.seed)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}nx.className="RandomUniform",Y(nx);class sx extends bn{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if(t=t||"float32",t!=="float32"&&t!=="int32")throw new Ce(`randomNormal does not support dType ${t}.`);return Pl(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}sx.className="RandomNormal",Y(sx);class ox extends bn{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if(t=t||"float32",t!=="float32"&&t!=="int32")throw new Ce(`truncatedNormal does not support dType ${t}.`);return Fm(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}ox.className="TruncatedNormal",Y(ox);class rx extends bn{constructor(e){super(),this.gain=e.gain!=null?e.gain:1}apply(e,t){return P(()=>{if(e.length!==2||e[0]!==e[1])throw new A("Identity matrix initializer can only be used for 2D square matrices.");return D(this.gain,mm(e[0]))})}getConfig(){return{gain:this.gain}}}rx.className="Identity",Y(rx);function QN(n,e="channelsLast"){let t,s;if(ot(e),n.length===2)t=n[0],s=n[1];else if([3,4,5].indexOf(n.length)!==-1){if(e==="channelsFirst"){const o=Ts(n,2);t=n[1]*o,s=n[0]*o}else if(e==="channelsLast"){const o=Ts(n,0,n.length-2);t=n[n.length-2]*o,s=n[n.length-1]*o}}else{const o=Ts(n);t=Math.sqrt(o),s=Math.sqrt(o)}return[t,s]}class Qt extends bn{constructor(e){if(super(),e.scale<0)throw new A(`scale must be a positive float. Got: ${e.scale}`);this.scale=e.scale==null?1:e.scale,this.mode=e.mode==null?"fanIn":e.mode,YN(this.mode),this.distribution=e.distribution==null?"normal":e.distribution,ZN(this.distribution),this.seed=e.seed}apply(e,t){const s=QN(e),o=s[0],r=s[1];let i=this.scale;if(this.mode==="fanIn"?i/=Math.max(1,o):this.mode==="fanOut"?i/=Math.max(1,r):i/=Math.max(1,(o+r)/2),this.distribution==="normal"){const a=Math.sqrt(i);if(t=t||"float32",t!=="float32"&&t!=="int32")throw new Ce(`${this.getClassName()} does not support dType ${t}.`);return Fm(e,0,a,t,this.seed)}else{const a=Math.sqrt(3*i);return Si(e,-a,a,t,this.seed)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}Qt.className="VarianceScaling",Y(Qt);class kd extends Qt{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qt.className}}kd.className="GlorotUniform",Y(kd);class Sd extends Qt{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qt.className}}Sd.className="GlorotNormal",Y(Sd);class Td extends Qt{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qt.className}}Td.className="HeNormal",Y(Td);class Nd extends Qt{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qt.className}}Nd.className="HeUniform",Y(Nd);class Ed extends Qt{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qt.className}}Ed.className="LeCunNormal",Y(Ed);class Rd extends Qt{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qt.className}}Rd.className="LeCunUniform",Y(Rd);class ix extends bn{constructor(e){super(),this.DEFAULT_GAIN=1,this.ELEMENTS_WARN_SLOW=2e3,this.gain=e.gain==null?this.DEFAULT_GAIN:e.gain,this.seed=e.seed}apply(e,t){return P(()=>{if(e.length<2)throw new Ce("Shape must be at least 2D.");if(t!=="int32"&&t!=="float32"&&t!==void 0)throw new TypeError(`Unsupported data type ${t}.`);t=t;const s=H(e.slice(0,-1)),o=e[e.length-1],r=s*o;r>this.ELEMENTS_WARN_SLOW&&console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${r}) elements: Slowness may result.`);const i=[Math.max(o,s),Math.min(o,s)],a=Pl(i,0,1,t,this.seed),l=s2.qr(a,!1);let c=l[0];const h=l[1].flatten().stridedSlice([0],[Math.min(o,s)*Math.min(o,s)],[Math.min(o,s)+1]);return c=D(c,h.sign()),ss*o);return e}/** + */function zl(n){let e=0;for(const t of n)t.shape.length===0?e+=1:e+=t.shape.reduce((s,o)=>s*o);return e}/** * @license * Copyright 2018 Google LLC * @@ -7553,7 +7553,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */const lx="Variable";class ZN{constructor(e,t="float32",s=lx,o=!0,r=null){this.dtype=t??"float32",this.shape=e.shape,this.id=Gg(),s=s??lx,this.originalName=qg(s),this.name=Kg(this.originalName),this.trainable_=o,this.constraint=r,this.val=eS(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),QN(this.val,e),this.val.id!==e.id&&(this.val.assign(e),this.constraint!=null&&this.val.assign(this.constraint.apply(this.val))),this}dispose(){this.assertNotDisposed(),this.val.dispose()}assertNotDisposed(){if(this.val.isDisposed)throw new Error(`LayersVariable ${this.name} is already disposed.`)}get trainable(){return this.trainable_}set trainable(e){this.trainable_=e,this.val.trainable=e}}function QN(n,e){if(n.shape.toString()!==e.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(n.shape)+" vs. "+JSON.stringify(e.shape))}function Dd(n){return n.map(e=>e.read())}function Fd(n){n.forEach(e=>{e[0].write(e[1])})}/** + */const cx="Variable";class JN{constructor(e,t="float32",s=cx,o=!0,r=null){this.dtype=t??"float32",this.shape=e.shape,this.id=Hg(),s=s??cx,this.originalName=Kg(s),this.name=Xg(this.originalName),this.trainable_=o,this.constraint=r,this.val=nS(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),eE(this.val,e),this.val.id!==e.id&&(this.val.assign(e),this.constraint!=null&&this.val.assign(this.constraint.apply(this.val))),this}dispose(){this.assertNotDisposed(),this.val.dispose()}assertNotDisposed(){if(this.val.isDisposed)throw new Error(`LayersVariable ${this.name} is already disposed.`)}get trainable(){return this.trainable_}set trainable(e){this.trainable_=e,this.val.trainable=e}}function eE(n,e){if(n.shape.toString()!==e.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(n.shape)+" vs. "+JSON.stringify(e.shape))}function Dd(n){return n.map(e=>e.read())}function Fd(n){n.forEach(e=>{e[0].write(e[1])})}/** * @license * Copyright 2018 Google LLC * @@ -7561,7 +7561,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class ht{constructor(e){this.dtype=e.dtype,this.shape=e.shape,e.shape!=null?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}}class Yn{constructor(e,t,s,o,r,i,a){this.dtype=e,this.shape=t,this.sourceLayer=s,this.inputs=o,this.callArgs=r,this.outputTensorIndex=a,this.id=Gg(),i!=null&&(this.originalName=qg(i),this.name=Kg(this.originalName)),this.rank=t.length}}let JN=0;class zl{constructor(e,t){this.callArgs=t,this.id=JN++,this.outboundLayer=e.outboundLayer,this.inboundLayers=e.inboundLayers,this.nodeIndices=e.nodeIndices,this.tensorIndices=e.tensorIndices,this.inputTensors=e.inputTensors,this.outputTensors=e.outputTensors,this.inputMasks=e.inputMasks,this.outputMasks=e.outputMasks,this.inputShapes=e.inputShapes,this.outputShapes=e.outputShapes;for(const s of e.inboundLayers)s!=null&&s.outboundNodes.push(this);e.outboundLayer.inboundNodes.push(this)}getConfig(){const e=[];for(const t of this.inboundLayers)t!=null?e.push(t.name):e.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let eE=0;class ke extends Zo{constructor(e={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=eE++,this.activityRegularizer=null,this.inputSpec=null,this.supportsMasking=!1,this._trainableWeights=[],this._nonTrainableWeights=[],this._losses=[],this._updates=[],this._built=!1,this.inboundNodes=[],this.outboundNodes=[];let t=e.name;if(!t){const s=this.getClassName();t=hs(s)+"_"+Ol(s)}if(this.name=t,this.trainable_=e.trainable==null?!0:e.trainable,e.inputShape!=null||e.batchInputShape!=null){let s;if(e.batchInputShape!=null)s=e.batchInputShape;else if(e.inputShape!=null){let r=null;e.batchSize!=null&&(r=e.batchSize),s=[r].concat(e.inputShape)}this.batchInputShape=s;let o=e.dtype;o==null&&(o=e.inputDType),o==null&&(o="float32"),this.dtype=o}e.weights!=null?this.initialWeights=e.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}static nodeKey(e,t){return e.name+"_ib-"+t.toString()}getNodeAtIndex(e,t){if(this.inboundNodes.length===0)throw new gn(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new A(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return Gt(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return Gt(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new jn(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(this.inboundNodes.length===0)throw new jn(`Layer ${this.name} is not connected, no input to return.`);return Gt(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(this.inboundNodes.length===0)throw new jn(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new jn(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return Gt(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map(e=>e())}get updates(){return this._updates}get built(){return this._built}set built(e){this._built=e}get trainable(){return this.trainable_}set trainable(e){this._trainableWeights.forEach(t=>t.trainable=e),this.trainable_=e}get trainableWeights(){return this.trainable_?this._trainableWeights.filter(e=>e.trainable):[]}set trainableWeights(e){this._trainableWeights=e}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter(e=>!e.trainable).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(e){this._nonTrainableWeights=e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}get stateful(){return this._stateful}resetStates(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(e){const t=Me(e);if(this.inputSpec==null||this.inputSpec.length===0)return;const s=Me(this.inputSpec);if(t.length!==s.length)throw new A(`Layer ${this.name} expects ${s.length} inputs, but it received ${t.length} input tensors. Input received: ${e}`);for(let o=0;oi.maxNDim)throw new A(`Input ${o} is incompatible with layer ${this.name}: expected max_ndim=${i.maxNDim}, found ndim=${a}`);if(i.minNDim!=null&&a=0?l[u]:l[l.length+u];if(h!=null&&[h,null].indexOf(d)===-1)throw new A(`Input ${o} is incompatible with layer ${this.name}: expected axis ${u} of input shape to have value ${h} but got shape ${l}.`)}}if(i.shape!=null)for(let l=0;l{if(!this.built){this.assertInputCompatibility(e);const i=[];for(const a of Me(e))i.push(a.shape);this.build(Gt(i)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),this._refCount===null&&r&&(this._refCount=1)}if(this.assertInputCompatibility(e),r){let i=this.call(e,t);this.supportsMasking&&this.setMaskMetadata(e,i);const a=Me(i),l=[];for(let c of a)s.indexOf(c)!==-1&&(c=c.clone()),l.push(c);if(i=Gt(l),this.activityRegularizer!=null)throw new Ce("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return i}else{const i=tE(e),a=this.computeOutputShape(i);let l;const c=nE(e);if(this.warnOnIncompatibleInputShape(Array.isArray(e)?i[0]:i),a!=null&&a.length>0&&Array.isArray(a[0])?l=a.map((u,h)=>new Yn(c,u,this,Me(e),t,this.name,h)):l=new Yn(c,a,this,Me(e),t,this.name),this.addInboundNode(e,l,null,null,i,a,t),this._refCount++,this.activityRegularizer!=null)throw new Ce("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return l}})}warnOnIncompatibleInputShape(e){if(this.batchInputShape!=null)if(e.length!==this.batchInputShape.length)console.warn(`The rank of the input tensor provided (shape: ${JSON.stringify(e)}) does not match that of the batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer ${this.name}`);else{let t=!1;this.batchInputShape.forEach((s,o)=>{s!=null&&e[o]!=null&&e[o]!==s&&(t=!0)}),t&&console.warn(`The shape of the input tensor (${JSON.stringify(e)}) does not match the expectation of layer ${this.name}: ${JSON.stringify(this.batchInputShape)}`)}}get outputShape(){if(this.inboundNodes==null||this.inboundNodes.length===0)throw new jn(`The layer ${this.name} has never been called and thus has no defined output shape.`);const e=[];for(const t of this.inboundNodes){const s=JSON.stringify(t.outputShapes);e.indexOf(s)===-1&&e.push(s)}if(e.length===1){const t=this.inboundNodes[0].outputShapes;return Array.isArray(t)&&Array.isArray(t[0])&&t.length===1?t[0]:t}else throw new jn(`The layer ${this.name} has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.`)}countParams(){if(!this.built)throw new gn(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return Bl(this.weights)}build(e){this.built=!0}getWeights(e=!1){return Dd(e?this.trainableWeights:this.weights)}setWeights(e){z(()=>{const t=this.weights;if(t.length!==e.length)throw new A(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${e.length}, but the layer was expecting ${t.length} weights. Provided weights: ${e}...`);if(t.length===0)return;const s=[],o=Dd(t);for(let r=0;rr.apply(u.read())),i==null&&(i=!0),i?this._trainableWeights.push(u):this._nonTrainableWeights.push(u),u}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){e==null||Array.isArray(e)&&e.length===0||(e=Me(e),this._losses!==void 0&&this._losses!==null&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,t){if(!this.supportsMasking){if(t!=null)if(Array.isArray(t))t.forEach(s=>{if(s!=null)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)});else throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);return null}return t}setMaskMetadata(e,t,s){if(!this.supportsMasking)return;const o=this.computeMask(e,s),r=Me(t),i=Me(o);if(r.length!==i.length)throw new Error(`${this.name} outputs ${r.length} tensors but ${r.length} masks for those tensors`);for(let a=0;ae.dispose()),this.weights.length}assertNotDisposed(){if(this._refCount===0)throw new Error(`Layer '${this.name}' is already disposed.`)}dispose(){if(!this.built)throw new Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`);if(this._refCount===null)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return--this._refCount===0&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}}function tE(n){n=Me(n);const e=[];for(const t of n)e.push(t.shape);return Gt(e)}function nE(n){return"float32"}function cx(n,e,t){if((e==null||t!=null&&t>0)&&(e=n.sourceLayer,t=n.nodeIndex),e.inboundNodes.length===0)return[n];{const s=e.inboundNodes[t];if(s.inboundLayers.length===0)return s.inputTensors;{const o=[];for(let r=0;r1)throw new qn(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(this.inboundNodes.length===0)throw new qn(`Layer ${this.name} is not connected, no input to return.`);return Ht(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(this.inboundNodes.length===0)throw new qn(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new qn(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return Ht(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map(e=>e())}get updates(){return this._updates}get built(){return this._built}set built(e){this._built=e}get trainable(){return this.trainable_}set trainable(e){this._trainableWeights.forEach(t=>t.trainable=e),this.trainable_=e}get trainableWeights(){return this.trainable_?this._trainableWeights.filter(e=>e.trainable):[]}set trainableWeights(e){this._trainableWeights=e}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter(e=>!e.trainable).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(e){this._nonTrainableWeights=e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}get stateful(){return this._stateful}resetStates(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(e){const t=Me(e);if(this.inputSpec==null||this.inputSpec.length===0)return;const s=Me(this.inputSpec);if(t.length!==s.length)throw new A(`Layer ${this.name} expects ${s.length} inputs, but it received ${t.length} input tensors. Input received: ${e}`);for(let o=0;oi.maxNDim)throw new A(`Input ${o} is incompatible with layer ${this.name}: expected max_ndim=${i.maxNDim}, found ndim=${a}`);if(i.minNDim!=null&&a=0?l[u]:l[l.length+u];if(h!=null&&[h,null].indexOf(d)===-1)throw new A(`Input ${o} is incompatible with layer ${this.name}: expected axis ${u} of input shape to have value ${h} but got shape ${l}.`)}}if(i.shape!=null)for(let l=0;l{if(!this.built){this.assertInputCompatibility(e);const i=[];for(const a of Me(e))i.push(a.shape);this.build(Ht(i)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),this._refCount===null&&r&&(this._refCount=1)}if(this.assertInputCompatibility(e),r){let i=this.call(e,t);this.supportsMasking&&this.setMaskMetadata(e,i);const a=Me(i),l=[];for(let c of a)s.indexOf(c)!==-1&&(c=c.clone()),l.push(c);if(i=Ht(l),this.activityRegularizer!=null)throw new Ce("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return i}else{const i=sE(e),a=this.computeOutputShape(i);let l;const c=oE(e);if(this.warnOnIncompatibleInputShape(Array.isArray(e)?i[0]:i),a!=null&&a.length>0&&Array.isArray(a[0])?l=a.map((u,h)=>new Yn(c,u,this,Me(e),t,this.name,h)):l=new Yn(c,a,this,Me(e),t,this.name),this.addInboundNode(e,l,null,null,i,a,t),this._refCount++,this.activityRegularizer!=null)throw new Ce("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return l}})}warnOnIncompatibleInputShape(e){if(this.batchInputShape!=null)if(e.length!==this.batchInputShape.length)console.warn(`The rank of the input tensor provided (shape: ${JSON.stringify(e)}) does not match that of the batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer ${this.name}`);else{let t=!1;this.batchInputShape.forEach((s,o)=>{s!=null&&e[o]!=null&&e[o]!==s&&(t=!0)}),t&&console.warn(`The shape of the input tensor (${JSON.stringify(e)}) does not match the expectation of layer ${this.name}: ${JSON.stringify(this.batchInputShape)}`)}}get outputShape(){if(this.inboundNodes==null||this.inboundNodes.length===0)throw new qn(`The layer ${this.name} has never been called and thus has no defined output shape.`);const e=[];for(const t of this.inboundNodes){const s=JSON.stringify(t.outputShapes);e.indexOf(s)===-1&&e.push(s)}if(e.length===1){const t=this.inboundNodes[0].outputShapes;return Array.isArray(t)&&Array.isArray(t[0])&&t.length===1?t[0]:t}else throw new qn(`The layer ${this.name} has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.`)}countParams(){if(!this.built)throw new gn(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return zl(this.weights)}build(e){this.built=!0}getWeights(e=!1){return Dd(e?this.trainableWeights:this.weights)}setWeights(e){P(()=>{const t=this.weights;if(t.length!==e.length)throw new A(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${e.length}, but the layer was expecting ${t.length} weights. Provided weights: ${e}...`);if(t.length===0)return;const s=[],o=Dd(t);for(let r=0;rr.apply(u.read())),i==null&&(i=!0),i?this._trainableWeights.push(u):this._nonTrainableWeights.push(u),u}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){e==null||Array.isArray(e)&&e.length===0||(e=Me(e),this._losses!==void 0&&this._losses!==null&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,t){if(!this.supportsMasking){if(t!=null)if(Array.isArray(t))t.forEach(s=>{if(s!=null)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)});else throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);return null}return t}setMaskMetadata(e,t,s){if(!this.supportsMasking)return;const o=this.computeMask(e,s),r=Me(t),i=Me(o);if(r.length!==i.length)throw new Error(`${this.name} outputs ${r.length} tensors but ${r.length} masks for those tensors`);for(let a=0;ae.dispose()),this.weights.length}assertNotDisposed(){if(this._refCount===0)throw new Error(`Layer '${this.name}' is already disposed.`)}dispose(){if(!this.built)throw new Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`);if(this._refCount===null)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return--this._refCount===0&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}}function sE(n){n=Me(n);const e=[];for(const t of n)e.push(t.shape);return Ht(e)}function oE(n){return"float32"}function ux(n,e,t){if((e==null||t!=null&&t>0)&&(e=n.sourceLayer,t=n.nodeIndex),e.inboundNodes.length===0)return[n];{const s=e.inboundNodes[t];if(s.inboundLayers.length===0)return s.inputTensors;{const o=[];for(let r=0;rf.name),l=[],c=e.names();for(const f of a)c.indexOf(f)!==-1?l.push(e.getValue(f)):l.push(null);s!=null&&(s.maxNumTensors=-1/0,s.minNumTensors=1/0);const u=a.join(",")+"|"+e.names().sort().join(",");let h=Vl.get(u),d;if(h==null){const f=lE(i,e);h=f.sorted,d=f.recipientCounts,Vl.put(u,h),Wl.put(u,d)}d={},o||Object.assign(d,Wl.get(u));const p=new Es(e);for(let f=0;fs.maxNumTensors&&(s.maxNumTensors=S),S0,()=>"Expected at least one fetch, got none");let t=[],s={};if(n.length===1){const o=ux(n[0],e);t=o.sorted,s=o.recipientMap}else{const o=new Set;for(const r of n){const{sorted:i,recipientMap:a}=ux(r,e);for(const l of i)o.has(l.name)||(t.push(l),o.add(l.name));for(const l in a)s[l]==null&&(s[l]=new Set),a[l].forEach(c=>s[l].add(c))}}return{sorted:t,recipientCounts:cE(s)}}function cE(n){const e={};for(const t in n)e[t]=n[t].size;return e}function ux(n,e){const t=new Set,s=[],o={};for(const a of e.names())t.add(a);const r=[],i=[];for(r.push(n);r.length>0;){const a=r[r.length-1];if(t.has(a.name)){r.pop();continue}const l=i[i.length-1]===r.length-1;if(a.inputs.length===0||l)r.pop(),s.push(a),t.add(a.name),l&&i.pop();else{i.push(r.length-1);for(const c of a.inputs)o[c.name]==null&&(o[c.name]=new Set),o[c.name].add(a.name),!t.has(c.name)&&r.push(c)}}return{sorted:s,recipientMap:o}}function uE(n){let e;if(n.sourceLayer.inboundNodes.length===1)e=n.sourceLayer.output;else{let t=null;for(let s=0;sf.name),l=[],c=e.names();for(const f of a)c.indexOf(f)!==-1?l.push(e.getValue(f)):l.push(null);s!=null&&(s.maxNumTensors=-1/0,s.minNumTensors=1/0);const u=a.join(",")+"|"+e.names().sort().join(",");let h=Wl.get(u),d;if(h==null){const f=uE(i,e);h=f.sorted,d=f.recipientCounts,Wl.put(u,h),Ul.put(u,d)}d={},o||Object.assign(d,Ul.get(u));const p=new Es(e);for(let f=0;fs.maxNumTensors&&(s.maxNumTensors=S),S0,()=>"Expected at least one fetch, got none");let t=[],s={};if(n.length===1){const o=hx(n[0],e);t=o.sorted,s=o.recipientMap}else{const o=new Set;for(const r of n){const{sorted:i,recipientMap:a}=hx(r,e);for(const l of i)o.has(l.name)||(t.push(l),o.add(l.name));for(const l in a)s[l]==null&&(s[l]=new Set),a[l].forEach(c=>s[l].add(c))}}return{sorted:t,recipientCounts:hE(s)}}function hE(n){const e={};for(const t in n)e[t]=n[t].size;return e}function hx(n,e){const t=new Set,s=[],o={};for(const a of e.names())t.add(a);const r=[],i=[];for(r.push(n);r.length>0;){const a=r[r.length-1];if(t.has(a.name)){r.pop();continue}const l=i[i.length-1]===r.length-1;if(a.inputs.length===0||l)r.pop(),s.push(a),t.add(a.name),l&&i.pop();else{i.push(r.length-1);for(const c of a.inputs)o[c.name]==null&&(o[c.name]=new Set),o[c.name].add(a.name),!t.has(c.name)&&r.push(c)}}return{sorted:s,recipientMap:o}}function dE(n){let e;if(n.sourceLayer.inboundNodes.length===1)e=n.sourceLayer.output;else{let t=null;for(let s=0;s100,aE);/** + */W().registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES",()=>100,cE);/** * @license * Copyright 2018 Google LLC * @@ -7600,7 +7600,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function _d(n,e){return z(()=>Lt(pe(F(n,n),e,!0)))}class Bi extends Zo{getConfig(){return{}}}class hx extends Bi{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return z(()=>{const t=_d(e,this.axis),s=nn(t,0,this.maxValue);return F(e,me(s,ee(ut(),t)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}hx.className="MaxNorm",Z(hx);class dx extends Bi{constructor(e){super(),this.defaultAxis=0,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return z(()=>me(e,ee(ut(),_d(e,this.axis))))}getConfig(){return{axis:this.axis}}}dx.className="UnitNorm",Z(dx);class px extends Bi{apply(e){return lo(e)}}px.className="NonNeg",Z(px);class fx extends Bi{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=e.minValue!=null?e.minValue:this.defaultMinValue,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.rate=e.rate!=null?e.rate:this.defaultRate,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return z(()=>{const t=_d(e,this.axis),s=ee(F(this.rate,nn(t,this.minValue,this.maxValue)),F(1-this.rate,t));return F(e,me(s,ee(ut(),t)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}fx.className="MinMaxNorm",Z(fx);const mx={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function dt(n){return gd(n)}function gx(n,e={}){return Di(n,mn.getMap().classNameMap,e,"constraint")}function pt(n){if(n==null)return null;if(typeof n=="string"){const t={className:n in mx?mx[n]:n,config:{}};return gx(t)}else return n instanceof Bi?n:gx(n)}/** + */function _d(n,e){return P(()=>Rt(pe(D(n,n),e,!0)))}class Bi extends Zo{getConfig(){return{}}}class dx extends Bi{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return P(()=>{const t=_d(e,this.axis),s=nn(t,0,this.maxValue);return D(e,me(s,ee(ut(),t)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}dx.className="MaxNorm",Y(dx);class px extends Bi{constructor(e){super(),this.defaultAxis=0,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return P(()=>me(e,ee(ut(),_d(e,this.axis))))}getConfig(){return{axis:this.axis}}}px.className="UnitNorm",Y(px);class fx extends Bi{apply(e){return co(e)}}fx.className="NonNeg",Y(fx);class mx extends Bi{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=e.minValue!=null?e.minValue:this.defaultMinValue,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.rate=e.rate!=null?e.rate:this.defaultRate,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return P(()=>{const t=_d(e,this.axis),s=ee(D(this.rate,nn(t,this.minValue,this.maxValue)),D(1-this.rate,t));return D(e,me(s,ee(ut(),t)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}mx.className="MinMaxNorm",Y(mx);const gx={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function dt(n){return gd(n)}function xx(n,e={}){return Di(n,mn.getMap().classNameMap,e,"constraint")}function pt(n){if(n==null)return null;if(typeof n=="string"){const t={className:n in gx?gx[n]:n,config:{}};return xx(t)}else return n instanceof Bi?n:xx(n)}/** * @license * Copyright 2018 Google LLC * @@ -7608,7 +7608,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */async function xo(n){if(n==null)return;const e=[],t=[],s=[];for(const o in n){const r=n[o];if(typeof r!="number"){const i=r;e.push(i.data()),t.push(o),s.push(i)}}if(e.length>0){const o=await Promise.all(e);for(let r=0;r0){const o=await Promise.all(e);for(let r=0;ree(this.totals[o],F(r,s)));this.totals[o]=a,i!=null&&i.dispose()}}}async onEpochEnd(e,t){if(t!=null)for(const s of this.params.metrics)this.totals[s]!=null&&(typeof this.totals[s]=="number"?t[s]=this.totals[s]/this.seen:z(()=>{const o=F(me(1,this.seen),this.totals[s]);t[s]=o,this.totals[s].dispose(),dn(t[s])}))}}class fE extends zi{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,t){t==null&&(t={}),this.epoch.push(e);for(const s in t)this.history[s]==null&&(this.history[s]=[]),this.history[s].push(t[s])}async syncData(){const e=[],t=[],s=[];for(const r in this.history){const i=this.history[r];for(let a=0;anew mE(s,e))}class yn{constructor(){}static registerCallbackConstructor(e,t){$(e>=0&&Number.isInteger(e),()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`),yn.checkForDuplicate(t),yn.constructors[e]==null&&(yn.constructors[e]=[]),yn.constructors[e].push(t)}static checkForDuplicate(e){for(const t in yn.constructors)yn.constructors[+t].forEach(o=>{if(o===e)throw new A("Duplicate callback constructor.")})}static clear(){yn.constructors={}}static createCallbacks(e){const t=[];for(const s in yn.constructors){const o=+s;e>=o&&t.push(...yn.constructors[o])}return t.map(s=>new s)}}yn.constructors={};function wx(n,e,t,s,o,r,i,a,l){const c=new fE,u=[new pE,...yn.createCallbacks(e)];n!=null&&u.push(...n),u.push(c);const h=new dE(u);return h.setParams({epochs:t,initialEpoch:s,samples:o,steps:r,batchSize:i,verbose:e,doValidation:a,metrics:l}),{callbackList:h,history:c}}/** + */var yx;(function(n){n[n.SILENT=0]="SILENT",n[n.VERBOSE=1]="VERBOSE"})(yx||(yx={}));const pE=125;class zi{constructor(){this.validationData=null}setParams(e){this.params=e}async onEpochBegin(e,t){}async onEpochEnd(e,t){}async onBatchBegin(e,t){}async onBatchEnd(e,t){}async onTrainBegin(e){}async onTrainEnd(e){}setModel(e){}}class fE{constructor(e,t=10){e==null&&(e=[]),this.callbacks=e,this.queueLength=t}append(e){this.callbacks.push(e)}setParams(e){for(const t of this.callbacks)t.setParams(e)}setModel(e){for(const t of this.callbacks)t.setModel(e)}async onEpochBegin(e,t){t==null&&(t={});for(const s of this.callbacks)await s.onEpochBegin(e,t)}async onEpochEnd(e,t){t==null&&(t={});for(const s of this.callbacks)await s.onEpochEnd(e,t)}async onBatchBegin(e,t){t==null&&(t={});for(const s of this.callbacks)await s.onBatchBegin(e,t)}async onBatchEnd(e,t){t==null&&(t={});for(const s of this.callbacks)await s.onBatchEnd(e,t)}async onTrainBegin(e){e==null&&(e={});for(const t of this.callbacks)await t.onTrainBegin(e)}async onTrainEnd(e){e==null&&(e={});for(const t of this.callbacks)await t.onTrainEnd(e)}}class mE extends zi{constructor(){super()}async onEpochBegin(e){this.seen=0,this.totals={}}async onBatchEnd(e,t){t==null&&(t={});const s=t.size==null?0:t.size;this.seen+=s;for(const o in t){const r=t[o];if(typeof r=="number")this.totals.hasOwnProperty(o)||(this.totals[o]=0),this.totals[o]=this.totals[o]+r*s;else{let i;o in this.totals?i=this.totals[o]:this.totals[o]=0;const a=P(()=>ee(this.totals[o],D(r,s)));this.totals[o]=a,i!=null&&i.dispose()}}}async onEpochEnd(e,t){if(t!=null)for(const s of this.params.metrics)this.totals[s]!=null&&(typeof this.totals[s]=="number"?t[s]=this.totals[s]/this.seen:P(()=>{const o=D(me(1,this.seen),this.totals[s]);t[s]=o,this.totals[s].dispose(),dn(t[s])}))}}class gE extends zi{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,t){t==null&&(t={}),this.epoch.push(e);for(const s in t)this.history[s]==null&&(this.history[s]=[]),this.history[s].push(t[s])}async syncData(){const e=[],t=[],s=[];for(const r in this.history){const i=this.history[r];for(let a=0;anew xE(s,e))}class yn{constructor(){}static registerCallbackConstructor(e,t){$(e>=0&&Number.isInteger(e),()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`),yn.checkForDuplicate(t),yn.constructors[e]==null&&(yn.constructors[e]=[]),yn.constructors[e].push(t)}static checkForDuplicate(e){for(const t in yn.constructors)yn.constructors[+t].forEach(o=>{if(o===e)throw new A("Duplicate callback constructor.")})}static clear(){yn.constructors={}}static createCallbacks(e){const t=[];for(const s in yn.constructors){const o=+s;e>=o&&t.push(...yn.constructors[o])}return t.map(s=>new s)}}yn.constructors={};function Cx(n,e,t,s,o,r,i,a,l){const c=new gE,u=[new mE,...yn.createCallbacks(e)];n!=null&&u.push(...n),u.push(c);const h=new fE(u);return h.setParams({epochs:t,initialEpoch:s,samples:o,steps:r,batchSize:i,verbose:e,doValidation:a,metrics:l}),{callbackList:h,history:c}}/** * @license * Copyright 2018 Google LLC * @@ -7632,7 +7632,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function Ul(n,e){return z(()=>{n.dtype!=="float32"&&(n=oe(n,"float32"));const t=pe(Oi(n),e,!0),s=Ii(t.shape,ut()),o=Lt(vs(t,s));return me(n,o)})}function Gl(n,e){return z(()=>at(Oi(ge(e,n)),-1))}function Od(n,e){return z(()=>at(_t(ge(e,n)),-1))}function Ld(n,e){return z(()=>{const t=ge(n,e),s=nn(_t(n),ut(),Number.MAX_VALUE),o=_t(me(t,s));return F(100,at(o,-1))})}function gE(n,e){return z(()=>{const t=nn(e,ut(),Number.MAX_VALUE),s=Wn(ee(1,t)),o=nn(n,ut(),Number.MAX_VALUE),r=Wn(ee(1,o));return at(Oi(ge(s,r)),-1)})}function xE(n,e){return z(()=>{const t=vs(0,ge(1,F(n,e)));return at(Oi(t),-1)})}function bE(n,e){return z(()=>{const t=vs(0,ge(1,F(n,e)));return at(t,-1)})}function yE(n,e){return z(()=>{const t=pe(F(n,e),-1),s=Sn(F(ge(1,n),e),-1);return vs(0,ee(1,ge(s,t)))})}function wE(n,e){return z(()=>{const t=Math.log(2),s=ge(e,n),o=ge(ee(s,vi(F(-2,s))),t);return at(o,-1)})}function Vi(n,e,t=!1){return z(()=>{if(t)e=Sh(e);else{const s=pe(e,e.shape.length-1,!0);e=me(e,s)}return e=nn(e,ut(),1-ut()),nt(pe(F(oe(n,"float32"),Wn(e)),e.shape.length-1))})}function Hl(n,e,t=!1){return z(()=>{const s=oe(vl(VN(n)),"int32");e=nn(e,ut(),1-ut());const o=e.shape,r=_(ym(s,o[o.length-1]),o);return Vi(r,e,t)})}function CE(n,e){if(!Oe(n.shape,e.shape))throw new A(`logits and labels must have the same shape, but got shapes ${JSON.stringify(n.shape)} and ${JSON.stringify(e.shape)}`);return z(()=>{const t=lo(e),s=nt(_t(e));return ee(ge(t,F(e,n)),mm(Vn(s)))})}function jl(n,e){return z(()=>{let t;return t=nn(e,ut(),1-ut()),t=Wn(me(t,ge(1,t))),at(CE(n,t),-1)})}function IE(n,e){return z(()=>{const t=nn(n,ut(),1),s=nn(e,ut(),1);return pe(F(n,Wn(me(t,s))),-1)})}function $E(n,e){return z(()=>{const t=Wn(ee(ut(),e));return at(ge(e,F(n,t)),-1)})}function Cx(n,e){return z(()=>{const t=Ul(n,-1),s=Ul(e,-1),o=F(t,s);return nt(pe(o,-1))})}const ql={meanSquaredError:Gl,meanAbsoluteError:Od,meanAbsolutePercentageError:Ld,meanSquaredLogarithmicError:gE,squaredHinge:xE,hinge:bE,categoricalHinge:yE,logcosh:wE,categoricalCrossentropy:Vi,sparseCategoricalCrossentropy:Hl,binaryCrossentropy:jl,kullbackLeiblerDivergence:IE,poisson:$E,cosineProximity:Cx};function Md(n){if(typeof n=="string"){if(n in ql)return ql[n];let e=`Unknown loss ${n}`;throw n.toLowerCase().includes("softmaxcrossentropy")&&(e=`Unknown loss ${n}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new A(e)}else return n}/** + */function Gl(n,e){return P(()=>{n.dtype!=="float32"&&(n=oe(n,"float32"));const t=pe(Oi(n),e,!0),s=Ii(t.shape,ut()),o=Rt(vs(t,s));return me(n,o)})}function Hl(n,e){return P(()=>at(Oi(ge(e,n)),-1))}function Od(n,e){return P(()=>at(Lt(ge(e,n)),-1))}function Ld(n,e){return P(()=>{const t=ge(n,e),s=nn(Lt(n),ut(),Number.MAX_VALUE),o=Lt(me(t,s));return D(100,at(o,-1))})}function bE(n,e){return P(()=>{const t=nn(e,ut(),Number.MAX_VALUE),s=Wn(ee(1,t)),o=nn(n,ut(),Number.MAX_VALUE),r=Wn(ee(1,o));return at(Oi(ge(s,r)),-1)})}function yE(n,e){return P(()=>{const t=vs(0,ge(1,D(n,e)));return at(Oi(t),-1)})}function wE(n,e){return P(()=>{const t=vs(0,ge(1,D(n,e)));return at(t,-1)})}function CE(n,e){return P(()=>{const t=pe(D(n,e),-1),s=Sn(D(ge(1,n),e),-1);return vs(0,ee(1,ge(s,t)))})}function IE(n,e){return P(()=>{const t=Math.log(2),s=ge(e,n),o=ge(ee(s,vi(D(-2,s))),t);return at(o,-1)})}function Vi(n,e,t=!1){return P(()=>{if(t)e=Sh(e);else{const s=pe(e,e.shape.length-1,!0);e=me(e,s)}return e=nn(e,ut(),1-ut()),nt(pe(D(oe(n,"float32"),Wn(e)),e.shape.length-1))})}function ql(n,e,t=!1){return P(()=>{const s=oe(kl(UN(n)),"int32");e=nn(e,ut(),1-ut());const o=e.shape,r=_(wm(s,o[o.length-1]),o);return Vi(r,e,t)})}function $E(n,e){if(!Oe(n.shape,e.shape))throw new A(`logits and labels must have the same shape, but got shapes ${JSON.stringify(n.shape)} and ${JSON.stringify(e.shape)}`);return P(()=>{const t=co(e),s=nt(Lt(e));return ee(ge(t,D(e,n)),gm(Vn(s)))})}function jl(n,e){return P(()=>{let t;return t=nn(e,ut(),1-ut()),t=Wn(me(t,ge(1,t))),at($E(n,t),-1)})}function vE(n,e){return P(()=>{const t=nn(n,ut(),1),s=nn(e,ut(),1);return pe(D(n,Wn(me(t,s))),-1)})}function kE(n,e){return P(()=>{const t=Wn(ee(ut(),e));return at(ge(e,D(n,t)),-1)})}function Ix(n,e){return P(()=>{const t=Gl(n,-1),s=Gl(e,-1),o=D(t,s);return nt(pe(o,-1))})}const Kl={meanSquaredError:Hl,meanAbsoluteError:Od,meanAbsolutePercentageError:Ld,meanSquaredLogarithmicError:bE,squaredHinge:yE,hinge:wE,categoricalHinge:CE,logcosh:IE,categoricalCrossentropy:Vi,sparseCategoricalCrossentropy:ql,binaryCrossentropy:jl,kullbackLeiblerDivergence:vE,poisson:kE,cosineProximity:Ix};function Md(n){if(typeof n=="string"){if(n in Kl)return Kl[n];let e=`Unknown loss ${n}`;throw n.toLowerCase().includes("softmaxcrossentropy")&&(e=`Unknown loss ${n}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new A(e)}else return n}/** * @license * Copyright 2018 Google LLC * @@ -7640,7 +7640,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function Ix(n,e){return z(()=>{const t=F(.5,fn(e)),s=Kn(Zt(e,t),n.dtype);return at(zn(n,s),-1)})}function $x(n,e){return z(()=>Kn(zn(no(n,-1),no(e,-1)),"float32"))}function vE(n,e){return z(()=>oe(pe(as(zn(n,1),zn(e,1))),"float32"))}function kE(n,e){return z(()=>oe(pe(as(zn(n,0),zn(e,1))),"float32"))}function SE(n,e){return z(()=>{const t=vE(n,e),s=kE(n,e),o=ee(t,s);return oe(Ct(Zt(o,0),me(t,o),0),"float32")})}function TE(n,e){return jl(n,e)}function NE(n,e){return n.rank===e.rank&&(n=Xo(n,[n.rank-1])),e=no(e,-1),e.dtype!==n.dtype&&(e=oe(e,n.dtype)),oe(zn(n,e),"float32")}const EE=Gl,RE=Gl,AE=Od,DE=Od,FE=Ld,_E=Ld,vx=Vi,OE=Cx,kx=Hl,Kl={binaryAccuracy:Ix,categoricalAccuracy:$x,precision:SE,categoricalCrossentropy:vx,sparseCategoricalCrossentropy:kx,mse:EE,MSE:RE,mae:AE,MAE:DE,mape:FE,MAPE:_E,cosine:OE};function LE(n){if(typeof n=="string"&&n in Kl)return Kl[n];if(typeof n!="string"&&n!=null)return n;throw new A(`Unknown metric ${n}`)}function Xl(n){if(qn(n!==null,`Unknown LossOrMetricFn ${n}`),typeof n=="string")return n;{let e;for(const t of Object.keys(ql))if(ql[t]===n){e=t;break}if(e!==void 0)return e;for(const t of Object.keys(Kl))if(Kl[t]===n){e=t;break}return e!==void 0?e:n.name}}/** + */function $x(n,e){return P(()=>{const t=D(.5,fn(e)),s=Kn(Zt(e,t),n.dtype);return at(zn(n,s),-1)})}function vx(n,e){return P(()=>Kn(zn(no(n,-1),no(e,-1)),"float32"))}function SE(n,e){return P(()=>oe(pe(as(zn(n,1),zn(e,1))),"float32"))}function TE(n,e){return P(()=>oe(pe(as(zn(n,0),zn(e,1))),"float32"))}function NE(n,e){return P(()=>{const t=SE(n,e),s=TE(n,e),o=ee(t,s);return oe(Ct(Zt(o,0),me(t,o),0),"float32")})}function EE(n,e){return jl(n,e)}function RE(n,e){return n.rank===e.rank&&(n=Xo(n,[n.rank-1])),e=no(e,-1),e.dtype!==n.dtype&&(e=oe(e,n.dtype)),oe(zn(n,e),"float32")}const AE=Hl,DE=Hl,FE=Od,_E=Od,OE=Ld,LE=Ld,kx=Vi,ME=Ix,Sx=ql,Xl={binaryAccuracy:$x,categoricalAccuracy:vx,precision:NE,categoricalCrossentropy:kx,sparseCategoricalCrossentropy:Sx,mse:AE,MSE:DE,mae:FE,MAE:_E,mape:OE,MAPE:LE,cosine:ME};function PE(n){if(typeof n=="string"&&n in Xl)return Xl[n];if(typeof n!="string"&&n!=null)return n;throw new A(`Unknown metric ${n}`)}function Yl(n){if(jn(n!==null,`Unknown LossOrMetricFn ${n}`),typeof n=="string")return n;{let e;for(const t of Object.keys(Kl))if(Kl[t]===n){e=t;break}if(e!==void 0)return e;for(const t of Object.keys(Xl))if(Xl[t]===n){e=t;break}return e!==void 0?e:n.name}}/** * @license * Copyright 2018 Google LLC * @@ -7648,7 +7648,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function ME(n){const e={Adagrad:()=>Qo.adagrad(.01),Adadelta:()=>Qo.adadelta(1,.95,ut()),Adam:()=>Qo.adam(.001,.9,.999,ut()),Adamax:()=>Qo.adamax(.002,.9,.999,ut(),0),RMSProp:()=>Qo.rmsprop(.001,.9,0,ut()),SGD:()=>Qo.sgd(.01)};if(e.adagrad=e.Adagrad,e.adadelta=e.Adadelta,e.adam=e.Adam,e.adamax=e.Adamax,e.rmsprop=e.RMSProp,e.sgd=e.SGD,n in e)return e[n]();throw new A(`Unknown Optimizer ${n}`)}/** + */function BE(n){const e={Adagrad:()=>Qo.adagrad(.01),Adadelta:()=>Qo.adadelta(1,.95,ut()),Adam:()=>Qo.adam(.001,.9,.999,ut()),Adamax:()=>Qo.adamax(.002,.9,.999,ut(),0),RMSProp:()=>Qo.rmsprop(.001,.9,0,ut()),SGD:()=>Qo.sgd(.01)};if(e.adagrad=e.Adagrad,e.adadelta=e.Adadelta,e.adam=e.Adam,e.adamax=e.Adamax,e.rmsprop=e.RMSProp,e.sgd=e.SGD,n in e)return e[n]();throw new A(`Unknown Optimizer ${n}`)}/** * @license * Copyright 2019 Google LLC * @@ -7656,7 +7656,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */const Sx=1*1024*1024;function Tx(n,e,t=!1){if(n==null||typeof n!="object"||Object.getPrototypeOf(n)!==Object.prototype||!Pd(n))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(t){const s=JSON.stringify(n);s.length>Sx&&console.warn(`User-defined metadata of model "${e}" is too large in size (length=${s.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= ${Sx}.`)}}function Pd(n){if(n===null)return!0;if(typeof n=="object")if(Object.getPrototypeOf(n)===Object.prototype){const e=Object.keys(n);for(const t of e)if(typeof t!="string"||!Pd(n[t]))return!1;return!0}else if(Array.isArray(n)){for(const e of n)if(!Pd(e))return!1;return!0}else return!1;else{const e=typeof n;return e==="string"||e==="number"||e==="boolean"}}/** + */const Tx=1*1024*1024;function Nx(n,e,t=!1){if(n==null||typeof n!="object"||Object.getPrototypeOf(n)!==Object.prototype||!Pd(n))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(t){const s=JSON.stringify(n);s.length>Tx&&console.warn(`User-defined metadata of model "${e}" is too large in size (length=${s.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= ${Tx}.`)}}function Pd(n){if(n===null)return!0;if(typeof n=="object")if(Object.getPrototypeOf(n)===Object.prototype){const e=Object.keys(n);for(const t of e)if(typeof t!="string"||!Pd(n[t]))return!1;return!0}else if(Array.isArray(n)){for(const e of n)if(!Pd(e))return!1;return!0}else return!1;else{const e=typeof n;return e==="string"||e==="number"||e==="boolean"}}/** * @license * Copyright 2018 Google LLC * @@ -7664,7 +7664,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function PE(n,e,t,s=console.log){const o=zE(n),r=["Layer (type)","Input Shape","Output shape","Param #"];o?(e=e||90,t=t||[.32,.61,.89,1]):(e=e||115,t=t||[.24,.48,.7,.8,1]),t[t.length-1]<=1&&(t=t.map(u=>Math.floor(e*u)));let i;if(!o){r.push("Receives inputs"),i=[];for(const u in n.nodesByDepth)i.push(...n.nodesByDepth[u])}s("_".repeat(e)),Yl(r,t,s),s("=".repeat(e));const a=n.layers;for(let u=0;u1||o.length===1&&o[0].inboundLayers.length>1){e=!1;break}s.push(...o)}if(e)for(const o of n.layers){let r=!1;for(const i of o.inboundNodes)if(s.indexOf(i)!==-1)if(r){e=!1;break}else r=!0;if(!e)break}return e}function Yl(n,e,t=console.log){let s="";for(let o=0;o0&&(s=s.slice(0,s.length-1)+" "),s+=n[o],s=s.slice(0,e[o]),s+=" ".repeat(e[o]-s.length);t(s)}function VE(n,e,t){let s,o;try{o=n.inboundNodes.map(l=>JSON.stringify(l.inputShapes)).join(",")}catch{o="multiple"}try{s=JSON.stringify(n.outputShape)}catch{s="multiple"}const r=n.name,i=n.getClassName(),a=[`${r} (${i})`,o,s,n.countParams().toString()];Yl(a,e,t)}function WE(n,e,t,s){let o,r;try{r=n.inboundNodes.map(h=>JSON.stringify(h.inputShapes)).join(",")}catch{r="multiple"}try{o=JSON.stringify(n.outputShape)}catch{o="multiple"}const i=[];for(const h of n.inboundNodes)if(!(t!=null&&t.length>0&&t.indexOf(h)===-1))for(let d=0;dMath.floor(e*u)));let i;if(!o){r.push("Receives inputs"),i=[];for(const u in n.nodesByDepth)i.push(...n.nodesByDepth[u])}s("_".repeat(e)),Zl(r,t,s),s("=".repeat(e));const a=n.layers;for(let u=0;u1||o.length===1&&o[0].inboundLayers.length>1){e=!1;break}s.push(...o)}if(e)for(const o of n.layers){let r=!1;for(const i of o.inboundNodes)if(s.indexOf(i)!==-1)if(r){e=!1;break}else r=!0;if(!e)break}return e}function Zl(n,e,t=console.log){let s="";for(let o=0;o0&&(s=s.slice(0,s.length-1)+" "),s+=n[o],s=s.slice(0,e[o]),s+=" ".repeat(e[o]-s.length);t(s)}function UE(n,e,t){let s,o;try{o=n.inboundNodes.map(l=>JSON.stringify(l.inputShapes)).join(",")}catch{o="multiple"}try{s=JSON.stringify(n.outputShape)}catch{s="multiple"}const r=n.name,i=n.getClassName(),a=[`${r} (${i})`,o,s,n.countParams().toString()];Zl(a,e,t)}function GE(n,e,t,s){let o,r;try{r=n.inboundNodes.map(h=>JSON.stringify(h.inputShapes)).join(",")}catch{r="multiple"}try{o=JSON.stringify(n.outputShape)}catch{o="multiple"}const i=[];for(const h of n.inboundNodes)if(!(t!=null&&t.length>0&&t.indexOf(h)===-1))for(let d=0;d{const e=Object.keys(n);if(e.length===0)return!1;const t=e[0].split("/");return!isNaN(parseInt(t[t.length-1],10))};class Fn extends ke{constructor(e){if(super({}),this.containerNodes=new Set,this.name=e.name,this.name==null){const b=this.getClassName().toLowerCase();this.name=Ol(b)}if(this.supportsMasking=!1,this.trainable_=!0,Array.isArray(e.inputs)?this.inputs=e.inputs.slice():this.inputs=[e.inputs],Array.isArray(e.outputs)?this.outputs=e.outputs.slice():this.outputs=[e.outputs],Ss(this.inputs).length!==this.inputs.length)throw new A(`The list of inputs passed to the model is redundant. All inputs should only appear once. Found: ${this.inputs.map(b=>b.name)}`);Ss(this.outputs).length!==this.outputs.length&&console.warn(`The list of outputs passed to the model is redundant. All outputs should only appear once. Found: ${this.outputs.map(b=>b.name)}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(const b of this.outputs){const w=b.sourceLayer,y=b.nodeIndex,C=b.tensorIndex;this.outputLayers.push(w),this.outputLayersNodeIndices.push(y),this.outputLayersTensorIndices.push(C)}for(const b of this.inputs){const w=b.sourceLayer,y=b.nodeIndex,C=b.tensorIndex;qn(y===0,"input layer has >1 nodes"),qn(C===0,"input layer has >1 tensors"),this.inputLayers.push(w),this.inputLayersNodeIndices.push(y),this.inputLayersTensorIndices.push(C)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let b=0;bb.shape),this.internalOutputShapes=this.outputs.map(b=>b.shape);const t={},s={},o={},r={},i={},a=[],l=(b,w,y,C,I,v)=>{(C==null||I==null||v==null)&&(C=b.sourceLayer,I=b.nodeIndex,v=b.tensorIndex);const k=C.inboundNodes[I];if(y.indexOf(k)!==-1)throw new gn(`The tensor ${b.name} at layer "${C.name}" is part of a cycle.`);if(w.indexOf(k)!==-1)return;this.containerNodes.add(Fn.nodeKey(C,I)),C.id in i||(i[C.id]=Object.keys(i).length),y.indexOf(k)===-1&&y.push(k);const S=k.inboundLayers.length;for(let T=0;T=0;)y.splice(y.indexOf(k),1);a.push(k)},c=[],u=[];for(const b of this.outputs)l(b,c,u);const h=a.slice().reverse();for(const b of h){s[b.id]=b,b.id in t||(t[b.id]=0);let w=t[b.id];const y=o[b.outboundLayer.id]==null?0:o[b.outboundLayer.id];w=Math.max(w,y),o[b.outboundLayer.id]=w,r[b.outboundLayer.id]=b.outboundLayer,t[b.id]=w;for(let C=0;CparseInt(b,10)).sort(Fl);this.layers=[];for(const b of f){const w=p[b];w.sort((y,C)=>{const I=i[y.id],v=i[C.id];return Iv?1:0});for(const y of w)y instanceof Fn&&this.internalContainerRefs.push(y),this.layers.push(y)}this.layersByDepth=p,f=Object.keys(d).map(b=>parseInt(b,10)).sort(Fl);const g=this.inputs.slice(),m=[];for(const b of f)for(const w of d[b]){const y=w.outboundLayer;if(y!=null){for(const C of w.inputTensors)if(g.indexOf(C)===-1)throw new gn(`Graph disconnected: cannot obtain value for tensor ${C} at layer "${y.name}". The following previous layers were accessed without issue: ${m}`);for(const C of w.outputTensors)g.push(C);m.push(y.name)}}this.nodesByDepth=d;const x=this.layers.map(b=>b.name);for(const b of x){const w=x.filter(y=>y===b).length;if(w!==1)throw new gn(`The name "${b}" is used ${w} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(x))}this.outboundNodes=[],this.inboundNodes=[],new zl({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map(b=>null),outputMasks:this.outputs.map(b=>null),inputShapes:this.inputs.map(b=>b.shape),outputShapes:this.outputs.map(b=>b.shape)}),this.built=!0,this._refCount=1}assertNotDisposed(){if(this._refCount===0)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();const e={refCountAfterDispose:null,numDisposedVariables:0};if(--this._refCount===0){for(const t of this.layers)e.numDisposedVariables+=t.dispose().numDisposedVariables;for(const t of this.internalContainerRefs)e.numDisposedVariables+=t.dispose().numDisposedVariables}return e.refCountAfterDispose=this._refCount,e}get trainable(){return this.trainable_}set trainable(e){this.layers.forEach(t=>{t._trainableWeights.forEach(s=>s.trainable=e)}),this.trainable_=e}get trainableWeights(){if(this._trainableWeights.length>0)throw new A("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return[];let e=[];for(const t of this.layers)e=e.concat(t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.layers)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const s of this.layers)t.push(...s.trainableWeights);return t.concat(e)}return e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(e,t=!0){const s={};let o=0;const r=UE(e);r&&this.parseWeights(e);for(const a of this.layers)for(const[l,c]of a.weights.entries()){const u=r?`${c.name.split("/").slice(0,-1).join("/")+"/"}${l}`:c.originalName;if(s[u]!=null)throw new A(`Duplicate weight name: ${u}`);s[u]=c,o++}const i=[];for(const a in e){let l=a;if(s[a]==null){const c=a.split("/");l=c.slice(0,-2).concat([c[c.length-1]]).join("/")}if(s[l]!=null)i.push([s[l],e[a]]);else if(t)throw new A(`Provided weight data has no target variable: ${a}`);delete s[l]}if(t){const a=[];for(const l in s)a.push(l);if(a.length>0)throw new A(`${a.length} of ${o} weights are not set: ${a}`)}Fd(i)}parseWeights(e){for(const t in Object.keys(e)){const s=t.split("/"),o=["vars","layer_checkpoint_dependencies"],r=s.map(i=>i.startsWith("_")?i.slice(1):i).filter(i=>!o.includes(i)).join("/");r!==t&&(e[r]=e[t],delete e[t])}}updatedConfig(){const e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion=`tfjs-layers ${Ex}`,t.backend="TensorFlow.js",t}toJSON(e,t=!0){const s=Bd(this.updatedConfig());return t?JSON.stringify(s):s}call(e,t){return z(()=>{e=Me(e);const s=new Es;for(let o=0;o{e=Me(e);let s;return t==null?s=ho(null,e.length):s=Me(t),this.runInternalGraph(e,s)[1]})}computeOutputShape(e){const t=Pl(e);if(t.length!==this.inputLayers.length)throw new A(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`);const s={};for(let a=0;aparseInt(a,10)).sort(Fl);if(o.length>1)for(const a of o){const l=this.nodesByDepth[a];for(const c of l){const u=c.outboundLayer;if(this.inputLayers.map(g=>g.id).indexOf(u.id)!==-1)continue;const h=[];for(let g=0;gparseInt(l,10)).sort(Fl);for(const l of o){const c=this.nodesByDepth[l];for(const u of c){const h=u.outboundLayer,d=u.inputTensors,p=u.outputTensors,f=new Array;for(const g of d)g.id in s&&f.push(s[g.id]);if(f.length===d.length){let g={},m,x,b,w;if(u.callArgs!=null&&(g=u.callArgs),f.length===1){const[y,C]=f[0];g.mask==null&&(g.mask=C),b=Me(h.call(y,g)),w=Me(h.computeMask(y,C)),m=[y],x=[C]}else m=f.map(y=>y[0]),x=f.map(y=>y[1]),g.mask==null&&(g.mask=x),b=Me(h.call(m,g)),w=Me(h.computeMask(m,x));if(h.activityRegularizer)throw new Ce("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let y=0;y{const e=[];for(const t of this.layers)for(let s=0;s0){const g=[];for(let m=0;m0&&m.apply(Gt(b),w)}function c(m){const x=m.name,b=Zn(m,t.customObjects!=null?t.customObjects:{});b.setFastWeightInitDuringBuild(o),r[x]=b,m.inboundNodes.forEach(y=>{if(!(y instanceof Array))throw new A(`Corrupted configuration, expected array for nodeData: ${y}`);a(b,y)})}const u=t.name,h=t.layers;for(const m of h)c(m);for(;!NN(i);)for(const m of h){const x=r[m.name];if(x.name in i){const b=i[x.name];delete i[x.name];for(const w of b)l(x,w)}}const d=[],p=[],f=t.inputLayers;for(const m of f){const x=m[0],b=m[1],w=m[2];qn(x in r);const C=r[x].inboundNodes[b].outputTensors;d.push(C[w])}const g=t.outputLayers;for(const m of g){const x=m[0],b=m[1],w=m[2];qn(x in r);const C=r[x].inboundNodes[b].outputTensors;p.push(C[w])}return new e({inputs:d,outputs:p,name:u})}get stateful(){if(this._stateful)throw new A("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");for(const e of this.layers)if(e.stateful)return!0;return!1}resetStates(){z(()=>{this.layers.forEach(e=>{e.stateful&&e.resetStates()})})}}/** + */const HE=n=>{const e=Object.keys(n);if(e.length===0)return!1;const t=e[0].split("/");return!isNaN(parseInt(t[t.length-1],10))};class Fn extends ke{constructor(e){if(super({}),this.containerNodes=new Set,this.name=e.name,this.name==null){const b=this.getClassName().toLowerCase();this.name=Ll(b)}if(this.supportsMasking=!1,this.trainable_=!0,Array.isArray(e.inputs)?this.inputs=e.inputs.slice():this.inputs=[e.inputs],Array.isArray(e.outputs)?this.outputs=e.outputs.slice():this.outputs=[e.outputs],Ss(this.inputs).length!==this.inputs.length)throw new A(`The list of inputs passed to the model is redundant. All inputs should only appear once. Found: ${this.inputs.map(b=>b.name)}`);Ss(this.outputs).length!==this.outputs.length&&console.warn(`The list of outputs passed to the model is redundant. All outputs should only appear once. Found: ${this.outputs.map(b=>b.name)}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(const b of this.outputs){const w=b.sourceLayer,y=b.nodeIndex,C=b.tensorIndex;this.outputLayers.push(w),this.outputLayersNodeIndices.push(y),this.outputLayersTensorIndices.push(C)}for(const b of this.inputs){const w=b.sourceLayer,y=b.nodeIndex,C=b.tensorIndex;jn(y===0,"input layer has >1 nodes"),jn(C===0,"input layer has >1 tensors"),this.inputLayers.push(w),this.inputLayersNodeIndices.push(y),this.inputLayersTensorIndices.push(C)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let b=0;bb.shape),this.internalOutputShapes=this.outputs.map(b=>b.shape);const t={},s={},o={},r={},i={},a=[],l=(b,w,y,C,I,v)=>{(C==null||I==null||v==null)&&(C=b.sourceLayer,I=b.nodeIndex,v=b.tensorIndex);const k=C.inboundNodes[I];if(y.indexOf(k)!==-1)throw new gn(`The tensor ${b.name} at layer "${C.name}" is part of a cycle.`);if(w.indexOf(k)!==-1)return;this.containerNodes.add(Fn.nodeKey(C,I)),C.id in i||(i[C.id]=Object.keys(i).length),y.indexOf(k)===-1&&y.push(k);const S=k.inboundLayers.length;for(let T=0;T=0;)y.splice(y.indexOf(k),1);a.push(k)},c=[],u=[];for(const b of this.outputs)l(b,c,u);const h=a.slice().reverse();for(const b of h){s[b.id]=b,b.id in t||(t[b.id]=0);let w=t[b.id];const y=o[b.outboundLayer.id]==null?0:o[b.outboundLayer.id];w=Math.max(w,y),o[b.outboundLayer.id]=w,r[b.outboundLayer.id]=b.outboundLayer,t[b.id]=w;for(let C=0;CparseInt(b,10)).sort(_l);this.layers=[];for(const b of f){const w=p[b];w.sort((y,C)=>{const I=i[y.id],v=i[C.id];return Iv?1:0});for(const y of w)y instanceof Fn&&this.internalContainerRefs.push(y),this.layers.push(y)}this.layersByDepth=p,f=Object.keys(d).map(b=>parseInt(b,10)).sort(_l);const g=this.inputs.slice(),m=[];for(const b of f)for(const w of d[b]){const y=w.outboundLayer;if(y!=null){for(const C of w.inputTensors)if(g.indexOf(C)===-1)throw new gn(`Graph disconnected: cannot obtain value for tensor ${C} at layer "${y.name}". The following previous layers were accessed without issue: ${m}`);for(const C of w.outputTensors)g.push(C);m.push(y.name)}}this.nodesByDepth=d;const x=this.layers.map(b=>b.name);for(const b of x){const w=x.filter(y=>y===b).length;if(w!==1)throw new gn(`The name "${b}" is used ${w} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(x))}this.outboundNodes=[],this.inboundNodes=[],new Vl({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map(b=>null),outputMasks:this.outputs.map(b=>null),inputShapes:this.inputs.map(b=>b.shape),outputShapes:this.outputs.map(b=>b.shape)}),this.built=!0,this._refCount=1}assertNotDisposed(){if(this._refCount===0)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();const e={refCountAfterDispose:null,numDisposedVariables:0};if(--this._refCount===0){for(const t of this.layers)e.numDisposedVariables+=t.dispose().numDisposedVariables;for(const t of this.internalContainerRefs)e.numDisposedVariables+=t.dispose().numDisposedVariables}return e.refCountAfterDispose=this._refCount,e}get trainable(){return this.trainable_}set trainable(e){this.layers.forEach(t=>{t._trainableWeights.forEach(s=>s.trainable=e)}),this.trainable_=e}get trainableWeights(){if(this._trainableWeights.length>0)throw new A("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return[];let e=[];for(const t of this.layers)e=e.concat(t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.layers)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const s of this.layers)t.push(...s.trainableWeights);return t.concat(e)}return e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(e,t=!0){const s={};let o=0;const r=HE(e);r&&this.parseWeights(e);for(const a of this.layers)for(const[l,c]of a.weights.entries()){const u=r?`${c.name.split("/").slice(0,-1).join("/")+"/"}${l}`:c.originalName;if(s[u]!=null)throw new A(`Duplicate weight name: ${u}`);s[u]=c,o++}const i=[];for(const a in e){let l=a;if(s[a]==null){const c=a.split("/");l=c.slice(0,-2).concat([c[c.length-1]]).join("/")}if(s[l]!=null)i.push([s[l],e[a]]);else if(t)throw new A(`Provided weight data has no target variable: ${a}`);delete s[l]}if(t){const a=[];for(const l in s)a.push(l);if(a.length>0)throw new A(`${a.length} of ${o} weights are not set: ${a}`)}Fd(i)}parseWeights(e){for(const t in Object.keys(e)){const s=t.split("/"),o=["vars","layer_checkpoint_dependencies"],r=s.map(i=>i.startsWith("_")?i.slice(1):i).filter(i=>!o.includes(i)).join("/");r!==t&&(e[r]=e[t],delete e[t])}}updatedConfig(){const e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion=`tfjs-layers ${Rx}`,t.backend="TensorFlow.js",t}toJSON(e,t=!0){const s=Bd(this.updatedConfig());return t?JSON.stringify(s):s}call(e,t){return P(()=>{e=Me(e);const s=new Es;for(let o=0;o{e=Me(e);let s;return t==null?s=po(null,e.length):s=Me(t),this.runInternalGraph(e,s)[1]})}computeOutputShape(e){const t=Bl(e);if(t.length!==this.inputLayers.length)throw new A(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`);const s={};for(let a=0;aparseInt(a,10)).sort(_l);if(o.length>1)for(const a of o){const l=this.nodesByDepth[a];for(const c of l){const u=c.outboundLayer;if(this.inputLayers.map(g=>g.id).indexOf(u.id)!==-1)continue;const h=[];for(let g=0;gparseInt(l,10)).sort(_l);for(const l of o){const c=this.nodesByDepth[l];for(const u of c){const h=u.outboundLayer,d=u.inputTensors,p=u.outputTensors,f=new Array;for(const g of d)g.id in s&&f.push(s[g.id]);if(f.length===d.length){let g={},m,x,b,w;if(u.callArgs!=null&&(g=u.callArgs),f.length===1){const[y,C]=f[0];g.mask==null&&(g.mask=C),b=Me(h.call(y,g)),w=Me(h.computeMask(y,C)),m=[y],x=[C]}else m=f.map(y=>y[0]),x=f.map(y=>y[1]),g.mask==null&&(g.mask=x),b=Me(h.call(m,g)),w=Me(h.computeMask(m,x));if(h.activityRegularizer)throw new Ce("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let y=0;y{const e=[];for(const t of this.layers)for(let s=0;s0){const g=[];for(let m=0;m0&&m.apply(Ht(b),w)}function c(m){const x=m.name,b=Zn(m,t.customObjects!=null?t.customObjects:{});b.setFastWeightInitDuringBuild(o),r[x]=b,m.inboundNodes.forEach(y=>{if(!(y instanceof Array))throw new A(`Corrupted configuration, expected array for nodeData: ${y}`);a(b,y)})}const u=t.name,h=t.layers;for(const m of h)c(m);for(;!RN(i);)for(const m of h){const x=r[m.name];if(x.name in i){const b=i[x.name];delete i[x.name];for(const w of b)l(x,w)}}const d=[],p=[],f=t.inputLayers;for(const m of f){const x=m[0],b=m[1],w=m[2];jn(x in r);const C=r[x].inboundNodes[b].outputTensors;d.push(C[w])}const g=t.outputLayers;for(const m of g){const x=m[0],b=m[1],w=m[2];jn(x in r);const C=r[x].inboundNodes[b].outputTensors;p.push(C[w])}return new e({inputs:d,outputs:p,name:u})}get stateful(){if(this._stateful)throw new A("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");for(const e of this.layers)if(e.stateful)return!0;return!1}resetStates(){P(()=>{this.layers.forEach(e=>{e.stateful&&e.resetStates()})})}}/** * @license * Copyright 2018 Google LLC * @@ -7688,7 +7688,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function GE(n,e,t){const s=e.length;if(n==null||Array.isArray(n)&&n.length===0)return e.map(o=>null);if(s===1)return Array.isArray(n)&&n.length===1?n:typeof n=="object"&&e[0]in n?[n[e[0]]]:[n];if(Array.isArray(n)){if(n.length!==s)throw new Error(`Provided ${t} is an array of ${n.length} element(s), but the model has ${s} outputs. Make sure a set of weights is provided for each model output.`);return n}else if(typeof n=="object"&&Object.keys(n).length>0&&typeof n[Object.keys(n)[0]]=="object"){const o=[];return e.forEach(r=>{r in n?o.push(n[r]):o.push(null)}),o}else throw new Error(`The model has multiple (${s}) outputs, so ${t} must be either an array with ${s} elements or an object with ${e} keys. Provided ${t} not understood: ${JSON.stringify(n)}`)}function Rx(n,e){return GE(n,e,"classWeight")}async function Ax(n,e,t,s){if(e!=null||s!=null)throw new Error("Support sampleWeight is not implemented yet");if(t!=null){const o=z(()=>{if(n.shape.length===1)return to(n);if(n.shape.length===2){if(n.shape[1]>1)return no(n,1);if(n.shape[1]===1)return _(n,[n.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${n.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}else throw new Error(`Unexpected rank of target (y) tensor (${n.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)}),r=Array.from(await o.data());fe(o);const i=[];return r.forEach(a=>{if(t[a]==null)throw new Error(`classWeight must contain all classes in the training data. The class ${a} exists in the data but not in classWeight`);i.push(t[a])}),Rt(i,"float32")}else return null}function HE(n,e){return F(n,e)}/** + */function qE(n,e,t){const s=e.length;if(n==null||Array.isArray(n)&&n.length===0)return e.map(o=>null);if(s===1)return Array.isArray(n)&&n.length===1?n:typeof n=="object"&&e[0]in n?[n[e[0]]]:[n];if(Array.isArray(n)){if(n.length!==s)throw new Error(`Provided ${t} is an array of ${n.length} element(s), but the model has ${s} outputs. Make sure a set of weights is provided for each model output.`);return n}else if(typeof n=="object"&&Object.keys(n).length>0&&typeof n[Object.keys(n)[0]]=="object"){const o=[];return e.forEach(r=>{r in n?o.push(n[r]):o.push(null)}),o}else throw new Error(`The model has multiple (${s}) outputs, so ${t} must be either an array with ${s} elements or an object with ${e} keys. Provided ${t} not understood: ${JSON.stringify(n)}`)}function Ax(n,e){return qE(n,e,"classWeight")}async function Dx(n,e,t,s){if(e!=null||s!=null)throw new Error("Support sampleWeight is not implemented yet");if(t!=null){const o=P(()=>{if(n.shape.length===1)return to(n);if(n.shape.length===2){if(n.shape[1]>1)return no(n,1);if(n.shape[1]===1)return _(n,[n.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${n.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}else throw new Error(`Unexpected rank of target (y) tensor (${n.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)}),r=Array.from(await o.data());fe(o);const i=[];return r.forEach(a=>{if(t[a]==null)throw new Error(`classWeight must contain all classes in the training data. The class ${a} exists in the data but not in classWeight`);i.push(t[a])}),At(i,"float32")}else return null}function jE(n,e){return D(n,e)}/** * @license * Copyright 2018 Google LLC * @@ -7696,7 +7696,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */const jE=32;function Dx(n,e){let t,s;const o=e;t=o.xs,s=o.ys,$(t!=null&&s!=null,()=>`A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates ${e}`);const r=Fx("input",n.inputNames,t),i=Fx("output",n.outputNames,s),a=r[0].shape[0];$(r.length===n.inputs.length,()=>`LayersModel has ${n.inputs.length} inputs, but the dataset provides ${r.length} inputs. (Expected input keys: ${JSON.stringify(n.inputNames)})`),$(i.length===n.outputs.length,()=>`LayersModel has ${n.outputs.length} outputs, but the dataset provides ${i.length} outputs. (Expected output keys: ${JSON.stringify(n.outputNames)})`);for(let l=0;l`Batch size mismatch: input ${n.inputNames[l]} has ${r[l].shape[0]}; expected ${a} based on input ${n.inputNames[0]}.`);for(let l=0;l`Batch size mismatch: output ${n.outputNames[l]} has ${i[l].shape[0]}; expected ${a} based on input ${n.inputNames[0]}.`);return{xs:r,ys:i}}function Fx(n,e,t){if(t instanceof lt)return[t];if(Array.isArray(t))return $(t.length===e.length,()=>`Received an array of ${t.length} Tensors, but expected ${e.length} to match the ${n} keys ${e}.`),t;{const s=[];for(const o of e){if(t[o]==null)throw new A(`The feature data generated by the dataset lacks the required ${n} key '${o}'.`);s.push(t[o])}return s}}function qE(n){if(n.length===3)throw new Ce("Validation with sample weights is not implemented yet.");return{xs:n[0],ys:n[1]}}async function KE(n,e,t){const s=t.batchesPerEpoch!=null;if($(n.optimizer!=null,()=>"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."),$(t!=null,()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."),$(t.epochs!=null&&t.epochs>0&&Number.isInteger(t.epochs),()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${t.epochs}`),$(!s||t.batchesPerEpoch>0&&Number.isInteger(t.batchesPerEpoch),()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${t.batchesPerEpoch}`),$(t.validationSplit==null,()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."),n.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");n.isTraining=!0;try{const o=t.validationData!=null;let r,i;if(o)if(_x(t.validationData))$(t.validationBatches==null||t.validationBatches>0&&Number.isInteger(t.validationBatches),()=>`For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${t.validationBatches}`);else{const m=qE(t.validationData);r=m.xs,i=m.ys}const a=n.makeTrainFunction(),l=n.getDedupedMetricsNames();let c;o?c=l.slice().concat(l.map(m=>"val_"+m)):c=l.slice();const u=yx(t.callbacks,t.yieldEvery),h=t.verbose==null?1:t.verbose,{callbackList:d,history:p}=wx(u,h,t.epochs,null,null,XE(e,t),null,o,c);d.setModel(n),n.history=p,await d.onTrainBegin(),n.stopTraining_=!1;let f=t.initialEpoch==null?0:t.initialEpoch,g=await e.iterator();for(;f=t.batchesPerEpoch:w.done){if(o){let y;_x(t.validationData)?y=Me(await n.evaluateDataset(t.validationData,{batches:t.validationBatches})):y=Me(n.evaluate(r,i,{batchSize:t.validationBatchSize==null?jE:t.validationBatchSize,verbose:0}));for(let C=0;C0)throw new Ce("Verbose mode is not implemented yet.");$(!s||t.batches>0&&Number.isInteger(t.batches),()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(t.batches)}`);const i=YE(e)?e:await e.iterator();let a=0,l=0;for(;!s||l{if(c.value){const{xs:u,ys:h}=Dx(n,c.value),d=u.concat(h),p=z(()=>o(d));if(fe(d),l===0)for(let g=0;gee(r[g],F(f,m))),l>0&&fe(x)}fe(p),a+=f,++l}return r}),c.done){s&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${t.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let c=0;c`A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates ${e}`);const r=_x("input",n.inputNames,t),i=_x("output",n.outputNames,s),a=r[0].shape[0];$(r.length===n.inputs.length,()=>`LayersModel has ${n.inputs.length} inputs, but the dataset provides ${r.length} inputs. (Expected input keys: ${JSON.stringify(n.inputNames)})`),$(i.length===n.outputs.length,()=>`LayersModel has ${n.outputs.length} outputs, but the dataset provides ${i.length} outputs. (Expected output keys: ${JSON.stringify(n.outputNames)})`);for(let l=0;l`Batch size mismatch: input ${n.inputNames[l]} has ${r[l].shape[0]}; expected ${a} based on input ${n.inputNames[0]}.`);for(let l=0;l`Batch size mismatch: output ${n.outputNames[l]} has ${i[l].shape[0]}; expected ${a} based on input ${n.inputNames[0]}.`);return{xs:r,ys:i}}function _x(n,e,t){if(t instanceof lt)return[t];if(Array.isArray(t))return $(t.length===e.length,()=>`Received an array of ${t.length} Tensors, but expected ${e.length} to match the ${n} keys ${e}.`),t;{const s=[];for(const o of e){if(t[o]==null)throw new A(`The feature data generated by the dataset lacks the required ${n} key '${o}'.`);s.push(t[o])}return s}}function XE(n){if(n.length===3)throw new Ce("Validation with sample weights is not implemented yet.");return{xs:n[0],ys:n[1]}}async function YE(n,e,t){const s=t.batchesPerEpoch!=null;if($(n.optimizer!=null,()=>"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."),$(t!=null,()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."),$(t.epochs!=null&&t.epochs>0&&Number.isInteger(t.epochs),()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${t.epochs}`),$(!s||t.batchesPerEpoch>0&&Number.isInteger(t.batchesPerEpoch),()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${t.batchesPerEpoch}`),$(t.validationSplit==null,()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."),n.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");n.isTraining=!0;try{const o=t.validationData!=null;let r,i;if(o)if(Ox(t.validationData))$(t.validationBatches==null||t.validationBatches>0&&Number.isInteger(t.validationBatches),()=>`For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${t.validationBatches}`);else{const m=XE(t.validationData);r=m.xs,i=m.ys}const a=n.makeTrainFunction(),l=n.getDedupedMetricsNames();let c;o?c=l.slice().concat(l.map(m=>"val_"+m)):c=l.slice();const u=wx(t.callbacks,t.yieldEvery),h=t.verbose==null?1:t.verbose,{callbackList:d,history:p}=Cx(u,h,t.epochs,null,null,ZE(e,t),null,o,c);d.setModel(n),n.history=p,await d.onTrainBegin(),n.stopTraining_=!1;let f=t.initialEpoch==null?0:t.initialEpoch,g=await e.iterator();for(;f=t.batchesPerEpoch:w.done){if(o){let y;Ox(t.validationData)?y=Me(await n.evaluateDataset(t.validationData,{batches:t.validationBatches})):y=Me(n.evaluate(r,i,{batchSize:t.validationBatchSize==null?KE:t.validationBatchSize,verbose:0}));for(let C=0;C0)throw new Ce("Verbose mode is not implemented yet.");$(!s||t.batches>0&&Number.isInteger(t.batches),()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(t.batches)}`);const i=QE(e)?e:await e.iterator();let a=0,l=0;for(;!s||l{if(c.value){const{xs:u,ys:h}=Fx(n,c.value),d=u.concat(h),p=P(()=>o(d));if(fe(d),l===0)for(let g=0;gee(r[g],D(f,m))),l>0&&fe(x)}fe(p),a+=f,++l}return r}),c.done){s&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${t.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let c=0;c0&&Number.isInteger(n),()=>`batchSize is required to be a positive integer, but got ${n}`)}function Wi(n,e,t){return n==null?[null]:Array.isArray(n)?n.map(s=>go(s,e,t-e)):go(n,e,t-e)}function Vd(n,e){return z(()=>n==null?null:Array.isArray(n)?n.map(t=>Vd(t,e)):Zg(n,e.dtype==="int32"?e:oe(e,"int32")))}function Wd(n,e){const t=[];let s=0,o=null;for(;s=n&&(o=n),t.push([s,o]),s=o;return t}function Ox(n){const e=[];n instanceof lt&&(n=[n]);for(let t=0;tt.push(o.id));else if(e!=null)for(const o in e){const r=e[o];t.push(r.id)}const s=[];if(n instanceof lt)t.indexOf(n.id)===-1&&s.push(n);else if(Array.isArray(n))n.forEach(o=>{t.indexOf(o.id)===-1&&s.push(o)});else if(n!=null)for(const o in n){const r=n[o];t.indexOf(r.id)===-1&&s.push(r)}s.forEach(o=>{o.isDisposed||o.dispose()})}/** + */function zd(n){$(n>0&&Number.isInteger(n),()=>`batchSize is required to be a positive integer, but got ${n}`)}function Wi(n,e,t){return n==null?[null]:Array.isArray(n)?n.map(s=>xo(s,e,t-e)):xo(n,e,t-e)}function Vd(n,e){return P(()=>n==null?null:Array.isArray(n)?n.map(t=>Vd(t,e)):Qg(n,e.dtype==="int32"?e:oe(e,"int32")))}function Wd(n,e){const t=[];let s=0,o=null;for(;s=n&&(o=n),t.push([s,o]),s=o;return t}function Lx(n){const e=[];n instanceof lt&&(n=[n]);for(let t=0;tt.push(o.id));else if(e!=null)for(const o in e){const r=e[o];t.push(r.id)}const s=[];if(n instanceof lt)t.indexOf(n.id)===-1&&s.push(n);else if(Array.isArray(n))n.forEach(o=>{t.indexOf(o.id)===-1&&s.push(o)});else if(n!=null)for(const o in n){const r=n[o];t.indexOf(r.id)===-1&&s.push(r)}s.forEach(o=>{o.isDisposed||o.dispose()})}/** * @license * Copyright 2018 Google LLC * @@ -7712,7 +7712,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function QE(n){return n instanceof lt}function Ud(n){return Array.isArray(n)}function Lx(n){return!QE(n)&&!Ud(n)}function Mx(n,e,t,s=!0,o=""){if(e==null||e.length===0){if(n!=null){let i=!1;if(Ud(n)&&n.length>0)i=!0;else if(Lx(n)){for(const a in n)if(n.hasOwnProperty(a)){i=!0;break}}else i=!0;if(i)throw new A(`Error when checking model ${o} expected no data, but got ${n}`)}return[]}if(n==null)return e.map(i=>null);let r;if(Lx(n)){n=n,r=[];for(const i of e){if(n[i]==null)throw new A(`No data provided for "${i}". Need data for each key in: ${e}`);r.push(n[i])}}else if(Ud(n)){if(n=n,n.length!==e.length)throw new A(`Error when checking model ${o}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${e.length} Tensor(s), but instead got the following list of Tensor(s): ${n}`);r=n}else{if(n=n,e.length>1)throw new A(`The model ${o} expects ${e.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${n.shape}`);r=[n]}if(r=Ox(r),t!=null)for(let i=0;i=0&&c!==u)throw new A(`${o} expected a batch of elements where each example has shape [${t[i].slice(1,t[i].length)}] (i.e.,tensor shape [*,${t[i].slice(1,t[i].length)}]) but the ${o} received an input with ${a.shape[0]} examples, each with shape [${a.shape.slice(1,a.shape.length)}] (tensor shape [${a.shape}])`)}}return r}function JE(n,e,t){const s=Ss(n.map(r=>r.shape[0]));s.sort();const o=Ss(e.map(r=>r.shape[0]));if(o.sort(),s.length>1)throw new A(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(n.map(r=>r.shape))}`);if(o.length>1)throw new A(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map(r=>r.shape))}`);if(s.length>0&&o.length>0&&!Oe(s,o))throw new A(`Input Tensors should have the same number of samples as target Tensors. Found ${s[0]} input sample(s) and ${o[0]} target sample(s).`)}function eR(n,e,t){const s=[Gl,jl,Vi];for(let o=0;o1)throw new A(`The model expects ${e.length} ${o} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(n.shape)}.`);r=[n]}if(t!=null)for(let i=0;i[]);let t;if(typeof n=="string"||typeof n=="function")t=[n];else if(Array.isArray(n)||typeof n=="object")t=n;else throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${n}`);if(Array.isArray(t))return e.map(s=>t);{const s=[];for(const o of e){let r=t.hasOwnProperty(o)?t[o]:[];Array.isArray(r)||(r=[r]),s.push(r)}return s}}const nR="layers-model";class tr extends Fn{constructor(e){super(e),this.isTraining=!1}summary(e,t,s=console.log){if(!this.built)throw new A("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");PE(this,e,t,s)}compile(e){if(e.loss==null&&(e.loss=[]),this.loss=e.loss,typeof e.optimizer=="string")this.optimizer_=ME(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof ks))throw new A("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let t=[];if(!Array.isArray(e.loss)&&typeof e.loss!="string"&&typeof e.loss!="function"){e.loss=e.loss;for(const i in e.loss)if(this.outputNames.indexOf(i)===-1)throw new A(`Unknown entry in loss dictionary: "${i}". Only expected the following keys: ${this.outputNames}`);for(const i of this.outputNames)e.loss[i]==null&&console.warn(`Output "${i}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${i} during training`),t.push(Md(e.loss[i]))}else if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new A(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${e.loss}.`);t=e.loss.map(a=>Md(a))}else{const i=Md(e.loss);this.outputs.forEach(a=>{t.push(i)})}this.lossFunctions=t,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let i=0;i{for(let i=0;i1&&(this.metricsTensors.push([a,i]),this.metricsNames.push(this.outputNames[i]+"_loss"))}});const o=tR(e.metrics,this.outputNames),r=(i,a,l)=>{this.outputNames.length>1&&(a=this.outputNames[i]+"_"+a),this.metricsNames.push(a),this.metricsTensors.push([l,i])};mo("metric",()=>{for(let i=0;i{const u="";let h,d,p;for(const f of c){if(typeof f=="string"&&["accuracy","acc","crossentropy","ce"].indexOf(f)!==-1){const m=this.internalOutputShapes[i];m[m.length-1]===1||this.lossFunctions[i]===jl?["accuracy","acc"].indexOf(f)!==-1?d=Ix:["crossentropy","ce"].indexOf(f)!==-1&&(d=TE):this.lossFunctions[i]===Hl?["accuracy","acc"].indexOf(f)!==-1?d=NE:["crossentropy","ce"].indexOf(f)!==-1&&(d=kx):["accuracy","acc"].indexOf(f)!==-1?d=$x:["crossentropy","ce"].indexOf(f)!==-1&&(d=vx);let x;["accuracy","acc"].indexOf(f)!==-1?x="acc":["crossentropy","ce"].indexOf(f)!==-1&&(x="ce"),p=d,h=u+x}else p=LE(f),h=u+Xl(f);let g;mo(h,()=>{g=p}),r(i,h,g)}})(a)}}),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){this.collectedTrainableWeights!=null&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")}evaluate(e,t,s={}){const o=s.batchSize==null?32:s.batchSize;zd(o);const i=this.standardizeUserDataXY(e,t,!0,o);try{const a=i[0].concat(i[1]);this.makeTestFunction();const l=this.testFunction,c=this.testLoop(l,a,o,s.verbose,s.steps);return Gt(c)}finally{_n(i[0],e),_n(i[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),ZE(this,e,t)}checkNumSamples(e,t,s,o="steps"){let r;if(s!=null){if(r=null,t!=null)throw new A(`If ${o} is set, batchSize must be null or undefined.Got batchSize = ${t}`)}else if(e!=null)Array.isArray(e)?r=e[0].shape[0]:r=e.shape[0];else throw new A(`Either the input data should have a defined shape, or ${o} shoud be specified.`);return r}execute(e,t){if(Array.isArray(t)&&t.length===0)throw new A("`outputs` is an empty Array, which is not allowed.");const s=Array.isArray(t),o=s?t:[t],r=this.retrieveSymbolicTensors(o),i=new Es;if(e instanceof lt&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new A(`The number of inputs provided (${e.length}) does not match the number of inputs of this model (${this.inputs.length}).`);for(let l=0;la.name);for(let a=0;a0){const o=[];throw t.forEach((r,i)=>{r==null&&o.push(e[i])}),new A(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(o)}`)}return t}predictLoop(e,t=32,s=!1){return z(()=>{const o=this.checkNumSamples(e);if(s)throw new Ce("Verbose predictLoop() is not implemented yet.");const r=Wd(o,t),i=this.outputs.map(a=>[]);for(let a=0;a{const c=r[a][0],u=r[a][1],h=Wi(e,c,u),d=[];if(Array.isArray(h))for(let f=0;fi[u].push(c));return Gt(i.map(a=>Ot(a,0)))})}predict(e,t={}){const s=Ox(e);Px(s,this.inputNames,this.feedInputShapes,!1);try{const o=t.batchSize==null?32:t.batchSize;return zd(o),this.predictLoop(s,o)}finally{_n(s,e)}}predictOnBatch(e){Px(e,this.inputNames,this.feedInputShapes,!0);const t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)}standardizeUserDataXY(e,t,s=!0,o){if(this.optimizer_==null)throw new gn("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const r=[];for(let i=0;i0&&e[0].shape[0]%o!==0)throw new A(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${o}. Found: ${e[0].shape[0]} sample(s).`);return[e,t]}async standardizeUserData(e,t,s,o,r=!0,i){const[a,l]=this.standardizeUserDataXY(e,t,r,i);if(s!=null)throw new Error("sample weight is not supported yet.");let c=null;if(o!=null){const u=Rx(o,this.outputNames);c=[];for(let h=0;h{const i=this.checkNumSamples(t,s,r,"steps"),a=[];if(o>0)throw new Ce("Verbose mode is not implemented yet.");if(r!=null)throw new Ce("steps mode in testLoop() is not implemented yet");{const l=Wd(i,s),c=Rt(Rn(0,i));for(let u=0;u1){const i=Vg(e.slice(0,s),o);r+=`_${i}`}t.push(r)}return t}makeTrainFunction(){return e=>{const t=[],s=e.slice(0,this.inputs.length),o=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),r=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+this.outputs.length*2),i=[],a=()=>{const h=[];for(let g=0;g1&&g{f=ee(f,g)}),f},l=this.collectedTrainableWeights.map(h=>h.read());return[this.optimizer_.minimize(a,!0,l)].concat(i)}}makeTestFunction(){this.testFunction=e=>z(()=>{const t=[];let s;const o=e.slice(0,this.inputs.length),r=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),i=[];for(let c=0;c0){if(m=!0,s.validationData.length===2)l=s.validationData[0],c=s.validationData[1];else throw s.validationData.length===3?new Ce("validationData including sample weights is not supported yet."):new A(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${s.validationData} is invalid.`);const T=await this.standardizeUserData(l,c,null,null,!0,p);u=T[0],h=T[1],x=u.concat(h)}else if(s.validationSplit!=null&&s.validationSplit>0&&s.validationSplit<1){m=!0;const S=Math.floor(o[0].shape[0]*(1-s.validationSplit)),T=o[0].shape[0];u=Wi(o,S,T),i=o,o=Wi(o,0,S),h=Wi(r,S,T),a=r,r=Wi(r,0,S),x=u.concat(h)}else s.validationSteps!=null&&(m=!0);const b=o.concat(r).concat(d);this.checkTrainableWeightsConsistency();const w=this.makeTrainFunction(),y=this.getDedupedMetricsNames();let C,I;m?(this.makeTestFunction(),C=this.testFunction,I=y.slice().concat(y.map(S=>"val_"+S))):(C=null,x=[],I=y.slice());const v=yx(s.callbacks,s.yieldEvery);return await this.fitLoop(w,b,y,p,s.epochs,s.verbose,v,C,x,s.shuffle,I,s.initialEpoch,null,null)}finally{this.isTraining=!1,_n(o,e),_n(r,t),_n(i,e),_n(a,t),_n(u,l),_n(h,c),d!=null&&fe(d)}}async fitLoop(e,t,s,o,r,i,a,l,c,u,h,d,p,f){o==null&&(o=32),r==null&&(r=1),u==null&&(u=!0),d==null&&(d=0);let g=!1;if(l!=null&&c!=null&&(g=!0),f!=null&&(g=!0,p==null))throw new A("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");const m=this.checkNumSamples(t,o,p,"steps_per_epoch");let x;m!=null&&(x=Rn(0,m)),i==null&&(i=1);const{callbackList:b,history:w}=wx(a,i,r,d,m,p,o,g,h);b.setModel(this),this.history=w,await b.onTrainBegin(),this.stopTraining_=!1;for(let y=d;y{const T=v[k][0],E=v[k][1],V=go(I,T,E-T);S.batch=k,S.size=E-T;const M=Vd(t,V),L=e(M);for(let R=0;Rhs(t))}else{const t=Object.keys(this.loss);e={};const s=this.loss;for(const o of t)if(typeof s[o]=="string")e[o]=hs(s[o]);else throw new Error("Serialization of non-string loss is not supported.")}return e}getMetricIdentifiers(){if(typeof this.metrics=="string"||typeof this.metrics=="function")return[hs(Xl(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(e=>hs(Xl(e)));{const e={};for(const t in this.metrics)e[t]=hs(Xl(this.metrics[t]));return e}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(e){if(e.weighted_metrics!=null)throw new Error("Loading weight_metrics is not supported yet.");if(e.loss_weights!=null)throw new Error("Loading loss_weights is not supported yet.");if(e.sample_weight_mode!=null)throw new Error("Loading sample_weight_mode is not supported yet.");const t=Zl(e.optimizer_config),s=Zn(t);let o;if(typeof e.loss=="string")o=po(e.loss);else if(Array.isArray(e.loss))o=e.loss.map(i=>po(i));else if(e.loss!=null){o={};for(const i in e.loss)o[i]=po(e.loss[i])}let r;if(Array.isArray(e.metrics))r=e.metrics.map(i=>po(i));else if(e.metrics!=null){r={};for(const i in e.metrics)r[i]=po(e.metrics[i])}this.compile({loss:o,metrics:r,optimizer:s})}async save(e,t){if(typeof e=="string"){const c=RC(e);if(c.length===0)throw new A(`Cannot find any save handlers for URL '${e}'`);if(c.length>1)throw new A(`Found more than one (${c.length}) save handlers for URL '${e}'`);e=c[0]}if(e.save==null)throw new A("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const s=await Kf(this.getNamedWeights(t)),a={modelTopology:this.toJSON(null,!1),format:nR,generatedBy:`TensorFlow.js tfjs-layers v${Ex}`,convertedBy:null};if((t==null?!1:t.includeOptimizer)&&this.optimizer!=null){a.trainingConfig=this.getTrainingConfig();const c="optimizer",{data:u,specs:h}=await Kf(await this.optimizer.getWeights(),c);s.specs.push(...h),s.data=IC([s.data,u])}return this.userDefinedMetadata!=null&&(Tx(this.userDefinedMetadata,this.name,!0),a.userDefinedMetadata=this.userDefinedMetadata),a.weightData=s.data,a.weightSpecs=s.specs,e.save(a)}setUserDefinedMetadata(e){Tx(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}}tr.className="Model",Z(tr);class Bx extends tr{}Bx.className="Functional",Z(Bx);/** + */function eR(n){return n instanceof lt}function Ud(n){return Array.isArray(n)}function Mx(n){return!eR(n)&&!Ud(n)}function Px(n,e,t,s=!0,o=""){if(e==null||e.length===0){if(n!=null){let i=!1;if(Ud(n)&&n.length>0)i=!0;else if(Mx(n)){for(const a in n)if(n.hasOwnProperty(a)){i=!0;break}}else i=!0;if(i)throw new A(`Error when checking model ${o} expected no data, but got ${n}`)}return[]}if(n==null)return e.map(i=>null);let r;if(Mx(n)){n=n,r=[];for(const i of e){if(n[i]==null)throw new A(`No data provided for "${i}". Need data for each key in: ${e}`);r.push(n[i])}}else if(Ud(n)){if(n=n,n.length!==e.length)throw new A(`Error when checking model ${o}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${e.length} Tensor(s), but instead got the following list of Tensor(s): ${n}`);r=n}else{if(n=n,e.length>1)throw new A(`The model ${o} expects ${e.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${n.shape}`);r=[n]}if(r=Lx(r),t!=null)for(let i=0;i=0&&c!==u)throw new A(`${o} expected a batch of elements where each example has shape [${t[i].slice(1,t[i].length)}] (i.e.,tensor shape [*,${t[i].slice(1,t[i].length)}]) but the ${o} received an input with ${a.shape[0]} examples, each with shape [${a.shape.slice(1,a.shape.length)}] (tensor shape [${a.shape}])`)}}return r}function tR(n,e,t){const s=Ss(n.map(r=>r.shape[0]));s.sort();const o=Ss(e.map(r=>r.shape[0]));if(o.sort(),s.length>1)throw new A(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(n.map(r=>r.shape))}`);if(o.length>1)throw new A(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map(r=>r.shape))}`);if(s.length>0&&o.length>0&&!Oe(s,o))throw new A(`Input Tensors should have the same number of samples as target Tensors. Found ${s[0]} input sample(s) and ${o[0]} target sample(s).`)}function nR(n,e,t){const s=[Hl,jl,Vi];for(let o=0;o1)throw new A(`The model expects ${e.length} ${o} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(n.shape)}.`);r=[n]}if(t!=null)for(let i=0;i[]);let t;if(typeof n=="string"||typeof n=="function")t=[n];else if(Array.isArray(n)||typeof n=="object")t=n;else throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${n}`);if(Array.isArray(t))return e.map(s=>t);{const s=[];for(const o of e){let r=t.hasOwnProperty(o)?t[o]:[];Array.isArray(r)||(r=[r]),s.push(r)}return s}}const oR="layers-model";class tr extends Fn{constructor(e){super(e),this.isTraining=!1}summary(e,t,s=console.log){if(!this.built)throw new A("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");zE(this,e,t,s)}compile(e){if(e.loss==null&&(e.loss=[]),this.loss=e.loss,typeof e.optimizer=="string")this.optimizer_=BE(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof ks))throw new A("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let t=[];if(!Array.isArray(e.loss)&&typeof e.loss!="string"&&typeof e.loss!="function"){e.loss=e.loss;for(const i in e.loss)if(this.outputNames.indexOf(i)===-1)throw new A(`Unknown entry in loss dictionary: "${i}". Only expected the following keys: ${this.outputNames}`);for(const i of this.outputNames)e.loss[i]==null&&console.warn(`Output "${i}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${i} during training`),t.push(Md(e.loss[i]))}else if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new A(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${e.loss}.`);t=e.loss.map(a=>Md(a))}else{const i=Md(e.loss);this.outputs.forEach(a=>{t.push(i)})}this.lossFunctions=t,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let i=0;i{for(let i=0;i1&&(this.metricsTensors.push([a,i]),this.metricsNames.push(this.outputNames[i]+"_loss"))}});const o=sR(e.metrics,this.outputNames),r=(i,a,l)=>{this.outputNames.length>1&&(a=this.outputNames[i]+"_"+a),this.metricsNames.push(a),this.metricsTensors.push([l,i])};go("metric",()=>{for(let i=0;i{const u="";let h,d,p;for(const f of c){if(typeof f=="string"&&["accuracy","acc","crossentropy","ce"].indexOf(f)!==-1){const m=this.internalOutputShapes[i];m[m.length-1]===1||this.lossFunctions[i]===jl?["accuracy","acc"].indexOf(f)!==-1?d=$x:["crossentropy","ce"].indexOf(f)!==-1&&(d=EE):this.lossFunctions[i]===ql?["accuracy","acc"].indexOf(f)!==-1?d=RE:["crossentropy","ce"].indexOf(f)!==-1&&(d=Sx):["accuracy","acc"].indexOf(f)!==-1?d=vx:["crossentropy","ce"].indexOf(f)!==-1&&(d=kx);let x;["accuracy","acc"].indexOf(f)!==-1?x="acc":["crossentropy","ce"].indexOf(f)!==-1&&(x="ce"),p=d,h=u+x}else p=PE(f),h=u+Yl(f);let g;go(h,()=>{g=p}),r(i,h,g)}})(a)}}),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){this.collectedTrainableWeights!=null&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")}evaluate(e,t,s={}){const o=s.batchSize==null?32:s.batchSize;zd(o);const i=this.standardizeUserDataXY(e,t,!0,o);try{const a=i[0].concat(i[1]);this.makeTestFunction();const l=this.testFunction,c=this.testLoop(l,a,o,s.verbose,s.steps);return Ht(c)}finally{_n(i[0],e),_n(i[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),JE(this,e,t)}checkNumSamples(e,t,s,o="steps"){let r;if(s!=null){if(r=null,t!=null)throw new A(`If ${o} is set, batchSize must be null or undefined.Got batchSize = ${t}`)}else if(e!=null)Array.isArray(e)?r=e[0].shape[0]:r=e.shape[0];else throw new A(`Either the input data should have a defined shape, or ${o} shoud be specified.`);return r}execute(e,t){if(Array.isArray(t)&&t.length===0)throw new A("`outputs` is an empty Array, which is not allowed.");const s=Array.isArray(t),o=s?t:[t],r=this.retrieveSymbolicTensors(o),i=new Es;if(e instanceof lt&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new A(`The number of inputs provided (${e.length}) does not match the number of inputs of this model (${this.inputs.length}).`);for(let l=0;la.name);for(let a=0;a0){const o=[];throw t.forEach((r,i)=>{r==null&&o.push(e[i])}),new A(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(o)}`)}return t}predictLoop(e,t=32,s=!1){return P(()=>{const o=this.checkNumSamples(e);if(s)throw new Ce("Verbose predictLoop() is not implemented yet.");const r=Wd(o,t),i=this.outputs.map(a=>[]);for(let a=0;a{const c=r[a][0],u=r[a][1],h=Wi(e,c,u),d=[];if(Array.isArray(h))for(let f=0;fi[u].push(c));return Ht(i.map(a=>Mt(a,0)))})}predict(e,t={}){const s=Lx(e);Bx(s,this.inputNames,this.feedInputShapes,!1);try{const o=t.batchSize==null?32:t.batchSize;return zd(o),this.predictLoop(s,o)}finally{_n(s,e)}}predictOnBatch(e){Bx(e,this.inputNames,this.feedInputShapes,!0);const t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)}standardizeUserDataXY(e,t,s=!0,o){if(this.optimizer_==null)throw new gn("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const r=[];for(let i=0;i0&&e[0].shape[0]%o!==0)throw new A(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${o}. Found: ${e[0].shape[0]} sample(s).`);return[e,t]}async standardizeUserData(e,t,s,o,r=!0,i){const[a,l]=this.standardizeUserDataXY(e,t,r,i);if(s!=null)throw new Error("sample weight is not supported yet.");let c=null;if(o!=null){const u=Ax(o,this.outputNames);c=[];for(let h=0;h{const i=this.checkNumSamples(t,s,r,"steps"),a=[];if(o>0)throw new Ce("Verbose mode is not implemented yet.");if(r!=null)throw new Ce("steps mode in testLoop() is not implemented yet");{const l=Wd(i,s),c=At(Rn(0,i));for(let u=0;u1){const i=Wg(e.slice(0,s),o);r+=`_${i}`}t.push(r)}return t}makeTrainFunction(){return e=>{const t=[],s=e.slice(0,this.inputs.length),o=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),r=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+this.outputs.length*2),i=[],a=()=>{const h=[];for(let g=0;g1&&g{f=ee(f,g)}),f},l=this.collectedTrainableWeights.map(h=>h.read());return[this.optimizer_.minimize(a,!0,l)].concat(i)}}makeTestFunction(){this.testFunction=e=>P(()=>{const t=[];let s;const o=e.slice(0,this.inputs.length),r=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),i=[];for(let c=0;c0){if(m=!0,s.validationData.length===2)l=s.validationData[0],c=s.validationData[1];else throw s.validationData.length===3?new Ce("validationData including sample weights is not supported yet."):new A(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${s.validationData} is invalid.`);const T=await this.standardizeUserData(l,c,null,null,!0,p);u=T[0],h=T[1],x=u.concat(h)}else if(s.validationSplit!=null&&s.validationSplit>0&&s.validationSplit<1){m=!0;const S=Math.floor(o[0].shape[0]*(1-s.validationSplit)),T=o[0].shape[0];u=Wi(o,S,T),i=o,o=Wi(o,0,S),h=Wi(r,S,T),a=r,r=Wi(r,0,S),x=u.concat(h)}else s.validationSteps!=null&&(m=!0);const b=o.concat(r).concat(d);this.checkTrainableWeightsConsistency();const w=this.makeTrainFunction(),y=this.getDedupedMetricsNames();let C,I;m?(this.makeTestFunction(),C=this.testFunction,I=y.slice().concat(y.map(S=>"val_"+S))):(C=null,x=[],I=y.slice());const v=wx(s.callbacks,s.yieldEvery);return await this.fitLoop(w,b,y,p,s.epochs,s.verbose,v,C,x,s.shuffle,I,s.initialEpoch,null,null)}finally{this.isTraining=!1,_n(o,e),_n(r,t),_n(i,e),_n(a,t),_n(u,l),_n(h,c),d!=null&&fe(d)}}async fitLoop(e,t,s,o,r,i,a,l,c,u,h,d,p,f){o==null&&(o=32),r==null&&(r=1),u==null&&(u=!0),d==null&&(d=0);let g=!1;if(l!=null&&c!=null&&(g=!0),f!=null&&(g=!0,p==null))throw new A("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");const m=this.checkNumSamples(t,o,p,"steps_per_epoch");let x;m!=null&&(x=Rn(0,m)),i==null&&(i=1);const{callbackList:b,history:w}=Cx(a,i,r,d,m,p,o,g,h);b.setModel(this),this.history=w,await b.onTrainBegin(),this.stopTraining_=!1;for(let y=d;y{const T=v[k][0],E=v[k][1],V=xo(I,T,E-T);S.batch=k,S.size=E-T;const M=Vd(t,V),L=e(M);for(let R=0;Rhs(t))}else{const t=Object.keys(this.loss);e={};const s=this.loss;for(const o of t)if(typeof s[o]=="string")e[o]=hs(s[o]);else throw new Error("Serialization of non-string loss is not supported.")}return e}getMetricIdentifiers(){if(typeof this.metrics=="string"||typeof this.metrics=="function")return[hs(Yl(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(e=>hs(Yl(e)));{const e={};for(const t in this.metrics)e[t]=hs(Yl(this.metrics[t]));return e}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(e){if(e.weighted_metrics!=null)throw new Error("Loading weight_metrics is not supported yet.");if(e.loss_weights!=null)throw new Error("Loading loss_weights is not supported yet.");if(e.sample_weight_mode!=null)throw new Error("Loading sample_weight_mode is not supported yet.");const t=Ql(e.optimizer_config),s=Zn(t);let o;if(typeof e.loss=="string")o=fo(e.loss);else if(Array.isArray(e.loss))o=e.loss.map(i=>fo(i));else if(e.loss!=null){o={};for(const i in e.loss)o[i]=fo(e.loss[i])}let r;if(Array.isArray(e.metrics))r=e.metrics.map(i=>fo(i));else if(e.metrics!=null){r={};for(const i in e.metrics)r[i]=fo(e.metrics[i])}this.compile({loss:o,metrics:r,optimizer:s})}async save(e,t){if(typeof e=="string"){const c=FC(e);if(c.length===0)throw new A(`Cannot find any save handlers for URL '${e}'`);if(c.length>1)throw new A(`Found more than one (${c.length}) save handlers for URL '${e}'`);e=c[0]}if(e.save==null)throw new A("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const s=await Kf(this.getNamedWeights(t)),a={modelTopology:this.toJSON(null,!1),format:oR,generatedBy:`TensorFlow.js tfjs-layers v${Rx}`,convertedBy:null};if((t==null?!1:t.includeOptimizer)&&this.optimizer!=null){a.trainingConfig=this.getTrainingConfig();const c="optimizer",{data:u,specs:h}=await Kf(await this.optimizer.getWeights(),c);s.specs.push(...h),s.data=kC([s.data,u])}return this.userDefinedMetadata!=null&&(Nx(this.userDefinedMetadata,this.name,!0),a.userDefinedMetadata=this.userDefinedMetadata),a.weightData=s.data,a.weightSpecs=s.specs,e.save(a)}setUserDefinedMetadata(e){Nx(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}}tr.className="Model",Y(tr);class zx extends tr{}zx.className="Functional",Y(zx);/** * @license * Copyright 2018 Google LLC * @@ -7720,7 +7720,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */async function sR(n,e){if(e==null&&(e={}),typeof n=="string"){const t=AC(n,e);if(t.length===0)t.push(h2(n,e));else if(t.length>1)throw new A(`Found more than one (${t.length}) load handlers for URL '${n}'`);n=t[0]}return oR(n,void 0,e)}async function oR(n,e,t){if(t==null&&(t={}),n.load==null)throw new A("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const s=await n.load();let o=s.modelTopology;o.model_config!=null&&(o=o.model_config);const r=t.strict==null?!0:t.strict,i=s.weightData!=null&&s.weightSpecs!=null&&r,a=Zn(Zl(o),e,i),l=s.trainingConfig;if(l!=null&&a.loadTrainingConfig(l),s.userDefinedMetadata!=null&&a.setUserDefinedMetadata(s.userDefinedMetadata),s.weightData!=null){if(s.weightSpecs==null)throw new A("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");const{modelWeights:c,optimizerWeights:u}=rR(s.weightData,s.weightSpecs);a.loadWeights(c,r),a.optimizer!=null&&u.length>0&&await a.optimizer.setWeights(u),fe(c),fe(u.map(h=>h.tensor))}return a}function rR(n,e){const t=gC(n,e),s={},o=[];return e.forEach(r=>{r.group==="optimizer"?o.push({name:r.name,tensor:t[r.name]}):s[r.name]=t[r.name]}),{modelWeights:s,optimizerWeights:o}}class Ui extends tr{constructor(e){if(super({inputs:[],outputs:[]}),e=e||{},this.trainable=!0,this.built=!1,this.name=e.name!=null?e.name:Ol("sequential_"),e.layers!=null)for(const t of e.layers)this.add(t)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some(s=>s<0))throw new A(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){const t=e instanceof Ui||e instanceof tr;let s;if(t){if(s=e,s.outputs.length!==1)throw new A("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(s.inputs.length!==1)throw new A("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(this.outputs.length===0){if(e.inboundNodes.length===0){if(e.batchInputShape==null)throw new A("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");const o=rE({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(o)}if(t)this.outputs=s.outputs,this.inputs=s.inputs;else{if(e.inboundNodes.length!==1)throw new A(`A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer ${e.name} which has ${e.inboundNodes.length} pre-existing inbound connections.`);if(e.inboundNodes[0].outputTensors.length!==1)throw new A("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[e.inboundNodes[0].outputTensors[0]],this.inputs=cx(this.outputs[0])}this.inboundNodes=[],new zl({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:ho(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(o=>o.shape),outputShapes:this.outputs[0].shape})}else{const o=e.apply(this.outputs[0]);if(Array.isArray(o))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[o],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(this.layers.length===0)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),this.layers.length===0)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{const e=this.layers.length-1;this.layers[e].outboundNodes=[],this.outputs=[this.layers[e].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}}call(e,t){return this.model==null&&this.build(),this.model.call(e,t)}build(e){if(_e(e),this.inputs.length===0||this.outputs.length===0)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new tr({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supportsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0}countParams(){return this.built||this.build(),super.countParams()}summary(e,t,s=console.log){this.built||this.build(),super.summary(e,t,s)}setWeights(e){this.model==null&&this.build(),this.model.setWeights(e)}evaluate(e,t,s={}){if(!this.built)throw new gn("The model needs to be compiled before being used.");return this.model.evaluate(e,t,s)}async evaluateDataset(e,t){if(!this.built)throw new gn("The model needs to be compiled before being used.");return this.model.evaluateDataset(e,t)}predict(e,t={}){return this.model==null&&this.build(),this.model.predict(e,t)}predictOnBatch(e){return this.model==null&&this.build(),this.model.predictOnBatch(e)}compile(e){this.build(),this.model.compile(e),this.optimizer_=this.model.optimizer,this.isOptimizerOwned=this.model.isOptimizerOwned,this.loss=this.model.loss,this.metrics=this.model.metrics,this.metricsTensors=this.model.metricsTensors,this.metricsNames=this.model.metricsNames}get optimizer(){return this.model==null?void 0:this.model.optimizer}set optimizer(e){this.model.optimizer=e}async fit(e,t,s={}){if(!this.built)throw new gn("The model needs to be compiled before being used.");return this.model.fit(e,t,s)}async fitDataset(e,t){if(!this.built)throw new gn("The model needs to be compiled before being used.");return this.model.fitDataset(e,t)}async trainOnBatch(e,t){return this.model.trainOnBatch(e,t)}static fromConfig(e,t,s={},o=!1){let r,i={};if(t instanceof Array){if(t[0].className==null||t[0].className==="Merge")throw new A("Legacy serialization format not supported yet.");r=t}else $(t.layers!=null,()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field."),r=t.layers,delete t.layers,i=t;const a=new e(i);if(!(a instanceof Ui))throw new Ce(`Sequential.fromConfig called on non-Sequential input: ${a}`);for(const l of r){const u=Zn(l,void 0,o);o&&u.setFastWeightInitDuringBuild(!0),a.add(u)}return a}set stopTraining(e){if(this.model==null)throw new A("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}get stopTraining(){if(this.model==null)throw new A("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}getConfig(){const e=[];for(const t of this.layers){const s={};s.className=t.getClassName(),s.config=t.getConfig(),e.push(s)}return{name:this.name,layers:e}}}Ui.className="Sequential",Z(Ui);/** + */async function rR(n,e){if(e==null&&(e={}),typeof n=="string"){const t=_C(n,e);if(t.length===0)t.push(p2(n,e));else if(t.length>1)throw new A(`Found more than one (${t.length}) load handlers for URL '${n}'`);n=t[0]}return iR(n,void 0,e)}async function iR(n,e,t){if(t==null&&(t={}),n.load==null)throw new A("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const s=await n.load();let o=s.modelTopology;o.model_config!=null&&(o=o.model_config);const r=t.strict==null?!0:t.strict,i=s.weightData!=null&&s.weightSpecs!=null&&r,a=Zn(Ql(o),e,i),l=s.trainingConfig;if(l!=null&&a.loadTrainingConfig(l),s.userDefinedMetadata!=null&&a.setUserDefinedMetadata(s.userDefinedMetadata),s.weightData!=null){if(s.weightSpecs==null)throw new A("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");const{modelWeights:c,optimizerWeights:u}=aR(s.weightData,s.weightSpecs);a.loadWeights(c,r),a.optimizer!=null&&u.length>0&&await a.optimizer.setWeights(u),fe(c),fe(u.map(h=>h.tensor))}return a}function aR(n,e){const t=yC(n,e),s={},o=[];return e.forEach(r=>{r.group==="optimizer"?o.push({name:r.name,tensor:t[r.name]}):s[r.name]=t[r.name]}),{modelWeights:s,optimizerWeights:o}}class Ui extends tr{constructor(e){if(super({inputs:[],outputs:[]}),e=e||{},this.trainable=!0,this.built=!1,this.name=e.name!=null?e.name:Ll("sequential_"),e.layers!=null)for(const t of e.layers)this.add(t)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some(s=>s<0))throw new A(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){const t=e instanceof Ui||e instanceof tr;let s;if(t){if(s=e,s.outputs.length!==1)throw new A("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(s.inputs.length!==1)throw new A("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(this.outputs.length===0){if(e.inboundNodes.length===0){if(e.batchInputShape==null)throw new A("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");const o=aE({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(o)}if(t)this.outputs=s.outputs,this.inputs=s.inputs;else{if(e.inboundNodes.length!==1)throw new A(`A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer ${e.name} which has ${e.inboundNodes.length} pre-existing inbound connections.`);if(e.inboundNodes[0].outputTensors.length!==1)throw new A("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[e.inboundNodes[0].outputTensors[0]],this.inputs=ux(this.outputs[0])}this.inboundNodes=[],new Vl({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:po(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(o=>o.shape),outputShapes:this.outputs[0].shape})}else{const o=e.apply(this.outputs[0]);if(Array.isArray(o))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[o],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(this.layers.length===0)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),this.layers.length===0)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{const e=this.layers.length-1;this.layers[e].outboundNodes=[],this.outputs=[this.layers[e].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}}call(e,t){return this.model==null&&this.build(),this.model.call(e,t)}build(e){if(_e(e),this.inputs.length===0||this.outputs.length===0)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new tr({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supportsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0}countParams(){return this.built||this.build(),super.countParams()}summary(e,t,s=console.log){this.built||this.build(),super.summary(e,t,s)}setWeights(e){this.model==null&&this.build(),this.model.setWeights(e)}evaluate(e,t,s={}){if(!this.built)throw new gn("The model needs to be compiled before being used.");return this.model.evaluate(e,t,s)}async evaluateDataset(e,t){if(!this.built)throw new gn("The model needs to be compiled before being used.");return this.model.evaluateDataset(e,t)}predict(e,t={}){return this.model==null&&this.build(),this.model.predict(e,t)}predictOnBatch(e){return this.model==null&&this.build(),this.model.predictOnBatch(e)}compile(e){this.build(),this.model.compile(e),this.optimizer_=this.model.optimizer,this.isOptimizerOwned=this.model.isOptimizerOwned,this.loss=this.model.loss,this.metrics=this.model.metrics,this.metricsTensors=this.model.metricsTensors,this.metricsNames=this.model.metricsNames}get optimizer(){return this.model==null?void 0:this.model.optimizer}set optimizer(e){this.model.optimizer=e}async fit(e,t,s={}){if(!this.built)throw new gn("The model needs to be compiled before being used.");return this.model.fit(e,t,s)}async fitDataset(e,t){if(!this.built)throw new gn("The model needs to be compiled before being used.");return this.model.fitDataset(e,t)}async trainOnBatch(e,t){return this.model.trainOnBatch(e,t)}static fromConfig(e,t,s={},o=!1){let r,i={};if(t instanceof Array){if(t[0].className==null||t[0].className==="Merge")throw new A("Legacy serialization format not supported yet.");r=t}else $(t.layers!=null,()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field."),r=t.layers,delete t.layers,i=t;const a=new e(i);if(!(a instanceof Ui))throw new Ce(`Sequential.fromConfig called on non-Sequential input: ${a}`);for(const l of r){const u=Zn(l,void 0,o);o&&u.setFastWeightInitDuringBuild(!0),a.add(u)}return a}set stopTraining(e){if(this.model==null)throw new A("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}get stopTraining(){if(this.model==null)throw new A("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}getConfig(){const e=[];for(const t of this.layers){const s={};s.className=t.getClassName(),s.config=t.getConfig(),e.push(s)}return{name:this.name,layers:e}}}Ui.className="Sequential",Y(Ui);/** * @license * Copyright 2018 Google LLC * @@ -7728,7 +7728,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */let Ht=class extends Zo{getConfig(){return{}}};class zx extends Ht{apply(e,t=1){return UN(e,t)}}zx.className="elu",Z(zx);class Vx extends Ht{apply(e){return km(e)}}Vx.className="selu",Z(Vx);class Wx extends Ht{apply(e){return lo(e)}}Wx.className="relu",Z(Wx);class Ux extends Ht{apply(e){return z(()=>ki(6,lo(e)))}}Ux.className="relu6",Z(Ux);class Gx extends Ht{apply(e){return e}}Gx.className="linear",Z(Gx);class Hx extends Ht{apply(e){return Go(e)}}Hx.className="sigmoid",Z(Hx);class jx extends Ht{apply(e){return HN(e)}}jx.className="hardSigmoid",Z(jx);class qx extends Ht{apply(e){return vi(e)}}qx.className="softplus",Z(qx);class Kx extends Ht{apply(e){return GN(e)}}Kx.className="softsign",Z(Kx);class Xx extends Ht{apply(e){return eh(e)}}Xx.className="tanh",Z(Xx);let Gd=class extends Ht{apply(e,t=-1){return Sh(e,t)}};Gd.className="softmax",Z(Gd);class Yx extends Ht{apply(e,t=-1){return gm(e,t)}}Yx.className="logSoftmax",Z(Yx);class Zx extends Ht{apply(e,t=1){return z(()=>F(Go(F(e,t)),e))}}Zx.className="swish",Z(Zx);class Qx extends Ht{apply(e){return z(()=>F(e,eh(vi(e))))}}Qx.className="mish",Z(Qx);function Rs(n){return n.getClassName()}function Hd(n,e={}){return Di(n,mn.getMap().classNameMap,e,"activation")}function As(n){if(n==null){const e={};return e.className="linear",e.config={},Hd(e)}if(typeof n=="string"){const e={};return e.className=n,e.config={},Hd(e)}else return n instanceof Ht?n:Hd(n)}/** + */let Dt=class extends Zo{getConfig(){return{}}};class Vx extends Dt{apply(e,t=1){return HN(e,t)}}Vx.className="elu",Y(Vx);class Wx extends Dt{apply(e){return Sm(e)}}Wx.className="selu",Y(Wx);class Ux extends Dt{apply(e){return co(e)}}Ux.className="relu",Y(Ux);class Gx extends Dt{apply(e){return P(()=>ki(6,co(e)))}}Gx.className="relu6",Y(Gx);class Hx extends Dt{apply(e){return e}}Hx.className="linear",Y(Hx);class qx extends Dt{apply(e){return Ho(e)}}qx.className="sigmoid",Y(qx);class jx extends Dt{apply(e){return jN(e)}}jx.className="hardSigmoid",Y(jx);class Kx extends Dt{apply(e){return vi(e)}}Kx.className="softplus",Y(Kx);class Xx extends Dt{apply(e){return qN(e)}}Xx.className="softsign",Y(Xx);class Yx extends Dt{apply(e){return wl(e)}}Yx.className="tanh",Y(Yx);let Gd=class extends Dt{apply(e,t=-1){return Sh(e,t)}};Gd.className="softmax",Y(Gd);class Zx extends Dt{apply(e,t=-1){return xm(e,t)}}Zx.className="logSoftmax",Y(Zx);class Qx extends Dt{apply(e){return P(()=>P(()=>{const t=Math.sqrt(2),s=D(.5,ee(1,dm(me(e,t))));return D(e,s)}))}}Qx.className="gelu",Y(Qx);class Jx extends Dt{apply(e){return P(()=>D(.5,D(e,ee(1,wl(D(Rt(me(2,Math.PI)),ee(e,D(.044715,io(e,3)))))))))}}Jx.className="gelu_new",Y(Jx);class eb extends Dt{apply(e){return P(()=>D(e,wl(vi(e))))}}eb.className="mish",Y(eb);class tb extends Dt{apply(e,t=1){return P(()=>D(Ho(D(e,t)),e))}}tb.className="swish",Y(tb);function Rs(n){return n.getClassName()}function Hd(n,e={}){return Di(n,mn.getMap().classNameMap,e,"activation")}function As(n){if(n==null){const e={};return e.className="linear",e.config={},Hd(e)}if(typeof n=="string"){const e={};return e.className=n,e.config={},Hd(e)}else return n instanceof Dt?n:Hd(n)}/** * @license * Copyright 2018 Google LLC * @@ -7736,7 +7736,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function iR(n){if(n!=null&&typeof n!="object")throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${n}`)}class Jx extends Zo{}class eb extends Jx{constructor(e){super(),iR(e),this.l1=e==null||e.l1==null?.01:e.l1,this.l2=e==null||e.l2==null?.01:e.l2,this.hasL1=this.l1!==0,this.hasL2=this.l2!==0}apply(e){return z(()=>{let t=st([1]);return this.hasL1&&(t=ee(t,pe(F(this.l1,_t(e))))),this.hasL2&&(t=ee(t,pe(F(this.l2,Oi(e))))),_(t,[])})}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}}eb.className="L1L2",Z(eb);const tb={l1l2:"L1L2"};function ze(n){return gd(n)}function nb(n,e={}){return Di(n,mn.getMap().classNameMap,e,"regularizer")}function Ke(n){if(n==null)return null;if(typeof n=="string"){const t={className:n in tb?tb[n]:n,config:{}};return nb(t)}else return n instanceof Jx?n:nb(n)}/** + */function lR(n){if(n!=null&&typeof n!="object")throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${n}`)}class nb extends Zo{}class sb extends nb{constructor(e){super(),lR(e),this.l1=e==null||e.l1==null?.01:e.l1,this.l2=e==null||e.l2==null?.01:e.l2,this.hasL1=this.l1!==0,this.hasL2=this.l2!==0}apply(e){return P(()=>{let t=st([1]);return this.hasL1&&(t=ee(t,pe(D(this.l1,Lt(e))))),this.hasL2&&(t=ee(t,pe(D(this.l2,Oi(e))))),_(t,[])})}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}}sb.className="L1L2",Y(sb);const ob={l1l2:"L1L2"};function ze(n){return gd(n)}function rb(n,e={}){return Di(n,mn.getMap().classNameMap,e,"regularizer")}function Ke(n){if(n==null)return null;if(typeof n=="string"){const t={className:n in ob?ob[n]:n,config:{}};return rb(t)}else return n instanceof nb?n:rb(n)}/** * @license * Copyright 2018 Google LLC * @@ -7744,7 +7744,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class sb extends ke{constructor(e){super(e??{}),this.supportsMasking=!0,e!=null&&(this.maxValue=e.maxValue)}call(e,t){e=xe(e);let s=lo(e);return this.maxValue!=null&&(s=nn(s,0,this.maxValue)),s}computeOutputShape(e){return e}getConfig(){const e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}}sb.className="ReLU",Z(sb);class ob extends ke{constructor(e){super(e??{}),this.DEFAULT_ALPHA=.3,e==null&&(e={}),this.alpha=e.alpha==null?this.DEFAULT_ALPHA:e.alpha}call(e,t){const s=xe(e);return uh(s,this.alpha)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}}ob.className="LeakyReLU",Z(ob);class rb extends ke{constructor(e){if(super(e??{}),this.DEFAULT_ALPHA_INITIALIZER="zeros",e==null&&(e={}),this.supportsMasking=!0,this.alphaInitializer=qe(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=Ke(e.alphaRegularizer),this.alphaConstraint=pt(e.alphaConstraint),e.sharedAxes==null)this.sharedAxes=null;else if(Array.isArray(e.sharedAxes))this.sharedAxes=e.sharedAxes;else if(typeof e.sharedAxes=="number")this.sharedAxes=[e.sharedAxes];else throw new A(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`)}build(e){e=_e(e);const t=e.slice(1);if(this.sharedAxes!=null)for(const o of this.sharedAxes)t[o-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);const s={};if(this.sharedAxes!=null)for(let o=1;o{let s=xe(e);const o=t.mask;if(o!=null){const r=F(ge(Nn(s.shape),oe(o,s.dtype)),Fe(-1e9));s=ee(s,r)}return this.axis instanceof Array?this.axis.length>1?Vn(ge(s,xm(s,this.axis,!0))):this.softmax(s,this.axis[0]):this.softmax(s,this.axis)})}computeOutputShape(e){return e}getConfig(){const e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}}lb.className="Softmax",Z(lb);/** + */class ib extends ke{constructor(e){super(e??{}),this.supportsMasking=!0,e!=null&&(this.maxValue=e.maxValue)}call(e,t){e=xe(e);let s=co(e);return this.maxValue!=null&&(s=nn(s,0,this.maxValue)),s}computeOutputShape(e){return e}getConfig(){const e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}}ib.className="ReLU",Y(ib);class ab extends ke{constructor(e){super(e??{}),this.DEFAULT_ALPHA=.3,e==null&&(e={}),this.alpha=e.alpha==null?this.DEFAULT_ALPHA:e.alpha}call(e,t){const s=xe(e);return uh(s,this.alpha)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}}ab.className="LeakyReLU",Y(ab);class lb extends ke{constructor(e){if(super(e??{}),this.DEFAULT_ALPHA_INITIALIZER="zeros",e==null&&(e={}),this.supportsMasking=!0,this.alphaInitializer=je(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=Ke(e.alphaRegularizer),this.alphaConstraint=pt(e.alphaConstraint),e.sharedAxes==null)this.sharedAxes=null;else if(Array.isArray(e.sharedAxes))this.sharedAxes=e.sharedAxes;else if(typeof e.sharedAxes=="number")this.sharedAxes=[e.sharedAxes];else throw new A(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`)}build(e){e=_e(e);const t=e.slice(1);if(this.sharedAxes!=null)for(const o of this.sharedAxes)t[o-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);const s={};if(this.sharedAxes!=null)for(let o=1;o{let s=xe(e);const o=t.mask;if(o!=null){const r=D(ge(Nn(s.shape),oe(o,s.dtype)),Fe(-1e9));s=ee(s,r)}return this.axis instanceof Array?this.axis.length>1?Vn(ge(s,bm(s,this.axis,!0))):this.softmax(s,this.axis[0]):this.softmax(s,this.axis)})}computeOutputShape(e){return e}getConfig(){const e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}}hb.className="Softmax",Y(hb);/** * @license * Copyright 2018 Google LLC * @@ -7752,7 +7752,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function nr(n,e,t){if(typeof n=="number")return ho(n,e);if(n.length!==e)throw new A(`The ${t} argument must be an integer or tuple of ${e} integers. Received: ${n.length} elements.`);for(let s=0;s(ot(e),e==="channelsFirst"?Ee(n,[0,2,3,1]):n))}function cb(n,e){return z(()=>(ot(e),e==="channelsFirst"?Ee(n,[0,2,3,4,1]):n))}function aR(n,e,t,s=1,o="valid",r,i=1){return z(()=>{if(r==null&&(r=An()),ot(r),n.shape.length!==3)throw new A(`The input of a conv1dWithBias operation should be 3, but is ${n.shape.length} instead.`);if(e.shape.length!==3)throw new A(`The kernel for a conv1dWithBias operation should be 3, but is ${e.shape.length} instead`);if(t!=null&&t.shape.length!==1)throw new A(`The bias for a conv1dWithBias operation should be 1, but is ${e.shape.length} instead`);if(r==="channelsFirst"&&(n=Ee(n,[0,2,1])),o==="causal")throw new Ce("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let a=im(n,e,s,o==="same"?"same":"valid","NWC",i);return t!=null&&(a=Dn(a,t)),a})}function ub(n,e,t,s=[1,1],o="valid",r,i,a=null){return z(()=>{if(r==null&&(r=An()),ot(r),n.rank!==3&&n.rank!==4)throw new A(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${n.rank}.`);if(e.rank!==3&&e.rank!==4)throw new A(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${n.rank}.`);let l=jd(n,r);if(o==="causal")throw new Ce("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=lS({x:l,filter:e,strides:s,pad:o==="same"?"same":"valid",dilations:i,dataFormat:"NHWC",bias:t,activation:a}),r==="channelsFirst"&&(l=Ee(l,[0,3,1,2])),l})}function lR(n,e,t,s=[1,1,1],o="valid",r,i){return z(()=>{if(r==null&&(r=An()),ot(r),n.rank!==4&&n.rank!==5)throw new A(`conv3dWithBias expects input to be of rank 4 or 5, but received ${n.rank}.`);if(e.rank!==4&&e.rank!==5)throw new A(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${n.rank}.`);let a=cb(n,r);if(o==="causal")throw new Ce("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return a=sh(a,e,s,o==="same"?"same":"valid","NDHWC",i),t!=null&&(a=Dn(a,t)),r==="channelsFirst"&&(a=Ee(a,[0,4,1,2,3])),a})}class Ql extends ke{constructor(e,t){if(super(t),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",Ql.verifyArgs(t),this.rank=e,bt(this.rank,"rank"),this.rank!==1&&this.rank!==2&&this.rank!==3)throw new Ce(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=nr(t.kernelSize,e,"kernelSize"),this.strides=nr(t.strides==null?1:t.strides,e,"strides"),this.padding=t.padding==null?"valid":t.padding,on(this.padding),this.dataFormat=t.dataFormat==null?"channelsLast":t.dataFormat,ot(this.dataFormat),this.activation=As(t.activation),this.useBias=t.useBias==null?!0:t.useBias,this.biasInitializer=qe(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=pt(t.biasConstraint),this.biasRegularizer=Ke(t.biasRegularizer),this.activityRegularizer=Ke(t.activityRegularizer),this.dilationRate=nr(t.dilationRate==null?1:t.dilationRate,e,"dilationRate"),this.rank===1&&Array.isArray(this.dilationRate)&&this.dilationRate.length!==1)throw new A(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(this.rank===2){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==2)throw new A(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(this.rank===3){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==3)throw new A(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}}static verifyArgs(e){if(qn("kernelSize"in e,"required key 'kernelSize' not in config"),typeof e.kernelSize!="number"&&!bd(e.kernelSize,"number",1,3))throw new A(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(e.kernelSize)}.`)}getConfig(){const e={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:Rs(this.activation),useBias:this.useBias,biasInitializer:Ze(this.biasInitializer),biasRegularizer:ze(this.biasRegularizer),activityRegularizer:ze(this.activityRegularizer),biasConstraint:dt(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}class sr extends Ql{constructor(e,t){super(e,t),this.kernel=null,sr.verifyArgs(t),this.filters=t.filters,bt(this.filters,"filters"),this.kernelInitializer=qe(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=pt(t.kernelConstraint),this.kernelRegularizer=Ke(t.kernelRegularizer)}build(e){e=_e(e);const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new A(`The channel dimension of the input should be defined. Found ${e[t]}`);const s=e[t],o=this.kernelSize.concat([s,this.filters]);this.kernel=this.addWeight("kernel",o,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[t]:s}}],this.built=!0}call(e,t){return z(()=>{e=xe(e);let s;const o=this.bias==null?null:this.bias.read(),r=Ug(this.activation.getClassName());if(r!=null&&this.rank===2)s=ub(e,this.kernel.read(),o,this.strides,this.padding,this.dataFormat,this.dilationRate,r);else{if(this.rank===1)s=aR(e,this.kernel.read(),o,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(this.rank===2)s=ub(e,this.kernel.read(),o,this.strides,this.padding,this.dataFormat,this.dilationRate);else if(this.rank===3)s=lR(e,this.kernel.read(),o,this.strides,this.padding,this.dataFormat,this.dilationRate);else throw new Ce("convolutions greater than 3D are not implemented yet.");this.activation!=null&&(s=this.activation.apply(s))}return s})}computeOutputShape(e){e=_e(e);const t=[],s=this.dataFormat==="channelsLast"?e.slice(1,e.length-1):e.slice(2);for(let r=0;r 0 but got ${JSON.stringify(e.filters)}`)}}class Gi extends sr{constructor(e){super(2,e),Gi.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!bd(e.kernelSize,"number",1,2))throw new A(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}}Gi.className="Conv2D",Z(Gi);class Hi extends sr{constructor(e){super(3,e),Hi.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!(Array.isArray(e.kernelSize)&&(e.kernelSize.length===1||e.kernelSize.length===3)))throw new A(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}}Hi.className="Conv3D",Z(Hi);class hb extends Gi{constructor(e){if(super(e),this.inputSpec=[new ht({ndim:4})],this.padding!=="same"&&this.padding!=="valid")throw new A(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=_e(e),e.length!==4)throw new A("Input should have rank 4; Received input shape: "+JSON.stringify(e));const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new A("The channel dimension of the inputs should be defined. Found `None`.");const s=e[t],o=this.kernelSize.concat([this.filters,s]);this.kernel=this.addWeight("kernel",o,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new ht({ndim:4,axes:{[t]:s}})],this.built=!0}call(e,t){return z(()=>{let s=xe(e);if(s.shape.length!==4)throw new A(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${s.shape.length}`);const o=s.shape,r=o[0];let i,a;this.dataFormat==="channelsFirst"?(i=2,a=3):(i=1,a=2);const l=o[i],c=o[a],u=this.kernelSize[0],h=this.kernelSize[1],d=this.strides[0],p=this.strides[1],f=Qn(l,d,u,this.padding),g=Qn(c,p,h,this.padding),m=[r,f,g,this.filters];this.dataFormat!=="channelsLast"&&(s=Ee(s,[0,2,3,1]));let x=am(s,this.kernel.read(),m,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(x=Ee(x,[0,3,1,2])),this.bias!=null&&(x=Dn(x,this.bias.read(),this.dataFormat)),this.activation!=null&&(x=this.activation.apply(x)),x})}computeOutputShape(e){e=_e(e);const t=e.slice();let s,o,r;this.dataFormat==="channelsFirst"?(s=1,o=2,r=3):(s=3,o=1,r=2);const i=this.kernelSize[0],a=this.kernelSize[1],l=this.strides[0],c=this.strides[1];return t[s]=this.filters,t[o]=Qn(t[o],l,i,this.padding),t[r]=Qn(t[r],c,a,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}hb.className="Conv2DTranspose",Z(hb);class db extends Hi{constructor(e){if(super(e),this.inputSpec=[new ht({ndim:5})],this.padding!=="same"&&this.padding!=="valid")throw new A(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=_e(e),e.length!==5)throw new A("Input should have rank 5; Received input shape: "+JSON.stringify(e));const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new A("The channel dimension of the inputs should be defined. Found `None`.");const s=e[t],o=this.kernelSize.concat([this.filters,s]);this.kernel=this.addWeight("kernel",o,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new ht({ndim:5,axes:{[t]:s}})],this.built=!0}call(e,t){return z(()=>{let s=xe(e);if(s.shape.length!==5)throw new A(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${s.shape.length}`);const o=s.shape,r=o[0];let i,a,l;this.dataFormat==="channelsFirst"?(l=2,i=3,a=4):(l=1,i=2,a=3);const c=o[l],u=o[i],h=o[a],d=this.kernelSize[0],p=this.kernelSize[1],f=this.kernelSize[2],g=this.strides[0],m=this.strides[1],x=this.strides[2],b=Qn(c,g,d,this.padding),w=Qn(u,m,p,this.padding),y=Qn(h,x,f,this.padding),C=[r,b,w,y,this.filters];this.dataFormat!=="channelsLast"&&(s=Ee(s,[0,2,3,4,1]));let I=l$(s,this.kernel.read(),C,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(I=Ee(I,[0,4,1,2,3])),this.bias!==null&&(I=Dn(I,this.bias.read(),this.dataFormat)),this.activation!==null&&(I=this.activation.apply(I)),I})}computeOutputShape(e){e=_e(e);const t=e.slice();let s,o,r,i;this.dataFormat==="channelsFirst"?(s=1,o=2,r=3,i=4):(s=4,o=1,r=2,i=3);const a=this.kernelSize[0],l=this.kernelSize[1],c=this.kernelSize[2],u=this.strides[0],h=this.strides[1],d=this.strides[2];return t[s]=this.filters,t[o]=Qn(t[o],u,a,this.padding),t[r]=Qn(t[r],h,l,this.padding),t[i]=Qn(t[i],d,c,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}db.className="Conv3DTranspose",Z(db);class pb extends sr{constructor(e,t){if(super(e,t),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,t.filters==null)throw new A("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(t.kernelInitializer!=null||t.kernelRegularizer!=null||t.kernelConstraint!=null)throw new A("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(t.padding!=null&&t.padding!=="same"&&t.padding!=="valid")throw new A(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(t.padding)}`);this.depthMultiplier=t.depthMultiplier==null?1:t.depthMultiplier,this.depthwiseInitializer=qe(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=Ke(t.depthwiseRegularizer),this.depthwiseConstraint=pt(t.depthwiseConstraint),this.pointwiseInitializer=qe(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=Ke(t.pointwiseRegularizer),this.pointwiseConstraint=pt(t.pointwiseConstraint)}build(e){if(e=_e(e),e.length{e=xe(e);let s;if(this.rank===1)throw new Ce("1D separable convolution is not implemented yet.");return this.rank===2&&(this.dataFormat==="channelsFirst"&&(e=Ee(e,[0,2,3,1])),s=Sm(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(s=Dn(s,this.bias.read(),this.dataFormat)),this.activation!=null&&(s=this.activation.apply(s)),this.dataFormat==="channelsFirst"&&(s=Ee(s,[0,3,1,2])),s})}getConfig(){const e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=Ze(this.depthwiseInitializer),e.pointwiseInitializer=Ze(this.pointwiseInitializer),e.depthwiseRegularizer=ze(this.depthwiseRegularizer),e.pointwiseRegularizer=ze(this.pointwiseRegularizer),e.depthwiseConstraint=dt(this.depthwiseConstraint),e.pointwiseConstraint=dt(this.pointwiseConstraint),e}}pb.className="SeparableConv";class fb extends pb{constructor(e){super(2,e)}}fb.className="SeparableConv2D",Z(fb);class Jl extends sr{constructor(e){super(1,e),Jl.verifyArgs(e),this.inputSpec=[{ndim:3}]}getConfig(){const e=super.getConfig();return delete e.rank,delete e.dataFormat,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!bd(e.kernelSize,"number",1,1))throw new A(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}}Jl.className="Conv1D",Z(Jl);class mb extends ke{constructor(e){super(e),typeof e.cropping=="number"?this.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:typeof e.cropping[0]=="number"?this.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:this.cropping=e.cropping,this.dataFormat=e.dataFormat===void 0?"channelsLast":e.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(e){return this.dataFormat==="channelsFirst"?[e[0],e[1],e[2]-this.cropping[0][0]-this.cropping[0][1],e[3]-this.cropping[1][0]-this.cropping[1][1]]:[e[0],e[1]-this.cropping[0][0]-this.cropping[0][1],e[2]-this.cropping[1][0]-this.cropping[1][1],e[3]]}call(e,t){return z(()=>{if(e=xe(e),this.dataFormat==="channelsLast"){const s=Ll(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return Ll(s,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}else{const s=Ll(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return Ll(s,this.cropping[1][0],e.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}})}getConfig(){const e={cropping:this.cropping,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}mb.className="Cropping2D",Z(mb);class gb extends ke{constructor(e){super(e),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=e.size==null?this.DEFAULT_SIZE:e.size,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,ot(this.dataFormat),this.interpolation=e.interpolation==null?"nearest":e.interpolation,LN(this.interpolation)}computeOutputShape(e){if(this.dataFormat==="channelsFirst"){const t=e[2]==null?null:this.size[0]*e[2],s=e[3]==null?null:this.size[1]*e[3];return[e[0],e[1],t,s]}else{const t=e[1]==null?null:this.size[0]*e[1],s=e[2]==null?null:this.size[1]*e[2];return[e[0],t,s,e[3]]}}call(e,t){return z(()=>{let s=xe(e);const o=s.shape;if(this.dataFormat==="channelsFirst"){s=Ee(s,[0,2,3,1]);const r=this.size[0]*o[2],i=this.size[1]*o[3],a=this.interpolation==="nearest"?ls.resizeNearestNeighbor(s,[r,i]):ls.resizeBilinear(s,[r,i]);return Ee(a,[0,3,1,2])}else{const r=this.size[0]*o[1],i=this.size[1]*o[2];return this.interpolation==="nearest"?ls.resizeNearestNeighbor(s,[r,i]):ls.resizeBilinear(s,[r,i])}})}getConfig(){const e={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},t=super.getConfig();return Object.assign(e,t),e}}gb.className="UpSampling2D",Z(gb);/** + */function qd(n,e){return P(()=>(ot(e),e==="channelsFirst"?Ee(n,[0,2,3,1]):n))}function db(n,e){return P(()=>(ot(e),e==="channelsFirst"?Ee(n,[0,2,3,4,1]):n))}function cR(n,e,t,s=1,o="valid",r,i=1){return P(()=>{if(r==null&&(r=An()),ot(r),n.shape.length!==3)throw new A(`The input of a conv1dWithBias operation should be 3, but is ${n.shape.length} instead.`);if(e.shape.length!==3)throw new A(`The kernel for a conv1dWithBias operation should be 3, but is ${e.shape.length} instead`);if(t!=null&&t.shape.length!==1)throw new A(`The bias for a conv1dWithBias operation should be 1, but is ${t.shape.length} instead`);if(r==="channelsFirst"&&(n=Ee(n,[0,2,1])),o==="causal")throw new Ce("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let a=im(n,e,s,o==="same"?"same":"valid","NWC",i);return t!=null&&(a=Dn(a,t)),a})}function pb(n,e,t,s=[1,1],o="valid",r,i,a=null){return P(()=>{if(r==null&&(r=An()),ot(r),n.rank!==3&&n.rank!==4)throw new A(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${n.rank}.`);if(e.rank!==3&&e.rank!==4)throw new A(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${n.rank}.`);let l=qd(n,r);if(o==="causal")throw new Ce("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=uS({x:l,filter:e,strides:s,pad:o==="same"?"same":"valid",dilations:i,dataFormat:"NHWC",bias:t,activation:a}),r==="channelsFirst"&&(l=Ee(l,[0,3,1,2])),l})}function uR(n,e,t,s=[1,1,1],o="valid",r,i){return P(()=>{if(r==null&&(r=An()),ot(r),n.rank!==4&&n.rank!==5)throw new A(`conv3dWithBias expects input to be of rank 4 or 5, but received ${n.rank}.`);if(e.rank!==4&&e.rank!==5)throw new A(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${n.rank}.`);let a=db(n,r);if(o==="causal")throw new Ce("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return a=sh(a,e,s,o==="same"?"same":"valid","NDHWC",i),t!=null&&(a=Dn(a,t)),r==="channelsFirst"&&(a=Ee(a,[0,4,1,2,3])),a})}class Jl extends ke{constructor(e,t){if(super(t),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",Jl.verifyArgs(t),this.rank=e,bt(this.rank,"rank"),this.rank!==1&&this.rank!==2&&this.rank!==3)throw new Ce(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=nr(t.kernelSize,e,"kernelSize"),this.strides=nr(t.strides==null?1:t.strides,e,"strides"),this.padding=t.padding==null?"valid":t.padding,on(this.padding),this.dataFormat=t.dataFormat==null?"channelsLast":t.dataFormat,ot(this.dataFormat),this.activation=As(t.activation),this.useBias=t.useBias==null?!0:t.useBias,this.biasInitializer=je(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=pt(t.biasConstraint),this.biasRegularizer=Ke(t.biasRegularizer),this.activityRegularizer=Ke(t.activityRegularizer),this.dilationRate=nr(t.dilationRate==null?1:t.dilationRate,e,"dilationRate"),this.rank===1&&Array.isArray(this.dilationRate)&&this.dilationRate.length!==1)throw new A(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(this.rank===2){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==2)throw new A(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(this.rank===3){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==3)throw new A(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}}static verifyArgs(e){if(jn("kernelSize"in e,"required key 'kernelSize' not in config"),typeof e.kernelSize!="number"&&!bd(e.kernelSize,"number",1,3))throw new A(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(e.kernelSize)}.`)}getConfig(){const e={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:Rs(this.activation),useBias:this.useBias,biasInitializer:Ze(this.biasInitializer),biasRegularizer:ze(this.biasRegularizer),activityRegularizer:ze(this.activityRegularizer),biasConstraint:dt(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}class sr extends Jl{constructor(e,t){super(e,t),this.kernel=null,sr.verifyArgs(t),this.filters=t.filters,bt(this.filters,"filters"),this.kernelInitializer=je(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=pt(t.kernelConstraint),this.kernelRegularizer=Ke(t.kernelRegularizer)}build(e){e=_e(e);const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new A(`The channel dimension of the input should be defined. Found ${e[t]}`);const s=e[t],o=this.kernelSize.concat([s,this.filters]);this.kernel=this.addWeight("kernel",o,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[t]:s}}],this.built=!0}call(e,t){return P(()=>{e=xe(e);let s;const o=this.bias==null?null:this.bias.read(),r=Gg(this.activation.getClassName());if(r!=null&&this.rank===2)s=pb(e,this.kernel.read(),o,this.strides,this.padding,this.dataFormat,this.dilationRate,r);else{if(this.rank===1)s=cR(e,this.kernel.read(),o,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(this.rank===2)s=pb(e,this.kernel.read(),o,this.strides,this.padding,this.dataFormat,this.dilationRate);else if(this.rank===3)s=uR(e,this.kernel.read(),o,this.strides,this.padding,this.dataFormat,this.dilationRate);else throw new Ce("convolutions greater than 3D are not implemented yet.");this.activation!=null&&(s=this.activation.apply(s))}return s})}computeOutputShape(e){e=_e(e);const t=[],s=this.dataFormat==="channelsLast"?e.slice(1,e.length-1):e.slice(2);for(let r=0;r 0 but got ${JSON.stringify(e.filters)}`)}}class Gi extends sr{constructor(e){super(2,e),Gi.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!bd(e.kernelSize,"number",1,2))throw new A(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}}Gi.className="Conv2D",Y(Gi);class Hi extends sr{constructor(e){super(3,e),Hi.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!(Array.isArray(e.kernelSize)&&(e.kernelSize.length===1||e.kernelSize.length===3)))throw new A(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}}Hi.className="Conv3D",Y(Hi);class fb extends Gi{constructor(e){if(super(e),this.inputSpec=[new ht({ndim:4})],this.padding!=="same"&&this.padding!=="valid")throw new A(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=_e(e),e.length!==4)throw new A("Input should have rank 4; Received input shape: "+JSON.stringify(e));const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new A("The channel dimension of the inputs should be defined. Found `None`.");const s=e[t],o=this.kernelSize.concat([this.filters,s]);this.kernel=this.addWeight("kernel",o,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new ht({ndim:4,axes:{[t]:s}})],this.built=!0}call(e,t){return P(()=>{let s=xe(e);if(s.shape.length!==4)throw new A(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${s.shape.length}`);const o=s.shape,r=o[0];let i,a;this.dataFormat==="channelsFirst"?(i=2,a=3):(i=1,a=2);const l=o[i],c=o[a],u=this.kernelSize[0],h=this.kernelSize[1],d=this.strides[0],p=this.strides[1],f=Qn(l,d,u,this.padding),g=Qn(c,p,h,this.padding),m=[r,f,g,this.filters];this.dataFormat!=="channelsLast"&&(s=Ee(s,[0,2,3,1]));let x=am(s,this.kernel.read(),m,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(x=Ee(x,[0,3,1,2])),this.bias!=null&&(x=Dn(x,this.bias.read(),this.dataFormat)),this.activation!=null&&(x=this.activation.apply(x)),x})}computeOutputShape(e){e=_e(e);const t=e.slice();let s,o,r;this.dataFormat==="channelsFirst"?(s=1,o=2,r=3):(s=3,o=1,r=2);const i=this.kernelSize[0],a=this.kernelSize[1],l=this.strides[0],c=this.strides[1];return t[s]=this.filters,t[o]=Qn(t[o],l,i,this.padding),t[r]=Qn(t[r],c,a,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}fb.className="Conv2DTranspose",Y(fb);class mb extends Hi{constructor(e){if(super(e),this.inputSpec=[new ht({ndim:5})],this.padding!=="same"&&this.padding!=="valid")throw new A(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=_e(e),e.length!==5)throw new A("Input should have rank 5; Received input shape: "+JSON.stringify(e));const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new A("The channel dimension of the inputs should be defined. Found `None`.");const s=e[t],o=this.kernelSize.concat([this.filters,s]);this.kernel=this.addWeight("kernel",o,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new ht({ndim:5,axes:{[t]:s}})],this.built=!0}call(e,t){return P(()=>{let s=xe(e);if(s.shape.length!==5)throw new A(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${s.shape.length}`);const o=s.shape,r=o[0];let i,a,l;this.dataFormat==="channelsFirst"?(l=2,i=3,a=4):(l=1,i=2,a=3);const c=o[l],u=o[i],h=o[a],d=this.kernelSize[0],p=this.kernelSize[1],f=this.kernelSize[2],g=this.strides[0],m=this.strides[1],x=this.strides[2],b=Qn(c,g,d,this.padding),w=Qn(u,m,p,this.padding),y=Qn(h,x,f,this.padding),C=[r,b,w,y,this.filters];this.dataFormat!=="channelsLast"&&(s=Ee(s,[0,2,3,4,1]));let I=h$(s,this.kernel.read(),C,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(I=Ee(I,[0,4,1,2,3])),this.bias!==null&&(I=Dn(I,this.bias.read(),this.dataFormat)),this.activation!==null&&(I=this.activation.apply(I)),I})}computeOutputShape(e){e=_e(e);const t=e.slice();let s,o,r,i;this.dataFormat==="channelsFirst"?(s=1,o=2,r=3,i=4):(s=4,o=1,r=2,i=3);const a=this.kernelSize[0],l=this.kernelSize[1],c=this.kernelSize[2],u=this.strides[0],h=this.strides[1],d=this.strides[2];return t[s]=this.filters,t[o]=Qn(t[o],u,a,this.padding),t[r]=Qn(t[r],h,l,this.padding),t[i]=Qn(t[i],d,c,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}mb.className="Conv3DTranspose",Y(mb);class gb extends sr{constructor(e,t){if(super(e,t),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,t.filters==null)throw new A("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(t.kernelInitializer!=null||t.kernelRegularizer!=null||t.kernelConstraint!=null)throw new A("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(t.padding!=null&&t.padding!=="same"&&t.padding!=="valid")throw new A(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(t.padding)}`);this.depthMultiplier=t.depthMultiplier==null?1:t.depthMultiplier,this.depthwiseInitializer=je(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=Ke(t.depthwiseRegularizer),this.depthwiseConstraint=pt(t.depthwiseConstraint),this.pointwiseInitializer=je(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=Ke(t.pointwiseRegularizer),this.pointwiseConstraint=pt(t.pointwiseConstraint)}build(e){if(e=_e(e),e.length{e=xe(e);let s;if(this.rank===1)throw new Ce("1D separable convolution is not implemented yet.");return this.rank===2&&(this.dataFormat==="channelsFirst"&&(e=Ee(e,[0,2,3,1])),s=Tm(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(s=Dn(s,this.bias.read(),this.dataFormat)),this.activation!=null&&(s=this.activation.apply(s)),this.dataFormat==="channelsFirst"&&(s=Ee(s,[0,3,1,2])),s})}getConfig(){const e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=Ze(this.depthwiseInitializer),e.pointwiseInitializer=Ze(this.pointwiseInitializer),e.depthwiseRegularizer=ze(this.depthwiseRegularizer),e.pointwiseRegularizer=ze(this.pointwiseRegularizer),e.depthwiseConstraint=dt(this.depthwiseConstraint),e.pointwiseConstraint=dt(this.pointwiseConstraint),e}}gb.className="SeparableConv";class xb extends gb{constructor(e){super(2,e)}}xb.className="SeparableConv2D",Y(xb);class ec extends sr{constructor(e){super(1,e),ec.verifyArgs(e),this.inputSpec=[{ndim:3}]}getConfig(){const e=super.getConfig();return delete e.rank,delete e.dataFormat,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!bd(e.kernelSize,"number",1,1))throw new A(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}}ec.className="Conv1D",Y(ec);class bb extends ke{constructor(e){super(e),typeof e.cropping=="number"?this.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:typeof e.cropping[0]=="number"?this.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:this.cropping=e.cropping,this.dataFormat=e.dataFormat===void 0?"channelsLast":e.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(e){return this.dataFormat==="channelsFirst"?[e[0],e[1],e[2]-this.cropping[0][0]-this.cropping[0][1],e[3]-this.cropping[1][0]-this.cropping[1][1]]:[e[0],e[1]-this.cropping[0][0]-this.cropping[0][1],e[2]-this.cropping[1][0]-this.cropping[1][1],e[3]]}call(e,t){return P(()=>{if(e=xe(e),this.dataFormat==="channelsLast"){const s=Ml(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return Ml(s,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}else{const s=Ml(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return Ml(s,this.cropping[1][0],e.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}})}getConfig(){const e={cropping:this.cropping,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}bb.className="Cropping2D",Y(bb);class yb extends ke{constructor(e){super(e),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=e.size==null?this.DEFAULT_SIZE:e.size,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,ot(this.dataFormat),this.interpolation=e.interpolation==null?"nearest":e.interpolation,PN(this.interpolation)}computeOutputShape(e){if(this.dataFormat==="channelsFirst"){const t=e[2]==null?null:this.size[0]*e[2],s=e[3]==null?null:this.size[1]*e[3];return[e[0],e[1],t,s]}else{const t=e[1]==null?null:this.size[0]*e[1],s=e[2]==null?null:this.size[1]*e[2];return[e[0],t,s,e[3]]}}call(e,t){return P(()=>{let s=xe(e);const o=s.shape;if(this.dataFormat==="channelsFirst"){s=Ee(s,[0,2,3,1]);const r=this.size[0]*o[2],i=this.size[1]*o[3],a=this.interpolation==="nearest"?ls.resizeNearestNeighbor(s,[r,i]):ls.resizeBilinear(s,[r,i]);return Ee(a,[0,3,1,2])}else{const r=this.size[0]*o[1],i=this.size[1]*o[2];return this.interpolation==="nearest"?ls.resizeNearestNeighbor(s,[r,i]):ls.resizeBilinear(s,[r,i])}})}getConfig(){const e={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},t=super.getConfig();return Object.assign(e,t),e}}yb.className="UpSampling2D",Y(yb);/** * @license * Copyright 2018 Google LLC * @@ -7768,7 +7768,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function cR(n,e,t=[1,1],s="valid",o,r){return z(()=>{o==null&&(o=An()),ot(o);let i=jd(n,o);if(n.rank!==4)throw new A(`Input for depthwiseConv2d is required to be 4-D, but is instead ${n.rank}-D`);if(e.rank!==4)throw new A(`depthwiseKernel is required to be 4-D, but is instead ${e.rank}-D`);return i=ih(i,e,t,s==="same"?"same":"valid","NHWC",r),o==="channelsFirst"&&(i=Ee(i,[0,3,1,2])),i})}class xb extends Ql{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=e.depthMultiplier==null?1:e.depthMultiplier,this.depthwiseInitializer=qe(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=pt(e.depthwiseConstraint),this.depthwiseRegularizer=Ke(e.depthwiseRegularizer)}build(e){if(e=_e(e),e.length<4)throw new A(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);const t=this.dataFormat==="channelsFirst"?1:3;if(e[t]==null||e[t]<0)throw new A(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);const s=e[t],o=[this.kernelSize[0],this.kernelSize[1],s,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",o,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[s*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return z(()=>{e=xe(e);let s=cR(e,this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(s=Dn(s,this.bias.read(),this.dataFormat)),this.activation!=null&&(s=this.activation.apply(s)),s})}computeOutputShape(e){e=_e(e);const t=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2],o=this.dataFormat==="channelsFirst"?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,r=On(t,this.kernelSize[0],this.padding,this.strides[0]),i=On(s,this.kernelSize[1],this.padding,this.strides[1]);return this.dataFormat==="channelsFirst"?[e[0],o,r,i]:[e[0],r,i,o]}getConfig(){const e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=Ze(this.depthwiseInitializer),e.depthwiseRegularizer=ze(this.depthwiseRegularizer),e.depthwiseConstraint=dt(this.depthwiseRegularizer),e}}xb.className="DepthwiseConv2D",Z(xb);/** + */function hR(n,e,t=[1,1],s="valid",o,r){return P(()=>{o==null&&(o=An()),ot(o);let i=qd(n,o);if(n.rank!==4)throw new A(`Input for depthwiseConv2d is required to be 4-D, but is instead ${n.rank}-D`);if(e.rank!==4)throw new A(`depthwiseKernel is required to be 4-D, but is instead ${e.rank}-D`);return i=ih(i,e,t,s==="same"?"same":"valid","NHWC",r),o==="channelsFirst"&&(i=Ee(i,[0,3,1,2])),i})}class wb extends Jl{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=e.depthMultiplier==null?1:e.depthMultiplier,this.depthwiseInitializer=je(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=pt(e.depthwiseConstraint),this.depthwiseRegularizer=Ke(e.depthwiseRegularizer)}build(e){if(e=_e(e),e.length<4)throw new A(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);const t=this.dataFormat==="channelsFirst"?1:3;if(e[t]==null||e[t]<0)throw new A(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);const s=e[t],o=[this.kernelSize[0],this.kernelSize[1],s,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",o,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[s*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return P(()=>{e=xe(e);let s=hR(e,this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(s=Dn(s,this.bias.read(),this.dataFormat)),this.activation!=null&&(s=this.activation.apply(s)),s})}computeOutputShape(e){e=_e(e);const t=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2],o=this.dataFormat==="channelsFirst"?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,r=On(t,this.kernelSize[0],this.padding,this.strides[0]),i=On(s,this.kernelSize[1],this.padding,this.strides[1]);return this.dataFormat==="channelsFirst"?[e[0],o,r,i]:[e[0],r,i,o]}getConfig(){const e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=Ze(this.depthwiseInitializer),e.depthwiseRegularizer=ze(this.depthwiseRegularizer),e.depthwiseConstraint=dt(this.depthwiseRegularizer),e}}wb.className="DepthwiseConv2D",Y(wb);/** * @license * Copyright 2018 Google LLC * @@ -7776,7 +7776,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function bb(n,e,t,s){if(Array.isArray(n)){if(e!=null||t!=null)throw new A("When inputs is an array, neither initialState or constants should be provided");s!=null&&(t=n.slice(n.length-s,n.length),n=n.slice(0,n.length-s)),n.length>1&&(e=n.slice(1,n.length)),n=n[0]}function o(r){return r==null||Array.isArray(r)?r:[r]}return e=o(e),t=o(t),{inputs:n,initialState:e,constants:t}}function yb(n,e,t,s=!1,o,r,i=!1,a=!1){return z(()=>{const l=e.shape.length;if(l<3)throw new A(`Input should be at least 3D, but is ${l}D.`);const c=[1,0].concat(Rn(2,l));if(e=Ee(e,c),r!=null)throw new Ce("The rnn() functoin of the deeplearn.js backend does not support constants yet.");i&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),o!=null&&(o=oe(oe(o,"bool"),"float32"),o.rank===l-1&&(o=Ut(o,-1)),o=Ee(o,c)),s&&(e=co(e,0),o!=null&&(o=co(o,0)));const u=[];let h,d=t;const p=e.shape[0],f=Gn(e);let g;o!=null&&(g=Gn(o));for(let x=0;xn(b,d));if(o==null)h=w[0],d=w[1];else{const y=z(()=>{const C=g[x],I=ge(fn(C),C),v=ee(F(w[0],C),F(d[0],I)),k=d.map((S,T)=>ee(F(w[1][T],C),F(S,I)));return{output:v,newStates:k}});h=y.output,d=y.newStates}a&&u.push(h)}let m;return a&&(m=Un(u,1)),[h,m,d]})}class Ds extends ke{constructor(e){super(e);let t;if(e.cell==null)throw new A("cell property is missing for the constructor of RNN.");if(Array.isArray(e.cell)?t=new Xd({cells:e.cell}):t=e.cell,t.stateSize==null)throw new A("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=t,this.returnSequences=e.returnSequences==null?!1:e.returnSequences,this.returnState=e.returnState==null?!1:e.returnState,this.goBackwards=e.goBackwards==null?!1:e.goBackwards,this._stateful=e.stateful==null?!1:e.stateful,this.unroll=e.unroll==null?!1:e.unroll,this.supportsMasking=!0,this.inputSpec=[new ht({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){if(this.states_==null){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;return Rn(0,e).map(t=>null)}else return this.states_}setStates(e){this.states_=e}computeOutputShape(e){Ad(e)&&(e=e[0]),e=e;let t=this.cell.stateSize;Array.isArray(t)||(t=[t]);const s=t[0];let o;if(this.returnSequences?o=[e[0],e[1],s]:o=[e[0],s],this.returnState){const r=[];for(const i of t)r.push([e[0],i]);return[o].concat(r)}else return o}computeMask(e,t){return z(()=>{Array.isArray(t)&&(t=t[0]);const s=this.returnSequences?t:null;if(this.returnState){const o=this.states.map(r=>null);return[s].concat(o)}else return s})}get states(){if(this.states_==null){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,t=[];for(let s=0;si.shape[i.shape.length-1]),r))throw new A(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is ${this.cell.stateSize}`)}else this.stateSpec=r.map(i=>new ht({shape:[null,i]}));this.stateful&&this.resetStates()}resetStates(e,t=!1){z(()=>{if(!this.stateful)throw new jn("Cannot call resetStates() on an RNN Layer that is not stateful.");const s=this.inputSpec[0].shape[0];if(s==null)throw new A("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(this.states_==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(o=>st([s,o])):this.states_=[st([s,this.cell.stateSize])];else if(e==null)fe(this.states_),this.keptStates!=null&&(fe(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(o=>st([s,o])):this.states_[0]=st([s,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new A(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t===!0?this.keptStates.push(this.states_.slice()):fe(this.states_);for(let o=0;odn(o.clone()))})}apply(e,t){let s=t==null?null:t.initialState,o=t==null?null:t.constants;t==null&&(t={});const r=bb(e,s,o,this.numConstants);e=r.inputs,s=r.initialState,o=r.constants;let i=[],a=[];if(s!=null){t.initialState=s,i=i.concat(s),this.stateSpec=[];for(const c of s)this.stateSpec.push(new ht({shape:c.shape}));a=a.concat(this.stateSpec)}if(o!=null&&(t.constants=o,i=i.concat(o),this.numConstants=o.length),i[0]instanceof Yn){const c=[e].concat(i),u=this.inputSpec.concat(a),h=this.inputSpec;this.inputSpec=u;const d=super.apply(c,t);return this.inputSpec=h,d}else return super.apply(e,t)}call(e,t){return z(()=>{const s=t==null?null:t.mask,o=t==null?null:t.training;let r=t==null?null:t.initialState;e=xe(e),r==null&&(this.stateful?r=this.states_:r=this.getInitialState(e));const i=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(r.length!==i)throw new A(`RNN Layer has ${i} state(s) but was passed ${r.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const a={training:o},c=yb((f,g)=>{const m=this.cell.call([f].concat(g),a);return[m[0],m.slice(1)]},e,r,this.goBackwards,s,null,this.unroll,this.returnSequences),u=c[0],h=c[1],d=c[2];this.stateful&&this.resetStates(d,o);const p=this.returnSequences?h:u;return this.returnState?[p].concat(d):p})}getInitialState(e){return z(()=>{let t=st(e.shape);return t=pe(t,[1,2]),t=_i(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map(s=>s>1?Id(t,[1,s]):t):this.cell.stateSize>1?[Id(t,[1,this.cell.stateSize])]:[t]})}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.cell!=null&&this.cell.setFastWeightInitDuringBuild(e)}getConfig(){const e=super.getConfig(),t={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};this.numConstants!=null&&(t.numConstants=this.numConstants);const s=this.cell.getConfig();return this.getClassName()===Ds.className&&(t.cell={className:this.cell.getClassName(),config:s}),Object.assign(Object.assign(Object.assign({},s),e),t)}static fromConfig(e,t,s={}){const o=t.cell,r=Zn(o,s);return new e(Object.assign(t,{cell:r}))}}Ds.className="RNN",Z(Ds);class ec extends ke{}class qd extends ec{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,bt(this.units,"units"),this.activation=As(e.activation==null?this.DEFAULT_ACTIVATION:e.activation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=qe(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=qe(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=qe(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Ke(e.kernelRegularizer),this.recurrentRegularizer=Ke(e.recurrentRegularizer),this.biasRegularizer=Ke(e.biasRegularizer),this.kernelConstraint=pt(e.kernelConstraint),this.recurrentConstraint=pt(e.recurrentConstraint),this.biasConstraint=pt(e.biasConstraint),this.dropout=er([1,Ns([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=er([1,Ns([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=_e(e),this.kernel=this.addWeight("kernel",[e[e.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return z(()=>{if(e=e,e.length!==2)throw new A(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let s=e[1];e=e[0];const o=t.training==null?!1:t.training;0fn(e),rate:this.dropout,training:o,dropoutFunc:this.dropoutFunc})),0fn(s),rate:this.recurrentDropout,training:o,dropoutFunc:this.dropoutFunc}));let r;const i=this.dropoutMask,a=this.recurrentDropoutMask;i!=null?r=Xn(F(e,i),this.kernel.read()):r=Xn(e,this.kernel.read()),this.bias!=null&&(r=Dn(r,this.bias.read())),a!=null&&(s=F(s,a));let l=ee(r,Xn(s,this.recurrentKernel.read()));return this.activation!=null&&(l=this.activation.apply(l)),[l,l]})}getConfig(){const e=super.getConfig(),t={units:this.units,activation:Rs(this.activation),useBias:this.useBias,kernelInitializer:Ze(this.kernelInitializer),recurrentInitializer:Ze(this.recurrentInitializer),biasInitializer:Ze(this.biasInitializer),kernelRegularizer:ze(this.kernelRegularizer),recurrentRegularizer:ze(this.recurrentRegularizer),biasRegularizer:ze(this.biasRegularizer),activityRegularizer:ze(this.activityRegularizer),kernelConstraint:dt(this.kernelConstraint),recurrentConstraint:dt(this.recurrentConstraint),biasConstraint:dt(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign(Object.assign({},e),t)}}qd.className="SimpleRNNCell",Z(qd);class wb extends Ds{constructor(e){e.cell=new qd(e),super(e)}call(e,t){return z(()=>{this.cell.dropoutMask!=null&&(fe(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(fe(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=t==null?null:t.mask,o=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:s,training:o,initialState:r})})}static fromConfig(e,t){return new e(t)}}wb.className="SimpleRNN",Z(wb);class Kd extends ec{constructor(e){if(super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.resetAfter)throw new A("GRUCell does not support reset_after parameter set to true.");this.units=e.units,bt(this.units,"units"),this.activation=As(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=As(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=qe(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=qe(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=qe(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Ke(e.kernelRegularizer),this.recurrentRegularizer=Ke(e.recurrentRegularizer),this.biasRegularizer=Ke(e.biasRegularizer),this.kernelConstraint=pt(e.kernelConstraint),this.recurrentConstraint=pt(e.recurrentConstraint),this.biasConstraint=pt(e.biasConstraint),this.dropout=er([1,Ns([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=er([1,Ns([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=_e(e);const t=e[e.length-1];this.kernel=this.addWeight("kernel",[t,this.units*3],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*3],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units*3],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return z(()=>{if(e=e,e.length!==2)throw new A(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);const s=t.training==null?!1:t.training;let o=e[1];e=e[0],0fn(e),rate:this.dropout,training:s,count:3,dropoutFunc:this.dropoutFunc})),0fn(o),rate:this.recurrentDropout,training:s,count:3,dropoutFunc:this.dropoutFunc}));const r=this.dropoutMask,i=this.recurrentDropoutMask;let a,l,c;0{this.cell.dropoutMask!=null&&(fe(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(fe(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=t==null?null:t.mask,o=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:s,training:o,initialState:r})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}}Cb.className="GRU",Z(Cb);class tc extends ec{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,bt(this.units,"units"),this.activation=As(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=As(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=qe(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=qe(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=qe(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=Ke(e.kernelRegularizer),this.recurrentRegularizer=Ke(e.recurrentRegularizer),this.biasRegularizer=Ke(e.biasRegularizer),this.kernelConstraint=pt(e.kernelConstraint),this.recurrentConstraint=pt(e.recurrentConstraint),this.biasConstraint=pt(e.biasConstraint),this.dropout=er([1,Ns([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=er([1,Ns([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){var t;e=_e(e);const s=e[e.length-1];this.kernel=this.addWeight("kernel",[s,this.units*4],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*4],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint);let o;if(this.useBias){if(this.unitForgetBias){const r=this.biasInitializer,i=this.units;o=new(t=class extends bn{apply(l,c){const u=r.apply([i]),h=new vd().apply([i]),d=r.apply([i*2]);return Yg(Yg(u,h),d)}},t.className="CustomInit",t)}else o=this.biasInitializer;this.bias=this.addWeight("bias",[this.units*4],null,o,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,t){return z(()=>{const s=t.training==null?!1:t.training;if(e=e,e.length!==3)throw new A(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let o=e[1];const r=e[2];e=e[0],0fn(e),rate:this.dropout,training:s,count:4,dropoutFunc:this.dropoutFunc})),0fn(o),rate:this.recurrentDropout,training:s,count:4,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,a=this.recurrentDropoutMask;let l,c,u,h;0{this.cell.dropoutMask!=null&&(fe(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(fe(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=t==null?null:t.mask,o=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:s,training:o,initialState:r})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}}Ib.className="LSTM",Z(Ib);class Xd extends ec{constructor(e){super(e),this.cells=e.cells}get stateSize(){const e=[];for(const t of this.cells.slice().reverse())Array.isArray(t.stateSize)?e.push(...t.stateSize):e.push(t.stateSize);return e}call(e,t){return z(()=>{e=e;let s=e.slice(1);const o=[];for(const a of this.cells.slice().reverse())Array.isArray(a.stateSize)?o.push(s.splice(0,a.stateSize.length)):o.push(s.splice(0,1));o.reverse();const r=[];let i;for(let a=0;a{mo(`RNNCell_${o}`,()=>{s.build(e),Array.isArray(s.stateSize)?t=s.stateSize[0]:t=s.stateSize,e=[e[0],t]})}),this.built=!0}getConfig(){const e=super.getConfig(),t=r=>({className:r.getClassName(),config:r.getConfig()}),o={cells:this.cells.map(t)};return Object.assign(Object.assign({},e),o)}static fromConfig(e,t,s={}){const o=[];for(const r of t.cells)o.push(Zn(r,s));return new e({cells:o})}get trainableWeights(){if(!this.trainable)return[];const e=[];for(const t of this.cells)e.push(...t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.cells)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const s of this.cells)t.push(...s.trainableWeights);return t.concat(e)}return e}getWeights(){const e=[];for(const t of this.cells)e.push(...t.weights);return Dd(e)}setWeights(e){const t=[];for(const s of this.cells){const o=s.weights.length,r=e.splice(o);for(let i=0;ir!=null?r(e(),t):Qg(e(),t),a=()=>Li(i,e,s);return!o||o<=1?dn(a().clone()):Array(o).fill(void 0).map(a).map(c=>dn(c.clone()))}/** + */function Cb(n,e,t,s){if(Array.isArray(n)){if(e!=null||t!=null)throw new A("When inputs is an array, neither initialState or constants should be provided");s!=null&&(t=n.slice(n.length-s,n.length),n=n.slice(0,n.length-s)),n.length>1&&(e=n.slice(1,n.length)),n=n[0]}function o(r){return r==null||Array.isArray(r)?r:[r]}return e=o(e),t=o(t),{inputs:n,initialState:e,constants:t}}function Ib(n,e,t,s=!1,o,r,i=!1,a=!1){return P(()=>{const l=e.shape.length;if(l<3)throw new A(`Input should be at least 3D, but is ${l}D.`);const c=[1,0].concat(Rn(2,l));if(e=Ee(e,c),r!=null)throw new Ce("The rnn() functoin of the deeplearn.js backend does not support constants yet.");i&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),o!=null&&(o=oe(oe(o,"bool"),"float32"),o.rank===l-1&&(o=Gt(o,-1)),o=Ee(o,c)),s&&(e=uo(e,0),o!=null&&(o=uo(o,0)));const u=[];let h,d=t;const p=e.shape[0],f=Gn(e);let g;o!=null&&(g=Gn(o));for(let x=0;xn(b,d));if(o==null)h=w[0],d=w[1];else{const y=P(()=>{const C=g[x],I=ge(fn(C),C),v=ee(D(w[0],C),D(d[0],I)),k=d.map((S,T)=>ee(D(w[1][T],C),D(S,I)));return{output:v,newStates:k}});h=y.output,d=y.newStates}a&&u.push(h)}let m;return a&&(m=Un(u,1)),[h,m,d]})}class Ds extends ke{constructor(e){super(e);let t;if(e.cell==null)throw new A("cell property is missing for the constructor of RNN.");if(Array.isArray(e.cell)?t=new Xd({cells:e.cell}):t=e.cell,t.stateSize==null)throw new A("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=t,this.returnSequences=e.returnSequences==null?!1:e.returnSequences,this.returnState=e.returnState==null?!1:e.returnState,this.goBackwards=e.goBackwards==null?!1:e.goBackwards,this._stateful=e.stateful==null?!1:e.stateful,this.unroll=e.unroll==null?!1:e.unroll,this.supportsMasking=!0,this.inputSpec=[new ht({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){if(this.states_==null){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;return Rn(0,e).map(t=>null)}else return this.states_}setStates(e){this.states_=e}computeOutputShape(e){Ad(e)&&(e=e[0]),e=e;let t=this.cell.stateSize;Array.isArray(t)||(t=[t]);const s=t[0];let o;if(this.returnSequences?o=[e[0],e[1],s]:o=[e[0],s],this.returnState){const r=[];for(const i of t)r.push([e[0],i]);return[o].concat(r)}else return o}computeMask(e,t){return P(()=>{Array.isArray(t)&&(t=t[0]);const s=this.returnSequences?t:null;if(this.returnState){const o=this.states.map(r=>null);return[s].concat(o)}else return s})}get states(){if(this.states_==null){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,t=[];for(let s=0;si.shape[i.shape.length-1]),r))throw new A(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is ${this.cell.stateSize}`)}else this.stateSpec=r.map(i=>new ht({shape:[null,i]}));this.stateful&&this.resetStates()}resetStates(e,t=!1){P(()=>{if(!this.stateful)throw new qn("Cannot call resetStates() on an RNN Layer that is not stateful.");const s=this.inputSpec[0].shape[0];if(s==null)throw new A("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(this.states_==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(o=>st([s,o])):this.states_=[st([s,this.cell.stateSize])];else if(e==null)fe(this.states_),this.keptStates!=null&&(fe(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(o=>st([s,o])):this.states_[0]=st([s,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new A(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t===!0?this.keptStates.push(this.states_.slice()):fe(this.states_);for(let o=0;odn(o.clone()))})}apply(e,t){let s=t==null?null:t.initialState,o=t==null?null:t.constants;t==null&&(t={});const r=Cb(e,s,o,this.numConstants);e=r.inputs,s=r.initialState,o=r.constants;let i=[],a=[];if(s!=null){t.initialState=s,i=i.concat(s),this.stateSpec=[];for(const c of s)this.stateSpec.push(new ht({shape:c.shape}));a=a.concat(this.stateSpec)}if(o!=null&&(t.constants=o,i=i.concat(o),this.numConstants=o.length),i[0]instanceof Yn){const c=[e].concat(i),u=this.inputSpec.concat(a),h=this.inputSpec;this.inputSpec=u;const d=super.apply(c,t);return this.inputSpec=h,d}else return super.apply(e,t)}call(e,t){return P(()=>{const s=t==null?null:t.mask,o=t==null?null:t.training;let r=t==null?null:t.initialState;e=xe(e),r==null&&(this.stateful?r=this.states_:r=this.getInitialState(e));const i=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(r.length!==i)throw new A(`RNN Layer has ${i} state(s) but was passed ${r.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const a={training:o},c=Ib((f,g)=>{const m=this.cell.call([f].concat(g),a);return[m[0],m.slice(1)]},e,r,this.goBackwards,s,null,this.unroll,this.returnSequences),u=c[0],h=c[1],d=c[2];this.stateful&&this.resetStates(d,o);const p=this.returnSequences?h:u;return this.returnState?[p].concat(d):p})}getInitialState(e){return P(()=>{let t=st(e.shape);return t=pe(t,[1,2]),t=_i(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map(s=>s>1?Id(t,[1,s]):t):this.cell.stateSize>1?[Id(t,[1,this.cell.stateSize])]:[t]})}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.cell!=null&&this.cell.setFastWeightInitDuringBuild(e)}getConfig(){const e=super.getConfig(),t={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};this.numConstants!=null&&(t.numConstants=this.numConstants);const s=this.cell.getConfig();return this.getClassName()===Ds.className&&(t.cell={className:this.cell.getClassName(),config:s}),Object.assign(Object.assign(Object.assign({},s),e),t)}static fromConfig(e,t,s={}){const o=t.cell,r=Zn(o,s);return new e(Object.assign(t,{cell:r}))}}Ds.className="RNN",Y(Ds);class tc extends ke{}class jd extends tc{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,bt(this.units,"units"),this.activation=As(e.activation==null?this.DEFAULT_ACTIVATION:e.activation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=je(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=je(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=je(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Ke(e.kernelRegularizer),this.recurrentRegularizer=Ke(e.recurrentRegularizer),this.biasRegularizer=Ke(e.biasRegularizer),this.kernelConstraint=pt(e.kernelConstraint),this.recurrentConstraint=pt(e.recurrentConstraint),this.biasConstraint=pt(e.biasConstraint),this.dropout=er([1,Ns([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=er([1,Ns([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=_e(e),this.kernel=this.addWeight("kernel",[e[e.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return P(()=>{if(e=e,e.length!==2)throw new A(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let s=e[1];e=e[0];const o=t.training==null?!1:t.training;0fn(e),rate:this.dropout,training:o,dropoutFunc:this.dropoutFunc})),0fn(s),rate:this.recurrentDropout,training:o,dropoutFunc:this.dropoutFunc}));let r;const i=this.dropoutMask,a=this.recurrentDropoutMask;i!=null?r=Xn(D(e,i),this.kernel.read()):r=Xn(e,this.kernel.read()),this.bias!=null&&(r=Dn(r,this.bias.read())),a!=null&&(s=D(s,a));let l=ee(r,Xn(s,this.recurrentKernel.read()));return this.activation!=null&&(l=this.activation.apply(l)),[l,l]})}getConfig(){const e=super.getConfig(),t={units:this.units,activation:Rs(this.activation),useBias:this.useBias,kernelInitializer:Ze(this.kernelInitializer),recurrentInitializer:Ze(this.recurrentInitializer),biasInitializer:Ze(this.biasInitializer),kernelRegularizer:ze(this.kernelRegularizer),recurrentRegularizer:ze(this.recurrentRegularizer),biasRegularizer:ze(this.biasRegularizer),activityRegularizer:ze(this.activityRegularizer),kernelConstraint:dt(this.kernelConstraint),recurrentConstraint:dt(this.recurrentConstraint),biasConstraint:dt(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign(Object.assign({},e),t)}}jd.className="SimpleRNNCell",Y(jd);class $b extends Ds{constructor(e){e.cell=new jd(e),super(e)}call(e,t){return P(()=>{this.cell.dropoutMask!=null&&(fe(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(fe(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=t==null?null:t.mask,o=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:s,training:o,initialState:r})})}static fromConfig(e,t){return new e(t)}}$b.className="SimpleRNN",Y($b);class Kd extends tc{constructor(e){if(super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.resetAfter)throw new A("GRUCell does not support reset_after parameter set to true.");this.units=e.units,bt(this.units,"units"),this.activation=As(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=As(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=je(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=je(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=je(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Ke(e.kernelRegularizer),this.recurrentRegularizer=Ke(e.recurrentRegularizer),this.biasRegularizer=Ke(e.biasRegularizer),this.kernelConstraint=pt(e.kernelConstraint),this.recurrentConstraint=pt(e.recurrentConstraint),this.biasConstraint=pt(e.biasConstraint),this.dropout=er([1,Ns([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=er([1,Ns([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=_e(e);const t=e[e.length-1];this.kernel=this.addWeight("kernel",[t,this.units*3],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*3],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units*3],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return P(()=>{if(e=e,e.length!==2)throw new A(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);const s=t.training==null?!1:t.training;let o=e[1];e=e[0],0fn(e),rate:this.dropout,training:s,count:3,dropoutFunc:this.dropoutFunc})),0fn(o),rate:this.recurrentDropout,training:s,count:3,dropoutFunc:this.dropoutFunc}));const r=this.dropoutMask,i=this.recurrentDropoutMask;let a,l,c;0{this.cell.dropoutMask!=null&&(fe(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(fe(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=t==null?null:t.mask,o=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:s,training:o,initialState:r})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}}vb.className="GRU",Y(vb);class nc extends tc{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,bt(this.units,"units"),this.activation=As(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=As(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=je(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=je(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=je(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=Ke(e.kernelRegularizer),this.recurrentRegularizer=Ke(e.recurrentRegularizer),this.biasRegularizer=Ke(e.biasRegularizer),this.kernelConstraint=pt(e.kernelConstraint),this.recurrentConstraint=pt(e.recurrentConstraint),this.biasConstraint=pt(e.biasConstraint),this.dropout=er([1,Ns([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=er([1,Ns([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){var t;e=_e(e);const s=e[e.length-1];this.kernel=this.addWeight("kernel",[s,this.units*4],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*4],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint);let o;if(this.useBias){if(this.unitForgetBias){const r=this.biasInitializer,i=this.units;o=new(t=class extends bn{apply(l,c){const u=r.apply([i]),h=new vd().apply([i]),d=r.apply([i*2]);return Zg(Zg(u,h),d)}},t.className="CustomInit",t)}else o=this.biasInitializer;this.bias=this.addWeight("bias",[this.units*4],null,o,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,t){return P(()=>{const s=t.training==null?!1:t.training;if(e=e,e.length!==3)throw new A(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let o=e[1];const r=e[2];e=e[0],0fn(e),rate:this.dropout,training:s,count:4,dropoutFunc:this.dropoutFunc})),0fn(o),rate:this.recurrentDropout,training:s,count:4,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,a=this.recurrentDropoutMask;let l,c,u,h;0{this.cell.dropoutMask!=null&&(fe(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(fe(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=t==null?null:t.mask,o=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:s,training:o,initialState:r})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}}kb.className="LSTM",Y(kb);class Xd extends tc{constructor(e){super(e),this.cells=e.cells}get stateSize(){const e=[];for(const t of this.cells.slice().reverse())Array.isArray(t.stateSize)?e.push(...t.stateSize):e.push(t.stateSize);return e}call(e,t){return P(()=>{e=e;let s=e.slice(1);const o=[];for(const a of this.cells.slice().reverse())Array.isArray(a.stateSize)?o.push(s.splice(0,a.stateSize.length)):o.push(s.splice(0,1));o.reverse();const r=[];let i;for(let a=0;a{go(`RNNCell_${o}`,()=>{s.build(e),Array.isArray(s.stateSize)?t=s.stateSize[0]:t=s.stateSize,e=[e[0],t]})}),this.built=!0}getConfig(){const e=super.getConfig(),t=r=>({className:r.getClassName(),config:r.getConfig()}),o={cells:this.cells.map(t)};return Object.assign(Object.assign({},e),o)}static fromConfig(e,t,s={}){const o=[];for(const r of t.cells)o.push(Zn(r,s));return new e({cells:o})}get trainableWeights(){if(!this.trainable)return[];const e=[];for(const t of this.cells)e.push(...t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.cells)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const s of this.cells)t.push(...s.trainableWeights);return t.concat(e)}return e}getWeights(){const e=[];for(const t of this.cells)e.push(...t.weights);return Dd(e)}setWeights(e){const t=[];for(const s of this.cells){const o=s.weights.length,r=e.splice(o);for(let i=0;ir!=null?r(e(),t):Jg(e(),t),a=()=>Li(i,e,s);return!o||o<=1?dn(a().clone()):Array(o).fill(void 0).map(a).map(c=>dn(c.clone()))}/** * @license * Copyright 2020 Google LLC * @@ -7784,7 +7784,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */var uR=function(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(n);o{if(this.cell.dropoutMask!=null&&(fe(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(fe(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new A("ConvRNN2D cell does not support constants");const s=t==null?null:t.mask,o=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:s,training:o,initialState:r})})}computeOutputShape(e){let t=this.computeSingleOutputShape(e);return this.returnSequences||(t=[t[0],...t.slice(2)]),this.returnState&&(t=[t,...Array(2).fill([e[0],...t.slice(-3)])]),t}getInitialState(e){return z(()=>{const{stateSize:t}=this.cell,s=e.shape,o=this.computeSingleOutputShape(s),r=[o[0],...o.slice(2)],i=st(r);return Array.isArray(t)?Array(t.length).fill(i):[i]})}resetStates(e,t=!1){z(()=>{if(!this.stateful)throw new jn("Cannot call resetStates() on an RNN Layer that is not stateful.");const s=this.inputSpec[0].shape,o=this.computeSingleOutputShape(s),r=[o[0],...o.slice(2)];if(s[0]==null)throw new A("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(this.getStates()==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>st(r)):this.states_=[st(r)];else if(e==null)fe(this.states_),this.keptStates!=null&&(fe(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>st(r)):this.states_[0]=st(r);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new A(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t?this.keptStates.push(this.states_.slice()):fe(this.states_);for(let a=0;adn(a.clone()))})}computeSingleOutputShape(e){const{dataFormat:t,filters:s,kernelSize:o,padding:r,strides:i,dilationRate:a}=this.cell,l=t==="channelsFirst",c=e[l?3:2],u=e[l?4:3],h=On(c,o[0],r,i[0],a[0]),d=On(u,o[1],r,i[1],a[1]);return[...e.slice(0,2),...l?[s,h,d]:[h,d,s]]}}$b.className="ConvRNN2D";class Yd extends tc{constructor(e){const{filters:t,kernelSize:s,strides:o,padding:r,dataFormat:i,dilationRate:a}=e;super(Object.assign(Object.assign({},e),{units:t})),this.filters=t,bt(this.filters,"filters"),this.kernelSize=nr(s,2,"kernelSize"),this.kernelSize.forEach(l=>bt(l,"kernelSize")),this.strides=nr(o||1,2,"strides"),this.strides.forEach(l=>bt(l,"strides")),this.padding=r||"valid",on(this.padding),this.dataFormat=i||"channelsLast",ot(this.dataFormat),this.dilationRate=nr(a||1,2,"dilationRate"),this.dilationRate.forEach(l=>bt(l,"dilationRate"))}build(e){var t;e=_e(e);const s=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[s]==null)throw new A(`The channel dimension of the input should be defined. Found ${e[s]}`);const o=e[s],r=4,i=this.kernelSize.concat([o,this.filters*r]);this.kernel=this.addWeight("kernel",i,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const a=this.kernelSize.concat([this.filters,this.filters*r]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",a,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let l;if(this.unitForgetBias){const c=this.biasInitializer,u=this.filters;l=new(t=class extends bn{apply(d,p){const f=c.apply([u]),g=Nn([u]),m=c.apply([u*2]);return Cd([f,g,m])}},t.className="CustomInit",t)}else l=this.biasInitializer;this.bias=this.addWeight("bias",[this.filters*r],null,l,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return z(()=>{if(e.length!==3)throw new A(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);const s=t.training||!1,o=e[0],r=e[1],i=e[2],a=4;0fn(o),rate:this.dropout,training:s,count:a,dropoutFunc:this.dropoutFunc}));const l=this.dropoutMask,c=(K,X,J)=>!X||!X[J]?K:F(X[J],K);let u=c(o,l,0),h=c(o,l,1),d=c(o,l,2),p=c(o,l,3);0fn(r),rate:this.recurrentDropout,training:s,count:a,dropoutFunc:this.dropoutFunc}));const f=this.recurrentDropoutMask;let g=c(r,f,0),m=c(r,f,1),x=c(r,f,2),b=c(r,f,3);const w=3,[y,C,I,v]=sn(this.kernel.read(),a,w),[k,S,T,E]=this.useBias?sn(this.bias.read(),a):[null,null,null,null];u=this.inputConv(u,y,k,this.padding),h=this.inputConv(h,C,S,this.padding),d=this.inputConv(d,I,T,this.padding),p=this.inputConv(p,v,E,this.padding);const[V,M,L,R]=sn(this.recurrentKernel.read(),a,w);g=this.recurrentConv(g,V),m=this.recurrentConv(m,M),x=this.recurrentConv(x,L),b=this.recurrentConv(b,R);const P=this.recurrentActivation.apply(ee(u,g)),G=this.recurrentActivation.apply(ee(h,m)),B=ee(F(G,i),F(P,this.activation.apply(ee(d,x)))),j=F(this.recurrentActivation.apply(ee(p,b)),this.activation.apply(B));return[j,j,B]})}getConfig(){const e=super.getConfig(),t=uR(e,["units"]),s={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign(Object.assign({},t),s)}inputConv(e,t,s,o){const r=ro(e,t,this.strides,o||"valid",this.dataFormat==="channelsFirst"?"NCHW":"NHWC",this.dilationRate);return s?Dn(r,s,this.dataFormat):r}recurrentConv(e,t){return ro(e,t,1,"same",this.dataFormat==="channelsFirst"?"NCHW":"NHWC")}}Yd.className="ConvLSTM2DCell",Z(Yd);class vb extends $b{constructor(e){const t=new Yd(e);super(Object.assign(Object.assign({},e),{cell:t}))}static fromConfig(e,t){return new e(t)}}vb.className="ConvLSTM2D",Z(vb);/** + */var dR=function(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(n);o{if(this.cell.dropoutMask!=null&&(fe(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(fe(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new A("ConvRNN2D cell does not support constants");const s=t==null?null:t.mask,o=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:s,training:o,initialState:r})})}computeOutputShape(e){let t=this.computeSingleOutputShape(e);return this.returnSequences||(t=[t[0],...t.slice(2)]),this.returnState&&(t=[t,...Array(2).fill([e[0],...t.slice(-3)])]),t}getInitialState(e){return P(()=>{const{stateSize:t}=this.cell,s=e.shape,o=this.computeSingleOutputShape(s),r=[o[0],...o.slice(2)],i=st(r);return Array.isArray(t)?Array(t.length).fill(i):[i]})}resetStates(e,t=!1){P(()=>{if(!this.stateful)throw new qn("Cannot call resetStates() on an RNN Layer that is not stateful.");const s=this.inputSpec[0].shape,o=this.computeSingleOutputShape(s),r=[o[0],...o.slice(2)];if(s[0]==null)throw new A("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(this.getStates()==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>st(r)):this.states_=[st(r)];else if(e==null)fe(this.states_),this.keptStates!=null&&(fe(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>st(r)):this.states_[0]=st(r);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new A(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t?this.keptStates.push(this.states_.slice()):fe(this.states_);for(let a=0;adn(a.clone()))})}computeSingleOutputShape(e){const{dataFormat:t,filters:s,kernelSize:o,padding:r,strides:i,dilationRate:a}=this.cell,l=t==="channelsFirst",c=e[l?3:2],u=e[l?4:3],h=On(c,o[0],r,i[0],a[0]),d=On(u,o[1],r,i[1],a[1]);return[...e.slice(0,2),...l?[s,h,d]:[h,d,s]]}}Sb.className="ConvRNN2D";class Yd extends nc{constructor(e){const{filters:t,kernelSize:s,strides:o,padding:r,dataFormat:i,dilationRate:a}=e;super(Object.assign(Object.assign({},e),{units:t})),this.filters=t,bt(this.filters,"filters"),this.kernelSize=nr(s,2,"kernelSize"),this.kernelSize.forEach(l=>bt(l,"kernelSize")),this.strides=nr(o||1,2,"strides"),this.strides.forEach(l=>bt(l,"strides")),this.padding=r||"valid",on(this.padding),this.dataFormat=i||"channelsLast",ot(this.dataFormat),this.dilationRate=nr(a||1,2,"dilationRate"),this.dilationRate.forEach(l=>bt(l,"dilationRate"))}build(e){var t;e=_e(e);const s=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[s]==null)throw new A(`The channel dimension of the input should be defined. Found ${e[s]}`);const o=e[s],r=4,i=this.kernelSize.concat([o,this.filters*r]);this.kernel=this.addWeight("kernel",i,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const a=this.kernelSize.concat([this.filters,this.filters*r]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",a,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let l;if(this.unitForgetBias){const c=this.biasInitializer,u=this.filters;l=new(t=class extends bn{apply(d,p){const f=c.apply([u]),g=Nn([u]),m=c.apply([u*2]);return Cd([f,g,m])}},t.className="CustomInit",t)}else l=this.biasInitializer;this.bias=this.addWeight("bias",[this.filters*r],null,l,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return P(()=>{if(e.length!==3)throw new A(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);const s=t.training||!1,o=e[0],r=e[1],i=e[2],a=4;0fn(o),rate:this.dropout,training:s,count:a,dropoutFunc:this.dropoutFunc}));const l=this.dropoutMask,c=(K,X,J)=>!X||!X[J]?K:D(X[J],K);let u=c(o,l,0),h=c(o,l,1),d=c(o,l,2),p=c(o,l,3);0fn(r),rate:this.recurrentDropout,training:s,count:a,dropoutFunc:this.dropoutFunc}));const f=this.recurrentDropoutMask;let g=c(r,f,0),m=c(r,f,1),x=c(r,f,2),b=c(r,f,3);const w=3,[y,C,I,v]=sn(this.kernel.read(),a,w),[k,S,T,E]=this.useBias?sn(this.bias.read(),a):[null,null,null,null];u=this.inputConv(u,y,k,this.padding),h=this.inputConv(h,C,S,this.padding),d=this.inputConv(d,I,T,this.padding),p=this.inputConv(p,v,E,this.padding);const[V,M,L,R]=sn(this.recurrentKernel.read(),a,w);g=this.recurrentConv(g,V),m=this.recurrentConv(m,M),x=this.recurrentConv(x,L),b=this.recurrentConv(b,R);const B=this.recurrentActivation.apply(ee(u,g)),G=this.recurrentActivation.apply(ee(h,m)),z=ee(D(G,i),D(B,this.activation.apply(ee(d,x)))),q=D(this.recurrentActivation.apply(ee(p,b)),this.activation.apply(z));return[q,q,z]})}getConfig(){const e=super.getConfig(),t=dR(e,["units"]),s={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign(Object.assign({},t),s)}inputConv(e,t,s,o){const r=ro(e,t,this.strides,o||"valid",this.dataFormat==="channelsFirst"?"NCHW":"NHWC",this.dilationRate);return s?Dn(r,s,this.dataFormat):r}recurrentConv(e,t){return ro(e,t,1,"same",this.dataFormat==="channelsFirst"?"NCHW":"NHWC")}}Yd.className="ConvLSTM2DCell",Y(Yd);class Tb extends Sb{constructor(e){const t=new Yd(e);super(Object.assign(Object.assign({},e),{cell:t}))}static fromConfig(e,t){return new e(t)}}Tb.className="ConvLSTM2D",Y(Tb);/** * @license * Copyright 2018 Google LLC * @@ -7792,7 +7792,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class Zd extends ke{constructor(e){super(e),this.rate=Math.max(Math.min(e.rate,1),0),this.noiseShape=e.noiseShape,this.seed=e.seed,this.supportsMasking=!0}getNoiseShape(e){if(this.noiseShape==null)return this.noiseShape;const t=e.shape,s=[];for(let o=0;o{this.invokeCallHook(e,t);const s=xe(e);if(0Qg(s,this.rate,r,this.seed),()=>s,o)}return e})}getConfig(){const e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},t=super.getConfig();return Object.assign(e,t),e}dispose(){return super.dispose()}}Zd.className="Dropout",Z(Zd);class kb extends Zd{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){const t=e.shape;return[t[0],1,t[2]]}}kb.className="SpatialDropout1D",Z(kb);class Sb extends ke{constructor(e){if(super(e),this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.batchInputShape==null&&e.inputShape==null&&e.inputDim!=null){let t=null;e.batchSize!=null&&(t=e.batchSize),this.batchInputShape=[t,e.inputDim]}this.units=e.units,bt(this.units,"units"),this.activation=As(e.activation),e.useBias!=null&&(this.useBias=e.useBias),this.kernelInitializer=qe(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=qe(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=pt(e.kernelConstraint),this.biasConstraint=pt(e.biasConstraint),this.kernelRegularizer=Ke(e.kernelRegularizer),this.biasRegularizer=Ke(e.biasRegularizer),this.activityRegularizer=Ke(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){e=_e(e);const t=e[e.length-1];this.kernel==null&&(this.kernel=this.addWeight("kernel",[t,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:{[-1]:t}}],this.built=!0}computeOutputShape(e){e=_e(e);const t=e.slice();return t[t.length-1]=this.units,t}call(e,t){return z(()=>{this.invokeCallHook(e,t);const s=xe(e),o=Ug(this.activation.getClassName());let r;return o!=null?r=Xn(s,this.kernel.read(),o,this.bias?this.bias.read():null):(r=Xn(s,this.kernel.read()),this.bias!=null&&(r=Dn(r,this.bias.read())),this.activation!=null&&(r=this.activation.apply(r))),r})}getConfig(){const e={units:this.units,activation:Rs(this.activation),useBias:this.useBias,kernelInitializer:Ze(this.kernelInitializer),biasInitializer:Ze(this.biasInitializer),kernelRegularizer:ze(this.kernelRegularizer),biasRegularizer:ze(this.biasRegularizer),activityRegularizer:ze(this.activityRegularizer),kernelConstraint:dt(this.kernelConstraint),biasConstraint:dt(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}Sb.className="Dense",Z(Sb);class Tb extends ke{constructor(e){e=e||{},super(e),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=_e(e);for(const t of e.slice(1))if(t==null)throw new A(`The shape of the input to "Flatten" is not fully defined (got ${e.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`);return[e[0],Ts(e,1)]}call(e,t){return z(()=>{this.invokeCallHook(e,t);let s=xe(e);if(this.dataFormat==="channelsFirst"&&s.rank>1){const o=[0];for(let r=2;r{this.invokeCallHook(e,t);const s=xe(e);return this.activation.apply(s)})}getConfig(){const e={activation:Rs(this.activation)},t=super.getConfig();return Object.assign(e,t),e}}Nb.className="Activation",Z(Nb);class Eb extends ke{constructor(e){super(e),this.n=e.n,this.inputSpec=[{ndim:2}]}computeOutputShape(e){return[e[0],this.n,e[1]]}call(e,t){return z(()=>(e=xe(e),zN(e,this.n)))}getConfig(){const e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}}Eb.className="RepeatVector",Z(Eb);class Rb extends ke{constructor(e){super(e),this.targetShape=e.targetShape;for(let t=0;t{this.invokeCallHook(e,t);const s=xe(e),o=s.shape,r=o.slice(0,1).concat(this.fixUnknownDimension(o.slice(1),this.targetShape));return _(s,r)})}getConfig(){const e={targetShape:this.targetShape},t=super.getConfig();return Object.assign(e,t),e}}Rb.className="Reshape",Z(Rb);class Ab extends ke{constructor(e){if(super(e),e.dims==null)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(e.dims))throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`);const t=Rn(1,e.dims.length+1);if(!Oe(e.dims.slice().sort(),t))throw new Error("Invalid permutation `dims`: "+JSON.stringify(e.dims)+" `dims` must contain consecutive integers starting from 1.");this.dims=e.dims,this.dimsIncludingBatch=[0].concat(this.dims),this.inputSpec=[new ht({ndim:this.dims.length+1})]}computeOutputShape(e){e=_e(e);const t=e.slice();return this.dims.forEach((s,o)=>{t[o+1]=e[s]}),t}call(e,t){return Ee(xe(e),this.dimsIncludingBatch)}getConfig(){const e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}}Ab.className="Permute",Z(Ab);class Db extends ke{constructor(e){super(e??{}),this.supportsMasking=!0,e!=null?this.maskValue=e.maskValue==null?0:e.maskValue:this.maskValue=0}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={maskValue:this.maskValue};return Object.assign(t,e),t}computeMask(e,t){const s=xe(e);return Yu(Sl(s,this.maskValue),-1)}call(e,t){return z(()=>{this.invokeCallHook(e,t);const s=xe(e),i=Yu(Sl(s,this.maskValue),-1,!0);return F(s,oe(i,s.dtype))})}}Db.className="Masking",Z(Db);/** + */class Zd extends ke{constructor(e){super(e),this.rate=Math.max(Math.min(e.rate,1),0),this.noiseShape=e.noiseShape,this.seed=e.seed,this.supportsMasking=!0}getNoiseShape(e){if(this.noiseShape==null)return this.noiseShape;const t=e.shape,s=[];for(let o=0;o{this.invokeCallHook(e,t);const s=xe(e);if(0Jg(s,this.rate,r,this.seed),()=>s,o)}return e})}getConfig(){const e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},t=super.getConfig();return Object.assign(e,t),e}dispose(){return super.dispose()}}Zd.className="Dropout",Y(Zd);class Nb extends Zd{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){const t=e.shape;return[t[0],1,t[2]]}}Nb.className="SpatialDropout1D",Y(Nb);class Eb extends ke{constructor(e){if(super(e),this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.batchInputShape==null&&e.inputShape==null&&e.inputDim!=null){let t=null;e.batchSize!=null&&(t=e.batchSize),this.batchInputShape=[t,e.inputDim]}this.units=e.units,bt(this.units,"units"),this.activation=As(e.activation),e.useBias!=null&&(this.useBias=e.useBias),this.kernelInitializer=je(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=je(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=pt(e.kernelConstraint),this.biasConstraint=pt(e.biasConstraint),this.kernelRegularizer=Ke(e.kernelRegularizer),this.biasRegularizer=Ke(e.biasRegularizer),this.activityRegularizer=Ke(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){e=_e(e);const t=e[e.length-1];this.kernel==null&&(this.kernel=this.addWeight("kernel",[t,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:{[-1]:t}}],this.built=!0}computeOutputShape(e){e=_e(e);const t=e.slice();return t[t.length-1]=this.units,t}call(e,t){return P(()=>{this.invokeCallHook(e,t);const s=xe(e),o=Gg(this.activation.getClassName());let r;return o!=null?r=Xn(s,this.kernel.read(),o,this.bias?this.bias.read():null):(r=Xn(s,this.kernel.read()),this.bias!=null&&(r=Dn(r,this.bias.read())),this.activation!=null&&(r=this.activation.apply(r))),r})}getConfig(){const e={units:this.units,activation:Rs(this.activation),useBias:this.useBias,kernelInitializer:Ze(this.kernelInitializer),biasInitializer:Ze(this.biasInitializer),kernelRegularizer:ze(this.kernelRegularizer),biasRegularizer:ze(this.biasRegularizer),activityRegularizer:ze(this.activityRegularizer),kernelConstraint:dt(this.kernelConstraint),biasConstraint:dt(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}Eb.className="Dense",Y(Eb);class Rb extends ke{constructor(e){e=e||{},super(e),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=_e(e);for(const t of e.slice(1))if(t==null)throw new A(`The shape of the input to "Flatten" is not fully defined (got ${e.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`);return[e[0],Ts(e,1)]}call(e,t){return P(()=>{this.invokeCallHook(e,t);let s=xe(e);if(this.dataFormat==="channelsFirst"&&s.rank>1){const o=[0];for(let r=2;r{this.invokeCallHook(e,t);const s=xe(e);return this.activation.apply(s)})}getConfig(){const e={activation:Rs(this.activation)},t=super.getConfig();return Object.assign(e,t),e}}Ab.className="Activation",Y(Ab);class Db extends ke{constructor(e){super(e),this.n=e.n,this.inputSpec=[{ndim:2}]}computeOutputShape(e){return[e[0],this.n,e[1]]}call(e,t){return P(()=>(e=xe(e),WN(e,this.n)))}getConfig(){const e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}}Db.className="RepeatVector",Y(Db);class Fb extends ke{constructor(e){super(e),this.targetShape=e.targetShape;for(let t=0;t{this.invokeCallHook(e,t);const s=xe(e),o=s.shape,r=o.slice(0,1).concat(this.fixUnknownDimension(o.slice(1),this.targetShape));return _(s,r)})}getConfig(){const e={targetShape:this.targetShape},t=super.getConfig();return Object.assign(e,t),e}}Fb.className="Reshape",Y(Fb);class _b extends ke{constructor(e){if(super(e),e.dims==null)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(e.dims))throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`);const t=Rn(1,e.dims.length+1);if(!Oe(e.dims.slice().sort(),t))throw new Error("Invalid permutation `dims`: "+JSON.stringify(e.dims)+" `dims` must contain consecutive integers starting from 1.");this.dims=e.dims,this.dimsIncludingBatch=[0].concat(this.dims),this.inputSpec=[new ht({ndim:this.dims.length+1})]}computeOutputShape(e){e=_e(e);const t=e.slice();return this.dims.forEach((s,o)=>{t[o+1]=e[s]}),t}call(e,t){return Ee(xe(e),this.dimsIncludingBatch)}getConfig(){const e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}}_b.className="Permute",Y(_b);class Ob extends ke{constructor(e){super(e??{}),this.supportsMasking=!0,e!=null?this.maskValue=e.maskValue==null?0:e.maskValue:this.maskValue=0}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={maskValue:this.maskValue};return Object.assign(t,e),t}computeMask(e,t){const s=xe(e);return Zu(Tl(s,this.maskValue),-1)}call(e,t){return P(()=>{this.invokeCallHook(e,t);const s=xe(e),i=Zu(Tl(s,this.maskValue),-1,!0);return D(s,oe(i,s.dtype))})}}Ob.className="Masking",Y(Ob);/** * @license * Copyright 2018 Google LLC * @@ -7800,7 +7800,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class Fb extends ke{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",e.batchInputShape==null&&e.inputShape==null){let t=null;e.batchSize!=null&&(t=e.batchSize),e.inputLength==null?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(Me(e.inputLength))}this.inputDim=e.inputDim,bt(this.inputDim,"inputDim"),this.outputDim=e.outputDim,bt(this.outputDim,"outputDim"),this.embeddingsInitializer=qe(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=Ke(e.embeddingsRegularizer),this.activityRegularizer=Ke(e.activityRegularizer),this.embeddingsConstraint=pt(e.embeddingsConstraint),this.maskZero=e.maskZero,this.supportsMasking=e.maskZero,this.inputLength=e.inputLength}build(e){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0}warnOnIncompatibleInputShape(e){}computeMask(e,t){return z(()=>this.maskZero?(e=xe(e),Sl(e,Ne(e))):null)}computeOutputShape(e){if(e=_e(e),this.inputLength==null)return[...e,this.outputDim];const t=Me(this.inputLength);if(t.length!==e.length-1)throw new A(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let s=0;for(let o=0;o{this.invokeCallHook(e,t);let s=xe(e);s.dtype!=="int32"&&(s=Kn(s,"int32"));const o=Zg(this.embeddings.read(),_(s,[s.size]));return _(o,_e(this.computeOutputShape(s.shape)))})}getConfig(){const e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:Ze(this.embeddingsInitializer),embeddingsRegularizer:ze(this.embeddingsRegularizer),activityRegularizer:ze(this.activityRegularizer),embeddingsConstraint:dt(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}}Fb.className="Embedding",Z(Fb);/** + */class Lb extends ke{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",e.batchInputShape==null&&e.inputShape==null){let t=null;e.batchSize!=null&&(t=e.batchSize),e.inputLength==null?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(Me(e.inputLength))}this.inputDim=e.inputDim,bt(this.inputDim,"inputDim"),this.outputDim=e.outputDim,bt(this.outputDim,"outputDim"),this.embeddingsInitializer=je(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=Ke(e.embeddingsRegularizer),this.activityRegularizer=Ke(e.activityRegularizer),this.embeddingsConstraint=pt(e.embeddingsConstraint),this.maskZero=e.maskZero,this.supportsMasking=e.maskZero,this.inputLength=e.inputLength}build(e){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0}warnOnIncompatibleInputShape(e){}computeMask(e,t){return P(()=>this.maskZero?(e=xe(e),Tl(e,Ne(e))):null)}computeOutputShape(e){if(e=_e(e),this.inputLength==null)return[...e,this.outputDim];const t=Me(this.inputLength);if(t.length!==e.length-1)throw new A(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let s=0;for(let o=0;o{this.invokeCallHook(e,t);let s=xe(e);s.dtype!=="int32"&&(s=Kn(s,"int32"));const o=Qg(this.embeddings.read(),_(s,[s.size]));return _(o,_e(this.computeOutputShape(s.shape)))})}getConfig(){const e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:Ze(this.embeddingsInitializer),embeddingsRegularizer:ze(this.embeddingsRegularizer),activityRegularizer:ze(this.activityRegularizer),embeddingsConstraint:dt(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}}Lb.className="Embedding",Y(Lb);/** * @license * Copyright 2018 Google LLC * @@ -7808,7 +7808,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class bo extends ke{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new Ce}computeElementwiseOpOutputShape(e,t){if(e==null||t==null)return null;if(e.length1)throw new A(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let s=e[0]==null?null:e[0].slice(1);for(let r=1;rr.length);e.indexOf(null)===-1&&Ss(o).length===1?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return z(()=>{if(e=e,this.reshapeRequired){const s=[],o=e.map(r=>r.rank);if(o.indexOf(null)===-1){const r=Ns(o);for(let i of e){const a=i.rank;for(let l=0;l1){const u=Rn(1,c).concat([0]);s.push(Ee(l,u)),r=!0}else s.push(l)}let i=this.mergeFunction(s);const a=i.rank;if(r){if(a==null){const l=i.shape,c=l.length,u=l[c-1],h=[u].concat(l.slice(0,l.length-1));i=_(Ee(_(i,[-1,u]),[1,0]),h)}else if(a>1){const l=[a-1].concat(Rn(0,a-1));i=Ee(i,l)}}return i}}else return this.mergeFunction(e)})}computeOutputShape(e){e=e;let t;e[0]==null?t=null:t=e[0].slice(1);for(let o=1;o{if(t==null)return null;if(!Array.isArray(t))throw new A("`mask` should be an Array");if(!Array.isArray(e))throw new A("`inputs` should be an Array");if(t.length!==e.length)throw new A(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every(o=>o==null))return null;t=t.map(o=>o==null?o:Ut(o,0));let s=t[0];for(let o=1;o{let t=e[0].clone();for(let s=1;s{let t=e[0].clone();for(let s=1;s{let t=e[0].clone();for(let s=1;s{let t=e[0];for(let s=1;s{let t=e[0];for(let s=1;s1)throw new A("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return z(()=>Cd(e,this.axis))}computeOutputShape(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))throw new A("A `Concatenate` layer should be called on a list of inputs.");const t=e,s=t[0].slice(),o=this.axis<0?s.length+this.axis:this.axis;for(const r of t.slice(1)){if(s[o]==null||r[o]==null){s[o]=null;break}s[o]+=r[o]}return s}computeMask(e,t){if(t==null)return null;if(!Array.isArray(t))throw new A("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new A("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new A(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return z(()=>{let s=!0;if(t.forEach(i=>{if(i!=null){s=!1;return}}),s)return null;const o=[];for(let i=0;i3||e.shape.length>3)throw new Ce("batchDot is not implemented for tensors of 4D or higher rank yet");if($(n.shape.length>=2,()=>`batchDot requires the rank of x to be >= 2, but got ${n.shape.length}`),$(n.shape.length>=2,()=>`batchDot requires the rank of y to be >= 2, but got ${e.shape.length}`),typeof t=="number"&&(t=[t,t]),n.dtype==="complex64"||e.dtype==="complex64")throw new Ce("batchDot is not implemented for complex64-type Tensors yet.");const s=n.shape.length,o=e.shape.length;t==null&&(t=[s-1,o-2]);const r=t;return z(()=>{let i;if(s>o){i=s-o;const l=[];for(let c=0;cs){i=o-s;const l=[];for(let c=0;c0){let l;s>o?l=s+o-3:l=s-1;const c=[];for(let u=l;u"A `Dot` layer should be called on a list of exactly 2 inputs.");const t=e[0],s=e[1];if(t.length>3||s.length>3)throw new Ce("Dot layer does not support tensors of 4D or higher rank yet.");const o=this.interpretAxes(t,s);if(t[o[0]]!==s[o[1]])throw new A(`Dimension incompatibility: ${t[o[0]]} !== ${s[o[1]]}`)}mergeFunction(e){if(e.length!==2)throw new A(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let t=e[0],s=e[1],o;return Array.isArray(this.axes)?o=this.axes.map((r,i)=>ji(r,e[i].shape.length)):o=[ji(this.axes,t.shape.length),ji(this.axes,s.shape.length)],this.normalize&&(t=Ul(t,o[0]),s=Ul(s,o[1])),hR(t,s,o)}interpretAxes(e,t){let s;return Array.isArray(this.axes)?s=this.axes:s=[ji(this.axes,e.length),ji(this.axes,t.length)],s}computeOutputShape(e){$(Array.isArray(e)&&e.length===2&&Array.isArray(e[0])&&Array.isArray(e[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");const t=e[0].slice(),s=e[1].slice();if(t.length>3||s.length>3)throw new Ce("Dot layer does not support tensors of 4D or higher rank yet.");const o=this.interpretAxes(t,s);t.splice(o[0],1),s.splice(o[1],1),s.splice(0,1);const r=t.concat(s);return r.length===1&&r.push(1),r}computeMask(e,t){return null}getConfig(){const e={axes:this.axes,normalize:this.normalize},t=super.getConfig();return Object.assign(e,t),e}}zb.className="Dot",Z(zb);/** + */class yo extends ke{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new Ce}computeElementwiseOpOutputShape(e,t){if(e==null||t==null)return null;if(e.length1)throw new A(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let s=e[0]==null?null:e[0].slice(1);for(let r=1;rr.length);e.indexOf(null)===-1&&Ss(o).length===1?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return P(()=>{if(e=e,this.reshapeRequired){const s=[],o=e.map(r=>r.rank);if(o.indexOf(null)===-1){const r=Ns(o);for(let i of e){const a=i.rank;for(let l=0;l1){const u=Rn(1,c).concat([0]);s.push(Ee(l,u)),r=!0}else s.push(l)}let i=this.mergeFunction(s);const a=i.rank;if(r){if(a==null){const l=i.shape,c=l.length,u=l[c-1],h=[u].concat(l.slice(0,l.length-1));i=_(Ee(_(i,[-1,u]),[1,0]),h)}else if(a>1){const l=[a-1].concat(Rn(0,a-1));i=Ee(i,l)}}return i}}else return this.mergeFunction(e)})}computeOutputShape(e){e=e;let t;e[0]==null?t=null:t=e[0].slice(1);for(let o=1;o{if(t==null)return null;if(!Array.isArray(t))throw new A("`mask` should be an Array");if(!Array.isArray(e))throw new A("`inputs` should be an Array");if(t.length!==e.length)throw new A(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every(o=>o==null))return null;t=t.map(o=>o==null?o:Gt(o,0));let s=t[0];for(let o=1;o{let t=e[0].clone();for(let s=1;s{let t=e[0].clone();for(let s=1;s{let t=e[0].clone();for(let s=1;s{let t=e[0];for(let s=1;s{let t=e[0];for(let s=1;s1)throw new A("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return P(()=>Cd(e,this.axis))}computeOutputShape(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))throw new A("A `Concatenate` layer should be called on a list of inputs.");const t=e,s=t[0].slice(),o=this.axis<0?s.length+this.axis:this.axis;for(const r of t.slice(1)){if(s[o]==null||r[o]==null){s[o]=null;break}s[o]+=r[o]}return s}computeMask(e,t){if(t==null)return null;if(!Array.isArray(t))throw new A("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new A("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new A(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return P(()=>{let s=!0;if(t.forEach(i=>{if(i!=null){s=!1;return}}),s)return null;const o=[];for(let i=0;i3||e.shape.length>3)throw new Ce("batchDot is not implemented for tensors of 4D or higher rank yet");if($(n.shape.length>=2,()=>`batchDot requires the rank of x to be >= 2, but got ${n.shape.length}`),$(n.shape.length>=2,()=>`batchDot requires the rank of y to be >= 2, but got ${e.shape.length}`),typeof t=="number"&&(t=[t,t]),n.dtype==="complex64"||e.dtype==="complex64")throw new Ce("batchDot is not implemented for complex64-type Tensors yet.");const s=n.shape.length,o=e.shape.length;t==null&&(t=[s-1,o-2]);const r=t;return P(()=>{let i;if(s>o){i=s-o;const l=[];for(let c=0;cs){i=o-s;const l=[];for(let c=0;c0){let l;s>o?l=s+o-3:l=s-1;const c=[];for(let u=l;u"A `Dot` layer should be called on a list of exactly 2 inputs.");const t=e[0],s=e[1];if(t.length>3||s.length>3)throw new Ce("Dot layer does not support tensors of 4D or higher rank yet.");const o=this.interpretAxes(t,s);if(t[o[0]]!==s[o[1]])throw new A(`Dimension incompatibility: ${t[o[0]]} !== ${s[o[1]]}`)}mergeFunction(e){if(e.length!==2)throw new A(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let t=e[0],s=e[1],o;return Array.isArray(this.axes)?o=this.axes.map((r,i)=>qi(r,e[i].shape.length)):o=[qi(this.axes,t.shape.length),qi(this.axes,s.shape.length)],this.normalize&&(t=Gl(t,o[0]),s=Gl(s,o[1])),pR(t,s,o)}interpretAxes(e,t){let s;return Array.isArray(this.axes)?s=this.axes:s=[qi(this.axes,e.length),qi(this.axes,t.length)],s}computeOutputShape(e){$(Array.isArray(e)&&e.length===2&&Array.isArray(e[0])&&Array.isArray(e[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");const t=e[0].slice(),s=e[1].slice();if(t.length>3||s.length>3)throw new Ce("Dot layer does not support tensors of 4D or higher rank yet.");const o=this.interpretAxes(t,s);t.splice(o[0],1),s.splice(o[1],1),s.splice(0,1);const r=t.concat(s);return r.length===1&&r.push(1),r}computeMask(e,t){return null}getConfig(){const e={axes:this.axes,normalize:this.normalize},t=super.getConfig();return Object.assign(e,t),e}}Ub.className="Dot",Y(Ub);/** * @license * Copyright 2018 Google LLC * @@ -7816,7 +7816,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class Vb extends ke{constructor(e){super(e),this.supportsMasking=!0,this.stddev=e.stddev}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={stddev:this.stddev};return Object.assign(t,e),t}call(e,t){return z(()=>{this.invokeCallHook(e,t);const s=xe(e);return Li(()=>ee(Ml(s.shape,0,this.stddev),s),()=>s,t.training||!1)})}}Vb.className="GaussianNoise",Z(Vb);class Wb extends ke{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return z(()=>{this.invokeCallHook(e,t);const s=xe(e);return this.rate>0&&this.rate<1?Li(()=>{const r=Math.sqrt(this.rate/(1-this.rate));return F(s,Ml(s.shape,1,r))},()=>s,t.training||!1):s})}}Wb.className="GaussianDropout",Z(Wb);class Ub extends ke{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||xe(e).shape}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return z(()=>{if(this.rate<1&&this.rate>0){const s=this._getNoiseShape(e);return Li(()=>{const r=xe(e),l=-1.6732632423543772*1.0507009873554805;let c=io(Si(s),this.rate);c=Kn(c,"float32");const u=((1-this.rate)*(1+this.rate*l**2))**-.5,h=-u*l*this.rate,d=ee(F(r,c),F(ee(c,-1),l));return ee(F(d,u),h)},()=>xe(e),t.training||!1)}return e})}}Ub.className="AlphaDropout",Z(Ub);/** + */class Gb extends ke{constructor(e){super(e),this.supportsMasking=!0,this.stddev=e.stddev}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={stddev:this.stddev};return Object.assign(t,e),t}call(e,t){return P(()=>{this.invokeCallHook(e,t);const s=xe(e);return Li(()=>ee(Pl(s.shape,0,this.stddev),s),()=>s,t.training||!1)})}}Gb.className="GaussianNoise",Y(Gb);class Hb extends ke{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return P(()=>{this.invokeCallHook(e,t);const s=xe(e);return this.rate>0&&this.rate<1?Li(()=>{const r=Math.sqrt(this.rate/(1-this.rate));return D(s,Pl(s.shape,1,r))},()=>s,t.training||!1):s})}}Hb.className="GaussianDropout",Y(Hb);class qb extends ke{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||xe(e).shape}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return P(()=>{if(this.rate<1&&this.rate>0){const s=this._getNoiseShape(e);return Li(()=>{const r=xe(e),l=-1.6732632423543772*1.0507009873554805;let c=ao(Si(s),this.rate);c=Kn(c,"float32");const u=((1-this.rate)*(1+this.rate*l**2))**-.5,h=-u*l*this.rate,d=ee(D(r,c),D(ee(c,-1),l));return ee(D(d,u),h)},()=>xe(e),t.training||!1)}return e})}}qb.className="AlphaDropout",Y(qb);/** * @license * Copyright 2018 Google LLC * @@ -7824,7 +7824,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function qi(n,e,t,s,o,r=.001){let i;if(n.rank===2)i=LI(n,e,t,s,o,r);else if(n.rank===3)i=PI(n,e,t,s,o,r);else if(n.rank===4)i=zI(n,e,t,s,o,r);else throw new Ce(`batchNormalization is not implemented for array of rank ${n.rank} yet`);return i}function dR(n,e,t,s,o=.001){return z(()=>{const r=ph(n,s),i=r.mean,a=r.variance;return[qi(n,i,a,t,e,o),i,a]})}function pR(n,e,t,s,o=.001){return z(()=>{const r=ph(n,s),i=r.mean,a=r.variance,l=[];for(const f of Rn(0,n.rank))s.indexOf(f)!==-1?l.push(1):l.push(n.shape[f]);const c=_(i,l),u=_(a,l),h=e==null?null:_(e,l),d=t==null?null:_(t,l);return[qi(n,c,u,d,h,o),i,a]})}function fR(n,e,t,s,o=.001){return Oe(s.slice().sort(),Rn(0,n.rank-1))?dR(n,e,t,s,o):pR(n,e,t,s,o)}class Gb extends ke{constructor(e){e==null&&(e={}),super(e),this.supportsMasking=!0,this.axis=e.axis==null?-1:e.axis,this.momentum=e.momentum==null?.99:e.momentum,this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=qe(e.betaInitializer||"zeros"),this.gammaInitializer=qe(e.gammaInitializer||"ones"),this.movingMeanInitializer=qe(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=qe(e.movingVarianceInitializer||"ones"),this.betaConstraint=pt(e.betaConstraint),this.gammaConstraint=pt(e.gammaConstraint),this.betaRegularizer=Ke(e.betaRegularizer),this.gammaRegularizer=Ke(e.gammaRegularizer)}build(e){e=_e(e);const t=this.axis>=0?this.axis:this.axis+e.length,s=e[t];if(s==null)throw new A(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new ht({ndim:e.length,axes:{[t]:s}})];const o=[s];this.scale&&(this.gamma=this.addWeight("gamma",o,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",o,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",o,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",o,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return z(()=>{const s=t.training==null?!1:t.training,o=xe(e),r=o.shape,i=r.length,a=Rn(0,i),l=this.axis>=0?this.axis:this.axis+i;a.splice(l,1);const c=ho(1,i);c[l]=r[l];const u=a.slice();u.sort();const h=!Oe(u,Rn(0,i).slice(0,i-1)),d=()=>{if(h){const b=_(this.movingMean.read(),c),w=_(this.movingVariance.read(),c),y=this.center?_(this.beta.read(),c):null,C=this.scale?_(this.gamma.read(),c):null;return qi(o,b,w,y,C,this.epsilon)}else return qi(o,this.movingMean.read(),this.movingVariance.read(),this.beta==null?null:this.beta.read(),this.gamma==null?null:this.gamma.read(),this.epsilon)};if(!s)return d();const[p,f,g]=fR(o,this.gamma.read(),this.beta.read(),a,this.epsilon),m=(b,w,y)=>{z(()=>{const C=1-y,I=b.read(),v=F(ge(I,w),C);b.write(ge(I,v))})};return(()=>{m(this.movingMean,f,this.momentum),m(this.movingVariance,g,this.momentum)})(),p})}getConfig(){const e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Ze(this.betaInitializer),gammaInitializer:Ze(this.gammaInitializer),movingMeanInitializer:Ze(this.movingMeanInitializer),movingVarianceInitializer:Ze(this.movingVarianceInitializer),betaRegularizer:ze(this.betaRegularizer),gammaRegularizer:ze(this.gammaRegularizer),betaConstraint:dt(this.betaConstraint),gammaConstraint:dt(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}}Gb.className="BatchNormalization",Z(Gb);class Hb extends ke{constructor(e){if(e==null&&(e={}),super(e),this.axis=e.axis==null?-1:e.axis,typeof this.axis=="number"){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else if(Array.isArray(this.axis)){for(const t of this.axis)if(!Number.isInteger(t))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}else throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=qe(e.betaInitializer||"zeros"),this.gammaInitializer=qe(e.gammaInitializer||"ones"),this.betaRegularizer=Ke(e.betaRegularizer),this.gammaRegularizer=Ke(e.gammaRegularizer),this.supportsMasking=!0}build(e){e=_e(e);const t=e.length;typeof this.axis=="number"&&(this.axis=[this.axis]);for(let r=0;r=t)throw new Error(`Invalid axis: ${r}`);if(this.axis.length!==Ss(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const s=this.axis.map(r=>e[r]),o=!0;this.scale?this.gamma=this.addWeight("gamma",s,"float32",this.gammaInitializer,this.gammaRegularizer,o):this.gamma=null,this.center?this.beta=this.addWeight("beta",s,"float32",this.betaInitializer,this.betaRegularizer,o):this.beta=null,this.built=!0}call(e,t){const s=xe(e),o=s.shape,r=o.length;return z(()=>{let{mean:a,variance:l}=ph(s,this.axis,!0);const c=ho(1,r);for(const g of this.axis)c[g]=o[g];const u=g=>g!=null&&g.shape.length!==r?_(g,c):g;let h=this.scale?u(this.gamma.read()):null,d=this.center?u(this.beta.read()):null;const p=[],f=[];for(let g=0;g{const r=ph(n,s),i=r.mean,a=r.variance;return[ji(n,i,a,t,e,o),i,a]})}function mR(n,e,t,s,o=.001){return P(()=>{const r=ph(n,s),i=r.mean,a=r.variance,l=[];for(const f of Rn(0,n.rank))s.indexOf(f)!==-1?l.push(1):l.push(n.shape[f]);const c=_(i,l),u=_(a,l),h=e==null?null:_(e,l),d=t==null?null:_(t,l);return[ji(n,c,u,d,h,o),i,a]})}function gR(n,e,t,s,o=.001){return Oe(s.slice().sort(),Rn(0,n.rank-1))?fR(n,e,t,s,o):mR(n,e,t,s,o)}class jb extends ke{constructor(e){e==null&&(e={}),super(e),this.supportsMasking=!0,this.axis=e.axis==null?-1:e.axis,this.momentum=e.momentum==null?.99:e.momentum,this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=je(e.betaInitializer||"zeros"),this.gammaInitializer=je(e.gammaInitializer||"ones"),this.movingMeanInitializer=je(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=je(e.movingVarianceInitializer||"ones"),this.betaConstraint=pt(e.betaConstraint),this.gammaConstraint=pt(e.gammaConstraint),this.betaRegularizer=Ke(e.betaRegularizer),this.gammaRegularizer=Ke(e.gammaRegularizer)}build(e){e=_e(e);const t=this.axis>=0?this.axis:this.axis+e.length,s=e[t];if(s==null)throw new A(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new ht({ndim:e.length,axes:{[t]:s}})];const o=[s];this.scale&&(this.gamma=this.addWeight("gamma",o,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",o,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",o,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",o,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return P(()=>{const s=t.training==null?!1:t.training,o=xe(e),r=o.shape,i=r.length,a=Rn(0,i),l=this.axis>=0?this.axis:this.axis+i;a.splice(l,1);const c=po(1,i);c[l]=r[l];const u=a.slice();u.sort();const h=!Oe(u,Rn(0,i).slice(0,i-1)),d=()=>{if(h){const b=_(this.movingMean.read(),c),w=_(this.movingVariance.read(),c),y=this.center?_(this.beta.read(),c):null,C=this.scale?_(this.gamma.read(),c):null;return ji(o,b,w,y,C,this.epsilon)}else return ji(o,this.movingMean.read(),this.movingVariance.read(),this.beta==null?null:this.beta.read(),this.gamma==null?null:this.gamma.read(),this.epsilon)};if(!s)return d();const[p,f,g]=gR(o,this.gamma.read(),this.beta.read(),a,this.epsilon),m=(b,w,y)=>{P(()=>{const C=1-y,I=b.read(),v=D(ge(I,w),C);b.write(ge(I,v))})};return(()=>{m(this.movingMean,f,this.momentum),m(this.movingVariance,g,this.momentum)})(),p})}getConfig(){const e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Ze(this.betaInitializer),gammaInitializer:Ze(this.gammaInitializer),movingMeanInitializer:Ze(this.movingMeanInitializer),movingVarianceInitializer:Ze(this.movingVarianceInitializer),betaRegularizer:ze(this.betaRegularizer),gammaRegularizer:ze(this.gammaRegularizer),betaConstraint:dt(this.betaConstraint),gammaConstraint:dt(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}}jb.className="BatchNormalization",Y(jb);class Kb extends ke{constructor(e){if(e==null&&(e={}),super(e),this.axis=e.axis==null?-1:e.axis,typeof this.axis=="number"){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else if(Array.isArray(this.axis)){for(const t of this.axis)if(!Number.isInteger(t))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}else throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=je(e.betaInitializer||"zeros"),this.gammaInitializer=je(e.gammaInitializer||"ones"),this.betaRegularizer=Ke(e.betaRegularizer),this.gammaRegularizer=Ke(e.gammaRegularizer),this.supportsMasking=!0}build(e){e=_e(e);const t=e.length;typeof this.axis=="number"&&(this.axis=[this.axis]);for(let r=0;r=t)throw new Error(`Invalid axis: ${r}`);if(this.axis.length!==Ss(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const s=this.axis.map(r=>e[r]),o=!0;this.scale?this.gamma=this.addWeight("gamma",s,"float32",this.gammaInitializer,this.gammaRegularizer,o):this.gamma=null,this.center?this.beta=this.addWeight("beta",s,"float32",this.betaInitializer,this.betaRegularizer,o):this.beta=null,this.built=!0}call(e,t){const s=xe(e),o=s.shape,r=o.length;return P(()=>{let{mean:a,variance:l}=ph(s,this.axis,!0);const c=po(1,r);for(const g of this.axis)c[g]=o[g];const u=g=>g!=null&&g.shape.length!==r?_(g,c):g;let h=this.scale?u(this.gamma.read()):null,d=this.center?u(this.beta.read()):null;const p=[],f=[];for(let g=0;g{if(n.rank!==4)throw new A(`temporalPadding expects input tensor to be 4-D, but received a ${n.rank}-D tensor.`);if(e==null&&(e=[[1,1],[1,1]]),e.length!==2||e[0].length!==2||e[1].length!==2)throw new A("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(t==null&&(t=An()),t!=="channelsLast"&&t!=="channelsFirst")throw new A(`Unknown data format: ${t}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let s;return t==="channelsFirst"?s=[[0,0],[0,0],e[0],e[1]]:s=[[0,0],e[0],e[1],[0,0]],fh(n,s)})}class jb extends ke{constructor(e){if(e==null&&(e={}),super(e),this.dataFormat=e.dataFormat==null?An():e.dataFormat,e.padding==null)this.padding=[[1,1],[1,1]];else if(typeof e.padding=="number")this.padding=[[e.padding,e.padding],[e.padding,e.padding]];else{if(e.padding=e.padding,e.padding.length!==2)throw new A(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${e.padding.length} array.`);let t,s;if(typeof e.padding[0]=="number")t=[e.padding[0],e.padding[0]],s=[e.padding[1],e.padding[1]];else{if(e.padding=e.padding,e.padding[0].length!==2)throw new A(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${e.padding[0].length} array.`);if(t=e.padding[0],e.padding[1].length!==2)throw new A(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${e.padding[1].length} array.`);s=e.padding[1]}this.padding=[t,s]}this.inputSpec=[new ht({ndim:4})]}computeOutputShape(e){e=_e(e);let t,s;return this.dataFormat==="channelsFirst"?(e[2]!=null&&e[2]>=0?t=e[2]+this.padding[0][0]+this.padding[0][1]:t=null,e[3]!=null&&e[3]>=0?s=e[3]+this.padding[1][0]+this.padding[1][1]:s=null,[e[0],e[1],t,s]):(e[1]!=null&&e[1]>=0?t=e[1]+this.padding[0][0]+this.padding[0][1]:t=null,e[2]!=null&&e[2]>=0?s=e[2]+this.padding[1][0]+this.padding[1][1]:s=null,[e[0],t,s,e[3]])}call(e,t){return z(()=>mR(xe(e),this.padding,this.dataFormat))}getConfig(){const e={padding:this.padding,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}jb.className="ZeroPadding2D",Z(jb);/** + */function xR(n,e,t){return P(()=>{if(n.rank!==4)throw new A(`temporalPadding expects input tensor to be 4-D, but received a ${n.rank}-D tensor.`);if(e==null&&(e=[[1,1],[1,1]]),e.length!==2||e[0].length!==2||e[1].length!==2)throw new A("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(t==null&&(t=An()),t!=="channelsLast"&&t!=="channelsFirst")throw new A(`Unknown data format: ${t}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let s;return t==="channelsFirst"?s=[[0,0],[0,0],e[0],e[1]]:s=[[0,0],e[0],e[1],[0,0]],fh(n,s)})}class Xb extends ke{constructor(e){if(e==null&&(e={}),super(e),this.dataFormat=e.dataFormat==null?An():e.dataFormat,e.padding==null)this.padding=[[1,1],[1,1]];else if(typeof e.padding=="number")this.padding=[[e.padding,e.padding],[e.padding,e.padding]];else{if(e.padding=e.padding,e.padding.length!==2)throw new A(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${e.padding.length} array.`);let t,s;if(typeof e.padding[0]=="number")t=[e.padding[0],e.padding[0]],s=[e.padding[1],e.padding[1]];else{if(e.padding=e.padding,e.padding[0].length!==2)throw new A(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${e.padding[0].length} array.`);if(t=e.padding[0],e.padding[1].length!==2)throw new A(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${e.padding[1].length} array.`);s=e.padding[1]}this.padding=[t,s]}this.inputSpec=[new ht({ndim:4})]}computeOutputShape(e){e=_e(e);let t,s;return this.dataFormat==="channelsFirst"?(e[2]!=null&&e[2]>=0?t=e[2]+this.padding[0][0]+this.padding[0][1]:t=null,e[3]!=null&&e[3]>=0?s=e[3]+this.padding[1][0]+this.padding[1][1]:s=null,[e[0],e[1],t,s]):(e[1]!=null&&e[1]>=0?t=e[1]+this.padding[0][0]+this.padding[0][1]:t=null,e[2]!=null&&e[2]>=0?s=e[2]+this.padding[1][0]+this.padding[1][1]:s=null,[e[0],t,s,e[3]])}call(e,t){return P(()=>xR(xe(e),this.padding,this.dataFormat))}getConfig(){const e={padding:this.padding,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}Xb.className="ZeroPadding2D",Y(Xb);/** * @license * Copyright 2018 Google LLC * @@ -7840,7 +7840,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function nc(n,e,t,s,o,r){return z(()=>{ot(o),Hg(r),on(s),t==null&&(t=[1,1]),s==null&&(s="valid"),o==null&&(o=An()),r==null&&(r="max"),n=jd(n,o);let i;const a=s==="same"?"same":"valid";return r==="max"?i=dh(n,e,t,a):i=Ju(n,e,t,a),o==="channelsFirst"&&(i=Ee(i,[0,3,1,2])),i})}function qb(n,e,t,s,o,r){return z(()=>{ot(o),Hg(r),on(s),t==null&&(t=[1,1,1]),s==null&&(s="valid"),o==null&&(o=An()),r==null&&(r="max"),n=cb(n,o);let i;const a=s==="same"?"same":"valid";return r==="max"?i=vv(n,e,t,a):i=SI(n,e,t,a),o==="channelsFirst"&&(i=Ee(i,[0,4,1,2,3])),i})}class Kb extends ke{constructor(e){if(e.poolSize==null&&(e.poolSize=2),super(e),typeof e.poolSize=="number")this.poolSize=[e.poolSize];else if(Array.isArray(e.poolSize)&&e.poolSize.length===1&&typeof e.poolSize[0]=="number")this.poolSize=e.poolSize;else throw new A(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);if(bt(this.poolSize,"poolSize"),e.strides==null)this.strides=this.poolSize;else if(typeof e.strides=="number")this.strides=[e.strides];else if(Array.isArray(e.strides)&&e.strides.length===1&&typeof e.strides[0]=="number")this.strides=e.strides;else throw new A(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);bt(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,on(this.padding),this.inputSpec=[new ht({ndim:3})]}computeOutputShape(e){e=_e(e);const t=On(e[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return z(()=>{this.invokeCallHook(e,t),e=_i(xe(e),2);const s=this.poolingFunction(xe(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return Xo(s,[2])})}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}}class Xb extends Kb{constructor(e){super(e)}poolingFunction(e,t,s,o,r){return ot(r),on(o),nc(e,t,s,o,r,"max")}}Xb.className="MaxPooling1D",Z(Xb);class Yb extends Kb{constructor(e){super(e)}poolingFunction(e,t,s,o,r){return ot(r),on(o),nc(e,t,s,o,r,"avg")}}Yb.className="AveragePooling1D",Z(Yb);class Zb extends ke{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==2)throw new A(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides];bt(this.poolSize,"poolSize"),bt(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,ot(this.dataFormat),on(this.padding),this.inputSpec=[new ht({ndim:4})]}computeOutputShape(e){e=_e(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2];return t=On(t,this.poolSize[0],this.padding,this.strides[0]),s=On(s,this.poolSize[1],this.padding,this.strides[1]),this.dataFormat==="channelsFirst"?[e[0],e[1],t,s]:[e[0],t,s,e[3]]}call(e,t){return z(()=>(this.invokeCallHook(e,t),this.poolingFunction(xe(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class Qb extends Zb{constructor(e){super(e)}poolingFunction(e,t,s,o,r){return ot(r),on(o),nc(e,t,s,o,r,"max")}}Qb.className="MaxPooling2D",Z(Qb);class Jb extends Zb{constructor(e){super(e)}poolingFunction(e,t,s,o,r){return ot(r),on(o),nc(e,t,s,o,r,"avg")}}Jb.className="AveragePooling2D",Z(Jb);class e0 extends ke{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==3)throw new A(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides,e.strides];bt(this.poolSize,"poolSize"),bt(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,ot(this.dataFormat),on(this.padding),this.inputSpec=[new ht({ndim:5})]}computeOutputShape(e){e=_e(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2],o=this.dataFormat==="channelsFirst"?e[4]:e[3];return t=On(t,this.poolSize[0],this.padding,this.strides[0]),s=On(s,this.poolSize[1],this.padding,this.strides[1]),o=On(o,this.poolSize[2],this.padding,this.strides[2]),this.dataFormat==="channelsFirst"?[e[0],e[1],t,s,o]:[e[0],t,s,o,e[4]]}call(e,t){return z(()=>(this.invokeCallHook(e,t),this.poolingFunction(xe(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class t0 extends e0{constructor(e){super(e)}poolingFunction(e,t,s,o,r){return ot(r),on(o),qb(e,t,s,o,r,"max")}}t0.className="MaxPooling3D",Z(t0);class n0 extends e0{constructor(e){super(e)}poolingFunction(e,t,s,o,r){return ot(r),on(o),qb(e,t,s,o,r,"avg")}}n0.className="AveragePooling3D",Z(n0);class s0 extends ke{constructor(e){super(e),this.inputSpec=[new ht({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new Ce}}class o0 extends s0{constructor(e){super(e||{})}call(e,t){return z(()=>{const s=xe(e);return at(s,1)})}}o0.className="GlobalAveragePooling1D",Z(o0);class r0 extends s0{constructor(e){super(e||{})}call(e,t){return z(()=>{const s=xe(e);return Sn(s,1)})}}r0.className="GlobalMaxPooling1D",Z(r0);class i0 extends ke{constructor(e){super(e),this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,ot(this.dataFormat),this.inputSpec=[new ht({ndim:4})]}computeOutputShape(e){return e=e,this.dataFormat==="channelsLast"?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new Ce}getConfig(){const e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class a0 extends i0{call(e,t){return z(()=>{const s=xe(e);return this.dataFormat==="channelsLast"?at(s,[1,2]):at(s,[2,3])})}}a0.className="GlobalAveragePooling2D",Z(a0);class l0 extends i0{call(e,t){return z(()=>{const s=xe(e);return this.dataFormat==="channelsLast"?Sn(s,[1,2]):Sn(s,[2,3])})}}l0.className="GlobalMaxPooling2D",Z(l0);/** + */function sc(n,e,t,s,o,r){return P(()=>{ot(o),qg(r),on(s),t==null&&(t=[1,1]),s==null&&(s="valid"),o==null&&(o=An()),r==null&&(r="max"),n=qd(n,o);let i;const a=s==="same"?"same":"valid";return r==="max"?i=dh(n,e,t,a):i=eh(n,e,t,a),o==="channelsFirst"&&(i=Ee(i,[0,3,1,2])),i})}function Yb(n,e,t,s,o,r){return P(()=>{ot(o),qg(r),on(s),t==null&&(t=[1,1,1]),s==null&&(s="valid"),o==null&&(o=An()),r==null&&(r="max"),n=db(n,o);let i;const a=s==="same"?"same":"valid";return r==="max"?i=Sv(n,e,t,a):i=EI(n,e,t,a),o==="channelsFirst"&&(i=Ee(i,[0,4,1,2,3])),i})}class Zb extends ke{constructor(e){if(e.poolSize==null&&(e.poolSize=2),super(e),typeof e.poolSize=="number")this.poolSize=[e.poolSize];else if(Array.isArray(e.poolSize)&&e.poolSize.length===1&&typeof e.poolSize[0]=="number")this.poolSize=e.poolSize;else throw new A(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);if(bt(this.poolSize,"poolSize"),e.strides==null)this.strides=this.poolSize;else if(typeof e.strides=="number")this.strides=[e.strides];else if(Array.isArray(e.strides)&&e.strides.length===1&&typeof e.strides[0]=="number")this.strides=e.strides;else throw new A(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);bt(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,on(this.padding),this.inputSpec=[new ht({ndim:3})]}computeOutputShape(e){e=_e(e);const t=On(e[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return P(()=>{this.invokeCallHook(e,t),e=_i(xe(e),2);const s=this.poolingFunction(xe(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return Xo(s,[2])})}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}}class Qb extends Zb{constructor(e){super(e)}poolingFunction(e,t,s,o,r){return ot(r),on(o),sc(e,t,s,o,r,"max")}}Qb.className="MaxPooling1D",Y(Qb);class Jb extends Zb{constructor(e){super(e)}poolingFunction(e,t,s,o,r){return ot(r),on(o),sc(e,t,s,o,r,"avg")}}Jb.className="AveragePooling1D",Y(Jb);class e0 extends ke{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==2)throw new A(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides];bt(this.poolSize,"poolSize"),bt(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,ot(this.dataFormat),on(this.padding),this.inputSpec=[new ht({ndim:4})]}computeOutputShape(e){e=_e(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2];return t=On(t,this.poolSize[0],this.padding,this.strides[0]),s=On(s,this.poolSize[1],this.padding,this.strides[1]),this.dataFormat==="channelsFirst"?[e[0],e[1],t,s]:[e[0],t,s,e[3]]}call(e,t){return P(()=>(this.invokeCallHook(e,t),this.poolingFunction(xe(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class t0 extends e0{constructor(e){super(e)}poolingFunction(e,t,s,o,r){return ot(r),on(o),sc(e,t,s,o,r,"max")}}t0.className="MaxPooling2D",Y(t0);class n0 extends e0{constructor(e){super(e)}poolingFunction(e,t,s,o,r){return ot(r),on(o),sc(e,t,s,o,r,"avg")}}n0.className="AveragePooling2D",Y(n0);class s0 extends ke{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==3)throw new A(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides,e.strides];bt(this.poolSize,"poolSize"),bt(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,ot(this.dataFormat),on(this.padding),this.inputSpec=[new ht({ndim:5})]}computeOutputShape(e){e=_e(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2],o=this.dataFormat==="channelsFirst"?e[4]:e[3];return t=On(t,this.poolSize[0],this.padding,this.strides[0]),s=On(s,this.poolSize[1],this.padding,this.strides[1]),o=On(o,this.poolSize[2],this.padding,this.strides[2]),this.dataFormat==="channelsFirst"?[e[0],e[1],t,s,o]:[e[0],t,s,o,e[4]]}call(e,t){return P(()=>(this.invokeCallHook(e,t),this.poolingFunction(xe(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class o0 extends s0{constructor(e){super(e)}poolingFunction(e,t,s,o,r){return ot(r),on(o),Yb(e,t,s,o,r,"max")}}o0.className="MaxPooling3D",Y(o0);class r0 extends s0{constructor(e){super(e)}poolingFunction(e,t,s,o,r){return ot(r),on(o),Yb(e,t,s,o,r,"avg")}}r0.className="AveragePooling3D",Y(r0);class i0 extends ke{constructor(e){super(e),this.inputSpec=[new ht({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new Ce}}class a0 extends i0{constructor(e){super(e||{})}call(e,t){return P(()=>{const s=xe(e);return at(s,1)})}}a0.className="GlobalAveragePooling1D",Y(a0);class l0 extends i0{constructor(e){super(e||{})}call(e,t){return P(()=>{const s=xe(e);return Sn(s,1)})}}l0.className="GlobalMaxPooling1D",Y(l0);class c0 extends ke{constructor(e){super(e),this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,ot(this.dataFormat),this.inputSpec=[new ht({ndim:4})]}computeOutputShape(e){return e=e,this.dataFormat==="channelsLast"?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new Ce}getConfig(){const e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class u0 extends c0{call(e,t){return P(()=>{const s=xe(e);return this.dataFormat==="channelsLast"?at(s,[1,2]):at(s,[2,3])})}}u0.className="GlobalAveragePooling2D",Y(u0);class h0 extends c0{call(e,t){return P(()=>{const s=xe(e);return this.dataFormat==="channelsLast"?Sn(s,[1,2]):Sn(s,[2,3])})}}h0.className="GlobalMaxPooling2D",Y(h0);/** * @license * Copyright 2018 Google LLC * @@ -7848,7 +7848,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class c0 extends ke{constructor(e){super(e),this.layer=e.layer}build(e){this.built=!0}get trainable(){return this.layer!=null?this.layer.trainable:!1}set trainable(e){this.layer!=null&&(this.layer.trainable=e)}get trainableWeights(){return this.layer.trainableWeights}get nonTrainableWeights(){return this.layer.nonTrainableWeights}get updates(){return this.layer._updates}get losses(){return this.layer.losses}getWeights(){return this.layer.getWeights()}setWeights(e){this.layer.setWeights(e)}getConfig(){const e={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},t=super.getConfig();return Object.assign(e,t),e}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.layer!=null&&this.layer.setFastWeightInitDuringBuild(e)}static fromConfig(e,t,s={}){const o=t.layer,r=Zn(o,s);delete t.layer;const i={layer:r};return Object.assign(i,t),new e(i)}}class u0 extends c0{constructor(e){super(e),this.supportsMasking=!0}build(e){if(e=_e(e),e.length<3)throw new A(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(e)}`);this.inputSpec=[{shape:e}];const t=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(t),this.layer.built=!0),super.build(e)}computeOutputShape(e){e=_e(e);const t=[e[0]].concat(e.slice(2)),s=this.layer.computeOutputShape(t),o=e[1];return[s[0],o].concat(s.slice(1))}call(e,t){return z(()=>(e=xe(e),yb((i,a)=>[xe(this.layer.call(i,t)),[]],e,[],!1,null,null,!1,!0)[1]))}}u0.className="TimeDistributed",Z(u0);function gR(n){fo(ON,"BidirectionalMergeMode",n)}const xR="concat";class h0 extends c0{constructor(e){super(e);const t=e.layer.getConfig(),s={};s.className=e.layer.getClassName(),s.config=t,this.forwardLayer=Zn(s),t.goBackwards=t.goBackwards!==!0;const o={};if(o.className=e.layer.getClassName(),o.config=t,this.backwardLayer=Zn(o),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=e.mergeMode===void 0?xR:e.mergeMode,gR(this.mergeMode),e.weights)throw new Ce("weights support is not implemented for Bidirectional layer yet.");this._stateful=e.layer.stateful,this.returnSequences=e.layer.returnSequences,this.returnState=e.layer.returnState,this.supportsMasking=!0,this._trainable=!0,this.inputSpec=e.layer.inputSpec,this.numConstants=null}get trainable(){return this._trainable}set trainable(e){this._trainable=e,this.forwardLayer!=null&&(this.forwardLayer.trainable=e),this.backwardLayer!=null&&(this.backwardLayer.trainable=e)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(e){const t=e.length,s=Math.floor(t/2);this.forwardLayer.setWeights(e.slice(0,s)),this.backwardLayer.setWeights(e.slice(s))}computeOutputShape(e){let t=this.forwardLayer.computeOutputShape(e);Array.isArray(t)&&Array.isArray(t[0])||(t=[t]),t=t;let s,o,r;return this.returnState&&(r=t.slice(1)),s=t[0],s=s,this.mergeMode==="concat"?(s[s.length-1]*=2,o=[s]):this.mergeMode==null?o=[s,s.slice()]:o=[s],this.returnState?this.mergeMode==null?o.concat(r).concat(r.slice()):[s].concat(r).concat(r.slice()):Gt(o)}apply(e,t){let s=t==null?null:t.initialState,o=t==null?null:t.constants;t==null&&(t={});const r=bb(e,s,o,this.numConstants);if(e=r.inputs,s=r.initialState,o=r.constants,Array.isArray(e)&&(s=e.slice(1),e=e[0]),(s==null||s.length===0)&&o==null)return super.apply(e,t);const i=[],a=[];if(s!=null){const c=s.length;if(c%2>0)throw new A("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");t.initialState=s,i.push(...s);const u=s.map(h=>new ht({shape:h.shape}));this.forwardLayer.stateSpec=u.slice(0,c/2),this.backwardLayer.stateSpec=u.slice(c/2),a.push(...u)}if(o!=null)throw new Ce("Support for constants in Bidirectional layers is not implemented yet.");const l=i[0]instanceof Yn;for(const c of i)if(c instanceof Yn!==l)throw new A("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(l){const c=[e].concat(i),u=this.inputSpec.concat(a),h=this.inputSpec;this.inputSpec=u;const d=super.apply(c,t);return this.inputSpec=h,d}else return super.apply(e,t)}call(e,t){return z(()=>{const s=t.initialState;let o,r;if(s==null)o=this.forwardLayer.call(e,t),r=this.backwardLayer.call(e,t);else{const l=s.slice(0,s.length/2),c=s.slice(s.length/2);o=this.forwardLayer.call(e,Object.assign(t,{initialState:l})),r=this.backwardLayer.call(e,Object.assign(t,{initialState:c}))}let i;this.returnState&&(Array.isArray(o)&&(i=o.slice(1).concat(r.slice(1))),o=o[0],r=r[0]),this.returnSequences&&(r=co(r,1));let a;return this.mergeMode==="concat"?a=Cd([o,r]):this.mergeMode==="sum"?a=ee(o,r):this.mergeMode==="ave"?a=F(.5,ee(o,r)):this.mergeMode==="mul"?a=F(o,r):this.mergeMode==null&&(a=[o,r]),this.returnState?this.mergeMode==null?a.concat(i):[a].concat(i):a})}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){mo(this.forwardLayer.name,()=>{this.forwardLayer.build(e)}),mo(this.backwardLayer.name,()=>{this.backwardLayer.build(e)}),this.built=!0}computeMask(e,t){Array.isArray(t)&&(t=t[0]);let s;if(this.returnSequences?this.mergeMode==null?s=[t,t]:s=t:this.mergeMode==null?s=[null,null]:s=null,this.returnState){const r=this.forwardLayer.states.map(i=>null);return Array.isArray(s)?s.concat(r).concat(r):[s].concat(r).concat(r)}else return s}get trainableWeights(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}get nonTrainableWeights(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.forwardLayer!=null&&this.forwardLayer.setFastWeightInitDuringBuild(e),this.backwardLayer!=null&&this.backwardLayer.setFastWeightInitDuringBuild(e)}getConfig(){const e={mergeMode:this.mergeMode},t=super.getConfig();return Object.assign(e,t),e}static fromConfig(e,t){const s=Zn(t.layer);if(delete t.layer,t.numConstants!=null)throw new Ce("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");const o=t;return o.layer=s,new e(o)}}h0.className="Bidirectional",Z(h0);/** + */class d0 extends ke{constructor(e){super(e),this.layer=e.layer}build(e){this.built=!0}get trainable(){return this.layer!=null?this.layer.trainable:!1}set trainable(e){this.layer!=null&&(this.layer.trainable=e)}get trainableWeights(){return this.layer.trainableWeights}get nonTrainableWeights(){return this.layer.nonTrainableWeights}get updates(){return this.layer._updates}get losses(){return this.layer.losses}getWeights(){return this.layer.getWeights()}setWeights(e){this.layer.setWeights(e)}getConfig(){const e={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},t=super.getConfig();return Object.assign(e,t),e}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.layer!=null&&this.layer.setFastWeightInitDuringBuild(e)}static fromConfig(e,t,s={}){const o=t.layer,r=Zn(o,s);delete t.layer;const i={layer:r};return Object.assign(i,t),new e(i)}}class p0 extends d0{constructor(e){super(e),this.supportsMasking=!0}build(e){if(e=_e(e),e.length<3)throw new A(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(e)}`);this.inputSpec=[{shape:e}];const t=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(t),this.layer.built=!0),super.build(e)}computeOutputShape(e){e=_e(e);const t=[e[0]].concat(e.slice(2)),s=this.layer.computeOutputShape(t),o=e[1];return[s[0],o].concat(s.slice(1))}call(e,t){return P(()=>(e=xe(e),Ib((i,a)=>[xe(this.layer.call(i,t)),[]],e,[],!1,null,null,!1,!0)[1]))}}p0.className="TimeDistributed",Y(p0);function bR(n){mo(MN,"BidirectionalMergeMode",n)}const yR="concat";class f0 extends d0{constructor(e){super(e);const t=e.layer.getConfig(),s={};s.className=e.layer.getClassName(),s.config=t,this.forwardLayer=Zn(s),t.goBackwards=t.goBackwards!==!0;const o={};if(o.className=e.layer.getClassName(),o.config=t,this.backwardLayer=Zn(o),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=e.mergeMode===void 0?yR:e.mergeMode,bR(this.mergeMode),e.weights)throw new Ce("weights support is not implemented for Bidirectional layer yet.");this._stateful=e.layer.stateful,this.returnSequences=e.layer.returnSequences,this.returnState=e.layer.returnState,this.supportsMasking=!0,this._trainable=!0,this.inputSpec=e.layer.inputSpec,this.numConstants=null}get trainable(){return this._trainable}set trainable(e){this._trainable=e,this.forwardLayer!=null&&(this.forwardLayer.trainable=e),this.backwardLayer!=null&&(this.backwardLayer.trainable=e)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(e){const t=e.length,s=Math.floor(t/2);this.forwardLayer.setWeights(e.slice(0,s)),this.backwardLayer.setWeights(e.slice(s))}computeOutputShape(e){let t=this.forwardLayer.computeOutputShape(e);Array.isArray(t)&&Array.isArray(t[0])||(t=[t]),t=t;let s,o,r;return this.returnState&&(r=t.slice(1)),s=t[0],s=s,this.mergeMode==="concat"?(s[s.length-1]*=2,o=[s]):this.mergeMode==null?o=[s,s.slice()]:o=[s],this.returnState?this.mergeMode==null?o.concat(r).concat(r.slice()):[s].concat(r).concat(r.slice()):Ht(o)}apply(e,t){let s=t==null?null:t.initialState,o=t==null?null:t.constants;t==null&&(t={});const r=Cb(e,s,o,this.numConstants);if(e=r.inputs,s=r.initialState,o=r.constants,Array.isArray(e)&&(s=e.slice(1),e=e[0]),(s==null||s.length===0)&&o==null)return super.apply(e,t);const i=[],a=[];if(s!=null){const c=s.length;if(c%2>0)throw new A("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");t.initialState=s,i.push(...s);const u=s.map(h=>new ht({shape:h.shape}));this.forwardLayer.stateSpec=u.slice(0,c/2),this.backwardLayer.stateSpec=u.slice(c/2),a.push(...u)}if(o!=null)throw new Ce("Support for constants in Bidirectional layers is not implemented yet.");const l=i[0]instanceof Yn;for(const c of i)if(c instanceof Yn!==l)throw new A("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(l){const c=[e].concat(i),u=this.inputSpec.concat(a),h=this.inputSpec;this.inputSpec=u;const d=super.apply(c,t);return this.inputSpec=h,d}else return super.apply(e,t)}call(e,t){return P(()=>{const s=t.initialState;let o,r;if(s==null)o=this.forwardLayer.call(e,t),r=this.backwardLayer.call(e,t);else{const l=s.slice(0,s.length/2),c=s.slice(s.length/2);o=this.forwardLayer.call(e,Object.assign(t,{initialState:l})),r=this.backwardLayer.call(e,Object.assign(t,{initialState:c}))}let i;this.returnState&&(Array.isArray(o)&&(i=o.slice(1).concat(r.slice(1))),o=o[0],r=r[0]),this.returnSequences&&(r=uo(r,1));let a;return this.mergeMode==="concat"?a=Cd([o,r]):this.mergeMode==="sum"?a=ee(o,r):this.mergeMode==="ave"?a=D(.5,ee(o,r)):this.mergeMode==="mul"?a=D(o,r):this.mergeMode==null&&(a=[o,r]),this.returnState?this.mergeMode==null?a.concat(i):[a].concat(i):a})}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){go(this.forwardLayer.name,()=>{this.forwardLayer.build(e)}),go(this.backwardLayer.name,()=>{this.backwardLayer.build(e)}),this.built=!0}computeMask(e,t){Array.isArray(t)&&(t=t[0]);let s;if(this.returnSequences?this.mergeMode==null?s=[t,t]:s=t:this.mergeMode==null?s=[null,null]:s=null,this.returnState){const r=this.forwardLayer.states.map(i=>null);return Array.isArray(s)?s.concat(r).concat(r):[s].concat(r).concat(r)}else return s}get trainableWeights(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}get nonTrainableWeights(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.forwardLayer!=null&&this.forwardLayer.setFastWeightInitDuringBuild(e),this.backwardLayer!=null&&this.backwardLayer.setFastWeightInitDuringBuild(e)}getConfig(){const e={mergeMode:this.mergeMode},t=super.getConfig();return Object.assign(e,t),e}static fromConfig(e,t){const s=Zn(t.layer);if(delete t.layer,t.numConstants!=null)throw new Ce("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");const o=t;return o.layer=s,new e(o)}}f0.className="Bidirectional",Y(f0);/** * @license * Copyright 2022 CodeSmith LLC * @@ -7856,7 +7856,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class d0 extends ke{constructor(e){super(e),this.scale=e.scale,e.offset?this.offset=e.offset:this.offset=0}getConfig(){const e={scale:this.scale,offset:this.offset},t=super.getConfig();return Object.assign(e,t),e}call(e,t){return z(()=>(e=xe(e),e.dtype!=="float32"&&(e=Kn(e,"float32")),ee(F(e,this.scale),this.offset)))}}d0.className="Rescaling",Z(d0);/** + */class m0 extends ke{constructor(e){super(e),this.scale=e.scale,e.offset?this.offset=e.offset:this.offset=0}getConfig(){const e={scale:this.scale,offset:this.offset},t=super.getConfig();return Object.assign(e,t),e}call(e,t){return P(()=>(e=xe(e),e.dtype!=="float32"&&(e=Kn(e,"float32")),ee(D(e,this.scale),this.offset)))}}m0.className="Rescaling",Y(m0);/** * @license * Copyright 2022 CodeSmith LLC * @@ -7864,7 +7864,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */const{resizeBilinear:bR,cropAndResize:yR}=ls;class p0 extends ke{constructor(e){super(e),this.height=e.height,this.width=e.width}centerCrop(e,t,s,o,r,i,a,l){return z(()=>{let c,u=!1;const h=t/i,d=s/a,p=(o+t)/i,f=(r+s)/a,g=[h,d,p,f],m=[];e.rank===3?(u=!0,c=Un([e])):c=e;for(let C=0;C{const r=bR(e,[t,s]);return Kn(r,o)})}call(e,t){return z(()=>{const s=xe(e),o=s.dtype,r=s.shape,i=r[r.length-3],a=r[r.length-2];let l=0;i!==this.height&&(l=Math.floor((i-this.height)/2));let c=0;return a!==this.width&&(c=Math.floor((a-this.width)/2),c===0&&(c=1)),l>=0&&c>=0?this.centerCrop(s,l,c,this.height,this.width,i,a,o):this.upsize(e,this.height,this.width,o)})}getConfig(){const e={height:this.height,width:this.width},t=super.getConfig();return Object.assign(e,t),e}computeOutputShape(e){e=_e(e);const t=e.length-3,s=e.length-2;return e[t]=this.height,e[s]=this.width,e}}p0.className="CenterCrop",Z(p0);/** + */const{resizeBilinear:wR,cropAndResize:CR}=ls;class g0 extends ke{constructor(e){super(e),this.height=e.height,this.width=e.width}centerCrop(e,t,s,o,r,i,a,l){return P(()=>{let c,u=!1;const h=t/i,d=s/a,p=(o+t)/i,f=(r+s)/a,g=[h,d,p,f],m=[];e.rank===3?(u=!0,c=Un([e])):c=e;for(let C=0;C{const r=wR(e,[t,s]);return Kn(r,o)})}call(e,t){return P(()=>{const s=xe(e),o=s.dtype,r=s.shape,i=r[r.length-3],a=r[r.length-2];let l=0;i!==this.height&&(l=Math.floor((i-this.height)/2));let c=0;return a!==this.width&&(c=Math.floor((a-this.width)/2),c===0&&(c=1)),l>=0&&c>=0?this.centerCrop(s,l,c,this.height,this.width,i,a,o):this.upsize(e,this.height,this.width,o)})}getConfig(){const e={height:this.height,width:this.width},t=super.getConfig();return Object.assign(e,t),e}computeOutputShape(e){e=_e(e);const t=e.length-3,s=e.length-2;return e[t]=this.height,e[s]=this.width,e}}g0.className="CenterCrop",Y(g0);/** * @license * Copyright 2022 CodeSmith LLC * @@ -7872,7 +7872,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function wR(n,e,t,s){let o=xe(n);if(o.dtype!=="int32"&&(o=Kn(o,"int32")),e==="int")return o;const r=o.shape;if(o.rank===0&&(o=Ut(o,-1)),e==="oneHot"&&o.shape[o.shape.length-1]!==1&&(o=Ut(o,-1)),o.rank>2)throw new A(`When outputMode is not int, maximum output rank is 2 Received outputMode ${e} and input shape ${r} which would result in output rank ${o.rank}.`);const i=["multiHot","oneHot"].includes(e),a=o;let l;if(typeof s<"u"&&e==="count"?l=hm(a,s,t,i):l=hm(a,[],t,i),e!=="tfIdf")return l;if(s)return F(l,s);throw new A("When outputMode is 'tfIdf', weights must be provided.")}/** + */function IR(n,e,t,s){let o=xe(n);if(o.dtype!=="int32"&&(o=Kn(o,"int32")),e==="int")return o;const r=o.shape;if(o.rank===0&&(o=Gt(o,-1)),e==="oneHot"&&o.shape[o.shape.length-1]!==1&&(o=Gt(o,-1)),o.rank>2)throw new A(`When outputMode is not int, maximum output rank is 2 Received outputMode ${e} and input shape ${r} which would result in output rank ${o.rank}.`);const i=["multiHot","oneHot"].includes(e),a=o;let l;if(typeof s<"u"&&e==="count"?l=hm(a,s,t,i):l=hm(a,[],t,i),e!=="tfIdf")return l;if(s)return D(l,s);throw new A("When outputMode is 'tfIdf', weights must be provided.")}/** * @license * Copyright 2022 CodeSmith LLC * @@ -7880,8 +7880,8 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class f0 extends ke{constructor(e){super(e),this.numTokens=e.numTokens,e.outputMode?this.outputMode=e.outputMode:this.outputMode="multiHot"}getConfig(){const e={numTokens:this.numTokens,outputMode:this.outputMode},t=super.getConfig();return Object.assign(e,t),e}computeOutputShape(e){return e=_e(e),e==null?[this.numTokens]:this.outputMode==="oneHot"&&e[e.length-1]!==1?(e.push(this.numTokens),e):(e[e.length-1]=this.numTokens,e)}call(e,t){return z(()=>{e=xe(e),e.dtype!=="int32"&&(e=Kn(e,"int32"));let s;if(typeof t.countWeights<"u"){if(this.outputMode!=="count")throw new A(`countWeights is not used when outputMode !== count. - Received countWeights=${t.countWeights}`);s=xe(t.countWeights)}const o=Sn(e),r=Il(e),i=Zt(this.numTokens,o).bufferSync().get(0),a=io(r,0).bufferSync().get(0);if(!(i&&a))throw new A(`Input values must be between 0 < values <= numTokens with numTokens=${this.numTokens}`);return wR(e,this.outputMode,this.numTokens,s)})}}f0.className="CategoryEncoding",Z(f0);/** + */class x0 extends ke{constructor(e){super(e),this.numTokens=e.numTokens,e.outputMode?this.outputMode=e.outputMode:this.outputMode="multiHot"}getConfig(){const e={numTokens:this.numTokens,outputMode:this.outputMode},t=super.getConfig();return Object.assign(e,t),e}computeOutputShape(e){return e=_e(e),e==null?[this.numTokens]:this.outputMode==="oneHot"&&e[e.length-1]!==1?(e.push(this.numTokens),e):(e[e.length-1]=this.numTokens,e)}call(e,t){return P(()=>{e=xe(e),e.dtype!=="int32"&&(e=Kn(e,"int32"));let s;if(typeof t.countWeights<"u"){if(this.outputMode!=="count")throw new A(`countWeights is not used when outputMode !== count. + Received countWeights=${t.countWeights}`);s=xe(t.countWeights)}const o=Sn(e),r=$l(e),i=Zt(this.numTokens,o).bufferSync().get(0),a=ao(r,0).bufferSync().get(0);if(!(i&&a))throw new A(`Input values must be between 0 < values <= numTokens with numTokens=${this.numTokens}`);return IR(e,this.outputMode,this.numTokens,s)})}}x0.className="CategoryEncoding",Y(x0);/** * @license * Copyright 2022 CodeSmith LLC * @@ -7889,7 +7889,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */const CR=["bilinear","nearest"],m0=new Set(CR);class g0 extends ke{constructor(e){if(super(e),this.height=e.height,this.width=e.width,e.interpolation)if(m0.has(e.interpolation))this.interpolation=e.interpolation;else throw new A(`Invalid interpolation parameter: ${e.interpolation} is not implemented`);else this.interpolation="bilinear";this.cropToAspectRatio=!!e.cropToAspectRatio}computeOutputShape(e){e=_e(e);const t=e[2];return[this.height,this.width,t]}getConfig(){const e={height:this.height,width:this.width,interpolation:this.interpolation,cropToAspectRatio:this.cropToAspectRatio},t=super.getConfig();return Object.assign(e,t),e}call(e,t){return z(()=>{const s=[this.height,this.width];if(this.interpolation==="bilinear")return ls.resizeBilinear(e,s,!this.cropToAspectRatio);if(this.interpolation==="nearest")return ls.resizeNearestNeighbor(e,s,!this.cropToAspectRatio);throw new Error(`Interpolation is ${this.interpolation} but only ${[...m0]} are supported`)})}}g0.className="Resizing",Z(g0);/** + */const $R=["bilinear","nearest"],b0=new Set($R);class y0 extends ke{constructor(e){if(super(e),this.height=e.height,this.width=e.width,e.interpolation)if(b0.has(e.interpolation))this.interpolation=e.interpolation;else throw new A(`Invalid interpolation parameter: ${e.interpolation} is not implemented`);else this.interpolation="bilinear";this.cropToAspectRatio=!!e.cropToAspectRatio}computeOutputShape(e){e=_e(e);const t=e[2];return[this.height,this.width,t]}getConfig(){const e={height:this.height,width:this.width,interpolation:this.interpolation,cropToAspectRatio:this.cropToAspectRatio},t=super.getConfig();return Object.assign(e,t),e}call(e,t){return P(()=>{const s=[this.height,this.width];if(this.interpolation==="bilinear")return ls.resizeBilinear(e,s,!this.cropToAspectRatio);if(this.interpolation==="nearest")return ls.resizeNearestNeighbor(e,s,!this.cropToAspectRatio);throw new Error(`Interpolation is ${this.interpolation} but only ${[...b0]} are supported`)})}}y0.className="Resizing",Y(y0);/** * @license * Copyright 2023 CodeSmith LLC * @@ -7897,7 +7897,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class x0{constructor(e){this.seed=e}next(){if(this.seed!==void 0)return this.seed++}}x0.className="RandomSeed";/** + */class w0{constructor(e){this.seed=e}next(){if(this.seed!==void 0)return this.seed++}}w0.className="RandomSeed";/** * @license * Copyright 2023 CodeSmith LLC * @@ -7905,7 +7905,7 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class b0 extends ke{constructor(e){super(e),this.randomGenerator=new x0(e.seed)}getConfig(){const e={seed:this.randomGenerator.seed},t=super.getConfig();return Object.assign(e,t),e}}b0.className="BaseRandomLayer";/** + */class C0 extends ke{constructor(e){super(e),this.randomGenerator=new w0(e.seed)}getConfig(){const e={seed:this.randomGenerator.seed},t=super.getConfig();return Object.assign(e,t),e}}C0.className="BaseRandomLayer";/** * @license * Copyright 2023 CodeSmith LLC * @@ -7913,11 +7913,11 @@ * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */const IR=["bilinear","nearest"],y0=new Set(IR);class w0 extends b0{constructor(e){super(e);const{factor:t,interpolation:s="bilinear"}=e;if(this.factor=t,Array.isArray(this.factor)&&this.factor.length===2)this.widthLower=this.factor[0],this.widthUpper=this.factor[1];else if(!Array.isArray(this.factor)&&this.factor>0)this.widthLower=-this.factor,this.widthUpper=this.factor;else throw new A(`Invalid factor: ${this.factor}. Must be positive number or tuple of 2 numbers`);if(this.widthLower<-1||this.widthUpper<-1)throw new A(`factor must have values larger than -1. Got: ${this.factor}`);if(this.widthUpper0)this.widthLower=-this.factor,this.widthUpper=this.factor;else throw new A(`Invalid factor: ${this.factor}. Must be positive number or tuple of 2 numbers`);if(this.widthLower<-1||this.widthUpper<-1)throw new A(`factor must have values larger than -1. Got: ${this.factor}`);if(this.widthUpper{const s=xe(e);this.imgHeight=s.shape[s.shape.length-3];const o=s.shape[s.shape.length-2];this.widthFactor=Si([1],1+this.widthLower,1+this.widthUpper,"float32",this.randomGenerator.next());let r=this.widthFactor.dataSync()[0]*o;r=Math.round(r);const i=[this.imgHeight,r];switch(this.interpolation){case"bilinear":return ls.resizeBilinear(e,i);case"nearest":return ls.resizeNearestNeighbor(e,i);default:throw new Error(`Interpolation is ${this.interpolation} - but only ${[...y0]} are supported`)}})}}w0.className="RandomWidth",Z(w0);/** + `);if(s)if(I0.has(s))this.interpolation=s;else throw new A(`Invalid interpolation parameter: ${s} is not implemented`)}getConfig(){const e={factor:this.factor,interpolation:this.interpolation},t=super.getConfig();return Object.assign(e,t),e}computeOutputShape(e){e=_e(e);const t=e[2];return[this.imgHeight,-1,t]}call(e,t){return P(()=>{const s=xe(e);this.imgHeight=s.shape[s.shape.length-3];const o=s.shape[s.shape.length-2];this.widthFactor=Si([1],1+this.widthLower,1+this.widthUpper,"float32",this.randomGenerator.next());let r=this.widthFactor.dataSync()[0]*o;r=Math.round(r);const i=[this.imgHeight,r];switch(this.interpolation){case"bilinear":return ls.resizeBilinear(e,i);case"nearest":return ls.resizeNearestNeighbor(e,i);default:throw new Error(`Interpolation is ${this.interpolation} + but only ${[...I0]} are supported`)}})}}$0.className="RandomWidth",Y($0);/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7948,7 +7948,7 @@ * limitations under the License. * * ============================================================================= - */var C0;(function(n){n[n.DT_INVALID=0]="DT_INVALID",n[n.DT_FLOAT=1]="DT_FLOAT",n[n.DT_DOUBLE=2]="DT_DOUBLE",n[n.DT_INT32=3]="DT_INT32",n[n.DT_UINT8=4]="DT_UINT8",n[n.DT_INT16=5]="DT_INT16",n[n.DT_INT8=6]="DT_INT8",n[n.DT_STRING=7]="DT_STRING",n[n.DT_COMPLEX64=8]="DT_COMPLEX64",n[n.DT_INT64=9]="DT_INT64",n[n.DT_BOOL=10]="DT_BOOL",n[n.DT_QINT8=11]="DT_QINT8",n[n.DT_QUINT8=12]="DT_QUINT8",n[n.DT_QINT32=13]="DT_QINT32",n[n.DT_BFLOAT16=14]="DT_BFLOAT16",n[n.DT_QINT16=15]="DT_QINT16",n[n.DT_QUINT16=16]="DT_QUINT16",n[n.DT_UINT16=17]="DT_UINT16",n[n.DT_COMPLEX128=18]="DT_COMPLEX128",n[n.DT_HALF=19]="DT_HALF",n[n.DT_RESOURCE=20]="DT_RESOURCE",n[n.DT_VARIANT=21]="DT_VARIANT",n[n.DT_UINT32=22]="DT_UINT32",n[n.DT_UINT64=23]="DT_UINT64",n[n.DT_FLOAT_REF=101]="DT_FLOAT_REF",n[n.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",n[n.DT_INT32_REF=103]="DT_INT32_REF",n[n.DT_UINT8_REF=104]="DT_UINT8_REF",n[n.DT_INT16_REF=105]="DT_INT16_REF",n[n.DT_INT8_REF=106]="DT_INT8_REF",n[n.DT_STRING_REF=107]="DT_STRING_REF",n[n.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",n[n.DT_INT64_REF=109]="DT_INT64_REF",n[n.DT_BOOL_REF=110]="DT_BOOL_REF",n[n.DT_QINT8_REF=111]="DT_QINT8_REF",n[n.DT_QUINT8_REF=112]="DT_QUINT8_REF",n[n.DT_QINT32_REF=113]="DT_QINT32_REF",n[n.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",n[n.DT_QINT16_REF=115]="DT_QINT16_REF",n[n.DT_QUINT16_REF=116]="DT_QUINT16_REF",n[n.DT_UINT16_REF=117]="DT_UINT16_REF",n[n.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",n[n.DT_HALF_REF=119]="DT_HALF_REF",n[n.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",n[n.DT_VARIANT_REF=121]="DT_VARIANT_REF",n[n.DT_UINT32_REF=122]="DT_UINT32_REF",n[n.DT_UINT64_REF=123]="DT_UINT64_REF"})(C0||(C0={}));var I0;(function(n){(function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"})(n.CheckpointFormatVersion||(n.CheckpointFormatVersion={}))})(I0||(I0={}));/** + */var v0;(function(n){n[n.DT_INVALID=0]="DT_INVALID",n[n.DT_FLOAT=1]="DT_FLOAT",n[n.DT_DOUBLE=2]="DT_DOUBLE",n[n.DT_INT32=3]="DT_INT32",n[n.DT_UINT8=4]="DT_UINT8",n[n.DT_INT16=5]="DT_INT16",n[n.DT_INT8=6]="DT_INT8",n[n.DT_STRING=7]="DT_STRING",n[n.DT_COMPLEX64=8]="DT_COMPLEX64",n[n.DT_INT64=9]="DT_INT64",n[n.DT_BOOL=10]="DT_BOOL",n[n.DT_QINT8=11]="DT_QINT8",n[n.DT_QUINT8=12]="DT_QUINT8",n[n.DT_QINT32=13]="DT_QINT32",n[n.DT_BFLOAT16=14]="DT_BFLOAT16",n[n.DT_QINT16=15]="DT_QINT16",n[n.DT_QUINT16=16]="DT_QUINT16",n[n.DT_UINT16=17]="DT_UINT16",n[n.DT_COMPLEX128=18]="DT_COMPLEX128",n[n.DT_HALF=19]="DT_HALF",n[n.DT_RESOURCE=20]="DT_RESOURCE",n[n.DT_VARIANT=21]="DT_VARIANT",n[n.DT_UINT32=22]="DT_UINT32",n[n.DT_UINT64=23]="DT_UINT64",n[n.DT_FLOAT_REF=101]="DT_FLOAT_REF",n[n.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",n[n.DT_INT32_REF=103]="DT_INT32_REF",n[n.DT_UINT8_REF=104]="DT_UINT8_REF",n[n.DT_INT16_REF=105]="DT_INT16_REF",n[n.DT_INT8_REF=106]="DT_INT8_REF",n[n.DT_STRING_REF=107]="DT_STRING_REF",n[n.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",n[n.DT_INT64_REF=109]="DT_INT64_REF",n[n.DT_BOOL_REF=110]="DT_BOOL_REF",n[n.DT_QINT8_REF=111]="DT_QINT8_REF",n[n.DT_QUINT8_REF=112]="DT_QUINT8_REF",n[n.DT_QINT32_REF=113]="DT_QINT32_REF",n[n.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",n[n.DT_QINT16_REF=115]="DT_QINT16_REF",n[n.DT_QUINT16_REF=116]="DT_QUINT16_REF",n[n.DT_UINT16_REF=117]="DT_UINT16_REF",n[n.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",n[n.DT_HALF_REF=119]="DT_HALF_REF",n[n.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",n[n.DT_VARIANT_REF=121]="DT_VARIANT_REF",n[n.DT_UINT32_REF=122]="DT_UINT32_REF",n[n.DT_UINT64_REF=123]="DT_UINT64_REF"})(v0||(v0={}));var k0;(function(n){(function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"})(n.CheckpointFormatVersion||(n.CheckpointFormatVersion={}))})(k0||(k0={}));/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7964,7 +7964,7 @@ * limitations under the License. * * ============================================================================= - */var $0;(function(n){n[n.FAIL=0]="FAIL",n[n.SHORTEST=1]="SHORTEST",n[n.LONGEST=2]="LONGEST"})($0||($0={}));/** + */var S0;(function(n){n[n.FAIL=0]="FAIL",n[n.SHORTEST=1]="SHORTEST",n[n.LONGEST=2]="LONGEST"})(S0||(S0={}));/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7994,10 +7994,10 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const $R=Eh;class sc extends Fc{nextDataId(){return sc.nextDataId++}constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new Op(this,Te())}write(e,t,s){this.firstUse&&(this.firstUse=!1,W().get("IS_NODE")&&tn(` + */const kR=Eh;class oc extends _c{nextDataId(){return oc.nextDataId++}constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new Op(this,Te())}write(e,t,s){this.firstUse&&(this.firstUse=!1,W().get("IS_NODE")&&tn(` ============================ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. -============================`));const o={id:this.nextDataId()};return this.data.set(o,{values:e,dtype:s,refCount:1}),o}makeTensorInfo(e,t,s){let o;if(t==="string"&&s!=null&&s.length>0&&br(s[0])){const r=s.map(i=>bs(i));o=this.write(r,e,t)}else o=this.write(s,e,t);return{dataId:o,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){const t=this.data.get(e);t.refCount++}decRef(e){if(this.data.has(e)){const t=this.data.get(e);t.refCount--}}move(e,t,s,o,r){this.data.set(e,{values:t,dtype:o,refCount:r})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:t,complexTensorInfos:s}=this.data.get(e);if(t==="complex64"){const o=this.readSync(s.real.dataId),r=this.readSync(s.imag.dataId);return cs(o,r)}return kw(this.data.get(e).values,t)}bufferSync(e){const t=this.readSync(e.dataId);if(e.dtype==="string")try{const s=t.map(o=>ys(o));return ve(e.shape,e.dtype,s)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return ve(e.shape,e.dtype,t)}makeOutput(e,t,s){return Te().makeTensorFromTensorInfo(this.makeTensorInfo(t,s,e),this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;const{complexTensorInfos:s}=this.data.get(e);s!=null&&(this.disposeData(s.real.dataId,!0),this.disposeData(s.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const t=zt();return e(),{kernelMs:zt()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){ce([e],"where");const t=this.readSync(e.dataId);return $R(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}sc.nextDataId=0;/** +============================`));const o={id:this.nextDataId()};return this.data.set(o,{values:e,dtype:s,refCount:1}),o}makeTensorInfo(e,t,s){let o;if(t==="string"&&s!=null&&s.length>0&&br(s[0])){const r=s.map(i=>bs(i));o=this.write(r,e,t)}else o=this.write(s,e,t);return{dataId:o,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){const t=this.data.get(e);t.refCount++}decRef(e){if(this.data.has(e)){const t=this.data.get(e);t.refCount--}}move(e,t,s,o,r){this.data.set(e,{values:t,dtype:o,refCount:r})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:t,complexTensorInfos:s}=this.data.get(e);if(t==="complex64"){const o=this.readSync(s.real.dataId),r=this.readSync(s.imag.dataId);return cs(o,r)}return Nw(this.data.get(e).values,t)}bufferSync(e){const t=this.readSync(e.dataId);if(e.dtype==="string")try{const s=t.map(o=>ys(o));return ve(e.shape,e.dtype,s)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return ve(e.shape,e.dtype,t)}makeOutput(e,t,s){return Te().makeTensorFromTensorInfo(this.makeTensorInfo(t,s,e),this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;const{complexTensorInfos:s}=this.data.get(e);s!=null&&(this.disposeData(s.real.dataId,!0),this.disposeData(s.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const t=Vt();return e(),{kernelMs:Vt()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){ce([e],"where");const t=this.readSync(e.dataId);return kR(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}oc.nextDataId=0;/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -8012,7 +8012,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function v0(n){const e=new Float32Array(n.length);for(let t=0;t{const{x:e}=n.inputs,t=n.backend;ce(e,"abs");let s=new Float32Array(H(e.shape));const o=t.data.get(e.dataId).values;return s=v0(o),t.makeOutput(s,e.shape,e.dtype)}};/** + */function T0(n){const e=new Float32Array(n.length);for(let t=0;t{const{x:e}=n.inputs,t=n.backend;ce(e,"abs");let s=new Float32Array(H(e.shape));const o=t.data.get(e.dataId).values;return s=T0(o),t.makeOutput(s,e.shape,e.dtype)}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8027,7 +8027,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function rt(n){return(e,t,s,o,r)=>{const i=we(e,t),a=i.length,l=de(i),c=H(i),u=Tt(r,c),h=e.length,d=t.length,p=de(e),f=de(t),g=Ho(e,i),m=Ho(t,i);if(g.length+m.length===0)for(let x=0;xw[v]=0);const y=Pn(w,h,p),C=b.slice(-d);m.forEach(v=>C[v]=0);const I=Pn(C,d,f);u[x]=n(s[y],o[I])}return[u,i]}}/** + */function rt(n){return(e,t,s,o,r)=>{const i=we(e,t),a=i.length,l=de(i),c=H(i),u=Tt(r,c),h=e.length,d=t.length,p=de(e),f=de(t),g=qo(e,i),m=qo(t,i);if(g.length+m.length===0)for(let x=0;xw[v]=0);const y=Pn(w,h,p),C=b.slice(-d);m.forEach(v=>C[v]=0);const I=Pn(C,d,f);u[x]=n(s[y],o[I])}return[u,i]}}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8042,7 +8042,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Jt(n){const{inputs:e,backend:t}=n,{real:s,imag:o}=e,r=t.data.get(s.dataId).values,i=t.data.get(o.dataId).values,a=t.makeTensorInfo(s.shape,"complex64"),l=t.data.get(a.dataId);return l.complexTensorInfos={real:t.makeTensorInfo(s.shape,"float32",r),imag:t.makeTensorInfo(o.shape,"float32",i)},a}const kR={kernelName:Zc,backendName:"cpu",kernelFunc:Jt};/** + */function Jt(n){const{inputs:e,backend:t}=n,{real:s,imag:o}=e,r=t.data.get(s.dataId).values,i=t.data.get(o.dataId).values,a=t.makeTensorInfo(s.shape,"complex64"),l=t.data.get(a.dataId);return l.complexTensorInfos={real:t.makeTensorInfo(s.shape,"float32",r),imag:t.makeTensorInfo(o.shape,"float32",i)},a}const TR={kernelName:Qc,backendName:"cpu",kernelFunc:Jt};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8057,7 +8057,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function oc(n,e,t="float32"){if(t==="complex64"){const o=oc(n,e,"float32"),r=oc(n,e,"float32");return Jt({inputs:{real:o,imag:r},backend:n})}const s=Nt(H(e),t);return n.makeTensorInfo(e,t,s)}/** + */function rc(n,e,t="float32"){if(t==="complex64"){const o=rc(n,e,"float32"),r=rc(n,e,"float32");return Jt({inputs:{real:o,imag:r},backend:n})}const s=Nt(H(e),t);return n.makeTensorInfo(e,t,s)}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8072,7 +8072,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Jn(n){const{inputs:e,backend:t}=n,{x:s}=e;return t.incRef(s.dataId),{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}const SR={kernelName:zr,backendName:"cpu",kernelFunc:Jn};/** + */function Jn(n){const{inputs:e,backend:t}=n,{x:s}=e;return t.incRef(s.dataId),{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}const NR={kernelName:zr,backendName:"cpu",kernelFunc:Jn};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8087,7 +8087,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function yo(n){const{inputs:e,backend:t}=n,{input:s}=e,o=t.data.get(s.dataId).complexTensorInfos.real,r=t.data.get(o.dataId).values;return t.makeTensorInfo(o.shape,o.dtype,r)}const TR={kernelName:$u,backendName:"cpu",kernelFunc:yo};/** + */function wo(n){const{inputs:e,backend:t}=n,{input:s}=e,o=t.data.get(s.dataId).complexTensorInfos.real,r=t.data.get(o.dataId).values;return t.makeTensorInfo(o.shape,o.dtype,r)}const ER={kernelName:vu,backendName:"cpu",kernelFunc:wo};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8102,7 +8102,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function k0(n,e,t,s){if(s==="int32"){const o=Int32Array.from(n);return[e,"int32",o]}if(s==="bool"){const o=Xs([0],t),[r,i]=rt((a,l)=>a!==l?1:0)(e,[],n,o,"bool");return[i,"bool",r]}throw new Error(`Error in Cast: failed to cast ${t} to ${s}`)}function _s(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{dtype:r}=s;if(r==="complex64"){if(o.dtype==="complex64")return Jn({inputs:{x:o},backend:t});const u=oc(t,o.shape,o.dtype),h=_s({inputs:{x:o},backend:t,attrs:{dtype:"float32"}}),d=Jt({inputs:{real:h,imag:u},backend:t});return t.disposeIntermediateTensorInfo(u),t.disposeIntermediateTensorInfo(h),d}if(o.dtype==="complex64"){const u=yo({inputs:{input:o},backend:t}),h=_s({inputs:{x:u},backend:t,attrs:{dtype:r}});return t.disposeIntermediateTensorInfo(u),h}if(!Bp(o.dtype,r)){const u=Jn({inputs:{x:o},backend:t});return{dataId:u.dataId,shape:u.shape,dtype:r}}const i=t.data.get(o.dataId).values,[a,l,c]=k0(i,o.shape,o.dtype,r);return t.makeTensorInfo(a,l,c)}const NR={kernelName:Tr,backendName:"cpu",kernelFunc:_s};/** + */function N0(n,e,t,s){if(s==="int32"){const o=Int32Array.from(n);return[e,"int32",o]}if(s==="bool"){const o=Xs([0],t),[r,i]=rt((a,l)=>a!==l?1:0)(e,[],n,o,"bool");return[i,"bool",r]}throw new Error(`Error in Cast: failed to cast ${t} to ${s}`)}function _s(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{dtype:r}=s;if(r==="complex64"){if(o.dtype==="complex64")return Jn({inputs:{x:o},backend:t});const u=rc(t,o.shape,o.dtype),h=_s({inputs:{x:o},backend:t,attrs:{dtype:"float32"}}),d=Jt({inputs:{real:h,imag:u},backend:t});return t.disposeIntermediateTensorInfo(u),t.disposeIntermediateTensorInfo(h),d}if(o.dtype==="complex64"){const u=wo({inputs:{input:o},backend:t}),h=_s({inputs:{x:u},backend:t,attrs:{dtype:r}});return t.disposeIntermediateTensorInfo(u),h}if(!Bp(o.dtype,r)){const u=Jn({inputs:{x:o},backend:t});return{dataId:u.dataId,shape:u.shape,dtype:r}}const i=t.data.get(o.dataId).values,[a,l,c]=N0(i,o.shape,o.dtype,r);return t.makeTensorInfo(a,l,c)}const RR={kernelName:Tr,backendName:"cpu",kernelFunc:_s};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8117,7 +8117,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ft(n,e,t,s){return t==null?({inputs:o,backend:r})=>{const{a:i,b:a}=o,l=r;ce([i,a],n);const c=l.data.get(i.dataId).values,u=l.data.get(a.dataId).values,h=i.dtype==="string"?us(c):c,d=i.dtype==="string"?us(u):u,p=s||i.dtype,[f,g]=e(i.shape,a.shape,h,d,p);return l.makeTensorInfo(g,p,f)}:({inputs:o,backend:r})=>{const{a:i,b:a}=o,l=r;if(i.dtype==="complex64"||a.dtype==="complex64"){const c=_s({inputs:{x:i},backend:l,attrs:{dtype:"complex64"}}),u=l.data.get(c.dataId),h=u.complexTensorInfos.real,d=u.complexTensorInfos.imag,p=l.data.get(h.dataId).values,f=l.data.get(d.dataId).values,g=_s({inputs:{x:a},backend:l,attrs:{dtype:"complex64"}}),m=l.data.get(g.dataId),x=m.complexTensorInfos.real,b=m.complexTensorInfos.imag,w=l.data.get(x.dataId).values,y=l.data.get(b.dataId).values,[C,I,v]=t(i.shape,a.shape,p,f,w,y),k=l.makeTensorInfo(v,"float32",C),S=l.makeTensorInfo(v,"float32",I),T=Jt({inputs:{real:k,imag:S},backend:l});return l.disposeIntermediateTensorInfo(c),l.disposeIntermediateTensorInfo(g),l.disposeIntermediateTensorInfo(k),l.disposeIntermediateTensorInfo(S),T}else{const c=l.data.get(i.dataId).values,u=l.data.get(a.dataId).values,h=s||i.dtype,[d,p]=e(i.shape,a.shape,c,u,h);return l.makeTensorInfo(p,h,d)}}}function Qd(n){return(e,t,s,o,r,i)=>{const a=we(e,t),l=H(a),c=a.length,u=de(a),h=Tt("float32",l),d=Tt("float32",l),p=Ho(e,a),f=Ho(t,a),g=cs(s,o),m=cs(r,i),x=e.length,b=de(e),w=t.length,y=de(t);if(p.length+f.length===0)for(let C=0;Cv[V]=0);const k=Pn(v,x,b),S=I.slice(-w);f.forEach(V=>S[V]=0);const T=Pn(S,w,y),E=n(g[k*2],g[k*2+1],m[T*2],m[T*2+1]);h[C]=E.real,d[C]=E.imag}return[h,d,a]}}/** + */function ft(n,e,t,s){return t==null?({inputs:o,backend:r})=>{const{a:i,b:a}=o,l=r;ce([i,a],n);const c=l.data.get(i.dataId).values,u=l.data.get(a.dataId).values,h=i.dtype==="string"?us(c):c,d=i.dtype==="string"?us(u):u,p=s||i.dtype,[f,g]=e(i.shape,a.shape,h,d,p);return l.makeTensorInfo(g,p,f)}:({inputs:o,backend:r})=>{const{a:i,b:a}=o,l=r;if(i.dtype==="complex64"||a.dtype==="complex64"){const c=_s({inputs:{x:i},backend:l,attrs:{dtype:"complex64"}}),u=l.data.get(c.dataId),h=u.complexTensorInfos.real,d=u.complexTensorInfos.imag,p=l.data.get(h.dataId).values,f=l.data.get(d.dataId).values,g=_s({inputs:{x:a},backend:l,attrs:{dtype:"complex64"}}),m=l.data.get(g.dataId),x=m.complexTensorInfos.real,b=m.complexTensorInfos.imag,w=l.data.get(x.dataId).values,y=l.data.get(b.dataId).values,[C,I,v]=t(i.shape,a.shape,p,f,w,y),k=l.makeTensorInfo(v,"float32",C),S=l.makeTensorInfo(v,"float32",I),T=Jt({inputs:{real:k,imag:S},backend:l});return l.disposeIntermediateTensorInfo(c),l.disposeIntermediateTensorInfo(g),l.disposeIntermediateTensorInfo(k),l.disposeIntermediateTensorInfo(S),T}else{const c=l.data.get(i.dataId).values,u=l.data.get(a.dataId).values,h=s||i.dtype,[d,p]=e(i.shape,a.shape,c,u,h);return l.makeTensorInfo(p,h,d)}}}function Qd(n){return(e,t,s,o,r,i)=>{const a=we(e,t),l=H(a),c=a.length,u=de(a),h=Tt("float32",l),d=Tt("float32",l),p=qo(e,a),f=qo(t,a),g=cs(s,o),m=cs(r,i),x=e.length,b=de(e),w=t.length,y=de(t);if(p.length+f.length===0)for(let C=0;Cv[V]=0);const k=Pn(v,x,b),S=I.slice(-w);f.forEach(V=>S[V]=0);const T=Pn(S,w,y),E=n(g[k*2],g[k*2+1],m[T*2],m[T*2+1]);h[C]=E.real,d[C]=E.imag}return[h,d,a]}}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8132,7 +8132,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const S0=rt((n,e)=>n+e),ER=Qd((n,e,t,s)=>({real:n+t,imag:e+s})),or=ft(Oo,S0,ER),RR={kernelName:Oo,backendName:"cpu",kernelFunc:or};/** + */const E0=rt((n,e)=>n+e),AR=Qd((n,e,t,s)=>({real:n+t,imag:e+s})),or=ft(Lo,E0,AR),DR={kernelName:Lo,backendName:"cpu",kernelFunc:or};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8147,7 +8147,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Jd(n,e,t,s,o){const r=H(s),i=Nt(o,t);for(let a=0;a=o||(r>0?i[l]+=e[a]:i[l]+=1)}return i}function T0(n,e,t,s=!1){const o=n.shape[0],r=n.shape[1],i=ve([o,t],e.dtype);for(let a=0;a=t||(s?i.set(1,a,c):e.size>0?i.set(i.get(a,c)+e.get(a,l),a,c):i.set(i.get(a,c)+1,a,c))}return i}/** + */function Jd(n,e,t,s,o){const r=H(s),i=Nt(o,t);for(let a=0;a=o||(r>0?i[l]+=e[a]:i[l]+=1)}return i}function R0(n,e,t,s=!1){const o=n.shape[0],r=n.shape[1],i=ve([o,t],e.dtype);for(let a=0;a=t||(s?i.set(1,a,c):e.size>0?i.set(i.get(a,c)+e.get(a,l),a,c):i.set(i.get(a,c)+1,a,c))}return i}/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8162,7 +8162,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const N0=rt((n,e)=>n&e),AR=ft(Yc,N0),DR={kernelName:Yc,backendName:"cpu",kernelFunc:AR};/** + */const A0=rt((n,e)=>n&e),FR=ft(Zc,A0),_R={kernelName:Zc,backendName:"cpu",kernelFunc:FR};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8207,7 +8207,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const E0=es(n=>Math.ceil(n)),FR=Os(Nr,E0),_R={kernelName:Nr,backendName:"cpu",kernelFunc:FR};/** + */const D0=es(n=>Math.ceil(n)),OR=Os(Nr,D0),LR={kernelName:Nr,backendName:"cpu",kernelFunc:OR};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8222,7 +8222,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function R0(n,e,t,s){const o=Je(t,H(e));if(s&&t!=="string"){let r=0;n.forEach(i=>{const a=H(i.shape);o.set(i.vals,r),r+=a})}else{let r=0;n.forEach(i=>{const a=t==="string"?us(i.vals):i.vals;let l=0;for(let c=0;c{const a=H(i.shape);o.set(i.vals,r),r+=a})}else{let r=0;n.forEach(i=>{const a=t==="string"?us(i.vals):i.vals;let l=0;for(let c=0;cn===e?1:0),D0=ft(va,A0,null,"bool"),OR={kernelName:va,backendName:"cpu",kernelFunc:D0};/** + */const _0=rt((n,e)=>n===e?1:0),O0=ft(va,_0,null,"bool"),MR={kernelName:va,backendName:"cpu",kernelFunc:O0};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -8252,7 +8252,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const F0=es(n=>Math.exp(n)),_0=Os(Or,F0,"float32"),LR={kernelName:Or,backendName:"cpu",kernelFunc:_0};/** + */const L0=es(n=>Math.exp(n)),M0=Os(Or,L0,"float32"),PR={kernelName:Or,backendName:"cpu",kernelFunc:M0};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -8267,7 +8267,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const O0=es(n=>Math.expm1(n)),MR=Os(Lr,O0),PR={kernelName:Lr,backendName:"cpu",kernelFunc:MR};/** + */const P0=es(n=>Math.expm1(n)),BR=Os(Lr,P0),zR={kernelName:Lr,backendName:"cpu",kernelFunc:BR};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -8282,7 +8282,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const L0=es(n=>Math.floor(n)),BR=Os(Mr,L0),zR={kernelName:Mr,backendName:"cpu",kernelFunc:BR};/** + */const B0=es(n=>Math.floor(n)),VR=Os(Mr,B0),WR={kernelName:Mr,backendName:"cpu",kernelFunc:VR};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8297,7 +8297,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const M0=rt((n,e)=>Math.floor(n/e)),VR=ft(Pr,M0,null,"int32"),WR={kernelName:Pr,backendName:"cpu",kernelFunc:VR};/** + */const z0=rt((n,e)=>Math.floor(n/e)),UR=ft(Pr,z0,null,"int32"),GR={kernelName:Pr,backendName:"cpu",kernelFunc:UR};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8312,7 +8312,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function P0(n,e,t,s,o,r,i,a,l){const c=ve([s,r],t);for(let u=0;u=l/r)throw new Error(`Invalid indices: ${h} does not index into ${a}`);for(let p=0;p=l/r)throw new Error(`Invalid indices: ${h} does not index into ${a}`);for(let p=0;pn>e?1:0),UR=ft(Na,z0,null,"bool"),GR={kernelName:Na,backendName:"cpu",kernelFunc:UR};/** + */const U0=rt((n,e)=>n>e?1:0),HR=ft(Na,U0,null,"bool"),qR={kernelName:Na,backendName:"cpu",kernelFunc:HR};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8357,7 +8357,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const V0=rt((n,e)=>n>=e?1:0),HR=ft(Br,V0,null,"bool"),jR={kernelName:Br,backendName:"cpu",kernelFunc:HR};/** + */const G0=rt((n,e)=>n>=e?1:0),jR=ft(Br,G0,null,"bool"),KR={kernelName:Br,backendName:"cpu",kernelFunc:jR};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8372,7 +8372,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const W0=rt((n,e)=>nnn<=e?1:0),XR=ft(Aa,U0,null,"bool"),YR={kernelName:Aa,backendName:"cpu",kernelFunc:XR};/** + */const q0=rt((n,e)=>n<=e?1:0),ZR=ft(Aa,q0,null,"bool"),QR={kernelName:Aa,backendName:"cpu",kernelFunc:ZR};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8402,7 +8402,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function G0(n,e,t){const s=(e-n)/(t-1),o=Nt(t,"float32");o[0]=n;for(let r=1;rMath.log(n)),ZR=Os(Gr,H0),QR={kernelName:Gr,backendName:"cpu",kernelFunc:ZR};/** + */const K0=es(n=>Math.log(n)),JR=Os(Gr,K0),eA={kernelName:Gr,backendName:"cpu",kernelFunc:JR};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8432,7 +8432,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function j0(n,e,t,s){const o=Tt(s,H(t));for(let r=0;ra)&&(a=c)}o[r]=a}return o}/** + */function X0(n,e,t,s){const o=Tt(s,H(t));for(let r=0;ra)&&(a=c)}o[r]=a}return o}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8447,7 +8447,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const q0=rt((n,e)=>Math.max(n,e)),JR=ft(jr,q0),eA={kernelName:jr,backendName:"cpu",kernelFunc:JR};/** + */const Y0=rt((n,e)=>Math.max(n,e)),tA=ft(qr,Y0),nA={kernelName:qr,backendName:"cpu",kernelFunc:tA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8462,7 +8462,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const K0=rt((n,e)=>Math.min(n,e)),tA=ft(qr,K0),nA={kernelName:qr,backendName:"cpu",kernelFunc:tA};/** + */const Z0=rt((n,e)=>Math.min(n,e)),sA=ft(jr,Z0),oA={kernelName:jr,backendName:"cpu",kernelFunc:sA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8477,7 +8477,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ep=rt((n,e)=>n*e),sA=Qd((n,e,t,s)=>({real:n*t-e*s,imag:n*s+e*t})),rc=ft(Xr,ep,sA),oA={kernelName:Xr,backendName:"cpu",kernelFunc:rc};/** + */const ep=rt((n,e)=>n*e),rA=Qd((n,e,t,s)=>({real:n*t-e*s,imag:n*s+e*t})),ic=ft(Xr,ep,rA),iA={kernelName:Xr,backendName:"cpu",kernelFunc:ic};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8492,7 +8492,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function X0(n,e,t){const s=xs(-1,t);return ep([],e,s,n,t)}function rA(n){const{inputs:e,backend:t}=n,{x:s}=e;ce(s,"neg");const o=t.data.get(s.dataId).values,[r,i]=X0(o,s.shape,s.dtype);return t.makeTensorInfo(i,s.dtype,r)}const iA={kernelName:Wa,backendName:"cpu",kernelFunc:rA};/** + */function Q0(n,e,t){const s=xs(-1,t);return ep([],e,s,n,t)}function aA(n){const{inputs:e,backend:t}=n,{x:s}=e;ce(s,"neg");const o=t.data.get(s.dataId).values,[r,i]=Q0(o,s.shape,s.dtype);return t.makeTensorInfo(i,s.dtype,r)}const lA={kernelName:Wa,backendName:"cpu",kernelFunc:aA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8507,7 +8507,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Y0=rt((n,e)=>n!==e?1:0),aA=ft(Ua,Y0,null,"bool"),lA={kernelName:Ua,backendName:"cpu",kernelFunc:aA};/** + */const J0=rt((n,e)=>n!==e?1:0),cA=ft(Ua,J0,null,"bool"),uA={kernelName:Ua,backendName:"cpu",kernelFunc:cA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8522,7 +8522,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function tp(n,e,t,s,o){const r=e.length,i=H(e),a=de(e),l=de(o),c=Tt(t,H(o));for(let u=0;ut.disposeIntermediateTensorInfo(b)),t.makeTensorInfo(x,m,f)}const hA={kernelName:Xa,backendName:"cpu",kernelFunc:uA};/** + */function e1(n,e,t,s){const[o,r]=xt(n,s),i=Yt(e,"int32"),a=Nt(H(o),i),l=H(r);for(let c=0;ct.disposeIntermediateTensorInfo(b)),t.makeTensorInfo(x,m,f)}const pA={kernelName:Xa,backendName:"cpu",kernelFunc:dA};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8567,7 +8567,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function dA(n,e,t){n.forEach((s,o)=>{if(s<0||s>=t){const r=_o(o,e.length,de(e)).join(",");throw new Error(`indices[${r}] = ${s} is not in [0, ${t})`)}})}function pA(n,e){for(let t=0;to)throw new Error("Ragged splits must not point past values");for(let r=1;rs[r])throw new Error("Ragged splits must be sorted in ascending order")}}function fA(n,e,t,s){const o=[];let r=0;const i=e.length-1+t.length,a=new Array(i).fill(null).map(()=>[0]);pA(t,s);let l=1;for(let c=0;c=0){const g=a[f],m=g[g.length-1]-p[u];for(let x=u;xo[i]=r)}return e}function Q0(n,e){const t=n.slice(0,e);for(;t.length{if(s<0||s>=t){const r=Oo(o,e.length,de(e)).join(",");throw new Error(`indices[${r}] = ${s} is not in [0, ${t})`)}})}function mA(n,e){for(let t=0;to)throw new Error("Ragged splits must not point past values");for(let r=1;rs[r])throw new Error("Ragged splits must be sorted in ascending order")}}function gA(n,e,t,s){const o=[];let r=0;const i=e.length-1+t.length,a=new Array(i).fill(null).map(()=>[0]);mA(t,s);let l=1;for(let c=0;c=0){const g=a[f],m=g[g.length-1]-p[u];for(let x=u;xo[i]=r)}return e}function t1(n,e){const t=n.slice(0,e);for(;t.length1)throw new Error("starts must be a scalar or vector");if(o.length>1)throw new Error("limits must be a scalar or vector");if(i.length>1)throw new Error("deltas must be a scalar or vector");const a=e.length===0,l=o.length===0,c=i.length===0,u=[];a||u.push(e[0]),l||u.push(o[0]),c||u.push(i[0]);for(let m=1;m0&&bx)y=0;else if(y=Math.ceil(Math.abs((b-x)/w)),y>e1)throw new Error(`Requires ((limit - start) / delta) <= ${e1}`);d[m+1]=d[m]+y}const p=d[h],f=Je(t,p);let g=0;for(let m=0;m1)throw new Error("starts must be a scalar or vector");if(o.length>1)throw new Error("limits must be a scalar or vector");if(i.length>1)throw new Error("deltas must be a scalar or vector");const a=e.length===0,l=o.length===0,c=i.length===0,u=[];a||u.push(e[0]),l||u.push(o[0]),c||u.push(i[0]);for(let m=1;m0&&bx)y=0;else if(y=Math.ceil(Math.abs((b-x)/w)),y>s1)throw new Error(`Requires ((limit - start) / delta) <= ${s1}`);d[m+1]=d[m]+y}const p=d[h],f=Je(t,p);let g=0;for(let m=0;ms&&(s=r)}return s}static getMaxWidthValueRowID(e){const t=e.length;if(t===0)return 0;let s=0,o=e[0],r=0;for(let i=1;i"Final length of result must be equal to firstDimension."),r}calculateOutputIndexRowSplit(e,t,s,o){const r=e.length,i=[];for(let a=0;a0&&i.length!==e[r-1])throw new Error("Invalid row split size.");return i}calculateOutputIndexValueRowID(e,t,s,o){const r=e.length,i=[];if(r===0)return[];let a=0,l=e[0];if(l>=t.length)throw new Error(`Got currentValueRowId=${l}, which is not less than ${t.length}`);let c=t[l];i.push(c);for(let u=1;u=0&&(++a,a=t.length)throw new Error(`Got nextValueRowId=${h} which is not less than ${t.length}`);c=t[h]}i.push(c)}if(i.length!==e.length)throw new Error("Invalid row ids.");return i}calculateOutputIndex(e,t,s,o){const r=this.getRowPartitionTensor(e),i=this.getRowPartitionTypeByDimension(e);switch(i){case wn.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(r,t,s,o);case wn.ROW_SPLITS:if(r.length-1>t.length)throw new Error(`Row partition size is greater than output size: ${r.length-1} > ${t.length}`);return this.calculateOutputIndexRowSplit(r,t,s,o);default:throw new Error(`Unsupported partition type: ${wn[i]}`)}}getFirstDimensionSize(){const e=this.rowPartitionValues[0];if(this.rowPartitionTypes.length===0)throw new Error("No row_partition_types given.");const t=this.rowPartitionTypes[0];switch(t){case wn.FIRST_DIM_SIZE:return e[0];case wn.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case wn.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${wn[t]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");const t=this.getFirstDimensionSize(),s=this.calculateOutputSize(t),o=new Array(this.raggedRank+1);o[o.length-1]=1;for(let l=o.length-2;l>=0;--l)o[l]=o[l+1]*s[l+1];const r=s1(s,!1),i=Je(this.valuesDType,H(r));if(o[0]*s[0]>0){let l=this.calculateFirstParentOutputIndex(t,o[0],s[0]);for(let c=1;c<=this.raggedRank;++c)l=this.calculateOutputIndex(c-1,l,o[c],s[c]);this.setOutput(this.raggedRank,l,i,r)}return[r,i]}setOutput(e,t,s,o){if(s.length===0)return;const r=this.values,i=s;let a=o.slice();a=a.slice(e+1);const l=H(a),c=t.length;let u=this.defaultValue;if(u.length!==l&&u.length!==1){const f=this.defaultValueShape;z(()=>{const g=_(u,f);u=Ci(g,a).dataSync()})}let h=0,d=0,p=0;for(let f=0;f<=c;++f){let g=f=c){const m=s.length;g=Math.floor(m/l)}if(g>p)if(this.defaultValue.length===1)i.subarray(p*l,g*l).fill(this.defaultValue[0]),p=g;else for(;g>p;){const m=i.slice(p*l);n1(m,u,l),++p}g<0?(h=f+1,d=p):(h=f,d=p,p=d+1)}}}function n1(n,e,t){for(let s=0;s= 0`);if(s<-1)throw new Error(`Dimension ${s} must be >= -1`);s=-1}t.push(s)}return t}function o1(n,e,t,s,o,r,i,a,l,c){return new ic(n,e,t,s,o,r,i,a,l,c).compute()}/** + */var wn=En;class ac{constructor(e,t,s,o,r,i,a,l,c,u){this.shape=e,this.shapeShape=t,this.values=s,this.valuesShape=o,this.valuesDType=r,this.defaultValue=i,this.defaultValueShape=a,this.rowPartitionValues=l,this.rowPartitionValuesShapes=c,this.rowPartitionTypes=lg(u),this.raggedRank=cg(this.rowPartitionTypes)}getRowPartitionTypeByDimension(e){return this.rowPartitionTypes[0]===wn.FIRST_DIM_SIZE?this.rowPartitionTypes[e+1]:this.rowPartitionTypes[e]}getRowPartitionTensor(e){return this.rowPartitionTypes[0]===wn.FIRST_DIM_SIZE?this.rowPartitionValues[e+1]:this.rowPartitionValues[e]}getMaxWidth(e){const t=this.getRowPartitionTensor(e-1);switch(this.getRowPartitionTypeByDimension(e-1)){case wn.VALUE_ROWIDS:return ac.getMaxWidthValueRowID(t);case wn.ROW_SPLITS:return ac.getMaxWidthRowSplit(t);default:throw new Error(`Cannot handle partition type ${wn[this.getRowPartitionTypeByDimension(e-1)]}`)}}static getMaxWidthRowSplit(e){const t=e.length;if(t===0||t===1)return 0;let s=0;for(let o=0;os&&(s=r)}return s}static getMaxWidthValueRowID(e){const t=e.length;if(t===0)return 0;let s=0,o=e[0],r=0;for(let i=1;i"Final length of result must be equal to firstDimension."),r}calculateOutputIndexRowSplit(e,t,s,o){const r=e.length,i=[];for(let a=0;a0&&i.length!==e[r-1])throw new Error("Invalid row split size.");return i}calculateOutputIndexValueRowID(e,t,s,o){const r=e.length,i=[];if(r===0)return[];let a=0,l=e[0];if(l>=t.length)throw new Error(`Got currentValueRowId=${l}, which is not less than ${t.length}`);let c=t[l];i.push(c);for(let u=1;u=0&&(++a,a=t.length)throw new Error(`Got nextValueRowId=${h} which is not less than ${t.length}`);c=t[h]}i.push(c)}if(i.length!==e.length)throw new Error("Invalid row ids.");return i}calculateOutputIndex(e,t,s,o){const r=this.getRowPartitionTensor(e),i=this.getRowPartitionTypeByDimension(e);switch(i){case wn.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(r,t,s,o);case wn.ROW_SPLITS:if(r.length-1>t.length)throw new Error(`Row partition size is greater than output size: ${r.length-1} > ${t.length}`);return this.calculateOutputIndexRowSplit(r,t,s,o);default:throw new Error(`Unsupported partition type: ${wn[i]}`)}}getFirstDimensionSize(){const e=this.rowPartitionValues[0];if(this.rowPartitionTypes.length===0)throw new Error("No row_partition_types given.");const t=this.rowPartitionTypes[0];switch(t){case wn.FIRST_DIM_SIZE:return e[0];case wn.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case wn.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${wn[t]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");const t=this.getFirstDimensionSize(),s=this.calculateOutputSize(t),o=new Array(this.raggedRank+1);o[o.length-1]=1;for(let l=o.length-2;l>=0;--l)o[l]=o[l+1]*s[l+1];const r=i1(s,!1),i=Je(this.valuesDType,H(r));if(o[0]*s[0]>0){let l=this.calculateFirstParentOutputIndex(t,o[0],s[0]);for(let c=1;c<=this.raggedRank;++c)l=this.calculateOutputIndex(c-1,l,o[c],s[c]);this.setOutput(this.raggedRank,l,i,r)}return[r,i]}setOutput(e,t,s,o){if(s.length===0)return;const r=this.values,i=s;let a=o.slice();a=a.slice(e+1);const l=H(a),c=t.length;let u=this.defaultValue;if(u.length!==l&&u.length!==1){const f=this.defaultValueShape;P(()=>{const g=_(u,f);u=Ci(g,a).dataSync()})}let h=0,d=0,p=0;for(let f=0;f<=c;++f){let g=f=c){const m=s.length;g=Math.floor(m/l)}if(g>p)if(this.defaultValue.length===1)i.subarray(p*l,g*l).fill(this.defaultValue[0]),p=g;else for(;g>p;){const m=i.slice(p*l);r1(m,u,l),++p}g<0?(h=f+1,d=p):(h=f,d=p,p=d+1)}}}function r1(n,e,t){for(let s=0;s= 0`);if(s<-1)throw new Error(`Dimension ${s} must be >= -1`);s=-1}t.push(s)}return t}function a1(n,e,t,s,o,r,i,a,l,c){return new ac(n,e,t,s,o,r,i,a,l,c).compute()}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8612,7 +8612,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function r1(n,e,t,s){const o=n===e,r=n1;if(o||r||i)return Nt(0,s);const a=Math.abs(Math.ceil((e-n)/t)),l=Nt(a,s);e1;if(o||r||i)return Nt(0,s);const a=Math.abs(Math.ceil((e-n)/t)),l=Nt(a,s);e1/Math.sqrt(n)),bA=Os(ti,i1),yA={kernelName:ti,backendName:"cpu",kernelFunc:bA};/** + */const c1=es(n=>1/Math.sqrt(n)),wA=Os(ti,c1),CA={kernelName:ti,backendName:"cpu",kernelFunc:wA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8642,7 +8642,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function wo(n,e,t,s,o,r,i,a,l,c){const u=[s/o,o],h=n.values,d=e.values;if(s===0)return ve(t,e.dtype);const p=l instanceof yt?l:ve(u,e.dtype);typeof l=="string"||typeof l=="number"?p.values.fill(l):typeof l=="boolean"&&p.values.fill(+l);for(let f=0;f=s/o)throw new Error(`Invalid indices: ${g} does not index into ${t}`);for(let x=0;x=s/o)throw new Error(`Invalid indices: ${g} does not index into ${t}`);for(let x=0;x1/(1+Math.exp(-n))),a1=Pe(ii,n=>1/(1+Math.exp(-n))),CA={kernelName:ii,backendName:"cpu",kernelFunc:a1};/** + */const IA=es(n=>1/(1+Math.exp(-n))),u1=Pe(ii,n=>1/(1+Math.exp(-n))),$A={kernelName:ii,backendName:"cpu",kernelFunc:u1};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8672,7 +8672,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function l1(n,e,t,s,o){const r=Hh(s,e,t),i=H(t),a=de(s);if(r){const h=jh(e,a);return o==="string"?n.slice(h,h+i):n.subarray(h,h+i)}const l=o==="string"?us(n):n,c=ve(s,o,l),u=ve(t,o);for(let h=0;hf+e[g]);u.set(c.get(...p),...d)}return o==="string"?Ag(u.values):u.values}function Co(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{begin:r,size:i}=s;ce(o,"slice");const[a,l]=El(o,r,i);Uh(o,a,l);const c=t.data.get(o.dataId).values,u=l1(c,a,l,o.shape,o.dtype);return t.makeTensorInfo(l,o.dtype,u)}const IA={kernelName:tl,backendName:"cpu",kernelFunc:Co};/** + */function h1(n,e,t,s,o){const r=Hh(s,e,t),i=H(t),a=de(s);if(r){const h=qh(e,a);return o==="string"?n.slice(h,h+i):n.subarray(h,h+i)}const l=o==="string"?us(n):n,c=ve(s,o,l),u=ve(t,o);for(let h=0;hf+e[g]);u.set(c.get(...p),...d)}return o==="string"?Dg(u.values):u.values}function Io(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{begin:r,size:i}=s;ce(o,"slice");const[a,l]=Rl(o,r,i);Uh(o,a,l);const c=t.data.get(o.dataId).values,u=h1(c,a,l,o.shape,o.dtype);return t.makeTensorInfo(l,o.dtype,u)}const vA={kernelName:tl,backendName:"cpu",kernelFunc:Io};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8687,7 +8687,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function c1(n,e,t,s,o,r,i){const a=e[0],l=r[0],c=new Array(l),u=new Array(a),h=e[1];if(l===0){if(a!==0)throw new Error(bg(a));const m=Je(t,0),x=Je(o,0);return[m,[0,h],x,c,u]}let d=!0,p=0;const f=new Array(l).fill(0);for(let m=0;m=l)throw new Error(wg(m,x,l));++f[x],d=d&&x>=p,p=x}let g=!0;for(let m=0;m0&&(f[m]+=f[m-1])}if(g&&d){const m=n,x=s;for(let b=0;b=l)throw new Error(Cg(m,x,l));++f[x],d=d&&x>=p,p=x}let g=!0;for(let m=0;m0&&(f[m]+=f[m-1])}if(g&&d){const m=n,x=s;for(let b=0;b0){p[d-1]=1;for(let m=d-2;m>=0;--m)p[m]=p[m+1]*s[m+1]}const f=[];if(a>0){f[a-1]=1;for(let m=a-2;m>=0;--m)f[m]=f[m+1]*l[m+1]}const g=Je(t,i*a);for(let m=0;m0){p[d-1]=1;for(let m=d-2;m>=0;--m)p[m]=p[m+1]*s[m+1]}const f=[];if(a>0){f[a-1]=1;for(let m=a-2;m>=0;--m)f[m]=f[m+1]*l[m+1]}const g=Je(t,i*a);for(let m=0;m0?o[a-1]+1:0;if(h<0)throw new Error(pd());const d=e.slice();d[0]=h;const p=d.reduce((w,y)=>w*y,1),f=Je(t,p);if(a===0)return h>0&&f.fill(i),[f,d];if(h<=0)throw new Error(pd());let g=0,m=1,x=0,b=o[g];for(;;){let w=0;if(m=w)throw new Error(Sg())}if(b<0||b>=h)throw new Error(Tg(b,h));b>x&&f.fill(i,x*c,b*c);for(let y=g;y=l[0])throw new Error(Ng(y,s[y],l[0]));for(let I=0;Ia)break}return x0?o[a-1]+1:0;if(h<0)throw new Error(pd());const d=e.slice();d[0]=h;const p=d.reduce((w,y)=>w*y,1),f=Je(t,p);if(a===0)return h>0&&f.fill(i),[f,d];if(h<=0)throw new Error(pd());let g=0,m=1,x=0,b=o[g];for(;;){let w=0;if(m=w)throw new Error(Tg())}if(b<0||b>=h)throw new Error(Ng(b,h));b>x&&f.fill(i,x*c,b*c);for(let y=g;y=l[0])throw new Error(Eg(y,s[y],l[0]));for(let I=0;Ia)break}return xMath.sqrt(n)),vA=Pe(li,n=>Math.sqrt(n)),kA={kernelName:li,backendName:"cpu",kernelFunc:vA};/** + */const kA=es(n=>Math.sqrt(n)),SA=Pe(li,n=>Math.sqrt(n)),TA={kernelName:li,backendName:"cpu",kernelFunc:SA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8747,7 +8747,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const h1=rt((n,e)=>{const t=n-e;return t*t}),SA=ft(ci,h1),TA={kernelName:ci,backendName:"cpu",kernelFunc:SA};/** + */const f1=rt((n,e)=>{const t=n-e;return t*t}),NA=ft(ci,f1),EA={kernelName:ci,backendName:"cpu",kernelFunc:NA};/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8762,7 +8762,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const d1=es((n,e)=>{const{pattern:t,replaceGlobal:s,rewrite:o}=e;return n.replace(new RegExp(t,s?"g":""),o)}),NA=Os(Tu,d1),EA={kernelName:Tu,backendName:"cpu",kernelFunc:NA};/** + */const m1=es((n,e)=>{const{pattern:t,replaceGlobal:s,rewrite:o}=e;return n.replace(new RegExp(t,s?"g":""),o)}),RA=Os(Nu,m1),AA={kernelName:Nu,backendName:"cpu",kernelFunc:RA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8777,7 +8777,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function p1(n,e,t,s){const o=ve(n,e.dtype);for(let r=0;r0?0:a-l);let p=0;p+=c*this.leftPad.length;for(let b=0;bb.forEach(w=>g[m++]=w);for(let b=0;b0){x(e[d+h-1]);for(let b=0;b0){let l=t[0];if(l!==0)throw new Error(`First split value must be 0, got ${l}`);for(let c=1;c=l;if(u=u&&t[c]<=s,!u)throw new Error(`Invalid split value ${t[c]}, must be in [${l}, ${s}]`);l=t[c]}if(l!==s)throw new Error(`Last split value must be data size. Expected ${s}, got ${l}`)}const r=o-1,i=Je("int32",o);if(s===0||o===0){const l=new Array(s);for(let c=0;c<=r;++c)i[c]=0;return[l,i]}i[0]=0;for(let l=1;l<=r;++l){const c=t[l]-t[l-1];let u=0;this.nGramWidths.forEach(h=>{u+=this.getNumNGrams(c,h)}),this.preserveShort&&c>0&&u===0&&(u=1),i[l]=i[l-1]+u}const a=new Array(i[r]);for(let l=0;l{const d=t[l+1]-t[l],p=this.getNumNGrams(d,h);this.createNGrams(e,c,a,u,p,h),u+=p}),this.preserveShort&&u===i[l]){const h=t[l+1]-t[l];if(h===0)continue;const d=h+2*this.padWidth;this.createNGrams(e,c,a,u,1,d)}}return[a,i]}}function f1(n,e,t,s,o,r,i,a){return new RA(t,s,o,r,i,a).compute(n,e)}/** + */class DA{constructor(e,t,s,o,r,i){this.separator=bs(e),this.nGramWidths=t,this.leftPad=bs(s),this.rightPad=bs(o),this.padWidth=r,this.preserveShort=i}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){const s=this.getPadWidth(t);return Math.max(0,e+2*s-t+1)}createNGrams(e,t,s,o,r,i){for(let a=0;a0?0:a-l);let p=0;p+=c*this.leftPad.length;for(let b=0;bb.forEach(w=>g[m++]=w);for(let b=0;b0){x(e[d+h-1]);for(let b=0;b0){let l=t[0];if(l!==0)throw new Error(`First split value must be 0, got ${l}`);for(let c=1;c=l;if(u=u&&t[c]<=s,!u)throw new Error(`Invalid split value ${t[c]}, must be in [${l}, ${s}]`);l=t[c]}if(l!==s)throw new Error(`Last split value must be data size. Expected ${s}, got ${l}`)}const r=o-1,i=Je("int32",o);if(s===0||o===0){const l=new Array(s);for(let c=0;c<=r;++c)i[c]=0;return[l,i]}i[0]=0;for(let l=1;l<=r;++l){const c=t[l]-t[l-1];let u=0;this.nGramWidths.forEach(h=>{u+=this.getNumNGrams(c,h)}),this.preserveShort&&c>0&&u===0&&(u=1),i[l]=i[l-1]+u}const a=new Array(i[r]);for(let l=0;l{const d=t[l+1]-t[l],p=this.getNumNGrams(d,h);this.createNGrams(e,c,a,u,p,h),u+=p}),this.preserveShort&&u===i[l]){const h=t[l+1]-t[l];if(h===0)continue;const d=h+2*this.padWidth;this.createNGrams(e,c,a,u,1,d)}}return[a,i]}}function x1(n,e,t,s,o,r,i,a){return new DA(t,s,o,r,i,a).compute(n,e)}/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8807,7 +8807,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function AA(n,e,t,s){if(!n.length)return;if(e.length===0){for(let r=0;rn-e),DA=Qd((n,e,t,s)=>({real:n-t,imag:e-s})),sp=ft(ui,x1,DA),FA={kernelName:ui,backendName:"cpu",kernelFunc:sp};/** + */const w1=rt((n,e)=>n-e),_A=Qd((n,e,t,s)=>({real:n-t,imag:e-s})),sp=ft(ui,w1,_A),OA={kernelName:ui,backendName:"cpu",kernelFunc:sp};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8852,7 +8852,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function b1(n,e){const t=new Array(n.rank);for(let o=0;o{const t=e.value-n.value;return t===0?n.index-e.index:t};function y1(n,e,t=0,s=n.length-1){for(;s>t;){if(s-t>600){const a=s-t+1,l=e-t+1,c=Math.log(a),u=.5*Math.exp(2*c/3),h=.5*Math.sqrt(c*u*(a-u)/a)*Math.sign(l-a/2),d=Math.max(t,Math.floor(e-l*u/a+h)),p=Math.min(s,Math.floor(e+(a-l)*u/a+h));y1(n,e,d,p)}const o=n[e];let r=t,i=s;for(Ro(n,t,e),Ki(n[s],o)>0&&Ro(n,t,s);r0;)i=i-1}Ki(n[t],o)===0?Ro(n,t,i):(i=i+1,Ro(n,i,s)),i<=e&&(t=i+1),e<=i&&(s=i-1)}}function w1(n,e,t,s,o){const r=e[e.length-1],[i,a]=[n.length/r,r],l=Tt(t,i*s),c=Tt("int32",i*s);for(let h=0;hf[w]={value:b,index:w}),s{const t=e.value-n.value;return t===0?n.index-e.index:t};function I1(n,e,t=0,s=n.length-1){for(;s>t;){if(s-t>600){const a=s-t+1,l=e-t+1,c=Math.log(a),u=.5*Math.exp(2*c/3),h=.5*Math.sqrt(c*u*(a-u)/a)*Math.sign(l-a/2),d=Math.max(t,Math.floor(e-l*u/a+h)),p=Math.min(s,Math.floor(e+(a-l)*u/a+h));I1(n,e,d,p)}const o=n[e];let r=t,i=s;for(Ao(n,t,e),Ki(n[s],o)>0&&Ao(n,t,s);r0;)i=i-1}Ki(n[t],o)===0?Ao(n,t,i):(i=i+1,Ao(n,i,s)),i<=e&&(t=i+1),e<=i&&(s=i-1)}}function $1(n,e,t,s,o){const r=e[e.length-1],[i,a]=[n.length/r,r],l=Tt(t,i*s),c=Tt("int32",i*s);for(let h=0;hf[w]={value:b,index:w}),s{for(let m=0;m{for(let m=0;mnew sc,1);/** + */jf("cpu",()=>new oc,1);/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -8927,7 +8927,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const I1=Pe(Fr,n=>n>=0?n:Math.exp(n)-1),OA={kernelName:Fr,backendName:"cpu",kernelFunc:I1};/** + */const k1=Pe(Fr,n=>n>=0?n:Math.exp(n)-1),MA={kernelName:Fr,backendName:"cpu",kernelFunc:k1};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8942,7 +8942,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $1(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{alpha:r}=s;ce([o],"leakyRelu");const i=H(o.shape),a=t.data.get(o.dataId).values,l=Tt("float32",i);for(let c=0;cn<0?e*n:n);function v1(n){const{inputs:e,backend:t}=n,{x:s,alpha:o}=e;ce([s,o],"prelu");const r=t.data.get(s.dataId).values,i=t.data.get(o.dataId).values,[a,l]=MA(s.shape,o.shape,r,i,"float32");return t.makeTensorInfo(l,"float32",a)}const PA={kernelName:Ka,backendName:"cpu",kernelFunc:v1};/** + */const BA=rt((n,e)=>n<0?e*n:n);function T1(n){const{inputs:e,backend:t}=n,{x:s,alpha:o}=e;ce([s,o],"prelu");const r=t.data.get(s.dataId).values,i=t.data.get(o.dataId).values,[a,l]=BA(s.shape,o.shape,r,i,"float32");return t.makeTensorInfo(l,"float32",a)}const zA={kernelName:Ka,backendName:"cpu",kernelFunc:T1};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -8972,7 +8972,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const k1=Pe(Qr,n=>Math.max(0,n)),BA={kernelName:Qr,backendName:"cpu",kernelFunc:k1};/** + */const N1=Pe(Qr,n=>Math.max(0,n)),VA={kernelName:Qr,backendName:"cpu",kernelFunc:N1};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -8987,7 +8987,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const S1=Pe(Jr,n=>Math.min(Math.max(0,n),6)),zA={kernelName:Jr,backendName:"cpu",kernelFunc:S1};/** + */const E1=Pe(Jr,n=>Math.min(Math.max(0,n),6)),WA={kernelName:Jr,backendName:"cpu",kernelFunc:E1};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9002,7 +9002,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ac(n,e,t,s,o){if(t==="linear")return Jn({inputs:{x:e},backend:n});if(t==="relu")return k1({inputs:{x:e},backend:n});if(t==="elu")return I1({inputs:{x:e},backend:n});if(t==="relu6")return S1({inputs:{x:e},backend:n});if(t==="prelu")return v1({inputs:{x:e,alpha:s},backend:n});if(t==="leakyrelu")return $1({inputs:{x:e},backend:n,attrs:{alpha:o}});if(t==="sigmoid")return a1({inputs:{x:e},backend:n});throw new Error(`Activation ${t} has not been implemented for the CPU backend.`)}/** + */function lc(n,e,t,s,o){if(t==="linear")return Jn({inputs:{x:e},backend:n});if(t==="relu")return N1({inputs:{x:e},backend:n});if(t==="elu")return k1({inputs:{x:e},backend:n});if(t==="relu6")return E1({inputs:{x:e},backend:n});if(t==="prelu")return T1({inputs:{x:e,alpha:s},backend:n});if(t==="leakyrelu")return S1({inputs:{x:e},backend:n,attrs:{alpha:o}});if(t==="sigmoid")return u1({inputs:{x:e},backend:n});throw new Error(`Activation ${t} has not been implemented for the CPU backend.`)}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9017,7 +9017,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ue(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{shape:r}=s,i=H(o.shape),a=Pp(r,i),l=H(a);$(i===l,()=>`The new shape (${a}) has ${l} elements and the old shape (${o.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`),t.incRef(o.dataId);const c=t.data.get(o.dataId);if(c.complexTensorInfos!=null){const u=c.complexTensorInfos.real,h=c.complexTensorInfos.imag;u.shape=a,h.shape=a}return{dataId:o.dataId,shape:a,dtype:o.dtype}}const VA={kernelName:Ya,backendName:"cpu",kernelFunc:Ue};/** + */function Ue(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{shape:r}=s,i=H(o.shape),a=Pp(r,i),l=H(a);$(i===l,()=>`The new shape (${a}) has ${l} elements and the old shape (${o.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`),t.incRef(o.dataId);const c=t.data.get(o.dataId);if(c.complexTensorInfos!=null){const u=c.complexTensorInfos.real,h=c.complexTensorInfos.imag;u.shape=a,h.shape=a}return{dataId:o.dataId,shape:a,dtype:o.dtype}}const UA={kernelName:Ya,backendName:"cpu",kernelFunc:Ue};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9032,7 +9032,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function T1(n){const{inputs:e,backend:t,attrs:s}=n,{a:o,b:r}=e,{transposeA:i,transposeB:a}=s;ce([o,r],"matMul");const l=o.shape.length,c=r.shape.length,u=i?o.shape[l-2]:o.shape[l-1],h=a?r.shape[c-1]:r.shape[c-2],d=i?o.shape[l-1]:o.shape[l-2],p=a?r.shape[c-2]:r.shape[c-1],f=o.shape.slice(0,-2),g=r.shape.slice(0,-2),m=H(f),x=H(g),w=we(o.shape.slice(0,-2),r.shape.slice(0,-2)).concat([d,p]);$(u===h,()=>`Error in matMul: inner shapes (${u}) and (${h}) of Tensors with shapes ${o.shape} and ${r.shape} and transposeA=${i} and transposeB=${a} must match.`);const y=i?[m,u,d]:[m,d,u],C=a?[x,p,h]:[x,h,p],I=Ue({inputs:{x:o},backend:t,attrs:{shape:y}}),v=Ue({inputs:{x:r},backend:t,attrs:{shape:C}}),k=i?I.shape[1]:I.shape[2],S=i?I.shape[2]:I.shape[1],T=a?v.shape[1]:v.shape[2],E=Math.max(m,x),V=t.data.get(I.dataId).values,M=t.data.get(v.dataId).values,L=de(I.shape),R=de(v.shape),[P,G,B]=i?[L[0],1,L[1]]:[L[0],L[1],1],[j,K,X]=a?[1,R[1],R[0]]:[R[1],1,R[0]],J=S*T,q=ve([E,S,T],I.dtype),Q=q.values,Y=t.blockSize;for(let te=0;te`Error in matMul: inner shapes (${u}) and (${h}) of Tensors with shapes ${o.shape} and ${r.shape} and transposeA=${i} and transposeB=${a} must match.`);const y=i?[m,u,d]:[m,d,u],C=a?[x,p,h]:[x,h,p],I=Ue({inputs:{x:o},backend:t,attrs:{shape:y}}),v=Ue({inputs:{x:r},backend:t,attrs:{shape:C}}),k=i?I.shape[1]:I.shape[2],S=i?I.shape[2]:I.shape[1],T=a?v.shape[1]:v.shape[2],E=Math.max(m,x),V=t.data.get(I.dataId).values,M=t.data.get(v.dataId).values,L=de(I.shape),R=de(v.shape),[B,G,z]=i?[L[0],1,L[1]]:[L[0],L[1],1],[q,K,X]=a?[1,R[1],R[0]]:[R[1],1,R[0]],J=S*T,j=ve([E,S,T],I.dtype),Q=j.values,Z=t.blockSize;for(let te=0;teMath.acos(n)),jA={kernelName:wr,backendName:"cpu",kernelFunc:HA};/** + */const jA=Pe(wr,n=>Math.acos(n)),KA={kernelName:wr,backendName:"cpu",kernelFunc:jA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9077,7 +9077,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const qA=Pe(Cr,n=>Math.acosh(n)),KA={kernelName:Cr,backendName:"cpu",kernelFunc:qA};/** + */const XA=Pe(Cr,n=>Math.acosh(n)),YA={kernelName:Cr,backendName:"cpu",kernelFunc:XA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9092,7 +9092,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function XA(n){const{inputs:e,backend:t}=n,s=e;ce(e,"addN");const o=s.map(a=>t.data.get(a.dataId).values),r=ve(s[0].shape,s[0].dtype),i=r.values;for(let a=0;at.data.get(a.dataId).values),r=ve(s[0].shape,s[0].dtype),i=r.values;for(let a=0;ab&&(b=C,w=y)}p[m]=w}return c.forEach(m=>t.disposeIntermediateTensorInfo(m)),t.makeTensorInfo(u,"int32",p)}const nD={kernelName:ua,backendName:"cpu",kernelFunc:tD};/** + */function sD(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r}=s;ce(o,"argMax");let i=$e(r,o.shape);const a=Ye(i,o.shape.length);let l=o;const c=[];a!=null&&(l=qt({inputs:{x:o},backend:t,attrs:{perm:a}}),c.push(l),i=tt(i.length,l.shape.length)),i=[i[0]],It("argMax",i,l.shape.length);const[u,h]=xt(l.shape,i),d=H(u),p=Nt(d,"int32"),f=H(h),g=t.data.get(l.dataId).values;for(let m=0;mb&&(b=C,w=y)}p[m]=w}return c.forEach(m=>t.disposeIntermediateTensorInfo(m)),t.makeTensorInfo(u,"int32",p)}const oD={kernelName:ua,backendName:"cpu",kernelFunc:sD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9152,7 +9152,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function sD(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r}=s;ce(o,"argMin");let i=$e(r,o.shape);const a=Ye(i,o.shape.length);let l=o;const c=[];a!=null&&(l=jt({inputs:{x:o},backend:t,attrs:{perm:a}}),c.push(l),i=tt(i.length,l.shape.length)),i=[i[0]],It("argMin",i,l.shape.length);const[u,h]=xt(l.shape,i),d=H(u),p=Nt(d,"int32"),f=H(h),g=t.data.get(l.dataId).values;for(let m=0;mt.disposeIntermediateTensorInfo(m)),t.makeTensorInfo(u,"int32",p)}const oD={kernelName:ha,backendName:"cpu",kernelFunc:sD};/** + */function rD(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r}=s;ce(o,"argMin");let i=$e(r,o.shape);const a=Ye(i,o.shape.length);let l=o;const c=[];a!=null&&(l=qt({inputs:{x:o},backend:t,attrs:{perm:a}}),c.push(l),i=tt(i.length,l.shape.length)),i=[i[0]],It("argMin",i,l.shape.length);const[u,h]=xt(l.shape,i),d=H(u),p=Nt(d,"int32"),f=H(h),g=t.data.get(l.dataId).values;for(let m=0;mt.disposeIntermediateTensorInfo(m)),t.makeTensorInfo(u,"int32",p)}const iD={kernelName:ha,backendName:"cpu",kernelFunc:rD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9167,7 +9167,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const rD=Pe(Ir,n=>Math.asin(n)),iD={kernelName:Ir,backendName:"cpu",kernelFunc:rD};/** + */const aD=Pe(Ir,n=>Math.asin(n)),lD={kernelName:Ir,backendName:"cpu",kernelFunc:aD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9182,7 +9182,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const aD=Pe($r,n=>Math.asinh(n)),lD={kernelName:$r,backendName:"cpu",kernelFunc:aD};/** + */const cD=Pe($r,n=>Math.asinh(n)),uD={kernelName:$r,backendName:"cpu",kernelFunc:cD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9197,7 +9197,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const cD=Pe(vr,n=>Math.atan(n)),uD={kernelName:vr,backendName:"cpu",kernelFunc:cD};/** + */const hD=Pe(vr,n=>Math.atan(n)),dD={kernelName:vr,backendName:"cpu",kernelFunc:hD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9212,7 +9212,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const hD=rt((n,e)=>Math.atan2(n,e)),dD=ft(Sr,hD),pD={kernelName:Sr,backendName:"cpu",kernelFunc:dD};/** + */const pD=rt((n,e)=>Math.atan2(n,e)),fD=ft(Sr,pD),mD={kernelName:Sr,backendName:"cpu",kernelFunc:fD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9227,7 +9227,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const fD=Pe(kr,n=>Math.atanh(n)),mD={kernelName:kr,backendName:"cpu",kernelFunc:fD};/** + */const gD=Pe(kr,n=>Math.atanh(n)),xD={kernelName:kr,backendName:"cpu",kernelFunc:gD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9242,7 +9242,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function op(n,e,t,s,o,r){const i=o.strideHeight,a=o.strideWidth,l=o.dilationHeight,c=o.dilationWidth,u=o.effectiveFilterHeight,h=o.effectiveFilterWidth,d=o.padInfo.top,p=o.padInfo.left,f=r==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,g=ve(o.outShape,t),m=g.values,x=o.outShape[1]*o.outShape[2]*o.outShape[3],b=o.outShape[2]*o.outShape[3],w=o.outShape[3];for(let y=0;yG?G=Y:r==="avg"&&(B+=Y,j++)}if(isNaN(G))break}const K=V+M*w+v;m[K]=r==="avg"?B/j:G}}}return g}function N1(n,e,t,s,o=!1,r=!1){const i=ve(s.outShape,"int32"),a=s.strideHeight,l=s.strideWidth,c=s.dilationHeight,u=s.dilationWidth,h=s.effectiveFilterHeight,d=s.effectiveFilterWidth,p=s.padInfo.top,f=s.padInfo.left,g=ve(e,t,n);for(let m=0;mT&&(T=P,o?E=r?((m*s.inHeight+V)*s.inWidth+L)*s.inChannels+x:(V*s.inWidth+L)*s.inChannels+x:E=M*d+R)}}i.set(E,m,b,I,x)}}return i}function E1(n,e,t,s,o,r){const i=o.strideDepth,a=o.strideHeight,l=o.strideWidth,c=o.dilationDepth,u=o.dilationHeight,h=o.dilationWidth,d=o.effectiveFilterDepth,p=o.effectiveFilterHeight,f=o.effectiveFilterWidth,g=o.padInfo.front,m=o.padInfo.top,x=o.padInfo.left,b=r==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,w=ve(o.outShape,t),y=w.values,C=o.outShape[1]*o.outShape[2]*o.outShape[3]*o.outShape[4],I=o.outShape[2]*o.outShape[3]*o.outShape[4],v=o.outShape[3]*o.outShape[4],k=o.outShape[4];for(let S=0;She?he=Xe:r==="avg"&&(le+=Xe,ae++),isNaN(he))break}if(isNaN(he))break}if(isNaN(he))break}const ye=ie+V;y[ye]=r==="avg"?le/Math.max(ae,1):he}}}}return w}function gD(n,e){const t=ve(e.outShape,"int32"),s=e.strideDepth,o=e.strideHeight,r=e.strideWidth,i=e.dilationDepth,a=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterDepth,u=e.effectiveFilterHeight,h=e.effectiveFilterWidth,d=e.padInfo.front,p=e.padInfo.top,f=e.padInfo.left;for(let g=0;g=M&&(M=X,L=P*u*h+B*u+K)}}}t.set(L,g,x,C,S,m)}}}return t}/** + */function op(n,e,t,s,o,r){const i=o.strideHeight,a=o.strideWidth,l=o.dilationHeight,c=o.dilationWidth,u=o.effectiveFilterHeight,h=o.effectiveFilterWidth,d=o.padInfo.top,p=o.padInfo.left,f=r==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,g=ve(o.outShape,t),m=g.values,x=o.outShape[1]*o.outShape[2]*o.outShape[3],b=o.outShape[2]*o.outShape[3],w=o.outShape[3];for(let y=0;yG?G=Z:r==="avg"&&(z+=Z,q++)}if(isNaN(G))break}const K=V+M*w+v;m[K]=r==="avg"?z/q:G}}}return g}function A1(n,e,t,s,o=!1,r=!1){const i=ve(s.outShape,"int32"),a=s.strideHeight,l=s.strideWidth,c=s.dilationHeight,u=s.dilationWidth,h=s.effectiveFilterHeight,d=s.effectiveFilterWidth,p=s.padInfo.top,f=s.padInfo.left,g=ve(e,t,n);for(let m=0;mT&&(T=B,o?E=r?((m*s.inHeight+V)*s.inWidth+L)*s.inChannels+x:(V*s.inWidth+L)*s.inChannels+x:E=M*d+R)}}i.set(E,m,b,I,x)}}return i}function D1(n,e,t,s,o,r){const i=o.strideDepth,a=o.strideHeight,l=o.strideWidth,c=o.dilationDepth,u=o.dilationHeight,h=o.dilationWidth,d=o.effectiveFilterDepth,p=o.effectiveFilterHeight,f=o.effectiveFilterWidth,g=o.padInfo.front,m=o.padInfo.top,x=o.padInfo.left,b=r==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,w=ve(o.outShape,t),y=w.values,C=o.outShape[1]*o.outShape[2]*o.outShape[3]*o.outShape[4],I=o.outShape[2]*o.outShape[3]*o.outShape[4],v=o.outShape[3]*o.outShape[4],k=o.outShape[4];for(let S=0;She?he=Xe:r==="avg"&&(le+=Xe,ae++),isNaN(he))break}if(isNaN(he))break}if(isNaN(he))break}const ye=ie+V;y[ye]=r==="avg"?le/Math.max(ae,1):he}}}}return w}function bD(n,e){const t=ve(e.outShape,"int32"),s=e.strideDepth,o=e.strideHeight,r=e.strideWidth,i=e.dilationDepth,a=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterDepth,u=e.effectiveFilterHeight,h=e.effectiveFilterWidth,d=e.padInfo.front,p=e.padInfo.top,f=e.padInfo.left;for(let g=0;g=M&&(M=X,L=B*u*h+z*u+K)}}}t.set(L,g,x,C,S,m)}}}return t}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9257,7 +9257,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xD(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e;ce(o,"avgPool");const{filterSize:r,strides:i,pad:a,dimRoundingMode:l}=s,c=1;$(Et(i,c),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=pn(o.shape,r,i,c,a,l);let h;if(u.filterWidth===1&&u.filterHeight===1&&Oe(u.inShape,u.outShape))h=Jn({inputs:{x:o},backend:t});else{const d=t.data.get(o.dataId).values,p=de(o.shape),f=op(d,o.shape,o.dtype,p,u,"avg");h=t.makeTensorInfo(u.outShape,o.dtype,f.values)}return h}const bD={kernelName:da,backendName:"cpu",kernelFunc:xD};/** + */function yD(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e;ce(o,"avgPool");const{filterSize:r,strides:i,pad:a,dimRoundingMode:l}=s,c=1;$(Et(i,c),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=pn(o.shape,r,i,c,a,l);let h;if(u.filterWidth===1&&u.filterHeight===1&&Oe(u.inShape,u.outShape))h=Jn({inputs:{x:o},backend:t});else{const d=t.data.get(o.dataId).values,p=de(o.shape),f=op(d,o.shape,o.dtype,p,u,"avg");h=t.makeTensorInfo(u.outShape,o.dtype,f.values)}return h}const wD={kernelName:da,backendName:"cpu",kernelFunc:yD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9272,7 +9272,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function yD(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{filterSize:r,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=s;ce(o,"avgPool3d");const u=rs(o.shape,r,i,1,a,l,c),h=t.data.get(o.dataId).values,d=E1(h,o.shape,o.dtype,de(o.shape),u,"avg");return t.makeTensorInfo(d.shape,"float32",d.values)}const wD={kernelName:pa,backendName:"cpu",kernelFunc:yD};/** + */function CD(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{filterSize:r,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=s;ce(o,"avgPool3d");const u=rs(o.shape,r,i,1,a,l,c),h=t.data.get(o.dataId).values,d=D1(h,o.shape,o.dtype,de(o.shape),u,"avg");return t.makeTensorInfo(d.shape,"float32",d.values)}const ID={kernelName:pa,backendName:"cpu",kernelFunc:CD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9287,7 +9287,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function CD(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r}=e,{filterSize:i,strides:a,pad:l,dimRoundingMode:c}=s;ce([o,r],"avgPool3DGrad");const u=rs(r.shape,i,a,1,l,c),h=u.strideDepth,d=u.strideHeight,p=u.strideWidth,f=u.filterDepth,g=u.filterHeight,m=u.filterWidth,x=u.dilationDepth,b=u.dilationHeight,w=u.dilationWidth,y=u.effectiveFilterDepth,C=u.effectiveFilterHeight,I=u.effectiveFilterWidth,v=y-1-u.padInfo.front,k=I-1-u.padInfo.left,S=C-1-u.padInfo.top,T=ve(r.shape,"float32"),E=1/(f*g*m),V=t.bufferSync(o);for(let M=0;M=u.outDepth||Math.floor(q)!==q))for(let Q=0;Q=u.outHeight||Math.floor(Y)!==Y))for(let te=0;te=u.outWidth||Math.floor(ie)!==ie)continue;const he=V.get(M,q,Y,ie,L);X+=he}}}T.set(X*E,M,R,P,G,L)}return t.makeTensorInfo(T.shape,T.dtype,T.values)}const ID={kernelName:Kc,backendName:"cpu",kernelFunc:CD};/** + */function $D(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r}=e,{filterSize:i,strides:a,pad:l,dimRoundingMode:c}=s;ce([o,r],"avgPool3DGrad");const u=rs(r.shape,i,a,1,l,c),h=u.strideDepth,d=u.strideHeight,p=u.strideWidth,f=u.filterDepth,g=u.filterHeight,m=u.filterWidth,x=u.dilationDepth,b=u.dilationHeight,w=u.dilationWidth,y=u.effectiveFilterDepth,C=u.effectiveFilterHeight,I=u.effectiveFilterWidth,v=y-1-u.padInfo.front,k=I-1-u.padInfo.left,S=C-1-u.padInfo.top,T=ve(r.shape,"float32"),E=1/(f*g*m),V=t.bufferSync(o);for(let M=0;M=u.outDepth||Math.floor(j)!==j))for(let Q=0;Q=u.outHeight||Math.floor(Z)!==Z))for(let te=0;te=u.outWidth||Math.floor(ie)!==ie)continue;const he=V.get(M,j,Z,ie,L);X+=he}}}T.set(X*E,M,R,B,G,L)}return t.makeTensorInfo(T.shape,T.dtype,T.values)}const vD={kernelName:Xc,backendName:"cpu",kernelFunc:$D};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9302,7 +9302,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $D(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r}=e,i=r;ce([o,r],"avgPoolGrad");const{filterSize:a,strides:l,pad:c}=s,u=pn(i.shape,a,l,1,c),h=u.strideHeight,d=u.strideWidth,p=u.filterHeight,f=u.filterWidth,g=u.dilationHeight,m=u.dilationWidth,x=u.effectiveFilterHeight,b=u.effectiveFilterWidth,w=b-1-u.padInfo.left,y=x-1-u.padInfo.top,C=ve(i.shape,"float32"),I=1/(p*f),v=t.data.get(o.dataId).values,k=ve(o.shape,"float32",v);for(let S=0;S=u.outHeight||Math.floor(G)!==G))for(let B=0;B=u.outWidth||Math.floor(j)!==j)continue;const K=k.get(S,G,j,T);R+=K}}C.set(R*I,S,E,V,T)}return t.makeTensorInfo(C.shape,C.dtype,C.values)}const vD={kernelName:qc,backendName:"cpu",kernelFunc:$D};/** + */function kD(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r}=e,i=r;ce([o,r],"avgPoolGrad");const{filterSize:a,strides:l,pad:c}=s,u=pn(i.shape,a,l,1,c),h=u.strideHeight,d=u.strideWidth,p=u.filterHeight,f=u.filterWidth,g=u.dilationHeight,m=u.dilationWidth,x=u.effectiveFilterHeight,b=u.effectiveFilterWidth,w=b-1-u.padInfo.left,y=x-1-u.padInfo.top,C=ve(i.shape,"float32"),I=1/(p*f),v=t.data.get(o.dataId).values,k=ve(o.shape,"float32",v);for(let S=0;S=u.outHeight||Math.floor(G)!==G))for(let z=0;z=u.outWidth||Math.floor(q)!==q)continue;const K=k.get(S,G,q,T);R+=K}}C.set(R*I,S,E,V,T)}return t.makeTensorInfo(C.shape,C.dtype,C.values)}const SD={kernelName:Kc,backendName:"cpu",kernelFunc:kD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9317,7 +9317,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function kD(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,scale:r,offset:i,mean:a,variance:l}=e;$(a.shape.length===l.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),$(i==null||a.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),$(r==null||a.shape.length===r.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks."),ce([o,a,l,r,i],"batchNorm");let{varianceEpsilon:c}=s;c==null&&(c=.001);const u=t.data.get(o.dataId).values,h=t.data.get(a.dataId).values,d=t.data.get(l.dataId).values,p=r?t.data.get(r.dataId).values:new Float32Array([1]),f=i?t.data.get(i.dataId).values:new Float32Array([0]),g=new Float32Array(u.length),m=f.length,x=p.length,b=d.length,w=h.length;let y=0,C=0,I=0,v=0;for(let k=0;k=m&&(y=0),C>=w&&(C=0),I>=x&&(I=0),v>=b&&(v=0);return t.makeTensorInfo(o.shape,o.dtype,g)}const SD={kernelName:Sa,backendName:"cpu",kernelFunc:kD};/** + */function TD(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,scale:r,offset:i,mean:a,variance:l}=e;$(a.shape.length===l.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),$(i==null||a.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),$(r==null||a.shape.length===r.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks."),ce([o,a,l,r,i],"batchNorm");let{varianceEpsilon:c}=s;c==null&&(c=.001);const u=t.data.get(o.dataId).values,h=t.data.get(a.dataId).values,d=t.data.get(l.dataId).values,p=r?t.data.get(r.dataId).values:new Float32Array([1]),f=i?t.data.get(i.dataId).values:new Float32Array([0]),g=new Float32Array(u.length),m=f.length,x=p.length,b=d.length,w=h.length;let y=0,C=0,I=0,v=0;for(let k=0;k=m&&(y=0),C>=w&&(C=0),I>=x&&(I=0),v>=b&&(v=0);return t.makeTensorInfo(o.shape,o.dtype,g)}const ND={kernelName:Sa,backendName:"cpu",kernelFunc:TD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9332,7 +9332,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function TD(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{blockShape:r,crops:i}=s;ce([o],"batchToSpaceND");const a=r.reduce((x,b)=>x*b),l=Ei(o.shape,r,a),c=Ri(l.length,r.length),u=Ai(o.shape,r,a),h=Zh(i,r.length),d=Qh(u,i,r.length),p=Ue({inputs:{x:o},backend:t,attrs:{shape:l}}),f=jt({inputs:{x:p},backend:t,attrs:{perm:c}}),g=Ue({inputs:{x:f},backend:t,attrs:{shape:u}}),m=Co({inputs:{x:g},backend:t,attrs:{begin:h,size:d}});return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(g),m}const ND={kernelName:ma,backendName:"cpu",kernelFunc:TD};/** + */function ED(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{blockShape:r,crops:i}=s;ce([o],"batchToSpaceND");const a=r.reduce((x,b)=>x*b),l=Ei(o.shape,r,a),c=Ri(l.length,r.length),u=Ai(o.shape,r,a),h=Zh(i,r.length),d=Qh(u,i,r.length),p=Ue({inputs:{x:o},backend:t,attrs:{shape:l}}),f=qt({inputs:{x:p},backend:t,attrs:{perm:c}}),g=Ue({inputs:{x:f},backend:t,attrs:{shape:u}}),m=Io({inputs:{x:g},backend:t,attrs:{begin:h,size:d}});return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(g),m}const RD={kernelName:ma,backendName:"cpu",kernelFunc:ED};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9347,7 +9347,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ED(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,weights:r}=e,{size:i}=s,a=t.data.get(o.dataId).values,l=t.data.get(r.dataId).values,c=Jd(a,l,r.dtype,r.shape,i);return t.makeTensorInfo([i],r.dtype,c)}const RD={kernelName:Xc,backendName:"cpu",kernelFunc:ED};/** + */function AD(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,weights:r}=e,{size:i}=s,a=t.data.get(o.dataId).values,l=t.data.get(r.dataId).values,c=Jd(a,l,r.dtype,r.shape,i);return t.makeTensorInfo([i],r.dtype,c)}const DD={kernelName:Yc,backendName:"cpu",kernelFunc:AD};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9362,7 +9362,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function AD(n){const{inputs:e,backend:t}=n,{s0:s,s1:o}=e,r=t.data.get(s.dataId).values,i=t.data.get(o.dataId).values,a=we(Array.from(r),Array.from(i));return t.makeTensorInfo([a.length],"int32",Int32Array.from(a))}const DD={kernelName:Gp,backendName:"cpu",kernelFunc:AD};/** + */function FD(n){const{inputs:e,backend:t}=n,{s0:s,s1:o}=e,r=t.data.get(s.dataId).values,i=t.data.get(o.dataId).values,a=we(Array.from(r),Array.from(i));return t.makeTensorInfo([a.length],"int32",Int32Array.from(a))}const _D={kernelName:Gp,backendName:"cpu",kernelFunc:FD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9377,7 +9377,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const FD=Pe(Er,(n,e)=>{const t=e;return n>t.clipValueMax?t.clipValueMax:n{const t=e;return n>t.clipValueMax?t.clipValueMax:n{const{x:e}=n.inputs,t=n.backend,s=new Float32Array(H(e.shape)),o=t.data.get(e.dataId),r=o.complexTensorInfos.real,i=o.complexTensorInfos.imag,a=t.data.get(r.dataId).values,l=t.data.get(i.dataId).values;for(let c=0;c{const{x:e}=n.inputs,t=n.backend,s=new Float32Array(H(e.shape)),o=t.data.get(e.dataId),r=o.complexTensorInfos.real,i=o.complexTensorInfos.imag,a=t.data.get(r.dataId).values,l=t.data.get(i.dataId).values;for(let c=0;cg.shape);Kh(i,r);let a=Hn(e.map(g=>g.shape),r);if(H(a)===0)return t.makeTensorInfo(a,e[0].dtype,[]);const l=e.filter(g=>H(g.shape)>0);if(l.length===1)return Jn({inputs:{x:l[0]},backend:t});if(l[0].dtype==="complex64"){const g=l.map(y=>yo({inputs:{input:y},backend:t})),m=l.map(y=>rr({inputs:{input:y},backend:t})),x=ir({inputs:g,backend:t,attrs:{axis:r}}),b=ir({inputs:m,backend:t,attrs:{axis:r}}),w=Jt({inputs:{real:x,imag:b},backend:t});return g.forEach(y=>t.disposeIntermediateTensorInfo(y)),m.forEach(y=>t.disposeIntermediateTensorInfo(y)),t.disposeIntermediateTensorInfo(x),t.disposeIntermediateTensorInfo(b),w}const c=l.map(g=>{const x=[-1,H(g.shape.slice(r))];return Ue({inputs:{x:g},backend:t,attrs:{shape:x}})}),u=c.map(g=>({vals:t.data.get(g.dataId).values,shape:g.shape}));a=Hn(c.map(g=>g.shape),1);const h=c[0].shape[0]===1,d=R0(u,a,e[0].dtype,h),p=Hn(l.map(g=>g.shape),r),f=t.makeTensorInfo(p,e[0].dtype,d);return c.forEach(g=>t.disposeIntermediateTensorInfo(g)),f}const MD={kernelName:xa,backendName:"cpu",kernelFunc:ir};/** + */function ir(n){const{inputs:e,backend:t,attrs:s}=n,{axis:o}=s,r=$e(o,e[0].shape)[0],i=e.map(g=>g.shape);Kh(i,r);let a=Hn(e.map(g=>g.shape),r);if(H(a)===0)return t.makeTensorInfo(a,e[0].dtype,[]);const l=e.filter(g=>H(g.shape)>0);if(l.length===1)return Jn({inputs:{x:l[0]},backend:t});if(l[0].dtype==="complex64"){const g=l.map(y=>wo({inputs:{input:y},backend:t})),m=l.map(y=>rr({inputs:{input:y},backend:t})),x=ir({inputs:g,backend:t,attrs:{axis:r}}),b=ir({inputs:m,backend:t,attrs:{axis:r}}),w=Jt({inputs:{real:x,imag:b},backend:t});return g.forEach(y=>t.disposeIntermediateTensorInfo(y)),m.forEach(y=>t.disposeIntermediateTensorInfo(y)),t.disposeIntermediateTensorInfo(x),t.disposeIntermediateTensorInfo(b),w}const c=l.map(g=>{const x=[-1,H(g.shape.slice(r))];return Ue({inputs:{x:g},backend:t,attrs:{shape:x}})}),u=c.map(g=>({vals:t.data.get(g.dataId).values,shape:g.shape}));a=Hn(c.map(g=>g.shape),1);const h=c[0].shape[0]===1,d=F0(u,a,e[0].dtype,h),p=Hn(l.map(g=>g.shape),r),f=t.makeTensorInfo(p,e[0].dtype,d);return c.forEach(g=>t.disposeIntermediateTensorInfo(g)),f}const BD={kernelName:xa,backendName:"cpu",kernelFunc:ir};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9437,7 +9437,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function R1(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,filter:r}=e,{strides:i,pad:a,dataFormat:l,dilations:c,dimRoundingMode:u}=s;ce([o,r],"conv2d");const h=is(l),d=wt(o.shape,r.shape,i,c,a,u,!1,h),p=d.filterHeight,f=d.filterWidth,g=d.dilationHeight,m=d.dilationWidth,x=d.padInfo.left,b=d.padInfo.top,w=d.dataFormat==="channelsLast",y=new yt(d.outShape,o.dtype),C=de(o.shape),I=de(r.shape),v=C[0],k=w?C[1]:C[2],S=w?C[2]:1,T=w?1:C[1],E=y.strides[0],V=w?y.strides[1]:y.strides[2],M=w?y.strides[2]:1,L=w?1:y.strides[1],R=t.data.get(o.dataId).values,P=t.data.get(r.dataId).values,G=y.values;for(let B=0;B=d.inHeight)continue;const te=Q*I[0],ie=j+Y*k;for(let he=0;he=d.inWidth)continue;const Ie=te+ye*I[1],be=ie+Ae*S;let Se=Ie;for(let Le=0;Le=d.inHeight)continue;const te=Q*I[0],ie=q+Z*k;for(let he=0;he=d.inWidth)continue;const Ie=te+ye*I[1],be=ie+Ae*S;let Se=Ie;for(let Le=0;Le=c.inDepth)continue;const B=P*S[0],j=E+G*k[1];for(let K=0;K=c.inHeight)continue;const Y=B+q*S[1],te=j+Q*k[2];for(let ie=0;ie=c.inWidth)continue;const Ae=Y+ae*S[2],Ie=te+ye*c.inChannels;let be=Ae;for(let Se=0;Se=c.inDepth)continue;const z=B*S[0],q=E+G*k[1];for(let K=0;K=c.inHeight)continue;const Z=z+j*S[1],te=q+Q*k[2];for(let ie=0;ie=c.inWidth)continue;const Ae=Z+ae*S[2],Ie=te+ye*c.inChannels;let be=Ae;for(let Se=0;SeMath.cos(n)),YD={kernelName:Rr,backendName:"cpu",kernelFunc:XD};/** + */const ZD=Pe(Rr,n=>Math.cos(n)),QD={kernelName:Rr,backendName:"cpu",kernelFunc:ZD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9542,7 +9542,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ZD=Pe(Ar,n=>Math.cosh(n)),QD={kernelName:Ar,backendName:"cpu",kernelFunc:ZD};/** + */const JD=Pe(Ar,n=>Math.cosh(n)),eF={kernelName:Ar,backendName:"cpu",kernelFunc:JD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9557,7 +9557,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function JD(n){const{inputs:e,backend:t,attrs:s}=n,{image:o,boxes:r,boxInd:i}=e,{cropSize:a,method:l,extrapolationValue:c}=s,[u,h,d,p]=o.shape,f=r.shape[0],[g,m]=a,x=ve([f,g,m,p],"float32"),b=t.data.get(r.dataId).values,w=t.data.get(i.dataId).values,y=t.data.get(o.dataId).values,C=de(o.shape),I=de(x.shape);for(let v=0;v=u)continue;const L=g>1?(E-S)*(h-1)/(g-1):0,R=m>1?(V-T)*(d-1)/(m-1):0;for(let P=0;P1?S*(h-1)+P*L:.5*(S+E)*(h-1);if(G<0||G>h-1){for(let B=0;B1?T*(d-1)+X*R:.5*(T+V)*(d-1);if(J<0||J>d-1){for(let te=0;te1?T*(d-1)+B*R:.5*(T+V)*(d-1);if(j<0||j>d-1){for(let J=0;J=u)continue;const L=g>1?(E-S)*(h-1)/(g-1):0,R=m>1?(V-T)*(d-1)/(m-1):0;for(let B=0;B1?S*(h-1)+B*L:.5*(S+E)*(h-1);if(G<0||G>h-1){for(let z=0;z1?T*(d-1)+X*R:.5*(T+V)*(d-1);if(J<0||J>d-1){for(let te=0;te1?T*(d-1)+z*R:.5*(T+V)*(d-1);if(q<0||q>d-1){for(let J=0;Jx+f-b-1:(x,b)=>x+b;for(let x=0;xx+f-b-1:(x,b)=>x+b;for(let x=0;xx+f-b-1:(x,b)=>x+b;for(let x=0;xx+f-b-1:(x,b)=>x+b;for(let x=0;x`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${i}`);const a=o.shape[0],l=o.shape[1],c=o.shape[2],u=o.shape[3],h=l*r,d=c*r,p=u/(r*r),f=t.data.get(o.dataId).values,g=new Float32Array(a*h*d*p);let m=0;for(let x=0;x`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${i}`);const a=o.shape[0],l=o.shape[1],c=o.shape[2],u=o.shape[3],h=l*r,d=c*r,p=u/(r*r),f=t.data.get(o.dataId).values,g=new Float32Array(a*h*d*p);let m=0;for(let x=0;x`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${d}'`);const p=wt(o.shape,r.shape,i,d,a,c,!0),{filterHeight:f,filterWidth:g,dilationHeight:m,dilationWidth:x,padInfo:b}=p,w=b.left,y=b.top,C=p.outChannels/p.inChannels,I=new yt(p.outShape,o.dtype),v=t.data.get(o.dataId).values,k=t.data.get(r.dataId).values,S=I.values;for(let T=0;T=p.inHeight)continue;const B=P*h[0],j=E+G*u[1];for(let K=0;K=p.inWidth)continue;const Y=B+q*h[1],te=j+Q*p.inChannels;let ie=X,he=Y;for(let le=0;le`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${d}'`);const p=wt(o.shape,r.shape,i,d,a,c,!0),{filterHeight:f,filterWidth:g,dilationHeight:m,dilationWidth:x,padInfo:b}=p,w=b.left,y=b.top,C=p.outChannels/p.inChannels,I=new yt(p.outShape,o.dtype),v=t.data.get(o.dataId).values,k=t.data.get(r.dataId).values,S=I.values;for(let T=0;T=p.inHeight)continue;const z=B*h[0],q=E+G*u[1];for(let K=0;K=p.inWidth)continue;const Z=z+j*h[1],te=q+Q*p.inChannels;let ie=X,he=Z;for(let le=0;le{const{x:s,filter:o}=n,{strides:r,pad:i,dilations:a}=t,l=e,c=l.data.get(s.dataId).values,u=s.shape.length,h=l.data.get(o.dataId).values,d=o.shape.length,{batchSize:p,inHeight:f,inWidth:g,inChannels:m,outHeight:x,outWidth:b,padInfo:w,strideHeight:y,strideWidth:C,filterHeight:I,filterWidth:v,dilationHeight:k,dilationWidth:S,outShape:T}=bi(s.shape,o.shape,r,i,"NHWC",a),E=H(T),V=T.length,M=Je(s.dtype,E);for(let R=0;R=0&&Q=0&&teX&&(X=le)}}}const J=Pn([R,P,B,K],V,de(T));M[J]=X}}}return{dataId:l.write(Xs(M,s.dtype),T,s.dtype),shape:T,dtype:s.dtype}}};/** + */const bF={kernelName:$a,backendName:"cpu",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:s,filter:o}=n,{strides:r,pad:i,dilations:a}=t,l=e,c=l.data.get(s.dataId).values,u=s.shape.length,h=l.data.get(o.dataId).values,d=o.shape.length,{batchSize:p,inHeight:f,inWidth:g,inChannels:m,outHeight:x,outWidth:b,padInfo:w,strideHeight:y,strideWidth:C,filterHeight:I,filterWidth:v,dilationHeight:k,dilationWidth:S,outShape:T}=bi(s.shape,o.shape,r,i,"NHWC",a),E=H(T),V=T.length,M=Je(s.dtype,E);for(let R=0;R=0&&Q=0&&teX&&(X=le)}}}const J=Pn([R,B,z,K],V,de(T));M[J]=X}}}return{dataId:l.write(Xs(M,s.dtype),T,s.dtype),shape:T,dtype:s.dtype}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9707,7 +9707,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const xF={kernelName:lu,backendName:"cpu",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:s,filter:o,dy:r}=n,{strides:i,pad:a,dilations:l}=t,c=e,u=$n(s.shape,c.data.get(s.dataId).values),h=$n(o.shape,c.data.get(o.dataId).values),{batchSize:d,inHeight:p,inWidth:f,inChannels:g,outHeight:m,outWidth:x,padInfo:b,strideHeight:w,strideWidth:y,filterHeight:C,filterWidth:I,dilationHeight:v,dilationWidth:k,outShape:S}=bi(s.shape,o.shape,i,a,"NHWC",l);$(r.rank===S.length,()=>`Error in ${lu}, dy must have the same rank as output ${S.length}, but got ${r.rank}`);const T=$n(S,c.data.get(r.dataId).values),E=Vp(o.shape,o.dtype);for(let M=0;M=0&&q=0&&Yj&&(j=te,K=J,X=Q)}}}E[K][X][B]+=T[M][L][P][B]}}}return{dataId:c.write(Xs(E,s.dtype),o.shape,o.dtype),shape:o.shape,dtype:o.dtype}}};/** + */const yF={kernelName:cu,backendName:"cpu",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:s,filter:o,dy:r}=n,{strides:i,pad:a,dilations:l}=t,c=e,u=$n(s.shape,c.data.get(s.dataId).values),h=$n(o.shape,c.data.get(o.dataId).values),{batchSize:d,inHeight:p,inWidth:f,inChannels:g,outHeight:m,outWidth:x,padInfo:b,strideHeight:w,strideWidth:y,filterHeight:C,filterWidth:I,dilationHeight:v,dilationWidth:k,outShape:S}=bi(s.shape,o.shape,i,a,"NHWC",l);$(r.rank===S.length,()=>`Error in ${cu}, dy must have the same rank as output ${S.length}, but got ${r.rank}`);const T=$n(S,c.data.get(r.dataId).values),E=Vp(o.shape,o.dtype);for(let M=0;M=0&&j=0&&Zq&&(q=te,K=J,X=Q)}}}E[K][X][z]+=T[M][L][B][z]}}}return{dataId:c.write(Xs(E,s.dtype),o.shape,o.dtype),shape:o.shape,dtype:o.dtype}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9722,7 +9722,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const bF={kernelName:au,backendName:"cpu",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:s,filter:o,dy:r}=n,{strides:i,pad:a,dilations:l}=t,c=e,u=$n(s.shape,c.data.get(s.dataId).values),h=$n(o.shape,c.data.get(o.dataId).values),{batchSize:d,inHeight:p,inWidth:f,inChannels:g,outHeight:m,outWidth:x,padInfo:b,strideHeight:w,strideWidth:y,filterHeight:C,filterWidth:I,dilationHeight:v,dilationWidth:k,outShape:S}=bi(s.shape,o.shape,i,a,"NHWC",l);$(r.rank===S.length,()=>`Error in ${au}, dy must have the same rank as output ${S.length}, but got ${r.rank}`);const T=$n(S,c.data.get(r.dataId).values),E=Vp(s.shape,s.dtype);for(let M=0;M=0&&q=0&&Yj&&(j=te,K=q,X=Y)}}}E[M][K][X][B]+=T[M][L][P][B]}}}return{dataId:c.write(Xs(E,s.dtype),s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}};/** + */const wF={kernelName:lu,backendName:"cpu",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:s,filter:o,dy:r}=n,{strides:i,pad:a,dilations:l}=t,c=e,u=$n(s.shape,c.data.get(s.dataId).values),h=$n(o.shape,c.data.get(o.dataId).values),{batchSize:d,inHeight:p,inWidth:f,inChannels:g,outHeight:m,outWidth:x,padInfo:b,strideHeight:w,strideWidth:y,filterHeight:C,filterWidth:I,dilationHeight:v,dilationWidth:k,outShape:S}=bi(s.shape,o.shape,i,a,"NHWC",l);$(r.rank===S.length,()=>`Error in ${lu}, dy must have the same rank as output ${S.length}, but got ${r.rank}`);const T=$n(S,c.data.get(r.dataId).values),E=Vp(s.shape,s.dtype);for(let M=0;M=0&&j=0&&Zq&&(q=te,K=j,X=Z)}}}E[M][K][X][z]+=T[M][L][B][z]}}}return{dataId:c.write(Xs(E,s.dtype),s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}};/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9737,7 +9737,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function yF(n){const{inputs:e,backend:t,attrs:s}=n,{image:o}=e,{canvas:r,options:i}=s,{contextOptions:a,imageOptions:l}=i||{},c=(l==null?void 0:l.alpha)||1,u=(a==null?void 0:a.contextType)||"2d";if(u!=="2d")throw new Error(`Context type ${a.contextType} is not supported by the CPU backend.`);const h=r.getContext(u,(a==null?void 0:a.contextAttributes)||{});if(h==null)throw new Error(`Could not get the context with ${u} type.`);const[d,p]=o.shape.slice(0,2),f=o.shape.length===2?1:o.shape[2],g=t.data.get(o.dataId).values,m=o.dtype==="float32"?255:1,x=new Uint8ClampedArray(p*d*4);for(let w=0;w1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${v}.`)}else if(o.dtype==="int32"&&(v<0||v>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${v}.`);f===1?(y[0]=v*m,y[1]=v*m,y[2]=v*m):y[I]=v*m}const C=w*4;x[C+0]=Math.round(y[0]),x[C+1]=Math.round(y[1]),x[C+2]=Math.round(y[2]),x[C+3]=Math.round(y[3])}r.width=p,r.height=d;const b=new ImageData(x,p,d);return h.putImageData(b,0,0),o}const wF={kernelName:Fw,backendName:"cpu",kernelFunc:yF};/** + */function CF(n){const{inputs:e,backend:t,attrs:s}=n,{image:o}=e,{canvas:r,options:i}=s,{contextOptions:a,imageOptions:l}=i||{},c=(l==null?void 0:l.alpha)||1,u=(a==null?void 0:a.contextType)||"2d";if(u!=="2d")throw new Error(`Context type ${a.contextType} is not supported by the CPU backend.`);const h=r.getContext(u,(a==null?void 0:a.contextAttributes)||{});if(h==null)throw new Error(`Could not get the context with ${u} type.`);const[d,p]=o.shape.slice(0,2),f=o.shape.length===2?1:o.shape[2],g=t.data.get(o.dataId).values,m=o.dtype==="float32"?255:1,x=new Uint8ClampedArray(p*d*4);for(let w=0;w1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${v}.`)}else if(o.dtype==="int32"&&(v<0||v>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${v}.`);f===1?(y[0]=v*m,y[1]=v*m,y[2]=v*m):y[I]=v*m}const C=w*4;x[C+0]=Math.round(y[0]),x[C+1]=Math.round(y[1]),x[C+2]=Math.round(y[2]),x[C+3]=Math.round(y[3])}r.width=p,r.height=d;const b=new ImageData(x,p,d);return h.putImageData(b,0,0),o}const IF={kernelName:Lw,backendName:"cpu",kernelFunc:CF};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9752,7 +9752,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Xi(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,keepDims:i}=s;ce(o,"sum");let a;o.dtype==="bool"?a=_s({inputs:{x:o},backend:t,attrs:{dtype:"int32"}}):a=Jn({inputs:{x:o},backend:t});const l=a.shape.length,c=$e(r,a.shape),u=Ye(c,l);let h=c,d=a;u!=null&&(d=jt({inputs:{x:a},backend:t,attrs:{perm:u}}),h=tt(h.length,l)),It("sum",h,d.shape.length);const[p,f]=xt(d.shape,h),g=Yt(d.dtype,"int32");let m=oc(t,p,g);const x=H(f),b=t.data.get(m.dataId).values,w=t.data.get(d.dataId).values;for(let y=0;y=0&&(d=Xi({inputs:{x:d},backend:t,attrs:{axis:c[g]-(i.length-p),keepDims:!1}}),f.push(d)),p--)}for(const g of f)g!==d&&t.disposeIntermediateTensorInfo(g);return d}const $F={kernelName:cu,backendName:"cpu",kernelFunc:IF};/** + */function vF(n){const{inputs:e,backend:t,attrs:s}=n,{equation:o}=s,r=e,{allDims:i,summedDims:a,idDims:l}=ad(o,r.length);cd(i.length,l,r);const{path:c,steps:u}=ud(a,l),h=u.length;let d=null,p=i.length;const f=[];for(let g=0;g=0&&(d=Xi({inputs:{x:d},backend:t,attrs:{axis:c[g]-(i.length-p),keepDims:!1}}),f.push(d)),p--)}for(const g of f)g!==d&&t.disposeIntermediateTensorInfo(g);return d}const kF={kernelName:uu,backendName:"cpu",kernelFunc:vF};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9782,7 +9782,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function vF(n){const{inputs:e,backend:t}=n,{dy:s,y:o}=e;ce([s,o],"eluGrad");const r=new Float32Array(H(o.shape)),i=t.data.get(o.dataId).values,a=t.data.get(s.dataId).values;for(let l=0;l=0?r[l]=a[l]:r[l]=a[l]*(c+1)}return t.makeTensorInfo(o.shape,"float32",r)}const kF={kernelName:uu,backendName:"cpu",kernelFunc:vF};/** + */function SF(n){const{inputs:e,backend:t}=n,{dy:s,y:o}=e;ce([s,o],"eluGrad");const r=new Float32Array(H(o.shape)),i=t.data.get(o.dataId).values,a=t.data.get(s.dataId).values;for(let l=0;l=0?r[l]=a[l]:r[l]=a[l]*(c+1)}return t.makeTensorInfo(o.shape,"float32",r)}const TF={kernelName:hu,backendName:"cpu",kernelFunc:SF};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9797,7 +9797,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const SF=Jh,TF=ed,NF=td,EF=nd,RF=sd,AF=od,DF=Pe(_r,n=>{const e=Math.sign(n),t=Math.abs(n),s=1/(1+SF*t);return e*(1-((((AF*s+RF)*s+EF)*s+NF)*s+TF)*s*Math.exp(-t*t))}),FF={kernelName:_r,backendName:"cpu",kernelFunc:DF};/** + */const NF=Jh,EF=ed,RF=td,AF=nd,DF=sd,FF=od,_F=Pe(_r,n=>{const e=Math.sign(n),t=Math.abs(n),s=1/(1+NF*t);return e*(1-((((FF*s+DF)*s+AF)*s+RF)*s+EF)*s*Math.exp(-t*t))}),OF={kernelName:_r,backendName:"cpu",kernelFunc:_F};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9812,7 +9812,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function lc(n){const{inputs:e,backend:t,attrs:s}=n,{input:o}=e,{dim:r}=s,i=o.shape.length,a=o.shape.slice();let l=r;return r<0&&($(-(i+1)<=r,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+r+1),a.splice(l,0,1),Ue({inputs:{x:o},backend:t,attrs:{shape:a}})}const _F={kernelName:ka,backendName:"cpu",kernelFunc:lc};/** + */function cc(n){const{inputs:e,backend:t,attrs:s}=n,{input:o}=e,{dim:r}=s,i=o.shape.length,a=o.shape.slice();let l=r;return r<0&&($(-(i+1)<=r,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+r+1),a.splice(l,0,1),Ue({inputs:{x:o},backend:t,attrs:{shape:a}})}const LF={kernelName:ka,backendName:"cpu",kernelFunc:cc};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9827,7 +9827,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const OF=rt((n,e)=>n/e),rp=ft(Dr,OF),ip={kernelName:Dr,backendName:"cpu",kernelFunc:rp};/** + */const MF=rt((n,e)=>n/e),rp=ft(Dr,MF),ip={kernelName:Dr,backendName:"cpu",kernelFunc:rp};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9842,7 +9842,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function D1(n,e,t){const s=n.shape,o=s[0],r=s[1],i=t.data.get(n.dataId),a=i.complexTensorInfos.real,l=i.complexTensorInfos.imag,c=[o,r],u=H(c),h=Tt("float32",u),d=Tt("float32",u);for(let m=0;m{const{image:s}=n,o=t,r=Tt(s.dtype,H(s.shape)),[i,a,l,c]=s.shape,u=o.data.get(s.dataId).values;for(let d=0;d=0&&w{const{image:s}=n,o=t,r=Tt(s.dtype,H(s.shape)),[i,a,l,c]=s.shape,u=o.data.get(s.dataId).values;for(let d=0;d=0&&w=0,()=>`GatherV2: the index value ${C} is not in [0, ${u-1}]`)}let h=a;a==null&&(h=0);const d=H(r.shape),p=fd(o,r,l,h),f=Ue({inputs:{x:o},backend:t,attrs:{shape:[p.batchSize,p.outerSize,p.dimSize,p.sliceSize]}}),g=Ue({inputs:{x:r},backend:t,attrs:{shape:[p.batchSize,d/p.batchSize]}}),m=[p.batchSize,p.outerSize,d/p.batchSize,p.sliceSize],x=t.bufferSync(g),b=t.bufferSync(f),w=B0(b,x,m);return t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(g),t.makeTensorInfo(p.outputShape,w.dtype,w.values)}const ZF={kernelName:Ta,backendName:"cpu",kernelFunc:YF};/** + */function QF(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,indices:r}=e,{axis:i,batchDims:a}=s;ce([o,r],"gatherV2");const l=$e(i,o.shape)[0],c=t.data.get(r.dataId).values,u=o.shape[l];for(let y=0;y=0,()=>`GatherV2: the index value ${C} is not in [0, ${u-1}]`)}let h=a;a==null&&(h=0);const d=H(r.shape),p=fd(o,r,l,h),f=Ue({inputs:{x:o},backend:t,attrs:{shape:[p.batchSize,p.outerSize,p.dimSize,p.sliceSize]}}),g=Ue({inputs:{x:r},backend:t,attrs:{shape:[p.batchSize,d/p.batchSize]}}),m=[p.batchSize,p.outerSize,d/p.batchSize,p.sliceSize],x=t.bufferSync(g),b=t.bufferSync(f),w=W0(b,x,m);return t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(g),t.makeTensorInfo(p.outputShape,w.dtype,w.values)}const JF={kernelName:Ta,backendName:"cpu",kernelFunc:QF};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9962,7 +9962,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function QF(n){const{inputs:e,backend:t}=n,{input:s}=e,o=H(s.shape),r=s.shape[s.shape.length-1],i=o/r,a=Ue({inputs:{x:s},backend:t,attrs:{shape:[i,r]}}),l=D1(a,!0,t),c=Ue({inputs:{x:l},backend:t,attrs:{shape:s.shape}});return t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(l),c}const JF={kernelName:fu,backendName:"cpu",kernelFunc:QF};/** + */function e_(n){const{inputs:e,backend:t}=n,{input:s}=e,o=H(s.shape),r=s.shape[s.shape.length-1],i=o/r,a=Ue({inputs:{x:s},backend:t,attrs:{shape:[i,r]}}),l=O1(a,!0,t),c=Ue({inputs:{x:l},backend:t,attrs:{shape:s.shape}});return t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(l),c}const t_={kernelName:mu,backendName:"cpu",kernelFunc:e_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9977,7 +9977,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const e_=Pe(Vr,n=>Number.isFinite(n)?1:0,"bool"),t_={kernelName:Vr,backendName:"cpu",kernelFunc:e_};/** + */const n_=Pe(Vr,n=>Number.isFinite(n)?1:0,"bool"),s_={kernelName:Vr,backendName:"cpu",kernelFunc:n_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9992,7 +9992,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const n_=Pe(Wr,n=>Math.abs(n)===1/0?1:0,"bool"),s_={kernelName:Wr,backendName:"cpu",kernelFunc:n_};/** + */const o_=Pe(Wr,n=>Math.abs(n)===1/0?1:0,"bool"),r_={kernelName:Wr,backendName:"cpu",kernelFunc:o_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10007,7 +10007,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const o_=Pe(Ur,n=>Number.isNaN(n)?1:0,"bool"),r_={kernelName:Ur,backendName:"cpu",kernelFunc:o_};/** + */const i_=Pe(Ur,n=>Number.isNaN(n)?1:0,"bool"),a_={kernelName:Ur,backendName:"cpu",kernelFunc:i_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10022,7 +10022,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function i_(n){const{backend:e,attrs:t}=n,{start:s,stop:o,num:r}=t,i=G0(s,o,r);return e.makeTensorInfo([i.length],"float32",i)}const a_={kernelName:qp,backendName:"cpu",kernelFunc:i_};/** + */function l_(n){const{backend:e,attrs:t}=n,{start:s,stop:o,num:r}=t,i=j0(s,o,r);return e.makeTensorInfo([i.length],"float32",i)}const c_={kernelName:jp,backendName:"cpu",kernelFunc:l_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10037,7 +10037,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const l_=Pe(Hr,n=>Math.log1p(n)),c_={kernelName:Hr,backendName:"cpu",kernelFunc:l_};/** + */const u_=Pe(Hr,n=>Math.log1p(n)),h_={kernelName:Hr,backendName:"cpu",kernelFunc:u_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10052,7 +10052,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const u_=rt((n,e)=>n&&e),h_=ft(Da,u_,null,"bool"),d_={kernelName:Da,backendName:"cpu",kernelFunc:h_};/** + */const d_=rt((n,e)=>n&&e),p_=ft(Da,d_,null,"bool"),f_={kernelName:Da,backendName:"cpu",kernelFunc:p_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10067,7 +10067,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const p_=Pe(Fa,n=>n?0:1,"bool"),f_={kernelName:Fa,backendName:"cpu",kernelFunc:p_};/** + */const m_=Pe(Fa,n=>n?0:1,"bool"),g_={kernelName:Fa,backendName:"cpu",kernelFunc:m_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10082,7 +10082,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const m_=rt((n,e)=>n||e),g_=ft(_a,m_,null,"bool"),x_={kernelName:_a,backendName:"cpu",kernelFunc:g_};/** + */const x_=rt((n,e)=>n||e),b_=ft(_a,x_,null,"bool"),y_={kernelName:_a,backendName:"cpu",kernelFunc:b_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10097,7 +10097,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function b_(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{depthRadius:r,bias:i,alpha:a,beta:l}=s;ce(o,"LRN");const c=o.shape[3],u=c-1,h=t.data.get(o.dataId).values,d=H(o.shape),p=new Float32Array(d);function f(g){const m=g%c;let x=g-m+Math.max(0,m-r);const b=g-m+Math.min(m+r,u);let w=0;for(;x<=b;x++){const y=h[x];w+=y*y}return w}for(let g=0;g`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=pn(o.shape,r,i,c,a,l);let h;if(u.filterWidth===1&&u.filterHeight===1&&Oe(u.inShape,u.outShape))h=Jn({inputs:{x:o},backend:t});else{const d=t.data.get(o.dataId).values,p=de(o.shape),f=op(d,o.shape,o.dtype,p,u,"max");h=t.makeTensorInfo(u.outShape,o.dtype,f.values)}return h}const v_={kernelName:Ma,backendName:"cpu",kernelFunc:$_};/** + */function k_(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e;ce(o,"maxPool");const{filterSize:r,strides:i,pad:a,dimRoundingMode:l}=s,c=1;$(Et(i,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=pn(o.shape,r,i,c,a,l);let h;if(u.filterWidth===1&&u.filterHeight===1&&Oe(u.inShape,u.outShape))h=Jn({inputs:{x:o},backend:t});else{const d=t.data.get(o.dataId).values,p=de(o.shape),f=op(d,o.shape,o.dtype,p,u,"max");h=t.makeTensorInfo(u.outShape,o.dtype,f.values)}return h}const S_={kernelName:Ma,backendName:"cpu",kernelFunc:k_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10157,7 +10157,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function k_(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{filterSize:r,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=s;ce(o,"maxPool3d");const u=rs(o.shape,r,i,1,a,l,c),h=t.data.get(o.dataId).values,d=E1(h,o.shape,o.dtype,de(o.shape),u,"max");return t.makeTensorInfo(d.shape,"float32",d.values)}const S_={kernelName:Pa,backendName:"cpu",kernelFunc:k_};/** + */function T_(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{filterSize:r,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=s;ce(o,"maxPool3d");const u=rs(o.shape,r,i,1,a,l,c),h=t.data.get(o.dataId).values,d=D1(h,o.shape,o.dtype,de(o.shape),u,"max");return t.makeTensorInfo(d.shape,"float32",d.values)}const N_={kernelName:Pa,backendName:"cpu",kernelFunc:T_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10172,7 +10172,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function T_(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r}=e,{filterSize:i,strides:a,pad:l,dimRoundingMode:c}=s;ce([o,r],"maxPool3DGrad");const u=rs(r.shape,i,a,1,l,c),h=t.bufferSync(r),d=gD(h,u),p=u.strideDepth,f=u.strideHeight,g=u.strideWidth,m=u.dilationDepth,x=u.dilationHeight,b=u.dilationWidth,w=u.effectiveFilterDepth,y=u.effectiveFilterHeight,C=u.effectiveFilterWidth,I=w-1-u.padInfo.front,v=C-1-u.padInfo.left,k=y-1-u.padInfo.top,S=ve(r.shape,"float32"),T=t.bufferSync(o);for(let E=0;E=u.outDepth||Math.floor(X)!==X))for(let J=0;J=u.outHeight||Math.floor(q)!==q))for(let Q=0;Q=u.outWidth||Math.floor(Y)!==Y)continue;const te=w*y*C-1-d.get(E,X,q,Y,V),ie=K*y*C+J*C+Q,he=te===ie?1:0;if(he===0)continue;const le=T.get(E,X,q,Y,V);j+=le*he}}}S.set(j,E,M,L,R,V)}return t.makeTensorInfo(S.shape,S.dtype,S.values)}const N_={kernelName:bu,backendName:"cpu",kernelFunc:T_};/** + */function E_(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r}=e,{filterSize:i,strides:a,pad:l,dimRoundingMode:c}=s;ce([o,r],"maxPool3DGrad");const u=rs(r.shape,i,a,1,l,c),h=t.bufferSync(r),d=bD(h,u),p=u.strideDepth,f=u.strideHeight,g=u.strideWidth,m=u.dilationDepth,x=u.dilationHeight,b=u.dilationWidth,w=u.effectiveFilterDepth,y=u.effectiveFilterHeight,C=u.effectiveFilterWidth,I=w-1-u.padInfo.front,v=C-1-u.padInfo.left,k=y-1-u.padInfo.top,S=ve(r.shape,"float32"),T=t.bufferSync(o);for(let E=0;E=u.outDepth||Math.floor(X)!==X))for(let J=0;J=u.outHeight||Math.floor(j)!==j))for(let Q=0;Q=u.outWidth||Math.floor(Z)!==Z)continue;const te=w*y*C-1-d.get(E,X,j,Z,V),ie=K*y*C+J*C+Q,he=te===ie?1:0;if(he===0)continue;const le=T.get(E,X,j,Z,V);q+=le*he}}}S.set(q,E,M,L,R,V)}return t.makeTensorInfo(S.shape,S.dtype,S.values)}const R_={kernelName:yu,backendName:"cpu",kernelFunc:E_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10187,7 +10187,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function E_(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r,output:i}=e,a=r;ce([r,i],"maxPoolGrad");const{filterSize:l,strides:c,pad:u,dimRoundingMode:h}=s,d=pn(a.shape,l,c,1,u,h),p=t.data.get(a.dataId).values,f=ve(d.outShape,a.dtype,N1(p,a.shape,a.dtype,d).values),g=d.strideHeight,m=d.strideWidth,x=d.dilationHeight,b=d.dilationWidth,w=d.effectiveFilterHeight,y=d.effectiveFilterWidth,C=y-1-d.padInfo.left,I=w-1-d.padInfo.top,v=ve(a.shape,"float32"),k=t.data.get(o.dataId).values,S=ve(o.shape,"float32",k);for(let T=0;T=d.outHeight||Math.floor(B)!==B))for(let j=0;j=d.outWidth||Math.floor(K)!==K)continue;const X=w*y-1-f.get(T,B,K,E),J=G*y+j,q=X===J?1:0;if(q===0)continue;const Q=S.get(T,B,K,E);P+=Q*q}}v.set(P,T,V,M,E)}return t.makeTensorInfo(v.shape,v.dtype,v.values)}const R_={kernelName:xu,backendName:"cpu",kernelFunc:E_};/** + */function A_(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r,output:i}=e,a=r;ce([r,i],"maxPoolGrad");const{filterSize:l,strides:c,pad:u,dimRoundingMode:h}=s,d=pn(a.shape,l,c,1,u,h),p=t.data.get(a.dataId).values,f=ve(d.outShape,a.dtype,A1(p,a.shape,a.dtype,d).values),g=d.strideHeight,m=d.strideWidth,x=d.dilationHeight,b=d.dilationWidth,w=d.effectiveFilterHeight,y=d.effectiveFilterWidth,C=y-1-d.padInfo.left,I=w-1-d.padInfo.top,v=ve(a.shape,"float32"),k=t.data.get(o.dataId).values,S=ve(o.shape,"float32",k);for(let T=0;T=d.outHeight||Math.floor(z)!==z))for(let q=0;q=d.outWidth||Math.floor(K)!==K)continue;const X=w*y-1-f.get(T,z,K,E),J=G*y+q,j=X===J?1:0;if(j===0)continue;const Q=S.get(T,z,K,E);B+=Q*j}}v.set(B,T,V,M,E)}return t.makeTensorInfo(v.shape,v.dtype,v.values)}const D_={kernelName:bu,backendName:"cpu",kernelFunc:A_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10202,7 +10202,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function A_(n,e,t,s,o){const r=de(e),i=op(n,e,t,r,o,"max"),a=N1(n,e,t,o,!0,s);return[i.values,a.values]}/** + */function F_(n,e,t,s,o){const r=de(e),i=op(n,e,t,r,o,"max"),a=A1(n,e,t,o,!0,s);return[i.values,a.values]}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10217,7 +10217,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const D_={kernelName:Kp,backendName:"cpu",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:s}=n,{filterSize:o,strides:r,pad:i,includeBatchInIndex:a}=e,l=t;ce(s,"MaxPoolWithArgmax");const c=l.data.get(s.dataId).values,u=pn(s.shape,o,r,[1,1],i),[h,d]=A_(c,s.shape,s.dtype,a,u),p=l.write(h,u.outShape,s.dtype),f=l.write(d,u.outShape,s.dtype);return[{dataId:p,shape:u.outShape,dtype:s.dtype},{dataId:f,shape:u.outShape,dtype:"int32"}]}};/** + */const __={kernelName:Kp,backendName:"cpu",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:s}=n,{filterSize:o,strides:r,pad:i,includeBatchInIndex:a}=e,l=t;ce(s,"MaxPoolWithArgmax");const c=l.data.get(s.dataId).values,u=pn(s.shape,o,r,[1,1],i),[h,d]=F_(c,s.shape,s.dtype,a,u),p=l.write(h,u.outShape,s.dtype),f=l.write(d,u.outShape,s.dtype);return[{dataId:p,shape:u.outShape,dtype:s.dtype},{dataId:f,shape:u.outShape,dtype:"int32"}]}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10232,7 +10232,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function F_(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,keepDims:i}=s,a=$e(r,o.shape),c=xt(o.shape,a)[1],u=H(c),h=[],d=t.makeTensorInfo([],"float32",new Float32Array([u]));h.push(d);const p=_s({inputs:{x:o},backend:t,attrs:{dtype:"float32"}});h.push(p);const f=rp({inputs:{a:p,b:d},backend:t});h.push(f);const g=Xi({inputs:{x:f},backend:t,attrs:{axis:r,keepDims:i}});return h.forEach(m=>t.disposeIntermediateTensorInfo(m)),g}const __={kernelName:Ba,backendName:"cpu",kernelFunc:F_};/** + */function O_(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,keepDims:i}=s,a=$e(r,o.shape),c=xt(o.shape,a)[1],u=H(c),h=[],d=t.makeTensorInfo([],"float32",new Float32Array([u]));h.push(d);const p=_s({inputs:{x:o},backend:t,attrs:{dtype:"float32"}});h.push(p);const f=rp({inputs:{a:p,b:d},backend:t});h.push(f);const g=Xi({inputs:{x:f},backend:t,attrs:{axis:r,keepDims:i}});return h.forEach(m=>t.disposeIntermediateTensorInfo(m)),g}const L_={kernelName:Ba,backendName:"cpu",kernelFunc:O_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10247,7 +10247,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function O_(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,keepDims:i}=s;ce(o,"min");const a=$e(r,o.shape);let l=a;const c=Ye(l,o.shape.length);let u=o;c!=null&&(u=jt({inputs:{x:o},backend:t,attrs:{perm:c}}),l=tt(l.length,o.shape.length)),It("min",l,u.shape.length);const[h,d]=xt(u.shape,l),p=H(d),f=Nt(H(h),u.dtype),g=t.data.get(u.dataId).values;for(let x=0;xw[0]+o.shape[y]+w[1]),l=r.map(w=>w[0]),c=r.map((w,y)=>w[0]+o.shape[y]),u=i==="reflect"?0:1,h=t.data.get(o.dataId).values,d=o.shape.length,p=de(o.shape),f=H(a),g=a.length,m=de(a),x=Tt(o.dtype,f);for(let w=0;w=c[I]&&(y[I]=(c[I]-1)*2-y[I]+u);y=y.map((I,v)=>I-l[v]);const C=Pn(y,d,p);x[w]=h[C]}return{dataId:t.write(x,a,o.dtype),shape:a,dtype:o.dtype}}const P_={kernelName:Va,backendName:"cpu",kernelFunc:M_};/** + */function B_(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{paddings:r,mode:i}=s;ce(o,"mirrorPad");const a=r.map((w,y)=>w[0]+o.shape[y]+w[1]),l=r.map(w=>w[0]),c=r.map((w,y)=>w[0]+o.shape[y]),u=i==="reflect"?0:1,h=t.data.get(o.dataId).values,d=o.shape.length,p=de(o.shape),f=H(a),g=a.length,m=de(a),x=Tt(o.dtype,f);for(let w=0;w=c[I]&&(y[I]=(c[I]-1)*2-y[I]+u);y=y.map((I,v)=>I-l[v]);const C=Pn(y,d,p);x[w]=h[C]}return{dataId:t.write(x,a,o.dtype),shape:a,dtype:o.dtype}}const z_={kernelName:Va,backendName:"cpu",kernelFunc:B_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10277,7 +10277,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const B_=rt((n,e)=>{const t=n%e;return n<0&&e<0||n>=0&&e>=0?t:(t+e)%e}),z_=ft(Kr,B_),V_={kernelName:Kr,backendName:"cpu",kernelFunc:z_};/** + */const V_=rt((n,e)=>{const t=n%e;return n<0&&e<0||n>=0&&e>=0?t:(t+e)%e}),W_=ft(Kr,V_),U_={kernelName:Kr,backendName:"cpu",kernelFunc:W_};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10292,7 +10292,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _1(n){const{inputs:e,backend:t,attrs:s}=n,{logits:o}=e,{dim:r}=s,i=o.shape.length;let a=r;if(a===-1&&(a=i-1),a!==i-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${i} and dim was ${a}`);const l=$e([a],o.shape),c=F1({inputs:{x:o},backend:t,attrs:{reductionIndices:l,keepDims:!1}}),u=it(c.shape,l),h=Ue({inputs:{x:c},backend:t,attrs:{shape:u}}),d=sp({inputs:{a:o,b:h},backend:t}),p=_0({inputs:{x:d},backend:t}),f=Xi({inputs:{x:p},backend:t,attrs:{axis:l,keepDims:!1}}),g=Ue({inputs:{x:f},backend:t,attrs:{shape:u}}),m=rp({inputs:{a:p,b:g},backend:t});return t.disposeIntermediateTensorInfo(c),t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(g),m}const W_={kernelName:rl,backendName:"cpu",kernelFunc:_1};/** + */function M1(n){const{inputs:e,backend:t,attrs:s}=n,{logits:o}=e,{dim:r}=s,i=o.shape.length;let a=r;if(a===-1&&(a=i-1),a!==i-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${i} and dim was ${a}`);const l=$e([a],o.shape),c=L1({inputs:{x:o},backend:t,attrs:{reductionIndices:l,keepDims:!1}}),u=it(c.shape,l),h=Ue({inputs:{x:c},backend:t,attrs:{shape:u}}),d=sp({inputs:{a:o,b:h},backend:t}),p=M0({inputs:{x:d},backend:t}),f=Xi({inputs:{x:p},backend:t,attrs:{axis:l,keepDims:!1}}),g=Ue({inputs:{x:f},backend:t,attrs:{shape:u}}),m=rp({inputs:{a:p,b:g},backend:t});return t.disposeIntermediateTensorInfo(c),t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(g),m}const G_={kernelName:rl,backendName:"cpu",kernelFunc:M1};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10307,7 +10307,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function U_(n){const{inputs:e,backend:t,attrs:s}=n,{logits:o}=e,{numSamples:r,seed:i,normalized:a}=s;ce(o,"multinomial");const l=a?o:_1({inputs:{logits:o},backend:t,attrs:{dim:-1}}),c=l.shape[0],u=l.shape[1],h=t.data.get(l.dataId).values,d=[c,r],p=Nt(H(d),"int32");for(let f=0;f=0&&h[d]=0&&h[d]{Oc(r,u.shape,"All tensors passed to stack must have matching shapes"),$(i===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});const a=[],l=e.map(u=>{const h=lc({inputs:{input:u},backend:t,attrs:{dim:o}});return a.push(h),h}),c=ir({inputs:l,backend:t,attrs:{axis:o}});return a.forEach(u=>t.disposeIntermediateTensorInfo(u)),c}const oO={kernelName:ja,backendName:"cpu",kernelFunc:L1};/** + */function B1(n){const{inputs:e,backend:t,attrs:s}=n,{axis:o}=s;if(e.length===1)return cc({inputs:{input:e[0]},backend:t,attrs:{dim:o}});const r=e[0].shape,i=e[0].dtype;e.forEach(u=>{Lc(r,u.shape,"All tensors passed to stack must have matching shapes"),$(i===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});const a=[],l=e.map(u=>{const h=cc({inputs:{input:u},backend:t,attrs:{dim:o}});return a.push(h),h}),c=ir({inputs:l,backend:t,attrs:{axis:o}});return a.forEach(u=>t.disposeIntermediateTensorInfo(u)),c}const iO={kernelName:qa,backendName:"cpu",kernelFunc:B1};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10427,7 +10427,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function rO(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{paddings:r,constantValue:i}=s;ce(o,"pad");const a=r.map((b,w)=>b[0]+o.shape[w]+b[1]),l=r.map(b=>b[0]),c=t.data.get(o.dataId).values,u=H(o.shape),h=o.shape.length,d=de(o.shape),p=H(a),f=a.length,g=de(a),m=Tt(o.dtype,p);i!==0&&m.fill(i);for(let b=0;bI+l[v]),C=Pn(y,f,g);m[C]=c[b]}return{dataId:t.write(m,a,o.dtype),shape:a,dtype:o.dtype}}const M1={kernelName:qa,backendName:"cpu",kernelFunc:rO};/** + */function aO(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{paddings:r,constantValue:i}=s;ce(o,"pad");const a=r.map((b,w)=>b[0]+o.shape[w]+b[1]),l=r.map(b=>b[0]),c=t.data.get(o.dataId).values,u=H(o.shape),h=o.shape.length,d=de(o.shape),p=H(a),f=a.length,g=de(a),m=Tt(o.dtype,p);i!==0&&m.fill(i);for(let b=0;bI+l[v]),C=Pn(y,f,g);m[C]=c[b]}return{dataId:t.write(m,a,o.dtype),shape:a,dtype:o.dtype}}const z1={kernelName:ja,backendName:"cpu",kernelFunc:aO};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10442,7 +10442,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const iO=rt((n,e)=>Math.pow(n,e)),aO=ft(Yr,iO),lO={kernelName:Yr,backendName:"cpu",kernelFunc:aO};/** + */const lO=rt((n,e)=>Math.pow(n,e)),cO=ft(Yr,lO),uO={kernelName:Yr,backendName:"cpu",kernelFunc:cO};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10457,7 +10457,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function cO(n){const{inputs:e,backend:t,attrs:s}=n,{paramsNestedSplits:o,paramsDenseValues:r,indices:i}=e,a=o.map(m=>t.data.get(m.dataId).values),l=o.map(m=>m.shape),c=t.data.get(r.dataId).values,u=t.data.get(i.dataId).values,[h,d,p]=J0(a,l,c,r.shape,r.dtype,u,i.shape),f=h.map(m=>t.makeTensorInfo([m.length],"int32",m)),g=t.makeTensorInfo(p,r.dtype,d);return f.concat([g])}const uO={kernelName:Yp,backendName:"cpu",kernelFunc:cO};/** + */function hO(n){const{inputs:e,backend:t,attrs:s}=n,{paramsNestedSplits:o,paramsDenseValues:r,indices:i}=e,a=o.map(m=>t.data.get(m.dataId).values),l=o.map(m=>m.shape),c=t.data.get(r.dataId).values,u=t.data.get(i.dataId).values,[h,d,p]=n1(a,l,c,r.shape,r.dtype,u,i.shape),f=h.map(m=>t.makeTensorInfo([m.length],"int32",m)),g=t.makeTensorInfo(p,r.dtype,d);return f.concat([g])}const dO={kernelName:Yp,backendName:"cpu",kernelFunc:hO};/** * @license * Copyright 2022 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10472,7 +10472,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hO(n){const{inputs:e,backend:t}=n,{starts:s,limits:o,deltas:r}=e,i=t.data.get(s.dataId).values,a=t.data.get(o.dataId).values,l=t.data.get(r.dataId).values,[c,u]=t1(i,s.shape,s.dtype,a,o.shape,l,r.shape),h=t.makeTensorInfo([c.length],"int32",c),d=t.makeTensorInfo([u.length],s.dtype,u);return[h,d]}const dO={kernelName:Zp,backendName:"cpu",kernelFunc:hO};/** + */function pO(n){const{inputs:e,backend:t}=n,{starts:s,limits:o,deltas:r}=e,i=t.data.get(s.dataId).values,a=t.data.get(o.dataId).values,l=t.data.get(r.dataId).values,[c,u]=o1(i,s.shape,s.dtype,a,o.shape,l,r.shape),h=t.makeTensorInfo([c.length],"int32",c),d=t.makeTensorInfo([u.length],s.dtype,u);return[h,d]}const fO={kernelName:Zp,backendName:"cpu",kernelFunc:pO};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10487,7 +10487,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function pO(n){const{inputs:e,backend:t,attrs:s}=n,{shape:o,values:r,defaultValue:i,rowPartitionTensors:a}=e,{rowPartitionTypes:l}=s,c=t.data.get(o.dataId).values,u=t.data.get(r.dataId).values,h=t.data.get(i.dataId).values,d=a.map(m=>t.data.get(m.dataId).values),p=a.map(m=>m.shape),[f,g]=o1(c,o.shape,u,r.shape,r.dtype,h,i.shape,d,p,l);return t.makeTensorInfo(f,r.dtype,g)}const fO={kernelName:Qp,backendName:"cpu",kernelFunc:pO};/** + */function mO(n){const{inputs:e,backend:t,attrs:s}=n,{shape:o,values:r,defaultValue:i,rowPartitionTensors:a}=e,{rowPartitionTypes:l}=s,c=t.data.get(o.dataId).values,u=t.data.get(r.dataId).values,h=t.data.get(i.dataId).values,d=a.map(m=>t.data.get(m.dataId).values),p=a.map(m=>m.shape),[f,g]=a1(c,o.shape,u,r.shape,r.dtype,h,i.shape,d,p,l);return t.makeTensorInfo(f,r.dtype,g)}const gO={kernelName:Qp,backendName:"cpu",kernelFunc:mO};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10502,7 +10502,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function mO(n){const{backend:e,attrs:t}=n,{start:s,stop:o,dtype:r,step:i}=t,a=r1(s,o,i,r);return e.makeTensorInfo([a.length],r,a)}const gO={kernelName:Iu,backendName:"cpu",kernelFunc:mO};/** + */function xO(n){const{backend:e,attrs:t}=n,{start:s,stop:o,dtype:r,step:i}=t,a=l1(s,o,i,r);return e.makeTensorInfo([a.length],r,a)}const bO={kernelName:$u,backendName:"cpu",kernelFunc:xO};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10517,7 +10517,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const xO=Pe(Zr,n=>1/n),bO={kernelName:Zr,backendName:"cpu",kernelFunc:xO};/** + */const yO=Pe(Zr,n=>1/n),wO={kernelName:Zr,backendName:"cpu",kernelFunc:yO};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10532,7 +10532,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function yO(n){const{inputs:e,backend:t,attrs:s}=n,{images:o}=e,{alignCorners:r,halfPixelCenters:i,size:a}=s;ce(o,"resizeBilinear");const l=de(o.shape),[c,u]=a,[h,d,p,f]=o.shape,g=t.data.get(o.dataId).values,m=new Float32Array(H([h,c,u,f])),x=[r&&c>1?d-1:d,r&&u>1?p-1:p],b=[r&&c>1?c-1:c,r&&u>1?u-1:u];let w=0;const y=x[0]/b[0],C=x[1]/b[1];for(let I=0;I1?d-1:d,r&&u>1?p-1:p],b=[r&&c>1?c-1:c,r&&u>1?u-1:u];let w=0;const y=x[0]/b[0],C=x[1]/b[1];for(let I=0;I1?c-1:c,i&&p>1?u-1:u],m=[i&&d>1?d-1:d,i&&p>1?p-1:p],x=g[0]/m[0],b=g[1]/m[1],w=t.data.get(r.dataId).values;let y=0;for(let C=0;C1?c-1:c,i&&p>1?u-1:u],m=[i&&d>1?d-1:d,i&&p>1?p-1:p],x=g[0]/m[0],b=g[1]/m[1],w=t.data.get(r.dataId).values;let y=0;for(let C=0;C1?d-1:d,r&&u>1?p-1:p],b=[r&&c>1?c-1:c,r&&u>1?u-1:u],w=x[0]/b[0],y=x[1]/b[1];let C=0;for(let I=0;I1?d-1:d,r&&u>1?p-1:p],b=[r&&c>1?c-1:c,r&&u>1?u-1:u],w=x[0]/b[0],y=x[1]/b[1];let C=0;for(let I=0;I1?u-1:u,i&&f>1?h-1:h],b=[i&&p>1?p-1:p,i&&f>1?f-1:f],w=x[0]/b[0],y=x[1]/b[1],C=1/w,I=1/y,v=Math.ceil(C)*2+2,k=Math.ceil(I)*2+2;for(let S=0;S=p)continue;const q=T+J*l[1],Q=J*w,Y=Math.min(u-1,i?Math.round(Q):Math.floor(Q));if(E===Y)for(let te=0;te=f)continue;const he=q+ie*l[2],le=ie*y,ae=Math.min(h-1,i?Math.round(le):Math.floor(le));R===ae&&(K+=m[he+j])}}g[P+j]=K}}}}return t.makeTensorInfo(o.shape,o.dtype,g)}const SO={kernelName:vu,backendName:"cpu",kernelFunc:kO};/** + */function TO(n){const{inputs:e,backend:t,attrs:s}=n,{images:o,dy:r}=e,{alignCorners:i}=s;ce([r,o],"resizeNearestNeighborGrad");const a=de(o.shape),l=de(r.shape),[c,u,h,d]=o.shape,[,p,f]=r.shape,g=new Float32Array(c*u*h*d),m=t.data.get(r.dataId).values,x=[i&&p>1?u-1:u,i&&f>1?h-1:h],b=[i&&p>1?p-1:p,i&&f>1?f-1:f],w=x[0]/b[0],y=x[1]/b[1],C=1/w,I=1/y,v=Math.ceil(C)*2+2,k=Math.ceil(I)*2+2;for(let S=0;S=p)continue;const j=T+J*l[1],Q=J*w,Z=Math.min(u-1,i?Math.round(Q):Math.floor(Q));if(E===Z)for(let te=0;te=f)continue;const he=j+ie*l[2],le=ie*y,ae=Math.min(h-1,i?Math.round(le):Math.floor(le));R===ae&&(K+=m[he+q])}}g[B+q]=K}}}}return t.makeTensorInfo(o.shape,o.dtype,g)}const NO={kernelName:ku,backendName:"cpu",kernelFunc:TO};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10592,7 +10592,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function TO(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{dims:r}=s;ce(o,"reverse");const i=o.shape.length,a=$e(r,o.shape);if(i===0)return Jn({inputs:{x:o},backend:t});const l=new yt(o.shape,o.dtype),c=t.bufferSync(o);for(let u=0;ud[p]=o.shape[p]-1-d[p]),l.set(c.get(...d),...h)}return t.makeTensorInfo(l.shape,l.dtype,l.values)}const NO={kernelName:Ja,backendName:"cpu",kernelFunc:TO};/** + */function EO(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{dims:r}=s;ce(o,"reverse");const i=o.shape.length,a=$e(r,o.shape);if(i===0)return Jn({inputs:{x:o},backend:t});const l=new yt(o.shape,o.dtype),c=t.bufferSync(o);for(let u=0;ud[p]=o.shape[p]-1-d[p]),l.set(c.get(...d),...h)}return t.makeTensorInfo(l.shape,l.dtype,l.values)}const RO={kernelName:Ja,backendName:"cpu",kernelFunc:EO};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10607,7 +10607,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const EO={kernelName:Du,backendName:"cpu",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{image:s}=n,{radians:o,fillValue:r,center:i}=e,a=t,l=Tt(s.dtype,H(s.shape)),[c,u,h,d]=s.shape,[p,f]=Yh(i,u,h),g=255,m=Math.sin(o),x=Math.cos(o),b=a.data.get(s.dataId).values;for(let y=0;y=0&&L=0&&R{const{image:s}=n,{radians:o,fillValue:r,center:i}=e,a=t,l=Tt(s.dtype,H(s.shape)),[c,u,h,d]=s.shape,[p,f]=Yh(i,u,h),g=255,m=Math.sin(o),x=Math.cos(o),b=a.data.get(s.dataId).values;for(let y=0;y=0&&L=0&&R{const e=Math.floor(n);return n-e<.5?Math.floor(n):n-e>.5?Math.ceil(n):e%2===0?e:e+1}),AO={kernelName:ei,backendName:"cpu",kernelFunc:RO};/** + */const DO=Pe(ei,n=>{const e=Math.floor(n);return n-e<.5?Math.floor(n):n-e>.5?Math.ceil(n):e%2===0?e:e+1}),FO={kernelName:ei,backendName:"cpu",kernelFunc:DO};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10637,7 +10637,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function DO(n){const{inputs:e,backend:t,attrs:s}=n,{indices:o,updates:r}=e,{shape:i}=s,{sliceRank:a,numUpdates:l,sliceSize:c,strides:u,outputSize:h}=uo(r,o,i),d=!0,p=t.bufferSync(o),f=t.bufferSync(r),g=wo(p,f,i,h,c,l,a,u,0,d);return t.makeTensorInfo(i,g.dtype,g.values)}const FO={kernelName:Jp,backendName:"cpu",kernelFunc:DO};/** + */function _O(n){const{inputs:e,backend:t,attrs:s}=n,{indices:o,updates:r}=e,{shape:i}=s,{sliceRank:a,numUpdates:l,sliceSize:c,strides:u,outputSize:h}=ho(r,o,i),d=!0,p=t.bufferSync(o),f=t.bufferSync(r),g=Co(p,f,i,h,c,l,a,u,0,d);return t.makeTensorInfo(i,g.dtype,g.values)}const OO={kernelName:Jp,backendName:"cpu",kernelFunc:_O};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10652,7 +10652,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _O(n,e){let t=0,s=n.length,o=0;for(;t1||o.shape.length===1?1:H(o.shape.slice(1));for(let f=0;f1||o.shape.length===1?1:H(o.shape.slice(1));for(let f=0;fn>=0?WO*n:VO*(Math.exp(n)-1)),GO={kernelName:ni,backendName:"cpu",kernelFunc:UO};/** + */const UO=Dl,GO=Fl,HO=Pe(ni,n=>n>=0?GO*n:UO*(Math.exp(n)-1)),qO={kernelName:ni,backendName:"cpu",kernelFunc:HO};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10712,7 +10712,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const HO=Pe(ri,n=>n<0?-1:n>0?1:0),jO={kernelName:ri,backendName:"cpu",kernelFunc:HO};/** + */const jO=Pe(ri,n=>n<0?-1:n>0?1:0),KO={kernelName:ri,backendName:"cpu",kernelFunc:jO};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10727,7 +10727,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const qO=Pe(si,n=>Math.sin(n)),KO={kernelName:si,backendName:"cpu",kernelFunc:qO};/** + */const XO=Pe(si,n=>Math.sin(n)),YO={kernelName:si,backendName:"cpu",kernelFunc:XO};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10742,7 +10742,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const XO=Pe(oi,n=>Math.sinh(n)),YO={kernelName:oi,backendName:"cpu",kernelFunc:XO};/** + */const ZO=Pe(oi,n=>Math.sinh(n)),QO={kernelName:oi,backendName:"cpu",kernelFunc:ZO};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10757,7 +10757,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const P1=Math.log(11920928955078125e-23)+2,ZO=Pe(ai,n=>{const e=n>-P1,t=n{const e=n>-V1,t=nNumber(m)))),t.makeTensorInfo([g.length],s.dtype,new Int32Array(g))]}const nL={kernelName:nf,backendName:"cpu",kernelFunc:tL};/** + ${i.shape}`);const a=t.data.get(s.dataId).values,l=t.data.get(o.dataId).values,c=t.data.get(r.dataId).values,u=t.data.get(i.dataId).values[0],[h,d,p,f,g]=d1(a,s.shape,s.dtype,l,o.dtype,c,u);return[t.makeTensorInfo(d,s.dtype,h),t.makeTensorInfo([d[0]],o.dtype,p),t.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(m=>Number(m)))),t.makeTensorInfo([g.length],s.dtype,new Int32Array(g))]}const oL={kernelName:nf,backendName:"cpu",kernelFunc:sL};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10806,9 +10806,9 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function sL(n){const{inputs:e,backend:t}=n,{inputIndices:s,inputShape:o,newShape:r}=e;if(s.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape + */function rL(n){const{inputs:e,backend:t}=n,{inputIndices:s,inputShape:o,newShape:r}=e;if(s.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape ${s.shape}`);if(o.shape.length!==1)throw new Error(`Input shape should be a vector but received shape - ${o.shape}`);if(r.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${r.shape}`);const i=Array.from(t.data.get(o.dataId).values),a=t.data.get(s.dataId).values,l=Array.from(t.data.get(r.dataId).values),[c,u,h]=u1(a,s.shape,s.dtype,i,l);return[t.makeTensorInfo(u,s.dtype,c),t.makeTensorInfo([h.length],r.dtype,new Int32Array(h))]}const oL={kernelName:sf,backendName:"cpu",kernelFunc:sL};/** + ${o.shape}`);if(r.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${r.shape}`);const i=Array.from(t.data.get(o.dataId).values),a=t.data.get(s.dataId).values,l=Array.from(t.data.get(r.dataId).values),[c,u,h]=p1(a,s.shape,s.dtype,i,l);return[t.makeTensorInfo(u,s.dtype,c),t.makeTensorInfo([h.length],r.dtype,new Int32Array(h))]}const iL={kernelName:sf,backendName:"cpu",kernelFunc:rL};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10823,9 +10823,9 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function rL(n){const{inputs:e,backend:t}=n,{data:s,indices:o,segmentIds:r}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(o.shape.length!==1)throw new Error(`Indices should be a vector but received shape + */function aL(n){const{inputs:e,backend:t}=n,{data:s,indices:o,segmentIds:r}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(o.shape.length!==1)throw new Error(`Indices should be a vector but received shape ${o.shape}`);if(r.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape - ${r.shape}`);if(o.shape[0]!==r.shape[0])throw new Error("segmentIds and indices should have same size.");const i=t.data.get(s.dataId).values,a=t.data.get(o.dataId).values,l=t.data.get(r.dataId).values,[c,u]=np(i,s.shape,s.dtype,a,l,!0);return t.makeTensorInfo(u,s.dtype,c)}const iL={kernelName:of,backendName:"cpu",kernelFunc:rL};/** + ${r.shape}`);if(o.shape[0]!==r.shape[0])throw new Error("segmentIds and indices should have same size.");const i=t.data.get(s.dataId).values,a=t.data.get(o.dataId).values,l=t.data.get(r.dataId).values,[c,u]=np(i,s.shape,s.dtype,a,l,!0);return t.makeTensorInfo(u,s.dtype,c)}const lL={kernelName:of,backendName:"cpu",kernelFunc:aL};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10840,9 +10840,9 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function aL(n){const{inputs:e,backend:t}=n,{data:s,indices:o,segmentIds:r}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(o.shape.length!==1)throw new Error(`Indices should be a vector but received shape + */function cL(n){const{inputs:e,backend:t}=n,{data:s,indices:o,segmentIds:r}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(o.shape.length!==1)throw new Error(`Indices should be a vector but received shape ${o.shape}`);if(r.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape - ${r.shape}`);if(o.shape[0]!==r.shape[0])throw new Error("segmentIds and indices should have same size.");const i=t.data.get(s.dataId).values,a=t.data.get(o.dataId).values,l=t.data.get(r.dataId).values,[c,u]=np(i,s.shape,s.dtype,a,l);return t.makeTensorInfo(u,s.dtype,c)}const lL={kernelName:rf,backendName:"cpu",kernelFunc:aL};/** + ${r.shape}`);if(o.shape[0]!==r.shape[0])throw new Error("segmentIds and indices should have same size.");const i=t.data.get(s.dataId).values,a=t.data.get(o.dataId).values,l=t.data.get(r.dataId).values,[c,u]=np(i,s.shape,s.dtype,a,l);return t.makeTensorInfo(u,s.dtype,c)}const uL={kernelName:rf,backendName:"cpu",kernelFunc:cL};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10857,7 +10857,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function cL(n){const{inputs:e,backend:t,attrs:s}=n,{sparseIndices:o,sparseValues:r,defaultValue:i}=e,{outputShape:a}=s,{sliceRank:l,numUpdates:c,sliceSize:u,strides:h,outputSize:d}=uo(r,o,a),p=!1,f=t.bufferSync(o);let g;switch(r.dtype){case"bool":{const m=t.bufferSync(r),x=!!t.data.get(i.dataId).values[0];g=wo(f,m,a,d,u,c,l,h,x,p);break}case"float32":{const m=t.bufferSync(r),x=t.data.get(i.dataId).values[0];g=wo(f,m,a,d,u,c,l,h,x,p);break}case"int32":{const m=t.bufferSync(r),x=t.data.get(i.dataId).values[0];g=wo(f,m,a,d,u,c,l,h,x,p);break}case"string":{const m=t.bufferSync(r),x=ys(t.data.get(i.dataId).values[0]);g=wo(f,m,a,d,u,c,l,h,x,p);break}default:throw new Error(`Unsupported type ${r.dtype}`)}return t.makeTensorInfo(a,g.dtype,g.values)}const uL={kernelName:af,backendName:"cpu",kernelFunc:cL};/** + */function hL(n){const{inputs:e,backend:t,attrs:s}=n,{sparseIndices:o,sparseValues:r,defaultValue:i}=e,{outputShape:a}=s,{sliceRank:l,numUpdates:c,sliceSize:u,strides:h,outputSize:d}=ho(r,o,a),p=!1,f=t.bufferSync(o);let g;switch(r.dtype){case"bool":{const m=t.bufferSync(r),x=!!t.data.get(i.dataId).values[0];g=Co(f,m,a,d,u,c,l,h,x,p);break}case"float32":{const m=t.bufferSync(r),x=t.data.get(i.dataId).values[0];g=Co(f,m,a,d,u,c,l,h,x,p);break}case"int32":{const m=t.bufferSync(r),x=t.data.get(i.dataId).values[0];g=Co(f,m,a,d,u,c,l,h,x,p);break}case"string":{const m=t.bufferSync(r),x=ys(t.data.get(i.dataId).values[0]);g=Co(f,m,a,d,u,c,l,h,x,p);break}default:throw new Error(`Unsupported type ${r.dtype}`)}return t.makeTensorInfo(a,g.dtype,g.values)}const dL={kernelName:af,backendName:"cpu",kernelFunc:hL};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10872,7 +10872,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hL(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{numOrSizeSplits:r,axis:i}=s,a=$e(i,o.shape)[0],l=dd(o,r,a),c=new Array(o.shape.length).fill(0),u=o.shape.slice();return l.map(h=>{const d=[...u];d[a]=h;const p=Co({inputs:{x:o},backend:t,attrs:{begin:c,size:d}});return c[a]+=h,p})}const dL={kernelName:ol,backendName:"cpu",kernelFunc:hL};/** + */function pL(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{numOrSizeSplits:r,axis:i}=s,a=$e(i,o.shape)[0],l=dd(o,r,a),c=new Array(o.shape.length).fill(0),u=o.shape.slice();return l.map(h=>{const d=[...u];d[a]=h;const p=Io({inputs:{x:o},backend:t,attrs:{begin:c,size:d}});return c[a]+=h,p})}const fL={kernelName:ol,backendName:"cpu",kernelFunc:pL};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10887,7 +10887,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const pL={kernelName:Su,backendName:"cpu",kernelFunc:({inputs:n,backend:e})=>{const{x:t}=n,s=e;ce(t,"square");const o=s.data.get(t.dataId).values,r=new Float32Array(o.length);for(let a=0;a{const{x:t}=n,s=e;ce(t,"square");const o=s.data.get(t.dataId).values,r=new Float32Array(o.length);for(let a=0;a{const t=e;return isNaN(n)?NaN:n>0?1:t.alpha}),mL={kernelName:fi,backendName:"cpu",kernelFunc:fL};/** + */const gL=Pe(fi,(n,e)=>{const t=e;return isNaN(n)?NaN:n>0?1:t.alpha}),xL={kernelName:fi,backendName:"cpu",kernelFunc:gL};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10917,7 +10917,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function gL(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{begin:r,end:i,strides:a,beginMask:l,endMask:c,ellipsisMask:u,newAxisMask:h,shrinkAxisMask:d}=s;ce(o,"stridedSlice");const{finalShapeSparse:p,finalShape:f,isIdentity:g,sliceDim0:m,isSimpleSlice:x,begin:b,end:w,strides:y}=qh(o.shape,r,i,a,l,c,u,h,d);let C;if(g)C=Ue({inputs:{x:o},backend:t,attrs:{shape:f}});else if(m||x){$(o.shape.length>=1,()=>`Input must have rank at least 1, got: ${o.shape.length}`);const I=Gh(b,w,y),v=Co({inputs:{x:o},backend:t,attrs:{begin:b,size:I}});C=Ue({inputs:{x:v},backend:t,attrs:{shape:f}}),t.disposeIntermediateTensorInfo(v)}else{const I=t.bufferSync(o),v=p1(p,I,y,b);C=t.makeTensorInfo(f,v.dtype,v.values)}return C}const xL={kernelName:Nu,backendName:"cpu",kernelFunc:gL};/** + */function bL(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{begin:r,end:i,strides:a,beginMask:l,endMask:c,ellipsisMask:u,newAxisMask:h,shrinkAxisMask:d}=s;ce(o,"stridedSlice");const{finalShapeSparse:p,finalShape:f,isIdentity:g,sliceDim0:m,isSimpleSlice:x,begin:b,end:w,strides:y}=jh(o.shape,r,i,a,l,c,u,h,d);let C;if(g)C=Ue({inputs:{x:o},backend:t,attrs:{shape:f}});else if(m||x){$(o.shape.length>=1,()=>`Input must have rank at least 1, got: ${o.shape.length}`);const I=Gh(b,w,y),v=Io({inputs:{x:o},backend:t,attrs:{begin:b,size:I}});C=Ue({inputs:{x:v},backend:t,attrs:{shape:f}}),t.disposeIntermediateTensorInfo(v)}else{const I=t.bufferSync(o),v=g1(p,I,y,b);C=t.makeTensorInfo(f,v.dtype,v.values)}return C}const yL={kernelName:Eu,backendName:"cpu",kernelFunc:bL};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10932,7 +10932,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function bL(n){const{inputs:e,backend:t,attrs:s}=n,{separator:o,nGramWidths:r,leftPad:i,rightPad:a,padWidth:l,preserveShortSequences:c}=s,{data:u,dataSplits:h}=e,d=t.data.get(u.dataId).values,p=t.data.get(h.dataId).values,[f,g]=f1(d,p,o,r,i,a,l,c);return[t.makeTensorInfo([f.length],"string",f),t.makeTensorInfo(h.shape,"int32",g)]}const yL={kernelName:lf,backendName:"cpu",kernelFunc:bL};/** + */function wL(n){const{inputs:e,backend:t,attrs:s}=n,{separator:o,nGramWidths:r,leftPad:i,rightPad:a,padWidth:l,preserveShortSequences:c}=s,{data:u,dataSplits:h}=e,d=t.data.get(u.dataId).values,p=t.data.get(h.dataId).values,[f,g]=x1(d,p,o,r,i,a,l,c);return[t.makeTensorInfo([f.length],"string",f),t.makeTensorInfo(h.shape,"int32",g)]}const CL={kernelName:lf,backendName:"cpu",kernelFunc:wL};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10947,7 +10947,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function wL(n){const{inputs:e,backend:t,attrs:s}=n,{skipEmpty:o}=s,{input:r,delimiter:i}=e;if(r.dtype!=="string")throw new Error("Input must be of datatype string");if(r.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${r.shape}`);if(i.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${i.shape}`);const a=t.data.get(r.dataId).values,l=t.data.get(i.dataId).values[0],[c,u,h]=m1(a,l,o),d=u.length;return[t.makeTensorInfo([d,2],"int32",c),t.makeTensorInfo([d],"string",u),t.makeTensorInfo([2],"int32",new Int32Array(h))]}const CL={kernelName:cf,backendName:"cpu",kernelFunc:wL};/** + */function IL(n){const{inputs:e,backend:t,attrs:s}=n,{skipEmpty:o}=s,{input:r,delimiter:i}=e;if(r.dtype!=="string")throw new Error("Input must be of datatype string");if(r.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${r.shape}`);if(i.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${i.shape}`);const a=t.data.get(r.dataId).values,l=t.data.get(i.dataId).values[0],[c,u,h]=b1(a,l,o),d=u.length;return[t.makeTensorInfo([d,2],"int32",c),t.makeTensorInfo([d],"string",u),t.makeTensorInfo([2],"int32",new Int32Array(h))]}const $L={kernelName:cf,backendName:"cpu",kernelFunc:IL};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10962,7 +10962,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function IL(n){const{inputs:e,backend:t,attrs:s}=n,{numBuckets:o}=s,{input:r}=e;if(r.dtype!=="string")throw new Error("Input must be of datatype string");if(o<=0)throw new Error("Number of buckets must be at least 1");const i=t.data.get(r.dataId).values,a=g1(i,o);return t.makeTensorInfo(r.shape,"int32",a)}const $L={kernelName:uf,backendName:"cpu",kernelFunc:IL};/** + */function vL(n){const{inputs:e,backend:t,attrs:s}=n,{numBuckets:o}=s,{input:r}=e;if(r.dtype!=="string")throw new Error("Input must be of datatype string");if(o<=0)throw new Error("Number of buckets must be at least 1");const i=t.data.get(r.dataId).values,a=y1(i,o);return t.makeTensorInfo(r.shape,"int32",a)}const kL={kernelName:uf,backendName:"cpu",kernelFunc:vL};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10977,7 +10977,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const vL=Pe(hi,n=>Math.tan(n)),kL={kernelName:hi,backendName:"cpu",kernelFunc:vL};/** + */const SL=Pe(hi,n=>Math.tan(n)),TL={kernelName:hi,backendName:"cpu",kernelFunc:SL};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10992,7 +10992,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const SL=Pe(di,n=>Math.tanh(n)),TL={kernelName:di,backendName:"cpu",kernelFunc:SL};/** + */const NL=Pe(di,n=>Math.tanh(n)),EL={kernelName:di,backendName:"cpu",kernelFunc:NL};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11007,7 +11007,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function NL(n){const{inputs:e,backend:t}=n,{tensor:s,indices:o,updates:r}=e,{sliceRank:i,numUpdates:a,sliceSize:l,strides:c,outputSize:u}=uo(r,o,s.shape),h=!1,d=t.bufferSync(o),p=t.bufferSync(r),f=t.bufferSync(s),g=wo(d,p,s.shape,u,l,a,i,c,f,h);return t.makeTensorInfo(s.shape,g.dtype,g.values)}const EL={kernelName:ef,backendName:"cpu",kernelFunc:NL};/** + */function RL(n){const{inputs:e,backend:t}=n,{tensor:s,indices:o,updates:r}=e,{sliceRank:i,numUpdates:a,sliceSize:l,strides:c,outputSize:u}=ho(r,o,s.shape),h=!1,d=t.bufferSync(o),p=t.bufferSync(r),f=t.bufferSync(s),g=Co(d,p,s.shape,u,l,a,i,c,f,h);return t.makeTensorInfo(s.shape,g.dtype,g.values)}const AL={kernelName:ef,backendName:"cpu",kernelFunc:RL};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11022,7 +11022,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function RL(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{reps:r}=s;ce(o,"tile");const i=b1(t.bufferSync(o),r);return t.makeTensorInfo(i.shape,i.dtype,i.values)}const AL={kernelName:pi,backendName:"cpu",kernelFunc:RL};/** + */function DL(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{reps:r}=s;ce(o,"tile");const i=C1(t.bufferSync(o),r);return t.makeTensorInfo(i.shape,i.dtype,i.values)}const FL={kernelName:pi,backendName:"cpu",kernelFunc:DL};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11037,7 +11037,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function DL(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{k:r,sorted:i}=s;ce(o,"topk");const a=t.data.get(o.dataId).values,[l,c]=w1(a,o.shape,o.dtype,r,i);return[t.makeTensorInfo(l.shape,l.dtype,l.values),t.makeTensorInfo(c.shape,c.dtype,c.values)]}const FL={kernelName:Eu,backendName:"cpu",kernelFunc:DL};/** + */function _L(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{k:r,sorted:i}=s;ce(o,"topk");const a=t.data.get(o.dataId).values,[l,c]=$1(a,o.shape,o.dtype,r,i);return[t.makeTensorInfo(l.shape,l.dtype,l.values),t.makeTensorInfo(c.shape,c.dtype,c.values)]}const OL={kernelName:Ru,backendName:"cpu",kernelFunc:_L};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11052,7 +11052,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _L(n){const{inputs:e,attrs:t,backend:s}=n,{image:o,transforms:r}=e,{interpolation:i,fillMode:a,fillValue:l,outputShape:c}=t,[u,h,d,p]=o.shape,[f,g]=c??[h,d],m=[u,f,g,p],x=de(o.shape),b=x[0],w=x[1],y=x[2],C=de(m),I=C[0],v=C[1],k=C[2],S=Tt(o.dtype,H(m));S.fill(l);const T=s.data.get(o.dataId).values,E=s.data.get(r.dataId).values;for(let M=0;Me-1)if(e<=1)t=0;else{const s=2*e;t-=s*Math.trunc(t/s),t>=e&&(t=s-t-1)}return Us(0,t,e-1)}function ML(n,e){let t=n;if(t<0)if(e<=1)t=0;else{const s=e-1;t+=e*(Math.trunc(-t/s)+1)}else if(t>e-1)if(e<=1)t=0;else{const s=e-1;t-=e*Math.trunc(t/s)}return Us(0,t,e-1)}function PL(n,e){return n}function BL(n,e){return Us(0,n,e-1)}function Yi(n,e,t,s,o,r,i,a,l,c,u){const h=i*s+a*o+l*r+c;return 0<=a&&ae-1)if(e<=1)t=0;else{const s=2*e;t-=s*Math.trunc(t/s),t>=e&&(t=s-t-1)}return Us(0,t,e-1)}function BL(n,e){let t=n;if(t<0)if(e<=1)t=0;else{const s=e-1;t+=e*(Math.trunc(-t/s)+1)}else if(t>e-1)if(e<=1)t=0;else{const s=e-1;t-=e*Math.trunc(t/s)}return Us(0,t,e-1)}function zL(n,e){return n}function VL(n,e){return Us(0,n,e-1)}function Yi(n,e,t,s,o,r,i,a,l,c,u){const h=i*s+a*o+l*r+c;return 0<=a&&at.disposeIntermediateTensorInfo(f)),p}const qL={kernelName:al,backendName:"cpu",kernelFunc:jL};/** + */function KL(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,segmentIds:r}=e,{numSegments:i}=s;ce(o,"unsortedSegmentSum");const a=o.shape.length,l=r.shape.length,c=[],u=[],h=a-l;let d=r;for(let f=0;ft.disposeIntermediateTensorInfo(f)),p}const XL={kernelName:al,backendName:"cpu",kernelFunc:KL};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11112,7 +11112,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const KL=[GA,vR,jA,KA,RR,YA,QA,eD,nD,oD,iD,lD,uD,pD,mD,bD,wD,ID,vD,WA,SD,ND,RD,DR,DD,NR,_R,_D,kR,OD,MD,PD,zD,WD,GD,jD,KD,YD,QD,eF,nF,oF,iF,lF,cF,hF,pF,mF,gF,xF,bF,wF,$F,OA,kF,OR,FF,LR,_F,PR,zF,VF,UF,zR,WR,HF,qF,XF,ZF,GR,jR,SR,JF,LD,t_,s_,r_,LA,KR,YR,a_,QR,c_,d_,f_,x_,y_,C_,I_,eA,v_,S_,N_,R_,D_,__,L_,nA,P_,V_,G_,oA,iA,q_,Y_,J_,lA,tO,sO,oO,M1,lO,PA,hA,uO,dO,fO,gO,TR,ip,bO,BA,zA,VA,wO,IO,vO,SO,NO,EO,AO,yA,FO,PO,zO,GO,CA,jO,KO,YO,IA,W_,QO,eL,nL,oL,iL,lL,uL,dL,kA,pL,TA,EA,mL,xL,yL,CL,$L,FA,CF,kL,TL,EL,AL,FL,OL,cA,UL,HL,qL,nO];for(const n of KL)mf(n);/** + */const YL=[qA,SR,KA,YA,DR,QA,eD,nD,oD,iD,lD,uD,dD,mD,xD,wD,ID,vD,SD,GA,ND,RD,DD,_R,_D,RR,LR,LD,TR,MD,BD,zD,WD,GD,qD,KD,YD,QD,eF,nF,oF,iF,lF,uF,hF,pF,mF,xF,bF,yF,wF,IF,kF,MA,TF,MR,OF,PR,LF,zR,WF,UF,HF,WR,GR,jF,XF,ZF,JF,qR,KR,NR,t_,PD,s_,r_,a_,PA,YR,QR,c_,eA,h_,f_,g_,y_,C_,$_,v_,nA,S_,N_,R_,D_,__,L_,P_,oA,z_,U_,q_,iA,lA,X_,Q_,tO,uA,sO,rO,iO,z1,uO,zA,pA,dO,fO,gO,bO,ER,ip,wO,VA,WA,UA,IO,vO,SO,NO,RO,AO,FO,CA,OO,zO,WO,qO,$A,KO,YO,QO,vA,G_,eL,nL,oL,iL,lL,uL,dL,fL,TA,mL,EA,AA,xL,yL,CL,$L,kL,OA,$F,TL,EL,AL,FL,OL,ML,hA,HL,jL,XL,oO];for(const n of YL)mf(n);/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11127,7 +11127,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Io={},uc={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function XL(n,e){Io[n]=e}function Ln(n,e){if(!(n in Io)||e!=null){const s=ZL(n,e);if(s!==null)Io[n]=s;else return console.log("Could not get context for WebGL version",n),null}const t=Io[n];return t==null||t.isContextLost()?(delete Io[n],Ln(n)):(t.disable(t.DEPTH_TEST),t.disable(t.STENCIL_TEST),t.disable(t.BLEND),t.disable(t.DITHER),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SAMPLE_COVERAGE),t.enable(t.SCISSOR_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),Io[n])}function YL(n){if(!W().getBool("IS_SAFARI")&&typeof OffscreenCanvas<"u"&&n===2)return new OffscreenCanvas(300,150);if(typeof document<"u")return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}function ZL(n,e){if(n!==1&&n!==2)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const t=e??YL(n);return t.addEventListener("webglcontextlost",s=>{s.preventDefault(),delete Io[n]},!1),W().getBool("SOFTWARE_WEBGL_ENABLED")&&(uc.failIfMajorPerformanceCaveat=!1),n===1?t.getContext("webgl",uc)||t.getContext("experimental-webgl",uc):t.getContext("webgl2",uc)}/** + */const $o={},hc={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function ZL(n,e){$o[n]=e}function Ln(n,e){if(!(n in $o)||e!=null){const s=JL(n,e);if(s!==null)$o[n]=s;else return console.log("Could not get context for WebGL version",n),null}const t=$o[n];return t==null||t.isContextLost()?(delete $o[n],Ln(n)):(t.disable(t.DEPTH_TEST),t.disable(t.STENCIL_TEST),t.disable(t.BLEND),t.disable(t.DITHER),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SAMPLE_COVERAGE),t.enable(t.SCISSOR_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),$o[n])}function QL(n){if(!W().getBool("IS_SAFARI")&&typeof OffscreenCanvas<"u"&&n===2)return new OffscreenCanvas(300,150);if(typeof document<"u")return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}function JL(n,e){if(n!==1&&n!==2)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const t=e??QL(n);return t.addEventListener("webglcontextlost",s=>{s.preventDefault(),delete $o[n]},!1),W().getBool("SOFTWARE_WEBGL_ENABLED")&&(hc.failIfMajorPerformanceCaveat=!1),n===1?t.getContext("webgl",hc)||t.getContext("experimental-webgl",hc):t.getContext("webgl2",hc)}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11142,7 +11142,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */var Zi;(function(n){n[n.DENSE=0]="DENSE",n[n.SHARED_BATCH=1]="SHARED_BATCH"})(Zi||(Zi={}));var rn;(function(n){n[n.RENDER=0]="RENDER",n[n.UPLOAD=1]="UPLOAD",n[n.PIXELS=2]="PIXELS",n[n.DOWNLOAD=3]="DOWNLOAD"})(rn||(rn={}));var $t;(function(n){n[n.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",n[n.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",n[n.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",n[n.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",n[n.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"})($t||($t={}));function Qi(n,e){return[e,n]}function QL(n,e){return n*e}function hc(n){const e=H(n),t=Math.ceil(e/4);return Lc(t)}function ar(n,e){return[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(n/2))]}function JL(n,e){const[t,s]=ar(n,e);return t*s*4}function cp(n,e){const t=n;let s,o,r,i,a,l,c,u,h,d;return W().getNumber("WEBGL_VERSION")===2?(s=t.R32F,o=t.R16F,r=t.RGBA16F,i=t.RGBA32F,a=t.RED,c=4,u=1,h=t.HALF_FLOAT,d=t.FLOAT,l=t.RGBA8):(s=n.RGBA,o=n.RGBA,r=n.RGBA,i=t.RGBA,a=n.RGBA,c=4,u=4,h=e!=null?e.HALF_FLOAT_OES:null,d=n.FLOAT,l=n.RGBA),{internalFormatFloat:s,internalFormatHalfFloat:o,internalFormatPackedHalfFloat:r,internalFormatPackedFloat:i,textureFormatFloat:a,downloadTextureFormat:l,downloadUnpackNumChannels:c,defaultNumChannels:u,textureTypeHalfFloat:h,textureTypeFloat:d}}/** + */var Zi;(function(n){n[n.DENSE=0]="DENSE",n[n.SHARED_BATCH=1]="SHARED_BATCH"})(Zi||(Zi={}));var rn;(function(n){n[n.RENDER=0]="RENDER",n[n.UPLOAD=1]="UPLOAD",n[n.PIXELS=2]="PIXELS",n[n.DOWNLOAD=3]="DOWNLOAD"})(rn||(rn={}));var $t;(function(n){n[n.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",n[n.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",n[n.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",n[n.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",n[n.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"})($t||($t={}));function Qi(n,e){return[e,n]}function eM(n,e){return n*e}function dc(n){const e=H(n),t=Math.ceil(e/4);return Mc(t)}function ar(n,e){return[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(n/2))]}function tM(n,e){const[t,s]=ar(n,e);return t*s*4}function cp(n,e){const t=n;let s,o,r,i,a,l,c,u,h,d;return W().getNumber("WEBGL_VERSION")===2?(s=t.R32F,o=t.R16F,r=t.RGBA16F,i=t.RGBA32F,a=t.RED,c=4,u=1,h=t.HALF_FLOAT,d=t.FLOAT,l=t.RGBA8):(s=n.RGBA,o=n.RGBA,r=n.RGBA,i=t.RGBA,a=n.RGBA,c=4,u=4,h=e!=null?e.HALF_FLOAT_OES:null,d=n.FLOAT,l=n.RGBA),{internalFormatFloat:s,internalFormatHalfFloat:o,internalFormatPackedHalfFloat:r,internalFormatPackedFloat:i,textureFormatFloat:a,downloadTextureFormat:l,downloadUnpackNumChannels:c,defaultNumChannels:u,textureTypeHalfFloat:h,textureTypeFloat:d}}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11157,11 +11157,11 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function re(n,e){const t=e();return W().getBool("DEBUG")&&eM(n),t}function eM(n){const e=n.getError();if(e!==n.NO_ERROR)throw new Error("WebGL Error: "+oM(n,e))}const tM=596e-10,nM=65504;function sM(n){return!!(W().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||n===0||tMn.getExtension(e),'Extension "'+e+'" not supported on this browser.')}function rM(n,e){const t=ds(n,()=>n.createShader(n.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(re(n,()=>n.shaderSource(t,e)),re(n,()=>n.compileShader(t)),n.getShaderParameter(t,n.COMPILE_STATUS)===!1)throw console.log(n.getShaderInfoLog(t)),new Error("Failed to compile vertex shader.");return t}function iM(n,e){const t=ds(n,()=>n.createShader(n.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(re(n,()=>n.shaderSource(t,e)),re(n,()=>n.compileShader(t)),W().get("ENGINE_COMPILE_ONLY"))return t;if(n.getShaderParameter(t,n.COMPILE_STATUS)===!1)throw z1(e,n.getShaderInfoLog(t)),new Error("Failed to compile fragment shader.");return t}const aM=/ERROR: [0-9]+:([0-9]+):/g;function z1(n,e){const t=aM.exec(e);if(t==null){console.log(`Couldn't parse line number in error: ${e}`),console.log(n);return}const s=+t[1],o=n.split(` -`),r=o.length.toString().length+2,i=o.map((h,d)=>Do((d+1).toString(),r)+h);let a=0;for(let h=0;hn.getExtension(e),'Extension "'+e+'" not supported on this browser.')}function aM(n,e){const t=ds(n,()=>n.createShader(n.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(re(n,()=>n.shaderSource(t,e)),re(n,()=>n.compileShader(t)),n.getShaderParameter(t,n.COMPILE_STATUS)===!1)throw console.log(n.getShaderInfoLog(t)),new Error("Failed to compile vertex shader.");return t}function lM(n,e){const t=ds(n,()=>n.createShader(n.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(re(n,()=>n.shaderSource(t,e)),re(n,()=>n.compileShader(t)),W().get("ENGINE_COMPILE_ONLY"))return t;if(n.getShaderParameter(t,n.COMPILE_STATUS)===!1)throw U1(e,n.getShaderInfoLog(t)),new Error("Failed to compile fragment shader.");return t}const cM=/ERROR: [0-9]+:([0-9]+):/g;function U1(n,e){const t=cM.exec(e);if(t==null){console.log(`Couldn't parse line number in error: ${e}`),console.log(n);return}const s=+t[1],o=n.split(` +`),r=o.length.toString().length+2,i=o.map((h,d)=>Fo((d+1).toString(),r)+h);let a=0;for(let h=0;hn.createProgram(),"Unable to create WebGLProgram.")}function cM(n,e){if(re(n,()=>n.linkProgram(e)),!W().get("ENGINE_COMPILE_ONLY")&&n.getProgramParameter(e,n.LINK_STATUS)===!1)throw console.log(n.getProgramInfoLog(e)),new Error("Failed to link vertex and fragment shaders.")}function up(n,e){if(re(n,()=>n.validateProgram(e)),n.getProgramParameter(e,n.VALIDATE_STATUS)===!1)throw console.log(n.getProgramInfoLog(e)),new Error("Shader program validation failed.")}function uM(n,e){const t=ds(n,()=>n.createBuffer(),"Unable to create WebGLBuffer");return re(n,()=>n.bindBuffer(n.ARRAY_BUFFER,t)),re(n,()=>n.bufferData(n.ARRAY_BUFFER,e,n.STATIC_DRAW)),t}function hM(n,e){const t=ds(n,()=>n.createBuffer(),"Unable to create WebGLBuffer");return re(n,()=>n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t)),re(n,()=>n.bufferData(n.ELEMENT_ARRAY_BUFFER,e,n.STATIC_DRAW)),t}function dM(n){return ds(n,()=>n.createTexture(),"Unable to create WebGLTexture.")}function pM(n,e){const t=W().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(n<=0||e<=0){const s=`[${n}x${e}]`;throw new Error("Requested texture size "+s+" is invalid.")}if(n>t||e>t){const s=`[${n}x${e}]`,o=`[${t}x${t}]`;throw new Error("Requested texture size "+s+" greater than WebGL maximum on this browser / GPU "+o+".")}}function fM(n){return ds(n,()=>n.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function V1(n,e,t,s,o,r,i){const a=n.getAttribLocation(e,t);return a===-1?!1:(re(n,()=>n.bindBuffer(n.ARRAY_BUFFER,s)),re(n,()=>n.vertexAttribPointer(a,o,n.FLOAT,!1,r,i)),re(n,()=>n.enableVertexAttribArray(a)),!0)}function mM(n,e,t){wM(n,t),re(n,()=>n.activeTexture(n.TEXTURE0+t)),re(n,()=>n.bindTexture(n.TEXTURE_2D,e))}function gM(n,e,t){return ds(n,()=>n.getUniformLocation(e,t),'uniform "'+t+'" not present in program.')}function xM(n,e,t){return n.getUniformLocation(e,t)}function bM(n,e,t,s){re(n,()=>mM(n,e,s)),re(n,()=>n.uniform1i(t,s))}function hp(n,e,t){re(n,()=>n.bindFramebuffer(n.FRAMEBUFFER,t)),re(n,()=>n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0))}function W1(n,e){re(n,()=>n.bindFramebuffer(n.FRAMEBUFFER,e)),re(n,()=>n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,null,0))}function pc(n){const e=n.checkFramebufferStatus(n.FRAMEBUFFER);if(e!==n.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+yM(n,e))}function yM(n,e){switch(e){case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case n.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${e}`}}function ds(n,e,t){const s=re(n,()=>e());if(s==null)throw new Error(t);return s}function wM(n,e){const t=n.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,s=e+n.TEXTURE0;if(st){const o=`[gl.TEXTURE0, gl.TEXTURE${t}]`;throw new Error(`textureUnit must be in ${o}.`)}}function lr(n,e=2){return H(n.slice(0,n.length-e))}function cr(n){if(n.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[n.length>1?n[n.length-2]:1,n[n.length-1]]}function fc(n){let e=[1,1,1];return n.length===0||n.length===1&&n[0]===1||(e=[lr(n),...cr(n)]),e}function CM(n,e=!1){let t=W().getNumber("WEBGL_MAX_TEXTURE_SIZE"),s=W().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");s===1/0&&W().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(s=t/2),e&&(t=t*2,s=s*2,n=n.map((a,l)=>l>=n.length-2?_c(n[l]):n[l]),n.length===1&&(n=[2,n[0]])),n.length!==2&&(n=ms(n).newShape);let o=H(n),r=null;n.length<=1&&o<=t?r=[1,o]:n.length===2&&n[0]<=t&&n[1]<=t?r=n:n.length===3&&n[0]*n[1]<=t&&n[2]<=t?r=[n[0]*n[1],n[2]]:n.length===3&&n[0]<=t&&n[1]*n[2]<=t?r=[n[0],n[1]*n[2]]:n.length===4&&n[0]*n[1]*n[2]<=t&&n[3]<=t?r=[n[0]*n[1]*n[2],n[3]]:n.length===4&&n[0]<=t&&n[1]*n[2]*n[3]<=t&&(r=[n[0],n[1]*n[2]*n[3]]);const i=r!=null&&Math.max(...r)>s&&Math.min(...r)<=(e?2:1)&&Math.min(...r)>0;if(r==null||i)if(e){const a=lr(n);let l=2,c=2;n.length&&([l,c]=cr(n)),o=a*(l/2)*(c/2),r=Lc(o).map(u=>u*2)}else r=Lc(o);return r}function mc(n){return n%2===0}function gc(n,e){if(n=n.slice(-2),e=e.slice(-2),Oe(n,e)||!n.length||!e.length||n[0]===0||n[1]===0||e[0]===0||e[1]===0)return!0;if(n.length!==e.length){const t=n[n.length-1],s=e[e.length-1];if(t===s||mc(t)&&mc(s)&&(n[0]===1||e[0]===1))return!0}return n[1]===e[1]&&mc(n[0])&&mc(e[0])}let dp,pp;function IM(n){if(dp==null){const e=Ln(n);dp=e.getParameter(e.MAX_TEXTURE_SIZE)}return dp}function $M(n){if(pp==null){const e=Ln(n);pp=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,pp)}function vM(n){if(n===0)return 0;let e;const t=Ln(n);return Cn(t,"EXT_disjoint_timer_query_webgl2")&&n===2?e=2:Cn(t,"EXT_disjoint_timer_query")?e=1:e=0,e}function Cn(n,e){return n.getExtension(e)!=null}function U1(n){try{if(Ln(n)!=null)return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function kM(n){if(n===0)return!1;const e=Ln(n);if(n===1){if(!Cn(e,"OES_texture_float"))return!1}else if(!Cn(e,"EXT_color_buffer_float"))return!1;return fp(e)}function SM(n){if(n===0)return!1;const e=Ln(n);if(n===1){if(!Cn(e,"OES_texture_float")||!Cn(e,"WEBGL_color_buffer_float"))return!1}else{if(Cn(e,"EXT_color_buffer_float"))return fp(e);const s="EXT_color_buffer_half_float";if(Cn(e,s)){const o=e.getExtension(s);return TM(e,o)}return!1}return fp(e)}function fp(n){const e=cp(n),t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texImage2D(n.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);const r=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,r),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0);const i=n.checkFramebufferStatus(n.FRAMEBUFFER)===n.FRAMEBUFFER_COMPLETE;return n.bindTexture(n.TEXTURE_2D,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(t),n.deleteFramebuffer(r),i}function TM(n,e){const t=cp(n,e),s=n.createTexture();n.bindTexture(n.TEXTURE_2D,s),n.texImage2D(n.TEXTURE_2D,0,t.internalFormatHalfFloat,1,1,0,t.textureFormatFloat,t.textureTypeHalfFloat,null);const i=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,i),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,s,0);const a=n.checkFramebufferStatus(n.FRAMEBUFFER)===n.FRAMEBUFFER_COMPLETE;return n.bindTexture(n.TEXTURE_2D,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(s),n.deleteFramebuffer(i),a}function NM(n){return n!==2?!1:Ln(n).fenceSync!=null}function Ji(n,e){Array.isArray(n)||(n=[n]),n.forEach(t=>{t!=null&&$(t.dtype!=="complex64",()=>`${e} does not support complex64 tensors in the WebGL backend.`)})}/** +`)[0]),console.log(`%c ${Fo(c[0],a)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(u.join(` +`))}function uM(n){return ds(n,()=>n.createProgram(),"Unable to create WebGLProgram.")}function hM(n,e){if(re(n,()=>n.linkProgram(e)),!W().get("ENGINE_COMPILE_ONLY")&&n.getProgramParameter(e,n.LINK_STATUS)===!1)throw console.log(n.getProgramInfoLog(e)),new Error("Failed to link vertex and fragment shaders.")}function up(n,e){if(re(n,()=>n.validateProgram(e)),n.getProgramParameter(e,n.VALIDATE_STATUS)===!1)throw console.log(n.getProgramInfoLog(e)),new Error("Shader program validation failed.")}function dM(n,e){const t=ds(n,()=>n.createBuffer(),"Unable to create WebGLBuffer");return re(n,()=>n.bindBuffer(n.ARRAY_BUFFER,t)),re(n,()=>n.bufferData(n.ARRAY_BUFFER,e,n.STATIC_DRAW)),t}function pM(n,e){const t=ds(n,()=>n.createBuffer(),"Unable to create WebGLBuffer");return re(n,()=>n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t)),re(n,()=>n.bufferData(n.ELEMENT_ARRAY_BUFFER,e,n.STATIC_DRAW)),t}function fM(n){return ds(n,()=>n.createTexture(),"Unable to create WebGLTexture.")}function mM(n,e){const t=W().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(n<=0||e<=0){const s=`[${n}x${e}]`;throw new Error("Requested texture size "+s+" is invalid.")}if(n>t||e>t){const s=`[${n}x${e}]`,o=`[${t}x${t}]`;throw new Error("Requested texture size "+s+" greater than WebGL maximum on this browser / GPU "+o+".")}}function gM(n){return ds(n,()=>n.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function G1(n,e,t,s,o,r,i){const a=n.getAttribLocation(e,t);return a===-1?!1:(re(n,()=>n.bindBuffer(n.ARRAY_BUFFER,s)),re(n,()=>n.vertexAttribPointer(a,o,n.FLOAT,!1,r,i)),re(n,()=>n.enableVertexAttribArray(a)),!0)}function xM(n,e,t){IM(n,t),re(n,()=>n.activeTexture(n.TEXTURE0+t)),re(n,()=>n.bindTexture(n.TEXTURE_2D,e))}function bM(n,e,t){return ds(n,()=>n.getUniformLocation(e,t),'uniform "'+t+'" not present in program.')}function yM(n,e,t){return n.getUniformLocation(e,t)}function wM(n,e,t,s){re(n,()=>xM(n,e,s)),re(n,()=>n.uniform1i(t,s))}function hp(n,e,t){re(n,()=>n.bindFramebuffer(n.FRAMEBUFFER,t)),re(n,()=>n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0))}function H1(n,e){re(n,()=>n.bindFramebuffer(n.FRAMEBUFFER,e)),re(n,()=>n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,null,0))}function fc(n){const e=n.checkFramebufferStatus(n.FRAMEBUFFER);if(e!==n.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+CM(n,e))}function CM(n,e){switch(e){case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case n.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${e}`}}function ds(n,e,t){const s=re(n,()=>e());if(s==null)throw new Error(t);return s}function IM(n,e){const t=n.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,s=e+n.TEXTURE0;if(st){const o=`[gl.TEXTURE0, gl.TEXTURE${t}]`;throw new Error(`textureUnit must be in ${o}.`)}}function lr(n,e=2){return H(n.slice(0,n.length-e))}function cr(n){if(n.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[n.length>1?n[n.length-2]:1,n[n.length-1]]}function mc(n){let e=[1,1,1];return n.length===0||n.length===1&&n[0]===1||(e=[lr(n),...cr(n)]),e}function $M(n,e=!1){let t=W().getNumber("WEBGL_MAX_TEXTURE_SIZE"),s=W().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");s===1/0&&W().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(s=t/2),e&&(t=t*2,s=s*2,n=n.map((a,l)=>l>=n.length-2?Oc(n[l]):n[l]),n.length===1&&(n=[2,n[0]])),n.length!==2&&(n=ms(n).newShape);let o=H(n),r=null;n.length<=1&&o<=t?r=[1,o]:n.length===2&&n[0]<=t&&n[1]<=t?r=n:n.length===3&&n[0]*n[1]<=t&&n[2]<=t?r=[n[0]*n[1],n[2]]:n.length===3&&n[0]<=t&&n[1]*n[2]<=t?r=[n[0],n[1]*n[2]]:n.length===4&&n[0]*n[1]*n[2]<=t&&n[3]<=t?r=[n[0]*n[1]*n[2],n[3]]:n.length===4&&n[0]<=t&&n[1]*n[2]*n[3]<=t&&(r=[n[0],n[1]*n[2]*n[3]]);const i=r!=null&&Math.max(...r)>s&&Math.min(...r)<=(e?2:1)&&Math.min(...r)>0;if(r==null||i)if(e){const a=lr(n);let l=2,c=2;n.length&&([l,c]=cr(n)),o=a*(l/2)*(c/2),r=Mc(o).map(u=>u*2)}else r=Mc(o);return r}function gc(n){return n%2===0}function xc(n,e){if(n=n.slice(-2),e=e.slice(-2),Oe(n,e)||!n.length||!e.length||n[0]===0||n[1]===0||e[0]===0||e[1]===0)return!0;if(n.length!==e.length){const t=n[n.length-1],s=e[e.length-1];if(t===s||gc(t)&&gc(s)&&(n[0]===1||e[0]===1))return!0}return n[1]===e[1]&&gc(n[0])&&gc(e[0])}let dp,pp;function vM(n){if(dp==null){const e=Ln(n);dp=e.getParameter(e.MAX_TEXTURE_SIZE)}return dp}function kM(n){if(pp==null){const e=Ln(n);pp=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,pp)}function SM(n){if(n===0)return 0;let e;const t=Ln(n);return Cn(t,"EXT_disjoint_timer_query_webgl2")&&n===2?e=2:Cn(t,"EXT_disjoint_timer_query")?e=1:e=0,e}function Cn(n,e){return n.getExtension(e)!=null}function q1(n){try{if(Ln(n)!=null)return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function TM(n){if(n===0)return!1;const e=Ln(n);if(n===1){if(!Cn(e,"OES_texture_float"))return!1}else if(!Cn(e,"EXT_color_buffer_float"))return!1;return fp(e)}function NM(n){if(n===0)return!1;const e=Ln(n);if(n===1){if(!Cn(e,"OES_texture_float")||!Cn(e,"WEBGL_color_buffer_float"))return!1}else{if(Cn(e,"EXT_color_buffer_float"))return fp(e);const s="EXT_color_buffer_half_float";if(Cn(e,s)){const o=e.getExtension(s);return EM(e,o)}return!1}return fp(e)}function fp(n){const e=cp(n),t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texImage2D(n.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);const r=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,r),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0);const i=n.checkFramebufferStatus(n.FRAMEBUFFER)===n.FRAMEBUFFER_COMPLETE;return n.bindTexture(n.TEXTURE_2D,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(t),n.deleteFramebuffer(r),i}function EM(n,e){const t=cp(n,e),s=n.createTexture();n.bindTexture(n.TEXTURE_2D,s),n.texImage2D(n.TEXTURE_2D,0,t.internalFormatHalfFloat,1,1,0,t.textureFormatFloat,t.textureTypeHalfFloat,null);const i=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,i),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,s,0);const a=n.checkFramebufferStatus(n.FRAMEBUFFER)===n.FRAMEBUFFER_COMPLETE;return n.bindTexture(n.TEXTURE_2D,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(s),n.deleteFramebuffer(i),a}function RM(n){return n!==2?!1:Ln(n).fenceSync!=null}function Ji(n,e){Array.isArray(n)||(n=[n]),n.forEach(t=>{t!=null&&$(t.dtype!=="complex64",()=>`${e} does not support complex64 tensors in the WebGL backend.`)})}/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11176,7 +11176,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ue=W();ue.registerFlag("HAS_WEBGL",()=>ue.getNumber("WEBGL_VERSION")>0),ue.registerFlag("WEBGL_VERSION",()=>U1(2)?2:U1(1)?1:0),ue.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1),ue.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>ue.get("WEBGL_VERSION")===2),ue.registerFlag("WEBGL_CPU_FORWARD",()=>!0),ue.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1),ue.registerFlag("WEBGL_PACK",()=>ue.getBool("HAS_WEBGL")),ue.registerFlag("WEBGL_PACK_NORMALIZATION",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_CLIP",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_REDUCE",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_LAZILY_UNPACK",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_CONV_IM2COL",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_CONV2DTRANSPOSE",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>IM(ue.getNumber("WEBGL_VERSION"))),ue.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>$M(ue.getNumber("WEBGL_VERSION"))),ue.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{const n=ue.getNumber("WEBGL_VERSION");return n===0?0:vM(n)}),ue.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>ue.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!Vf()),ue.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>kM(ue.getNumber("WEBGL_VERSION"))),ue.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>ue.getBool("WEBGL_FORCE_F16_TEXTURES")?!1:ue.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")),ue.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>SM(ue.getNumber("WEBGL_VERSION"))),ue.registerFlag("WEBGL_FENCE_API_ENABLED",()=>NM(ue.getNumber("WEBGL_VERSION"))),ue.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>ue.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0),ue.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",()=>-1,n=>{if(typeof n!="number")throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be a number but got ${n}.`);if(n<0&&n!==-1)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${n}.`)}),ue.registerFlag("WEBGL_FLUSH_THRESHOLD",()=>Vf()?1:-1,n=>{if(typeof n!="number")throw new Error(`WEBGL_FLUSH_THRESHOLD must be a number but got ${n}.`);if(n<0&&n!==-1)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${n}.`)}),ue.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",()=>128),ue.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",()=>!1),ue.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",()=>1e5),ue.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",()=>128),ue.registerFlag("WEBGL_EXP_CONV",()=>!1),ue.registerFlag("SOFTWARE_WEBGL_ENABLED",()=>ue.getBool("IS_TEST")),ue.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",()=>1/0),ue.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",()=>!1),ue.registerFlag("WEBGL2_ISNAN_CUSTOM",()=>!1),ue.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);/** + */const ue=W();ue.registerFlag("HAS_WEBGL",()=>ue.getNumber("WEBGL_VERSION")>0),ue.registerFlag("WEBGL_VERSION",()=>q1(2)?2:q1(1)?1:0),ue.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1),ue.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>ue.get("WEBGL_VERSION")===2),ue.registerFlag("WEBGL_CPU_FORWARD",()=>!0),ue.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1),ue.registerFlag("WEBGL_PACK",()=>ue.getBool("HAS_WEBGL")),ue.registerFlag("WEBGL_PACK_NORMALIZATION",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_CLIP",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_REDUCE",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_LAZILY_UNPACK",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_CONV_IM2COL",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_PACK_CONV2DTRANSPOSE",()=>ue.getBool("WEBGL_PACK")),ue.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>vM(ue.getNumber("WEBGL_VERSION"))),ue.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>kM(ue.getNumber("WEBGL_VERSION"))),ue.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{const n=ue.getNumber("WEBGL_VERSION");return n===0?0:SM(n)}),ue.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>ue.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!Vf()),ue.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>TM(ue.getNumber("WEBGL_VERSION"))),ue.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>ue.getBool("WEBGL_FORCE_F16_TEXTURES")?!1:ue.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")),ue.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>NM(ue.getNumber("WEBGL_VERSION"))),ue.registerFlag("WEBGL_FENCE_API_ENABLED",()=>RM(ue.getNumber("WEBGL_VERSION"))),ue.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>ue.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0),ue.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",()=>-1,n=>{if(typeof n!="number")throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be a number but got ${n}.`);if(n<0&&n!==-1)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${n}.`)}),ue.registerFlag("WEBGL_FLUSH_THRESHOLD",()=>Vf()?1:-1,n=>{if(typeof n!="number")throw new Error(`WEBGL_FLUSH_THRESHOLD must be a number but got ${n}.`);if(n<0&&n!==-1)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${n}.`)}),ue.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",()=>128),ue.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",()=>!1),ue.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",()=>1e5),ue.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",()=>128),ue.registerFlag("WEBGL_EXP_CONV",()=>!1),ue.registerFlag("SOFTWARE_WEBGL_ENABLED",()=>ue.getBool("IS_TEST")),ue.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",()=>1/0),ue.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",()=>!1),ue.registerFlag("WEBGL2_ISNAN_CUSTOM",()=>!1),ue.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11191,7 +11191,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Mt(){let n,e,t,s,o,r,i,a,l,c;return W().getNumber("WEBGL_VERSION")===2?(n="#version 300 es",e="in",t="out",s="in",o="texture",r="outputColor",i="out vec4 outputColor;",a=W().getBool("WEBGL2_ISNAN_CUSTOM")?` + */function Pt(){let n,e,t,s,o,r,i,a,l,c;return W().getNumber("WEBGL_VERSION")===2?(n="#version 300 es",e="in",t="out",s="in",o="texture",r="outputColor",i="out vec4 outputColor;",a=W().getBool("WEBGL2_ISNAN_CUSTOM")?` bool isnan_custom(float val) { uint floatToUint = floatBitsToUint(val); return (floatToUint & 0x7fffffffu) > 0x7f800000u; @@ -11252,7 +11252,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $o(n,e,t="index"){const s=de(e);return s.map((o,r)=>{const i=`int ${n[r]} = ${t} / ${o}`,a=r===s.length-1?`int ${n[r+1]} = ${t} - ${n[r]} * ${o}`:`index -= ${n[r]} * ${o}`;return`${i}; ${a};`}).join("")}function xc(n,e,t="index"){const s=de(e);return s.map((o,r)=>{const i=`int ${n[r]} = ${t} / outShapeStrides[${r}]`,a=r===s.length-1?`int ${n[r+1]} = ${t} - ${n[r]} * outShapeStrides[${r}]`:`index -= ${n[r]} * outShapeStrides[${r}]`;return`${i}; ${a};`}).join("")}function EM(n,e){const t=n.length,s=n.map(r=>`${e}[${r}]`),o=new Array(t-1);o[t-2]=s[t-1];for(let r=t-3;r>=0;--r)o[r]=`(${o[r+1]} * ${s[r+1]})`;return o}function RM(n,e,t="index"){const s=n.map((r,i)=>i),o=EM(s,e);return o.map((r,i)=>{const a=`int ${n[i]} = ${t} / ${o[i]}`,l=i===o.length-1?`int ${n[i+1]} = ${t} - ${n[i]} * ${o[i]}`:`index -= ${n[i]} * ${o[i]}`;return`${a}; ${l};`}).join("")}function mp(n){const e=de(n).map(t=>t.toString());return` + */function vo(n,e,t="index"){const s=de(e);return s.map((o,r)=>{const i=`int ${n[r]} = ${t} / ${o}`,a=r===s.length-1?`int ${n[r+1]} = ${t} - ${n[r]} * ${o}`:`index -= ${n[r]} * ${o}`;return`${i}; ${a};`}).join("")}function bc(n,e,t="index"){const s=de(e);return s.map((o,r)=>{const i=`int ${n[r]} = ${t} / outShapeStrides[${r}]`,a=r===s.length-1?`int ${n[r+1]} = ${t} - ${n[r]} * outShapeStrides[${r}]`:`index -= ${n[r]} * outShapeStrides[${r}]`;return`${i}; ${a};`}).join("")}function AM(n,e){const t=n.length,s=n.map(r=>`${e}[${r}]`),o=new Array(t-1);o[t-2]=s[t-1];for(let r=t-3;r>=0;--r)o[r]=`(${o[r+1]} * ${s[r+1]})`;return o}function DM(n,e,t="index"){const s=n.map((r,i)=>i),o=AM(s,e);return o.map((r,i)=>{const a=`int ${n[i]} = ${t} / ${o[i]}`,l=i===o.length-1?`int ${n[i+1]} = ${t} - ${n[i]} * ${o[i]}`:`index -= ${n[i]} * ${o[i]}`;return`${a}; ${l};`}).join("")}function mp(n){const e=de(n).map(t=>t.toString());return` int getFlatIndex(ivec3 coords) { return coords.x * ${e[0]} + coords.y * ${e[1]} + coords.z; } @@ -11260,7 +11260,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram int getFlatIndex(ivec3 coords) { return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z; } -`}const G1=` +`}const j1=` const float FLOAT_MAX = 1.70141184e38; const float FLOAT_MIN = 1.17549435e-38; @@ -11314,22 +11314,22 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const{getBroadcastDims:H1}=I2;function AM(n,e,t){const s=[];if(n.forEach(p=>{const f=H(p.shapeInfo.logicalShape);if(p.shapeInfo.isUniform?s.push(`uniform float ${p.name}${f>1?`[${f}]`:""};`):(s.push(`uniform sampler2D ${p.name};`),s.push(`uniform int offset${p.name};`)),t.enableShapeUniforms){const{uniformShape:g}=xp(t.packedInputs,p.shapeInfo.logicalShape,p.shapeInfo.texShape);switch(g.length){case 1:s.push(`uniform int ${p.name}Shape;`);break;case 2:s.push(`uniform ivec2 ${p.name}Shape;`);break;case 3:s.push(`uniform ivec3 ${p.name}Shape;`);break;case 4:s.push(`uniform ivec4 ${p.name}Shape;`);break}s.push(`uniform ivec2 ${p.name}TexShape;`)}}),t.enableShapeUniforms){switch(e.logicalShape.length){case 1:s.push("uniform int outShape;");break;case 2:s.push("uniform ivec2 outShape;"),s.push("uniform int outShapeStrides;");break;case 3:s.push("uniform ivec3 outShape;"),s.push("uniform ivec2 outShapeStrides;");break;case 4:s.push("uniform ivec4 outShape;"),s.push("uniform ivec3 outShapeStrides;");break}s.push("uniform ivec2 outTexShape;")}t.customUniforms&&t.customUniforms.forEach(p=>{s.push(`uniform ${p.type} ${p.name}${p.arrayIndex?`[${p.arrayIndex}]`:""};`)});const o=s.join(` -`),r=n.map(p=>DM(p,e,t.packedInputs,t.enableShapeUniforms)).join(` -`),i=e.texShape,a=Mt(),l=OM(a);let c,u,h=PM(a);return e.isPacked?(c=FM(e.logicalShape,i,t.enableShapeUniforms),u=MM(a)):(c=_M(e.logicalShape,i,t.enableShapeUniforms),u=LM(a)),t.packedInputs&&(h+=WM),[h,l,u,o,c,r,t.userCode].join(` -`)}function ur(n,e=!1){const t=n.shapeInfo.logicalShape;switch(t.length){case 0:return eP(n,e);case 1:return nP(n,e);case 2:return oP(n,e);case 3:return iP(n,e);case 4:return lP(n,e);case 5:return cP(n);case 6:return uP(n);default:throw new Error(`${t.length}-D input sampling is not yet supported`)}}function j1(n,e){switch(n.shapeInfo.logicalShape.length){case 0:return JM(n);case 1:return tP(n,e);case 2:return sP(n,e);case 3:return rP(n,e);default:return aP(n,e)}}function DM(n,e,t=!1,s){let o="";t?o+=j1(n,s):o+=ur(n,s);const r=n.shapeInfo.logicalShape,i=e.logicalShape;return r.length<=i.length&&(t?o+=hP(n,e):o+=dP(n,e)),o}function FM(n,e,t){switch(n.length){case 0:return q1();case 1:return UM(n,e,t);case 2:return ZM(n,e,t);case 3:return HM(n,e,t);default:return qM(n,e,t)}}function _M(n,e,t){switch(n.length){case 0:return q1();case 1:return GM(n,e,t);case 2:return QM(n,e,t);case 3:return jM(n,e,t);case 4:return KM(n,e,t);case 5:return XM(n,e);case 6:return YM(n,e);default:throw new Error(`${n.length}-D output sampling is not yet supported`)}}function OM(n){return` + */const{getBroadcastDims:K1}=v2;function FM(n,e,t){const s=[];if(n.forEach(p=>{const f=H(p.shapeInfo.logicalShape);if(p.shapeInfo.isUniform?s.push(`uniform float ${p.name}${f>1?`[${f}]`:""};`):(s.push(`uniform sampler2D ${p.name};`),s.push(`uniform int offset${p.name};`)),t.enableShapeUniforms){const{uniformShape:g}=xp(t.packedInputs,p.shapeInfo.logicalShape,p.shapeInfo.texShape);switch(g.length){case 1:s.push(`uniform int ${p.name}Shape;`);break;case 2:s.push(`uniform ivec2 ${p.name}Shape;`);break;case 3:s.push(`uniform ivec3 ${p.name}Shape;`);break;case 4:s.push(`uniform ivec4 ${p.name}Shape;`);break}s.push(`uniform ivec2 ${p.name}TexShape;`)}}),t.enableShapeUniforms){switch(e.logicalShape.length){case 1:s.push("uniform int outShape;");break;case 2:s.push("uniform ivec2 outShape;"),s.push("uniform int outShapeStrides;");break;case 3:s.push("uniform ivec3 outShape;"),s.push("uniform ivec2 outShapeStrides;");break;case 4:s.push("uniform ivec4 outShape;"),s.push("uniform ivec3 outShapeStrides;");break}s.push("uniform ivec2 outTexShape;")}t.customUniforms&&t.customUniforms.forEach(p=>{s.push(`uniform ${p.type} ${p.name}${p.arrayIndex?`[${p.arrayIndex}]`:""};`)});const o=s.join(` +`),r=n.map(p=>_M(p,e,t.packedInputs,t.enableShapeUniforms)).join(` +`),i=e.texShape,a=Pt(),l=MM(a);let c,u,h=zM(a);return e.isPacked?(c=OM(e.logicalShape,i,t.enableShapeUniforms),u=BM(a)):(c=LM(e.logicalShape,i,t.enableShapeUniforms),u=PM(a)),t.packedInputs&&(h+=GM),[h,l,u,o,c,r,t.userCode].join(` +`)}function ur(n,e=!1){const t=n.shapeInfo.logicalShape;switch(t.length){case 0:return nP(n,e);case 1:return oP(n,e);case 2:return iP(n,e);case 3:return lP(n,e);case 4:return uP(n,e);case 5:return hP(n);case 6:return dP(n);default:throw new Error(`${t.length}-D input sampling is not yet supported`)}}function X1(n,e){switch(n.shapeInfo.logicalShape.length){case 0:return tP(n);case 1:return sP(n,e);case 2:return rP(n,e);case 3:return aP(n,e);default:return cP(n,e)}}function _M(n,e,t=!1,s){let o="";t?o+=X1(n,s):o+=ur(n,s);const r=n.shapeInfo.logicalShape,i=e.logicalShape;return r.length<=i.length&&(t?o+=pP(n,e):o+=fP(n,e)),o}function OM(n,e,t){switch(n.length){case 0:return Y1();case 1:return HM(n,e,t);case 2:return JM(n,e,t);case 3:return jM(n,e,t);default:return XM(n,e,t)}}function LM(n,e,t){switch(n.length){case 0:return Y1();case 1:return qM(n,e,t);case 2:return eP(n,e,t);case 3:return KM(n,e,t);case 4:return YM(n,e,t);case 5:return ZM(n,e);case 6:return QM(n,e);default:throw new Error(`${n.length}-D output sampling is not yet supported`)}}function MM(n){return` float sampleTexture(sampler2D textureSampler, vec2 uv) { return ${n.texture2D}(textureSampler, uv).r; } - `}function LM(n){return` + `}function PM(n){return` void setOutput(float val) { ${n.output} = vec4(val, 0, 0, 0); } - `}function MM(n){return` + `}function BM(n){return` void setOutput(vec4 val) { ${n.output} = val; } - `}function PM(n){return`${n.version} + `}function zM(n){return`${n.version} precision highp float; precision highp int; precision highp sampler2D; @@ -11384,10 +11384,10 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram return fract((p3.x + p3.y) * p3.z); } - ${BM} - ${zM} ${VM} - `}const BM=` + ${WM} + ${UM} + `}const VM=` vec2 uvFromFlat(int texNumR, int texNumC, int index) { int texR = index / texNumC; int texC = index - texR * texNumC; @@ -11399,7 +11399,7 @@ vec2 packedUVfrom1D(int texNumR, int texNumC, int index) { int texC = texelIndex - texR * texNumC; return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); } -`,zM=` +`,WM=` vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR, int texNumC, int row, int col) { int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2); @@ -11407,7 +11407,7 @@ vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR, int texC = texelIndex - texR * texNumC; return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); } -`,VM=` +`,UM=` vec2 packedUVfrom3D(int texNumR, int texNumC, int texelsInBatch, int texelsInLogicalRow, int b, int row, int col) { @@ -11416,7 +11416,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, int texC = index - texR * texNumC; return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); } -`,WM=` +`,GM=` float getChannel(vec4 frag, vec2 innerDims) { vec2 modCoord = mod(innerDims, 2.); return modCoord.x == 0. ? @@ -11427,11 +11427,11 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, float modCoord = mod(float(dim), 2.); return modCoord == 0. ? frag.r : frag.g; } -`;function q1(){return` +`;function Y1(){return` int getOutputCoords() { return 0; } - `}function UM(n,e,t){const s=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];return s[0]===1?t?` + `}function HM(n,e,t){const s=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];return s[0]===1?t?` int getOutputCoords() { return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0)); } @@ -11460,7 +11460,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec2(${s[0]}, ${s[1]})); return 2 * (resTexRC.x * ${s[1]} + resTexRC.y); } - `}function GM(n,e,t){return e[0]===1?t?` + `}function qM(n,e,t){return e[0]===1?t?` int getOutputCoords() { return int(resultUV.x * float(outTexShape[1])); } @@ -11488,7 +11488,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec2(${e[0]}, ${e[1]})); return resTexRC.x * ${e[1]} + resTexRC.y; } - `}function HM(n,e,t){if(t)return` + `}function jM(n,e,t){if(t)return` ivec3 getOutputCoords() { ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0)); @@ -11519,15 +11519,15 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, return ivec3(b, r, c); } - `}function jM(n,e,t){if(t)return` + `}function KM(n,e,t){if(t)return` ivec3 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1])); int index = resTexRC.x * outTexShape[1] + resTexRC.y; - ${xc(["r","c","d"],n)} + ${bc(["r","c","d"],n)} return ivec3(r, c, d); } -`;const s=$o(["r","c","d"],n);return` +`;const s=vo(["r","c","d"],n);return` ivec3 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]})); @@ -11535,7 +11535,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, ${s} return ivec3(r, c, d); } - `}function qM(n,e,t){if(t)return` + `}function XM(n,e,t){if(t)return` ivec4 getOutputCoords() { ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); ivec2 resTexRC = ivec2(resultUV.yx * @@ -11576,15 +11576,15 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, return ivec${n.length}(${l}); } - `}function KM(n,e,t){if(t)return` + `}function YM(n,e,t){if(t)return` ivec4 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1])); int index = resTexRC.x * outTexShape[1] + resTexRC.y; - ${xc(["r","c","d","d2"],n)} + ${bc(["r","c","d","d2"],n)} return ivec4(r, c, d, d2); } - `;const s=$o(["r","c","d","d2"],n);return` + `;const s=vo(["r","c","d","d2"],n);return` ivec4 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]})); @@ -11592,7 +11592,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, ${s} return ivec4(r, c, d, d2); } - `}function XM(n,e){const t=$o(["r","c","d","d2","d3"],n);return` + `}function ZM(n,e){const t=vo(["r","c","d","d2","d3"],n);return` ivec5 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]})); @@ -11604,7 +11604,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, ivec5 outShape = ivec5(r, c, d, d2, d3); return outShape; } - `}function YM(n,e){const t=$o(["r","c","d","d2","d3","d4"],n);return` + `}function QM(n,e){const t=vo(["r","c","d","d2","d3","d4"],n);return` ivec6 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]})); @@ -11615,7 +11615,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, ivec6 result = ivec6(r, c, d, d2, d3, d4); return result; } - `}function ZM(n,e,t){const s=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(Oe(n,e))return t?` + `}function JM(n,e,t){const s=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(Oe(n,e))return t?` ivec2 getOutputCoords() { ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1])); @@ -11648,7 +11648,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, return ivec2(r, c); } - `}function QM(n,e,t){return Oe(n,e)?t?` + `}function eP(n,e,t){return Oe(n,e)?t?` ivec2 getOutputCoords() { return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1])); } @@ -11702,15 +11702,15 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, int c = index - r * ${n[1]}; return ivec2(r, c); } - `}function vo(n){return`offset${n}`}function JM(n){const e=n.name,t="get"+e.charAt(0).toUpperCase()+e.slice(1),s=Mt();return` + `}function ko(n){return`offset${n}`}function tP(n){const e=n.name,t="get"+e.charAt(0).toUpperCase()+e.slice(1),s=Pt();return` vec4 ${t}() { return ${s.texture2D}(${e}, halfCR); } - `}function eP(n,e){const t=n.name,s="get"+t.charAt(0).toUpperCase()+t.slice(1);if(n.shapeInfo.isUniform)return`float ${s}() {return ${t};}`;const[o,r]=n.shapeInfo.texShape;if(o===1&&r===1)return` + `}function nP(n,e){const t=n.name,s="get"+t.charAt(0).toUpperCase()+t.slice(1);if(n.shapeInfo.isUniform)return`float ${s}() {return ${t};}`;const[o,r]=n.shapeInfo.texShape;if(o===1&&r===1)return` float ${s}() { return sampleTexture(${t}, halfCR); } - `;const i=vo(t);if(e)return` + `;const i=ko(t);if(e)return` float ${s}() { vec2 uv = uvFromFlat(${t}TexShape[0], ${t}TexShape[1], ${i}); return sampleTexture(${t}, uv); @@ -11720,7 +11720,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec2 uv = uvFromFlat(${a}, ${l}, ${i}); return sampleTexture(${t}, uv); } - `}function tP(n,e){const t=n.name,s="get"+t.charAt(0).toUpperCase()+t.slice(1),o=n.shapeInfo.texShape,r=Mt();if(e)return` + `}function sP(n,e){const t=n.name,s="get"+t.charAt(0).toUpperCase()+t.slice(1),o=n.shapeInfo.texShape,r=Pt();if(e)return` vec4 ${s}(int index) { ivec2 packedTexShape = ivec2(ceil(float(${t}TexShape[0]) / 2.0), ceil(float(${t}TexShape[1]) / 2.0)); vec2 uv = packedUVfrom1D( @@ -11733,7 +11733,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, ${i[0]}, ${i[1]}, index); return ${r.texture2D}(${t}, uv); } - `}function nP(n,e){const t=n.name,s="get"+t.charAt(0).toUpperCase()+t.slice(1);if(n.shapeInfo.isUniform)return` + `}function oP(n,e){const t=n.name,s="get"+t.charAt(0).toUpperCase()+t.slice(1);if(n.shapeInfo.isUniform)return` float ${s}(int index) { ${hr(n)} } @@ -11741,7 +11741,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, float ${s}(int index) { return sampleTexture(${t}, halfCR); } - `;const a=vo(t);return i===1?e?` + `;const a=ko(t);return i===1?e?` float ${s}(int index) { vec2 uv = vec2(0.5, (float(index + ${a}) + 0.5) / float(${t}TexShape[0])); return sampleTexture(${t}, uv); @@ -11771,7 +11771,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec2 uv = uvFromFlat(${r}, ${i}, index + ${a}); return sampleTexture(${t}, uv); } - `}function sP(n,e){const t=n.shapeInfo.logicalShape,s=n.name,o="get"+s.charAt(0).toUpperCase()+s.slice(1),r=n.shapeInfo.texShape,i=r[0],a=r[1],l=Mt();if(r!=null&&Oe(t,r))return e?` + `}function rP(n,e){const t=n.shapeInfo.logicalShape,s=n.name,o="get"+s.charAt(0).toUpperCase()+s.slice(1),r=n.shapeInfo.texShape,i=r[0],a=r[1],l=Pt();if(r!=null&&Oe(t,r))return e?` vec4 ${o}(int row, int col) { vec2 uv = (vec2(col, row) + halfCR) / vec2(${s}TexShape[1], ${s}TexShape[0]); @@ -11795,7 +11795,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec2 uv = packedUVfrom2D(${u}, ${c[0]}, ${c[1]}, row, col); return ${l.texture2D}(${s}, uv); } - `}function oP(n,e){const t=n.shapeInfo.logicalShape,s=n.name,o="get"+s.charAt(0).toUpperCase()+s.slice(1),r=n.shapeInfo.texShape;if(r!=null&&Oe(t,r)){if(e)return` + `}function iP(n,e){const t=n.shapeInfo.logicalShape,s=n.name,o="get"+s.charAt(0).toUpperCase()+s.slice(1),r=n.shapeInfo.texShape;if(r!=null&&Oe(t,r)){if(e)return` float ${o}(int row, int col) { vec2 uv = (vec2(col, row) + halfCR) / vec2(${s}TexShape[1], ${s}TexShape[0]); return sampleTexture(${s}, uv); @@ -11815,7 +11815,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, int index = round(dot(vec2(row, col), vec2(${t[1]}, 1))); ${hr(n)} } - `;const c=r[0],u=r[1],h=vo(s);return u===1?e?` + `;const c=r[0],u=r[1],h=ko(s);return u===1?e?` float ${o}(int row, int col) { float index = dot(vec3(row, col, ${h}), vec3(${s}Shape[1], 1, 1)); vec2 uv = vec2(0.5, (index + 0.5) / float(${s}TexShape[0])); @@ -11853,12 +11853,12 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec2 uv = uvFromFlat(${c}, ${u}, index); return sampleTexture(${s}, uv); } -`}function rP(n,e){const t=n.shapeInfo.logicalShape,s=n.name,o="get"+s.charAt(0).toUpperCase()+s.slice(1),r=n.shapeInfo.texShape,i=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)];if(t[0]===1){const d=t.slice(1),p=[1,2],f=dr(n,d),g=["b","row","col"];return` - ${j1(f,e)} +`}function aP(n,e){const t=n.shapeInfo.logicalShape,s=n.name,o="get"+s.charAt(0).toUpperCase()+s.slice(1),r=n.shapeInfo.texShape,i=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)];if(t[0]===1){const d=t.slice(1),p=[1,2],f=dr(n,d),g=["b","row","col"];return` + ${X1(f,e)} vec4 ${o}(int b, int row, int col) { return ${o}(${pr(g,p)}); } - `}const a=Mt();if(e)return` + `}const a=Pt();if(e)return` vec4 ${o}(int b, int row, int col) { ivec2 packedTexShape = ivec2(ceil(float(${s}TexShape[0]) / 2.0), ceil(float(${s}TexShape[1]) / 2.0)); int valuesPerRow = int(ceil(float(${s}Shape[2]) / 2.0)); @@ -11873,7 +11873,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, ${l}, ${c}, ${h}, ${u}, b, row, col); return ${a.texture2D}(${s}, uv); } - `}function iP(n,e){const t=n.shapeInfo.logicalShape,s=n.name,o="get"+s.charAt(0).toUpperCase()+s.slice(1),r=t[1]*t[2],i=t[2],{newShape:a,keptDims:l}=ms(t),c=a;if(c.length=1?u="coords = 0;":u=a.map(b=>`coords.${h[b+c]} = 0;`).join(` + `}function pP(n,e){const t=n.name,s=t.charAt(0).toUpperCase()+t.slice(1),o="get"+s+"AtOutCoords",r=n.shapeInfo.logicalShape.length,i=e.logicalShape.length,a=K1(n.shapeInfo.logicalShape,e.logicalShape),l=Be(i),c=i-r;let u;const h=["x","y","z","w","u","v"];r===0?u="":i<2&&a.length>=1?u="coords = 0;":u=a.map(b=>`coords.${h[b+c]} = 0;`).join(` `);let d="";i<2&&r>0?d="coords":d=n.shapeInfo.logicalShape.map((b,w)=>`coords.${h[w+c]}`).join(", ");let p="return outputValue;";const g=H(n.shapeInfo.logicalShape)===1,x=H(e.logicalShape)===1;if(r===1&&!g&&!x)p=` return vec4(outputValue.xy, outputValue.xy); `;else if(g&&!x)i===1?p=` @@ -12132,11 +12132,11 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec4 outputValue = get${s}(${d}); ${p} } - `}function dP(n,e){const t=n.name,s=t.charAt(0).toUpperCase()+t.slice(1),o="get"+s+"AtOutCoords",r=e.texShape,i=n.shapeInfo.texShape,a=n.shapeInfo.logicalShape.length,l=e.logicalShape.length;if(!n.shapeInfo.isUniform&&a===l&&n.shapeInfo.flatOffset==null&&Oe(i,r))return` + `}function fP(n,e){const t=n.name,s=t.charAt(0).toUpperCase()+t.slice(1),o="get"+s+"AtOutCoords",r=e.texShape,i=n.shapeInfo.texShape,a=n.shapeInfo.logicalShape.length,l=e.logicalShape.length;if(!n.shapeInfo.isUniform&&a===l&&n.shapeInfo.flatOffset==null&&Oe(i,r))return` float ${o}() { return sampleTexture(${t}, resultUV); } - `;const c=Be(l),u=H1(n.shapeInfo.logicalShape,e.logicalShape),h=l-a;let d;const p=["x","y","z","w","u","v"];a===0?d="":l<2&&u.length>=1?d="coords = 0;":d=u.map(g=>`coords.${p[g+h]} = 0;`).join(` + `;const c=Be(l),u=K1(n.shapeInfo.logicalShape,e.logicalShape),h=l-a;let d;const p=["x","y","z","w","u","v"];a===0?d="":l<2&&u.length>=1?d="coords = 0;":d=u.map(g=>`coords.${p[g+h]} = 0;`).join(` `);let f="";return l<2&&a>0?f="coords":f=n.shapeInfo.logicalShape.map((g,m)=>`coords.${p[m+h]}`).join(", "),` float ${o}() { ${c} coords = getOutputCoords(); @@ -12158,7 +12158,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function pP(n,e,t,s){const o=t.map((u,h)=>{const d={logicalShape:u.shape,texShape:u.isUniform?null:u.texData.texShape,isUniform:u.isUniform,isPacked:u.isUniform?!1:u.texData.isPacked,flatOffset:null};return u.texData!=null&&u.texData.slice!=null&&u.texData.slice.flatOffset>0&&(d.flatOffset=u.texData.slice.flatOffset),{name:e.variableNames[h],shapeInfo:d}}),r=o.map(u=>u.shapeInfo),i={logicalShape:s.shape,texShape:s.texData.texShape,isUniform:!1,isPacked:s.texData.isPacked,flatOffset:null},a=AM(o,i,e),l=iM(n.gl,a),c=n.createProgram(l);return W().get("ENGINE_COMPILE_ONLY")?{program:e,fragmentShader:l,source:a,webGLProgram:c,inShapeInfos:r,outShapeInfo:i,variablesLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:(n.buildVao(c),Object.assign({program:e,fragmentShader:l,source:a,webGLProgram:c,inShapeInfos:r,outShapeInfo:i},K1(n,e,c)))}function K1(n,e,t){const s=[],o=[];let r,i,a,l=null,c=null;c=n.getUniformLocation(t,"NAN",!1),W().getNumber("WEBGL_VERSION")===1&&(l=n.getUniformLocation(t,"INFINITY",!1));const u=!1;for(const h of e.variableNames){const d={name:h,uniform:n.getUniformLocation(t,h,u),offset:n.getUniformLocation(t,`offset${h}`,u)};e.enableShapeUniforms&&(d.shape=n.getUniformLocation(t,`${h}Shape`,u),d.texShape=n.getUniformLocation(t,`${h}TexShape`,u)),s.push(d)}if(e.enableShapeUniforms&&(r=n.getUniformLocation(t,"outShape",u),a=n.getUniformLocation(t,"outShapeStrides",u),i=n.getUniformLocation(t,"outTexShape",u)),e.customUniforms)for(const h of e.customUniforms)o.push(n.getUniformLocation(t,h.name,u));return{variablesLocations:s,customUniformLocations:o,infLoc:l,nanLoc:c,outShapeLocation:r,outShapeStridesLocation:a,outTexShapeLocation:i}}function X1(n,e){if(n.length!==e.length)throw Error(`Binary was compiled with ${n.length} inputs, but was executed with ${e.length} inputs`);n.forEach((t,s)=>{const o=t.logicalShape,r=e[s],i=r.shape;if(!Oe(o,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${o} and ${i} must match`);if(t.isUniform&&r.isUniform)return;const a=t.texShape,l=r.isUniform?null:r.texData.texShape;if(!Oe(a,l))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${a} and ${l} must match`)})}function fP(n,e,t,s,o){e.program.enableShapeUniforms||(X1(e.inShapeInfos,t),X1([e.outShapeInfo],[s]));const r=s.texData.texture,i=s.texData.texShape;s.texData.isPacked?n.setOutputPackedMatrixTexture(r.texture,i[0],i[1]):n.setOutputMatrixTexture(r.texture,i[0],i[1]),n.setProgram(e.webGLProgram),n.bindVertexArray(e.webGLProgram.vao),W().getNumber("WEBGL_VERSION")===1&&e.infLoc!==null&&n.gl.uniform1f(e.infLoc,1/0),e.nanLoc!==null&&n.gl.uniform1f(e.nanLoc,NaN);for(let l=0;l{const a=i.texData!=null&&i.texData.slice!=null&&i.texData.slice.flatOffset>0;if(n.enableShapeUniforms&&!i.isUniform){const l=i.texData.texShape,{useSqueezeShape:c,uniformShape:u,keptDims:h}=xp(n.packedInputs,i.shape,l);let d="",p="",f="";if(u.length===1&&n.packedInputs){const C=[Math.ceil(l[0]/2),Math.ceil(l[1]/2)];d=`${C[0]>1}_${C[1]>1}`}else if(u.length===2&&!n.packedInputs)p=`${u[0]>1}_${u[1]>1}`;else if(u.length>2&&!n.packedInputs){const C=de(u);f=`${C[0]===l[1]}_${C[C.length-1]===l[1]}`}const g=i.shape.length,m=u.length===2&&Oe(i.shape,l),x=H(i.shape)===1,b=Ho(i.shape,t.shape),w=!n.packedInputs&&g===t.shape.length&&Oe(l,t.texData.texShape),y=n.packedInputs||u.length>2?"":`${l[0]>1}_${l[1]>1}`;s+=`${g}_${w}_${c?h:""}_${u.length}_${x}_${b}_${m}_${d}_${p}_${f}_${y}_${a}`}else{const l=i.isUniform?"uniform":i.texData.texShape;s+=`${i.shape}_${l}_${a}`}});const o=n.userCode;let r=n.constructor.name;return r+="_"+s+"_"+o+`${W().getNumber("WEBGL_VERSION")}`,r}function At(n){return W().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&n<=4}/** + */function mP(n,e,t,s){const o=t.map((u,h)=>{const d={logicalShape:u.shape,texShape:u.isUniform?null:u.texData.texShape,isUniform:u.isUniform,isPacked:u.isUniform?!1:u.texData.isPacked,flatOffset:null};return u.texData!=null&&u.texData.slice!=null&&u.texData.slice.flatOffset>0&&(d.flatOffset=u.texData.slice.flatOffset),{name:e.variableNames[h],shapeInfo:d}}),r=o.map(u=>u.shapeInfo),i={logicalShape:s.shape,texShape:s.texData.texShape,isUniform:!1,isPacked:s.texData.isPacked,flatOffset:null},a=FM(o,i,e),l=lM(n.gl,a),c=n.createProgram(l);return W().get("ENGINE_COMPILE_ONLY")?{program:e,fragmentShader:l,source:a,webGLProgram:c,inShapeInfos:r,outShapeInfo:i,variablesLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:(n.buildVao(c),Object.assign({program:e,fragmentShader:l,source:a,webGLProgram:c,inShapeInfos:r,outShapeInfo:i},Z1(n,e,c)))}function Z1(n,e,t){const s=[],o=[];let r,i,a,l=null,c=null;c=n.getUniformLocation(t,"NAN",!1),W().getNumber("WEBGL_VERSION")===1&&(l=n.getUniformLocation(t,"INFINITY",!1));const u=!1;for(const h of e.variableNames){const d={name:h,uniform:n.getUniformLocation(t,h,u),offset:n.getUniformLocation(t,`offset${h}`,u)};e.enableShapeUniforms&&(d.shape=n.getUniformLocation(t,`${h}Shape`,u),d.texShape=n.getUniformLocation(t,`${h}TexShape`,u)),s.push(d)}if(e.enableShapeUniforms&&(r=n.getUniformLocation(t,"outShape",u),a=n.getUniformLocation(t,"outShapeStrides",u),i=n.getUniformLocation(t,"outTexShape",u)),e.customUniforms)for(const h of e.customUniforms)o.push(n.getUniformLocation(t,h.name,u));return{variablesLocations:s,customUniformLocations:o,infLoc:l,nanLoc:c,outShapeLocation:r,outShapeStridesLocation:a,outTexShapeLocation:i}}function Q1(n,e){if(n.length!==e.length)throw Error(`Binary was compiled with ${n.length} inputs, but was executed with ${e.length} inputs`);n.forEach((t,s)=>{const o=t.logicalShape,r=e[s],i=r.shape;if(!Oe(o,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${o} and ${i} must match`);if(t.isUniform&&r.isUniform)return;const a=t.texShape,l=r.isUniform?null:r.texData.texShape;if(!Oe(a,l))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${a} and ${l} must match`)})}function gP(n,e,t,s,o){e.program.enableShapeUniforms||(Q1(e.inShapeInfos,t),Q1([e.outShapeInfo],[s]));const r=s.texData.texture,i=s.texData.texShape;s.texData.isPacked?n.setOutputPackedMatrixTexture(r.texture,i[0],i[1]):n.setOutputMatrixTexture(r.texture,i[0],i[1]),n.setProgram(e.webGLProgram),n.bindVertexArray(e.webGLProgram.vao),W().getNumber("WEBGL_VERSION")===1&&e.infLoc!==null&&n.gl.uniform1f(e.infLoc,1/0),e.nanLoc!==null&&n.gl.uniform1f(e.nanLoc,NaN);for(let l=0;l{const a=i.texData!=null&&i.texData.slice!=null&&i.texData.slice.flatOffset>0;if(n.enableShapeUniforms&&!i.isUniform){const l=i.texData.texShape,{useSqueezeShape:c,uniformShape:u,keptDims:h}=xp(n.packedInputs,i.shape,l);let d="",p="",f="";if(u.length===1&&n.packedInputs){const C=[Math.ceil(l[0]/2),Math.ceil(l[1]/2)];d=`${C[0]>1}_${C[1]>1}`}else if(u.length===2&&!n.packedInputs)p=`${u[0]>1}_${u[1]>1}`;else if(u.length>2&&!n.packedInputs){const C=de(u);f=`${C[0]===l[1]}_${C[C.length-1]===l[1]}`}const g=i.shape.length,m=u.length===2&&Oe(i.shape,l),x=H(i.shape)===1,b=qo(i.shape,t.shape),w=!n.packedInputs&&g===t.shape.length&&Oe(l,t.texData.texShape),y=n.packedInputs||u.length>2?"":`${l[0]>1}_${l[1]>1}`;s+=`${g}_${w}_${c?h:""}_${u.length}_${x}_${b}_${m}_${d}_${p}_${f}_${y}_${a}`}else{const l=i.isUniform?"uniform":i.texData.texShape;s+=`${i.shape}_${l}_${a}`}});const o=n.userCode;let r=n.constructor.name;return r+="_"+s+"_"+o+`${W().getNumber("WEBGL_VERSION")}`,r}function Ft(n){return W().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&n<=4}/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12173,9 +12173,9 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class gP{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=Zi.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=Mt();this.outputShape=e,this.enableShapeUniforms=At(this.outputShape.length),this.userCode=` + */class bP{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=Zi.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=Pt();this.outputShape=e,this.enableShapeUniforms=Ft(this.outputShape.length),this.userCode=` ivec3 outCoordsFromFlatIndex(int index) { - ${this.enableShapeUniforms?xc(["r","c","d"],e):$o(["r","c","d"],e)} + ${this.enableShapeUniforms?bc(["r","c","d"],e):vo(["r","c","d"],e)} return ivec3(r, c, d); } @@ -12208,9 +12208,9 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class xP{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=Zi.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=Mt();this.outputShape=e,this.enableShapeUniforms=At(this.outputShape.length),this.userCode=` + */class yP{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=Zi.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=Pt();this.outputShape=e,this.enableShapeUniforms=Ft(this.outputShape.length),this.userCode=` ivec3 outCoordsFromFlatIndex(int index) { - ${this.enableShapeUniforms?xc(["r","c","d"],e):$o(["r","c","d"],e)} + ${this.enableShapeUniforms?bc(["r","c","d"],e):vo(["r","c","d"],e)} return ivec3(r, c, d); } @@ -12243,8 +12243,8 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class bP{constructor(e){this.variableNames=["A"],this.outTexUsage=rn.DOWNLOAD;const t=Mt();this.outputShape=e,this.userCode=` - ${G1} + */class wP{constructor(e){this.variableNames=["A"],this.outTexUsage=rn.DOWNLOAD;const t=Pt();this.outputShape=e,this.userCode=` + ${j1} void main() { float x = getAAtOutCoords(); @@ -12265,8 +12265,8 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class yP{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=rn.DOWNLOAD;const t=Mt();this.outputShape=e,this.userCode=` - ${G1} + */class CP{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=rn.DOWNLOAD;const t=Pt();this.outputShape=e,this.userCode=` + ${j1} void main() { ivec3 coords = getOutputCoords(); @@ -12288,9 +12288,9 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const wP={R:0,G:1,B:2,A:3};class Y1{constructor(e,t=!1,s="RGBA"){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const o=Mt();this.outputShape=e,this.enableShapeUniforms=At(this.outputShape.length);let r="result";t&&(r="floor(result * 255. + 0.5)");let i="";for(let a=0;an.bindTexture(a,i)),re(n,()=>n.texParameteri(a,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE)),re(n,()=>n.texParameteri(a,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)),re(n,()=>n.texParameteri(a,n.TEXTURE_MIN_FILTER,n.NEAREST)),re(n,()=>n.texParameteri(a,n.TEXTURE_MAG_FILTER,n.NEAREST)),W().getNumber("WEBGL_VERSION")===1?re(n,()=>n.texImage2D(a,0,s,e,t,0,o,r,null)):re(n,()=>n.texStorage2D(a,1,s,e,t)),re(n,()=>n.bindTexture(n.TEXTURE_2D,null)),{texture:i,texShape:[t,e]}}function Z1(n){return n.internalFormatFloat}function kP(n,e,t,s){const[o,r]=Qi(e,t);return ea(n,o,r,Z1(s),s.textureFormatFloat,n.FLOAT)}function Q1(n){return n.internalFormatHalfFloat}function SP(n,e,t,s){const[o,r]=Qi(e,t);return ea(n,o,r,Q1(s),s.textureFormatFloat,s.textureTypeHalfFloat)}function J1(n){return n.downloadTextureFormat}function TP(n,e,t,s){const[o,r]=Qi(e,t);return ea(n,o,r,J1(s),n.RGBA,n.UNSIGNED_BYTE)}function ey(n){return n.internalFormatPackedFloat}function NP(n,e,t,s){const[o,r]=ar(e,t);return ea(n,o,r,ey(s),n.RGBA,n.FLOAT)}function ty(n){return n.internalFormatPackedHalfFloat}function EP(n,e,t,s){const[o,r]=ar(e,t);return ea(n,o,r,ty(s),n.RGBA,s.textureTypeHalfFloat)}function RP(n,e,t){return re(n,()=>n.bindBuffer(n.ARRAY_BUFFER,t)),V1(n,e,"clipSpacePos",t,3,20,0)&&V1(n,e,"uv",t,2,20,12)}function AP(n,e,t,s,o,r){re(n,()=>n.bindTexture(n.TEXTURE_2D,e));let i,a,l;o instanceof Uint8Array?(i=new Uint8Array(t*s*4),a=n.UNSIGNED_BYTE,l=n.RGBA):(i=new Float32Array(t*s*4),a=n.FLOAT,l=r.internalFormatPackedFloat),i.set(o),W().getNumber("WEBGL_VERSION")===2?re(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,t,s,n.RGBA,a,i)):re(n,()=>n.texImage2D(n.TEXTURE_2D,0,l,t,s,0,n.RGBA,a,i)),re(n,()=>n.bindTexture(n.TEXTURE_2D,null))}function DP(n,e,t){re(n,()=>n.bindTexture(n.TEXTURE_2D,e)),t.data instanceof Uint8Array?W().getNumber("WEBGL_VERSION")===2?re(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,t.width,t.height,n.RGBA,n.UNSIGNED_BYTE,t.data)):re(n,()=>n.texImage2D(n.TEXTURE_2D,0,n.RGBA,t.width,t.height,0,n.RGBA,n.UNSIGNED_BYTE,t.data)):W().getNumber("WEBGL_VERSION")===2?re(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,t)):re(n,()=>n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t)),re(n,()=>n.bindTexture(n.TEXTURE_2D,null))}function FP(n,e,t,s){const o=n.createBuffer();re(n,()=>n.bindBuffer(n.PIXEL_PACK_BUFFER,o));const a=4*4*e*t;return re(n,()=>n.bufferData(n.PIXEL_PACK_BUFFER,a,n.STREAM_READ)),re(n,()=>n.readPixels(0,0,t,e,n.RGBA,n.FLOAT,0)),re(n,()=>n.bindBuffer(n.PIXEL_PACK_BUFFER,null)),o}function _P(n,e,t){const s=n,o=new Float32Array(t);return s.bindBuffer(s.PIXEL_PACK_BUFFER,e),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,o),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),o}function OP(n,e,t,s){const[o,r]=Qi(e,t),i=4,a=new Uint8Array(QL(e*t,i));return re(n,()=>n.readPixels(0,0,o,r,s.downloadTextureFormat,n.UNSIGNED_BYTE,a)),new Float32Array(a.buffer)}function LP(n,e,t,s,o,r,i,a){const l=n,c=new Float32Array(JL(r,i));return l.bindBuffer(l.PIXEL_PACK_BUFFER,e),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,c),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),c}function MP(n,e,t){const s=new Float32Array(e*t*4);return re(n,()=>n.readPixels(0,0,t,e,n.RGBA,n.FLOAT,s)),s}/** + }`;return aM(n,t)}function kP(n){const e=new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]);return dM(n,e)}function SP(n){const e=new Uint16Array([0,1,2,2,1,3]);return pM(n,e)}function ea(n,e,t,s,o,r){mM(e,t);const i=fM(n),a=n.TEXTURE_2D;return re(n,()=>n.bindTexture(a,i)),re(n,()=>n.texParameteri(a,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE)),re(n,()=>n.texParameteri(a,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)),re(n,()=>n.texParameteri(a,n.TEXTURE_MIN_FILTER,n.NEAREST)),re(n,()=>n.texParameteri(a,n.TEXTURE_MAG_FILTER,n.NEAREST)),W().getNumber("WEBGL_VERSION")===1?re(n,()=>n.texImage2D(a,0,s,e,t,0,o,r,null)):re(n,()=>n.texStorage2D(a,1,s,e,t)),re(n,()=>n.bindTexture(n.TEXTURE_2D,null)),{texture:i,texShape:[t,e]}}function ey(n){return n.internalFormatFloat}function TP(n,e,t,s){const[o,r]=Qi(e,t);return ea(n,o,r,ey(s),s.textureFormatFloat,n.FLOAT)}function ty(n){return n.internalFormatHalfFloat}function NP(n,e,t,s){const[o,r]=Qi(e,t);return ea(n,o,r,ty(s),s.textureFormatFloat,s.textureTypeHalfFloat)}function ny(n){return n.downloadTextureFormat}function EP(n,e,t,s){const[o,r]=Qi(e,t);return ea(n,o,r,ny(s),n.RGBA,n.UNSIGNED_BYTE)}function sy(n){return n.internalFormatPackedFloat}function RP(n,e,t,s){const[o,r]=ar(e,t);return ea(n,o,r,sy(s),n.RGBA,n.FLOAT)}function oy(n){return n.internalFormatPackedHalfFloat}function AP(n,e,t,s){const[o,r]=ar(e,t);return ea(n,o,r,oy(s),n.RGBA,s.textureTypeHalfFloat)}function DP(n,e,t){return re(n,()=>n.bindBuffer(n.ARRAY_BUFFER,t)),G1(n,e,"clipSpacePos",t,3,20,0)&&G1(n,e,"uv",t,2,20,12)}function FP(n,e,t,s,o,r){re(n,()=>n.bindTexture(n.TEXTURE_2D,e));let i,a,l;o instanceof Uint8Array?(i=new Uint8Array(t*s*4),a=n.UNSIGNED_BYTE,l=n.RGBA):(i=new Float32Array(t*s*4),a=n.FLOAT,l=r.internalFormatPackedFloat),i.set(o),W().getNumber("WEBGL_VERSION")===2?re(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,t,s,n.RGBA,a,i)):re(n,()=>n.texImage2D(n.TEXTURE_2D,0,l,t,s,0,n.RGBA,a,i)),re(n,()=>n.bindTexture(n.TEXTURE_2D,null))}function _P(n,e,t){re(n,()=>n.bindTexture(n.TEXTURE_2D,e)),t.data instanceof Uint8Array?W().getNumber("WEBGL_VERSION")===2?re(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,t.width,t.height,n.RGBA,n.UNSIGNED_BYTE,t.data)):re(n,()=>n.texImage2D(n.TEXTURE_2D,0,n.RGBA,t.width,t.height,0,n.RGBA,n.UNSIGNED_BYTE,t.data)):W().getNumber("WEBGL_VERSION")===2?re(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,t)):re(n,()=>n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t)),re(n,()=>n.bindTexture(n.TEXTURE_2D,null))}function OP(n,e,t,s){const o=n.createBuffer();re(n,()=>n.bindBuffer(n.PIXEL_PACK_BUFFER,o));const a=4*4*e*t;return re(n,()=>n.bufferData(n.PIXEL_PACK_BUFFER,a,n.STREAM_READ)),re(n,()=>n.readPixels(0,0,t,e,n.RGBA,n.FLOAT,0)),re(n,()=>n.bindBuffer(n.PIXEL_PACK_BUFFER,null)),o}function LP(n,e,t){const s=n,o=new Float32Array(t);return s.bindBuffer(s.PIXEL_PACK_BUFFER,e),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,o),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),o}function MP(n,e,t,s){const[o,r]=Qi(e,t),i=4,a=new Uint8Array(eM(e*t,i));return re(n,()=>n.readPixels(0,0,o,r,s.downloadTextureFormat,n.UNSIGNED_BYTE,a)),new Float32Array(a.buffer)}function PP(n,e,t,s,o,r,i,a){const l=n,c=new Float32Array(tM(r,i));return l.bindBuffer(l.PIXEL_PACK_BUFFER,e),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,c),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),c}function BP(n,e,t){const s=new Float32Array(e*t*4);return re(n,()=>n.readPixels(0,0,t,e,n.RGBA,n.FLOAT,s)),s}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12409,7 +12409,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class bp{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.itemsToPoll=[];const t=W().getNumber("WEBGL_VERSION");if(e!=null?(this.gl=e,XL(t,e)):this.gl=Ln(t),e=this.gl,W().getNumber("WEBGL_VERSION")===2){const r=e;this.createVertexArray=()=>re(r,()=>r.createVertexArray()),this.bindVertexArray=i=>re(r,()=>r.bindVertexArray(i)),this.deleteVertexArray=i=>re(r,()=>r.deleteVertexArray(i)),this.getVertexArray=()=>re(r,()=>r.getParameter(r.VERTEX_ARRAY_BINDING))}else if(e!=null){const r=e.getExtension("OES_vertex_array_object");if(r==null)throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");this.createVertexArray=()=>re(e,()=>r.createVertexArrayOES()),this.bindVertexArray=i=>re(e,()=>r.bindVertexArrayOES(i)),this.deleteVertexArray=i=>re(e,()=>r.deleteVertexArrayOES(i)),this.getVertexArray=()=>re(e,()=>e.getParameter(r.VERTEX_ARRAY_BINDING_OES))}let s="WEBGL_color_buffer_float";const o="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),W().getNumber("WEBGL_VERSION")===1){const r="OES_texture_float",i="OES_texture_half_float";if(this.textureFloatExtension=dc(this.gl,r),Cn(this.gl,i))this.textureHalfFloatExtension=dc(this.gl,i);else if(W().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(s),Cn(this.gl,o))this.colorBufferHalfFloatExtension=dc(this.gl,o);else if(W().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(s="EXT_color_buffer_float",Cn(this.gl,s))this.colorBufferFloatExtension=this.gl.getExtension(s);else if(Cn(this.gl,o))this.colorBufferHalfFloatExtension=this.gl.getExtension(o);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=$P(this.gl),this.indexBuffer=vP(this.gl),this.framebuffer=fM(this.gl),this.textureConfig=cp(this.gl,this.textureHalfFloatExtension)}get debug(){return W().getBool("DEBUG")}dispose(){if(this.disposed)return;this.program!=null&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),this.outputTexture!=null&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");const e=this.gl;re(e,()=>e.finish()),re(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),re(e,()=>e.deleteFramebuffer(this.framebuffer)),re(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),re(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),re(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),kP(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),SP(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),TP(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),DP(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,s,o){this.throwIfDisposed(),AP(this.gl,e,t,s,o,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),EP(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),NP(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(W1(this.gl,this.framebuffer),this.outputTexture=null),re(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,s){return this.downloadMatrixDriver(e,()=>OP(this.gl,t,s,this.textureConfig))}downloadPackedMatrixFromBuffer(e,t,s,o,r,i){return LP(this.gl,e,t,s,o,r,i,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return _P(this.gl,e,t)}createBufferFromTexture(e,t,s){this.bindTextureToFrameBuffer(e);const o=FP(this.gl,t,s,this.textureConfig);return this.unbindTextureToFrameBuffer(),o}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,s;if(W().getBool("WEBGL_FENCE_API_ENABLED")){const o=e,r=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),s=()=>{const i=o.clientWaitSync(r,0,0);return i===o.ALREADY_SIGNALED||i===o.CONDITION_SATISFIED},t=r}else W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),s=()=>this.isQueryAvailable(t,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):s=()=>!0;return{query:t,isFencePassed:s}}downloadMatrixFromPackedTexture(e,t,s){return this.downloadMatrixDriver(e,()=>MP(this.gl,t,s))}createProgram(e){this.throwIfDisposed();const t=this.gl;this.vertexShader==null&&(this.vertexShader=IP(t));const s=lM(t);re(t,()=>t.attachShader(s,this.vertexShader)),re(t,()=>t.attachShader(s,e)),cM(t,s);const o=Object.assign(s,{vao:this.createVertexArray()});return this.debug&&up(t,o),o}buildVao(e){this.setProgram(e),this.bindVertexArray(e.vao);const t=this.gl;re(t,()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer)),RP(t,e,this.vertexBuffer)}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),e!=null&&(re(this.gl,()=>this.gl.deleteProgram(e)),this.deleteVertexArray(e.vao))}setProgram(e){this.throwIfDisposed(),this.program=e,this.program!=null&&this.debug&&up(this.gl,this.program),re(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,t,s=!0){return this.throwIfDisposed(),s?gM(this.gl,e,t):xM(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),re(this.gl,()=>this.gl.getAttribLocation(e,t))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,s){this.throwIfDisposed(),this.throwIfNoProgram(),bM(this.gl,e,t,s)}setOutputMatrixTexture(e,t,s){this.setOutputMatrixTextureDriver(e,s,t)}setOutputPackedMatrixTexture(e,t,s){this.throwIfDisposed();const[o,r]=ar(t,s);this.setOutputMatrixTextureDriver(e,o,r)}setOutputMatrixWriteRegion(e,t,s,o){this.setOutputMatrixWriteRegionDriver(s,e,o,t)}setOutputPackedMatrixWriteRegion(e,t,s,o){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){this.program!=null&&up(this.gl,this.program),pc(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;if(this.debug){const t=this.getVertexArray();console.assert(t===this.program.vao,"VAO changed between setProgram and executeProgram!"),this.debugValidate()}re(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),re(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=dc(this.gl,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const s=this.gl,o=this.getQueryTimerExtensionWebGL2(),r=s.createQuery();return s.beginQuery(o.TIME_ELAPSED_EXT,r),r}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const t=this.gl,s=this.getQueryTimerExtensionWebGL2();t.endQuery(s.TIME_ELAPSED_EXT);return}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await Mp(()=>this.disposed||this.isQueryAvailable(e,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(t===0)return null;if(t===2){const s=this.gl;return s.getQueryParameter(e,s.QUERY_RESULT)/1e6}else{const s=this.getQueryTimerExtensionWebGL1();return s.getQueryObjectEXT(e,s.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(t===0)return!0;if(t===2){const s=this.gl,o=this.getQueryTimerExtensionWebGL2(),r=s.getQueryParameter(e,s.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(o.GPU_DISJOINT_EXT)),r&&!this.disjoint}else{const s=this.getQueryTimerExtensionWebGL1(),o=s.getQueryObjectEXT(e,s.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(s.GPU_DISJOINT_EXT)),o&&!this.disjoint}}pollFence(e){return new Promise(t=>{this.addItemToPoll(()=>e.isFencePassed(),()=>t())})}pollItems(){const e=PP(this.itemsToPoll.map(t=>t.isDoneFn));for(let t=0;t<=e;++t){const{resolveFn:s}=this.itemsToPoll[t];s()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){if(this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1)return;let s;"setTimeoutCustom"in W().platform&&(s=W().platform.setTimeoutCustom.bind(W().platform)),Mp(()=>(this.pollItems(),this.itemsToPoll.length===0),()=>0,null,s)}bindTextureToFrameBuffer(e){this.throwIfDisposed(),hp(this.gl,e,this.framebuffer),this.debug&&pc(this.gl)}unbindTextureToFrameBuffer(){this.outputTexture!=null?(hp(this.gl,this.outputTexture,this.framebuffer),this.debug&&pc(this.gl)):W1(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const s=t();return this.unbindTextureToFrameBuffer(),s}setOutputMatrixTextureDriver(e,t,s){this.throwIfDisposed();const o=this.gl;hp(o,e,this.framebuffer),this.debug&&pc(o),this.outputTexture=e,re(o,()=>o.viewport(0,0,t,s)),re(o,()=>o.scissor(0,0,t,s))}setOutputMatrixWriteRegionDriver(e,t,s,o){this.throwIfDisposed(),re(this.gl,()=>this.gl.scissor(e,t,s,o))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(this.program==null)throw new Error("No GPU program is currently set.")}}function PP(n){let e=0;for(;ere(r,()=>r.createVertexArray()),this.bindVertexArray=i=>re(r,()=>r.bindVertexArray(i)),this.deleteVertexArray=i=>re(r,()=>r.deleteVertexArray(i)),this.getVertexArray=()=>re(r,()=>r.getParameter(r.VERTEX_ARRAY_BINDING))}else if(e!=null){const r=e.getExtension("OES_vertex_array_object");if(r==null)throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");this.createVertexArray=()=>re(e,()=>r.createVertexArrayOES()),this.bindVertexArray=i=>re(e,()=>r.bindVertexArrayOES(i)),this.deleteVertexArray=i=>re(e,()=>r.deleteVertexArrayOES(i)),this.getVertexArray=()=>re(e,()=>e.getParameter(r.VERTEX_ARRAY_BINDING_OES))}let s="WEBGL_color_buffer_float";const o="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),W().getNumber("WEBGL_VERSION")===1){const r="OES_texture_float",i="OES_texture_half_float";if(this.textureFloatExtension=pc(this.gl,r),Cn(this.gl,i))this.textureHalfFloatExtension=pc(this.gl,i);else if(W().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(s),Cn(this.gl,o))this.colorBufferHalfFloatExtension=pc(this.gl,o);else if(W().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(s="EXT_color_buffer_float",Cn(this.gl,s))this.colorBufferFloatExtension=this.gl.getExtension(s);else if(Cn(this.gl,o))this.colorBufferHalfFloatExtension=this.gl.getExtension(o);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=kP(this.gl),this.indexBuffer=SP(this.gl),this.framebuffer=gM(this.gl),this.textureConfig=cp(this.gl,this.textureHalfFloatExtension)}get debug(){return W().getBool("DEBUG")}dispose(){if(this.disposed)return;this.program!=null&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),this.outputTexture!=null&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");const e=this.gl;re(e,()=>e.finish()),re(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),re(e,()=>e.deleteFramebuffer(this.framebuffer)),re(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),re(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),re(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),TP(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),NP(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),EP(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),_P(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,s,o){this.throwIfDisposed(),FP(this.gl,e,t,s,o,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),AP(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),RP(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(H1(this.gl,this.framebuffer),this.outputTexture=null),re(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,s){return this.downloadMatrixDriver(e,()=>MP(this.gl,t,s,this.textureConfig))}downloadPackedMatrixFromBuffer(e,t,s,o,r,i){return PP(this.gl,e,t,s,o,r,i,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return LP(this.gl,e,t)}createBufferFromTexture(e,t,s){this.bindTextureToFrameBuffer(e);const o=OP(this.gl,t,s,this.textureConfig);return this.unbindTextureToFrameBuffer(),o}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,s;if(W().getBool("WEBGL_FENCE_API_ENABLED")){const o=e,r=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),s=()=>{const i=o.clientWaitSync(r,0,0);return i===o.ALREADY_SIGNALED||i===o.CONDITION_SATISFIED},t=r}else W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),s=()=>this.isQueryAvailable(t,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):s=()=>!0;return{query:t,isFencePassed:s}}downloadMatrixFromPackedTexture(e,t,s){return this.downloadMatrixDriver(e,()=>BP(this.gl,t,s))}createProgram(e){this.throwIfDisposed();const t=this.gl;this.vertexShader==null&&(this.vertexShader=vP(t));const s=uM(t);re(t,()=>t.attachShader(s,this.vertexShader)),re(t,()=>t.attachShader(s,e)),hM(t,s);const o=Object.assign(s,{vao:this.createVertexArray()});return this.debug&&up(t,o),o}buildVao(e){this.setProgram(e),this.bindVertexArray(e.vao);const t=this.gl;re(t,()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer)),DP(t,e,this.vertexBuffer)}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),e!=null&&(re(this.gl,()=>this.gl.deleteProgram(e)),this.deleteVertexArray(e.vao))}setProgram(e){this.throwIfDisposed(),this.program=e,this.program!=null&&this.debug&&up(this.gl,this.program),re(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,t,s=!0){return this.throwIfDisposed(),s?bM(this.gl,e,t):yM(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),re(this.gl,()=>this.gl.getAttribLocation(e,t))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,s){this.throwIfDisposed(),this.throwIfNoProgram(),wM(this.gl,e,t,s)}setOutputMatrixTexture(e,t,s){this.setOutputMatrixTextureDriver(e,s,t)}setOutputPackedMatrixTexture(e,t,s){this.throwIfDisposed();const[o,r]=ar(t,s);this.setOutputMatrixTextureDriver(e,o,r)}setOutputMatrixWriteRegion(e,t,s,o){this.setOutputMatrixWriteRegionDriver(s,e,o,t)}setOutputPackedMatrixWriteRegion(e,t,s,o){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){this.program!=null&&up(this.gl,this.program),fc(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;if(this.debug){const t=this.getVertexArray();console.assert(t===this.program.vao,"VAO changed between setProgram and executeProgram!"),this.debugValidate()}re(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),re(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=pc(this.gl,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const s=this.gl,o=this.getQueryTimerExtensionWebGL2(),r=s.createQuery();return s.beginQuery(o.TIME_ELAPSED_EXT,r),r}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const t=this.gl,s=this.getQueryTimerExtensionWebGL2();t.endQuery(s.TIME_ELAPSED_EXT);return}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await Mp(()=>this.disposed||this.isQueryAvailable(e,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(t===0)return null;if(t===2){const s=this.gl;return s.getQueryParameter(e,s.QUERY_RESULT)/1e6}else{const s=this.getQueryTimerExtensionWebGL1();return s.getQueryObjectEXT(e,s.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(t===0)return!0;if(t===2){const s=this.gl,o=this.getQueryTimerExtensionWebGL2(),r=s.getQueryParameter(e,s.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(o.GPU_DISJOINT_EXT)),r&&!this.disjoint}else{const s=this.getQueryTimerExtensionWebGL1(),o=s.getQueryObjectEXT(e,s.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(s.GPU_DISJOINT_EXT)),o&&!this.disjoint}}pollFence(e){return new Promise(t=>{this.addItemToPoll(()=>e.isFencePassed(),()=>t())})}pollItems(){const e=zP(this.itemsToPoll.map(t=>t.isDoneFn));for(let t=0;t<=e;++t){const{resolveFn:s}=this.itemsToPoll[t];s()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){if(this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1)return;let s;"setTimeoutCustom"in W().platform&&(s=W().platform.setTimeoutCustom.bind(W().platform)),Mp(()=>(this.pollItems(),this.itemsToPoll.length===0),()=>0,null,s)}bindTextureToFrameBuffer(e){this.throwIfDisposed(),hp(this.gl,e,this.framebuffer),this.debug&&fc(this.gl)}unbindTextureToFrameBuffer(){this.outputTexture!=null?(hp(this.gl,this.outputTexture,this.framebuffer),this.debug&&fc(this.gl)):H1(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const s=t();return this.unbindTextureToFrameBuffer(),s}setOutputMatrixTextureDriver(e,t,s){this.throwIfDisposed();const o=this.gl;hp(o,e,this.framebuffer),this.debug&&fc(o),this.outputTexture=e,re(o,()=>o.viewport(0,0,t,s)),re(o,()=>o.scissor(0,0,t,s))}setOutputMatrixWriteRegionDriver(e,t,s,o){this.throwIfDisposed(),re(this.gl,()=>this.gl.scissor(e,t,s,o))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(this.program==null)throw new Error("No GPU program is currently set.")}}function zP(n){let e=0;for(;e`${n}.${t}`)}function Pt(n,e){return e===1?[n]:ry(n,e)}function R3(n,e){if(n===1)return"rc";let t="";for(let s=0;s`${n}.${t}`)}function Bt(n,e){return e===1?[n]:ly(n,e)}function D3(n,e){if(n===1)return"rc";let t="";for(let s=0;s1&&(r+="thisRC.y += 1;"),s+=` + */class cy{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=Ft(this.outputShape.length);let s="";for(let o=0;o<4;o++){let r="thisRC = rc;";o%2===1&&(r+="thisRC.z += 1;"),o>1&&(r+="thisRC.y += 1;"),s+=` ${r} ${o>0?"if(thisRC.y < rows && thisRC.z < cols){":""} int flatIndex = getFlatIndex(thisRC); @@ -12508,7 +12508,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims); ${o>0?"}":""} `}this.userCode=` - ${D3(t,this.enableShapeUniforms)} + ${_3(t,this.enableShapeUniforms)} ${this.enableShapeUniforms?gp():mp(e)} void main() { @@ -12524,9 +12524,9 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, setOutput(result); } - `}}function D3(n,e){return` + `}}function _3(n,e){return` ivec3 inputCoordsFromReshapedOutCoords(int index) { - ${e?RM(["r","c","d"],"inputShape"):$o(["r","c","d"],n)} + ${e?DM(["r","c","d"],"inputShape"):vo(["r","c","d"],n)} return ivec3(r, c, d); } `}/** @@ -12544,7 +12544,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class F3{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.usedTextures={},this.logEnabled=!1}acquireTexture(e,t,s){const o=ly(t,s),r=cy(e,o,s);r in this.freeTextures||(this.freeTextures[r]=[]),r in this.usedTextures||(this.usedTextures[r]=[]);const i=ay(e,o,this.gpgpu.gl,this.gpgpu.textureConfig,s);if(this.freeTextures[r].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=i,this.log();const l=this.freeTextures[r].pop();return this.usedTextures[r].push(l),l}let a;return o===$t.PACKED_2X2_FLOAT32?a=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):o===$t.PACKED_2X2_FLOAT16?a=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):o===$t.UNPACKED_FLOAT32?a=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):o===$t.UNPACKED_FLOAT16?a=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):o===$t.PACKED_4X1_UNSIGNED_BYTE&&(a=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[r].push(a),this.numUsedTextures++,this._numBytesAllocated+=i,this.log(),a}releaseTexture(e,t,s,o){if(this.freeTextures==null)return;const r=ly(s,o),i=cy(t,r,o);i in this.freeTextures||(this.freeTextures[i]=[]);const a=ay(t,r,this.gpgpu.gl,this.gpgpu.textureConfig,o),l=W().getNumber("WEBGL_DELETE_TEXTURE_THRESHOLD");l!==-1&&this._numBytesAllocated>l?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=a):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=a),this.numUsedTextures--;const c=this.usedTextures[i],u=c&&c.indexOf(e);if(u==null||u<0)throw new Error("Cannot release a texture that was never provided by this texture manager");c[u]=c[c.length-1],c.pop(),this.log()}log(){if(!this.logEnabled)return;const e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);const t=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*t)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(this.freeTextures!=null){for(const e in this.freeTextures)this.freeTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t.texture)});for(const e in this.usedTextures)this.usedTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t.texture)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function _3(n,e){const t=n;if(e===t.R32F)return 4;if(e===t.R16F)return 2;if(e===t.RGBA32F)return 16;if(e===n.RGBA)return 16;if(e===t.RGBA16F)return 8;if(e===t.RGBA8)return 4;throw new Error(`Unknown internal format ${e}`)}function ay(n,e,t,s,o){const r=O3(e,s);let i;if(o){const[l,c]=ar(n[0],n[1]);i=l*c}else{const[l,c]=Qi(n[0],n[1]);i=l*c}const a=_3(t,r);return i*a}function O3(n,e){switch(n){case $t.PACKED_2X2_FLOAT32:return ey(e);case $t.PACKED_2X2_FLOAT16:return ty(e);case $t.UNPACKED_FLOAT32:return Z1(e);case $t.UNPACKED_FLOAT16:return Q1(e);case $t.PACKED_4X1_UNSIGNED_BYTE:return J1(e);default:throw new Error(`Unknown physical texture type ${n}`)}}function L3(n){return W().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?n?$t.PACKED_2X2_FLOAT32:$t.UNPACKED_FLOAT32:n?$t.PACKED_2X2_FLOAT16:$t.UNPACKED_FLOAT16}function ly(n,e){if(n===rn.UPLOAD)return $t.PACKED_2X2_FLOAT32;if(n===rn.RENDER||n==null)return L3(e);if(n===rn.DOWNLOAD||n===rn.PIXELS)return $t.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${n}`)}function cy(n,e,t){return`${n[0]}_${n[1]}_${e}_${t}`}/** + */class O3{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.usedTextures={},this.logEnabled=!1}acquireTexture(e,t,s){const o=hy(t,s),r=dy(e,o,s);r in this.freeTextures||(this.freeTextures[r]=[]),r in this.usedTextures||(this.usedTextures[r]=[]);const i=uy(e,o,this.gpgpu.gl,this.gpgpu.textureConfig,s);if(this.freeTextures[r].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=i,this.log();const l=this.freeTextures[r].pop();return this.usedTextures[r].push(l),l}let a;return o===$t.PACKED_2X2_FLOAT32?a=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):o===$t.PACKED_2X2_FLOAT16?a=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):o===$t.UNPACKED_FLOAT32?a=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):o===$t.UNPACKED_FLOAT16?a=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):o===$t.PACKED_4X1_UNSIGNED_BYTE&&(a=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[r].push(a),this.numUsedTextures++,this._numBytesAllocated+=i,this.log(),a}releaseTexture(e,t,s,o){if(this.freeTextures==null)return;const r=hy(s,o),i=dy(t,r,o);i in this.freeTextures||(this.freeTextures[i]=[]);const a=uy(t,r,this.gpgpu.gl,this.gpgpu.textureConfig,o),l=W().getNumber("WEBGL_DELETE_TEXTURE_THRESHOLD");l!==-1&&this._numBytesAllocated>l?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=a):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=a),this.numUsedTextures--;const c=this.usedTextures[i],u=c&&c.indexOf(e);if(u==null||u<0)throw new Error("Cannot release a texture that was never provided by this texture manager");c[u]=c[c.length-1],c.pop(),this.log()}log(){if(!this.logEnabled)return;const e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);const t=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*t)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(this.freeTextures!=null){for(const e in this.freeTextures)this.freeTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t.texture)});for(const e in this.usedTextures)this.usedTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t.texture)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function L3(n,e){const t=n;if(e===t.R32F)return 4;if(e===t.R16F)return 2;if(e===t.RGBA32F)return 16;if(e===n.RGBA)return 16;if(e===t.RGBA16F)return 8;if(e===t.RGBA8)return 4;throw new Error(`Unknown internal format ${e}`)}function uy(n,e,t,s,o){const r=M3(e,s);let i;if(o){const[l,c]=ar(n[0],n[1]);i=l*c}else{const[l,c]=Qi(n[0],n[1]);i=l*c}const a=L3(t,r);return i*a}function M3(n,e){switch(n){case $t.PACKED_2X2_FLOAT32:return sy(e);case $t.PACKED_2X2_FLOAT16:return oy(e);case $t.UNPACKED_FLOAT32:return ey(e);case $t.UNPACKED_FLOAT16:return ty(e);case $t.PACKED_4X1_UNSIGNED_BYTE:return ny(e);default:throw new Error(`Unknown physical texture type ${n}`)}}function P3(n){return W().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?n?$t.PACKED_2X2_FLOAT32:$t.UNPACKED_FLOAT32:n?$t.PACKED_2X2_FLOAT16:$t.UNPACKED_FLOAT16}function hy(n,e){if(n===rn.UPLOAD)return $t.PACKED_2X2_FLOAT32;if(n===rn.RENDER||n==null)return P3(e);if(n===rn.DOWNLOAD||n===rn.PIXELS)return $t.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${n}`)}function dy(n,e,t){return`${n[0]}_${n[1]}_${e}_${t}`}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12559,7 +12559,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class ts{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=At(this.outputShape.length),this.userCode=` + */class ts{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=Ft(this.outputShape.length),this.userCode=` float unaryOperation(float x) { ${t} } @@ -12570,11 +12570,11 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, setOutput(y); } - `}}const In="if (isnan(x)) return x;",M3="return x;",uy="return abs(x);",P3="return (x >= 0.0) ? x : (exp(x) - 1.0);",B3=In+` + `}}const In="if (isnan(x)) return x;",B3="return x;",py="return abs(x);",z3="return (x >= 0.0) ? x : (exp(x) - 1.0);",V3=In+` return (x < 0.0) ? 0.0 : x; -`,z3=In+` +`,W3=In+` return (x < 0.0) ? 0.0 : min(6.0, x); -`,Ls="return x;",V3="return 1.0 / (1.0 + exp(-1.0 * x));";/** +`,Ls="return x;",U3="return 1.0 / (1.0 + exp(-1.0 * x));";/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12589,7 +12589,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const W3="return x;",U3=` + */const G3="return x;",H3=` vec4 result; result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); @@ -12598,7 +12598,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); return result; -`,G3=` +`,q3=` vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); bvec4 isNaN = isnan(x); @@ -12608,7 +12608,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, result.a = isNaN.a ? x.a : result.a; return result; -`,H3=` +`,j3=` vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); bvec4 isNaN = isnan(x); @@ -12618,7 +12618,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, result.a = isNaN.a ? x.a : result.a; return result; -`,j3="return 1.0 / (1.0 + exp(-1.0 * x));";class Ms{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=At(this.outputShape.length),this.userCode=` +`,K3="return 1.0 / (1.0 + exp(-1.0 * x));";class Ms{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=Ft(this.outputShape.length),this.userCode=` vec4 unaryOperation(vec4 x) { ${t} } @@ -12644,7 +12644,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class q3{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=At(this.outputShape.length);const t=e.length,s=Pt("rc",t),o=Be(t),r=R3(t,s),i=s.slice(-2),a=t<=1?"rc":`vec2(${i.join(",")})`;this.userCode=` + */class X3{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=Ft(this.outputShape.length);const t=e.length,s=Bt("rc",t),o=Be(t),r=D3(t,s),i=s.slice(-2),a=t<=1?"rc":`vec2(${i.join(",")})`;this.userCode=` void main() { ${o} rc = getOutputCoords(); vec4 packedInput = getA(${r}); @@ -12666,7 +12666,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const K3=Eh,X3=1e-7,Y3=1e-4,bc={};function Z3(n){return n in bc||(bc[n]={}),bc[n]}const Q3=W().getNumber("CPU_HANDOFF_SIZE_THRESHOLD"),J3=600;function eB(){return W().global.screen==null?1024:W().global.screen.height*W().global.screen.width*window.devicePixelRatio*J3/1024/1024}class yc extends Fc{nextDataId(){return yc.nextDataId++}constructor(e){if(super(),this.pendingRead=new WeakMap,this.pendingDisposal=new WeakSet,this.dataRefCount=new WeakMap,this.numBytesInGPU=0,this.uploadWaitMs=0,this.downloadWaitMs=0,this.lastGlFlushTime=0,this.warnedAboutMemory=!1,this.pendingDeletes=0,this.disposed=!1,!W().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");let t;if(e!=null){if(e instanceof bp)t=e;else{const s=Ln(W().getNumber("WEBGL_VERSION"),e);t=new bp(s)}this.binaryCache={},this.gpgpuCreatedLocally=!1}else{const s=Ln(W().getNumber("WEBGL_VERSION"));t=new bp(s),this.binaryCache=Z3(W().getNumber("WEBGL_VERSION")),this.gpgpuCreatedLocally=!0}this.gpgpu=t,this.canvas=this.gpgpu.gl.canvas,this.textureManager=new F3(this.gpgpu),this.numMBBeforeWarning=eB(),this.texData=new Op(this,Te())}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}writeTexture(e,t,s,o,r,i){const a=this.makeTensorInfo(t,s),l=this.texData.get(a.dataId);l.isPacked=!1,l.texture={texture:e,texShape:[o,r]},l.texShape=[o,r];const c=fc(t),u=new Y1(c,!1,i),h=this.runWebGLProgram(u,[a],s,[[o,r]]);return h.shape=t,l.texture=null,this.disposeIntermediateTensorInfo(a),h.dataId}write(e,t,s){if((W().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||W().getBool("DEBUG"))&&this.checkNumericalProblems(e),s==="complex64"&&e!=null)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");const o={id:this.nextDataId()};return this.texData.set(o,{shape:t,dtype:s,values:e,usage:rn.UPLOAD,refCount:1}),o}refCount(e){return this.texData.has(e)?this.texData.get(e).refCount:0}incRef(e){const t=this.texData.get(e);t.refCount++}decRef(e){if(this.texData.has(e)){const t=this.texData.get(e);t.refCount--}}move(e,t,s,o,r){if(W().getBool("DEBUG")&&this.checkNumericalProblems(t),o==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:s,dtype:o,values:t,usage:rn.UPLOAD,refCount:r})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){const t=this.texData.get(e),{values:s,dtype:o,complexTensorInfos:r,slice:i,shape:a,isPacked:l}=t;if(i!=null){let d;l?d=new Ms(a,Ls):d=new ts(a,Ls);const p=this.runWebGLProgram(d,[{dataId:e,shape:a,dtype:o}],o),f=this.readSync(p.dataId);return this.disposeIntermediateTensorInfo(p),f}if(s!=null)return this.convertAndCacheOnCPU(e);if(o==="string")return s;const c=this.activeTimers!=null;let u;c&&(u=zt());let h;if(o==="complex64"){const d=this.readSync(r.real.dataId),p=this.readSync(r.imag.dataId);h=cs(d,p)}else h=this.getValuesFromTexture(e);return c&&(this.downloadWaitMs+=zt()-u),this.convertAndCacheOnCPU(e,h)}async read(e){if(this.pendingRead.has(e)){const f=this.pendingRead.get(e);return new Promise(g=>f.push(g))}const t=this.texData.get(e),{values:s,shape:o,slice:r,dtype:i,complexTensorInfos:a,isPacked:l}=t;if(r!=null){let f;l?f=new Ms(o,Ls):f=new ts(o,Ls);const g=this.runWebGLProgram(f,[{dataId:e,shape:o,dtype:i}],i),m=this.read(g.dataId);return this.disposeIntermediateTensorInfo(g),m}if(s!=null)return this.convertAndCacheOnCPU(e);if(W().getBool("DEBUG")&&!W().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&W().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let c=null,u;if(i!=="complex64"&&W().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);const f=this.texData.get(u.dataId);c=this.gpgpu.createBufferFromTexture(f.texture.texture,...hc(o))}this.pendingRead.set(e,[]),i!=="complex64"&&await this.gpgpu.createAndWaitForFence();let h;if(i==="complex64"){const f=await Promise.all([this.read(a.real.dataId),this.read(a.imag.dataId)]),g=f[0],m=f[1];h=cs(g,m)}else if(c==null)h=this.getValuesFromTexture(e);else{const f=H(o);h=this.gpgpu.downloadFloat32MatrixFromBuffer(c,f)}if(u!=null&&this.disposeIntermediateTensorInfo(u),c!=null){const f=this.gpgpu.gl;re(f,()=>f.deleteBuffer(c))}const d=this.convertAndCacheOnCPU(e,h),p=this.pendingRead.get(e);return this.pendingRead.delete(e),p.forEach(f=>f(d)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&Te().removeDataId(e,this),this.pendingDeletes--),d}readToGPU(e,t={}){const s=this.texData.get(e),{values:o,shape:r,slice:i,dtype:a,isPacked:l,texture:c}=s;if(a==="complex64")throw new Error("Does not support reading texture for complex64 dtype.");if(i!=null){let p;l?p=new Ms(r,Ls):p=new ts(r,Ls);const f=this.runWebGLProgram(p,[{dataId:e,shape:r,dtype:a}],a),g=this.readToGPU(f,t);return this.disposeIntermediateTensorInfo(f),g}if(c==null)throw o!=null?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const u=this.decode(e,t.customTexShape),h=Te().makeTensorFromTensorInfo(u),d=this.texData.get(u.dataId);return Object.assign({tensorRef:h},d.texture)}bufferSync(e){const t=this.readSync(e.dataId);if(e.dtype==="string")try{const s=t.map(o=>ys(o));return ve(e.shape,e.dtype,s)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return ve(e.shape,e.dtype,t)}checkNumericalProblems(e){if(e!=null)for(let t=0;t0}time(e){const t=this.activeTimers,s=[];let o=!1;this.programTimersStack==null?(this.programTimersStack=s,o=!0):this.activeTimers.push(s),this.activeTimers=s,e();const r=Ys(this.activeTimers.map(l=>l.query)).filter(l=>l!=null),i=Ys(this.activeTimers.map(l=>l.name)).filter(l=>l!=null);this.activeTimers=t,o&&(this.programTimersStack=null);const a={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const l=await Promise.all(r);a.kernelMs=ww(l),a.getExtraProfileInfo=()=>l.map((c,u)=>({name:i[u],ms:c})).map(c=>`${c.name}: ${c.ms}`).join(", ")}else a.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,a})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:zt(),endMs:null}}endTimer(e){return W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=zt(),e)}async getQueryTime(e){if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(e);const t=e;return t.endMs-t.startMs}disposeData(e,t=!1){if(this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(t?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!t&&this.texData.get(e).refCount>0)return!1;if(this.pendingRead.has(e))return this.pendingDisposal.add(e),this.pendingDeletes++,!1;this.releaseGPUData(e);const{complexTensorInfos:s}=this.texData.get(e);return s!=null&&(this.disposeData(s.real.dataId,t),this.disposeData(s.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:s,texShape:o,usage:r,isPacked:i,slice:a}=this.texData.get(e),l=a&&a.origDataId||e,c=this.dataRefCount.get(l);c>1?this.dataRefCount.set(l,c-1):(this.dataRefCount.delete(l),t!=null&&(this.numBytesInGPU-=this.computeBytes(o,s),this.textureManager.releaseTexture(t,o,r,i)));const u=this.texData.get(e);u.texture=null,u.texShape=null,u.isPacked=!1,u.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=Q3){return W().getBool("WEBGL_CPU_FORWARD")&&e.every(s=>this.texData.get(s.dataId).texture==null&&H(s.shape)0&&br(s[0])){const r=s.map(i=>bs(i));o=this.write(r,e,t)}else o=this.write(s,e,t);return this.texData.get(o).usage=null,{dataId:o,shape:e,dtype:t}}makeOutput(e,t,s){return Te().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,s),this)}unpackTensor(e){const t=new q3(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new A3(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const s=[lr(e.shape),...cr(e.shape)],o={dtype:e.dtype,shape:s,dataId:e.dataId},r=[lr(t),...cr(t)],i=new iy(r,s),a=!0,l=[s],c=this.runWebGLProgram(i,[o],e.dtype,l,a);return{dataId:c.dataId,shape:t,dtype:c.dtype}}decode(e,t){const s=this.texData.get(e),{isPacked:o,shape:r,dtype:i}=s;if(t!=null){const d=H(r),p=t[0]*t[1]*4;$(d<=p,()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data.")}const a=fc(r);let l;o?l=new xP(a):l=new gP(a);const c=!0,u=[t??hc(a)],h=this.runWebGLProgram(l,[{shape:a,dtype:i,dataId:e}],i,u,c,t);return{dtype:i,shape:r,dataId:h.dataId}}runWebGLProgram(e,t,s,o,r=!1,i){const a=this.makeTensorInfo(e.outputShape,s),l=this.texData.get(a.dataId);if(e.packedOutput&&(l.isPacked=!0),e.outPackingScheme===Zi.DENSE){const x=i??hc(e.outputShape);l.texShape=x.map(b=>b*2)}if(e.outTexUsage!=null&&(l.usage=e.outTexUsage),H(a.shape)===0)return l.values=Tt(a.dtype,0),a;const c=[],u=t.map(x=>{if(x.dtype==="complex64")throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let b=this.texData.get(x.dataId);if(b.texture==null){if(!e.packedInputs&&H(x.shape)<=W().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:x.shape,texData:null,isUniform:!0,uniformValues:b.values};e.packedInputs&&(b.isPacked=!0,b.shape=x.shape)}if(this.uploadToGPU(x.dataId),!!b.isPacked!=!!e.packedInputs)x=b.isPacked?this.unpackTensor(x):this.packTensor(x),c.push(x),b=this.texData.get(x.dataId);else if(b.isPacked&&!gc(b.shape,x.shape)){const w=x,y=x.shape;x.shape=b.shape,x=this.packedReshape(x,y),c.push(x),b=this.texData.get(x.dataId),w.shape=y}return{shape:x.shape,texData:b,isUniform:!1}});this.uploadToGPU(a.dataId);const h={shape:a.shape,texData:l,isUniform:!1},d=mP(e,u,h),p=this.getAndSaveBinary(d,()=>pP(this.gpgpu,e,u,h)),f=this.activeTimers!=null;let g;f&&(g=this.startTimer()),W().get("ENGINE_COMPILE_ONLY")||fP(this.gpgpu,p,u,h,o),c.forEach(x=>this.disposeIntermediateTensorInfo(x)),f&&(g=this.endTimer(g),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(g)}));const m=W().getNumber("WEBGL_FLUSH_THRESHOLD");if(m>0){const x=zt();x-this.lastGlFlushTime>m&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=x)}if(!W().getBool("WEBGL_LAZILY_UNPACK")&&l.isPacked&&r===!1){const x=this.unpackTensor(a);return this.disposeIntermediateTensorInfo(a),x}return a}compileAndRun(e,t,s,o,r=!1){return s=s||t[0].dtype,this.runWebGLProgram(e,t,s,o,r)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(W().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach(t=>{this.gpgpu.deleteProgram(this.binaryCache[t].webGLProgram),delete this.binaryCache[t]}),this.textureManager.dispose(),this.canvas!=null&&typeof HTMLCanvasElement<"u"&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)}floatPrecision(){return this.floatPrecisionValue==null&&(this.floatPrecisionValue=z(()=>{if(!W().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=W().getBool("DEBUG");W().set("DEBUG",!1);const t=this.abs(Fe(1e-8)).dataSync()[0];if(W().set("DEBUG",e),t>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return this.floatPrecision()===32?X3:Y3}uploadToGPU(e){const t=this.texData.get(e),{shape:s,dtype:o,values:r,texture:i,usage:a,isPacked:l}=t;if(i!=null)return;const c=this.activeTimers!=null;let u;c&&(u=zt());let h=t.texShape;if(h==null&&(h=CM(s,l),t.texShape=h),r!=null){const d=fc(s);let p,f=h[1],g=h[0];const m=r instanceof Uint8Array||r instanceof Uint8ClampedArray;(l||!m)&&([f,g]=ar(h[0],h[1])),l?p=new CP(d,m):p=new Y1(d,m);const x=m?[g,f]:h,b=this.makeTensorInfo(x,o),w=this.texData.get(b.dataId);m?w.usage=rn.PIXELS:w.usage=rn.UPLOAD,w.texShape=x,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(b.dataId),f,g,r);const y=[[g,f]],I=this.runWebGLProgram(p,[b],o,y,!0),v=this.texData.get(I.dataId);t.texShape=v.texShape,t.isPacked=v.isPacked,t.usage=v.usage,W().get("ENGINE_COMPILE_ONLY")?this.disposeData(I.dataId):(t.texture=v.texture,t.values=null,this.texData.delete(I.dataId)),this.disposeIntermediateTensorInfo(b),c&&(this.uploadWaitMs+=zt()-u)}else{const d=this.acquireTexture(h,a,o,l);t.texture=d}}convertAndCacheOnCPU(e,t){const s=this.texData.get(e),{dtype:o}=s;return t!=null&&(s.values=tB(t,o)),s.values}acquireTexture(e,t,s,o){if(this.numBytesInGPU+=this.computeBytes(e,s),!this.warnedAboutMemory&&this.numBytesInGPU>this.numMBBeforeWarning*1024*1024){const r=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${r} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,o)}computeBytes(e,t){return e[0]*e[1]*la(t)}checkCompileCompletion(){for(const[,e]of Object.entries(this.binaryCache))this.checkCompletion_(e)}async checkCompileCompletionAsync(){const e=[];if(this.gpgpu.parallelCompilationExtension){for(const[,t]of Object.entries(this.binaryCache))e.push(this.checkCompletionAsync_(t));return Promise.all(e)}else{for(const[,t]of Object.entries(this.binaryCache)){const s=new Promise(o=>{try{this.checkCompletion_(t),o(!0)}catch(r){throw r}});e.push(s)}return Promise.all(e)}}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await rg(),this.checkCompletionAsync_(e))}checkCompletion_(e){if(this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)===!1)throw console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)),this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS)===!1?(z1(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.")):new Error("Failed to link vertex and fragment shaders.");return!0}getUniformLocations(){for(const e of Object.values(this.binaryCache)){this.gpgpu.buildVao(e.webGLProgram);const{variablesLocations:t,customUniformLocations:s,infLoc:o,nanLoc:r,outShapeLocation:i,outShapeStridesLocation:a,outTexShapeLocation:l}=K1(this.gpgpu,e.program,e.webGLProgram);e.variablesLocations=t,e.customUniformLocations=s,e.infLoc=o,e.nanLoc=r,e.outShapeLocation=i,e.outShapeStridesLocation=a,e.outTexShapeLocation=l}}createTensorFromGPUData(e,t,s){e.channels=e.channels||"RGBA";const{texture:o,height:r,width:i,channels:a}=e,l=Te().backend;if(!l.gpgpu.gl.isTexture(o))throw new Error("The texture is invalid. Also, please make sure the texture and the TFJS WebGL backend are using the same canvas. If you want to use your own custom canvas, you have to create and use the custom TFJS WebGL backend created from the canvas through 'new tf.MathBackendWebGL(customCanvas)'.");const c=l.writeTexture(o,t,s,r,i,a);return Te().makeTensorFromDataId(c,t,s,l)}}yc.nextDataId=0;function tB(n,e){if(e==="float32"||e==="complex64")return n;if(e==="int32"||e==="bool"){const t=e==="int32"?new Int32Array(n.length):new Uint8Array(n.length);for(let s=0;sf.push(g))}const t=this.texData.get(e),{values:s,shape:o,slice:r,dtype:i,complexTensorInfos:a,isPacked:l}=t;if(r!=null){let f;l?f=new Ms(o,Ls):f=new ts(o,Ls);const g=this.runWebGLProgram(f,[{dataId:e,shape:o,dtype:i}],i),m=this.read(g.dataId);return this.disposeIntermediateTensorInfo(g),m}if(s!=null)return this.convertAndCacheOnCPU(e);if(W().getBool("DEBUG")&&!W().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&W().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let c=null,u;if(i!=="complex64"&&W().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);const f=this.texData.get(u.dataId);c=this.gpgpu.createBufferFromTexture(f.texture.texture,...dc(o))}this.pendingRead.set(e,[]),i!=="complex64"&&await this.gpgpu.createAndWaitForFence();let h;if(i==="complex64"){const f=await Promise.all([this.read(a.real.dataId),this.read(a.imag.dataId)]),g=f[0],m=f[1];h=cs(g,m)}else if(c==null)h=this.getValuesFromTexture(e);else{const f=H(o);h=this.gpgpu.downloadFloat32MatrixFromBuffer(c,f)}if(u!=null&&this.disposeIntermediateTensorInfo(u),c!=null){const f=this.gpgpu.gl;re(f,()=>f.deleteBuffer(c))}const d=this.convertAndCacheOnCPU(e,h),p=this.pendingRead.get(e);return this.pendingRead.delete(e),p.forEach(f=>f(d)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&Te().removeDataId(e,this),this.pendingDeletes--),d}readToGPU(e,t={}){const s=this.texData.get(e),{values:o,shape:r,slice:i,dtype:a,isPacked:l,texture:c}=s;if(a==="complex64")throw new Error("Does not support reading texture for complex64 dtype.");if(i!=null){let p;l?p=new Ms(r,Ls):p=new ts(r,Ls);const f=this.runWebGLProgram(p,[{dataId:e,shape:r,dtype:a}],a),g=this.readToGPU(f,t);return this.disposeIntermediateTensorInfo(f),g}if(c==null)throw o!=null?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const u=this.decode(e,t.customTexShape),h=Te().makeTensorFromTensorInfo(u),d=this.texData.get(u.dataId);return Object.assign({tensorRef:h},d.texture)}bufferSync(e){const t=this.readSync(e.dataId);if(e.dtype==="string")try{const s=t.map(o=>ys(o));return ve(e.shape,e.dtype,s)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return ve(e.shape,e.dtype,t)}checkNumericalProblems(e){if(e!=null)for(let t=0;t0}time(e){const t=this.activeTimers,s=[];let o=!1;this.programTimersStack==null?(this.programTimersStack=s,o=!0):this.activeTimers.push(s),this.activeTimers=s,e();const r=Ys(this.activeTimers.map(l=>l.query)).filter(l=>l!=null),i=Ys(this.activeTimers.map(l=>l.name)).filter(l=>l!=null);this.activeTimers=t,o&&(this.programTimersStack=null);const a={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const l=await Promise.all(r);a.kernelMs=$w(l),a.getExtraProfileInfo=()=>l.map((c,u)=>({name:i[u],ms:c})).map(c=>`${c.name}: ${c.ms}`).join(", ")}else a.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,a})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:Vt(),endMs:null}}endTimer(e){return W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=Vt(),e)}async getQueryTime(e){if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(e);const t=e;return t.endMs-t.startMs}disposeData(e,t=!1){if(this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(t?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!t&&this.texData.get(e).refCount>0)return!1;if(this.pendingRead.has(e))return this.pendingDisposal.add(e),this.pendingDeletes++,!1;this.releaseGPUData(e);const{complexTensorInfos:s}=this.texData.get(e);return s!=null&&(this.disposeData(s.real.dataId,t),this.disposeData(s.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:s,texShape:o,usage:r,isPacked:i,slice:a}=this.texData.get(e),l=a&&a.origDataId||e,c=this.dataRefCount.get(l);c>1?this.dataRefCount.set(l,c-1):(this.dataRefCount.delete(l),t!=null&&(this.numBytesInGPU-=this.computeBytes(o,s),this.textureManager.releaseTexture(t,o,r,i)));const u=this.texData.get(e);u.texture=null,u.texShape=null,u.isPacked=!1,u.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=eB){return W().getBool("WEBGL_CPU_FORWARD")&&e.every(s=>this.texData.get(s.dataId).texture==null&&H(s.shape)0&&br(s[0])){const r=s.map(i=>bs(i));o=this.write(r,e,t)}else o=this.write(s,e,t);return this.texData.get(o).usage=null,{dataId:o,shape:e,dtype:t}}makeOutput(e,t,s){return Te().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,s),this)}unpackTensor(e){const t=new X3(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new F3(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const s=[lr(e.shape),...cr(e.shape)],o={dtype:e.dtype,shape:s,dataId:e.dataId},r=[lr(t),...cr(t)],i=new cy(r,s),a=!0,l=[s],c=this.runWebGLProgram(i,[o],e.dtype,l,a);return{dataId:c.dataId,shape:t,dtype:c.dtype}}decode(e,t){const s=this.texData.get(e),{isPacked:o,shape:r,dtype:i}=s;if(t!=null){const d=H(r),p=t[0]*t[1]*4;$(d<=p,()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data.")}const a=mc(r);let l;o?l=new yP(a):l=new bP(a);const c=!0,u=[t??dc(a)],h=this.runWebGLProgram(l,[{shape:a,dtype:i,dataId:e}],i,u,c,t);return{dtype:i,shape:r,dataId:h.dataId}}runWebGLProgram(e,t,s,o,r=!1,i){const a=this.makeTensorInfo(e.outputShape,s),l=this.texData.get(a.dataId);if(e.packedOutput&&(l.isPacked=!0),e.outPackingScheme===Zi.DENSE){const x=i??dc(e.outputShape);l.texShape=x.map(b=>b*2)}if(e.outTexUsage!=null&&(l.usage=e.outTexUsage),H(a.shape)===0)return l.values=Tt(a.dtype,0),a;const c=[],u=t.map(x=>{if(x.dtype==="complex64")throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let b=this.texData.get(x.dataId);if(b.texture==null){if(!e.packedInputs&&H(x.shape)<=W().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:x.shape,texData:null,isUniform:!0,uniformValues:b.values};e.packedInputs&&(b.isPacked=!0,b.shape=x.shape)}if(this.uploadToGPU(x.dataId),!!b.isPacked!=!!e.packedInputs)x=b.isPacked?this.unpackTensor(x):this.packTensor(x),c.push(x),b=this.texData.get(x.dataId);else if(b.isPacked&&!xc(b.shape,x.shape)){const w=x,y=x.shape;x.shape=b.shape,x=this.packedReshape(x,y),c.push(x),b=this.texData.get(x.dataId),w.shape=y}return{shape:x.shape,texData:b,isUniform:!1}});this.uploadToGPU(a.dataId);const h={shape:a.shape,texData:l,isUniform:!1},d=xP(e,u,h),p=this.getAndSaveBinary(d,()=>mP(this.gpgpu,e,u,h)),f=this.activeTimers!=null;let g;f&&(g=this.startTimer()),W().get("ENGINE_COMPILE_ONLY")||gP(this.gpgpu,p,u,h,o),c.forEach(x=>this.disposeIntermediateTensorInfo(x)),f&&(g=this.endTimer(g),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(g)}));const m=W().getNumber("WEBGL_FLUSH_THRESHOLD");if(m>0){const x=Vt();x-this.lastGlFlushTime>m&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=x)}if(!W().getBool("WEBGL_LAZILY_UNPACK")&&l.isPacked&&r===!1){const x=this.unpackTensor(a);return this.disposeIntermediateTensorInfo(a),x}return a}compileAndRun(e,t,s,o,r=!1){return s=s||t[0].dtype,this.runWebGLProgram(e,t,s,o,r)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(W().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach(t=>{this.gpgpu.deleteProgram(this.binaryCache[t].webGLProgram),delete this.binaryCache[t]}),this.textureManager.dispose(),this.canvas!=null&&typeof HTMLCanvasElement<"u"&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)}floatPrecision(){return this.floatPrecisionValue==null&&(this.floatPrecisionValue=P(()=>{if(!W().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=W().getBool("DEBUG");W().set("DEBUG",!1);const t=this.abs(Fe(1e-8)).dataSync()[0];if(W().set("DEBUG",e),t>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return this.floatPrecision()===32?Z3:Q3}uploadToGPU(e){const t=this.texData.get(e),{shape:s,dtype:o,values:r,texture:i,usage:a,isPacked:l}=t;if(i!=null)return;const c=this.activeTimers!=null;let u;c&&(u=Vt());let h=t.texShape;if(h==null&&(h=$M(s,l),t.texShape=h),r!=null){const d=mc(s);let p,f=h[1],g=h[0];const m=r instanceof Uint8Array||r instanceof Uint8ClampedArray;(l||!m)&&([f,g]=ar(h[0],h[1])),l?p=new $P(d,m):p=new J1(d,m);const x=m?[g,f]:h,b=this.makeTensorInfo(x,o),w=this.texData.get(b.dataId);m?w.usage=rn.PIXELS:w.usage=rn.UPLOAD,w.texShape=x,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(b.dataId),f,g,r);const y=[[g,f]],I=this.runWebGLProgram(p,[b],o,y,!0),v=this.texData.get(I.dataId);t.texShape=v.texShape,t.isPacked=v.isPacked,t.usage=v.usage,W().get("ENGINE_COMPILE_ONLY")?this.disposeData(I.dataId):(t.texture=v.texture,t.values=null,this.texData.delete(I.dataId)),this.disposeIntermediateTensorInfo(b),c&&(this.uploadWaitMs+=Vt()-u)}else{const d=this.acquireTexture(h,a,o,l);t.texture=d}}convertAndCacheOnCPU(e,t){const s=this.texData.get(e),{dtype:o}=s;return t!=null&&(s.values=sB(t,o)),s.values}acquireTexture(e,t,s,o){if(this.numBytesInGPU+=this.computeBytes(e,s),!this.warnedAboutMemory&&this.numBytesInGPU>this.numMBBeforeWarning*1024*1024){const r=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${r} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,o)}computeBytes(e,t){return e[0]*e[1]*la(t)}checkCompileCompletion(){for(const[,e]of Object.entries(this.binaryCache))this.checkCompletion_(e)}async checkCompileCompletionAsync(){const e=[];if(this.gpgpu.parallelCompilationExtension){for(const[,t]of Object.entries(this.binaryCache))e.push(this.checkCompletionAsync_(t));return Promise.all(e)}else{for(const[,t]of Object.entries(this.binaryCache)){const s=new Promise(o=>{try{this.checkCompletion_(t),o(!0)}catch(r){throw r}});e.push(s)}return Promise.all(e)}}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await ig(),this.checkCompletionAsync_(e))}checkCompletion_(e){if(this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)===!1)throw console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)),this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS)===!1?(U1(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.")):new Error("Failed to link vertex and fragment shaders.");return!0}getUniformLocations(){for(const e of Object.values(this.binaryCache)){this.gpgpu.buildVao(e.webGLProgram);const{variablesLocations:t,customUniformLocations:s,infLoc:o,nanLoc:r,outShapeLocation:i,outShapeStridesLocation:a,outTexShapeLocation:l}=Z1(this.gpgpu,e.program,e.webGLProgram);e.variablesLocations=t,e.customUniformLocations=s,e.infLoc=o,e.nanLoc=r,e.outShapeLocation=i,e.outShapeStridesLocation=a,e.outTexShapeLocation=l}}createTensorFromGPUData(e,t,s){e.channels=e.channels||"RGBA";const{texture:o,height:r,width:i,channels:a}=e,l=Te().backend;if(!l.gpgpu.gl.isTexture(o))throw new Error("The texture is invalid. Also, please make sure the texture and the TFJS WebGL backend are using the same canvas. If you want to use your own custom canvas, you have to create and use the custom TFJS WebGL backend created from the canvas through 'new tf.MathBackendWebGL(customCanvas)'.");const c=l.writeTexture(o,t,s,r,i,a);return Te().makeTensorFromDataId(c,t,s,l)}}wc.nextDataId=0;function sB(n,e){if(e==="float32"||e==="complex64")return n;if(e==="int32"||e==="bool"){const t=e==="int32"?new Int32Array(n.length):new Uint8Array(n.length);for(let s=0;snew yc,2);/** + */Wf()&&jf("webgl",()=>new wc,2);/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12699,7 +12699,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, */const wp=` if (isnan(a)) return a; if (isnan(b)) return b; -`;class ko{constructor(e,t,s){this.variableNames=["A","B"],this.outputShape=we(t,s),this.enableShapeUniforms=At(this.outputShape.length),this.userCode=` +`;class So{constructor(e,t,s){this.variableNames=["A","B"],this.outputShape=we(t,s),this.enableShapeUniforms=Ft(this.outputShape.length),this.userCode=` float binaryOperation(float a, float b) { ${e} } @@ -12724,12 +12724,12 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const So=` + */const To=` result.r = isNaN.r ? NAN : result.r; result.g = isNaN.g ? NAN : result.g; result.b = isNaN.b ? NAN : result.b; result.a = isNaN.a ? NAN : result.a; -`;class fr{constructor(e,t,s,o=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=we(t,s);const r=this.outputShape.length;this.enableShapeUniforms=At(r);let i="";if(o)if(r===0||H(this.outputShape)===1)i=` +`;class fr{constructor(e,t,s,o=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=we(t,s);const r=this.outputShape.length;this.enableShapeUniforms=Ft(r);let i="";if(o)if(r===0||H(this.outputShape)===1)i=` result.y = 0.; result.z = 0.; result.w = 0.; @@ -12743,7 +12743,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y; result.z = 0.; result.w = 0.; - `;else{const l=Pt("coords",r);this.enableShapeUniforms?i+=` + `;else{const l=Bt("coords",r);this.enableShapeUniforms?i+=` bool nextRowOutOfBounds = (${l[r-2]} + 1) >= outShape[${r} - 2]; bool nextColOutOfBounds = @@ -12788,7 +12788,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function en(n){const{inputs:e,backend:t}=n,{x:s}=e;return t.incRef(s.dataId),{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}const nB={kernelName:zr,backendName:"webgl",kernelFunc:en};/** + */function en(n){const{inputs:e,backend:t}=n,{x:s}=e;return t.incRef(s.dataId),{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}const oB={kernelName:zr,backendName:"webgl",kernelFunc:en};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12803,7 +12803,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ps(n){const{inputs:e,backend:t}=n,{real:s,imag:o}=e,r=t.makeTensorInfo(s.shape,"complex64"),i=t.texData.get(r.dataId),a=en({inputs:{x:s},backend:t}),l=en({inputs:{x:o},backend:t});return i.complexTensorInfos={real:a,imag:l},r}const sB={kernelName:Zc,backendName:"webgl",kernelFunc:Ps};/** + */function Ps(n){const{inputs:e,backend:t}=n,{real:s,imag:o}=e,r=t.makeTensorInfo(s.shape,"complex64"),i=t.texData.get(r.dataId),a=en({inputs:{x:s},backend:t}),l=en({inputs:{x:o},backend:t});return i.complexTensorInfos={real:a,imag:l},r}const rB={kernelName:Qc,backendName:"webgl",kernelFunc:Ps};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12818,10 +12818,10 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const hy="return (a < 0.) ? b * a : a;",dy=` + */const fy="return (a < 0.) ? b * a : a;",my=` vec4 aLessThanZero = vec4(lessThan(a, vec4(0.))); return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); -`;function oB(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{alpha:r}=s,i=t.makeTensorInfo([],"float32",xs(r,"float32")),a=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new fr(dy,o.shape,i.shape):new ko(hy,o.shape,i.shape),l=t.runWebGLProgram(a,[o,i],"float32");return t.disposeIntermediateTensorInfo(i),l}const rB={kernelName:Ea,backendName:"webgl",kernelFunc:oB};/** +`;function iB(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{alpha:r}=s,i=t.makeTensorInfo([],"float32",xs(r,"float32")),a=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new fr(my,o.shape,i.shape):new So(fy,o.shape,i.shape),l=t.runWebGLProgram(a,[o,i],"float32");return t.disposeIntermediateTensorInfo(i),l}const aB={kernelName:Ea,backendName:"webgl",kernelFunc:iB};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12836,10 +12836,10 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const py="return (a < 0.) ? b * a : a;",fy=` + */const gy="return (a < 0.) ? b * a : a;",xy=` vec4 aLessThanZero = vec4(lessThan(a, vec4(0.))); return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); -`;function iB(n){const{inputs:e,backend:t}=n,{x:s,alpha:o}=e,r=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new fr(fy,s.shape,o.shape):new ko(py,s.shape,o.shape);return t.runWebGLProgram(r,[s,o],"float32")}const aB={kernelName:Ka,backendName:"webgl",kernelFunc:iB};/** +`;function lB(n){const{inputs:e,backend:t}=n,{x:s,alpha:o}=e,r=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new fr(xy,s.shape,o.shape):new So(gy,s.shape,o.shape);return t.runWebGLProgram(r,[s,o],"float32")}const cB={kernelName:Ka,backendName:"webgl",kernelFunc:lB};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12854,7 +12854,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const mr="if (isnan(x)) return x;";function Re({opSnippet:n,packedOpSnippet:e,cpuKernelImpl:t,dtype:s}){return({inputs:o,backend:r})=>{const{x:i}=o,a=r,l=s||i.dtype;if(a.shouldExecuteOnCPU([i])&&t!=null){const h=a.texData.get(i.dataId),d=t(h.values,l);return a.makeTensorInfo(i.shape,l,d)}const c=W().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&e!=null;let u;return c?u=new Ms(i.shape,e):u=new ts(i.shape,n),a.runWebGLProgram(u,[i],l)}}function vt({opSnippet:n,packedOpSnippet:e,checkOutOfBounds:t=!1,supportsComplex:s=!1,cpuKernelImpl:o,dtype:r}){return({inputs:i,backend:a})=>{const{a:l,b:c}=i,u=a;if(s&&l.dtype==="complex64"){const f=u.texData.get(l.dataId),g=u.texData.get(c.dataId),[m,x]=[[f.complexTensorInfos.real,g.complexTensorInfos.real],[f.complexTensorInfos.imag,g.complexTensorInfos.imag]].map(w=>{const[y,C]=w,I={dataId:y.dataId,dtype:y.dtype,shape:l.shape},v={dataId:C.dataId,dtype:C.dtype,shape:c.shape},k=new ko(n,l.shape,c.shape);return u.runWebGLProgram(k,[I,v],Yt(y.dtype,C.dtype))}),b=Ps({inputs:{real:m,imag:x},backend:u});return u.disposeIntermediateTensorInfo(m),u.disposeIntermediateTensorInfo(x),b}const h=r||Yt(l.dtype,c.dtype);if((l.dtype==="string"||c.dtype==="string"||u.shouldExecuteOnCPU([l,c]))&&o!=null){const f=u.texData.get(l.dataId).values,g=u.texData.get(c.dataId).values,m=l.dtype==="string"?us(f):f,x=l.dtype==="string"?us(g):g,[b,w]=o(l.shape,c.shape,m,x,h),y=u.makeTensorInfo(w,h),C=u.texData.get(y.dataId);return C.values=b,y}const d=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&e!=null;let p;return d?p=new fr(e,l.shape,c.shape,t):p=new ko(n,l.shape,c.shape),u.runWebGLProgram(p,[l,c],h)}}function ta(n,e=!1){if(n==="linear")return e?W3:M3;if(n==="relu")return e?G3:B3;if(n==="elu")return e?U3:P3;if(n==="relu6")return e?H3:z3;if(n==="prelu")return e?fy:py;if(n==="leakyrelu")return e?dy:hy;if(n==="sigmoid")return e?j3:V3;throw new Error(`Activation ${n} has not been implemented for the WebGL backend.`)}/** + */const mr="if (isnan(x)) return x;";function Re({opSnippet:n,packedOpSnippet:e,cpuKernelImpl:t,dtype:s}){return({inputs:o,backend:r})=>{const{x:i}=o,a=r,l=s||i.dtype;if(a.shouldExecuteOnCPU([i])&&t!=null){const h=a.texData.get(i.dataId),d=t(h.values,l);return a.makeTensorInfo(i.shape,l,d)}const c=W().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&e!=null;let u;return c?u=new Ms(i.shape,e):u=new ts(i.shape,n),a.runWebGLProgram(u,[i],l)}}function vt({opSnippet:n,packedOpSnippet:e,checkOutOfBounds:t=!1,supportsComplex:s=!1,cpuKernelImpl:o,dtype:r}){return({inputs:i,backend:a})=>{const{a:l,b:c}=i,u=a;if(s&&l.dtype==="complex64"){const f=u.texData.get(l.dataId),g=u.texData.get(c.dataId),[m,x]=[[f.complexTensorInfos.real,g.complexTensorInfos.real],[f.complexTensorInfos.imag,g.complexTensorInfos.imag]].map(w=>{const[y,C]=w,I={dataId:y.dataId,dtype:y.dtype,shape:l.shape},v={dataId:C.dataId,dtype:C.dtype,shape:c.shape},k=new So(n,l.shape,c.shape);return u.runWebGLProgram(k,[I,v],Yt(y.dtype,C.dtype))}),b=Ps({inputs:{real:m,imag:x},backend:u});return u.disposeIntermediateTensorInfo(m),u.disposeIntermediateTensorInfo(x),b}const h=r||Yt(l.dtype,c.dtype);if((l.dtype==="string"||c.dtype==="string"||u.shouldExecuteOnCPU([l,c]))&&o!=null){const f=u.texData.get(l.dataId).values,g=u.texData.get(c.dataId).values,m=l.dtype==="string"?us(f):f,x=l.dtype==="string"?us(g):g,[b,w]=o(l.shape,c.shape,m,x,h),y=u.makeTensorInfo(w,h),C=u.texData.get(y.dataId);return C.values=b,y}const d=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&e!=null;let p;return d?p=new fr(e,l.shape,c.shape,t):p=new So(n,l.shape,c.shape),u.runWebGLProgram(p,[l,c],h)}}function ta(n,e=!1){if(n==="linear")return e?G3:B3;if(n==="relu")return e?q3:V3;if(n==="elu")return e?H3:z3;if(n==="relu6")return e?j3:W3;if(n==="prelu")return e?xy:gy;if(n==="leakyrelu")return e?my:fy;if(n==="sigmoid")return e?K3:U3;throw new Error(`Activation ${n} has not been implemented for the WebGL backend.`)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12869,7 +12869,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class my{constructor(e,t,s,o=!1,r=!1,i=!1,a=null,l=!1,c=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=s,this.enableShapeUniforms=At(this.outputShape.length);const u=o?e[1]:e[2],h=Math.ceil(u/2),d=o?"i * 2, rc.y":"rc.y, i * 2",p=r?"rc.z, i * 2":"i * 2, rc.z",f=o?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],g=r?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let m="",x="";a&&(l?m=`vec4 activation(vec4 a) { + */class by{constructor(e,t,s,o=!1,r=!1,i=!1,a=null,l=!1,c=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=s,this.enableShapeUniforms=Ft(this.outputShape.length);const u=o?e[1]:e[2],h=Math.ceil(u/2),d=o?"i * 2, rc.y":"rc.y, i * 2",p=r?"rc.z, i * 2":"i * 2, rc.z",f=o?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],g=r?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let m="",x="";a&&(l?m=`vec4 activation(vec4 a) { vec4 b = getPreluActivationWeightsAtOutCoords(); ${a} }`:c?m=`vec4 activation(vec4 a) { @@ -12923,7 +12923,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const gy={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"};class xy{constructor(e,t,s){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=we(t,s),this.userCode=` + */const yy={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"};class wy{constructor(e,t,s){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=we(t,s),this.userCode=` float binaryOpComplex( float areal, float aimag, float breal, float bimag) { ${e} @@ -12951,7 +12951,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const by="return a * b;";function Cp(n){const{inputs:e,backend:t}=n,{a:s,b:o}=e,r=Yt(s.dtype,o.dtype);if(s.dtype==="complex64"){const a=t.texData.get(s.dataId),l=t.texData.get(o.dataId),c=new xy(gy.REAL,s.shape,o.shape),u=new xy(gy.IMAG,s.shape,o.shape),h=[{dataId:a.complexTensorInfos.real.dataId,dtype:a.complexTensorInfos.real.dtype,shape:s.shape},{dataId:a.complexTensorInfos.imag.dataId,dtype:a.complexTensorInfos.imag.dtype,shape:s.shape},{dataId:l.complexTensorInfos.real.dataId,dtype:l.complexTensorInfos.real.dtype,shape:o.shape},{dataId:l.complexTensorInfos.imag.dataId,dtype:l.complexTensorInfos.imag.dtype,shape:o.shape}],d=t.runWebGLProgram(c,h,"float32"),p=t.runWebGLProgram(u,h,"float32"),f=Ps({inputs:{real:d,imag:p},backend:t});return t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),f}if(t.shouldExecuteOnCPU([s,o])){const a=t.texData.get(s.dataId),l=t.texData.get(o.dataId),[c,u]=i3(s.shape,o.shape,a.values,l.values,r),h=t.makeTensorInfo(u,r),d=t.texData.get(h.dataId);return d.values=c,h}let i;return W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?i=new fr(by,s.shape,o.shape):i=new ko(by,s.shape,o.shape),t.runWebGLProgram(i,[s,o],r)}const lB={kernelName:Xr,backendName:"webgl",kernelFunc:Cp};/** + */const Cy="return a * b;";function Cp(n){const{inputs:e,backend:t}=n,{a:s,b:o}=e,r=Yt(s.dtype,o.dtype);if(s.dtype==="complex64"){const a=t.texData.get(s.dataId),l=t.texData.get(o.dataId),c=new wy(yy.REAL,s.shape,o.shape),u=new wy(yy.IMAG,s.shape,o.shape),h=[{dataId:a.complexTensorInfos.real.dataId,dtype:a.complexTensorInfos.real.dtype,shape:s.shape},{dataId:a.complexTensorInfos.imag.dataId,dtype:a.complexTensorInfos.imag.dtype,shape:s.shape},{dataId:l.complexTensorInfos.real.dataId,dtype:l.complexTensorInfos.real.dtype,shape:o.shape},{dataId:l.complexTensorInfos.imag.dataId,dtype:l.complexTensorInfos.imag.dtype,shape:o.shape}],d=t.runWebGLProgram(c,h,"float32"),p=t.runWebGLProgram(u,h,"float32"),f=Ps({inputs:{real:d,imag:p},backend:t});return t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),f}if(t.shouldExecuteOnCPU([s,o])){const a=t.texData.get(s.dataId),l=t.texData.get(o.dataId),[c,u]=l3(s.shape,o.shape,a.values,l.values,r),h=t.makeTensorInfo(u,r),d=t.texData.get(h.dataId);return d.values=c,h}let i;return W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?i=new fr(Cy,s.shape,o.shape):i=new So(Cy,s.shape,o.shape),t.runWebGLProgram(i,[s,o],r)}const uB={kernelName:Xr,backendName:"webgl",kernelFunc:Cp};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12966,7 +12966,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function cB(n,e,t){const s=[lr(n.shape),...cr(n.shape)],o={dtype:n.dtype,shape:s,dataId:n.dataId},r=[lr(e),...cr(e)],i=new iy(r,s),a=!0,l=[s],c=t.runWebGLProgram(i,[o],n.dtype,l,a);return{dataId:c.dataId,shape:e,dtype:c.dtype}}/** + */function hB(n,e,t){const s=[lr(n.shape),...cr(n.shape)],o={dtype:n.dtype,shape:s,dataId:n.dataId},r=[lr(e),...cr(e)],i=new cy(r,s),a=!0,l=[s],c=t.runWebGLProgram(i,[o],n.dtype,l,a);return{dataId:c.dataId,shape:e,dtype:c.dtype}}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12981,7 +12981,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ne(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{shape:r}=s,i=t,a=H(o.shape),l=Pp(r,a),c=H(l);$(a===c,()=>`The new shape (${l}) has ${c} elements and the old shape (${o.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`);const u=i.texData.get(o.dataId);return u.isPacked&&!gc(o.shape,l)&&!(u.texture!==null&&gc(u.shape,l))?cB(o,l,i):(i.incRef(o.dataId),{dataId:o.dataId,shape:l,dtype:o.dtype})}const uB={kernelName:Ya,backendName:"webgl",kernelFunc:ne};/** + */function ne(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{shape:r}=s,i=t,a=H(o.shape),l=Pp(r,a),c=H(l);$(a===c,()=>`The new shape (${l}) has ${c} elements and the old shape (${o.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`);const u=i.texData.get(o.dataId);return u.isPacked&&!xc(o.shape,l)&&!(u.texture!==null&&xc(u.shape,l))?hB(o,l,i):(i.incRef(o.dataId),{dataId:o.dataId,shape:l,dtype:o.dtype})}const dB={kernelName:Ya,backendName:"webgl",kernelFunc:ne};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12996,7 +12996,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class yy{constructor(e,t){this.variableNames=["x"];const{windowSize:s,batchSize:o,inSize:r,outSize:i}=e;this.outputShape=[o,i];const a=Math.floor(s/4)*4,l=s%4;let c="sumValue += dot(values, ones);";if(t!=null){const h=1/t;c=`sumValue += dot(values * ${Ao(h)?h.toPrecision(2):h}, ones);`}let u="";r%s>0&&(u=` + */class Iy{constructor(e,t){this.variableNames=["x"];const{windowSize:s,batchSize:o,inSize:r,outSize:i}=e;this.outputShape=[o,i];const a=Math.floor(s/4)*4,l=s%4;let c="sumValue += dot(values, ones);";if(t!=null){const h=1/t;c=`sumValue += dot(values * ${Do(h)?h.toPrecision(2):h}, ones);`}let u="";r%s>0&&(u=` if (inIdx < 0 || inIdx >= ${r}) { return 0.0; } @@ -13064,7 +13064,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class hB{constructor(e,t){this.variableNames=["x"];const{windowSize:s,batchSize:o,inSize:r,outSize:i}=e;this.outputShape=[o,i];let a="0.0",l="";t==="prod"?a="1.0":t==="min"?(a="1.0 / 1e-20",l="min"):t==="max"&&(a="-1.0 / 1e-20",l="max");let c=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="sum"?c="sumValue":t==="prod"?c="prodValue":t==="all"?c="allValue":t==="any"&&(c="anyValue");const u=Math.floor(s/4)*4,h=s%4;let d=` + */class pB{constructor(e,t){this.variableNames=["x"];const{windowSize:s,batchSize:o,inSize:r,outSize:i}=e;this.outputShape=[o,i];let a="0.0",l="";t==="prod"?a="1.0":t==="min"?(a="1.0 / 1e-20",l="min"):t==="max"&&(a="-1.0 / 1e-20",l="max");let c=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="sum"?c="sumValue":t==="prod"?c="prodValue":t==="all"?c="allValue":t==="any"&&(c="anyValue");const u=Math.floor(s/4)*4,h=s%4;let d=` if (${t==="sum"}) { sumValue += dot(values, ones); } else if (${t==="prod"}) { @@ -13171,7 +13171,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function dB(n){const e=[];for(;e.length===0||e[e.length-1].outSize!==1;){const t=e.length?e[e.length-1].outSize:n[1],s=Rl(t);e.push({inSize:t,windowSize:s,outSize:Math.ceil(t/s)})}return e}function To(n,e,t,s){const o=dB(n.shape);let r=n;for(let i=0;i6)throw Error(`Transpose for rank ${e} is not yet supported`);const t=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],s=new Array(e);for(let o=0;o6)throw Error(`Transpose for rank ${e} is not yet supported`);const t=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],s=new Array(e);for(let o=0;o6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const o=Be(this.rank),r=ry("rc",this.rank),i=new Array(this.rank);for(let u=0;u6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const o=Be(this.rank),r=ly("rc",this.rank),i=new Array(this.rank);for(let u=0;u`Error in matMul: inner shapes (${h}) and (${d}) of Tensors with shapes ${n.shape} and ${e.shape} and transposeA=${t} and transposeB=${s} must match.`);const C=t?[x,h,p]:[x,p,h],I=s?[b,f,d]:[b,d,f],v=ne({inputs:{x:n},backend:o,attrs:{shape:C}}),k=ne({inputs:{x:e},backend:o,attrs:{shape:I}}),S=[v,k],T=Math.max(x,b),E=t?v.shape[1]:v.shape[2],V=r!=null,M=i!=null,L=l==="leakyrelu",R=l!=null?ta(l,!0):null,P=V||M||L||R!=null;let G;if((p===1||f===1)&&E>wy&&P===!1){let j=v,K=k;t&&(j=Bt({inputs:{x:v},backend:o,attrs:{perm:[0,2,1]}}),S.push(j)),s&&(K=Bt({inputs:{x:k},backend:o,attrs:{perm:[0,2,1]}}),S.push(K));const X=f!==1,J=f===1;let q=j;X&&(q=ne({inputs:{x:j},backend:o,attrs:{shape:[T,E,1]}}),S.push(q));const Q=f===1?2:1;let Y=K;J&&(Y=ne({inputs:{x:K},backend:o,attrs:{shape:[T,1,E]}}),S.push(Y));const te=Cp({inputs:{a:q,b:Y},backend:o});G=Cc({inputs:{x:te},backend:o,attrs:{axis:Q,keepDims:!0}}),S.push(te)}else{const j=Yt(n.dtype,e.dtype),K=new my(C,I,[T,p,f],t,s,V,R,M,L),X=[v,k];if(r!=null&&X.push(r),M&&X.push(i),L){const J=o.makeTensorInfo([],"float32",xs(a,"float32"));X.push(J),S.push(J)}G=o.runWebGLProgram(K,X,j)}const B=ne({inputs:{x:G},backend:o,attrs:{shape:y}});S.push(G);for(const j of S)o.disposeIntermediateTensorInfo(j);return B}/** + */const $y=1e3;function $c({a:n,b:e,transposeA:t,transposeB:s,backend:o,bias:r=null,preluActivationWeights:i=null,leakyreluAlpha:a=0,activation:l=null}){const c=n.shape.length,u=e.shape.length,h=t?n.shape[c-2]:n.shape[c-1],d=s?e.shape[u-1]:e.shape[u-2],p=t?n.shape[c-1]:n.shape[c-2],f=s?e.shape[u-2]:e.shape[u-1],g=n.shape.slice(0,-2),m=e.shape.slice(0,-2),x=H(g),b=H(m),y=we(n.shape.slice(0,-2),e.shape.slice(0,-2)).concat([p,f]);$(h===d,()=>`Error in matMul: inner shapes (${h}) and (${d}) of Tensors with shapes ${n.shape} and ${e.shape} and transposeA=${t} and transposeB=${s} must match.`);const C=t?[x,h,p]:[x,p,h],I=s?[b,f,d]:[b,d,f],v=ne({inputs:{x:n},backend:o,attrs:{shape:C}}),k=ne({inputs:{x:e},backend:o,attrs:{shape:I}}),S=[v,k],T=Math.max(x,b),E=t?v.shape[1]:v.shape[2],V=r!=null,M=i!=null,L=l==="leakyrelu",R=l!=null?ta(l,!0):null,B=V||M||L||R!=null;let G;if((p===1||f===1)&&E>$y&&B===!1){let q=v,K=k;t&&(q=zt({inputs:{x:v},backend:o,attrs:{perm:[0,2,1]}}),S.push(q)),s&&(K=zt({inputs:{x:k},backend:o,attrs:{perm:[0,2,1]}}),S.push(K));const X=f!==1,J=f===1;let j=q;X&&(j=ne({inputs:{x:q},backend:o,attrs:{shape:[T,E,1]}}),S.push(j));const Q=f===1?2:1;let Z=K;J&&(Z=ne({inputs:{x:K},backend:o,attrs:{shape:[T,1,E]}}),S.push(Z));const te=Cp({inputs:{a:j,b:Z},backend:o});G=Ic({inputs:{x:te},backend:o,attrs:{axis:Q,keepDims:!0}}),S.push(te)}else{const q=Yt(n.dtype,e.dtype),K=new by(C,I,[T,p,f],t,s,V,R,M,L),X=[v,k];if(r!=null&&X.push(r),M&&X.push(i),L){const J=o.makeTensorInfo([],"float32",xs(a,"float32"));X.push(J),S.push(J)}G=o.runWebGLProgram(K,X,q)}const z=ne({inputs:{x:G},backend:o,attrs:{shape:y}});S.push(G);for(const q of S)o.disposeIntermediateTensorInfo(q);return z}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -13313,7 +13313,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function yB(n){const{inputs:e,backend:t,attrs:s}=n,{a:o,b:r,bias:i,preluActivationWeights:a}=e,{transposeA:l,transposeB:c,activation:u,leakyreluAlpha:h}=s;return Ic({a:o,b:r,transposeA:l,transposeB:c,backend:t,bias:i,preluActivationWeights:a,leakyreluAlpha:h,activation:u})}const wB={kernelName:cl,backendName:"webgl",kernelFunc:yB};/** + */function CB(n){const{inputs:e,backend:t,attrs:s}=n,{a:o,b:r,bias:i,preluActivationWeights:a}=e,{transposeA:l,transposeB:c,activation:u,leakyreluAlpha:h}=s;return $c({a:o,b:r,transposeA:l,transposeB:c,backend:t,bias:i,preluActivationWeights:a,leakyreluAlpha:h,activation:u})}const IB={kernelName:cl,backendName:"webgl",kernelFunc:CB};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13328,7 +13328,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Cy="return abs(x);";function CB(n){const{inputs:e,backend:t}=n,{x:s}=e;if(t.shouldExecuteOnCPU([s])&&s.dtype!=="complex64"){const r=t.texData.get(s.dataId),i=sy(r.values);return t.makeTensorInfo(s.shape,s.dtype,i)}let o;return W().getBool("WEBGL_PACK_UNARY_OPERATIONS")?o=new Ms(s.shape,Cy):o=new ts(s.shape,Cy),t.runWebGLProgram(o,[s],s.dtype)}const IB={kernelName:ca,backendName:"webgl",kernelFunc:CB};/** + */const vy="return abs(x);";function $B(n){const{inputs:e,backend:t}=n,{x:s}=e;if(t.shouldExecuteOnCPU([s])&&s.dtype!=="complex64"){const r=t.texData.get(s.dataId),i=iy(r.values);return t.makeTensorInfo(s.shape,s.dtype,i)}let o;return W().getBool("WEBGL_PACK_UNARY_OPERATIONS")?o=new Ms(s.shape,vy):o=new ts(s.shape,vy),t.runWebGLProgram(o,[s],s.dtype)}const vB={kernelName:ca,backendName:"webgl",kernelFunc:$B};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13343,12 +13343,12 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const $B=In+` + */const kB=In+` if (abs(x) > 1.) { return NAN; } return acos(x); -`,vB=Re({opSnippet:$B}),kB={kernelName:wr,backendName:"webgl",kernelFunc:vB};/** +`,SB=Re({opSnippet:kB}),TB={kernelName:wr,backendName:"webgl",kernelFunc:SB};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13363,9 +13363,9 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const SB=In+` + */const NB=In+` if (x < 1.0) return NAN; -return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,backendName:"webgl",kernelFunc:TB};/** +return log(x + sqrt(x * x - 1.0));`,EB=Re({opSnippet:NB}),RB={kernelName:Cr,backendName:"webgl",kernelFunc:EB};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13380,7 +13380,7 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Iy="return a + b;",EB=vt({opSnippet:Iy,packedOpSnippet:Iy,supportsComplex:!0,cpuKernelImpl:BP}),RB={kernelName:Oo,backendName:"webgl",kernelFunc:EB};/** + */const ky="return a + b;",AB=vt({opSnippet:ky,packedOpSnippet:ky,supportsComplex:!0,cpuKernelImpl:VP}),DB={kernelName:Lo,backendName:"webgl",kernelFunc:AB};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13395,7 +13395,7 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class AB{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((r,i)=>`T${i}`);const s=[];this.variableNames.forEach(r=>{s.push(`float v${r} = get${r}AtOutCoords();`)});const o=this.variableNames.map(r=>`v${r}`).join(" + ");this.userCode=` + */class FB{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((r,i)=>`T${i}`);const s=[];this.variableNames.forEach(r=>{s.push(`float v${r} = get${r}AtOutCoords();`)});const o=this.variableNames.map(r=>`v${r}`).join(" + ");this.userCode=` void main() { ${s.join(` `)} @@ -13418,7 +13418,7 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class DB{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((r,i)=>`T${i}`);const s=[];this.variableNames.forEach(r=>{s.push(`vec4 v${r} = get${r}AtOutCoords();`)});const o=this.variableNames.map(r=>`v${r}`).join(" + ");this.userCode=` + */class _B{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((r,i)=>`T${i}`);const s=[];this.variableNames.forEach(r=>{s.push(`vec4 v${r} = get${r}AtOutCoords();`)});const o=this.variableNames.map(r=>`v${r}`).join(" + ");this.userCode=` void main() { ${s.join(` `)} @@ -13441,7 +13441,7 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $c(n){const{inputs:e,backend:t}=n,s=e;if(s.length===1)return en({inputs:{x:s[0]},backend:t});if(s.length>W().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){const l=Math.floor(s.length/2),c=$c({inputs:s.slice(0,l),backend:t}),u=$c({inputs:s.slice(l),backend:t});return $c({inputs:[c,u],backend:t})}const o=s.map(l=>l.dtype).reduce((l,c)=>Yt(l,c)),r=s.map(l=>l.shape),a=W().getBool("WEBGL_PACK")?new DB(s[0].shape,r):new AB(s[0].shape,r);return t.runWebGLProgram(a,s,o)}const FB={kernelName:Gc,backendName:"webgl",kernelFunc:$c};/** + */function vc(n){const{inputs:e,backend:t}=n,s=e;if(s.length===1)return en({inputs:{x:s[0]},backend:t});if(s.length>W().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){const l=Math.floor(s.length/2),c=vc({inputs:s.slice(0,l),backend:t}),u=vc({inputs:s.slice(l),backend:t});return vc({inputs:[c,u],backend:t})}const o=s.map(l=>l.dtype).reduce((l,c)=>Yt(l,c)),r=s.map(l=>l.shape),a=W().getBool("WEBGL_PACK")?new _B(s[0].shape,r):new FB(s[0].shape,r);return t.runWebGLProgram(a,s,o)}const OB={kernelName:Hc,backendName:"webgl",kernelFunc:vc};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13456,7 +13456,7 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _B(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,keepDims:i}=s,a=o.shape.length,l=$e(r,o.shape);let c=l;const u=Ye(c,a);let h=o;u!=null&&(h=Bt({inputs:{x:o},backend:t,attrs:{perm:u}}),c=tt(c.length,a)),It("all",c,a);const[d,p]=xt(h.shape,c),f=H(p),g=ne({inputs:{x:h},backend:t,attrs:{shape:[-1,f]}}),m=To(g,g.dtype,"all",t);let x;if(i){const b=it(d,l);x=ne({inputs:{x:m},backend:t,attrs:{shape:b}})}else x=ne({inputs:{x:m},backend:t,attrs:{shape:d}});return t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(m),u!=null&&t.disposeIntermediateTensorInfo(h),x}const OB={kernelName:Hc,backendName:"webgl",kernelFunc:_B};/** + */function LB(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,keepDims:i}=s,a=o.shape.length,l=$e(r,o.shape);let c=l;const u=Ye(c,a);let h=o;u!=null&&(h=zt({inputs:{x:o},backend:t,attrs:{perm:u}}),c=tt(c.length,a)),It("all",c,a);const[d,p]=xt(h.shape,c),f=H(p),g=ne({inputs:{x:h},backend:t,attrs:{shape:[-1,f]}}),m=No(g,g.dtype,"all",t);let x;if(i){const b=it(d,l);x=ne({inputs:{x:m},backend:t,attrs:{shape:b}})}else x=ne({inputs:{x:m},backend:t,attrs:{shape:d}});return t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(m),u!=null&&t.disposeIntermediateTensorInfo(h),x}const MB={kernelName:qc,backendName:"webgl",kernelFunc:LB};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13471,7 +13471,7 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function LB(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,keepDims:i}=s,a=o.shape.length,l=$e(r,o.shape);let c=l;const u=Ye(c,a);let h=o;u!=null&&(h=Bt({inputs:{x:o},backend:t,attrs:{perm:u}}),c=tt(c.length,a)),It("any",c,a);const[d,p]=xt(h.shape,c),f=H(p),g=ne({inputs:{x:h},backend:t,attrs:{shape:[-1,f]}}),m=To(g,g.dtype,"any",t);let x;if(i){const b=it(d,l);x=ne({inputs:{x:m},backend:t,attrs:{shape:b}})}else x=ne({inputs:{x:m},backend:t,attrs:{shape:d}});return t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(m),u!=null&&t.disposeIntermediateTensorInfo(h),x}const MB={kernelName:jc,backendName:"webgl",kernelFunc:LB};/** + */function PB(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,keepDims:i}=s,a=o.shape.length,l=$e(r,o.shape);let c=l;const u=Ye(c,a);let h=o;u!=null&&(h=zt({inputs:{x:o},backend:t,attrs:{perm:u}}),c=tt(c.length,a)),It("any",c,a);const[d,p]=xt(h.shape,c),f=H(p),g=ne({inputs:{x:h},backend:t,attrs:{shape:[-1,f]}}),m=No(g,g.dtype,"any",t);let x;if(i){const b=it(d,l);x=ne({inputs:{x:m},backend:t,attrs:{shape:b}})}else x=ne({inputs:{x:m},backend:t,attrs:{shape:d}});return t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(m),u!=null&&t.disposeIntermediateTensorInfo(h),x}const BB={kernelName:jc,backendName:"webgl",kernelFunc:PB};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13486,7 +13486,7 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class PB{constructor(e,t,s){this.variableNames=["A"];const{windowSize:o,batchSize:r,outSize:i}=e;s||this.variableNames.push("bestIndicesA"),this.outputShape=[r,i];const a=t==="max"?">":"<",l=s?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=` + */class zB{constructor(e,t,s){this.variableNames=["A"];const{windowSize:o,batchSize:r,outSize:i}=e;s||this.variableNames.push("bestIndicesA"),this.outputShape=[r,i];const a=t==="max"?">":"<",l=s?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=` void main() { ivec2 coords = getOutputCoords(); int batch = coords[0]; @@ -13521,7 +13521,7 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class BB{constructor(e,t,s,o){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,$(e.length>2,()=>`Packed arg${s.charAt(0).toUpperCase()+s.slice(1)} supports only inputs with rank above 2.`);const r=e[e.length-1],i=Math.ceil(r/t);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),o||this.variableNames.push("bestIndicesA");const a=this.outputShape,l=a.length,c=Be(l),u=Pt("coords",l);let h,d;if(i===1){d=l+1;const k=Be(d);h=` + */class VB{constructor(e,t,s,o){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,$(e.length>2,()=>`Packed arg${s.charAt(0).toUpperCase()+s.slice(1)} supports only inputs with rank above 2.`);const r=e[e.length-1],i=Math.ceil(r/t);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),o||this.variableNames.push("bestIndicesA");const a=this.outputShape,l=a.length,c=Be(l),u=Bt("coords",l);let h,d;if(i===1){d=l+1;const k=Be(d);h=` ${k} sourceLocR = ${k}(${u.join()}, 0); ++${u[l-1]}; ${k} sourceLocG = ${k}(${u.join()}, 0); @@ -13537,7 +13537,7 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back ${c} sourceLocA = coords; --${u[l-1]}; ${c} sourceLocB = coords; - --${u[l-2]};`;const p=["x","y","z","w","u","v"].slice(0,d),f="."+p[d-1],g=p.map(k=>"int "+k),m=Pt("sourceLocR",d-1).concat("inIdx.r"),x=Pt("sourceLocG",d-1).concat("inIdx.g"),b=Pt("sourceLocB",d-1).concat("inIdx.b"),w=Pt("sourceLocA",d-1).concat("inIdx.a"),y=s==="max"?"greaterThan":"lessThan",C=o?"":` + --${u[l-2]};`;const p=["x","y","z","w","u","v"].slice(0,d),f="."+p[d-1],g=p.map(k=>"int "+k),m=Bt("sourceLocR",d-1).concat("inIdx.r"),x=Bt("sourceLocG",d-1).concat("inIdx.g"),b=Bt("sourceLocB",d-1).concat("inIdx.b"),w=Bt("sourceLocA",d-1).concat("inIdx.a"),y=s==="max"?"greaterThan":"lessThan",C=o?"":` inIdx = round(vec4(getBestIndicesAChannel(${m.join()}), getBestIndicesAChannel(${x.join()}), getBestIndicesAChannel(${b.join()}), @@ -13598,7 +13598,7 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $y(n,e,t,s=null){let o=e.shape[0],r=e.shape[1];s!=null&&(o=s.shape[0],r=s.shape[1]);const i=Rl(r),a={windowSize:i,inSize:r,batchSize:o,outSize:Math.ceil(r/i)},l=new PB(a,t,s==null),c=[e];s!=null&&c.push(s);const u=n.runWebGLProgram(l,c,"int32");if(u.shape[1]===1)return u;const h=$y(n,e,t,u);return n.disposeIntermediateTensorInfo(u),h}function vy(n,e,t,s=null){const o=s!=null?s.shape:e.shape,r=o[o.length-1],i=Rl(r),a=new BB(o,i,t,s==null),l=s==null?[e]:[e,s],c=n.runWebGLProgram(a,l,"int32");if(c.shape.length===e.shape.length){const u=vy(n,e,t,c);return n.disposeIntermediateTensorInfo(c),u}return c}function ky(n,e,t,s){const o=[t];if(It("arg"+s.charAt(0).toUpperCase()+s.slice(1),o,e.shape.length),!W().getBool("WEBGL_PACK_REDUCE")||e.shape.length<=2){const r=[],i=n.texData.get(e.dataId),a=i!==null&&i.isPacked;let l=e;a&&(l=n.unpackTensor(e),r.push(l));const[c,u]=xt(l.shape,o),h=H(u),d=ne({inputs:{x:l},backend:n,attrs:{shape:[-1,h]}});r.push(d);const p=$y(n,d,s);r.push(p);const f=ne({inputs:{x:p},backend:n,attrs:{shape:c}});return r.forEach(g=>n.disposeIntermediateTensorInfo(g)),f}return vy(n,e,s)}/** + */function Sy(n,e,t,s=null){let o=e.shape[0],r=e.shape[1];s!=null&&(o=s.shape[0],r=s.shape[1]);const i=Al(r),a={windowSize:i,inSize:r,batchSize:o,outSize:Math.ceil(r/i)},l=new zB(a,t,s==null),c=[e];s!=null&&c.push(s);const u=n.runWebGLProgram(l,c,"int32");if(u.shape[1]===1)return u;const h=Sy(n,e,t,u);return n.disposeIntermediateTensorInfo(u),h}function Ty(n,e,t,s=null){const o=s!=null?s.shape:e.shape,r=o[o.length-1],i=Al(r),a=new VB(o,i,t,s==null),l=s==null?[e]:[e,s],c=n.runWebGLProgram(a,l,"int32");if(c.shape.length===e.shape.length){const u=Ty(n,e,t,c);return n.disposeIntermediateTensorInfo(c),u}return c}function Ny(n,e,t,s){const o=[t];if(It("arg"+s.charAt(0).toUpperCase()+s.slice(1),o,e.shape.length),!W().getBool("WEBGL_PACK_REDUCE")||e.shape.length<=2){const r=[],i=n.texData.get(e.dataId),a=i!==null&&i.isPacked;let l=e;a&&(l=n.unpackTensor(e),r.push(l));const[c,u]=xt(l.shape,o),h=H(u),d=ne({inputs:{x:l},backend:n,attrs:{shape:[-1,h]}});r.push(d);const p=Sy(n,d,s);r.push(p);const f=ne({inputs:{x:p},backend:n,attrs:{shape:c}});return r.forEach(g=>n.disposeIntermediateTensorInfo(g)),f}return Ty(n,e,s)}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13613,7 +13613,7 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function zB(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r}=s;let i=$e(r,o.shape);const a=Ye(i,o.shape.length);let l=o;const c=[];a!=null&&(l=Bt({inputs:{x:o},backend:t,attrs:{perm:a}}),c.push(l),i=tt(i.length,l.shape.length)),It("argMax",[i[0]],l.shape.length);const u=ky(t,l,i[0],"max");return c.forEach(h=>t.disposeIntermediateTensorInfo(h)),u}const VB={kernelName:ua,backendName:"webgl",kernelFunc:zB};/** + */function WB(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r}=s;let i=$e(r,o.shape);const a=Ye(i,o.shape.length);let l=o;const c=[];a!=null&&(l=zt({inputs:{x:o},backend:t,attrs:{perm:a}}),c.push(l),i=tt(i.length,l.shape.length)),It("argMax",[i[0]],l.shape.length);const u=Ny(t,l,i[0],"max");return c.forEach(h=>t.disposeIntermediateTensorInfo(h)),u}const UB={kernelName:ua,backendName:"webgl",kernelFunc:WB};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13628,7 +13628,7 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function WB(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r}=s;let i=$e(r,o.shape);const a=Ye(i,o.shape.length);let l=o;const c=[];a!=null&&(l=Bt({inputs:{x:o},backend:t,attrs:{perm:a}}),c.push(l),i=tt(i.length,l.shape.length)),It("argMin",[i[0]],l.shape.length);const u=ky(t,l,i[0],"min");return c.forEach(h=>t.disposeIntermediateTensorInfo(h)),u}const UB={kernelName:ha,backendName:"webgl",kernelFunc:WB};/** + */function GB(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r}=s;let i=$e(r,o.shape);const a=Ye(i,o.shape.length);let l=o;const c=[];a!=null&&(l=zt({inputs:{x:o},backend:t,attrs:{perm:a}}),c.push(l),i=tt(i.length,l.shape.length)),It("argMin",[i[0]],l.shape.length);const u=Ny(t,l,i[0],"min");return c.forEach(h=>t.disposeIntermediateTensorInfo(h)),u}const HB={kernelName:ha,backendName:"webgl",kernelFunc:GB};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13643,12 +13643,12 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const GB=In+` + */const qB=In+` if (abs(x) > 1.) { return NAN; } return asin(x); -`,HB=Re({opSnippet:GB}),jB={kernelName:Ir,backendName:"webgl",kernelFunc:HB};/** +`,jB=Re({opSnippet:qB}),KB={kernelName:Ir,backendName:"webgl",kernelFunc:jB};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13663,7 +13663,7 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const qB=In+"return log(x + sqrt(x * x + 1.0));",KB=Re({opSnippet:qB}),XB={kernelName:$r,backendName:"webgl",kernelFunc:KB};/** + */const XB=In+"return log(x + sqrt(x * x + 1.0));",YB=Re({opSnippet:XB}),ZB={kernelName:$r,backendName:"webgl",kernelFunc:YB};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13678,9 +13678,9 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const YB=In+` + */const QB=In+` return atan(x); -`,ZB=Re({opSnippet:YB}),QB={kernelName:vr,backendName:"webgl",kernelFunc:ZB};/** +`,JB=Re({opSnippet:QB}),ez={kernelName:vr,backendName:"webgl",kernelFunc:JB};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13695,16 +13695,16 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const JB=wp+` + */const tz=wp+` return atan(a, b); -`,ez=` +`,nz=` vec4 result = atan(a, b); bvec4 isNaNA = isnan(a); bvec4 isNaNB = isnan(b); bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); - `+So+` + `+To+` return result; -`,tz=vt({opSnippet:JB,packedOpSnippet:ez}),nz={kernelName:Sr,backendName:"webgl",kernelFunc:tz};/** +`,sz=vt({opSnippet:tz,packedOpSnippet:nz}),oz={kernelName:Sr,backendName:"webgl",kernelFunc:sz};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13719,9 +13719,9 @@ return log(x + sqrt(x * x - 1.0));`,TB=Re({opSnippet:SB}),NB={kernelName:Cr,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const sz=In+` + */const rz=In+` if ((x < -1.0) || (x > 1.0)) return NAN; -return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelName:kr,backendName:"webgl",kernelFunc:oz};/** +return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,iz=Re({opSnippet:rz}),az={kernelName:kr,backendName:"webgl",kernelFunc:iz};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14055,7 +14055,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function iz(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e;Ji(o,"avgPool");const{filterSize:r,strides:i,pad:a,dimRoundingMode:l}=s,c=1;$(Et(i,c),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=pn(o.shape,r,i,c,a,l);if(u.filterWidth===1&&u.filterHeight===1&&Oe(u.inShape,u.outShape))return en({inputs:{x:o},backend:t});const h=new na(u,"avg",!1);return t.runWebGLProgram(h,[o],"float32")}const az={kernelName:da,backendName:"webgl",kernelFunc:iz};/** + */function lz(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e;Ji(o,"avgPool");const{filterSize:r,strides:i,pad:a,dimRoundingMode:l}=s,c=1;$(Et(i,c),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=pn(o.shape,r,i,c,a,l);if(u.filterWidth===1&&u.filterHeight===1&&Oe(u.inShape,u.outShape))return en({inputs:{x:o},backend:t});const h=new na(u,"avg",!1);return t.runWebGLProgram(h,[o],"float32")}const cz={kernelName:da,backendName:"webgl",kernelFunc:lz};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14070,7 +14070,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function lz(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{filterSize:r,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=s,u=[1,1,1],h=rs(o.shape,r,i,u,a,l,c),d=new Ip(h,"avg",!1);return t.runWebGLProgram(d,[o],"float32")}const cz={kernelName:pa,backendName:"webgl",kernelFunc:lz};/** + */function uz(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{filterSize:r,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=s,u=[1,1,1],h=rs(o.shape,r,i,u,a,l,c),d=new Ip(h,"avg",!1);return t.runWebGLProgram(d,[o],"float32")}const hz={kernelName:pa,backendName:"webgl",kernelFunc:uz};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14085,7 +14085,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class uz{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterHeight,s=e.filterWidth,o=e.strideHeight,r=e.strideWidth,i=e.dilationHeight,a=e.dilationWidth,l=e.effectiveFilterHeight,c=e.effectiveFilterWidth,u=l-1-e.padInfo.top,h=c-1-e.padInfo.left,d=1/(t*s);this.userCode=` + */class dz{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterHeight,s=e.filterWidth,o=e.strideHeight,r=e.strideWidth,i=e.dilationHeight,a=e.dilationWidth,l=e.effectiveFilterHeight,c=e.effectiveFilterWidth,u=l-1-e.padInfo.top,h=c-1-e.padInfo.left,d=1/(t*s);this.userCode=` const ivec2 pads = ivec2(${u}, ${h}); const float avgMultiplier = float(${d}); @@ -14127,7 +14127,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam } setOutput(dotProd); } - `}}class hz{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterDepth,s=e.filterHeight,o=e.filterWidth,r=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,u=e.dilationWidth,h=e.effectiveFilterDepth,d=e.effectiveFilterHeight,p=e.effectiveFilterWidth,f=h-1-e.padInfo.front,g=d-1-e.padInfo.top,m=p-1-e.padInfo.left,x=1/(t*s*o);this.userCode=` + `}}class pz{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterDepth,s=e.filterHeight,o=e.filterWidth,r=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,u=e.dilationWidth,h=e.effectiveFilterDepth,d=e.effectiveFilterHeight,p=e.effectiveFilterWidth,f=h-1-e.padInfo.front,g=d-1-e.padInfo.top,m=p-1-e.padInfo.left,x=1/(t*s*o);this.userCode=` const ivec3 pads = ivec3(${f}, ${g}, ${m}); const float avgMultiplier = float(${x}); @@ -14198,7 +14198,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function dz(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r}=e,i=r,{filterSize:a,strides:l,pad:c,dimRoundingMode:u}=s,h=[1,1,1],d=rs(i.shape,a,l,h,c,u),p=new hz(d);return t.runWebGLProgram(p,[o],i.dtype)}const pz={kernelName:Kc,backendName:"webgl",kernelFunc:dz};/** + */function fz(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r}=e,i=r,{filterSize:a,strides:l,pad:c,dimRoundingMode:u}=s,h=[1,1,1],d=rs(i.shape,a,l,h,c,u),p=new pz(d);return t.runWebGLProgram(p,[o],i.dtype)}const mz={kernelName:Xc,backendName:"webgl",kernelFunc:fz};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14213,7 +14213,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function fz(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r}=e,i=r;Ji([o,r],"avgPoolGrad");const{filterSize:a,strides:l,pad:c}=s,u=pn(i.shape,a,l,1,c),h=new uz(u);return t.runWebGLProgram(h,[o],i.dtype)}const mz={kernelName:qc,backendName:"webgl",kernelFunc:fz};/** + */function gz(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r}=e,i=r;Ji([o,r],"avgPoolGrad");const{filterSize:a,strides:l,pad:c}=s,u=pn(i.shape,a,l,1,c),h=new dz(u);return t.runWebGLProgram(h,[o],i.dtype)}const xz={kernelName:Kc,backendName:"webgl",kernelFunc:gz};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14228,7 +14228,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function gz(n){const{inputs:e,backend:t,attrs:s}=n,{a:o,b:r}=e,{transposeA:i,transposeB:a}=s;return Ic({a:o,b:r,transposeA:i,transposeB:a,backend:t})}const xz={kernelName:fa,backendName:"webgl",kernelFunc:gz};/** + */function bz(n){const{inputs:e,backend:t,attrs:s}=n,{a:o,b:r}=e,{transposeA:i,transposeB:a}=s;return $c({a:o,b:r,transposeA:i,transposeB:a,backend:t})}const yz={kernelName:fa,backendName:"webgl",kernelFunc:bz};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14243,7 +14243,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class bz{constructor(e,t,s,o,r,i){this.outputShape=[],this.variableNames=["x","mean","variance"],we(e,t),we(e,s);let a="0.0";o!=null&&(we(e,o),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let l="1.0";r!=null&&(we(e,r),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` + */class wz{constructor(e,t,s,o,r,i){this.outputShape=[],this.variableNames=["x","mean","variance"],we(e,t),we(e,s);let a="0.0";o!=null&&(we(e,o),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let l="1.0";r!=null&&(we(e,r),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` void main() { float x = getXAtOutCoords(); float mean = getMeanAtOutCoords(); @@ -14268,7 +14268,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class yz{constructor(e,t,s,o,r,i){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],we(e,t),we(e,s);let a="vec4(0.0)";o!=null&&(we(e,o),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let l="vec4(1.0)";r!=null&&(we(e,r),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` + */class Cz{constructor(e,t,s,o,r,i){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],we(e,t),we(e,s);let a="vec4(0.0)";o!=null&&(we(e,o),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let l="vec4(1.0)";r!=null&&(we(e,r),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` void main() { vec4 offset = ${a}; vec4 scale = ${l}; @@ -14296,7 +14296,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const wz={kernelName:Sa,backendName:"webgl",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:s,mean:o,variance:r,offset:i,scale:a}=n;$(o.shape.length===r.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),$(i==null||o.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),$(a==null||o.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:l}=t;l==null&&(l=.001);const c=[s,o,r];let u=null;i!=null&&(u=i.shape,c.push(i));let h=null;a!=null&&(h=a.shape,c.push(a));const d=W().getBool("WEBGL_PACK_NORMALIZATION")?new yz(s.shape,o.shape,r.shape,u,h,l):new bz(s.shape,o.shape,r.shape,u,h,l);return e.runWebGLProgram(d,c,c[0].dtype)}};/** + */const Iz={kernelName:Sa,backendName:"webgl",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:s,mean:o,variance:r,offset:i,scale:a}=n;$(o.shape.length===r.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),$(i==null||o.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),$(a==null||o.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:l}=t;l==null&&(l=.001);const c=[s,o,r];let u=null;i!=null&&(u=i.shape,c.push(i));let h=null;a!=null&&(h=a.shape,c.push(a));const d=W().getBool("WEBGL_PACK_NORMALIZATION")?new Cz(s.shape,o.shape,r.shape,u,h,l):new wz(s.shape,o.shape,r.shape,u,h,l);return e.runWebGLProgram(d,c,c[0].dtype)}};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14311,7 +14311,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Cz{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=Be(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const s=Iz(this.rank);let o;const r=e.map((i,a)=>`sourceLoc.${$p[a]} = start[${a}] + coords.${$p[a]};`);o=` + */class $z{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=Be(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const s=vz(this.rank);let o;const r=e.map((i,a)=>`sourceLoc.${$p[a]} = start[${a}] + coords.${$p[a]};`);o=` ${t} sourceLoc; ${t} coords = getOutputCoords(); ${r.join(` @@ -14321,7 +14321,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam ${o} setOutput(getSource(${s})); } - `}}const $p=["x","y","z","w","u","v"];function Iz(n){if(n===1)return"sourceLoc";if(n<=6)return $p.slice(0,n).map(e=>"sourceLoc."+e).join(",");throw Error(`Slicing for rank ${n} is not yet supported`)}/** + `}}const $p=["x","y","z","w","u","v"];function vz(n){if(n===1)return"sourceLoc";if(n<=6)return $p.slice(0,n).map(e=>"sourceLoc."+e).join(",");throw Error(`Slicing for rank ${n} is not yet supported`)}/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14336,7 +14336,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class $z{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const t=Be(this.rank),s=Pt("coords",this.rank),o=Pt("sourceLoc",this.rank),r=this.rank===1?"sourceLoc":`vec2(${o.slice(-2).join()})`,i=`getChannel(getSource(${o.join()}), ${r})`,a=` + */class kz{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const t=Be(this.rank),s=Bt("coords",this.rank),o=Bt("sourceLoc",this.rank),r=this.rank===1?"sourceLoc":`vec2(${o.slice(-2).join()})`,i=`getChannel(getSource(${o.join()}), ${r})`,a=` result.x = ${i}; if (++${s[this.rank-1]} < ${e[this.rank-1]}) { ++${o[this.rank-1]}; @@ -14380,7 +14380,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function vz(n,e,t,s){const o=s.texData.get(n.dataId),r=s.makeTensorInfo(t,n.dtype),i=s.texData.get(r.dataId);Object.assign(i,o),i.refCount=1,i.shape=t,i.dtype=n.dtype;let a=jh(e,de(n.shape));o.slice&&(a+=o.slice.flatOffset),i.slice={flatOffset:a,origDataId:o.slice&&o.slice.origDataId||n.dataId};const l=s.dataRefCount.get(i.slice.origDataId)||1;return s.dataRefCount.set(i.slice.origDataId,l+1),r}function gr(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{begin:r,size:i}=s,[a,l]=El(o,r,i);if(Uh(o,a,l),H(l)===0)return t.makeTensorInfo(l,o.dtype,[]);if(t.shouldExecuteOnCPU([o])||o.dtype==="string"){const h=t.texData.get(o.dataId),d=x3(h.values,a,l,o.shape,o.dtype);return t.makeTensorInfo(l,o.dtype,d)}const{isPacked:c}=t.texData.get(o.dataId),u=Hh(o.shape,a,l);if(c||!u){const h=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new $z(l):new Cz(l),d=[a];return t.runWebGLProgram(h,[o],o.dtype,d)}return t.uploadToGPU(o.dataId),vz(o,a,l,t)}const kz={kernelName:tl,backendName:"webgl",kernelFunc:gr};/** + */function Sz(n,e,t,s){const o=s.texData.get(n.dataId),r=s.makeTensorInfo(t,n.dtype),i=s.texData.get(r.dataId);Object.assign(i,o),i.refCount=1,i.shape=t,i.dtype=n.dtype;let a=qh(e,de(n.shape));o.slice&&(a+=o.slice.flatOffset),i.slice={flatOffset:a,origDataId:o.slice&&o.slice.origDataId||n.dataId};const l=s.dataRefCount.get(i.slice.origDataId)||1;return s.dataRefCount.set(i.slice.origDataId,l+1),r}function gr(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{begin:r,size:i}=s,[a,l]=Rl(o,r,i);if(Uh(o,a,l),H(l)===0)return t.makeTensorInfo(l,o.dtype,[]);if(t.shouldExecuteOnCPU([o])||o.dtype==="string"){const h=t.texData.get(o.dataId),d=y3(h.values,a,l,o.shape,o.dtype);return t.makeTensorInfo(l,o.dtype,d)}const{isPacked:c}=t.texData.get(o.dataId),u=Hh(o.shape,a,l);if(c||!u){const h=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new kz(l):new $z(l),d=[a];return t.runWebGLProgram(h,[o],o.dtype,d)}return t.uploadToGPU(o.dataId),Sz(o,a,l,t)}const Tz={kernelName:tl,backendName:"webgl",kernelFunc:gr};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14395,7 +14395,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Sz={kernelName:ma,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{blockShape:r,crops:i}=s;$(o.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");const a=r.reduce((b,w)=>b*w),l=Ei(o.shape,r,a),c=Ri(l.length,r.length),u=Ai(o.shape,r,a),h=Zh(i,r.length),d=Qh(u,i,r.length),p=[],f=ne({inputs:{x:o},backend:t,attrs:{shape:l}}),g=Bt({inputs:{x:f},backend:t,attrs:{perm:c}}),m=ne({inputs:{x:g},backend:t,attrs:{shape:u}}),x=gr({inputs:{x:m},backend:t,attrs:{begin:h,size:d}});return p.push(f),p.push(g),p.push(m),p.forEach(b=>t.disposeIntermediateTensorInfo(b)),x}};/** + */const Nz={kernelName:ma,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{blockShape:r,crops:i}=s;$(o.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");const a=r.reduce((b,w)=>b*w),l=Ei(o.shape,r,a),c=Ri(l.length,r.length),u=Ai(o.shape,r,a),h=Zh(i,r.length),d=Qh(u,i,r.length),p=[],f=ne({inputs:{x:o},backend:t,attrs:{shape:l}}),g=zt({inputs:{x:f},backend:t,attrs:{perm:c}}),m=ne({inputs:{x:g},backend:t,attrs:{shape:u}}),x=gr({inputs:{x:m},backend:t,attrs:{begin:h,size:d}});return p.push(f),p.push(g),p.push(m),p.forEach(b=>t.disposeIntermediateTensorInfo(b)),x}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14410,7 +14410,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Tz(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,weights:r}=e,{size:i}=s,a=t.readSync(o.dataId),l=t.readSync(r.dataId),c=ny(a,l,r.dtype,r.shape,i);return t.makeTensorInfo([i],r.dtype,c)}const Nz={kernelName:Xc,backendName:"webgl",kernelFunc:Tz};/** + */function Ez(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,weights:r}=e,{size:i}=s,a=t.readSync(o.dataId),l=t.readSync(r.dataId),c=ry(a,l,r.dtype,r.shape,i);return t.makeTensorInfo([i],r.dtype,c)}const Rz={kernelName:Yc,backendName:"webgl",kernelFunc:Ez};/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14425,15 +14425,15 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Ez=` + */const Az=` int r = int(a.r) & int(b.r); int g = int(a.g) & int(b.g); int rb = int(a.b) & int(b.b); int ra = int(a.a) & int(b.a); return vec4(r, g, rb, ra); -`,Rz=` +`,Dz=` return float(int(a.r) & int(b.r)); -`;function Az(n){const{inputs:e,backend:t}=n,{a:s,b:o}=e,r=W().getBool("WEBGL_PACK_BINARY_OPERATIONS"),i=W().getNumber("WEBGL_VERSION");if(t.shouldExecuteOnCPU([s,o])||i===1){const l=t.texData.get(s.dataId).values,c=t.texData.get(o.dataId).values,[u,h]=VP(s.shape,o.shape,l,c,s.dtype),d=t.makeTensorInfo(h,s.dtype),p=t.texData.get(d.dataId);return p.values=u,d}let a;return r?a=new fr(Ez,s.shape,o.shape,!1):a=new ko(Rz,s.shape,o.shape),t.runWebGLProgram(a,[s,o],s.dtype)}const Dz={kernelName:Yc,backendName:"webgl",kernelFunc:Az};/** +`;function Fz(n){const{inputs:e,backend:t}=n,{a:s,b:o}=e,r=W().getBool("WEBGL_PACK_BINARY_OPERATIONS"),i=W().getNumber("WEBGL_VERSION");if(t.shouldExecuteOnCPU([s,o])||i===1){const l=t.texData.get(s.dataId).values,c=t.texData.get(o.dataId).values,[u,h]=UP(s.shape,o.shape,l,c,s.dtype),d=t.makeTensorInfo(h,s.dtype),p=t.texData.get(d.dataId);return p.values=u,d}let a;return r?a=new fr(Az,s.shape,o.shape,!1):a=new So(Dz,s.shape,o.shape),t.runWebGLProgram(a,[s,o],s.dtype)}const _z={kernelName:Zc,backendName:"webgl",kernelFunc:Fz};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14448,7 +14448,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Fz(n){const{inputs:e,backend:t}=n,{s0:s,s1:o}=e,r=t.readSync(s.dataId),i=t.readSync(o.dataId),a=we(Array.from(r),Array.from(i));return t.makeTensorInfo([a.length],"int32",Int32Array.from(a))}const _z={kernelName:Gp,backendName:"webgl",kernelFunc:Fz};/** + */function Oz(n){const{inputs:e,backend:t}=n,{s0:s,s1:o}=e,r=t.readSync(s.dataId),i=t.readSync(o.dataId),a=we(Array.from(r),Array.from(i));return t.makeTensorInfo([a.length],"int32",Int32Array.from(a))}const Lz={kernelName:Gp,backendName:"webgl",kernelFunc:Oz};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14463,7 +14463,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Sy=vt({opSnippet:"return float(a != b);",cpuKernelImpl:l3,dtype:"bool"}),Oz={kernelName:Ua,backendName:"webgl",kernelFunc:Sy};/** + */const Ey=vt({opSnippet:"return float(a != b);",cpuKernelImpl:u3,dtype:"bool"}),Mz={kernelName:Ua,backendName:"webgl",kernelFunc:Ey};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14478,7 +14478,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function sa(n){const{inputs:e,backend:t}=n,{input:s}=e,o=t.texData.get(s.dataId);return en({inputs:{x:o.complexTensorInfos.real},backend:t})}const Lz={kernelName:$u,backendName:"webgl",kernelFunc:sa};/** + */function sa(n){const{inputs:e,backend:t}=n,{input:s}=e,o=t.texData.get(s.dataId);return en({inputs:{x:o.complexTensorInfos.real},backend:t})}const Pz={kernelName:vu,backendName:"webgl",kernelFunc:sa};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14493,7 +14493,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Mz="return float(int(x));";function Pz(n,e){const t=new ts(n.shape,Mz),s=e.runWebGLProgram(t,[n],"int32");return{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}/** + */const Bz="return float(int(x));";function zz(n,e){const t=new ts(n.shape,Bz),s=e.runWebGLProgram(t,[n],"int32");return{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14508,7 +14508,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function vp(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{dtype:r}=s;if(r==="complex64"){if(o.dtype==="complex64")return en({inputs:{x:o},backend:t});const i=st(o.shape),a=vp({inputs:{x:o},backend:t,attrs:{dtype:"float32"}}),l=Ps({inputs:{real:a,imag:i},backend:t});return i.dispose(),t.disposeIntermediateTensorInfo(a),l}if(o.dtype==="complex64"){const i=sa({inputs:{input:o},backend:t}),a=vp({inputs:{x:i},backend:t,attrs:{dtype:r}});return t.disposeIntermediateTensorInfo(i),a}if(!Bp(o.dtype,r)){const i=en({inputs:{x:o},backend:t});return{dataId:i.dataId,shape:i.shape,dtype:r}}if(t.shouldExecuteOnCPU([o])){const i=t.texData.get(o.dataId).values,[a,l,c]=WP(i,o.shape,o.dtype,r);return t.makeTensorInfo(a,l,c)}if(r==="int32")return Pz(o,t);if(r==="bool"){const i=t.makeTensorInfo([],"bool",Tt("bool",1)),l=Sy({inputs:{a:o,b:i},backend:t});return t.disposeIntermediateTensorInfo(i),l}throw new Error(`Error in Cast: failed to cast ${o.dtype} to ${r}`)}const Bz={kernelName:Tr,backendName:"webgl",kernelFunc:vp};/** + */function vp(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{dtype:r}=s;if(r==="complex64"){if(o.dtype==="complex64")return en({inputs:{x:o},backend:t});const i=st(o.shape),a=vp({inputs:{x:o},backend:t,attrs:{dtype:"float32"}}),l=Ps({inputs:{real:a,imag:i},backend:t});return i.dispose(),t.disposeIntermediateTensorInfo(a),l}if(o.dtype==="complex64"){const i=sa({inputs:{input:o},backend:t}),a=vp({inputs:{x:i},backend:t,attrs:{dtype:r}});return t.disposeIntermediateTensorInfo(i),a}if(!Bp(o.dtype,r)){const i=en({inputs:{x:o},backend:t});return{dataId:i.dataId,shape:i.shape,dtype:r}}if(t.shouldExecuteOnCPU([o])){const i=t.texData.get(o.dataId).values,[a,l,c]=GP(i,o.shape,o.dtype,r);return t.makeTensorInfo(a,l,c)}if(r==="int32")return zz(o,t);if(r==="bool"){const i=t.makeTensorInfo([],"bool",Tt("bool",1)),l=Ey({inputs:{a:o,b:i},backend:t});return t.disposeIntermediateTensorInfo(i),l}throw new Error(`Error in Cast: failed to cast ${o.dtype} to ${r}`)}const Vz={kernelName:Tr,backendName:"webgl",kernelFunc:vp};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14523,7 +14523,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Ty="return ceil(x);",zz=Re({opSnippet:Ty,packedOpSnippet:Ty,cpuKernelImpl:UP}),Vz={kernelName:Nr,backendName:"webgl",kernelFunc:zz};/** + */const Ry="return ceil(x);",Wz=Re({opSnippet:Ry,packedOpSnippet:Ry,cpuKernelImpl:HP}),Uz={kernelName:Nr,backendName:"webgl",kernelFunc:Wz};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14538,7 +14538,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Wz{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=` + */class Gz{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=` void main() { float value = getAAtOutCoords(); @@ -14564,7 +14564,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Uz{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=` + */class Hz{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=` void main() { vec4 value = getAAtOutCoords(); @@ -14590,7 +14590,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Gz(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{clipValueMin:r,clipValueMax:i}=s;let a;W().getBool("WEBGL_PACK_CLIP")?a=new Uz(o.shape):a=new Wz(o.shape);const l=[[r],[i]];return t.runWebGLProgram(a,[o],o.dtype,l)}const Hz={kernelName:Er,backendName:"webgl",kernelFunc:Gz};/** + */function qz(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{clipValueMin:r,clipValueMax:i}=s;let a;W().getBool("WEBGL_PACK_CLIP")?a=new Hz(o.shape):a=new Gz(o.shape);const l=[[r],[i]];return t.runWebGLProgram(a,[o],o.dtype,l)}const jz={kernelName:Er,backendName:"webgl",kernelFunc:qz};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14605,7 +14605,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class jz{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode=` + */class Kz{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode=` void main() { float re = abs(getRealAtOutCoords()); float im = abs(getImagAtOutCoords()); @@ -14633,7 +14633,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ny(n,e){return{dataId:e.dataId,dtype:e.dtype,shape:n.shape}}function qz(n){const{inputs:e,backend:t}=n,{x:s}=e,o=t.texData.get(s.dataId),r=new jz(s.shape),i=[Ny(s,o.complexTensorInfos.real),Ny(s,o.complexTensorInfos.imag)];return t.runWebGLProgram(r,i,i[0].dtype)}const Kz={kernelName:ga,backendName:"webgl",kernelFunc:qz};/** + */function Ay(n,e){return{dataId:e.dataId,dtype:e.dtype,shape:n.shape}}function Xz(n){const{inputs:e,backend:t}=n,{x:s}=e,o=t.texData.get(s.dataId),r=new Kz(s.shape),i=[Ay(s,o.complexTensorInfos.real),Ay(s,o.complexTensorInfos.imag)];return t.runWebGLProgram(r,i,i[0].dtype)}const Yz={kernelName:ga,backendName:"webgl",kernelFunc:Xz};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14648,7 +14648,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Xz{constructor(e){this.outputShape=[],this.outputShape=Hn(e,1),this.variableNames=e.map((i,a)=>`T${a}`);const t=new Array(e.length-1);t[0]=e[0][1];for(let i=1;i`T${a}`);const t=new Array(e.length-1);t[0]=e[0][1];for(let i=1;i`T${m}`);const l=new Array(e.length-1);l[0]=e[0][t];for(let g=1;g`T${m}`);const l=new Array(e.length-1);l[0]=e[0][t];for(let g=1;g= ${l[g-1]}) { return getChannel( - getT${g}(${vc(a,c,m)}), - vec2(${vc(u,c,m)})); + getT${g}(${kc(a,c,m)}), + vec2(${kc(u,c,m)})); }`}const p=l.length,f=l[l.length-1];d+=` return getChannel( - getT${p}(${vc(a,c,f)}), - vec2(${vc(u,c,f)}));`,this.userCode=` + getT${p}(${kc(a,c,f)}), + vec2(${kc(u,c,f)}));`,this.userCode=` float getValue(${a.map(g=>"int "+g)}) { ${d} } @@ -14709,7 +14709,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam } setOutput(result); } - `}}function vc(n,e,t){const s=n.indexOf(e);return n.map((r,i)=>i===s?`${r} - ${t}`:r).join()}/** + `}}function kc(n,e,t){const s=n.indexOf(e);return n.map((r,i)=>i===s?`${r} - ${t}`:r).join()}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14724,7 +14724,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function kc(n){const{inputs:e,backend:t}=n,{input:s}=e,o=t.texData.get(s.dataId);return en({inputs:{x:o.complexTensorInfos.imag},backend:t})}const Zz={kernelName:mu,backendName:"webgl",kernelFunc:kc};/** + */function Sc(n){const{inputs:e,backend:t}=n,{input:s}=e,o=t.texData.get(s.dataId);return en({inputs:{x:o.complexTensorInfos.imag},backend:t})}const Jz={kernelName:gu,backendName:"webgl",kernelFunc:Sc};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14739,7 +14739,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function oa(n,e,t){const s=n[0].dtype;if(s==="complex64"){const p=n.map(b=>sa({inputs:{input:b},backend:t})),f=n.map(b=>kc({inputs:{input:b},backend:t})),g=oa(p,e,t),m=oa(f,e,t),x=Ps({inputs:{real:g,imag:m},backend:t});return p.forEach(b=>t.disposeIntermediateTensorInfo(b)),f.forEach(b=>t.disposeIntermediateTensorInfo(b)),t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(m),x}let o=t.shouldExecuteOnCPU(n);if(s==="string"&&(o=!0),o){const p=n.map(y=>{const I=[-1,H(y.shape.slice(e))];return ne({inputs:{x:y},backend:t,attrs:{shape:I}})}),f=p.map(y=>({vals:t.readSync(y.dataId),shape:y.shape})),g=Hn(p.map(y=>y.shape),1),m=p[0].shape[0]===1,x=GP(f,g,s,m),b=Hn(n.map(y=>y.shape),e),w=t.makeTensorInfo(b,s,x);return p.forEach(y=>t.disposeIntermediateTensorInfo(y)),w}const r=n.filter(p=>H(p.shape)>0),i=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&r[0].shape.length>1;if(r.length===1){const p=i?new ts(n[0].shape,Ls):new Ms(n[0].shape,Ls);return t.runWebGLProgram(p,n,s)}const a=W().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(r.length>a){const p=[];for(let g=0;gf.shape),e);return t.runWebGLProgram(p,r,s)}const{tensors2D:l,outShape:c}=Qz(r,e,t),u=new Xz(l.map(p=>p.shape)),h=t.runWebGLProgram(u,l,s);l.forEach(p=>t.disposeIntermediateTensorInfo(p));const d=ne({inputs:{x:h},attrs:{shape:c},backend:t});return t.disposeIntermediateTensorInfo(h),d}function Qz(n,e,t){const s=Hn(n.map(r=>r.shape),e);return{tensors2D:n.map(r=>ne({inputs:{x:r},attrs:{shape:[-1,H(r.shape.slice(e))]},backend:t})),outShape:s}}/** + */function oa(n,e,t){const s=n[0].dtype;if(s==="complex64"){const p=n.map(b=>sa({inputs:{input:b},backend:t})),f=n.map(b=>Sc({inputs:{input:b},backend:t})),g=oa(p,e,t),m=oa(f,e,t),x=Ps({inputs:{real:g,imag:m},backend:t});return p.forEach(b=>t.disposeIntermediateTensorInfo(b)),f.forEach(b=>t.disposeIntermediateTensorInfo(b)),t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(m),x}let o=t.shouldExecuteOnCPU(n);if(s==="string"&&(o=!0),o){const p=n.map(y=>{const I=[-1,H(y.shape.slice(e))];return ne({inputs:{x:y},backend:t,attrs:{shape:I}})}),f=p.map(y=>({vals:t.readSync(y.dataId),shape:y.shape})),g=Hn(p.map(y=>y.shape),1),m=p[0].shape[0]===1,x=qP(f,g,s,m),b=Hn(n.map(y=>y.shape),e),w=t.makeTensorInfo(b,s,x);return p.forEach(y=>t.disposeIntermediateTensorInfo(y)),w}const r=n.filter(p=>H(p.shape)>0),i=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&r[0].shape.length>1;if(r.length===1){const p=i?new ts(n[0].shape,Ls):new Ms(n[0].shape,Ls);return t.runWebGLProgram(p,n,s)}const a=W().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(r.length>a){const p=[];for(let g=0;gf.shape),e);return t.runWebGLProgram(p,r,s)}const{tensors2D:l,outShape:c}=eV(r,e,t),u=new Zz(l.map(p=>p.shape)),h=t.runWebGLProgram(u,l,s);l.forEach(p=>t.disposeIntermediateTensorInfo(p));const d=ne({inputs:{x:h},attrs:{shape:c},backend:t});return t.disposeIntermediateTensorInfo(h),d}function eV(n,e,t){const s=Hn(n.map(r=>r.shape),e);return{tensors2D:n.map(r=>ne({inputs:{x:r},attrs:{shape:[-1,H(r.shape.slice(e))]},backend:t})),outShape:s}}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14754,7 +14754,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ey(n){const{inputs:e,backend:t,attrs:s}=n,{axis:o}=s,r=$e(o,e[0].shape)[0],i=e.map(c=>c.shape);Kh(i,r);const a=Hn(e.map(c=>c.shape),r);if(H(a)===0)return t.makeTensorInfo(a,e[0].dtype,[]);const l=e.filter(c=>H(c.shape)>0);return l.length===1?en({inputs:{x:l[0]},backend:t}):oa(l,r,t)}const Jz={kernelName:xa,backendName:"webgl",kernelFunc:Ey};/** + */function Dy(n){const{inputs:e,backend:t,attrs:s}=n,{axis:o}=s,r=$e(o,e[0].shape)[0],i=e.map(c=>c.shape);Kh(i,r);const a=Hn(e.map(c=>c.shape),r);if(H(a)===0)return t.makeTensorInfo(a,e[0].dtype,[]);const l=e.filter(c=>H(c.shape)>0);return l.length===1?en({inputs:{x:l[0]},backend:t}):oa(l,r,t)}const tV={kernelName:xa,backendName:"webgl",kernelFunc:Dy};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14769,7 +14769,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Ry{constructor(e,t=!1,s=null,o=!1,r=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const i=e.padInfo.top,a=e.padInfo.left,l=e.strideHeight,c=e.strideWidth,u=e.dilationHeight,h=e.dilationWidth,d=e.filterHeight,p=e.filterWidth,f=Math.floor(e.inChannels/4)*4,g=e.inChannels%4,m=e.dataFormat==="channelsLast",x=m?1:2,b=m?2:3,w=m?3:1;let y="",C="";s&&(o?y=`float activation(float a) { + */class Fy{constructor(e,t=!1,s=null,o=!1,r=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const i=e.padInfo.top,a=e.padInfo.left,l=e.strideHeight,c=e.strideWidth,u=e.dilationHeight,h=e.dilationWidth,d=e.filterHeight,p=e.filterWidth,f=Math.floor(e.inChannels/4)*4,g=e.inChannels%4,m=e.dataFormat==="channelsLast",x=m?1:2,b=m?2:3,w=m?3:1;let y="",C="";s&&(o?y=`float activation(float a) { float b = getPreluActivationWeightsAtOutCoords(); ${s} }`:r?y=`float activation(float a) { @@ -14903,7 +14903,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam ${C} setOutput(result); } - `}}class eV{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const t=e.padInfo.front,s=e.padInfo.top,o=e.padInfo.left,r=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,u=e.dilationWidth,h=e.filterDepth,d=e.filterHeight,p=e.filterWidth,f=Math.floor(e.inChannels/4)*4,g=e.inChannels%4;this.userCode=` + `}}class nV{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const t=e.padInfo.front,s=e.padInfo.top,o=e.padInfo.left,r=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,u=e.dilationWidth,h=e.filterDepth,d=e.filterHeight,p=e.filterWidth,f=Math.floor(e.inChannels/4)*4,g=e.inChannels%4;this.userCode=` const ivec3 strides = ivec3(${r}, ${i}, ${a}); const ivec3 pads = ivec3(${t}, ${s}, ${o}); @@ -15006,7 +15006,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Ay{constructor(e,t=!1,s=null,o=!1,r=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=At(this.outputShape.length);const i=e.padInfo.left,a=e.strideWidth,l=e.dilationWidth,c=e.filterHeight,u=e.filterWidth,h=u;let d=` + */class _y{constructor(e,t=!1,s=null,o=!1,r=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=Ft(this.outputShape.length);const i=e.padInfo.left,a=e.strideWidth,l=e.dilationWidth,c=e.filterHeight,u=e.filterWidth,h=u;let d=` int xR; int xC; int xCOffset; vec4 wTexel; vec4 previous; vec4 final;`;for(let m=0;m= 0 && xCOffset < inDims[1] && xTexelC${x+1}Ready == 0) { @@ -15217,7 +15217,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class tV{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec4"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=e,this.enableShapeUniforms=At(this.outputShape.length);const{dataFormat:s}=t,o=Mt(),r=s==="channelsLast",i=r?1:2,a=r?2:3,l=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let c="";for(let u=0;u<=1;u++)for(let h=0;h<=1;h++)c+=` + */class sV{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec4"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=e,this.enableShapeUniforms=Ft(this.outputShape.length);const{dataFormat:s}=t,o=Pt(),r=s==="channelsLast",i=r?1:2,a=r?2:3,l=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let c="";for(let u=0;u<=1;u++)for(let h=0;h<=1;h++)c+=` blockIndex = rc.z + ${h}; pos = rc.y + ${u}; @@ -15279,7 +15279,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Sc(n,e){const t=n.length;return t>=3?e?[...n.slice(0,-3),n[t-3]*n[t-2],n[t-1]]:[...n.slice(0,-3),n[t-3],n[t-2]*n[t-1]]:!e&&t===1&&n[0]>1?[n[0],1]:null}function Dy({x:n,filter:e,convInfo:t,backend:s,bias:o=null,preluActivationWeights:r=null,leakyreluAlpha:i=0,activation:a=null}){const l=n.shape,c=s.texData.get(n.dataId),u=t.inChannels,h=l[0]*l[1]*l[2],d=t.outChannels,p=t.dataFormat==="channelsLast",f=!1,g=!1;let m;const x=[];if(r!=null){const y=Sc(r.shape,p);y!=null&&(r=ne({inputs:{x:r},backend:s,attrs:{shape:y}}),x.push(r))}if(o!=null){const y=Sc(o.shape,p);y!=null&&(o=ne({inputs:{x:o},backend:s,attrs:{shape:y}}),x.push(o))}if(!((h===1||d===1)&&u>wy)&&c.isPacked&&p&&c.texture!=null&&l[2]%2!==0&&Oe(c.shape.slice(-3),l.slice(-3))){const y=l[0]*l[1]*(l[2]+1),C={dataId:n.dataId,shape:[1,y,t.inChannels],dtype:n.dtype},I=c.shape;c.shape=c.shape.slice(),c.shape[c.shape.length-2]++,$(gc(c.shape,C.shape),()=>`packed reshape ${c.shape} to ${C.shape} isn't free`);const v=ne({inputs:{x:e},backend:s,attrs:{shape:[1,t.inChannels,t.outChannels]}});x.push(v);const k=Ic({a:C,b:v,backend:s,transposeA:f,transposeB:g,bias:o,activation:a,preluActivationWeights:r,leakyreluAlpha:i}),S=s.texData.get(k.dataId);$(S.isPacked,()=>"batchMatMul result is expected to be packed"),c.shape=I,S.shape=t.outShape,m=en({inputs:{x:k},backend:s}),m.shape=t.outShape,x.push(k)}else{const y=t.outHeight*t.outWidth,C=ne({inputs:{x:n},backend:s,attrs:{shape:p?[t.batchSize,y,t.inChannels]:[t.batchSize,t.inChannels,y]}}),I=ne({inputs:{x:e},backend:s,attrs:{shape:[1,t.inChannels,t.outChannels]}}),v=Ic({a:p?C:I,b:p?I:C,transposeA:!p,transposeB:g,backend:s,bias:o,activation:a,preluActivationWeights:r,leakyreluAlpha:i});m=ne({inputs:{x:v},backend:s,attrs:{shape:t.outShape}}),x.push(C),x.push(I),x.push(v)}for(const y of x)s.disposeIntermediateTensorInfo(y);return m}function Fy({x:n,filter:e,convInfo:t,backend:s,bias:o=null,preluActivationWeights:r=null,leakyreluAlpha:i=0,activation:a=null}){const{filterWidth:l,filterHeight:c,inChannels:u,outWidth:h,outHeight:d,dataFormat:p}=t,f=p==="channelsLast",g=l*c*u,m=d*h,x=[t.batchSize,g,m],b=!0,w=!1,y=[];if(r!=null){const B=Sc(r.shape,f);B!=null&&(r=ne({inputs:{x:r},backend:s,attrs:{shape:B}}),y.push(r))}if(o!=null){const B=Sc(o.shape,f);B!=null&&(o=ne({inputs:{x:o},backend:s,attrs:{shape:B}}),y.push(o))}const C=ne({inputs:{x:e},backend:s,attrs:{shape:[1,g,H(e.shape)/g]}});y.push(C);const I=new tV(x,t),v=[n.shape,[t.padInfo.top,t.padInfo.left],[t.strideHeight,t.strideWidth],[t.dilationHeight,t.dilationWidth],[t.inChannels],[t.filterWidth*t.inChannels],[t.outWidth]],k=s.runWebGLProgram(I,[n],"float32",v),S=ne({inputs:{x:k},backend:s,attrs:{shape:x}});y.push(k),y.push(S);const T=o!=null,E=r!=null,V=a==="leakyrelu",M=a?ta(a,!0):null,L=new my(f?S.shape:C.shape,f?C.shape:S.shape,f?[t.batchSize,m,t.outChannels]:[t.batchSize,t.outChannels,m],b,w,T,M,E,V),R=f?[S,C]:[C,S];if(o&&R.push(o),E&&R.push(r),V){const B=s.makeTensorInfo([],"float32",xs(i,"float32"));R.push(B),y.push(B)}const P=s.runWebGLProgram(L,R,"float32"),G=ne({inputs:{x:P},backend:s,attrs:{shape:t.outShape}});y.push(P);for(const B of y)s.disposeIntermediateTensorInfo(B);return G}/** + */function Tc(n,e){const t=n.length;return t>=3?e?[...n.slice(0,-3),n[t-3]*n[t-2],n[t-1]]:[...n.slice(0,-3),n[t-3],n[t-2]*n[t-1]]:!e&&t===1&&n[0]>1?[n[0],1]:null}function Oy({x:n,filter:e,convInfo:t,backend:s,bias:o=null,preluActivationWeights:r=null,leakyreluAlpha:i=0,activation:a=null}){const l=n.shape,c=s.texData.get(n.dataId),u=t.inChannels,h=l[0]*l[1]*l[2],d=t.outChannels,p=t.dataFormat==="channelsLast",f=!1,g=!1;let m;const x=[];if(r!=null){const y=Tc(r.shape,p);y!=null&&(r=ne({inputs:{x:r},backend:s,attrs:{shape:y}}),x.push(r))}if(o!=null){const y=Tc(o.shape,p);y!=null&&(o=ne({inputs:{x:o},backend:s,attrs:{shape:y}}),x.push(o))}if(!((h===1||d===1)&&u>$y)&&c.isPacked&&p&&c.texture!=null&&l[2]%2!==0&&Oe(c.shape.slice(-3),l.slice(-3))){const y=l[0]*l[1]*(l[2]+1),C={dataId:n.dataId,shape:[1,y,t.inChannels],dtype:n.dtype},I=c.shape;c.shape=c.shape.slice(),c.shape[c.shape.length-2]++,$(xc(c.shape,C.shape),()=>`packed reshape ${c.shape} to ${C.shape} isn't free`);const v=ne({inputs:{x:e},backend:s,attrs:{shape:[1,t.inChannels,t.outChannels]}});x.push(v);const k=$c({a:C,b:v,backend:s,transposeA:f,transposeB:g,bias:o,activation:a,preluActivationWeights:r,leakyreluAlpha:i}),S=s.texData.get(k.dataId);$(S.isPacked,()=>"batchMatMul result is expected to be packed"),c.shape=I,S.shape=t.outShape,m=en({inputs:{x:k},backend:s}),m.shape=t.outShape,x.push(k)}else{const y=t.outHeight*t.outWidth,C=ne({inputs:{x:n},backend:s,attrs:{shape:p?[t.batchSize,y,t.inChannels]:[t.batchSize,t.inChannels,y]}}),I=ne({inputs:{x:e},backend:s,attrs:{shape:[1,t.inChannels,t.outChannels]}}),v=$c({a:p?C:I,b:p?I:C,transposeA:!p,transposeB:g,backend:s,bias:o,activation:a,preluActivationWeights:r,leakyreluAlpha:i});m=ne({inputs:{x:v},backend:s,attrs:{shape:t.outShape}}),x.push(C),x.push(I),x.push(v)}for(const y of x)s.disposeIntermediateTensorInfo(y);return m}function Ly({x:n,filter:e,convInfo:t,backend:s,bias:o=null,preluActivationWeights:r=null,leakyreluAlpha:i=0,activation:a=null}){const{filterWidth:l,filterHeight:c,inChannels:u,outWidth:h,outHeight:d,dataFormat:p}=t,f=p==="channelsLast",g=l*c*u,m=d*h,x=[t.batchSize,g,m],b=!0,w=!1,y=[];if(r!=null){const z=Tc(r.shape,f);z!=null&&(r=ne({inputs:{x:r},backend:s,attrs:{shape:z}}),y.push(r))}if(o!=null){const z=Tc(o.shape,f);z!=null&&(o=ne({inputs:{x:o},backend:s,attrs:{shape:z}}),y.push(o))}const C=ne({inputs:{x:e},backend:s,attrs:{shape:[1,g,H(e.shape)/g]}});y.push(C);const I=new sV(x,t),v=[n.shape,[t.padInfo.top,t.padInfo.left],[t.strideHeight,t.strideWidth],[t.dilationHeight,t.dilationWidth],[t.inChannels],[t.filterWidth*t.inChannels],[t.outWidth]],k=s.runWebGLProgram(I,[n],"float32",v),S=ne({inputs:{x:k},backend:s,attrs:{shape:x}});y.push(k),y.push(S);const T=o!=null,E=r!=null,V=a==="leakyrelu",M=a?ta(a,!0):null,L=new by(f?S.shape:C.shape,f?C.shape:S.shape,f?[t.batchSize,m,t.outChannels]:[t.batchSize,t.outChannels,m],b,w,T,M,E,V),R=f?[S,C]:[C,S];if(o&&R.push(o),E&&R.push(r),V){const z=s.makeTensorInfo([],"float32",xs(i,"float32"));R.push(z),y.push(z)}const B=s.runWebGLProgram(L,R,"float32"),G=ne({inputs:{x:B},backend:s,attrs:{shape:t.outShape}});y.push(B);for(const z of y)s.disposeIntermediateTensorInfo(z);return G}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15294,7 +15294,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function nV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,filter:r}=e,{strides:i,pad:a,dataFormat:l,dilations:c,dimRoundingMode:u}=s,h=is(l),d=wt(o.shape,r.shape,i,c,a,u,!1,h);let p;if(d.filterHeight===1&&d.filterWidth===1&&d.dilationHeight===1&&d.dilationWidth===1&&d.strideHeight===1&&d.strideWidth===1&&(d.padInfo.type==="SAME"||d.padInfo.type==="VALID"))p=Dy({x:o,filter:r,convInfo:d,backend:t});else if(d.strideWidth<=2&&h==="channelsLast"&&W().getBool("WEBGL_EXP_CONV")){const g=new Ay(d),m=[[d.padInfo.top,d.padInfo.left],[d.strideHeight,d.strideWidth],[d.dilationHeight,d.dilationWidth],[d.inHeight,d.inWidth]];p=t.runWebGLProgram(g,[o,r],"float32",m)}else if(W().getBool("WEBGL_CONV_IM2COL"))p=Fy({x:o,filter:r,convInfo:d,backend:t});else{const g=new Ry(d);p=t.runWebGLProgram(g,[o,r],"float32")}const f=ne({inputs:{x:p},backend:t,attrs:{shape:d.outShape}});return t.disposeIntermediateTensorInfo(p),f}const sV={kernelName:ba,backendName:"webgl",kernelFunc:nV};/** + */function oV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,filter:r}=e,{strides:i,pad:a,dataFormat:l,dilations:c,dimRoundingMode:u}=s,h=is(l),d=wt(o.shape,r.shape,i,c,a,u,!1,h);let p;if(d.filterHeight===1&&d.filterWidth===1&&d.dilationHeight===1&&d.dilationWidth===1&&d.strideHeight===1&&d.strideWidth===1&&(d.padInfo.type==="SAME"||d.padInfo.type==="VALID"))p=Oy({x:o,filter:r,convInfo:d,backend:t});else if(d.strideWidth<=2&&h==="channelsLast"&&W().getBool("WEBGL_EXP_CONV")){const g=new _y(d),m=[[d.padInfo.top,d.padInfo.left],[d.strideHeight,d.strideWidth],[d.dilationHeight,d.dilationWidth],[d.inHeight,d.inWidth]];p=t.runWebGLProgram(g,[o,r],"float32",m)}else if(W().getBool("WEBGL_CONV_IM2COL"))p=Ly({x:o,filter:r,convInfo:d,backend:t});else{const g=new Fy(d);p=t.runWebGLProgram(g,[o,r],"float32")}const f=ne({inputs:{x:p},backend:t,attrs:{shape:d.outShape}});return t.disposeIntermediateTensorInfo(p),f}const rV={kernelName:ba,backendName:"webgl",kernelFunc:oV};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15309,7 +15309,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class oV{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,s=e.strideWidth,o=e.padInfo.top,r=e.padInfo.left,i=e.dataFormat==="channelsLast";this.userCode=` + */class iV{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,s=e.strideWidth,o=e.padInfo.top,r=e.padInfo.left,i=e.dataFormat==="channelsLast";this.userCode=` void main() { ivec4 coords = getOutputCoords(); int wR = coords.x; @@ -15346,7 +15346,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam } setOutput(dotProd); } - `}}class rV{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,s=e.filterWidth,o=e.strideHeight,r=e.strideWidth,i=e.dataFormat==="channelsLast",a=t-1-e.padInfo.top,l=s-1-e.padInfo.left,c=i?1:2,u=i?2:3,h=i?3:1;this.userCode=` + `}}class aV{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,s=e.filterWidth,o=e.strideHeight,r=e.strideWidth,i=e.dataFormat==="channelsLast",a=t-1-e.padInfo.top,l=s-1-e.padInfo.left,c=i?1:2,u=i?2:3,h=i?3:1;this.userCode=` const ivec2 pads = ivec2(${a}, ${l}); void main() { @@ -15399,7 +15399,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam } setOutput(dotProd); } - `}}class iV{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideDepth,s=e.strideHeight,o=e.strideWidth,r=e.padInfo.front,i=e.padInfo.top,a=e.padInfo.left;this.userCode=` + `}}class lV{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideDepth,s=e.strideHeight,o=e.strideWidth,r=e.padInfo.front,i=e.padInfo.top,a=e.padInfo.left;this.userCode=` void main() { ivec5 coords = getOutputCoords(); int wF = coords.x; @@ -15441,7 +15441,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam } setOutput(dotProd); } - `}}class aV{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterDepth,s=e.filterHeight,o=e.filterWidth,r=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=t-1-e.padInfo.front,c=s-1-e.padInfo.top,u=o-1-e.padInfo.left;this.userCode=` + `}}class cV{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterDepth,s=e.filterHeight,o=e.filterWidth,r=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=t-1-e.padInfo.front,c=s-1-e.padInfo.top,u=o-1-e.padInfo.left;this.userCode=` const ivec3 pads = ivec3(${l}, ${c}, ${u}); void main() { @@ -15513,7 +15513,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function lV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,dy:r}=e,{strides:i,pad:a,dataFormat:l,dimRoundingMode:c,filterShape:u}=s,h=is(l),d=wt(o.shape,u,i,1,a,c,!1,h),p=new oV(d);return t.runWebGLProgram(p,[o,r],"float32")}const cV={kernelName:Qc,backendName:"webgl",kernelFunc:lV};/** + */function uV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,dy:r}=e,{strides:i,pad:a,dataFormat:l,dimRoundingMode:c,filterShape:u}=s,h=is(l),d=wt(o.shape,u,i,1,a,c,!1,h),p=new iV(d);return t.runWebGLProgram(p,[o,r],"float32")}const hV={kernelName:Jc,backendName:"webgl",kernelFunc:uV};/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15528,7 +15528,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class uV{constructor(e){this.variableNames=["dy","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"strides",type:"vec2"}],this.outputShape=e.inShape,this.enableShapeUniforms=At(this.outputShape.length);const t=e.filterHeight,s=e.filterWidth,o=t-1-e.padInfo.top,r=s-1-e.padInfo.left;this.userCode=` + */class dV{constructor(e){this.variableNames=["dy","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"strides",type:"vec2"}],this.outputShape=e.inShape,this.enableShapeUniforms=Ft(this.outputShape.length);const t=e.filterHeight,s=e.filterWidth,o=t-1-e.padInfo.top,r=s-1-e.padInfo.left;this.userCode=` const ivec2 pads = ivec2(${o}, ${r}); void main() { @@ -15617,7 +15617,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hV(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,filter:r}=e,{inputShape:i,strides:a,pad:l,dataFormat:c,dimRoundingMode:u}=s,h=is(c),d=wt(i,r.shape,a,1,l,u,!1,h);if(W().getBool("WEBGL_PACK_CONV2DTRANSPOSE")&&h==="channelsLast"){const p=[[d.strideHeight,d.strideWidth]],f=new uV(d);return t.runWebGLProgram(f,[o,r],"float32",p)}else{const p=new rV(d);return t.runWebGLProgram(p,[o,r],"float32")}}const dV={kernelName:ya,backendName:"webgl",kernelFunc:hV};/** + */function pV(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,filter:r}=e,{inputShape:i,strides:a,pad:l,dataFormat:c,dimRoundingMode:u}=s,h=is(c),d=wt(i,r.shape,a,1,l,u,!1,h);if(W().getBool("WEBGL_PACK_CONV2DTRANSPOSE")&&h==="channelsLast"){const p=[[d.strideHeight,d.strideWidth]],f=new dV(d);return t.runWebGLProgram(f,[o,r],"float32",p)}else{const p=new aV(d);return t.runWebGLProgram(p,[o,r],"float32")}}const fV={kernelName:ya,backendName:"webgl",kernelFunc:pV};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15632,7 +15632,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function pV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,filter:r}=e,{strides:i,pad:a,dilations:l}=s,c=Is(o.shape,r.shape,i,l,a),u=new eV(c);return t.runWebGLProgram(u,[o,r],"float32")}const fV={kernelName:wa,backendName:"webgl",kernelFunc:pV};/** + */function mV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,filter:r}=e,{strides:i,pad:a,dilations:l}=s,c=Is(o.shape,r.shape,i,l,a),u=new nV(c);return t.runWebGLProgram(u,[o,r],"float32")}const gV={kernelName:wa,backendName:"webgl",kernelFunc:mV};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15647,7 +15647,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function mV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,dy:r}=e,{strides:i,pad:a,filterShape:l}=s,c=Is(o.shape,l,i,1,a),u=new iV(c);return t.runWebGLProgram(u,[o,r],"float32")}const gV={kernelName:Jc,backendName:"webgl",kernelFunc:mV};/** + */function xV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,dy:r}=e,{strides:i,pad:a,filterShape:l}=s,c=Is(o.shape,l,i,1,a),u=new lV(c);return t.runWebGLProgram(u,[o,r],"float32")}const bV={kernelName:eu,backendName:"webgl",kernelFunc:xV};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15662,7 +15662,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xV(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,filter:r}=e,{pad:i,strides:a,inputShape:l}=s,c=Is(l,r.shape,a,1,i),u=new aV(c);return t.runWebGLProgram(u,[o,r],"float32")}const bV={kernelName:eu,backendName:"webgl",kernelFunc:xV};/** + */function yV(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,filter:r}=e,{pad:i,strides:a,inputShape:l}=s,c=Is(l,r.shape,a,1,i),u=new cV(c);return t.runWebGLProgram(u,[o,r],"float32")}const wV={kernelName:tu,backendName:"webgl",kernelFunc:yV};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15677,14 +15677,14 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const yV=mr+` + */const CV=mr+` return cos(x); -`,wV=` +`,IV=` vec4 result = cos(x); bvec4 isNaN = isnan(x); - ${So} + ${To} return result; -`,CV=Re({opSnippet:yV,packedOpSnippet:wV}),IV={kernelName:Rr,backendName:"webgl",kernelFunc:CV};/** +`,$V=Re({opSnippet:CV,packedOpSnippet:IV}),vV={kernelName:Rr,backendName:"webgl",kernelFunc:$V};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15699,10 +15699,10 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const $V=Re({opSnippet:` + */const kV=Re({opSnippet:` float e2x = exp(-x); return (e2x + 1.0 / e2x) / 2.0; -`}),vV={kernelName:Ar,backendName:"webgl",kernelFunc:$V};/** +`}),SV={kernelName:Ar,backendName:"webgl",kernelFunc:kV};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15717,7 +15717,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class kV{constructor(e,t,s,o,r){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[i,a,l,c]=e,[u]=t,[h,d]=s;this.outputShape=[u,h,d,c];const p=o==="bilinear"?1:0,[f,g]=[`${a-1}.0`,`${l-1}.0`],[m,x,b]=h>1?[`${(a-1)/(h-1)}`,"(y2-y1) * height_ratio",`y1*${f} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${f}`],[w,y,C]=d>1?[`${(l-1)/(d-1)}`,"(x2-x1) * width_ratio",`x1*${g} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${g}`];this.userCode=` + */class TV{constructor(e,t,s,o,r){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[i,a,l,c]=e,[u]=t,[h,d]=s;this.outputShape=[u,h,d,c];const p=o==="bilinear"?1:0,[f,g]=[`${a-1}.0`,`${l-1}.0`],[m,x,b]=h>1?[`${(a-1)/(h-1)}`,"(y2-y1) * height_ratio",`y1*${f} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${f}`],[w,y,C]=d>1?[`${(l-1)/(d-1)}`,"(x2-x1) * width_ratio",`x1*${g} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${g}`];this.userCode=` const float height_ratio = float(${m}); const float width_ratio = float(${w}); void main() { @@ -15793,20 +15793,20 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const SV={kernelName:nu,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t,attrs:s}=n,{image:o,boxes:r,boxInd:i}=e,{cropSize:a,method:l,extrapolationValue:c}=s,u=new kV(o.shape,r.shape,a,l,c);return t.runWebGLProgram(u,[o,r,i],"float32")}};var ra;(function(n){n.Prod="*",n.Sum="+"})(ra||(ra={}));class _y{constructor(e,t,s,o){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const r=this.outputShape.length,i=this.op===ra.Prod?"1.0":"0.0",a=s?i:`getX(${Oy(r,"coords",this.op)})`,l=this.outputShape[this.outputShape.length-1];let c="",u="";s?(c=o?`end != ${l-1}`:"end != 0",u=o?"end + 1":"end - 1"):(c=o?`end + pow2 < ${l}`:"end >= pow2",u=o?"end + pow2":"end - pow2"),this.userCode=` + */const NV={kernelName:su,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t,attrs:s}=n,{image:o,boxes:r,boxInd:i}=e,{cropSize:a,method:l,extrapolationValue:c}=s,u=new TV(o.shape,r.shape,a,l,c);return t.runWebGLProgram(u,[o,r,i],"float32")}};var ra;(function(n){n.Prod="*",n.Sum="+"})(ra||(ra={}));class My{constructor(e,t,s,o){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const r=this.outputShape.length,i=this.op===ra.Prod?"1.0":"0.0",a=s?i:`getX(${Py(r,"coords",this.op)})`,l=this.outputShape[this.outputShape.length-1];let c="",u="";s?(c=o?`end != ${l-1}`:"end != 0",u=o?"end + 1":"end - 1"):(c=o?`end + pow2 < ${l}`:"end >= pow2",u=o?"end + pow2":"end - pow2"),this.userCode=` void main() { ${Be(r)} coords = getOutputCoords(); - int end = ${Ly(r,"coords",this.op)}; + int end = ${By(r,"coords",this.op)}; float val = ${a}; int pow2 = int(pow(2.0, index)); if (${c}) { int idx = ${u}; - ${Ly(r,"coords",this.op)} = idx; - val ${this.op}= getX(${Oy(r,"coords",this.op)}); + ${By(r,"coords",this.op)} = idx; + val ${this.op}= getX(${Py(r,"coords",this.op)}); } setOutput(val); } - `}}function Oy(n,e,t){if(n===1)return`${e}`;if(n===2)return`${e}.x, ${e}.y`;if(n===3)return`${e}.x, ${e}.y, ${e}.z`;if(n===4)return`${e}.x, ${e}.y, ${e}.z, ${e}.w`;throw new Error(`Cumulative ${t} for rank ${n} is not yet supported`)}function Ly(n,e,t){if(n===1)return`${e}`;if(n===2)return`${e}.y`;if(n===3)return`${e}.z`;if(n===4)return`${e}.w`;throw new Error(`Cumulative ${t} for rank ${n} is not yet supported`)}/** + `}}function Py(n,e,t){if(n===1)return`${e}`;if(n===2)return`${e}.x, ${e}.y`;if(n===3)return`${e}.x, ${e}.y, ${e}.z`;if(n===4)return`${e}.x, ${e}.y, ${e}.z, ${e}.w`;throw new Error(`Cumulative ${t} for rank ${n} is not yet supported`)}function By(n,e,t){if(n===1)return`${e}`;if(n===2)return`${e}.y`;if(n===3)return`${e}.z`;if(n===4)return`${e}.w`;throw new Error(`Cumulative ${t} for rank ${n} is not yet supported`)}/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15821,7 +15821,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function My(n,e,t,s,o,r){const i=e.shape.length,a=Ye([s],i);let l=e;a!=null&&(l=Bt({inputs:{x:e},backend:t,attrs:{perm:a}}));const c=tt(1,i)[0];if(c!==i-1)throw new Error(`WebGL cumprod shader expects an inner-most axis=${e.shape.length-1} but got axis=${s}`);const u=l.shape[c];let h=en({inputs:{x:l},backend:t});for(let d=0;d<=Math.ceil(Math.log2(u))-1;d++){const p=new _y(n,l.shape,!1,r),f=[[d]],g=h;h=t.runWebGLProgram(p,[h],h.dtype,f),t.disposeIntermediateTensorInfo(g)}if(o){const d=new _y(n,l.shape,o,r),p=h;h=t.runWebGLProgram(d,[h],h.dtype),t.disposeIntermediateTensorInfo(p)}if(a!=null){const d=$s(a),p=Bt({inputs:{x:h},backend:t,attrs:{perm:d}});return t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(l),p}return h}/** + */function zy(n,e,t,s,o,r){const i=e.shape.length,a=Ye([s],i);let l=e;a!=null&&(l=zt({inputs:{x:e},backend:t,attrs:{perm:a}}));const c=tt(1,i)[0];if(c!==i-1)throw new Error(`WebGL cumprod shader expects an inner-most axis=${e.shape.length-1} but got axis=${s}`);const u=l.shape[c];let h=en({inputs:{x:l},backend:t});for(let d=0;d<=Math.ceil(Math.log2(u))-1;d++){const p=new My(n,l.shape,!1,r),f=[[d]],g=h;h=t.runWebGLProgram(p,[h],h.dtype,f),t.disposeIntermediateTensorInfo(g)}if(o){const d=new My(n,l.shape,o,r),p=h;h=t.runWebGLProgram(d,[h],h.dtype),t.disposeIntermediateTensorInfo(p)}if(a!=null){const d=$s(a),p=zt({inputs:{x:h},backend:t,attrs:{perm:d}});return t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(l),p}return h}/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15836,7 +15836,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function TV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,exclusive:i,reverse:a}=s;return My(ra.Prod,o,t,r,i,a)}const NV={kernelName:tu,backendName:"webgl",kernelFunc:TV};/** + */function EV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,exclusive:i,reverse:a}=s;return zy(ra.Prod,o,t,r,i,a)}const RV={kernelName:nu,backendName:"webgl",kernelFunc:EV};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15851,7 +15851,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function EV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,exclusive:i,reverse:a}=s;return My(ra.Sum,o,t,r,i,a)}const RV={kernelName:Ca,backendName:"webgl",kernelFunc:EV};/** + */function AV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,exclusive:i,reverse:a}=s;return zy(ra.Sum,o,t,r,i,a)}const DV={kernelName:Ca,backendName:"webgl",kernelFunc:AV};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15866,7 +15866,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function AV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,weights:r}=e,{size:i,binaryOutput:a}=s;if(o.shape.length===1){const l=t.readSync(o.dataId),c=t.readSync(r.dataId),u=ny(l,c,r.dtype,r.shape,i);return t.makeTensorInfo([i],r.dtype,u)}else if(o.shape.length===2){const l=t.bufferSync(o),c=t.bufferSync(r),u=zP(l,c,i,a);return t.makeTensorInfo(u.shape,r.dtype,u.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${o.shape.length}.`)}const DV={kernelName:su,backendName:"webgl",kernelFunc:AV};/** + */function FV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,weights:r}=e,{size:i,binaryOutput:a}=s;if(o.shape.length===1){const l=t.readSync(o.dataId),c=t.readSync(r.dataId),u=ry(l,c,r.dtype,r.shape,i);return t.makeTensorInfo([i],r.dtype,u)}else if(o.shape.length===2){const l=t.bufferSync(o),c=t.bufferSync(r),u=WP(l,c,i,a);return t.makeTensorInfo(u.shape,r.dtype,u.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${o.shape.length}.`)}const _V={kernelName:ou,backendName:"webgl",kernelFunc:FV};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15881,7 +15881,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class FV{constructor(e,t,s){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=s,this.userCode=` + */class OV{constructor(e,t,s){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=s,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; @@ -15915,7 +15915,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _V(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{blockSize:r,dataFormat:i}=s,a=o.shape[0],l=i==="NHWC"?o.shape[1]:o.shape[2],c=i==="NHWC"?o.shape[2]:o.shape[3],u=i==="NHWC"?o.shape[3]:o.shape[1],h=l*r,d=c*r,p=u/(r*r),f=i==="NHWC"?[a,h,d,p]:[a,p,h,d],g=new FV(f,r,i);return t.runWebGLProgram(g,[o],o.dtype)}const OV={kernelName:ou,backendName:"webgl",kernelFunc:_V};/** + */function LV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{blockSize:r,dataFormat:i}=s,a=o.shape[0],l=i==="NHWC"?o.shape[1]:o.shape[2],c=i==="NHWC"?o.shape[2]:o.shape[3],u=i==="NHWC"?o.shape[3]:o.shape[1],h=l*r,d=c*r,p=u/(r*r),f=i==="NHWC"?[a,h,d,p]:[a,p,h,d],g=new OV(f,r,i);return t.runWebGLProgram(g,[o],o.dtype)}const MV={kernelName:ru,backendName:"webgl",kernelFunc:LV};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15930,7 +15930,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Py{constructor(e,t=!1,s=null,o=!1,r=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=At(this.outputShape.length);const i=e.filterHeight,a=e.filterWidth,l=e.outChannels/e.inChannels;let c="",u="";s&&(o?c=`float activation(float a) { + */class Vy{constructor(e,t=!1,s=null,o=!1,r=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=Ft(this.outputShape.length);const i=e.filterHeight,a=e.filterWidth,l=e.outChannels/e.inChannels;let c="",u="";s&&(o?c=`float activation(float a) { float b = getPreluActivationWeightsAtOutCoords(); ${s} }`:r?c=`float activation(float a) { @@ -15998,7 +15998,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class By{constructor(e,t=!1,s=null,o=!1,r=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=At(this.outputShape.length);const i=e.outChannels/e.inChannels,a=e.padInfo.left,l=e.strideWidth,c=e.dilationWidth,u=e.filterHeight,h=e.filterWidth,d=h;let p=` + */class Wy{constructor(e,t=!1,s=null,o=!1,r=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=Ft(this.outputShape.length);const i=e.outChannels/e.inChannels,a=e.padInfo.left,l=e.strideWidth,c=e.dilationWidth,u=e.filterHeight,h=e.filterWidth,d=h;let p=` int xR; int xC; int xCOffset; vec4 wTexel; vec4 previous; vec4 final;`;for(let x=0;x= 0 && xCOffset < inDims[1] && xTexelC${b+1}Ready == 0) { @@ -16202,7 +16202,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function LV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,filter:r}=e,{strides:i,pad:a,dilations:l,dimRoundingMode:c}=s;let u=l;u==null&&(u=[1,1]),$(Et(i,u),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${u}'`);const h=wt(o.shape,r.shape,i,u,a,c,!0);let d;W().getBool("WEBGL_PACK_DEPTHWISECONV")&&h.strideWidth<=2&&h.outChannels/h.inChannels===1?d=new By(h):d=new Py(h);const p=[[h.padInfo.top,h.padInfo.left],[h.strideHeight,h.strideWidth],[h.dilationHeight,h.dilationWidth],[h.inHeight,h.inWidth]];return t.runWebGLProgram(d,[o,r],"float32",p)}const MV={kernelName:Ia,backendName:"webgl",kernelFunc:LV};/** + */function PV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,filter:r}=e,{strides:i,pad:a,dilations:l,dimRoundingMode:c}=s;let u=l;u==null&&(u=[1,1]),$(Et(i,u),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${u}'`);const h=wt(o.shape,r.shape,i,u,a,c,!0);let d;W().getBool("WEBGL_PACK_DEPTHWISECONV")&&h.strideWidth<=2&&h.outChannels/h.inChannels===1?d=new Wy(h):d=new Vy(h);const p=[[h.padInfo.top,h.padInfo.left],[h.strideHeight,h.strideWidth],[h.dilationHeight,h.dilationWidth],[h.inHeight,h.inWidth]];return t.runWebGLProgram(d,[o,r],"float32",p)}const BV={kernelName:Ia,backendName:"webgl",kernelFunc:PV};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16217,7 +16217,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class PV{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,s=e.strideWidth,o=e.padInfo.top,r=e.padInfo.left,i=e.outChannels/e.inChannels;this.userCode=` + */class zV{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,s=e.strideWidth,o=e.padInfo.top,r=e.padInfo.left,i=e.outChannels/e.inChannels;this.userCode=` void main() { ivec4 coords = getOutputCoords(); int wR = coords.x; @@ -16252,7 +16252,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam } setOutput(dotProd); } - `}}class BV{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,s=e.filterWidth,o=e.strideHeight,r=e.strideWidth,i=t-1-e.padInfo.top,a=s-1-e.padInfo.left,l=e.outChannels/e.inChannels;this.userCode=` + `}}class VV{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,s=e.filterWidth,o=e.strideHeight,r=e.strideWidth,i=t-1-e.padInfo.top,a=s-1-e.padInfo.left,l=e.outChannels/e.inChannels;this.userCode=` const ivec2 pads = ivec2(${i}, ${a}); void main() { @@ -16312,7 +16312,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function zV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,dy:r}=e,{strides:i,dilations:a,pad:l,dimRoundingMode:c,filterShape:u}=s,h=wt(o.shape,u,i,a,l,c,!0),d=new PV(h);return t.runWebGLProgram(d,[o,r],"float32")}const VV={kernelName:ru,backendName:"webgl",kernelFunc:zV};/** + */function WV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,dy:r}=e,{strides:i,dilations:a,pad:l,dimRoundingMode:c,filterShape:u}=s,h=wt(o.shape,u,i,a,l,c,!0),d=new zV(h);return t.runWebGLProgram(d,[o,r],"float32")}const UV={kernelName:iu,backendName:"webgl",kernelFunc:WV};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16327,7 +16327,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function WV(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,filter:r}=e,{strides:i,dilations:a,pad:l,dimRoundingMode:c,inputShape:u}=s,h=wt(u,r.shape,i,a,l,c,!0),d=new BV(h);return t.runWebGLProgram(d,[o,r],"float32")}const UV={kernelName:iu,backendName:"webgl",kernelFunc:WV};/** + */function GV(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,filter:r}=e,{strides:i,dilations:a,pad:l,dimRoundingMode:c,inputShape:u}=s,h=wt(u,r.shape,i,a,l,c,!0),d=new VV(h);return t.runWebGLProgram(d,[o,r],"float32")}const HV={kernelName:au,backendName:"webgl",kernelFunc:GV};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16342,7 +16342,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class GV{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode=` + */class qV{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode=` void main() { ivec2 coords = getOutputCoords(); float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0; @@ -16363,7 +16363,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function HV(n){const{inputs:e,backend:t}=n,{x:s}=e,o=[...s.shape,...s.shape],r=H(s.shape),i=ne({inputs:{x:s},backend:t,attrs:{shape:[r]}}),a=new GV(r),l=t.runWebGLProgram(a,[i],i.dtype),c=ne({inputs:{x:l},backend:t,attrs:{shape:o}});return t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(l),c}const jV={kernelName:Hp,backendName:"webgl",kernelFunc:HV};/** + */function jV(n){const{inputs:e,backend:t}=n,{x:s}=e,o=[...s.shape,...s.shape],r=H(s.shape),i=ne({inputs:{x:s},backend:t,attrs:{shape:[r]}}),a=new qV(r),l=t.runWebGLProgram(a,[i],i.dtype),c=ne({inputs:{x:l},backend:t,attrs:{shape:o}});return t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(l),c}const KV={kernelName:Hp,backendName:"webgl",kernelFunc:jV};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16378,7 +16378,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class qV{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:t,inWidth:s,padInfo:o,strideHeight:r,strideWidth:i,filterHeight:a,filterWidth:l,dilationHeight:c,dilationWidth:u}=e,{top:h,left:d}=o;this.userCode=` + */class XV{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:t,inWidth:s,padInfo:o,strideHeight:r,strideWidth:i,filterHeight:a,filterWidth:l,dilationHeight:c,dilationWidth:u}=e,{top:h,left:d}=o;this.userCode=` const ivec2 strides = ivec2(${r}, ${i}); const ivec2 pads = ivec2(${h}, ${d}); const float neg_infinity = -3.4e38; @@ -16431,7 +16431,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function KV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,filter:r}=e,{strides:i,pad:a,dilations:l}=s,c=bi(o.shape,r.shape,i,a,"NHWC",l);let u;const h=new qV(c);u=t.runWebGLProgram(h,[o,r],"float32");const d=ne({inputs:{x:u},backend:t,attrs:{shape:c.outShape}});return t.disposeIntermediateTensorInfo(u),d}const XV={kernelName:$a,backendName:"webgl",kernelFunc:KV};/** + */function YV(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,filter:r}=e,{strides:i,pad:a,dilations:l}=s,c=bi(o.shape,r.shape,i,a,"NHWC",l);let u;const h=new XV(c);u=t.runWebGLProgram(h,[o,r],"float32");const d=ne({inputs:{x:u},backend:t,attrs:{shape:c.outShape}});return t.disposeIntermediateTensorInfo(u),d}const ZV={kernelName:$a,backendName:"webgl",kernelFunc:YV};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16446,7 +16446,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function YV(n){const{inputs:e,backend:t,attrs:s}=n,{equation:o}=s,r=e,{allDims:i,summedDims:a,idDims:l}=ad(o,r.length);cd(i.length,l,r);const{path:c,steps:u}=ud(a,l),h=u.length;let d=null,p=i.length;const f=[];for(let g=0;g=0&&(d=Cc({inputs:{x:d},backend:t,attrs:{axis:c[g]-(i.length-p),keepDims:!1}}),f.push(d)),p--)}for(const g of f)g!==d&&t.disposeIntermediateTensorInfo(g);return d}const ZV={kernelName:cu,backendName:"webgl",kernelFunc:YV};/** + */function QV(n){const{inputs:e,backend:t,attrs:s}=n,{equation:o}=s,r=e,{allDims:i,summedDims:a,idDims:l}=ad(o,r.length);cd(i.length,l,r);const{path:c,steps:u}=ud(a,l),h=u.length;let d=null,p=i.length;const f=[];for(let g=0;g=0&&(d=Ic({inputs:{x:d},backend:t,attrs:{axis:c[g]-(i.length-p),keepDims:!1}}),f.push(d)),p--)}for(const g of f)g!==d&&t.disposeIntermediateTensorInfo(g);return d}const JV={kernelName:uu,backendName:"webgl",kernelFunc:QV};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16461,7 +16461,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const QV=Re({opSnippet:"return (x >= 0.0) ? x : (exp(x) - 1.0);",packedOpSnippet:` + */const eW=Re({opSnippet:"return (x >= 0.0) ? x : (exp(x) - 1.0);",packedOpSnippet:` vec4 result; result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); @@ -16470,7 +16470,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); return result; -`}),JV={kernelName:Fr,backendName:"webgl",kernelFunc:QV};/** +`}),tW={kernelName:Fr,backendName:"webgl",kernelFunc:eW};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16485,10 +16485,10 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const eW="return (b >= 0.0) ? a : a * (b + 1.0);",tW=` + */const nW="return (b >= 0.0) ? a : a * (b + 1.0);",sW=` vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.))); return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0)))); -`,nW={kernelName:uu,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t}=n,{dy:s,y:o}=e,r=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new fr(tW,s.shape,o.shape):new ko(eW,s.shape,o.shape);return t.runWebGLProgram(r,[s,o],s.dtype)}};/** +`,oW={kernelName:hu,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t}=n,{dy:s,y:o}=e,r=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new fr(sW,s.shape,o.shape):new So(nW,s.shape,o.shape);return t.runWebGLProgram(r,[s,o],s.dtype)}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16503,9 +16503,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const sW=vt({opSnippet:"return float(a == b);",packedOpSnippet:` + */const rW=vt({opSnippet:"return float(a == b);",packedOpSnippet:` return vec4(equal(a, b)); -`,dtype:"bool",cpuKernelImpl:HP}),oW={kernelName:va,backendName:"webgl",kernelFunc:sW};/** +`,dtype:"bool",cpuKernelImpl:jP}),iW={kernelName:va,backendName:"webgl",kernelFunc:rW};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16520,7 +16520,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const rW=` + */const aW=` // Error function is calculated approximately with elementary function. // See "Handbook of Mathematical Functions with Formulas, // Graphs, and Mathematical Tables", Abramowitz and Stegun. @@ -16535,7 +16535,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam x = abs(x); float t = 1.0 / (1.0 + p * x); return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x)); -`,iW=Re({opSnippet:rW}),aW={kernelName:_r,backendName:"webgl",kernelFunc:iW};/** +`,lW=Re({opSnippet:aW}),cW={kernelName:_r,backendName:"webgl",kernelFunc:lW};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16550,9 +16550,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const lW=mr+` + */const uW=mr+` return exp(x); -`,zy=Re({opSnippet:lW,packedOpSnippet:` +`,Uy=Re({opSnippet:uW,packedOpSnippet:` vec4 result = exp(x); bvec4 isNaN = isnan(x); result.r = isNaN.r ? x.r : result.r; @@ -16561,7 +16561,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam result.a = isNaN.a ? x.a : result.a; return result; -`,cpuKernelImpl:jP,dtype:"float32"}),cW={kernelName:Or,backendName:"webgl",kernelFunc:zy};/** +`,cpuKernelImpl:KP,dtype:"float32"}),hW={kernelName:Or,backendName:"webgl",kernelFunc:Uy};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -16576,7 +16576,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function kp(n){const{inputs:e,attrs:t,backend:s}=n,{dim:o}=t,{input:r}=e,i=r.shape.length,a=r.shape.slice();let l=o;return o<0&&($(-(i+1)<=o,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+o+1),a.splice(l,0,1),ne({inputs:{x:r},backend:s,attrs:{shape:a}})}const uW={kernelName:ka,backendName:"webgl",kernelFunc:kp};/** + */function kp(n){const{inputs:e,attrs:t,backend:s}=n,{dim:o}=t,{input:r}=e,i=r.shape.length,a=r.shape.slice();let l=o;return o<0&&($(-(i+1)<=o,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+o+1),a.splice(l,0,1),ne({inputs:{x:r},backend:s,attrs:{shape:a}})}const dW={kernelName:ka,backendName:"webgl",kernelFunc:kp};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16591,7 +16591,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Vy="return exp(x) - 1.0;",hW=Re({opSnippet:Vy,packedOpSnippet:Vy,cpuKernelImpl:qP}),dW={kernelName:Lr,backendName:"webgl",kernelFunc:hW};/** + */const Gy="return exp(x) - 1.0;",pW=Re({opSnippet:Gy,packedOpSnippet:Gy,cpuKernelImpl:XP}),fW={kernelName:Lr,backendName:"webgl",kernelFunc:pW};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16606,7 +16606,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Wy{constructor(e,t,s){this.variableNames=["real","imag"];const o=t[1];this.outputShape=t;const r=s?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,i=s?`${o}.0`:"1.0";let a;if(e==="real")a="return real * expR - imag * expI;";else if(e==="imag")a="return real * expI + imag * expR;";else throw new Error(`FFT component must be either "real" or "imag", got ${e}.`);this.userCode=` + */class Hy{constructor(e,t,s){this.variableNames=["real","imag"];const o=t[1];this.outputShape=t;const r=s?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,i=s?`${o}.0`:"1.0";let a;if(e==="real")a="return real * expR - imag * expI;";else if(e==="imag")a="return real * expI + imag * expR;";else throw new Error(`FFT component must be either "real" or "imag", got ${e}.`);this.userCode=` const float exponentMultiplier = ${r}; float unaryOpComplex(float real, float expR, float imag, float expI) { @@ -16654,7 +16654,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Uy(n,e,t){const s=t.texData.get(n.dataId),o=H(n.shape),r=n.shape[n.shape.length-1],i=o/r,a=ne({inputs:{x:n},backend:t,attrs:{shape:[i,r]}}),l=a.shape,c=new Wy("real",l,e),u=new Wy("imag",l,e),h=[{dataId:s.complexTensorInfos.real.dataId,dtype:s.complexTensorInfos.real.dtype,shape:l},{dataId:s.complexTensorInfos.imag.dataId,dtype:s.complexTensorInfos.imag.dtype,shape:l}],d=t.runWebGLProgram(c,h,"float32"),p=t.runWebGLProgram(u,h,"float32"),f=Ps({inputs:{real:d,imag:p},backend:t});t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p);const g=ne({inputs:{x:f},backend:t,attrs:{shape:n.shape}});return t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(f),g}/** + */function qy(n,e,t){const s=t.texData.get(n.dataId),o=H(n.shape),r=n.shape[n.shape.length-1],i=o/r,a=ne({inputs:{x:n},backend:t,attrs:{shape:[i,r]}}),l=a.shape,c=new Hy("real",l,e),u=new Hy("imag",l,e),h=[{dataId:s.complexTensorInfos.real.dataId,dtype:s.complexTensorInfos.real.dtype,shape:l},{dataId:s.complexTensorInfos.imag.dataId,dtype:s.complexTensorInfos.imag.dtype,shape:l}],d=t.runWebGLProgram(c,h,"float32"),p=t.runWebGLProgram(u,h,"float32"),f=Ps({inputs:{real:d,imag:p},backend:t});t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p);const g=ne({inputs:{x:f},backend:t,attrs:{shape:n.shape}});return t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(f),g}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16669,7 +16669,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function pW(n){const{inputs:e,backend:t}=n,{input:s}=e;return Uy(s,!1,t)}const fW={kernelName:hu,backendName:"webgl",kernelFunc:pW};/** + */function mW(n){const{inputs:e,backend:t}=n,{input:s}=e;return qy(s,!1,t)}const gW={kernelName:du,backendName:"webgl",kernelFunc:mW};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16684,7 +16684,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class mW{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode=` + */class xW{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode=` void main() { // Input can be obtained from uniform value. setOutput(value); @@ -16704,7 +16704,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ia(n){const{backend:e,attrs:t}=n,{shape:s,value:o}=t;let{dtype:r}=t;if(r=r||Fo(o),r==="string"){const i=Je(r,H(s));return i.fill(o),e.makeTensorInfo(s,r,i)}else{const i=new mW(s,o),a=[[o]];return e.runWebGLProgram(i,[],r,a)}}const gW={kernelName:du,backendName:"webgl",kernelFunc:ia};/** + */function ia(n){const{backend:e,attrs:t}=n,{shape:s,value:o}=t;let{dtype:r}=t;if(r=r||_o(o),r==="string"){const i=Je(r,H(s));return i.fill(o),e.makeTensorInfo(s,r,i)}else{const i=new xW(s,o),a=[[o]];return e.runWebGLProgram(i,[],r,a)}}const bW={kernelName:pu,backendName:"webgl",kernelFunc:ia};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16719,7 +16719,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class xW{constructor(e){this.variableNames=["Image"],this.outputShape=[];const t=e[2];this.outputShape=e,this.userCode=` + */class yW{constructor(e){this.variableNames=["Image"],this.outputShape=[];const t=e[2];this.outputShape=e,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int x = coords[2]; @@ -16748,7 +16748,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const bW={kernelName:pu,backendName:"webgl",kernelFunc:({inputs:n,backend:e})=>{const{image:t}=n,s=e,o=new xW(t.shape);return s.runWebGLProgram(o,[t],t.dtype)}};/** + */const wW={kernelName:fu,backendName:"webgl",kernelFunc:({inputs:n,backend:e})=>{const{image:t}=n,s=e,o=new yW(t.shape);return s.runWebGLProgram(o,[t],t.dtype)}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16763,7 +16763,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Gy="return floor(x);",yW=Re({opSnippet:Gy,packedOpSnippet:Gy,cpuKernelImpl:KP}),wW={kernelName:Mr,backendName:"webgl",kernelFunc:yW};/** + */const jy="return floor(x);",CW=Re({opSnippet:jy,packedOpSnippet:jy,cpuKernelImpl:YP}),IW={kernelName:Mr,backendName:"webgl",kernelFunc:CW};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16778,7 +16778,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const CW=vt({opSnippet:` + */const $W=vt({opSnippet:` float s = sign(a) * sign(b); int ia = round(a); int ib = round(b); @@ -16809,7 +16809,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam result[3] = idiv(ia[3], ib[3], s[3]); } return vec4(result); -`,dtype:"int32"}),IW={kernelName:Pr,backendName:"webgl",kernelFunc:CW};/** +`,dtype:"int32"}),vW={kernelName:Pr,backendName:"webgl",kernelFunc:$W};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16824,7 +16824,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class $W{constructor(e){this.variableNames=["A"];const t=Mt(),[s,o]=e;this.outputShape=e,this.userCode=` + */class kW{constructor(e){this.variableNames=["A"];const t=Pt(),[s,o]=e;this.outputShape=e,this.userCode=` void main() { ivec3 coords = getOutputCoords(); int texR = coords[0]; @@ -16861,7 +16861,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class vW{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=Mt(),[s,o]=e;this.outputShape=e,this.userCode=` + */class SW{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=Pt(),[s,o]=e;this.outputShape=e,this.userCode=` void main() { ivec3 coords = getOutputCoords(); int texR = coords[0]; @@ -16910,7 +16910,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const kW={kernelName:Ow,backendName:"webgl",kernelFunc:SW};let xr,Sp=W().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");function SW(n){const{inputs:e,backend:t,attrs:s}=n;let{pixels:o}=e;const{numChannels:r}=s,i=typeof HTMLVideoElement<"u"&&o instanceof HTMLVideoElement,a=typeof HTMLImageElement<"u"&&o instanceof HTMLImageElement,[l,c]=i?[o.videoWidth,o.videoHeight]:[o.width,o.height],u=[c,l],h=[c,l,r];if(a||i){const g=W().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");(xr==null||g!==Sp)&&(Sp=g,xr=document.createElement("canvas").getContext("2d",{willReadFrequently:Sp})),xr.canvas.width=l,xr.canvas.height=c,xr.drawImage(o,0,0,l,c),o=xr.canvas}const d=t.makeTensorInfo(u,"int32");t.texData.get(d.dataId).usage=rn.PIXELS,t.gpgpu.uploadPixelDataToTexture(t.getTexture(d.dataId),o);const p=W().getBool("WEBGL_PACK")?new vW(h):new $W(h),f=t.runWebGLProgram(p,[d],"int32");return t.disposeData(d.dataId),f}/** + */const TW={kernelName:Pw,backendName:"webgl",kernelFunc:NW};let xr,Sp=W().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");function NW(n){const{inputs:e,backend:t,attrs:s}=n;let{pixels:o}=e;const{numChannels:r}=s,i=typeof HTMLVideoElement<"u"&&o instanceof HTMLVideoElement,a=typeof HTMLImageElement<"u"&&o instanceof HTMLImageElement,[l,c]=i?[o.videoWidth,o.videoHeight]:[o.width,o.height],u=[c,l],h=[c,l,r];if(a||i){const g=W().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");(xr==null||g!==Sp)&&(Sp=g,xr=document.createElement("canvas").getContext("2d",{willReadFrequently:Sp})),xr.canvas.width=l,xr.canvas.height=c,xr.drawImage(o,0,0,l,c),o=xr.canvas}const d=t.makeTensorInfo(u,"int32");t.texData.get(d.dataId).usage=rn.PIXELS,t.gpgpu.uploadPixelDataToTexture(t.getTexture(d.dataId),o);const p=W().getBool("WEBGL_PACK")?new SW(h):new kW(h),f=t.runWebGLProgram(p,[d],"int32");return t.disposeData(d.dataId),f}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16925,7 +16925,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function TW(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,filter:r,bias:i,preluActivationWeights:a}=e,{strides:l,pad:c,dataFormat:u,dilations:h,dimRoundingMode:d,activation:p,leakyreluAlpha:f}=s,g=is(u),m=wt(o.shape,r.shape,l,h,c,d,!1,g);let x;const b=[],w=i!=null,y=a!=null,C=p==="leakyrelu",I=()=>{const k=[o,r],S=(T,E)=>{if(E==="NCHW"&&T.shape.length===1&&T.shape[0]!==1){const V=ne({inputs:{x:T},backend:t,attrs:{shape:[T.shape[0],1,1]}});return b.push(V),V}return T};if(w&&k.push(S(i,u)),y&&k.push(S(a,u)),C){const T=t.makeTensorInfo([],"float32",xs(f,"float32"));k.push(T),b.push(T)}return k};if(m.filterHeight===1&&m.filterWidth===1&&m.dilationHeight===1&&m.dilationWidth===1&&m.strideHeight===1&&m.strideWidth===1&&(m.padInfo.type==="SAME"||m.padInfo.type==="VALID"))x=Dy({x:o,filter:r,convInfo:m,backend:t,bias:i,activation:p,preluActivationWeights:a,leakyreluAlpha:f});else if(m.strideWidth<=2&&g==="channelsLast"&&W().getBool("WEBGL_EXP_CONV")){const k=p?ta(p,!0):null,S=new Ay(m,w,k,y,C),T=[[m.padInfo.top,m.padInfo.left],[m.strideHeight,m.strideWidth],[m.dilationHeight,m.dilationWidth],[m.inHeight,m.inWidth]],E=I();x=t.runWebGLProgram(S,E,"float32",T)}else if(W().getBool("WEBGL_CONV_IM2COL"))x=Fy({x:o,filter:r,convInfo:m,backend:t,bias:i,activation:p,preluActivationWeights:a,leakyreluAlpha:f});else{const k=p?ta(p,!1):null,S=new Ry(m,w,k,y,C),T=I();x=t.runWebGLProgram(S,T,"float32")}const v=ne({inputs:{x},backend:t,attrs:{shape:m.outShape}});return b.push(x),b.forEach(k=>t.disposeIntermediateTensorInfo(k)),v}const NW={kernelName:ul,backendName:"webgl",kernelFunc:TW};/** + */function EW(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,filter:r,bias:i,preluActivationWeights:a}=e,{strides:l,pad:c,dataFormat:u,dilations:h,dimRoundingMode:d,activation:p,leakyreluAlpha:f}=s,g=is(u),m=wt(o.shape,r.shape,l,h,c,d,!1,g);let x;const b=[],w=i!=null,y=a!=null,C=p==="leakyrelu",I=()=>{const k=[o,r],S=(T,E)=>{if(E==="NCHW"&&T.shape.length===1&&T.shape[0]!==1){const V=ne({inputs:{x:T},backend:t,attrs:{shape:[T.shape[0],1,1]}});return b.push(V),V}return T};if(w&&k.push(S(i,u)),y&&k.push(S(a,u)),C){const T=t.makeTensorInfo([],"float32",xs(f,"float32"));k.push(T),b.push(T)}return k};if(m.filterHeight===1&&m.filterWidth===1&&m.dilationHeight===1&&m.dilationWidth===1&&m.strideHeight===1&&m.strideWidth===1&&(m.padInfo.type==="SAME"||m.padInfo.type==="VALID"))x=Oy({x:o,filter:r,convInfo:m,backend:t,bias:i,activation:p,preluActivationWeights:a,leakyreluAlpha:f});else if(m.strideWidth<=2&&g==="channelsLast"&&W().getBool("WEBGL_EXP_CONV")){const k=p?ta(p,!0):null,S=new _y(m,w,k,y,C),T=[[m.padInfo.top,m.padInfo.left],[m.strideHeight,m.strideWidth],[m.dilationHeight,m.dilationWidth],[m.inHeight,m.inWidth]],E=I();x=t.runWebGLProgram(S,E,"float32",T)}else if(W().getBool("WEBGL_CONV_IM2COL"))x=Ly({x:o,filter:r,convInfo:m,backend:t,bias:i,activation:p,preluActivationWeights:a,leakyreluAlpha:f});else{const k=p?ta(p,!1):null,S=new Fy(m,w,k,y,C),T=I();x=t.runWebGLProgram(S,T,"float32")}const v=ne({inputs:{x},backend:t,attrs:{shape:m.outShape}});return b.push(x),b.forEach(k=>t.disposeIntermediateTensorInfo(k)),v}const RW={kernelName:ul,backendName:"webgl",kernelFunc:EW};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16940,7 +16940,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function EW(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,filter:r,bias:i,preluActivationWeights:a}=e,{strides:l,pad:c,dilations:u,dimRoundingMode:h,activation:d,leakyreluAlpha:p}=s,f=[];let g=u;g==null&&(g=[1,1]),$(Et(l,g),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${g}'`);const m=wt(o.shape,r.shape,l,g,c,h,!0),x=W().getBool("WEBGL_PACK_DEPTHWISECONV")&&m.strideWidth<=2&&m.outChannels/m.inChannels===1,b=d?ta(d,x):null,w=[o,r],y=i!=null,C=a!=null,I=d==="leakyrelu";if(y&&w.push(i),C&&w.push(a),I){const T=t.makeTensorInfo([],"float32",xs(p,"float32"));w.push(T),f.push(T)}let v;x?v=new By(m,y,b,C,I):v=new Py(m,y,b,C,I);const k=[[m.padInfo.top,m.padInfo.left],[m.strideHeight,m.strideWidth],[m.dilationHeight,m.dilationWidth],[m.inHeight,m.inWidth]],S=t.runWebGLProgram(v,w,"float32",k);return f.forEach(T=>t.disposeIntermediateTensorInfo(T)),S}const RW={kernelName:hf,backendName:"webgl",kernelFunc:EW};class AW{constructor(e,t,s,o){this.sliceDim=e,this.strides=t,this.paramsShape=o,this.variableNames=["x","indices"],this.outputShape=s;const r=Be(s.length);let i=` + */function AW(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,filter:r,bias:i,preluActivationWeights:a}=e,{strides:l,pad:c,dilations:u,dimRoundingMode:h,activation:d,leakyreluAlpha:p}=s,f=[];let g=u;g==null&&(g=[1,1]),$(Et(l,g),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${g}'`);const m=wt(o.shape,r.shape,l,g,c,h,!0),x=W().getBool("WEBGL_PACK_DEPTHWISECONV")&&m.strideWidth<=2&&m.outChannels/m.inChannels===1,b=d?ta(d,x):null,w=[o,r],y=i!=null,C=a!=null,I=d==="leakyrelu";if(y&&w.push(i),C&&w.push(a),I){const T=t.makeTensorInfo([],"float32",xs(p,"float32"));w.push(T),f.push(T)}let v;x?v=new Wy(m,y,b,C,I):v=new Vy(m,y,b,C,I);const k=[[m.padInfo.top,m.padInfo.left],[m.strideHeight,m.strideWidth],[m.dilationHeight,m.dilationWidth],[m.inHeight,m.inWidth]],S=t.runWebGLProgram(v,w,"float32",k);return f.forEach(T=>t.disposeIntermediateTensorInfo(T)),S}const DW={kernelName:hf,backendName:"webgl",kernelFunc:AW};class FW{constructor(e,t,s,o){this.sliceDim=e,this.strides=t,this.paramsShape=o,this.variableNames=["x","indices"],this.outputShape=s;const r=Be(s.length);let i=` int index;`;for(let a=0;a= 0) && (index < ${e[2]}) ? 1.0 : 0.0; setOutput(inBounds * getA(${o})); } - `}}function OW(n,e){const t=["resRC.x","resRC.y","resRC.z","resRC.w"],s=[];for(let o=0;o=0,()=>`GatherV2: the index value ${C} is not in [0, ${w-1}]`)}}const c=fd(o,r,l,a),u=H(r.shape),h=[],d=ne({inputs:{x:o},backend:t,attrs:{shape:[c.batchSize,c.outerSize,c.dimSize,c.sliceSize]}}),p=ne({inputs:{x:r},backend:t,attrs:{shape:[c.batchSize,u/c.batchSize]}});h.push(d),h.push(p);const f=[c.batchSize,c.outerSize,u/c.batchSize,c.sliceSize];if(t.shouldExecuteOnCPU([o,r])||o.dtype==="string"){const b=t.bufferSync(p),w=t.bufferSync(d),y=YP(w,b,f);return h.forEach(C=>t.disposeIntermediateTensorInfo(C)),t.makeTensorInfo(c.outputShape,y.dtype,y.values)}const g=new _W(d.shape,f),m=t.runWebGLProgram(g,[d,p],d.dtype);h.push(m);const x=ne({inputs:{x:m},backend:t,attrs:{shape:c.outputShape}});return h.forEach(b=>t.disposeIntermediateTensorInfo(b)),x}const LW={kernelName:Ta,backendName:"webgl",kernelFunc:Hy};/** + */function Ky(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,indices:r}=e,{axis:i,batchDims:a}=s,l=$e(i,o.shape)[0];if(W().get("DEBUG")){const b=t.readSync(r.dataId),w=o.shape[l];for(let y=0;y=0,()=>`GatherV2: the index value ${C} is not in [0, ${w-1}]`)}}const c=fd(o,r,l,a),u=H(r.shape),h=[],d=ne({inputs:{x:o},backend:t,attrs:{shape:[c.batchSize,c.outerSize,c.dimSize,c.sliceSize]}}),p=ne({inputs:{x:r},backend:t,attrs:{shape:[c.batchSize,u/c.batchSize]}});h.push(d),h.push(p);const f=[c.batchSize,c.outerSize,u/c.batchSize,c.sliceSize];if(t.shouldExecuteOnCPU([o,r])||o.dtype==="string"){const b=t.bufferSync(p),w=t.bufferSync(d),y=QP(w,b,f);return h.forEach(C=>t.disposeIntermediateTensorInfo(C)),t.makeTensorInfo(c.outputShape,y.dtype,y.values)}const g=new LW(d.shape,f),m=t.runWebGLProgram(g,[d,p],d.dtype);h.push(m);const x=ne({inputs:{x:m},backend:t,attrs:{shape:c.outputShape}});return h.forEach(b=>t.disposeIntermediateTensorInfo(b)),x}const PW={kernelName:Ta,backendName:"webgl",kernelFunc:Ky};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17022,9 +17022,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const MW=vt({opSnippet:"return float(a > b);",packedOpSnippet:` + */const BW=vt({opSnippet:"return float(a > b);",packedOpSnippet:` return vec4(greaterThan(a, b)); -`,cpuKernelImpl:ZP,dtype:"bool"}),PW={kernelName:Na,backendName:"webgl",kernelFunc:MW};/** +`,cpuKernelImpl:JP,dtype:"bool"}),zW={kernelName:Na,backendName:"webgl",kernelFunc:BW};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17039,9 +17039,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const BW=vt({opSnippet:"return float(a >= b);",packedOpSnippet:` + */const VW=vt({opSnippet:"return float(a >= b);",packedOpSnippet:` return vec4(greaterThanEqual(a, b)); -`,dtype:"bool",cpuKernelImpl:QP}),zW={kernelName:Br,backendName:"webgl",kernelFunc:BW};/** +`,dtype:"bool",cpuKernelImpl:e3}),WW={kernelName:Br,backendName:"webgl",kernelFunc:VW};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17056,7 +17056,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function VW(n){const{inputs:e,backend:t}=n,{input:s}=e;return Uy(s,!0,t)}const WW={kernelName:fu,backendName:"webgl",kernelFunc:VW};/** + */function UW(n){const{inputs:e,backend:t}=n,{input:s}=e;return qy(s,!0,t)}const GW={kernelName:mu,backendName:"webgl",kernelFunc:UW};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17071,7 +17071,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const UW=Re({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"}),GW={kernelName:Vr,backendName:"webgl",kernelFunc:UW};/** + */const HW=Re({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"}),qW={kernelName:Vr,backendName:"webgl",kernelFunc:HW};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17086,7 +17086,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const HW=Re({opSnippet:"return float(isinf(x));",dtype:"bool"}),jW={kernelName:Wr,backendName:"webgl",kernelFunc:HW};/** + */const jW=Re({opSnippet:"return float(isinf(x));",dtype:"bool"}),KW={kernelName:Wr,backendName:"webgl",kernelFunc:jW};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17101,7 +17101,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const qW=Re({opSnippet:"return float(isnan(x));",dtype:"bool"}),KW={kernelName:Ur,backendName:"webgl",kernelFunc:qW};/** + */const XW=Re({opSnippet:"return float(isnan(x));",dtype:"bool"}),YW={kernelName:Ur,backendName:"webgl",kernelFunc:XW};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17116,9 +17116,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const XW=vt({opSnippet:"return float(a < b);",packedOpSnippet:` + */const ZW=vt({opSnippet:"return float(a < b);",packedOpSnippet:` return vec4(lessThan(a, b)); -`,cpuKernelImpl:JP,dtype:"bool"}),YW={kernelName:Ra,backendName:"webgl",kernelFunc:XW};/** +`,cpuKernelImpl:t3,dtype:"bool"}),QW={kernelName:Ra,backendName:"webgl",kernelFunc:ZW};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17133,9 +17133,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ZW=vt({opSnippet:"return float(a <= b);",packedOpSnippet:` + */const JW=vt({opSnippet:"return float(a <= b);",packedOpSnippet:` return vec4(lessThanEqual(a, b)); -`,cpuKernelImpl:e3,dtype:"bool"}),QW={kernelName:Aa,backendName:"webgl",kernelFunc:ZW};/** +`,cpuKernelImpl:n3,dtype:"bool"}),e4={kernelName:Aa,backendName:"webgl",kernelFunc:JW};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17150,7 +17150,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function JW(n){const{backend:e,attrs:t}=n,{start:s,stop:o,num:r}=t,i=t3(s,o,r);return e.makeTensorInfo([i.length],"float32",i)}const e4={kernelName:qp,backendName:"webgl",kernelFunc:JW};/** + */function t4(n){const{backend:e,attrs:t}=n,{start:s,stop:o,num:r}=t,i=s3(s,o,r);return e.makeTensorInfo([i.length],"float32",i)}const n4={kernelName:jp,backendName:"webgl",kernelFunc:t4};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17165,9 +17165,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const t4=mr+` + */const s4=mr+` return x < 0.0 ? 0./0. : log(x); -`,n4=Re({opSnippet:t4,packedOpSnippet:` +`,o4=Re({opSnippet:s4,packedOpSnippet:` vec4 result = log(x); bvec4 isNaN = isnan(x); result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r); @@ -17175,7 +17175,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b); result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a); return result; -`,cpuKernelImpl:n3}),s4={kernelName:Gr,backendName:"webgl",kernelFunc:n4};/** +`,cpuKernelImpl:o3}),r4={kernelName:Gr,backendName:"webgl",kernelFunc:o4};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17190,9 +17190,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const o4=mr+` + */const i4=mr+` return log(1.0 + x); -`,r4=Re({opSnippet:o4}),i4={kernelName:Hr,backendName:"webgl",kernelFunc:r4};/** +`,a4=Re({opSnippet:i4}),l4={kernelName:Hr,backendName:"webgl",kernelFunc:a4};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17207,11 +17207,11 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const a4=vt({opSnippet:"return float(a >= 1.0 && b >= 1.0);",packedOpSnippet:` + */const c4=vt({opSnippet:"return float(a >= 1.0 && b >= 1.0);",packedOpSnippet:` return vec4( vec4(greaterThanEqual(a, vec4(1.0))) * vec4(greaterThanEqual(b, vec4(1.0)))); -`,dtype:"bool"}),l4={kernelName:Da,backendName:"webgl",kernelFunc:a4};/** +`,dtype:"bool"}),u4={kernelName:Da,backendName:"webgl",kernelFunc:c4};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17226,7 +17226,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const c4=Re({opSnippet:"return float(!(x >= 1.0));"}),u4={kernelName:Fa,backendName:"webgl",kernelFunc:c4};/** + */const h4=Re({opSnippet:"return float(!(x >= 1.0));"}),d4={kernelName:Fa,backendName:"webgl",kernelFunc:h4};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17241,12 +17241,12 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const h4=vt({opSnippet:"return float(a >= 1.0 || b >= 1.0);",packedOpSnippet:` + */const p4=vt({opSnippet:"return float(a >= 1.0 || b >= 1.0);",packedOpSnippet:` return min( vec4(greaterThanEqual(a, vec4(1.0))) + vec4(greaterThanEqual(b, vec4(1.0))), vec4(1.0)); -`,dtype:"bool"}),d4={kernelName:_a,backendName:"webgl",kernelFunc:h4};/** +`,dtype:"bool"}),f4={kernelName:_a,backendName:"webgl",kernelFunc:p4};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17261,7 +17261,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class p4{constructor(e,t,s,o,r){this.variableNames=["x"],this.outputShape=[];const i=t,a=e[3]-1;this.outputShape=e;let l;const c=`float(${s}) + float(${o}) * sum`;r===.5?l=`inversesqrt(${c})`:r===1?l=`1.0/(${c})`:l=`exp(log(${c}) * float(-${r}));`,this.userCode=` + */class m4{constructor(e,t,s,o,r){this.variableNames=["x"],this.outputShape=[];const i=t,a=e[3]-1;this.outputShape=e;let l;const c=`float(${s}) + float(${o}) * sum`;r===.5?l=`inversesqrt(${c})`:r===1?l=`1.0/(${c})`:l=`exp(log(${c}) * float(-${r}));`,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; @@ -17295,7 +17295,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class f4{constructor(e,t,s,o,r){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const i=t,a=e[3]-1;this.outputShape=e;let l;const c=`float(${s}) + float(${o}) * sum`;r===.5?l=`inversesqrt(${c})`:r===1?l=`1.0/(${c})`:l=`exp(log(${c}) * float(-${r}));`,this.userCode=` + */class g4{constructor(e,t,s,o,r){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const i=t,a=e[3]-1;this.outputShape=e;let l;const c=`float(${s}) + float(${o}) * sum`;r===.5?l=`inversesqrt(${c})`:r===1?l=`1.0/(${c})`:l=`exp(log(${c}) * float(-${r}));`,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords.x; @@ -17372,7 +17372,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const m4={kernelName:Oa,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{depthRadius:r,bias:i,alpha:a,beta:l}=s,c=W().getBool("WEBGL_PACK_NORMALIZATION")?new f4(o.shape,r,i,a,l):new p4(o.shape,r,i,a,l);return t.runWebGLProgram(c,[o],o.dtype)}};/** + */const x4={kernelName:Oa,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{depthRadius:r,bias:i,alpha:a,beta:l}=s,c=W().getBool("WEBGL_PACK_NORMALIZATION")?new g4(o.shape,r,i,a,l):new m4(o.shape,r,i,a,l);return t.runWebGLProgram(c,[o],o.dtype)}};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17387,7 +17387,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class g4{constructor(e,t,s,o,r){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=s,this.alpha=o,this.beta=r,this.userCode=` + */class b4{constructor(e,t,s,o,r){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=s,this.alpha=o,this.beta=r,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; @@ -17457,7 +17457,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const x4={kernelName:gu,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t,attrs:s}=n,{x:o,y:r,dy:i}=e,{depthRadius:a,bias:l,alpha:c,beta:u}=s,h=new g4(o.shape,a,l,c,u);return t.runWebGLProgram(h,[o,r,i],o.dtype)}};/** + */const y4={kernelName:xu,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t,attrs:s}=n,{x:o,y:r,dy:i}=e,{depthRadius:a,bias:l,alpha:c,beta:u}=s,h=new b4(o.shape,a,l,c,u);return t.runWebGLProgram(h,[o,r,i],o.dtype)}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17472,7 +17472,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function b4(n,e,t,s){const o=H(e),i=H(n.shape)/o,a=ne({inputs:{x:n},attrs:{shape:[i,o]},backend:s}),l=To(a,n.dtype,"max",s),c=ne({inputs:{x:l},attrs:{shape:t},backend:s});return s.disposeIntermediateTensorInfo(a),s.disposeIntermediateTensorInfo(l),c}/** + */function w4(n,e,t,s){const o=H(e),i=H(n.shape)/o,a=ne({inputs:{x:n},attrs:{shape:[i,o]},backend:s}),l=No(a,n.dtype,"max",s),c=ne({inputs:{x:l},attrs:{shape:t},backend:s});return s.disposeIntermediateTensorInfo(a),s.disposeIntermediateTensorInfo(l),c}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17487,7 +17487,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function jy(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{reductionIndices:r,keepDims:i}=s,a=o.shape.length,l=$e(r,o.shape);let c=l;const u=Ye(c,a),h=u!=null,d=t.shouldExecuteOnCPU([o]);let p=o;if(h){if(d){const w=t.texData.get(p.dataId).values,y=new Array(a);for(let v=0;v`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=pn(o.shape,r,i,c,a,l);if(u.filterWidth===1&&u.filterHeight===1&&Oe(u.inShape,u.outShape))return en({inputs:{x:o},backend:t});const h=new na(u,"max",!1);return t.runWebGLProgram(h,[o],o.dtype)}const k4={kernelName:Ma,backendName:"webgl",kernelFunc:v4};/** + */function S4(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e;Ji(o,"maxPool");const{filterSize:r,strides:i,pad:a,dimRoundingMode:l}=s,c=1;$(Et(i,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=pn(o.shape,r,i,c,a,l);if(u.filterWidth===1&&u.filterHeight===1&&Oe(u.inShape,u.outShape))return en({inputs:{x:o},backend:t});const h=new na(u,"max",!1);return t.runWebGLProgram(h,[o],o.dtype)}const T4={kernelName:Ma,backendName:"webgl",kernelFunc:S4};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17541,7 +17541,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function S4(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{filterSize:r,strides:i,pad:a,dataFormat:l,dimRoundingMode:c}=s,u=[1,1,1],h=rs(o.shape,r,i,u,a,c,l),d=new Ip(h,"max",!1);return t.runWebGLProgram(d,[o],o.dtype)}const T4={kernelName:Pa,backendName:"webgl",kernelFunc:S4};/** + */function N4(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{filterSize:r,strides:i,pad:a,dataFormat:l,dimRoundingMode:c}=s,u=[1,1,1],h=rs(o.shape,r,i,u,a,c,l),d=new Ip(h,"max",!1);return t.runWebGLProgram(d,[o],o.dtype)}const E4={kernelName:Pa,backendName:"webgl",kernelFunc:N4};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17556,7 +17556,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class N4{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideHeight,s=e.strideWidth,o=e.dilationHeight,r=e.effectiveFilterHeight,i=e.effectiveFilterWidth,a=r-1-e.padInfo.top,l=i-1-e.padInfo.left,c=r*i-1;this.userCode=` + */class R4{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideHeight,s=e.strideWidth,o=e.dilationHeight,r=e.effectiveFilterHeight,i=e.effectiveFilterWidth,a=r-1-e.padInfo.top,l=i-1-e.padInfo.left,c=r*i-1;this.userCode=` const ivec2 pads = ivec2(${a}, ${l}); void main() { @@ -17602,7 +17602,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam } setOutput(dotProd); } - `}}class E4{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideDepth,s=e.strideHeight,o=e.strideWidth,r=e.dilationDepth,i=e.dilationHeight,a=e.dilationWidth,l=e.effectiveFilterDepth,c=e.effectiveFilterHeight,u=e.effectiveFilterWidth,h=l-1-e.padInfo.front,d=c-1-e.padInfo.top,p=u-1-e.padInfo.left,f=l*c*u-1;this.userCode=` + `}}class A4{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideDepth,s=e.strideHeight,o=e.strideWidth,r=e.dilationDepth,i=e.dilationHeight,a=e.dilationWidth,l=e.effectiveFilterDepth,c=e.effectiveFilterHeight,u=e.effectiveFilterWidth,h=l-1-e.padInfo.front,d=c-1-e.padInfo.top,p=u-1-e.padInfo.left,f=l*c*u-1;this.userCode=` const ivec3 pads = ivec3(${h}, ${d}, ${p}); void main() { @@ -17681,7 +17681,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function R4(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r}=e,i=r,{filterSize:a,strides:l,pad:c,dimRoundingMode:u}=s,h=[1,1,1],d=rs(i.shape,a,l,h,c,u),p=new Ip(d,"max",!0),f=t.runWebGLProgram(p,[i],i.dtype),g=new E4(d),m=t.runWebGLProgram(g,[o,f],i.dtype);return t.disposeIntermediateTensorInfo(f),m}const A4={kernelName:bu,backendName:"webgl",kernelFunc:R4};/** + */function D4(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r}=e,i=r,{filterSize:a,strides:l,pad:c,dimRoundingMode:u}=s,h=[1,1,1],d=rs(i.shape,a,l,h,c,u),p=new Ip(d,"max",!0),f=t.runWebGLProgram(p,[i],i.dtype),g=new A4(d),m=t.runWebGLProgram(g,[o,f],i.dtype);return t.disposeIntermediateTensorInfo(f),m}const F4={kernelName:yu,backendName:"webgl",kernelFunc:D4};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17696,7 +17696,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function D4(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r,output:i}=e,a=r;Ji([r,i],"maxPoolGrad");const{filterSize:l,strides:c,pad:u,dimRoundingMode:h}=s,d=pn(a.shape,l,c,1,u,h),p=!0,f=new na(d,"max",p),g=t.runWebGLProgram(f,[a],a.dtype),m=new N4(d),x=t.runWebGLProgram(m,[o,g],a.dtype);return t.disposeIntermediateTensorInfo(g),x}const F4={kernelName:xu,backendName:"webgl",kernelFunc:D4};/** + */function _4(n){const{inputs:e,backend:t,attrs:s}=n,{dy:o,input:r,output:i}=e,a=r;Ji([r,i],"maxPoolGrad");const{filterSize:l,strides:c,pad:u,dimRoundingMode:h}=s,d=pn(a.shape,l,c,1,u,h),p=!0,f=new na(d,"max",p),g=t.runWebGLProgram(f,[a],a.dtype),m=new R4(d),x=t.runWebGLProgram(m,[o,g],a.dtype);return t.disposeIntermediateTensorInfo(g),x}const O4={kernelName:bu,backendName:"webgl",kernelFunc:_4};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17711,7 +17711,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _4(n,e,t,s){let o=new na(t,"max",!1);const r=s.runWebGLProgram(o,[n],"float32");o=new na(t,"max",!0,!0,e);const i=s.runWebGLProgram(o,[n],"float32");return[r,i]}/** + */function L4(n,e,t,s){let o=new na(t,"max",!1);const r=s.runWebGLProgram(o,[n],"float32");o=new na(t,"max",!0,!0,e);const i=s.runWebGLProgram(o,[n],"float32");return[r,i]}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17726,7 +17726,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const O4={kernelName:Kp,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:s}=n,{filterSize:o,strides:r,pad:i,includeBatchInIndex:a}=e,l=t;$(s.shape.length===4,()=>`Error in maxPool: input must be rank 4 but got rank ${s.shape.length}.`);const c=[1,1];$(Et(r,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${r} and dilations '${c}'`);const u=pn(s.shape,o,r,c,i),[h,d]=_4(s,a,u,l);return[h,d]}};/** + */const M4={kernelName:Kp,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:s}=n,{filterSize:o,strides:r,pad:i,includeBatchInIndex:a}=e,l=t;$(s.shape.length===4,()=>`Error in maxPool: input must be rank 4 but got rank ${s.shape.length}.`);const c=[1,1];$(Et(r,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${r} and dilations '${c}'`);const u=pn(s.shape,o,r,c,i),[h,d]=L4(s,a,u,l);return[h,d]}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17741,7 +17741,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function L4(n,e,t,s){const o=H(e),i=H(n.shape)/o,a=ne({inputs:{x:n},attrs:{shape:[i,o]},backend:s}),l=To(a,"float32","mean",s),c=ne({inputs:{x:l},attrs:{shape:t},backend:s});return s.disposeIntermediateTensorInfo(a),s.disposeIntermediateTensorInfo(l),c}/** + */function P4(n,e,t,s){const o=H(e),i=H(n.shape)/o,a=ne({inputs:{x:n},attrs:{shape:[i,o]},backend:s}),l=No(a,"float32","mean",s),c=ne({inputs:{x:l},attrs:{shape:t},backend:s});return s.disposeIntermediateTensorInfo(a),s.disposeIntermediateTensorInfo(l),c}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17756,7 +17756,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const M4={kernelName:Ba,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:s}=n,{keepDims:o,axis:r}=e,i=t,a=s.shape.length,l=$e(r,s.shape);let c=l;const u=Ye(c,a),h=u!=null,d=i.shouldExecuteOnCPU([s]),p=[];let f=s;if(h){if(d){const y=i.texData.get(f.dataId).values,C=new Array(a);for(let k=0;k{const{x:s}=n,{keepDims:o,axis:r}=e,i=t,a=s.shape.length,l=$e(r,s.shape);let c=l;const u=Ye(c,a),h=u!=null,d=i.shouldExecuteOnCPU([s]),p=[];let f=s;if(h){if(d){const y=i.texData.get(f.dataId).values,C=new Array(a);for(let k=0;ku[0]+e[h]+u[1]);const o=e.length,r=Be(o),i=t.map(u=>u[0]).join(","),a=t.map((u,h)=>u[0]+e[h]).join(","),l=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,o),c=s==="reflect"?0:1;if(o===1){this.userCode=` + */class q4{constructor(e,t,s){this.variableNames=["x"],this.outputShape=t.map((u,h)=>u[0]+e[h]+u[1]);const o=e.length,r=Be(o),i=t.map(u=>u[0]).join(","),a=t.map((u,h)=>u[0]+e[h]).join(","),l=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,o),c=s==="reflect"?0:1;if(o===1){this.userCode=` int start = ${i}; int end = ${a}; @@ -17854,7 +17854,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class H4{constructor(e,t,s){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((f,g)=>f[0]+e[g]+f[1]);const o=e.length,r=Be(o),i=t.map(f=>f[0]).join(","),a=t.map((f,g)=>f[0]+e[g]).join(","),l=Pt("rc",o),c=Pt("source",o),u=`${l[o-1]} < ${this.outputShape[o-1]}`,h=o===1?"source":`vec2(${c.slice(-2).join()})`,d=s==="reflect"?0:1;let p="";if(o===1){const f=` + */class j4{constructor(e,t,s){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((f,g)=>f[0]+e[g]+f[1]);const o=e.length,r=Be(o),i=t.map(f=>f[0]).join(","),a=t.map((f,g)=>f[0]+e[g]).join(","),l=Bt("rc",o),c=Bt("source",o),u=`${l[o-1]} < ${this.outputShape[o-1]}`,h=o===1?"source":`vec2(${c.slice(-2).join()})`,d=s==="reflect"?0:1;let p="";if(o===1){const f=` ${r} source = rc; if (source < start) { source = start * 2 - source - ${d}; @@ -17925,7 +17925,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const j4={kernelName:Va,backendName:"webgl",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:s}=n,{paddings:o,mode:r}=t,i=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new H4(s.shape,o,r):new G4(s.shape,o,r);return e.runWebGLProgram(i,[s],s.dtype)}};/** + */const K4={kernelName:Va,backendName:"webgl",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:s}=n,{paddings:o,mode:r}=t,i=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new j4(s.shape,o,r):new q4(s.shape,o,r);return e.runWebGLProgram(i,[s],s.dtype)}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17940,13 +17940,13 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const q4=`if (b == 0.0) return NAN; - return mod(a, b);`,K4=` + */const X4=`if (b == 0.0) return NAN; + return mod(a, b);`,Y4=` vec4 result = mod(a, b); bvec4 isNaN = equal(b, vec4(0.0)); - `+So+` + `+To+` return result; -`,X4=vt({opSnippet:q4,packedOpSnippet:K4}),Y4={kernelName:Kr,backendName:"webgl",kernelFunc:X4};/** +`,Z4=vt({opSnippet:X4,packedOpSnippet:Y4}),Q4={kernelName:Kr,backendName:"webgl",kernelFunc:Z4};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17961,7 +17961,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Z4{constructor(e,t,s){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,s],this.userCode=` + */class J4{constructor(e,t,s){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,s],this.userCode=` void main() { ivec2 coords = getOutputCoords(); int batch = coords[0]; @@ -17996,7 +17996,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,oz=Re({opSnippet:sz}),rz={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const qy=vt({opSnippet:` + */const Yy=vt({opSnippet:` if (a == b) { return 1.0; }; @@ -18018,7 +18018,7 @@ return a / b;`,packedOpSnippet:` } return result; -`,checkOutOfBounds:!0}),Q4={kernelName:Dr,backendName:"webgl",kernelFunc:qy};/** +`,checkOutOfBounds:!0}),eU={kernelName:Dr,backendName:"webgl",kernelFunc:Yy};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18033,7 +18033,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Ky="return a - b;",Xy=vt({opSnippet:Ky,packedOpSnippet:Ky,supportsComplex:!0,cpuKernelImpl:S3}),J4={kernelName:ui,backendName:"webgl",kernelFunc:Xy};/** + */const Zy="return a - b;",Qy=vt({opSnippet:Zy,packedOpSnippet:Zy,supportsComplex:!0,cpuKernelImpl:N3}),tU={kernelName:ui,backendName:"webgl",kernelFunc:Qy};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18048,7 +18048,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Yy(n){const{inputs:e,backend:t,attrs:s}=n,{logits:o}=e,{dim:r}=s,i=$e([r],o.shape),a=jy({inputs:{x:o},backend:t,attrs:{reductionIndices:i,keepDims:!1}}),l=it(a.shape,i),c=ne({inputs:{x:a},backend:t,attrs:{shape:l}}),u=Xy({inputs:{a:o,b:c},backend:t}),h=zy({inputs:{x:u},backend:t}),d=Cc({inputs:{x:h},backend:t,attrs:{axis:i,keepDims:!1}}),p=ne({inputs:{x:d},backend:t,attrs:{shape:l}}),f=qy({inputs:{a:h,b:p},backend:t});return t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(c),t.disposeIntermediateTensorInfo(u),t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),f}const eU={kernelName:rl,backendName:"webgl",kernelFunc:Yy};/** + */function Jy(n){const{inputs:e,backend:t,attrs:s}=n,{logits:o}=e,{dim:r}=s,i=$e([r],o.shape),a=Xy({inputs:{x:o},backend:t,attrs:{reductionIndices:i,keepDims:!1}}),l=it(a.shape,i),c=ne({inputs:{x:a},backend:t,attrs:{shape:l}}),u=Qy({inputs:{a:o,b:c},backend:t}),h=Uy({inputs:{x:u},backend:t}),d=Ic({inputs:{x:h},backend:t,attrs:{axis:i,keepDims:!1}}),p=ne({inputs:{x:d},backend:t,attrs:{shape:l}}),f=Yy({inputs:{a:h,b:p},backend:t});return t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(c),t.disposeIntermediateTensorInfo(u),t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),f}const nU={kernelName:rl,backendName:"webgl",kernelFunc:Jy};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18063,7 +18063,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function tU(n){const{inputs:e,backend:t,attrs:s}=n,{logits:o}=e,{numSamples:r,seed:i,normalized:a}=s,l=a?o:Yy({inputs:{logits:o},backend:t,attrs:{dim:o.shape.length-1}}),c=l.shape[0],u=l.shape[1],h=new Z4(c,u,r),d=[[i]],p=t.runWebGLProgram(h,[l],"int32",d);return a||t.disposeIntermediateTensorInfo(l),p}const nU={kernelName:Xp,backendName:"webgl",kernelFunc:tU};/** + */function sU(n){const{inputs:e,backend:t,attrs:s}=n,{logits:o}=e,{numSamples:r,seed:i,normalized:a}=s,l=a?o:Jy({inputs:{logits:o},backend:t,attrs:{dim:o.shape.length-1}}),c=l.shape[0],u=l.shape[1],h=new J4(c,u,r),d=[[i]],p=t.runWebGLProgram(h,[l],"int32",d);return a||t.disposeIntermediateTensorInfo(l),p}const oU={kernelName:Xp,backendName:"webgl",kernelFunc:sU};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18078,9 +18078,9 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const sU=In+` + */const rU=In+` return -x; -`,oU=` +`,iU=` vec4 result = -x; bvec4 isNaN = isnan(x); @@ -18090,7 +18090,7 @@ return a / b;`,packedOpSnippet:` result.a = isNaN.a ? x.a : result.a; return result; -`;function rU(n){const{inputs:e,backend:t}=n,{x:s}=e;if(t.shouldExecuteOnCPU([s])){const r=t.texData.get(s.dataId),[i,a]=a3(r.values,s.shape,s.dtype);return t.makeTensorInfo(a,s.dtype,i)}let o;return W().getBool("WEBGL_PACK_UNARY_OPERATIONS")?o=new Ms(s.shape,oU):o=new ts(s.shape,sU),t.runWebGLProgram(o,[s],s.dtype)}const iU={kernelName:Wa,backendName:"webgl",kernelFunc:rU};/** +`;function aU(n){const{inputs:e,backend:t}=n,{x:s}=e;if(t.shouldExecuteOnCPU([s])){const r=t.texData.get(s.dataId),[i,a]=c3(r.values,s.shape,s.dtype);return t.makeTensorInfo(a,s.dtype,i)}let o;return W().getBool("WEBGL_PACK_UNARY_OPERATIONS")?o=new Ms(s.shape,iU):o=new ts(s.shape,rU),t.runWebGLProgram(o,[s],s.dtype)}const lU={kernelName:Wa,backendName:"webgl",kernelFunc:aU};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18105,7 +18105,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const aU=Oh;function lU(n){tn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:s}=n,{boxes:o,scores:r}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l}=s,c=t.readSync(o.dataId),u=t.readSync(r.dataId),{selectedIndices:h}=aU(c,u,i,a,l);return t.makeTensorInfo([h.length],"int32",new Int32Array(h))}const cU={kernelName:yu,backendName:"webgl",kernelFunc:lU};/** + */const cU=Oh;function uU(n){tn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:s}=n,{boxes:o,scores:r}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l}=s,c=t.readSync(o.dataId),u=t.readSync(r.dataId),{selectedIndices:h}=cU(c,u,i,a,l);return t.makeTensorInfo([h.length],"int32",new Int32Array(h))}const hU={kernelName:wu,backendName:"webgl",kernelFunc:uU};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18120,7 +18120,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const uU=Lh;function hU(n){tn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:s}=n,{boxes:o,scores:r}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l,padToMaxOutputSize:c}=s,u=t.readSync(o.dataId),h=t.readSync(r.dataId),{selectedIndices:d,validOutputs:p}=uU(u,h,i,a,l,c);return[t.makeTensorInfo([d.length],"int32",new Int32Array(d)),t.makeTensorInfo([],"int32",new Int32Array([p]))]}const dU={kernelName:wu,backendName:"webgl",kernelFunc:hU};/** + */const dU=Lh;function pU(n){tn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:s}=n,{boxes:o,scores:r}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l,padToMaxOutputSize:c}=s,u=t.readSync(o.dataId),h=t.readSync(r.dataId),{selectedIndices:d,validOutputs:p}=dU(u,h,i,a,l,c);return[t.makeTensorInfo([d.length],"int32",new Int32Array(d)),t.makeTensorInfo([],"int32",new Int32Array([p]))]}const fU={kernelName:Cu,backendName:"webgl",kernelFunc:pU};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18135,7 +18135,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const pU=Mh;function fU(n){tn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:s}=n,{boxes:o,scores:r}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l,softNmsSigma:c}=s,u=t.readSync(o.dataId),h=t.readSync(r.dataId),d=i,p=a,f=l,g=c,{selectedIndices:m,selectedScores:x}=pU(u,h,d,p,f,g);return[t.makeTensorInfo([m.length],"int32",new Int32Array(m)),t.makeTensorInfo([x.length],"float32",new Float32Array(x))]}const mU={kernelName:Cu,backendName:"webgl",kernelFunc:fU};/** + */const mU=Mh;function gU(n){tn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:s}=n,{boxes:o,scores:r}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l,softNmsSigma:c}=s,u=t.readSync(o.dataId),h=t.readSync(r.dataId),d=i,p=a,f=l,g=c,{selectedIndices:m,selectedScores:x}=mU(u,h,d,p,f,g);return[t.makeTensorInfo([m.length],"int32",new Int32Array(m)),t.makeTensorInfo([x.length],"float32",new Float32Array(x))]}const xU={kernelName:Iu,backendName:"webgl",kernelFunc:gU};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18150,7 +18150,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class gU{constructor(e,t,s,o){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=` + */class bU{constructor(e,t,s,o){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=` void main() { ivec2 coords = getOutputCoords(); int index = round(getIndices(coords.x)); @@ -18172,7 +18172,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const xU={kernelName:Ha,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t,attrs:s}=n,{indices:o}=e,{dtype:r,depth:i,onValue:a,offValue:l}=s,c=H(o.shape),u=new gU(c,i,a,l),h=ne({inputs:{x:o},backend:t,attrs:{shape:[c]}}),d=t.runWebGLProgram(u,[h],r);t.disposeIntermediateTensorInfo(h);const p=[...o.shape,i],f=ne({inputs:{x:d},backend:t,attrs:{shape:p}});return t.disposeIntermediateTensorInfo(d),f}};/** + */const yU={kernelName:Ha,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t,attrs:s}=n,{indices:o}=e,{dtype:r,depth:i,onValue:a,offValue:l}=s,c=H(o.shape),u=new bU(c,i,a,l),h=ne({inputs:{x:o},backend:t,attrs:{shape:[c]}}),d=t.runWebGLProgram(u,[h],r);t.disposeIntermediateTensorInfo(h);const p=[...o.shape,i],f=ne({inputs:{x:d},backend:t,attrs:{shape:p}});return t.disposeIntermediateTensorInfo(d),f}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18187,7 +18187,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Tc(n){const{inputs:e,backend:t}=n,{x:s}=e;if(s.dtype==="complex64"){const o=sa({inputs:{input:s},backend:t}),r=Tc({inputs:{x:o},backend:t}),i=kc({inputs:{input:s},backend:t}),a=Tc({inputs:{x:i},backend:t}),l=Ps({inputs:{real:r,imag:a},backend:t});return t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(r),t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(a),l}else return ia({attrs:{shape:s.shape,dtype:s.dtype,value:s.dtype==="string"?"":0},backend:t})}const bU={kernelName:ll,backendName:"webgl",kernelFunc:Tc};/** + */function Nc(n){const{inputs:e,backend:t}=n,{x:s}=e;if(s.dtype==="complex64"){const o=sa({inputs:{input:s},backend:t}),r=Nc({inputs:{x:o},backend:t}),i=Sc({inputs:{input:s},backend:t}),a=Nc({inputs:{x:i},backend:t}),l=Ps({inputs:{real:r,imag:a},backend:t});return t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(r),t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(a),l}else return ia({attrs:{shape:s.shape,dtype:s.dtype,value:s.dtype==="string"?"":0},backend:t})}const wU={kernelName:ll,backendName:"webgl",kernelFunc:Nc};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18202,7 +18202,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Zy(n){const{inputs:e,backend:t}=n,{x:s}=e;if(s.dtype==="string")throw new Error("onesLike is not supported under string dtype");if(s.dtype==="complex64"){const o=sa({inputs:{input:s},backend:t}),r=Zy({inputs:{x:o},backend:t}),i=kc({inputs:{input:s},backend:t}),a=Tc({inputs:{x:i},backend:t}),l=Ps({inputs:{real:r,imag:a},backend:t});return t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(r),t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(a),l}else return ia({attrs:{shape:s.shape,dtype:s.dtype,value:1},backend:t})}const yU={kernelName:Ga,backendName:"webgl",kernelFunc:Zy};/** + */function ew(n){const{inputs:e,backend:t}=n,{x:s}=e;if(s.dtype==="string")throw new Error("onesLike is not supported under string dtype");if(s.dtype==="complex64"){const o=sa({inputs:{input:s},backend:t}),r=ew({inputs:{x:o},backend:t}),i=Sc({inputs:{input:s},backend:t}),a=Nc({inputs:{x:i},backend:t}),l=Ps({inputs:{real:r,imag:a},backend:t});return t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(r),t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(a),l}else return ia({attrs:{shape:s.shape,dtype:s.dtype,value:1},backend:t})}const CU={kernelName:Ga,backendName:"webgl",kernelFunc:ew};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18217,7 +18217,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function wU(n){const{inputs:e,backend:t,attrs:s}=n,{axis:o}=s;if(e.length===1)return kp({inputs:{input:e[0]},backend:t,attrs:{dim:o}});const r=e[0].shape,i=e[0].dtype;e.forEach(u=>{Oc(r,u.shape,"All tensors passed to stack must have matching shapes"),$(i===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});const a=[],l=e.map(u=>{const h=kp({inputs:{input:u},backend:t,attrs:{dim:o}});return a.push(h),h}),c=Ey({inputs:l,backend:t,attrs:{axis:o}});return a.forEach(u=>t.disposeIntermediateTensorInfo(u)),c}const CU={kernelName:ja,backendName:"webgl",kernelFunc:wU};/** + */function IU(n){const{inputs:e,backend:t,attrs:s}=n,{axis:o}=s;if(e.length===1)return kp({inputs:{input:e[0]},backend:t,attrs:{dim:o}});const r=e[0].shape,i=e[0].dtype;e.forEach(u=>{Lc(r,u.shape,"All tensors passed to stack must have matching shapes"),$(i===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});const a=[],l=e.map(u=>{const h=kp({inputs:{input:u},backend:t,attrs:{dim:o}});return a.push(h),h}),c=Dy({inputs:l,backend:t,attrs:{axis:o}});return a.forEach(u=>t.disposeIntermediateTensorInfo(u)),c}const $U={kernelName:qa,backendName:"webgl",kernelFunc:IU};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18232,7 +18232,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class IU{constructor(e,t,s){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((c,u)=>c[0]+e[u]+c[1]);const o=e.length,r=Be(o),i=t.map(c=>c[0]).join(","),a=t.map((c,u)=>c[0]+e[u]).join(","),l=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,o);if(o===1){this.userCode=` + */class vU{constructor(e,t,s){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((c,u)=>c[0]+e[u]+c[1]);const o=e.length,r=Be(o),i=t.map(c=>c[0]).join(","),a=t.map((c,u)=>c[0]+e[u]).join(","),l=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,o);if(o===1){this.userCode=` int start = ${i}; int end = ${a}; @@ -18272,7 +18272,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class $U{constructor(e,t,s){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((g,m)=>g[0]+e[m]+g[1]);const o=e.length,r=Be(o),i=t.map(g=>g[0]).join(","),a=t.map((g,m)=>g[0]+e[m]).join(","),l=Pt("rc",o),c=Pt("source",o),u=`${l[o-1]} < ${this.outputShape[o-1]}`,h=o===1?"source":`vec2(${c.slice(-2).join()})`,d=[`${r} rc = outputLoc;`,`${l[o-1]} += 1; + */class kU{constructor(e,t,s){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((g,m)=>g[0]+e[m]+g[1]);const o=e.length,r=Be(o),i=t.map(g=>g[0]).join(","),a=t.map((g,m)=>g[0]+e[m]).join(","),l=Bt("rc",o),c=Bt("source",o),u=`${l[o-1]} < ${this.outputShape[o-1]}`,h=o===1?"source":`vec2(${c.slice(-2).join()})`,d=[`${r} rc = outputLoc;`,`${l[o-1]} += 1; if(${u}) { `,o===1?"":`} rc = outputLoc; @@ -18311,7 +18311,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Qy=n=>{const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{paddings:r,constantValue:i}=s;if(H(o.shape)===0){const c=r.map((u,h)=>u[0]+o.shape[h]+u[1]);return ia({backend:t,attrs:{shape:c,value:i,dtype:o.dtype}})}const a=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new $U(o.shape,r,i):new IU(o.shape,r,i),l=[[i]];return t.runWebGLProgram(a,[o],o.dtype,l)},vU={kernelName:qa,backendName:"webgl",kernelFunc:Qy};/** + */const tw=n=>{const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{paddings:r,constantValue:i}=s;if(H(o.shape)===0){const c=r.map((u,h)=>u[0]+o.shape[h]+u[1]);return ia({backend:t,attrs:{shape:c,value:i,dtype:o.dtype}})}const a=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new kU(o.shape,r,i):new vU(o.shape,r,i),l=[[i]];return t.runWebGLProgram(a,[o],o.dtype,l)},SU={kernelName:ja,backendName:"webgl",kernelFunc:tw};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18326,7 +18326,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const kU=` + */const TU=` if(a < 0.0 && floor(b) < b){ return NAN; } @@ -18335,7 +18335,7 @@ return a / b;`,packedOpSnippet:` } return (round(mod(b, 2.0)) != 1) ? pow(abs(a), b) : sign(a) * pow(abs(a), b); -`,SU=` +`,NU=` // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise. vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1))); vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1); @@ -18351,9 +18351,9 @@ return a / b;`,packedOpSnippet:` bvec4 isNaN1 = lessThan(a, vec4(0.0)); bvec4 isNaN2 = lessThan(floor(b), b); bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w); - `+So+` + `+To+` return result; -`,TU=vt({opSnippet:kU,packedOpSnippet:SU}),NU={kernelName:Yr,backendName:"webgl",kernelFunc:TU};/** +`,EU=vt({opSnippet:TU,packedOpSnippet:NU}),RU={kernelName:Yr,backendName:"webgl",kernelFunc:EU};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18368,7 +18368,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function EU(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,keepDims:i}=s,a=o.shape.length,l=[],c=$e(r,o.shape);let u=c;const h=Ye(u,a);let d=o;h!=null&&(d=Bt({inputs:{x:o},backend:t,attrs:{perm:h}}),u=tt(u.length,a),l.push(d)),It("prod",u,a);let p;if(t.shouldExecuteOnCPU([d])){const f=t.texData.get(d.dataId).values,{outVals:g,outShape:m,outDtype:x}=c3(d.shape,d.dtype,f,u);p=t.makeTensorInfo(m,x,g)}else{const[f,g]=xt(d.shape,u),m=H(g),x=ne({inputs:{x:d},backend:t,attrs:{shape:[-1,m]}}),b=Wu(o.dtype),w=To(x,b,"prod",t);p=ne({inputs:{x:w},backend:t,attrs:{shape:f}}),l.push(x),l.push(w)}if(i){l.push(p);const f=it(p.shape,c);p=ne({inputs:{x:p},backend:t,attrs:{shape:f}})}return l.forEach(f=>t.disposeIntermediateTensorInfo(f)),p}const RU={kernelName:Xa,backendName:"webgl",kernelFunc:EU};/** + */function AU(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{axis:r,keepDims:i}=s,a=o.shape.length,l=[],c=$e(r,o.shape);let u=c;const h=Ye(u,a);let d=o;h!=null&&(d=zt({inputs:{x:o},backend:t,attrs:{perm:h}}),u=tt(u.length,a),l.push(d)),It("prod",u,a);let p;if(t.shouldExecuteOnCPU([d])){const f=t.texData.get(d.dataId).values,{outVals:g,outShape:m,outDtype:x}=h3(d.shape,d.dtype,f,u);p=t.makeTensorInfo(m,x,g)}else{const[f,g]=xt(d.shape,u),m=H(g),x=ne({inputs:{x:d},backend:t,attrs:{shape:[-1,m]}}),b=Uu(o.dtype),w=No(x,b,"prod",t);p=ne({inputs:{x:w},backend:t,attrs:{shape:f}}),l.push(x),l.push(w)}if(i){l.push(p);const f=it(p.shape,c);p=ne({inputs:{x:p},backend:t,attrs:{shape:f}})}return l.forEach(f=>t.disposeIntermediateTensorInfo(f)),p}const DU={kernelName:Xa,backendName:"webgl",kernelFunc:AU};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18383,7 +18383,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function AU(n){const{inputs:e,backend:t,attrs:s}=n,{paramsNestedSplits:o,paramsDenseValues:r,indices:i}=e,{outputRaggedRank:a}=s,l=o.map(x=>t.readSync(x.dataId)),c=o.map(x=>x.shape),u=t.readSync(r.dataId),h=t.readSync(i.dataId),[d,p,f]=u3(l,c,u,r.shape,r.dtype,h,i.shape,a),g=d.map(x=>t.makeTensorInfo([x.length],"int32",x)),m=t.makeTensorInfo(f,r.dtype,p);return g.concat([m])}const DU={kernelName:Yp,backendName:"webgl",kernelFunc:AU};/** + */function FU(n){const{inputs:e,backend:t,attrs:s}=n,{paramsNestedSplits:o,paramsDenseValues:r,indices:i}=e,{outputRaggedRank:a}=s,l=o.map(x=>t.readSync(x.dataId)),c=o.map(x=>x.shape),u=t.readSync(r.dataId),h=t.readSync(i.dataId),[d,p,f]=d3(l,c,u,r.shape,r.dtype,h,i.shape,a),g=d.map(x=>t.makeTensorInfo([x.length],"int32",x)),m=t.makeTensorInfo(f,r.dtype,p);return g.concat([m])}const _U={kernelName:Yp,backendName:"webgl",kernelFunc:FU};/** * @license * Copyright 2022 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18398,7 +18398,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function FU(n){const{inputs:e,backend:t}=n,{starts:s,limits:o,deltas:r}=e,i=t.readSync(s.dataId),a=t.readSync(o.dataId),l=t.readSync(r.dataId),[c,u]=h3(i,s.shape,s.dtype,a,o.shape,l,r.shape),h=t.makeTensorInfo([c.length],"int32",c),d=t.makeTensorInfo([u.length],s.dtype,u);return[h,d]}const _U={kernelName:Zp,backendName:"webgl",kernelFunc:FU};/** + */function OU(n){const{inputs:e,backend:t}=n,{starts:s,limits:o,deltas:r}=e,i=t.readSync(s.dataId),a=t.readSync(o.dataId),l=t.readSync(r.dataId),[c,u]=p3(i,s.shape,s.dtype,a,o.shape,l,r.shape),h=t.makeTensorInfo([c.length],"int32",c),d=t.makeTensorInfo([u.length],s.dtype,u);return[h,d]}const LU={kernelName:Zp,backendName:"webgl",kernelFunc:OU};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18413,7 +18413,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function OU(n){const{inputs:e,backend:t,attrs:s}=n,{shape:o,values:r,defaultValue:i,rowPartitionTensors:a}=e,{rowPartitionTypes:l}=s,c=t.readSync(o.dataId),u=t.readSync(r.dataId),h=t.readSync(i.dataId),d=a.map(m=>t.readSync(m.dataId)),p=a.map(m=>m.shape),[f,g]=d3(c,o.shape,u,r.shape,r.dtype,h,i.shape,d,p,l);return t.makeTensorInfo(f,r.dtype,g)}const LU={kernelName:Qp,backendName:"webgl",kernelFunc:OU};/** + */function MU(n){const{inputs:e,backend:t,attrs:s}=n,{shape:o,values:r,defaultValue:i,rowPartitionTensors:a}=e,{rowPartitionTypes:l}=s,c=t.readSync(o.dataId),u=t.readSync(r.dataId),h=t.readSync(i.dataId),d=a.map(m=>t.readSync(m.dataId)),p=a.map(m=>m.shape),[f,g]=f3(c,o.shape,u,r.shape,r.dtype,h,i.shape,d,p,l);return t.makeTensorInfo(f,r.dtype,g)}const PU={kernelName:Qp,backendName:"webgl",kernelFunc:MU};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18428,7 +18428,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Jy=n=>{const{backend:e,attrs:t}=n,{start:s,stop:o,step:r,dtype:i}=t,a=p3(s,o,r,i);return e.makeTensorInfo([a.length],i,a)},MU={kernelName:Iu,backendName:"webgl",kernelFunc:Jy};/** + */const nw=n=>{const{backend:e,attrs:t}=n,{start:s,stop:o,step:r,dtype:i}=t,a=m3(s,o,r,i);return e.makeTensorInfo([a.length],i,a)},BU={kernelName:$u,backendName:"webgl",kernelFunc:nw};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18443,7 +18443,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const PU=Re({opSnippet:"return 1.0 / x;"}),BU={kernelName:Zr,backendName:"webgl",kernelFunc:PU};/** + */const zU=Re({opSnippet:"return 1.0 / x;"}),VU={kernelName:Zr,backendName:"webgl",kernelFunc:zU};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18458,9 +18458,9 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const zU=In+` + */const WU=In+` return (x < 0.0) ? 0.0 : x; -`,VU=Re({opSnippet:zU,packedOpSnippet:` +`,UU=Re({opSnippet:WU,packedOpSnippet:` vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); bvec4 isNaN = isnan(x); @@ -18470,7 +18470,7 @@ return a / b;`,packedOpSnippet:` result.a = isNaN.a ? x.a : result.a; return result; -`}),WU={kernelName:Qr,backendName:"webgl",kernelFunc:VU};/** +`}),GU={kernelName:Qr,backendName:"webgl",kernelFunc:UU};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18485,9 +18485,9 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const UU=In+` + */const HU=In+` return (x < 0.0) ? 0.0 : min(6.0, x); -`,GU=Re({opSnippet:UU,packedOpSnippet:` +`,qU=Re({opSnippet:HU,packedOpSnippet:` vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); bvec4 isNaN = isnan(x); @@ -18497,7 +18497,7 @@ return a / b;`,packedOpSnippet:` result.a = isNaN.a ? x.a : result.a; return result; -`}),HU={kernelName:Jr,backendName:"webgl",kernelFunc:GU};/** +`}),jU={kernelName:Jr,backendName:"webgl",kernelFunc:qU};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18512,7 +18512,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class jU{constructor(e,t,s,o,r){this.variableNames=["A"],this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,t,s,c];const u=[o&&t>1?a-1:a,o&&s>1?l-1:l],h=[o&&t>1?t-1:t,o&&s>1?s-1:s];let d;r?d="(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":d="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` + */class KU{constructor(e,t,s,o,r){this.variableNames=["A"],this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,t,s,c];const u=[o&&t>1?a-1:a,o&&s>1?l-1:l],h=[o&&t>1?t-1:t,o&&s>1?s-1:s];let d;r?d="(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":d="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` const vec2 effectiveInputOverOutputRatioRC = vec2( ${u[0]/h[0]}, ${u[1]/h[1]}); @@ -18560,7 +18560,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class qU{constructor(e,t,s,o,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,t,s,c];const u=[o&&t>1?a-1:a,o&&s>1?l-1:l],h=[o&&t>1?t-1:t,o&&s>1?s-1:s];let d;r?d="(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":d="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` + */class XU{constructor(e,t,s,o,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,t,s,c];const u=[o&&t>1?a-1:a,o&&s>1?l-1:l],h=[o&&t>1?t-1:t,o&&s>1?s-1:s];let d;r?d="(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":d="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` const vec3 effectiveInputOverOutputRatioRC = vec3( ${u[0]/h[0]}, ${u[1]/h[1]}, @@ -18652,7 +18652,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function KU(n){const{inputs:e,backend:t,attrs:s}=n,{images:o}=e,{alignCorners:r,halfPixelCenters:i,size:a}=s,[l,c]=a,u=W().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new qU(o.shape,l,c,r,i):new jU(o.shape,l,c,r,i);return t.runWebGLProgram(u,[o],"float32")}const XU={kernelName:Qa,backendName:"webgl",kernelFunc:KU};/** + */function YU(n){const{inputs:e,backend:t,attrs:s}=n,{images:o}=e,{alignCorners:r,halfPixelCenters:i,size:a}=s,[l,c]=a,u=W().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new XU(o.shape,l,c,r,i):new KU(o.shape,l,c,r,i);return t.runWebGLProgram(u,[o],"float32")}const ZU={kernelName:Qa,backendName:"webgl",kernelFunc:YU};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18667,7 +18667,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class YU{constructor(e,t,s){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,o,r]=t,[,i,a]=e,l=[s&&i>1?o-1:o,s&&a>1?r-1:r],c=[s&&i>1?i-1:i,s&&a>1?a-1:a],u=l[0]/c[0],h=l[1]/c[1],d=1/u,p=1/h,f=Math.ceil(d)*2+2,g=Math.ceil(p)*2+2;this.userCode=` + */class QU{constructor(e,t,s){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,o,r]=t,[,i,a]=e,l=[s&&i>1?o-1:o,s&&a>1?r-1:r],c=[s&&i>1?i-1:i,s&&a>1?a-1:a],u=l[0]/c[0],h=l[1]/c[1],d=1/u,p=1/h,f=Math.ceil(d)*2+2,g=Math.ceil(p)*2+2;this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; @@ -18763,7 +18763,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ZU(n){const{inputs:e,backend:t,attrs:s}=n,{images:o,dy:r}=e,{alignCorners:i}=s,a=new YU(r.shape,o.shape,i);return t.runWebGLProgram(a,[r],r.dtype)}const QU={kernelName:ku,backendName:"webgl",kernelFunc:ZU};/** + */function JU(n){const{inputs:e,backend:t,attrs:s}=n,{images:o,dy:r}=e,{alignCorners:i}=s,a=new QU(r.shape,o.shape,i);return t.runWebGLProgram(a,[r],r.dtype)}const eG={kernelName:Su,backendName:"webgl",kernelFunc:JU};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18778,7 +18778,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class JU{constructor(e,t,s,o,r){this.variableNames=["A"],this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,t,s,c];const u=[o&&t>1?a-1:a,o&&s>1?l-1:l],h=[o&&t>1?t-1:t,o&&s>1?s-1:s],d=o?"0.5":"0.0";let p;r?p="max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":p="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` + */class tG{constructor(e,t,s,o,r){this.variableNames=["A"],this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,t,s,c];const u=[o&&t>1?a-1:a,o&&s>1?l-1:l],h=[o&&t>1?t-1:t,o&&s>1?s-1:s],d=o?"0.5":"0.0";let p;r?p="max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":p="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` const vec2 effectiveInputOverOutputRatioRC = vec2( ${u[0]/h[0]}, ${u[1]/h[1]}); @@ -18815,7 +18815,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class eG{constructor(e,t,s,o,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,t,s,c];const u=[o&&t>1?a-1:a,o&&s>1?l-1:l],h=[o&&t>1?t-1:t,o&&s>1?s-1:s],d=o?"0.5":"0.0";let p;r?p="max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":p="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` + */class nG{constructor(e,t,s,o,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,t,s,c];const u=[o&&t>1?a-1:a,o&&s>1?l-1:l],h=[o&&t>1?t-1:t,o&&s>1?s-1:s],d=o?"0.5":"0.0";let p;r?p="max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":p="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` const vec3 effectiveInputOverOutputRatioRC = vec3( ${u[0]/h[0]}, ${u[1]/h[1]}, @@ -18871,7 +18871,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function tG(n){const{inputs:e,backend:t,attrs:s}=n,{images:o}=e,{alignCorners:r,halfPixelCenters:i,size:a}=s,[l,c]=a,u=W().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new eG(o.shape,l,c,r,i):new JU(o.shape,l,c,r,i);return t.runWebGLProgram(u,[o],o.dtype)}const nG={kernelName:Za,backendName:"webgl",kernelFunc:tG};/** + */function sG(n){const{inputs:e,backend:t,attrs:s}=n,{images:o}=e,{alignCorners:r,halfPixelCenters:i,size:a}=s,[l,c]=a,u=W().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new nG(o.shape,l,c,r,i):new tG(o.shape,l,c,r,i);return t.runWebGLProgram(u,[o],o.dtype)}const oG={kernelName:Za,backendName:"webgl",kernelFunc:sG};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18886,7 +18886,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class sG{constructor(e,t,s){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,o,r]=t,[,i,a]=e,l=[s&&i>1?o-1:o,s&&a>1?r-1:r],c=[s&&i>1?i-1:i,s&&a>1?a-1:a],u=l[0]/c[0],h=l[1]/c[1],d=1/u,p=1/h,f=Math.ceil(d)*2+2,g=Math.ceil(p)*2+2;this.userCode=` + */class rG{constructor(e,t,s){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,o,r]=t,[,i,a]=e,l=[s&&i>1?o-1:o,s&&a>1?r-1:r],c=[s&&i>1?i-1:i,s&&a>1?a-1:a],u=l[0]/c[0],h=l[1]/c[1],d=1/u,p=1/h,f=Math.ceil(d)*2+2,g=Math.ceil(p)*2+2;this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; @@ -18971,7 +18971,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function oG(n){const{inputs:e,backend:t,attrs:s}=n,{images:o,dy:r}=e,{alignCorners:i}=s,a=new sG(r.shape,o.shape,i);return t.runWebGLProgram(a,[r],r.dtype)}const rG={kernelName:vu,backendName:"webgl",kernelFunc:oG};/** + */function iG(n){const{inputs:e,backend:t,attrs:s}=n,{images:o,dy:r}=e,{alignCorners:i}=s,a=new rG(r.shape,o.shape,i);return t.runWebGLProgram(a,[r],r.dtype)}const aG={kernelName:ku,backendName:"webgl",kernelFunc:iG};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18986,7 +18986,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class iG{constructor(e,t){this.variableNames=["x"];const s=e.length;if(s>4)throw new Error(`WebGL backend: Reverse of rank-${s} tensor is not yet supported`);if(this.outputShape=e,s===1){this.userCode=` + */class lG{constructor(e,t){this.variableNames=["x"];const s=e.length;if(s>4)throw new Error(`WebGL backend: Reverse of rank-${s} tensor is not yet supported`);if(this.outputShape=e,s===1){this.userCode=` void main() { int coord = getOutputCoords(); setOutput(getX(${e[0]} - coord - 1)); @@ -19011,7 +19011,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class aG{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const s=e.length;if(s>4)throw new Error(`WebGL backend: Reverse of rank-${s} tensor is not yet supported`);this.outputShape=e;const o=Pt("rc",s),r=`${o[s-1]} + 1 < ${this.outputShape[s-1]}`,i=`${o[s-2]} + 1 < ${this.outputShape[s-2]}`,a=Be(s);s===1?this.userCode=` + */class cG{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const s=e.length;if(s>4)throw new Error(`WebGL backend: Reverse of rank-${s} tensor is not yet supported`);this.outputShape=e;const o=Bt("rc",s),r=`${o[s-1]} + 1 < ${this.outputShape[s-1]}`,i=`${o[s-2]} + 1 < ${this.outputShape[s-2]}`,a=Be(s);s===1?this.userCode=` void main(){ int rc = getOutputCoords(); vec4 result = vec4(0.); @@ -19054,7 +19054,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function lG(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{dims:r}=s,i=o.shape.length,a=$e(r,o.shape);if(i===0)return en({inputs:{x:o},backend:t});const l=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new aG(o.shape,a):new iG(o.shape,a);return t.runWebGLProgram(l,[o],o.dtype)}const cG={kernelName:Ja,backendName:"webgl",kernelFunc:lG};/** + */function uG(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{dims:r}=s,i=o.shape.length,a=$e(r,o.shape);if(i===0)return en({inputs:{x:o},backend:t});const l=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new cG(o.shape,a):new lG(o.shape,a);return t.runWebGLProgram(l,[o],o.dtype)}const hG={kernelName:Ja,backendName:"webgl",kernelFunc:uG};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19069,7 +19069,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class uG{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const s=e[1],o=e[2];this.outputShape=e;let r="";typeof t=="number"?r=`float outputValue = ${t.toFixed(2)};`:r=` + */class dG{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const s=e[1],o=e[2];this.outputShape=e;let r="";typeof t=="number"?r=`float outputValue = ${t.toFixed(2)};`:r=` vec3 fill = vec3(${t.join(",")}); float outputValue = fill[coords[3]];`,this.userCode=` void main() { @@ -19103,7 +19103,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const hG={kernelName:Du,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{image:s}=n,{radians:o,fillValue:r,center:i}=e,a=t,l=new uG(s.shape,r),[c,u]=Yh(i,s.shape[1],s.shape[2]),h=[[c,u,Math.sin(o),Math.cos(o)]];return a.runWebGLProgram(l,[s],s.dtype,h)}};/** + */const pG={kernelName:Fu,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{image:s}=n,{radians:o,fillValue:r,center:i}=e,a=t,l=new dG(s.shape,r),[c,u]=Yh(i,s.shape[1],s.shape[2]),h=[[c,u,Math.sin(o),Math.cos(o)]];return a.runWebGLProgram(l,[s],s.dtype,h)}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19118,7 +19118,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const dG=Re({opSnippet:` + */const fG=Re({opSnippet:` // OpenGL ES does not support round function. // The algorithm is based on banker's rounding. float base = floor(x); @@ -19133,7 +19133,7 @@ return a / b;`,packedOpSnippet:` return base + 1.0; } } -`}),pG={kernelName:ei,backendName:"webgl",kernelFunc:dG};/** +`}),mG={kernelName:ei,backendName:"webgl",kernelFunc:fG};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19148,7 +19148,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const fG=Re({opSnippet:"return inversesqrt(x);",cpuKernelImpl:f3}),mG={kernelName:ti,backendName:"webgl",kernelFunc:fG};/** + */const gG=Re({opSnippet:"return inversesqrt(x);",cpuKernelImpl:g3}),xG={kernelName:ti,backendName:"webgl",kernelFunc:gG};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19198,7 +19198,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class gG{constructor(e,t,s,o,r,i,a=!0,l=!1){this.variableNames=["updates","indices","defaultValue"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=i;const c=Be(r.length),u=Be(i.length);let h="";s===1?h="i":s===2&&(h="i, j");const d=`getIndices(${h})`;let p="";o===1?p="i":o===2&&(p="i, coords[1]");const f=`getUpdates(${p})`;let g="";l&&(g="coords[0], coords[1]");const m=`getDefaultValue(${g})`,x=t>1?"strides[j]":"strides",b=t>1?"strides[j + 1]":"strides";this.userCode=` + */class bG{constructor(e,t,s,o,r,i,a=!0,l=!1){this.variableNames=["updates","indices","defaultValue"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=i;const c=Be(r.length),u=Be(i.length);let h="";s===1?h="i":s===2&&(h="i, j");const d=`getIndices(${h})`;let p="";o===1?p="i":o===2&&(p="i, coords[1]");const f=`getUpdates(${p})`;let g="";l&&(g="coords[0], coords[1]");const m=`getDefaultValue(${g})`,x=t>1?"strides[j]":"strides",b=t>1?"strides[j + 1]":"strides";this.userCode=` ${c} strides = ${c}(${r}); void main() { @@ -19250,7 +19250,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xG(n){const{inputs:e,backend:t,attrs:s}=n,{indices:o,updates:r}=e,{shape:i}=s,{sliceRank:a,numUpdates:l,sliceSize:c,strides:u,outputSize:h}=uo(r,o,i),d=[h/c,c];if(h===0)return t.makeTensorInfo(i,o.dtype);const p=ne({inputs:{x:o},backend:t,attrs:{shape:[l,a]}}),f=ne({inputs:{x:r},backend:t,attrs:{shape:[l,c]}}),g=t.makeTensorInfo([],"float32",new Float32Array([0]));let m;W().getBool("WEBGL_PACK")?m=new gG(l,a,p.shape.length,f.shape.length,u,d):m=new Tp(l,a,p.shape.length,f.shape.length,u,d);const x=t.runWebGLProgram(m,[f,p,g],f.dtype),b=ne({inputs:{x},backend:t,attrs:{shape:i}});return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(x),t.disposeIntermediateTensorInfo(g),b}const bG={kernelName:Jp,backendName:"webgl",kernelFunc:xG};/** + */function yG(n){const{inputs:e,backend:t,attrs:s}=n,{indices:o,updates:r}=e,{shape:i}=s,{sliceRank:a,numUpdates:l,sliceSize:c,strides:u,outputSize:h}=ho(r,o,i),d=[h/c,c];if(h===0)return t.makeTensorInfo(i,o.dtype);const p=ne({inputs:{x:o},backend:t,attrs:{shape:[l,a]}}),f=ne({inputs:{x:r},backend:t,attrs:{shape:[l,c]}}),g=t.makeTensorInfo([],"float32",new Float32Array([0]));let m;W().getBool("WEBGL_PACK")?m=new bG(l,a,p.shape.length,f.shape.length,u,d):m=new Tp(l,a,p.shape.length,f.shape.length,u,d);const x=t.runWebGLProgram(m,[f,p,g],f.dtype),b=ne({inputs:{x},backend:t,attrs:{shape:i}});return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(x),t.disposeIntermediateTensorInfo(g),b}const wG={kernelName:Jp,backendName:"webgl",kernelFunc:yG};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19265,7 +19265,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class yG{constructor(e,t,s,o){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,s];const r="while (left < right) {",i=`for (int i = 0; i < ${Math.ceil(Math.log2(t+1))}; ++i) { if (left >= right) break;`,a=W().getNumber("WEBGL_VERSION")===2?r:i,l=o==="left"?"<":"<=";this.userCode=` + */class CG{constructor(e,t,s,o){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,s];const r="while (left < right) {",i=`for (int i = 0; i < ${Math.ceil(Math.log2(t+1))}; ++i) { if (left >= right) break;`,a=W().getNumber("WEBGL_VERSION")===2?r:i,l=o==="left"?"<":"<=";this.userCode=` int findBound(int batch, float value) { int left = 0; int right = numInputs; @@ -19305,7 +19305,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function wG(n){const{inputs:e,backend:t,attrs:s}=n,{sortedSequence:o,values:r}=e,{side:i}=s,a=new yG(o.shape[0],o.shape[1],r.shape[1],i),l=[[o.shape[1]]];return t.runWebGLProgram(a,[o,r],"int32",l)}const CG={kernelName:tf,backendName:"webgl",kernelFunc:wG};/** + */function IG(n){const{inputs:e,backend:t,attrs:s}=n,{sortedSequence:o,values:r}=e,{side:i}=s,a=new CG(o.shape[0],o.shape[1],r.shape[1],i),l=[[o.shape[1]]];return t.runWebGLProgram(a,[o,r],"int32",l)}const $G={kernelName:tf,backendName:"webgl",kernelFunc:IG};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19320,7 +19320,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class IG{constructor(e,t,s){this.variableNames=["c","a","b"],this.outputShape=t;let o,r;if(s>4)throw Error(`Where for rank ${s} is not yet supported`);if(s===1)r="resRC",o="resRC";else{const a=["resRC.x","resRC.y","resRC.z","resRC.w"],l=[],c=[];for(let u=0;u4)throw Error(`Where for rank ${s} is not yet supported`);if(s===1)r="resRC",o="resRC";else{const a=["resRC.x","resRC.y","resRC.z","resRC.w"],l=[],c=[];for(let u=0;u= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0); -`,SG=Re({opSnippet:kG}),TG={kernelName:ni,backendName:"webgl",kernelFunc:SG};/** +`,NG=Re({opSnippet:TG}),EG={kernelName:ni,backendName:"webgl",kernelFunc:NG};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19381,9 +19381,9 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const NG=mr+` + */const RG=mr+` return 1.0 / (1.0 + exp(-1.0 * x)); -`,EG=Re({opSnippet:NG,packedOpSnippet:` +`,AG=Re({opSnippet:RG,packedOpSnippet:` vec4 result = 1.0 / (1.0 + exp(-1.0 * x)); bvec4 isNaN = isnan(x); @@ -19393,7 +19393,7 @@ return a / b;`,packedOpSnippet:` result.a = isNaN.a ? x.a : result.a; return result; -`,cpuKernelImpl:g3}),RG={kernelName:ii,backendName:"webgl",kernelFunc:EG};/** +`,cpuKernelImpl:b3}),DG={kernelName:ii,backendName:"webgl",kernelFunc:AG};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19408,10 +19408,10 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const AG=Re({opSnippet:` + */const FG=Re({opSnippet:` if (isnan(x)) { return 0.0; } return sign(x); -`}),DG={kernelName:ri,backendName:"webgl",kernelFunc:AG};/** +`}),_G={kernelName:ri,backendName:"webgl",kernelFunc:FG};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19426,14 +19426,14 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const FG=mr+` + */const OG=mr+` return sin(x); -`,_G=` +`,LG=` vec4 result = sin(x); bvec4 isNaN = isnan(x); - ${So} + ${To} return result; -`,OG=Re({opSnippet:FG,packedOpSnippet:_G}),LG={kernelName:si,backendName:"webgl",kernelFunc:OG};/** +`,MG=Re({opSnippet:OG,packedOpSnippet:LG}),PG={kernelName:si,backendName:"webgl",kernelFunc:MG};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19448,10 +19448,10 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const MG=Re({opSnippet:` + */const BG=Re({opSnippet:` float e2x = exp(x); return (e2x - 1.0 / e2x) / 2.0; -`}),PG={kernelName:oi,backendName:"webgl",kernelFunc:MG};/** +`}),zG={kernelName:oi,backendName:"webgl",kernelFunc:BG};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19466,7 +19466,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const BG=Re({opSnippet:` + */const VG=Re({opSnippet:` float epsilon = 1.1920928955078125e-7; float threshold = log(epsilon) + 2.0; @@ -19486,7 +19486,7 @@ return a / b;`,packedOpSnippet:` result = log(exp_x + 1.0); } return result; -`}),zG={kernelName:ai,backendName:"webgl",kernelFunc:BG};/** +`}),WG={kernelName:ai,backendName:"webgl",kernelFunc:VG};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19501,7 +19501,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const VG={kernelName:sl,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{blockShape:r,paddings:i}=s;$(o.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");const a=r.reduce((x,b)=>x*b),l=[[0,0]];l.push(...i);for(let x=1+r.length;xt.disposeIntermediateTensorInfo(x)),m}};/** + */const UG={kernelName:sl,backendName:"webgl",kernelFunc:n=>{const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{blockShape:r,paddings:i}=s;$(o.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");const a=r.reduce((x,b)=>x*b),l=[[0,0]];l.push(...i);for(let x=1+r.length;xt.disposeIntermediateTensorInfo(x)),m}};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19516,11 +19516,11 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function WG(n){const{inputs:e,backend:t}=n,{indices:s,values:o,denseShape:r,defaultValue:i}=e;if(r.shape.length!==1)throw new Error(`Dense shape must be a vector, saw: + */function GG(n){const{inputs:e,backend:t}=n,{indices:s,values:o,denseShape:r,defaultValue:i}=e;if(r.shape.length!==1)throw new Error(`Dense shape must be a vector, saw: ${r.shape}`);if(s.shape.length!==2)throw new Error(`Indices must be a matrix, saw: ${s.shape}`);if(o.shape.length!==1)throw new Error(`Values must be a vector, saw: ${o.shape}`);if(i.shape.length!==0)throw new Error(`Default value must be a scalar, saw: - ${i.shape}`);const a=t.readSync(s.dataId),l=t.readSync(o.dataId),c=t.readSync(r.dataId),u=t.readSync(i.dataId)[0],[h,d,p,f,g]=b3(a,s.shape,s.dtype,l,o.dtype,c,u);return[t.makeTensorInfo(d,s.dtype,h),t.makeTensorInfo([d[0]],o.dtype,p),t.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(m=>Number(m)))),t.makeTensorInfo([g.length],s.dtype,new Int32Array(g))]}const UG={kernelName:nf,backendName:"webgl",kernelFunc:WG};/** + ${i.shape}`);const a=t.readSync(s.dataId),l=t.readSync(o.dataId),c=t.readSync(r.dataId),u=t.readSync(i.dataId)[0],[h,d,p,f,g]=w3(a,s.shape,s.dtype,l,o.dtype,c,u);return[t.makeTensorInfo(d,s.dtype,h),t.makeTensorInfo([d[0]],o.dtype,p),t.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(m=>Number(m)))),t.makeTensorInfo([g.length],s.dtype,new Int32Array(g))]}const HG={kernelName:nf,backendName:"webgl",kernelFunc:GG};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19535,7 +19535,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function GG(n){const{inputs:e,backend:t}=n,{inputIndices:s,inputShape:o,newShape:r}=e;if(s.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape ${s.shape}`);if(o.shape.length!==1)throw new Error(`Input shape should be a vector but received shape ${o.shape}`);if(r.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${r.shape}`);const i=Array.from(t.readSync(o.dataId)),a=t.readSync(s.dataId),l=Array.from(t.readSync(r.dataId)),[c,u,h]=y3(a,s.shape,s.dtype,i,l);return[t.makeTensorInfo(u,s.dtype,c),t.makeTensorInfo([h.length],r.dtype,new Int32Array(h))]}const HG={kernelName:sf,backendName:"webgl",kernelFunc:GG};/** + */function qG(n){const{inputs:e,backend:t}=n,{inputIndices:s,inputShape:o,newShape:r}=e;if(s.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape ${s.shape}`);if(o.shape.length!==1)throw new Error(`Input shape should be a vector but received shape ${o.shape}`);if(r.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${r.shape}`);const i=Array.from(t.readSync(o.dataId)),a=t.readSync(s.dataId),l=Array.from(t.readSync(r.dataId)),[c,u,h]=C3(a,s.shape,s.dtype,i,l);return[t.makeTensorInfo(u,s.dtype,c),t.makeTensorInfo([h.length],r.dtype,new Int32Array(h))]}const jG={kernelName:sf,backendName:"webgl",kernelFunc:qG};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19550,9 +19550,9 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function jG(n){const{inputs:e,backend:t}=n,{data:s,indices:o,segmentIds:r}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(o.shape.length!==1)throw new Error(`Indices should be a vector but received shape + */function KG(n){const{inputs:e,backend:t}=n,{data:s,indices:o,segmentIds:r}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(o.shape.length!==1)throw new Error(`Indices should be a vector but received shape ${o.shape}`);if(r.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape - ${r.shape}`);const i=t.readSync(s.dataId),a=t.readSync(o.dataId),l=t.readSync(r.dataId),[c,u]=oy(i,s.shape,s.dtype,a,l,!0);return t.makeTensorInfo(u,s.dtype,c)}const qG={kernelName:of,backendName:"webgl",kernelFunc:jG};/** + ${r.shape}`);const i=t.readSync(s.dataId),a=t.readSync(o.dataId),l=t.readSync(r.dataId),[c,u]=ay(i,s.shape,s.dtype,a,l,!0);return t.makeTensorInfo(u,s.dtype,c)}const XG={kernelName:of,backendName:"webgl",kernelFunc:KG};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19567,9 +19567,9 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function KG(n){const{inputs:e,backend:t}=n,{data:s,indices:o,segmentIds:r}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(o.shape.length!==1)throw new Error(`Indices should be a vector but received shape + */function YG(n){const{inputs:e,backend:t}=n,{data:s,indices:o,segmentIds:r}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(o.shape.length!==1)throw new Error(`Indices should be a vector but received shape ${o.shape}`);if(r.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape - ${r.shape}`);const i=t.readSync(s.dataId),a=t.readSync(o.dataId),l=t.readSync(r.dataId),[c,u]=oy(i,s.shape,s.dtype,a,l);return t.makeTensorInfo(u,s.dtype,c)}const XG={kernelName:rf,backendName:"webgl",kernelFunc:KG};/** + ${r.shape}`);const i=t.readSync(s.dataId),a=t.readSync(o.dataId),l=t.readSync(r.dataId),[c,u]=ay(i,s.shape,s.dtype,a,l);return t.makeTensorInfo(u,s.dtype,c)}const ZG={kernelName:rf,backendName:"webgl",kernelFunc:YG};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19584,7 +19584,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function YG(n){const{inputs:e,backend:t,attrs:s}=n,{sparseIndices:o,sparseValues:r,defaultValue:i}=e,{outputShape:a}=s,{sliceRank:l,numUpdates:c,sliceSize:u,strides:h,outputSize:d}=uo(r,o,a),p=!1;if(r.dtype==="string"){const x=t.bufferSync(o),b=t.bufferSync(r),w=ys(t.readSync(i.dataId)[0]),y=m3(x,b,a,d,u,c,l,h,w,p);return t.makeTensorInfo(a,y.dtype,y.values)}const f=new Tp(c,l,o.shape.length,r.shape.length,h,[d,1],p),g=t.runWebGLProgram(f,[r,o,i],r.dtype),m=ne({inputs:{x:g},backend:t,attrs:{shape:a}});return t.disposeIntermediateTensorInfo(g),m}const ZG={kernelName:af,backendName:"webgl",kernelFunc:YG};/** + */function QG(n){const{inputs:e,backend:t,attrs:s}=n,{sparseIndices:o,sparseValues:r,defaultValue:i}=e,{outputShape:a}=s,{sliceRank:l,numUpdates:c,sliceSize:u,strides:h,outputSize:d}=ho(r,o,a),p=!1;if(r.dtype==="string"){const x=t.bufferSync(o),b=t.bufferSync(r),w=ys(t.readSync(i.dataId)[0]),y=x3(x,b,a,d,u,c,l,h,w,p);return t.makeTensorInfo(a,y.dtype,y.values)}const f=new Tp(c,l,o.shape.length,r.shape.length,h,[d,1],p),g=t.runWebGLProgram(f,[r,o,i],r.dtype),m=ne({inputs:{x:g},backend:t,attrs:{shape:a}});return t.disposeIntermediateTensorInfo(g),m}const JG={kernelName:af,backendName:"webgl",kernelFunc:QG};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19599,7 +19599,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function QG(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{numOrSizeSplits:r,axis:i}=s,a=$e(i,o.shape)[0],l=dd(o,r,a),c=o.shape.length,u=new Array(c).fill(0),h=o.shape.slice();return l.map(d=>{const p=[...h];p[a]=d;const f=gr({inputs:{x:o},backend:t,attrs:{begin:u,size:p}});return u[a]+=d,f})}const JG={kernelName:ol,backendName:"webgl",kernelFunc:QG};/** + */function eH(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{numOrSizeSplits:r,axis:i}=s,a=$e(i,o.shape)[0],l=dd(o,r,a),c=o.shape.length,u=new Array(c).fill(0),h=o.shape.slice();return l.map(d=>{const p=[...h];p[a]=d;const f=gr({inputs:{x:o},backend:t,attrs:{begin:u,size:p}});return u[a]+=d,f})}const tH={kernelName:ol,backendName:"webgl",kernelFunc:eH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19614,7 +19614,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ew="return sqrt(x);",eH=Re({opSnippet:ew,packedOpSnippet:ew,cpuKernelImpl:w3}),tH={kernelName:li,backendName:"webgl",kernelFunc:eH};/** + */const sw="return sqrt(x);",nH=Re({opSnippet:sw,packedOpSnippet:sw,cpuKernelImpl:I3}),sH={kernelName:li,backendName:"webgl",kernelFunc:nH};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19629,7 +19629,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const nH=Re({opSnippet:"return x * x;"}),sH={kernelName:Su,backendName:"webgl",kernelFunc:nH};/** + */const oH=Re({opSnippet:"return x * x;"}),rH={kernelName:Tu,backendName:"webgl",kernelFunc:oH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19644,7 +19644,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const tw="return (a - b) * (a - b);",oH=vt({opSnippet:tw,packedOpSnippet:tw}),rH={kernelName:ci,backendName:"webgl",kernelFunc:oH};/** + */const ow="return (a - b) * (a - b);",iH=vt({opSnippet:ow,packedOpSnippet:ow}),aH={kernelName:ci,backendName:"webgl",kernelFunc:iH};/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19659,7 +19659,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function iH(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");const r=t.readSync(o.dataId),i=us(r),a=C3(i,"string",s);return t.makeTensorInfo(o.shape,"string",a)}const aH={kernelName:Tu,backendName:"webgl",kernelFunc:iH};/** + */function lH(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");const r=t.readSync(o.dataId),i=us(r),a=$3(i,"string",s);return t.makeTensorInfo(o.shape,"string",a)}const cH={kernelName:Nu,backendName:"webgl",kernelFunc:lH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19674,9 +19674,9 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function lH({inputs:n,attrs:e,backend:t}){const{x:s}=n,o=In+` + */function uH({inputs:n,attrs:e,backend:t}){const{x:s}=n,o=In+` return x > 0.0 ? 1.0 : float(${e.alpha}); - `,r=new ts(s.shape,o);return t.runWebGLProgram(r,[s],s.dtype)}const cH={kernelName:fi,backendName:"webgl",kernelFunc:lH};/** + `,r=new ts(s.shape,o);return t.runWebGLProgram(r,[s],s.dtype)}const hH={kernelName:fi,backendName:"webgl",kernelFunc:uH};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19691,7 +19691,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class uH{constructor(e,t,s){this.variableNames=["x"],this.outputShape=s;const o=s.length,r=Be(s.length),i=Be(s.length);let a="";if(o===1)a="coords * strides + begin";else{let l=0;a=s.map((c,u)=>(l++,s.length===1?`coords * strides[${u}] + begin[${u}]`:`coords[${l-1}] * strides[${u}] + begin[${u}]`)).join(",")}this.userCode=` + */class dH{constructor(e,t,s){this.variableNames=["x"],this.outputShape=s;const o=s.length,r=Be(s.length),i=Be(s.length);let a="";if(o===1)a="coords * strides + begin";else{let l=0;a=s.map((c,u)=>(l++,s.length===1?`coords * strides[${u}] + begin[${u}]`:`coords[${l-1}] * strides[${u}] + begin[${u}]`)).join(",")}this.userCode=` ${r} begin = ${r}(${e}); ${r} strides = ${r}(${t}); @@ -19714,7 +19714,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hH(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{begin:r,end:i,strides:a,beginMask:l,endMask:c,ellipsisMask:u,newAxisMask:h,shrinkAxisMask:d}=s,{finalShapeSparse:p,finalShape:f,isIdentity:g,sliceDim0:m,isSimpleSlice:x,begin:b,end:w,strides:y}=qh(o.shape,r,i,a,l,c,u,h,d);let C;if(g)C=ne({inputs:{x:o},backend:t,attrs:{shape:f}});else if(m||x){$(o.shape.length>=1,()=>`Input must have rank at least 1, got: ${o.shape.length}`);const v=Gh(b,w,y),k=gr({inputs:{x:o},backend:t,attrs:{begin:b,size:v}});C=ne({inputs:{x:k},backend:t,attrs:{shape:f}}),t.disposeIntermediateTensorInfo(k)}else if(t.shouldExecuteOnCPU([o])){const k=t.readSync(o.dataId),S=ve(o.shape,o.dtype,k),T=I3(p,S,y,b);C=t.makeTensorInfo(f,o.dtype,T.values)}else{const k=new uH(b,y,p);C=t.runWebGLProgram(k,[o],o.dtype)}const I=ne({inputs:{x:C},backend:t,attrs:{shape:f}});return t.disposeIntermediateTensorInfo(C),I}const dH={kernelName:Nu,backendName:"webgl",kernelFunc:hH};/** + */function pH(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{begin:r,end:i,strides:a,beginMask:l,endMask:c,ellipsisMask:u,newAxisMask:h,shrinkAxisMask:d}=s,{finalShapeSparse:p,finalShape:f,isIdentity:g,sliceDim0:m,isSimpleSlice:x,begin:b,end:w,strides:y}=jh(o.shape,r,i,a,l,c,u,h,d);let C;if(g)C=ne({inputs:{x:o},backend:t,attrs:{shape:f}});else if(m||x){$(o.shape.length>=1,()=>`Input must have rank at least 1, got: ${o.shape.length}`);const v=Gh(b,w,y),k=gr({inputs:{x:o},backend:t,attrs:{begin:b,size:v}});C=ne({inputs:{x:k},backend:t,attrs:{shape:f}}),t.disposeIntermediateTensorInfo(k)}else if(t.shouldExecuteOnCPU([o])){const k=t.readSync(o.dataId),S=ve(o.shape,o.dtype,k),T=v3(p,S,y,b);C=t.makeTensorInfo(f,o.dtype,T.values)}else{const k=new dH(b,y,p);C=t.runWebGLProgram(k,[o],o.dtype)}const I=ne({inputs:{x:C},backend:t,attrs:{shape:f}});return t.disposeIntermediateTensorInfo(C),I}const fH={kernelName:Eu,backendName:"webgl",kernelFunc:pH};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19729,7 +19729,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function pH(n){const{inputs:e,backend:t,attrs:s}=n,{separator:o,nGramWidths:r,leftPad:i,rightPad:a,padWidth:l,preserveShortSequences:c}=s,{data:u,dataSplits:h}=e,d=t.readSync(u.dataId),p=t.readSync(h.dataId),[f,g]=$3(d,p,o,r,i,a,l,c);return[t.makeTensorInfo([f.length],"string",f),t.makeTensorInfo(h.shape,"int32",g)]}const fH={kernelName:lf,backendName:"webgl",kernelFunc:pH};/** + */function mH(n){const{inputs:e,backend:t,attrs:s}=n,{separator:o,nGramWidths:r,leftPad:i,rightPad:a,padWidth:l,preserveShortSequences:c}=s,{data:u,dataSplits:h}=e,d=t.readSync(u.dataId),p=t.readSync(h.dataId),[f,g]=k3(d,p,o,r,i,a,l,c);return[t.makeTensorInfo([f.length],"string",f),t.makeTensorInfo(h.shape,"int32",g)]}const gH={kernelName:lf,backendName:"webgl",kernelFunc:mH};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19744,7 +19744,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function mH(n){const{inputs:e,backend:t,attrs:s}=n,{skipEmpty:o}=s,{input:r,delimiter:i}=e;if(r.dtype!=="string")throw new Error("Input must be of datatype string");if(r.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${r.shape}`);if(i.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${i.shape}`);const a=t.readSync(r.dataId),l=t.readSync(i.dataId)[0],[c,u,h]=v3(a,l,o),d=u.length;return[t.makeTensorInfo([d,2],"int32",c),t.makeTensorInfo([d],"string",u),t.makeTensorInfo([2],"int32",new Int32Array(h))]}const gH={kernelName:cf,backendName:"webgl",kernelFunc:mH};/** + */function xH(n){const{inputs:e,backend:t,attrs:s}=n,{skipEmpty:o}=s,{input:r,delimiter:i}=e;if(r.dtype!=="string")throw new Error("Input must be of datatype string");if(r.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${r.shape}`);if(i.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${i.shape}`);const a=t.readSync(r.dataId),l=t.readSync(i.dataId)[0],[c,u,h]=S3(a,l,o),d=u.length;return[t.makeTensorInfo([d,2],"int32",c),t.makeTensorInfo([d],"string",u),t.makeTensorInfo([2],"int32",new Int32Array(h))]}const bH={kernelName:cf,backendName:"webgl",kernelFunc:xH};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19759,7 +19759,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xH(n){const{inputs:e,backend:t,attrs:s}=n,{numBuckets:o}=s,{input:r}=e;if(r.dtype!=="string")throw new Error("Input must be of datatype string");if(o<=0)throw new Error("Number of buckets must be at least 1");const i=t.readSync(r.dataId),a=k3(i,o);return t.makeTensorInfo(r.shape,"int32",a)}const bH={kernelName:uf,backendName:"webgl",kernelFunc:xH};/** + */function yH(n){const{inputs:e,backend:t,attrs:s}=n,{numBuckets:o}=s,{input:r}=e;if(r.dtype!=="string")throw new Error("Input must be of datatype string");if(o<=0)throw new Error("Number of buckets must be at least 1");const i=t.readSync(r.dataId),a=T3(i,o);return t.makeTensorInfo(r.shape,"int32",a)}const wH={kernelName:uf,backendName:"webgl",kernelFunc:yH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19774,7 +19774,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const yH=Re({opSnippet:"return tan(x);"}),wH={kernelName:hi,backendName:"webgl",kernelFunc:yH};/** + */const CH=Re({opSnippet:"return tan(x);"}),IH={kernelName:hi,backendName:"webgl",kernelFunc:CH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19789,10 +19789,10 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const CH=Re({opSnippet:` + */const $H=Re({opSnippet:` float e2x = exp(-2.0 * abs(x)); return sign(x) * (1.0 - e2x) / (1.0 + e2x); -`}),IH={kernelName:di,backendName:"webgl",kernelFunc:CH};/** +`}),vH={kernelName:di,backendName:"webgl",kernelFunc:$H};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19807,7 +19807,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $H(n){const{inputs:e,backend:t,attrs:s}=n,{tensor:o,indices:r,updates:i}=e,{sliceRank:a,numUpdates:l,sliceSize:c,strides:u,outputSize:h}=uo(i,r,o.shape),d=[h/c,c];if(h===0)return t.makeTensorInfo(o.shape,r.dtype);const p=ne({inputs:{x:r},backend:t,attrs:{shape:[l,a]}}),f=ne({inputs:{x:i},backend:t,attrs:{shape:[l,c]}}),g=ne({inputs:{x:o},backend:t,attrs:{shape:d}}),m=new Tp(l,a,p.shape.length,f.shape.length,u,d,!1,!0),x=t.runWebGLProgram(m,[f,p,g],g.dtype),b=ne({inputs:{x},backend:t,attrs:{shape:o.shape}});return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(x),b}const vH={kernelName:ef,backendName:"webgl",kernelFunc:$H};/** + */function kH(n){const{inputs:e,backend:t,attrs:s}=n,{tensor:o,indices:r,updates:i}=e,{sliceRank:a,numUpdates:l,sliceSize:c,strides:u,outputSize:h}=ho(i,r,o.shape),d=[h/c,c];if(h===0)return t.makeTensorInfo(o.shape,r.dtype);const p=ne({inputs:{x:r},backend:t,attrs:{shape:[l,a]}}),f=ne({inputs:{x:i},backend:t,attrs:{shape:[l,c]}}),g=ne({inputs:{x:o},backend:t,attrs:{shape:d}}),m=new Tp(l,a,p.shape.length,f.shape.length,u,d,!1,!0),x=t.runWebGLProgram(m,[f,p,g],g.dtype),b=ne({inputs:{x},backend:t,attrs:{shape:o.shape}});return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(x),b}const SH={kernelName:ef,backendName:"webgl",kernelFunc:kH};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19822,12 +19822,12 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class kH{constructor(e,t){this.variableNames=["A"];const s=new Array(e.length);for(let i=0;i5)throw Error(`Tile for rank ${e} is not yet supported`);if(e===1)return`imod(resRC, ${n[0]})`;const t=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],s=[];for(let o=0;o5)throw Error(`Tile for rank ${e} is not yet supported`);if(e===1)return`imod(resRC, ${n[0]})`;const t=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],s=[];for(let o=0;o5){const l=t.readSync(o.dataId),c=o.dtype==="string"?l.map(d=>ys(d)):l,u=ve(o.shape,o.dtype,c),h=T3(u,r);return t.makeTensorInfo(h.shape,h.dtype,h.values)}const i=new kH(o.shape,r);return t.runWebGLProgram(i,[o],o.dtype)}const TH={kernelName:pi,backendName:"webgl",kernelFunc:nw};class NH{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"negativeInf",type:"float"},{name:"dir",type:"int"},{name:"inc",type:"int"}],this.outputShape=e,this.userCode=` + */function rw(n){const{inputs:e,backend:t,attrs:s}=n,{x:o}=e,{reps:r}=s;if(o.dtype==="string"||o.shape.length>5){const l=t.readSync(o.dataId),c=o.dtype==="string"?l.map(d=>ys(d)):l,u=ve(o.shape,o.dtype,c),h=E3(u,r);return t.makeTensorInfo(h.shape,h.dtype,h.values)}const i=new TH(o.shape,r);return t.runWebGLProgram(i,[o],o.dtype)}const EH={kernelName:pi,backendName:"webgl",kernelFunc:rw};class RH{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"negativeInf",type:"float"},{name:"dir",type:"int"},{name:"inc",type:"int"}],this.outputShape=e,this.userCode=` void main() { ivec2 coords = getOutputCoords(); int batch = coords[0]; @@ -19882,7 +19882,7 @@ return a / b;`,packedOpSnippet:` setOutput(float(i1)); } } - `}}class EH{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=e,this.userCode=` + `}}class AH{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=e,this.userCode=` void main() { // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ... ivec2 coords = getOutputCoords(); @@ -19931,7 +19931,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function No(n,e){e!==null&&n.disposeIntermediateTensorInfo(e)}function sw(n){let e=1;for(;el){const T=t.readSync(o.dataId),[E,V]=N3(T,c,o.dtype,r,i);return[t.makeTensorInfo(E.shape,E.dtype,E.values),t.makeTensorInfo(V.shape,V.dtype,V.values)]}if(r===0)return c[c.length-1]=0,[t.makeTensorInfo(c,o.dtype,[]),t.makeTensorInfo(c,"int32",[])];if(u===1)return[o,ia({attrs:{shape:c,dtype:"int32",value:0},backend:t})];const h=t.texData.get(o.dataId),d=h!==null&&h.isPacked,p=d?t.unpackTensor(o):o,g=H(c)/u,m=ne({inputs:{x:p},attrs:{shape:[g,u]},backend:t});d&&No(t,p);const x=sw(r),b=sw(u);let w=null;const y=()=>w===null?[m,m]:[m,w],C=(T,E,V)=>{const M=y(),L=new NH(V),P=[[u],[w===null?1:0],[Number.NEGATIVE_INFINITY],[T],[E]],G=w;w=t.runWebGLProgram(L,M,"int32",P),No(t,G)};for(let T=1;T=1;V/=2)C(E,V,[g,b])}for(let T=b;T>x;T/=2){const E=y(),V=new EH([g,T/2]),L=[[u],[w===null?1:0],[x]],R=w;w=t.runWebGLProgram(V,E,"int32",L),No(t,R);const P=x/2,G=P*2;for(let B=P;B>=1;B/=2)C(G,B,w.shape)}let I=w;w=gr({inputs:{x:w},backend:t,attrs:{begin:0,size:[g,r]}}),No(t,I);let v=Hy({inputs:{x:m,indices:w},backend:t,attrs:{axis:1,batchDims:1}});No(t,m);const k=c.slice(0,-1);k.push(r),I=w,w=ne({inputs:{x:w},attrs:{shape:k},backend:t}),No(t,I);const S=v;return v=ne({inputs:{x:v},attrs:{shape:k},backend:t}),No(t,S),[v,w]}const AH={kernelName:Eu,backendName:"webgl",kernelFunc:RH};/** + */function Eo(n,e){e!==null&&n.disposeIntermediateTensorInfo(e)}function iw(n){let e=1;for(;el){const T=t.readSync(o.dataId),[E,V]=R3(T,c,o.dtype,r,i);return[t.makeTensorInfo(E.shape,E.dtype,E.values),t.makeTensorInfo(V.shape,V.dtype,V.values)]}if(r===0)return c[c.length-1]=0,[t.makeTensorInfo(c,o.dtype,[]),t.makeTensorInfo(c,"int32",[])];if(u===1)return[o,ia({attrs:{shape:c,dtype:"int32",value:0},backend:t})];const h=t.texData.get(o.dataId),d=h!==null&&h.isPacked,p=d?t.unpackTensor(o):o,g=H(c)/u,m=ne({inputs:{x:p},attrs:{shape:[g,u]},backend:t});d&&Eo(t,p);const x=iw(r),b=iw(u);let w=null;const y=()=>w===null?[m,m]:[m,w],C=(T,E,V)=>{const M=y(),L=new RH(V),B=[[u],[w===null?1:0],[Number.NEGATIVE_INFINITY],[T],[E]],G=w;w=t.runWebGLProgram(L,M,"int32",B),Eo(t,G)};for(let T=1;T=1;V/=2)C(E,V,[g,b])}for(let T=b;T>x;T/=2){const E=y(),V=new AH([g,T/2]),L=[[u],[w===null?1:0],[x]],R=w;w=t.runWebGLProgram(V,E,"int32",L),Eo(t,R);const B=x/2,G=B*2;for(let z=B;z>=1;z/=2)C(G,z,w.shape)}let I=w;w=gr({inputs:{x:w},backend:t,attrs:{begin:0,size:[g,r]}}),Eo(t,I);let v=Ky({inputs:{x:m,indices:w},backend:t,attrs:{axis:1,batchDims:1}});Eo(t,m);const k=c.slice(0,-1);k.push(r),I=w,w=ne({inputs:{x:w},attrs:{shape:k},backend:t}),Eo(t,I);const S=v;return v=ne({inputs:{x:v},attrs:{shape:k},backend:t}),Eo(t,S),[v,w]}const FH={kernelName:Ru,backendName:"webgl",kernelFunc:DH};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19946,7 +19946,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class DH{constructor(e,t,s,o,r,i){this.variableNames=["Image","Transforms"],this.outputShape=i;const a=s==="nearest"?1:2;let l;switch(o){case"constant":l=1;break;case"reflect":l=2;break;case"wrap":l=3;break;case"nearest":l=4;break;default:l=1;break}this.userCode=` + */class _H{constructor(e,t,s,o,r,i){this.variableNames=["Image","Transforms"],this.outputShape=i;const a=s==="nearest"?1:2;let l;switch(o){case"constant":l=1;break;case"reflect":l=2;break;case"wrap":l=3;break;case"nearest":l=4;break;default:l=1;break}this.userCode=` float mapCoord(float outCoord, float len) { float inCoord = outCoord; if(${l} == 2) { @@ -20073,7 +20073,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function FH(n){const{inputs:e,backend:t,attrs:s}=n,{image:o,transforms:r}=e,{interpolation:i,fillMode:a,fillValue:l,outputShape:c}=s,[u,h,d,p]=o.shape,[f,g]=c??[h,d],m=[u,f,g,p],x=new DH(h,d,i,a,l,m);return t.runWebGLProgram(x,[o,r],"float32")}const _H={kernelName:Ru,backendName:"webgl",kernelFunc:FH};/** + */function OH(n){const{inputs:e,backend:t,attrs:s}=n,{image:o,transforms:r}=e,{interpolation:i,fillMode:a,fillValue:l,outputShape:c}=s,[u,h,d,p]=o.shape,[f,g]=c??[h,d],m=[u,f,g,p],x=new _H(h,d,i,a,l,m);return t.runWebGLProgram(x,[o,r],"float32")}const LH={kernelName:Au,backendName:"webgl",kernelFunc:OH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -20088,7 +20088,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function OH(n){const{inputs:e,attrs:t,backend:s}=n,{axis:o}=t,{x:r}=e;Ji(r,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const i=s.readSync(r.dataId),{outputValues:a,outputShape:l,indices:c}=E3(i,o,r.shape,r.dtype);return[s.makeTensorInfo(l,r.dtype,a),s.makeTensorInfo([c.length],"int32",c)]}const LH={kernelName:Au,backendName:"webgl",kernelFunc:OH};/** + */function MH(n){const{inputs:e,attrs:t,backend:s}=n,{axis:o}=t,{x:r}=e;Ji(r,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const i=s.readSync(r.dataId),{outputValues:a,outputShape:l,indices:c}=A3(i,o,r.shape,r.dtype);return[s.makeTensorInfo(l,r.dtype,a),s.makeTensorInfo([c.length],"int32",c)]}const PH={kernelName:Du,backendName:"webgl",kernelFunc:MH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20103,7 +20103,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function MH(n){const{inputs:e,backend:t,attrs:s}=n,{value:o}=e;let{axis:r}=s;r<0&&(r+=o.shape.length);const i=o,a=i.shape.length,l=o.shape[r],c=new Array(a-1);let u=0;for(let g=0;gt.disposeIntermediateTensorInfo(g)),f}const PH={kernelName:il,backendName:"webgl",kernelFunc:MH};/** + */function BH(n){const{inputs:e,backend:t,attrs:s}=n,{value:o}=e;let{axis:r}=s;r<0&&(r+=o.shape.length);const i=o,a=i.shape.length,l=o.shape[r],c=new Array(a-1);let u=0;for(let g=0;gt.disposeIntermediateTensorInfo(g)),f}const zH={kernelName:il,backendName:"webgl",kernelFunc:BH};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20118,7 +20118,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class BH{constructor(e,t){this.variableNames=["x","segmentIds"];const s=e.windowSize,o=e.batchSize,r=e.inSize,i=e.numSegments,a=i*Math.ceil(r/s);this.outputShape=[o,a];const l="0.0",c="sumValue",u=Math.floor(s/4)*4,h=s%4,d=` + */class VH{constructor(e,t){this.variableNames=["x","segmentIds"];const s=e.windowSize,o=e.batchSize,r=e.inSize,i=e.numSegments,a=i*Math.ceil(r/s);this.outputShape=[o,a];const l="0.0",c="sumValue",u=Math.floor(s/4)*4,h=s%4,d=` sumValue += dot(values, segFilter); `;let p="";r%s>0&&(p=` if (inIdx < 0 || inIdx >= ${r}) { @@ -20239,7 +20239,7 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function zH(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,segmentIds:r}=e,{numSegments:i}=s,a=o.shape.length,l=[];let c=0;const u=Ye([c],a);let h=o;u!=null&&(h=Bt({inputs:{x:o},backend:t,attrs:{perm:u}}),l.push(h),c=tt(1,a)[0]);const d=Rg(h.shape,c,i),p=H([h.shape[c]]),f=ne({inputs:{x:h},backend:t,attrs:{shape:[-1,p]}});l.push(f);const g=Wu(o.dtype),m=(y,C,I,v,k)=>{const S=y.shape[0],T=y.shape[1],E=Eg(T,k),V={windowSize:E,inSize:T,batchSize:S,numSegments:k},M=new BH(V,C),L=t.compileAndRun(M,[y,I],v);if(l.push(L),L.shape[1]===k)return L;const R=Jy({backend:t,attrs:{start:0,stop:k,step:1,dtype:"float32"}}),P=nw({inputs:{x:R},backend:t,attrs:{reps:[T/E]}});return l.push(R),l.push(P),m(L,C,P,v,k)},x=m(f,"unsortedSegmentSum",r,g,i),b=ne({inputs:{x},backend:t,attrs:{shape:d}});let w=b;if(u!=null){l.push(b);const y=$s(u);w=Bt({inputs:{x:w},backend:t,attrs:{perm:y}})}return l.forEach(y=>t.disposeIntermediateTensorInfo(y)),w}const VH={kernelName:al,backendName:"webgl",kernelFunc:zH};/** + */function WH(n){const{inputs:e,backend:t,attrs:s}=n,{x:o,segmentIds:r}=e,{numSegments:i}=s,a=o.shape.length,l=[];let c=0;const u=Ye([c],a);let h=o;u!=null&&(h=zt({inputs:{x:o},backend:t,attrs:{perm:u}}),l.push(h),c=tt(1,a)[0]);const d=Ag(h.shape,c,i),p=H([h.shape[c]]),f=ne({inputs:{x:h},backend:t,attrs:{shape:[-1,p]}});l.push(f);const g=Uu(o.dtype),m=(y,C,I,v,k)=>{const S=y.shape[0],T=y.shape[1],E=Rg(T,k),V={windowSize:E,inSize:T,batchSize:S,numSegments:k},M=new VH(V,C),L=t.compileAndRun(M,[y,I],v);if(l.push(L),L.shape[1]===k)return L;const R=nw({backend:t,attrs:{start:0,stop:k,step:1,dtype:"float32"}}),B=rw({inputs:{x:R},backend:t,attrs:{reps:[T/E]}});return l.push(R),l.push(B),m(L,C,B,v,k)},x=m(f,"unsortedSegmentSum",r,g,i),b=ne({inputs:{x},backend:t,attrs:{shape:d}});let w=b;if(u!=null){l.push(b);const y=$s(u);w=zt({inputs:{x:w},backend:t,attrs:{perm:y}})}return l.forEach(y=>t.disposeIntermediateTensorInfo(y)),w}const UH={kernelName:al,backendName:"webgl",kernelFunc:WH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20254,4 +20254,4 @@ return a / b;`,packedOpSnippet:` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const WH=[wB,IB,kB,NB,RB,FB,OB,MB,VB,UB,jB,XB,QB,nz,rz,az,cz,pz,mz,xz,wz,Sz,Nz,Dz,_z,Bz,Vz,Hz,sB,Kz,Jz,sV,cV,dV,fV,gV,bV,IV,vV,SV,NV,RV,DV,OV,MV,VV,UV,jV,XV,ZV,JV,nW,oW,aW,cW,uW,dW,fW,gW,bW,wW,IW,kW,NW,RW,FW,LW,PW,zW,nB,WW,Zz,GW,jW,KW,rB,YW,QW,e4,s4,i4,l4,u4,d4,m4,x4,y4,$4,k4,T4,A4,F4,O4,M4,B4,U4,j4,Y4,nU,lB,iU,cU,dU,mU,Oz,xU,yU,CU,vU,NU,aB,RU,DU,_U,LU,MU,Lz,Q4,BU,WU,HU,uB,XU,QU,nG,rG,cG,hG,pG,mG,bG,CG,vG,TG,RG,DG,LG,PG,kz,eU,zG,VG,UG,HG,qG,XG,ZG,JG,tH,sH,rH,aH,cH,dH,fH,gH,bH,J4,xB,wH,IH,vH,TH,AH,_H,bB,LH,PH,VH,bU];for(const n of WH)mf(n);class UH{idx(e,t,s,o){return s*o[0]*o[1]+t*o[0]+e}check_previous_slice(e,t,s,o,r,i,a,l,c,u){let h=0;if(!r)return 0;const d=e[this.idx(s,o,r,i)];if(a>=6){const p=this.idx(s,o,r-1,i);d===e[p]&&(c[h++]=t[p])}if(a>=18){if(s){const p=this.idx(s-1,o,r-1,i);d===e[p]&&(c[h++]=t[p])}if(o){const p=this.idx(s,o-1,r-1,i);d===e[p]&&(c[h++]=t[p])}if(s=6){if(f){const x=this.idx(f-1,p,d,t);m===e[x]&&(h[g++]=u[x])}if(p){const x=this.idx(f,p-1,d,t);m===e[x]&&(h[g++]=u[x])}}if(s>=18){if(p&&f){const x=this.idx(f-1,p-1,d,t);m===e[x]&&(h[g++]=u[x])}if(p&&f=l){l+=a;const x=new Uint32Array(l);x.set(c),c=x}c[i-1]=i,i++}}}for(let d=0;d.",inferenceDelay:100,description:"Gray and white matter segmentation model. Operates on full T1 image in a single pass but needs a dedicated graphics card to operate. Provides the best accuracy with hard cropping for better speed"},{id:3,type:"Segmentation",path:"/models/model20chan3cls/model.json",modelName:"🔪 Tissue GWM (High Acc, Low Mem)",labelsPath:"./models/model20chan3cls/labels.json",colorsPath:"./models/model20chan3cls/colorLUT.json",colormapPath:"./models/model20chan3cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Gray and white matter segmentation model. Operates on full T1 image in a single pass but needs a dedicated graphics card to operate. Provides high accuracy and fit low memory available but slower"},{id:4,type:"Atlas",path:"/models/model30chan18cls/model.json",modelName:"🪓 Subcortical + GWM (High Mem, Fast)",labelsPath:"./models/model30chan18cls/labels.json",colorsPath:"./models/model30chan18cls/colorLUT.json",colormapPath:"./models/model30chan18cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is a robust model able to handle range of data quality, including varying saturation, and even clinical scans. It may work on infant brains, but your mileage may vary."},{id:5,type:"Atlas",path:"/models/model30chan18cls/model.json",modelName:"🪓 Subcortical + GWM (Low Mem, Slow)",labelsPath:"./models/model30chan18cls/labels.json",colorsPath:"./models/model30chan18cls/colorLUT.json",colormapPath:"./models/model30chan18cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is a robust model able to handle range of data quality, including varying saturation, and even clinical scans. It may work on infant brains, but your mileage may vary."},{id:6,type:"Atlas",path:"/models/model18cls/model.json",modelName:"🪓 Subcortical + GWM (Low Mem, Faster)",labelsPath:"./models/model18cls/labels.json",colorsPath:"./models/model18cls/colorLUT.json",colormapPath:"./models/model18cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is a robust model able to handle range of data quality, including varying saturation, and even clinical scans. It may work on infant brains, but your mileage may vary."},{id:7,type:"Atlas",path:"/models/model30chan18cls/model.json",modelName:"🔪🪓 Subcortical + GWM (Failsafe, Less Acc)",labelsPath:"./models/model30chan18cls/labels.json",colorsPath:"./models/model30chan18cls/colorLUT.json",colormapPath:"./models/model30chan18cls/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is not a robust model, it may work on low data quality, including varying saturation, and even clinical scans. It may work also on infant brains, but your mileage may vary."},{id:8,type:"Atlas",path:"/models/model30chan50cls/model.json",modelName:"🔪 Aparc+Aseg 50 (High Mem, Fast)",labelsPath:"./models/model30chan50cls/labels.json",colorsPath:"./models/model30chan50cls/colorLUT.json",colormapPath:"./models/model30chan50cls/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"This is a 50-class model, that segments the brain into the Aparc+Aseg Freesurfer Atlas but one where cortical homologues are merged into a single class."},{id:9,type:"Atlas",path:"/models/model30chan50cls/model.json",modelName:"🔪 Aparc+Aseg 50 (Low Mem, Slow)",labelsPath:"./models/model30chan50cls/labels.json",colorsPath:"./models/model30chan50cls/colorLUT.json",colormapPath:"./models/model30chan50cls/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"This is a 50-class model, that segments the brain into the Aparc+Aseg Freesurfer Atlas but one where cortical homologues are merged into a single class. The model use sequential convolution for inference to overcome browser memory limitations but leads to longer computation time."},{id:10,type:"Brain_Extraction",path:"/models/model5_gw_ae/model.json",modelName:"⚡ Extract the Brain (FAST)",labelsPath:null,colorsPath:null,preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:18,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:null,inferenceDelay:100,description:"Extract the brain fast model operates on full T1 image in a single pass, but uses only 5 filters per layer. Can work on integrated graphics cards but is barely large enough to provide good accuracy. Still more accurate than the failsafe version."},{id:11,type:"Brain_Extraction",path:"/models/model11_gw_ae/model.json",modelName:"🔪 Extract the Brain (High Acc, Slow)",labelsPath:null,colorsPath:null,preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Extract the brain high accuracy model operates on full T1 image in a single pass, but uses only 11 filters per layer. Can work on dedicated graphics cards. Still more accurate than the fast version."},{id:12,type:"Brain_Masking",path:"/models/model5_gw_ae/model.json",modelName:"⚡ Brain Mask (FAST)",labelsPath:null,colorsPath:null,colormapPath:"./models/model5_gw_ae/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:17,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:null,inferenceDelay:100,description:"This fast masking model operates on full T1 image in a single pass, but uses only 5 filters per layer. Can work on integrated graphics cards but is barely large enough to provide good accuracy. Still more accurate than failsafe version."},{id:13,type:"Brain_Masking",path:"/models/model11_gw_ae/model.json",modelName:"🔪 Brain Mask (High Acc, Low Mem)",labelsPath:null,colorsPath:null,preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"This masking model operates on full T1 image in a single pass, but uses 11 filters per layer. Can work on dedicated graphics cards. Still more accurate than fast version."},{id:14,type:"Atlas",path:"/models/model21_104class/model.json",modelName:"🔪 Aparc+Aseg 104 (High Mem, Fast)",labelsPath:"./models/model21_104class/labels.json",colorsPath:"./models/model21_104class/colorLUT.json",colormapPath:"./models/model21_104class/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"FreeSurfer aparc+aseg atlas 104 parcellate brain areas into 104 regions. It contains a combination of the Desikan-Killiany atlas for cortical area and also segmentation of subcortical regions."},{id:15,type:"Atlas",path:"/models/model21_104class/model.json",modelName:"🔪 Aparc+Aseg 104 (Low Mem, Slow)",labelsPath:"./models/model21_104class/labels.json",colorsPath:"./models/model21_104class/colorLUT.json",colormapPath:"./models/model21_104class/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"FreeSurfer aparc+aseg atlas 104 parcellate brain areas into 104 regions. It contains a combination of the Desikan-Killiany atlas for cortical area and also segmentation of subcortical regions. The model use sequential convolution for inference to overcome browser memory limitations but leads to longer computation time. "}];function kt(n="",e=-1,t="",s=[]){let o=[];Object.keys(s).length>0&&(o=function(i){let a={};for(var l in s)a[l]=s[l];return JSON.stringify(a)}()),self.postMessage({cmd:"ui",message:n,progressFrac:e,modalMessage:t,statData:o})}function ow(n,e,t){self.postMessage({cmd:"img",img:n,opts:e,modelEntry:t})}async function Ep(n){let e=0;for(let t=0;tp-f);const r=Rt(o),i=r.shape[0],a=Math.floor(i*e),l=Math.ceil(i*t)-1,c=r.slice(a,1),u=r.slice(l,1),h=(await c.array())[0],d=(await u.array())[0];return s.dispose(),r.dispose(),c.dispose(),u.dispose(),{qmin:h,qmax:d}}async function Ap(n,e=.05,t=.95){const{qmin:s,qmax:o}=await jH(n,e,t),r=Fe(s),i=Fe(o),a=n.sub(r).div(i.sub(r));return r.dispose(),i.dispose(),a}async function Dp(n){const e=n.max(),t=n.min();return await n.sub(t).div(e.sub(t))}async function qH(n,e,t,s,o,r,i){callbackUI(msg,-1,"inferenceFullVolumeSeqCovLayer() is not dead code?")}async function KH(n,e,t,s,o,r,i){kt("",-1,"inferenceFullVolume() is not dead code?")}async function aw(n,e,t,s,o,r=null){kt("",-1,"inferenceSubVolumes() is not dead code?")}async function lw(n,e){kt("",-1,"tensor2LightBuffer() is not dead code?")}async function cw(n,e,t){let s=[];for(let l=0;l0?t-c-1:0,p=s-u-1>0?s-u-1:0,f=e-h-1>0?e-h-1:0;return n.pad([[i,d],[a,p],[l,f]])}async function dw(n,e){const t=n.max(),s=t.mul(e),o=await s.data();return t.dispose(),s.dispose(),z(()=>n.clone().greater(o[0]))}async function Ac(n){return n.step(0)}async function XH(n,e,t,s,o,r,i,a,l,c,u=!0){console.log("Generate Brain Masking ... ");let h=[];for(let m=0;m{const m="postProcessSlices3D() should be upgraded to BWLabeler";i(m,-1,m)}),console.log("Post processing done ")):console.log("Phase-1 Post processing disabled ... ");const p=new Array(h[0].length*h.length);let f=0;for(let m=0;m{const w=n.slice([0,0,0,0,m],[-1,-1,-1,-1,x-m]),y=e.slice([0,0,0,m,u],[-1,-1,-1,x-m,1]);return sh(w,y,s,o,"NDHWC",r)});if(p===null)p=b;else{const w=p.add(b);p.dispose(),b.dispose(),p=w}}}const f=p.add(d);if(p.dispose(),d.dispose(),c==null)c=f;else{const g=await Ot([c,f],4);f.dispose(),c.dispose(),c=g}}return c}function ZH(n,e,t){const i=n.shape[4],a=Math.ceil(i/t);let l=null;for(let c=0;cn.slice([0,0,0,0,u],[-1,-1,-1,-1,d])),f=z(()=>e.slice([0,0,0,u,0],[-1,-1,-1,d,-1])),g=sh(p,f,1,0,"NDHWC",1);p.dispose(),f.dispose();const m=Xo(g);if(g.dispose(),l===null)l=m;else{const x=l.add(m);l.dispose(),l!==m&&m.dispose(),l=x}z(()=>{De(st([1,1]),st([1,1]))})}return l}class QH{constructor(e,t,s,o){this.model=e,this.outChannels=e.outputLayers[0].kernel.shape[4],this.chunkSize=t,this.isChannelLast=s,this.callbackUI=o}async apply(e){const t=yr.get("WEBGL_DELETE_TEXTURE_THRESHOLD");yr.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0);const s=this,o=performance.now(),r=s.model.layers[s.model.layers.length-1],i=r.getWeights()[0],a=r.getWeights()[1],l=s.isChannelLast?e.shape.slice(1,-1):e.shape.slice(2);let c=F(Nn(l),-1e4),u=st(l),h=0;for(console.log(" channel loop");;){Te().startScope(),console.log("=======================");const d=await Ft();console.log(`| Number of Tensors: ${d.numTensors}`),console.log(`| Number of Data Buffers: ${d.numDataBuffers}`),console.log("Channel : ",h);const p=await z(()=>{const g=i.slice([0,0,0,0,h],[-1,-1,-1,-1,1]),m=a.slice([h],[1]),x=ZH(e,g,Math.min(s.chunkSize,s.outChannels)).add(m),b=Zt(x,c),w=Ct(b,x,c),y=Ct(b,Ii(u.shape,h),u);return fe([c,u,g,m,x,b]),z(()=>De(Nn([1,1]),Nn([1,1]))),[y,w]});console.log("=======================");const f=await Ft();if(s.callbackUI(`Iteration ${h}`,h/s.outChannels),console.log(`Number of Tensors: ${f.numTensors}`),console.log(`Number of Data Buffers: ${f.numDataBuffers}`),console.log(`Megabytes In Use: ${(f.numBytes/1048576).toFixed(3)} MB`),f.unreliable&&console.log(`Unreliable: ${f.unreliable}`),typeof u<"u"&&u.dispose(),typeof c<"u"&&c.dispose(),u=dn(p[0]),c=dn(p[1]),Te().endScope(),h===s.outChannels-1){fe(c);const m=performance.now()-o;return console.log(`Execution time for output layer: ${m} milliseconds`),yr.set("WEBGL_DELETE_TEXTURE_THRESHOLD",t),u}else{h++;const g=u.shape,m=u.dataSync(),x=u.shape,b=c.dataSync();u.dispose(),c.dispose(),u=ss(m,g),c=ss(b,x)}}}}async function pw(n,e,t,s,o,r,i,a,l,c){if(l.isPostProcessEnable){const d=new UH,p=new Uint32Array(e),f=26,g=!0,m=!0,[x,b]=d.bwlabel(n,p,f,g,m);for(let w=0;w0&&E<=1?p=await dw(s,E):(console.log("No valid crop threshold value"),p=await s.greater([0]).asType("bool"))}else p=await a.greater([0]).asType("bool");console.log(" mask_3d shape : ",p.shape);const f=await _m(p);p.dispose();const g=f.min(0).arraySync()[0],m=f.max(0).arraySync()[0],x=f.min(0).arraySync()[1],b=f.max(0).arraySync()[1],w=f.min(0).arraySync()[2],y=f.max(0).arraySync()[2];console.log("row min and max :",g,m),console.log("col min and max :",x,b),console.log("depth min and max :",w,y);const C=[g,x,w],I=[m-g+1,b-x+1,y-w+1];f.dispose();const v=await s.slice([g,x,w],[m-g+1,b-x+1,y-w+1]);s.dispose();const k=e.cropPadding;let S=await hw(v,[k,k],[k,k],[k,k]);if(console.log(" cropped slices_3d with padding shape: ",S.shape),v.dispose(),n.drawBoundingVolume){let E=await Ec(S,k,k,k);return console.log(" outLabelVolume without padding shape : ",E.shape),E=await Rc(E,o,r,i,C,I),console.log(" outLabelVolume final shape after resizing : ",E.shape),cw(Gn(E),n,e),E.dispose(),0}u.Brainchop_Ver="FullVolume";const T=await t;try{let E=performance.now();const V=performance.now();let M=0;const L=e.enableTranspose;L?(S=await S.transpose(),console.log("Input transposed for pre-model")):console.log("Transpose not enabled for pre-model");let R=1;const P=T.layers.length;console.log("res.layers.length ",P);const G=Nc(T),B=n.batchSize,j=n.numOfChan;let K;G?(T.layers[0].batchInputShape[1]=S.shape[0],T.layers[0].batchInputShape[2]=S.shape[1],T.layers[0].batchInputShape[3]=S.shape[2],K=[B,T.layers[0].batchInputShape[1],T.layers[0].batchInputShape[2],T.layers[0].batchInputShape[3],j]):(T.layers[0].batchInputShape[2]=S.shape[0],T.layers[0].batchInputShape[3]=S.shape[1],T.layers[0].batchInputShape[4]=S.shape[2],K=[B,j,T.layers[0].batchInputShape[2],T.layers[0].batchInputShape[3],T.layers[0].batchInputShape[4]]),console.log(" Model batch input shape : ",T.layers[0].batchInputShape),u.Input_Shape=JSON.stringify(T.layers[0].batchInputShape),u.Output_Shape=JSON.stringify(T.output.shape),u.Channel_Last=await G,u.Model_Param=await Ep(T),u.Model_Layers=await Rp(T),u.Model=e.modelName,u.Seq_Conv=e.enableSeqConv;const X=T.layers[T.layers.length-1];console.log("Output Layer : ",X);const J=G?X.outputShape[X.outputShape.length-1]:X.outputShape[1];console.log("Num of output channels x: ",J);const q=[];for(q[0]=await S.reshape(K);;){try{T.layers[R].activation.getClassName()!=="linear"?q[R]=await T.layers[R].apply(q[R-1]):q[R]=await YH(q[R-1],T.layers[R].getWeights()[0],T.layers[R].getWeights()[1],T.layers[R].strides,T.layers[R].padding,T.layers[R].dilationRate,3),fe(q[R-1])}catch(Q){const Y="Your graphics card (e.g. Intel) may not be compatible with WebGL. "+Q.message;return l(Y,-1,Y),Te().endScope(),Te().disposeVariables(),u.Inference_t=1/0,u.Postprocess_t=1/0,u.Status="Fail",u.Error_Type=Q.message,u.Extra_Err_Info="Failed while model layer "+R+" apply",kt("",-1,"",u),0}if(console.log("layer output Tensor shape : ",q[R].shape),console.log("layer count params ",T.layers[R].countParams()),T.layers[R].dispose(),q[R-1].dispose(),l("Layer "+R.toString(),(R+1)/P),Ft().unreliable){const Q="unreliable reasons :"+Ft().reasons;l(Q,NaN,Q)}if(R===P-2){const Q=await new QH(T,10,G,l);let Y=null;const te=await dC(async()=>{Y=await Q.apply(q[R])});if(console.log("profileInfo : ",te),fe(q[R]),console.log(" Output tensor",Y),console.log(" Output tensor shape : ",Y.shape),Y.shape.length!==3){const be="Output tensor shape should be 3 dims but it is "+Y.shape.length;l(be,-1,be)}const ie=((performance.now()-E)/1e3).toFixed(4);console.log(" find array max ");const he=await Y.max().dataSync()[0];Mhere'),Ft().unreliable){const V="unreliable reasons :"+Ft().reasons;l(V,NaN,V)}}}async function mw(n,e,t,s,o,r,i,a,l,c,u,h){let d=[];console.log(" ---- Start FullVolume inference phase-II ---- "),i.enableQuantileNorm?(console.log("preModel Quantile normalization enabled"),e=await Ap(e)):(console.log("preModel Min Max normalization enabled"),e=await Dp(e));let f;if(r==null){const R=i.autoThreshold;R>0&&R<=1?f=await dw(e,R):(console.log("No valid crop threshold value"),f=await e.greater([0]).asType("bool"))}else f=await r.greater([0]).asType("bool");console.log(" mask_3d shape : ",f.shape);const g=await _m(f);f.dispose();const m=g.arraySync();let x=s,b=0,w=o,y=0,C=t,I=0;for(let R=0;Rm[R][0]?x=m[R][0]:bm[R][1]?w=m[R][1]:ym[R][2]?C=m[R][2]:Ihere')}}async function JH(n,e,t,s,o,r,i,a,l,c,u,h,d){if(a.No_SubVolumes=1,i.preModelId){const p=await rw(l.rootURL+Np[i.preModelId-1].path),f=Np[i.preModelId-1].enableTranspose,g=Np[i.preModelId-1].enableQuantileNorm;let m=null;g?(console.log("preModel Quantile normalization enabled"),m=await Ap(e)):(console.log("preModel Min Max normalization enabled"),m=await Dp(e)),f?(m=m.transpose(),console.log("Input transposed for pre-model")):console.log("Transpose not enabled for pre-model"),a.Brainchop_Ver="PreModel_FV";const x=await p;try{const b=performance.now(),w=x,y=w.layers[0].batchInputShape;if(console.log(" Pre-Model batch input shape : ",y),y.length!==5){const P="The pre-model input shape must be 5D ";return u(P,-1,P),0}const C=await Nc(w),I=l.batchSize,v=l.numOfChan;let k,S,T,E;if(C){if(console.log("Pre-Model Channel Last"),isNaN(y[4])||y[4]!==1){const P="The number of channels for pre-model input shape must be 1";return u(P,-1,P),0}k=y[1],S=y[2],T=y[3],E=[I,k,S,T,v]}else{if(console.log("Pre-Model Channel First"),isNaN(y[1])||y[1]!==1){const P="The number of channels for pre-model input shape must be 1";return u(P,-1,P),0}k=y[2],S=y[3],T=y[4],E=[I,v,k,S,T]}a.Input_Shape=JSON.stringify(E),a.Output_Shape=JSON.stringify(w.output.shape),a.Channel_Last=await C,a.Model_Param=await Ep(w),a.Model_Layers=await Rp(w);let V=0,M=1;const L=x.layers.length,R=[];for(R[0]=m.reshape(E),fe(m);;){try{R[M]=x.layers[M].apply(R[M-1])}catch(P){const G="Your graphics card (e.g. Intel) may not be compatible with WebGL. "+P.message;return u(G,-1,G),Te().endScope(),Te().disposeVariables(),a.Inference_t=1/0,a.Postprocess_t=1/0,a.Status="Fail",a.Error_Type=P.message,a.Extra_Err_Info="PreModel Failed while model layer "+M+" apply",kt("",-1,"",a),0}if(x.layers[M].dispose(),R[M-1].dispose(),u("Layer "+M.toString(),(M+1)/L),Ft().unreliable){const P="unreliable reasons :"+Ft().reasons;u(P,NaN,P)}if(M===L-1){const P=C?-1:1;console.log(" find argmax "),console.log("last Tensor shape : ",R[M].shape);const G=C?R[M].shape[4]:R[M].shape[1];let B;try{console.log(" Try tf.argMax for fullVolume .."),B=await no(R[M],P)}catch(te){if(P===-1)try{const ie=performance.now();console.log(" tf.argMax failed .. try argMaxLarge ..");const he=lw(R[M].reshape([t,s,o,G]),"float16");B=uw(he,t,s,o,G,"float16"),console.log("argMaxLarge for fullVolume takes : ",((performance.now()-ie)/1e3).toFixed(4))}catch(ie){const he="argMax buffer couldn't be created due to limited memory resources.";return u(he,-1,he),B.dispose(),Te().endScope(),Te().disposeVariables(),a.Inference_t=1/0,a.Postprocess_t=1/0,a.Status="Fail",a.Error_Type=ie.message,a.Extra_Err_Info="preModel prediction_argmax from argMaxLarge failed",kt("",-1,"",a),0}else{const ie="argMax buffer couldn't be created due to limited memory resources.";return u(ie,-1,ie),B.dispose(),Te().endScope(),Te().disposeVariables(),a.Inference_t=1/0,a.Postprocess_t=1/0,a.Status="Fail",a.Error_Type=te.message,a.Extra_Err_Info="preModel prediction_argmax from argMaxLarge not support yet channel first",kt("",-1,"",a),0}}console.log(" Pre-model prediction_argmax shape : ",B.shape);const j=((performance.now()-b)/1e3).toFixed(4);fe(R[M]),console.log(" Pre-model find array max ");const K=await B.max().dataSync()[0];Vhere')}}else console.log("--- No pre-model is selected ---"),console.log("------ Run voxel cropping ------"),r?i.enableSeqConv?(console.log("------ Seq Convoluton ------"),await fw(l,i,n,e,t,s,o,null,u,c,a,d)):mw(n,e,t,s,o,null,i,a,l,c,u,d):aw(n,e,t,s,o,null)}async function ej(n=!0){pC("webgl"),await hC(),W().set("DEBUG",!1),W().set("WEBGL_FORCE_F16_TEXTURES",n),W().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0),await fC(),console.log("tf env() flags :",W().flags),console.log("tf env() features :",W().features),console.log("tf env total features: ",Object.keys(W().features).length),console.log("tf backend: ",jf())}async function tj(n,e,t,s,o,r){const i=[];i.startTime=performance.now(),r("Segmentation started",0);const a=n.batchSize,l=n.numOfChan;if(isNaN(a)||a!==1){const S="The batch Size for input shape must be 1";return r(S,-1,S),0}if(isNaN(l)||l!==1){const S="The number of channels for input shape must be 1";return r(S,-1,S),0}Te().startScope(),console.log("Batch size: ",a),console.log("Num of Channels: ",l);const c=await rw(n.rootURL+e.path);await ej(!0),i.TF_Backend=jf();const u=c;let h=[];if(h=u.layers[0].batchInputShape,console.log(" Model batch input shape : ",h),h.length!==5){const S="The model input shape must be 5D";return r(S,-1,S),0}let d,p,f;const g=t.dims[1],m=t.dims[2],x=t.dims[3];if(await Nc(u)){if(console.log("Model Channel Last"),isNaN(h[4])||h[4]!==1){const S="The number of channels for input shape must be 1";return r(S,-1,S),0}d=h[1],p=h[2],f=h[3]}else{if(console.log("Model Channel First"),isNaN(h[1])||h[1]!==1){const S="The number of channels for input shape must be 1";return r(S,-1,S),0}d=h[2],p=h[3],f=h[4]}let w;d===256&&p===256&&f===256?w=!0:w=!1,i.isModelFullVol=w;let y=await iw(x,t,s);const C=await GH(y,m,g);y=null;let I=await HH(C);fe(C);const v=e.enableTranspose,k=e.enableCrop;w&&(k?await JH(c,I,x,m,g,w,e,i,n,o,r,t,s):(console.log("Cropping Disabled"),v?(I=I.transpose(),console.log("Input transposed")):console.log("Transpose NOT Enabled"),e.enableSeqConv?(console.log("Seq Convoluton Enabled"),await qH()):(console.log("Seq Convoluton Disabled"),await KH())))}self.addEventListener("message",function(n){tj(n.data.opts,n.data.modelEntry,n.data.niftiHeader,n.data.niftiImage,ow,kt)},!1)})(); + */const GH=[IB,vB,TB,RB,DB,OB,MB,BB,UB,HB,KB,ZB,ez,oz,az,cz,hz,mz,xz,yz,Iz,Nz,Rz,_z,Lz,Vz,Uz,jz,rB,Yz,tV,rV,hV,fV,gV,bV,wV,vV,SV,NV,RV,DV,_V,MV,BV,UV,HV,KV,ZV,JV,tW,oW,iW,cW,hW,dW,fW,gW,bW,wW,IW,vW,TW,RW,DW,OW,PW,zW,WW,oB,GW,Jz,qW,KW,YW,aB,QW,e4,n4,r4,l4,u4,d4,f4,x4,y4,C4,k4,T4,E4,F4,O4,M4,B4,V4,H4,K4,Q4,oU,uB,lU,hU,fU,xU,Mz,yU,CU,$U,SU,RU,cB,DU,_U,LU,PU,BU,Pz,eU,VU,GU,jU,dB,ZU,eG,oG,aG,hG,pG,mG,xG,wG,$G,SG,EG,DG,_G,PG,zG,Tz,nU,WG,UG,HG,jG,XG,ZG,JG,tH,sH,rH,aH,cH,hH,fH,gH,bH,wH,tU,yB,IH,vH,SH,EH,FH,LH,wB,PH,zH,UH,wU];for(const n of GH)mf(n);class HH{idx(e,t,s,o){return s*o[0]*o[1]+t*o[0]+e}check_previous_slice(e,t,s,o,r,i,a,l,c,u){let h=0;if(!r)return 0;const d=e[this.idx(s,o,r,i)];if(a>=6){const p=this.idx(s,o,r-1,i);d===e[p]&&(c[h++]=t[p])}if(a>=18){if(s){const p=this.idx(s-1,o,r-1,i);d===e[p]&&(c[h++]=t[p])}if(o){const p=this.idx(s,o-1,r-1,i);d===e[p]&&(c[h++]=t[p])}if(s=6){if(f){const x=this.idx(f-1,p,d,t);m===e[x]&&(h[g++]=u[x])}if(p){const x=this.idx(f,p-1,d,t);m===e[x]&&(h[g++]=u[x])}}if(s>=18){if(p&&f){const x=this.idx(f-1,p-1,d,t);m===e[x]&&(h[g++]=u[x])}if(p&&f=l){l+=a;const x=new Uint32Array(l);x.set(c),c=x}c[i-1]=i,i++}}}for(let d=0;d.",inferenceDelay:100,description:"Gray and white matter segmentation model. Operates on full T1 image in a single pass but needs a dedicated graphics card to operate. Provides the best accuracy with hard cropping for better speed"},{id:3,type:"Segmentation",path:"/models/model20chan3cls/model.json",modelName:"🔪 Tissue GWM (High Acc, Low Mem)",labelsPath:"./models/model20chan3cls/labels.json",colorsPath:"./models/model20chan3cls/colorLUT.json",colormapPath:"./models/model20chan3cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Gray and white matter segmentation model. Operates on full T1 image in a single pass but needs a dedicated graphics card to operate. Provides high accuracy and fit low memory available but slower"},{id:4,type:"Atlas",path:"/models/model30chan18cls/model.json",modelName:"🪓 Subcortical + GWM (High Mem, Fast)",labelsPath:"./models/model30chan18cls/labels.json",colorsPath:"./models/model30chan18cls/colorLUT.json",colormapPath:"./models/model30chan18cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is a robust model able to handle range of data quality, including varying saturation, and even clinical scans. It may work on infant brains, but your mileage may vary."},{id:5,type:"Atlas",path:"/models/model30chan18cls/model.json",modelName:"🪓 Subcortical + GWM (Low Mem, Slow)",labelsPath:"./models/model30chan18cls/labels.json",colorsPath:"./models/model30chan18cls/colorLUT.json",colormapPath:"./models/model30chan18cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is a robust model able to handle range of data quality, including varying saturation, and even clinical scans. It may work on infant brains, but your mileage may vary."},{id:6,type:"Atlas",path:"/models/model18cls/model.json",modelName:"🪓 Subcortical + GWM (Low Mem, Faster)",labelsPath:"./models/model18cls/labels.json",colorsPath:"./models/model18cls/colorLUT.json",colormapPath:"./models/model18cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is a robust model able to handle range of data quality, including varying saturation, and even clinical scans. It may work on infant brains, but your mileage may vary."},{id:7,type:"Atlas",path:"/models/model30chan18cls/model.json",modelName:"🔪🪓 Subcortical + GWM (Failsafe, Less Acc)",labelsPath:"./models/model30chan18cls/labels.json",colorsPath:"./models/model30chan18cls/colorLUT.json",colormapPath:"./models/model30chan18cls/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is not a robust model, it may work on low data quality, including varying saturation, and even clinical scans. It may work also on infant brains, but your mileage may vary."},{id:8,type:"Atlas",path:"/models/model30chan50cls/model.json",modelName:"🔪 Aparc+Aseg 50 (High Mem, Fast)",labelsPath:"./models/model30chan50cls/labels.json",colorsPath:"./models/model30chan50cls/colorLUT.json",colormapPath:"./models/model30chan50cls/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"This is a 50-class model, that segments the brain into the Aparc+Aseg Freesurfer Atlas but one where cortical homologues are merged into a single class."},{id:9,type:"Atlas",path:"/models/model30chan50cls/model.json",modelName:"🔪 Aparc+Aseg 50 (Low Mem, Slow)",labelsPath:"./models/model30chan50cls/labels.json",colorsPath:"./models/model30chan50cls/colorLUT.json",colormapPath:"./models/model30chan50cls/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"This is a 50-class model, that segments the brain into the Aparc+Aseg Freesurfer Atlas but one where cortical homologues are merged into a single class. The model use sequential convolution for inference to overcome browser memory limitations but leads to longer computation time."},{id:10,type:"Brain_Extraction",path:"/models/model5_gw_ae/model.json",modelName:"⚡ Extract the Brain (FAST)",labelsPath:null,colorsPath:null,preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:18,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:null,inferenceDelay:100,description:"Extract the brain fast model operates on full T1 image in a single pass, but uses only 5 filters per layer. Can work on integrated graphics cards but is barely large enough to provide good accuracy. Still more accurate than the failsafe version."},{id:11,type:"Brain_Extraction",path:"/models/model11_gw_ae/model.json",modelName:"🔪 Extract the Brain (High Acc, Slow)",labelsPath:null,colorsPath:null,preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Extract the brain high accuracy model operates on full T1 image in a single pass, but uses only 11 filters per layer. Can work on dedicated graphics cards. Still more accurate than the fast version."},{id:12,type:"Brain_Masking",path:"/models/model5_gw_ae/model.json",modelName:"⚡ Brain Mask (FAST)",labelsPath:null,colorsPath:null,colormapPath:"./models/model5_gw_ae/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:17,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:null,inferenceDelay:100,description:"This fast masking model operates on full T1 image in a single pass, but uses only 5 filters per layer. Can work on integrated graphics cards but is barely large enough to provide good accuracy. Still more accurate than failsafe version."},{id:13,type:"Brain_Masking",path:"/models/model11_gw_ae/model.json",modelName:"🔪 Brain Mask (High Acc, Low Mem)",labelsPath:null,colorsPath:null,preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"This masking model operates on full T1 image in a single pass, but uses 11 filters per layer. Can work on dedicated graphics cards. Still more accurate than fast version."},{id:14,type:"Atlas",path:"/models/model21_104class/model.json",modelName:"🔪 Aparc+Aseg 104 (High Mem, Fast)",labelsPath:"./models/model21_104class/labels.json",colorsPath:"./models/model21_104class/colorLUT.json",colormapPath:"./models/model21_104class/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"FreeSurfer aparc+aseg atlas 104 parcellate brain areas into 104 regions. It contains a combination of the Desikan-Killiany atlas for cortical area and also segmentation of subcortical regions."},{id:15,type:"Atlas",path:"/models/model21_104class/model.json",modelName:"🔪 Aparc+Aseg 104 (Low Mem, Slow)",labelsPath:"./models/model21_104class/labels.json",colorsPath:"./models/model21_104class/colorLUT.json",colormapPath:"./models/model21_104class/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"FreeSurfer aparc+aseg atlas 104 parcellate brain areas into 104 regions. It contains a combination of the Desikan-Killiany atlas for cortical area and also segmentation of subcortical regions. The model use sequential convolution for inference to overcome browser memory limitations but leads to longer computation time. "}];function kt(n="",e=-1,t="",s=[]){let o=[];Object.keys(s).length>0&&(o=function(i){let a={};for(var l in s)a[l]=s[l];return JSON.stringify(a)}()),self.postMessage({cmd:"ui",message:n,progressFrac:e,modalMessage:t,statData:o})}function aw(n,e,t){self.postMessage({cmd:"img",img:n,opts:e,modelEntry:t})}async function Ep(n){let e=0;for(let t=0;tp-f);const r=At(o),i=r.shape[0],a=Math.floor(i*e),l=Math.ceil(i*t)-1,c=r.slice(a,1),u=r.slice(l,1),h=(await c.array())[0],d=(await u.array())[0];return s.dispose(),r.dispose(),c.dispose(),u.dispose(),{qmin:h,qmax:d}}async function Ap(n,e=.05,t=.95){const{qmin:s,qmax:o}=await KH(n,e,t),r=Fe(s),i=Fe(o),a=n.sub(r).div(i.sub(r));return r.dispose(),i.dispose(),a}async function Dp(n){const e=n.max(),t=n.min();return await n.sub(t).div(e.sub(t))}async function XH(n,e,t,s,o,r,i){callbackUI(msg,-1,"inferenceFullVolumeSeqCovLayer() is not dead code?")}async function YH(n,e,t,s,o,r,i){kt("",-1,"inferenceFullVolume() is not dead code?")}async function uw(n,e,t,s,o,r=null){kt("",-1,"inferenceSubVolumes() is not dead code?")}async function hw(n,e){kt("",-1,"tensor2LightBuffer() is not dead code?")}async function dw(n,e,t){let s=[];for(let l=0;l0?t-c-1:0,p=s-u-1>0?s-u-1:0,f=e-h-1>0?e-h-1:0;return n.pad([[i,d],[a,p],[l,f]])}async function mw(n,e){const t=n.max(),s=t.mul(e),o=await s.data();return t.dispose(),s.dispose(),P(()=>n.clone().greater(o[0]))}async function Dc(n){return n.step(0)}async function ZH(n,e,t,s,o,r,i,a,l,c,u=!0){console.log("Generate Brain Masking ... ");let h=[];for(let m=0;m{const m="postProcessSlices3D() should be upgraded to BWLabeler";i(m,-1,m)}),console.log("Post processing done ")):console.log("Phase-1 Post processing disabled ... ");const p=new Array(h[0].length*h.length);let f=0;for(let m=0;m{const w=n.slice([0,0,0,0,m],[-1,-1,-1,-1,x-m]),y=e.slice([0,0,0,m,u],[-1,-1,-1,x-m,1]);return sh(w,y,s,o,"NDHWC",r)});if(p===null)p=b;else{const w=p.add(b);p.dispose(),b.dispose(),p=w}}}const f=p.add(d);if(p.dispose(),d.dispose(),c==null)c=f;else{const g=await Mt([c,f],4);f.dispose(),c.dispose(),c=g}}return c}function JH(n,e,t){const i=n.shape[4],a=Math.ceil(i/t);let l=null;for(let c=0;cn.slice([0,0,0,0,u],[-1,-1,-1,-1,d])),f=P(()=>e.slice([0,0,0,u,0],[-1,-1,-1,d,-1])),g=sh(p,f,1,0,"NDHWC",1);p.dispose(),f.dispose();const m=Xo(g);if(g.dispose(),l===null)l=m;else{const x=l.add(m);l.dispose(),l!==m&&m.dispose(),l=x}P(()=>{De(st([1,1]),st([1,1]))})}return l}class eq{constructor(e,t,s,o){this.model=e,this.outChannels=e.outputLayers[0].kernel.shape[4],this.chunkSize=t,this.isChannelLast=s,this.callbackUI=o}async apply(e){const t=yr.get("WEBGL_DELETE_TEXTURE_THRESHOLD");yr.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0);const s=this,o=performance.now(),r=s.model.layers[s.model.layers.length-1],i=r.getWeights()[0],a=r.getWeights()[1],l=s.isChannelLast?e.shape.slice(1,-1):e.shape.slice(2);let c=D(Nn(l),-1e4),u=st(l),h=0;for(console.log(" channel loop");;){Te().startScope(),console.log("=======================");const d=await Ot();console.log(`| Number of Tensors: ${d.numTensors}`),console.log(`| Number of Data Buffers: ${d.numDataBuffers}`),console.log("Channel : ",h);const p=await P(()=>{const g=i.slice([0,0,0,0,h],[-1,-1,-1,-1,1]),m=a.slice([h],[1]),x=JH(e,g,Math.min(s.chunkSize,s.outChannels)).add(m),b=Zt(x,c),w=Ct(b,x,c),y=Ct(b,Ii(u.shape,h),u);return fe([c,u,g,m,x,b]),P(()=>De(Nn([1,1]),Nn([1,1]))),[y,w]});console.log("=======================");const f=await Ot();if(s.callbackUI(`Iteration ${h}`,h/s.outChannels),console.log(`Number of Tensors: ${f.numTensors}`),console.log(`Number of Data Buffers: ${f.numDataBuffers}`),console.log(`Megabytes In Use: ${(f.numBytes/1048576).toFixed(3)} MB`),f.unreliable&&console.log(`Unreliable: ${f.unreliable}`),typeof u<"u"&&u.dispose(),typeof c<"u"&&c.dispose(),u=dn(p[0]),c=dn(p[1]),Te().endScope(),h===s.outChannels-1){fe(c);const m=performance.now()-o;return console.log(`Execution time for output layer: ${m} milliseconds`),yr.set("WEBGL_DELETE_TEXTURE_THRESHOLD",t),u}else{h++;const g=u.shape,m=u.dataSync(),x=u.shape,b=c.dataSync();u.dispose(),c.dispose(),u=ss(m,g),c=ss(b,x)}}}}async function gw(n,e,t,s,o,r,i,a,l,c){if(l.isPostProcessEnable){const d=new HH,p=new Uint32Array(e),f=26,g=!0,m=!0,[x,b]=d.bwlabel(n,p,f,g,m);for(let w=0;w0&&E<=1?p=await mw(s,E):(console.log("No valid crop threshold value"),p=await s.greater([0]).asType("bool"))}else p=await a.greater([0]).asType("bool");console.log(" mask_3d shape : ",p.shape);const f=await Om(p);p.dispose();const g=f.min(0).arraySync()[0],m=f.max(0).arraySync()[0],x=f.min(0).arraySync()[1],b=f.max(0).arraySync()[1],w=f.min(0).arraySync()[2],y=f.max(0).arraySync()[2];console.log("row min and max :",g,m),console.log("col min and max :",x,b),console.log("depth min and max :",w,y);const C=[g,x,w],I=[m-g+1,b-x+1,y-w+1];f.dispose();const v=await s.slice([g,x,w],[m-g+1,b-x+1,y-w+1]);s.dispose();const k=e.cropPadding;let S=await fw(v,[k,k],[k,k],[k,k]);if(console.log(" cropped slices_3d with padding shape: ",S.shape),v.dispose(),n.drawBoundingVolume){let E=await Rc(S,k,k,k);return console.log(" outLabelVolume without padding shape : ",E.shape),E=await Ac(E,o,r,i,C,I),console.log(" outLabelVolume final shape after resizing : ",E.shape),dw(Gn(E),n,e),E.dispose(),0}u.Brainchop_Ver="FullVolume";const T=await t;try{let E=performance.now();const V=performance.now();let M=0;const L=e.enableTranspose;L?(S=await S.transpose(),console.log("Input transposed for pre-model")):console.log("Transpose not enabled for pre-model");let R=1;const B=T.layers.length;console.log("res.layers.length ",B);const G=Ec(T),z=n.batchSize,q=n.numOfChan;let K;G?(T.layers[0].batchInputShape[1]=S.shape[0],T.layers[0].batchInputShape[2]=S.shape[1],T.layers[0].batchInputShape[3]=S.shape[2],K=[z,T.layers[0].batchInputShape[1],T.layers[0].batchInputShape[2],T.layers[0].batchInputShape[3],q]):(T.layers[0].batchInputShape[2]=S.shape[0],T.layers[0].batchInputShape[3]=S.shape[1],T.layers[0].batchInputShape[4]=S.shape[2],K=[z,q,T.layers[0].batchInputShape[2],T.layers[0].batchInputShape[3],T.layers[0].batchInputShape[4]]),console.log(" Model batch input shape : ",T.layers[0].batchInputShape),u.Input_Shape=JSON.stringify(T.layers[0].batchInputShape),u.Output_Shape=JSON.stringify(T.output.shape),u.Channel_Last=await G,u.Model_Param=await Ep(T),u.Model_Layers=await Rp(T),u.Model=e.modelName,u.Seq_Conv=e.enableSeqConv;const X=T.layers[T.layers.length-1];console.log("Output Layer : ",X);const J=G?X.outputShape[X.outputShape.length-1]:X.outputShape[1];console.log("Num of output channels x: ",J);const j=[];for(j[0]=await S.reshape(K);;){try{T.layers[R].activation.getClassName()!=="linear"?j[R]=await T.layers[R].apply(j[R-1]):j[R]=await QH(j[R-1],T.layers[R].getWeights()[0],T.layers[R].getWeights()[1],T.layers[R].strides,T.layers[R].padding,T.layers[R].dilationRate,3),fe(j[R-1])}catch(Q){const Z="Your graphics card (e.g. Intel) may not be compatible with WebGL. "+Q.message;return l(Z,-1,Z),Te().endScope(),Te().disposeVariables(),u.Inference_t=1/0,u.Postprocess_t=1/0,u.Status="Fail",u.Error_Type=Q.message,u.Extra_Err_Info="Failed while model layer "+R+" apply",kt("",-1,"",u),0}if(console.log("layer output Tensor shape : ",j[R].shape),console.log("layer count params ",T.layers[R].countParams()),T.layers[R].dispose(),j[R-1].dispose(),l("Layer "+R.toString(),(R+1)/B),Ot().unreliable){const Q="unreliable reasons :"+Ot().reasons;l(Q,NaN,Q)}if(R===B-2){const Q=await new eq(T,10,G,l);let Z=null;const te=await mC(async()=>{Z=await Q.apply(j[R])});if(console.log("profileInfo : ",te),fe(j[R]),console.log(" Output tensor",Z),console.log(" Output tensor shape : ",Z.shape),Z.shape.length!==3){const be="Output tensor shape should be 3 dims but it is "+Z.shape.length;l(be,-1,be)}const ie=((performance.now()-E)/1e3).toFixed(4);console.log(" find array max ");const he=await Z.max().dataSync()[0];Mhere'),Ot().unreliable){const V="unreliable reasons :"+Ot().reasons;l(V,NaN,V)}}}async function bw(n,e,t,s,o,r,i,a,l,c,u,h){let d=[];console.log(" ---- Start FullVolume inference phase-II ---- "),i.enableQuantileNorm?(console.log("preModel Quantile normalization enabled"),e=await Ap(e)):(console.log("preModel Min Max normalization enabled"),e=await Dp(e));let f;if(r==null){const R=i.autoThreshold;R>0&&R<=1?f=await mw(e,R):(console.log("No valid crop threshold value"),f=await e.greater([0]).asType("bool"))}else f=await r.greater([0]).asType("bool");console.log(" mask_3d shape : ",f.shape);const g=await Om(f);f.dispose();const m=g.arraySync();let x=s,b=0,w=o,y=0,C=t,I=0;for(let R=0;Rm[R][0]?x=m[R][0]:bm[R][1]?w=m[R][1]:ym[R][2]?C=m[R][2]:Ihere')}}async function tq(n,e,t,s,o,r,i,a,l,c,u,h,d){if(a.No_SubVolumes=1,i.preModelId){const p=await lw(l.rootURL+Np[i.preModelId-1].path),f=Np[i.preModelId-1].enableTranspose,g=Np[i.preModelId-1].enableQuantileNorm;let m=null;g?(console.log("preModel Quantile normalization enabled"),m=await Ap(e)):(console.log("preModel Min Max normalization enabled"),m=await Dp(e)),f?(m=m.transpose(),console.log("Input transposed for pre-model")):console.log("Transpose not enabled for pre-model"),a.Brainchop_Ver="PreModel_FV";const x=await p;try{const b=performance.now(),w=x,y=w.layers[0].batchInputShape;if(console.log(" Pre-Model batch input shape : ",y),y.length!==5){const B="The pre-model input shape must be 5D ";return u(B,-1,B),0}const C=await Ec(w),I=l.batchSize,v=l.numOfChan;let k,S,T,E;if(C){if(console.log("Pre-Model Channel Last"),isNaN(y[4])||y[4]!==1){const B="The number of channels for pre-model input shape must be 1";return u(B,-1,B),0}k=y[1],S=y[2],T=y[3],E=[I,k,S,T,v]}else{if(console.log("Pre-Model Channel First"),isNaN(y[1])||y[1]!==1){const B="The number of channels for pre-model input shape must be 1";return u(B,-1,B),0}k=y[2],S=y[3],T=y[4],E=[I,v,k,S,T]}a.Input_Shape=JSON.stringify(E),a.Output_Shape=JSON.stringify(w.output.shape),a.Channel_Last=await C,a.Model_Param=await Ep(w),a.Model_Layers=await Rp(w);let V=0,M=1;const L=x.layers.length,R=[];for(R[0]=m.reshape(E),fe(m);;){try{R[M]=x.layers[M].apply(R[M-1])}catch(B){const G="Your graphics card (e.g. Intel) may not be compatible with WebGL. "+B.message;return u(G,-1,G),Te().endScope(),Te().disposeVariables(),a.Inference_t=1/0,a.Postprocess_t=1/0,a.Status="Fail",a.Error_Type=B.message,a.Extra_Err_Info="PreModel Failed while model layer "+M+" apply",kt("",-1,"",a),0}if(x.layers[M].dispose(),R[M-1].dispose(),u("Layer "+M.toString(),(M+1)/L),Ot().unreliable){const B="unreliable reasons :"+Ot().reasons;u(B,NaN,B)}if(M===L-1){const B=C?-1:1;console.log(" find argmax "),console.log("last Tensor shape : ",R[M].shape);const G=C?R[M].shape[4]:R[M].shape[1];let z;try{console.log(" Try tf.argMax for fullVolume .."),z=await no(R[M],B)}catch(te){if(B===-1)try{const ie=performance.now();console.log(" tf.argMax failed .. try argMaxLarge ..");const he=hw(R[M].reshape([t,s,o,G]),"float16");z=pw(he,t,s,o,G,"float16"),console.log("argMaxLarge for fullVolume takes : ",((performance.now()-ie)/1e3).toFixed(4))}catch(ie){const he="argMax buffer couldn't be created due to limited memory resources.";return u(he,-1,he),z.dispose(),Te().endScope(),Te().disposeVariables(),a.Inference_t=1/0,a.Postprocess_t=1/0,a.Status="Fail",a.Error_Type=ie.message,a.Extra_Err_Info="preModel prediction_argmax from argMaxLarge failed",kt("",-1,"",a),0}else{const ie="argMax buffer couldn't be created due to limited memory resources.";return u(ie,-1,ie),z.dispose(),Te().endScope(),Te().disposeVariables(),a.Inference_t=1/0,a.Postprocess_t=1/0,a.Status="Fail",a.Error_Type=te.message,a.Extra_Err_Info="preModel prediction_argmax from argMaxLarge not support yet channel first",kt("",-1,"",a),0}}console.log(" Pre-model prediction_argmax shape : ",z.shape);const q=((performance.now()-b)/1e3).toFixed(4);fe(R[M]),console.log(" Pre-model find array max ");const K=await z.max().dataSync()[0];Vhere')}}else console.log("--- No pre-model is selected ---"),console.log("------ Run voxel cropping ------"),r?i.enableSeqConv?(console.log("------ Seq Convoluton ------"),await xw(l,i,n,e,t,s,o,null,u,c,a,d)):bw(n,e,t,s,o,null,i,a,l,c,u,d):uw(n,e,t,s,o,null)}async function nq(n=!0){gC("webgl"),await fC(),W().set("DEBUG",!1),W().set("WEBGL_FORCE_F16_TEXTURES",n),W().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0),await xC(),console.log("tf env() flags :",W().flags),console.log("tf env() features :",W().features),console.log("tf env total features: ",Object.keys(W().features).length),console.log("tf backend: ",qf())}async function sq(n,e,t,s,o,r){const i=[];i.startTime=Date.now(),r("Segmentation started",0);const a=n.batchSize,l=n.numOfChan;if(isNaN(a)||a!==1){const S="The batch Size for input shape must be 1";return r(S,-1,S),0}if(isNaN(l)||l!==1){const S="The number of channels for input shape must be 1";return r(S,-1,S),0}Te().startScope(),console.log("Batch size: ",a),console.log("Num of Channels: ",l);const c=await lw(n.rootURL+e.path);await nq(!0),i.TF_Backend=qf();const u=c;let h=[];if(h=u.layers[0].batchInputShape,console.log(" Model batch input shape : ",h),h.length!==5){const S="The model input shape must be 5D";return r(S,-1,S),0}let d,p,f;const g=t.dims[1],m=t.dims[2],x=t.dims[3];if(await Ec(u)){if(console.log("Model Channel Last"),isNaN(h[4])||h[4]!==1){const S="The number of channels for input shape must be 1";return r(S,-1,S),0}d=h[1],p=h[2],f=h[3]}else{if(console.log("Model Channel First"),isNaN(h[1])||h[1]!==1){const S="The number of channels for input shape must be 1";return r(S,-1,S),0}d=h[2],p=h[3],f=h[4]}let w;d===256&&p===256&&f===256?w=!0:w=!1,i.isModelFullVol=w;let y=await cw(x,t,s);const C=await qH(y,m,g);y=null;let I=await jH(C);fe(C);const v=e.enableTranspose,k=e.enableCrop;w&&(k?await tq(c,I,x,m,g,w,e,i,n,o,r,t,s):(console.log("Cropping Disabled"),v?(I=I.transpose(),console.log("Input transposed")):console.log("Transpose NOT Enabled"),e.enableSeqConv?(console.log("Seq Convoluton Enabled"),await XH()):(console.log("Seq Convoluton Disabled"),await YH())))}self.addEventListener("message",function(n){sq(n.data.opts,n.data.modelEntry,n.data.niftiHeader,n.data.niftiImage,aw,kt)},!1)})(); diff --git a/assets/index-D8WZGP6y.js b/assets/index-C04JT-qQ.js similarity index 97% rename from assets/index-D8WZGP6y.js rename to assets/index-C04JT-qQ.js index 14dba17..d8094bd 100644 --- a/assets/index-D8WZGP6y.js +++ b/assets/index-C04JT-qQ.js @@ -90,7 +90,7 @@ var tA=Object.defineProperty;var iA=(a,n,s)=>n in a?tA(a,n,{enumerable:!0,config `},"%p":function(B){return B.tm_hour>0&&B.tm_hour<13?"AM":"PM"},"%S":function(B){return E(B.tm_sec,2)},"%t":function(){return" "},"%u":function(B){var z=new Date(B.tm_year+1900,B.tm_mon+1,B.tm_mday,0,0,0,0);return z.getDay()||7},"%U":function(B){var z=new Date(B.tm_year+1900,0,1),b=z.getDay()===0?z:__addDays(z,7-z.getDay()),W=new Date(B.tm_year+1900,B.tm_mon,B.tm_mday);if(e(b,W)<0){var q=__arraySum(__isLeapYear(W.getFullYear())?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR,W.getMonth()-1)-31,Y=31-b.getDate(),X=Y+q+W.getDate();return E(Math.ceil(X/7),2)}return e(b,z)===0?"01":"00"},"%V":function(B){var z=new Date(B.tm_year+1900,0,4),b=new Date(B.tm_year+1901,0,4),W=F(z),q=F(b),Y=__addDays(new Date(B.tm_year+1900,0,1),B.tm_yday);if(e(Y,W)<0)return"53";if(e(q,Y)<=0)return"01";var X;return W.getFullYear()=0;return z=Math.abs(z)/60,z=z/60*100+z%60,(b?"+":"-")+("0000"+z).slice(-4)},"%Z":function(B){return B.tm_zone},"%%":function(){return"%"}};for(var y in L)A.indexOf(y)>=0&&(A=A.replace(new RegExp(y,"g"),L[y](m)));var V=intArrayFromString(A,!1);return V.length>n?0:(writeArrayToMemory(V,a),V.length-1)}function _strftime_l(a,n,s,u){return _strftime(a,n,s,u)}function _abort(){Module.abort()}function _free(){}Module._free=_free;function ___cxa_free_exception(a){try{return _free(a)}catch{}}function ___cxa_end_catch(){if(___cxa_end_catch.rethrown){___cxa_end_catch.rethrown=!1;return}asm.setThrew(0);var a=EXCEPTIONS.caught.pop();a&&(EXCEPTIONS.decRef(EXCEPTIONS.deAdjust(a)),EXCEPTIONS.last=0)}function _pthread_once(a,n){_pthread_once.seen||(_pthread_once.seen={}),!(a in _pthread_once.seen)&&(Runtime.dynCall("v",n),_pthread_once.seen[a]=1)}function ___lock(){}function ___unlock(){}var PTHREAD_SPECIFIC={};function _pthread_getspecific(a){return PTHREAD_SPECIFIC[a]||0}function ___setErrNo(a){return Module.___errno_location&&(HEAP32[Module.___errno_location()>>2]=a),a}var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};function _sysconf(a){switch(a){case 30:return PAGE_SIZE;case 85:return totalMemory/PAGE_SIZE;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:return typeof navigator=="object"&&navigator.hardwareConcurrency||1}return ___setErrNo(ERRNO_CODES.EINVAL),-1}var _fabs=Math_abs,PTHREAD_SPECIFIC_NEXT_KEY=1;function _pthread_key_create(a,n){return a==0?ERRNO_CODES.EINVAL:(HEAP32[a>>2]=PTHREAD_SPECIFIC_NEXT_KEY,PTHREAD_SPECIFIC[PTHREAD_SPECIFIC_NEXT_KEY]=0,PTHREAD_SPECIFIC_NEXT_KEY++,0)}function _emscripten_set_main_loop_timing(a,n){if(Browser.mainLoop.timingMode=a,Browser.mainLoop.timingValue=n,!Browser.mainLoop.func)return 1;if(a==0)Browser.mainLoop.scheduler=function(){setTimeout(Browser.mainLoop.runner,n)},Browser.mainLoop.method="timeout";else if(a==1)Browser.mainLoop.scheduler=function(){Browser.requestAnimationFrame(Browser.mainLoop.runner)},Browser.mainLoop.method="rAF";else if(a==2){if(!window.setImmediate){let f=function(m){m.source===window&&m.data===u&&(m.stopPropagation(),s.shift()())};var s=[],u="__emcc";window.addEventListener("message",f,!0),window.setImmediate=function(A){s.push(A),window.postMessage(u,"*")}}Browser.mainLoop.scheduler=function(){window.setImmediate(Browser.mainLoop.runner)},Browser.mainLoop.method="immediate"}return 0}function _emscripten_set_main_loop(a,n,s,u,f){Module.noExitRuntime=!0,assert(!Browser.mainLoop.func,"emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters."),Browser.mainLoop.func=a,Browser.mainLoop.arg=u;var m=Browser.mainLoop.currentlyRunningMainloop;if(Browser.mainLoop.runner=function(){if(!ABORT){if(Browser.mainLoop.queue.length>0){var v=Date.now(),y=Browser.mainLoop.queue.shift();if(y.func(y.arg),Browser.mainLoop.remainingBlockers){var T=Browser.mainLoop.remainingBlockers,I=T%1==0?T-1:Math.floor(T);y.counted?Browser.mainLoop.remainingBlockers=I:(I=I+.5,Browser.mainLoop.remainingBlockers=(8*T+I)/9)}console.log('main loop blocker "'+y.name+'" took '+(Date.now()-v)+" ms"),Browser.mainLoop.updateStatus(),setTimeout(Browser.mainLoop.runner,0);return}if(!(m1&&Browser.mainLoop.currentFrameNumber%Browser.mainLoop.timingValue!=0){Browser.mainLoop.scheduler();return}Browser.mainLoop.method==="timeout"&&Module.ctx&&(Module.printErr("Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!"),Browser.mainLoop.method=""),Browser.mainLoop.runIter(function(){typeof u<"u"?Runtime.dynCall("vi",a,[u]):Runtime.dynCall("v",a)}),!(m0?_emscripten_set_main_loop_timing(0,1e3/n):_emscripten_set_main_loop_timing(1,1),Browser.mainLoop.scheduler()),s)throw"SimulateInfiniteLoop"}var Browser={mainLoop:{scheduler:null,method:"",currentlyRunningMainloop:0,func:null,arg:0,timingMode:0,timingValue:0,currentFrameNumber:0,queue:[],pause:function(){Browser.mainLoop.scheduler=null,Browser.mainLoop.currentlyRunningMainloop++},resume:function(){Browser.mainLoop.currentlyRunningMainloop++;var a=Browser.mainLoop.timingMode,n=Browser.mainLoop.timingValue,s=Browser.mainLoop.func;Browser.mainLoop.func=null,_emscripten_set_main_loop(s,0,!1,Browser.mainLoop.arg,!0),_emscripten_set_main_loop_timing(a,n),Browser.mainLoop.scheduler()},updateStatus:function(){if(Module.setStatus){var a=Module.statusMessage||"Please wait...",n=Browser.mainLoop.remainingBlockers,s=Browser.mainLoop.expectedBlockers;n?n"u"&&(console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available."),Module.noImageDecoding=!0);var a={};a.canHandle=function(m){return!Module.noImageDecoding&&/\.(jpg|jpeg|png|bmp)$/i.test(m)},a.handle=function(m,A,v,y){var T=null;if(Browser.hasBlobConstructor)try{T=new Blob([m],{type:Browser.getMimetype(A)}),T.size!==m.length&&(T=new Blob([new Uint8Array(m).buffer],{type:Browser.getMimetype(A)}))}catch(e){Runtime.warnOnce("Blob constructor present but fails: "+e+"; falling back to blob builder")}if(!T){var I=new Browser.BlobBuilder;I.append(new Uint8Array(m).buffer),T=I.getBlob()}var S=Browser.URLObject.createObjectURL(T),E=new Image;E.onload=function(){assert(E.complete,"Image "+A+" could not be decoded");var F=document.createElement("canvas");F.width=E.width,F.height=E.height;var M=F.getContext("2d");M.drawImage(E,0,0),Module.preloadedImages[A]=F,Browser.URLObject.revokeObjectURL(S),v&&v(m)},E.onerror=function(F){console.log("Image "+S+" could not be decoded"),y&&y()},E.src=S},Module.preloadPlugins.push(a);var n={};n.canHandle=function(m){return!Module.noAudioDecoding&&m.substr(-4)in{".ogg":1,".wav":1,".mp3":1}},n.handle=function(m,A,v,y){var T=!1;function I(M){T||(T=!0,Module.preloadedAudios[A]=M,v&&v(m))}function S(){T||(T=!0,Module.preloadedAudios[A]=new Audio,y&&y())}if(Browser.hasBlobConstructor){try{var E=new Blob([m],{type:Browser.getMimetype(A)})}catch{return S()}var e=Browser.URLObject.createObjectURL(E),F=new Audio;F.addEventListener("canplaythrough",function(){I(F)},!1),F.onerror=function(L){if(T)return;console.log("warning: browser could not fully decode audio "+A+", trying slower base64 approach");function V(B){for(var z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b="=",W="",q=0,Y=0,X=0;X=6;){var H=q>>Y-6&63;Y-=6,W+=z[H]}return Y==2?(W+=z[(q&3)<<4],W+=b+b):Y==4&&(W+=z[(q&15)<<2],W+=b),W}F.src="data:audio/x-"+A.substr(-3)+";base64,"+V(m),I(F)},F.src=e,Browser.safeSetTimeout(function(){I(F)},1e4)}else return S()},Module.preloadPlugins.push(n);var s=Module.canvas;function u(){Browser.pointerLock=document.pointerLockElement===s||document.mozPointerLockElement===s||document.webkitPointerLockElement===s||document.msPointerLockElement===s}s&&(s.requestPointerLock=s.requestPointerLock||s.mozRequestPointerLock||s.webkitRequestPointerLock||s.msRequestPointerLock||function(){},s.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||function(){},s.exitPointerLock=s.exitPointerLock.bind(document),document.addEventListener("pointerlockchange",u,!1),document.addEventListener("mozpointerlockchange",u,!1),document.addEventListener("webkitpointerlockchange",u,!1),document.addEventListener("mspointerlockchange",u,!1),Module.elementPointerLock&&s.addEventListener("click",function(f){!Browser.pointerLock&&s.requestPointerLock&&(s.requestPointerLock(),f.preventDefault())},!1))},createContext:function(a,n,s,u){if(n&&Module.ctx&&a==Module.canvas)return Module.ctx;var f,m;if(n){var A={antialias:!1,alpha:!1};if(u)for(var v in u)A[v]=u[v];m=GL.createContext(a,A),m&&(f=GL.getContext(m).GLctx),a.style.backgroundColor="black"}else f=a.getContext("2d");return f?(s&&(n||assert(typeof GLctx>"u","cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),Module.ctx=f,n&&GL.makeContextCurrent(m),Module.useWebGL=n,Browser.moduleContextCreatedCallbacks.forEach(function(y){y()}),Browser.init()),f):null},destroyContext:function(a,n,s){},fullScreenHandlersInstalled:!1,lockPointer:void 0,resizeCanvas:void 0,requestFullScreen:function(a,n,s){Browser.lockPointer=a,Browser.resizeCanvas=n,Browser.vrDevice=s,typeof Browser.lockPointer>"u"&&(Browser.lockPointer=!0),typeof Browser.resizeCanvas>"u"&&(Browser.resizeCanvas=!1),typeof Browser.vrDevice>"u"&&(Browser.vrDevice=null);var u=Module.canvas;function f(){Browser.isFullScreen=!1;var A=u.parentNode;(document.webkitFullScreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.mozFullscreenElement||document.fullScreenElement||document.fullscreenElement||document.msFullScreenElement||document.msFullscreenElement||document.webkitCurrentFullScreenElement)===A?(u.cancelFullScreen=document.cancelFullScreen||document.mozCancelFullScreen||document.webkitCancelFullScreen||document.msExitFullscreen||document.exitFullscreen||function(){},u.cancelFullScreen=u.cancelFullScreen.bind(document),Browser.lockPointer&&u.requestPointerLock(),Browser.isFullScreen=!0,Browser.resizeCanvas&&Browser.setFullScreenCanvasSize()):(A.parentNode.insertBefore(u,A),A.parentNode.removeChild(A),Browser.resizeCanvas&&Browser.setWindowedCanvasSize()),Module.onFullScreen&&Module.onFullScreen(Browser.isFullScreen),Browser.updateCanvasDimensions(u)}Browser.fullScreenHandlersInstalled||(Browser.fullScreenHandlersInstalled=!0,document.addEventListener("fullscreenchange",f,!1),document.addEventListener("mozfullscreenchange",f,!1),document.addEventListener("webkitfullscreenchange",f,!1),document.addEventListener("MSFullscreenChange",f,!1));var m=document.createElement("div");u.parentNode.insertBefore(m,u),m.appendChild(u),m.requestFullScreen=m.requestFullScreen||m.mozRequestFullScreen||m.msRequestFullscreen||(m.webkitRequestFullScreen?function(){m.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:null),s?m.requestFullScreen({vrDisplay:s}):m.requestFullScreen()},nextRAF:0,fakeRequestAnimationFrame:function(a){var n=Date.now();if(Browser.nextRAF===0)Browser.nextRAF=n+1e3/60;else for(;n+2>=Browser.nextRAF;)Browser.nextRAF+=1e3/60;var s=Math.max(Browser.nextRAF-n,0);setTimeout(a,s)},requestAnimationFrame:function a(n){typeof window>"u"?Browser.fakeRequestAnimationFrame(n):(window.requestAnimationFrame||(window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||Browser.fakeRequestAnimationFrame),window.requestAnimationFrame(n))},safeCallback:function(a){return function(){if(!ABORT)return a.apply(null,arguments)}},allowAsyncCallbacks:!0,queuedAsyncCallbacks:[],pauseAsyncCallbacks:function(){Browser.allowAsyncCallbacks=!1},resumeAsyncCallbacks:function(){if(Browser.allowAsyncCallbacks=!0,Browser.queuedAsyncCallbacks.length>0){var a=Browser.queuedAsyncCallbacks;Browser.queuedAsyncCallbacks=[],a.forEach(function(n){n()})}},safeRequestAnimationFrame:function(a){return Browser.requestAnimationFrame(function(){ABORT||(Browser.allowAsyncCallbacks?a():Browser.queuedAsyncCallbacks.push(a))})},safeSetTimeout:function(a,n){return Module.noExitRuntime=!0,setTimeout(function(){ABORT||(Browser.allowAsyncCallbacks?a():Browser.queuedAsyncCallbacks.push(a))},n)},safeSetInterval:function(a,n){return Module.noExitRuntime=!0,setInterval(function(){ABORT||Browser.allowAsyncCallbacks&&a()},n)},getMimetype:function(a){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[a.substr(a.lastIndexOf(".")+1)]},getUserMedia:function(a){window.getUserMedia||(window.getUserMedia=navigator.getUserMedia||navigator.mozGetUserMedia),window.getUserMedia(a)},getMovementX:function(a){return a.movementX||a.mozMovementX||a.webkitMovementX||0},getMovementY:function(a){return a.movementY||a.mozMovementY||a.webkitMovementY||0},getMouseWheelDelta:function(a){var n=0;switch(a.type){case"DOMMouseScroll":n=a.detail;break;case"mousewheel":n=a.wheelDelta;break;case"wheel":n=a.deltaY;break;default:throw"unrecognized mouse wheel event: "+a.type}return n},mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,touches:{},lastTouches:{},calculateMouseEvent:function(a){if(Browser.pointerLock)a.type!="mousemove"&&"mozMovementX"in a?Browser.mouseMovementX=Browser.mouseMovementY=0:(Browser.mouseMovementX=Browser.getMovementX(a),Browser.mouseMovementY=Browser.getMovementY(a)),typeof SDL<"u"?(Browser.mouseX=SDL.mouseX+Browser.mouseMovementX,Browser.mouseY=SDL.mouseY+Browser.mouseMovementY):(Browser.mouseX+=Browser.mouseMovementX,Browser.mouseY+=Browser.mouseMovementY);else{var n=Module.canvas.getBoundingClientRect(),s=Module.canvas.width,u=Module.canvas.height,f=typeof window.scrollX<"u"?window.scrollX:window.pageXOffset,m=typeof window.scrollY<"u"?window.scrollY:window.pageYOffset;if(a.type==="touchstart"||a.type==="touchend"||a.type==="touchmove"){var A=a.touch;if(A===void 0)return;var v=A.pageX-(f+n.left),y=A.pageY-(m+n.top);v=v*(s/n.width),y=y*(u/n.height);var T={x:v,y};if(a.type==="touchstart")Browser.lastTouches[A.identifier]=T,Browser.touches[A.identifier]=T;else if(a.type==="touchend"||a.type==="touchmove"){var I=Browser.touches[A.identifier];I||(I=T),Browser.lastTouches[A.identifier]=I,Browser.touches[A.identifier]=T}return}var S=a.pageX-(f+n.left),E=a.pageY-(m+n.top);S=S*(s/n.width),E=E*(u/n.height),Browser.mouseMovementX=S-Browser.mouseX,Browser.mouseMovementY=E-Browser.mouseY,Browser.mouseX=S,Browser.mouseY=E}},xhrLoad:function(a,n,s){var u=new XMLHttpRequest;u.open("GET",a,!0),u.responseType="arraybuffer",u.onload=function(){u.status==200||u.status==0&&u.response?n(u.response):s()},u.onerror=s,u.send(null)},asyncLoad:function(a,n,s,u){Browser.xhrLoad(a,function(f){assert(f,'Loading data file "'+a+'" failed (no arrayBuffer).'),n(new Uint8Array(f)),u||removeRunDependency()},function(f){if(s)s();else throw'Loading data file "'+a+'" failed.'}),u||addRunDependency()},resizeListeners:[],updateResizeListeners:function(){var a=Module.canvas;Browser.resizeListeners.forEach(function(n){n(a.width,a.height)})},setCanvasSize:function(a,n,s){var u=Module.canvas;Browser.updateCanvasDimensions(u,a,n),s||Browser.updateResizeListeners()},windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function(){if(typeof SDL<"u"){var a=HEAPU32[SDL.screen+Runtime.QUANTUM_SIZE*0>>2];a=a|8388608,HEAP32[SDL.screen+Runtime.QUANTUM_SIZE*0>>2]=a}Browser.updateResizeListeners()},setWindowedCanvasSize:function(){if(typeof SDL<"u"){var a=HEAPU32[SDL.screen+Runtime.QUANTUM_SIZE*0>>2];a=a&-8388609,HEAP32[SDL.screen+Runtime.QUANTUM_SIZE*0>>2]=a}Browser.updateResizeListeners()},updateCanvasDimensions:function(a,n,s){n&&s?(a.widthNative=n,a.heightNative=s):(n=a.widthNative,s=a.heightNative);var u=n,f=s;if(Module.forcedAspectRatio&&Module.forcedAspectRatio>0&&(u/f>2];return n},getStr:function(){var a=Pointer_stringify(SYSCALLS.get());return a},get64:function(){var a=SYSCALLS.get(),n=SYSCALLS.get();return a>=0?assert(n===0):assert(n===-1),a},getZero:function(){assert(SYSCALLS.get()===0)}};function ___syscall54(a,n){SYSCALLS.varargs=n;try{return 0}catch(s){return(typeof FS>"u"||!(s instanceof FS.ErrnoError))&&abort(s),-s.errno}}Module._i64Add=_i64Add,Module._bitshift64Lshr=_bitshift64Lshr;function ___cxa_pure_virtual(){throw ABORT=!0,"Pure virtual function called!"}function _pthread_cleanup_push(a,n){__ATEXIT__.push(function(){Runtime.dynCall("vi",a,[n])}),_pthread_cleanup_push.level=__ATEXIT__.length}function _pthread_cond_broadcast(){return 0}function ___cxa_guard_acquire(a){return HEAP8[a>>0]?0:(HEAP8[a>>0]=1,1)}function _pthread_cleanup_pop(){assert(_pthread_cleanup_push.level==__ATEXIT__.length,"cannot pop if something else added meanwhile!"),__ATEXIT__.pop(),_pthread_cleanup_push.level=__ATEXIT__.length}function ___cxa_guard_release(){}function ___cxa_begin_catch(a){return __ZSt18uncaught_exceptionv.uncaught_exception--,EXCEPTIONS.caught.push(a),EXCEPTIONS.addRef(EXCEPTIONS.deAdjust(a)),a}function _llvm_eh_typeid_for(a){return a}function _emscripten_memcpy_big(a,n,s){return HEAPU8.set(HEAPU8.subarray(n,n+s),a),a}Module._memcpy=_memcpy;function ___syscall6(a,n){SYSCALLS.varargs=n;try{var s=SYSCALLS.getStreamFromFD();return FS.close(s),0}catch(u){return(typeof FS>"u"||!(u instanceof FS.ErrnoError))&&abort(u),-u.errno}}function _pthread_mutex_lock(){}function _sbrk(a){var n=_sbrk;n.called||(DYNAMICTOP=alignMemoryPage(DYNAMICTOP),n.called=!0,assert(Runtime.dynamicAlloc),n.alloc=Runtime.dynamicAlloc,Runtime.dynamicAlloc=function(){abort("cannot dynamically allocate, sbrk now has control")});var s=DYNAMICTOP;if(a!=0){var u=n.alloc(a);if(!u)return 4294967295}return s}Module._bitshift64Shl=_bitshift64Shl;function ___cxa_guard_abort(){}Module._memmove=_memmove;function _pthread_cond_wait(){return 0}function ___cxa_rethrow(){___cxa_end_catch.rethrown=!0;var a=EXCEPTIONS.caught.pop();throw EXCEPTIONS.last=a,a}function _pthread_mutex_unlock(){}function _time(a){var n=Date.now()/1e3|0;return a&&(HEAP32[a>>2]=n),n}function _pthread_self(){return 0}function ___syscall140(a,n){SYSCALLS.varargs=n;try{var s=SYSCALLS.getStreamFromFD(),u=SYSCALLS.get(),f=SYSCALLS.get(),m=SYSCALLS.get(),A=SYSCALLS.get(),v=f;return assert(u===0),FS.llseek(s,v,A),HEAP32[m>>2]=s.position,s.getdents&&v===0&&A===0&&(s.getdents=null),0}catch(y){return(typeof FS>"u"||!(y instanceof FS.ErrnoError))&&abort(y),-y.errno}}function ___syscall146(a,n){SYSCALLS.varargs=n;try{var s=SYSCALLS.get(),u=SYSCALLS.get(),f=SYSCALLS.get(),m=0;___syscall146.buffer||(___syscall146.buffer=[]);for(var A=___syscall146.buffer,v=0;v>2],T=HEAP32[u+(v*8+4)>>2],I=0;I"u"||!(E instanceof FS.ErrnoError))&&abort(E),-E.errno}}function ___syscall145(a,n){SYSCALLS.varargs=n;try{var s=SYSCALLS.getStreamFromFD(),u=SYSCALLS.get(),f=SYSCALLS.get();return SYSCALLS.doReadv(s,u,f)}catch(m){return(typeof FS>"u"||!(m instanceof FS.ErrnoError))&&abort(m),-m.errno}}var ___dso_handle=allocate(1,"i32*",ALLOC_STATIC);Module.requestFullScreen=function a(n,s,u){Browser.requestFullScreen(n,s,u)},Module.requestAnimationFrame=function a(n){Browser.requestAnimationFrame(n)},Module.setCanvasSize=function a(n,s,u){Browser.setCanvasSize(n,s,u)},Module.pauseMainLoop=function a(){Browser.mainLoop.pause()},Module.resumeMainLoop=function a(){Browser.mainLoop.resume()},Module.getUserMedia=function a(){Browser.getUserMedia()},Module.createContext=function a(n,s,u,f){return Browser.createContext(n,s,u,f)},STACK_BASE=STACKTOP=Runtime.alignMemory(STATICTOP),staticSealed=!0,STACK_MAX=STACK_BASE+TOTAL_STACK,DYNAMIC_BASE=DYNAMICTOP=Runtime.alignMemory(STACK_MAX),assert(DYNAMIC_BASE2147483648?!1:(S=new u(t),E=new f(t),e=new m(t),F=new A(t),M=new v(t),L=new y(t),V=new T(t),B=new I(t),s=t,!0)}function na(t){t=t|0;var r=0;return r=b,b=b+t|0,b=b+15&-16,r|0}function ra(){return b|0}function sa(t){t=t|0,b=t}function oa(t,r){t=t|0,r=r|0,b=t,W=r}function aa(t,r){t=t|0,r=r|0,g||(g=t,J=r)}function hA(t){t=t|0,S[q>>0]=S[t>>0],S[q+1>>0]=S[t+1>>0],S[q+2>>0]=S[t+2>>0],S[q+3>>0]=S[t+3>>0]}function dA(t){t=t|0,S[q>>0]=S[t>>0],S[q+1>>0]=S[t+1>>0],S[q+2>>0]=S[t+2>>0],S[q+3>>0]=S[t+3>>0],S[q+4>>0]=S[t+4>>0],S[q+5>>0]=S[t+5>>0],S[q+6>>0]=S[t+6>>0],S[q+7>>0]=S[t+7>>0]}function la(t){t=t|0,ye=t}function ua(){return ye|0}function ca(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0;if($=b,b=b+128|0,N=$+44|0,U=$+8|0,C=$+4|0,k=$,R=o+4|0,_=o+8|0,g=0,$e(35,e[o>>2]|0,e[R>>2]|0,e[_>>2]|0,l|0),D=g,g=0,D&1)Q=5;else{d=N,h=d+84|0;do e[d>>2]=e[l>>2],d=d+4|0,l=l+4|0;while((d|0)<(h|0));if(l=N+12|0,!(e[l>>2]|0)&&(w=ee(((e[N+8>>2]|0)+7|0)/8|0,e[N>>2]|0)|0,e[l>>2]=w,(e[N+24>>2]|0)!=0)&&(D=ee(e[N+16>>2]|0,w)|0,e[l>>2]=D),g=0,ue(176,U|0),D=g,g=0,D&1)Q=5;else{l=N+56|0;do if(e[l>>2]|0)if(g=0,l=ge(66,l|0)|0,D=g,g=0,D&1)Q=15;else{if(e[C>>2]=l,h=U+28|0,d=e[h>>2]|0,d>>>0<(e[U+32>>2]|0)>>>0){e[d>>2]=l,e[h>>2]=d+4,e[C>>2]=0,Q=19;break}if(g=0,Ae(57,U+24|0,C|0),D=g,g=0,D&1){if(h=j(824,0)|0,l=ye,d=e[C>>2]|0,e[C>>2]=0,!d)break;Mt[e[(e[d>>2]|0)+4>>2]&255](d);break}else{if(l=e[C>>2]|0,e[C>>2]=0,!l){Q=19;break}Mt[e[(e[l>>2]|0)+4>>2]&255](l),Q=19;break}}else Q=19;while(!1);e:do if((Q|0)==19)if(d=N+4|0,w=N+8|0,C=N+16|0,g=0,l=Pe(14,e[N>>2]|0,e[d>>2]|0,e[w>>2]|0,e[C>>2]|0)|0,D=g,g=0,D&1)Q=15;else{e[k>>2]=l,D=U+28|0,h=e[D>>2]|0;do if(h>>>0>=(e[U+32>>2]|0)>>>0)if(g=0,Ae(57,U+24|0,k|0),h=g,g=0,h&1){if(h=j(824,0)|0,l=ye,d=e[k>>2]|0,e[k>>2]=0,!d)break e;Mt[e[(e[d>>2]|0)+4>>2]&255](d);break e}else{if(l=e[k>>2]|0,e[k>>2]=0,!l)break;Mt[e[(e[l>>2]|0)+4>>2]&255](l);break}else e[h>>2]=l,e[D>>2]=h+4,e[k>>2]=0;while(!1);if(l=e[N+28>>2]|0,l|0&&(g=0,Ae(58,U|0,l|0),Q=g,g=0,Q&1)){Q=15;break}t:do if(e[N+24>>2]|0){if(g=0,xe(4,U|0,o|0,N|0),Q=g,g=0,Q&1){Q=15;break e}}else if(l=ee(e[d>>2]|0,e[N>>2]|0)|0,l=ee(l,((e[w>>2]|0)+7|0)/8|0)|0,(e[C>>2]|0)>0){for(d=0;g=0,xe(4,U|0,o|0,N|0),Q=g,g=0,!(Q&1);)if(h=e[R>>2]|0,h&&(e[R>>2]=h+l,e[_>>2]=(e[_>>2]|0)-l),d=d+1|0,(d|0)>=(e[C>>2]|0))break t;h=j(824,0)|0,l=ye,Q=16;break e}while(!1);if(g=0,be(33,U|0,t|0)|0,Q=g,g=0,Q&1)Q=15;else{if(e[r>>2]=e[U+16>>2],c&&(S[c>>0]=0),d=U+24|0,l=e[d>>2]|0,l){if(h=e[D>>2]|0,(h|0)!=(l|0)){do c=h+-4|0,e[D>>2]=c,h=e[c>>2]|0,e[c>>2]=0,h&&Mt[e[(e[h>>2]|0)+4>>2]&255](h),h=e[D>>2]|0;while((h|0)!=(l|0));l=e[d>>2]|0}he(l)}return c=0,b=$,c|0}}while(!1);if((Q|0)==15&&(h=j(824,0)|0,l=ye,Q=16),D=U+24|0,d=e[D>>2]|0,d){if(C=U+28|0,w=e[C>>2]|0,(w|0)!=(d|0)){do U=w+-4|0,e[C>>2]=U,w=e[U>>2]|0,e[U>>2]=0,w&&Mt[e[(e[w>>2]|0)+4>>2]&255](w),w=e[C>>2]|0;while((w|0)!=(d|0));d=e[D>>2]|0}he(d)}}}if((Q|0)==5&&(h=j(824,0)|0,l=ye),U=(l|0)==($n(824)|0),w=K0(h|0)|0,l=(c|0)==0,!U)return l||(S[c>>0]=0),ei(),c=14,b=$,c|0;d=w+12|0;do if(l)Q=60;else if(l=e[d>>2]|0,g=0,h=Ce(1)|0,U=g,g=0,!(U&1))if((l|0)==(h|0)){Rr(c,Dt[e[(e[w>>2]|0)+8>>2]&127](w)|0)|0,Q=60;break}else{S[c>>0]=0,Q=60;break}while(!1);return(Q|0)==60&&(K=e[d>>2]|0,g=0,G=Ce(1)|0,c=g,g=0,!(c&1))?(c=(K|0)==(G|0)?e[w+8>>2]|0:13,ei(),b=$,c|0):(l=j()|0,g=0,Nt(3),$=g,g=0,$&1?($=j(0)|0,$t($)):le(l|0),0)}function fa(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0;switch(D=b,b=b+112|0,h=D+96|0,C=D+84|0,k=D+72|0,N=D+60|0,R=D+48|0,_=D+36|0,U=D+24|0,Q=D+12|0,K=D,w=(r|0)==0,(t|0)==0&w&&(c=Ct(16)|0,g=0,xe(5,h|0,48504,52),K=g,g=0,K&1?r=j()|0:(g=0,r=Ce(1)|0,K=g,g=0,!(K&1)&&(g=0,$e(36,c|0,1,r|0,h|0),K=g,g=0,!(K&1))?(g=0,xe(6,c|0,824,96),g=0,t=0):t=1,r=j()|0,de(h),t||(K=r,le(K|0))),Tt(c|0),K=r,le(K|0)),d=e[l>>2]|0,(d+-1|0)>>>0>65534&&(c=Ct(16)|0,g=0,xe(5,C|0,48557,41),K=g,g=0,K&1?r=j()|0:(g=0,r=Ce(1)|0,K=g,g=0,!(K&1)&&(g=0,$e(36,c|0,1,r|0,C|0),K=g,g=0,!(K&1))?(g=0,xe(6,c|0,824,96),g=0,t=0):t=1,r=j()|0,de(C),t||(K=r,le(K|0))),Tt(c|0),K=r,le(K|0)),h=e[l+4>>2]|0,(h+-1|0)>>>0>65534&&(c=Ct(16)|0,g=0,xe(5,k|0,48599,42),K=g,g=0,K&1?r=j()|0:(g=0,r=Ce(1)|0,K=g,g=0,!(K&1)&&(g=0,$e(36,c|0,1,r|0,k|0),K=g,g=0,!(K&1))?(g=0,xe(6,c|0,824,96),g=0,t=0):t=1,r=j()|0,de(k),t||(K=r,le(K|0))),Tt(c|0),K=r,le(K|0)),c=e[l+8>>2]|0,(c+-2|0)>>>0>14&&(c=Ct(16)|0,g=0,xe(5,N|0,48642,46),K=g,g=0,K&1?r=j()|0:(g=0,r=Ce(1)|0,K=g,g=0,!(K&1)&&(g=0,$e(36,c|0,1,r|0,N|0),K=g,g=0,!(K&1))?(g=0,xe(6,c|0,824,96),g=0,t=0):t=1,r=j()|0,de(N),t||(K=r,le(K|0))),Tt(c|0),K=r,le(K|0)),t=e[l+24>>2]|0,t>>>0>=3&&(c=Ct(16)|0,g=0,xe(5,R|0,48689,65),K=g,g=0,K&1?r=j()|0:(g=0,r=Ce(1)|0,K=g,g=0,!(K&1)&&(g=0,$e(36,c|0,1,r|0,R|0),K=g,g=0,!(K&1))?(g=0,xe(6,c|0,824,96),g=0,t=0):t=1,r=j()|0,de(R),t||(K=r,le(K|0))),Tt(c|0),K=r,le(K|0)),r=e[l+16>>2]|0,(r+-1|0)>>>0>254&&(c=Ct(16)|0,g=0,xe(5,_|0,48755,44),K=g,g=0,K&1?r=j()|0:(g=0,r=Ce(1)|0,K=g,g=0,!(K&1)&&(g=0,$e(36,c|0,1,r|0,_|0),K=g,g=0,!(K&1))?(g=0,xe(6,c|0,824,96),g=0,t=0):t=1,r=j()|0,de(_),t||(K=r,le(K|0))),Tt(c|0),K=r,le(K|0)),!w&&(_=ee(h,d)|0,(ee(ee(_,(c|0)>8?2:1)|0,r)|0)>>>0>o>>>0)&&(c=Ct(16)|0,g=0,xe(5,U|0,48800,58),K=g,g=0,K&1?r=j()|0:(g=0,r=Ce(1)|0,K=g,g=0,!(K&1)&&(g=0,$e(36,c|0,1,r|0,U|0),K=g,g=0,!(K&1))?(g=0,xe(6,c|0,824,96),g=0,t=0):t=1,r=j()|0,de(U),t||(K=r,le(K|0))),Tt(c|0),K=r,le(K|0)),r|0){case 4:{if((t|0)!=2){b=D;return}c=Ct(16)|0,g=0,xe(5,Q|0,48859,73),K=g,g=0,K&1?r=j()|0:(g=0,r=Ce(1)|0,K=g,g=0,!(K&1)&&(g=0,$e(36,c|0,1,r|0,Q|0),K=g,g=0,!(K&1))?(g=0,xe(6,c|0,824,96),g=0,t=0):t=1,r=j()|0,de(Q),t||(K=r,le(K|0))),Tt(c|0),K=r,le(K|0)}case 3:{b=D;return}default:{if(!t){b=D;return}c=Ct(16)|0,g=0,xe(5,K|0,48933,73),Q=g,g=0,Q&1?r=j()|0:(g=0,r=Ce(1)|0,Q=g,g=0,!(Q&1)&&(g=0,$e(36,c|0,1,r|0,K|0),Q=g,g=0,!(Q&1))?(g=0,xe(6,c|0,824,96),g=0,t=0):t=1,r=j()|0,de(K),t||(K=r,le(K|0))),Tt(c|0),K=r,le(K|0)}}}function $t(t){t=t|0,K0(t|0)|0,P6()}function ha(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=b,b=b+128|0,h=k+116|0,d=k,g=0,e[h>>2]=e[r>>2],e[h+4>>2]=e[r+4>>2],e[h+8>>2]=e[r+8>>2],Ae(59,d|0,h|0),c=g,g=0,!(c&1)){if(o){c=d+16|0,r=c+84|0;do e[c>>2]=e[o>>2],c=c+4|0,o=o+4|0;while((c|0)<(r|0))}if(g=0,e[h>>2]=e[t>>2],e[h+4>>2]=e[t+4>>2],e[h+8>>2]=e[t+8>>2],Ae(60,d|0,h|0),d=g,g=0,!(d&1))return l&&(S[l>>0]=0),D=0,b=k,D|0}if(t=j(824,0)|0,d=ye,d=(d|0)==($n(824)|0),t=K0(t|0)|0,r=(l|0)==0,!d)return r||(S[l>>0]=0),ei(),D=14,b=k,D|0;c=t+12|0;do if(r)D=10;else if(r=e[c>>2]|0,g=0,o=Ce(1)|0,d=g,g=0,!(d&1))if((r|0)==(o|0)){Rr(l,Dt[e[(e[t>>2]|0)+8>>2]&127](t)|0)|0,D=10;break}else{S[l>>0]=0,D=10;break}while(!1);return(D|0)==10&&(w=e[c>>2]|0,g=0,C=Ce(1)|0,D=g,g=0,!(D&1))?(D=(w|0)==(C|0)?e[t+8>>2]|0:13,ei(),b=k,D|0):(r=j()|0,g=0,Nt(3),k=g,g=0,k&1?(k=j(0)|0,$t(k)):le(r|0),0)}function da(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(C=b,b=b+128|0,c=C+116|0,l=C,g=0,e[c>>2]=e[t>>2],e[c+4>>2]=e[t+4>>2],e[c+8>>2]=e[t+8>>2],Ae(59,l|0,c|0),c=g,g=0,!(c&1)&&(g=0,ue(177,l|0),c=g,g=0,!(c&1))&&(g=0,Ae(61,l|0,1),c=g,g=0,!(c&1))){t=l+16|0,l=r+84|0;do e[r>>2]=e[t>>2],r=r+4|0,t=t+4|0;while((r|0)<(l|0));return o&&(S[o>>0]=0),o=0,b=C,o|0}if(c=j(824,0)|0,r=ye,r=(r|0)==($n(824)|0),c=K0(c|0)|0,t=(o|0)==0,!r)return t||(S[o>>0]=0),ei(),o=14,b=C,o|0;r=c+12|0;do if(t)w=13;else if(t=e[r>>2]|0,g=0,l=Ce(1)|0,D=g,g=0,!(D&1))if((t|0)==(l|0)){Rr(o,Dt[e[(e[c>>2]|0)+8>>2]&127](c)|0)|0,w=13;break}else{S[o>>0]=0,w=13;break}while(!1);return(w|0)==13&&(h=e[r>>2]|0,g=0,d=Ce(1)|0,D=g,g=0,!(D&1))?(D=(h|0)==(d|0)?e[c+8>>2]|0:13,ei(),b=C,D|0):(t=j()|0,g=0,Nt(3),D=g,g=0,D&1?(D=j(0)|0,$t(D)):le(t|0),0)}function pa(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0,D=0,k=0,N=0;return N=b,b=b+48|0,C=N+36|0,w=N+24|0,D=N+12|0,k=N,(t|0)!=0&(o|0)!=0&(l|0)!=0&(h|0)!=0?(e[D>>2]=0,e[D+4>>2]=t,e[D+8>>2]=r,e[k>>2]=0,e[k+4>>2]=l,e[k+8>>2]=c,e[w>>2]=e[D>>2],e[w+4>>2]=e[D+4>>2],e[w+8>>2]=e[D+8>>2],e[C>>2]=e[k>>2],e[C+4>>2]=e[k+4>>2],e[C+8>>2]=e[k+8>>2],c=ca(w,o,C,h,d)|0,b=N,c|0):(c=1,b=N,c|0)}function ma(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0;return c=b,b=b+32|0,h=c+12|0,d=c,w=d,e[w>>2]=0,e[w+4>>2]=0,e[d+4>>2]=t,e[d+8>>2]=r,e[h>>2]=e[d>>2],e[h+4>>2]=e[d+4>>2],e[h+8>>2]=e[d+8>>2],o=da(h,o,l)|0,b=c,o|0}function ga(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+48|0,w=d+36|0,C=d+24|0,k=d+12|0,D=d,e[k>>2]=0,e[k+4>>2]=t,e[k+8>>2]=r,e[D>>2]=0,e[D+4>>2]=o,e[D+8>>2]=l,e[C>>2]=e[k>>2],e[C+4>>2]=e[k+4>>2],e[C+8>>2]=e[k+8>>2],e[w>>2]=e[D>>2],e[w+4>>2]=e[D+4>>2],e[w+8>>2]=e[D+8>>2],l=ha(C,w,c,h)|0,b=d,l|0}function Sa(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(D=t+4|0,o=e[t>>2]|0,c=((e[D>>2]|0)-o>>2)+1|0,c>>>0>1073741823&&(pi(t),o=e[t>>2]|0),k=t+8|0,l=(e[k>>2]|0)-o|0,l>>2>>>0<536870911?(l=l>>1,l=l>>>0>>0?c:l,o=(e[D>>2]|0)-o>>2,l?w=6:(h=0,d=0)):(l=1073741823,o=(e[D>>2]|0)-o>>2,w=6),(w|0)==6&&(h=l,d=Xe(l<<2)|0),c=d+(o<<2)|0,l=c,C=d+(h<<2)|0,w=e[r>>2]|0,e[r>>2]=0,e[c>>2]=w,w=d+(o+1<<2)|0,d=e[t>>2]|0,o=e[D>>2]|0,(o|0)==(d|0))c=t,h=D;else{do o=o+-4|0,r=e[o>>2]|0,e[o>>2]=0,e[c+-4>>2]=r,c=l+-4|0,l=c;while((o|0)!=(d|0));o=l,c=t,h=D,l=o,d=e[t>>2]|0,o=e[D>>2]|0}if(e[c>>2]=l,e[h>>2]=w,e[k>>2]=C,c=d,(o|0)!=(c|0))do o=o+-4|0,l=e[o>>2]|0,e[o>>2]=0,l&&Mt[e[(e[l>>2]|0)+4>>2]&255](l);while((o|0)!=(c|0));d&&he(d)}function Aa(){return S[8]|0||!(kt(8)|0)||(Ft(72,35648,H|0)|0,bt(8)),35648}function un(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;k=b,b=b+32|0,C=k,m0(C,(1<>2]|0,D=h+1|0,o=D<<1,e[t>>2]=0,d=t+4|0,e[d>>2]=0,e[t+8>>2]=0;e:do if(D){if((h|0)<-1&&(g=0,ue(178,t|0),w=g,g=0,w&1)||(l=4),(l|0)==4&&(g=0,c=ge(67,o|0)|0,w=g,g=0,!(w&1))){for(e[d>>2]=c,e[t>>2]=c,e[t+8>>2]=c+o,r=c;;)if(S[r>>0]=0,r=(e[d>>2]|0)+1|0,e[d>>2]=r,o=o+-1|0,!o)break e}o=j()|0,r=e[t>>2]|0,r||le(o|0),(e[d>>2]|0)!=(r|0)&&(e[d>>2]=r),he(r),le(o|0)}while(!1);if(r=~h,(h|0)<(r|0)){b=k;return}d=C+12|0,w=C+8|0,h=C+4|0,c=r;do r=e[d>>2]|0,(c|0)>(0-r|0)?(o=e[w>>2]|0,(c|0)>(0-o|0)?(l=e[h>>2]|0,(c|0)>(0-l|0)?(c|0)>=0?(c|0)>0?(l|0)<=(c|0)?(o|0)>(c|0)?r=2:r=(r|0)>(c|0)?3:4:r=1:r=0:r=-1:r=-2):r=-3):r=-4,S[(e[t>>2]|0)+(c+D)>>0]=r,c=c+1|0;while((c|0)<(D|0));b=k}function va(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;switch(R=e[o+16>>2]|0,R|0){case 64:case 0:{g=0,t=be(34,t|0,r|0)|0,r=g,g=0,r&1?_=16:l=t;break}default:{for(c=(1<>2])+-1|0,N=e[r+20>>2]|0,k=N<<1,k=((k+c|0)/(k|1|0)|0)+1|0,t=0;(1<>2]|0,g=0,l=ge(67,4624)|0,D=g,g=0,D&1)_=16;else{h=((d|0)<8?8:d)+d<<1,w=l+4|0,C=r,D=w+84|0;do e[w>>2]=e[C>>2],w=w+4|0,C=C+4|0;while((w|0)<(D|0));w=l+88|0,D=w+40|0;do e[w>>2]=0,w=w+4|0;while((w|0)<(D|0));e[l>>2]=35660,e[l+128>>2]=c,e[l+132>>2]=k,e[l+136>>2]=N,e[l+140>>2]=t,e[l+144>>2]=d,e[l+148>>2]=h,e[l+152>>2]=R,t=l+156|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[l+172>>2]=e[r>>2],e[l+176>>2]=0,e[l+180>>2]=0,e[l+184>>2]=0,t=l+4568|0,c=l+188|0;do e[c>>2]=0,e[c+4>>2]=0,E[c+8>>1]=0,E[c+10>>1]=1,c=c+12|0;while((c|0)!=(t|0));e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=l+4580|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=l+4592|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[l+28>>2]|0||(e[l+20>>2]=1)}}}return(_|0)==16&&(_=j()|0,le(_|0)),!l||(g=0,Ae(e[(e[l>>2]|0)+12>>2]|0,l|0,o|0),_=g,g=0,!(_&1))?l|0:(t=j()|0,l||(_=t,le(_|0)),Mt[e[(e[l>>2]|0)+4>>2]&255](l),_=t,le(_|0),0)}function xa(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(o=(e[r+24>>2]|0)==2,o&&(e[r+16>>2]|0)!=3)return r=0,r|0;k=e[r+20>>2]|0,t=e[r+8>>2]|0;e:do if(!k){if(o){if((t|0)!=8)break;l=Xe(4600)|0,d=l+4|0,w=r,C=d+84|0;do e[d>>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));d=l+88|0,C=d+40|0;do e[d>>2]=0,d=d+4|0;while((d|0)<(C|0));e[l>>2]=35688,t=l+132|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[l+148>>2]=e[r>>2],e[l+152>>2]=0,e[l+156>>2]=0,e[l+160>>2]=0,t=l+4544|0,o=l+164|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=l+4556|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=l+4568|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[l+28>>2]|0||(e[l+20>>2]=1),r=l,r|0}switch(t|0){case 8:{l=Xe(4600)|0,d=l+4|0,w=r,C=d+84|0;do e[d>>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));d=l+88|0,C=d+40|0;do e[d>>2]=0,d=d+4|0;while((d|0)<(C|0));e[l>>2]=35716,t=l+132|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[l+148>>2]=e[r>>2],e[l+152>>2]=0,e[l+156>>2]=0,e[l+160>>2]=0,t=l+4544|0,o=l+164|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=l+4556|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=l+4568|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[l+28>>2]|0||(e[l+20>>2]=1),r=l,r|0}case 12:{l=Xe(4600)|0,d=l+4|0,w=r,C=d+84|0;do e[d>>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));d=l+88|0,C=d+40|0;do e[d>>2]=0,d=d+4|0;while((d|0)<(C|0));e[l>>2]=35744,t=l+132|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[l+148>>2]=e[r>>2],e[l+152>>2]=0,e[l+156>>2]=0,e[l+160>>2]=0,t=l+4544|0,o=l+164|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=l+4556|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=l+4568|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[l+28>>2]|0||(e[l+20>>2]=1),r=l,r|0}case 16:{l=Xe(4600)|0,d=l+4|0,w=r,C=d+84|0;do e[d>>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));d=l+88|0,C=d+40|0;do e[d>>2]=0,d=d+4|0;while((d|0)<(C|0));e[l>>2]=35772,t=l+132|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[l+148>>2]=e[r>>2],e[l+152>>2]=0,e[l+156>>2]=0,e[l+160>>2]=0,t=l+4544|0,o=l+164|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=l+4556|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=l+4568|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[l+28>>2]|0||(e[l+20>>2]=1),r=l,r|0}default:break e}}while(!1);if(D=(1<>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));d=c+88|0,C=d+40|0;do e[d>>2]=0,d=d+4|0;while((d|0)<(C|0));e[c>>2]=35800,e[c+128>>2]=D,e[c+132>>2]=h,e[c+136>>2]=k,e[c+140>>2]=t,e[c+144>>2]=o,e[c+148>>2]=l,e[c+152>>2]=64,t=c+156|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[c+172>>2]=e[r>>2],e[c+176>>2]=0,e[c+180>>2]=0,e[c+184>>2]=0,t=c+4568|0,o=c+188|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=c+4580|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=c+4592|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[c+28>>2]|0||(e[c+20>>2]=1),r=c,r|0}else{for(t=0;(1<>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));d=c+88|0,C=d+40|0;do e[d>>2]=0,d=d+4|0;while((d|0)<(C|0));e[c>>2]=35660,e[c+128>>2]=D,e[c+132>>2]=h,e[c+136>>2]=k,e[c+140>>2]=t,e[c+144>>2]=o,e[c+148>>2]=l,e[c+152>>2]=64,t=c+156|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[c+172>>2]=e[r>>2],e[c+176>>2]=0,e[c+180>>2]=0,e[c+184>>2]=0,t=c+4568|0,o=c+188|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=c+4580|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=c+4592|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[c+28>>2]|0||(e[c+20>>2]=1),r=c,r|0}if((t|0)>=17)return r=0,r|0;if(h=k<<1,h=((h+D|0)/(h|1|0)|0)+1|0,o){for(t=0;(1<>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));d=c+88|0,C=d+40|0;do e[d>>2]=0,d=d+4|0;while((d|0)<(C|0));e[c>>2]=35828,e[c+128>>2]=D,e[c+132>>2]=h,e[c+136>>2]=k,e[c+140>>2]=t,e[c+144>>2]=o,e[c+148>>2]=l,e[c+152>>2]=64,t=c+156|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[c+172>>2]=e[r>>2],e[c+176>>2]=0,e[c+180>>2]=0,e[c+184>>2]=0,t=c+4568|0,o=c+188|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=c+4580|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=c+4592|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[c+28>>2]|0||(e[c+20>>2]=1),r=c,r|0}else{for(t=0;(1<>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));d=c+88|0,C=d+40|0;do e[d>>2]=0,d=d+4|0;while((d|0)<(C|0));e[c>>2]=35856,e[c+128>>2]=D,e[c+132>>2]=h,e[c+136>>2]=k,e[c+140>>2]=t,e[c+144>>2]=o,e[c+148>>2]=l,e[c+152>>2]=64,t=c+156|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[c+172>>2]=e[r>>2],e[c+176>>2]=0,e[c+180>>2]=0,e[c+184>>2]=0,t=c+4568|0,o=c+188|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=c+4580|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=c+4592|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[c+28>>2]|0||(e[c+20>>2]=1),r=c,r|0}return 0}function wa(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;switch(R=e[o+16>>2]|0,R|0){case 64:case 0:{g=0,t=be(35,t|0,r|0)|0,r=g,g=0,r&1?_=16:l=t;break}default:{for(c=(1<>2])+-1|0,N=e[r+20>>2]|0,k=N<<1,k=((k+c|0)/(k|1|0)|0)+1|0,t=0;(1<>2]|0,g=0,l=ge(67,4632)|0,D=g,g=0,D&1)_=16;else{h=((d|0)<8?8:d)+d<<1,e[l+4>>2]=0,w=l+8|0,C=r,D=w+84|0;do e[w>>2]=e[C>>2],w=w+4|0,C=C+4|0;while((w|0)<(D|0));e[l+92>>2]=0,e[l+96>>2]=0,e[l+100>>2]=32,e[l+104>>2]=0,e[l+108>>2]=0,S[l+112>>0]=0,D=l+116|0,e[D>>2]=0,e[D+4>>2]=0,e[D+8>>2]=0,e[D+12>>2]=0,e[D+16>>2]=0,e[l>>2]=35884,e[l+136>>2]=c,e[l+140>>2]=k,e[l+144>>2]=N,e[l+148>>2]=t,e[l+152>>2]=d,e[l+156>>2]=h,e[l+160>>2]=R,t=l+164|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[l+180>>2]=e[r>>2],e[l+184>>2]=0,e[l+188>>2]=0,e[l+192>>2]=0,t=l+4576|0,c=l+196|0;do e[c>>2]=0,e[c+4>>2]=0,E[c+8>>1]=0,E[c+10>>1]=1,c=c+12|0;while((c|0)!=(t|0));e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=l+4588|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=l+4600|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[l+32>>2]|0||(e[l+24>>2]=1)}}}return(_|0)==16&&(_=j()|0,le(_|0)),!l||(g=0,Ae(e[(e[l>>2]|0)+8>>2]|0,l|0,o|0),_=g,g=0,!(_&1))?l|0:(t=j()|0,l||(_=t,le(_|0)),Mt[e[(e[l>>2]|0)+4>>2]&255](l),_=t,le(_|0),0)}function ya(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(o=(e[r+24>>2]|0)==2,o&&(e[r+16>>2]|0)!=3)return r=0,r|0;k=e[r+20>>2]|0,t=e[r+8>>2]|0;e:do if(!k){if(o){if((t|0)!=8)break;l=Xe(4608)|0,e[l+4>>2]=0,d=l+8|0,w=r,C=d+84|0;do e[d>>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));e[l+92>>2]=0,e[l+96>>2]=0,e[l+100>>2]=32,e[l+104>>2]=0,e[l+108>>2]=0,S[l+112>>0]=0,t=l+116|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[t+16>>2]=0,e[l>>2]=35912,t=l+140|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[l+156>>2]=e[r>>2],e[l+160>>2]=0,e[l+164>>2]=0,e[l+168>>2]=0,t=l+4552|0,o=l+172|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=l+4564|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=l+4576|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[l+32>>2]|0||(e[l+24>>2]=1),r=l,r|0}switch(t|0){case 8:{l=Xe(4608)|0,e[l+4>>2]=0,d=l+8|0,w=r,C=d+84|0;do e[d>>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));e[l+92>>2]=0,e[l+96>>2]=0,e[l+100>>2]=32,e[l+104>>2]=0,e[l+108>>2]=0,S[l+112>>0]=0,t=l+116|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[t+16>>2]=0,e[l>>2]=35940,t=l+140|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[l+156>>2]=e[r>>2],e[l+160>>2]=0,e[l+164>>2]=0,e[l+168>>2]=0,t=l+4552|0,o=l+172|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=l+4564|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=l+4576|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[l+32>>2]|0||(e[l+24>>2]=1),r=l,r|0}case 12:{l=Xe(4608)|0,e[l+4>>2]=0,d=l+8|0,w=r,C=d+84|0;do e[d>>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));e[l+92>>2]=0,e[l+96>>2]=0,e[l+100>>2]=32,e[l+104>>2]=0,e[l+108>>2]=0,S[l+112>>0]=0,t=l+116|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[t+16>>2]=0,e[l>>2]=35968,t=l+140|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[l+156>>2]=e[r>>2],e[l+160>>2]=0,e[l+164>>2]=0,e[l+168>>2]=0,t=l+4552|0,o=l+172|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=l+4564|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=l+4576|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[l+32>>2]|0||(e[l+24>>2]=1),r=l,r|0}case 16:{l=Xe(4608)|0,e[l+4>>2]=0,d=l+8|0,w=r,C=d+84|0;do e[d>>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));e[l+92>>2]=0,e[l+96>>2]=0,e[l+100>>2]=32,e[l+104>>2]=0,e[l+108>>2]=0,S[l+112>>0]=0,t=l+116|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[t+16>>2]=0,e[l>>2]=35996,t=l+140|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[l+156>>2]=e[r>>2],e[l+160>>2]=0,e[l+164>>2]=0,e[l+168>>2]=0,t=l+4552|0,o=l+172|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=l+4564|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=l+4576|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[l+32>>2]|0||(e[l+24>>2]=1),r=l,r|0}default:break e}}while(!1);if(D=(1<>2]=0,d=c+8|0,w=r,C=d+84|0;do e[d>>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));e[c+92>>2]=0,e[c+96>>2]=0,e[c+100>>2]=32,e[c+104>>2]=0,e[c+108>>2]=0,S[c+112>>0]=0,C=c+116|0,e[C>>2]=0,e[C+4>>2]=0,e[C+8>>2]=0,e[C+12>>2]=0,e[C+16>>2]=0,e[c>>2]=36024,e[c+136>>2]=D,e[c+140>>2]=h,e[c+144>>2]=k,e[c+148>>2]=t,e[c+152>>2]=o,e[c+156>>2]=l,e[c+160>>2]=64,t=c+164|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[c+180>>2]=e[r>>2],e[c+184>>2]=0,e[c+188>>2]=0,e[c+192>>2]=0,t=c+4576|0,o=c+196|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=c+4588|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=c+4600|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[c+32>>2]|0||(e[c+24>>2]=1),r=c,r|0}else{for(t=0;(1<>2]=0,d=c+8|0,w=r,C=d+84|0;do e[d>>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));e[c+92>>2]=0,e[c+96>>2]=0,e[c+100>>2]=32,e[c+104>>2]=0,e[c+108>>2]=0,S[c+112>>0]=0,C=c+116|0,e[C>>2]=0,e[C+4>>2]=0,e[C+8>>2]=0,e[C+12>>2]=0,e[C+16>>2]=0,e[c>>2]=35884,e[c+136>>2]=D,e[c+140>>2]=h,e[c+144>>2]=k,e[c+148>>2]=t,e[c+152>>2]=o,e[c+156>>2]=l,e[c+160>>2]=64,t=c+164|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[c+180>>2]=e[r>>2],e[c+184>>2]=0,e[c+188>>2]=0,e[c+192>>2]=0,t=c+4576|0,o=c+196|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=c+4588|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=c+4600|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[c+32>>2]|0||(e[c+24>>2]=1),r=c,r|0}if((t|0)>=17)return r=0,r|0;if(h=k<<1,h=((h+D|0)/(h|1|0)|0)+1|0,o){for(t=0;(1<>2]=0,d=c+8|0,w=r,C=d+84|0;do e[d>>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));e[c+92>>2]=0,e[c+96>>2]=0,e[c+100>>2]=32,e[c+104>>2]=0,e[c+108>>2]=0,S[c+112>>0]=0,C=c+116|0,e[C>>2]=0,e[C+4>>2]=0,e[C+8>>2]=0,e[C+12>>2]=0,e[C+16>>2]=0,e[c>>2]=36052,e[c+136>>2]=D,e[c+140>>2]=h,e[c+144>>2]=k,e[c+148>>2]=t,e[c+152>>2]=o,e[c+156>>2]=l,e[c+160>>2]=64,t=c+164|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[c+180>>2]=e[r>>2],e[c+184>>2]=0,e[c+188>>2]=0,e[c+192>>2]=0,t=c+4576|0,o=c+196|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=c+4588|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=c+4600|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[c+32>>2]|0||(e[c+24>>2]=1),r=c,r|0}else{for(t=0;(1<>2]=0,d=c+8|0,w=r,C=d+84|0;do e[d>>2]=e[w>>2],d=d+4|0,w=w+4|0;while((d|0)<(C|0));e[c+92>>2]=0,e[c+96>>2]=0,e[c+100>>2]=32,e[c+104>>2]=0,e[c+108>>2]=0,S[c+112>>0]=0,C=c+116|0,e[C>>2]=0,e[C+4>>2]=0,e[C+8>>2]=0,e[C+12>>2]=0,e[C+16>>2]=0,e[c>>2]=36080,e[c+136>>2]=D,e[c+140>>2]=h,e[c+144>>2]=k,e[c+148>>2]=t,e[c+152>>2]=o,e[c+156>>2]=l,e[c+160>>2]=64,t=c+164|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[c+180>>2]=e[r>>2],e[c+184>>2]=0,e[c+188>>2]=0,e[c+192>>2]=0,t=c+4576|0,o=c+196|0;do e[o>>2]=0,e[o+4>>2]=0,E[o+8>>1]=0,E[o+10>>1]=1,o=o+12|0;while((o|0)!=(t|0));return e[t>>2]=0,e[t+4>>2]=0,E[t+8>>1]=0,S[t+10>>0]=0,r=c+4588|0,e[r>>2]=0,e[r+4>>2]=0,E[r+8>>1]=0,S[r+10>>0]=0,r=c+4600|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[r+16>>2]=0,e[r+20>>2]=0,e[r+24>>2]=0,S[r+28>>0]=0,e[c+32>>2]|0||(e[c+24>>2]=1),r=c,r|0}return 0}function Ca(){var t=0,r=0,o=0,l=0,c=0,h=0,d=0;t=2832;do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=4880);Jt(2832,0,2048)|0,t=0;do d=2832+(t+128<<3)|0,e[d>>2]=0,e[d+4>>2]=1,t=t+1|0;while((t|0)!=128);t=3088,e[t>>2]=1,e[t+4>>2]=3,t=3096,e[t>>2]=1,e[t+4>>2]=3,t=3104,e[t>>2]=1,e[t+4>>2]=3,t=3112,e[t>>2]=1,e[t+4>>2]=3,t=3120,e[t>>2]=1,e[t+4>>2]=3,t=3128,e[t>>2]=1,e[t+4>>2]=3,t=3136,e[t>>2]=1,e[t+4>>2]=3,t=3144,e[t>>2]=1,e[t+4>>2]=3,t=3152,e[t>>2]=1,e[t+4>>2]=3,t=3160,e[t>>2]=1,e[t+4>>2]=3,t=3168,e[t>>2]=1,e[t+4>>2]=3,t=3176,e[t>>2]=1,e[t+4>>2]=3,t=3184,e[t>>2]=1,e[t+4>>2]=3,t=3192,e[t>>2]=1,e[t+4>>2]=3,t=3200,e[t>>2]=1,e[t+4>>2]=3,t=3208,e[t>>2]=1,e[t+4>>2]=3,t=3216,e[t>>2]=1,e[t+4>>2]=3,t=3224,e[t>>2]=1,e[t+4>>2]=3,t=3232,e[t>>2]=1,e[t+4>>2]=3,t=3240,e[t>>2]=1,e[t+4>>2]=3,t=3248,e[t>>2]=1,e[t+4>>2]=3,t=3256,e[t>>2]=1,e[t+4>>2]=3,t=3264,e[t>>2]=1,e[t+4>>2]=3,t=3272,e[t>>2]=1,e[t+4>>2]=3,t=3280,e[t>>2]=1,e[t+4>>2]=3,t=3288,e[t>>2]=1,e[t+4>>2]=3,t=3296,e[t>>2]=1,e[t+4>>2]=3,t=3304,e[t>>2]=1,e[t+4>>2]=3,t=3312,e[t>>2]=1,e[t+4>>2]=3,t=3320,e[t>>2]=1,e[t+4>>2]=3,t=3328,e[t>>2]=1,e[t+4>>2]=3,t=3336,e[t>>2]=1,e[t+4>>2]=3,t=2896,e[t>>2]=2,e[t+4>>2]=5,t=2904,e[t>>2]=2,e[t+4>>2]=5,t=2912,e[t>>2]=2,e[t+4>>2]=5,t=2920,e[t>>2]=2,e[t+4>>2]=5,t=2928,e[t>>2]=2,e[t+4>>2]=5,t=2936,e[t>>2]=2,e[t+4>>2]=5,t=2944,e[t>>2]=2,e[t+4>>2]=5,t=2952,e[t>>2]=2,e[t+4>>2]=5,t=2848,e[t>>2]=3,e[t+4>>2]=7,t=2856,e[t>>2]=3,e[t+4>>2]=7,t=0;do d=2832+(t+64<<3)|0,e[d>>2]=-1,e[d+4>>2]=2,t=t+1|0;while((t|0)!=64);t=2960,e[t>>2]=-2,e[t+4>>2]=4,t=2968,e[t>>2]=-2,e[t+4>>2]=4,t=2976,e[t>>2]=-2,e[t+4>>2]=4,t=2984,e[t>>2]=-2,e[t+4>>2]=4,t=2992,e[t>>2]=-2,e[t+4>>2]=4,t=3e3,e[t>>2]=-2,e[t+4>>2]=4,t=3008,e[t>>2]=-2,e[t+4>>2]=4,t=3016,e[t>>2]=-2,e[t+4>>2]=4,t=3024,e[t>>2]=-2,e[t+4>>2]=4,t=3032,e[t>>2]=-2,e[t+4>>2]=4,t=3040,e[t>>2]=-2,e[t+4>>2]=4,t=3048,e[t>>2]=-2,e[t+4>>2]=4,t=3056,e[t>>2]=-2,e[t+4>>2]=4,t=3064,e[t>>2]=-2,e[t+4>>2]=4,t=3072,e[t>>2]=-2,e[t+4>>2]=4,t=3080,e[t>>2]=-2,e[t+4>>2]=4,t=2864,e[t>>2]=-3,e[t+4>>2]=6,t=2872,e[t>>2]=-3,e[t+4>>2]=6,t=2880,e[t>>2]=-3,e[t+4>>2]=6,t=2888,e[t>>2]=-3,e[t+4>>2]=6,t=2840,e[t>>2]=-4,e[t+4>>2]=8,t=4880;do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=6928);for(Jt(4880,0,2048)|0,o=2,t=0,c=0,h=0;;){if(o=o<<16>>16,r=8-o|0,l=1<>2]=c,e[d+4>>2]=o,r=r+1|0;while((r|0)<(l|0))}if(r=(h<<16)+65536|0,t=r>>31^r>>15,h=h+1|0,(h|0)==7){r=2,c=1,h=-1,d=-1;break}else o=(t>>1)+2|0,c=r>>16}for(;;){if(o=r<<16>>16,t=8-o|0,l=1<>2]=h,e[c+4>>2]=o,r=r+1|0;while((r|0)<(l|0))}if(t=(d<<16)+-65536|0,c=t>>31^t>>15,r=(c>>1)+2|0,(r|0)>8){t=6928;break}else h=t>>16,d=d+-1|0}do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=8976);for(Jt(6928,0,2048)|0,c=3,t=0,l=0,h=0;;){if(r=8-c|0,o=1<>2]=l,e[d+4>>2]=c,r=r+1|0;while((r|0)<(o|0))}if(r=(h<<16)+65536|0,t=r>>31^r>>15,h=h+1|0,(h|0)==12){c=3,r=1,l=-1,h=-1;break}else c=(t>>2)+3|0,l=r>>16}for(;;){if(t=8-c|0,o=1<>2]=l,e[d+4>>2]=c,r=r+1|0;while((r|0)<(o|0))}if(t=(h<<16)+-65536|0,r=t>>31^t>>15,c=(r>>2)+3|0,(c|0)>8){t=8976;break}else l=t>>16,h=h+-1|0}do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=11024);for(Jt(8976,0,2048)|0,c=4,t=0,l=0,h=0;;){if(r=8-c|0,o=1<>2]=l,e[d+4>>2]=c,r=r+1|0;while((r|0)<(o|0))}if(r=(h<<16)+65536|0,t=r>>31^r>>15,h=h+1|0,(h|0)==20){c=4,r=1,l=-1,h=-1;break}else c=(t>>3)+4|0,l=r>>16}for(;;){if(t=8-c|0,o=1<>2]=l,e[d+4>>2]=c,r=r+1|0;while((r|0)<(o|0))}if(t=(h<<16)+-65536|0,r=t>>31^t>>15,c=(r>>3)+4|0,(c|0)>8){t=11024;break}else l=t>>16,h=h+-1|0}do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=13072);for(Jt(11024,0,2048)|0,c=5,t=0,l=0,h=0;;){if(r=8-c|0,o=1<>2]=l,e[d+4>>2]=c,r=r+1|0;while((r|0)<(o|0))}if(r=(h<<16)+65536|0,t=r>>31^r>>15,h=h+1|0,(h|0)==32){c=5,r=1,l=-1,h=-1;break}else c=(t>>4)+5|0,l=r>>16}for(;;){if(t=8-c|0,o=1<>2]=l,e[d+4>>2]=c,r=r+1|0;while((r|0)<(o|0))}if(t=(h<<16)+-65536|0,r=t>>31^t>>15,c=(r>>4)+5|0,(c|0)>8){t=13072;break}else l=t>>16,h=h+-1|0}do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=15120);for(Jt(13072,0,2048)|0,c=6,t=0,l=0,h=0;;){if(r=8-c|0,o=1<>2]=l,e[d+4>>2]=c,r=r+1|0;while((r|0)<(o|0))}if(r=(h<<16)+65536|0,t=r>>31^r>>15,h=h+1|0,(h|0)==48){c=6,r=1,l=-1,h=-1;break}else c=(t>>5)+6|0,l=r>>16}for(;;){if(t=8-c|0,o=1<>2]=l,e[d+4>>2]=c,r=r+1|0;while((r|0)<(o|0))}if(t=(h<<16)+-65536|0,r=t>>31^t>>15,c=(r>>5)+6|0,(c|0)>8){t=15120;break}else l=t>>16,h=h+-1|0}do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=17168);for(Jt(15120,0,2048)|0,c=7,t=0,l=0,h=0;;){if(r=8-c|0,o=1<>2]=l,e[d+4>>2]=c,r=r+1|0;while((r|0)<(o|0))}if(r=(h<<16)+65536|0,t=r>>31^r>>15,h=h+1|0,(h|0)==64){c=7,r=1,l=-1,h=-1;break}else c=(t>>6)+7|0,l=r>>16}for(;;){if(t=8-c|0,o=1<>2]=l,e[d+4>>2]=c,r=r+1|0;while((r|0)<(o|0))}if(t=(h<<16)+-65536|0,r=t>>31^t>>15,c=(r>>6)+7|0,(c|0)>8){t=17168;break}else l=t>>16,h=h+-1|0}do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=19216);for(Jt(17168,0,2048)|0,c=8,t=0,l=0,h=0;;){if(r=8-c|0,o=1<>2]=l,e[d+4>>2]=c,r=r+1|0;while((r|0)<(o|0))}if(r=(h<<16)+65536|0,t=r>>31^r>>15,h=h+1|0,(h|0)==64){h=8,l=1,c=-1,d=-1;break}else c=(t>>7)+8|0,l=r>>16}for(;;){if(t=8-h|0,o=1<>2]=c,e[l+4>>2]=h,r=r+1|0;while((r|0)<(o|0))}if(r=(d<<16)+-65536|0,l=r>>31^r>>15,t=l>>7,(t|0)>0){t=19216;break}else h=t+8|0,c=r>>16,d=d+-1|0}do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=21264);Jt(19216,0,2048)|0,t=21264;do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=23312);Jt(21264,0,2048)|0,t=23312;do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=25360);Jt(23312,0,2048)|0,t=25360;do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=27408);Jt(25360,0,2048)|0,t=27408;do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=29456);Jt(27408,0,2048)|0,t=29456;do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=31504);Jt(29456,0,2048)|0,t=31504;do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=33552);Jt(31504,0,2048)|0,t=33552;do e[t>>2]=0,e[t+4>>2]=0,t=t+8|0;while((t|0)!=35600);Jt(33552,0,2048)|0,un(35600,8),Ft(179,35600,H|0)|0,un(35612,10),Ft(179,35612,H|0)|0,un(35624,12),Ft(179,35624,H|0)|0,un(35636,16),Ft(179,35636,H|0)|0}function Ta(t){t=t|0;var r=0;r=e[t>>2]|0,r&&(t=t+4|0,(e[t>>2]|0)!=(r|0)&&(e[t>>2]=r),he(r))}function Ia(t){t=t|0;var r=0,o=0;e[t>>2]=36080,r=e[t+4616>>2]|0,r&&(o=t+4620|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),t=t+4|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function Ea(t){t=t|0;var r=0,o=0;if(e[t>>2]=36080,r=e[t+4616>>2]|0,r&&(o=t+4620|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),o=t+4|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function ka(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;d=b,b=b+32|0,C=d,m0(C,e[t+136>>2]|0,e[t+144>>2]|0),w=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[C+8>>2]|0,c=e[r+12>>2]|0,c=c|0?c:e[C+12>>2]|0,o=e[r+16>>2]|0,l=e[C+16>>2]|0,e[t+184>>2]=w|0?w:e[C+4>>2]|0,e[t+188>>2]=h,e[t+192>>2]=c,Wl(t),c=t+140|0,r=(e[c>>2]|0)+32|0,r=(r|0)<128?2:(r|0)/64|0,h=0;do e[t+196+(h*12|0)>>2]=r,e[t+196+(h*12|0)+4>>2]=0,E[t+196+(h*12|0)+8>>1]=0,E[t+196+(h*12|0)+10>>1]=1,h=h+1|0;while((h|0)!=365);w=(e[c>>2]|0)+32|0,w=(w|0)<128?2:(w|0)/64|0,C=(o|0?o:l)&255,e[t+4576>>2]=w,e[t+4580>>2]=0,S[t+4584>>0]=C,S[t+4585>>0]=1,S[t+4586>>0]=0,e[t+4588>>2]=w,e[t+4592>>2]=1,S[t+4596>>0]=C,S[t+4597>>0]=1,S[t+4598>>0]=0,e[t+4600>>2]=0,b=d}function Da(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=b,b=b+16|0,C=k,w=t+92|0,d=e[r>>2]|0,e[r>>2]=0,r=e[w>>2]|0,e[w>>2]=d,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),e[C>>2]=0,e[C+4>>2]=l,w=o+8|0,e[C+8>>2]=e[w>>2],l){r=Xe(4624)|0,l=t+8|0,c=r+4|0,h=l,d=c+84|0;do e[c>>2]=e[h>>2],c=c+4|0,h=h+4|0;while((c|0)<(d|0));c=r+88|0,d=c+40|0;do e[c>>2]=0,c=c+4|0;while((c|0)<(d|0));e[r>>2]=35856,e[r+128>>2]=e[t+136>>2],e[r+132>>2]=e[t+140>>2],e[r+136>>2]=e[t+144>>2],e[r+140>>2]=e[t+148>>2],e[r+144>>2]=e[t+152>>2],e[r+148>>2]=e[t+156>>2],e[r+152>>2]=e[t+160>>2],c=r+156|0,e[c>>2]=0,e[c+4>>2]=0,e[c+8>>2]=0,e[c+12>>2]=0,e[r+172>>2]=e[l>>2],e[r+176>>2]=0,e[r+180>>2]=0,e[r+184>>2]=0,c=r+4568|0,l=r+188|0;do e[l>>2]=0,e[l+4>>2]=0,E[l+8>>1]=0,E[l+10>>1]=1,l=l+12|0;while((l|0)!=(c|0));h=t+4|0,e[c>>2]=0,e[c+4>>2]=0,E[c+8>>1]=0,S[c+10>>0]=0,d=r+4580|0,e[d>>2]=0,e[d+4>>2]=0,E[d+8>>1]=0,S[d+10>>0]=0,d=r+4592|0,e[d>>2]=0,e[d+4>>2]=0,e[d+8>>2]=0,e[d+12>>2]=0,e[d+16>>2]=0,e[d+20>>2]=0,e[d+24>>2]=0,S[d+28>>0]=0,e[r+28>>2]|0||(e[r+20>>2]=1),l=e[h>>2]|0,e[h>>2]=r,l&&(Mt[e[(e[l>>2]|0)+4>>2]&255](l),r=e[h>>2]|0),Y0(r,C)}return C=t+100|0,e[C>>2]=32,e[t+96>>2]=0,r=e[o>>2]|0,r?(e[t+132>>2]=r,c=t+120|0,w=t+124|0,l=e[w>>2]|0,r=e[c>>2]|0,h=r,d=l-h|0,d>>>0>=4e3?d>>>0>4e3&&(D=r+4e3|0,(l|0)!=(D|0))&&(e[w>>2]=D,l=D):(vi(c,4e3-d|0),r=e[c>>2]|0,h=r,l=e[w>>2]|0),e[t+108>>2]=h,e[t+104>>2]=l-r,es(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0):(e[t+108>>2]=e[o+4>>2],e[t+104>>2]=e[w>>2],es(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0)}function ba(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+32>>2]|0&&(e[t+24>>2]|0)!=1){if(_=t+8|0,Q=t+36|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(37,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+16>>2]|0,(t|0)==16)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(38,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(39,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(40,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+20>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=2,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=2,e[l+12>>2]=t,O=l,b=G,O|0)}function Na(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;e[t>>2]=36460,e[t+4>>2]=o,N=t+8|0,h=e[o>>2]|0,D=o+16|0,l=e[D>>2]|0,d=ee(l,h)|0,e[N>>2]=0,R=t+12|0,e[R>>2]=0,e[t+16>>2]=0;do if(d){if((d|0)<0&&(g=0,ue(178,N|0),h=g,g=0,h&1)||(k=4),(k|0)==4&&(w=d<<1,g=0,C=ge(67,w|0)|0,h=g,g=0,!(h&1))){e[N>>2]=C,h=C+(d<<1)|0,e[t+16>>2]=h,Jt(C|0,0,w|0)|0,e[R>>2]=h,h=e[o>>2]|0,l=e[D>>2]|0;break}d=j()|0,c=e[N>>2]|0,l=c,c&&(h=e[R>>2]|0,(h|0)!=(c|0)&&(e[R>>2]=h+(~((h+-2-l|0)>>>1)<<1)),he(c)),R=d,le(R|0)}while(!1);if(d=t+20|0,l=ee(h<<1,l)|0,e[d>>2]=0,w=t+24|0,e[w>>2]=0,e[t+28>>2]=0,!l){R=t+36|0,e[R>>2]=e[r>>2],e[R+4>>2]=e[r+4>>2],e[R+8>>2]=e[r+8>>2];return}if((l|0)<0&&(g=0,ue(178,d|0),o=g,g=0,o&1)||(k=13),(k|0)==13&&(g=0,c=ge(67,l|0)|0,k=g,g=0,!(k&1))){e[w>>2]=c,e[d>>2]=c,e[t+28>>2]=c+l;do S[c>>0]=0,c=(e[w>>2]|0)+1|0,e[w>>2]=c,l=l+-1|0;while(l|0);R=t+36|0,e[R>>2]=e[r>>2],e[R+4>>2]=e[r+4>>2],e[R+8>>2]=e[r+8>>2];return}h=j()|0,c=e[d>>2]|0,c&&((e[w>>2]|0)!=(c|0)&&(e[w>>2]=c),he(c)),c=e[N>>2]|0,c||(R=h,le(R|0)),l=e[R>>2]|0,(l|0)!=(c|0)&&(e[R>>2]=l+(~((l+-2-c|0)>>>1)<<1)),he(c),R=h,le(R|0)}function Fa(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;e[t>>2]=36436,e[t+4>>2]=o,N=t+8|0,h=e[o>>2]|0,D=o+16|0,l=e[D>>2]|0,d=ee(l,h)|0,e[N>>2]=0,R=t+12|0,e[R>>2]=0,e[t+16>>2]=0;do if(d){if((d|0)<0&&(g=0,ue(178,N|0),h=g,g=0,h&1)||(k=4),(k|0)==4&&(w=d<<1,g=0,C=ge(67,w|0)|0,h=g,g=0,!(h&1))){e[N>>2]=C,h=C+(d<<1)|0,e[t+16>>2]=h,Jt(C|0,0,w|0)|0,e[R>>2]=h,h=e[o>>2]|0,l=e[D>>2]|0;break}d=j()|0,c=e[N>>2]|0,l=c,c&&(h=e[R>>2]|0,(h|0)!=(c|0)&&(e[R>>2]=h+(~((h+-2-l|0)>>>1)<<1)),he(c)),R=d,le(R|0)}while(!1);if(d=t+20|0,l=ee(h<<1,l)|0,e[d>>2]=0,w=t+24|0,e[w>>2]=0,e[t+28>>2]=0,!l){R=t+36|0,e[R>>2]=e[r>>2],e[R+4>>2]=e[r+4>>2],e[R+8>>2]=e[r+8>>2];return}if((l|0)<0&&(g=0,ue(178,d|0),o=g,g=0,o&1)||(k=13),(k|0)==13&&(g=0,c=ge(67,l|0)|0,k=g,g=0,!(k&1))){e[w>>2]=c,e[d>>2]=c,e[t+28>>2]=c+l;do S[c>>0]=0,c=(e[w>>2]|0)+1|0,e[w>>2]=c,l=l+-1|0;while(l|0);R=t+36|0,e[R>>2]=e[r>>2],e[R+4>>2]=e[r+4>>2],e[R+8>>2]=e[r+8>>2];return}h=j()|0,c=e[d>>2]|0,c&&((e[w>>2]|0)!=(c|0)&&(e[w>>2]=c),he(c)),c=e[N>>2]|0,c||(R=h,le(R|0)),l=e[R>>2]|0,(l|0)!=(c|0)&&(e[R>>2]=l+(~((l+-2-c|0)>>>1)<<1)),he(c),R=h,le(R|0)}function Ra(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;e[t>>2]=36412,e[t+4>>2]=o,N=t+8|0,h=e[o>>2]|0,D=o+16|0,l=e[D>>2]|0,d=ee(l,h)|0,e[N>>2]=0,R=t+12|0,e[R>>2]=0,e[t+16>>2]=0;do if(d){if((d|0)<0&&(g=0,ue(178,N|0),h=g,g=0,h&1)||(k=4),(k|0)==4&&(w=d<<1,g=0,C=ge(67,w|0)|0,h=g,g=0,!(h&1))){e[N>>2]=C,h=C+(d<<1)|0,e[t+16>>2]=h,Jt(C|0,0,w|0)|0,e[R>>2]=h,h=e[o>>2]|0,l=e[D>>2]|0;break}d=j()|0,c=e[N>>2]|0,l=c,c&&(h=e[R>>2]|0,(h|0)!=(c|0)&&(e[R>>2]=h+(~((h+-2-l|0)>>>1)<<1)),he(c)),R=d,le(R|0)}while(!1);if(d=t+20|0,l=ee(h<<1,l)|0,e[d>>2]=0,w=t+24|0,e[w>>2]=0,e[t+28>>2]=0,!l){R=t+36|0,e[R>>2]=e[r>>2],e[R+4>>2]=e[r+4>>2],e[R+8>>2]=e[r+8>>2];return}if((l|0)<0&&(g=0,ue(178,d|0),o=g,g=0,o&1)||(k=13),(k|0)==13&&(g=0,c=ge(67,l|0)|0,k=g,g=0,!(k&1))){e[w>>2]=c,e[d>>2]=c,e[t+28>>2]=c+l;do S[c>>0]=0,c=(e[w>>2]|0)+1|0,e[w>>2]=c,l=l+-1|0;while(l|0);R=t+36|0,e[R>>2]=e[r>>2],e[R+4>>2]=e[r+4>>2],e[R+8>>2]=e[r+8>>2];return}h=j()|0,c=e[d>>2]|0,c&&((e[w>>2]|0)!=(c|0)&&(e[w>>2]=c),he(c)),c=e[N>>2]|0,c||(R=h,le(R|0)),l=e[R>>2]|0,(l|0)!=(c|0)&&(e[R>>2]=l+(~((l+-2-c|0)>>>1)<<1)),he(c),R=h,le(R|0)}function Ma(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;e[t>>2]=36388,e[t+4>>2]=o,N=t+8|0,h=e[o>>2]|0,D=o+16|0,l=e[D>>2]|0,d=ee(l,h)|0,e[N>>2]=0,R=t+12|0,e[R>>2]=0,e[t+16>>2]=0;do if(d){if((d|0)<0&&(g=0,ue(178,N|0),h=g,g=0,h&1)||(k=4),(k|0)==4&&(w=d<<1,g=0,C=ge(67,w|0)|0,h=g,g=0,!(h&1))){e[N>>2]=C,h=C+(d<<1)|0,e[t+16>>2]=h,Jt(C|0,0,w|0)|0,e[R>>2]=h,h=e[o>>2]|0,l=e[D>>2]|0;break}d=j()|0,c=e[N>>2]|0,l=c,c&&(h=e[R>>2]|0,(h|0)!=(c|0)&&(e[R>>2]=h+(~((h+-2-l|0)>>>1)<<1)),he(c)),R=d,le(R|0)}while(!1);if(d=t+20|0,l=ee(h<<1,l)|0,e[d>>2]=0,w=t+24|0,e[w>>2]=0,e[t+28>>2]=0,!l){R=t+36|0,e[R>>2]=e[r>>2],e[R+4>>2]=e[r+4>>2],e[R+8>>2]=e[r+8>>2];return}if((l|0)<0&&(g=0,ue(178,d|0),o=g,g=0,o&1)||(k=13),(k|0)==13&&(g=0,c=ge(67,l|0)|0,k=g,g=0,!(k&1))){e[w>>2]=c,e[d>>2]=c,e[t+28>>2]=c+l;do S[c>>0]=0,c=(e[w>>2]|0)+1|0,e[w>>2]=c,l=l+-1|0;while(l|0);R=t+36|0,e[R>>2]=e[r>>2],e[R+4>>2]=e[r+4>>2],e[R+8>>2]=e[r+8>>2];return}h=j()|0,c=e[d>>2]|0,c&&((e[w>>2]|0)!=(c|0)&&(e[w>>2]=c),he(c)),c=e[N>>2]|0,c||(R=h,le(R|0)),l=e[R>>2]|0,(l|0)!=(c|0)&&(e[R>>2]=l+(~((l+-2-c|0)>>>1)<<1)),he(c),R=h,le(R|0)}function Pa(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0;d=t+32|0,Sp(d,r)|0,h=t+44|0,e[h>>2]=0,w=t+48|0,c=e[w>>2]|0,c&8&&(r=S[d>>0]|0,r&1?(r=(e[t+40>>2]|0)+(e[t+36>>2]|0)|0,e[h>>2]=r,l=e[t+40>>2]|0,o=l):(r=((r&255)>>>1)+(d+1)|0,e[h>>2]=r,o=d+1|0,l=d+1|0),e[t+8>>2]=o,e[t+12>>2]=l,e[t+16>>2]=r),c&16&&(r=S[d>>0]|0,r&1?(c=e[t+36>>2]|0,e[h>>2]=(e[t+40>>2]|0)+c,r=(e[d>>2]&-2)+-1|0,h=c):(c=(r&255)>>>1,e[h>>2]=d+1+c,r=10,h=c),zs(d,r,0),r=S[d>>0]|0,r&1?(o=e[t+40>>2]|0,c=o,l=e[t+36>>2]|0):(c=d+1|0,l=(r&255)>>>1,o=d+1|0),r=t+24|0,e[r>>2]=o,e[t+20>>2]=o,e[t+28>>2]=c+l,e[w>>2]&3&&(e[r>>2]=o+h))}function La(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;R=b,b=b+32|0,d=R+16|0,N=R+8|0,w=R,g=0,Ae(65,N|0,t|0),D=g,g=0;e:do if(D&1)o=j(0)|0,l=t,c=t;else{do if(S[N>>0]|0){l=e[(e[t>>2]|0)+-12>>2]|0,e[w>>2]=e[t+(l+24)>>2],C=t+l|0,D=e[t+(l+4)>>2]|0,c=r+o|0,l=t+(l+76)|0,o=e[l>>2]|0;do if((o|0)==-1)if(g=0,o=ge(68,C|0)|0,_=g,g=0,_&1)k=13;else{if(e[d>>2]=o,g=0,o=be(37,d|0,44220)|0,_=g,g=0,!(_&1)&&(g=0,h=be(e[(e[o>>2]|0)+28>>2]|0,o|0,32)|0,_=g,g=0,!(_&1))){_0(d),o=h<<24>>24,e[l>>2]=o,k=9;break}o=j(0)|0,_0(d)}else k=9;while(!1);if((k|0)==9)if(g=0,e[d>>2]=e[w>>2],o=Vt(39,d|0,r|0,((D&176|0)==32?c:r)|0,c|0,C|0,o&255|0)|0,_=g,g=0,_&1)k=13;else{if(o)break;if(_=e[(e[t>>2]|0)+-12>>2]|0,g=0,Ae(66,t+_|0,e[t+(_+16)>>2]|5|0),_=g,g=0,_&1)k=13;else break}(k|0)==13&&(o=j(0)|0),Ei(N),l=t,c=t;break e}while(!1);return Ei(N),b=R,t|0}while(!1);return K0(o|0)|0,g=0,ue(181,l+(e[(e[c>>2]|0)+-12>>2]|0)|0),_=g,g=0,_&1?(o=j()|0,g=0,Nt(3),_=g,g=0,_&1?(_=j(0)|0,$t(_)):le(o|0),0):(ei(),b=R,t|0)}function Oa(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0;if(o=e[r+48>>2]|0,o&16){if(o=r+44|0,l=e[o>>2]|0,c=e[r+24>>2]|0,l>>>0>>0?e[o>>2]=c:c=l,l=e[r+20>>2]|0,h=c-l|0,h>>>0>4294967279&&si(t),h>>>0<11?(S[t>>0]=h<<1,o=t+1|0):(r=h+16&-16,o=Xe(r)|0,e[t+8>>2]=o,e[t>>2]=r|1,e[t+4>>2]=h),(l|0)!=(c|0)){for(r=o;S[r>>0]=S[l>>0]|0,l=l+1|0,(l|0)!=(c|0);)r=r+1|0;o=o+h|0}S[o>>0]=0;return}if(!(o&8)){e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0;return}if(l=e[r+8>>2]|0,r=e[r+16>>2]|0,h=r-l|0,h>>>0>4294967279&&si(t),h>>>0<11?(S[t>>0]=h<<1,o=t+1|0):(c=h+16&-16,o=Xe(c)|0,e[t+8>>2]=o,e[t>>2]=c|1,e[t+4>>2]=h),(l|0)!=(r|0)){for(c=o;S[c>>0]=S[l>>0]|0,l=l+1|0,(l|0)!=(r|0);)c=c+1|0;o=o+h|0}S[o>>0]=0}function $a(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;e[t>>2]=36364,e[t+4>>2]=o,R=t+8|0,d=e[o>>2]|0,k=o+16|0,h=e[k>>2]|0,D=ee(h,d)|0,e[R>>2]=0,_=t+12|0,e[_>>2]=0,e[t+16>>2]=0;do if(D){if((D|0)<0&&(g=0,ue(178,R|0),d=g,g=0,d&1)||(N=4),(N|0)==4&&(w=D<<1,g=0,C=ge(67,w|0)|0,d=g,g=0,!(d&1))){e[R>>2]=C,d=C+(D<<1)|0,e[t+16>>2]=d,Jt(C|0,0,w|0)|0,e[_>>2]=d,d=e[o>>2]|0,h=e[k>>2]|0;break}w=j()|0,c=e[R>>2]|0,h=c,c&&(d=e[_>>2]|0,(d|0)!=(c|0)&&(e[_>>2]=d+(~((d+-2-h|0)>>>1)<<1)),he(c)),_=w,le(_|0)}while(!1);if(w=t+20|0,h=ee(d<<1,h)|0,e[w>>2]=0,C=t+24|0,e[C>>2]=0,e[t+28>>2]=0,!h){_=t+32|0,R=l,R=e[R>>2]|0,l=l+4|0,l=e[l>>2]|0,N=_,e[N>>2]=R,_=_+4|0,e[_>>2]=l,_=t+40|0,e[_>>2]=R,_=t+48|0,e[_>>2]=e[r>>2],e[_+4>>2]=e[r+4>>2],e[_+8>>2]=e[r+8>>2];return}if((h|0)<0&&(g=0,ue(178,w|0),k=g,g=0,k&1)||(N=13),(N|0)==13&&(g=0,c=ge(67,h|0)|0,N=g,g=0,!(N&1))){e[C>>2]=c,e[w>>2]=c,e[t+28>>2]=c+h;do S[c>>0]=0,c=(e[C>>2]|0)+1|0,e[C>>2]=c,h=h+-1|0;while(h|0);_=t+32|0,R=l,R=e[R>>2]|0,l=l+4|0,l=e[l>>2]|0,N=_,e[N>>2]=R,_=_+4|0,e[_>>2]=l,_=t+40|0,e[_>>2]=R,_=t+48|0,e[_>>2]=e[r>>2],e[_+4>>2]=e[r+4>>2],e[_+8>>2]=e[r+8>>2];return}d=j()|0,c=e[w>>2]|0,c&&((e[C>>2]|0)!=(c|0)&&(e[C>>2]=c),he(c)),c=e[R>>2]|0,c||(_=d,le(_|0)),h=e[_>>2]|0,(h|0)!=(c|0)&&(e[_>>2]=h+(~((h+-2-c|0)>>>1)<<1)),he(c),_=d,le(_|0)}function Ba(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;e[t>>2]=36340,e[t+4>>2]=o,R=t+8|0,d=e[o>>2]|0,k=o+16|0,h=e[k>>2]|0,D=ee(h,d)|0,e[R>>2]=0,_=t+12|0,e[_>>2]=0,e[t+16>>2]=0;do if(D){if((D|0)<0&&(g=0,ue(178,R|0),d=g,g=0,d&1)||(N=4),(N|0)==4&&(w=D<<1,g=0,C=ge(67,w|0)|0,d=g,g=0,!(d&1))){e[R>>2]=C,d=C+(D<<1)|0,e[t+16>>2]=d,Jt(C|0,0,w|0)|0,e[_>>2]=d,d=e[o>>2]|0,h=e[k>>2]|0;break}w=j()|0,c=e[R>>2]|0,h=c,c&&(d=e[_>>2]|0,(d|0)!=(c|0)&&(e[_>>2]=d+(~((d+-2-h|0)>>>1)<<1)),he(c)),_=w,le(_|0)}while(!1);if(w=t+20|0,h=ee(d<<1,h)|0,e[w>>2]=0,C=t+24|0,e[C>>2]=0,e[t+28>>2]=0,!h){_=t+32|0,R=l,R=e[R>>2]|0,l=l+4|0,l=e[l>>2]|0,N=_,e[N>>2]=R,_=_+4|0,e[_>>2]=l,_=t+40|0,e[_>>2]=R,_=t+48|0,e[_>>2]=e[r>>2],e[_+4>>2]=e[r+4>>2],e[_+8>>2]=e[r+8>>2];return}if((h|0)<0&&(g=0,ue(178,w|0),k=g,g=0,k&1)||(N=13),(N|0)==13&&(g=0,c=ge(67,h|0)|0,N=g,g=0,!(N&1))){e[C>>2]=c,e[w>>2]=c,e[t+28>>2]=c+h;do S[c>>0]=0,c=(e[C>>2]|0)+1|0,e[C>>2]=c,h=h+-1|0;while(h|0);_=t+32|0,R=l,R=e[R>>2]|0,l=l+4|0,l=e[l>>2]|0,N=_,e[N>>2]=R,_=_+4|0,e[_>>2]=l,_=t+40|0,e[_>>2]=R,_=t+48|0,e[_>>2]=e[r>>2],e[_+4>>2]=e[r+4>>2],e[_+8>>2]=e[r+8>>2];return}d=j()|0,c=e[w>>2]|0,c&&((e[C>>2]|0)!=(c|0)&&(e[C>>2]=c),he(c)),c=e[R>>2]|0,c||(_=d,le(_|0)),h=e[_>>2]|0,(h|0)!=(c|0)&&(e[_>>2]=h+(~((h+-2-c|0)>>>1)<<1)),he(c),_=d,le(_|0)}function Va(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;e[t>>2]=36316,e[t+4>>2]=o,R=t+8|0,d=e[o>>2]|0,k=o+16|0,h=e[k>>2]|0,D=ee(h,d)|0,e[R>>2]=0,_=t+12|0,e[_>>2]=0,e[t+16>>2]=0;do if(D){if((D|0)<0&&(g=0,ue(178,R|0),d=g,g=0,d&1)||(N=4),(N|0)==4&&(w=D<<1,g=0,C=ge(67,w|0)|0,d=g,g=0,!(d&1))){e[R>>2]=C,d=C+(D<<1)|0,e[t+16>>2]=d,Jt(C|0,0,w|0)|0,e[_>>2]=d,d=e[o>>2]|0,h=e[k>>2]|0;break}w=j()|0,c=e[R>>2]|0,h=c,c&&(d=e[_>>2]|0,(d|0)!=(c|0)&&(e[_>>2]=d+(~((d+-2-h|0)>>>1)<<1)),he(c)),_=w,le(_|0)}while(!1);if(w=t+20|0,h=ee(d<<1,h)|0,e[w>>2]=0,C=t+24|0,e[C>>2]=0,e[t+28>>2]=0,!h){_=t+32|0,R=l,R=e[R>>2]|0,l=l+4|0,l=e[l>>2]|0,N=_,e[N>>2]=R,_=_+4|0,e[_>>2]=l,_=t+40|0,e[_>>2]=R,_=t+48|0,e[_>>2]=e[r>>2],e[_+4>>2]=e[r+4>>2],e[_+8>>2]=e[r+8>>2];return}if((h|0)<0&&(g=0,ue(178,w|0),k=g,g=0,k&1)||(N=13),(N|0)==13&&(g=0,c=ge(67,h|0)|0,N=g,g=0,!(N&1))){e[C>>2]=c,e[w>>2]=c,e[t+28>>2]=c+h;do S[c>>0]=0,c=(e[C>>2]|0)+1|0,e[C>>2]=c,h=h+-1|0;while(h|0);_=t+32|0,R=l,R=e[R>>2]|0,l=l+4|0,l=e[l>>2]|0,N=_,e[N>>2]=R,_=_+4|0,e[_>>2]=l,_=t+40|0,e[_>>2]=R,_=t+48|0,e[_>>2]=e[r>>2],e[_+4>>2]=e[r+4>>2],e[_+8>>2]=e[r+8>>2];return}d=j()|0,c=e[w>>2]|0,c&&((e[C>>2]|0)!=(c|0)&&(e[C>>2]=c),he(c)),c=e[R>>2]|0,c||(_=d,le(_|0)),h=e[_>>2]|0,(h|0)!=(c|0)&&(e[_>>2]=h+(~((h+-2-c|0)>>>1)<<1)),he(c),_=d,le(_|0)}function Ua(t){t=t|0;var r=0,o=0,l=0;e[t>>2]=36316,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,l&&(r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l))}function za(t){t=t|0;var r=0,o=0,l=0;if(e[t>>2]=36316,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,!l){he(t);return}r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l),he(t)}function Ga(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;if(c=t+48|0,!(e[c>>2]|0)){w=t+52|0,Qr(t,r,e[w>>2]|0,o,l),e[w>>2]=(e[w>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}C=t+4|0,h=o<<1,d=ee(h,e[(e[C>>2]|0)+16>>2]|0)|0,w=t+20|0,Qr(t,r,e[w>>2]|0,o,l),r=e[C>>2]|0,(e[r+28>>2]|0)==536870912&&ti(e[w>>2]|0,ee(h,e[r+16>>2]|0)|0),C=e[c>>2]|0,(Yt[e[(e[C>>2]|0)+48>>2]&63](C,e[w>>2]|0,d)|0)!=(d|0)&&(r=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,r|0,3,35648),C=g,g=0,C&1?(C=j()|0,Tt(r|0),le(C|0)):Qt(r|0,824,96))}function qa(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0;if(c=e[t+48>>2]|0,c){Wa(t,c,r,o,l);return}else{c=t+52|0,Bn(t,e[c>>2]|0,r,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}}function Bn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0;C=t+4|0,h=e[C>>2]|0;do if(!(S[h+32>>0]|0))D=r;else{if(d=t+8|0,o0(e[d>>2]|0,r|0,l*6|0)|0,h=e[C>>2]|0,w=e[h+16>>2]|0,(l|0)<=0){D=e[d>>2]|0;break}for(r=e[d>>2]|0,h=r,d=0;D=h+4|0,k=E[h>>1]|0,E[h>>1]=E[D>>1]|0,E[D>>1]=k,d=d+1|0,(d|0)!=(l|0);)h=h+(w<<1)|0;D=r,h=e[C>>2]|0}while(!1);switch(e[h+16>>2]|0){case 3:if((e[h+24>>2]|0)==2){if((l|0)<=0)return;h=t+32|0,r=0;do k=e[h>>2]|0,C=M[D+(r*6|0)+2>>1]<>1]<>1]<>1]=(C+49152+((t+c|0)>>>2)&65535)>>>k,E[o+(r*6|0)+2>>1]=t>>>k,E[o+(r*6|0)+4>>1]=c>>>k,r=r+1|0;while((r|0)!=(l|0));return}else{if(d=(c|0)<(l|0)?c:l,(d|0)<=0)return;w=c<<1,h=e[t+32>>2]|0,r=0;do l=M[D+(r*6|0)+2>>1]<>1]<>1]<>1]=(l+49152+((t+k|0)>>>2)&65535)>>>h,E[o+(r+c<<1)>>1]=t>>>h,E[o+(r+w<<1)>>1]=k>>>h,r=r+1|0;while((r|0)!=(d|0));return}case 4:{if((e[h+24>>2]|0)!=1||(d=(c|0)<(l|0)?c:l,(d|0)<=0))return;w=c<<1,C=c*3|0,h=e[t+32>>2]|0,r=0;do k=E[D+(r<<3)+6>>1]|0,N=M[D+(r<<3)+2>>1]<>1]<>1]<>1]=(N+49152+((l+t|0)>>>2)&65535)>>>h,E[o+(r+c<<1)>>1]=l>>>h,E[o+(r+w<<1)>>1]=t>>>h,E[o+(r+C<<1)>>1]=k,r=r+1|0;while((r|0)!=(d|0));return}default:return}}function Wa(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;N=b,b=b+176|0,R=N+152|0,U=N+16|0,_=N,C=t+4|0,h=e[C>>2]|0,k=l<<1,d=ee(k,e[h+16>>2]|0)|0;do if(d){for(w=t+20|0;h=Yt[e[(e[r>>2]|0)+32>>2]&63](r,e[w>>2]|0,d)|0,!!h;)if((d|0)==(h|0)){D=26;break}else d=d-h|0;if((D|0)==26){h=e[C>>2]|0;break}D=U+56|0,C=U+4|0,e[U>>2]=36160,e[D>>2]=36180,g=0,Ae(62,U+56|0,C|0),N=g,g=0,N&1&&(U=j()|0,tt(D),le(U|0)),e[U+128>>2]=0,e[U+132>>2]=-1,e[U>>2]=36200,e[U+56>>2]=36220,g=0,ue(180,C|0),N=g,g=0;do if(N&1)h=j()|0;else{if(e[C>>2]=36236,r=U+36|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[U+52>>2]=16,e[R>>2]=0,e[R+4>>2]=0,e[R+8>>2]=0,g=0,Ae(63,C|0,R|0),N=g,g=0,N&1){h=j()|0,de(R),de(r),wt(C);break}de(R),g=0,h=Ve(28,U|0,49029,57)|0,R=g,g=0,!(R&1)&&(g=0,be(36,h|0,0)|0,R=g,g=0,!(R&1))&&(w=Ct(16)|0,g=0,Ae(64,_|0,C|0),R=g,g=0,R&1?h=j()|0:(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,w|0,3,35648,_|0),R=g,g=0,R&1?d=1:(g=0,xe(6,w|0,824,96),g=0,d=0),h=j()|0,de(_),d||(_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0))),Tt(w|0),_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)),_=j()|0,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)}while(!1);U=h,tt(D),le(U|0)}while(!1);if(d=t+20|0,(e[h+28>>2]|0)!=536870912){U=e[d>>2]|0,Bn(t,U,o,l,c),b=N;return}ti(e[d>>2]|0,ee(k,e[h+16>>2]|0)|0),U=e[d>>2]|0,Bn(t,U,o,l,c),b=N}function ti(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;if(c=b,b=b+176|0,o=c+152|0,C=c+16|0,d=c,!(r&1)){if(o=(r|0)/4|0,(r|0)>3){l=0;do C=t+(l<<2)|0,w=e[C>>2]|0,e[C>>2]=w>>>8&16711935|w<<8&-16711936,l=l+1|0;while((l|0)<(o|0))}if(!(r&3)){b=c;return}d=t+(r+-2)|0,C=t+(r+-1)|0,w=S[d>>0]|0,S[d>>0]=S[C>>0]|0,S[C>>0]=w,b=c;return}w=C+56|0,h=C+4|0,e[C>>2]=36160,e[w>>2]=36180,g=0,Ae(62,C+56|0,h|0),c=g,g=0,c&1&&(C=j()|0,tt(w),le(C|0)),e[C+128>>2]=0,e[C+132>>2]=-1,e[C>>2]=36200,e[C+56>>2]=36220,g=0,ue(180,h|0),c=g,g=0;do if(c&1)o=j()|0;else{if(e[h>>2]=36236,c=C+36|0,e[c>>2]=0,e[c+4>>2]=0,e[c+8>>2]=0,e[c+12>>2]=0,e[C+52>>2]=16,e[o>>2]=0,e[o+4>>2]=0,e[o+8>>2]=0,g=0,Ae(63,h|0,o|0),t=g,g=0,t&1){C=j()|0,de(o),de(c),wt(h),o=C;break}de(o),g=0,o=Ve(28,C|0,49087,24)|0,t=g,g=0,!(t&1)&&(g=0,l=be(36,o|0,r|0)|0,r=g,g=0,!(r&1))&&(g=0,Ve(28,l|0,49112,20)|0,r=g,g=0,!(r&1))&&(t=Ct(16)|0,g=0,Ae(64,d|0,h|0),r=g,g=0,r&1?o=j()|0:(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,t|0,1,35648,d|0),r=g,g=0,r&1?l=1:(g=0,xe(6,t|0,824,96),g=0,l=0),o=j()|0,de(d),l||(d=o,e[C>>2]=36200,e[w>>2]=36220,e[h>>2]=36236,de(c),wt(h),tt(w),le(d|0))),Tt(t|0),d=o,e[C>>2]=36200,e[w>>2]=36220,e[h>>2]=36236,de(c),wt(h),tt(w),le(d|0)),d=j()|0,e[C>>2]=36200,e[w>>2]=36220,e[h>>2]=36236,de(c),wt(h),tt(w),le(d|0)}while(!1);C=o,tt(w),le(C|0)}function Qr(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;D=t+4|0,h=e[D>>2]|0;e:do switch(e[h+16>>2]|0){case 3:{if((e[h+24>>2]|0)==2){if((l|0)<=0)break e;h=t+40|0,t=0;do c=e[h>>2]|0,w=M[r+(t*6|0)+2>>1]<>1]<>1]<>2)+16384|0,E[o+(t*6|0)>>1]=(d+32768+C&65535)>>>c,E[o+(t*6|0)+2>>1]=(C&65535)>>>c,E[o+(t*6|0)+4>>1]=(w+32768+C&65535)>>>c,t=t+1|0;while((t|0)!=(l|0))}else{if(d=(l|0)<(c|0)?l:c,(d|0)<=0)break e;w=c<<1,h=t+40|0,t=0;do C=e[h>>2]|0,N=M[r+(t+c<<1)>>1]<>1]<>1]<>2)+16384|0,E[o+(t*6|0)>>1]=(R+32768+k&65535)>>>C,E[o+(t*6|0)+2>>1]=(k&65535)>>>C,E[o+(t*6|0)+4>>1]=(N+32768+k&65535)>>>C,t=t+1|0;while((t|0)!=(d|0))}break}case 4:{if((e[h+24>>2]|0)==1&&(C=(l|0)<(c|0)?l:c,(C|0)>0)){w=c<<1,h=t+40|0,t=c*3|0,d=0;do R=e[h>>2]|0,N=M[r+(d+c<<1)>>1]<>1]<>1]<>2)+16384|0,_=E[r+(d+t<<1)>>1]|0,Q=v0((k&65535)>>>R&65535|0,0,16)|0,N=(N+32768+k&65535)>>>R|ye,_=v0(_&65535|0,0,48)|0,_=Q|(U+32768+k&65535)>>>R&65535|_,N=N&65535|ye,R=o+(d<<3)|0,k=R,E[k>>1]=_,E[k+2>>1]=_>>>16,R=R+4|0,E[R>>1]=N,E[R+2>>1]=N>>>16,d=d+1|0;while((d|0)!=(C|0))}break}default:}while(!1);if(h=e[D>>2]|0,!!(S[h+32>>0]|0)&&(d=e[h+16>>2]|0,!((l|0)<=0)))for(h=o,t=0;Q=h+4|0,U=E[h>>1]|0,E[h>>1]=E[Q>>1]|0,E[Q>>1]=U,t=t+1|0,(t|0)!=(l|0);)h=h+(d<<1)|0}function Ha(t){t=t|0;var r=0,o=0,l=0;e[t>>2]=36340,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,l&&(r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l))}function Qa(t){t=t|0;var r=0,o=0,l=0;if(e[t>>2]=36340,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,!l){he(t);return}r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l),he(t)}function Ka(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;if(c=t+48|0,!(e[c>>2]|0)){w=t+52|0,Kr(t,r,e[w>>2]|0,o,l),e[w>>2]=(e[w>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}C=t+4|0,h=o<<1,d=ee(h,e[(e[C>>2]|0)+16>>2]|0)|0,w=t+20|0,Kr(t,r,e[w>>2]|0,o,l),r=e[C>>2]|0,(e[r+28>>2]|0)==536870912&&ti(e[w>>2]|0,ee(h,e[r+16>>2]|0)|0),C=e[c>>2]|0,(Yt[e[(e[C>>2]|0)+48>>2]&63](C,e[w>>2]|0,d)|0)!=(d|0)&&(r=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,r|0,3,35648),C=g,g=0,C&1?(C=j()|0,Tt(r|0),le(C|0)):Qt(r|0,824,96))}function Ya(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0;if(c=e[t+48>>2]|0,c){ja(t,c,r,o,l);return}else{c=t+52|0,Vn(t,e[c>>2]|0,r,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}}function Vn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0;C=t+4|0,h=e[C>>2]|0;do if(!(S[h+32>>0]|0))D=r;else{if(d=t+8|0,o0(e[d>>2]|0,r|0,l*6|0)|0,h=e[C>>2]|0,w=e[h+16>>2]|0,(l|0)<=0){D=e[d>>2]|0;break}for(r=e[d>>2]|0,h=r,d=0;D=h+4|0,k=E[h>>1]|0,E[h>>1]=E[D>>1]|0,E[D>>1]=k,d=d+1|0,(d|0)!=(l|0);)h=h+(w<<1)|0;D=r,h=e[C>>2]|0}while(!1);switch(e[h+16>>2]|0){case 3:if((e[h+24>>2]|0)==2){if((l|0)<=0)return;h=t+32|0,r=0;do c=e[h>>2]|0,C=M[D+(r*6|0)>>1]<>1]<>1]<>>1)&65535)>>>c&65535,E[o+(r*6|0)>>1]=(C+32768-t&65535)>>>c,E[o+(r*6|0)+2>>1]=(t&65535)>>>c,E[o+(r*6|0)+4>>1]=k,r=r+1|0;while((r|0)!=(l|0));return}else{if(d=(c|0)<(l|0)?c:l,(d|0)<=0)return;w=c<<1,h=e[t+32>>2]|0,r=0;do l=M[D+(r*6|0)>>1]<>1]<>1]<>>1)&65535)>>>h&65535,E[o+(r<<1)>>1]=(l+32768-t&65535)>>>h,E[o+(r+c<<1)>>1]=(t&65535)>>>h,E[o+(r+w<<1)>>1]=k,r=r+1|0;while((r|0)!=(d|0));return}case 4:{if((e[h+24>>2]|0)!=1||(d=(c|0)<(l|0)?c:l,(d|0)<=0))return;w=c<<1,C=c*3|0,h=e[t+32>>2]|0,r=0;do k=E[D+(r<<3)+6>>1]|0,N=M[D+(r<<3)>>1]<>1]<>1]<>>1)&65535)>>>h&65535,E[o+(r<<1)>>1]=(N+32768-l&65535)>>>h,E[o+(r+c<<1)>>1]=(l&65535)>>>h,E[o+(r+w<<1)>>1]=t,E[o+(r+C<<1)>>1]=k,r=r+1|0;while((r|0)!=(d|0));return}default:return}}function ja(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;N=b,b=b+176|0,R=N+152|0,U=N+16|0,_=N,C=t+4|0,h=e[C>>2]|0,k=l<<1,d=ee(k,e[h+16>>2]|0)|0;do if(d){for(w=t+20|0;h=Yt[e[(e[r>>2]|0)+32>>2]&63](r,e[w>>2]|0,d)|0,!!h;)if((d|0)==(h|0)){D=26;break}else d=d-h|0;if((D|0)==26){h=e[C>>2]|0;break}D=U+56|0,C=U+4|0,e[U>>2]=36160,e[D>>2]=36180,g=0,Ae(62,U+56|0,C|0),N=g,g=0,N&1&&(U=j()|0,tt(D),le(U|0)),e[U+128>>2]=0,e[U+132>>2]=-1,e[U>>2]=36200,e[U+56>>2]=36220,g=0,ue(180,C|0),N=g,g=0;do if(N&1)h=j()|0;else{if(e[C>>2]=36236,r=U+36|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[U+52>>2]=16,e[R>>2]=0,e[R+4>>2]=0,e[R+8>>2]=0,g=0,Ae(63,C|0,R|0),N=g,g=0,N&1){h=j()|0,de(R),de(r),wt(C);break}de(R),g=0,h=Ve(28,U|0,49029,57)|0,R=g,g=0,!(R&1)&&(g=0,be(36,h|0,0)|0,R=g,g=0,!(R&1))&&(w=Ct(16)|0,g=0,Ae(64,_|0,C|0),R=g,g=0,R&1?h=j()|0:(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,w|0,3,35648,_|0),R=g,g=0,R&1?d=1:(g=0,xe(6,w|0,824,96),g=0,d=0),h=j()|0,de(_),d||(_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0))),Tt(w|0),_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)),_=j()|0,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)}while(!1);U=h,tt(D),le(U|0)}while(!1);if(d=t+20|0,(e[h+28>>2]|0)!=536870912){U=e[d>>2]|0,Vn(t,U,o,l,c),b=N;return}ti(e[d>>2]|0,ee(k,e[h+16>>2]|0)|0),U=e[d>>2]|0,Vn(t,U,o,l,c),b=N}function Kr(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;D=t+4|0,h=e[D>>2]|0;e:do switch(e[h+16>>2]|0){case 3:{if((e[h+24>>2]|0)==2){if((l|0)<=0)break e;h=t+40|0,t=0;do C=e[h>>2]|0,w=M[r+(t*6|0)+2>>1]<>1]<>1]<>>1)&65535)>>>C&65535,E[o+(t*6|0)>>1]=d>>>C,E[o+(t*6|0)+2>>1]=w>>>C,E[o+(t*6|0)+4>>1]=c,t=t+1|0;while((t|0)!=(l|0))}else{if(d=(l|0)<(c|0)?l:c,(d|0)<=0)break e;w=c<<1,h=t+40|0,t=0;do k=e[h>>2]|0,N=M[r+(t+c<<1)>>1]<>1]<>1]<>>1)&65535)>>>k&65535,E[o+(t*6|0)>>1]=R>>>k,E[o+(t*6|0)+2>>1]=N>>>k,E[o+(t*6|0)+4>>1]=C,t=t+1|0;while((t|0)!=(d|0))}break}case 4:{if((e[h+24>>2]|0)==1&&(C=(l|0)<(c|0)?l:c,(C|0)>0)){w=c<<1,h=t+40|0,t=c*3|0,d=0;do k=e[h>>2]|0,R=M[r+(d+c<<1)>>1]<>1]<>1]<>>1)&65535)>>>k,_=E[r+(d+t<<1)>>1]|0,R=v0(R>>>k&65535|0,0,16)|0,N=ye|N,_=v0(_&65535|0,0,48)|0,_=U>>>k&65535|R|_,N=N&65535|ye,R=o+(d<<3)|0,k=R,E[k>>1]=_,E[k+2>>1]=_>>>16,R=R+4|0,E[R>>1]=N,E[R+2>>1]=N>>>16,d=d+1|0;while((d|0)!=(C|0))}break}default:}while(!1);if(h=e[D>>2]|0,!!(S[h+32>>0]|0)&&(d=e[h+16>>2]|0,!((l|0)<=0)))for(h=o,t=0;U=h+4|0,_=E[h>>1]|0,E[h>>1]=E[U>>1]|0,E[U>>1]=_,t=t+1|0,(t|0)!=(l|0);)h=h+(d<<1)|0}function Xa(t){t=t|0;var r=0,o=0,l=0;e[t>>2]=36364,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,l&&(r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l))}function Za(t){t=t|0;var r=0,o=0,l=0;if(e[t>>2]=36364,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,!l){he(t);return}r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l),he(t)}function Ja(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;if(c=t+48|0,!(e[c>>2]|0)){w=t+52|0,Yr(t,r,e[w>>2]|0,o,l),e[w>>2]=(e[w>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}C=t+4|0,h=o<<1,d=ee(h,e[(e[C>>2]|0)+16>>2]|0)|0,w=t+20|0,Yr(t,r,e[w>>2]|0,o,l),r=e[C>>2]|0,(e[r+28>>2]|0)==536870912&&ti(e[w>>2]|0,ee(h,e[r+16>>2]|0)|0),C=e[c>>2]|0,(Yt[e[(e[C>>2]|0)+48>>2]&63](C,e[w>>2]|0,d)|0)!=(d|0)&&(r=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,r|0,3,35648),C=g,g=0,C&1?(C=j()|0,Tt(r|0),le(C|0)):Qt(r|0,824,96))}function el(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0;if(c=e[t+48>>2]|0,c){tl(t,c,r,o,l);return}else{c=t+52|0,Un(t,e[c>>2]|0,r,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}}function Un(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0;C=t+4|0,h=e[C>>2]|0;do if(!(S[h+32>>0]|0))D=r;else{if(d=t+8|0,o0(e[d>>2]|0,r|0,l*6|0)|0,h=e[C>>2]|0,w=e[h+16>>2]|0,(l|0)<=0){D=e[d>>2]|0;break}for(r=e[d>>2]|0,h=r,d=0;D=h+4|0,k=E[h>>1]|0,E[h>>1]=E[D>>1]|0,E[D>>1]=k,d=d+1|0,(d|0)!=(l|0);)h=h+(w<<1)|0;D=r,h=e[C>>2]|0}while(!1);switch(e[h+16>>2]|0){case 3:if((e[h+24>>2]|0)==2){if((l|0)<=0)return;h=t+32|0,r=0;do c=e[h>>2]|0,t=M[D+(r*6|0)+2>>1]<>1]<>>c&65535,E[o+(r*6|0)>>1]=((M[D+(r*6|0)>>1]<>>c,E[o+(r*6|0)+2>>1]=(t&65535)>>>c,E[o+(r*6|0)+4>>1]=k,r=r+1|0;while((r|0)!=(l|0));return}else{if(d=(c|0)<(l|0)?c:l,(d|0)<=0)return;w=c<<1,h=e[t+32>>2]|0,r=0;do t=M[D+(r*6|0)+2>>1]<>1]<>>h&65535,E[o+(r<<1)>>1]=((M[D+(r*6|0)>>1]<>>h,E[o+(r+c<<1)>>1]=(t&65535)>>>h,E[o+(r+w<<1)>>1]=k,r=r+1|0;while((r|0)!=(d|0));return}case 4:{if((e[h+24>>2]|0)!=1||(w=(c|0)<(l|0)?c:l,(w|0)<=0))return;C=c<<1,d=c*3|0,h=e[t+32>>2]|0,r=0;do k=E[D+(r<<3)+6>>1]|0,l=M[D+(r<<3)+2>>1]<>1]<>>h&65535,E[o+(r<<1)>>1]=((M[D+(r<<3)>>1]<>>h,E[o+(r+c<<1)>>1]=(l&65535)>>>h,E[o+(r+C<<1)>>1]=t,E[o+(r+d<<1)>>1]=k,r=r+1|0;while((r|0)!=(w|0));return}default:return}}function tl(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;N=b,b=b+176|0,R=N+152|0,U=N+16|0,_=N,C=t+4|0,h=e[C>>2]|0,k=l<<1,d=ee(k,e[h+16>>2]|0)|0;do if(d){for(w=t+20|0;h=Yt[e[(e[r>>2]|0)+32>>2]&63](r,e[w>>2]|0,d)|0,!!h;)if((d|0)==(h|0)){D=26;break}else d=d-h|0;if((D|0)==26){h=e[C>>2]|0;break}D=U+56|0,C=U+4|0,e[U>>2]=36160,e[D>>2]=36180,g=0,Ae(62,U+56|0,C|0),N=g,g=0,N&1&&(U=j()|0,tt(D),le(U|0)),e[U+128>>2]=0,e[U+132>>2]=-1,e[U>>2]=36200,e[U+56>>2]=36220,g=0,ue(180,C|0),N=g,g=0;do if(N&1)h=j()|0;else{if(e[C>>2]=36236,r=U+36|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[U+52>>2]=16,e[R>>2]=0,e[R+4>>2]=0,e[R+8>>2]=0,g=0,Ae(63,C|0,R|0),N=g,g=0,N&1){h=j()|0,de(R),de(r),wt(C);break}de(R),g=0,h=Ve(28,U|0,49029,57)|0,R=g,g=0,!(R&1)&&(g=0,be(36,h|0,0)|0,R=g,g=0,!(R&1))&&(w=Ct(16)|0,g=0,Ae(64,_|0,C|0),R=g,g=0,R&1?h=j()|0:(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,w|0,3,35648,_|0),R=g,g=0,R&1?d=1:(g=0,xe(6,w|0,824,96),g=0,d=0),h=j()|0,de(_),d||(_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0))),Tt(w|0),_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)),_=j()|0,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)}while(!1);U=h,tt(D),le(U|0)}while(!1);if(d=t+20|0,(e[h+28>>2]|0)!=536870912){U=e[d>>2]|0,Un(t,U,o,l,c),b=N;return}ti(e[d>>2]|0,ee(k,e[h+16>>2]|0)|0),U=e[d>>2]|0,Un(t,U,o,l,c),b=N}function Yr(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;D=t+4|0,h=e[D>>2]|0;e:do switch(e[h+16>>2]|0){case 3:{if((e[h+24>>2]|0)==2){if((l|0)<=0)break e;h=t+40|0,t=0;do C=e[h>>2]|0,w=M[r+(t*6|0)+2>>1]<>1]<>>C&65535,E[o+(t*6|0)>>1]=((M[r+(t*6|0)>>1]<>>C,E[o+(t*6|0)+2>>1]=(w&65535)>>>C,E[o+(t*6|0)+4>>1]=c,t=t+1|0;while((t|0)!=(l|0))}else{if(d=(l|0)<(c|0)?l:c,(d|0)<=0)break e;w=c<<1,h=t+40|0,t=0;do k=e[h>>2]|0,N=M[r+(t+c<<1)>>1]<>1]<>>k&65535,E[o+(t*6|0)>>1]=((M[r+(t<<1)>>1]<>>k,E[o+(t*6|0)+2>>1]=(N&65535)>>>k,E[o+(t*6|0)+4>>1]=C,t=t+1|0;while((t|0)!=(d|0))}break}case 4:{if((e[h+24>>2]|0)==1&&(C=(l|0)<(c|0)?l:c,(C|0)>0)){w=c<<1,h=t+40|0,t=c*3|0,d=0;do R=e[h>>2]|0,U=M[r+(d+c<<1)>>1]<>1]<>>R,k=(U+32768+(M[r+(d+w<<1)>>1]<>>R,_=E[r+(d+t<<1)>>1]|0,R=v0((U&65535)>>>R&65535|0,0,16)|0,k=k|ye,_=v0(_&65535|0,0,48)|0,_=R|N&65535|_,k=k&65535|ye,N=o+(d<<3)|0,R=N,E[R>>1]=_,E[R+2>>1]=_>>>16,N=N+4|0,E[N>>1]=k,E[N+2>>1]=k>>>16,d=d+1|0;while((d|0)!=(C|0))}break}default:}while(!1);if(h=e[D>>2]|0,!!(S[h+32>>0]|0)&&(d=e[h+16>>2]|0,!((l|0)<=0)))for(h=o,t=0;U=h+4|0,_=E[h>>1]|0,E[h>>1]=E[U>>1]|0,E[U>>1]=_,t=t+1|0,(t|0)!=(l|0);)h=h+(d<<1)|0}function Ui(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0;if(N=b,b=b+16|0,D=N,k=e[t>>2]|0,!k)return t=0,b=N,t|0;if(R=r,w=l-R|0,C=c+12|0,d=e[C>>2]|0,w=(d|0)>(w|0)?d-w|0:0,d=o,c=d-R|0,(c|0)>0&&(Yt[e[(e[k>>2]|0)+48>>2]&63](k,r,c)|0)!=(c|0))return e[t>>2]=0,R=0,b=N,R|0;do if((w|0)>0){if(dr(D,w,h),g=0,c=Ve(e[(e[k>>2]|0)+48>>2]|0,k|0,(S[D>>0]&1?e[D+8>>2]|0:D+1|0)|0,w|0)|0,R=g,g=0,R&1&&(R=j()|0,de(D),le(R|0)),(c|0)==(w|0)){de(D);break}return e[t>>2]=0,de(D),R=0,b=N,R|0}while(!1);return l=l-d|0,(l|0)>0&&(Yt[e[(e[k>>2]|0)+48>>2]&63](k,o,l)|0)!=(l|0)?(e[t>>2]=0,R=0,b=N,R|0):(e[C>>2]=0,R=k,b=N,R|0)}function il(t){t=t|0,e[t>>2]=36236,de(t+32|0),wt(t)}function nl(t){t=t|0,e[t>>2]=36236,de(t+32|0),wt(t),he(t)}function rl(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;if(d=r+44|0,w=e[d>>2]|0,D=r+24|0,k=e[D>>2]|0,w>>>0>>0&&(e[d>>2]=k,w=k),C=w,d=h&24,!d){r=t,e[r>>2]=0,e[r+4>>2]=0,r=t+8|0,e[r>>2]=-1,e[r+4>>2]=-1;return}if((c|0)==1&(d|0)==24){r=t,e[r>>2]=0,e[r+4>>2]=0,r=t+8|0,e[r>>2]=-1,e[r+4>>2]=-1;return}e:do switch(c|0){case 0:{d=0,c=0;break}case 1:if(h&8){c=(e[r+12>>2]|0)-(e[r+8>>2]|0)|0,d=c,c=((c|0)<0)<<31>>31;break e}else{c=k-(e[r+20>>2]|0)|0,d=c,c=((c|0)<0)<<31>>31;break e}case 2:{d=r+32|0,S[d>>0]&1?d=e[r+40>>2]|0:d=d+1|0,c=w-d|0,d=c,c=((c|0)<0)<<31>>31;break}default:{r=t,e[r>>2]=0,e[r+4>>2]=0,r=t+8|0,e[r>>2]=-1,e[r+4>>2]=-1;return}}while(!1);if(c=$0(d|0,c|0,o|0,l|0)|0,o=ye,(o|0)>=0&&(d=r+32|0,S[d>>0]&1?d=e[r+40>>2]|0:d=d+1|0,l=w-d|0,w=((l|0)<0)<<31>>31,!((w|0)<(o|0)|(w|0)==(o|0)&l>>>0>>0))){if(d=h&8,!((c|0)==0&(o|0)==0)){if(d|0&&!(e[r+12>>2]|0)){r=t,e[r>>2]=0,e[r+4>>2]=0,r=t+8|0,e[r>>2]=-1,e[r+4>>2]=-1;return}if((h&16|0)!=0&(k|0)==0){r=t,e[r>>2]=0,e[r+4>>2]=0,r=t+8|0,e[r>>2]=-1,e[r+4>>2]=-1;return}}d&&(e[r+12>>2]=(e[r+8>>2]|0)+c,e[r+16>>2]=C),h&16&&(e[D>>2]=(e[r+20>>2]|0)+c),r=t,e[r>>2]=0,e[r+4>>2]=0,r=t+8|0,e[r>>2]=c,e[r+4>>2]=o;return}r=t,e[r>>2]=0,e[r+4>>2]=0,r=t+8|0,e[r>>2]=-1,e[r+4>>2]=-1}function sl(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0,o=o+8|0,Vi[e[(e[r>>2]|0)+16>>2]&15](t,r,e[o>>2]|0,e[o+4>>2]|0,0,l)}function ol(t){t=t|0;var r=0,o=0,l=0,c=0;return r=t+44|0,o=e[r>>2]|0,l=e[t+24>>2]|0,o>>>0>>0&&(e[r>>2]=l,o=l),!(e[t+48>>2]&8)||(c=t+16|0,r=e[c>>2]|0,l=t+12|0,r>>>0>>0?(l=e[l>>2]|0,e[c>>2]=o,r=o):l=e[l>>2]|0,l>>>0>=r>>>0)?(t=-1,t|0):(t=F[l>>0]|0,t|0)}function al(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;if(l=t+44|0,o=e[l>>2]|0,c=e[t+24>>2]|0,o>>>0>>0&&(e[l>>2]=c,o=c),w=t+8|0,l=e[w>>2]|0,C=t+12|0,h=e[C>>2]|0,d=l,l>>>0>=h>>>0)return t=-1,t|0;if((r|0)==-1)return e[w>>2]=l,e[C>>2]=h+-1,e[t+16>>2]=o,t=0,t|0;if(e[t+48>>2]&16)c=r&255,l=h+-1|0;else if(c=r&255,l=h+-1|0,c<<24>>24!=(S[l>>0]|0))return t=-1,t|0;return e[w>>2]=d,e[C>>2]=l,e[t+16>>2]=o,S[l>>0]=c,t=r,t|0}function ll(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0;if(Q=b,b=b+16|0,k=Q,(r|0)==-1)return t=0,b=Q,t|0;N=t+12|0,R=t+8|0,_=(e[N>>2]|0)-(e[R>>2]|0)|0,U=t+24|0,o=e[U>>2]|0,D=t+28|0,l=e[D>>2]|0;do if((o|0)==(l|0)){if(w=t+48|0,!(e[w>>2]&16))return t=-1,b=Q,t|0;if(C=t+20|0,d=e[C>>2]|0,c=o-d|0,h=t+44|0,d=(e[h>>2]|0)-d|0,l=t+32|0,g=0,Ae(67,l|0,0),o=g,g=0,!(o&1)&&(S[l>>0]&1?o=(e[l>>2]&-2)+-1|0:o=10,g=0,xe(8,l|0,o|0,0),o=g,g=0,!(o&1))){o=S[l>>0]|0,o&1?(l=e[t+40>>2]|0,o=e[t+36>>2]|0):(l=l+1|0,o=(o&255)>>>1),K=l+o|0,e[C>>2]=l,e[D>>2]=K,C=l+c|0,e[U>>2]=C,o=l+d|0,e[h>>2]=o,l=K;break}return K=j(0)|0,K0(K|0)|0,ei(),K=-1,b=Q,K|0}else K=t+44|0,w=t+48|0,h=K,C=o,o=e[K>>2]|0;while(!1);return d=C+1|0,e[k>>2]=d,c=e[(d>>>0>>0?h:k)>>2]|0,e[h>>2]=c,e[w>>2]&8&&(o=t+32|0,S[o>>0]&1?o=e[t+40>>2]|0:o=o+1|0,e[R>>2]=o,e[N>>2]=o+_,e[t+16>>2]=c),(C|0)==(l|0)?(K=U0[e[(e[t>>2]|0)+52>>2]&63](t,r&255)|0,b=Q,K|0):(e[U>>2]=d,S[C>>0]=r,K=r&255,b=Q,K|0)}function ul(t){t=t|0;var r=0,o=0;e[t>>2]=36200,r=t+56|0,e[r>>2]=36220,o=t+4|0,e[o>>2]=36236,de(t+36|0),wt(o),tt(r)}function cl(t){t=t|0;var r=0,o=0;e[t>>2]=36200,r=t+56|0,e[r>>2]=36220,o=t+4|0,e[o>>2]=36236,de(t+36|0),wt(o),tt(r),he(t)}function hl(t){t=t|0;var r=0,o=0,l=0,c=0;c=e[(e[t>>2]|0)+-12>>2]|0,r=t+c|0,e[r>>2]=36200,o=t+(c+56)|0,e[o>>2]=36220,l=t+(c+4)|0,e[l>>2]=36236,de(t+(c+36)|0),wt(l),tt(o),he(r)}function dl(t){t=t|0;var r=0,o=0,l=0;e[t>>2]=36388,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,l&&(r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l))}function pl(t){t=t|0;var r=0,o=0,l=0;if(e[t>>2]=36388,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,!l){he(t);return}r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l),he(t)}function ml(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;if(c=t+36|0,!(e[c>>2]|0)){w=t+40|0,jr(t,r,e[w>>2]|0,o,l),e[w>>2]=(e[w>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}C=t+4|0,h=o<<1,d=ee(h,e[(e[C>>2]|0)+16>>2]|0)|0,w=t+20|0,jr(t,r,e[w>>2]|0,o,l),r=e[C>>2]|0,(e[r+28>>2]|0)==536870912&&ti(e[w>>2]|0,ee(h,e[r+16>>2]|0)|0),C=e[c>>2]|0,(Yt[e[(e[C>>2]|0)+48>>2]&63](C,e[w>>2]|0,d)|0)!=(d|0)&&(r=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,r|0,3,35648),C=g,g=0,C&1?(C=j()|0,Tt(r|0),le(C|0)):Qt(r|0,824,96))}function gl(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0;if(c=e[t+36>>2]|0,c){Sl(t,c,r,o,l);return}else{c=t+40|0,zn(t,e[c>>2]|0,r,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}}function zn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0;w=t+4|0,h=e[w>>2]|0;do if(!(S[h+32>>0]|0))C=r;else{if(t=t+8|0,o0(e[t>>2]|0,r|0,l*6|0)|0,h=e[w>>2]|0,d=e[h+16>>2]|0,(l|0)<=0){C=e[t>>2]|0;break}for(t=e[t>>2]|0,h=t,r=0;C=h+4|0,D=E[h>>1]|0,E[h>>1]=E[C>>1]|0,E[C>>1]=D,r=r+1|0,(r|0)!=(l|0);)h=h+(d<<1)|0;C=t,h=e[w>>2]|0}while(!1);switch(e[h+16>>2]|0){case 3:{if((e[h+24>>2]|0)==2){if((l|0)>0)h=0;else return;do w=M[C+(h*6|0)+2>>1]|0,c=32768-w+(M[C+(h*6|0)+4>>1]|0)|0,D=(M[C+(h*6|0)>>1]|0)-w+32768|0,E[o+(h*6|0)>>1]=w+49152+(((c&65535)+(D&65535)|0)>>>2),E[o+(h*6|0)+2>>1]=c,E[o+(h*6|0)+4>>1]=D,h=h+1|0;while((h|0)!=(l|0));return}if(h=(c|0)<(l|0)?c:l,(h|0)<=0)return;t=c<<1,r=0;do w=M[C+(r*6|0)+2>>1]|0,l=32768-w+(M[C+(r*6|0)+4>>1]|0)|0,D=(M[C+(r*6|0)>>1]|0)-w+32768|0,E[o+(r<<1)>>1]=w+49152+(((l&65535)+(D&65535)|0)>>>2),E[o+(r+c<<1)>>1]=l,E[o+(r+t<<1)>>1]=D,r=r+1|0;while((r|0)!=(h|0));return}case 4:{if((e[h+24>>2]|0)!=1||(h=(c|0)<(l|0)?c:l,(h|0)<=0))return;t=c<<1,r=c*3|0,d=0;do D=E[C+(d<<3)+6>>1]|0,k=M[C+(d<<3)+2>>1]|0,w=32768-k+(M[C+(d<<3)+4>>1]|0)|0,l=(M[C+(d<<3)>>1]|0)-k+32768|0,E[o+(d<<1)>>1]=k+49152+(((w&65535)+(l&65535)|0)>>>2),E[o+(d+c<<1)>>1]=w,E[o+(d+t<<1)>>1]=l,E[o+(d+r<<1)>>1]=D,d=d+1|0;while((d|0)!=(h|0));return}default:return}}function Sl(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;N=b,b=b+176|0,R=N+152|0,U=N+16|0,_=N,C=t+4|0,h=e[C>>2]|0,k=l<<1,d=ee(k,e[h+16>>2]|0)|0;do if(d){for(w=t+20|0;h=Yt[e[(e[r>>2]|0)+32>>2]&63](r,e[w>>2]|0,d)|0,!!h;)if((d|0)==(h|0)){D=26;break}else d=d-h|0;if((D|0)==26){h=e[C>>2]|0;break}D=U+56|0,C=U+4|0,e[U>>2]=36160,e[D>>2]=36180,g=0,Ae(62,U+56|0,C|0),N=g,g=0,N&1&&(U=j()|0,tt(D),le(U|0)),e[U+128>>2]=0,e[U+132>>2]=-1,e[U>>2]=36200,e[U+56>>2]=36220,g=0,ue(180,C|0),N=g,g=0;do if(N&1)h=j()|0;else{if(e[C>>2]=36236,r=U+36|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[U+52>>2]=16,e[R>>2]=0,e[R+4>>2]=0,e[R+8>>2]=0,g=0,Ae(63,C|0,R|0),N=g,g=0,N&1){h=j()|0,de(R),de(r),wt(C);break}de(R),g=0,h=Ve(28,U|0,49029,57)|0,R=g,g=0,!(R&1)&&(g=0,be(36,h|0,0)|0,R=g,g=0,!(R&1))&&(w=Ct(16)|0,g=0,Ae(64,_|0,C|0),R=g,g=0,R&1?h=j()|0:(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,w|0,3,35648,_|0),R=g,g=0,R&1?d=1:(g=0,xe(6,w|0,824,96),g=0,d=0),h=j()|0,de(_),d||(_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0))),Tt(w|0),_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)),_=j()|0,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)}while(!1);U=h,tt(D),le(U|0)}while(!1);if(d=t+20|0,(e[h+28>>2]|0)!=536870912){U=e[d>>2]|0,zn(t,U,o,l,c),b=N;return}ti(e[d>>2]|0,ee(k,e[h+16>>2]|0)|0),U=e[d>>2]|0,zn(t,U,o,l,c),b=N}function jr(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;C=t+4|0,t=e[C>>2]|0;e:do switch(e[t+16>>2]|0){case 3:{if((e[t+24>>2]|0)==2){if((l|0)>0)t=0;else break e;for(;;)if(w=M[r+(t*6|0)+2>>1]|0,d=M[r+(t*6|0)+4>>1]|0,c=(M[r+(t*6|0)>>1]|0)-((d+w|0)>>>2)+16384|0,E[o+(t*6|0)>>1]=d+32768+c,E[o+(t*6|0)+2>>1]=c,E[o+(t*6|0)+4>>1]=w+32768+c,t=t+1|0,(t|0)==(l|0))break e}if(t=(l|0)<(c|0)?l:c,(t|0)>0){h=c<<1,d=0;do D=M[r+(d+c<<1)>>1]|0,k=M[r+(d+h<<1)>>1]|0,w=(M[r+(d<<1)>>1]|0)-((k+D|0)>>>2)+16384|0,E[o+(d*6|0)>>1]=k+32768+w,E[o+(d*6|0)+2>>1]=w,E[o+(d*6|0)+4>>1]=D+32768+w,d=d+1|0;while((d|0)!=(t|0))}break}case 4:{if((e[t+24>>2]|0)==1&&(w=(l|0)<(c|0)?l:c,(w|0)>0)){t=c<<1,h=c*3|0,d=0;do D=M[r+(d+c<<1)>>1]|0,N=M[r+(d+t<<1)>>1]|0,k=(M[r+(d<<1)>>1]|0)-((N+D|0)>>>2)+16384|0,R=E[r+(d+h<<1)>>1]|0,_=v0(k&65535|0,0,16)|0,D=D+32768+k|ye,R=v0(R&65535|0,0,48)|0,R=_|N+32768+k&65535|R,D=D&65535|ye,k=o+(d<<3)|0,N=k,E[N>>1]=R,E[N+2>>1]=R>>>16,k=k+4|0,E[k>>1]=D,E[k+2>>1]=D>>>16,d=d+1|0;while((d|0)!=(w|0))}break}default:}while(!1);if(t=e[C>>2]|0,!!(S[t+32>>0]|0)&&(d=e[t+16>>2]|0,!((l|0)<=0)))for(t=o,h=0;_=t+4|0,R=E[t>>1]|0,E[t>>1]=E[_>>1]|0,E[_>>1]=R,h=h+1|0,(h|0)!=(l|0);)t=t+(d<<1)|0}function Al(t){t=t|0;var r=0,o=0,l=0;e[t>>2]=36412,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,l&&(r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l))}function vl(t){t=t|0;var r=0,o=0,l=0;if(e[t>>2]=36412,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,!l){he(t);return}r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l),he(t)}function xl(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;if(c=t+36|0,!(e[c>>2]|0)){w=t+40|0,Xr(t,r,e[w>>2]|0,o,l),e[w>>2]=(e[w>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}C=t+4|0,h=o<<1,d=ee(h,e[(e[C>>2]|0)+16>>2]|0)|0,w=t+20|0,Xr(t,r,e[w>>2]|0,o,l),r=e[C>>2]|0,(e[r+28>>2]|0)==536870912&&ti(e[w>>2]|0,ee(h,e[r+16>>2]|0)|0),C=e[c>>2]|0,(Yt[e[(e[C>>2]|0)+48>>2]&63](C,e[w>>2]|0,d)|0)!=(d|0)&&(r=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,r|0,3,35648),C=g,g=0,C&1?(C=j()|0,Tt(r|0),le(C|0)):Qt(r|0,824,96))}function wl(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0;if(c=e[t+36>>2]|0,c){yl(t,c,r,o,l);return}else{c=t+40|0,Gn(t,e[c>>2]|0,r,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}}function Gn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0;w=t+4|0,h=e[w>>2]|0;do if(!(S[h+32>>0]|0))C=r;else{if(t=t+8|0,o0(e[t>>2]|0,r|0,l*6|0)|0,h=e[w>>2]|0,d=e[h+16>>2]|0,(l|0)<=0){C=e[t>>2]|0;break}for(t=e[t>>2]|0,h=t,r=0;C=h+4|0,D=E[h>>1]|0,E[h>>1]=E[C>>1]|0,E[C>>1]=D,r=r+1|0,(r|0)!=(l|0);)h=h+(d<<1)|0;C=t,h=e[w>>2]|0}while(!1);switch(e[h+16>>2]|0){case 3:{if((e[h+24>>2]|0)==2){if((l|0)>0)h=0;else return;do d=M[C+(h*6|0)>>1]|0,c=E[C+(h*6|0)+2>>1]|0,w=c&65535,D=(M[C+(h*6|0)+4>>1]|0)+32768-((w+d|0)>>>1)&65535,E[o+(h*6|0)>>1]=d+32768-w,E[o+(h*6|0)+2>>1]=c,E[o+(h*6|0)+4>>1]=D,h=h+1|0;while((h|0)!=(l|0));return}if(h=(c|0)<(l|0)?c:l,(h|0)<=0)return;t=c<<1,r=0;do l=E[C+(r*6|0)+2>>1]|0,d=M[C+(r*6|0)>>1]|0,w=l&65535,D=(M[C+(r*6|0)+4>>1]|0)+32768-((w+d|0)>>>1)&65535,E[o+(r<<1)>>1]=d+32768-w,E[o+(r+c<<1)>>1]=l,E[o+(r+t<<1)>>1]=D,r=r+1|0;while((r|0)!=(h|0));return}case 4:{if((e[h+24>>2]|0)!=1||(h=(c|0)<(l|0)?c:l,(h|0)<=0))return;t=c<<1,r=c*3|0,d=0;do w=E[C+(d<<3)+2>>1]|0,D=E[C+(d<<3)+6>>1]|0,N=M[C+(d<<3)>>1]|0,k=w&65535,l=(M[C+(d<<3)+4>>1]|0)+32768-((k+N|0)>>>1)&65535,E[o+(d<<1)>>1]=N+32768-k,E[o+(d+c<<1)>>1]=w,E[o+(d+t<<1)>>1]=l,E[o+(d+r<<1)>>1]=D,d=d+1|0;while((d|0)!=(h|0));return}default:return}}function yl(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;N=b,b=b+176|0,R=N+152|0,U=N+16|0,_=N,C=t+4|0,h=e[C>>2]|0,k=l<<1,d=ee(k,e[h+16>>2]|0)|0;do if(d){for(w=t+20|0;h=Yt[e[(e[r>>2]|0)+32>>2]&63](r,e[w>>2]|0,d)|0,!!h;)if((d|0)==(h|0)){D=26;break}else d=d-h|0;if((D|0)==26){h=e[C>>2]|0;break}D=U+56|0,C=U+4|0,e[U>>2]=36160,e[D>>2]=36180,g=0,Ae(62,U+56|0,C|0),N=g,g=0,N&1&&(U=j()|0,tt(D),le(U|0)),e[U+128>>2]=0,e[U+132>>2]=-1,e[U>>2]=36200,e[U+56>>2]=36220,g=0,ue(180,C|0),N=g,g=0;do if(N&1)h=j()|0;else{if(e[C>>2]=36236,r=U+36|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[U+52>>2]=16,e[R>>2]=0,e[R+4>>2]=0,e[R+8>>2]=0,g=0,Ae(63,C|0,R|0),N=g,g=0,N&1){h=j()|0,de(R),de(r),wt(C);break}de(R),g=0,h=Ve(28,U|0,49029,57)|0,R=g,g=0,!(R&1)&&(g=0,be(36,h|0,0)|0,R=g,g=0,!(R&1))&&(w=Ct(16)|0,g=0,Ae(64,_|0,C|0),R=g,g=0,R&1?h=j()|0:(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,w|0,3,35648,_|0),R=g,g=0,R&1?d=1:(g=0,xe(6,w|0,824,96),g=0,d=0),h=j()|0,de(_),d||(_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0))),Tt(w|0),_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)),_=j()|0,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)}while(!1);U=h,tt(D),le(U|0)}while(!1);if(d=t+20|0,(e[h+28>>2]|0)!=536870912){U=e[d>>2]|0,Gn(t,U,o,l,c),b=N;return}ti(e[d>>2]|0,ee(k,e[h+16>>2]|0)|0),U=e[d>>2]|0,Gn(t,U,o,l,c),b=N}function Xr(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;C=t+4|0,t=e[C>>2]|0;e:do switch(e[t+16>>2]|0){case 3:{if((e[t+24>>2]|0)==2){if((l|0)>0)t=0;else break e;for(;;)if(w=E[r+(t*6|0)+2>>1]|0,c=w&65535,d=(M[r+(t*6|0)>>1]|0)+32768+c|0,c=(M[r+(t*6|0)+4>>1]|0)+32768+(((d&65535)+c|0)>>>1)&65535,E[o+(t*6|0)>>1]=d,E[o+(t*6|0)+2>>1]=w,E[o+(t*6|0)+4>>1]=c,t=t+1|0,(t|0)==(l|0))break e}if(t=(l|0)<(c|0)?l:c,(t|0)>0){h=c<<1,d=0;do D=E[r+(d+c<<1)>>1]|0,w=D&65535,k=(M[r+(d<<1)>>1]|0)+32768+w|0,w=(M[r+(d+h<<1)>>1]|0)+32768+(((k&65535)+w|0)>>>1)&65535,E[o+(d*6|0)>>1]=k,E[o+(d*6|0)+2>>1]=D,E[o+(d*6|0)+4>>1]=w,d=d+1|0;while((d|0)!=(t|0))}break}case 4:{if((e[t+24>>2]|0)==1&&(w=(l|0)<(c|0)?l:c,(w|0)>0)){t=c<<1,h=c*3|0,d=0;do k=E[r+(d+c<<1)>>1]|0,D=k&65535,N=(M[r+(d<<1)>>1]|0)+32768+D&65535,D=(M[r+(d+t<<1)>>1]|0)+32768+((N+D|0)>>>1)|0,R=E[r+(d+h<<1)>>1]|0,k=v0(k&65535|0,0,16)|0,D=ye|D,R=v0(R&65535|0,0,48)|0,R=N|k|R,D=D&65535|ye,k=o+(d<<3)|0,N=k,E[N>>1]=R,E[N+2>>1]=R>>>16,k=k+4|0,E[k>>1]=D,E[k+2>>1]=D>>>16,d=d+1|0;while((d|0)!=(w|0))}break}default:}while(!1);if(t=e[C>>2]|0,!!(S[t+32>>0]|0)&&(d=e[t+16>>2]|0,!((l|0)<=0)))for(t=o,h=0;R=t+4|0,N=E[t>>1]|0,E[t>>1]=E[R>>1]|0,E[R>>1]=N,h=h+1|0,(h|0)!=(l|0);)t=t+(d<<1)|0}function Cl(t){t=t|0;var r=0,o=0,l=0;e[t>>2]=36436,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,l&&(r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l))}function Tl(t){t=t|0;var r=0,o=0,l=0;if(e[t>>2]=36436,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,!l){he(t);return}r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l),he(t)}function Il(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;if(c=t+36|0,!(e[c>>2]|0)){w=t+40|0,Zr(t,r,e[w>>2]|0,o,l),e[w>>2]=(e[w>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}C=t+4|0,h=o<<1,d=ee(h,e[(e[C>>2]|0)+16>>2]|0)|0,w=t+20|0,Zr(t,r,e[w>>2]|0,o,l),r=e[C>>2]|0,(e[r+28>>2]|0)==536870912&&ti(e[w>>2]|0,ee(h,e[r+16>>2]|0)|0),C=e[c>>2]|0,(Yt[e[(e[C>>2]|0)+48>>2]&63](C,e[w>>2]|0,d)|0)!=(d|0)&&(r=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,r|0,3,35648),C=g,g=0,C&1?(C=j()|0,Tt(r|0),le(C|0)):Qt(r|0,824,96))}function El(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0;if(c=e[t+36>>2]|0,c){kl(t,c,r,o,l);return}else{c=t+40|0,qn(t,e[c>>2]|0,r,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}}function qn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0;w=t+4|0,h=e[w>>2]|0;do if(!(S[h+32>>0]|0))C=r;else{if(t=t+8|0,o0(e[t>>2]|0,r|0,l*6|0)|0,h=e[w>>2]|0,d=e[h+16>>2]|0,(l|0)<=0){C=e[t>>2]|0;break}for(t=e[t>>2]|0,h=t,r=0;C=h+4|0,D=E[h>>1]|0,E[h>>1]=E[C>>1]|0,E[C>>1]=D,r=r+1|0,(r|0)!=(l|0);)h=h+(d<<1)|0;C=t,h=e[w>>2]|0}while(!1);switch(e[h+16>>2]|0){case 3:{if((e[h+24>>2]|0)==2){if((l|0)>0)h=0;else return;do c=E[C+(h*6|0)+2>>1]|0,w=c&65535,D=32768-w+(M[C+(h*6|0)+4>>1]|0)&65535,E[o+(h*6|0)>>1]=(M[C+(h*6|0)>>1]|0)+32768-w,E[o+(h*6|0)+2>>1]=c,E[o+(h*6|0)+4>>1]=D,h=h+1|0;while((h|0)!=(l|0));return}if(h=(c|0)<(l|0)?c:l,(h|0)<=0)return;t=c<<1,r=0;do l=E[C+(r*6|0)+2>>1]|0,w=l&65535,D=32768-w+(M[C+(r*6|0)+4>>1]|0)&65535,E[o+(r<<1)>>1]=(M[C+(r*6|0)>>1]|0)+32768-w,E[o+(r+c<<1)>>1]=l,E[o+(r+t<<1)>>1]=D,r=r+1|0;while((r|0)!=(h|0));return}case 4:{if((e[h+24>>2]|0)!=1||(h=(c|0)<(l|0)?c:l,(h|0)<=0))return;t=c<<1,r=c*3|0,d=0;do w=E[C+(d<<3)+2>>1]|0,D=E[C+(d<<3)+6>>1]|0,k=w&65535,l=32768-k+(M[C+(d<<3)+4>>1]|0)&65535,E[o+(d<<1)>>1]=(M[C+(d<<3)>>1]|0)+32768-k,E[o+(d+c<<1)>>1]=w,E[o+(d+t<<1)>>1]=l,E[o+(d+r<<1)>>1]=D,d=d+1|0;while((d|0)!=(h|0));return}default:return}}function kl(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;N=b,b=b+176|0,R=N+152|0,U=N+16|0,_=N,C=t+4|0,h=e[C>>2]|0,k=l<<1,d=ee(k,e[h+16>>2]|0)|0;do if(d){for(w=t+20|0;h=Yt[e[(e[r>>2]|0)+32>>2]&63](r,e[w>>2]|0,d)|0,!!h;)if((d|0)==(h|0)){D=26;break}else d=d-h|0;if((D|0)==26){h=e[C>>2]|0;break}D=U+56|0,C=U+4|0,e[U>>2]=36160,e[D>>2]=36180,g=0,Ae(62,U+56|0,C|0),N=g,g=0,N&1&&(U=j()|0,tt(D),le(U|0)),e[U+128>>2]=0,e[U+132>>2]=-1,e[U>>2]=36200,e[U+56>>2]=36220,g=0,ue(180,C|0),N=g,g=0;do if(N&1)h=j()|0;else{if(e[C>>2]=36236,r=U+36|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[U+52>>2]=16,e[R>>2]=0,e[R+4>>2]=0,e[R+8>>2]=0,g=0,Ae(63,C|0,R|0),N=g,g=0,N&1){h=j()|0,de(R),de(r),wt(C);break}de(R),g=0,h=Ve(28,U|0,49029,57)|0,R=g,g=0,!(R&1)&&(g=0,be(36,h|0,0)|0,R=g,g=0,!(R&1))&&(w=Ct(16)|0,g=0,Ae(64,_|0,C|0),R=g,g=0,R&1?h=j()|0:(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,w|0,3,35648,_|0),R=g,g=0,R&1?d=1:(g=0,xe(6,w|0,824,96),g=0,d=0),h=j()|0,de(_),d||(_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0))),Tt(w|0),_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)),_=j()|0,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)}while(!1);U=h,tt(D),le(U|0)}while(!1);if(d=t+20|0,(e[h+28>>2]|0)!=536870912){U=e[d>>2]|0,qn(t,U,o,l,c),b=N;return}ti(e[d>>2]|0,ee(k,e[h+16>>2]|0)|0),U=e[d>>2]|0,qn(t,U,o,l,c),b=N}function Zr(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;C=t+4|0,t=e[C>>2]|0;e:do switch(e[t+16>>2]|0){case 3:{if((e[t+24>>2]|0)==2){if((l|0)>0)t=0;else break e;for(;;)if(w=E[r+(t*6|0)+2>>1]|0,d=w&65535,c=d+32768+(M[r+(t*6|0)+4>>1]|0)&65535,E[o+(t*6|0)>>1]=(M[r+(t*6|0)>>1]|0)+32768+d,E[o+(t*6|0)+2>>1]=w,E[o+(t*6|0)+4>>1]=c,t=t+1|0,(t|0)==(l|0))break e}if(t=(l|0)<(c|0)?l:c,(t|0)>0){h=c<<1,d=0;do D=E[r+(d+c<<1)>>1]|0,k=D&65535,w=k+32768+(M[r+(d+h<<1)>>1]|0)&65535,E[o+(d*6|0)>>1]=(M[r+(d<<1)>>1]|0)+32768+k,E[o+(d*6|0)+2>>1]=D,E[o+(d*6|0)+4>>1]=w,d=d+1|0;while((d|0)!=(t|0))}break}case 4:{if((e[t+24>>2]|0)==1&&(w=(l|0)<(c|0)?l:c,(w|0)>0)){t=c<<1,h=c*3|0,d=0;do k=E[r+(d+c<<1)>>1]|0,D=k&65535,N=(M[r+(d<<1)>>1]|0)+32768+D|0,D=D+32768+(M[r+(d+t<<1)>>1]|0)|0,R=E[r+(d+h<<1)>>1]|0,k=v0(k&65535|0,0,16)|0,D=ye|D,R=v0(R&65535|0,0,48)|0,R=N&65535|k|R,D=D&65535|ye,k=o+(d<<3)|0,N=k,E[N>>1]=R,E[N+2>>1]=R>>>16,k=k+4|0,E[k>>1]=D,E[k+2>>1]=D>>>16,d=d+1|0;while((d|0)!=(w|0))}break}default:}while(!1);if(t=e[C>>2]|0,!!(S[t+32>>0]|0)&&(d=e[t+16>>2]|0,!((l|0)<=0)))for(t=o,h=0;R=t+4|0,N=E[t>>1]|0,E[t>>1]=E[R>>1]|0,E[R>>1]=N,h=h+1|0,(h|0)!=(l|0);)t=t+(d<<1)|0}function Dl(t){t=t|0;var r=0,o=0,l=0;e[t>>2]=36460,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,l&&(r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l))}function bl(t){t=t|0;var r=0,o=0,l=0;if(e[t>>2]=36460,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),l=e[t+8>>2]|0,!l){he(t);return}r=t+12|0,o=e[r>>2]|0,(o|0)!=(l|0)&&(e[r>>2]=o+(~((o+-2-l|0)>>>1)<<1)),he(l),he(t)}function Nl(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;if(c=t+36|0,!(e[c>>2]|0)){w=t+40|0,Jr(t,r,e[w>>2]|0,o,l),e[w>>2]=(e[w>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}C=t+4|0,h=o<<1,d=ee(h,e[(e[C>>2]|0)+16>>2]|0)|0,w=t+20|0,Jr(t,r,e[w>>2]|0,o,l),r=e[C>>2]|0,(e[r+28>>2]|0)==536870912&&ti(e[w>>2]|0,ee(h,e[r+16>>2]|0)|0),C=e[c>>2]|0,(Yt[e[(e[C>>2]|0)+48>>2]&63](C,e[w>>2]|0,d)|0)!=(d|0)&&(r=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,r|0,3,35648),C=g,g=0,C&1?(C=j()|0,Tt(r|0),le(C|0)):Qt(r|0,824,96))}function Fl(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0;if(c=e[t+36>>2]|0,c){Rl(t,c,r,o,l);return}else{c=t+40|0,Wn(t,e[c>>2]|0,r,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}}function Wn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0;w=t+4|0,h=e[w>>2]|0;do if(!(S[h+32>>0]|0))C=r;else{if(t=t+8|0,o0(e[t>>2]|0,r|0,l*6|0)|0,h=e[w>>2]|0,d=e[h+16>>2]|0,(l|0)<=0){C=e[t>>2]|0;break}for(t=e[t>>2]|0,h=t,r=0;C=h+4|0,D=E[h>>1]|0,E[h>>1]=E[C>>1]|0,E[C>>1]=D,r=r+1|0,(r|0)!=(l|0);)h=h+(d<<1)|0;C=t,h=e[w>>2]|0}while(!1);switch(e[h+16>>2]|0){case 3:{if((e[h+24>>2]|0)==2){if((l|0)>0)h=0;else return;do c=E[C+(h*6|0)+2>>1]|0,D=E[C+(h*6|0)+4>>1]|0,E[o+(h*6|0)>>1]=E[C+(h*6|0)>>1]|0,E[o+(h*6|0)+2>>1]=c,E[o+(h*6|0)+4>>1]=D,h=h+1|0;while((h|0)!=(l|0));return}if(h=(c|0)<(l|0)?c:l,(h|0)<=0)return;t=c<<1,r=0;do l=E[C+(r*6|0)+2>>1]|0,D=E[C+(r*6|0)+4>>1]|0,E[o+(r<<1)>>1]=E[C+(r*6|0)>>1]|0,E[o+(r+c<<1)>>1]=l,E[o+(r+t<<1)>>1]=D,r=r+1|0;while((r|0)!=(h|0));return}case 4:{if((e[h+24>>2]|0)!=1||(h=(c|0)<(l|0)?c:l,(h|0)<=0))return;t=c<<1,r=c*3|0,d=0;do w=E[C+(d<<3)+2>>1]|0,l=E[C+(d<<3)+4>>1]|0,D=E[C+(d<<3)+6>>1]|0,E[o+(d<<1)>>1]=E[C+(d<<3)>>1]|0,E[o+(d+c<<1)>>1]=w,E[o+(d+t<<1)>>1]=l,E[o+(d+r<<1)>>1]=D,d=d+1|0;while((d|0)!=(h|0));return}default:return}}function Rl(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;N=b,b=b+176|0,R=N+152|0,U=N+16|0,_=N,C=t+4|0,h=e[C>>2]|0,k=l<<1,d=ee(k,e[h+16>>2]|0)|0;do if(d){for(w=t+20|0;h=Yt[e[(e[r>>2]|0)+32>>2]&63](r,e[w>>2]|0,d)|0,!!h;)if((d|0)==(h|0)){D=26;break}else d=d-h|0;if((D|0)==26){h=e[C>>2]|0;break}D=U+56|0,C=U+4|0,e[U>>2]=36160,e[D>>2]=36180,g=0,Ae(62,U+56|0,C|0),N=g,g=0,N&1&&(U=j()|0,tt(D),le(U|0)),e[U+128>>2]=0,e[U+132>>2]=-1,e[U>>2]=36200,e[U+56>>2]=36220,g=0,ue(180,C|0),N=g,g=0;do if(N&1)h=j()|0;else{if(e[C>>2]=36236,r=U+36|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[U+52>>2]=16,e[R>>2]=0,e[R+4>>2]=0,e[R+8>>2]=0,g=0,Ae(63,C|0,R|0),N=g,g=0,N&1){h=j()|0,de(R),de(r),wt(C);break}de(R),g=0,h=Ve(28,U|0,49029,57)|0,R=g,g=0,!(R&1)&&(g=0,be(36,h|0,0)|0,R=g,g=0,!(R&1))&&(w=Ct(16)|0,g=0,Ae(64,_|0,C|0),R=g,g=0,R&1?h=j()|0:(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,w|0,3,35648,_|0),R=g,g=0,R&1?d=1:(g=0,xe(6,w|0,824,96),g=0,d=0),h=j()|0,de(_),d||(_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0))),Tt(w|0),_=h,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)),_=j()|0,e[U>>2]=36200,e[D>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(D),le(_|0)}while(!1);U=h,tt(D),le(U|0)}while(!1);if(d=t+20|0,(e[h+28>>2]|0)!=536870912){U=e[d>>2]|0,Wn(t,U,o,l,c),b=N;return}ti(e[d>>2]|0,ee(k,e[h+16>>2]|0)|0),U=e[d>>2]|0,Wn(t,U,o,l,c),b=N}function Jr(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;C=t+4|0,t=e[C>>2]|0;e:do switch(e[t+16>>2]|0){case 3:{if((e[t+24>>2]|0)==2){if((l|0)>0)t=0;else break e;for(;;)if(w=E[r+(t*6|0)+2>>1]|0,c=E[r+(t*6|0)+4>>1]|0,E[o+(t*6|0)>>1]=E[r+(t*6|0)>>1]|0,E[o+(t*6|0)+2>>1]=w,E[o+(t*6|0)+4>>1]=c,t=t+1|0,(t|0)==(l|0))break e}if(t=(l|0)<(c|0)?l:c,(t|0)>0){h=c<<1,d=0;do D=E[r+(d+c<<1)>>1]|0,w=E[r+(d+h<<1)>>1]|0,E[o+(d*6|0)>>1]=E[r+(d<<1)>>1]|0,E[o+(d*6|0)+2>>1]=D,E[o+(d*6|0)+4>>1]=w,d=d+1|0;while((d|0)!=(t|0))}break}case 4:{if((e[t+24>>2]|0)==1&&(w=(l|0)<(c|0)?l:c,(w|0)>0)){t=c<<1,h=c*3|0,d=0;do D=E[r+(d<<1)>>1]|0,R=E[r+(d+h<<1)>>1]|0,k=M[r+(d+t<<1)>>1]|0,N=v0(M[r+(d+c<<1)>>1]|0,0,16)|0,k=ye|k,R=v0(R&65535|0,0,48)|0,R=N|D&65535|R,k=k&65535|ye,D=o+(d<<3)|0,N=D,E[N>>1]=R,E[N+2>>1]=R>>>16,D=D+4|0,E[D>>1]=k,E[D+2>>1]=k>>>16,d=d+1|0;while((d|0)!=(w|0))}break}default:}while(!1);if(t=e[C>>2]|0,!!(S[t+32>>0]|0)&&(d=e[t+16>>2]|0,!((l|0)<=0)))for(t=o,h=0;R=t+4|0,N=E[t>>1]|0,E[t>>1]=E[R>>1]|0,E[R>>1]=N,h=h+1|0,(h|0)!=(l|0);)t=t+(d<<1)|0}function Ml(t){t=t|0}function _l(t){t=t|0,he(t)}function Pl(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0,o=ee(e[t+8>>2]|0,o)|0,t=e[t+4>>2]|0,(Yt[e[(e[t>>2]|0)+48>>2]&63](t,r,o)|0)!=(o|0)&&(l=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,l|0,3,35648),t=g,g=0,t&1?(t=j()|0,Tt(l|0),le(t|0)):Qt(l|0,824,96))}function Ll(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0;k=b,b=b+16|0,D=k,C=t+8|0,c=e[C>>2]|0,l=ee(c,o)|0;do if(l){for(d=t+4|0,h=l;c=e[d>>2]|0,c=Yt[e[(e[c>>2]|0)+32>>2]&63](c,r,h)|0,!!c;)if(l=h-c|0,(h|0)==(c|0)){w=11;break}else h=l;if((w|0)==11){c=e[C>>2]|0,h=l;break}l=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,l|0,3,35648),t=g,g=0,t&1?(t=j()|0,Tt(l|0),le(t|0)):Qt(l|0,824,96)}else h=0;while(!1);if((c|0)==2&&(ti(r,o<<1),c=e[C>>2]|0),l=e[t+12>>2]|0,(l|0)<=(ee(c,o)|0)){b=k;return}t=e[t+4>>2]|0,Vi[e[(e[t>>2]|0)+16>>2]&15](D,t,l-h|0,0,1,24),b=k}function Ol(t){t=t|0,he(t)}function $l(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0,l=t+4|0,o0(e[l>>2]|0,r|0,ee(e[t+8>>2]|0,o)|0)|0,e[l>>2]=(e[l>>2]|0)+(e[t+12>>2]|0)}function Bl(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0,l=t+4|0,o0(r|0,e[l>>2]|0,ee(e[t+8>>2]|0,o)|0)|0,e[l>>2]=(e[l>>2]|0)+(e[t+12>>2]|0)}function Y0(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;e[t+112>>2]=0,e[t+108>>2]=0,D=e[r>>2]|0,c=D;do if(D)if(d=t+92|0,D=t+96|0,w=e[D>>2]|0,C=e[d>>2]|0,o=C,l=w-o|0,l>>>0>=4e4?(l>>>0>4e4&&(h=C+4e4|0,(w|0)!=(h|0))&&(e[D>>2]=h),h=o):(vi(d,4e4-l|0),h=e[d>>2]|0,c=e[r>>2]|0),o=t+116|0,e[o>>2]=h,w=t+124|0,e[w>>2]=h,C=t+104|0,e[C>>2]=c,l=c,c){if((e[l+12>>2]|0)==(e[l+16>>2]|0)){if(r=(Dt[e[(e[c>>2]|0)+36>>2]&127](l)|0)==-1,l=e[w>>2]|0,r)break;c=e[o>>2]|0}else l=h,c=h;if(d=l-c|0,d>>>0<=64){if(h=t+92|0,(l|0)==(c|0))l=c;else{l=c,c=0;do S[(e[h>>2]|0)+c>>0]=S[l+c>>0]|0,c=c+1|0,l=e[o>>2]|0;while(c>>>0>>0);c=e[w>>2]|0}h=e[h>>2]|0,r=h,k=r-l|0,e[o>>2]=h,l=c+k|0,e[w>>2]=l,h=t+120|0,e[h>>2]=(e[h>>2]|0)+k,C=e[C>>2]|0,l=Yt[e[(e[C>>2]|0)+32>>2]&63](C,l,(e[D>>2]|0)-(r+d)|0)|0,l=(e[w>>2]|0)+l|0,e[w>>2]=l}}else l=h;else e[t+104>>2]=0,l=e[r+4>>2]|0,o=t+116|0,e[o>>2]=l,l=l+(e[r+8>>2]|0)|0,e[t+124>>2]=l;while(!1);if(o=e[o>>2]|0,o>>>0>=l>>>0){D=o,k=t+120|0,e[k>>2]=D,P0(t);return}for(;;){if((S[o>>0]|0)==-1){l=20;break}if(o=o+1|0,o>>>0>=l>>>0){l=20;break}}if((l|0)==20){k=t+120|0,e[k>>2]=o,P0(t);return}}function vi(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(C=t+8|0,c=e[C>>2]|0,D=t+4|0,o=e[D>>2]|0,l=o,(c-l|0)>>>0>=r>>>0){do S[o>>0]=0,o=(e[D>>2]|0)+1|0,e[D>>2]=o,r=r+-1|0;while(r|0);return}o=e[t>>2]|0,h=l-o+r|0,(h|0)<0&&(pi(t),c=e[C>>2]|0,o=e[t>>2]|0),l=c-o|0,l>>>0<1073741823?(l=l<<1,l=l>>>0>>0?h:l,o=(e[D>>2]|0)-o|0,l?w=8:(c=0,d=0,h=o)):(l=2147483647,o=(e[D>>2]|0)-o|0,w=8),(w|0)==8&&(c=l,d=Xe(l)|0,h=o),o=d+h|0,c=d+c|0,l=o;do S[l>>0]=0,l=o+1|0,o=l,r=r+-1|0;while(r|0);r=e[t>>2]|0,l=(e[D>>2]|0)-r|0,w=d+(h-l)|0,o0(w|0,r|0,l|0)|0,e[t>>2]=w,e[D>>2]=o,e[C>>2]=c,r&&he(r)}function es(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;G=b,b=b+32|0,P=G+12|0,K=G,_=t+180|0,U=(e[_>>2]|0)+4|0,(e[t+32>>2]|0)==1?Q=e[t+24>>2]|0:Q=1,r=ee(Q<<1,U)|0,e[P>>2]=0,O=P+4|0,e[O>>2]=0,e[P+8>>2]=0;do if(r){if((r|0)<0&&(g=0,ue(178,P|0),$=g,g=0,$&1)||(d=6),(d|0)==6&&(o=r<<1,g=0,l=ge(67,o|0)|0,$=g,g=0,!($&1))){e[P>>2]=l,$=l+(r<<1)|0,e[P+8>>2]=$,Jt(l|0,0,o|0)|0,e[O>>2]=$;break}l=j()|0,r=e[P>>2]|0,r||le(l|0),o=e[O>>2]|0,(o|0)!=(r|0)&&(e[O>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),le(l|0)}while(!1);e[K>>2]=0,$=K+4|0,e[$>>2]=0,e[K+8>>2]=0;do if(!Q)d=18;else{if(Q>>>0>1073741823&&(g=0,ue(178,K|0),R=g,g=0,R&1)||(d=16),(d|0)==16&&(c=Q<<2,g=0,h=ge(67,c|0)|0,R=g,g=0,!(R&1))){e[K>>2]=h,d=h+(Q<<2)|0,e[K+8>>2]=d,Jt(h|0,0,c|0)|0,e[$>>2]=d,d=18;break}l=j()|0,r=e[K>>2]|0,o=r,r&&(c=e[$>>2]|0,(c|0)!=(r|0)&&(e[$>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}while(!1);if((d|0)==18){h=t+12|0;e:do if((e[h>>2]|0)>0){d=t+4604|0,w=(ee(Q,U)|0)+1|0,C=t+4608|0,D=t+92|0,k=(Q|0)>0,N=t+4600|0,R=0;t:for(;;){if(o=e[P>>2]|0,r=o+2|0,e[d>>2]=r,o=o+(w<<1)|0,e[C>>2]=o,R&1?(e[d>>2]=o,e[C>>2]=r):r=o,c=e[D>>2]|0,g=0,$e(e[(e[c>>2]|0)+12>>2]|0,c|0,r|0,e[_>>2]|0,U|0),c=g,g=0,c&1){d=28;break}if(k){r=e[d>>2]|0,o=e[C>>2]|0,l=e[K>>2]|0,c=0;do{if(e[N>>2]=e[l+(c<<2)>>2],l=e[_>>2]|0,E[r+(l<<1)>>1]=E[r+(l+-1<<1)>>1]|0,E[o+-2>>1]=E[r>>1]|0,g=0,Ae(68,t|0,0),l=g,g=0,l&1){d=27;break t}l=e[K>>2]|0,e[l+(c<<2)>>2]=e[N>>2],r=(e[d>>2]|0)+(U<<1)|0,e[d>>2]=r,o=(e[C>>2]|0)+(U<<1)|0,e[C>>2]=o,c=c+1|0}while((c|0)<(Q|0))}if(R=R+1|0,(R|0)>=(e[h>>2]|0)){d=40;break e}}if((d|0)==27){l=j()|0;break}else if((d|0)==28){l=j()|0;break}}else d=40;while(!1);do if((d|0)==40){if(g=0,ue(182,t|0),t=g,g=0,t&1){l=j()|0;break}if(r=e[K>>2]|0,o=r,r&&(l=e[$>>2]|0,(l|0)!=(r|0)&&(e[$>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[P>>2]|0,!r){b=G;return}o=e[O>>2]|0,(o|0)!=(r|0)&&(e[O>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),b=G;return}while(!1);r=e[K>>2]|0,o=r,r&&(c=e[$>>2]|0,(c|0)!=(r|0)&&(e[$>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}r=e[P>>2]|0,r||le(l|0),o=e[O>>2]|0,(o|0)!=(r|0)&&(e[O>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),le(l|0)}function Vl(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(N=t+4604|0,r=e[N>>2]|0,U=t+180|0,!((e[U>>2]|0)<=0))for(R=t+4608|0,_=t+4612|0,c=r,h=M[r+-2>>1]|0,r=M[r>>1]|0,k=0;D=e[R>>2]|0,C=M[D+(k+-1<<1)>>1]|0,l=k+1|0,o=M[c+(l<<1)>>1]|0,w=e[_>>2]|0,d=r-h|0,c=h-C|0,w=((((S[w+(o-r)>>0]|0)*9|0)+(S[w+d>>0]|0)|0)*9|0)+(S[w+c>>0]|0)|0,w?(h=r-C>>31,(h^c|0)<0?c=r:c=C+((h^d|0)<0?0:d)|0,D=zl(t,w,M[D+(k<<1)>>1]|0,c,0)|0,E[(e[R>>2]|0)+(k<<1)>>1]=D):(l=(Gl(t,k,0)|0)+k|0,o=e[N>>2]|0,r=M[o+(l+-1<<1)>>1]|0,o=M[o+(l<<1)>>1]|0),!((l|0)>=(e[U>>2]|0));)c=e[N>>2]|0,h=r,r=o,k=l}function Ul(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;c=t+104|0,(e[c>>2]|0)>>>0<4&&en(t),h=t+100|0,d=t+112|0,w=t+96|0,C=t+108|0,D=t+116|0,r=e[h>>2]|0,l=0;do{if(o=S[d>>0]|0,(r|0)>31)break;r=e[w>>2]|0,o<<24>>24?(S[e[C>>2]>>0]=r>>>25,e[w>>2]=e[w>>2]<<7,r=(e[h>>2]|0)+7|0):(S[e[C>>2]>>0]=r>>>24,e[w>>2]=e[w>>2]<<8,r=(e[h>>2]|0)+8|0),e[h>>2]=r,k=e[C>>2]|0,o=(S[k>>0]|0)==-1&1,S[d>>0]=o,e[C>>2]=k+1,e[c>>2]=(e[c>>2]|0)+-1,e[D>>2]=(e[D>>2]|0)+1,l=l+1|0}while((l|0)<4);o<<24>>24?_t(t,0,(r+-1|0)%8|0):_t(t,0,(r|0)%8|0),(e[c>>2]|0)>>>0<4&&en(t),r=e[h>>2]|0,o=0;do{if((r|0)>31)break;r=e[w>>2]|0,S[d>>0]|0?(S[e[C>>2]>>0]=r>>>25,e[w>>2]=e[w>>2]<<7,r=(e[h>>2]|0)+7|0):(S[e[C>>2]>>0]=r>>>24,e[w>>2]=e[w>>2]<<8,r=(e[h>>2]|0)+8|0),e[h>>2]=r,k=e[C>>2]|0,S[d>>0]=(S[k>>0]|0)==-1&1,e[C>>2]=k+1,e[c>>2]=(e[c>>2]|0)+-1,e[D>>2]=(e[D>>2]|0)+1,o=o+1|0}while((o|0)<4);e[t+132>>2]|0&&en(t)}function en(t){t=t|0;var r=0,o=0,l=0,c=0,h=0;if(r=e[t+132>>2]|0,r||(r=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,r|0,4,35648),t=g,g=0,t&1||Qt(r|0,824,96),t=j()|0,Tt(r|0),le(t|0)),o=t+108|0,l=t+120|0,h=e[l>>2]|0,c=(e[o>>2]|0)-h|0,(Yt[e[(e[r>>2]|0)+48>>2]&63](r,h,c)|0)==(c|0)){h=e[l>>2]|0,e[o>>2]=h,e[t+104>>2]=(e[t+124>>2]|0)-h;return}r=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,r|0,4,35648),h=g,g=0,h&1||Qt(r|0,824,96),h=j()|0,Tt(r|0),le(h|0)}function _t(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0;if(D=t+100|0,o=(e[D>>2]|0)-o|0,e[D>>2]=o,(o|0)>-1){k=t+96|0,e[k>>2]=e[k>>2]|r<>2]=e[k>>2]|r>>0-o,C=t+104|0,(e[C>>2]|0)>>>0<4&&(en(t),o=e[D>>2]|0),h=t+112|0,d=t+108|0,w=t+116|0,l=0;!((o|0)>31);)if(o=e[k>>2]|0,S[h>>0]|0?(S[e[d>>2]>>0]=o>>>25,e[k>>2]=e[k>>2]<<7,o=(e[D>>2]|0)+7|0):(S[e[d>>2]>>0]=o>>>24,e[k>>2]=e[k>>2]<<8,o=(e[D>>2]|0)+8|0),e[D>>2]=o,N=e[d>>2]|0,S[h>>0]=(S[N>>0]|0)==-1&1,e[d>>2]=N+1,e[C>>2]=(e[C>>2]|0)+-1,e[w>>2]=(e[w>>2]|0)+1,l=l+1|0,(l|0)>=4){c=11;break}e:do if((c|0)==11&&(o|0)<0){e[k>>2]=e[k>>2]|r>>0-o,(e[C>>2]|0)>>>0<4&&(en(t),o=e[D>>2]|0),l=0;do{if((o|0)>31)break e;o=e[k>>2]|0,S[h>>0]|0?(S[e[d>>2]>>0]=o>>>25,e[k>>2]=e[k>>2]<<7,o=(e[D>>2]|0)+7|0):(S[e[d>>2]>>0]=o>>>24,e[k>>2]=e[k>>2]<<8,o=(e[D>>2]|0)+8|0),e[D>>2]=o,N=e[d>>2]|0,S[h>>0]=(S[N>>0]|0)==-1&1,e[d>>2]=N+1,e[C>>2]=(e[C>>2]|0)+-1,e[w>>2]=(e[w>>2]|0)+1,l=l+1|0}while((l|0)<4)}while(!1);e[k>>2]=e[k>>2]|r<>31,h=(Q^r)-Q|0,_=t+196+(h*12|0)+10|0,d=E[_>>1]|0,R=t+196+(h*12|0)|0,c=e[R>>2]|0,(d|0)<(c|0))if((d<<1|0)<(c|0))if((d<<2|0)<(c|0))if((d<<3|0)<(c|0))if((d<<4|0)<(c|0))for(r=5;(d<>1]^Q)-Q+l|0,U=t+136|0,l=e[U>>2]|0,(c&l|0)==(c|0)?D=c:D=l&~(c>>31),c=(o-D^Q)-Q|0,C=t+144|0,l=e[C>>2]|0,(c|0)>0?c=(c+l|0)/(l<<1|1|0)|0:c=(c-l|0)/(l<<1|1|0)|0,N=t+140|0,w=e[N>>2]|0,o=((c|0)<0?w:0)+c|0,w=o-((o|0)<((w+1|0)/2|0|0)?0:w)|0,h=t+196+(h*12|0)+4|0,l|r?c=0:c=(e[h>>2]<<1)+-1+d>>31,l=c^w,is(t,r,l>>30^l<<1,e[t+156>>2]|0),l=e[t+160>>2]|0,r=(e[R>>2]|0)+((w|0)>-1?w:0-w|0)|0,c=(e[h>>2]|0)+(ee(e[C>>2]<<1|1,w)|0)|0,o=E[_>>1]|0,(o|0)==(l|0)&&(r=r>>1,c=c>>1,o=l>>1),e[R>>2]=r,l=o+1|0,E[_>>1]=l,r=l+c|0,(r|0)>=1?(c|0)>0&&(c=c-l|0,_=E[k>>1]|0,E[k>>1]=(_<<16>>16<127&1)+(_&65535),c=(c|0)>0?0:c):(c=E[k>>1]|0,E[k>>1]=(c&65535)-(c<<16>>16>-128&1),c=(r|0)>(~o|0)?r:0-o|0),e[h>>2]=c,l=e[C>>2]|0,o=l<<1|1,r=(ee(o,(w^Q)-Q|0)|0)+D|0,(r|0)>=(0-l|0)?(c=e[U>>2]|0,(c+l|0)<(r|0)&&(r=r-(ee(e[N>>2]|0,o)|0)|0)):(r=(ee(e[N>>2]|0,o)|0)+r|0,c=e[U>>2]|0),(r&c|0)==(r|0)?(Q=r,Q=Q&65535,Q|0):(Q=c&~(r>>31),Q=Q&65535,Q|0)}function Gl(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;for(C=(e[t+180>>2]|0)-r|0,D=e[t+4608>>2]|0,k=e[t+4604>>2]|0,c=E[D+(r+-1<<1)>>1]|0,w=c&65535,o=e[t+144>>2]|0,h=0;l=D+(h+r<<1)|0,d=(M[l>>1]|0)-w|0,!((((d|0)>-1?d:0-d|0)|0)>(o|0));)if(E[l>>1]=c,h=h+1|0,(h|0)==(C|0)){h=C;break}if(c=(h|0)==(C|0),d=t+4600|0,l=e[36476+(e[d>>2]<<2)>>2]|0,(1<(h|0))o=h;else{o=h;do _t(t,1,1),l=e[d>>2]|0,o=o-(1<>2])|0,l=(l|0)>30?31:l+1|0,e[d>>2]=l,l=e[36476+(l<<2)>>2]|0;while((o|0)>=(1<>1]|0,w,M[k+(C<<1)>>1]|0)|0,E[r>>1]=t,t=e[d>>2]|0,e[d>>2]=(t|0)<1?0:t+-1|0,t=h+1|0,t|0)}function ql(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;return w=o-l|0,C=t+136|0,d=t+144|0,c=e[d>>2]|0,(((w|0)>-1?w:0-w|0)|0)>(c|0)?(h=l-o>>31|1,r=ee(h,r-l|0)|0,(r|0)>0?r=(c+r|0)/(c<<1|1|0)|0:r=(r-c|0)/(c<<1|1|0)|0,w=t+140|0,c=e[w>>2]|0,o=((r|0)<0?c:0)+r|0,c=o-((o|0)<((c+1|0)/2|0|0)?0:c)|0,ts(t,t+4576|0,c),c=ee(c,h)|0,h=e[d>>2]|0,d=h<<1|1,c=(ee(c,d)|0)+l|0,(c|0)>=(0-h|0)?(r=e[C>>2]|0,(r+h|0)<(c|0)&&(c=c-(ee(e[w>>2]|0,d)|0)|0)):(c=(ee(e[w>>2]|0,d)|0)+c|0,r=e[C>>2]|0),(c&r|0)==(c|0)?(C=c,C=C&65535,C|0):(C=r&~(c>>31),C=C&65535,C|0)):(r=r-o|0,(r|0)>0?r=(c+r|0)/(c<<1|1|0)|0:r=(r-c|0)/(c<<1|1|0)|0,w=t+140|0,c=e[w>>2]|0,h=((r|0)<0?c:0)+r|0,c=h-((h|0)<((c+1|0)/2|0|0)?0:c)|0,ts(t,t+4588|0,c),h=e[d>>2]|0,d=h<<1|1,c=(ee(d,c)|0)+o|0,(c|0)>=(0-h|0)?(r=e[C>>2]|0,(r+h|0)<(c|0)&&(c=c-(ee(e[w>>2]|0,d)|0)|0)):(c=(ee(e[w>>2]|0,d)|0)+c|0,r=e[C>>2]|0),(c&r|0)==(c|0)?(C=c,C=C&65535,C|0):(C=r&~(c>>31),C=C&65535,C|0))}function ts(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=r+9|0,d=F[k>>0]|0,D=r+4|0,C=e[D>>2]|0,c=(ee(d>>>1,C)|0)+(e[r>>2]|0)|0,(d|0)<(c|0)){h=d,l=0;do h=h<<1,l=l+1|0;while((h|0)<(c|0));c=l}else c=0;(o|0)>0&(c|0)==0&&F[r+10>>0]<<1>>>0>>0?l=1:w=5;do if((w|0)==5){if(l=(o|0)<0,l&&F[r+10>>0]<<1>>>0>=d>>>0){l=1;break}l=l&(c|0)!=0}while(!1);if(l=(((o|0)>-1?o:0-o|0)<<1)-C+(l<<31>>31)|0,is(t,c,l,(e[t+156>>2]|0)+-1-(e[36476+(e[t+4600>>2]<<2)>>2]|0)|0),(o|0)<0&&(t=r+10|0,S[t>>0]=(F[t>>0]|0)+1),l=(l+1-(e[D>>2]|0)>>1)+(e[r>>2]|0)|0,e[r>>2]=l,c=S[k>>0]|0,c<<24>>24!=(S[r+8>>0]|0)){r=c,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r;return}e[r>>2]=l>>1,t=(c&255)>>>1,S[k>>0]=t,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,r=t,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r}function is(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0;if(c=o>>r,h=t+148|0,d=l-(e[h>>2]|0)|0,(c|0)<(d+-1|0)){(c|0)>30&&(l=(c|0)/2|0,_t(t,0,l),c=c-l|0),_t(t,1,c+1|0),_t(t,(1<31?(_t(t,0,31),_t(t,1,l+-31-(e[h>>2]|0)|0)):_t(t,1,d),r=e[h>>2]|0,_t(t,(1<>2]|0,C=t+120|0,r>>>0<((e[C>>2]|0)+-3|0)>>>0){C=t+112|0,d=e[C>>2]|0,t=t+108|0,e[t>>2]=(F[r+1>>0]<<16|F[r>>0]<<24|F[r+2>>0]<<8|F[r+3>>0])>>>d|e[t>>2],t=32-d>>3,e[w>>2]=r+t,e[C>>2]=(t<<3)+d;return}d=t+104|0,o=e[d>>2]|0;do if(o){if((e[o+12>>2]|0)==(e[o+16>>2]|0)){if((Dt[e[(e[o>>2]|0)+36>>2]&127](o)|0)==-1)break;r=e[w>>2]|0}if(c=t+124|0,o=e[c>>2]|0,h=o-r|0,h>>>0<=64){if(l=t+92|0,(o|0)==(r|0))o=r;else{o=0;do S[(e[l>>2]|0)+o>>0]=S[r+o>>0]|0,o=o+1|0,r=e[w>>2]|0;while(o>>>0>>0);o=r,r=e[c>>2]|0}k=e[l>>2]|0,l=k,D=l-o|0,e[w>>2]=k,o=r+D|0,e[c>>2]=o,e[C>>2]=(e[C>>2]|0)+D,d=e[d>>2]|0,d=Yt[e[(e[d>>2]|0)+32>>2]&63](d,o,(e[t+96>>2]|0)-(l+h)|0)|0,e[c>>2]=(e[c>>2]|0)+d}}while(!1);for(d=t+112|0,h=t+108|0,t=e[t+124>>2]|0,c=t+-1|0,r=e[w>>2]|0;;){if(r>>>0>=t>>>0){o=14;break}if(l=S[r>>0]|0,o=l&255,l=l<<24>>24==-1,l){if((r|0)==(c|0)){o=25;break}if(r=r+1|0,(S[r>>0]|0)<0){o=25;break}}else r=r+1|0;if(k=e[d>>2]|0,e[h>>2]=o<<24-k|e[h>>2],e[w>>2]=r,k=k+(l?7:8)|0,e[d>>2]=k,(k|0)>=24){o=33;break}}if((o|0)==14){if((e[d>>2]|0)>=1)return;r=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,r|0,5,35648),k=g,g=0,k&1||Qt(r|0,824,96),k=j()|0,Tt(r|0),le(k|0)}else if((o|0)==25){if((e[d>>2]|0)>=1)return;r=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,r|0,5,35648),k=g,g=0,k&1||Qt(r|0,824,96),k=j()|0,Tt(r|0),le(k|0)}else if((o|0)==33){e:do if(r>>>0>>0)do{if((S[r>>0]|0)==-1)break e;r=r+1|0}while(r>>>0>>0);while(!1);e[C>>2]=r;return}}function Wl(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;R=b,b=b+32|0,l=R,N=t+144|0;e:do if(e[N>>2]|0)r=t+152|0;else if(o=e[t+136>>2]|0,r=t+152|0,(o|0)==((1<>2])+-1|0)&&(m0(l,o,0),(e[l+4>>2]|0)==(e[t+184>>2]|0))&&(e[l+8>>2]|0)==(e[t+188>>2]|0)&&(e[l+12>>2]|0)==(e[t+192>>2]|0))switch(e[r>>2]|0){case 8:{N=e[8900]|0,e[t+4612>>2]=N+(((e[8901]|0)-N|0)>>>1),b=R;return}case 10:{N=e[8903]|0,e[t+4612>>2]=N+(((e[8904]|0)-N|0)>>>1),b=R;return}case 12:{N=e[8906]|0,e[t+4612>>2]=N+(((e[8907]|0)-N|0)>>>1),b=R;return}case 16:{N=e[8909]|0,e[t+4612>>2]=N+(((e[8910]|0)-N|0)>>>1),b=R;return}default:break e}while(!1);if(k=1<>2],o=t+4616|0,l=k<<1,c=t+4620|0,h=e[c>>2]|0,r=e[o>>2]|0,d=h-r|0,l>>>0<=d>>>0?l>>>0>>0&&(w=r+l|0,(h|0)!=(w|0))&&(e[c>>2]=w):(j0(o,l-d|0),r=e[o>>2]|0),D=t+4612|0,e[D>>2]=r+k,r=0-k|0,(k|0)<=(r|0)){b=R;return}w=t+192|0,C=t+188|0,d=t+184|0,h=r;do r=e[w>>2]|0,(h|0)>(0-r|0)?(o=e[C>>2]|0,(h|0)>(0-o|0)?(l=e[d>>2]|0,(h|0)>(0-l|0)?(c=e[N>>2]|0,(h|0)>=(0-c|0)?(c|0)<(h|0)?(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1:r=0:r=-1):r=-2):r=-3):r=-4,S[(e[D>>2]|0)+h>>0]=r,h=h+1|0;while((h|0)!=(k|0));b=R}function j0(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(C=t+8|0,c=e[C>>2]|0,D=t+4|0,o=e[D>>2]|0,l=o,(c-l|0)>>>0>=r>>>0){do S[o>>0]=0,o=(e[D>>2]|0)+1|0,e[D>>2]=o,r=r+-1|0;while(r|0);return}o=e[t>>2]|0,h=l-o+r|0,(h|0)<0&&(pi(t),c=e[C>>2]|0,o=e[t>>2]|0),l=c-o|0,l>>>0<1073741823?(l=l<<1,l=l>>>0>>0?h:l,o=(e[D>>2]|0)-o|0,l?w=8:(c=0,d=0,h=o)):(l=2147483647,o=(e[D>>2]|0)-o|0,w=8),(w|0)==8&&(c=l,d=Xe(l)|0,h=o),o=d+h|0,c=d+c|0,l=o;do S[l>>0]=0,l=o+1|0,o=l,r=r+-1|0;while(r|0);r=e[t>>2]|0,l=(e[D>>2]|0)-r|0,w=d+(h-l)|0,o0(w|0,r|0,l|0)|0,e[t>>2]=w,e[D>>2]=o,e[C>>2]=c,r&&he(r)}function Hl(t){t=t|0;var r=0,o=0;e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),t=t+4|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function Ql(t){t=t|0;var r=0,o=0;if(e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),o=t+4|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function Kl(t){t=t|0;var r=0,o=0;e[t>>2]=36052,r=e[t+4616>>2]|0,r&&(o=t+4620|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),t=t+4|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function Yl(t){t=t|0;var r=0,o=0;if(e[t>>2]=36052,r=e[t+4616>>2]|0,r&&(o=t+4620|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),o=t+4|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function jl(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;d=b,b=b+32|0,C=d,m0(C,e[t+136>>2]|0,e[t+144>>2]|0),w=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[C+8>>2]|0,c=e[r+12>>2]|0,c=c|0?c:e[C+12>>2]|0,o=e[r+16>>2]|0,l=e[C+16>>2]|0,e[t+184>>2]=w|0?w:e[C+4>>2]|0,e[t+188>>2]=h,e[t+192>>2]=c,i1(t),c=t+140|0,r=(e[c>>2]|0)+32|0,r=(r|0)<128?2:(r|0)/64|0,h=0;do e[t+196+(h*12|0)>>2]=r,e[t+196+(h*12|0)+4>>2]=0,E[t+196+(h*12|0)+8>>1]=0,E[t+196+(h*12|0)+10>>1]=1,h=h+1|0;while((h|0)!=365);w=(e[c>>2]|0)+32|0,w=(w|0)<128?2:(w|0)/64|0,C=(o|0?o:l)&255,e[t+4576>>2]=w,e[t+4580>>2]=0,S[t+4584>>0]=C,S[t+4585>>0]=1,S[t+4586>>0]=0,e[t+4588>>2]=w,e[t+4592>>2]=1,S[t+4596>>0]=C,S[t+4597>>0]=1,S[t+4598>>0]=0,e[t+4600>>2]=0,b=d}function Xl(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=b,b=b+16|0,C=k,w=t+92|0,d=e[r>>2]|0,e[r>>2]=0,r=e[w>>2]|0,e[w>>2]=d,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),e[C>>2]=0,e[C+4>>2]=l,w=o+8|0,e[C+8>>2]=e[w>>2],l){r=Xe(4624)|0,l=t+8|0,c=r+4|0,h=l,d=c+84|0;do e[c>>2]=e[h>>2],c=c+4|0,h=h+4|0;while((c|0)<(d|0));c=r+88|0,d=c+40|0;do e[c>>2]=0,c=c+4|0;while((c|0)<(d|0));e[r>>2]=35828,e[r+128>>2]=e[t+136>>2],e[r+132>>2]=e[t+140>>2],e[r+136>>2]=e[t+144>>2],e[r+140>>2]=e[t+148>>2],e[r+144>>2]=e[t+152>>2],e[r+148>>2]=e[t+156>>2],e[r+152>>2]=e[t+160>>2],c=r+156|0,e[c>>2]=0,e[c+4>>2]=0,e[c+8>>2]=0,e[c+12>>2]=0,e[r+172>>2]=e[l>>2],e[r+176>>2]=0,e[r+180>>2]=0,e[r+184>>2]=0,c=r+4568|0,l=r+188|0;do e[l>>2]=0,e[l+4>>2]=0,E[l+8>>1]=0,E[l+10>>1]=1,l=l+12|0;while((l|0)!=(c|0));h=t+4|0,e[c>>2]=0,e[c+4>>2]=0,E[c+8>>1]=0,S[c+10>>0]=0,d=r+4580|0,e[d>>2]=0,e[d+4>>2]=0,E[d+8>>1]=0,S[d+10>>0]=0,d=r+4592|0,e[d>>2]=0,e[d+4>>2]=0,e[d+8>>2]=0,e[d+12>>2]=0,e[d+16>>2]=0,e[d+20>>2]=0,e[d+24>>2]=0,S[d+28>>0]=0,e[r+28>>2]|0||(e[r+20>>2]=1),l=e[h>>2]|0,e[h>>2]=r,l&&(Mt[e[(e[l>>2]|0)+4>>2]&255](l),r=e[h>>2]|0),Y0(r,C)}return C=t+100|0,e[C>>2]=32,e[t+96>>2]=0,r=e[o>>2]|0,r?(e[t+132>>2]=r,c=t+120|0,w=t+124|0,l=e[w>>2]|0,r=e[c>>2]|0,h=r,d=l-h|0,d>>>0>=4e3?d>>>0>4e3&&(D=r+4e3|0,(l|0)!=(D|0))&&(e[w>>2]=D,l=D):(vi(c,4e3-d|0),r=e[c>>2]|0,h=r,l=e[w>>2]|0),e[t+108>>2]=h,e[t+104>>2]=l-r,ns(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0):(e[t+108>>2]=e[o+4>>2],e[t+104>>2]=e[w>>2],ns(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0)}function Zl(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+32>>2]|0&&(e[t+24>>2]|0)!=1){if(_=t+8|0,Q=t+36|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(37,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+16>>2]|0,(t|0)==16)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(38,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(39,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(40,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+20>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=6,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=6,e[l+12>>2]=t,O=l,b=G,O|0)}function ns(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;K=b,b=b+32|0,$=K+12|0,Q=K,R=t+180|0,_=(e[R>>2]|0)+4|0,(e[t+32>>2]|0)==1?U=e[t+24>>2]|0:U=1,r=ee(U<<1,_)|0,e[$>>2]=0,P=$+4|0,e[P>>2]=0,e[$+8>>2]=0;do if(r){if(r>>>0>715827882&&(g=0,ue(178,$|0),G=g,g=0,G&1)||(d=6),(d|0)==6&&(g=0,o=ge(67,r*6|0)|0,G=g,g=0,!(G&1))){for(e[P>>2]=o,e[$>>2]=o,l=o+(r*6|0)|0,e[$+8>>2]=l;E[o>>1]=0,E[o+2>>1]=0,E[o+4>>1]=0,r=r+-1|0,r;)o=o+6|0;e[P>>2]=l;break}l=j()|0,r=e[$>>2]|0,r||le(l|0),o=e[P>>2]|0,(o|0)!=(r|0)&&(e[P>>2]=o+(~(((o+-6-r|0)>>>0)/6|0)*6|0)),he(r),le(l|0)}while(!1);e[Q>>2]=0,G=Q+4|0,e[G>>2]=0,e[Q+8>>2]=0;do if(!U)d=20;else{if(U>>>0>1073741823&&(g=0,ue(178,Q|0),N=g,g=0,N&1)||(d=18),(d|0)==18&&(c=U<<2,g=0,h=ge(67,c|0)|0,N=g,g=0,!(N&1))){e[Q>>2]=h,d=h+(U<<2)|0,e[Q+8>>2]=d,Jt(h|0,0,c|0)|0,e[G>>2]=d,d=20;break}l=j()|0,r=e[Q>>2]|0,o=r,r&&(c=e[G>>2]|0,(c|0)!=(r|0)&&(e[G>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}while(!1);if((d|0)==20){c=t+12|0;e:do if((e[c>>2]|0)>0){h=t+4604|0,d=(ee(U,_)|0)+1|0,w=t+4608|0,C=t+92|0,D=(U|0)>0,k=t+4600|0,N=0;t:for(;;){if(o=e[$>>2]|0,r=o+6|0,e[h>>2]=r,o=o+(d*6|0)|0,e[w>>2]=o,N&1?(e[h>>2]=o,e[w>>2]=r):r=o,l=e[C>>2]|0,g=0,$e(e[(e[l>>2]|0)+12>>2]|0,l|0,r|0,e[R>>2]|0,_|0),l=g,g=0,l&1){d=30;break}if(D){r=e[Q>>2]|0,o=e[h>>2]|0,l=0;do{if(e[k>>2]=e[r+(l<<2)>>2],O=e[R>>2]|0,r=o+(O*6|0)|0,o=o+((O+-1|0)*6|0)|0,E[r>>1]=E[o>>1]|0,E[r+2>>1]=E[o+2>>1]|0,E[r+4>>1]=E[o+4>>1]|0,o=(e[w>>2]|0)+-6|0,r=e[h>>2]|0,E[o>>1]=E[r>>1]|0,E[o+2>>1]=E[r+2>>1]|0,E[o+4>>1]=E[r+4>>1]|0,g=0,Ae(69,t|0,0),o=g,g=0,o&1){d=29;break t}r=e[Q>>2]|0,e[r+(l<<2)>>2]=e[k>>2],o=(e[h>>2]|0)+(_*6|0)|0,e[h>>2]=o,e[w>>2]=(e[w>>2]|0)+(_*6|0),l=l+1|0}while((l|0)<(U|0))}if(N=N+1|0,(N|0)>=(e[c>>2]|0)){d=42;break e}}if((d|0)==29){l=j()|0;break}else if((d|0)==30){l=j()|0;break}}else d=42;while(!1);do if((d|0)==42){if(g=0,ue(182,t|0),O=g,g=0,O&1){l=j()|0;break}if(r=e[Q>>2]|0,o=r,r&&(l=e[G>>2]|0,(l|0)!=(r|0)&&(e[G>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[$>>2]|0,!r){b=K;return}o=e[P>>2]|0,(o|0)!=(r|0)&&(e[P>>2]=o+(~(((o+-6-r|0)>>>0)/6|0)*6|0)),he(r),b=K;return}while(!1);r=e[Q>>2]|0,o=r,r&&(c=e[G>>2]|0,(c|0)!=(r|0)&&(e[G>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}r=e[$>>2]|0,r||le(l|0),o=e[P>>2]|0,(o|0)!=(r|0)&&(e[P>>2]=o+(~(((o+-6-r|0)>>>0)/6|0)*6|0)),he(r),le(l|0)}function Jl(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0;if(oe=t+180|0,!((e[oe>>2]|0)<=0))for(ne=t+4608|0,ce=t+4604|0,ke=t+4612|0,ie=0;P=ie+-1|0,h=e[ne>>2]|0,d=e[ce>>2]|0,r=ie+1|0,c=M[d+(ie*6|0)>>1]|0,Z=e[ke>>2]|0,w=M[d+(P*6|0)>>1]|0,C=c-w|0,D=M[h+(P*6|0)>>1]|0,k=w-D|0,N=((((S[Z+((M[d+(r*6|0)>>1]|0)-c)>>0]|0)*9|0)+(S[Z+C>>0]|0)|0)*9|0)+(S[Z+k>>0]|0)|0,l=M[d+(ie*6|0)+2>>1]|0,R=M[d+(P*6|0)+2>>1]|0,_=l-R|0,U=M[h+(P*6|0)+2>>1]|0,Q=R-U|0,K=((((S[Z+((M[d+(r*6|0)+2>>1]|0)-l)>>0]|0)*9|0)+(S[Z+_>>0]|0)|0)*9|0)+(S[Z+Q>>0]|0)|0,o=M[d+(ie*6|0)+4>>1]|0,G=M[d+(P*6|0)+4>>1]|0,$=o-G|0,P=M[h+(P*6|0)+4>>1]|0,O=G-P|0,Z=((((S[Z+((M[d+(r*6|0)+4>>1]|0)-o)>>0]|0)*9|0)+(S[Z+$>>0]|0)|0)*9|0)+(S[Z+O>>0]|0)|0,K|N|Z?(d=M[h+(ie*6|0)>>1]|0,h=c-D>>31,(h^k|0)>=0&&((h^C|0)<0?c=D:c=D-w+c|0),d=Hn(t,N,d,c,0)|0,h=M[(e[ne>>2]|0)+(ie*6|0)+2>>1]|0,c=l-U>>31,(c^Q|0)>=0&&((c^_|0)<0?l=U:l=U-R+l|0),c=Hn(t,K,h,l,0)|0,h=M[(e[ne>>2]|0)+(ie*6|0)+4>>1]|0,l=o-P>>31,(l^O|0)>=0&&((l^$|0)<0?o=P:o=P-G+o|0),O=Hn(t,Z,h,o,0)|0,Z=e[ne>>2]|0,E[Z+(ie*6|0)>>1]=d,E[Z+(ie*6|0)+2>>1]=c,E[Z+(ie*6|0)+4>>1]=O):r=(e1(t,ie,0)|0)+ie|0,(r|0)<(e[oe>>2]|0);)ie=r}function e1(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0;for(oe=b,b=b+48|0,_=oe+30|0,R=oe+24|0,N=oe+18|0,U=oe+12|0,P=oe+6|0,O=oe,Z=(e[t+180>>2]|0)-r|0,ie=e[t+4608>>2]|0,Q=e[t+4604>>2]|0,$=r+-1|0,K=E[ie+($*6|0)>>1]|0,G=E[ie+($*6|0)+2>>1]|0,$=E[ie+($*6|0)+4>>1]|0,o=K&65535,l=t+144|0,c=G&65535,h=$&65535,k=0;C=k+r|0,d=ie+(C*6|0)|0,w=ie+(C*6|0)+2|0,C=ie+(C*6|0)+4|0,ne=(M[d>>1]|0)-o|0,D=e[l>>2]|0,!((((ne|0)>-1?ne:0-ne|0)|0)>(D|0)||(ne=(M[w>>1]|0)-c|0,(((ne|0)>-1?ne:0-ne|0)|0)>(D|0))||(ne=(M[C>>1]|0)-h|0,(((ne|0)>-1?ne:0-ne|0)|0)>(D|0)));)if(E[d>>1]=K,E[w>>1]=G,E[C>>1]=$,k=k+1|0,(k|0)==(Z|0)){k=Z;break}if(c=(k|0)==(Z|0),h=t+4600|0,l=e[36476+(e[h>>2]<<2)>>2]|0,(1<(k|0))o=k;else{o=k;do _t(t,1,1),l=e[h>>2]|0,o=o-(1<>2])|0,l=(l|0)>30?31:l+1|0,e[h>>2]=l,l=e[36476+(l<<2)>>2]|0;while((o|0)>=(1<>1]=E[ne>>1]|0,E[P+2>>1]=E[ne+2>>1]|0,E[P+4>>1]=E[ne+4>>1]|0,E[O>>1]=K,E[O+2>>1]=G,E[O+4>>1]=$,r=Q+(r*6|0)|0,E[N>>1]=E[P>>1]|0,E[N+2>>1]=E[P+2>>1]|0,E[N+4>>1]=E[P+4>>1]|0,E[R>>1]=E[O>>1]|0,E[R+2>>1]=E[O+2>>1]|0,E[R+4>>1]=E[O+4>>1]|0,E[_>>1]=E[r>>1]|0,E[_+2>>1]=E[r+2>>1]|0,E[_+4>>1]=E[r+4>>1]|0,t1(U,t,N,R,_),E[ne>>1]=E[U>>1]|0,E[ne+2>>1]=E[U+2>>1]|0,E[ne+4>>1]=E[U+4>>1]|0,ne=e[h>>2]|0,e[h>>2]=(ne|0)<1?0:ne+-1|0,ne=k+1|0,b=oe,ne|0)}function Hn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;if(Q=r>>31,h=(Q^r)-Q|0,_=t+196+(h*12|0)+10|0,d=E[_>>1]|0,R=t+196+(h*12|0)|0,c=e[R>>2]|0,(d|0)<(c|0))if((d<<1|0)<(c|0))if((d<<2|0)<(c|0))if((d<<3|0)<(c|0))if((d<<4|0)<(c|0))for(r=5;(d<>1]^Q)-Q+l|0,U=t+136|0,l=e[U>>2]|0,(c&l|0)==(c|0)?D=c:D=l&~(c>>31),c=(o-D^Q)-Q|0,C=t+144|0,l=e[C>>2]|0,(c|0)>0?c=(c+l|0)/(l<<1|1|0)|0:c=(c-l|0)/(l<<1|1|0)|0,N=t+140|0,w=e[N>>2]|0,o=((c|0)<0?w:0)+c|0,w=o-((o|0)<((w+1|0)/2|0|0)?0:w)|0,h=t+196+(h*12|0)+4|0,l|r?c=0:c=(e[h>>2]<<1)+-1+d>>31,l=c^w,rs(t,r,l>>30^l<<1,e[t+156>>2]|0),l=e[t+160>>2]|0,r=(e[R>>2]|0)+((w|0)>-1?w:0-w|0)|0,c=(e[h>>2]|0)+(ee(e[C>>2]<<1|1,w)|0)|0,o=E[_>>1]|0,(o|0)==(l|0)&&(r=r>>1,c=c>>1,o=l>>1),e[R>>2]=r,l=o+1|0,E[_>>1]=l,r=l+c|0,(r|0)>=1?(c|0)>0&&(c=c-l|0,_=E[k>>1]|0,E[k>>1]=(_<<16>>16<127&1)+(_&65535),c=(c|0)>0?0:c):(c=E[k>>1]|0,E[k>>1]=(c&65535)-(c<<16>>16>-128&1),c=(r|0)>(~o|0)?r:0-o|0),e[h>>2]=c,l=e[C>>2]|0,o=l<<1|1,r=(ee(o,(w^Q)-Q|0)|0)+D|0,(r|0)>=(0-l|0)?(c=e[U>>2]|0,(c+l|0)<(r|0)&&(r=r-(ee(e[N>>2]|0,o)|0)|0)):(r=(ee(e[N>>2]|0,o)|0)+r|0,c=e[U>>2]|0),(r&c|0)==(r|0)?(Q=r,Q=Q&65535,Q|0):(Q=c&~(r>>31),Q=Q&65535,Q|0)}function rs(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0;if(c=o>>r,h=t+148|0,d=l-(e[h>>2]|0)|0,(c|0)<(d+-1|0)){(c|0)>30&&(l=(c|0)/2|0,_t(t,0,l),c=c-l|0),_t(t,1,c+1|0),_t(t,(1<31?(_t(t,0,31),_t(t,1,l+-31-(e[h>>2]|0)|0)):_t(t,1,d),r=e[h>>2]|0,_t(t,(1<>1]|0,R=N-(M[l>>1]|0)>>31|1,h=ee(R,(M[o>>1]|0)-N|0)|0,D=r+144|0,d=e[D>>2]|0,(h|0)>0?h=(h+d|0)/(d<<1|1|0)|0:h=(h-d|0)/(d<<1|1|0)|0,P=r+140|0,C=e[P>>2]|0,w=((h|0)<0?C:0)+h|0,C=w-((w|0)<((C+1|0)/2|0|0)?0:C)|0,w=r+4576|0,Qn(r,w,C),K=M[c+2>>1]|0,G=K-(M[l+2>>1]|0)>>31|1,h=ee(G,(M[o+2>>1]|0)-K|0)|0,d=e[D>>2]|0,(h|0)>0?h=(h+d|0)/(d<<1|1|0)|0:h=(h-d|0)/(d<<1|1|0)|0,_=e[P>>2]|0,$=((h|0)<0?_:0)+h|0,_=$-(($|0)<((_+1|0)/2|0|0)?0:_)|0,Qn(r,w,_),$=M[c+4>>1]|0,Q=$-(M[l+4>>1]|0)>>31|1,h=ee(Q,(M[o+4>>1]|0)-$|0)|0,d=e[D>>2]|0,(h|0)>0?h=(h+d|0)/(d<<1|1|0)|0:h=(h-d|0)/(d<<1|1|0)|0,k=e[P>>2]|0,h=((h|0)<0?k:0)+h|0,k=h-((h|0)<((k+1|0)/2|0|0)?0:k)|0,Qn(r,w,k),w=e[D>>2]|0,D=w<<1|1,h=(ee(ee(D,C)|0,R)|0)+N|0,o=0-w|0,(h|0)>=(o|0)?(d=e[U>>2]|0,(d+w|0)<(h|0)&&(h=h-(ee(e[P>>2]|0,D)|0)|0),l=d):(h=(ee(e[P>>2]|0,D)|0)+h|0,l=e[U>>2]|0),(h&l|0)!=(h|0)&&(h=l&~(h>>31)),c=h&65535,h=(ee(ee(D,_)|0,G)|0)+K|0,(h|0)>=(o|0)?(l+w|0)<(h|0)&&(h=h-(ee(e[P>>2]|0,D)|0)|0):h=(ee(e[P>>2]|0,D)|0)+h|0,(h&l|0)!=(h|0)&&(h=l&~(h>>31)),d=h&65535,h=(ee(ee(D,k)|0,Q)|0)+$|0,(h|0)>=(o|0)?(l+w|0)<(h|0)&&(h=h-(ee(e[P>>2]|0,D)|0)|0):h=(ee(e[P>>2]|0,D)|0)+h|0,(h&l|0)==(h|0)){P=h,P=P&65535,E[t>>1]=c,$=t+2|0,E[$>>1]=d,t=t+4|0,E[t>>1]=P;return}P=l&~(h>>31),P=P&65535,E[t>>1]=c,$=t+2|0,E[$>>1]=d,t=t+4|0,E[t>>1]=P}function Qn(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=r+9|0,d=F[k>>0]|0,D=r+4|0,C=e[D>>2]|0,c=(ee(d>>>1,C)|0)+(e[r>>2]|0)|0,(d|0)<(c|0)){h=d,l=0;do h=h<<1,l=l+1|0;while((h|0)<(c|0));c=l}else c=0;(o|0)>0&(c|0)==0&&F[r+10>>0]<<1>>>0>>0?l=1:w=5;do if((w|0)==5){if(l=(o|0)<0,l&&F[r+10>>0]<<1>>>0>=d>>>0){l=1;break}l=l&(c|0)!=0}while(!1);if(l=(((o|0)>-1?o:0-o|0)<<1)-C+(l<<31>>31)|0,rs(t,c,l,(e[t+156>>2]|0)+-1-(e[36476+(e[t+4600>>2]<<2)>>2]|0)|0),(o|0)<0&&(t=r+10|0,S[t>>0]=(F[t>>0]|0)+1),l=(l+1-(e[D>>2]|0)>>1)+(e[r>>2]|0)|0,e[r>>2]=l,c=S[k>>0]|0,c<<24>>24!=(S[r+8>>0]|0)){r=c,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r;return}e[r>>2]=l>>1,t=(c&255)>>>1,S[k>>0]=t,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,r=t,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r}function i1(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;R=b,b=b+32|0,l=R,N=t+144|0;e:do if(e[N>>2]|0)r=t+152|0;else if(o=e[t+136>>2]|0,r=t+152|0,(o|0)==((1<>2])+-1|0)&&(m0(l,o,0),(e[l+4>>2]|0)==(e[t+184>>2]|0))&&(e[l+8>>2]|0)==(e[t+188>>2]|0)&&(e[l+12>>2]|0)==(e[t+192>>2]|0))switch(e[r>>2]|0){case 8:{N=e[8900]|0,e[t+4612>>2]=N+(((e[8901]|0)-N|0)>>>1),b=R;return}case 10:{N=e[8903]|0,e[t+4612>>2]=N+(((e[8904]|0)-N|0)>>>1),b=R;return}case 12:{N=e[8906]|0,e[t+4612>>2]=N+(((e[8907]|0)-N|0)>>>1),b=R;return}case 16:{N=e[8909]|0,e[t+4612>>2]=N+(((e[8910]|0)-N|0)>>>1),b=R;return}default:break e}while(!1);if(k=1<>2],o=t+4616|0,l=k<<1,c=t+4620|0,h=e[c>>2]|0,r=e[o>>2]|0,d=h-r|0,l>>>0<=d>>>0?l>>>0>>0&&(w=r+l|0,(h|0)!=(w|0))&&(e[c>>2]=w):(j0(o,l-d|0),r=e[o>>2]|0),D=t+4612|0,e[D>>2]=r+k,r=0-k|0,(k|0)<=(r|0)){b=R;return}w=t+192|0,C=t+188|0,d=t+184|0,h=r;do r=e[w>>2]|0,(h|0)>(0-r|0)?(o=e[C>>2]|0,(h|0)>(0-o|0)?(l=e[d>>2]|0,(h|0)>(0-l|0)?(c=e[N>>2]|0,(h|0)>=(0-c|0)?(c|0)<(h|0)?(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1:r=0:r=-1):r=-2):r=-3):r=-4,S[(e[D>>2]|0)+h>>0]=r,h=h+1|0;while((h|0)!=(k|0));b=R}function n1(t){t=t|0;var r=0,o=0;e[t>>2]=36024,r=e[t+4616>>2]|0,r&&(o=t+4620|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),t=t+4|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function r1(t){t=t|0;var r=0,o=0;if(e[t>>2]=36024,r=e[t+4616>>2]|0,r&&(o=t+4620|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),o=t+4|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function s1(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;d=b,b=b+32|0,C=d,m0(C,e[t+136>>2]|0,e[t+144>>2]|0),w=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[C+8>>2]|0,c=e[r+12>>2]|0,c=c|0?c:e[C+12>>2]|0,o=e[r+16>>2]|0,l=e[C+16>>2]|0,e[t+184>>2]=w|0?w:e[C+4>>2]|0,e[t+188>>2]=h,e[t+192>>2]=c,O1(t),c=t+140|0,r=(e[c>>2]|0)+32|0,r=(r|0)<128?2:(r|0)/64|0,h=0;do e[t+196+(h*12|0)>>2]=r,e[t+196+(h*12|0)+4>>2]=0,E[t+196+(h*12|0)+8>>1]=0,E[t+196+(h*12|0)+10>>1]=1,h=h+1|0;while((h|0)!=365);w=(e[c>>2]|0)+32|0,w=(w|0)<128?2:(w|0)/64|0,C=(o|0?o:l)&255,e[t+4576>>2]=w,e[t+4580>>2]=0,S[t+4584>>0]=C,S[t+4585>>0]=1,S[t+4586>>0]=0,e[t+4588>>2]=w,e[t+4592>>2]=1,S[t+4596>>0]=C,S[t+4597>>0]=1,S[t+4598>>0]=0,e[t+4600>>2]=0,b=d}function o1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=b,b=b+16|0,C=k,w=t+92|0,d=e[r>>2]|0,e[r>>2]=0,r=e[w>>2]|0,e[w>>2]=d,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),e[C>>2]=0,e[C+4>>2]=l,w=o+8|0,e[C+8>>2]=e[w>>2],l){r=Xe(4624)|0,l=t+8|0,c=r+4|0,h=l,d=c+84|0;do e[c>>2]=e[h>>2],c=c+4|0,h=h+4|0;while((c|0)<(d|0));c=r+88|0,d=c+40|0;do e[c>>2]=0,c=c+4|0;while((c|0)<(d|0));e[r>>2]=35800,e[r+128>>2]=e[t+136>>2],e[r+132>>2]=e[t+140>>2],e[r+136>>2]=e[t+144>>2],e[r+140>>2]=e[t+148>>2],e[r+144>>2]=e[t+152>>2],e[r+148>>2]=e[t+156>>2],e[r+152>>2]=e[t+160>>2],c=r+156|0,e[c>>2]=0,e[c+4>>2]=0,e[c+8>>2]=0,e[c+12>>2]=0,e[r+172>>2]=e[l>>2],e[r+176>>2]=0,e[r+180>>2]=0,e[r+184>>2]=0,c=r+4568|0,l=r+188|0;do e[l>>2]=0,e[l+4>>2]=0,E[l+8>>1]=0,E[l+10>>1]=1,l=l+12|0;while((l|0)!=(c|0));h=t+4|0,e[c>>2]=0,e[c+4>>2]=0,E[c+8>>1]=0,S[c+10>>0]=0,d=r+4580|0,e[d>>2]=0,e[d+4>>2]=0,E[d+8>>1]=0,S[d+10>>0]=0,d=r+4592|0,e[d>>2]=0,e[d+4>>2]=0,e[d+8>>2]=0,e[d+12>>2]=0,e[d+16>>2]=0,e[d+20>>2]=0,e[d+24>>2]=0,S[d+28>>0]=0,e[r+28>>2]|0||(e[r+20>>2]=1),l=e[h>>2]|0,e[h>>2]=r,l&&(Mt[e[(e[l>>2]|0)+4>>2]&255](l),r=e[h>>2]|0),Y0(r,C)}return C=t+100|0,e[C>>2]=32,e[t+96>>2]=0,r=e[o>>2]|0,r?(e[t+132>>2]=r,c=t+120|0,w=t+124|0,l=e[w>>2]|0,r=e[c>>2]|0,h=r,d=l-h|0,d>>>0>=4e3?d>>>0>4e3&&(D=r+4e3|0,(l|0)!=(D|0))&&(e[w>>2]=D,l=D):(vi(c,4e3-d|0),r=e[c>>2]|0,h=r,l=e[w>>2]|0),e[t+108>>2]=h,e[t+104>>2]=l-r,us(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0):(e[t+108>>2]=e[o+4>>2],e[t+104>>2]=e[w>>2],us(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0)}function l1(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+32>>2]|0&&(e[t+24>>2]|0)!=1){if(_=t+8|0,Q=t+36|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(44,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+16>>2]|0,(t|0)==8)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(45,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(46,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(47,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+20>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=3,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=3,e[l+12>>2]=t,O=l,b=G,O|0)}function u1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0;e[t>>2]=36712,e[t+4>>2]=o,k=t+8|0,l=e[o>>2]|0,C=o+16|0,d=e[C>>2]|0,h=ee(d,l)|0,e[k>>2]=0,N=t+12|0,e[N>>2]=0,e[t+16>>2]=0;do if(!h)h=d;else{if((h|0)<0&&(g=0,ue(178,k|0),d=g,g=0,d&1)||(D=4),(D|0)==4&&(g=0,w=ge(67,h|0)|0,d=g,g=0,!(d&1))){e[N>>2]=w,e[k>>2]=w,e[t+16>>2]=w+h,l=w;do S[l>>0]=0,l=(e[N>>2]|0)+1|0,e[N>>2]=l,h=h+-1|0;while(h|0);h=e[C>>2]|0,l=e[o>>2]|0;break}l=j()|0,c=e[k>>2]|0,c&&((e[N>>2]|0)!=(c|0)&&(e[N>>2]=c),he(c)),N=l,le(N|0)}while(!1);if(d=t+20|0,l=ee(h,l)|0,e[d>>2]=0,h=t+24|0,e[h>>2]=0,e[t+28>>2]=0,!l){N=t+36|0,e[N>>2]=e[r>>2],e[N+4>>2]=e[r+4>>2],e[N+8>>2]=e[r+8>>2];return}if((l|0)<0&&(g=0,ue(178,d|0),o=g,g=0,o&1)||(D=15),(D|0)==15&&(g=0,c=ge(67,l|0)|0,D=g,g=0,!(D&1))){e[h>>2]=c,e[d>>2]=c,e[t+28>>2]=c+l;do S[c>>0]=0,c=(e[h>>2]|0)+1|0,e[h>>2]=c,l=l+-1|0;while(l|0);N=t+36|0,e[N>>2]=e[r>>2],e[N+4>>2]=e[r+4>>2],e[N+8>>2]=e[r+8>>2];return}l=j()|0,c=e[d>>2]|0,c&&((e[h>>2]|0)!=(c|0)&&(e[h>>2]=c),he(c)),c=e[k>>2]|0,c||(N=l,le(N|0)),(e[N>>2]|0)!=(c|0)&&(e[N>>2]=c),he(c),N=l,le(N|0)}function c1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0;e[t>>2]=36688,e[t+4>>2]=o,k=t+8|0,l=e[o>>2]|0,C=o+16|0,d=e[C>>2]|0,h=ee(d,l)|0,e[k>>2]=0,N=t+12|0,e[N>>2]=0,e[t+16>>2]=0;do if(!h)h=d;else{if((h|0)<0&&(g=0,ue(178,k|0),d=g,g=0,d&1)||(D=4),(D|0)==4&&(g=0,w=ge(67,h|0)|0,d=g,g=0,!(d&1))){e[N>>2]=w,e[k>>2]=w,e[t+16>>2]=w+h,l=w;do S[l>>0]=0,l=(e[N>>2]|0)+1|0,e[N>>2]=l,h=h+-1|0;while(h|0);h=e[C>>2]|0,l=e[o>>2]|0;break}l=j()|0,c=e[k>>2]|0,c&&((e[N>>2]|0)!=(c|0)&&(e[N>>2]=c),he(c)),N=l,le(N|0)}while(!1);if(d=t+20|0,l=ee(h,l)|0,e[d>>2]=0,h=t+24|0,e[h>>2]=0,e[t+28>>2]=0,!l){N=t+36|0,e[N>>2]=e[r>>2],e[N+4>>2]=e[r+4>>2],e[N+8>>2]=e[r+8>>2];return}if((l|0)<0&&(g=0,ue(178,d|0),o=g,g=0,o&1)||(D=15),(D|0)==15&&(g=0,c=ge(67,l|0)|0,D=g,g=0,!(D&1))){e[h>>2]=c,e[d>>2]=c,e[t+28>>2]=c+l;do S[c>>0]=0,c=(e[h>>2]|0)+1|0,e[h>>2]=c,l=l+-1|0;while(l|0);N=t+36|0,e[N>>2]=e[r>>2],e[N+4>>2]=e[r+4>>2],e[N+8>>2]=e[r+8>>2];return}l=j()|0,c=e[d>>2]|0,c&&((e[h>>2]|0)!=(c|0)&&(e[h>>2]=c),he(c)),c=e[k>>2]|0,c||(N=l,le(N|0)),(e[N>>2]|0)!=(c|0)&&(e[N>>2]=c),he(c),N=l,le(N|0)}function f1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0;e[t>>2]=36664,e[t+4>>2]=o,k=t+8|0,l=e[o>>2]|0,C=o+16|0,d=e[C>>2]|0,h=ee(d,l)|0,e[k>>2]=0,N=t+12|0,e[N>>2]=0,e[t+16>>2]=0;do if(!h)h=d;else{if((h|0)<0&&(g=0,ue(178,k|0),d=g,g=0,d&1)||(D=4),(D|0)==4&&(g=0,w=ge(67,h|0)|0,d=g,g=0,!(d&1))){e[N>>2]=w,e[k>>2]=w,e[t+16>>2]=w+h,l=w;do S[l>>0]=0,l=(e[N>>2]|0)+1|0,e[N>>2]=l,h=h+-1|0;while(h|0);h=e[C>>2]|0,l=e[o>>2]|0;break}l=j()|0,c=e[k>>2]|0,c&&((e[N>>2]|0)!=(c|0)&&(e[N>>2]=c),he(c)),N=l,le(N|0)}while(!1);if(d=t+20|0,l=ee(h,l)|0,e[d>>2]=0,h=t+24|0,e[h>>2]=0,e[t+28>>2]=0,!l){N=t+36|0,e[N>>2]=e[r>>2],e[N+4>>2]=e[r+4>>2],e[N+8>>2]=e[r+8>>2];return}if((l|0)<0&&(g=0,ue(178,d|0),o=g,g=0,o&1)||(D=15),(D|0)==15&&(g=0,c=ge(67,l|0)|0,D=g,g=0,!(D&1))){e[h>>2]=c,e[d>>2]=c,e[t+28>>2]=c+l;do S[c>>0]=0,c=(e[h>>2]|0)+1|0,e[h>>2]=c,l=l+-1|0;while(l|0);N=t+36|0,e[N>>2]=e[r>>2],e[N+4>>2]=e[r+4>>2],e[N+8>>2]=e[r+8>>2];return}l=j()|0,c=e[d>>2]|0,c&&((e[h>>2]|0)!=(c|0)&&(e[h>>2]=c),he(c)),c=e[k>>2]|0,c||(N=l,le(N|0)),(e[N>>2]|0)!=(c|0)&&(e[N>>2]=c),he(c),N=l,le(N|0)}function h1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0;e[t>>2]=36640,e[t+4>>2]=o,k=t+8|0,l=e[o>>2]|0,C=o+16|0,d=e[C>>2]|0,h=ee(d,l)|0,e[k>>2]=0,N=t+12|0,e[N>>2]=0,e[t+16>>2]=0;do if(!h)h=d;else{if((h|0)<0&&(g=0,ue(178,k|0),d=g,g=0,d&1)||(D=4),(D|0)==4&&(g=0,w=ge(67,h|0)|0,d=g,g=0,!(d&1))){e[N>>2]=w,e[k>>2]=w,e[t+16>>2]=w+h,l=w;do S[l>>0]=0,l=(e[N>>2]|0)+1|0,e[N>>2]=l,h=h+-1|0;while(h|0);h=e[C>>2]|0,l=e[o>>2]|0;break}l=j()|0,c=e[k>>2]|0,c&&((e[N>>2]|0)!=(c|0)&&(e[N>>2]=c),he(c)),N=l,le(N|0)}while(!1);if(d=t+20|0,l=ee(h,l)|0,e[d>>2]=0,h=t+24|0,e[h>>2]=0,e[t+28>>2]=0,!l){N=t+36|0,e[N>>2]=e[r>>2],e[N+4>>2]=e[r+4>>2],e[N+8>>2]=e[r+8>>2];return}if((l|0)<0&&(g=0,ue(178,d|0),o=g,g=0,o&1)||(D=15),(D|0)==15&&(g=0,c=ge(67,l|0)|0,D=g,g=0,!(D&1))){e[h>>2]=c,e[d>>2]=c,e[t+28>>2]=c+l;do S[c>>0]=0,c=(e[h>>2]|0)+1|0,e[h>>2]=c,l=l+-1|0;while(l|0);N=t+36|0,e[N>>2]=e[r>>2],e[N+4>>2]=e[r+4>>2],e[N+8>>2]=e[r+8>>2];return}l=j()|0,c=e[d>>2]|0,c&&((e[h>>2]|0)!=(c|0)&&(e[h>>2]=c),he(c)),c=e[k>>2]|0,c||(N=l,le(N|0)),(e[N>>2]|0)!=(c|0)&&(e[N>>2]=c),he(c),N=l,le(N|0)}function d1(t){t=t|0;var r=0,o=0;e[t>>2]=36640,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=e[t+8>>2]|0,o&&(r=t+12|0,(e[r>>2]|0)!=(o|0)&&(e[r>>2]=o),he(o))}function p1(t){t=t|0;var r=0,o=0;if(e[t>>2]=36640,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),r=e[t+8>>2]|0,!r){he(t);return}o=t+12|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r),he(t)}function m1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0;if(c=t+36|0,!(e[c>>2]|0)){c=t+40|0,ss(t,r,e[c>>2]|0,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}h=ee(e[(e[t+4>>2]|0)+16>>2]|0,o)|0,d=t+20|0,ss(t,r,e[d>>2]|0,o,l),t=e[c>>2]|0,(Yt[e[(e[t>>2]|0)+48>>2]&63](t,e[d>>2]|0,h)|0)!=(h|0)&&(c=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,c|0,3,35648),d=g,g=0,d&1?(d=j()|0,Tt(c|0),le(d|0)):Qt(c|0,824,96))}function g1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0;if(c=e[t+36>>2]|0,c){S1(t,c,r,o,l);return}else{c=t+40|0,Kn(t,e[c>>2]|0,r,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}}function Kn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0;if(w=t+4|0,h=e[w>>2]|0,!(S[h+32>>0]|0))w=r;else{if(d=t+8|0,o0(e[d>>2]|0,r|0,l*3|0)|0,h=e[w>>2]|0,r=e[h+16>>2]|0,(l|0)>0){for(h=e[d>>2]|0,t=0;C=h+2|0,D=S[h>>0]|0,S[h>>0]=S[C>>0]|0,S[C>>0]=D,t=t+1|0,(t|0)!=(l|0);)h=h+r|0;h=e[w>>2]|0}w=e[d>>2]|0}switch(e[h+16>>2]|0){case 3:{if((e[h+24>>2]|0)==2){if((l|0)>0)h=0;else return;do d=F[w+(h*3|0)+1>>0]|0,c=128-d+(F[w+(h*3|0)+2>>0]|0)|0,C=(F[w+(h*3|0)>>0]|0)-d+128|0,D=o+(h*3|0)|0,S[D>>0]=d+192+(((c&255)+(C&255)|0)>>>2),S[D+1>>0]=c,S[D+2>>0]=C,h=h+1|0;while((h|0)!=(l|0));return}if(h=(c|0)<(l|0)?c:l,(h|0)<=0)return;t=c<<1,r=0;do l=F[w+(r*3|0)+1>>0]|0,C=128-l+(F[w+(r*3|0)+2>>0]|0)|0,D=(F[w+(r*3|0)>>0]|0)-l+128|0,S[o+r>>0]=l+192+(((C&255)+(D&255)|0)>>>2),S[o+(r+c)>>0]=C,S[o+(r+t)>>0]=D,r=r+1|0;while((r|0)!=(h|0));return}case 4:{if((e[h+24>>2]|0)!=1||(h=(c|0)<(l|0)?c:l,(h|0)<=0))return;t=c<<1,r=c*3|0,d=0;do D=S[w+(d<<2)+3>>0]|0,k=F[w+(d<<2)+1>>0]|0,l=128-k+(F[w+(d<<2)+2>>0]|0)|0,C=(F[w+(d<<2)>>0]|0)-k+128|0,S[o+d>>0]=k+192+(((l&255)+(C&255)|0)>>>2),S[o+(d+c)>>0]=l,S[o+(d+t)>>0]=C,S[o+(d+r)>>0]=D,d=d+1|0;while((d|0)!=(h|0));return}default:return}}function S1(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(k=b,b=b+176|0,N=k+152|0,_=k+16|0,R=k,d=ee(e[(e[t+4>>2]|0)+16>>2]|0,l)|0,C=t+20|0,h=e[C>>2]|0,!d){_=h,Kn(t,_,o,l,c),b=k;return}for(;w=Yt[e[(e[r>>2]|0)+32>>2]&63](r,h,d)|0,!!w;)if(h=e[C>>2]|0,(d|0)==(w|0)){D=26;break}else d=d-w|0;if((D|0)==26){Kn(t,h,o,l,c),b=k;return}o=_+56|0,C=_+4|0,e[_>>2]=36160,e[o>>2]=36180,g=0,Ae(62,_+56|0,C|0),k=g,g=0,k&1&&(_=j()|0,tt(o),le(_|0)),e[_+128>>2]=0,e[_+132>>2]=-1,e[_>>2]=36200,e[_+56>>2]=36220,g=0,ue(180,C|0),k=g,g=0;do if(k&1)h=j()|0;else{if(e[C>>2]=36236,r=_+36|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[_+52>>2]=16,e[N>>2]=0,e[N+4>>2]=0,e[N+8>>2]=0,g=0,Ae(63,C|0,N|0),k=g,g=0,k&1){h=j()|0,de(N),de(r),wt(C);break}de(N),g=0,h=Ve(28,_|0,49029,57)|0,N=g,g=0,!(N&1)&&(g=0,be(36,h|0,0)|0,N=g,g=0,!(N&1))&&(w=Ct(16)|0,g=0,Ae(64,R|0,C|0),N=g,g=0,N&1?h=j()|0:(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,w|0,3,35648,R|0),N=g,g=0,N&1?d=1:(g=0,xe(6,w|0,824,96),g=0,d=0),h=j()|0,de(R),d||(R=h,e[_>>2]=36200,e[o>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(o),le(R|0))),Tt(w|0),R=h,e[_>>2]=36200,e[o>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(o),le(R|0)),R=j()|0,e[_>>2]=36200,e[o>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(o),le(R|0)}while(!1);_=h,tt(o),le(_|0)}function ss(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;C=t+4|0,t=e[C>>2]|0;e:do switch(e[t+16>>2]|0){case 3:{if((e[t+24>>2]|0)==2){if((l|0)>0)t=0;else break e;for(;;)if(d=F[r+(t*3|0)+1>>0]|0,h=F[r+(t*3|0)+2>>0]|0,w=(F[r+(t*3|0)>>0]|0)-((h+d|0)>>>2)+64|0,c=o+(t*3|0)|0,S[c>>0]=h+128+w,S[c+1>>0]=w,S[c+2>>0]=d+128+w,t=t+1|0,(t|0)==(l|0))break e}if(t=(l|0)<(c|0)?l:c,(t|0)>0){h=c<<1,d=0;do k=F[r+(d+c)>>0]|0,N=F[r+(d+h)>>0]|0,D=(F[r+d>>0]|0)-((N+k|0)>>>2)+64|0,w=o+(d*3|0)|0,S[w>>0]=N+128+D,S[w+1>>0]=D,S[w+2>>0]=k+128+D,d=d+1|0;while((d|0)!=(t|0))}break}case 4:{if((e[t+24>>2]|0)==1&&(w=(l|0)<(c|0)?l:c,(w|0)>0)){t=c<<1,h=c*3|0,d=0;do D=F[r+(d+c)>>0]|0,R=F[r+(d+t)>>0]|0,k=(F[r+d>>0]|0)-((R+D|0)>>>2)+64|0,N=o+(d<<2)|0,k=k<<8&65280|F[r+(d+h)>>0]<<24|R+128+k&255|D+128+k<<16&16711680,S[N>>0]=k,S[N+1>>0]=k>>8,S[N+2>>0]=k>>16,S[N+3>>0]=k>>24,d=d+1|0;while((d|0)!=(w|0))}break}default:}while(!1);if(t=e[C>>2]|0,!!(S[t+32>>0]|0)){if(d=e[t+16>>2]|0,(l|0)>0)t=o,h=0;else return;for(;R=t+2|0,N=S[t>>0]|0,S[t>>0]=S[R>>0]|0,S[R>>0]=N,h=h+1|0,(h|0)!=(l|0);)t=t+d|0}}function A1(t){t=t|0;var r=0,o=0;e[t>>2]=36664,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=e[t+8>>2]|0,o&&(r=t+12|0,(e[r>>2]|0)!=(o|0)&&(e[r>>2]=o),he(o))}function v1(t){t=t|0;var r=0,o=0;if(e[t>>2]=36664,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),r=e[t+8>>2]|0,!r){he(t);return}o=t+12|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r),he(t)}function x1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0;if(c=t+36|0,!(e[c>>2]|0)){c=t+40|0,os(t,r,e[c>>2]|0,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}h=ee(e[(e[t+4>>2]|0)+16>>2]|0,o)|0,d=t+20|0,os(t,r,e[d>>2]|0,o,l),t=e[c>>2]|0,(Yt[e[(e[t>>2]|0)+48>>2]&63](t,e[d>>2]|0,h)|0)!=(h|0)&&(c=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,c|0,3,35648),d=g,g=0,d&1?(d=j()|0,Tt(c|0),le(d|0)):Qt(c|0,824,96))}function w1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0;if(c=e[t+36>>2]|0,c){y1(t,c,r,o,l);return}else{c=t+40|0,Yn(t,e[c>>2]|0,r,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}}function Yn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0;if(w=t+4|0,h=e[w>>2]|0,!(S[h+32>>0]|0))w=r;else{if(d=t+8|0,o0(e[d>>2]|0,r|0,l*3|0)|0,h=e[w>>2]|0,r=e[h+16>>2]|0,(l|0)>0){for(h=e[d>>2]|0,t=0;C=h+2|0,D=S[h>>0]|0,S[h>>0]=S[C>>0]|0,S[C>>0]=D,t=t+1|0,(t|0)!=(l|0);)h=h+r|0;h=e[w>>2]|0}w=e[d>>2]|0}switch(e[h+16>>2]|0){case 3:{if((e[h+24>>2]|0)==2){if((l|0)>0)h=0;else return;do r=F[w+(h*3|0)>>0]|0,c=S[w+(h*3|0)+1>>0]|0,d=c&255,C=(F[w+(h*3|0)+2>>0]|0)+128-((d+r|0)>>>1)&255,D=o+(h*3|0)|0,S[D>>0]=r+128-d,S[D+1>>0]=c,S[D+2>>0]=C,h=h+1|0;while((h|0)!=(l|0));return}if(h=(c|0)<(l|0)?c:l,(h|0)<=0)return;t=c<<1,r=0;do C=S[w+(r*3|0)+1>>0]|0,d=F[w+(r*3|0)>>0]|0,l=C&255,D=(F[w+(r*3|0)+2>>0]|0)+128-((l+d|0)>>>1)&255,S[o+r>>0]=d+128-l,S[o+(r+c)>>0]=C,S[o+(r+t)>>0]=D,r=r+1|0;while((r|0)!=(h|0));return}case 4:{if((e[h+24>>2]|0)!=1||(h=(c|0)<(l|0)?c:l,(h|0)<=0))return;t=c<<1,r=c*3|0,d=0;do l=S[w+(d<<2)+1>>0]|0,D=S[w+(d<<2)+3>>0]|0,N=F[w+(d<<2)>>0]|0,k=l&255,C=(F[w+(d<<2)+2>>0]|0)+128-((k+N|0)>>>1)&255,S[o+d>>0]=N+128-k,S[o+(d+c)>>0]=l,S[o+(d+t)>>0]=C,S[o+(d+r)>>0]=D,d=d+1|0;while((d|0)!=(h|0));return}default:return}}function y1(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(k=b,b=b+176|0,N=k+152|0,_=k+16|0,R=k,d=ee(e[(e[t+4>>2]|0)+16>>2]|0,l)|0,C=t+20|0,h=e[C>>2]|0,!d){_=h,Yn(t,_,o,l,c),b=k;return}for(;w=Yt[e[(e[r>>2]|0)+32>>2]&63](r,h,d)|0,!!w;)if(h=e[C>>2]|0,(d|0)==(w|0)){D=26;break}else d=d-w|0;if((D|0)==26){Yn(t,h,o,l,c),b=k;return}o=_+56|0,C=_+4|0,e[_>>2]=36160,e[o>>2]=36180,g=0,Ae(62,_+56|0,C|0),k=g,g=0,k&1&&(_=j()|0,tt(o),le(_|0)),e[_+128>>2]=0,e[_+132>>2]=-1,e[_>>2]=36200,e[_+56>>2]=36220,g=0,ue(180,C|0),k=g,g=0;do if(k&1)h=j()|0;else{if(e[C>>2]=36236,r=_+36|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[_+52>>2]=16,e[N>>2]=0,e[N+4>>2]=0,e[N+8>>2]=0,g=0,Ae(63,C|0,N|0),k=g,g=0,k&1){h=j()|0,de(N),de(r),wt(C);break}de(N),g=0,h=Ve(28,_|0,49029,57)|0,N=g,g=0,!(N&1)&&(g=0,be(36,h|0,0)|0,N=g,g=0,!(N&1))&&(w=Ct(16)|0,g=0,Ae(64,R|0,C|0),N=g,g=0,N&1?h=j()|0:(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,w|0,3,35648,R|0),N=g,g=0,N&1?d=1:(g=0,xe(6,w|0,824,96),g=0,d=0),h=j()|0,de(R),d||(R=h,e[_>>2]=36200,e[o>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(o),le(R|0))),Tt(w|0),R=h,e[_>>2]=36200,e[o>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(o),le(R|0)),R=j()|0,e[_>>2]=36200,e[o>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(o),le(R|0)}while(!1);_=h,tt(o),le(_|0)}function os(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0;C=t+4|0,t=e[C>>2]|0;e:do switch(e[t+16>>2]|0){case 3:{if((e[t+24>>2]|0)==2){if((l|0)>0)t=0;else break e;for(;;)if(d=S[r+(t*3|0)+1>>0]|0,w=d&255,h=(F[r+(t*3|0)>>0]|0)+128+w|0,w=(F[r+(t*3|0)+2>>0]|0)+128+(((h&255)+w|0)>>>1)&255,c=o+(t*3|0)|0,S[c>>0]=h,S[c+1>>0]=d,S[c+2>>0]=w,t=t+1|0,(t|0)==(l|0))break e}if(t=(l|0)<(c|0)?l:c,(t|0)>0){h=c<<1,d=0;do k=S[r+(d+c)>>0]|0,D=k&255,N=(F[r+d>>0]|0)+128+D|0,D=(F[r+(d+h)>>0]|0)+128+(((N&255)+D|0)>>>1)&255,w=o+(d*3|0)|0,S[w>>0]=N,S[w+1>>0]=k,S[w+2>>0]=D,d=d+1|0;while((d|0)!=(t|0))}break}case 4:{if((e[t+24>>2]|0)==1&&(w=(l|0)<(c|0)?l:c,(w|0)>0)){t=c<<1,h=c*3|0,d=0;do k=F[r+(d+c)>>0]|0,D=(F[r+d>>0]|0)+128+k&255,N=o+(d<<2)|0,k=D|k<<8|F[r+(d+h)>>0]<<24|(F[r+(d+t)>>0]|0)+128+((D+k|0)>>>1)<<16&16711680,S[N>>0]=k,S[N+1>>0]=k>>8,S[N+2>>0]=k>>16,S[N+3>>0]=k>>24,d=d+1|0;while((d|0)!=(w|0))}break}default:}while(!1);if(t=e[C>>2]|0,!!(S[t+32>>0]|0)){if(d=e[t+16>>2]|0,(l|0)>0)t=o,h=0;else return;for(;N=t+2|0,k=S[t>>0]|0,S[t>>0]=S[N>>0]|0,S[N>>0]=k,h=h+1|0,(h|0)!=(l|0);)t=t+d|0}}function C1(t){t=t|0;var r=0,o=0;e[t>>2]=36688,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=e[t+8>>2]|0,o&&(r=t+12|0,(e[r>>2]|0)!=(o|0)&&(e[r>>2]=o),he(o))}function T1(t){t=t|0;var r=0,o=0;if(e[t>>2]=36688,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),r=e[t+8>>2]|0,!r){he(t);return}o=t+12|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r),he(t)}function I1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0;if(c=t+36|0,!(e[c>>2]|0)){c=t+40|0,as(t,r,e[c>>2]|0,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}h=ee(e[(e[t+4>>2]|0)+16>>2]|0,o)|0,d=t+20|0,as(t,r,e[d>>2]|0,o,l),t=e[c>>2]|0,(Yt[e[(e[t>>2]|0)+48>>2]&63](t,e[d>>2]|0,h)|0)!=(h|0)&&(c=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,c|0,3,35648),d=g,g=0,d&1?(d=j()|0,Tt(c|0),le(d|0)):Qt(c|0,824,96))}function E1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0;if(c=e[t+36>>2]|0,c){D1(t,c,r,o,l);return}else{c=t+40|0,jn(t,e[c>>2]|0,r,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}}function jn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0;if(w=t+4|0,h=e[w>>2]|0,!(S[h+32>>0]|0))w=r;else{if(d=t+8|0,o0(e[d>>2]|0,r|0,l*3|0)|0,h=e[w>>2]|0,r=e[h+16>>2]|0,(l|0)>0){for(h=e[d>>2]|0,t=0;C=h+2|0,D=S[h>>0]|0,S[h>>0]=S[C>>0]|0,S[C>>0]=D,t=t+1|0,(t|0)!=(l|0);)h=h+r|0;h=e[w>>2]|0}w=e[d>>2]|0}switch(e[h+16>>2]|0){case 3:{if((e[h+24>>2]|0)==2){if((l|0)>0)h=0;else return;do c=S[w+(h*3|0)+1>>0]|0,d=c&255,C=128-d+(F[w+(h*3|0)+2>>0]|0)&255,D=o+(h*3|0)|0,S[D>>0]=(F[w+(h*3|0)>>0]|0)+128-d,S[D+1>>0]=c,S[D+2>>0]=C,h=h+1|0;while((h|0)!=(l|0));return}if(h=(c|0)<(l|0)?c:l,(h|0)<=0)return;t=c<<1,r=0;do C=S[w+(r*3|0)+1>>0]|0,l=C&255,D=128-l+(F[w+(r*3|0)+2>>0]|0)&255,S[o+r>>0]=(F[w+(r*3|0)>>0]|0)+128-l,S[o+(r+c)>>0]=C,S[o+(r+t)>>0]=D,r=r+1|0;while((r|0)!=(h|0));return}case 4:{if((e[h+24>>2]|0)!=1||(h=(c|0)<(l|0)?c:l,(h|0)<=0))return;t=c<<1,r=c*3|0,d=0;do l=S[w+(d<<2)+1>>0]|0,D=S[w+(d<<2)+3>>0]|0,k=l&255,C=128-k+(F[w+(d<<2)+2>>0]|0)&255,S[o+d>>0]=(F[w+(d<<2)>>0]|0)+128-k,S[o+(d+c)>>0]=l,S[o+(d+t)>>0]=C,S[o+(d+r)>>0]=D,d=d+1|0;while((d|0)!=(h|0));return}default:return}}function D1(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(k=b,b=b+176|0,N=k+152|0,_=k+16|0,R=k,d=ee(e[(e[t+4>>2]|0)+16>>2]|0,l)|0,C=t+20|0,h=e[C>>2]|0,!d){_=h,jn(t,_,o,l,c),b=k;return}for(;w=Yt[e[(e[r>>2]|0)+32>>2]&63](r,h,d)|0,!!w;)if(h=e[C>>2]|0,(d|0)==(w|0)){D=26;break}else d=d-w|0;if((D|0)==26){jn(t,h,o,l,c),b=k;return}o=_+56|0,C=_+4|0,e[_>>2]=36160,e[o>>2]=36180,g=0,Ae(62,_+56|0,C|0),k=g,g=0,k&1&&(_=j()|0,tt(o),le(_|0)),e[_+128>>2]=0,e[_+132>>2]=-1,e[_>>2]=36200,e[_+56>>2]=36220,g=0,ue(180,C|0),k=g,g=0;do if(k&1)h=j()|0;else{if(e[C>>2]=36236,r=_+36|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[_+52>>2]=16,e[N>>2]=0,e[N+4>>2]=0,e[N+8>>2]=0,g=0,Ae(63,C|0,N|0),k=g,g=0,k&1){h=j()|0,de(N),de(r),wt(C);break}de(N),g=0,h=Ve(28,_|0,49029,57)|0,N=g,g=0,!(N&1)&&(g=0,be(36,h|0,0)|0,N=g,g=0,!(N&1))&&(w=Ct(16)|0,g=0,Ae(64,R|0,C|0),N=g,g=0,N&1?h=j()|0:(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,w|0,3,35648,R|0),N=g,g=0,N&1?d=1:(g=0,xe(6,w|0,824,96),g=0,d=0),h=j()|0,de(R),d||(R=h,e[_>>2]=36200,e[o>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(o),le(R|0))),Tt(w|0),R=h,e[_>>2]=36200,e[o>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(o),le(R|0)),R=j()|0,e[_>>2]=36200,e[o>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(o),le(R|0)}while(!1);_=h,tt(o),le(_|0)}function as(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0;C=t+4|0,t=e[C>>2]|0;e:do switch(e[t+16>>2]|0){case 3:{if((e[t+24>>2]|0)==2){if((l|0)>0)t=0;else break e;for(;;)if(d=S[r+(t*3|0)+1>>0]|0,h=d&255,w=h+128+(F[r+(t*3|0)+2>>0]|0)&255,c=o+(t*3|0)|0,S[c>>0]=(F[r+(t*3|0)>>0]|0)+128+h,S[c+1>>0]=d,S[c+2>>0]=w,t=t+1|0,(t|0)==(l|0))break e}if(t=(l|0)<(c|0)?l:c,(t|0)>0){h=c<<1,d=0;do k=S[r+(d+c)>>0]|0,N=k&255,D=N+128+(F[r+(d+h)>>0]|0)&255,w=o+(d*3|0)|0,S[w>>0]=(F[r+d>>0]|0)+128+N,S[w+1>>0]=k,S[w+2>>0]=D,d=d+1|0;while((d|0)!=(t|0))}break}case 4:{if((e[t+24>>2]|0)==1&&(w=(l|0)<(c|0)?l:c,(w|0)>0)){t=c<<1,h=c*3|0,d=0;do k=F[r+(d+c)>>0]|0,N=o+(d<<2)|0,k=(F[r+d>>0]|0)+128+k&255|k<<8|F[r+(d+h)>>0]<<24|k+128+(F[r+(d+t)>>0]|0)<<16&16711680,S[N>>0]=k,S[N+1>>0]=k>>8,S[N+2>>0]=k>>16,S[N+3>>0]=k>>24,d=d+1|0;while((d|0)!=(w|0))}break}default:}while(!1);if(t=e[C>>2]|0,!!(S[t+32>>0]|0)){if(d=e[t+16>>2]|0,(l|0)>0)t=o,h=0;else return;for(;N=t+2|0,k=S[t>>0]|0,S[t>>0]=S[N>>0]|0,S[N>>0]=k,h=h+1|0,(h|0)!=(l|0);)t=t+d|0}}function b1(t){t=t|0;var r=0,o=0;e[t>>2]=36712,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=e[t+8>>2]|0,o&&(r=t+12|0,(e[r>>2]|0)!=(o|0)&&(e[r>>2]=o),he(o))}function N1(t){t=t|0;var r=0,o=0;if(e[t>>2]=36712,r=e[t+20>>2]|0,r&&(o=t+24|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),r=e[t+8>>2]|0,!r){he(t);return}o=t+12|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r),he(t)}function F1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0;if(c=t+36|0,!(e[c>>2]|0)){c=t+40|0,ls(t,r,e[c>>2]|0,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}h=ee(e[(e[t+4>>2]|0)+16>>2]|0,o)|0,d=t+20|0,ls(t,r,e[d>>2]|0,o,l),t=e[c>>2]|0,(Yt[e[(e[t>>2]|0)+48>>2]&63](t,e[d>>2]|0,h)|0)!=(h|0)&&(c=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,c|0,3,35648),d=g,g=0,d&1?(d=j()|0,Tt(c|0),le(d|0)):Qt(c|0,824,96))}function R1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0;if(c=e[t+36>>2]|0,c){M1(t,c,r,o,l);return}else{c=t+40|0,Xn(t,e[c>>2]|0,r,o,l),e[c>>2]=(e[c>>2]|0)+(e[(e[t+4>>2]|0)+12>>2]|0);return}}function Xn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0;if(w=t+4|0,h=e[w>>2]|0,!(S[h+32>>0]|0))w=r;else{if(d=t+8|0,o0(e[d>>2]|0,r|0,l*3|0)|0,h=e[w>>2]|0,r=e[h+16>>2]|0,(l|0)>0){for(h=e[d>>2]|0,t=0;C=h+2|0,D=S[h>>0]|0,S[h>>0]=S[C>>0]|0,S[C>>0]=D,t=t+1|0,(t|0)!=(l|0);)h=h+r|0;h=e[w>>2]|0}w=e[d>>2]|0}switch(e[h+16>>2]|0){case 3:{if((e[h+24>>2]|0)==2){if((l|0)>0)h=0;else return;do c=S[w+(h*3|0)+1>>0]|0,C=S[w+(h*3|0)+2>>0]|0,D=o+(h*3|0)|0,S[D>>0]=S[w+(h*3|0)>>0]|0,S[D+1>>0]=c,S[D+2>>0]=C,h=h+1|0;while((h|0)!=(l|0));return}if(h=(c|0)<(l|0)?c:l,(h|0)<=0)return;t=c<<1,r=0;do C=S[w+(r*3|0)+1>>0]|0,D=S[w+(r*3|0)+2>>0]|0,S[o+r>>0]=S[w+(r*3|0)>>0]|0,S[o+(r+c)>>0]=C,S[o+(r+t)>>0]=D,r=r+1|0;while((r|0)!=(h|0));return}case 4:{if((e[h+24>>2]|0)!=1||(h=(c|0)<(l|0)?c:l,(h|0)<=0))return;t=c<<1,r=c*3|0,d=0;do l=S[w+(d<<2)+1>>0]|0,C=S[w+(d<<2)+2>>0]|0,D=S[w+(d<<2)+3>>0]|0,S[o+d>>0]=S[w+(d<<2)>>0]|0,S[o+(d+c)>>0]=l,S[o+(d+t)>>0]=C,S[o+(d+r)>>0]=D,d=d+1|0;while((d|0)!=(h|0));return}default:return}}function M1(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(k=b,b=b+176|0,N=k+152|0,_=k+16|0,R=k,d=ee(e[(e[t+4>>2]|0)+16>>2]|0,l)|0,C=t+20|0,h=e[C>>2]|0,!d){_=h,Xn(t,_,o,l,c),b=k;return}for(;w=Yt[e[(e[r>>2]|0)+32>>2]&63](r,h,d)|0,!!w;)if(h=e[C>>2]|0,(d|0)==(w|0)){D=26;break}else d=d-w|0;if((D|0)==26){Xn(t,h,o,l,c),b=k;return}o=_+56|0,C=_+4|0,e[_>>2]=36160,e[o>>2]=36180,g=0,Ae(62,_+56|0,C|0),k=g,g=0,k&1&&(_=j()|0,tt(o),le(_|0)),e[_+128>>2]=0,e[_+132>>2]=-1,e[_>>2]=36200,e[_+56>>2]=36220,g=0,ue(180,C|0),k=g,g=0;do if(k&1)h=j()|0;else{if(e[C>>2]=36236,r=_+36|0,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,e[r+12>>2]=0,e[_+52>>2]=16,e[N>>2]=0,e[N+4>>2]=0,e[N+8>>2]=0,g=0,Ae(63,C|0,N|0),k=g,g=0,k&1){h=j()|0,de(N),de(r),wt(C);break}de(N),g=0,h=Ve(28,_|0,49029,57)|0,N=g,g=0,!(N&1)&&(g=0,be(36,h|0,0)|0,N=g,g=0,!(N&1))&&(w=Ct(16)|0,g=0,Ae(64,R|0,C|0),N=g,g=0,N&1?h=j()|0:(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,w|0,3,35648,R|0),N=g,g=0,N&1?d=1:(g=0,xe(6,w|0,824,96),g=0,d=0),h=j()|0,de(R),d||(R=h,e[_>>2]=36200,e[o>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(o),le(R|0))),Tt(w|0),R=h,e[_>>2]=36200,e[o>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(o),le(R|0)),R=j()|0,e[_>>2]=36200,e[o>>2]=36220,e[C>>2]=36236,de(r),wt(C),tt(o),le(R|0)}while(!1);_=h,tt(o),le(_|0)}function ls(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0;C=t+4|0,t=e[C>>2]|0;e:do switch(e[t+16>>2]|0){case 3:{if((e[t+24>>2]|0)==2){if((l|0)>0)t=0;else break e;for(;;)if(d=S[r+(t*3|0)+1>>0]|0,w=S[r+(t*3|0)+2>>0]|0,c=o+(t*3|0)|0,S[c>>0]=S[r+(t*3|0)>>0]|0,S[c+1>>0]=d,S[c+2>>0]=w,t=t+1|0,(t|0)==(l|0))break e}if(t=(l|0)<(c|0)?l:c,(t|0)>0){h=c<<1,d=0;do k=S[r+(d+c)>>0]|0,D=S[r+(d+h)>>0]|0,w=o+(d*3|0)|0,S[w>>0]=S[r+d>>0]|0,S[w+1>>0]=k,S[w+2>>0]=D,d=d+1|0;while((d|0)!=(t|0))}break}case 4:{if((e[t+24>>2]|0)==1&&(w=(l|0)<(c|0)?l:c,(w|0)>0)){t=c<<1,h=c*3|0,d=0;do k=o+(d<<2)|0,D=F[r+(d+c)>>0]<<8|F[r+d>>0]|F[r+(d+t)>>0]<<16|F[r+(d+h)>>0]<<24,S[k>>0]=D,S[k+1>>0]=D>>8,S[k+2>>0]=D>>16,S[k+3>>0]=D>>24,d=d+1|0;while((d|0)!=(w|0))}break}default:}while(!1);if(t=e[C>>2]|0,!!(S[t+32>>0]|0)){if(d=e[t+16>>2]|0,(l|0)>0)t=o,h=0;else return;for(;k=t+2|0,D=S[t>>0]|0,S[t>>0]=S[k>>0]|0,S[k>>0]=D,h=h+1|0,(h|0)!=(l|0);)t=t+d|0}}function us(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;K=b,b=b+32|0,$=K+12|0,Q=K,R=t+180|0,_=(e[R>>2]|0)+4|0,(e[t+32>>2]|0)==1?U=e[t+24>>2]|0:U=1,r=ee(U<<1,_)|0,e[$>>2]=0,P=$+4|0,e[P>>2]=0,e[$+8>>2]=0;e:do if(r){if(r>>>0>1431655765&&(g=0,ue(178,$|0),G=g,g=0,G&1)||(h=6),(h|0)==6&&(g=0,o=ge(67,r*3|0)|0,G=g,g=0,!(G&1))){for(e[P>>2]=o,e[$>>2]=o,e[$+8>>2]=o+(r*3|0);;)if(S[o>>0]=0,S[o+1>>0]=0,S[o+2>>0]=0,o=(e[P>>2]|0)+3|0,e[P>>2]=o,r=r+-1|0,!r)break e}l=j()|0,r=e[$>>2]|0,r||le(l|0),o=e[P>>2]|0,(o|0)!=(r|0)&&(e[P>>2]=o+(~(((o+-3-r|0)>>>0)/3|0)*3|0)),he(r),le(l|0)}while(!1);e[Q>>2]=0,G=Q+4|0,e[G>>2]=0,e[Q+8>>2]=0;do if(!U)h=19;else{if(U>>>0>1073741823&&(g=0,ue(178,Q|0),N=g,g=0,N&1)||(h=17),(h|0)==17&&(l=U<<2,g=0,c=ge(67,l|0)|0,N=g,g=0,!(N&1))){e[Q>>2]=c,h=c+(U<<2)|0,e[Q+8>>2]=h,Jt(c|0,0,l|0)|0,e[G>>2]=h,h=19;break}l=j()|0,r=e[Q>>2]|0,o=r,r&&(c=e[G>>2]|0,(c|0)!=(r|0)&&(e[G>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}while(!1);if((h|0)==19){c=t+12|0;e:do if((e[c>>2]|0)>0){h=t+4604|0,d=(ee(U,_)|0)+1|0,w=t+4608|0,C=t+92|0,D=(U|0)>0,k=t+4600|0,N=0;t:for(;;){if(l=e[$>>2]|0,r=l+3|0,e[h>>2]=r,o=l+(d*3|0)|0,e[w>>2]=o,N&1?(e[h>>2]=o,e[w>>2]=r,r=1):r=d,o=e[C>>2]|0,g=0,$e(e[(e[o>>2]|0)+12>>2]|0,o|0,l+(r*3|0)|0,e[R>>2]|0,_|0),l=g,g=0,l&1){h=29;break}if(D){r=e[Q>>2]|0,o=e[h>>2]|0,l=0;do{if(e[k>>2]=e[r+(l<<2)>>2],O=e[R>>2]|0,r=o+(O*3|0)|0,o=o+((O+-1|0)*3|0)|0,S[r>>0]=S[o>>0]|0,S[r+1>>0]=S[o+1>>0]|0,S[r+2>>0]=S[o+2>>0]|0,r=e[h>>2]|0,o=(e[w>>2]|0)+-3|0,S[o>>0]=S[r>>0]|0,S[o+1>>0]=S[r+1>>0]|0,S[o+2>>0]=S[r+2>>0]|0,g=0,Ae(70,t|0,0),o=g,g=0,o&1){h=28;break t}r=e[Q>>2]|0,e[r+(l<<2)>>2]=e[k>>2],o=(e[h>>2]|0)+(_*3|0)|0,e[h>>2]=o,e[w>>2]=(e[w>>2]|0)+(_*3|0),l=l+1|0}while((l|0)<(U|0))}if(N=N+1|0,(N|0)>=(e[c>>2]|0)){h=41;break e}}if((h|0)==28){l=j()|0;break}else if((h|0)==29){l=j()|0;break}}else h=41;while(!1);do if((h|0)==41){if(g=0,ue(182,t|0),O=g,g=0,O&1){l=j()|0;break}if(r=e[Q>>2]|0,o=r,r&&(l=e[G>>2]|0,(l|0)!=(r|0)&&(e[G>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[$>>2]|0,!r){b=K;return}o=e[P>>2]|0,(o|0)!=(r|0)&&(e[P>>2]=o+(~(((o+-3-r|0)>>>0)/3|0)*3|0)),he(r),b=K;return}while(!1);r=e[Q>>2]|0,o=r,r&&(c=e[G>>2]|0,(c|0)!=(r|0)&&(e[G>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}r=e[$>>2]|0,r||le(l|0),o=e[P>>2]|0,(o|0)!=(r|0)&&(e[P>>2]=o+(~(((o+-3-r|0)>>>0)/3|0)*3|0)),he(r),le(l|0)}function _1(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0;if(oe=t+180|0,!((e[oe>>2]|0)<=0))for(ne=t+4608|0,ce=t+4604|0,ke=t+4612|0,ie=0;P=ie+-1|0,h=e[ne>>2]|0,d=e[ce>>2]|0,r=ie+1|0,c=F[d+(ie*3|0)>>0]|0,Z=e[ke>>2]|0,w=F[d+(P*3|0)>>0]|0,C=c-w|0,D=F[h+(P*3|0)>>0]|0,k=w-D|0,N=((((S[Z+((F[d+(r*3|0)>>0]|0)-c)>>0]|0)*9|0)+(S[Z+C>>0]|0)|0)*9|0)+(S[Z+k>>0]|0)|0,l=F[d+(ie*3|0)+1>>0]|0,R=F[d+(P*3|0)+1>>0]|0,_=l-R|0,U=F[h+(P*3|0)+1>>0]|0,Q=R-U|0,K=((((S[Z+((F[d+(r*3|0)+1>>0]|0)-l)>>0]|0)*9|0)+(S[Z+_>>0]|0)|0)*9|0)+(S[Z+Q>>0]|0)|0,o=F[d+(ie*3|0)+2>>0]|0,G=F[d+(P*3|0)+2>>0]|0,$=o-G|0,P=F[h+(P*3|0)+2>>0]|0,O=G-P|0,Z=((((S[Z+((F[d+(r*3|0)+2>>0]|0)-o)>>0]|0)*9|0)+(S[Z+$>>0]|0)|0)*9|0)+(S[Z+O>>0]|0)|0,K|N|Z?(d=F[h+(ie*3|0)>>0]|0,h=c-D>>31,(h^k|0)>=0&&((h^C|0)<0?c=D:c=D-w+c|0),d=Zn(t,N,d,c,0)|0,h=F[(e[ne>>2]|0)+(ie*3|0)+1>>0]|0,c=l-U>>31,(c^Q|0)>=0&&((c^_|0)<0?l=U:l=U-R+l|0),c=Zn(t,K,h,l,0)|0,h=F[(e[ne>>2]|0)+(ie*3|0)+2>>0]|0,l=o-P>>31,(l^O|0)>=0&&((l^$|0)<0?o=P:o=P-G+o|0),Z=Zn(t,Z,h,o,0)|0,ie=(e[ne>>2]|0)+(ie*3|0)|0,S[ie>>0]=d,S[ie+1>>0]=c,S[ie+2>>0]=Z):r=(P1(t,ie,0)|0)+ie|0,(r|0)<(e[oe>>2]|0);)ie=r}function P1(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0;for(oe=b,b=b+32|0,ie=oe+15|0,R=oe+12|0,N=oe+9|0,_=oe+6|0,$=oe+3|0,P=oe,O=(e[t+180>>2]|0)-r|0,Z=e[t+4608>>2]|0,U=e[t+4604>>2]|0,G=Z+((r+-1|0)*3|0)|0,Q=S[G>>0]|0,K=S[G+1>>0]|0,G=S[G+2>>0]|0,o=Q&255,l=t+144|0,c=K&255,h=G&255,k=0;d=Z+((k+r|0)*3|0)|0,w=d+1|0,C=d+2|0,ne=(F[d>>0]|0)-o|0,D=e[l>>2]|0,!((((ne|0)>-1?ne:0-ne|0)|0)>(D|0)||(ne=(F[w>>0]|0)-c|0,(((ne|0)>-1?ne:0-ne|0)|0)>(D|0))||(ne=(F[C>>0]|0)-h|0,(((ne|0)>-1?ne:0-ne|0)|0)>(D|0)));)if(S[d>>0]=Q,S[w>>0]=K,S[C>>0]=G,k=k+1|0,(k|0)==(O|0)){k=O;break}if(c=(k|0)==(O|0),h=t+4600|0,l=e[36476+(e[h>>2]<<2)>>2]|0,(1<(k|0))o=k;else{o=k;do _t(t,1,1),l=e[h>>2]|0,o=o-(1<>2])|0,l=(l|0)>30?31:l+1|0,e[h>>2]=l,l=e[36476+(l<<2)>>2]|0;while((o|0)>=(1<>0]=S[ne>>0]|0,S[$+1>>0]=S[ne+1>>0]|0,S[$+2>>0]=S[ne+2>>0]|0,S[P>>0]=Q,S[P+1>>0]=K,S[P+2>>0]=G,r=U+(r*3|0)|0,S[N>>0]=S[$>>0]|0,S[N+1>>0]=S[$+1>>0]|0,S[N+2>>0]=S[$+2>>0]|0,S[R>>0]=S[P>>0]|0,S[R+1>>0]=S[P+1>>0]|0,S[R+2>>0]=S[P+2>>0]|0,S[ie>>0]=S[r>>0]|0,S[ie+1>>0]=S[r+1>>0]|0,S[ie+2>>0]=S[r+2>>0]|0,L1(_,t,N,R,ie),S[ne>>0]=S[_>>0]|0,S[ne+1>>0]=S[_+1>>0]|0,S[ne+2>>0]=S[_+2>>0]|0,ne=e[h>>2]|0,e[h>>2]=(ne|0)<1?0:ne+-1|0,ne=k+1|0,b=oe,ne|0)}function Zn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;if(Q=r>>31,h=(Q^r)-Q|0,_=t+196+(h*12|0)+10|0,d=E[_>>1]|0,R=t+196+(h*12|0)|0,c=e[R>>2]|0,(d|0)<(c|0))if((d<<1|0)<(c|0))if((d<<2|0)<(c|0))if((d<<3|0)<(c|0))if((d<<4|0)<(c|0))for(r=5;(d<>1]^Q)-Q+l|0,U=t+136|0,l=e[U>>2]|0,(c&l|0)==(c|0)?D=c:D=l&~(c>>31),c=(o-D^Q)-Q|0,C=t+144|0,l=e[C>>2]|0,(c|0)>0?c=(c+l|0)/(l<<1|1|0)|0:c=(c-l|0)/(l<<1|1|0)|0,N=t+140|0,w=e[N>>2]|0,o=((c|0)<0?w:0)+c|0,w=o-((o|0)<((w+1|0)/2|0|0)?0:w)|0,h=t+196+(h*12|0)+4|0,l|r?c=0:c=(e[h>>2]<<1)+-1+d>>31,l=c^w,cs(t,r,l>>30^l<<1,e[t+156>>2]|0),l=e[t+160>>2]|0,r=(e[R>>2]|0)+((w|0)>-1?w:0-w|0)|0,c=(e[h>>2]|0)+(ee(e[C>>2]<<1|1,w)|0)|0,o=E[_>>1]|0,(o|0)==(l|0)&&(r=r>>1,c=c>>1,o=l>>1),e[R>>2]=r,l=o+1|0,E[_>>1]=l,r=l+c|0,(r|0)>=1?(c|0)>0&&(c=c-l|0,_=E[k>>1]|0,E[k>>1]=(_<<16>>16<127&1)+(_&65535),c=(c|0)>0?0:c):(c=E[k>>1]|0,E[k>>1]=(c&65535)-(c<<16>>16>-128&1),c=(r|0)>(~o|0)?r:0-o|0),e[h>>2]=c,l=e[C>>2]|0,o=l<<1|1,r=(ee(o,(w^Q)-Q|0)|0)+D|0,(r|0)>=(0-l|0)?(c=e[U>>2]|0,(c+l|0)<(r|0)&&(r=r-(ee(e[N>>2]|0,o)|0)|0)):(r=(ee(e[N>>2]|0,o)|0)+r|0,c=e[U>>2]|0),(r&c|0)==(r|0)?(Q=r,Q=Q&255,Q|0):(Q=c&~(r>>31),Q=Q&255,Q|0)}function cs(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0;if(c=o>>r,h=t+148|0,d=l-(e[h>>2]|0)|0,(c|0)<(d+-1|0)){(c|0)>30&&(l=(c|0)/2|0,_t(t,0,l),c=c-l|0),_t(t,1,c+1|0),_t(t,(1<31?(_t(t,0,31),_t(t,1,l+-31-(e[h>>2]|0)|0)):_t(t,1,d),r=e[h>>2]|0,_t(t,(1<>0]|0,R=N-(F[l>>0]|0)>>31|1,h=ee(R,(F[o>>0]|0)-N|0)|0,D=r+144|0,d=e[D>>2]|0,(h|0)>0?h=(h+d|0)/(d<<1|1|0)|0:h=(h-d|0)/(d<<1|1|0)|0,P=r+140|0,C=e[P>>2]|0,w=((h|0)<0?C:0)+h|0,C=w-((w|0)<((C+1|0)/2|0|0)?0:C)|0,w=r+4576|0,Jn(r,w,C),K=F[c+1>>0]|0,G=K-(F[l+1>>0]|0)>>31|1,h=ee(G,(F[o+1>>0]|0)-K|0)|0,d=e[D>>2]|0,(h|0)>0?h=(h+d|0)/(d<<1|1|0)|0:h=(h-d|0)/(d<<1|1|0)|0,_=e[P>>2]|0,$=((h|0)<0?_:0)+h|0,_=$-(($|0)<((_+1|0)/2|0|0)?0:_)|0,Jn(r,w,_),$=F[c+2>>0]|0,Q=$-(F[l+2>>0]|0)>>31|1,h=ee(Q,(F[o+2>>0]|0)-$|0)|0,d=e[D>>2]|0,(h|0)>0?h=(h+d|0)/(d<<1|1|0)|0:h=(h-d|0)/(d<<1|1|0)|0,k=e[P>>2]|0,h=((h|0)<0?k:0)+h|0,k=h-((h|0)<((k+1|0)/2|0|0)?0:k)|0,Jn(r,w,k),w=e[D>>2]|0,D=w<<1|1,h=(ee(ee(D,C)|0,R)|0)+N|0,o=0-w|0,(h|0)>=(o|0)?(d=e[U>>2]|0,(d+w|0)<(h|0)&&(h=h-(ee(e[P>>2]|0,D)|0)|0),l=d):(h=(ee(e[P>>2]|0,D)|0)+h|0,l=e[U>>2]|0),(h&l|0)!=(h|0)&&(h=l&~(h>>31)),c=h&255,h=(ee(ee(D,_)|0,G)|0)+K|0,(h|0)>=(o|0)?(l+w|0)<(h|0)&&(h=h-(ee(e[P>>2]|0,D)|0)|0):h=(ee(e[P>>2]|0,D)|0)+h|0,(h&l|0)!=(h|0)&&(h=l&~(h>>31)),d=h&255,h=(ee(ee(D,k)|0,Q)|0)+$|0,(h|0)>=(o|0)?(l+w|0)<(h|0)&&(h=h-(ee(e[P>>2]|0,D)|0)|0):h=(ee(e[P>>2]|0,D)|0)+h|0,(h&l|0)==(h|0)){P=h,P=P&255,S[t>>0]=c,$=t+1|0,S[$>>0]=d,t=t+2|0,S[t>>0]=P;return}P=l&~(h>>31),P=P&255,S[t>>0]=c,$=t+1|0,S[$>>0]=d,t=t+2|0,S[t>>0]=P}function Jn(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=r+9|0,d=F[k>>0]|0,D=r+4|0,C=e[D>>2]|0,c=(ee(d>>>1,C)|0)+(e[r>>2]|0)|0,(d|0)<(c|0)){h=d,l=0;do h=h<<1,l=l+1|0;while((h|0)<(c|0));c=l}else c=0;(o|0)>0&(c|0)==0&&F[r+10>>0]<<1>>>0>>0?l=1:w=5;do if((w|0)==5){if(l=(o|0)<0,l&&F[r+10>>0]<<1>>>0>=d>>>0){l=1;break}l=l&(c|0)!=0}while(!1);if(l=(((o|0)>-1?o:0-o|0)<<1)-C+(l<<31>>31)|0,cs(t,c,l,(e[t+156>>2]|0)+-1-(e[36476+(e[t+4600>>2]<<2)>>2]|0)|0),(o|0)<0&&(t=r+10|0,S[t>>0]=(F[t>>0]|0)+1),l=(l+1-(e[D>>2]|0)>>1)+(e[r>>2]|0)|0,e[r>>2]=l,c=S[k>>0]|0,c<<24>>24!=(S[r+8>>0]|0)){r=c,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r;return}e[r>>2]=l>>1,t=(c&255)>>>1,S[k>>0]=t,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,r=t,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r}function O1(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;R=b,b=b+32|0,l=R,N=t+144|0;e:do if(e[N>>2]|0)r=t+152|0;else if(o=e[t+136>>2]|0,r=t+152|0,(o|0)==((1<>2])+-1|0)&&(m0(l,o,0),(e[l+4>>2]|0)==(e[t+184>>2]|0))&&(e[l+8>>2]|0)==(e[t+188>>2]|0)&&(e[l+12>>2]|0)==(e[t+192>>2]|0))switch(e[r>>2]|0){case 8:{N=e[8900]|0,e[t+4612>>2]=N+(((e[8901]|0)-N|0)>>>1),b=R;return}case 10:{N=e[8903]|0,e[t+4612>>2]=N+(((e[8904]|0)-N|0)>>>1),b=R;return}case 12:{N=e[8906]|0,e[t+4612>>2]=N+(((e[8907]|0)-N|0)>>>1),b=R;return}case 16:{N=e[8909]|0,e[t+4612>>2]=N+(((e[8910]|0)-N|0)>>>1),b=R;return}default:break e}while(!1);if(k=1<>2],o=t+4616|0,l=k<<1,c=t+4620|0,h=e[c>>2]|0,r=e[o>>2]|0,d=h-r|0,l>>>0<=d>>>0?l>>>0>>0&&(w=r+l|0,(h|0)!=(w|0))&&(e[c>>2]=w):(j0(o,l-d|0),r=e[o>>2]|0),D=t+4612|0,e[D>>2]=r+k,r=0-k|0,(k|0)<=(r|0)){b=R;return}w=t+192|0,C=t+188|0,d=t+184|0,h=r;do r=e[w>>2]|0,(h|0)>(0-r|0)?(o=e[C>>2]|0,(h|0)>(0-o|0)?(l=e[d>>2]|0,(h|0)>(0-l|0)?(c=e[N>>2]|0,(h|0)>=(0-c|0)?(c|0)<(h|0)?(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1:r=0:r=-1):r=-2):r=-3):r=-4,S[(e[D>>2]|0)+h>>0]=r,h=h+1|0;while((h|0)!=(k|0));b=R}function $1(t){t=t|0;var r=0,o=0;e[t>>2]=35996,r=e[t+4592>>2]|0,r&&(o=t+4596|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),t=t+4|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function B1(t){t=t|0;var r=0,o=0;if(e[t>>2]=35996,r=e[t+4592>>2]|0,r&&(o=t+4596|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),o=t+4|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function V1(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0;c=b,b=b+32|0,w=c,m0(w,65535,0),d=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[w+8>>2]|0,l=e[r+12>>2]|0,l=l|0?l:e[w+12>>2]|0,r=e[r+16>>2]|0,o=e[w+16>>2]|0,e[t+160>>2]=d|0?d:e[w+4>>2]|0,e[t+164>>2]=h,e[t+168>>2]=l,Q1(t),l=0;do e[t+172+(l*12|0)>>2]=1024,e[t+172+(l*12|0)+4>>2]=0,E[t+172+(l*12|0)+8>>1]=0,E[t+172+(l*12|0)+10>>1]=1,l=l+1|0;while((l|0)!=365);w=(r|0?r:o)&255,e[t+4552>>2]=1024,e[t+4556>>2]=0,S[t+4560>>0]=w,S[t+4561>>0]=1,S[t+4562>>0]=0,e[t+4564>>2]=1024,e[t+4568>>2]=1,S[t+4572>>0]=w,S[t+4573>>0]=1,S[t+4574>>0]=0,e[t+4576>>2]=0,b=c}function U1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=b,b=b+16|0,C=k,w=t+92|0,d=e[r>>2]|0,e[r>>2]=0,r=e[w>>2]|0,e[w>>2]=d,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),e[C>>2]=0,e[C+4>>2]=l,w=o+8|0,e[C+8>>2]=e[w>>2],l){r=Xe(4600)|0,l=t+8|0,c=r+4|0,h=l,d=c+84|0;do e[c>>2]=e[h>>2],c=c+4|0,h=h+4|0;while((c|0)<(d|0));c=r+88|0,d=c+40|0;do e[c>>2]=0,c=c+4|0;while((c|0)<(d|0));e[r>>2]=35772,c=r+132|0,e[c>>2]=0,e[c+4>>2]=0,e[c+8>>2]=0,e[c+12>>2]=0,e[r+148>>2]=e[l>>2],e[r+152>>2]=0,e[r+156>>2]=0,e[r+160>>2]=0,c=r+4544|0,l=r+164|0;do e[l>>2]=0,e[l+4>>2]=0,E[l+8>>1]=0,E[l+10>>1]=1,l=l+12|0;while((l|0)!=(c|0));h=t+4|0,e[c>>2]=0,e[c+4>>2]=0,E[c+8>>1]=0,S[c+10>>0]=0,d=r+4556|0,e[d>>2]=0,e[d+4>>2]=0,E[d+8>>1]=0,S[d+10>>0]=0,d=r+4568|0,e[d>>2]=0,e[d+4>>2]=0,e[d+8>>2]=0,e[d+12>>2]=0,e[d+16>>2]=0,e[d+20>>2]=0,e[d+24>>2]=0,S[d+28>>0]=0,e[r+28>>2]|0||(e[r+20>>2]=1),l=e[h>>2]|0,e[h>>2]=r,l&&(Mt[e[(e[l>>2]|0)+4>>2]&255](l),r=e[h>>2]|0),Y0(r,C)}return C=t+100|0,e[C>>2]=32,e[t+96>>2]=0,r=e[o>>2]|0,r?(e[t+132>>2]=r,c=t+120|0,w=t+124|0,l=e[w>>2]|0,r=e[c>>2]|0,h=r,d=l-h|0,d>>>0>=4e3?d>>>0>4e3&&(D=r+4e3|0,(l|0)!=(D|0))&&(e[w>>2]=D,l=D):(vi(c,4e3-d|0),r=e[c>>2]|0,h=r,l=e[w>>2]|0),e[t+108>>2]=h,e[t+104>>2]=l-r,fs(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0):(e[t+108>>2]=e[o+4>>2],e[t+104>>2]=e[w>>2],fs(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0)}function z1(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+32>>2]|0&&(e[t+24>>2]|0)!=1){if(_=t+8|0,Q=t+36|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(37,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+16>>2]|0,(t|0)==16)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(38,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(39,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(40,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+20>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=2,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=2,e[l+12>>2]=t,O=l,b=G,O|0)}function fs(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;G=b,b=b+32|0,P=G+12|0,K=G,_=t+156|0,U=(e[_>>2]|0)+4|0,(e[t+32>>2]|0)==1?Q=e[t+24>>2]|0:Q=1,r=ee(Q<<1,U)|0,e[P>>2]=0,O=P+4|0,e[O>>2]=0,e[P+8>>2]=0;do if(r){if((r|0)<0&&(g=0,ue(178,P|0),$=g,g=0,$&1)||(d=6),(d|0)==6&&(o=r<<1,g=0,l=ge(67,o|0)|0,$=g,g=0,!($&1))){e[P>>2]=l,$=l+(r<<1)|0,e[P+8>>2]=$,Jt(l|0,0,o|0)|0,e[O>>2]=$;break}l=j()|0,r=e[P>>2]|0,r||le(l|0),o=e[O>>2]|0,(o|0)!=(r|0)&&(e[O>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),le(l|0)}while(!1);e[K>>2]=0,$=K+4|0,e[$>>2]=0,e[K+8>>2]=0;do if(!Q)d=18;else{if(Q>>>0>1073741823&&(g=0,ue(178,K|0),R=g,g=0,R&1)||(d=16),(d|0)==16&&(c=Q<<2,g=0,h=ge(67,c|0)|0,R=g,g=0,!(R&1))){e[K>>2]=h,d=h+(Q<<2)|0,e[K+8>>2]=d,Jt(h|0,0,c|0)|0,e[$>>2]=d,d=18;break}l=j()|0,r=e[K>>2]|0,o=r,r&&(c=e[$>>2]|0,(c|0)!=(r|0)&&(e[$>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}while(!1);if((d|0)==18){h=t+12|0;e:do if((e[h>>2]|0)>0){d=t+4580|0,w=(ee(Q,U)|0)+1|0,C=t+4584|0,D=t+92|0,k=(Q|0)>0,N=t+4576|0,R=0;t:for(;;){if(o=e[P>>2]|0,r=o+2|0,e[d>>2]=r,o=o+(w<<1)|0,e[C>>2]=o,R&1?(e[d>>2]=o,e[C>>2]=r):r=o,c=e[D>>2]|0,g=0,$e(e[(e[c>>2]|0)+12>>2]|0,c|0,r|0,e[_>>2]|0,U|0),c=g,g=0,c&1){d=28;break}if(k){r=e[d>>2]|0,o=e[C>>2]|0,l=e[K>>2]|0,c=0;do{if(e[N>>2]=e[l+(c<<2)>>2],l=e[_>>2]|0,E[r+(l<<1)>>1]=E[r+(l+-1<<1)>>1]|0,E[o+-2>>1]=E[r>>1]|0,g=0,Ae(71,t|0,0),l=g,g=0,l&1){d=27;break t}l=e[K>>2]|0,e[l+(c<<2)>>2]=e[N>>2],r=(e[d>>2]|0)+(U<<1)|0,e[d>>2]=r,o=(e[C>>2]|0)+(U<<1)|0,e[C>>2]=o,c=c+1|0}while((c|0)<(Q|0))}if(R=R+1|0,(R|0)>=(e[h>>2]|0)){d=40;break e}}if((d|0)==27){l=j()|0;break}else if((d|0)==28){l=j()|0;break}}else d=40;while(!1);do if((d|0)==40){if(g=0,ue(182,t|0),t=g,g=0,t&1){l=j()|0;break}if(r=e[K>>2]|0,o=r,r&&(l=e[$>>2]|0,(l|0)!=(r|0)&&(e[$>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[P>>2]|0,!r){b=G;return}o=e[O>>2]|0,(o|0)!=(r|0)&&(e[O>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),b=G;return}while(!1);r=e[K>>2]|0,o=r,r&&(c=e[$>>2]|0,(c|0)!=(r|0)&&(e[$>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}r=e[P>>2]|0,r||le(l|0),o=e[O>>2]|0,(o|0)!=(r|0)&&(e[O>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),le(l|0)}function G1(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(N=t+4580|0,r=e[N>>2]|0,U=t+156|0,!((e[U>>2]|0)<=0))for(R=t+4584|0,_=t+4588|0,c=r,h=M[r+-2>>1]|0,r=M[r>>1]|0,k=0;D=e[R>>2]|0,C=M[D+(k+-1<<1)>>1]|0,l=k+1|0,o=M[c+(l<<1)>>1]|0,w=e[_>>2]|0,d=r-h|0,c=h-C|0,w=((((S[w+(o-r)>>0]|0)*9|0)+(S[w+d>>0]|0)|0)*9|0)+(S[w+c>>0]|0)|0,w?(h=r-C>>31,(h^c|0)<0?c=r:c=C+((h^d|0)<0?0:d)|0,D=q1(t,w,M[D+(k<<1)>>1]|0,c,0)|0,E[(e[R>>2]|0)+(k<<1)>>1]=D):(l=(W1(t,k,0)|0)+k|0,o=e[N>>2]|0,r=M[o+(l+-1<<1)>>1]|0,o=M[o+(l<<1)>>1]|0),!((l|0)>=(e[U>>2]|0));)c=e[N>>2]|0,h=r,r=o,k=l}function q1(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(U=r>>31,C=(U^r)-U|0,_=t+172+(C*12|0)+10|0,d=E[_>>1]|0,R=t+172+(C*12|0)|0,c=e[R>>2]|0,(d|0)<(c|0))if((d<<1|0)<(c|0))if((d<<2|0)<(c|0))if((d<<3|0)<(c|0))if((d<<4|0)<(c|0))for(h=5;(d<>1]^U)-U+l|0,(c&65535|0)==(c|0)?k=c:k=c>>31&65535^65535,w=(o-k^U)-U<<16,D=w>>16,h?c=0:c=(e[t+172+(C*12|0)+4>>2]<<1)+-1+d>>31,l=c^D,l=l>>30^l<<1,c=l>>h,(c|0)<47?((c|0)>30&&(d=(c|0)/2|0,_t(t,0,d),c=c-d|0),_t(t,1,c+1|0),_t(t,l&(1<>1]|0,c=d<<16>>16==64,h=c&1,o=(e[l>>2]|0)+D>>h,d=c?32:d<<16>>16,e[R>>2]=(e[R>>2]|0)+((w|0)>-65536?D:0-D|0)>>h,h=d+1|0,E[_>>1]=h,c=h+o|0,(c|0)<1?(_=E[N>>1]|0,E[N>>1]=(_&65535)-(_<<16>>16>-128&1),_=(c|0)>(~d|0)?c:0-d|0,e[l>>2]=_,U=D^U,r=r>>>31,r=k+r|0,r=r+U|0,r=r&65535,r|0):(o|0)<=0?(_=o,e[l>>2]=_,U=D^U,r=r>>>31,r=k+r|0,r=r+U|0,r=r&65535,r|0):(_=o-h|0,R=E[N>>1]|0,E[N>>1]=(R<<16>>16<127&1)+(R&65535),_=(_|0)>0?0:_,e[l>>2]=_,U=D^U,r=r>>>31,r=k+r|0,r=r+U|0,r=r&65535,r|0)}function W1(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;for(d=(e[t+156>>2]|0)-r|0,w=e[t+4584>>2]|0,D=e[t+4580>>2]|0,c=E[w+(r+-1<<1)>>1]|0,l=0;;){if(o=w+(l+r<<1)|0,(E[o>>1]|0)!=c<<16>>16){k=l;break}if(E[o>>1]=c,l=l+1|0,(l|0)==(d|0)){k=d;break}}if(h=c&65535,c=(k|0)==(d|0),C=t+4576|0,l=e[36476+(e[C>>2]<<2)>>2]|0,(1<(k|0))o=k;else{o=k;do _t(t,1,1),l=e[C>>2]|0,o=o-(1<>2])|0,l=(l|0)>30?31:l+1|0,e[C>>2]=l,l=e[36476+(l<<2)>>2]|0;while((o|0)>=(1<>1]|0,o=M[D+(o<<1)>>1]|0,D=h-o|0,(((D|0)>-1?D:0-D|0)|0)<1?(o=l-h<<16>>16,hs(t,t+4564|0,o),o=o+h|0):(D=o-h>>31|1,r=(ee(l-o<<16,D)|0)>>16,hs(t,t+4552|0,r),o=(ee(r,D)|0)+o|0),E[c>>1]=o,t=e[C>>2]|0,e[C>>2]=(t|0)<1?0:t+-1|0,t=k+1|0,t|0)}function hs(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=r+9|0,d=F[k>>0]|0,D=r+4|0,C=e[D>>2]|0,c=(ee(d>>>1,C)|0)+(e[r>>2]|0)|0,(d|0)<(c|0)){h=d,l=0;do h=h<<1,l=l+1|0;while((h|0)<(c|0));c=l}else c=0;(o|0)>0&(c|0)==0&&F[r+10>>0]<<1>>>0>>0?l=1:w=5;do if((w|0)==5){if(l=(o|0)<0,l&&F[r+10>>0]<<1>>>0>=d>>>0){l=1;break}l=l&(c|0)!=0}while(!1);if(l=(((o|0)>-1?o:0-o|0)<<1)-C+(l<<31>>31)|0,H1(t,c,l,63-(e[36476+(e[t+4576>>2]<<2)>>2]|0)|0),(o|0)<0&&(t=r+10|0,S[t>>0]=(F[t>>0]|0)+1),l=(l+1-(e[D>>2]|0)>>1)+(e[r>>2]|0)|0,e[r>>2]=l,c=S[k>>0]|0,c<<24>>24!=(S[r+8>>0]|0)){r=c,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r;return}e[r>>2]=l>>1,t=(c&255)>>>1,S[k>>0]=t,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,r=t,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r}function H1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;if(c=o>>r,h=l+-16|0,(c|0)<(l+-17|0)){(c|0)>30&&(l=(c|0)/2|0,_t(t,0,l),c=c-l|0),_t(t,1,c+1|0),_t(t,(1<31?(_t(t,0,31),_t(t,1,l+-47|0)):_t(t,1,h),_t(t,o+65535&65535,16)}function Q1(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(D=b,b=b+32|0,w=D,m0(w,65535,0),C=t+160|0,(e[w+4>>2]|0)==(e[C>>2]|0)&&(e[w+8>>2]|0)==(e[t+164>>2]|0)&&(e[w+12>>2]|0)==(e[t+168>>2]|0)){C=e[8909]|0,e[t+4588>>2]=C+(((e[8910]|0)-C|0)>>>1),b=D;return}for(o=t+4592|0,l=t+4596|0,c=e[l>>2]|0,r=e[o>>2]|0,h=c-r|0,h>>>0>=131072?h>>>0>131072&&(d=r+131072|0,(c|0)!=(d|0))&&(e[l>>2]=d):(j0(o,131072-h|0),r=e[o>>2]|0),w=t+4588|0,e[w>>2]=r+65536,d=t+168|0,c=t+164|0,h=-65536;;){if(r=e[d>>2]|0,(h|0)>(0-r|0))if(o=e[c>>2]|0,(h|0)>(0-o|0))if(l=e[C>>2]|0,(h|0)>(0-l|0))if((h|0)>=0){if((h|0)<1){S[(e[w>>2]|0)+h>>0]=0,h=1;continue}(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1}else r=-1;else r=-2;else r=-3;else r=-4;if(S[(e[w>>2]|0)+h>>0]=r,h=h+1|0,(h|0)==65536)break}b=D}function K1(t){t=t|0;var r=0,o=0;e[t>>2]=35968,r=e[t+4592>>2]|0,r&&(o=t+4596|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),t=t+4|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function Y1(t){t=t|0;var r=0,o=0;if(e[t>>2]=35968,r=e[t+4592>>2]|0,r&&(o=t+4596|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),o=t+4|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function j1(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0;c=b,b=b+32|0,w=c,m0(w,4095,0),d=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[w+8>>2]|0,l=e[r+12>>2]|0,l=l|0?l:e[w+12>>2]|0,r=e[r+16>>2]|0,o=e[w+16>>2]|0,e[t+160>>2]=d|0?d:e[w+4>>2]|0,e[t+164>>2]=h,e[t+168>>2]=l,n2(t),l=0;do e[t+172+(l*12|0)>>2]=64,e[t+172+(l*12|0)+4>>2]=0,E[t+172+(l*12|0)+8>>1]=0,E[t+172+(l*12|0)+10>>1]=1,l=l+1|0;while((l|0)!=365);w=(r|0?r:o)&255,e[t+4552>>2]=64,e[t+4556>>2]=0,S[t+4560>>0]=w,S[t+4561>>0]=1,S[t+4562>>0]=0,e[t+4564>>2]=64,e[t+4568>>2]=1,S[t+4572>>0]=w,S[t+4573>>0]=1,S[t+4574>>0]=0,e[t+4576>>2]=0,b=c}function X1(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=b,b=b+16|0,C=k,w=t+92|0,d=e[r>>2]|0,e[r>>2]=0,r=e[w>>2]|0,e[w>>2]=d,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),e[C>>2]=0,e[C+4>>2]=l,w=o+8|0,e[C+8>>2]=e[w>>2],l){r=Xe(4600)|0,l=t+8|0,c=r+4|0,h=l,d=c+84|0;do e[c>>2]=e[h>>2],c=c+4|0,h=h+4|0;while((c|0)<(d|0));c=r+88|0,d=c+40|0;do e[c>>2]=0,c=c+4|0;while((c|0)<(d|0));e[r>>2]=35744,c=r+132|0,e[c>>2]=0,e[c+4>>2]=0,e[c+8>>2]=0,e[c+12>>2]=0,e[r+148>>2]=e[l>>2],e[r+152>>2]=0,e[r+156>>2]=0,e[r+160>>2]=0,c=r+4544|0,l=r+164|0;do e[l>>2]=0,e[l+4>>2]=0,E[l+8>>1]=0,E[l+10>>1]=1,l=l+12|0;while((l|0)!=(c|0));h=t+4|0,e[c>>2]=0,e[c+4>>2]=0,E[c+8>>1]=0,S[c+10>>0]=0,d=r+4556|0,e[d>>2]=0,e[d+4>>2]=0,E[d+8>>1]=0,S[d+10>>0]=0,d=r+4568|0,e[d>>2]=0,e[d+4>>2]=0,e[d+8>>2]=0,e[d+12>>2]=0,e[d+16>>2]=0,e[d+20>>2]=0,e[d+24>>2]=0,S[d+28>>0]=0,e[r+28>>2]|0||(e[r+20>>2]=1),l=e[h>>2]|0,e[h>>2]=r,l&&(Mt[e[(e[l>>2]|0)+4>>2]&255](l),r=e[h>>2]|0),Y0(r,C)}return C=t+100|0,e[C>>2]=32,e[t+96>>2]=0,r=e[o>>2]|0,r?(e[t+132>>2]=r,c=t+120|0,w=t+124|0,l=e[w>>2]|0,r=e[c>>2]|0,h=r,d=l-h|0,d>>>0>=4e3?d>>>0>4e3&&(D=r+4e3|0,(l|0)!=(D|0))&&(e[w>>2]=D,l=D):(vi(c,4e3-d|0),r=e[c>>2]|0,h=r,l=e[w>>2]|0),e[t+108>>2]=h,e[t+104>>2]=l-r,ds(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0):(e[t+108>>2]=e[o+4>>2],e[t+104>>2]=e[w>>2],ds(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0)}function Z1(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+32>>2]|0&&(e[t+24>>2]|0)!=1){if(_=t+8|0,Q=t+36|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(37,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+16>>2]|0,(t|0)==16)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(38,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(39,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(40,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+20>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=2,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=2,e[l+12>>2]=t,O=l,b=G,O|0)}function ds(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;G=b,b=b+32|0,P=G+12|0,K=G,_=t+156|0,U=(e[_>>2]|0)+4|0,(e[t+32>>2]|0)==1?Q=e[t+24>>2]|0:Q=1,r=ee(Q<<1,U)|0,e[P>>2]=0,O=P+4|0,e[O>>2]=0,e[P+8>>2]=0;do if(r){if((r|0)<0&&(g=0,ue(178,P|0),$=g,g=0,$&1)||(d=6),(d|0)==6&&(o=r<<1,g=0,l=ge(67,o|0)|0,$=g,g=0,!($&1))){e[P>>2]=l,$=l+(r<<1)|0,e[P+8>>2]=$,Jt(l|0,0,o|0)|0,e[O>>2]=$;break}l=j()|0,r=e[P>>2]|0,r||le(l|0),o=e[O>>2]|0,(o|0)!=(r|0)&&(e[O>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),le(l|0)}while(!1);e[K>>2]=0,$=K+4|0,e[$>>2]=0,e[K+8>>2]=0;do if(!Q)d=18;else{if(Q>>>0>1073741823&&(g=0,ue(178,K|0),R=g,g=0,R&1)||(d=16),(d|0)==16&&(c=Q<<2,g=0,h=ge(67,c|0)|0,R=g,g=0,!(R&1))){e[K>>2]=h,d=h+(Q<<2)|0,e[K+8>>2]=d,Jt(h|0,0,c|0)|0,e[$>>2]=d,d=18;break}l=j()|0,r=e[K>>2]|0,o=r,r&&(c=e[$>>2]|0,(c|0)!=(r|0)&&(e[$>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}while(!1);if((d|0)==18){h=t+12|0;e:do if((e[h>>2]|0)>0){d=t+4580|0,w=(ee(Q,U)|0)+1|0,C=t+4584|0,D=t+92|0,k=(Q|0)>0,N=t+4576|0,R=0;t:for(;;){if(o=e[P>>2]|0,r=o+2|0,e[d>>2]=r,o=o+(w<<1)|0,e[C>>2]=o,R&1?(e[d>>2]=o,e[C>>2]=r):r=o,c=e[D>>2]|0,g=0,$e(e[(e[c>>2]|0)+12>>2]|0,c|0,r|0,e[_>>2]|0,U|0),c=g,g=0,c&1){d=28;break}if(k){r=e[d>>2]|0,o=e[C>>2]|0,l=e[K>>2]|0,c=0;do{if(e[N>>2]=e[l+(c<<2)>>2],l=e[_>>2]|0,E[r+(l<<1)>>1]=E[r+(l+-1<<1)>>1]|0,E[o+-2>>1]=E[r>>1]|0,g=0,Ae(72,t|0,0),l=g,g=0,l&1){d=27;break t}l=e[K>>2]|0,e[l+(c<<2)>>2]=e[N>>2],r=(e[d>>2]|0)+(U<<1)|0,e[d>>2]=r,o=(e[C>>2]|0)+(U<<1)|0,e[C>>2]=o,c=c+1|0}while((c|0)<(Q|0))}if(R=R+1|0,(R|0)>=(e[h>>2]|0)){d=40;break e}}if((d|0)==27){l=j()|0;break}else if((d|0)==28){l=j()|0;break}}else d=40;while(!1);do if((d|0)==40){if(g=0,ue(182,t|0),t=g,g=0,t&1){l=j()|0;break}if(r=e[K>>2]|0,o=r,r&&(l=e[$>>2]|0,(l|0)!=(r|0)&&(e[$>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[P>>2]|0,!r){b=G;return}o=e[O>>2]|0,(o|0)!=(r|0)&&(e[O>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),b=G;return}while(!1);r=e[K>>2]|0,o=r,r&&(c=e[$>>2]|0,(c|0)!=(r|0)&&(e[$>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}r=e[P>>2]|0,r||le(l|0),o=e[O>>2]|0,(o|0)!=(r|0)&&(e[O>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),le(l|0)}function J1(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(N=t+4580|0,r=e[N>>2]|0,U=t+156|0,!((e[U>>2]|0)<=0))for(R=t+4584|0,_=t+4588|0,c=r,h=M[r+-2>>1]|0,r=M[r>>1]|0,k=0;D=e[R>>2]|0,C=M[D+(k+-1<<1)>>1]|0,l=k+1|0,o=M[c+(l<<1)>>1]|0,w=e[_>>2]|0,d=r-h|0,c=h-C|0,w=((((S[w+(o-r)>>0]|0)*9|0)+(S[w+d>>0]|0)|0)*9|0)+(S[w+c>>0]|0)|0,w?(h=r-C>>31,(h^c|0)<0?c=r:c=C+((h^d|0)<0?0:d)|0,D=e2(t,w,M[D+(k<<1)>>1]|0,c,0)|0,E[(e[R>>2]|0)+(k<<1)>>1]=D):(l=(t2(t,k,0)|0)+k|0,o=e[N>>2]|0,r=M[o+(l+-1<<1)>>1]|0,o=M[o+(l<<1)>>1]|0),!((l|0)>=(e[U>>2]|0));)c=e[N>>2]|0,h=r,r=o,k=l}function e2(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(U=r>>31,C=(U^r)-U|0,_=t+172+(C*12|0)+10|0,d=E[_>>1]|0,R=t+172+(C*12|0)|0,c=e[R>>2]|0,(d|0)<(c|0))if((d<<1|0)<(c|0))if((d<<2|0)<(c|0))if((d<<3|0)<(c|0))if((d<<4|0)<(c|0))for(h=5;(d<>1]^U)-U+l|0,(c&4095|0)==(c|0)?k=c:k=c>>31&4095^4095,w=(o-k^U)-U<<20,D=w>>20,h?c=0:c=(e[t+172+(C*12|0)+4>>2]<<1)+-1+d>>31,l=c^D,l=l>>30^l<<1,c=l>>h,(c|0)<35?((c|0)>30&&(d=(c|0)/2|0,_t(t,0,d),c=c-d|0),_t(t,1,c+1|0),_t(t,l&(1<>1]|0,c=d<<16>>16==64,h=c&1,o=(e[l>>2]|0)+D>>h,d=c?32:d<<16>>16,e[R>>2]=(e[R>>2]|0)+((w|0)>-1048576?D:0-D|0)>>h,h=d+1|0,E[_>>1]=h,c=h+o|0,(c|0)<1?(_=E[N>>1]|0,E[N>>1]=(_&65535)-(_<<16>>16>-128&1),_=(c|0)>(~d|0)?c:0-d|0,e[l>>2]=_,U=D^U,r=r>>>31,r=k+r|0,r=r+U|0,r=r&4095,r=r&65535,r|0):(o|0)<=0?(_=o,e[l>>2]=_,U=D^U,r=r>>>31,r=k+r|0,r=r+U|0,r=r&4095,r=r&65535,r|0):(_=o-h|0,R=E[N>>1]|0,E[N>>1]=(R<<16>>16<127&1)+(R&65535),_=(_|0)>0?0:_,e[l>>2]=_,U=D^U,r=r>>>31,r=k+r|0,r=r+U|0,r=r&4095,r=r&65535,r|0)}function t2(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;for(d=(e[t+156>>2]|0)-r|0,w=e[t+4584>>2]|0,D=e[t+4580>>2]|0,c=E[w+(r+-1<<1)>>1]|0,l=0;;){if(o=w+(l+r<<1)|0,(E[o>>1]|0)!=c<<16>>16){k=l;break}if(E[o>>1]=c,l=l+1|0,(l|0)==(d|0)){k=d;break}}if(h=c&65535,c=(k|0)==(d|0),C=t+4576|0,l=e[36476+(e[C>>2]<<2)>>2]|0,(1<(k|0))o=k;else{o=k;do _t(t,1,1),l=e[C>>2]|0,o=o-(1<>2])|0,l=(l|0)>30?31:l+1|0,e[C>>2]=l,l=e[36476+(l<<2)>>2]|0;while((o|0)>=(1<>1]|0,o=M[D+(o<<1)>>1]|0,D=h-o|0,(((D|0)>-1?D:0-D|0)|0)<1?(o=l-h<<20>>20,ps(t,t+4564|0,o),o=o+h|0):(D=o-h>>31|1,r=(ee(l-o<<20,D)|0)>>20,ps(t,t+4552|0,r),o=(ee(r,D)|0)+o|0),E[c>>1]=o&4095,t=e[C>>2]|0,e[C>>2]=(t|0)<1?0:t+-1|0,t=k+1|0,t|0)}function ps(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=r+9|0,d=F[k>>0]|0,D=r+4|0,C=e[D>>2]|0,c=(ee(d>>>1,C)|0)+(e[r>>2]|0)|0,(d|0)<(c|0)){h=d,l=0;do h=h<<1,l=l+1|0;while((h|0)<(c|0));c=l}else c=0;(o|0)>0&(c|0)==0&&F[r+10>>0]<<1>>>0>>0?l=1:w=5;do if((w|0)==5){if(l=(o|0)<0,l&&F[r+10>>0]<<1>>>0>=d>>>0){l=1;break}l=l&(c|0)!=0}while(!1);if(l=(((o|0)>-1?o:0-o|0)<<1)-C+(l<<31>>31)|0,i2(t,c,l,47-(e[36476+(e[t+4576>>2]<<2)>>2]|0)|0),(o|0)<0&&(t=r+10|0,S[t>>0]=(F[t>>0]|0)+1),l=(l+1-(e[D>>2]|0)>>1)+(e[r>>2]|0)|0,e[r>>2]=l,c=S[k>>0]|0,c<<24>>24!=(S[r+8>>0]|0)){r=c,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r;return}e[r>>2]=l>>1,t=(c&255)>>>1,S[k>>0]=t,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,r=t,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r}function i2(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;if(c=o>>r,h=l+-12|0,(c|0)<(l+-13|0)){(c|0)>30&&(l=(c|0)/2|0,_t(t,0,l),c=c-l|0),_t(t,1,c+1|0),_t(t,(1<31?(_t(t,0,31),_t(t,1,l+-43|0)):_t(t,1,h),_t(t,o+4095&4095,12)}function n2(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(D=b,b=b+32|0,w=D,m0(w,4095,0),C=t+160|0,(e[w+4>>2]|0)==(e[C>>2]|0)&&(e[w+8>>2]|0)==(e[t+164>>2]|0)&&(e[w+12>>2]|0)==(e[t+168>>2]|0)){C=e[8906]|0,e[t+4588>>2]=C+(((e[8907]|0)-C|0)>>>1),b=D;return}for(o=t+4592|0,l=t+4596|0,c=e[l>>2]|0,r=e[o>>2]|0,h=c-r|0,h>>>0>=8192?h>>>0>8192&&(d=r+8192|0,(c|0)!=(d|0))&&(e[l>>2]=d):(j0(o,8192-h|0),r=e[o>>2]|0),w=t+4588|0,e[w>>2]=r+4096,d=t+168|0,c=t+164|0,h=-4096;;){if(r=e[d>>2]|0,(h|0)>(0-r|0))if(o=e[c>>2]|0,(h|0)>(0-o|0))if(l=e[C>>2]|0,(h|0)>(0-l|0))if((h|0)>=0){if((h|0)<1){S[(e[w>>2]|0)+h>>0]=0,h=1;continue}(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1}else r=-1;else r=-2;else r=-3;else r=-4;if(S[(e[w>>2]|0)+h>>0]=r,h=h+1|0,(h|0)==4096)break}b=D}function r2(t){t=t|0;var r=0,o=0;e[t>>2]=35940,r=e[t+4592>>2]|0,r&&(o=t+4596|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),t=t+4|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function s2(t){t=t|0;var r=0,o=0;if(e[t>>2]=35940,r=e[t+4592>>2]|0,r&&(o=t+4596|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),o=t+4|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function o2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0;c=b,b=b+32|0,w=c,m0(w,255,0),d=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[w+8>>2]|0,l=e[r+12>>2]|0,l=l|0?l:e[w+12>>2]|0,r=e[r+16>>2]|0,o=e[w+16>>2]|0,e[t+160>>2]=d|0?d:e[w+4>>2]|0,e[t+164>>2]=h,e[t+168>>2]=l,p2(t),l=0;do e[t+172+(l*12|0)>>2]=4,e[t+172+(l*12|0)+4>>2]=0,E[t+172+(l*12|0)+8>>1]=0,E[t+172+(l*12|0)+10>>1]=1,l=l+1|0;while((l|0)!=365);w=(r|0?r:o)&255,e[t+4552>>2]=4,e[t+4556>>2]=0,S[t+4560>>0]=w,S[t+4561>>0]=1,S[t+4562>>0]=0,e[t+4564>>2]=4,e[t+4568>>2]=1,S[t+4572>>0]=w,S[t+4573>>0]=1,S[t+4574>>0]=0,e[t+4576>>2]=0,b=c}function l2(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=b,b=b+16|0,C=k,w=t+92|0,d=e[r>>2]|0,e[r>>2]=0,r=e[w>>2]|0,e[w>>2]=d,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),e[C>>2]=0,e[C+4>>2]=l,w=o+8|0,e[C+8>>2]=e[w>>2],l){r=Xe(4600)|0,l=t+8|0,c=r+4|0,h=l,d=c+84|0;do e[c>>2]=e[h>>2],c=c+4|0,h=h+4|0;while((c|0)<(d|0));c=r+88|0,d=c+40|0;do e[c>>2]=0,c=c+4|0;while((c|0)<(d|0));e[r>>2]=35716,c=r+132|0,e[c>>2]=0,e[c+4>>2]=0,e[c+8>>2]=0,e[c+12>>2]=0,e[r+148>>2]=e[l>>2],e[r+152>>2]=0,e[r+156>>2]=0,e[r+160>>2]=0,c=r+4544|0,l=r+164|0;do e[l>>2]=0,e[l+4>>2]=0,E[l+8>>1]=0,E[l+10>>1]=1,l=l+12|0;while((l|0)!=(c|0));h=t+4|0,e[c>>2]=0,e[c+4>>2]=0,E[c+8>>1]=0,S[c+10>>0]=0,d=r+4556|0,e[d>>2]=0,e[d+4>>2]=0,E[d+8>>1]=0,S[d+10>>0]=0,d=r+4568|0,e[d>>2]=0,e[d+4>>2]=0,e[d+8>>2]=0,e[d+12>>2]=0,e[d+16>>2]=0,e[d+20>>2]=0,e[d+24>>2]=0,S[d+28>>0]=0,e[r+28>>2]|0||(e[r+20>>2]=1),l=e[h>>2]|0,e[h>>2]=r,l&&(Mt[e[(e[l>>2]|0)+4>>2]&255](l),r=e[h>>2]|0),Y0(r,C)}return C=t+100|0,e[C>>2]=32,e[t+96>>2]=0,r=e[o>>2]|0,r?(e[t+132>>2]=r,c=t+120|0,w=t+124|0,l=e[w>>2]|0,r=e[c>>2]|0,h=r,d=l-h|0,d>>>0>=4e3?d>>>0>4e3&&(D=r+4e3|0,(l|0)!=(D|0))&&(e[w>>2]=D,l=D):(vi(c,4e3-d|0),r=e[c>>2]|0,h=r,l=e[w>>2]|0),e[t+108>>2]=h,e[t+104>>2]=l-r,ms(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0):(e[t+108>>2]=e[o+4>>2],e[t+104>>2]=e[w>>2],ms(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0)}function u2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+32>>2]|0&&(e[t+24>>2]|0)!=1){if(_=t+8|0,Q=t+36|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(44,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+16>>2]|0,(t|0)==8)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(45,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(46,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(47,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+20>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=1,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=1,e[l+12>>2]=t,O=l,b=G,O|0)}function ms(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0;K=b,b=b+32|0,$=K+12|0,Q=K,R=t+156|0,_=(e[R>>2]|0)+4|0,(e[t+32>>2]|0)==1?U=e[t+24>>2]|0:U=1,r=ee(U<<1,_)|0,e[$>>2]=0,P=$+4|0,e[P>>2]=0,e[$+8>>2]=0;e:do if(r){if((r|0)<0&&(g=0,ue(178,$|0),G=g,g=0,G&1)||(h=6),(h|0)==6&&(g=0,o=ge(67,r|0)|0,G=g,g=0,!(G&1))){for(e[P>>2]=o,e[$>>2]=o,e[$+8>>2]=o+r;;)if(S[o>>0]=0,o=(e[P>>2]|0)+1|0,e[P>>2]=o,r=r+-1|0,!r)break e}o=j()|0,r=e[$>>2]|0,r||le(o|0),(e[P>>2]|0)!=(r|0)&&(e[P>>2]=r),he(r),le(o|0)}while(!1);e[Q>>2]=0,G=Q+4|0,e[G>>2]=0,e[Q+8>>2]=0;do if(!U)h=19;else{if(U>>>0>1073741823&&(g=0,ue(178,Q|0),N=g,g=0,N&1)||(h=17),(h|0)==17&&(l=U<<2,g=0,c=ge(67,l|0)|0,N=g,g=0,!(N&1))){e[Q>>2]=c,h=c+(U<<2)|0,e[Q+8>>2]=h,Jt(c|0,0,l|0)|0,e[G>>2]=h,h=19;break}o=j()|0,r=e[Q>>2]|0,l=r,r&&(c=e[G>>2]|0,(c|0)!=(r|0)&&(e[G>>2]=c+(~((c+-4-l|0)>>>2)<<2)),he(r))}while(!1);if((h|0)==19){c=t+12|0;e:do if((e[c>>2]|0)>0){h=t+4580|0,d=(ee(U,_)|0)+1|0,w=t+4584|0,C=t+92|0,D=(U|0)>0,k=t+4576|0,N=0;t:for(;;){if(o=e[$>>2]|0,r=o+1|0,e[h>>2]=r,o=o+d|0,e[w>>2]=o,N&1?(e[h>>2]=o,e[w>>2]=r):r=o,l=e[C>>2]|0,g=0,$e(e[(e[l>>2]|0)+12>>2]|0,l|0,r|0,e[R>>2]|0,_|0),l=g,g=0,l&1){h=29;break}if(D){r=e[h>>2]|0,o=e[Q>>2]|0,l=0;do{if(e[k>>2]=e[o+(l<<2)>>2],o=e[R>>2]|0,S[r+o>>0]=S[r+(o+-1)>>0]|0,S[(e[w>>2]|0)+-1>>0]=S[e[h>>2]>>0]|0,g=0,Ae(73,t|0,0),o=g,g=0,o&1){h=28;break t}o=e[Q>>2]|0,e[o+(l<<2)>>2]=e[k>>2],r=(e[h>>2]|0)+_|0,e[h>>2]=r,e[w>>2]=(e[w>>2]|0)+_,l=l+1|0}while((l|0)<(U|0))}if(N=N+1|0,(N|0)>=(e[c>>2]|0)){h=41;break e}}if((h|0)==28){o=j()|0;break}else if((h|0)==29){o=j()|0;break}}else h=41;while(!1);do if((h|0)==41){if(g=0,ue(182,t|0),t=g,g=0,t&1){o=j()|0;break}if(r=e[Q>>2]|0,o=r,r&&(l=e[G>>2]|0,(l|0)!=(r|0)&&(e[G>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[$>>2]|0,!r){b=K;return}(e[P>>2]|0)!=(r|0)&&(e[P>>2]=r),he(r),b=K;return}while(!1);r=e[Q>>2]|0,l=r,r&&(c=e[G>>2]|0,(c|0)!=(r|0)&&(e[G>>2]=c+(~((c+-4-l|0)>>>2)<<2)),he(r))}r=e[$>>2]|0,r||le(o|0),(e[P>>2]|0)!=(r|0)&&(e[P>>2]=r),he(r),le(o|0)}function c2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(N=t+4580|0,r=e[N>>2]|0,U=t+156|0,!((e[U>>2]|0)<=0))for(R=t+4584|0,_=t+4588|0,c=r,h=F[r+-1>>0]|0,r=F[r>>0]|0,k=0;D=e[R>>2]|0,C=F[D+(k+-1)>>0]|0,l=k+1|0,o=F[c+l>>0]|0,w=e[_>>2]|0,d=r-h|0,c=h-C|0,w=((((S[w+(o-r)>>0]|0)*9|0)+(S[w+d>>0]|0)|0)*9|0)+(S[w+c>>0]|0)|0,w?(h=r-C>>31,(h^c|0)<0?c=r:c=C+((h^d|0)<0?0:d)|0,D=f2(t,w,F[D+k>>0]|0,c,0)|0,S[(e[R>>2]|0)+k>>0]=D):(l=(h2(t,k,0)|0)+k|0,o=e[N>>2]|0,r=F[o+(l+-1)>>0]|0,o=F[o+l>>0]|0),!((l|0)>=(e[U>>2]|0));)c=e[N>>2]|0,h=r,r=o,k=l}function f2(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(U=r>>31,C=(U^r)-U|0,_=t+172+(C*12|0)+10|0,d=E[_>>1]|0,R=t+172+(C*12|0)|0,c=e[R>>2]|0,(d|0)<(c|0))if((d<<1|0)<(c|0))if((d<<2|0)<(c|0))if((d<<3|0)<(c|0))if((d<<4|0)<(c|0))for(h=5;(d<>1]^U)-U+l|0,(c&255|0)==(c|0)?k=c:k=c>>31&255^255,w=(o-k^U)-U<<24,D=w>>24,h?c=0:c=(e[t+172+(C*12|0)+4>>2]<<1)+-1+d>>31,c=c^D,c=c>>30^c<<1,l=c>>h,(l|0)<23?(_t(t,1,l+1|0),_t(t,c&(1<>1]|0,c=d<<16>>16==64,h=c&1,o=(e[l>>2]|0)+D>>h,d=c?32:d<<16>>16,e[R>>2]=(e[R>>2]|0)+((w|0)>-16777216?D:0-D|0)>>h,h=d+1|0,E[_>>1]=h,c=h+o|0,(c|0)<1?(_=E[N>>1]|0,E[N>>1]=(_&65535)-(_<<16>>16>-128&1),_=(c|0)>(~d|0)?c:0-d|0,e[l>>2]=_,U=D^U,r=r>>>31,r=k+r|0,r=r+U|0,r=r&255,r|0):(o|0)<=0?(_=o,e[l>>2]=_,U=D^U,r=r>>>31,r=k+r|0,r=r+U|0,r=r&255,r|0):(_=o-h|0,R=E[N>>1]|0,E[N>>1]=(R<<16>>16<127&1)+(R&65535),_=(_|0)>0?0:_,e[l>>2]=_,U=D^U,r=r>>>31,r=k+r|0,r=r+U|0,r=r&255,r|0)}function h2(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;for(d=(e[t+156>>2]|0)-r|0,w=e[t+4584>>2]|0,D=e[t+4580>>2]|0,c=S[w+(r+-1)>>0]|0,l=0;;){if(o=w+(l+r)|0,(S[o>>0]|0)!=c<<24>>24){k=l;break}if(S[o>>0]=c,l=l+1|0,(l|0)==(d|0)){k=d;break}}if(h=c&255,c=(k|0)==(d|0),C=t+4576|0,l=e[36476+(e[C>>2]<<2)>>2]|0,(1<(k|0))o=k;else{o=k;do _t(t,1,1),l=e[C>>2]|0,o=o-(1<>2])|0,l=(l|0)>30?31:l+1|0,e[C>>2]=l,l=e[36476+(l<<2)>>2]|0;while((o|0)>=(1<>0]|0,o=F[D+o>>0]|0,D=h-o|0,(((D|0)>-1?D:0-D|0)|0)<1?(o=l-h<<24>>24,gs(t,t+4564|0,o),o=o+h|0):(D=o-h>>31|1,r=(ee(l-o<<24,D)|0)>>24,gs(t,t+4552|0,r),o=(ee(r,D)|0)+o|0),S[c>>0]=o,t=e[C>>2]|0,e[C>>2]=(t|0)<1?0:t+-1|0,t=k+1|0,t|0)}function gs(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=r+9|0,d=F[k>>0]|0,D=r+4|0,C=e[D>>2]|0,c=(ee(d>>>1,C)|0)+(e[r>>2]|0)|0,(d|0)<(c|0)){h=d,l=0;do h=h<<1,l=l+1|0;while((h|0)<(c|0));c=l}else c=0;(o|0)>0&(c|0)==0&&F[r+10>>0]<<1>>>0>>0?l=1:w=5;do if((w|0)==5){if(l=(o|0)<0,l&&F[r+10>>0]<<1>>>0>=d>>>0){l=1;break}l=l&(c|0)!=0}while(!1);if(l=(((o|0)>-1?o:0-o|0)<<1)-C+(l<<31>>31)|0,d2(t,c,l,31-(e[36476+(e[t+4576>>2]<<2)>>2]|0)|0),(o|0)<0&&(t=r+10|0,S[t>>0]=(F[t>>0]|0)+1),l=(l+1-(e[D>>2]|0)>>1)+(e[r>>2]|0)|0,e[r>>2]=l,c=S[k>>0]|0,c<<24>>24!=(S[r+8>>0]|0)){r=c,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r;return}e[r>>2]=l>>1,t=(c&255)>>>1,S[k>>0]=t,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,r=t,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r}function d2(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;if(c=o>>r,h=l+-8|0,(c|0)<(l+-9|0)){(c|0)>30&&(l=(c|0)/2|0,_t(t,0,l),c=c-l|0),_t(t,1,c+1|0),_t(t,(1<31?(_t(t,0,31),_t(t,1,l+-39|0)):_t(t,1,h),_t(t,o+255&255,8)}function p2(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(D=b,b=b+32|0,w=D,m0(w,255,0),C=t+160|0,(e[w+4>>2]|0)==(e[C>>2]|0)&&(e[w+8>>2]|0)==(e[t+164>>2]|0)&&(e[w+12>>2]|0)==(e[t+168>>2]|0)){C=e[8900]|0,e[t+4588>>2]=C+(((e[8901]|0)-C|0)>>>1),b=D;return}for(o=t+4592|0,l=t+4596|0,c=e[l>>2]|0,r=e[o>>2]|0,h=c-r|0,h>>>0>=512?h>>>0>512&&(d=r+512|0,(c|0)!=(d|0))&&(e[l>>2]=d):(j0(o,512-h|0),r=e[o>>2]|0),w=t+4588|0,e[w>>2]=r+256,d=t+168|0,c=t+164|0,h=-256;;){if(r=e[d>>2]|0,(h|0)>(0-r|0))if(o=e[c>>2]|0,(h|0)>(0-o|0))if(l=e[C>>2]|0,(h|0)>(0-l|0))if((h|0)>=0){if((h|0)<1){S[(e[w>>2]|0)+h>>0]=0,h=1;continue}(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1}else r=-1;else r=-2;else r=-3;else r=-4;if(S[(e[w>>2]|0)+h>>0]=r,h=h+1|0,(h|0)==256)break}b=D}function m2(t){t=t|0;var r=0,o=0;e[t>>2]=35912,r=e[t+4592>>2]|0,r&&(o=t+4596|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),t=t+4|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function g2(t){t=t|0;var r=0,o=0;if(e[t>>2]=35912,r=e[t+4592>>2]|0,r&&(o=t+4596|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),o=t+4|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function S2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0;c=b,b=b+32|0,w=c,m0(w,255,0),d=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[w+8>>2]|0,l=e[r+12>>2]|0,l=l|0?l:e[w+12>>2]|0,r=e[r+16>>2]|0,o=e[w+16>>2]|0,e[t+160>>2]=d|0?d:e[w+4>>2]|0,e[t+164>>2]=h,e[t+168>>2]=l,C2(t),l=0;do e[t+172+(l*12|0)>>2]=4,e[t+172+(l*12|0)+4>>2]=0,E[t+172+(l*12|0)+8>>1]=0,E[t+172+(l*12|0)+10>>1]=1,l=l+1|0;while((l|0)!=365);w=(r|0?r:o)&255,e[t+4552>>2]=4,e[t+4556>>2]=0,S[t+4560>>0]=w,S[t+4561>>0]=1,S[t+4562>>0]=0,e[t+4564>>2]=4,e[t+4568>>2]=1,S[t+4572>>0]=w,S[t+4573>>0]=1,S[t+4574>>0]=0,e[t+4576>>2]=0,b=c}function A2(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=b,b=b+16|0,C=k,w=t+92|0,d=e[r>>2]|0,e[r>>2]=0,r=e[w>>2]|0,e[w>>2]=d,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),e[C>>2]=0,e[C+4>>2]=l,w=o+8|0,e[C+8>>2]=e[w>>2],l){r=Xe(4600)|0,l=t+8|0,c=r+4|0,h=l,d=c+84|0;do e[c>>2]=e[h>>2],c=c+4|0,h=h+4|0;while((c|0)<(d|0));c=r+88|0,d=c+40|0;do e[c>>2]=0,c=c+4|0;while((c|0)<(d|0));e[r>>2]=35688,c=r+132|0,e[c>>2]=0,e[c+4>>2]=0,e[c+8>>2]=0,e[c+12>>2]=0,e[r+148>>2]=e[l>>2],e[r+152>>2]=0,e[r+156>>2]=0,e[r+160>>2]=0,c=r+4544|0,l=r+164|0;do e[l>>2]=0,e[l+4>>2]=0,E[l+8>>1]=0,E[l+10>>1]=1,l=l+12|0;while((l|0)!=(c|0));h=t+4|0,e[c>>2]=0,e[c+4>>2]=0,E[c+8>>1]=0,S[c+10>>0]=0,d=r+4556|0,e[d>>2]=0,e[d+4>>2]=0,E[d+8>>1]=0,S[d+10>>0]=0,d=r+4568|0,e[d>>2]=0,e[d+4>>2]=0,e[d+8>>2]=0,e[d+12>>2]=0,e[d+16>>2]=0,e[d+20>>2]=0,e[d+24>>2]=0,S[d+28>>0]=0,e[r+28>>2]|0||(e[r+20>>2]=1),l=e[h>>2]|0,e[h>>2]=r,l&&(Mt[e[(e[l>>2]|0)+4>>2]&255](l),r=e[h>>2]|0),Y0(r,C)}return C=t+100|0,e[C>>2]=32,e[t+96>>2]=0,r=e[o>>2]|0,r?(e[t+132>>2]=r,c=t+120|0,w=t+124|0,l=e[w>>2]|0,r=e[c>>2]|0,h=r,d=l-h|0,d>>>0>=4e3?d>>>0>4e3&&(D=r+4e3|0,(l|0)!=(D|0))&&(e[w>>2]=D,l=D):(vi(c,4e3-d|0),r=e[c>>2]|0,h=r,l=e[w>>2]|0),e[t+108>>2]=h,e[t+104>>2]=l-r,Ss(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0):(e[t+108>>2]=e[o+4>>2],e[t+104>>2]=e[w>>2],Ss(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0)}function v2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+32>>2]|0&&(e[t+24>>2]|0)!=1){if(_=t+8|0,Q=t+36|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(44,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+16>>2]|0,(t|0)==8)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(45,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(46,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(47,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+20>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=3,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=3,e[l+12>>2]=t,O=l,b=G,O|0)}function Ss(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;K=b,b=b+32|0,$=K+12|0,Q=K,R=t+156|0,_=(e[R>>2]|0)+4|0,(e[t+32>>2]|0)==1?U=e[t+24>>2]|0:U=1,r=ee(U<<1,_)|0,e[$>>2]=0,P=$+4|0,e[P>>2]=0,e[$+8>>2]=0;e:do if(r){if(r>>>0>1431655765&&(g=0,ue(178,$|0),G=g,g=0,G&1)||(h=6),(h|0)==6&&(g=0,o=ge(67,r*3|0)|0,G=g,g=0,!(G&1))){for(e[P>>2]=o,e[$>>2]=o,e[$+8>>2]=o+(r*3|0);;)if(S[o>>0]=0,S[o+1>>0]=0,S[o+2>>0]=0,o=(e[P>>2]|0)+3|0,e[P>>2]=o,r=r+-1|0,!r)break e}l=j()|0,r=e[$>>2]|0,r||le(l|0),o=e[P>>2]|0,(o|0)!=(r|0)&&(e[P>>2]=o+(~(((o+-3-r|0)>>>0)/3|0)*3|0)),he(r),le(l|0)}while(!1);e[Q>>2]=0,G=Q+4|0,e[G>>2]=0,e[Q+8>>2]=0;do if(!U)h=19;else{if(U>>>0>1073741823&&(g=0,ue(178,Q|0),N=g,g=0,N&1)||(h=17),(h|0)==17&&(l=U<<2,g=0,c=ge(67,l|0)|0,N=g,g=0,!(N&1))){e[Q>>2]=c,h=c+(U<<2)|0,e[Q+8>>2]=h,Jt(c|0,0,l|0)|0,e[G>>2]=h,h=19;break}l=j()|0,r=e[Q>>2]|0,o=r,r&&(c=e[G>>2]|0,(c|0)!=(r|0)&&(e[G>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}while(!1);if((h|0)==19){c=t+12|0;e:do if((e[c>>2]|0)>0){h=t+4580|0,d=(ee(U,_)|0)+1|0,w=t+4584|0,C=t+92|0,D=(U|0)>0,k=t+4576|0,N=0;t:for(;;){if(l=e[$>>2]|0,r=l+3|0,e[h>>2]=r,o=l+(d*3|0)|0,e[w>>2]=o,N&1?(e[h>>2]=o,e[w>>2]=r,r=1):r=d,o=e[C>>2]|0,g=0,$e(e[(e[o>>2]|0)+12>>2]|0,o|0,l+(r*3|0)|0,e[R>>2]|0,_|0),l=g,g=0,l&1){h=29;break}if(D){r=e[Q>>2]|0,o=e[h>>2]|0,l=0;do{if(e[k>>2]=e[r+(l<<2)>>2],O=e[R>>2]|0,r=o+(O*3|0)|0,o=o+((O+-1|0)*3|0)|0,S[r>>0]=S[o>>0]|0,S[r+1>>0]=S[o+1>>0]|0,S[r+2>>0]=S[o+2>>0]|0,r=e[h>>2]|0,o=(e[w>>2]|0)+-3|0,S[o>>0]=S[r>>0]|0,S[o+1>>0]=S[r+1>>0]|0,S[o+2>>0]=S[r+2>>0]|0,g=0,Ae(74,t|0,0),o=g,g=0,o&1){h=28;break t}r=e[Q>>2]|0,e[r+(l<<2)>>2]=e[k>>2],o=(e[h>>2]|0)+(_*3|0)|0,e[h>>2]=o,e[w>>2]=(e[w>>2]|0)+(_*3|0),l=l+1|0}while((l|0)<(U|0))}if(N=N+1|0,(N|0)>=(e[c>>2]|0)){h=41;break e}}if((h|0)==28){l=j()|0;break}else if((h|0)==29){l=j()|0;break}}else h=41;while(!1);do if((h|0)==41){if(g=0,ue(182,t|0),O=g,g=0,O&1){l=j()|0;break}if(r=e[Q>>2]|0,o=r,r&&(l=e[G>>2]|0,(l|0)!=(r|0)&&(e[G>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[$>>2]|0,!r){b=K;return}o=e[P>>2]|0,(o|0)!=(r|0)&&(e[P>>2]=o+(~(((o+-3-r|0)>>>0)/3|0)*3|0)),he(r),b=K;return}while(!1);r=e[Q>>2]|0,o=r,r&&(c=e[G>>2]|0,(c|0)!=(r|0)&&(e[G>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}r=e[$>>2]|0,r||le(l|0),o=e[P>>2]|0,(o|0)!=(r|0)&&(e[P>>2]=o+(~(((o+-3-r|0)>>>0)/3|0)*3|0)),he(r),le(l|0)}function x2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0;if(oe=t+156|0,!((e[oe>>2]|0)<=0))for(ne=t+4584|0,ce=t+4580|0,ke=t+4588|0,ie=0;P=ie+-1|0,h=e[ne>>2]|0,d=e[ce>>2]|0,r=ie+1|0,c=F[d+(ie*3|0)>>0]|0,Z=e[ke>>2]|0,w=F[d+(P*3|0)>>0]|0,C=c-w|0,D=F[h+(P*3|0)>>0]|0,k=w-D|0,N=((((S[Z+((F[d+(r*3|0)>>0]|0)-c)>>0]|0)*9|0)+(S[Z+C>>0]|0)|0)*9|0)+(S[Z+k>>0]|0)|0,l=F[d+(ie*3|0)+1>>0]|0,R=F[d+(P*3|0)+1>>0]|0,_=l-R|0,U=F[h+(P*3|0)+1>>0]|0,Q=R-U|0,K=((((S[Z+((F[d+(r*3|0)+1>>0]|0)-l)>>0]|0)*9|0)+(S[Z+_>>0]|0)|0)*9|0)+(S[Z+Q>>0]|0)|0,o=F[d+(ie*3|0)+2>>0]|0,G=F[d+(P*3|0)+2>>0]|0,$=o-G|0,P=F[h+(P*3|0)+2>>0]|0,O=G-P|0,Z=((((S[Z+((F[d+(r*3|0)+2>>0]|0)-o)>>0]|0)*9|0)+(S[Z+$>>0]|0)|0)*9|0)+(S[Z+O>>0]|0)|0,K|N|Z?(d=F[h+(ie*3|0)>>0]|0,h=c-D>>31,(h^k|0)>=0&&((h^C|0)<0?c=D:c=D-w+c|0),d=er(t,N,d,c,0)|0,h=F[(e[ne>>2]|0)+(ie*3|0)+1>>0]|0,c=l-U>>31,(c^Q|0)>=0&&((c^_|0)<0?l=U:l=U-R+l|0),c=er(t,K,h,l,0)|0,h=F[(e[ne>>2]|0)+(ie*3|0)+2>>0]|0,l=o-P>>31,(l^O|0)>=0&&((l^$|0)<0?o=P:o=P-G+o|0),Z=er(t,Z,h,o,0)|0,ie=(e[ne>>2]|0)+(ie*3|0)|0,S[ie>>0]=d,S[ie+1>>0]=c,S[ie+2>>0]=Z):r=(w2(t,ie,0)|0)+ie|0,(r|0)<(e[oe>>2]|0);)ie=r}function w2(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0;for(D=(e[t+156>>2]|0)-r|0,k=e[t+4584>>2]|0,N=e[t+4580>>2]|0,C=k+((r+-1|0)*3|0)|0,R=S[C>>0]|0,w=S[C+1>>0]|0,C=S[C+2>>0]|0,h=0;o=k+((h+r|0)*3|0)|0,l=o+1|0,c=o+2|0,!!(((S[o>>0]|0)==R<<24>>24?(S[l>>0]|0)==w<<24>>24:0)&(S[c>>0]|0)==C<<24>>24);)if(S[o>>0]=R,S[l>>0]=w,S[c>>0]=C,h=h+1|0,(h|0)==(D|0)){h=D;break}if(c=(h|0)==(D|0),d=t+4576|0,l=e[36476+(e[d>>2]<<2)>>2]|0,(1<(h|0))o=h;else{o=h;do _t(t,1,1),l=e[d>>2]|0,o=o-(1<>2])|0,l=(l|0)>30?31:l+1|0,e[d>>2]=l,l=e[36476+(l<<2)>>2]|0;while((o|0)>=(1<>0]|0,r=D+2|0,c=S[r>>0]|0,N=N+(l*3|0)|0,l=S[N+1>>0]|0,K=S[N+2>>0]|0,N=F[N>>0]|0,_=N-(R&255)>>31|1,U=(ee((F[D>>0]|0)-N<<24,_)|0)>>24,Q=t+4552|0,tr(t,Q,U),R=l&255,l=R-(w&255)>>31|1,o=(ee((o&255)-R<<24,l)|0)>>24,tr(t,Q,o),w=K&255,C=w-(C&255)>>31|1,c=(ee((c&255)-w<<24,C)|0)>>24,tr(t,Q,c),N=(ee(U,_)|0)+N&255,R=(ee(o,l)|0)+R&255,t=(ee(c,C)|0)+w&255,S[D>>0]=N,S[k>>0]=R,S[r>>0]=t,t=e[d>>2]|0,e[d>>2]=(t|0)<1?0:t+-1|0,t=h+1|0,t|0)}function er(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(U=r>>31,C=(U^r)-U|0,_=t+172+(C*12|0)+10|0,d=E[_>>1]|0,R=t+172+(C*12|0)|0,c=e[R>>2]|0,(d|0)<(c|0))if((d<<1|0)<(c|0))if((d<<2|0)<(c|0))if((d<<3|0)<(c|0))if((d<<4|0)<(c|0))for(h=5;(d<>1]^U)-U+l|0,(c&255|0)==(c|0)?k=c:k=c>>31&255^255,w=(o-k^U)-U<<24,D=w>>24,h?c=0:c=(e[t+172+(C*12|0)+4>>2]<<1)+-1+d>>31,c=c^D,c=c>>30^c<<1,l=c>>h,(l|0)<23?(_t(t,1,l+1|0),_t(t,c&(1<>1]|0,c=d<<16>>16==64,h=c&1,o=(e[l>>2]|0)+D>>h,d=c?32:d<<16>>16,e[R>>2]=(e[R>>2]|0)+((w|0)>-16777216?D:0-D|0)>>h,h=d+1|0,E[_>>1]=h,c=h+o|0,(c|0)<1?(_=E[N>>1]|0,E[N>>1]=(_&65535)-(_<<16>>16>-128&1),_=(c|0)>(~d|0)?c:0-d|0,e[l>>2]=_,U=D^U,r=r>>>31,r=k+r|0,r=r+U|0,r=r&255,r|0):(o|0)<=0?(_=o,e[l>>2]=_,U=D^U,r=r>>>31,r=k+r|0,r=r+U|0,r=r&255,r|0):(_=o-h|0,R=E[N>>1]|0,E[N>>1]=(R<<16>>16<127&1)+(R&65535),_=(_|0)>0?0:_,e[l>>2]=_,U=D^U,r=r>>>31,r=k+r|0,r=r+U|0,r=r&255,r|0)}function tr(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=r+9|0,d=F[k>>0]|0,D=r+4|0,C=e[D>>2]|0,c=(ee(d>>>1,C)|0)+(e[r>>2]|0)|0,(d|0)<(c|0)){h=d,l=0;do h=h<<1,l=l+1|0;while((h|0)<(c|0));c=l}else c=0;(o|0)>0&(c|0)==0&&F[r+10>>0]<<1>>>0>>0?l=1:w=5;do if((w|0)==5){if(l=(o|0)<0,l&&F[r+10>>0]<<1>>>0>=d>>>0){l=1;break}l=l&(c|0)!=0}while(!1);if(l=(((o|0)>-1?o:0-o|0)<<1)-C+(l<<31>>31)|0,y2(t,c,l,31-(e[36476+(e[t+4576>>2]<<2)>>2]|0)|0),(o|0)<0&&(t=r+10|0,S[t>>0]=(F[t>>0]|0)+1),l=(l+1-(e[D>>2]|0)>>1)+(e[r>>2]|0)|0,e[r>>2]=l,c=S[k>>0]|0,c<<24>>24!=(S[r+8>>0]|0)){r=c,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r;return}e[r>>2]=l>>1,t=(c&255)>>>1,S[k>>0]=t,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,r=t,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r}function y2(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;if(c=o>>r,h=l+-8|0,(c|0)<(l+-9|0)){(c|0)>30&&(l=(c|0)/2|0,_t(t,0,l),c=c-l|0),_t(t,1,c+1|0),_t(t,(1<31?(_t(t,0,31),_t(t,1,l+-39|0)):_t(t,1,h),_t(t,o+255&255,8)}function C2(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(D=b,b=b+32|0,w=D,m0(w,255,0),C=t+160|0,(e[w+4>>2]|0)==(e[C>>2]|0)&&(e[w+8>>2]|0)==(e[t+164>>2]|0)&&(e[w+12>>2]|0)==(e[t+168>>2]|0)){C=e[8900]|0,e[t+4588>>2]=C+(((e[8901]|0)-C|0)>>>1),b=D;return}for(o=t+4592|0,l=t+4596|0,c=e[l>>2]|0,r=e[o>>2]|0,h=c-r|0,h>>>0>=512?h>>>0>512&&(d=r+512|0,(c|0)!=(d|0))&&(e[l>>2]=d):(j0(o,512-h|0),r=e[o>>2]|0),w=t+4588|0,e[w>>2]=r+256,d=t+168|0,c=t+164|0,h=-256;;){if(r=e[d>>2]|0,(h|0)>(0-r|0))if(o=e[c>>2]|0,(h|0)>(0-o|0))if(l=e[C>>2]|0,(h|0)>(0-l|0))if((h|0)>=0){if((h|0)<1){S[(e[w>>2]|0)+h>>0]=0,h=1;continue}(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1}else r=-1;else r=-2;else r=-3;else r=-4;if(S[(e[w>>2]|0)+h>>0]=r,h=h+1|0,(h|0)==256)break}b=D}function T2(t){t=t|0;var r=0,o=0;e[t>>2]=35884,r=e[t+4616>>2]|0,r&&(o=t+4620|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),t=t+4|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function I2(t){t=t|0;var r=0,o=0;if(e[t>>2]=35884,r=e[t+4616>>2]|0,r&&(o=t+4620|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36612,r=e[t+120>>2]|0,r&&(o=t+124|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+92|0,r=e[o>>2]|0,e[o>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),o=t+4|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function E2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;d=b,b=b+32|0,C=d,m0(C,e[t+136>>2]|0,e[t+144>>2]|0),w=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[C+8>>2]|0,c=e[r+12>>2]|0,c=c|0?c:e[C+12>>2]|0,o=e[r+16>>2]|0,l=e[C+16>>2]|0,e[t+184>>2]=w|0?w:e[C+4>>2]|0,e[t+188>>2]=h,e[t+192>>2]=c,P2(t),c=t+140|0,r=(e[c>>2]|0)+32|0,r=(r|0)<128?2:(r|0)/64|0,h=0;do e[t+196+(h*12|0)>>2]=r,e[t+196+(h*12|0)+4>>2]=0,E[t+196+(h*12|0)+8>>1]=0,E[t+196+(h*12|0)+10>>1]=1,h=h+1|0;while((h|0)!=365);w=(e[c>>2]|0)+32|0,w=(w|0)<128?2:(w|0)/64|0,C=(o|0?o:l)&255,e[t+4576>>2]=w,e[t+4580>>2]=0,S[t+4584>>0]=C,S[t+4585>>0]=1,S[t+4586>>0]=0,e[t+4588>>2]=w,e[t+4592>>2]=1,S[t+4596>>0]=C,S[t+4597>>0]=1,S[t+4598>>0]=0,e[t+4600>>2]=0,b=d}function D2(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=b,b=b+16|0,C=k,w=t+92|0,d=e[r>>2]|0,e[r>>2]=0,r=e[w>>2]|0,e[w>>2]=d,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),e[C>>2]=0,e[C+4>>2]=l,w=o+8|0,e[C+8>>2]=e[w>>2],l){r=Xe(4624)|0,l=t+8|0,c=r+4|0,h=l,d=c+84|0;do e[c>>2]=e[h>>2],c=c+4|0,h=h+4|0;while((c|0)<(d|0));c=r+88|0,d=c+40|0;do e[c>>2]=0,c=c+4|0;while((c|0)<(d|0));e[r>>2]=35660,e[r+128>>2]=e[t+136>>2],e[r+132>>2]=e[t+140>>2],e[r+136>>2]=e[t+144>>2],e[r+140>>2]=e[t+148>>2],e[r+144>>2]=e[t+152>>2],e[r+148>>2]=e[t+156>>2],e[r+152>>2]=e[t+160>>2],c=r+156|0,e[c>>2]=0,e[c+4>>2]=0,e[c+8>>2]=0,e[c+12>>2]=0,e[r+172>>2]=e[l>>2],e[r+176>>2]=0,e[r+180>>2]=0,e[r+184>>2]=0,c=r+4568|0,l=r+188|0;do e[l>>2]=0,e[l+4>>2]=0,E[l+8>>1]=0,E[l+10>>1]=1,l=l+12|0;while((l|0)!=(c|0));h=t+4|0,e[c>>2]=0,e[c+4>>2]=0,E[c+8>>1]=0,S[c+10>>0]=0,d=r+4580|0,e[d>>2]=0,e[d+4>>2]=0,E[d+8>>1]=0,S[d+10>>0]=0,d=r+4592|0,e[d>>2]=0,e[d+4>>2]=0,e[d+8>>2]=0,e[d+12>>2]=0,e[d+16>>2]=0,e[d+20>>2]=0,e[d+24>>2]=0,S[d+28>>0]=0,e[r+28>>2]|0||(e[r+20>>2]=1),l=e[h>>2]|0,e[h>>2]=r,l&&(Mt[e[(e[l>>2]|0)+4>>2]&255](l),r=e[h>>2]|0),Y0(r,C)}return C=t+100|0,e[C>>2]=32,e[t+96>>2]=0,r=e[o>>2]|0,r?(e[t+132>>2]=r,c=t+120|0,w=t+124|0,l=e[w>>2]|0,r=e[c>>2]|0,h=r,d=l-h|0,d>>>0>=4e3?d>>>0>4e3&&(D=r+4e3|0,(l|0)!=(D|0))&&(e[w>>2]=D,l=D):(vi(c,4e3-d|0),r=e[c>>2]|0,h=r,l=e[w>>2]|0),e[t+108>>2]=h,e[t+104>>2]=l-r,As(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0):(e[t+108>>2]=e[o+4>>2],e[t+104>>2]=e[w>>2],As(t),D=t+116|0,D=e[D>>2]|0,t=e[C>>2]|0,t=t+-32|0,t=(t|0)/8|0,t=D-t|0,b=k,t|0)}function N2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+32>>2]|0&&(e[t+24>>2]|0)!=1){if(_=t+8|0,Q=t+36|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(44,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+16>>2]|0,(t|0)==8)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(45,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(46,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(47,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+20>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=1,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=1,e[l+12>>2]=t,O=l,b=G,O|0)}function As(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0;K=b,b=b+32|0,$=K+12|0,Q=K,_=t+180|0,U=(e[_>>2]|0)+4|0,(e[t+32>>2]|0)==1?N=e[t+24>>2]|0:N=1,r=ee(N<<1,U)|0,e[$>>2]=0,P=$+4|0,e[P>>2]=0,e[$+8>>2]=0;e:do if(r){if((r|0)<0&&(g=0,ue(178,$|0),G=g,g=0,G&1)||(R=6),(R|0)==6&&(g=0,o=ge(67,r|0)|0,G=g,g=0,!(G&1))){for(e[P>>2]=o,e[$>>2]=o,e[$+8>>2]=o+r;;)if(S[o>>0]=0,o=(e[P>>2]|0)+1|0,e[P>>2]=o,r=r+-1|0,!r)break e}o=j()|0,r=e[$>>2]|0,r||le(o|0),(e[P>>2]|0)!=(r|0)&&(e[P>>2]=r),he(r),le(o|0)}while(!1);e[Q>>2]=0,G=Q+4|0,e[G>>2]=0,e[Q+8>>2]=0;do if(!N)R=19;else{if(N>>>0>1073741823&&(g=0,ue(178,Q|0),k=g,g=0,k&1)||(R=17),(R|0)==17&&(l=N<<2,g=0,c=ge(67,l|0)|0,k=g,g=0,!(k&1))){e[Q>>2]=c,R=c+(N<<2)|0,e[Q+8>>2]=R,Jt(c|0,0,l|0)|0,e[G>>2]=R,R=19;break}o=j()|0,r=e[Q>>2]|0,l=r,r&&(c=e[G>>2]|0,(c|0)!=(r|0)&&(e[G>>2]=c+(~((c+-4-l|0)>>>2)<<2)),he(r))}while(!1);if((R|0)==19){d=t+12|0;e:do if((e[d>>2]|0)>0){if(w=t+4604|0,C=(ee(N,U)|0)+1|0,D=t+4608|0,k=t+92|0,h=t+4600|0,(N|0)>0)c=0;else{for(l=0;o=e[$>>2]|0,r=o+1|0,e[w>>2]=r,o=o+C|0,e[D>>2]=o,l&1?(e[w>>2]=o,e[D>>2]=r):r=o,N=e[k>>2]|0,g=0,$e(e[(e[N>>2]|0)+12>>2]|0,N|0,r|0,e[_>>2]|0,U|0),N=g,g=0,!(N&1);)if(l=l+1|0,(l|0)>=(e[d>>2]|0)){R=45;break e}o=j()|0;break}t:for(;;){if(o=e[$>>2]|0,r=o+1|0,e[w>>2]=r,o=o+C|0,e[D>>2]=o,c&1?(e[w>>2]=o,e[D>>2]=r):r=o,R=e[k>>2]|0,g=0,$e(e[(e[R>>2]|0)+12>>2]|0,R|0,r|0,e[_>>2]|0,U|0),R=g,g=0,R&1){R=28;break}r=e[Q>>2]|0,o=e[w>>2]|0,l=0;do{if(e[h>>2]=e[r+(l<<2)>>2],R=e[_>>2]|0,S[o+R>>0]=S[o+(R+-1)>>0]|0,S[(e[D>>2]|0)+-1>>0]=S[e[w>>2]>>0]|0,g=0,Ae(75,t|0,0),R=g,g=0,R&1){R=36;break t}r=e[Q>>2]|0,e[r+(l<<2)>>2]=e[h>>2],o=(e[w>>2]|0)+U|0,e[w>>2]=o,e[D>>2]=(e[D>>2]|0)+U,l=l+1|0}while((l|0)<(N|0));if(c=c+1|0,(c|0)>=(e[d>>2]|0)){R=45;break e}}if((R|0)==28){o=j()|0;break}else if((R|0)==36){o=j()|0;break}}else R=45;while(!1);do if((R|0)==45){if(g=0,ue(182,t|0),t=g,g=0,t&1){o=j()|0;break}if(r=e[Q>>2]|0,o=r,r&&(l=e[G>>2]|0,(l|0)!=(r|0)&&(e[G>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[$>>2]|0,!r){b=K;return}(e[P>>2]|0)!=(r|0)&&(e[P>>2]=r),he(r),b=K;return}while(!1);r=e[Q>>2]|0,l=r,r&&(c=e[G>>2]|0,(c|0)!=(r|0)&&(e[G>>2]=c+(~((c+-4-l|0)>>>2)<<2)),he(r))}r=e[$>>2]|0,r||le(o|0),(e[P>>2]|0)!=(r|0)&&(e[P>>2]=r),he(r),le(o|0)}function F2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(N=t+4604|0,r=e[N>>2]|0,U=t+180|0,!((e[U>>2]|0)<=0))for(R=t+4608|0,_=t+4612|0,c=r,h=F[r+-1>>0]|0,r=F[r>>0]|0,k=0;D=e[R>>2]|0,C=F[D+(k+-1)>>0]|0,l=k+1|0,o=F[c+l>>0]|0,w=e[_>>2]|0,d=r-h|0,c=h-C|0,w=((((S[w+(o-r)>>0]|0)*9|0)+(S[w+d>>0]|0)|0)*9|0)+(S[w+c>>0]|0)|0,w?(h=r-C>>31,(h^c|0)<0?c=r:c=C+((h^d|0)<0?0:d)|0,D=R2(t,w,F[D+k>>0]|0,c,0)|0,S[(e[R>>2]|0)+k>>0]=D):(l=(M2(t,k,0)|0)+k|0,o=e[N>>2]|0,r=F[o+(l+-1)>>0]|0,o=F[o+l>>0]|0),!((l|0)>=(e[U>>2]|0));)c=e[N>>2]|0,h=r,r=o,k=l}function R2(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;if(Q=r>>31,h=(Q^r)-Q|0,_=t+196+(h*12|0)+10|0,d=E[_>>1]|0,R=t+196+(h*12|0)|0,c=e[R>>2]|0,(d|0)<(c|0))if((d<<1|0)<(c|0))if((d<<2|0)<(c|0))if((d<<3|0)<(c|0))if((d<<4|0)<(c|0))for(r=5;(d<>1]^Q)-Q+l|0,U=t+136|0,l=e[U>>2]|0,(c&l|0)==(c|0)?D=c:D=l&~(c>>31),c=(o-D^Q)-Q|0,C=t+144|0,l=e[C>>2]|0,(c|0)>0?c=(c+l|0)/(l<<1|1|0)|0:c=(c-l|0)/(l<<1|1|0)|0,N=t+140|0,w=e[N>>2]|0,o=((c|0)<0?w:0)+c|0,w=o-((o|0)<((w+1|0)/2|0|0)?0:w)|0,h=t+196+(h*12|0)+4|0,l|r?c=0:c=(e[h>>2]<<1)+-1+d>>31,l=c^w,xs(t,r,l>>30^l<<1,e[t+156>>2]|0),l=e[t+160>>2]|0,r=(e[R>>2]|0)+((w|0)>-1?w:0-w|0)|0,c=(e[h>>2]|0)+(ee(e[C>>2]<<1|1,w)|0)|0,o=E[_>>1]|0,(o|0)==(l|0)&&(r=r>>1,c=c>>1,o=l>>1),e[R>>2]=r,l=o+1|0,E[_>>1]=l,r=l+c|0,(r|0)>=1?(c|0)>0&&(c=c-l|0,_=E[k>>1]|0,E[k>>1]=(_<<16>>16<127&1)+(_&65535),c=(c|0)>0?0:c):(c=E[k>>1]|0,E[k>>1]=(c&65535)-(c<<16>>16>-128&1),c=(r|0)>(~o|0)?r:0-o|0),e[h>>2]=c,l=e[C>>2]|0,o=l<<1|1,r=(ee(o,(w^Q)-Q|0)|0)+D|0,(r|0)>=(0-l|0)?(c=e[U>>2]|0,(c+l|0)<(r|0)&&(r=r-(ee(e[N>>2]|0,o)|0)|0)):(r=(ee(e[N>>2]|0,o)|0)+r|0,c=e[U>>2]|0),(r&c|0)==(r|0)?(Q=r,Q=Q&255,Q|0):(Q=c&~(r>>31),Q=Q&255,Q|0)}function M2(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;for(C=(e[t+180>>2]|0)-r|0,D=e[t+4608>>2]|0,k=e[t+4604>>2]|0,c=S[D+(r+-1)>>0]|0,w=c&255,o=t+144|0,h=0;l=D+(h+r)|0,d=(F[l>>0]|0)-w|0,!((((d|0)>-1?d:0-d|0)|0)>(e[o>>2]|0));)if(S[l>>0]=c,h=h+1|0,(h|0)==(C|0)){h=C;break}if(c=(h|0)==(C|0),d=t+4600|0,l=e[36476+(e[d>>2]<<2)>>2]|0,(1<(h|0))o=h;else{o=h;do _t(t,1,1),l=e[d>>2]|0,o=o-(1<>2])|0,l=(l|0)>30?31:l+1|0,e[d>>2]=l,l=e[36476+(l<<2)>>2]|0;while((o|0)>=(1<>0]|0,w,F[k+C>>0]|0)|0,S[r>>0]=t,t=e[d>>2]|0,e[d>>2]=(t|0)<1?0:t+-1|0,t=h+1|0,t|0)}function _2(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;return w=o-l|0,C=t+136|0,d=t+144|0,c=e[d>>2]|0,(((w|0)>-1?w:0-w|0)|0)>(c|0)?(h=l-o>>31|1,r=ee(h,r-l|0)|0,(r|0)>0?r=(c+r|0)/(c<<1|1|0)|0:r=(r-c|0)/(c<<1|1|0)|0,w=t+140|0,c=e[w>>2]|0,o=((r|0)<0?c:0)+r|0,c=o-((o|0)<((c+1|0)/2|0|0)?0:c)|0,vs(t,t+4576|0,c),c=ee(c,h)|0,h=e[d>>2]|0,d=h<<1|1,c=(ee(c,d)|0)+l|0,(c|0)>=(0-h|0)?(r=e[C>>2]|0,(r+h|0)<(c|0)&&(c=c-(ee(e[w>>2]|0,d)|0)|0)):(c=(ee(e[w>>2]|0,d)|0)+c|0,r=e[C>>2]|0),(c&r|0)==(c|0)?(C=c,C=C&255,C|0):(C=r&~(c>>31),C=C&255,C|0)):(r=r-o|0,(r|0)>0?r=(c+r|0)/(c<<1|1|0)|0:r=(r-c|0)/(c<<1|1|0)|0,w=t+140|0,c=e[w>>2]|0,h=((r|0)<0?c:0)+r|0,c=h-((h|0)<((c+1|0)/2|0|0)?0:c)|0,vs(t,t+4588|0,c),h=e[d>>2]|0,d=h<<1|1,c=(ee(d,c)|0)+o|0,(c|0)>=(0-h|0)?(r=e[C>>2]|0,(r+h|0)<(c|0)&&(c=c-(ee(e[w>>2]|0,d)|0)|0)):(c=(ee(e[w>>2]|0,d)|0)+c|0,r=e[C>>2]|0),(c&r|0)==(c|0)?(C=c,C=C&255,C|0):(C=r&~(c>>31),C=C&255,C|0))}function vs(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;if(k=r+9|0,d=F[k>>0]|0,D=r+4|0,C=e[D>>2]|0,c=(ee(d>>>1,C)|0)+(e[r>>2]|0)|0,(d|0)<(c|0)){h=d,l=0;do h=h<<1,l=l+1|0;while((h|0)<(c|0));c=l}else c=0;(o|0)>0&(c|0)==0&&F[r+10>>0]<<1>>>0>>0?l=1:w=5;do if((w|0)==5){if(l=(o|0)<0,l&&F[r+10>>0]<<1>>>0>=d>>>0){l=1;break}l=l&(c|0)!=0}while(!1);if(l=(((o|0)>-1?o:0-o|0)<<1)-C+(l<<31>>31)|0,xs(t,c,l,(e[t+156>>2]|0)+-1-(e[36476+(e[t+4600>>2]<<2)>>2]|0)|0),(o|0)<0&&(t=r+10|0,S[t>>0]=(F[t>>0]|0)+1),l=(l+1-(e[D>>2]|0)>>1)+(e[r>>2]|0)|0,e[r>>2]=l,c=S[k>>0]|0,c<<24>>24!=(S[r+8>>0]|0)){r=c,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r;return}e[r>>2]=l>>1,t=(c&255)>>>1,S[k>>0]=t,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,r=t,r=r&255,r=r+1|0,r=r&255,S[k>>0]=r}function xs(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0;if(c=o>>r,h=t+148|0,d=l-(e[h>>2]|0)|0,(c|0)<(d+-1|0)){(c|0)>30&&(l=(c|0)/2|0,_t(t,0,l),c=c-l|0),_t(t,1,c+1|0),_t(t,(1<31?(_t(t,0,31),_t(t,1,l+-31-(e[h>>2]|0)|0)):_t(t,1,d),r=e[h>>2]|0,_t(t,(1<>2]|0)r=t+152|0;else if(o=e[t+136>>2]|0,r=t+152|0,(o|0)==((1<>2])+-1|0)&&(m0(l,o,0),(e[l+4>>2]|0)==(e[t+184>>2]|0))&&(e[l+8>>2]|0)==(e[t+188>>2]|0)&&(e[l+12>>2]|0)==(e[t+192>>2]|0))switch(e[r>>2]|0){case 8:{N=e[8900]|0,e[t+4612>>2]=N+(((e[8901]|0)-N|0)>>>1),b=R;return}case 10:{N=e[8903]|0,e[t+4612>>2]=N+(((e[8904]|0)-N|0)>>>1),b=R;return}case 12:{N=e[8906]|0,e[t+4612>>2]=N+(((e[8907]|0)-N|0)>>>1),b=R;return}case 16:{N=e[8909]|0,e[t+4612>>2]=N+(((e[8910]|0)-N|0)>>>1),b=R;return}default:break e}while(!1);if(k=1<>2],o=t+4616|0,l=k<<1,c=t+4620|0,h=e[c>>2]|0,r=e[o>>2]|0,d=h-r|0,l>>>0<=d>>>0?l>>>0>>0&&(w=r+l|0,(h|0)!=(w|0))&&(e[c>>2]=w):(j0(o,l-d|0),r=e[o>>2]|0),D=t+4612|0,e[D>>2]=r+k,r=0-k|0,(k|0)<=(r|0)){b=R;return}w=t+192|0,C=t+188|0,d=t+184|0,h=r;do r=e[w>>2]|0,(h|0)>(0-r|0)?(o=e[C>>2]|0,(h|0)>(0-o|0)?(l=e[d>>2]|0,(h|0)>(0-l|0)?(c=e[N>>2]|0,(h|0)>=(0-c|0)?(c|0)<(h|0)?(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1:r=0:r=-1):r=-2):r=-3):r=-4,S[(e[D>>2]|0)+h>>0]=r,h=h+1|0;while((h|0)!=(k|0));b=R}function L2(t){t=t|0;var r=0,o=0;e[t>>2]=35856,r=e[t+4608>>2]|0,r&&(o=t+4612|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),t=t+88|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function O2(t){t=t|0;var r=0,o=0;if(e[t>>2]=35856,r=e[t+4608>>2]|0,r&&(o=t+4612|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+88|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function $2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+28>>2]|0&&(e[t+20>>2]|0)!=1){if(_=t+4|0,Q=t+32|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(37,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+12>>2]|0,(t|0)==16)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(38,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(39,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(40,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+16>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=2,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=2,e[l+12>>2]=t,O=l,b=G,O|0)}function B2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;d=b,b=b+32|0,C=d,m0(C,e[t+128>>2]|0,e[t+136>>2]|0),w=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[C+8>>2]|0,c=e[r+12>>2]|0,c=c|0?c:e[C+12>>2]|0,o=e[r+16>>2]|0,l=e[C+16>>2]|0,e[t+176>>2]=w|0?w:e[C+4>>2]|0,e[t+180>>2]=h,e[t+184>>2]=c,Q2(t),c=t+132|0,r=(e[c>>2]|0)+32|0,r=(r|0)<128?2:(r|0)/64|0,h=0;do e[t+188+(h*12|0)>>2]=r,e[t+188+(h*12|0)+4>>2]=0,E[t+188+(h*12|0)+8>>1]=0,E[t+188+(h*12|0)+10>>1]=1,h=h+1|0;while((h|0)!=365);w=(e[c>>2]|0)+32|0,w=(w|0)<128?2:(w|0)/64|0,C=(o|0?o:l)&255,e[t+4568>>2]=w,e[t+4572>>2]=0,S[t+4576>>0]=C,S[t+4577>>0]=1,S[t+4578>>0]=0,e[t+4580>>2]=w,e[t+4584>>2]=1,S[t+4588>>0]=C,S[t+4589>>0]=1,S[t+4590>>0]=0,e[t+4592>>2]=0,b=d}function V2(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;for(d=t+88|0,h=e[r>>2]|0,e[r>>2]=0,r=e[d>>2]|0,e[d>>2]=h,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),d=l+4|0,h=e[d>>2]|0,S[t+4620>>0]=c&1,r=t+156|0,e[r>>2]=e[o>>2],e[r+4>>2]=e[o+4>>2],e[r+8>>2]=e[o+8>>2],e[r+12>>2]=e[o+12>>2],Y0(t,l),U2(t),r=e[t+116>>2]|0,t=e[t+112>>2]|0;c=r+-1|0,o=(S[c>>0]|0)==-1?7:8,!((t|0)<(o|0));)r=c,t=t-o|0;r=r-h|0,c=e[d>>2]|0,c&&(e[d>>2]=c+r,l=l+8|0,e[l>>2]=(e[l>>2]|0)-r)}function U2(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;ie=b,b=b+32|0,ne=ie+12|0,Z=ie,$=t+172|0,P=(e[$>>2]|0)+4|0,(e[t+28>>2]|0)==1?O=e[t+20>>2]|0:O=1,r=ee(O<<1,P)|0,e[ne>>2]=0,ce=ne+4|0,e[ce>>2]=0,e[ne+8>>2]=0;do if(r){if((r|0)<0&&(g=0,ue(178,ne|0),oe=g,g=0,oe&1)||(d=6),(d|0)==6&&(o=r<<1,g=0,l=ge(67,o|0)|0,oe=g,g=0,!(oe&1))){e[ne>>2]=l,oe=l+(r<<1)|0,e[ne+8>>2]=oe,Jt(l|0,0,o|0)|0,e[ce>>2]=oe;break}l=j()|0,r=e[ne>>2]|0,r||le(l|0),o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),le(l|0)}while(!1);e[Z>>2]=0,oe=Z+4|0,e[oe>>2]=0,e[Z+8>>2]=0;do if(!O)d=18;else{if(O>>>0>1073741823&&(g=0,ue(178,Z|0),G=g,g=0,G&1)||(d=16),(d|0)==16&&(c=O<<2,g=0,h=ge(67,c|0)|0,G=g,g=0,!(G&1))){e[Z>>2]=h,d=h+(O<<2)|0,e[Z+8>>2]=d,Jt(h|0,0,c|0)|0,e[oe>>2]=d,d=18;break}l=j()|0,r=e[Z>>2]|0,o=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}while(!1);if((d|0)==18){h=t+8|0;e:do if((e[h>>2]|0)>0){d=t+4596|0,w=ee(O,P)|0,C=w+1|0,D=t+4600|0,k=(O|0)>0,N=t+160|0,R=t+168|0,_=t+164|0,U=t+156|0,Q=t+88|0,K=t+4592|0,G=0;t:for(;;){if(l=e[ne>>2]|0,o=l+2|0,e[d>>2]=o,l=l+(C<<1)|0,e[D>>2]=l,G&1?(e[d>>2]=l,e[D>>2]=o,r=o,o=l):r=l,k){c=e[Z>>2]|0,l=0;do{if(e[K>>2]=e[c+(l<<2)>>2],c=e[$>>2]|0,E[o+(c<<1)>>1]=E[o+(c+-1<<1)>>1]|0,E[r+-2>>1]=E[o>>1]|0,g=0,Ae(76,t|0,0),c=g,g=0,c&1){d=29;break t}c=e[Z>>2]|0,e[c+(l<<2)>>2]=e[K>>2],o=(e[d>>2]|0)+(P<<1)|0,e[d>>2]=o,r=(e[D>>2]|0)+(P<<1)|0,e[D>>2]=r,l=l+1|0}while((l|0)<(O|0))}if(c=e[N>>2]|0,(c|0)<=(G|0)&&(G|0)<((e[R>>2]|0)+c|0)&&(c=e[Q>>2]|0,g=0,$e(e[(e[c>>2]|0)+8>>2]|0,c|0,r+((e[U>>2]|0)-w<<1)|0,e[_>>2]|0,P|0),c=g,g=0,c&1)){d=30;break}if(G=G+1|0,(G|0)>=(e[h>>2]|0)){d=42;break e}}if((d|0)==29){l=j()|0;break}else if((d|0)==30){l=j()|0;break}}else d=42;while(!1);do if((d|0)==42){if(g=0,ue(183,t|0),t=g,g=0,t&1){l=j()|0;break}if(r=e[Z>>2]|0,o=r,r&&(l=e[oe>>2]|0,(l|0)!=(r|0)&&(e[oe>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[ne>>2]|0,!r){b=ie;return}o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),b=ie;return}while(!1);r=e[Z>>2]|0,o=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}r=e[ne>>2]|0,r||le(l|0),o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),le(l|0)}function z2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0;if(R=t+4596|0,o=e[R>>2]|0,K=t+172|0,r=e[K>>2]|0,!((r|0)<=0))for(_=t+4600|0,U=t+4604|0,Q=t+4592|0,w=o,h=M[o+-2>>1]|0,o=M[o>>1]|0,N=0;D=e[_>>2]|0,d=E[D+(N+-1<<1)>>1]|0,k=d&65535,c=N+1|0,l=M[w+(c<<1)>>1]|0,C=e[U>>2]|0,w=o-h|0,h=h-k|0,C=((((S[C+(l-o)>>0]|0)*9|0)+(S[C+w>>0]|0)|0)*9|0)+(S[C+h>>0]|0)|0,D=D+(N<<1)|0,C?(r=o-k>>31,(r^h|0)<0?r=o:r=k+((r^w|0)<0?0:w)|0,k=q2(t,C,M[D>>1]|0,r,0)|0,E[(e[_>>2]|0)+(N<<1)>>1]=k):(r=W2(t,d,D,r-N|0)|0,o=r+N|0,(o|0)!=(e[K>>2]|0)&&(k=H2(t,k,M[(e[R>>2]|0)+(o<<1)>>1]|0)|0,E[(e[_>>2]|0)+(o<<1)>>1]=k,k=e[Q>>2]|0,e[Q>>2]=(k|0)<1?0:k+-1|0,r=r+1|0),c=r+N|0,l=e[R>>2]|0,o=M[l+(c+-1<<1)>>1]|0,l=M[l+(c<<1)>>1]|0),r=e[K>>2]|0,!((r|0)<=(c|0));)w=e[R>>2]|0,h=o,o=l,N=c}function G2(t){t=t|0;var r=0,o=0,l=0,c=0;l=t+116|0,o=e[l>>2]|0,(S[o>>0]|0)!=-1?(c=t+112|0,r=e[c>>2]|0,(r|0)<1&&(P0(t),r=e[c>>2]|0,o=e[l>>2]|0),t=t+108|0,l=e[t>>2]|0,e[c>>2]=r+-1,r=l<<1,e[t>>2]=r,(S[o>>0]|0)!=-1&&(r=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,r|0,6,35648),t=g,g=0,t&1||Qt(r|0,824,96),t=j()|0,Tt(r|0),le(t|0))):r=e[t+108>>2]|0,r&&(r=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,r|0,6,35648),t=g,g=0,t&1||Qt(r|0,824,96),t=j()|0,Tt(r|0),le(t|0))}function q2(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(U=r>>31,C=(U^r)-U|0,R=t+188+(C*12|0)+10|0,o=E[R>>1]|0,N=t+188+(C*12|0)|0,c=e[N>>2]|0,(o|0)<(c|0))if((o<<1|0)<(c|0))if((o<<2|0)<(c|0))if((o<<3|0)<(c|0))if((o<<4|0)<(c|0))for(r=5;(o<>1]^U)-U+l|0,_=t+128|0,c=e[_>>2]|0,(o&c|0)==(o|0)?D=o:D=c&~(o>>31),o=t+112|0,(e[o>>2]|0)<8&&P0(t),c=t+108|0,l=e[c>>2]|0,h=l>>>24,d=e[2832+(r<<11)+(h<<3)+4>>2]|0,d?(e[o>>2]=(e[o>>2]|0)-d,e[c>>2]=l<>2]|0):(w=e[t+148>>2]|0,c=e[t+140>>2]|0,o=X0(t)|0,(o|0)<(w+-1-c|0)?r&&(o=(l0(t,r)|0)+(o<>31^o>>1,(((o|0)>-1?o:0-o|0)|0)>65535&&(o=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,o|0,5,35648),t=g,g=0,t&1?(t=j()|0,Tt(o|0),le(t|0)):Qt(o|0,824,96))),w=t+136|0,l=e[w>>2]|0,r?d=o:(l?c=0:c=(e[t+188+(C*12|0)+4>>2]<<1)+-1+(E[R>>1]|0)>>31,d=c^o),r=e[t+152>>2]|0,c=(e[N>>2]|0)+((d|0)>-1?d:0-d|0)|0,h=t+188+(C*12|0)+4|0,o=(e[h>>2]|0)+(ee(l<<1|1,d)|0)|0,l=E[R>>1]|0,(l|0)==(r|0)&&(c=c>>1,o=o>>1,l=r>>1),e[N>>2]=c,r=l+1|0,E[R>>1]=r,c=r+o|0,(c|0)>=1?(o|0)>0&&(o=o-r|0,R=E[k>>1]|0,E[k>>1]=(R<<16>>16<127&1)+(R&65535),o=(o|0)>0?0:o):(o=E[k>>1]|0,E[k>>1]=(o&65535)-(o<<16>>16>-128&1),o=(c|0)>(~l|0)?c:0-l|0),e[h>>2]=o,r=e[w>>2]|0,l=r<<1|1,c=(ee(l,(d^U)-U|0)|0)+D|0,(c|0)>=(0-r|0)?(o=e[_>>2]|0,(o+r|0)<(c|0)&&(c=c-(ee(e[t+132>>2]|0,l)|0)|0)):(c=(ee(e[t+132>>2]|0,l)|0)+c|0,o=e[_>>2]|0),(c&o|0)==(c|0)?(t=c,t=t&65535,t|0):(t=o&~(c>>31),t=t&65535,t|0)}function W2(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;for(w=t+112|0,C=t+108|0,D=t+4592|0,c=e[w>>2]|0,h=0;;){if((c|0)<1&&(P0(t),c=e[w>>2]|0),d=e[C>>2]|0,c=c+-1|0,e[w>>2]=c,e[C>>2]=d<<1,(d|0)>=0){k=8;break}if(d=e[D>>2]|0,N=1<>2],R=l-h|0,R=(N|0)<(R|0)?N:R,h=R+h|0,(R|0)==(N|0)&&(e[D>>2]=(d|0)>30?31:d+1|0),(h|0)==(l|0)){c=l;break}}if((k|0)==8&&((h|0)!=(l|0)?(c=e[D>>2]|0,(c+-4|0)>>>0<28?c=l0(t,e[36476+(c<<2)>>2]|0)|0:c=0,c=c+h|0,(c|0)>(l|0)&&(c=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,c|0,5,35648),R=g,g=0,R&1?(R=j()|0,Tt(c|0),le(R|0)):Qt(c|0,824,96))):c=l),(c|0)>0)h=0;else return c|0;do E[o+(h<<1)>>1]=r,h=h+1|0;while((h|0)!=(c|0));return c|0}function H2(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;return h=r-o|0,d=t+128|0,l=t+136|0,(((h|0)>-1?h:0-h|0)|0)>(e[l>>2]|0)?(r=ee(ws(t,t+4568|0)|0,o-r>>31|1)|0,c=e[l>>2]|0,h=c<<1|1,r=(ee(r,h)|0)+o|0,(r|0)>=(0-c|0)?(l=e[d>>2]|0,(l+c|0)<(r|0)&&(r=r-(ee(e[t+132>>2]|0,h)|0)|0)):(r=(ee(e[t+132>>2]|0,h)|0)+r|0,l=e[d>>2]|0),(r&l|0)==(r|0)?(t=r,t=t&65535,t|0):(t=l&~(r>>31),t=t&65535,t|0)):(o=ws(t,t+4580|0)|0,h=e[l>>2]|0,c=h<<1|1,r=(ee(c,o)|0)+r|0,(r|0)>=(0-h|0)?(l=e[d>>2]|0,(l+h|0)<(r|0)&&(r=r-(ee(e[t+132>>2]|0,c)|0)|0)):(r=(ee(e[t+132>>2]|0,c)|0)+r|0,l=e[d>>2]|0),(r&l|0)==(r|0)?(t=r,t=t&65535,t|0):(t=l&~(r>>31),t=t&65535,t|0))}function ws(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(D=r+9|0,o=F[D>>0]|0,h=r+4|0,c=(ee(o>>>1,e[h>>2]|0)|0)+(e[r>>2]|0)|0,(o|0)<(c|0)){l=0;do o=o<<1,l=l+1|0;while((o|0)<(c|0))}else l=0;d=e[t+148>>2]|0,w=e[36476+(e[t+4592>>2]<<2)>>2]|0,o=e[t+140>>2]|0,c=X0(t)|0;do if((c|0)<(d+-2-w-o|0))if(l){w=(l0(t,l)|0)+(c<>2]|0,c=w+l|0,d=c&1,o=d,h=1,c=(d+c|0)/2|0;break}else{l=e[h>>2]|0,t=l+c|0,o=t&1,t=(o+t|0)/2|0,C=8;break}else c=(l0(t,o)|0)+1|0,d=e[h>>2]|0,t=c+d|0,o=t&1,t=(o+t|0)/2|0,l?(w=c,h=1,c=t,l=d):(l=d,C=8);while(!1);return(C|0)==8&&(w=c,h=F[r+10>>0]<<1>>>0>=(F[D>>0]|0)>>>0,c=t),c=(o|0)!=0^h?c:0-c|0,(c|0)<0&&(C=r+10|0,S[C>>0]=(F[C>>0]|0)+1),o=(w+1-l>>1)+(e[r>>2]|0)|0,e[r>>2]=o,l=S[D>>0]|0,l<<24>>24!=(S[r+8>>0]|0)?(r=l,r=r&255,r=r+1|0,r=r&255,S[D>>0]=r,c|0):(e[r>>2]=o>>1,C=(l&255)>>>1,S[D>>0]=C,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,r=C,r=r&255,r=r+1|0,r=r&255,S[D>>0]=r,c|0)}function X0(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0;if(h=t+112|0,(e[h>>2]|0)<16&&P0(t),d=t+108|0,o=e[d>>2]|0,(o|0)>=0){if(o&1073741824)r=1;else if(o&536870912)r=2;else if(o&268435456)r=3;else if(o&134217728)r=4;else if(o&67108864)r=5;else if(o&33554432)r=6;else if(o&16777216)r=7;else if(o&8388608)r=8;else if(o&4194304)r=9;else if(o&2097152)r=10;else if(o&1048576)r=11;else if(o&524288)r=12;else if(o&262144)r=13;else if(o&131072)r=14;else if(c=o>>>12&16,r=c+-1|0,!c){for(r=(e[h>>2]|0)+-15|0,e[h>>2]=r,l=o<<15,e[d>>2]=l,o=r,r=15;(o|0)<1?(P0(t),c=e[d>>2]|0,o=e[h>>2]|0):c=l,o=o+-1|0,e[h>>2]=o,l=c<<1,e[d>>2]=l,!((c|0)<0);)r=r+1|0;return r|0}}else r=0;return t=r+1|0,e[h>>2]=(e[h>>2]|0)-t,e[d>>2]=o<>2]|0,(o|0)<(r|0)&&(P0(t),o=e[l>>2]|0,(o|0)<(r|0)&&(o=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,o|0,5,35648),t=g,g=0,t&1?(t=j()|0,Tt(o|0),le(t|0)):Qt(o|0,824,96))),c=t+108|0,t=e[c>>2]|0,e[l>>2]=o-r,e[c>>2]=t<>>(32-r|0)|0}function Q2(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;R=b,b=b+32|0,l=R,N=t+136|0;e:do if(e[N>>2]|0)r=t+144|0;else if(o=e[t+128>>2]|0,r=t+144|0,(o|0)==((1<>2])+-1|0)&&(m0(l,o,0),(e[l+4>>2]|0)==(e[t+176>>2]|0))&&(e[l+8>>2]|0)==(e[t+180>>2]|0)&&(e[l+12>>2]|0)==(e[t+184>>2]|0))switch(e[r>>2]|0){case 8:{N=e[8900]|0,e[t+4604>>2]=N+(((e[8901]|0)-N|0)>>>1),b=R;return}case 10:{N=e[8903]|0,e[t+4604>>2]=N+(((e[8904]|0)-N|0)>>>1),b=R;return}case 12:{N=e[8906]|0,e[t+4604>>2]=N+(((e[8907]|0)-N|0)>>>1),b=R;return}case 16:{N=e[8909]|0,e[t+4604>>2]=N+(((e[8910]|0)-N|0)>>>1),b=R;return}default:break e}while(!1);if(k=1<>2],o=t+4608|0,l=k<<1,c=t+4612|0,h=e[c>>2]|0,r=e[o>>2]|0,d=h-r|0,l>>>0<=d>>>0?l>>>0>>0&&(w=r+l|0,(h|0)!=(w|0))&&(e[c>>2]=w):(j0(o,l-d|0),r=e[o>>2]|0),D=t+4604|0,e[D>>2]=r+k,r=0-k|0,(k|0)<=(r|0)){b=R;return}w=t+184|0,C=t+180|0,d=t+176|0,h=r;do r=e[w>>2]|0,(h|0)>(0-r|0)?(o=e[C>>2]|0,(h|0)>(0-o|0)?(l=e[d>>2]|0,(h|0)>(0-l|0)?(c=e[N>>2]|0,(h|0)>=(0-c|0)?(c|0)<(h|0)?(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1:r=0:r=-1):r=-2):r=-3):r=-4,S[(e[D>>2]|0)+h>>0]=r,h=h+1|0;while((h|0)!=(k|0));b=R}function K2(t){t=t|0;var r=0,o=0;e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),t=t+88|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function Y2(t){t=t|0;var r=0,o=0;if(e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+88|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function j2(t){t=t|0;var r=0,o=0;e[t>>2]=35828,r=e[t+4608>>2]|0,r&&(o=t+4612|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),t=t+88|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function X2(t){t=t|0;var r=0,o=0;if(e[t>>2]=35828,r=e[t+4608>>2]|0,r&&(o=t+4612|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+88|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function Z2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+28>>2]|0&&(e[t+20>>2]|0)!=1){if(_=t+4|0,Q=t+32|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(37,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+12>>2]|0,(t|0)==16)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(38,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(39,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(40,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+16>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=6,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=6,e[l+12>>2]=t,O=l,b=G,O|0)}function J2(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;d=b,b=b+32|0,C=d,m0(C,e[t+128>>2]|0,e[t+136>>2]|0),w=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[C+8>>2]|0,c=e[r+12>>2]|0,c=c|0?c:e[C+12>>2]|0,o=e[r+16>>2]|0,l=e[C+16>>2]|0,e[t+176>>2]=w|0?w:e[C+4>>2]|0,e[t+180>>2]=h,e[t+184>>2]=c,su(t),c=t+132|0,r=(e[c>>2]|0)+32|0,r=(r|0)<128?2:(r|0)/64|0,h=0;do e[t+188+(h*12|0)>>2]=r,e[t+188+(h*12|0)+4>>2]=0,E[t+188+(h*12|0)+8>>1]=0,E[t+188+(h*12|0)+10>>1]=1,h=h+1|0;while((h|0)!=365);w=(e[c>>2]|0)+32|0,w=(w|0)<128?2:(w|0)/64|0,C=(o|0?o:l)&255,e[t+4568>>2]=w,e[t+4572>>2]=0,S[t+4576>>0]=C,S[t+4577>>0]=1,S[t+4578>>0]=0,e[t+4580>>2]=w,e[t+4584>>2]=1,S[t+4588>>0]=C,S[t+4589>>0]=1,S[t+4590>>0]=0,e[t+4592>>2]=0,b=d}function eu(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;for(d=t+88|0,h=e[r>>2]|0,e[r>>2]=0,r=e[d>>2]|0,e[d>>2]=h,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),d=l+4|0,h=e[d>>2]|0,S[t+4620>>0]=c&1,r=t+156|0,e[r>>2]=e[o>>2],e[r+4>>2]=e[o+4>>2],e[r+8>>2]=e[o+8>>2],e[r+12>>2]=e[o+12>>2],Y0(t,l),tu(t),r=e[t+116>>2]|0,t=e[t+112>>2]|0;c=r+-1|0,o=(S[c>>0]|0)==-1?7:8,!((t|0)<(o|0));)r=c,t=t-o|0;r=r-h|0,c=e[d>>2]|0,c&&(e[d>>2]=c+r,l=l+8|0,e[l>>2]=(e[l>>2]|0)-r)}function tu(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;ie=b,b=b+32|0,ne=ie+12|0,Z=ie,$=t+172|0,P=(e[$>>2]|0)+4|0,(e[t+28>>2]|0)==1?O=e[t+20>>2]|0:O=1,r=ee(O<<1,P)|0,e[ne>>2]=0,ce=ne+4|0,e[ce>>2]=0,e[ne+8>>2]=0;do if(r){if(r>>>0>715827882&&(g=0,ue(178,ne|0),oe=g,g=0,oe&1)||(d=6),(d|0)==6&&(g=0,o=ge(67,r*6|0)|0,oe=g,g=0,!(oe&1))){for(e[ce>>2]=o,e[ne>>2]=o,l=o+(r*6|0)|0,e[ne+8>>2]=l;E[o>>1]=0,E[o+2>>1]=0,E[o+4>>1]=0,r=r+-1|0,r;)o=o+6|0;e[ce>>2]=l;break}l=j()|0,r=e[ne>>2]|0,r||le(l|0),o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~(((o+-6-r|0)>>>0)/6|0)*6|0)),he(r),le(l|0)}while(!1);e[Z>>2]=0,oe=Z+4|0,e[oe>>2]=0,e[Z+8>>2]=0;do if(!O)d=20;else{if(O>>>0>1073741823&&(g=0,ue(178,Z|0),G=g,g=0,G&1)||(d=18),(d|0)==18&&(c=O<<2,g=0,h=ge(67,c|0)|0,G=g,g=0,!(G&1))){e[Z>>2]=h,d=h+(O<<2)|0,e[Z+8>>2]=d,Jt(h|0,0,c|0)|0,e[oe>>2]=d,d=20;break}l=j()|0,r=e[Z>>2]|0,o=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}while(!1);if((d|0)==20){h=t+8|0;e:do if((e[h>>2]|0)>0){d=t+4596|0,w=ee(O,P)|0,C=w+1|0,D=t+4600|0,k=(O|0)>0,N=t+160|0,R=t+168|0,_=t+164|0,U=t+156|0,Q=t+88|0,K=t+4592|0,G=0;t:for(;;){if(l=e[ne>>2]|0,o=l+6|0,e[d>>2]=o,l=l+(C*6|0)|0,e[D>>2]=l,G&1?(e[d>>2]=l,e[D>>2]=o,r=o,o=l):r=l,k){c=e[Z>>2]|0,l=0;do{if(e[K>>2]=e[c+(l<<2)>>2],r=e[$>>2]|0,c=o+(r*6|0)|0,o=o+((r+-1|0)*6|0)|0,E[c>>1]=E[o>>1]|0,E[c+2>>1]=E[o+2>>1]|0,E[c+4>>1]=E[o+4>>1]|0,c=(e[D>>2]|0)+-6|0,o=e[d>>2]|0,E[c>>1]=E[o>>1]|0,E[c+2>>1]=E[o+2>>1]|0,E[c+4>>1]=E[o+4>>1]|0,g=0,Ae(77,t|0,0),c=g,g=0,c&1){d=31;break t}c=e[Z>>2]|0,e[c+(l<<2)>>2]=e[K>>2],o=(e[d>>2]|0)+(P*6|0)|0,e[d>>2]=o,r=(e[D>>2]|0)+(P*6|0)|0,e[D>>2]=r,l=l+1|0}while((l|0)<(O|0))}if(c=e[N>>2]|0,(c|0)<=(G|0)&&(G|0)<((e[R>>2]|0)+c|0)&&(c=e[Q>>2]|0,g=0,$e(e[(e[c>>2]|0)+8>>2]|0,c|0,r+(((e[U>>2]|0)-w|0)*6|0)|0,e[_>>2]|0,P|0),c=g,g=0,c&1)){d=32;break}if(G=G+1|0,(G|0)>=(e[h>>2]|0)){d=44;break e}}if((d|0)==31){l=j()|0;break}else if((d|0)==32){l=j()|0;break}}else d=44;while(!1);do if((d|0)==44){if(g=0,ue(183,t|0),t=g,g=0,t&1){l=j()|0;break}if(r=e[Z>>2]|0,o=r,r&&(l=e[oe>>2]|0,(l|0)!=(r|0)&&(e[oe>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[ne>>2]|0,!r){b=ie;return}o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~(((o+-6-r|0)>>>0)/6|0)*6|0)),he(r),b=ie;return}while(!1);r=e[Z>>2]|0,o=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}r=e[ne>>2]|0,r||le(l|0),o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~(((o+-6-r|0)>>>0)/6|0)*6|0)),he(r),le(l|0)}function iu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0,jt=0,Gt=0,s0=0,i0=0,zt=0,gt=0;if(zt=b,b=b+32|0,ne=zt+24|0,i0=zt+18|0,s0=zt+12|0,ce=zt+6|0,ke=zt,Ee=t+172|0,r=e[Ee>>2]|0,(r|0)<=0){b=zt;return}for(Te=t+4600|0,it=t+4596|0,jt=t+4604|0,Gt=t+4592|0,oe=0;l=oe+-1|0,c=e[Te>>2]|0,gt=e[it>>2]|0,o=oe+1|0,h=M[gt+(oe*6|0)>>1]|0,ie=e[jt>>2]|0,d=M[gt+(l*6|0)>>1]|0,w=h-d|0,C=M[c+(l*6|0)>>1]|0,D=d-C|0,k=((((S[ie+((M[gt+(o*6|0)>>1]|0)-h)>>0]|0)*9|0)+(S[ie+w>>0]|0)|0)*9|0)+(S[ie+D>>0]|0)|0,N=M[gt+(oe*6|0)+2>>1]|0,R=M[gt+(l*6|0)+2>>1]|0,_=N-R|0,U=M[c+(l*6|0)+2>>1]|0,Q=R-U|0,K=((((S[ie+((M[gt+(o*6|0)+2>>1]|0)-N)>>0]|0)*9|0)+(S[ie+_>>0]|0)|0)*9|0)+(S[ie+Q>>0]|0)|0,G=M[gt+(oe*6|0)+4>>1]|0,$=M[gt+(l*6|0)+4>>1]|0,P=G-$|0,O=M[c+(l*6|0)+4>>1]|0,Z=$-O|0,ie=((((S[ie+((M[gt+(o*6|0)+4>>1]|0)-G)>>0]|0)*9|0)+(S[ie+P>>0]|0)|0)*9|0)+(S[ie+Z>>0]|0)|0,K|k|ie?(l=M[c+(oe*6|0)>>1]|0,r=h-C>>31,(r^D|0)>=0?(r^w|0)<0?r=C:r=C-d+h|0:r=h,h=ir(t,k,l,r,0)|0,l=M[(e[Te>>2]|0)+(oe*6|0)+2>>1]|0,r=N-U>>31,(r^Q|0)>=0?(r^_|0)<0?r=U:r=U-R+N|0:r=N,l=ir(t,K,l,r,0)|0,c=M[(e[Te>>2]|0)+(oe*6|0)+4>>1]|0,r=G-O>>31,(r^Z|0)>=0?(r^P|0)<0?r=O:r=O-$+G|0:r=G,ie=ir(t,ie,c,r,0)|0,gt=e[Te>>2]|0,E[gt+(oe*6|0)>>1]=h,E[gt+(oe*6|0)+2>>1]=l,E[gt+(oe*6|0)+4>>1]=ie):(o=c+(l*6|0)|0,E[s0>>1]=E[o>>1]|0,E[s0+2>>1]=E[o+2>>1]|0,E[s0+4>>1]=E[o+4>>1]|0,E[ne>>1]=E[o>>1]|0,E[ne+2>>1]=E[o+2>>1]|0,E[ne+4>>1]=E[o+4>>1]|0,r=nu(t,ne,c+(oe*6|0)|0,r-oe|0)|0,o=r+oe|0,(o|0)!=(e[Ee>>2]|0)&&(gt=(e[it>>2]|0)+(o*6|0)|0,E[ke>>1]=E[gt>>1]|0,E[ke+2>>1]=E[gt+2>>1]|0,E[ke+4>>1]=E[gt+4>>1]|0,gt=(e[Te>>2]|0)+(o*6|0)|0,E[i0>>1]=E[s0>>1]|0,E[i0+2>>1]=E[s0+2>>1]|0,E[i0+4>>1]=E[s0+4>>1]|0,E[ne>>1]=E[ke>>1]|0,E[ne+2>>1]=E[ke+2>>1]|0,E[ne+4>>1]=E[ke+4>>1]|0,ru(ce,t,i0,ne),E[gt>>1]=E[ce>>1]|0,E[gt+2>>1]=E[ce+2>>1]|0,E[gt+4>>1]=E[ce+4>>1]|0,gt=e[Gt>>2]|0,e[Gt>>2]=(gt|0)<1?0:gt+-1|0,r=r+1|0),o=r+oe|0),r=e[Ee>>2]|0,!((o|0)>=(r|0));)oe=o;b=zt}function nu(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;for(w=t+112|0,C=t+108|0,D=t+4592|0,c=e[w>>2]|0,h=0;;){if((c|0)<1&&(P0(t),c=e[w>>2]|0),d=e[C>>2]|0,c=c+-1|0,e[w>>2]=c,e[C>>2]=d<<1,(d|0)>=0){k=8;break}if(d=e[D>>2]|0,N=1<>2],R=l-h|0,R=(N|0)<(R|0)?N:R,h=R+h|0,(R|0)==(N|0)&&(e[D>>2]=(d|0)>30?31:d+1|0),(h|0)==(l|0)){c=l;break}}if((k|0)==8&&((h|0)!=(l|0)?(c=e[D>>2]|0,(c+-4|0)>>>0<28?c=l0(t,e[36476+(c<<2)>>2]|0)|0:c=0,c=c+h|0,(c|0)>(l|0)&&(c=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,c|0,5,35648),R=g,g=0,R&1?(R=j()|0,Tt(c|0),le(R|0)):Qt(c|0,824,96))):c=l),(c|0)<=0)return c|0;h=0;do R=o+(h*6|0)|0,E[R>>1]=E[r>>1]|0,E[R+2>>1]=E[r+2>>1]|0,E[R+4>>1]=E[r+4>>1]|0,h=h+1|0;while((h|0)!=(c|0));return c|0}function ru(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0;if(C=r+4568|0,N=nr(r,C)|0,d=nr(r,C)|0,C=nr(r,C)|0,h=r+128|0,c=M[l>>1]|0,D=e[r+136>>2]|0,k=D<<1|1,c=(ee(ee(k,N)|0,c-(M[o>>1]|0)>>31|1)|0)+c|0,N=0-D|0,(c|0)>=(N|0)?(h=e[h>>2]|0,(h+D|0)<(c|0)&&(c=c-(ee(e[r+132>>2]|0,k)|0)|0)):(c=(ee(e[r+132>>2]|0,k)|0)+c|0,h=e[h>>2]|0),(c&h|0)!=(c|0)&&(c=h&~(c>>31)),w=c&65535,c=M[l+2>>1]|0,c=(ee(ee(k,d)|0,c-(M[o+2>>1]|0)>>31|1)|0)+c|0,(c|0)>=(N|0)?(h+D|0)<(c|0)&&(c=c-(ee(e[r+132>>2]|0,k)|0)|0):c=(ee(e[r+132>>2]|0,k)|0)+c|0,(c&h|0)!=(c|0)&&(c=h&~(c>>31)),d=c&65535,c=M[l+4>>1]|0,c=(ee(ee(k,C)|0,c-(M[o+4>>1]|0)>>31|1)|0)+c|0,(c|0)>=(N|0)?(h+D|0)<(c|0)&&(c=c-(ee(e[r+132>>2]|0,k)|0)|0):c=(ee(e[r+132>>2]|0,k)|0)+c|0,(c&h|0)==(c|0)){r=c,r=r&65535,E[t>>1]=w,N=t+2|0,E[N>>1]=d,t=t+4|0,E[t>>1]=r;return}r=h&~(c>>31),r=r&65535,E[t>>1]=w,N=t+2|0,E[N>>1]=d,t=t+4|0,E[t>>1]=r}function ir(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(U=r>>31,C=(U^r)-U|0,R=t+188+(C*12|0)+10|0,o=E[R>>1]|0,N=t+188+(C*12|0)|0,c=e[N>>2]|0,(o|0)<(c|0))if((o<<1|0)<(c|0))if((o<<2|0)<(c|0))if((o<<3|0)<(c|0))if((o<<4|0)<(c|0))for(r=5;(o<>1]^U)-U+l|0,_=t+128|0,c=e[_>>2]|0,(o&c|0)==(o|0)?D=o:D=c&~(o>>31),o=t+112|0,(e[o>>2]|0)<8&&P0(t),c=t+108|0,l=e[c>>2]|0,h=l>>>24,d=e[2832+(r<<11)+(h<<3)+4>>2]|0,d?(e[o>>2]=(e[o>>2]|0)-d,e[c>>2]=l<>2]|0):(w=e[t+148>>2]|0,c=e[t+140>>2]|0,o=X0(t)|0,(o|0)<(w+-1-c|0)?r&&(o=(l0(t,r)|0)+(o<>31^o>>1,(((o|0)>-1?o:0-o|0)|0)>65535&&(o=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,o|0,5,35648),t=g,g=0,t&1?(t=j()|0,Tt(o|0),le(t|0)):Qt(o|0,824,96))),w=t+136|0,l=e[w>>2]|0,r?d=o:(l?c=0:c=(e[t+188+(C*12|0)+4>>2]<<1)+-1+(E[R>>1]|0)>>31,d=c^o),r=e[t+152>>2]|0,c=(e[N>>2]|0)+((d|0)>-1?d:0-d|0)|0,h=t+188+(C*12|0)+4|0,o=(e[h>>2]|0)+(ee(l<<1|1,d)|0)|0,l=E[R>>1]|0,(l|0)==(r|0)&&(c=c>>1,o=o>>1,l=r>>1),e[N>>2]=c,r=l+1|0,E[R>>1]=r,c=r+o|0,(c|0)>=1?(o|0)>0&&(o=o-r|0,R=E[k>>1]|0,E[k>>1]=(R<<16>>16<127&1)+(R&65535),o=(o|0)>0?0:o):(o=E[k>>1]|0,E[k>>1]=(o&65535)-(o<<16>>16>-128&1),o=(c|0)>(~l|0)?c:0-l|0),e[h>>2]=o,r=e[w>>2]|0,l=r<<1|1,c=(ee(l,(d^U)-U|0)|0)+D|0,(c|0)>=(0-r|0)?(o=e[_>>2]|0,(o+r|0)<(c|0)&&(c=c-(ee(e[t+132>>2]|0,l)|0)|0)):(c=(ee(e[t+132>>2]|0,l)|0)+c|0,o=e[_>>2]|0),(c&o|0)==(c|0)?(t=c,t=t&65535,t|0):(t=o&~(c>>31),t=t&65535,t|0)}function nr(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(D=r+9|0,o=F[D>>0]|0,h=r+4|0,c=(ee(o>>>1,e[h>>2]|0)|0)+(e[r>>2]|0)|0,(o|0)<(c|0)){l=0;do o=o<<1,l=l+1|0;while((o|0)<(c|0))}else l=0;d=e[t+148>>2]|0,w=e[36476+(e[t+4592>>2]<<2)>>2]|0,o=e[t+140>>2]|0,c=X0(t)|0;do if((c|0)<(d+-2-w-o|0))if(l){w=(l0(t,l)|0)+(c<>2]|0,c=w+l|0,d=c&1,o=d,h=1,c=(d+c|0)/2|0;break}else{l=e[h>>2]|0,t=l+c|0,o=t&1,t=(o+t|0)/2|0,C=8;break}else c=(l0(t,o)|0)+1|0,d=e[h>>2]|0,t=c+d|0,o=t&1,t=(o+t|0)/2|0,l?(w=c,h=1,c=t,l=d):(l=d,C=8);while(!1);return(C|0)==8&&(w=c,h=F[r+10>>0]<<1>>>0>=(F[D>>0]|0)>>>0,c=t),c=(o|0)!=0^h?c:0-c|0,(c|0)<0&&(C=r+10|0,S[C>>0]=(F[C>>0]|0)+1),o=(w+1-l>>1)+(e[r>>2]|0)|0,e[r>>2]=o,l=S[D>>0]|0,l<<24>>24!=(S[r+8>>0]|0)?(r=l,r=r&255,r=r+1|0,r=r&255,S[D>>0]=r,c|0):(e[r>>2]=o>>1,C=(l&255)>>>1,S[D>>0]=C,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,r=C,r=r&255,r=r+1|0,r=r&255,S[D>>0]=r,c|0)}function su(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;R=b,b=b+32|0,l=R,N=t+136|0;e:do if(e[N>>2]|0)r=t+144|0;else if(o=e[t+128>>2]|0,r=t+144|0,(o|0)==((1<>2])+-1|0)&&(m0(l,o,0),(e[l+4>>2]|0)==(e[t+176>>2]|0))&&(e[l+8>>2]|0)==(e[t+180>>2]|0)&&(e[l+12>>2]|0)==(e[t+184>>2]|0))switch(e[r>>2]|0){case 8:{N=e[8900]|0,e[t+4604>>2]=N+(((e[8901]|0)-N|0)>>>1),b=R;return}case 10:{N=e[8903]|0,e[t+4604>>2]=N+(((e[8904]|0)-N|0)>>>1),b=R;return}case 12:{N=e[8906]|0,e[t+4604>>2]=N+(((e[8907]|0)-N|0)>>>1),b=R;return}case 16:{N=e[8909]|0,e[t+4604>>2]=N+(((e[8910]|0)-N|0)>>>1),b=R;return}default:break e}while(!1);if(k=1<>2],o=t+4608|0,l=k<<1,c=t+4612|0,h=e[c>>2]|0,r=e[o>>2]|0,d=h-r|0,l>>>0<=d>>>0?l>>>0>>0&&(w=r+l|0,(h|0)!=(w|0))&&(e[c>>2]=w):(j0(o,l-d|0),r=e[o>>2]|0),D=t+4604|0,e[D>>2]=r+k,r=0-k|0,(k|0)<=(r|0)){b=R;return}w=t+184|0,C=t+180|0,d=t+176|0,h=r;do r=e[w>>2]|0,(h|0)>(0-r|0)?(o=e[C>>2]|0,(h|0)>(0-o|0)?(l=e[d>>2]|0,(h|0)>(0-l|0)?(c=e[N>>2]|0,(h|0)>=(0-c|0)?(c|0)<(h|0)?(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1:r=0:r=-1):r=-2):r=-3):r=-4,S[(e[D>>2]|0)+h>>0]=r,h=h+1|0;while((h|0)!=(k|0));b=R}function ou(t){t=t|0;var r=0,o=0;e[t>>2]=35800,r=e[t+4608>>2]|0,r&&(o=t+4612|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),t=t+88|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function au(t){t=t|0;var r=0,o=0;if(e[t>>2]=35800,r=e[t+4608>>2]|0,r&&(o=t+4612|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+88|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function lu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+28>>2]|0&&(e[t+20>>2]|0)!=1){if(_=t+4|0,Q=t+32|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(44,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+12>>2]|0,(t|0)==8)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(45,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(46,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(47,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+16>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=3,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=3,e[l+12>>2]=t,O=l,b=G,O|0)}function uu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;d=b,b=b+32|0,C=d,m0(C,e[t+128>>2]|0,e[t+136>>2]|0),w=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[C+8>>2]|0,c=e[r+12>>2]|0,c=c|0?c:e[C+12>>2]|0,o=e[r+16>>2]|0,l=e[C+16>>2]|0,e[t+176>>2]=w|0?w:e[C+4>>2]|0,e[t+180>>2]=h,e[t+184>>2]=c,mu(t),c=t+132|0,r=(e[c>>2]|0)+32|0,r=(r|0)<128?2:(r|0)/64|0,h=0;do e[t+188+(h*12|0)>>2]=r,e[t+188+(h*12|0)+4>>2]=0,E[t+188+(h*12|0)+8>>1]=0,E[t+188+(h*12|0)+10>>1]=1,h=h+1|0;while((h|0)!=365);w=(e[c>>2]|0)+32|0,w=(w|0)<128?2:(w|0)/64|0,C=(o|0?o:l)&255,e[t+4568>>2]=w,e[t+4572>>2]=0,S[t+4576>>0]=C,S[t+4577>>0]=1,S[t+4578>>0]=0,e[t+4580>>2]=w,e[t+4584>>2]=1,S[t+4588>>0]=C,S[t+4589>>0]=1,S[t+4590>>0]=0,e[t+4592>>2]=0,b=d}function cu(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;for(d=t+88|0,h=e[r>>2]|0,e[r>>2]=0,r=e[d>>2]|0,e[d>>2]=h,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),d=l+4|0,h=e[d>>2]|0,S[t+4620>>0]=c&1,r=t+156|0,e[r>>2]=e[o>>2],e[r+4>>2]=e[o+4>>2],e[r+8>>2]=e[o+8>>2],e[r+12>>2]=e[o+12>>2],Y0(t,l),fu(t),r=e[t+116>>2]|0,t=e[t+112>>2]|0;c=r+-1|0,o=(S[c>>0]|0)==-1?7:8,!((t|0)<(o|0));)r=c,t=t-o|0;r=r-h|0,c=e[d>>2]|0,c&&(e[d>>2]=c+r,l=l+8|0,e[l>>2]=(e[l>>2]|0)-r)}function fu(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;ie=b,b=b+32|0,ne=ie+12|0,Z=ie,$=t+172|0,P=(e[$>>2]|0)+4|0,(e[t+28>>2]|0)==1?O=e[t+20>>2]|0:O=1,r=ee(O<<1,P)|0,e[ne>>2]=0,ce=ne+4|0,e[ce>>2]=0,e[ne+8>>2]=0;e:do if(r){if(r>>>0>1431655765&&(g=0,ue(178,ne|0),oe=g,g=0,oe&1)||(h=6),(h|0)==6&&(g=0,o=ge(67,r*3|0)|0,oe=g,g=0,!(oe&1))){for(e[ce>>2]=o,e[ne>>2]=o,e[ne+8>>2]=o+(r*3|0);;)if(S[o>>0]=0,S[o+1>>0]=0,S[o+2>>0]=0,o=(e[ce>>2]|0)+3|0,e[ce>>2]=o,r=r+-1|0,!r)break e}l=j()|0,r=e[ne>>2]|0,r||le(l|0),o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~(((o+-3-r|0)>>>0)/3|0)*3|0)),he(r),le(l|0)}while(!1);e[Z>>2]=0,oe=Z+4|0,e[oe>>2]=0,e[Z+8>>2]=0;do if(!O)h=19;else{if(O>>>0>1073741823&&(g=0,ue(178,Z|0),G=g,g=0,G&1)||(h=17),(h|0)==17&&(l=O<<2,g=0,c=ge(67,l|0)|0,G=g,g=0,!(G&1))){e[Z>>2]=c,h=c+(O<<2)|0,e[Z+8>>2]=h,Jt(c|0,0,l|0)|0,e[oe>>2]=h,h=19;break}l=j()|0,r=e[Z>>2]|0,o=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}while(!1);if((h|0)==19){h=t+8|0;e:do if((e[h>>2]|0)>0){d=t+4596|0,w=ee(O,P)|0,C=w+1|0,D=t+4600|0,k=(O|0)>0,N=t+160|0,R=t+168|0,_=t+164|0,U=t+156|0,Q=t+88|0,K=t+4592|0,G=0;t:for(;;){if(l=e[ne>>2]|0,o=l+3|0,e[d>>2]=o,l=l+(C*3|0)|0,e[D>>2]=l,G&1?(e[d>>2]=l,e[D>>2]=o,r=o,o=l):r=l,k){c=e[Z>>2]|0,l=0;do{if(e[K>>2]=e[c+(l<<2)>>2],r=e[$>>2]|0,c=o+(r*3|0)|0,o=o+((r+-1|0)*3|0)|0,S[c>>0]=S[o>>0]|0,S[c+1>>0]=S[o+1>>0]|0,S[c+2>>0]=S[o+2>>0]|0,o=e[d>>2]|0,c=(e[D>>2]|0)+-3|0,S[c>>0]=S[o>>0]|0,S[c+1>>0]=S[o+1>>0]|0,S[c+2>>0]=S[o+2>>0]|0,g=0,Ae(78,t|0,0),c=g,g=0,c&1){h=30;break t}c=e[Z>>2]|0,e[c+(l<<2)>>2]=e[K>>2],o=(e[d>>2]|0)+(P*3|0)|0,e[d>>2]=o,r=(e[D>>2]|0)+(P*3|0)|0,e[D>>2]=r,l=l+1|0}while((l|0)<(O|0))}if(c=e[N>>2]|0,(c|0)<=(G|0)&&(G|0)<((e[R>>2]|0)+c|0)&&(c=e[Q>>2]|0,g=0,$e(e[(e[c>>2]|0)+8>>2]|0,c|0,r+(((e[U>>2]|0)-w|0)*3|0)|0,e[_>>2]|0,P|0),c=g,g=0,c&1)){h=31;break}if(G=G+1|0,(G|0)>=(e[h>>2]|0)){h=43;break e}}if((h|0)==30){l=j()|0;break}else if((h|0)==31){l=j()|0;break}}else h=43;while(!1);do if((h|0)==43){if(g=0,ue(183,t|0),t=g,g=0,t&1){l=j()|0;break}if(r=e[Z>>2]|0,o=r,r&&(l=e[oe>>2]|0,(l|0)!=(r|0)&&(e[oe>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[ne>>2]|0,!r){b=ie;return}o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~(((o+-3-r|0)>>>0)/3|0)*3|0)),he(r),b=ie;return}while(!1);r=e[Z>>2]|0,o=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}r=e[ne>>2]|0,r||le(l|0),o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~(((o+-3-r|0)>>>0)/3|0)*3|0)),he(r),le(l|0)}function hu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0,jt=0,Gt=0,s0=0,i0=0,zt=0,gt=0;if(zt=b,b=b+16|0,ne=zt+12|0,i0=zt+9|0,s0=zt+6|0,ce=zt+3|0,ke=zt,Ee=t+172|0,r=e[Ee>>2]|0,(r|0)<=0){b=zt;return}for(Te=t+4600|0,it=t+4596|0,jt=t+4604|0,Gt=t+4592|0,oe=0;O=oe+-1|0,l=e[Te>>2]|0,c=l+(O*3|0)|0,gt=e[it>>2]|0,o=oe+1|0,h=F[gt+(oe*3|0)>>0]|0,ie=e[jt>>2]|0,d=F[gt+(O*3|0)>>0]|0,w=h-d|0,C=F[c>>0]|0,D=d-C|0,k=((((S[ie+((F[gt+(o*3|0)>>0]|0)-h)>>0]|0)*9|0)+(S[ie+w>>0]|0)|0)*9|0)+(S[ie+D>>0]|0)|0,N=F[gt+(oe*3|0)+1>>0]|0,R=F[gt+(O*3|0)+1>>0]|0,_=N-R|0,U=F[l+(O*3|0)+1>>0]|0,Q=R-U|0,K=((((S[ie+((F[gt+(o*3|0)+1>>0]|0)-N)>>0]|0)*9|0)+(S[ie+_>>0]|0)|0)*9|0)+(S[ie+Q>>0]|0)|0,G=F[gt+(oe*3|0)+2>>0]|0,$=F[gt+(O*3|0)+2>>0]|0,P=G-$|0,O=F[l+(O*3|0)+2>>0]|0,Z=$-O|0,ie=((((S[ie+((F[gt+(o*3|0)+2>>0]|0)-G)>>0]|0)*9|0)+(S[ie+P>>0]|0)|0)*9|0)+(S[ie+Z>>0]|0)|0,K|k|ie?(l=F[l+(oe*3|0)>>0]|0,r=h-C>>31,(r^D|0)>=0?(r^w|0)<0?r=C:r=C-d+h|0:r=h,h=rr(t,k,l,r,0)|0,l=F[(e[Te>>2]|0)+(oe*3|0)+1>>0]|0,r=N-U>>31,(r^Q|0)>=0?(r^_|0)<0?r=U:r=U-R+N|0:r=N,l=rr(t,K,l,r,0)|0,c=F[(e[Te>>2]|0)+(oe*3|0)+2>>0]|0,r=G-O>>31,(r^Z|0)>=0?(r^P|0)<0?r=O:r=O-$+G|0:r=G,ie=rr(t,ie,c,r,0)|0,gt=(e[Te>>2]|0)+(oe*3|0)|0,S[gt>>0]=h,S[gt+1>>0]=l,S[gt+2>>0]=ie):(S[s0>>0]=S[c>>0]|0,S[s0+1>>0]=S[c+1>>0]|0,S[s0+2>>0]=S[c+2>>0]|0,S[ne>>0]=S[c>>0]|0,S[ne+1>>0]=S[c+1>>0]|0,S[ne+2>>0]=S[c+2>>0]|0,r=du(t,ne,l+(oe*3|0)|0,r-oe|0)|0,o=r+oe|0,(o|0)!=(e[Ee>>2]|0)&&(gt=(e[it>>2]|0)+(o*3|0)|0,S[ke>>0]=S[gt>>0]|0,S[ke+1>>0]=S[gt+1>>0]|0,S[ke+2>>0]=S[gt+2>>0]|0,gt=e[Te>>2]|0,S[i0>>0]=S[s0>>0]|0,S[i0+1>>0]=S[s0+1>>0]|0,S[i0+2>>0]=S[s0+2>>0]|0,S[ne>>0]=S[ke>>0]|0,S[ne+1>>0]=S[ke+1>>0]|0,S[ne+2>>0]=S[ke+2>>0]|0,pu(ce,t,i0,ne),gt=gt+(o*3|0)|0,S[gt>>0]=S[ce>>0]|0,S[gt+1>>0]=S[ce+1>>0]|0,S[gt+2>>0]=S[ce+2>>0]|0,gt=e[Gt>>2]|0,e[Gt>>2]=(gt|0)<1?0:gt+-1|0,r=r+1|0),o=r+oe|0),r=e[Ee>>2]|0,!((o|0)>=(r|0));)oe=o;b=zt}function du(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;for(w=t+112|0,C=t+108|0,D=t+4592|0,c=e[w>>2]|0,h=0;;){if((c|0)<1&&(P0(t),c=e[w>>2]|0),d=e[C>>2]|0,c=c+-1|0,e[w>>2]=c,e[C>>2]=d<<1,(d|0)>=0){k=8;break}if(d=e[D>>2]|0,N=1<>2],R=l-h|0,R=(N|0)<(R|0)?N:R,h=R+h|0,(R|0)==(N|0)&&(e[D>>2]=(d|0)>30?31:d+1|0),(h|0)==(l|0)){c=l;break}}if((k|0)==8&&((h|0)!=(l|0)?(c=e[D>>2]|0,(c+-4|0)>>>0<28?c=l0(t,e[36476+(c<<2)>>2]|0)|0:c=0,c=c+h|0,(c|0)>(l|0)&&(c=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,c|0,5,35648),R=g,g=0,R&1?(R=j()|0,Tt(c|0),le(R|0)):Qt(c|0,824,96))):c=l),(c|0)<=0)return c|0;h=0;do R=o+(h*3|0)|0,S[R>>0]=S[r>>0]|0,S[R+1>>0]=S[r+1>>0]|0,S[R+2>>0]=S[r+2>>0]|0,h=h+1|0;while((h|0)!=(c|0));return c|0}function pu(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0;if(C=r+4568|0,N=or(r,C)|0,d=or(r,C)|0,C=or(r,C)|0,h=r+128|0,c=F[l>>0]|0,D=e[r+136>>2]|0,k=D<<1|1,c=(ee(ee(k,N)|0,c-(F[o>>0]|0)>>31|1)|0)+c|0,N=0-D|0,(c|0)>=(N|0)?(h=e[h>>2]|0,(h+D|0)<(c|0)&&(c=c-(ee(e[r+132>>2]|0,k)|0)|0)):(c=(ee(e[r+132>>2]|0,k)|0)+c|0,h=e[h>>2]|0),(c&h|0)!=(c|0)&&(c=h&~(c>>31)),w=c&255,c=F[l+1>>0]|0,c=(ee(ee(k,d)|0,c-(F[o+1>>0]|0)>>31|1)|0)+c|0,(c|0)>=(N|0)?(h+D|0)<(c|0)&&(c=c-(ee(e[r+132>>2]|0,k)|0)|0):c=(ee(e[r+132>>2]|0,k)|0)+c|0,(c&h|0)!=(c|0)&&(c=h&~(c>>31)),d=c&255,c=F[l+2>>0]|0,c=(ee(ee(k,C)|0,c-(F[o+2>>0]|0)>>31|1)|0)+c|0,(c|0)>=(N|0)?(h+D|0)<(c|0)&&(c=c-(ee(e[r+132>>2]|0,k)|0)|0):c=(ee(e[r+132>>2]|0,k)|0)+c|0,(c&h|0)==(c|0)){r=c,r=r&255,S[t>>0]=w,N=t+1|0,S[N>>0]=d,t=t+2|0,S[t>>0]=r;return}r=h&~(c>>31),r=r&255,S[t>>0]=w,N=t+1|0,S[N>>0]=d,t=t+2|0,S[t>>0]=r}function rr(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(U=r>>31,C=(U^r)-U|0,R=t+188+(C*12|0)+10|0,o=E[R>>1]|0,N=t+188+(C*12|0)|0,c=e[N>>2]|0,(o|0)<(c|0))if((o<<1|0)<(c|0))if((o<<2|0)<(c|0))if((o<<3|0)<(c|0))if((o<<4|0)<(c|0))for(r=5;(o<>1]^U)-U+l|0,_=t+128|0,c=e[_>>2]|0,(o&c|0)==(o|0)?D=o:D=c&~(o>>31),o=t+112|0,(e[o>>2]|0)<8&&P0(t),c=t+108|0,l=e[c>>2]|0,h=l>>>24,d=e[2832+(r<<11)+(h<<3)+4>>2]|0,d?(e[o>>2]=(e[o>>2]|0)-d,e[c>>2]=l<>2]|0):(w=e[t+148>>2]|0,c=e[t+140>>2]|0,o=X0(t)|0,(o|0)<(w+-1-c|0)?r&&(o=(l0(t,r)|0)+(o<>31^o>>1,(((o|0)>-1?o:0-o|0)|0)>65535&&(o=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,o|0,5,35648),t=g,g=0,t&1?(t=j()|0,Tt(o|0),le(t|0)):Qt(o|0,824,96))),w=t+136|0,l=e[w>>2]|0,r?d=o:(l?c=0:c=(e[t+188+(C*12|0)+4>>2]<<1)+-1+(E[R>>1]|0)>>31,d=c^o),r=e[t+152>>2]|0,c=(e[N>>2]|0)+((d|0)>-1?d:0-d|0)|0,h=t+188+(C*12|0)+4|0,o=(e[h>>2]|0)+(ee(l<<1|1,d)|0)|0,l=E[R>>1]|0,(l|0)==(r|0)&&(c=c>>1,o=o>>1,l=r>>1),e[N>>2]=c,r=l+1|0,E[R>>1]=r,c=r+o|0,(c|0)>=1?(o|0)>0&&(o=o-r|0,R=E[k>>1]|0,E[k>>1]=(R<<16>>16<127&1)+(R&65535),o=(o|0)>0?0:o):(o=E[k>>1]|0,E[k>>1]=(o&65535)-(o<<16>>16>-128&1),o=(c|0)>(~l|0)?c:0-l|0),e[h>>2]=o,r=e[w>>2]|0,l=r<<1|1,c=(ee(l,(d^U)-U|0)|0)+D|0,(c|0)>=(0-r|0)?(o=e[_>>2]|0,(o+r|0)<(c|0)&&(c=c-(ee(e[t+132>>2]|0,l)|0)|0)):(c=(ee(e[t+132>>2]|0,l)|0)+c|0,o=e[_>>2]|0),(c&o|0)==(c|0)?(t=c,t=t&255,t|0):(t=o&~(c>>31),t=t&255,t|0)}function or(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(D=r+9|0,o=F[D>>0]|0,h=r+4|0,c=(ee(o>>>1,e[h>>2]|0)|0)+(e[r>>2]|0)|0,(o|0)<(c|0)){l=0;do o=o<<1,l=l+1|0;while((o|0)<(c|0))}else l=0;d=e[t+148>>2]|0,w=e[36476+(e[t+4592>>2]<<2)>>2]|0,o=e[t+140>>2]|0,c=X0(t)|0;do if((c|0)<(d+-2-w-o|0))if(l){w=(l0(t,l)|0)+(c<>2]|0,c=w+l|0,d=c&1,o=d,h=1,c=(d+c|0)/2|0;break}else{l=e[h>>2]|0,t=l+c|0,o=t&1,t=(o+t|0)/2|0,C=8;break}else c=(l0(t,o)|0)+1|0,d=e[h>>2]|0,t=c+d|0,o=t&1,t=(o+t|0)/2|0,l?(w=c,h=1,c=t,l=d):(l=d,C=8);while(!1);return(C|0)==8&&(w=c,h=F[r+10>>0]<<1>>>0>=(F[D>>0]|0)>>>0,c=t),c=(o|0)!=0^h?c:0-c|0,(c|0)<0&&(C=r+10|0,S[C>>0]=(F[C>>0]|0)+1),o=(w+1-l>>1)+(e[r>>2]|0)|0,e[r>>2]=o,l=S[D>>0]|0,l<<24>>24!=(S[r+8>>0]|0)?(r=l,r=r&255,r=r+1|0,r=r&255,S[D>>0]=r,c|0):(e[r>>2]=o>>1,C=(l&255)>>>1,S[D>>0]=C,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,r=C,r=r&255,r=r+1|0,r=r&255,S[D>>0]=r,c|0)}function mu(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;R=b,b=b+32|0,l=R,N=t+136|0;e:do if(e[N>>2]|0)r=t+144|0;else if(o=e[t+128>>2]|0,r=t+144|0,(o|0)==((1<>2])+-1|0)&&(m0(l,o,0),(e[l+4>>2]|0)==(e[t+176>>2]|0))&&(e[l+8>>2]|0)==(e[t+180>>2]|0)&&(e[l+12>>2]|0)==(e[t+184>>2]|0))switch(e[r>>2]|0){case 8:{N=e[8900]|0,e[t+4604>>2]=N+(((e[8901]|0)-N|0)>>>1),b=R;return}case 10:{N=e[8903]|0,e[t+4604>>2]=N+(((e[8904]|0)-N|0)>>>1),b=R;return}case 12:{N=e[8906]|0,e[t+4604>>2]=N+(((e[8907]|0)-N|0)>>>1),b=R;return}case 16:{N=e[8909]|0,e[t+4604>>2]=N+(((e[8910]|0)-N|0)>>>1),b=R;return}default:break e}while(!1);if(k=1<>2],o=t+4608|0,l=k<<1,c=t+4612|0,h=e[c>>2]|0,r=e[o>>2]|0,d=h-r|0,l>>>0<=d>>>0?l>>>0>>0&&(w=r+l|0,(h|0)!=(w|0))&&(e[c>>2]=w):(j0(o,l-d|0),r=e[o>>2]|0),D=t+4604|0,e[D>>2]=r+k,r=0-k|0,(k|0)<=(r|0)){b=R;return}w=t+184|0,C=t+180|0,d=t+176|0,h=r;do r=e[w>>2]|0,(h|0)>(0-r|0)?(o=e[C>>2]|0,(h|0)>(0-o|0)?(l=e[d>>2]|0,(h|0)>(0-l|0)?(c=e[N>>2]|0,(h|0)>=(0-c|0)?(c|0)<(h|0)?(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1:r=0:r=-1):r=-2):r=-3):r=-4,S[(e[D>>2]|0)+h>>0]=r,h=h+1|0;while((h|0)!=(k|0));b=R}function gu(t){t=t|0;var r=0,o=0;e[t>>2]=35772,r=e[t+4584>>2]|0,r&&(o=t+4588|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),t=t+88|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function Su(t){t=t|0;var r=0,o=0;if(e[t>>2]=35772,r=e[t+4584>>2]|0,r&&(o=t+4588|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+88|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function Au(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+28>>2]|0&&(e[t+20>>2]|0)!=1){if(_=t+4|0,Q=t+32|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(37,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+12>>2]|0,(t|0)==16)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(38,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(39,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(40,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+16>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=2,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=2,e[l+12>>2]=t,O=l,b=G,O|0)}function vu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0;c=b,b=b+32|0,w=c,m0(w,65535,0),d=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[w+8>>2]|0,l=e[r+12>>2]|0,l=l|0?l:e[w+12>>2]|0,r=e[r+16>>2]|0,o=e[w+16>>2]|0,e[t+152>>2]=d|0?d:e[w+4>>2]|0,e[t+156>>2]=h,e[t+160>>2]=l,Eu(t),l=0;do e[t+164+(l*12|0)>>2]=1024,e[t+164+(l*12|0)+4>>2]=0,E[t+164+(l*12|0)+8>>1]=0,E[t+164+(l*12|0)+10>>1]=1,l=l+1|0;while((l|0)!=365);w=(r|0?r:o)&255,e[t+4544>>2]=1024,e[t+4548>>2]=0,S[t+4552>>0]=w,S[t+4553>>0]=1,S[t+4554>>0]=0,e[t+4556>>2]=1024,e[t+4560>>2]=1,S[t+4564>>0]=w,S[t+4565>>0]=1,S[t+4566>>0]=0,e[t+4568>>2]=0,b=c}function xu(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;for(d=t+88|0,h=e[r>>2]|0,e[r>>2]=0,r=e[d>>2]|0,e[d>>2]=h,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),d=l+4|0,h=e[d>>2]|0,S[t+4596>>0]=c&1,r=t+132|0,e[r>>2]=e[o>>2],e[r+4>>2]=e[o+4>>2],e[r+8>>2]=e[o+8>>2],e[r+12>>2]=e[o+12>>2],Y0(t,l),wu(t),r=e[t+116>>2]|0,t=e[t+112>>2]|0;c=r+-1|0,o=(S[c>>0]|0)==-1?7:8,!((t|0)<(o|0));)r=c,t=t-o|0;r=r-h|0,c=e[d>>2]|0,c&&(e[d>>2]=c+r,l=l+8|0,e[l>>2]=(e[l>>2]|0)-r)}function wu(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;ie=b,b=b+32|0,ne=ie+12|0,Z=ie,$=t+148|0,P=(e[$>>2]|0)+4|0,(e[t+28>>2]|0)==1?O=e[t+20>>2]|0:O=1,r=ee(O<<1,P)|0,e[ne>>2]=0,ce=ne+4|0,e[ce>>2]=0,e[ne+8>>2]=0;do if(r){if((r|0)<0&&(g=0,ue(178,ne|0),oe=g,g=0,oe&1)||(d=6),(d|0)==6&&(o=r<<1,g=0,l=ge(67,o|0)|0,oe=g,g=0,!(oe&1))){e[ne>>2]=l,oe=l+(r<<1)|0,e[ne+8>>2]=oe,Jt(l|0,0,o|0)|0,e[ce>>2]=oe;break}l=j()|0,r=e[ne>>2]|0,r||le(l|0),o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),le(l|0)}while(!1);e[Z>>2]=0,oe=Z+4|0,e[oe>>2]=0,e[Z+8>>2]=0;do if(!O)d=18;else{if(O>>>0>1073741823&&(g=0,ue(178,Z|0),G=g,g=0,G&1)||(d=16),(d|0)==16&&(c=O<<2,g=0,h=ge(67,c|0)|0,G=g,g=0,!(G&1))){e[Z>>2]=h,d=h+(O<<2)|0,e[Z+8>>2]=d,Jt(h|0,0,c|0)|0,e[oe>>2]=d,d=18;break}l=j()|0,r=e[Z>>2]|0,o=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}while(!1);if((d|0)==18){h=t+8|0;e:do if((e[h>>2]|0)>0){d=t+4572|0,w=ee(O,P)|0,C=w+1|0,D=t+4576|0,k=(O|0)>0,N=t+136|0,R=t+144|0,_=t+140|0,U=t+132|0,Q=t+88|0,K=t+4568|0,G=0;t:for(;;){if(l=e[ne>>2]|0,o=l+2|0,e[d>>2]=o,l=l+(C<<1)|0,e[D>>2]=l,G&1?(e[d>>2]=l,e[D>>2]=o,r=o,o=l):r=l,k){c=e[Z>>2]|0,l=0;do{if(e[K>>2]=e[c+(l<<2)>>2],c=e[$>>2]|0,E[o+(c<<1)>>1]=E[o+(c+-1<<1)>>1]|0,E[r+-2>>1]=E[o>>1]|0,g=0,Ae(79,t|0,0),c=g,g=0,c&1){d=29;break t}c=e[Z>>2]|0,e[c+(l<<2)>>2]=e[K>>2],o=(e[d>>2]|0)+(P<<1)|0,e[d>>2]=o,r=(e[D>>2]|0)+(P<<1)|0,e[D>>2]=r,l=l+1|0}while((l|0)<(O|0))}if(c=e[N>>2]|0,(c|0)<=(G|0)&&(G|0)<((e[R>>2]|0)+c|0)&&(c=e[Q>>2]|0,g=0,$e(e[(e[c>>2]|0)+8>>2]|0,c|0,r+((e[U>>2]|0)-w<<1)|0,e[_>>2]|0,P|0),c=g,g=0,c&1)){d=30;break}if(G=G+1|0,(G|0)>=(e[h>>2]|0)){d=42;break e}}if((d|0)==29){l=j()|0;break}else if((d|0)==30){l=j()|0;break}}else d=42;while(!1);do if((d|0)==42){if(g=0,ue(183,t|0),t=g,g=0,t&1){l=j()|0;break}if(r=e[Z>>2]|0,o=r,r&&(l=e[oe>>2]|0,(l|0)!=(r|0)&&(e[oe>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[ne>>2]|0,!r){b=ie;return}o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),b=ie;return}while(!1);r=e[Z>>2]|0,o=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}r=e[ne>>2]|0,r||le(l|0),o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),le(l|0)}function yu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(N=t+4572|0,r=e[N>>2]|0,U=t+148|0,!((e[U>>2]|0)<=0))for(R=t+4576|0,_=t+4580|0,c=r,h=M[r+-2>>1]|0,r=M[r>>1]|0,k=0;D=e[R>>2]|0,C=M[D+(k+-1<<1)>>1]|0,l=k+1|0,o=M[c+(l<<1)>>1]|0,w=e[_>>2]|0,d=r-h|0,c=h-C|0,w=((((S[w+(o-r)>>0]|0)*9|0)+(S[w+d>>0]|0)|0)*9|0)+(S[w+c>>0]|0)|0,w?(h=r-C>>31,(h^c|0)<0?c=r:c=C+((h^d|0)<0?0:d)|0,D=Cu(t,w,M[D+(k<<1)>>1]|0,c,0)|0,E[(e[R>>2]|0)+(k<<1)>>1]=D):(l=(Tu(t,k,0)|0)+k|0,o=e[N>>2]|0,r=M[o+(l+-1<<1)>>1]|0,o=M[o+(l<<1)>>1]|0),!((l|0)>=(e[U>>2]|0));)c=e[N>>2]|0,h=r,r=o,k=l}function Cu(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(_=r>>31,D=(_^r)-_|0,R=t+164+(D*12|0)+10|0,o=E[R>>1]|0,N=t+164+(D*12|0)|0,c=e[N>>2]|0,(o|0)<(c|0))if((o<<1|0)<(c|0))if((o<<2|0)<(c|0))if((o<<3|0)<(c|0))if((o<<4|0)<(c|0))for(h=5;(o<>1]^_)-_+l|0,(o&65535|0)!=(o|0)&&(o=o>>31&65535^65535),c=t+112|0,(e[c>>2]|0)<8&&P0(t),l=t+108|0,d=e[l>>2]|0,w=d>>>24,C=e[2832+(h<<11)+(w<<3)+4>>2]|0,C?(e[c>>2]=(e[c>>2]|0)-C,e[l>>2]=d<>2]|0):(c=X0(t)|0,(c|0)<47?h&&(c=(l0(t,h)|0)+(c<>31^c>>1,(((c|0)>-1?c:0-c|0)|0)>65535&&(o=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,o|0,5,35648),r=g,g=0,r&1?(r=j()|0,Tt(o|0),le(r|0)):Qt(o|0,824,96))),C=t+164+(D*12|0)+4|0,l=e[C>>2]|0,h?h=E[R>>1]|0:(t=E[R>>1]|0,h=t,c=(l<<1)+-1+(t<<16>>16)>>31^c),d=h<<16>>16==64,t=d&1,w=l+c>>t,d=d?32:h<<16>>16,e[N>>2]=((c|0)>-1?c:0-c|0)+(e[N>>2]|0)>>t,l=d+1|0,E[R>>1]=l,h=l+w|0,(h|0)<1?(R=E[k>>1]|0,E[k>>1]=(R&65535)-(R<<16>>16>-128&1),R=(h|0)>(~d|0)?h:0-d|0,e[C>>2]=R,_=c^_,r=r>>>31,r=o+r|0,r=r+_|0,r=r&65535,r|0):(w|0)<=0?(R=w,e[C>>2]=R,_=c^_,r=r>>>31,r=o+r|0,r=r+_|0,r=r&65535,r|0):(R=w-l|0,N=E[k>>1]|0,E[k>>1]=(N<<16>>16<127&1)+(N&65535),R=(R|0)>0?0:R,e[C>>2]=R,_=c^_,r=r>>>31,r=o+r|0,r=r+_|0,r=r&65535,r|0)}function Tu(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;return h=t+4576|0,c=e[h>>2]|0,o=E[c+(r+-1<<1)>>1]|0,d=t+148|0,c=Iu(t,o,c+(r<<1)|0,(e[d>>2]|0)-r|0)|0,l=c+r|0,(l|0)==(e[d>>2]|0)?(d=c,d|0):(o=o&65535,r=M[(e[t+4572>>2]|0)+(l<<1)>>1]|0,d=o-r|0,(((d|0)>-1?d:0-d|0)|0)<1?o=(ys(t,t+4556|0)|0)+o|0:o=(ee(ys(t,t+4544|0)|0,r-o>>31|1)|0)+r|0,E[(e[h>>2]|0)+(l<<1)>>1]=o,d=t+4568|0,t=e[d>>2]|0,e[d>>2]=(t|0)<1?0:t+-1|0,d=c+1|0,d|0)}function Iu(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;for(w=t+112|0,C=t+108|0,D=t+4568|0,c=e[w>>2]|0,h=0;;){if((c|0)<1&&(P0(t),c=e[w>>2]|0),d=e[C>>2]|0,c=c+-1|0,e[w>>2]=c,e[C>>2]=d<<1,(d|0)>=0){k=8;break}if(d=e[D>>2]|0,N=1<>2],R=l-h|0,R=(N|0)<(R|0)?N:R,h=R+h|0,(R|0)==(N|0)&&(e[D>>2]=(d|0)>30?31:d+1|0),(h|0)==(l|0)){c=l;break}}if((k|0)==8&&((h|0)!=(l|0)?(c=e[D>>2]|0,(c+-4|0)>>>0<28?c=l0(t,e[36476+(c<<2)>>2]|0)|0:c=0,c=c+h|0,(c|0)>(l|0)&&(c=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,c|0,5,35648),R=g,g=0,R&1?(R=j()|0,Tt(c|0),le(R|0)):Qt(c|0,824,96))):c=l),(c|0)>0)h=0;else return c|0;do E[o+(h<<1)>>1]=r,h=h+1|0;while((h|0)!=(c|0));return c|0}function ys(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;if(w=r+9|0,o=F[w>>0]|0,h=r+4|0,c=(ee(o>>>1,e[h>>2]|0)|0)+(e[r>>2]|0)|0,(o|0)<(c|0)){l=0;do o=o<<1,l=l+1|0;while((o|0)<(c|0))}else l=0;c=e[36476+(e[t+4568>>2]<<2)>>2]|0,o=X0(t)|0;do if((o|0)<(46-c|0))if(l){o=(l0(t,l)|0)+(o<>2]|0,c=o+t|0,C=c&1,l=C,h=1,c=(C+c|0)/2|0;break}else{t=e[h>>2]|0,c=t+o|0,l=c&1,c=(l+c|0)/2|0,d=8;break}else o=(l0(t,16)|0)+1|0,t=e[h>>2]|0,c=o+t|0,h=c&1,c=(h+c|0)/2|0,l?(l=h,h=1):(l=h,d=8);while(!1);return(d|0)==8&&(h=F[r+10>>0]<<1>>>0>=(F[w>>0]|0)>>>0),c=(l|0)!=0^h?c:0-c|0,(c|0)<0&&(C=r+10|0,S[C>>0]=(F[C>>0]|0)+1),o=(o+1-t>>1)+(e[r>>2]|0)|0,e[r>>2]=o,l=S[w>>0]|0,l<<24>>24!=(S[r+8>>0]|0)?(C=l,C=C&255,C=C+1|0,C=C&255,S[w>>0]=C,c|0):(e[r>>2]=o>>1,C=(l&255)>>>1,S[w>>0]=C,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,C=C&255,C=C+1|0,C=C&255,S[w>>0]=C,c|0)}function Eu(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(D=b,b=b+32|0,w=D,m0(w,65535,0),C=t+152|0,(e[w+4>>2]|0)==(e[C>>2]|0)&&(e[w+8>>2]|0)==(e[t+156>>2]|0)&&(e[w+12>>2]|0)==(e[t+160>>2]|0)){C=e[8909]|0,e[t+4580>>2]=C+(((e[8910]|0)-C|0)>>>1),b=D;return}for(o=t+4584|0,l=t+4588|0,c=e[l>>2]|0,r=e[o>>2]|0,h=c-r|0,h>>>0>=131072?h>>>0>131072&&(d=r+131072|0,(c|0)!=(d|0))&&(e[l>>2]=d):(j0(o,131072-h|0),r=e[o>>2]|0),w=t+4580|0,e[w>>2]=r+65536,d=t+160|0,c=t+156|0,h=-65536;;){if(r=e[d>>2]|0,(h|0)>(0-r|0))if(o=e[c>>2]|0,(h|0)>(0-o|0))if(l=e[C>>2]|0,(h|0)>(0-l|0))if((h|0)>=0){if((h|0)<1){S[(e[w>>2]|0)+h>>0]=0,h=1;continue}(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1}else r=-1;else r=-2;else r=-3;else r=-4;if(S[(e[w>>2]|0)+h>>0]=r,h=h+1|0,(h|0)==65536)break}b=D}function ku(t){t=t|0;var r=0,o=0;e[t>>2]=35744,r=e[t+4584>>2]|0,r&&(o=t+4588|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),t=t+88|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function Du(t){t=t|0;var r=0,o=0;if(e[t>>2]=35744,r=e[t+4584>>2]|0,r&&(o=t+4588|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+88|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function bu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+28>>2]|0&&(e[t+20>>2]|0)!=1){if(_=t+4|0,Q=t+32|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(37,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+12>>2]|0,(t|0)==16)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(38,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(39,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(40,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+16>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=2,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=2,e[l+12>>2]=t,O=l,b=G,O|0)}function Nu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0;c=b,b=b+32|0,w=c,m0(w,4095,0),d=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[w+8>>2]|0,l=e[r+12>>2]|0,l=l|0?l:e[w+12>>2]|0,r=e[r+16>>2]|0,o=e[w+16>>2]|0,e[t+152>>2]=d|0?d:e[w+4>>2]|0,e[t+156>>2]=h,e[t+160>>2]=l,Ou(t),l=0;do e[t+164+(l*12|0)>>2]=64,e[t+164+(l*12|0)+4>>2]=0,E[t+164+(l*12|0)+8>>1]=0,E[t+164+(l*12|0)+10>>1]=1,l=l+1|0;while((l|0)!=365);w=(r|0?r:o)&255,e[t+4544>>2]=64,e[t+4548>>2]=0,S[t+4552>>0]=w,S[t+4553>>0]=1,S[t+4554>>0]=0,e[t+4556>>2]=64,e[t+4560>>2]=1,S[t+4564>>0]=w,S[t+4565>>0]=1,S[t+4566>>0]=0,e[t+4568>>2]=0,b=c}function Fu(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;for(d=t+88|0,h=e[r>>2]|0,e[r>>2]=0,r=e[d>>2]|0,e[d>>2]=h,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),d=l+4|0,h=e[d>>2]|0,S[t+4596>>0]=c&1,r=t+132|0,e[r>>2]=e[o>>2],e[r+4>>2]=e[o+4>>2],e[r+8>>2]=e[o+8>>2],e[r+12>>2]=e[o+12>>2],Y0(t,l),Ru(t),r=e[t+116>>2]|0,t=e[t+112>>2]|0;c=r+-1|0,o=(S[c>>0]|0)==-1?7:8,!((t|0)<(o|0));)r=c,t=t-o|0;r=r-h|0,c=e[d>>2]|0,c&&(e[d>>2]=c+r,l=l+8|0,e[l>>2]=(e[l>>2]|0)-r)}function Ru(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;ie=b,b=b+32|0,ne=ie+12|0,Z=ie,$=t+148|0,P=(e[$>>2]|0)+4|0,(e[t+28>>2]|0)==1?O=e[t+20>>2]|0:O=1,r=ee(O<<1,P)|0,e[ne>>2]=0,ce=ne+4|0,e[ce>>2]=0,e[ne+8>>2]=0;do if(r){if((r|0)<0&&(g=0,ue(178,ne|0),oe=g,g=0,oe&1)||(d=6),(d|0)==6&&(o=r<<1,g=0,l=ge(67,o|0)|0,oe=g,g=0,!(oe&1))){e[ne>>2]=l,oe=l+(r<<1)|0,e[ne+8>>2]=oe,Jt(l|0,0,o|0)|0,e[ce>>2]=oe;break}l=j()|0,r=e[ne>>2]|0,r||le(l|0),o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),le(l|0)}while(!1);e[Z>>2]=0,oe=Z+4|0,e[oe>>2]=0,e[Z+8>>2]=0;do if(!O)d=18;else{if(O>>>0>1073741823&&(g=0,ue(178,Z|0),G=g,g=0,G&1)||(d=16),(d|0)==16&&(c=O<<2,g=0,h=ge(67,c|0)|0,G=g,g=0,!(G&1))){e[Z>>2]=h,d=h+(O<<2)|0,e[Z+8>>2]=d,Jt(h|0,0,c|0)|0,e[oe>>2]=d,d=18;break}l=j()|0,r=e[Z>>2]|0,o=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}while(!1);if((d|0)==18){h=t+8|0;e:do if((e[h>>2]|0)>0){d=t+4572|0,w=ee(O,P)|0,C=w+1|0,D=t+4576|0,k=(O|0)>0,N=t+136|0,R=t+144|0,_=t+140|0,U=t+132|0,Q=t+88|0,K=t+4568|0,G=0;t:for(;;){if(l=e[ne>>2]|0,o=l+2|0,e[d>>2]=o,l=l+(C<<1)|0,e[D>>2]=l,G&1?(e[d>>2]=l,e[D>>2]=o,r=o,o=l):r=l,k){c=e[Z>>2]|0,l=0;do{if(e[K>>2]=e[c+(l<<2)>>2],c=e[$>>2]|0,E[o+(c<<1)>>1]=E[o+(c+-1<<1)>>1]|0,E[r+-2>>1]=E[o>>1]|0,g=0,Ae(80,t|0,0),c=g,g=0,c&1){d=29;break t}c=e[Z>>2]|0,e[c+(l<<2)>>2]=e[K>>2],o=(e[d>>2]|0)+(P<<1)|0,e[d>>2]=o,r=(e[D>>2]|0)+(P<<1)|0,e[D>>2]=r,l=l+1|0}while((l|0)<(O|0))}if(c=e[N>>2]|0,(c|0)<=(G|0)&&(G|0)<((e[R>>2]|0)+c|0)&&(c=e[Q>>2]|0,g=0,$e(e[(e[c>>2]|0)+8>>2]|0,c|0,r+((e[U>>2]|0)-w<<1)|0,e[_>>2]|0,P|0),c=g,g=0,c&1)){d=30;break}if(G=G+1|0,(G|0)>=(e[h>>2]|0)){d=42;break e}}if((d|0)==29){l=j()|0;break}else if((d|0)==30){l=j()|0;break}}else d=42;while(!1);do if((d|0)==42){if(g=0,ue(183,t|0),t=g,g=0,t&1){l=j()|0;break}if(r=e[Z>>2]|0,o=r,r&&(l=e[oe>>2]|0,(l|0)!=(r|0)&&(e[oe>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[ne>>2]|0,!r){b=ie;return}o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),b=ie;return}while(!1);r=e[Z>>2]|0,o=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}r=e[ne>>2]|0,r||le(l|0),o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~((o+-2-r|0)>>>1)<<1)),he(r),le(l|0)}function Mu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(N=t+4572|0,r=e[N>>2]|0,U=t+148|0,!((e[U>>2]|0)<=0))for(R=t+4576|0,_=t+4580|0,c=r,h=M[r+-2>>1]|0,r=M[r>>1]|0,k=0;D=e[R>>2]|0,C=M[D+(k+-1<<1)>>1]|0,l=k+1|0,o=M[c+(l<<1)>>1]|0,w=e[_>>2]|0,d=r-h|0,c=h-C|0,w=((((S[w+(o-r)>>0]|0)*9|0)+(S[w+d>>0]|0)|0)*9|0)+(S[w+c>>0]|0)|0,w?(h=r-C>>31,(h^c|0)<0?c=r:c=C+((h^d|0)<0?0:d)|0,D=_u(t,w,M[D+(k<<1)>>1]|0,c,0)|0,E[(e[R>>2]|0)+(k<<1)>>1]=D):(l=(Pu(t,k,0)|0)+k|0,o=e[N>>2]|0,r=M[o+(l+-1<<1)>>1]|0,o=M[o+(l<<1)>>1]|0),!((l|0)>=(e[U>>2]|0));)c=e[N>>2]|0,h=r,r=o,k=l}function _u(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(_=r>>31,D=(_^r)-_|0,R=t+164+(D*12|0)+10|0,o=E[R>>1]|0,N=t+164+(D*12|0)|0,c=e[N>>2]|0,(o|0)<(c|0))if((o<<1|0)<(c|0))if((o<<2|0)<(c|0))if((o<<3|0)<(c|0))if((o<<4|0)<(c|0))for(h=5;(o<>1]^_)-_+l|0,(o&4095|0)!=(o|0)&&(o=o>>31&4095^4095),c=t+112|0,(e[c>>2]|0)<8&&P0(t),l=t+108|0,d=e[l>>2]|0,w=d>>>24,C=e[2832+(h<<11)+(w<<3)+4>>2]|0,C?(e[c>>2]=(e[c>>2]|0)-C,e[l>>2]=d<>2]|0):(c=X0(t)|0,(c|0)<35?h&&(c=(l0(t,h)|0)+(c<>31^c>>1,(((c|0)>-1?c:0-c|0)|0)>65535&&(o=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,o|0,5,35648),r=g,g=0,r&1?(r=j()|0,Tt(o|0),le(r|0)):Qt(o|0,824,96))),C=t+164+(D*12|0)+4|0,l=e[C>>2]|0,h?h=E[R>>1]|0:(t=E[R>>1]|0,h=t,c=(l<<1)+-1+(t<<16>>16)>>31^c),d=h<<16>>16==64,t=d&1,w=l+c>>t,d=d?32:h<<16>>16,e[N>>2]=((c|0)>-1?c:0-c|0)+(e[N>>2]|0)>>t,l=d+1|0,E[R>>1]=l,h=l+w|0,(h|0)<1?(R=E[k>>1]|0,E[k>>1]=(R&65535)-(R<<16>>16>-128&1),R=(h|0)>(~d|0)?h:0-d|0,e[C>>2]=R,_=c^_,r=r>>>31,r=o+r|0,r=r+_|0,r=r&4095,r=r&65535,r|0):(w|0)<=0?(R=w,e[C>>2]=R,_=c^_,r=r>>>31,r=o+r|0,r=r+_|0,r=r&4095,r=r&65535,r|0):(R=w-l|0,N=E[k>>1]|0,E[k>>1]=(N<<16>>16<127&1)+(N&65535),R=(R|0)>0?0:R,e[C>>2]=R,_=c^_,r=r>>>31,r=o+r|0,r=r+_|0,r=r&4095,r=r&65535,r|0)}function Pu(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;return h=t+4576|0,c=e[h>>2]|0,o=E[c+(r+-1<<1)>>1]|0,d=t+148|0,c=Lu(t,o,c+(r<<1)|0,(e[d>>2]|0)-r|0)|0,l=c+r|0,(l|0)==(e[d>>2]|0)?(d=c,d|0):(o=o&65535,r=M[(e[t+4572>>2]|0)+(l<<1)>>1]|0,d=o-r|0,(((d|0)>-1?d:0-d|0)|0)<1?o=(Cs(t,t+4556|0)|0)+o|0:o=(ee(Cs(t,t+4544|0)|0,r-o>>31|1)|0)+r|0,E[(e[h>>2]|0)+(l<<1)>>1]=o&4095,d=t+4568|0,t=e[d>>2]|0,e[d>>2]=(t|0)<1?0:t+-1|0,d=c+1|0,d|0)}function Lu(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;for(w=t+112|0,C=t+108|0,D=t+4568|0,c=e[w>>2]|0,h=0;;){if((c|0)<1&&(P0(t),c=e[w>>2]|0),d=e[C>>2]|0,c=c+-1|0,e[w>>2]=c,e[C>>2]=d<<1,(d|0)>=0){k=8;break}if(d=e[D>>2]|0,N=1<>2],R=l-h|0,R=(N|0)<(R|0)?N:R,h=R+h|0,(R|0)==(N|0)&&(e[D>>2]=(d|0)>30?31:d+1|0),(h|0)==(l|0)){c=l;break}}if((k|0)==8&&((h|0)!=(l|0)?(c=e[D>>2]|0,(c+-4|0)>>>0<28?c=l0(t,e[36476+(c<<2)>>2]|0)|0:c=0,c=c+h|0,(c|0)>(l|0)&&(c=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,c|0,5,35648),R=g,g=0,R&1?(R=j()|0,Tt(c|0),le(R|0)):Qt(c|0,824,96))):c=l),(c|0)>0)h=0;else return c|0;do E[o+(h<<1)>>1]=r,h=h+1|0;while((h|0)!=(c|0));return c|0}function Cs(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;if(w=r+9|0,o=F[w>>0]|0,h=r+4|0,c=(ee(o>>>1,e[h>>2]|0)|0)+(e[r>>2]|0)|0,(o|0)<(c|0)){l=0;do o=o<<1,l=l+1|0;while((o|0)<(c|0))}else l=0;c=e[36476+(e[t+4568>>2]<<2)>>2]|0,o=X0(t)|0;do if((o|0)<(34-c|0))if(l){o=(l0(t,l)|0)+(o<>2]|0,c=o+t|0,C=c&1,l=C,h=1,c=(C+c|0)/2|0;break}else{t=e[h>>2]|0,c=t+o|0,l=c&1,c=(l+c|0)/2|0,d=8;break}else o=(l0(t,12)|0)+1|0,t=e[h>>2]|0,c=o+t|0,h=c&1,c=(h+c|0)/2|0,l?(l=h,h=1):(l=h,d=8);while(!1);return(d|0)==8&&(h=F[r+10>>0]<<1>>>0>=(F[w>>0]|0)>>>0),c=(l|0)!=0^h?c:0-c|0,(c|0)<0&&(C=r+10|0,S[C>>0]=(F[C>>0]|0)+1),o=(o+1-t>>1)+(e[r>>2]|0)|0,e[r>>2]=o,l=S[w>>0]|0,l<<24>>24!=(S[r+8>>0]|0)?(C=l,C=C&255,C=C+1|0,C=C&255,S[w>>0]=C,c|0):(e[r>>2]=o>>1,C=(l&255)>>>1,S[w>>0]=C,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,C=C&255,C=C+1|0,C=C&255,S[w>>0]=C,c|0)}function Ou(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(D=b,b=b+32|0,w=D,m0(w,4095,0),C=t+152|0,(e[w+4>>2]|0)==(e[C>>2]|0)&&(e[w+8>>2]|0)==(e[t+156>>2]|0)&&(e[w+12>>2]|0)==(e[t+160>>2]|0)){C=e[8906]|0,e[t+4580>>2]=C+(((e[8907]|0)-C|0)>>>1),b=D;return}for(o=t+4584|0,l=t+4588|0,c=e[l>>2]|0,r=e[o>>2]|0,h=c-r|0,h>>>0>=8192?h>>>0>8192&&(d=r+8192|0,(c|0)!=(d|0))&&(e[l>>2]=d):(j0(o,8192-h|0),r=e[o>>2]|0),w=t+4580|0,e[w>>2]=r+4096,d=t+160|0,c=t+156|0,h=-4096;;){if(r=e[d>>2]|0,(h|0)>(0-r|0))if(o=e[c>>2]|0,(h|0)>(0-o|0))if(l=e[C>>2]|0,(h|0)>(0-l|0))if((h|0)>=0){if((h|0)<1){S[(e[w>>2]|0)+h>>0]=0,h=1;continue}(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1}else r=-1;else r=-2;else r=-3;else r=-4;if(S[(e[w>>2]|0)+h>>0]=r,h=h+1|0,(h|0)==4096)break}b=D}function $u(t){t=t|0;var r=0,o=0;e[t>>2]=35716,r=e[t+4584>>2]|0,r&&(o=t+4588|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),t=t+88|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function Bu(t){t=t|0;var r=0,o=0;if(e[t>>2]=35716,r=e[t+4584>>2]|0,r&&(o=t+4588|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+88|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function Vu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+28>>2]|0&&(e[t+20>>2]|0)!=1){if(_=t+4|0,Q=t+32|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(44,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+12>>2]|0,(t|0)==8)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(45,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(46,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(47,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+16>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=1,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=1,e[l+12>>2]=t,O=l,b=G,O|0)}function Uu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0;c=b,b=b+32|0,w=c,m0(w,255,0),d=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[w+8>>2]|0,l=e[r+12>>2]|0,l=l|0?l:e[w+12>>2]|0,r=e[r+16>>2]|0,o=e[w+16>>2]|0,e[t+152>>2]=d|0?d:e[w+4>>2]|0,e[t+156>>2]=h,e[t+160>>2]=l,Ku(t),l=0;do e[t+164+(l*12|0)>>2]=4,e[t+164+(l*12|0)+4>>2]=0,E[t+164+(l*12|0)+8>>1]=0,E[t+164+(l*12|0)+10>>1]=1,l=l+1|0;while((l|0)!=365);w=(r|0?r:o)&255,e[t+4544>>2]=4,e[t+4548>>2]=0,S[t+4552>>0]=w,S[t+4553>>0]=1,S[t+4554>>0]=0,e[t+4556>>2]=4,e[t+4560>>2]=1,S[t+4564>>0]=w,S[t+4565>>0]=1,S[t+4566>>0]=0,e[t+4568>>2]=0,b=c}function zu(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;for(d=t+88|0,h=e[r>>2]|0,e[r>>2]=0,r=e[d>>2]|0,e[d>>2]=h,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),d=l+4|0,h=e[d>>2]|0,S[t+4596>>0]=c&1,r=t+132|0,e[r>>2]=e[o>>2],e[r+4>>2]=e[o+4>>2],e[r+8>>2]=e[o+8>>2],e[r+12>>2]=e[o+12>>2],Y0(t,l),Gu(t),r=e[t+116>>2]|0,t=e[t+112>>2]|0;c=r+-1|0,o=(S[c>>0]|0)==-1?7:8,!((t|0)<(o|0));)r=c,t=t-o|0;r=r-h|0,c=e[d>>2]|0,c&&(e[d>>2]=c+r,l=l+8|0,e[l>>2]=(e[l>>2]|0)-r)}function Gu(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;ie=b,b=b+32|0,ne=ie+12|0,Z=ie,$=t+148|0,P=(e[$>>2]|0)+4|0,(e[t+28>>2]|0)==1?O=e[t+20>>2]|0:O=1,r=ee(O<<1,P)|0,e[ne>>2]=0,ce=ne+4|0,e[ce>>2]=0,e[ne+8>>2]=0;e:do if(r){if((r|0)<0&&(g=0,ue(178,ne|0),oe=g,g=0,oe&1)||(h=6),(h|0)==6&&(g=0,o=ge(67,r|0)|0,oe=g,g=0,!(oe&1))){for(e[ce>>2]=o,e[ne>>2]=o,e[ne+8>>2]=o+r;;)if(S[o>>0]=0,o=(e[ce>>2]|0)+1|0,e[ce>>2]=o,r=r+-1|0,!r)break e}o=j()|0,r=e[ne>>2]|0,r||le(o|0),(e[ce>>2]|0)!=(r|0)&&(e[ce>>2]=r),he(r),le(o|0)}while(!1);e[Z>>2]=0,oe=Z+4|0,e[oe>>2]=0,e[Z+8>>2]=0;do if(!O)h=19;else{if(O>>>0>1073741823&&(g=0,ue(178,Z|0),G=g,g=0,G&1)||(h=17),(h|0)==17&&(l=O<<2,g=0,c=ge(67,l|0)|0,G=g,g=0,!(G&1))){e[Z>>2]=c,h=c+(O<<2)|0,e[Z+8>>2]=h,Jt(c|0,0,l|0)|0,e[oe>>2]=h,h=19;break}o=j()|0,r=e[Z>>2]|0,l=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-l|0)>>>2)<<2)),he(r))}while(!1);if((h|0)==19){h=t+8|0;e:do if((e[h>>2]|0)>0){d=t+4572|0,w=ee(O,P)|0,C=w+1|0,D=t+4576|0,k=(O|0)>0,N=t+136|0,R=t+144|0,_=t+140|0,U=t+132|0,Q=t+88|0,K=t+4568|0,G=0;t:for(;;){if(l=e[ne>>2]|0,o=l+1|0,e[d>>2]=o,l=l+C|0,e[D>>2]=l,G&1?(e[d>>2]=l,e[D>>2]=o,r=o,o=l):r=l,k){c=e[Z>>2]|0,l=0;do{if(e[K>>2]=e[c+(l<<2)>>2],c=e[$>>2]|0,S[o+c>>0]=S[o+(c+-1)>>0]|0,S[(e[D>>2]|0)+-1>>0]=S[e[d>>2]>>0]|0,g=0,Ae(81,t|0,0),c=g,g=0,c&1){h=30;break t}c=e[Z>>2]|0,e[c+(l<<2)>>2]=e[K>>2],o=(e[d>>2]|0)+P|0,e[d>>2]=o,r=(e[D>>2]|0)+P|0,e[D>>2]=r,l=l+1|0}while((l|0)<(O|0))}if(c=e[N>>2]|0,(c|0)<=(G|0)&&(G|0)<((e[R>>2]|0)+c|0)&&(c=e[Q>>2]|0,g=0,$e(e[(e[c>>2]|0)+8>>2]|0,c|0,r+((e[U>>2]|0)-w)|0,e[_>>2]|0,P|0),c=g,g=0,c&1)){h=31;break}if(G=G+1|0,(G|0)>=(e[h>>2]|0)){h=43;break e}}if((h|0)==30){o=j()|0;break}else if((h|0)==31){o=j()|0;break}}else h=43;while(!1);do if((h|0)==43){if(g=0,ue(183,t|0),t=g,g=0,t&1){o=j()|0;break}if(r=e[Z>>2]|0,o=r,r&&(l=e[oe>>2]|0,(l|0)!=(r|0)&&(e[oe>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[ne>>2]|0,!r){b=ie;return}(e[ce>>2]|0)!=(r|0)&&(e[ce>>2]=r),he(r),b=ie;return}while(!1);r=e[Z>>2]|0,l=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-l|0)>>>2)<<2)),he(r))}r=e[ne>>2]|0,r||le(o|0),(e[ce>>2]|0)!=(r|0)&&(e[ce>>2]=r),he(r),le(o|0)}function qu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(N=t+4572|0,r=e[N>>2]|0,U=t+148|0,!((e[U>>2]|0)<=0))for(R=t+4576|0,_=t+4580|0,c=r,h=F[r+-1>>0]|0,r=F[r>>0]|0,k=0;D=e[R>>2]|0,C=F[D+(k+-1)>>0]|0,l=k+1|0,o=F[c+l>>0]|0,w=e[_>>2]|0,d=r-h|0,c=h-C|0,w=((((S[w+(o-r)>>0]|0)*9|0)+(S[w+d>>0]|0)|0)*9|0)+(S[w+c>>0]|0)|0,w?(h=r-C>>31,(h^c|0)<0?c=r:c=C+((h^d|0)<0?0:d)|0,D=Wu(t,w,F[D+k>>0]|0,c,0)|0,S[(e[R>>2]|0)+k>>0]=D):(l=(Hu(t,k,0)|0)+k|0,o=e[N>>2]|0,r=F[o+(l+-1)>>0]|0,o=F[o+l>>0]|0),!((l|0)>=(e[U>>2]|0));)c=e[N>>2]|0,h=r,r=o,k=l}function Wu(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(_=r>>31,D=(_^r)-_|0,R=t+164+(D*12|0)+10|0,o=E[R>>1]|0,N=t+164+(D*12|0)|0,c=e[N>>2]|0,(o|0)<(c|0))if((o<<1|0)<(c|0))if((o<<2|0)<(c|0))if((o<<3|0)<(c|0))if((o<<4|0)<(c|0))for(h=5;(o<>1]^_)-_+l|0,(o&255|0)!=(o|0)&&(o=o>>31&255^255),c=t+112|0,(e[c>>2]|0)<8&&P0(t),l=t+108|0,d=e[l>>2]|0,w=d>>>24,C=e[2832+(h<<11)+(w<<3)+4>>2]|0,C?(e[c>>2]=(e[c>>2]|0)-C,e[l>>2]=d<>2]|0):(c=X0(t)|0,(c|0)<23?h&&(c=(l0(t,h)|0)+(c<>31^c>>1,(((c|0)>-1?c:0-c|0)|0)>65535&&(o=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,o|0,5,35648),r=g,g=0,r&1?(r=j()|0,Tt(o|0),le(r|0)):Qt(o|0,824,96))),C=t+164+(D*12|0)+4|0,l=e[C>>2]|0,h?h=E[R>>1]|0:(t=E[R>>1]|0,h=t,c=(l<<1)+-1+(t<<16>>16)>>31^c),d=h<<16>>16==64,t=d&1,w=l+c>>t,d=d?32:h<<16>>16,e[N>>2]=((c|0)>-1?c:0-c|0)+(e[N>>2]|0)>>t,l=d+1|0,E[R>>1]=l,h=l+w|0,(h|0)<1?(R=E[k>>1]|0,E[k>>1]=(R&65535)-(R<<16>>16>-128&1),R=(h|0)>(~d|0)?h:0-d|0,e[C>>2]=R,_=c^_,r=r>>>31,r=o+r|0,r=r+_|0,r=r&255,r|0):(w|0)<=0?(R=w,e[C>>2]=R,_=c^_,r=r>>>31,r=o+r|0,r=r+_|0,r=r&255,r|0):(R=w-l|0,N=E[k>>1]|0,E[k>>1]=(N<<16>>16<127&1)+(N&65535),R=(R|0)>0?0:R,e[C>>2]=R,_=c^_,r=r>>>31,r=o+r|0,r=r+_|0,r=r&255,r|0)}function Hu(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;return h=t+4576|0,c=e[h>>2]|0,o=S[c+(r+-1)>>0]|0,d=t+148|0,c=Qu(t,o,c+r|0,(e[d>>2]|0)-r|0)|0,l=c+r|0,(l|0)==(e[d>>2]|0)?(d=c,d|0):(o=o&255,r=F[(e[t+4572>>2]|0)+l>>0]|0,d=o-r|0,(((d|0)>-1?d:0-d|0)|0)<1?o=(Ts(t,t+4556|0)|0)+o|0:o=(ee(Ts(t,t+4544|0)|0,r-o>>31|1)|0)+r|0,S[(e[h>>2]|0)+l>>0]=o,d=t+4568|0,t=e[d>>2]|0,e[d>>2]=(t|0)<1?0:t+-1|0,d=c+1|0,d|0)}function Qu(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;for(w=t+112|0,C=t+108|0,D=t+4568|0,c=e[w>>2]|0,h=0;;){if((c|0)<1&&(P0(t),c=e[w>>2]|0),d=e[C>>2]|0,c=c+-1|0,e[w>>2]=c,e[C>>2]=d<<1,(d|0)>=0){k=8;break}if(d=e[D>>2]|0,N=1<>2],R=l-h|0,R=(N|0)<(R|0)?N:R,h=R+h|0,(R|0)==(N|0)&&(e[D>>2]=(d|0)>30?31:d+1|0),(h|0)==(l|0)){c=l;break}}return(k|0)==8&&((h|0)!=(l|0)?(c=e[D>>2]|0,(c+-4|0)>>>0<28?c=l0(t,e[36476+(c<<2)>>2]|0)|0:c=0,c=c+h|0,(c|0)>(l|0)&&(c=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,c|0,5,35648),R=g,g=0,R&1?(R=j()|0,Tt(c|0),le(R|0)):Qt(c|0,824,96))):c=l),(c|0)<=0||Jt(o|0,r|0,c|0)|0,c|0}function Ts(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;if(w=r+9|0,o=F[w>>0]|0,h=r+4|0,c=(ee(o>>>1,e[h>>2]|0)|0)+(e[r>>2]|0)|0,(o|0)<(c|0)){l=0;do o=o<<1,l=l+1|0;while((o|0)<(c|0))}else l=0;c=e[36476+(e[t+4568>>2]<<2)>>2]|0,o=X0(t)|0;do if((o|0)<(22-c|0))if(l){o=(l0(t,l)|0)+(o<>2]|0,c=o+t|0,C=c&1,l=C,h=1,c=(C+c|0)/2|0;break}else{t=e[h>>2]|0,c=t+o|0,l=c&1,c=(l+c|0)/2|0,d=8;break}else o=(l0(t,8)|0)+1|0,t=e[h>>2]|0,c=o+t|0,h=c&1,c=(h+c|0)/2|0,l?(l=h,h=1):(l=h,d=8);while(!1);return(d|0)==8&&(h=F[r+10>>0]<<1>>>0>=(F[w>>0]|0)>>>0),c=(l|0)!=0^h?c:0-c|0,(c|0)<0&&(C=r+10|0,S[C>>0]=(F[C>>0]|0)+1),o=(o+1-t>>1)+(e[r>>2]|0)|0,e[r>>2]=o,l=S[w>>0]|0,l<<24>>24!=(S[r+8>>0]|0)?(C=l,C=C&255,C=C+1|0,C=C&255,S[w>>0]=C,c|0):(e[r>>2]=o>>1,C=(l&255)>>>1,S[w>>0]=C,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,C=C&255,C=C+1|0,C=C&255,S[w>>0]=C,c|0)}function Ku(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(D=b,b=b+32|0,w=D,m0(w,255,0),C=t+152|0,(e[w+4>>2]|0)==(e[C>>2]|0)&&(e[w+8>>2]|0)==(e[t+156>>2]|0)&&(e[w+12>>2]|0)==(e[t+160>>2]|0)){C=e[8900]|0,e[t+4580>>2]=C+(((e[8901]|0)-C|0)>>>1),b=D;return}for(o=t+4584|0,l=t+4588|0,c=e[l>>2]|0,r=e[o>>2]|0,h=c-r|0,h>>>0>=512?h>>>0>512&&(d=r+512|0,(c|0)!=(d|0))&&(e[l>>2]=d):(j0(o,512-h|0),r=e[o>>2]|0),w=t+4580|0,e[w>>2]=r+256,d=t+160|0,c=t+156|0,h=-256;;){if(r=e[d>>2]|0,(h|0)>(0-r|0))if(o=e[c>>2]|0,(h|0)>(0-o|0))if(l=e[C>>2]|0,(h|0)>(0-l|0))if((h|0)>=0){if((h|0)<1){S[(e[w>>2]|0)+h>>0]=0,h=1;continue}(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1}else r=-1;else r=-2;else r=-3;else r=-4;if(S[(e[w>>2]|0)+h>>0]=r,h=h+1|0,(h|0)==256)break}b=D}function Yu(t){t=t|0;var r=0,o=0;e[t>>2]=35688,r=e[t+4584>>2]|0,r&&(o=t+4588|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),t=t+88|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function ju(t){t=t|0;var r=0,o=0;if(e[t>>2]=35688,r=e[t+4584>>2]|0,r&&(o=t+4588|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+88|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function Xu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+28>>2]|0&&(e[t+20>>2]|0)!=1){if(_=t+4|0,Q=t+32|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(44,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+12>>2]|0,(t|0)==8)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(45,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(46,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(47,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+16>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=3,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=3,e[l+12>>2]=t,O=l,b=G,O|0)}function Zu(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0;c=b,b=b+32|0,w=c,m0(w,255,0),d=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[w+8>>2]|0,l=e[r+12>>2]|0,l=l|0?l:e[w+12>>2]|0,r=e[r+16>>2]|0,o=e[w+16>>2]|0,e[t+152>>2]=d|0?d:e[w+4>>2]|0,e[t+156>>2]=h,e[t+160>>2]=l,q5(t),l=0;do e[t+164+(l*12|0)>>2]=4,e[t+164+(l*12|0)+4>>2]=0,E[t+164+(l*12|0)+8>>1]=0,E[t+164+(l*12|0)+10>>1]=1,l=l+1|0;while((l|0)!=365);w=(r|0?r:o)&255,e[t+4544>>2]=4,e[t+4548>>2]=0,S[t+4552>>0]=w,S[t+4553>>0]=1,S[t+4554>>0]=0,e[t+4556>>2]=4,e[t+4560>>2]=1,S[t+4564>>0]=w,S[t+4565>>0]=1,S[t+4566>>0]=0,e[t+4568>>2]=0,b=c}function Ju(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;for(d=t+88|0,h=e[r>>2]|0,e[r>>2]=0,r=e[d>>2]|0,e[d>>2]=h,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),d=l+4|0,h=e[d>>2]|0,S[t+4596>>0]=c&1,r=t+132|0,e[r>>2]=e[o>>2],e[r+4>>2]=e[o+4>>2],e[r+8>>2]=e[o+8>>2],e[r+12>>2]=e[o+12>>2],Y0(t,l),tc(t),r=e[t+116>>2]|0,t=e[t+112>>2]|0;c=r+-1|0,o=(S[c>>0]|0)==-1?7:8,!((t|0)<(o|0));)r=c,t=t-o|0;r=r-h|0,c=e[d>>2]|0,c&&(e[d>>2]=c+r,l=l+8|0,e[l>>2]=(e[l>>2]|0)-r)}function tc(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;ie=b,b=b+32|0,ne=ie+12|0,Z=ie,$=t+148|0,P=(e[$>>2]|0)+4|0,(e[t+28>>2]|0)==1?O=e[t+20>>2]|0:O=1,r=ee(O<<1,P)|0,e[ne>>2]=0,ce=ne+4|0,e[ce>>2]=0,e[ne+8>>2]=0;e:do if(r){if(r>>>0>1431655765&&(g=0,ue(178,ne|0),oe=g,g=0,oe&1)||(h=6),(h|0)==6&&(g=0,o=ge(67,r*3|0)|0,oe=g,g=0,!(oe&1))){for(e[ce>>2]=o,e[ne>>2]=o,e[ne+8>>2]=o+(r*3|0);;)if(S[o>>0]=0,S[o+1>>0]=0,S[o+2>>0]=0,o=(e[ce>>2]|0)+3|0,e[ce>>2]=o,r=r+-1|0,!r)break e}l=j()|0,r=e[ne>>2]|0,r||le(l|0),o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~(((o+-3-r|0)>>>0)/3|0)*3|0)),he(r),le(l|0)}while(!1);e[Z>>2]=0,oe=Z+4|0,e[oe>>2]=0,e[Z+8>>2]=0;do if(!O)h=19;else{if(O>>>0>1073741823&&(g=0,ue(178,Z|0),G=g,g=0,G&1)||(h=17),(h|0)==17&&(l=O<<2,g=0,c=ge(67,l|0)|0,G=g,g=0,!(G&1))){e[Z>>2]=c,h=c+(O<<2)|0,e[Z+8>>2]=h,Jt(c|0,0,l|0)|0,e[oe>>2]=h,h=19;break}l=j()|0,r=e[Z>>2]|0,o=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}while(!1);if((h|0)==19){h=t+8|0;e:do if((e[h>>2]|0)>0){d=t+4572|0,w=ee(O,P)|0,C=w+1|0,D=t+4576|0,k=(O|0)>0,N=t+136|0,R=t+144|0,_=t+140|0,U=t+132|0,Q=t+88|0,K=t+4568|0,G=0;t:for(;;){if(l=e[ne>>2]|0,o=l+3|0,e[d>>2]=o,l=l+(C*3|0)|0,e[D>>2]=l,G&1?(e[d>>2]=l,e[D>>2]=o,r=o,o=l):r=l,k){c=e[Z>>2]|0,l=0;do{if(e[K>>2]=e[c+(l<<2)>>2],r=e[$>>2]|0,c=o+(r*3|0)|0,o=o+((r+-1|0)*3|0)|0,S[c>>0]=S[o>>0]|0,S[c+1>>0]=S[o+1>>0]|0,S[c+2>>0]=S[o+2>>0]|0,o=e[d>>2]|0,c=(e[D>>2]|0)+-3|0,S[c>>0]=S[o>>0]|0,S[c+1>>0]=S[o+1>>0]|0,S[c+2>>0]=S[o+2>>0]|0,g=0,Ae(82,t|0,0),c=g,g=0,c&1){h=30;break t}c=e[Z>>2]|0,e[c+(l<<2)>>2]=e[K>>2],o=(e[d>>2]|0)+(P*3|0)|0,e[d>>2]=o,r=(e[D>>2]|0)+(P*3|0)|0,e[D>>2]=r,l=l+1|0}while((l|0)<(O|0))}if(c=e[N>>2]|0,(c|0)<=(G|0)&&(G|0)<((e[R>>2]|0)+c|0)&&(c=e[Q>>2]|0,g=0,$e(e[(e[c>>2]|0)+8>>2]|0,c|0,r+(((e[U>>2]|0)-w|0)*3|0)|0,e[_>>2]|0,P|0),c=g,g=0,c&1)){h=31;break}if(G=G+1|0,(G|0)>=(e[h>>2]|0)){h=43;break e}}if((h|0)==30){l=j()|0;break}else if((h|0)==31){l=j()|0;break}}else h=43;while(!1);do if((h|0)==43){if(g=0,ue(183,t|0),t=g,g=0,t&1){l=j()|0;break}if(r=e[Z>>2]|0,o=r,r&&(l=e[oe>>2]|0,(l|0)!=(r|0)&&(e[oe>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[ne>>2]|0,!r){b=ie;return}o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~(((o+-3-r|0)>>>0)/3|0)*3|0)),he(r),b=ie;return}while(!1);r=e[Z>>2]|0,o=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-o|0)>>>2)<<2)),he(r))}r=e[ne>>2]|0,r||le(l|0),o=e[ce>>2]|0,(o|0)!=(r|0)&&(e[ce>>2]=o+(~(((o+-3-r|0)>>>0)/3|0)*3|0)),he(r),le(l|0)}function ic(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0;if(oe=t+148|0,!((e[oe>>2]|0)<=0))for(ne=t+4576|0,ce=t+4572|0,ke=t+4580|0,ie=0;P=ie+-1|0,h=e[ne>>2]|0,d=e[ce>>2]|0,r=ie+1|0,c=F[d+(ie*3|0)>>0]|0,Z=e[ke>>2]|0,w=F[d+(P*3|0)>>0]|0,C=c-w|0,D=F[h+(P*3|0)>>0]|0,k=w-D|0,N=((((S[Z+((F[d+(r*3|0)>>0]|0)-c)>>0]|0)*9|0)+(S[Z+C>>0]|0)|0)*9|0)+(S[Z+k>>0]|0)|0,l=F[d+(ie*3|0)+1>>0]|0,R=F[d+(P*3|0)+1>>0]|0,_=l-R|0,U=F[h+(P*3|0)+1>>0]|0,Q=R-U|0,K=((((S[Z+((F[d+(r*3|0)+1>>0]|0)-l)>>0]|0)*9|0)+(S[Z+_>>0]|0)|0)*9|0)+(S[Z+Q>>0]|0)|0,o=F[d+(ie*3|0)+2>>0]|0,G=F[d+(P*3|0)+2>>0]|0,$=o-G|0,P=F[h+(P*3|0)+2>>0]|0,O=G-P|0,Z=((((S[Z+((F[d+(r*3|0)+2>>0]|0)-o)>>0]|0)*9|0)+(S[Z+$>>0]|0)|0)*9|0)+(S[Z+O>>0]|0)|0,K|N|Z?(d=F[h+(ie*3|0)>>0]|0,h=c-D>>31,(h^k|0)>=0&&((h^C|0)<0?c=D:c=D-w+c|0),d=ar(t,N,d,c,0)|0,h=F[(e[ne>>2]|0)+(ie*3|0)+1>>0]|0,c=l-U>>31,(c^Q|0)>=0&&((c^_|0)<0?l=U:l=U-R+l|0),c=ar(t,K,h,l,0)|0,h=F[(e[ne>>2]|0)+(ie*3|0)+2>>0]|0,l=o-P>>31,(l^O|0)>=0&&((l^$|0)<0?o=P:o=P-G+o|0),Z=ar(t,Z,h,o,0)|0,ie=(e[ne>>2]|0)+(ie*3|0)|0,S[ie>>0]=d,S[ie+1>>0]=c,S[ie+2>>0]=Z):r=(nc(t,ie,0)|0)+ie|0,(r|0)<(e[oe>>2]|0);)ie=r}function nc(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;return C=b,b=b+16|0,k=C+3|0,N=C,h=t+4576|0,o=e[h>>2]|0,l=o+((r+-1|0)*3|0)|0,d=S[l>>0]|0,w=S[l+1>>0]|0,l=S[l+2>>0]|0,S[N>>0]=d,S[N+1>>0]=w,S[N+2>>0]=l,D=t+148|0,c=(e[D>>2]|0)-r|0,S[k>>0]=S[N>>0]|0,S[k+1>>0]=S[N+1>>0]|0,S[k+2>>0]=S[N+2>>0]|0,c=rc(t,k,o+(r*3|0)|0,c)|0,o=c+r|0,(o|0)==(e[D>>2]|0)?(N=c,b=C,N|0):(k=(e[t+4572>>2]|0)+(o*3|0)|0,r=S[k>>0]|0,D=S[k+1>>0]|0,k=S[k+2>>0]|0,N=e[h>>2]|0,h=t+4544|0,_=lr(t,h)|0,R=lr(t,h)|0,r=r&255,r=(ee(r-(d&255)>>31|1,_)|0)+r&255,D=D&255,D=(ee(D-(w&255)>>31|1,R)|0)+D&255,k=k&255,k=(ee(k-(l&255)>>31|1,lr(t,h)|0)|0)+k&255,N=N+(o*3|0)|0,S[N>>0]=r,S[N+1>>0]=D,S[N+2>>0]=k,N=t+4568|0,k=e[N>>2]|0,e[N>>2]=(k|0)<1?0:k+-1|0,N=c+1|0,b=C,N|0)}function ar(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(_=r>>31,D=(_^r)-_|0,R=t+164+(D*12|0)+10|0,o=E[R>>1]|0,N=t+164+(D*12|0)|0,c=e[N>>2]|0,(o|0)<(c|0))if((o<<1|0)<(c|0))if((o<<2|0)<(c|0))if((o<<3|0)<(c|0))if((o<<4|0)<(c|0))for(h=5;(o<>1]^_)-_+l|0,(o&255|0)!=(o|0)&&(o=o>>31&255^255),c=t+112|0,(e[c>>2]|0)<8&&P0(t),l=t+108|0,d=e[l>>2]|0,w=d>>>24,C=e[2832+(h<<11)+(w<<3)+4>>2]|0,C?(e[c>>2]=(e[c>>2]|0)-C,e[l>>2]=d<>2]|0):(c=X0(t)|0,(c|0)<23?h&&(c=(l0(t,h)|0)+(c<>31^c>>1,(((c|0)>-1?c:0-c|0)|0)>65535&&(o=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,o|0,5,35648),r=g,g=0,r&1?(r=j()|0,Tt(o|0),le(r|0)):Qt(o|0,824,96))),C=t+164+(D*12|0)+4|0,l=e[C>>2]|0,h?h=E[R>>1]|0:(t=E[R>>1]|0,h=t,c=(l<<1)+-1+(t<<16>>16)>>31^c),d=h<<16>>16==64,t=d&1,w=l+c>>t,d=d?32:h<<16>>16,e[N>>2]=((c|0)>-1?c:0-c|0)+(e[N>>2]|0)>>t,l=d+1|0,E[R>>1]=l,h=l+w|0,(h|0)<1?(R=E[k>>1]|0,E[k>>1]=(R&65535)-(R<<16>>16>-128&1),R=(h|0)>(~d|0)?h:0-d|0,e[C>>2]=R,_=c^_,r=r>>>31,r=o+r|0,r=r+_|0,r=r&255,r|0):(w|0)<=0?(R=w,e[C>>2]=R,_=c^_,r=r>>>31,r=o+r|0,r=r+_|0,r=r&255,r|0):(R=w-l|0,N=E[k>>1]|0,E[k>>1]=(N<<16>>16<127&1)+(N&65535),R=(R|0)>0?0:R,e[C>>2]=R,_=c^_,r=r>>>31,r=o+r|0,r=r+_|0,r=r&255,r|0)}function rc(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;for(w=t+112|0,C=t+108|0,D=t+4568|0,c=e[w>>2]|0,h=0;;){if((c|0)<1&&(P0(t),c=e[w>>2]|0),d=e[C>>2]|0,c=c+-1|0,e[w>>2]=c,e[C>>2]=d<<1,(d|0)>=0){k=8;break}if(d=e[D>>2]|0,N=1<>2],R=l-h|0,R=(N|0)<(R|0)?N:R,h=R+h|0,(R|0)==(N|0)&&(e[D>>2]=(d|0)>30?31:d+1|0),(h|0)==(l|0)){c=l;break}}if((k|0)==8&&((h|0)!=(l|0)?(c=e[D>>2]|0,(c+-4|0)>>>0<28?c=l0(t,e[36476+(c<<2)>>2]|0)|0:c=0,c=c+h|0,(c|0)>(l|0)&&(c=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,c|0,5,35648),R=g,g=0,R&1?(R=j()|0,Tt(c|0),le(R|0)):Qt(c|0,824,96))):c=l),(c|0)<=0)return c|0;h=0;do R=o+(h*3|0)|0,S[R>>0]=S[r>>0]|0,S[R+1>>0]=S[r+1>>0]|0,S[R+2>>0]=S[r+2>>0]|0,h=h+1|0;while((h|0)!=(c|0));return c|0}function lr(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;if(w=r+9|0,o=F[w>>0]|0,h=r+4|0,c=(ee(o>>>1,e[h>>2]|0)|0)+(e[r>>2]|0)|0,(o|0)<(c|0)){l=0;do o=o<<1,l=l+1|0;while((o|0)<(c|0))}else l=0;c=e[36476+(e[t+4568>>2]<<2)>>2]|0,o=X0(t)|0;do if((o|0)<(22-c|0))if(l){o=(l0(t,l)|0)+(o<>2]|0,c=o+t|0,C=c&1,l=C,h=1,c=(C+c|0)/2|0;break}else{t=e[h>>2]|0,c=t+o|0,l=c&1,c=(l+c|0)/2|0,d=8;break}else o=(l0(t,8)|0)+1|0,t=e[h>>2]|0,c=o+t|0,h=c&1,c=(h+c|0)/2|0,l?(l=h,h=1):(l=h,d=8);while(!1);return(d|0)==8&&(h=F[r+10>>0]<<1>>>0>=(F[w>>0]|0)>>>0),c=(l|0)!=0^h?c:0-c|0,(c|0)<0&&(C=r+10|0,S[C>>0]=(F[C>>0]|0)+1),o=(o+1-t>>1)+(e[r>>2]|0)|0,e[r>>2]=o,l=S[w>>0]|0,l<<24>>24!=(S[r+8>>0]|0)?(C=l,C=C&255,C=C+1|0,C=C&255,S[w>>0]=C,c|0):(e[r>>2]=o>>1,C=(l&255)>>>1,S[w>>0]=C,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,C=C&255,C=C+1|0,C=C&255,S[w>>0]=C,c|0)}function sc(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(k=b,b=b+128|0,h=k,R=k+116|0,_=k+104|0,w=k+20|0,D=k+16|0,C=k+12|0,N=k+8|0,d=k+4|0,S[R>>0]=S[58887]|0,S[R+1>>0]=S[58888]|0,S[R+2>>0]=S[58889]|0,S[R+3>>0]=S[58890]|0,S[R+4>>0]=S[58891]|0,S[R+5>>0]=S[58892]|0,ki(R+1|0,58893,0,e[o+4>>2]|0),t=b0()|0,e[h>>2]=c,c=_+(q0(_,12,t,R,h)|0)|0,R=ri(_,c,o)|0,t=f0(o)|0,e[N>>2]=t,g=0,ht(3,_|0,R|0,c|0,w|0,D|0,C|0,N|0),c=g,g=0,c&1)_=j()|0,Bt(t)|0,le(_|0);else return Bt(t)|0,e[d>>2]=e[r>>2],R=e[D>>2]|0,_=e[C>>2]|0,e[h>>2]=e[d>>2],_=Hi(h,w,R,_,o,l)|0,b=k,_|0;return 0}function oc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;if(N=b,b=b+240|0,d=N+8|0,t=N,_=N+204|0,C=N+32|0,k=N+28|0,D=N+24|0,R=N+20|0,w=N+16|0,U=t,e[U>>2]=37,e[U+4>>2]=0,ki(t+1|0,58895,0,e[o+4>>2]|0),U=b0()|0,Q=d,e[Q>>2]=c,e[Q+4>>2]=h,h=_+(q0(_,23,U,t,d)|0)|0,c=ri(_,h,o)|0,t=f0(o)|0,e[R>>2]=t,g=0,ht(3,_|0,c|0,h|0,C|0,k|0,D|0,R|0),h=g,g=0,h&1)Q=j()|0,Bt(t)|0,le(Q|0);else return Bt(t)|0,e[w>>2]=e[r>>2],U=e[k>>2]|0,Q=e[D>>2]|0,e[d>>2]=e[w>>2],Q=Hi(d,C,U,Q,o,l)|0,b=N,Q|0;return 0}function ac(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=+c;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0;Z=b,b=b+352|0,K=Z+312|0,R=Z+48|0,N=Z+32|0,C=Z+24|0,h=Z+8|0,k=Z,U=Z+316|0,Q=Z+80|0,w=Z+84|0,O=Z+76|0,P=Z+72|0,G=Z+68|0,$=Z+64|0,D=k,e[D>>2]=37,e[D+4>>2]=0,D=gn(k+1|0,58898,e[o+4>>2]|0)|0,e[Q>>2]=U,t=b0()|0,D?(e[h>>2]=e[o+8>>2],B[h+8>>3]=c,h=q0(U,30,t,k,h)|0):(B[C>>3]=c,h=q0(U,30,t,k,C)|0);e:do if((h|0)>29){g=0,t=Ce(3)|0,h=g,g=0,h=h&1,D?!h&&(g=0,e[N>>2]=e[o+8>>2],B[N+8>>3]=c,d=Pe(17,Q|0,t|0,k|0,N|0)|0,_=g,g=0,!(_&1))&&(ie=12):!h&&(g=0,e[R>>2]=e[o+8>>2],B[R+8>>3]=c,_=Pe(17,Q|0,t|0,k|0,R|0)|0,R=g,g=0,!(R&1))&&(d=_,ie=12);do if((ie|0)==12){if(t=e[Q>>2]|0,t)h=t;else{if(g=0,Nt(6),_=g,g=0,_&1)break;h=e[Q>>2]|0}t=h,k=h,ie=16;break e}while(!1);t=j()|0}else t=e[Q>>2]|0,k=0,d=h,ie=16;while(!1);if((ie|0)==16){C=t+d|0,D=ri(t,C,o)|0;do if((t|0)==(U|0))t=U,h=0,ie=22;else{if(d=E0(d<<3)|0,!d){if(g=0,Nt(6),ie=g,g=0,ie&1){h=0,ie=20;break}t=e[Q>>2]|0}h=d,w=d,ie=22}while(!1);do if((ie|0)==22)if(g=0,d=ge(68,o|0)|0,Q=g,g=0,Q&1)ie=20;else{if(e[G>>2]=d,g=0,ht(4,t|0,D|0,C|0,w|0,O|0,P|0,G|0),G=g,g=0,G&1){t=j()|0,Bt(d)|0;break}if(Bt(d)|0,e[$>>2]=e[r>>2],ie=e[O>>2]|0,t=e[P>>2]|0,g=0,e[K>>2]=e[$>>2],t=Vt(40,K|0,w|0,ie|0,t|0,o|0,l|0)|0,ie=g,g=0,ie&1)ie=20;else return e[r>>2]=t,h&&n0(h),k&&n0(k),b=Z,t|0}while(!1);(ie|0)==20&&(t=j()|0),h&&n0(h),k&&n0(k)}return le(t|0),0}function uc(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0;switch(O=b,b=b+16|0,Z=O,P=O0(d,44212)|0,G=O0(d,44368)|0,t0[e[(e[G>>2]|0)+20>>2]&127](Z,G),e[h>>2]=l,d=S[t>>0]|0,d<<24>>24){case 43:case 45:{g=0,d=be(e[(e[P>>2]|0)+44>>2]|0,P|0,d|0)|0,$=g,g=0,$&1?K=8:(D=e[h>>2]|0,e[h>>2]=D+4,e[D>>2]=d,D=t+1|0,K=10);break}default:D=t,K=10}e:do if((K|0)==10){$=o;t:do if(($-D|0)>1&&(S[D>>0]|0)==48){switch(w=D+1|0,S[w>>0]|0){case 88:case 120:break;default:{K=11;break t}}if(g=0,d=be(e[(e[P>>2]|0)+44>>2]|0,P|0,48)|0,Q=g,g=0,Q&1){K=8;break e}if(Q=e[h>>2]|0,e[h>>2]=Q+4,e[Q>>2]=d,D=D+2|0,g=0,d=be(e[(e[P>>2]|0)+44>>2]|0,P|0,S[w>>0]|0)|0,Q=g,g=0,Q&1){K=8;break e}if(Q=e[h>>2]|0,e[h>>2]=Q+4,e[Q>>2]=d,D>>>0>>0){for(d=D;w=S[d>>0]|0,g=0,C=Ce(3)|0,Q=g,g=0,!(Q&1||(g=0,w=be(39,w<<24>>24|0,C|0)|0,Q=g,g=0,Q&1));){if(!w){Q=D;break t}if(d=d+1|0,d>>>0>=o>>>0){Q=D;break t}}d=j()|0;break e}else Q=D,d=D}else K=11;while(!1);t:do if((K|0)==11)if(D>>>0>>0){for(d=D;w=S[d>>0]|0,g=0,C=Ce(3)|0,Q=g,g=0,!(Q&1||(g=0,w=be(40,w<<24>>24|0,C|0)|0,Q=g,g=0,Q&1));){if(!w){Q=D;break t}if(d=d+1|0,d>>>0>=o>>>0){Q=D;break t}}d=j()|0;break e}else Q=D,d=D;while(!1);if(_=S[Z>>0]|0,U=Z+4|0,(_&1?e[U>>2]|0:(_&255)>>>1)|0){if((Q|0)!=(d|0)&&(k=d+-1|0,Q>>>0>>0)){C=Q,w=k;do _=S[C>>0]|0,S[C>>0]=S[w>>0]|0,S[w>>0]=_,C=C+1|0,w=w+-1|0;while(C>>>0>>0)}if(g=0,k=ge(e[(e[G>>2]|0)+16>>2]|0,G|0)|0,_=g,g=0,_&1){K=8;break}N=Z+8|0,R=Z+1|0;t:do if(Q>>>0>>0){for(w=0,C=0,_=Q;D=S[(S[Z>>0]&1?e[N>>2]|0:R)+C>>0]|0,D<<24>>24>0&(w|0)==(D<<24>>24|0)?(w=e[h>>2]|0,e[h>>2]=w+4,e[w>>2]=k,w=S[Z>>0]|0,D=0,C=(C>>>0<((w&1?e[U>>2]|0:(w&255)>>>1)+-1|0)>>>0&1)+C|0):D=w,g=0,w=be(e[(e[P>>2]|0)+44>>2]|0,P|0,S[_>>0]|0)|0,ie=g,g=0,!(ie&1);){if(ie=e[h>>2]|0,e[h>>2]=ie+4,e[ie>>2]=w,_=_+1|0,_>>>0>=d>>>0)break t;w=D+1|0}d=j()|0;break e}while(!1);if(w=l+(Q-t<<2)|0,D=e[h>>2]|0,(w|0)!=(D|0))if(C=D+-4|0,w>>>0>>0){do ie=e[w>>2]|0,e[w>>2]=e[C>>2],e[C>>2]=ie,w=w+4|0,C=C+-4|0;while(w>>>0>>0);k=P,w=D}else k=P,w=D;else k=P}else{if(g=0,Pe(e[(e[P>>2]|0)+48>>2]|0,P|0,Q|0,d|0,e[h>>2]|0)|0,ie=g,g=0,ie&1){K=8;break}w=(e[h>>2]|0)+(d-Q<<2)|0,e[h>>2]=w,k=P}t:do if(d>>>0>>0){for(;;){if(w=S[d>>0]|0,w<<24>>24==46){C=d;break}if(g=0,C=be(e[(e[k>>2]|0)+44>>2]|0,P|0,w|0)|0,ie=g,g=0,ie&1){K=4;break}if(ie=e[h>>2]|0,w=ie+4|0,e[h>>2]=w,e[ie>>2]=C,d=d+1|0,d>>>0>=o>>>0)break t}if((K|0)==4){d=j()|0;break e}if(g=0,d=ge(e[(e[G>>2]|0)+12>>2]|0,G|0)|0,ie=g,g=0,ie&1){K=8;break e}ie=e[h>>2]|0,w=ie+4|0,e[h>>2]=w,e[ie>>2]=d,d=C+1|0}while(!1);if(g=0,Pe(e[(e[P>>2]|0)+48>>2]|0,P|0,d|0,o|0,w|0)|0,ie=g,g=0,ie&1)K=8;else{ie=(e[h>>2]|0)+($-d<<2)|0,e[h>>2]=ie,e[c>>2]=(r|0)==(o|0)?ie:l+(r-t<<2)|0,de(Z),b=O;return}}while(!1);(K|0)==8&&(d=j()|0),de(Z),le(d|0)}function cc(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=+c;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0;Z=b,b=b+352|0,K=Z+304|0,R=Z+48|0,N=Z+32|0,C=Z+24|0,h=Z+8|0,k=Z,U=Z+308|0,Q=Z+72|0,w=Z+76|0,O=Z+68|0,P=Z+64|0,G=Z+60|0,$=Z+56|0,D=k,e[D>>2]=37,e[D+4>>2]=0,D=gn(k+1|0,58899,e[o+4>>2]|0)|0,e[Q>>2]=U,t=b0()|0,D?(e[h>>2]=e[o+8>>2],B[h+8>>3]=c,h=q0(U,30,t,k,h)|0):(B[C>>3]=c,h=q0(U,30,t,k,C)|0);e:do if((h|0)>29){g=0,t=Ce(3)|0,h=g,g=0,h=h&1,D?!h&&(g=0,e[N>>2]=e[o+8>>2],B[N+8>>3]=c,d=Pe(17,Q|0,t|0,k|0,N|0)|0,_=g,g=0,!(_&1))&&(ie=12):!h&&(g=0,B[R>>3]=c,_=Pe(17,Q|0,t|0,k|0,R|0)|0,R=g,g=0,!(R&1))&&(d=_,ie=12);do if((ie|0)==12){if(t=e[Q>>2]|0,t)h=t;else{if(g=0,Nt(6),_=g,g=0,_&1)break;h=e[Q>>2]|0}t=h,k=h,ie=16;break e}while(!1);t=j()|0}else t=e[Q>>2]|0,k=0,d=h,ie=16;while(!1);if((ie|0)==16){C=t+d|0,D=ri(t,C,o)|0;do if((t|0)==(U|0))t=U,h=0,ie=22;else{if(d=E0(d<<3)|0,!d){if(g=0,Nt(6),ie=g,g=0,ie&1){h=0,ie=20;break}t=e[Q>>2]|0}h=d,w=d,ie=22}while(!1);do if((ie|0)==22)if(g=0,d=ge(68,o|0)|0,Q=g,g=0,Q&1)ie=20;else{if(e[G>>2]=d,g=0,ht(4,t|0,D|0,C|0,w|0,O|0,P|0,G|0),G=g,g=0,G&1){t=j()|0,Bt(d)|0;break}if(Bt(d)|0,e[$>>2]=e[r>>2],ie=e[O>>2]|0,t=e[P>>2]|0,g=0,e[K>>2]=e[$>>2],t=Vt(40,K|0,w|0,ie|0,t|0,o|0,l|0)|0,ie=g,g=0,ie&1)ie=20;else return e[r>>2]=t,h&&n0(h),k&&n0(k),b=Z,t|0}while(!1);(ie|0)==20&&(t=j()|0),h&&n0(h),k&&n0(k)}return le(t|0),0}function fc(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(R=b,b=b+192|0,C=R,t=R+180|0,k=R+160|0,N=R+12|0,w=R+8|0,D=R+4|0,S[t>>0]=S[58901]|0,S[t+1>>0]=S[58902]|0,S[t+2>>0]=S[58903]|0,S[t+3>>0]=S[58904]|0,S[t+4>>0]=S[58905]|0,S[t+5>>0]=S[58906]|0,h=b0()|0,e[C>>2]=c,t=q0(k,20,h,t,C)|0,c=k+t|0,h=ri(k,c,o)|0,d=f0(o)|0,e[w>>2]=d,g=0,w=be(37,w|0,44212)|0,_=g,g=0,_&1)_=j()|0,Bt(d)|0,le(_|0);else return Bt(d)|0,_r[e[(e[w>>2]|0)+48>>2]&31](w,k,c,N)|0,_=N+(t<<2)|0,e[D>>2]=e[r>>2],e[C>>2]=e[D>>2],_=Hi(C,N,(h|0)==(c|0)?_:N+(h-k<<2)|0,_,o,l)|0,b=R,_|0;return 0}function xi(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0;ie=b,b=b+32|0,K=ie+16|0,Q=ie+12|0,P=ie+8|0,G=ie+4|0,$=ie,C=f0(l)|0,e[P>>2]=C,g=0,P=be(37,P|0,44220)|0,U=g,g=0,U&1&&(ie=j()|0,Bt(C)|0,le(ie|0)),Bt(C)|0,e[c>>2]=0,U=P+8|0,C=e[r>>2]|0;e:do if((d|0)!=(w|0)){t:for(;;){D=C,C?(e[C+12>>2]|0)==(e[C+16>>2]|0)&&(Dt[e[(e[C>>2]|0)+36>>2]&127](C)|0)==-1&&(e[r>>2]=0,C=0,D=0):C=0,R=(C|0)==0,N=e[o>>2]|0,k=N;do if(N){if((e[N+12>>2]|0)==(e[N+16>>2]|0)&&(Dt[e[(e[N>>2]|0)+36>>2]&127](N)|0)==-1){e[o>>2]=0,k=0,Z=12;break}if(!R){Z=13;break t}}else Z=12;while(!1);if((Z|0)==12)if(Z=0,R){Z=13;break}else N=0;i:do if((Yt[e[(e[P>>2]|0)+36>>2]&63](P,S[d>>0]|0,0)|0)<<24>>24==37){if(N=d+1|0,(N|0)==(w|0)){Z=17;break t}switch(_=Yt[e[(e[P>>2]|0)+36>>2]&63](P,S[N>>0]|0,0)|0,_<<24>>24){case 48:case 69:{if(R=d+2|0,(R|0)==(w|0)){Z=20;break t}d=N,N=Yt[e[(e[P>>2]|0)+36>>2]&63](P,S[R>>0]|0,0)|0,C=_;break}default:N=_,C=0}_=e[(e[t>>2]|0)+36>>2]|0,e[G>>2]=D,e[$>>2]=k,e[Q>>2]=e[G>>2],e[K>>2]=e[$>>2],_=Ci[_&15](t,Q,K,l,c,h,N,C)|0,e[r>>2]=_,d=d+2|0}else{if(D=S[d>>0]|0,D<<24>>24>-1&&(O=e[U>>2]|0,(E[O+(D<<24>>24<<1)>>1]&8192)!=0)){do{if(d=d+1|0,(d|0)==(w|0)){d=w;break}if(D=S[d>>0]|0,D<<24>>24<=-1)break}while(E[O+(D<<24>>24<<1)>>1]&8192);for(D=N;;){C?(e[C+12>>2]|0)==(e[C+16>>2]|0)&&(Dt[e[(e[C>>2]|0)+36>>2]&127](C)|0)==-1&&(e[r>>2]=0,C=0):C=0,k=(C|0)==0;do if(N){if((e[N+12>>2]|0)!=(e[N+16>>2]|0))if(k){_=D;break}else break i;if((Dt[e[(e[N>>2]|0)+36>>2]&127](N)|0)!=-1)if(k^(D|0)==0){_=D,N=D;break}else break i;else{e[o>>2]=0,D=0,Z=39;break}}else Z=39;while(!1);if((Z|0)==39){if(Z=0,k)break i;_=D,N=0}if(k=C+12|0,D=e[k>>2]|0,R=C+16|0,(D|0)==(e[R>>2]|0)?D=Dt[e[(e[C>>2]|0)+36>>2]&127](C)|0:D=F[D>>0]|0,(D&255)<<24>>24<=-1||!(E[(e[U>>2]|0)+(D<<24>>24<<1)>>1]&8192))break i;if(D=e[k>>2]|0,(D|0)==(e[R>>2]|0)){Dt[e[(e[C>>2]|0)+40>>2]&127](C)|0,D=_;continue}else{e[k>>2]=D+1,D=_;continue}}}if(k=C+12|0,D=e[k>>2]|0,N=C+16|0,(D|0)==(e[N>>2]|0)?D=Dt[e[(e[C>>2]|0)+36>>2]&127](C)|0:D=F[D>>0]|0,_=U0[e[(e[P>>2]|0)+12>>2]&63](P,D&255)|0,_<<24>>24!=(U0[e[(e[P>>2]|0)+12>>2]&63](P,S[d>>0]|0)|0)<<24>>24){Z=57;break t}D=e[k>>2]|0,(D|0)==(e[N>>2]|0)?Dt[e[(e[C>>2]|0)+40>>2]&127](C)|0:e[k>>2]=D+1,d=d+1|0}while(!1);if(C=e[r>>2]|0,!((d|0)!=(w|0)&(e[c>>2]|0)==0))break e}if((Z|0)==13){e[c>>2]=4;break}else if((Z|0)==17){e[c>>2]=4;break}else if((Z|0)==20){e[c>>2]=4;break}else if((Z|0)==57){e[c>>2]=4,C=e[r>>2]|0;break}}while(!1);C?(e[C+12>>2]|0)==(e[C+16>>2]|0)&&(Dt[e[(e[C>>2]|0)+36>>2]&127](C)|0)==-1&&(e[r>>2]=0,C=0):C=0,d=(C|0)==0,D=e[o>>2]|0;do if(D){if((e[D+12>>2]|0)==(e[D+16>>2]|0)&&(Dt[e[(e[D>>2]|0)+36>>2]&127](D)|0)==-1){e[o>>2]=0,Z=67;break}d||(Z=68)}else Z=67;while(!1);return(Z|0)==67&&d&&(Z=68),(Z|0)==68&&(e[c>>2]=e[c>>2]|2),b=ie,C|0}function hc(t){t=t|0}function dc(t){t=t|0,he(t)}function pc(t){return t=t|0,2}function mc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=xi(t,C,w,l,c,h,58907,58915)|0,b=d,t|0}function gc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,N=t+8|0,N=Dt[e[(e[N>>2]|0)+20>>2]&127](N)|0,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],o=S[N>>0]|0,R=(o&1)==0,r=R?N+1|0:e[N+8>>2]|0,o=r+(R?(o&255)>>>1:e[N+4>>2]|0)|0,e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=xi(t,C,w,l,c,h,r,o)|0,b=d,t|0}function Sc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;if(D=b,b=b+16|0,w=D+8|0,d=D+4|0,C=D,l=f0(l)|0,e[d>>2]=l,g=0,d=be(37,d|0,44220)|0,k=g,g=0,k&1)k=j()|0,Bt(l)|0,le(k|0);else return Bt(l)|0,e[C>>2]=e[o>>2],e[w>>2]=e[C>>2],Is(t,h+24|0,r,w,c,d),b=D,e[r>>2]|0;return 0}function Is(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0;d=b,b=b+16|0,w=d+4|0,C=d,t=t+8|0,t=Dt[e[e[t>>2]>>2]&127](t)|0,e[C>>2]=e[l>>2],e[w>>2]=e[C>>2],o=(Sn(o,w,t,t+168|0,h,c,0)|0)-t|0,(o|0)<168&&(e[r>>2]=((o|0)/12|0|0)%7|0),b=d}function Ac(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;if(D=b,b=b+16|0,w=D+8|0,d=D+4|0,C=D,l=f0(l)|0,e[d>>2]=l,g=0,d=be(37,d|0,44220)|0,k=g,g=0,k&1)k=j()|0,Bt(l)|0,le(k|0);else return Bt(l)|0,e[C>>2]=e[o>>2],e[w>>2]=e[C>>2],Es(t,h+16|0,r,w,c,d),b=D,e[r>>2]|0;return 0}function Es(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0;d=b,b=b+16|0,w=d+4|0,C=d,t=t+8|0,t=Dt[e[(e[t>>2]|0)+4>>2]&127](t)|0,e[C>>2]=e[l>>2],e[w>>2]=e[C>>2],o=(Sn(o,w,t,t+288|0,h,c,0)|0)-t|0,(o|0)<288&&(e[r>>2]=((o|0)/12|0|0)%12|0),b=d}function vc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;if(D=b,b=b+16|0,w=D+8|0,d=D+4|0,C=D,l=f0(l)|0,e[d>>2]=l,g=0,d=be(37,d|0,44220)|0,k=g,g=0,k&1)k=j()|0,Bt(l)|0,le(k|0);else return Bt(l)|0,e[C>>2]=e[o>>2],e[w>>2]=e[C>>2],ks(t,h+20|0,r,w,c,d),b=D,e[r>>2]|0;return 0}function ks(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=fi(o,t,c,h,4)|0,e[c>>2]&4||((t|0)<69?t=t+2e3|0:t=(t+-69|0)>>>0<31?t+1900|0:t,e[r>>2]=t+-1900),b=d}function xc(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0,jt=0,Gt=0,s0=0,i0=0,zt=0,gt=0,Kt=0,dt=0,At=0,y0=0,T0=0,g0=0,Oe=0,yt=0,qt=0;Oe=b,b=b+144|0,C=Oe+132|0,w=Oe+116|0,gt=Oe+128|0,P=Oe+124|0,jt=Oe+120|0,Kt=Oe+112|0,dt=Oe+108|0,At=Oe+104|0,y0=Oe+100|0,T0=Oe+96|0,g0=Oe+92|0,D=Oe+88|0,k=Oe+84|0,N=Oe+80|0,R=Oe+76|0,_=Oe+72|0,U=Oe+68|0,Q=Oe+64|0,K=Oe+60|0,G=Oe+56|0,$=Oe+52|0,O=Oe+48|0,Z=Oe+44|0,ie=Oe+40|0,oe=Oe+36|0,ne=Oe+32|0,ce=Oe+28|0,ke=Oe+24|0,Ee=Oe+20|0,Te=Oe+16|0,it=Oe+12|0,Gt=Oe+8|0,s0=Oe+4|0,i0=Oe,e[c>>2]=0,zt=f0(l)|0,e[gt>>2]=zt,g=0,gt=be(37,gt|0,44220)|0,qt=g,g=0,qt&1&&(qt=j()|0,Bt(zt)|0,le(qt|0)),Bt(zt)|0;do switch(d<<24>>24|0){case 65:case 97:{e[P>>2]=e[o>>2],e[C>>2]=e[P>>2],Is(t,h+24|0,r,C,c,gt),yt=28;break}case 104:case 66:case 98:{e[jt>>2]=e[o>>2],e[C>>2]=e[jt>>2],Es(t,h+16|0,r,C,c,gt),yt=28;break}case 99:{yt=t+8|0,yt=Dt[e[(e[yt>>2]|0)+12>>2]&127](yt)|0,e[Kt>>2]=e[r>>2],e[dt>>2]=e[o>>2],d=S[yt>>0]|0,o=(d&1)==0,qt=o?yt+1|0:e[yt+8>>2]|0,yt=qt+(o?(d&255)>>>1:e[yt+4>>2]|0)|0,e[w>>2]=e[Kt>>2],e[C>>2]=e[dt>>2],yt=xi(t,w,C,l,c,h,qt,yt)|0,e[r>>2]=yt,yt=28;break}case 101:case 100:{e[At>>2]=e[o>>2],e[C>>2]=e[At>>2],wc(t,h+12|0,r,C,c,gt),yt=28;break}case 68:{e[y0>>2]=e[r>>2],e[T0>>2]=e[o>>2],e[w>>2]=e[y0>>2],e[C>>2]=e[T0>>2],yt=xi(t,w,C,l,c,h,58915,58923)|0,e[r>>2]=yt,yt=28;break}case 70:{e[g0>>2]=e[r>>2],e[D>>2]=e[o>>2],e[w>>2]=e[g0>>2],e[C>>2]=e[D>>2],yt=xi(t,w,C,l,c,h,58923,58931)|0,e[r>>2]=yt,yt=28;break}case 72:{e[k>>2]=e[o>>2],e[C>>2]=e[k>>2],yc(t,h+8|0,r,C,c,gt),yt=28;break}case 73:{e[N>>2]=e[o>>2],e[C>>2]=e[N>>2],Cc(t,h+8|0,r,C,c,gt),yt=28;break}case 106:{e[R>>2]=e[o>>2],e[C>>2]=e[R>>2],Tc(t,h+28|0,r,C,c,gt),yt=28;break}case 109:{e[_>>2]=e[o>>2],e[C>>2]=e[_>>2],Ic(t,h+16|0,r,C,c,gt),yt=28;break}case 77:{e[U>>2]=e[o>>2],e[C>>2]=e[U>>2],Ec(t,h+4|0,r,C,c,gt),yt=28;break}case 116:case 110:{e[Q>>2]=e[o>>2],e[C>>2]=e[Q>>2],kc(t,r,C,c,gt),yt=28;break}case 112:{e[K>>2]=e[o>>2],e[C>>2]=e[K>>2],Dc(t,h+8|0,r,C,c,gt),yt=28;break}case 114:{e[G>>2]=e[r>>2],e[$>>2]=e[o>>2],e[w>>2]=e[G>>2],e[C>>2]=e[$>>2],yt=xi(t,w,C,l,c,h,58931,58942)|0,e[r>>2]=yt,yt=28;break}case 82:{e[O>>2]=e[r>>2],e[Z>>2]=e[o>>2],e[w>>2]=e[O>>2],e[C>>2]=e[Z>>2],yt=xi(t,w,C,l,c,h,58942,58947)|0,e[r>>2]=yt,yt=28;break}case 83:{e[ie>>2]=e[o>>2],e[C>>2]=e[ie>>2],bc(t,h,r,C,c,gt),yt=28;break}case 84:{e[oe>>2]=e[r>>2],e[ne>>2]=e[o>>2],e[w>>2]=e[oe>>2],e[C>>2]=e[ne>>2],yt=xi(t,w,C,l,c,h,58947,58955)|0,e[r>>2]=yt,yt=28;break}case 119:{e[ce>>2]=e[o>>2],e[C>>2]=e[ce>>2],Nc(t,h+24|0,r,C,c,gt),yt=28;break}case 120:{qt=e[(e[t>>2]|0)+20>>2]|0,e[ke>>2]=e[r>>2],e[Ee>>2]=e[o>>2],e[w>>2]=e[ke>>2],e[C>>2]=e[Ee>>2],w=on[qt&63](t,w,C,l,c,h)|0;break}case 88:{yt=t+8|0,yt=Dt[e[(e[yt>>2]|0)+24>>2]&127](yt)|0,e[Te>>2]=e[r>>2],e[it>>2]=e[o>>2],d=S[yt>>0]|0,o=(d&1)==0,qt=o?yt+1|0:e[yt+8>>2]|0,yt=qt+(o?(d&255)>>>1:e[yt+4>>2]|0)|0,e[w>>2]=e[Te>>2],e[C>>2]=e[it>>2],yt=xi(t,w,C,l,c,h,qt,yt)|0,e[r>>2]=yt,yt=28;break}case 121:{e[Gt>>2]=e[o>>2],e[C>>2]=e[Gt>>2],ks(t,h+20|0,r,C,c,gt),yt=28;break}case 89:{e[s0>>2]=e[o>>2],e[C>>2]=e[s0>>2],Fc(t,h+20|0,r,C,c,gt),yt=28;break}case 37:{e[i0>>2]=e[o>>2],e[C>>2]=e[i0>>2],Rc(t,r,C,c,gt),yt=28;break}default:e[c>>2]=e[c>>2]|4,yt=28}while(!1);return(yt|0)==28&&(w=e[r>>2]|0),b=Oe,w|0}function wc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=fi(o,t,c,h,2)|0,o=e[c>>2]|0,(t+-1|0)>>>0<31&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function yc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=fi(o,t,c,h,2)|0,o=e[c>>2]|0,(t|0)<24&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function Cc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=fi(o,t,c,h,2)|0,o=e[c>>2]|0,(t+-1|0)>>>0<12&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function Tc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=fi(o,t,c,h,3)|0,o=e[c>>2]|0,(t|0)<366&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function Ic(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=fi(o,t,c,h,2)|0,o=e[c>>2]|0,(t|0)<13&(o&4|0)==0?e[r>>2]=t+-1:e[c>>2]=o|4,b=d}function Ec(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=fi(o,t,c,h,2)|0,o=e[c>>2]|0,(t|0)<60&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function kc(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0;d=c+8|0;e:for(;;){c=e[r>>2]|0;do if(c){if((e[c+12>>2]|0)==(e[c+16>>2]|0))if((Dt[e[(e[c>>2]|0)+36>>2]&127](c)|0)==-1){e[r>>2]=0,c=0;break}else{c=e[r>>2]|0;break}}else c=0;while(!1);c=(c|0)==0,t=e[o>>2]|0;do if(t){if((e[t+12>>2]|0)!=(e[t+16>>2]|0)){if(c)break;break e}if((Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0)!=-1){if(c)break;break e}else{e[o>>2]=0,w=12;break}}else w=12;while(!1);if((w|0)==12)if(w=0,c){t=0;break}else t=0;if(c=e[r>>2]|0,h=e[c+12>>2]|0,(h|0)==(e[c+16>>2]|0)?c=Dt[e[(e[c>>2]|0)+36>>2]&127](c)|0:c=F[h>>0]|0,(c&255)<<24>>24<=-1||!(E[(e[d>>2]|0)+(c<<24>>24<<1)>>1]&8192))break;if(c=e[r>>2]|0,t=c+12|0,h=e[t>>2]|0,(h|0)==(e[c+16>>2]|0)){Dt[e[(e[c>>2]|0)+40>>2]&127](c)|0;continue}else{e[t>>2]=h+1;continue}}c=e[r>>2]|0;do if(c){if((e[c+12>>2]|0)==(e[c+16>>2]|0))if((Dt[e[(e[c>>2]|0)+36>>2]&127](c)|0)==-1){e[r>>2]=0,c=0;break}else{c=e[r>>2]|0;break}}else c=0;while(!1);c=(c|0)==0;do if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)&&(Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0)==-1){e[o>>2]=0,w=32;break}c||(w=33)}else w=32;while(!1);(w|0)==32&&c&&(w=33),(w|0)==33&&(e[l>>2]=e[l>>2]|2)}function Dc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;k=b,b=b+16|0,w=k+4|0,C=k,D=t+8|0,D=Dt[e[(e[D>>2]|0)+8>>2]&127](D)|0,t=S[D>>0]|0,t&1?d=e[D+4>>2]|0:d=(t&255)>>>1,t=S[D+12>>0]|0,t&1?t=e[D+16>>2]|0:t=(t&255)>>>1;do if((d|0)!=(0-t|0)){if(e[C>>2]=e[l>>2],e[w>>2]=e[C>>2],t=Sn(o,w,D,D+24|0,h,c,0)|0,d=e[r>>2]|0,(t|0)==(D|0)&(d|0)==12){e[r>>2]=0;break}(d|0)<12&(t-D|0)==12&&(e[r>>2]=d+12)}else e[c>>2]=e[c>>2]|4;while(!1);b=k}function bc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=fi(o,t,c,h,2)|0,o=e[c>>2]|0,(t|0)<61&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function Nc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=fi(o,t,c,h,1)|0,o=e[c>>2]|0,(t|0)<7&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function Fc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=fi(o,t,c,h,4)|0,e[c>>2]&4||(e[r>>2]=t+-1900),b=d}function Rc(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0;t=e[r>>2]|0;do if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0))if((Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0)==-1){e[r>>2]=0,t=0;break}else{t=e[r>>2]|0;break}}else t=0;while(!1);h=(t|0)==0,t=e[o>>2]|0;do if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)&&(Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0)==-1){e[o>>2]=0,w=11;break}h?(d=t,w=13):w=12}else w=11;while(!1);(w|0)==11&&(h?w=12:(d=0,w=13));e:do if((w|0)==12)e[l>>2]=e[l>>2]|6;else if((w|0)==13){if(t=e[r>>2]|0,h=e[t+12>>2]|0,(h|0)==(e[t+16>>2]|0)?t=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0:t=F[h>>0]|0,(Yt[e[(e[c>>2]|0)+36>>2]&63](c,t&255,0)|0)<<24>>24!=37){e[l>>2]=e[l>>2]|4;break}t=e[r>>2]|0,h=t+12|0,c=e[h>>2]|0,(c|0)==(e[t+16>>2]|0)?(Dt[e[(e[t>>2]|0)+40>>2]&127](t)|0,t=e[r>>2]|0,t?w=21:t=0):(e[h>>2]=c+1,w=21);do if((w|0)==21&&(e[t+12>>2]|0)==(e[t+16>>2]|0))if((Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0)==-1){e[r>>2]=0,t=0;break}else{t=e[r>>2]|0;break}while(!1);t=(t|0)==0;do if(d){if((e[d+12>>2]|0)==(e[d+16>>2]|0)&&(Dt[e[(e[d>>2]|0)+36>>2]&127](d)|0)==-1){e[o>>2]=0,w=30;break}if(t)break e}else w=30;while(!1);if((w|0)==30&&!t)break;e[l>>2]=e[l>>2]|2}while(!1)}function wi(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;O=b,b=b+32|0,Q=O+16|0,U=O+12|0,$=O+8|0,K=O+4|0,G=O,C=f0(l)|0,e[$>>2]=C,g=0,$=be(37,$|0,44212)|0,_=g,g=0,_&1&&(O=j()|0,Bt(C)|0,le(O|0)),Bt(C)|0,e[c>>2]=0,C=e[r>>2]|0;e:do if((d|0)!=(w|0)){t:for(;;){k=C,C?(D=e[C+12>>2]|0,(D|0)==(e[C+16>>2]|0)?D=Dt[e[(e[C>>2]|0)+36>>2]&127](C)|0:D=e[D>>2]|0,(D|0)==-1?(e[r>>2]=0,C=0,R=1,_=0):(R=0,_=k)):(C=0,R=1,_=k),N=e[o>>2]|0,D=N;do if(N)if(k=e[N+12>>2]|0,(k|0)==(e[N+16>>2]|0)?k=Dt[e[(e[N>>2]|0)+36>>2]&127](N)|0:k=e[k>>2]|0,(k|0)!=-1){if(R)break;P=17;break t}else{e[o>>2]=0,D=0,P=15;break}else P=15;while(!1);if((P|0)==15)if(P=0,R){P=17;break}else N=0;i:do if((Yt[e[(e[$>>2]|0)+52>>2]&63]($,e[d>>2]|0,0)|0)<<24>>24==37){if(k=d+4|0,(k|0)==(w|0)){P=21;break t}switch(R=Yt[e[(e[$>>2]|0)+52>>2]&63]($,e[k>>2]|0,0)|0,R<<24>>24){case 48:case 69:{if(N=d+8|0,(N|0)==(w|0)){P=24;break t}d=k,k=Yt[e[(e[$>>2]|0)+52>>2]&63]($,e[N>>2]|0,0)|0,C=R;break}default:k=R,C=0}R=e[(e[t>>2]|0)+36>>2]|0,e[K>>2]=_,e[G>>2]=D,e[U>>2]=e[K>>2],e[Q>>2]=e[G>>2],_=Ci[R&15](t,U,Q,l,c,h,k,C)|0,e[r>>2]=_,d=d+8|0}else{if(!(Yt[e[(e[$>>2]|0)+12>>2]&63]($,8192,e[d>>2]|0)|0)){if(k=C+12|0,D=e[k>>2]|0,N=C+16|0,(D|0)==(e[N>>2]|0)?D=Dt[e[(e[C>>2]|0)+36>>2]&127](C)|0:D=e[D>>2]|0,_=U0[e[(e[$>>2]|0)+28>>2]&63]($,D)|0,(_|0)!=(U0[e[(e[$>>2]|0)+28>>2]&63]($,e[d>>2]|0)|0)){P=61;break t}D=e[k>>2]|0,(D|0)==(e[N>>2]|0)?Dt[e[(e[C>>2]|0)+40>>2]&127](C)|0:e[k>>2]=D+4,d=d+4|0;break}do if(d=d+4|0,(d|0)==(w|0)){d=w;break}while(Yt[e[(e[$>>2]|0)+12>>2]&63]($,8192,e[d>>2]|0)|0);for(D=N,R=N;;){C?(k=e[C+12>>2]|0,(k|0)==(e[C+16>>2]|0)?k=Dt[e[(e[C>>2]|0)+36>>2]&127](C)|0:k=e[k>>2]|0,(k|0)==-1?(e[r>>2]=0,N=1,C=0):N=0):(N=1,C=0);do if(R)if(k=e[R+12>>2]|0,(k|0)==(e[R+16>>2]|0)?k=Dt[e[(e[R>>2]|0)+36>>2]&127](R)|0:k=e[k>>2]|0,(k|0)!=-1)if(N^(D|0)==0){_=D,R=D;break}else break i;else{e[o>>2]=0,D=0,P=44;break}else P=44;while(!1);if((P|0)==44){if(P=0,N)break i;_=D,R=0}if(k=C+12|0,D=e[k>>2]|0,N=C+16|0,(D|0)==(e[N>>2]|0)?D=Dt[e[(e[C>>2]|0)+36>>2]&127](C)|0:D=e[D>>2]|0,!(Yt[e[(e[$>>2]|0)+12>>2]&63]($,8192,D)|0))break i;if(D=e[k>>2]|0,(D|0)==(e[N>>2]|0)){Dt[e[(e[C>>2]|0)+40>>2]&127](C)|0,D=_;continue}else{e[k>>2]=D+4,D=_;continue}}}while(!1);if(C=e[r>>2]|0,!((d|0)!=(w|0)&(e[c>>2]|0)==0))break e}if((P|0)==17){e[c>>2]=4;break}else if((P|0)==21){e[c>>2]=4;break}else if((P|0)==24){e[c>>2]=4;break}else if((P|0)==61){e[c>>2]=4,C=e[r>>2]|0;break}}while(!1);C?(d=e[C+12>>2]|0,(d|0)==(e[C+16>>2]|0)?d=Dt[e[(e[C>>2]|0)+36>>2]&127](C)|0:d=e[d>>2]|0,(d|0)==-1?(e[r>>2]=0,C=0,k=1):k=0):(C=0,k=1),d=e[o>>2]|0;do if(d)if(D=e[d+12>>2]|0,(D|0)==(e[d+16>>2]|0)?d=Dt[e[(e[d>>2]|0)+36>>2]&127](d)|0:d=e[D>>2]|0,(d|0)!=-1){if(k)break;P=76;break}else{e[o>>2]=0,P=74;break}else P=74;while(!1);return(P|0)==74&&k&&(P=76),(P|0)==76&&(e[c>>2]=e[c>>2]|2),b=O,C|0}function Mc(t){t=t|0}function _c(t){t=t|0,he(t)}function Pc(t){return t=t|0,2}function Lc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=wi(t,C,w,l,c,h,44788,44820)|0,b=d,t|0}function Oc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,_=t+8|0,_=Dt[e[(e[_>>2]|0)+20>>2]&127](_)|0,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],N=S[_>>0]|0,R=(N&1)==0,o=_+4|0,r=R?o:e[_+8>>2]|0,o=r+((R?(N&255)>>>1:e[o>>2]|0)<<2)|0,e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=wi(t,C,w,l,c,h,r,o)|0,b=d,t|0}function $c(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;if(D=b,b=b+16|0,w=D+8|0,d=D+4|0,C=D,l=f0(l)|0,e[d>>2]=l,g=0,d=be(37,d|0,44212)|0,k=g,g=0,k&1)k=j()|0,Bt(l)|0,le(k|0);else return Bt(l)|0,e[C>>2]=e[o>>2],e[w>>2]=e[C>>2],Ds(t,h+24|0,r,w,c,d),b=D,e[r>>2]|0;return 0}function Ds(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0;d=b,b=b+16|0,w=d+4|0,C=d,t=t+8|0,t=Dt[e[e[t>>2]>>2]&127](t)|0,e[C>>2]=e[l>>2],e[w>>2]=e[C>>2],o=(An(o,w,t,t+168|0,h,c,0)|0)-t|0,(o|0)<168&&(e[r>>2]=((o|0)/12|0|0)%7|0),b=d}function Bc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;if(D=b,b=b+16|0,w=D+8|0,d=D+4|0,C=D,l=f0(l)|0,e[d>>2]=l,g=0,d=be(37,d|0,44212)|0,k=g,g=0,k&1)k=j()|0,Bt(l)|0,le(k|0);else return Bt(l)|0,e[C>>2]=e[o>>2],e[w>>2]=e[C>>2],bs(t,h+16|0,r,w,c,d),b=D,e[r>>2]|0;return 0}function bs(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0;d=b,b=b+16|0,w=d+4|0,C=d,t=t+8|0,t=Dt[e[(e[t>>2]|0)+4>>2]&127](t)|0,e[C>>2]=e[l>>2],e[w>>2]=e[C>>2],o=(An(o,w,t,t+288|0,h,c,0)|0)-t|0,(o|0)<288&&(e[r>>2]=((o|0)/12|0|0)%12|0),b=d}function Vc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;if(D=b,b=b+16|0,w=D+8|0,d=D+4|0,C=D,l=f0(l)|0,e[d>>2]=l,g=0,d=be(37,d|0,44212)|0,k=g,g=0,k&1)k=j()|0,Bt(l)|0,le(k|0);else return Bt(l)|0,e[C>>2]=e[o>>2],e[w>>2]=e[C>>2],Ns(t,h+20|0,r,w,c,d),b=D,e[r>>2]|0;return 0}function Ns(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=hi(o,t,c,h,4)|0,e[c>>2]&4||((t|0)<69?t=t+2e3|0:t=(t+-69|0)>>>0<31?t+1900|0:t,e[r>>2]=t+-1900),b=d}function Uc(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0,jt=0,Gt=0,s0=0,i0=0,zt=0,gt=0,Kt=0,dt=0,At=0,y0=0,T0=0,g0=0,Oe=0,yt=0,qt=0;Oe=b,b=b+144|0,C=Oe+132|0,w=Oe+116|0,gt=Oe+128|0,P=Oe+124|0,jt=Oe+120|0,Kt=Oe+112|0,dt=Oe+108|0,At=Oe+104|0,y0=Oe+100|0,T0=Oe+96|0,g0=Oe+92|0,D=Oe+88|0,k=Oe+84|0,N=Oe+80|0,R=Oe+76|0,_=Oe+72|0,U=Oe+68|0,Q=Oe+64|0,K=Oe+60|0,G=Oe+56|0,$=Oe+52|0,O=Oe+48|0,Z=Oe+44|0,ie=Oe+40|0,oe=Oe+36|0,ne=Oe+32|0,ce=Oe+28|0,ke=Oe+24|0,Ee=Oe+20|0,Te=Oe+16|0,it=Oe+12|0,Gt=Oe+8|0,s0=Oe+4|0,i0=Oe,e[c>>2]=0,zt=f0(l)|0,e[gt>>2]=zt,g=0,gt=be(37,gt|0,44212)|0,qt=g,g=0,qt&1&&(qt=j()|0,Bt(zt)|0,le(qt|0)),Bt(zt)|0;do switch(d<<24>>24|0){case 65:case 97:{e[P>>2]=e[o>>2],e[C>>2]=e[P>>2],Ds(t,h+24|0,r,C,c,gt),yt=28;break}case 104:case 66:case 98:{e[jt>>2]=e[o>>2],e[C>>2]=e[jt>>2],bs(t,h+16|0,r,C,c,gt),yt=28;break}case 99:{qt=t+8|0,qt=Dt[e[(e[qt>>2]|0)+12>>2]&127](qt)|0,e[Kt>>2]=e[r>>2],e[dt>>2]=e[o>>2],d=S[qt>>0]|0,o=(d&1)==0,yt=qt+4|0,qt=o?yt:e[qt+8>>2]|0,yt=qt+((o?(d&255)>>>1:e[yt>>2]|0)<<2)|0,e[w>>2]=e[Kt>>2],e[C>>2]=e[dt>>2],yt=wi(t,w,C,l,c,h,qt,yt)|0,e[r>>2]=yt,yt=28;break}case 101:case 100:{e[At>>2]=e[o>>2],e[C>>2]=e[At>>2],zc(t,h+12|0,r,C,c,gt),yt=28;break}case 68:{e[y0>>2]=e[r>>2],e[T0>>2]=e[o>>2],e[w>>2]=e[y0>>2],e[C>>2]=e[T0>>2],yt=wi(t,w,C,l,c,h,44820,44852)|0,e[r>>2]=yt,yt=28;break}case 70:{e[g0>>2]=e[r>>2],e[D>>2]=e[o>>2],e[w>>2]=e[g0>>2],e[C>>2]=e[D>>2],yt=wi(t,w,C,l,c,h,44852,44884)|0,e[r>>2]=yt,yt=28;break}case 72:{e[k>>2]=e[o>>2],e[C>>2]=e[k>>2],Gc(t,h+8|0,r,C,c,gt),yt=28;break}case 73:{e[N>>2]=e[o>>2],e[C>>2]=e[N>>2],qc(t,h+8|0,r,C,c,gt),yt=28;break}case 106:{e[R>>2]=e[o>>2],e[C>>2]=e[R>>2],Wc(t,h+28|0,r,C,c,gt),yt=28;break}case 109:{e[_>>2]=e[o>>2],e[C>>2]=e[_>>2],Hc(t,h+16|0,r,C,c,gt),yt=28;break}case 77:{e[U>>2]=e[o>>2],e[C>>2]=e[U>>2],Qc(t,h+4|0,r,C,c,gt),yt=28;break}case 116:case 110:{e[Q>>2]=e[o>>2],e[C>>2]=e[Q>>2],Kc(t,r,C,c,gt),yt=28;break}case 112:{e[K>>2]=e[o>>2],e[C>>2]=e[K>>2],Yc(t,h+8|0,r,C,c,gt),yt=28;break}case 114:{e[G>>2]=e[r>>2],e[$>>2]=e[o>>2],e[w>>2]=e[G>>2],e[C>>2]=e[$>>2],yt=wi(t,w,C,l,c,h,44884,44928)|0,e[r>>2]=yt,yt=28;break}case 82:{e[O>>2]=e[r>>2],e[Z>>2]=e[o>>2],e[w>>2]=e[O>>2],e[C>>2]=e[Z>>2],yt=wi(t,w,C,l,c,h,44928,44948)|0,e[r>>2]=yt,yt=28;break}case 83:{e[ie>>2]=e[o>>2],e[C>>2]=e[ie>>2],jc(t,h,r,C,c,gt),yt=28;break}case 84:{e[oe>>2]=e[r>>2],e[ne>>2]=e[o>>2],e[w>>2]=e[oe>>2],e[C>>2]=e[ne>>2],yt=wi(t,w,C,l,c,h,44948,44980)|0,e[r>>2]=yt,yt=28;break}case 119:{e[ce>>2]=e[o>>2],e[C>>2]=e[ce>>2],Xc(t,h+24|0,r,C,c,gt),yt=28;break}case 120:{qt=e[(e[t>>2]|0)+20>>2]|0,e[ke>>2]=e[r>>2],e[Ee>>2]=e[o>>2],e[w>>2]=e[ke>>2],e[C>>2]=e[Ee>>2],w=on[qt&63](t,w,C,l,c,h)|0;break}case 88:{qt=t+8|0,qt=Dt[e[(e[qt>>2]|0)+24>>2]&127](qt)|0,e[Te>>2]=e[r>>2],e[it>>2]=e[o>>2],d=S[qt>>0]|0,o=(d&1)==0,yt=qt+4|0,qt=o?yt:e[qt+8>>2]|0,yt=qt+((o?(d&255)>>>1:e[yt>>2]|0)<<2)|0,e[w>>2]=e[Te>>2],e[C>>2]=e[it>>2],yt=wi(t,w,C,l,c,h,qt,yt)|0,e[r>>2]=yt,yt=28;break}case 121:{e[Gt>>2]=e[o>>2],e[C>>2]=e[Gt>>2],Ns(t,h+20|0,r,C,c,gt),yt=28;break}case 89:{e[s0>>2]=e[o>>2],e[C>>2]=e[s0>>2],Zc(t,h+20|0,r,C,c,gt),yt=28;break}case 37:{e[i0>>2]=e[o>>2],e[C>>2]=e[i0>>2],Jc(t,r,C,c,gt),yt=28;break}default:e[c>>2]=e[c>>2]|4,yt=28}while(!1);return(yt|0)==28&&(w=e[r>>2]|0),b=Oe,w|0}function zc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=hi(o,t,c,h,2)|0,o=e[c>>2]|0,(t+-1|0)>>>0<31&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function Gc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=hi(o,t,c,h,2)|0,o=e[c>>2]|0,(t|0)<24&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function qc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=hi(o,t,c,h,2)|0,o=e[c>>2]|0,(t+-1|0)>>>0<12&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function Wc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=hi(o,t,c,h,3)|0,o=e[c>>2]|0,(t|0)<366&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function Hc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=hi(o,t,c,h,2)|0,o=e[c>>2]|0,(t|0)<13&(o&4|0)==0?e[r>>2]=t+-1:e[c>>2]=o|4,b=d}function Qc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=hi(o,t,c,h,2)|0,o=e[c>>2]|0,(t|0)<60&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function Kc(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0;e:for(;;){t=e[r>>2]|0;do if(t)if(h=e[t+12>>2]|0,(h|0)==(e[t+16>>2]|0)?t=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0:t=e[h>>2]|0,(t|0)==-1){e[r>>2]=0,d=1;break}else{d=(e[r>>2]|0)==0;break}else d=1;while(!1);h=e[o>>2]|0;do if(h)if(t=e[h+12>>2]|0,(t|0)==(e[h+16>>2]|0)?t=Dt[e[(e[h>>2]|0)+36>>2]&127](h)|0:t=e[t>>2]|0,(t|0)!=-1)if(d){d=h;break}else{d=h;break e}else{e[o>>2]=0,w=15;break}else w=15;while(!1);if((w|0)==15)if(w=0,d){d=0;break}else d=0;if(t=e[r>>2]|0,h=e[t+12>>2]|0,(h|0)==(e[t+16>>2]|0)?t=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0:t=e[h>>2]|0,!(Yt[e[(e[c>>2]|0)+12>>2]&63](c,8192,t)|0))break;if(t=e[r>>2]|0,h=t+12|0,d=e[h>>2]|0,(d|0)==(e[t+16>>2]|0)){Dt[e[(e[t>>2]|0)+40>>2]&127](t)|0;continue}else{e[h>>2]=d+4;continue}}t=e[r>>2]|0;do if(t)if(h=e[t+12>>2]|0,(h|0)==(e[t+16>>2]|0)?t=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0:t=e[h>>2]|0,(t|0)==-1){e[r>>2]=0,h=1;break}else{h=(e[r>>2]|0)==0;break}else h=1;while(!1);do if(d)if(t=e[d+12>>2]|0,(t|0)==(e[d+16>>2]|0)?t=Dt[e[(e[d>>2]|0)+36>>2]&127](d)|0:t=e[t>>2]|0,(t|0)!=-1){if(h)break;w=39;break}else{e[o>>2]=0,w=37;break}else w=37;while(!1);(w|0)==37&&h&&(w=39),(w|0)==39&&(e[l>>2]=e[l>>2]|2)}function Yc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;k=b,b=b+16|0,w=k+4|0,C=k,D=t+8|0,D=Dt[e[(e[D>>2]|0)+8>>2]&127](D)|0,t=S[D>>0]|0,t&1?d=e[D+4>>2]|0:d=(t&255)>>>1,t=S[D+12>>0]|0,t&1?t=e[D+16>>2]|0:t=(t&255)>>>1;do if((d|0)!=(0-t|0)){if(e[C>>2]=e[l>>2],e[w>>2]=e[C>>2],t=An(o,w,D,D+24|0,h,c,0)|0,d=e[r>>2]|0,(t|0)==(D|0)&(d|0)==12){e[r>>2]=0;break}(d|0)<12&(t-D|0)==12&&(e[r>>2]=d+12)}else e[c>>2]=e[c>>2]|4;while(!1);b=k}function jc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=hi(o,t,c,h,2)|0,o=e[c>>2]|0,(t|0)<61&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function Xc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=hi(o,t,c,h,1)|0,o=e[c>>2]|0,(t|0)<7&(o&4|0)==0?e[r>>2]=t:e[c>>2]=o|4,b=d}function Zc(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;d=b,b=b+16|0,t=d+4|0,w=d,e[w>>2]=e[l>>2],e[t>>2]=e[w>>2],t=hi(o,t,c,h,4)|0,e[c>>2]&4||(e[r>>2]=t+-1900),b=d}function Jc(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0;t=e[r>>2]|0;do if(t)if(h=e[t+12>>2]|0,(h|0)==(e[t+16>>2]|0)?t=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0:t=e[h>>2]|0,(t|0)==-1){e[r>>2]=0,d=1;break}else{d=(e[r>>2]|0)==0;break}else d=1;while(!1);h=e[o>>2]|0;do if(h)if(t=e[h+12>>2]|0,(t|0)==(e[h+16>>2]|0)?t=Dt[e[(e[h>>2]|0)+36>>2]&127](h)|0:t=e[t>>2]|0,(t|0)!=-1)if(d){w=h,C=17;break}else{C=16;break}else{e[o>>2]=0,C=14;break}else C=14;while(!1);(C|0)==14&&(d?C=16:(w=0,C=17));e:do if((C|0)==16)e[l>>2]=e[l>>2]|6;else if((C|0)==17){if(t=e[r>>2]|0,h=e[t+12>>2]|0,(h|0)==(e[t+16>>2]|0)?t=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0:t=e[h>>2]|0,(Yt[e[(e[c>>2]|0)+52>>2]&63](c,t,0)|0)<<24>>24!=37){e[l>>2]=e[l>>2]|4;break}t=e[r>>2]|0,h=t+12|0,d=e[h>>2]|0,(d|0)==(e[t+16>>2]|0)?(Dt[e[(e[t>>2]|0)+40>>2]&127](t)|0,t=e[r>>2]|0,t?C=25:h=1):(e[h>>2]=d+4,C=25);do if((C|0)==25)if(h=e[t+12>>2]|0,(h|0)==(e[t+16>>2]|0)?t=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0:t=e[h>>2]|0,(t|0)==-1){e[r>>2]=0,h=1;break}else{h=(e[r>>2]|0)==0;break}while(!1);do if(w)if(t=e[w+12>>2]|0,(t|0)==(e[w+16>>2]|0)?t=Dt[e[(e[w>>2]|0)+36>>2]&127](w)|0:t=e[t>>2]|0,(t|0)!=-1){if(h)break e;break}else{e[o>>2]=0,C=37;break}else C=37;while(!1);if((C|0)==37&&!h)break;e[l>>2]=e[l>>2]|2}while(!1)}function ef(t){t=t|0,cn(t+8|0)}function cn(t){t=t|0;var r=0,o=0,l=0;r=e[t>>2]|0,g=0,o=Ce(3)|0,l=g,g=0;do if(!(l&1)){if((r|0)!=(o|0)&&(g=0,ue(188,e[t>>2]|0),l=g,g=0,l&1))break;return}while(!1);l=j(0)|0,$t(l)}function tf(t){t=t|0,cn(t+8|0),he(t)}function nf(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0;if(C=b,b=b+112|0,w=C+4|0,o=C,e[o>>2]=w+100,Fs(t+8|0,w,o,c,h,d),c=e[o>>2]|0,o=e[r>>2]|0,(w|0)!=(c|0))do{d=S[w>>0]|0;do if(o)if(l=o+24|0,h=e[l>>2]|0,(h|0)==(e[o+28>>2]|0)){r=(U0[e[(e[o>>2]|0)+52>>2]&63](o,d&255)|0)==-1,o=r?0:o;break}else{e[l>>2]=h+1,S[h>>0]=d;break}else o=0;while(!1);w=w+1|0}while((w|0)!=(c|0));return b=C,o|0}function Fs(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0;D=b,b=b+16|0,C=D,S[C>>0]=37,d=C+1|0,S[d>>0]=c,w=C+2|0,S[w>>0]=h,S[C+3>>0]=0,h<<24>>24&&(S[d>>0]=h,S[w>>0]=c),t=r+(Go(r|0,(e[o>>2]|0)-r|0,C|0,l|0,e[t>>2]|0)|0)|0,e[o>>2]=t,b=D}function rf(t){t=t|0,cn(t+8|0)}function sf(t){t=t|0,cn(t+8|0),he(t)}function of(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0;if(w=b,b=b+416|0,l=w+8|0,o=w,e[o>>2]=l+400,af(t+8|0,l,o,c,h,d),t=e[o>>2]|0,o=e[r>>2]|0,(l|0)!=(t|0)){c=l;do l=e[c>>2]|0,o?(h=o+24|0,d=e[h>>2]|0,(d|0)==(e[o+28>>2]|0)?l=U0[e[(e[o>>2]|0)+52>>2]&63](o,l)|0:(e[h>>2]=d+4,e[d>>2]=l),o=(l|0)==-1?0:o):o=0,c=c+4|0;while((c|0)!=(t|0))}return b=w,o|0}function af(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;if(d=b,b=b+128|0,D=d+16|0,k=d+12|0,w=d,C=d+8|0,e[k>>2]=D+100,Fs(t,D,k,l,c,h),c=w,e[c>>2]=0,e[c+4>>2]=0,e[C>>2]=D,c=(e[o>>2]|0)-r>>2,h=ai(e[t>>2]|0)|0,g=0,c=Pe(18,r|0,C|0,c|0,w|0)|0,t=g,g=0,t&1&&(c=j()|0,h|0&&(g=0,ge(75,h|0)|0,k=g,g=0,k&1)&&(k=j(0)|0,$t(k)),le(c|0)),h|0&&(g=0,ge(75,h|0)|0,k=g,g=0,k&1)&&(k=j(0)|0,$t(k)),(c|0)==-1)fn(58955);else{e[o>>2]=r+(c<<2),b=d;return}}function lf(t){t=t|0}function uf(t){t=t|0,he(t)}function cf(t){return t=t|0,127}function ff(t){return t=t|0,127}function hf(t,r){t=t|0,r=r|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function df(t,r){t=t|0,r=r|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function pf(t,r){t=t|0,r=r|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function mf(t,r){t=t|0,r=r|0,dr(t,1,45)}function gf(t){return t=t|0,0}function Sf(t,r){t=t|0,r=r|0,S[t>>0]=2,S[t+1>>0]=3,S[t+2>>0]=0,S[t+3>>0]=4}function Af(t,r){t=t|0,r=r|0,S[t>>0]=2,S[t+1>>0]=3,S[t+2>>0]=0,S[t+3>>0]=4}function vf(t){t=t|0}function xf(t){t=t|0,he(t)}function wf(t){return t=t|0,127}function yf(t){return t=t|0,127}function Cf(t,r){t=t|0,r=r|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function Tf(t,r){t=t|0,r=r|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function If(t,r){t=t|0,r=r|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function Ef(t,r){t=t|0,r=r|0,dr(t,1,45)}function kf(t){return t=t|0,0}function Df(t,r){t=t|0,r=r|0,S[t>>0]=2,S[t+1>>0]=3,S[t+2>>0]=0,S[t+3>>0]=4}function bf(t,r){t=t|0,r=r|0,S[t>>0]=2,S[t+1>>0]=3,S[t+2>>0]=0,S[t+3>>0]=4}function Nf(t){t=t|0}function Ff(t){t=t|0,he(t)}function Rf(t){return t=t|0,2147483647}function Mf(t){return t=t|0,2147483647}function _f(t,r){t=t|0,r=r|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function Pf(t,r){t=t|0,r=r|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function Lf(t,r){t=t|0,r=r|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function Of(t,r){t=t|0,r=r|0,gr(t,1,45)}function $f(t){return t=t|0,0}function Bf(t,r){t=t|0,r=r|0,S[t>>0]=2,S[t+1>>0]=3,S[t+2>>0]=0,S[t+3>>0]=4}function Vf(t,r){t=t|0,r=r|0,S[t>>0]=2,S[t+1>>0]=3,S[t+2>>0]=0,S[t+3>>0]=4}function Uf(t){t=t|0}function zf(t){t=t|0,he(t)}function Gf(t){return t=t|0,2147483647}function qf(t){return t=t|0,2147483647}function Wf(t,r){t=t|0,r=r|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function Hf(t,r){t=t|0,r=r|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function Qf(t,r){t=t|0,r=r|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function Kf(t,r){t=t|0,r=r|0,gr(t,1,45)}function Yf(t){return t=t|0,0}function jf(t,r){t=t|0,r=r|0,S[t>>0]=2,S[t+1>>0]=3,S[t+2>>0]=0,S[t+3>>0]=4}function Xf(t,r){t=t|0,r=r|0,S[t>>0]=2,S[t+1>>0]=3,S[t+2>>0]=0,S[t+3>>0]=4}function Zf(t){t=t|0}function Jf(t){t=t|0,he(t)}function eh(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0;if(oe=b,b=b+240|0,Z=oe+24|0,ie=oe,t=oe+136|0,ce=oe+16|0,O=oe+12|0,ne=oe+8|0,N=oe+134|0,C=oe+4|0,P=oe+124|0,e[ce>>2]=t,ke=ce+4|0,e[ke>>2]=189,D=t+100|0,g=0,w=ge(68,c|0)|0,$=g,g=0,$&1)C=j()|0,e[ce>>2]=0,w=189,Te=45;else{e[ne>>2]=w,g=0,t=be(37,ne|0,44220)|0,$=g,g=0;e:do if(!($&1)&&(S[N>>0]=0,e[C>>2]=e[o>>2],k=e[c+4>>2]|0,g=0,e[Z>>2]=e[C>>2],k=Ut(1,r|0,Z|0,l|0,ne|0,k|0,h|0,N|0,t|0,ce|0,O|0,D|0)|0,$=g,g=0,!($&1))){t:do if(k){if(g=0,Pe(e[(e[t>>2]|0)+32>>2]|0,t|0,58976,58986,P|0)|0,$=g,g=0,$&1){Te=10;break e}C=e[O>>2]|0,D=e[ce>>2]|0,t=C-D|0,(t|0)>98?(t=E0(t+2|0)|0,w=t,t?Te=13:(g=0,Nt(6),$=g,g=0,$&1||(t=0,Te=13))):(w=0,t=Z,Te=13);do if((Te|0)==13){if(S[N>>0]|0&&(S[t>>0]=45,t=t+1|0),G=P+10|0,$=P,D>>>0>>0){k=P+1|0,l=k+1|0,c=l+1|0,N=c+1|0,R=N+1|0,_=R+1|0,U=_+1|0,Q=U+1|0,K=Q+1|0;do{C=S[D>>0]|0;do if((S[P>>0]|0)!=C<<24>>24)if((S[k>>0]|0)!=C<<24>>24)if((S[l>>0]|0)!=C<<24>>24)if((S[c>>0]|0)!=C<<24>>24)if((S[N>>0]|0)==C<<24>>24)C=N;else{if((S[R>>0]|0)==C<<24>>24){C=R;break}if((S[_>>0]|0)==C<<24>>24){C=_;break}if((S[U>>0]|0)==C<<24>>24){C=U;break}if((S[Q>>0]|0)==C<<24>>24){C=Q;break}C=(S[K>>0]|0)==C<<24>>24?K:G}else C=c;else C=l;else C=k;else C=P;while(!1);S[t>>0]=S[58976+(C-$)>>0]|0,D=D+1|0,t=t+1|0}while(D>>>0<(e[O>>2]|0)>>>0)}if(S[t>>0]=0,e[ie>>2]=d,(_o(Z,58987,ie)|0)!=1&&(g=0,ue(190,58991),d=g,g=0,d&1))break;w&&n0(w);break t}while(!1);if(t=j()|0,!w){C=t,w=ce;break e}n0(w),C=t,w=ce;break e}while(!1);t=e[r>>2]|0;do if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,t=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,d=g,g=0,d&1){Te=10;break e}if((t|0)==-1){e[r>>2]=0,t=0;break}else{t=e[r>>2]|0;break}}}else t=0;while(!1);w=(t|0)==0,t=e[o>>2]|0;do if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,t=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,d=g,g=0,d&1){Te=10;break e}if((t|0)==-1){e[o>>2]=0,Te=37;break}}w||(Te=38)}else Te=37;while(!1);return(Te|0)==37&&w&&(Te=38),(Te|0)==38&&(e[h>>2]=e[h>>2]|2),w=e[r>>2]|0,Bt(e[ne>>2]|0)|0,t=e[ce>>2]|0,e[ce>>2]=0,t|0&&(g=0,ue(e[ke>>2]|0,t|0),Te=g,g=0,Te&1)&&(Te=j(0)|0,$t(Te)),b=oe,w|0}else Te=10;while(!1);(Te|0)==10&&(C=j()|0,w=ce),Bt(e[ne>>2]|0)|0,t=e[w>>2]|0,e[w>>2]=0,t?(w=e[ke>>2]|0,Te=45):Ee=C}return(Te|0)==45&&(g=0,ue(w|0,t|0),Te=g,g=0,Te&1?(Te=j(0)|0,$t(Te)):Ee=C),le(Ee|0),0}function th(t){t=t|0}function ih(t,r,o,l,c,h,d,w,C,D,k){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0,k=k|0;var N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0,jt=0,Gt=0,s0=0,i0=0,zt=0,gt=0,Kt=0,dt=0,At=0,y0=0,T0=0,g0=0,Oe=0,yt=0,qt=0,c0=0,a0=0,h0=0,D0=0,A0=0,Ti=0,F0=0;A0=b,b=b+512|0,gt=A0+88|0,U=A0+96|0,F0=A0+80|0,y0=A0+72|0,At=A0+68|0,T0=A0+500|0,Kt=A0+497|0,g0=A0+496|0,qt=A0+56|0,D0=A0+44|0,a0=A0+32|0,c0=A0+20|0,h0=A0+8|0,dt=A0+4|0,yt=A0,e[gt>>2]=k,e[F0>>2]=U,Ti=F0+4|0,e[Ti>>2]=189,e[y0>>2]=U,e[At>>2]=U+400,e[qt>>2]=0,e[qt+4>>2]=0,e[qt+8>>2]=0,e[D0>>2]=0,e[D0+4>>2]=0,e[D0+8>>2]=0,e[a0>>2]=0,e[a0+4>>2]=0,e[a0+8>>2]=0,e[c0>>2]=0,e[c0+4>>2]=0,e[c0+8>>2]=0,e[h0>>2]=0,e[h0+4>>2]=0,e[h0+8>>2]=0,g=0,I0(1,o|0,l|0,T0|0,Kt|0,g0|0,qt|0,D0|0,a0|0,c0|0,dt|0),zt=g,g=0;e:do if(zt&1)w=j()|0;else{e[D>>2]=e[C>>2],Te=w+8|0,it=a0+4|0,jt=c0+4|0,Gt=c0+8|0,s0=c0+1|0,i0=a0+8|0,zt=a0+1|0,P=(c&512|0)!=0,O=D0+8|0,Z=D0+1|0,ie=D0+4|0,oe=h0+4|0,ne=h0+8|0,ce=h0+1|0,ke=T0+3|0,Ee=qt+4|0,$=0,_=0;t:for(;;){k=e[t>>2]|0;do if(k){if((e[k+12>>2]|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,G=g,g=0,G&1){Oe=24;break t}if((k|0)==-1){e[t>>2]=0,k=0;break}else{k=e[t>>2]|0;break}}}else k=0;while(!1);k=(k|0)==0,w=e[r>>2]|0;do if(w){if((e[w+12>>2]|0)!=(e[w+16>>2]|0))if(k){G=w;break}else{Oe=235;break t}if(g=0,o=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,G=g,g=0,G&1){Oe=24;break t}if((o|0)!=-1)if(k){G=w;break}else{Oe=235;break t}else{e[r>>2]=0,Oe=15;break}}else Oe=15;while(!1);if((Oe|0)==15)if(Oe=0,k){Oe=235;break}else G=0;i:do switch(S[T0+$>>0]|0){case 1:{if(($|0)!=3){if(k=e[t>>2]|0,w=e[k+12>>2]|0,(w|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,Oe=g,g=0,Oe&1){Oe=24;break t}}else k=F[w>>0]|0;if((k&255)<<24>>24<=-1){Oe=40;break t}if(!(E[(e[Te>>2]|0)+(k<<24>>24<<1)>>1]&8192)){Oe=40;break t}if(k=e[t>>2]|0,w=k+12|0,o=e[w>>2]|0,(o|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+40>>2]|0,k|0)|0,Oe=g,g=0,Oe&1){Oe=24;break t}}else e[w>>2]=o+1,k=F[o>>0]|0;if(g=0,Ae(67,h0|0,k&255|0),Oe=g,g=0,Oe&1){Oe=24;break t}else k=G,l=G,Oe=42}break}case 0:{($|0)!=3&&(k=G,l=G,Oe=42);break}case 3:{if(w=S[a0>>0]|0,k=w&1?e[it>>2]|0:(w&255)>>>1,o=S[c0>>0]|0,l=o&1?e[jt>>2]|0:(o&255)>>>1,(k|0)!=(0-l|0)){if(!k){if(k=e[t>>2]|0,w=e[k+12>>2]|0,(w|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,G=g,g=0,G&1){Oe=24;break t}w=S[c0>>0]|0}else k=F[w>>0]|0,w=o;if((k&255)<<24>>24!=(S[(w&1?e[Gt>>2]|0:s0)>>0]|0))break i;if(k=e[t>>2]|0,w=k+12|0,o=e[w>>2]|0,(o|0)==(e[k+16>>2]|0)){if(g=0,ge(e[(e[k>>2]|0)+40>>2]|0,k|0)|0,G=g,g=0,G&1){Oe=24;break t}}else e[w>>2]=o+1;S[d>>0]=1,G=S[c0>>0]|0,_=(G&1?e[jt>>2]|0:(G&255)>>>1)>>>0>1?c0:_;break i}if(c=e[t>>2]|0,N=e[c+12>>2]|0,o=e[c+16>>2]|0,k=(N|0)==(o|0),!l){if(k){if(g=0,k=ge(e[(e[c>>2]|0)+36>>2]|0,c|0)|0,G=g,g=0,G&1){Oe=24;break t}w=S[a0>>0]|0}else k=F[N>>0]|0;if((k&255)<<24>>24!=(S[(w&1?e[i0>>2]|0:zt)>>0]|0)){S[d>>0]=1;break i}if(k=e[t>>2]|0,w=k+12|0,o=e[w>>2]|0,(o|0)==(e[k+16>>2]|0)){if(g=0,ge(e[(e[k>>2]|0)+40>>2]|0,k|0)|0,G=g,g=0,G&1){Oe=24;break t}}else e[w>>2]=o+1;G=S[a0>>0]|0,_=(G&1?e[it>>2]|0:(G&255)>>>1)>>>0>1?a0:_;break i}if(k){if(g=0,k=ge(e[(e[c>>2]|0)+36>>2]|0,c|0)|0,G=g,g=0,G&1){Oe=24;break t}o=e[t>>2]|0,w=S[a0>>0]|0,c=o,N=e[o+12>>2]|0,o=e[o+16>>2]|0}else k=F[N>>0]|0;if(l=c+12|0,o=(N|0)==(o|0),(k&255)<<24>>24==(S[(w&1?e[i0>>2]|0:zt)>>0]|0)){if(o){if(g=0,ge(e[(e[c>>2]|0)+40>>2]|0,c|0)|0,G=g,g=0,G&1){Oe=24;break t}}else e[l>>2]=N+1;G=S[a0>>0]|0,_=(G&1?e[it>>2]|0:(G&255)>>>1)>>>0>1?a0:_;break i}if(o){if(g=0,k=ge(e[(e[c>>2]|0)+36>>2]|0,c|0)|0,G=g,g=0,G&1){Oe=24;break t}}else k=F[N>>0]|0;if((k&255)<<24>>24!=(S[(S[c0>>0]&1?e[Gt>>2]|0:s0)>>0]|0)){Oe=104;break t}if(k=e[t>>2]|0,w=k+12|0,o=e[w>>2]|0,(o|0)==(e[k+16>>2]|0)){if(g=0,ge(e[(e[k>>2]|0)+40>>2]|0,k|0)|0,G=g,g=0,G&1){Oe=24;break t}}else e[w>>2]=o+1;S[d>>0]=1,G=S[c0>>0]|0,_=(G&1?e[jt>>2]|0:(G&255)>>>1)>>>0>1?c0:_}break}case 2:{if(!($>>>0<2|(_|0)!=0)&&!(P|($|0)==2&(S[ke>>0]|0)!=0)){_=0;break i}Q=S[D0>>0]|0,k=(Q&1)==0,K=e[O>>2]|0,o=k?Z:K,R=o;n:do if($|0&&(F[T0+($+-1)>>0]|0)<2){N=k?(Q&255)>>>1:e[ie>>2]|0,l=o+N|0,c=e[Te>>2]|0;r:do if(!N)w=R;else{N=o,w=R;do{if(k=S[N>>0]|0,k<<24>>24<=-1||!(E[c+(k<<24>>24<<1)>>1]&8192))break r;N=N+1|0,w=N}while((N|0)!=(l|0))}while(!1);if(l=w-R|0,c=S[h0>>0]|0,k=(c&1)==0,c=k?(c&255)>>>1:e[oe>>2]|0,c>>>0>=l>>>0){if(k=k?ce:e[ne>>2]|0,N=k+c|0,(w|0)!=(R|0))for(k=k+(c-l)|0;;){if((S[k>>0]|0)!=(S[o>>0]|0)){w=R;break n}if(k=k+1|0,(k|0)==(N|0))break;o=o+1|0}}else w=R}else w=R;while(!1);k=(Q&1)==0,k=(k?Z:K)+(k?(Q&255)>>>1:e[ie>>2]|0)|0;n:do if((w|0)!=(k|0))for(c=G,l=G,k=w;;){w=e[t>>2]|0;do if(w){if((e[w+12>>2]|0)==(e[w+16>>2]|0)){if(g=0,w=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,G=g,g=0,G&1){Oe=21;break t}if((w|0)==-1){e[t>>2]=0,w=0;break}else{w=e[t>>2]|0;break}}}else w=0;while(!1);o=(w|0)==0;do if(l){if((e[l+12>>2]|0)!=(e[l+16>>2]|0))if(o){w=c,N=l;break}else break n;if(g=0,w=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,G=g,g=0,G&1){Oe=21;break t}if((w|0)!=-1)if(o^(c|0)==0){w=c,N=c;break}else break n;else{e[r>>2]=0,w=0,Oe=131;break}}else w=c,Oe=131;while(!1);if((Oe|0)==131){if(Oe=0,o)break n;N=0}if(o=e[t>>2]|0,l=e[o+12>>2]|0,(l|0)==(e[o+16>>2]|0)){if(g=0,o=ge(e[(e[o>>2]|0)+36>>2]|0,o|0)|0,G=g,g=0,G&1){Oe=21;break t}}else o=F[l>>0]|0;if((o&255)<<24>>24!=(S[k>>0]|0))break n;if(o=e[t>>2]|0,l=o+12|0,c=e[l>>2]|0,(c|0)==(e[o+16>>2]|0)){if(g=0,ge(e[(e[o>>2]|0)+40>>2]|0,o|0)|0,G=g,g=0,G&1){Oe=21;break t}}else e[l>>2]=c+1;if(k=k+1|0,o=S[D0>>0]|0,G=(o&1)==0,o=(G?Z:e[O>>2]|0)+(G?(o&255)>>>1:e[ie>>2]|0)|0,(k|0)==(o|0)){k=o;break}else c=w,l=N}while(!1);if(P&&(G=S[D0>>0]|0,K=(G&1)==0,(k|0)!=((K?Z:e[O>>2]|0)+(K?(G&255)>>>1:e[ie>>2]|0)|0))){Oe=143;break t}break}case 4:{R=S[g0>>0]|0,w=G,c=G,k=0;n:for(;;){o=e[t>>2]|0;do if(o){if((e[o+12>>2]|0)==(e[o+16>>2]|0)){if(g=0,o=ge(e[(e[o>>2]|0)+36>>2]|0,o|0)|0,G=g,g=0,G&1){Oe=23;break t}if((o|0)==-1){e[t>>2]=0,o=0;break}else{o=e[t>>2]|0;break}}}else o=0;while(!1);l=(o|0)==0;do if(c){if((e[c+12>>2]|0)!=(e[c+16>>2]|0))if(l){N=w;break}else{l=w;break n}if(g=0,o=ge(e[(e[c>>2]|0)+36>>2]|0,c|0)|0,G=g,g=0,G&1){Oe=23;break t}if((o|0)!=-1)if(l^(w|0)==0){N=w,c=w;break}else{l=w;break n}else{e[r>>2]=0,w=0,Oe=156;break}}else Oe=156;while(!1);if((Oe|0)==156)if(Oe=0,l){l=w;break}else N=w,c=0;if(w=e[t>>2]|0,o=e[w+12>>2]|0,(o|0)==(e[w+16>>2]|0)){if(g=0,w=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,G=g,g=0,G&1){Oe=23;break t}}else w=F[o>>0]|0;if(o=w&255,o<<24>>24>-1&&E[(e[Te>>2]|0)+(w<<24>>24<<1)>>1]&2048){if(w=e[D>>2]|0,(w|0)==(e[gt>>2]|0)){if(g=0,xe(12,C|0,D|0,gt|0),G=g,g=0,G&1){Oe=23;break t}w=e[D>>2]|0}e[D>>2]=w+1,S[w>>0]=o,k=k+1|0}else{if(G=S[qt>>0]|0,!(o<<24>>24==R<<24>>24&(k|0?((G&1?e[Ee>>2]|0:(G&255)>>>1)|0)!=0:0))){l=N;break}if((U|0)==(e[At>>2]|0)){if(g=0,xe(13,F0|0,y0|0,At|0),G=g,g=0,G&1){Oe=23;break t}U=e[y0>>2]|0}G=U+4|0,e[y0>>2]=G,e[U>>2]=k,U=G,k=0}if(w=e[t>>2]|0,o=w+12|0,l=e[o>>2]|0,(l|0)==(e[w+16>>2]|0))if(g=0,ge(e[(e[w>>2]|0)+40>>2]|0,w|0)|0,G=g,g=0,G&1){Oe=23;break t}else{w=N;continue}else{e[o>>2]=l+1,w=N;continue}}if(k|0&&(e[F0>>2]|0)!=(U|0)){if((U|0)==(e[At>>2]|0)){if(g=0,xe(13,F0|0,y0|0,At|0),G=g,g=0,G&1){Oe=24;break t}U=e[y0>>2]|0}G=U+4|0,e[y0>>2]=G,e[U>>2]=k,U=G}if(N=e[dt>>2]|0,(N|0)>0){k=e[t>>2]|0;do if(k){if((e[k+12>>2]|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,G=g,g=0,G&1){Oe=24;break t}if((k|0)==-1){e[t>>2]=0,k=0;break}else{k=e[t>>2]|0;break}}}else k=0;while(!1);k=(k|0)==0;do if(l){if((e[l+12>>2]|0)==(e[l+16>>2]|0)){if(g=0,w=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,G=g,g=0,G&1){Oe=24;break t}if((w|0)==-1){e[r>>2]=0,Oe=193;break}}if(!k){Oe=198;break t}}else Oe=193;while(!1);if((Oe|0)==193)if(Oe=0,k){Oe=198;break t}else l=0;if(k=e[t>>2]|0,w=e[k+12>>2]|0,(w|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,G=g,g=0,G&1){Oe=24;break t}}else k=F[w>>0]|0;if((k&255)<<24>>24!=(S[Kt>>0]|0)){Oe=198;break t}if(k=e[t>>2]|0,w=k+12|0,o=e[w>>2]|0,(o|0)==(e[k+16>>2]|0)){if(g=0,ge(e[(e[k>>2]|0)+40>>2]|0,k|0)|0,G=g,g=0,G&1){Oe=24;break t}}else e[w>>2]=o+1;if((N|0)>0)for(c=l,o=l,R=N;;){k=e[t>>2]|0;do if(k){if((e[k+12>>2]|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,G=g,g=0,G&1){Oe=22;break t}if((k|0)==-1){e[t>>2]=0,k=0;break}else{k=e[t>>2]|0;break}}}else k=0;while(!1);w=(k|0)==0;do if(o){if((e[o+12>>2]|0)!=(e[o+16>>2]|0))if(w){k=c,N=o;break}else{Oe=222;break t}if(g=0,k=ge(e[(e[o>>2]|0)+36>>2]|0,o|0)|0,G=g,g=0,G&1){Oe=22;break t}if((k|0)!=-1)if(w^(c|0)==0){k=c,N=c;break}else{Oe=222;break t}else{e[r>>2]=0,k=0,Oe=215;break}}else k=c,Oe=215;while(!1);if((Oe|0)==215)if(Oe=0,w){Oe=222;break t}else N=0;if(w=e[t>>2]|0,o=e[w+12>>2]|0,(o|0)==(e[w+16>>2]|0)){if(g=0,w=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,G=g,g=0,G&1){Oe=22;break t}}else w=F[o>>0]|0;if((w&255)<<24>>24<=-1){Oe=222;break t}if(!(E[(e[Te>>2]|0)+(w<<24>>24<<1)>>1]&2048)){Oe=222;break t}if((e[D>>2]|0)==(e[gt>>2]|0)&&(g=0,xe(12,C|0,D|0,gt|0),G=g,g=0,G&1)){Oe=22;break t}if(w=e[t>>2]|0,o=e[w+12>>2]|0,(o|0)==(e[w+16>>2]|0)){if(g=0,w=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,G=g,g=0,G&1){Oe=22;break t}}else w=F[o>>0]|0;if(o=e[D>>2]|0,e[D>>2]=o+1,S[o>>0]=w,w=R,R=R+-1|0,e[dt>>2]=R,o=e[t>>2]|0,l=o+12|0,c=e[l>>2]|0,(c|0)==(e[o+16>>2]|0)){if(g=0,ge(e[(e[o>>2]|0)+40>>2]|0,o|0)|0,G=g,g=0,G&1){Oe=22;break t}}else e[l>>2]=c+1;if((w|0)<=1)break;c=k,o=N}}if((e[D>>2]|0)==(e[C>>2]|0)){Oe=233;break t}break}default:}while(!1);i:do if((Oe|0)==42)for(;;){Oe=0,w=e[t>>2]|0;do if(w){if((e[w+12>>2]|0)==(e[w+16>>2]|0)){if(g=0,w=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,G=g,g=0,G&1){Oe=20;break t}if((w|0)==-1){e[t>>2]=0,w=0;break}else{w=e[t>>2]|0;break}}}else w=0;while(!1);o=(w|0)==0;do if(l){if((e[l+12>>2]|0)!=(e[l+16>>2]|0))if(o){c=k;break}else break i;if(g=0,w=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,G=g,g=0,G&1){Oe=20;break t}if((w|0)!=-1)if(o^(k|0)==0){c=k,l=k;break}else break i;else{e[r>>2]=0,k=0,Oe=54;break}}else Oe=54;while(!1);if((Oe|0)==54){if(Oe=0,o)break i;c=k,l=0}if(k=e[t>>2]|0,w=e[k+12>>2]|0,(w|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,G=g,g=0,G&1){Oe=20;break t}}else k=F[w>>0]|0;if((k&255)<<24>>24<=-1||!(E[(e[Te>>2]|0)+(k<<24>>24<<1)>>1]&8192))break i;if(k=e[t>>2]|0,w=k+12|0,o=e[w>>2]|0,(o|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+40>>2]|0,k|0)|0,Oe=g,g=0,Oe&1){Oe=20;break t}}else e[w>>2]=o+1,k=F[o>>0]|0;if(g=0,Ae(67,h0|0,k&255|0),Oe=g,g=0,Oe&1){Oe=20;break t}else k=c,Oe=42}while(!1);if($=$+1|0,$>>>0>=4){Oe=235;break}}t:switch(Oe|0){case 20:{w=j()|0;break e}case 21:{w=j()|0;break e}case 22:{w=j()|0;break e}case 23:{w=j()|0;break e}case 24:{w=j()|0;break e}case 40:{e[h>>2]=e[h>>2]|4,w=0;break}case 104:{e[h>>2]=e[h>>2]|4,w=0;break}case 143:{e[h>>2]=e[h>>2]|4,w=0;break}case 198:{e[h>>2]=e[h>>2]|4,w=0;break}case 222:{e[h>>2]=e[h>>2]|4,w=0;break}case 233:{e[h>>2]=e[h>>2]|4,w=0;break}case 235:{i:do if(_){c=_+1|0,N=_+8|0,R=_+4|0,o=1;n:for(;;){if(k=S[_>>0]|0,k&1?k=e[R>>2]|0:k=(k&255)>>>1,o>>>0>=k>>>0)break i;k=e[t>>2]|0;do if(k){if((e[k+12>>2]|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,D=g,g=0,D&1){Oe=19;break n}if((k|0)==-1){e[t>>2]=0,k=0;break}else{k=e[t>>2]|0;break}}}else k=0;while(!1);w=(k|0)==0,k=e[r>>2]|0;do if(k){if((e[k+12>>2]|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,D=g,g=0,D&1){Oe=19;break n}if((k|0)==-1){e[r>>2]=0,Oe=253;break}}if(!w){Oe=260;break n}}else Oe=253;while(!1);if((Oe|0)==253&&(Oe=0,w)){Oe=260;break}if(k=e[t>>2]|0,w=e[k+12>>2]|0,(w|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,D=g,g=0,D&1){Oe=19;break}}else k=F[w>>0]|0;if(S[_>>0]&1?w=e[N>>2]|0:w=c,(k&255)<<24>>24!=(S[w+o>>0]|0)){Oe=260;break}if(k=o+1|0,w=e[t>>2]|0,o=w+12|0,l=e[o>>2]|0,(l|0)==(e[w+16>>2]|0))if(g=0,ge(e[(e[w>>2]|0)+40>>2]|0,w|0)|0,D=g,g=0,D&1){Oe=19;break}else{o=k;continue}else{e[o>>2]=l+1,o=k;continue}}if((Oe|0)==19){w=j()|0;break e}else if((Oe|0)==260){e[h>>2]=e[h>>2]|4,w=0;break t}}while(!1);k=e[F0>>2]|0,(k|0)!=(U|0)&&(e[yt>>2]=0,V0(qt,k,U,yt),(e[yt>>2]|0)!=0)?(e[h>>2]=e[h>>2]|4,w=0):w=1;break}}return de(h0),de(c0),de(a0),de(D0),de(qt),k=e[F0>>2]|0,e[F0>>2]=0,k|0&&(g=0,ue(e[Ti>>2]|0,k|0),F0=g,g=0,F0&1)&&(F0=j(0)|0,$t(F0)),b=A0,w|0}while(!1);return de(h0),de(c0),de(a0),de(D0),de(qt),k=e[F0>>2]|0,e[F0>>2]=0,k|0&&(g=0,ue(e[Ti>>2]|0,k|0),F0=g,g=0,F0&1)&&(F0=j(0)|0,$t(F0)),le(w|0),0}function fn(t){t=t|0;var r=0;r=Ct(8)|0,g=0,Ae(90,r|0,t|0),t=g,g=0,t&1?(t=j()|0,Tt(r|0),le(t|0)):Qt(r|0,616,80)}function nh(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0;if($=b,b=b+144|0,w=$+24|0,t=$+32|0,P=$+16|0,U=$+8|0,N=$+4|0,R=$+28|0,C=$,e[P>>2]=t,ie=P+4|0,e[ie>>2]=189,D=t+100|0,g=0,G=ge(68,c|0)|0,k=g,g=0,k&1)w=j()|0,e[P>>2]=0,Z=36;else{e[N>>2]=G,g=0,k=be(37,N|0,44220)|0,t=g,g=0;e:do if(!(t&1)&&(S[R>>0]=0,Q=e[o>>2]|0,e[C>>2]=Q,_=e[c+4>>2]|0,K=Q,g=0,e[w>>2]=e[C>>2],_=Ut(1,r|0,w|0,l|0,N|0,_|0,h|0,R|0,k|0,P|0,U|0,D|0)|0,c=g,g=0,!(c&1))){if(_){if(S[d>>0]&1?(S[e[d+8>>2]>>0]=0,e[d+4>>2]=0):(S[d+1>>0]=0,S[d>>0]=0),S[R>>0]|0&&(g=0,t=be(e[(e[k>>2]|0)+28>>2]|0,k|0,45)|0,c=g,g=0,c&1||(g=0,Ae(67,d|0,t|0),c=g,g=0,c&1))||(g=0,C=be(e[(e[k>>2]|0)+28>>2]|0,k|0,48)|0,c=g,g=0,c&1))break;t=e[P>>2]|0,D=e[U>>2]|0,w=D+-1|0;t:do if(t>>>0>>0)do{if((S[t>>0]|0)!=C<<24>>24)break t;t=t+1|0}while(t>>>0>>0);while(!1);if(g=0,Ve(32,d|0,t|0,D|0)|0,d=g,g=0,d&1)break}t=e[r>>2]|0;do if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,t=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,d=g,g=0,d&1)break e;if((t|0)==-1){e[r>>2]=0,t=0;break}else{t=e[r>>2]|0;break}}}else t=0;while(!1);w=(t|0)==0;do if(Q){if((e[K+12>>2]|0)==(e[K+16>>2]|0)){if(g=0,t=ge(e[(e[Q>>2]|0)+36>>2]|0,K|0)|0,K=g,g=0,K&1)break e;if((t|0)==-1){e[o>>2]=0,Z=29;break}}w||(Z=30)}else Z=29;while(!1);return(Z|0)==29&&w&&(Z=30),(Z|0)==30&&(e[h>>2]=e[h>>2]|2),w=e[r>>2]|0,Bt(G)|0,t=e[P>>2]|0,e[P>>2]=0,t|0&&(g=0,ue(e[ie>>2]|0,t|0),ie=g,g=0,ie&1)&&(ie=j(0)|0,$t(ie)),b=$,w|0}while(!1);w=j()|0,Bt(G)|0,t=e[P>>2]|0,e[P>>2]=0,t?Z=36:O=w}return(Z|0)==36&&(g=0,ue(e[ie>>2]|0,t|0),ie=g,g=0,ie&1?(ie=j(0)|0,$t(ie)):O=w),le(O|0),0}function rh(t,r,o,l,c,h,d,w,C,D){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0;var k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0;Z=b,b=b+112|0,k=Z+100|0,N=Z+88|0,R=Z+76|0,_=Z+64|0,U=Z+52|0,Q=Z+48|0,K=Z+36|0,G=Z+24|0,$=Z+12|0,P=Z;do if(t)if(t=O0(r,43828)|0,t0[e[(e[t>>2]|0)+44>>2]&127](k,t),P=e[k>>2]|0,S[o>>0]=P,S[o+1>>0]=P>>8,S[o+2>>0]=P>>16,S[o+3>>0]=P>>24,t0[e[(e[t>>2]|0)+32>>2]&127](N,t),S[C>>0]&1?(S[e[C+8>>2]>>0]=0,e[C+4>>2]=0):(S[C+1>>0]=0,S[C>>0]=0),g=0,Ae(91,C|0,0),o=g,g=0,o&1&&(o=j(0)|0,$t(o)),e[C>>2]=e[N>>2],e[C+4>>2]=e[N+4>>2],e[C+8>>2]=e[N+8>>2],e[N>>2]=0,e[N+4>>2]=0,e[N+8>>2]=0,de(N),t0[e[(e[t>>2]|0)+28>>2]&127](R,t),S[w>>0]&1?(S[e[w+8>>2]>>0]=0,e[w+4>>2]=0):(S[w+1>>0]=0,S[w>>0]=0),g=0,Ae(91,w|0,0),o=g,g=0,o&1&&(o=j(0)|0,$t(o)),e[w>>2]=e[R>>2],e[w+4>>2]=e[R+4>>2],e[w+8>>2]=e[R+8>>2],e[R>>2]=0,e[R+4>>2]=0,e[R+8>>2]=0,de(R),w=Dt[e[(e[t>>2]|0)+12>>2]&127](t)|0,S[l>>0]=w,w=Dt[e[(e[t>>2]|0)+16>>2]&127](t)|0,S[c>>0]=w,t0[e[(e[t>>2]|0)+20>>2]&127](_,t),S[h>>0]&1?(S[e[h+8>>2]>>0]=0,e[h+4>>2]=0):(S[h+1>>0]=0,S[h>>0]=0),g=0,Ae(91,h|0,0),c=g,g=0,c&1&&(c=j(0)|0,$t(c)),e[h>>2]=e[_>>2],e[h+4>>2]=e[_+4>>2],e[h+8>>2]=e[_+8>>2],e[_>>2]=0,e[_+4>>2]=0,e[_+8>>2]=0,de(_),t0[e[(e[t>>2]|0)+24>>2]&127](U,t),S[d>>0]&1?(S[e[d+8>>2]>>0]=0,e[d+4>>2]=0):(S[d+1>>0]=0,S[d>>0]=0),g=0,Ae(91,d|0,0),c=g,g=0,c&1)c=j(0)|0,$t(c);else{e[d>>2]=e[U>>2],e[d+4>>2]=e[U+4>>2],e[d+8>>2]=e[U+8>>2],e[U>>2]=0,e[U+4>>2]=0,e[U+8>>2]=0,de(U),O=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0;break}else if(t=O0(r,43764)|0,t0[e[(e[t>>2]|0)+44>>2]&127](Q,t),Q=e[Q>>2]|0,S[o>>0]=Q,S[o+1>>0]=Q>>8,S[o+2>>0]=Q>>16,S[o+3>>0]=Q>>24,t0[e[(e[t>>2]|0)+32>>2]&127](K,t),S[C>>0]&1?(S[e[C+8>>2]>>0]=0,e[C+4>>2]=0):(S[C+1>>0]=0,S[C>>0]=0),g=0,Ae(91,C|0,0),o=g,g=0,o&1&&(o=j(0)|0,$t(o)),e[C>>2]=e[K>>2],e[C+4>>2]=e[K+4>>2],e[C+8>>2]=e[K+8>>2],e[K>>2]=0,e[K+4>>2]=0,e[K+8>>2]=0,de(K),t0[e[(e[t>>2]|0)+28>>2]&127](G,t),S[w>>0]&1?(S[e[w+8>>2]>>0]=0,e[w+4>>2]=0):(S[w+1>>0]=0,S[w>>0]=0),g=0,Ae(91,w|0,0),o=g,g=0,o&1&&(o=j(0)|0,$t(o)),e[w>>2]=e[G>>2],e[w+4>>2]=e[G+4>>2],e[w+8>>2]=e[G+8>>2],e[G>>2]=0,e[G+4>>2]=0,e[G+8>>2]=0,de(G),w=Dt[e[(e[t>>2]|0)+12>>2]&127](t)|0,S[l>>0]=w,w=Dt[e[(e[t>>2]|0)+16>>2]&127](t)|0,S[c>>0]=w,t0[e[(e[t>>2]|0)+20>>2]&127]($,t),S[h>>0]&1?(S[e[h+8>>2]>>0]=0,e[h+4>>2]=0):(S[h+1>>0]=0,S[h>>0]=0),g=0,Ae(91,h|0,0),c=g,g=0,c&1&&(c=j(0)|0,$t(c)),e[h>>2]=e[$>>2],e[h+4>>2]=e[$+4>>2],e[h+8>>2]=e[$+8>>2],e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,de($),t0[e[(e[t>>2]|0)+24>>2]&127](P,t),S[d>>0]&1?(S[e[d+8>>2]>>0]=0,e[d+4>>2]=0):(S[d+1>>0]=0,S[d>>0]=0),g=0,Ae(91,d|0,0),c=g,g=0,c&1)c=j(0)|0,$t(c);else{e[d>>2]=e[P>>2],e[d+4>>2]=e[P+4>>2],e[d+8>>2]=e[P+8>>2],e[P>>2]=0,e[P+4>>2]=0,e[P+8>>2]=0,de(P),O=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0;break}while(!1);e[D>>2]=O,b=Z}function V0(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0;c=S[t>>0]|0,d=t+4|0,h=e[d>>2]|0;e:do if((c&1?h:(c&255)>>>1)|0){if((r|0)!=(o|0)){if(c=o+-4|0,c>>>0>r>>>0){h=r;do w=e[h>>2]|0,e[h>>2]=e[c>>2],e[c>>2]=w,h=h+4|0,c=c+-4|0;while(h>>>0>>0)}c=S[t>>0]|0,h=e[d>>2]|0}w=(c&1)==0,d=w?t+1|0:e[t+8>>2]|0,o=o+-4|0,t=d+(w?(c&255)>>>1:h)|0,h=S[d>>0]|0,c=h<<24>>24<1|h<<24>>24==127;t:do if(o>>>0>r>>>0){for(;!(!c&&(h<<24>>24|0)!=(e[r>>2]|0));)if(d=(t-d|0)>1?d+1|0:d,r=r+4|0,h=S[d>>0]|0,c=h<<24>>24<1|h<<24>>24==127,r>>>0>=o>>>0)break t;e[l>>2]=4;break e}while(!1);!c&&((e[o>>2]|0)+-1|0)>>>0>=h<<24>>24>>>0&&(e[l>>2]=4)}while(!1)}function sh(t){t=t|0}function oh(t){t=t|0,he(t)}function ah(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0;if(oe=b,b=b+576|0,P=oe+424|0,ie=oe,t=oe+24|0,ce=oe+16|0,O=oe+12|0,ne=oe+8|0,N=oe+464|0,C=oe+4|0,Z=oe+468|0,e[ce>>2]=t,Ee=ce+4|0,e[Ee>>2]=189,D=t+400|0,g=0,w=ge(68,c|0)|0,$=g,g=0,$&1)C=j()|0,e[ce>>2]=0,w=189,Te=47;else{e[ne>>2]=w,g=0,t=be(37,ne|0,44212)|0,$=g,g=0;e:do if(!($&1)&&(S[N>>0]=0,e[C>>2]=e[o>>2],k=e[c+4>>2]|0,g=0,e[P>>2]=e[C>>2],k=Ut(2,r|0,P|0,l|0,ne|0,k|0,h|0,N|0,t|0,ce|0,O|0,D|0)|0,$=g,g=0,!($&1))){t:do if(k){if(g=0,Pe(e[(e[t>>2]|0)+48>>2]|0,t|0,59007,59017,P|0)|0,$=g,g=0,$&1){Te=10;break e}C=e[O>>2]|0,D=e[ce>>2]|0,t=C-D|0,(t|0)>392?(t=E0((t>>2)+2|0)|0,w=t,t?Te=13:(g=0,Nt(6),$=g,g=0,$&1||(t=0,Te=13))):(w=0,t=Z,Te=13);do if((Te|0)==13){if(S[N>>0]|0&&(S[t>>0]=45,t=t+1|0),G=P+40|0,$=P,D>>>0>>0){k=P+4|0,l=k+4|0,c=l+4|0,N=c+4|0,R=N+4|0,_=R+4|0,U=_+4|0,Q=U+4|0,K=Q+4|0;do{C=e[D>>2]|0;do if((e[P>>2]|0)!=(C|0))if((e[k>>2]|0)!=(C|0))if((e[l>>2]|0)!=(C|0))if((e[c>>2]|0)!=(C|0))if((e[N>>2]|0)==(C|0))C=N;else{if((e[R>>2]|0)==(C|0)){C=R;break}if((e[_>>2]|0)==(C|0)){C=_;break}if((e[U>>2]|0)==(C|0)){C=U;break}if((e[Q>>2]|0)==(C|0)){C=Q;break}C=(e[K>>2]|0)==(C|0)?K:G}else C=c;else C=l;else C=k;else C=P;while(!1);S[t>>0]=S[59007+(C-$>>2)>>0]|0,D=D+4|0,t=t+1|0}while(D>>>0<(e[O>>2]|0)>>>0)}if(S[t>>0]=0,e[ie>>2]=d,(_o(Z,58987,ie)|0)!=1&&(g=0,ue(190,58991),d=g,g=0,d&1))break;w&&n0(w);break t}while(!1);if(t=j()|0,!w){C=t,w=ce;break e}n0(w),C=t,w=ce;break e}while(!1);t=e[r>>2]|0;do if(t){if(w=e[t+12>>2]|0,(w|0)==(e[t+16>>2]|0)){if(g=0,t=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,d=g,g=0,d&1){Te=10;break e}}else t=e[w>>2]|0;if((t|0)==-1){e[r>>2]=0,C=1;break}else{C=(e[r>>2]|0)==0;break}}else C=1;while(!1);t=e[o>>2]|0;do if(t){if(w=e[t+12>>2]|0,(w|0)==(e[t+16>>2]|0)){if(g=0,t=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,d=g,g=0,d&1){Te=10;break e}}else t=e[w>>2]|0;if((t|0)!=-1){if(C)break;Te=40;break}else{e[o>>2]=0,Te=38;break}}else Te=38;while(!1);return(Te|0)==38&&C&&(Te=40),(Te|0)==40&&(e[h>>2]=e[h>>2]|2),w=e[r>>2]|0,Bt(e[ne>>2]|0)|0,t=e[ce>>2]|0,e[ce>>2]=0,t|0&&(g=0,ue(e[Ee>>2]|0,t|0),Te=g,g=0,Te&1)&&(Te=j(0)|0,$t(Te)),b=oe,w|0}else Te=10;while(!1);(Te|0)==10&&(C=j()|0,w=ce),Bt(e[ne>>2]|0)|0,t=e[w>>2]|0,e[w>>2]=0,t?(w=e[Ee>>2]|0,Te=47):ke=C}return(Te|0)==47&&(g=0,ue(w|0,t|0),Te=g,g=0,Te&1?(Te=j(0)|0,$t(Te)):ke=C),le(ke|0),0}function lh(t,r,o,l,c,h,d,w,C,D,k){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0,k=k|0;var N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0,jt=0,Gt=0,s0=0,i0=0,zt=0,gt=0,Kt=0,dt=0,At=0,y0=0,T0=0,g0=0,Oe=0,yt=0,qt=0,c0=0,a0=0,h0=0;c0=b,b=b+512|0,Gt=c0+96|0,N=c0+104|0,h0=c0+88|0,gt=c0+80|0,zt=c0+76|0,Kt=c0+504|0,s0=c0+72|0,dt=c0+68|0,T0=c0+56|0,qt=c0+44|0,Oe=c0+32|0,g0=c0+20|0,yt=c0+8|0,i0=c0+4|0,y0=c0,e[Gt>>2]=k,e[h0>>2]=N,a0=h0+4|0,e[a0>>2]=189,e[gt>>2]=N,e[zt>>2]=N+400,e[T0>>2]=0,e[T0+4>>2]=0,e[T0+8>>2]=0,e[qt>>2]=0,e[qt+4>>2]=0,e[qt+8>>2]=0,e[Oe>>2]=0,e[Oe+4>>2]=0,e[Oe+8>>2]=0,e[g0>>2]=0,e[g0+4>>2]=0,e[g0+8>>2]=0,e[yt>>2]=0,e[yt+4>>2]=0,e[yt+8>>2]=0,g=0,I0(2,o|0,l|0,Kt|0,s0|0,dt|0,T0|0,qt|0,Oe|0,g0|0,i0|0),jt=g,g=0;e:do if(jt&1)o=j()|0;else{e[D>>2]=e[C>>2],Ee=Oe+4|0,Te=g0+4|0,it=g0+8|0,jt=Oe+8|0,O=(c&512|0)!=0,Z=qt+8|0,ie=qt+4|0,oe=yt+4|0,ne=yt+8|0,ce=Kt+3|0,ke=T0+4|0,P=0,_=0;t:for(;;){k=e[t>>2]|0;do if(k){if(o=e[k+12>>2]|0,(o|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,$=g,g=0,$&1){At=26;break t}}else k=e[o>>2]|0;if((k|0)==-1){e[t>>2]=0,l=1;break}else{l=(e[t>>2]|0)==0;break}}else l=1;while(!1);o=e[r>>2]|0;do if(o){if(k=e[o+12>>2]|0,(k|0)==(e[o+16>>2]|0)){if(g=0,k=ge(e[(e[o>>2]|0)+36>>2]|0,o|0)|0,$=g,g=0,$&1){At=26;break t}}else k=e[k>>2]|0;if((k|0)!=-1)if(l){$=o;break}else{U=N,At=244;break t}else{e[r>>2]=0,At=16;break}}else At=16;while(!1);if((At|0)==16)if(At=0,l){U=N,At=244;break}else $=0;i:do switch(S[Kt+P>>0]|0){case 1:{if((P|0)!=3){if(k=e[t>>2]|0,o=e[k+12>>2]|0,(o|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,At=g,g=0,At&1){At=26;break t}}else k=e[o>>2]|0;if(g=0,k=Ve(e[(e[w>>2]|0)+12>>2]|0,w|0,8192,k|0)|0,At=g,g=0,At&1){At=26;break t}if(!k){At=42;break t}if(k=e[t>>2]|0,o=k+12|0,l=e[o>>2]|0,(l|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+40>>2]|0,k|0)|0,At=g,g=0,At&1){At=26;break t}}else e[o>>2]=l+4,k=e[l>>2]|0;if(g=0,Ae(92,yt|0,k|0),At=g,g=0,At&1){At=26;break t}else k=$,c=$,At=44}else k=N;break}case 0:{(P|0)==3?k=N:(k=$,c=$,At=44);break}case 3:{if(o=S[Oe>>0]|0,k=o&1?e[Ee>>2]|0:(o&255)>>>1,l=S[g0>>0]|0,c=l&1?e[Te>>2]|0:(l&255)>>>1,(k|0)==(0-c|0))k=N;else{if(!k){if(k=e[t>>2]|0,o=e[k+12>>2]|0,(o|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,$=g,g=0,$&1){At=26;break t}o=S[g0>>0]|0}else k=e[o>>2]|0,o=l;if((k|0)!=(e[(o&1?e[it>>2]|0:Te)>>2]|0)){k=N;break i}if(k=e[t>>2]|0,o=k+12|0,l=e[o>>2]|0,(l|0)==(e[k+16>>2]|0)){if(g=0,ge(e[(e[k>>2]|0)+40>>2]|0,k|0)|0,$=g,g=0,$&1){At=26;break t}}else e[o>>2]=l+4;S[d>>0]=1,$=S[g0>>0]|0,k=N,_=($&1?e[Te>>2]|0:($&255)>>>1)>>>0>1?g0:_;break i}if(R=e[t>>2]|0,U=e[R+12>>2]|0,l=e[R+16>>2]|0,k=(U|0)==(l|0),!c){if(k){if(g=0,k=ge(e[(e[R>>2]|0)+36>>2]|0,R|0)|0,$=g,g=0,$&1){At=26;break t}o=S[Oe>>0]|0}else k=e[U>>2]|0;if((k|0)!=(e[(o&1?e[jt>>2]|0:Ee)>>2]|0)){S[d>>0]=1,k=N;break i}if(k=e[t>>2]|0,o=k+12|0,l=e[o>>2]|0,(l|0)==(e[k+16>>2]|0)){if(g=0,ge(e[(e[k>>2]|0)+40>>2]|0,k|0)|0,$=g,g=0,$&1){At=26;break t}}else e[o>>2]=l+4;$=S[Oe>>0]|0,k=N,_=($&1?e[Ee>>2]|0:($&255)>>>1)>>>0>1?Oe:_;break i}if(k){if(g=0,k=ge(e[(e[R>>2]|0)+36>>2]|0,R|0)|0,$=g,g=0,$&1){At=26;break t}l=e[t>>2]|0,o=S[Oe>>0]|0,R=l,U=e[l+12>>2]|0,l=e[l+16>>2]|0}else k=e[U>>2]|0;if(c=R+12|0,l=(U|0)==(l|0),(k|0)==(e[(o&1?e[jt>>2]|0:Ee)>>2]|0)){if(l){if(g=0,ge(e[(e[R>>2]|0)+40>>2]|0,R|0)|0,$=g,g=0,$&1){At=26;break t}}else e[c>>2]=U+4;$=S[Oe>>0]|0,k=N,_=($&1?e[Ee>>2]|0:($&255)>>>1)>>>0>1?Oe:_;break i}if(l){if(g=0,k=ge(e[(e[R>>2]|0)+36>>2]|0,R|0)|0,$=g,g=0,$&1){At=26;break t}}else k=e[U>>2]|0;if((k|0)!=(e[(S[g0>>0]&1?e[it>>2]|0:Te)>>2]|0)){At=107;break t}if(k=e[t>>2]|0,o=k+12|0,l=e[o>>2]|0,(l|0)==(e[k+16>>2]|0)){if(g=0,ge(e[(e[k>>2]|0)+40>>2]|0,k|0)|0,$=g,g=0,$&1){At=26;break t}}else e[o>>2]=l+4;S[d>>0]=1,$=S[g0>>0]|0,k=N,_=($&1?e[Te>>2]|0:($&255)>>>1)>>>0>1?g0:_}break}case 2:{if(!(P>>>0<2|(_|0)!=0)&&!(O|(P|0)==2&(S[ce>>0]|0)!=0)){k=N,_=0;break i}c=S[qt>>0]|0,l=e[Z>>2]|0,o=c&1?l:ie,k=o;n:do if(P|0&&(F[Kt+(P+-1)>>0]|0)<2){G=(c&1)==0;r:do if((o|0)!=((G?ie:l)+((G?(c&255)>>>1:e[ie>>2]|0)<<2)|0)){for(c=o;;){if(g=0,o=Ve(e[(e[w>>2]|0)+12>>2]|0,w|0,8192,e[c>>2]|0)|0,G=g,g=0,G&1){At=23;break t}if(!o)break;if(c=c+4|0,k=c,o=S[qt>>0]|0,l=e[Z>>2]|0,G=(o&1)==0,(c|0)==((G?ie:l)+((G?(o&255)>>>1:e[ie>>2]|0)<<2)|0)){c=o;break r}}c=S[qt>>0]|0,l=e[Z>>2]|0}while(!1);if(U=c&1?l:ie,o=U,Q=k-o>>2,K=S[yt>>0]|0,R=(K&1)==0,K=R?(K&255)>>>1:e[oe>>2]|0,K>>>0>=Q>>>0)if(R=R?oe:e[ne>>2]|0,G=R+(K<<2)|0,!Q)o=k;else for(R=R+(K-Q<<2)|0;;){if((e[R>>2]|0)!=(e[U>>2]|0))break n;if(R=R+4|0,(R|0)==(G|0)){o=k;break}else U=U+4|0}}else o=k;while(!1);k=(c&1)==0,k=(k?ie:l)+((k?(c&255)>>>1:e[ie>>2]|0)<<2)|0;n:do if((o|0)!=(k|0))for(R=$,c=$,k=o;;){o=e[t>>2]|0;do if(o){if(l=e[o+12>>2]|0,(l|0)==(e[o+16>>2]|0)){if(g=0,o=ge(e[(e[o>>2]|0)+36>>2]|0,o|0)|0,$=g,g=0,$&1){At=22;break t}}else o=e[l>>2]|0;if((o|0)==-1){e[t>>2]=0,l=1;break}else{l=(e[t>>2]|0)==0;break}}else l=1;while(!1);do if(c){if(o=e[c+12>>2]|0,(o|0)==(e[c+16>>2]|0)){if(g=0,o=ge(e[(e[c>>2]|0)+36>>2]|0,c|0)|0,$=g,g=0,$&1){At=22;break t}}else o=e[o>>2]|0;if((o|0)!=-1)if(l^(R|0)==0){o=R,U=R;break}else break n;else{e[r>>2]=0,o=0,At=136;break}}else o=R,At=136;while(!1);if((At|0)==136){if(At=0,l)break n;U=0}if(l=e[t>>2]|0,c=e[l+12>>2]|0,(c|0)==(e[l+16>>2]|0)){if(g=0,l=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,$=g,g=0,$&1){At=22;break t}}else l=e[c>>2]|0;if((l|0)!=(e[k>>2]|0))break n;if(l=e[t>>2]|0,c=l+12|0,R=e[c>>2]|0,(R|0)==(e[l+16>>2]|0)){if(g=0,ge(e[(e[l>>2]|0)+40>>2]|0,l|0)|0,$=g,g=0,$&1){At=22;break t}}else e[c>>2]=R+4;if(k=k+4|0,l=S[qt>>0]|0,$=(l&1)==0,l=($?ie:e[Z>>2]|0)+(($?(l&255)>>>1:e[ie>>2]|0)<<2)|0,(k|0)==(l|0)){k=l;break}else R=o,c=U}while(!1);if(O&&($=S[qt>>0]|0,G=($&1)==0,(k|0)!=((G?ie:e[Z>>2]|0)+((G?($&255)>>>1:e[ie>>2]|0)<<2)|0))){At=148;break t}else k=N;break}case 4:{K=e[dt>>2]|0,Q=$,R=$,k=N,o=0;n:for(;;){l=e[t>>2]|0;do if(l){if(c=e[l+12>>2]|0,(c|0)==(e[l+16>>2]|0)){if(g=0,l=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,$=g,g=0,$&1){At=25;break t}}else l=e[c>>2]|0;if((l|0)==-1){e[t>>2]=0,c=1;break}else{c=(e[t>>2]|0)==0;break}}else c=1;while(!1);do if(R){if(l=e[R+12>>2]|0,(l|0)==(e[R+16>>2]|0)){if(g=0,l=ge(e[(e[R>>2]|0)+36>>2]|0,R|0)|0,$=g,g=0,$&1){At=25;break t}}else l=e[l>>2]|0;if((l|0)!=-1)if(c^(Q|0)==0){l=Q,U=Q;break}else{N=Q;break n}else{e[r>>2]=0,l=0,At=162;break}}else l=Q,At=162;while(!1);if((At|0)==162)if(At=0,c){N=l;break}else U=0;if(c=e[t>>2]|0,N=e[c+12>>2]|0,(N|0)==(e[c+16>>2]|0)){if(g=0,c=ge(e[(e[c>>2]|0)+36>>2]|0,c|0)|0,$=g,g=0,$&1){At=25;break t}}else c=e[N>>2]|0;if(g=0,N=Ve(e[(e[w>>2]|0)+12>>2]|0,w|0,2048,c|0)|0,$=g,g=0,$&1){At=25;break t}if(N){if(N=e[D>>2]|0,(N|0)==(e[Gt>>2]|0)){if(g=0,xe(14,C|0,D|0,Gt|0),$=g,g=0,$&1){At=25;break t}N=e[D>>2]|0}e[D>>2]=N+4,e[N>>2]=c,o=o+1|0}else{if($=S[T0>>0]|0,!((c|0)==(K|0)&(o|0?(($&1?e[ke>>2]|0:($&255)>>>1)|0)!=0:0))){N=l;break}if((k|0)==(e[zt>>2]|0)){if(g=0,xe(13,h0|0,gt|0,zt|0),$=g,g=0,$&1){At=25;break t}k=e[gt>>2]|0}$=k+4|0,e[gt>>2]=$,e[k>>2]=o,k=$,o=0}if(c=e[t>>2]|0,N=c+12|0,R=e[N>>2]|0,(R|0)==(e[c+16>>2]|0))if(g=0,ge(e[(e[c>>2]|0)+40>>2]|0,c|0)|0,$=g,g=0,$&1){At=25;break t}else{Q=l,R=U;continue}else{e[N>>2]=R+4,Q=l,R=U;continue}}if(o|0&&(e[h0>>2]|0)!=(k|0)){if((k|0)==(e[zt>>2]|0)){if(g=0,xe(13,h0|0,gt|0,zt|0),$=g,g=0,$&1){At=26;break t}k=e[gt>>2]|0}$=k+4|0,e[gt>>2]=$,e[k>>2]=o,k=$}if(U=e[i0>>2]|0,(U|0)>0){o=e[t>>2]|0;do if(o){if(l=e[o+12>>2]|0,(l|0)==(e[o+16>>2]|0)){if(g=0,o=ge(e[(e[o>>2]|0)+36>>2]|0,o|0)|0,$=g,g=0,$&1){At=26;break t}}else o=e[l>>2]|0;if((o|0)==-1){e[t>>2]=0,l=1;break}else{l=(e[t>>2]|0)==0;break}}else l=1;while(!1);do if(N){if(o=e[N+12>>2]|0,(o|0)==(e[N+16>>2]|0)){if(g=0,o=ge(e[(e[N>>2]|0)+36>>2]|0,N|0)|0,$=g,g=0,$&1){At=26;break t}}else o=e[o>>2]|0;if((o|0)!=-1){if(l)break;At=206;break t}else{e[r>>2]=0,At=200;break}}else At=200;while(!1);if((At|0)==200)if(At=0,l){At=206;break t}else N=0;if(o=e[t>>2]|0,l=e[o+12>>2]|0,(l|0)==(e[o+16>>2]|0)){if(g=0,o=ge(e[(e[o>>2]|0)+36>>2]|0,o|0)|0,$=g,g=0,$&1){At=26;break t}}else o=e[l>>2]|0;if((o|0)!=(e[s0>>2]|0)){At=206;break t}if(o=e[t>>2]|0,l=o+12|0,c=e[l>>2]|0,(c|0)==(e[o+16>>2]|0)){if(g=0,ge(e[(e[o>>2]|0)+40>>2]|0,o|0)|0,$=g,g=0,$&1){At=26;break t}}else e[l>>2]=c+4;if((U|0)>0)for(R=N,c=N,Q=U;;){o=e[t>>2]|0;do if(o){if(l=e[o+12>>2]|0,(l|0)==(e[o+16>>2]|0)){if(g=0,o=ge(e[(e[o>>2]|0)+36>>2]|0,o|0)|0,$=g,g=0,$&1){At=24;break t}}else o=e[l>>2]|0;if((o|0)==-1){e[t>>2]=0,l=1;break}else{l=(e[t>>2]|0)==0;break}}else l=1;while(!1);do if(c){if(o=e[c+12>>2]|0,(o|0)==(e[c+16>>2]|0)){if(g=0,o=ge(e[(e[c>>2]|0)+36>>2]|0,c|0)|0,$=g,g=0,$&1){At=24;break t}}else o=e[o>>2]|0;if((o|0)!=-1)if(l^(R|0)==0){o=R,U=R;break}else{At=231;break t}else{e[r>>2]=0,o=0,At=224;break}}else o=R,At=224;while(!1);if((At|0)==224)if(At=0,l){At=231;break t}else U=0;if(l=e[t>>2]|0,c=e[l+12>>2]|0,(c|0)==(e[l+16>>2]|0)){if(g=0,l=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,$=g,g=0,$&1){At=24;break t}}else l=e[c>>2]|0;if(g=0,l=Ve(e[(e[w>>2]|0)+12>>2]|0,w|0,2048,l|0)|0,$=g,g=0,$&1){At=24;break t}if(!l){At=231;break t}if((e[D>>2]|0)==(e[Gt>>2]|0)&&(g=0,xe(14,C|0,D|0,Gt|0),$=g,g=0,$&1)){At=24;break t}if(l=e[t>>2]|0,c=e[l+12>>2]|0,(c|0)==(e[l+16>>2]|0)){if(g=0,l=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,$=g,g=0,$&1){At=24;break t}}else l=e[c>>2]|0;if(c=e[D>>2]|0,e[D>>2]=c+4,e[c>>2]=l,l=Q,Q=Q+-1|0,e[i0>>2]=Q,c=e[t>>2]|0,N=c+12|0,R=e[N>>2]|0,(R|0)==(e[c+16>>2]|0)){if(g=0,ge(e[(e[c>>2]|0)+40>>2]|0,c|0)|0,$=g,g=0,$&1){At=24;break t}}else e[N>>2]=R+4;if((l|0)<=1)break;R=o,c=U}}if((e[D>>2]|0)==(e[C>>2]|0)){At=242;break t}break}default:k=N}while(!1);i:do if((At|0)==44)for(;;){At=0,o=e[t>>2]|0;do if(o){if(l=e[o+12>>2]|0,(l|0)==(e[o+16>>2]|0)){if(g=0,o=ge(e[(e[o>>2]|0)+36>>2]|0,o|0)|0,$=g,g=0,$&1){At=21;break t}}else o=e[l>>2]|0;if((o|0)==-1){e[t>>2]=0,l=1;break}else{l=(e[t>>2]|0)==0;break}}else l=1;while(!1);do if(c){if(o=e[c+12>>2]|0,(o|0)==(e[c+16>>2]|0)){if(g=0,o=ge(e[(e[c>>2]|0)+36>>2]|0,c|0)|0,$=g,g=0,$&1){At=21;break t}}else o=e[o>>2]|0;if((o|0)!=-1)if(l^(k|0)==0){R=k,c=k;break}else{k=N;break i}else{e[r>>2]=0,k=0,At=57;break}}else At=57;while(!1);if((At|0)==57)if(At=0,l){k=N;break i}else R=k,c=0;if(k=e[t>>2]|0,o=e[k+12>>2]|0,(o|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,$=g,g=0,$&1){At=21;break t}}else k=e[o>>2]|0;if(g=0,k=Ve(e[(e[w>>2]|0)+12>>2]|0,w|0,8192,k|0)|0,$=g,g=0,$&1){At=21;break t}if(!k){k=N;break i}if(k=e[t>>2]|0,o=k+12|0,l=e[o>>2]|0,(l|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+40>>2]|0,k|0)|0,At=g,g=0,At&1){At=21;break t}}else e[o>>2]=l+4,k=e[l>>2]|0;if(g=0,Ae(92,yt|0,k|0),At=g,g=0,At&1){At=21;break t}else k=R,At=44}while(!1);if(P=P+1|0,P>>>0>=4){U=k,At=244;break}else N=k}t:switch(At|0){case 21:{o=j()|0;break e}case 22:{o=j()|0;break e}case 23:{o=j()|0;break e}case 24:{o=j()|0;break e}case 25:{o=j()|0;break e}case 26:{o=j()|0;break e}case 42:{e[h>>2]=e[h>>2]|4,o=0;break}case 107:{e[h>>2]=e[h>>2]|4,o=0;break}case 148:{e[h>>2]=e[h>>2]|4,o=0;break}case 206:{e[h>>2]=e[h>>2]|4,o=0;break}case 231:{e[h>>2]=e[h>>2]|4,o=0;break}case 242:{e[h>>2]=e[h>>2]|4,o=0;break}case 244:{i:do if(_){N=_+4|0,R=_+8|0,c=1;n:for(;;){if(k=S[_>>0]|0,k&1?k=e[N>>2]|0:k=(k&255)>>>1,c>>>0>=k>>>0)break i;k=e[t>>2]|0;do if(k){if(o=e[k+12>>2]|0,(o|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,D=g,g=0,D&1){At=20;break n}}else k=e[o>>2]|0;if((k|0)==-1){e[t>>2]=0,l=1;break}else{l=(e[t>>2]|0)==0;break}}else l=1;while(!1);k=e[r>>2]|0;do if(k){if(o=e[k+12>>2]|0,(o|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,D=g,g=0,D&1){At=20;break n}}else k=e[o>>2]|0;if((k|0)!=-1){if(l)break;At=271;break n}else{e[r>>2]=0,At=263;break}}else At=263;while(!1);if((At|0)==263&&(At=0,l)){At=271;break}if(k=e[t>>2]|0,o=e[k+12>>2]|0,(o|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,D=g,g=0,D&1){At=20;break}}else k=e[o>>2]|0;if(S[_>>0]&1?o=e[R>>2]|0:o=N,(k|0)!=(e[o+(c<<2)>>2]|0)){At=271;break}if(k=c+1|0,o=e[t>>2]|0,l=o+12|0,c=e[l>>2]|0,(c|0)==(e[o+16>>2]|0))if(g=0,ge(e[(e[o>>2]|0)+40>>2]|0,o|0)|0,D=g,g=0,D&1){At=20;break}else{c=k;continue}else{e[l>>2]=c+4,c=k;continue}}if((At|0)==20){o=j()|0;break e}else if((At|0)==271){e[h>>2]=e[h>>2]|4,o=0;break t}}while(!1);k=e[h0>>2]|0,(k|0)!=(U|0)&&(e[y0>>2]=0,V0(T0,k,U,y0),(e[y0>>2]|0)!=0)?(e[h>>2]=e[h>>2]|4,o=0):o=1;break}}return Pt(yt),Pt(g0),Pt(Oe),Pt(qt),de(T0),k=e[h0>>2]|0,e[h0>>2]=0,k|0&&(g=0,ue(e[a0>>2]|0,k|0),h0=g,g=0,h0&1)&&(h0=j(0)|0,$t(h0)),b=c0,o|0}while(!1);return Pt(yt),Pt(g0),Pt(Oe),Pt(qt),de(T0),k=e[h0>>2]|0,e[h0>>2]=0,k|0&&(g=0,ue(e[a0>>2]|0,k|0),h0=g,g=0,h0&1)&&(h0=j(0)|0,$t(h0)),le(o|0),0}function uh(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0;if($=b,b=b+432|0,w=$+424|0,t=$+24|0,O=$+16|0,U=$+8|0,N=$+4|0,R=$+428|0,C=$,e[O>>2]=t,ie=O+4|0,e[ie>>2]=189,D=t+400|0,g=0,G=ge(68,c|0)|0,k=g,g=0,k&1)w=j()|0,e[O>>2]=0,Z=38;else{e[N>>2]=G,g=0,k=be(37,N|0,44212)|0,t=g,g=0;e:do if(!(t&1)&&(S[R>>0]=0,Q=e[o>>2]|0,e[C>>2]=Q,_=e[c+4>>2]|0,K=Q,g=0,e[w>>2]=e[C>>2],_=Ut(2,r|0,w|0,l|0,N|0,_|0,h|0,R|0,k|0,O|0,U|0,D|0)|0,c=g,g=0,!(c&1))){if(_){if(S[d>>0]&1?e[e[d+8>>2]>>2]=0:S[d>>0]=0,e[d+4>>2]=0,S[R>>0]|0&&(g=0,t=be(e[(e[k>>2]|0)+44>>2]|0,k|0,45)|0,c=g,g=0,c&1||(g=0,Ae(92,d|0,t|0),c=g,g=0,c&1))||(g=0,C=be(e[(e[k>>2]|0)+44>>2]|0,k|0,48)|0,c=g,g=0,c&1))break;t=e[O>>2]|0,D=e[U>>2]|0,w=D+-4|0;t:do if(t>>>0>>0)do{if((e[t>>2]|0)!=(C|0))break t;t=t+4|0}while(t>>>0>>0);while(!1);if(g=0,Ve(33,d|0,t|0,D|0)|0,d=g,g=0,d&1)break}t=e[r>>2]|0;do if(t){if(w=e[t+12>>2]|0,(w|0)==(e[t+16>>2]|0)){if(g=0,t=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,d=g,g=0,d&1)break e}else t=e[w>>2]|0;if((t|0)==-1){e[r>>2]=0,w=1;break}else{w=(e[r>>2]|0)==0;break}}else w=1;while(!1);do if(Q){if(t=e[K+12>>2]|0,(t|0)==(e[K+16>>2]|0)){if(g=0,t=ge(e[(e[Q>>2]|0)+36>>2]|0,K|0)|0,K=g,g=0,K&1)break e}else t=e[t>>2]|0;if((t|0)!=-1){if(w)break;Z=32;break}else{e[o>>2]=0,Z=30;break}}else Z=30;while(!1);return(Z|0)==30&&w&&(Z=32),(Z|0)==32&&(e[h>>2]=e[h>>2]|2),w=e[r>>2]|0,Bt(G)|0,t=e[O>>2]|0,e[O>>2]=0,t|0&&(g=0,ue(e[ie>>2]|0,t|0),ie=g,g=0,ie&1)&&(ie=j(0)|0,$t(ie)),b=$,w|0}while(!1);w=j()|0,Bt(G)|0,t=e[O>>2]|0,e[O>>2]=0,t?Z=38:P=w}return(Z|0)==38&&(g=0,ue(e[ie>>2]|0,t|0),ie=g,g=0,ie&1?(ie=j(0)|0,$t(ie)):P=w),le(P|0),0}function fh(t,r,o,l,c,h,d,w,C,D){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0;var k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0;Z=b,b=b+112|0,k=Z+100|0,N=Z+88|0,R=Z+76|0,_=Z+64|0,U=Z+52|0,Q=Z+48|0,K=Z+36|0,G=Z+24|0,$=Z+12|0,P=Z;do if(t)if(t=O0(r,43956)|0,t0[e[(e[t>>2]|0)+44>>2]&127](k,t),P=e[k>>2]|0,S[o>>0]=P,S[o+1>>0]=P>>8,S[o+2>>0]=P>>16,S[o+3>>0]=P>>24,t0[e[(e[t>>2]|0)+32>>2]&127](N,t),S[C>>0]&1?e[e[C+8>>2]>>2]=0:S[C>>0]=0,e[C+4>>2]=0,g=0,Ae(93,C|0,0),o=g,g=0,o&1&&(o=j(0)|0,$t(o)),e[C>>2]=e[N>>2],e[C+4>>2]=e[N+4>>2],e[C+8>>2]=e[N+8>>2],e[N>>2]=0,e[N+4>>2]=0,e[N+8>>2]=0,Pt(N),t0[e[(e[t>>2]|0)+28>>2]&127](R,t),S[w>>0]&1?e[e[w+8>>2]>>2]=0:S[w>>0]=0,e[w+4>>2]=0,g=0,Ae(93,w|0,0),o=g,g=0,o&1&&(o=j(0)|0,$t(o)),e[w>>2]=e[R>>2],e[w+4>>2]=e[R+4>>2],e[w+8>>2]=e[R+8>>2],e[R>>2]=0,e[R+4>>2]=0,e[R+8>>2]=0,Pt(R),w=Dt[e[(e[t>>2]|0)+12>>2]&127](t)|0,e[l>>2]=w,w=Dt[e[(e[t>>2]|0)+16>>2]&127](t)|0,e[c>>2]=w,t0[e[(e[t>>2]|0)+20>>2]&127](_,t),S[h>>0]&1?(S[e[h+8>>2]>>0]=0,e[h+4>>2]=0):(S[h+1>>0]=0,S[h>>0]=0),g=0,Ae(91,h|0,0),c=g,g=0,c&1&&(c=j(0)|0,$t(c)),e[h>>2]=e[_>>2],e[h+4>>2]=e[_+4>>2],e[h+8>>2]=e[_+8>>2],e[_>>2]=0,e[_+4>>2]=0,e[_+8>>2]=0,de(_),t0[e[(e[t>>2]|0)+24>>2]&127](U,t),S[d>>0]&1?e[e[d+8>>2]>>2]=0:S[d>>0]=0,e[d+4>>2]=0,g=0,Ae(93,d|0,0),c=g,g=0,c&1)c=j(0)|0,$t(c);else{e[d>>2]=e[U>>2],e[d+4>>2]=e[U+4>>2],e[d+8>>2]=e[U+8>>2],e[U>>2]=0,e[U+4>>2]=0,e[U+8>>2]=0,Pt(U),O=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0;break}else if(t=O0(r,43892)|0,t0[e[(e[t>>2]|0)+44>>2]&127](Q,t),Q=e[Q>>2]|0,S[o>>0]=Q,S[o+1>>0]=Q>>8,S[o+2>>0]=Q>>16,S[o+3>>0]=Q>>24,t0[e[(e[t>>2]|0)+32>>2]&127](K,t),S[C>>0]&1?e[e[C+8>>2]>>2]=0:S[C>>0]=0,e[C+4>>2]=0,g=0,Ae(93,C|0,0),o=g,g=0,o&1&&(o=j(0)|0,$t(o)),e[C>>2]=e[K>>2],e[C+4>>2]=e[K+4>>2],e[C+8>>2]=e[K+8>>2],e[K>>2]=0,e[K+4>>2]=0,e[K+8>>2]=0,Pt(K),t0[e[(e[t>>2]|0)+28>>2]&127](G,t),S[w>>0]&1?e[e[w+8>>2]>>2]=0:S[w>>0]=0,e[w+4>>2]=0,g=0,Ae(93,w|0,0),o=g,g=0,o&1&&(o=j(0)|0,$t(o)),e[w>>2]=e[G>>2],e[w+4>>2]=e[G+4>>2],e[w+8>>2]=e[G+8>>2],e[G>>2]=0,e[G+4>>2]=0,e[G+8>>2]=0,Pt(G),w=Dt[e[(e[t>>2]|0)+12>>2]&127](t)|0,e[l>>2]=w,w=Dt[e[(e[t>>2]|0)+16>>2]&127](t)|0,e[c>>2]=w,t0[e[(e[t>>2]|0)+20>>2]&127]($,t),S[h>>0]&1?(S[e[h+8>>2]>>0]=0,e[h+4>>2]=0):(S[h+1>>0]=0,S[h>>0]=0),g=0,Ae(91,h|0,0),c=g,g=0,c&1&&(c=j(0)|0,$t(c)),e[h>>2]=e[$>>2],e[h+4>>2]=e[$+4>>2],e[h+8>>2]=e[$+8>>2],e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,de($),t0[e[(e[t>>2]|0)+24>>2]&127](P,t),S[d>>0]&1?e[e[d+8>>2]>>2]=0:S[d>>0]=0,e[d+4>>2]=0,g=0,Ae(93,d|0,0),c=g,g=0,c&1)c=j(0)|0,$t(c);else{e[d>>2]=e[P>>2],e[d+4>>2]=e[P+4>>2],e[d+8>>2]=e[P+8>>2],e[P>>2]=0,e[P+4>>2]=0,e[P+8>>2]=0,Pt(P),O=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0;break}while(!1);e[D>>2]=O,b=Z}function hh(t){t=t|0}function dh(t){t=t|0,he(t)}function ph(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=+h;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0;ne=b,b=b+384|0,K=ne+8|0,d=ne,C=ne+284|0,D=ne+72|0,w=ne+184|0,ke=ne+68|0,Z=ne+80|0,$=ne+77|0,ie=ne+76|0,Ee=ne+56|0,it=ne+44|0,Te=ne+32|0,k=ne+28|0,Q=ne+84|0,O=ne+24|0,P=ne+20|0,G=ne+16|0,e[D>>2]=C,B[K>>3]=h,C=Mo(C,100,59018,K)|0;do if(C>>>0>99)if(g=0,t=Ce(3)|0,oe=g,g=0,!(oe&1)&&(g=0,B[d>>3]=h,_=Pe(17,D|0,t|0,59018,d|0)|0,oe=g,g=0,!(oe&1))){if(t=e[D>>2]|0,!t){if(g=0,Nt(6),oe=g,g=0,oe&1){t=0,d=0,oe=7;break}t=e[D>>2]|0}w=E0(_)|0,d=w,w?(U=w,oe=10):(g=0,Nt(6),oe=g,g=0,oe&1?oe=7:(U=0,oe=10))}else t=0,d=0,oe=7;else d=0,t=0,U=w,_=C,oe=10;while(!1);if((oe|0)==10)if(g=0,w=ge(68,l|0)|0,R=g,g=0,R&1)oe=7;else{if(e[ke>>2]=w,g=0,R=be(37,ke|0,44220)|0,N=g,g=0,!(N&1)&&(N=e[D>>2]|0,g=0,Pe(e[(e[R>>2]|0)+32>>2]|0,R|0,N|0,N+_|0,U|0)|0,N=g,g=0,!(N&1))){if(_?N=(S[e[D>>2]>>0]|0)==45:N=0,e[Ee>>2]=0,e[Ee+4>>2]=0,e[Ee+8>>2]=0,e[it>>2]=0,e[it+4>>2]=0,e[it+8>>2]=0,e[Te>>2]=0,e[Te+4>>2]=0,e[Te+8>>2]=0,g=0,I0(3,o|0,N|0,ke|0,Z|0,$|0,ie|0,Ee|0,it|0,Te|0,k|0),o=g,g=0,o&1)C=j()|0;else{if(k=e[k>>2]|0,(_|0)>(k|0)?(o=S[Te>>0]|0,C=S[it>>0]|0,C=(_-k<<1|1)+k+(o&1?e[Te+4>>2]|0:(o&255)>>>1)+(C&1?e[it+4>>2]|0:(C&255)>>>1)|0):(o=S[Te>>0]|0,C=S[it>>0]|0,C=k+2+(o&1?e[Te+4>>2]|0:(o&255)>>>1)+(C&1?e[it+4>>2]|0:(C&255)>>>1)|0),C>>>0>100?(C=E0(C)|0,D=C,C?oe=26:(g=0,Nt(6),Q=g,g=0,Q&1||(C=0,oe=26))):(D=0,C=Q,oe=26),(oe|0)==26&&(g=0,Zt(1,C|0,O|0,P|0,e[l+4>>2]|0,U|0,U+_|0,R|0,N|0,Z|0,S[$>>0]|0,S[ie>>0]|0,Ee|0,it|0,Te|0,k|0),ie=g,g=0,!(ie&1)&&(e[G>>2]=e[r>>2],r=e[O>>2]|0,ce=e[P>>2]|0,g=0,e[K>>2]=e[G>>2],ce=Vt(39,K|0,C|0,r|0,ce|0,l|0,c|0)|0,r=g,g=0,!(r&1))))return D&&(n0(D),w=e[ke>>2]|0),de(Te),de(it),de(Ee),Bt(w)|0,d&&n0(d),t&&n0(t),b=ne,ce|0;C=j()|0,D&&(n0(D),w=e[ke>>2]|0)}de(Te),de(it),de(Ee)}else C=j()|0;Bt(w)|0}return(oe|0)==7&&(C=j()|0),d&&n0(d),t&&n0(t),le(C|0),0}function mh(t,r,o,l,c,h,d,w,C,D){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0;var k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;ce=b,b=b+112|0,R=ce+108|0,_=ce+96|0,K=ce+92|0,G=ce+80|0,$=ce+68|0,P=ce+56|0,O=ce+52|0,Z=ce+40|0,ie=ce+36|0,oe=ce+24|0,U=ce+12|0,Q=ce;do if(t){t=O0(o,43828)|0,o=e[t>>2]|0;do if(r)if(t0[e[o+44>>2]&127](R,t),r=e[R>>2]|0,S[l>>0]=r,S[l+1>>0]=r>>8,S[l+2>>0]=r>>16,S[l+3>>0]=r>>24,t0[e[(e[t>>2]|0)+32>>2]&127](_,t),S[C>>0]&1?(S[e[C+8>>2]>>0]=0,e[C+4>>2]=0):(S[C+1>>0]=0,S[C>>0]=0),g=0,Ae(91,C|0,0),l=g,g=0,l&1)C=j(0)|0,$t(C);else{e[C>>2]=e[_>>2],e[C+4>>2]=e[_+4>>2],e[C+8>>2]=e[_+8>>2],e[_>>2]=0,e[_+4>>2]=0,e[_+8>>2]=0,de(_),N=t;break}else if(t0[e[o+40>>2]&127](K,t),r=e[K>>2]|0,S[l>>0]=r,S[l+1>>0]=r>>8,S[l+2>>0]=r>>16,S[l+3>>0]=r>>24,t0[e[(e[t>>2]|0)+28>>2]&127](G,t),S[C>>0]&1?(S[e[C+8>>2]>>0]=0,e[C+4>>2]=0):(S[C+1>>0]=0,S[C>>0]=0),g=0,Ae(91,C|0,0),l=g,g=0,l&1)C=j(0)|0,$t(C);else{e[C>>2]=e[G>>2],e[C+4>>2]=e[G+4>>2],e[C+8>>2]=e[G+8>>2],e[G>>2]=0,e[G+4>>2]=0,e[G+8>>2]=0,de(G),N=t;break}while(!1);if(C=Dt[e[(e[t>>2]|0)+12>>2]&127](t)|0,S[c>>0]=C,C=Dt[e[(e[t>>2]|0)+16>>2]&127](t)|0,S[h>>0]=C,t0[e[(e[N>>2]|0)+20>>2]&127]($,t),S[d>>0]&1?(S[e[d+8>>2]>>0]=0,e[d+4>>2]=0):(S[d+1>>0]=0,S[d>>0]=0),g=0,Ae(91,d|0,0),h=g,g=0,h&1&&(h=j(0)|0,$t(h)),e[d>>2]=e[$>>2],e[d+4>>2]=e[$+4>>2],e[d+8>>2]=e[$+8>>2],e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,de($),t0[e[(e[N>>2]|0)+24>>2]&127](P,t),S[w>>0]&1?(S[e[w+8>>2]>>0]=0,e[w+4>>2]=0):(S[w+1>>0]=0,S[w>>0]=0),g=0,Ae(91,w|0,0),h=g,g=0,h&1)h=j(0)|0,$t(h);else{e[w>>2]=e[P>>2],e[w+4>>2]=e[P+4>>2],e[w+8>>2]=e[P+8>>2],e[P>>2]=0,e[P+4>>2]=0,e[P+8>>2]=0,de(P),ne=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0;break}}else{t=O0(o,43764)|0,o=e[t>>2]|0;do if(r)if(t0[e[o+44>>2]&127](O,t),r=e[O>>2]|0,S[l>>0]=r,S[l+1>>0]=r>>8,S[l+2>>0]=r>>16,S[l+3>>0]=r>>24,t0[e[(e[t>>2]|0)+32>>2]&127](Z,t),S[C>>0]&1?(S[e[C+8>>2]>>0]=0,e[C+4>>2]=0):(S[C+1>>0]=0,S[C>>0]=0),g=0,Ae(91,C|0,0),l=g,g=0,l&1)C=j(0)|0,$t(C);else{e[C>>2]=e[Z>>2],e[C+4>>2]=e[Z+4>>2],e[C+8>>2]=e[Z+8>>2],e[Z>>2]=0,e[Z+4>>2]=0,e[Z+8>>2]=0,de(Z),k=t;break}else if(t0[e[o+40>>2]&127](ie,t),r=e[ie>>2]|0,S[l>>0]=r,S[l+1>>0]=r>>8,S[l+2>>0]=r>>16,S[l+3>>0]=r>>24,t0[e[(e[t>>2]|0)+28>>2]&127](oe,t),S[C>>0]&1?(S[e[C+8>>2]>>0]=0,e[C+4>>2]=0):(S[C+1>>0]=0,S[C>>0]=0),g=0,Ae(91,C|0,0),l=g,g=0,l&1)C=j(0)|0,$t(C);else{e[C>>2]=e[oe>>2],e[C+4>>2]=e[oe+4>>2],e[C+8>>2]=e[oe+8>>2],e[oe>>2]=0,e[oe+4>>2]=0,e[oe+8>>2]=0,de(oe),k=t;break}while(!1);if(C=Dt[e[(e[t>>2]|0)+12>>2]&127](t)|0,S[c>>0]=C,C=Dt[e[(e[t>>2]|0)+16>>2]&127](t)|0,S[h>>0]=C,t0[e[(e[k>>2]|0)+20>>2]&127](U,t),S[d>>0]&1?(S[e[d+8>>2]>>0]=0,e[d+4>>2]=0):(S[d+1>>0]=0,S[d>>0]=0),g=0,Ae(91,d|0,0),h=g,g=0,h&1&&(h=j(0)|0,$t(h)),e[d>>2]=e[U>>2],e[d+4>>2]=e[U+4>>2],e[d+8>>2]=e[U+8>>2],e[U>>2]=0,e[U+4>>2]=0,e[U+8>>2]=0,de(U),t0[e[(e[k>>2]|0)+24>>2]&127](Q,t),S[w>>0]&1?(S[e[w+8>>2]>>0]=0,e[w+4>>2]=0):(S[w+1>>0]=0,S[w>>0]=0),g=0,Ae(91,w|0,0),h=g,g=0,h&1)h=j(0)|0,$t(h);else{e[w>>2]=e[Q>>2],e[w+4>>2]=e[Q+4>>2],e[w+8>>2]=e[Q+8>>2],e[Q>>2]=0,e[Q+4>>2]=0,e[Q+8>>2]=0,de(Q),ne=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0;break}}while(!1);e[D>>2]=ne,b=ce}function gh(t,r,o,l,c,h,d,w,C,D,k,N,R,_,U){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0,k=k|0,N=N|0,R=R|0,_=_|0,U=U|0;var Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0,jt=0,Gt=0,s0=0,i0=0,zt=0,gt=0,Kt=0,dt=0,At=0;e[o>>2]=t,Kt=_+4|0,dt=_+8|0,At=_+1|0,jt=R+4|0,Gt=(l&512|0)==0,s0=R+8|0,i0=R+1|0,zt=d+8|0,gt=(U|0)>0,oe=N+4|0,ne=N+8|0,ce=N+1|0,ke=U+1|0,Te=-2-U-((U|0)<0?~U:-1)|0,it=(U|0)>0,ie=0;do{switch(S[C+ie>>0]|0){case 0:{e[r>>2]=e[o>>2];break}case 1:{e[r>>2]=e[o>>2],O=U0[e[(e[d>>2]|0)+28>>2]&63](d,32)|0,Z=e[o>>2]|0,e[o>>2]=Z+1,S[Z>>0]=O;break}case 3:{Z=S[_>>0]|0,Q=(Z&1)==0,(Q?(Z&255)>>>1:e[Kt>>2]|0)|0&&(O=S[(Q?At:e[dt>>2]|0)>>0]|0,Z=e[o>>2]|0,e[o>>2]=Z+1,S[Z>>0]=O);break}case 2:{if(G=S[R>>0]|0,Q=(G&1)==0,G=Q?(G&255)>>>1:e[jt>>2]|0,!(Gt|(G|0)==0)){if(K=Q?i0:e[s0>>2]|0,$=K+G|0,Q=e[o>>2]|0,G)do S[Q>>0]=S[K>>0]|0,K=K+1|0,Q=Q+1|0;while((K|0)!=($|0));e[o>>2]=Q}break}case 4:{Q=e[o>>2]|0,c=w?c+1|0:c,P=c,$=e[zt>>2]|0;e:do if(c>>>0>>0){K=c;do{if(G=S[K>>0]|0,G<<24>>24<=-1||!(E[$+(G<<24>>24<<1)>>1]&2048))break e;K=K+1|0}while(K>>>0>>0)}else K=c;while(!1);if(G=K,gt){if(O=-2-G-~(G>>>0>P>>>0?P:G)|0,O=Te>>>0>O>>>0?Te:O,K>>>0>c>>>0&it)for(G=K,P=U;G=G+-1|0,Z=S[G>>0]|0,$=e[o>>2]|0,e[o>>2]=$+1,S[$>>0]=Z,$=(P|0)>1,G>>>0>c>>>0&$;)P=P+-1|0;else $=it;if(Z=ke+O|0,G=K+(O+1)|0,$?P=U0[e[(e[d>>2]|0)+28>>2]&63](d,48)|0:P=0,K=e[o>>2]|0,e[o>>2]=K+1,(Z|0)>0)for($=Z;S[K>>0]=P,K=e[o>>2]|0,e[o>>2]=K+1,($|0)>1;)$=$+-1|0;S[K>>0]=D}else G=K;if((G|0)!=(c|0)){if(Z=S[N>>0]|0,K=(Z&1)==0,(K?(Z&255)>>>1:e[oe>>2]|0)|0?K=S[(K?ce:e[ne>>2]|0)>>0]|0:K=-1,(G|0)!=(c|0))for($=0,P=0;(P|0)==(K|0)&&(Z=e[o>>2]|0,e[o>>2]=Z+1,S[Z>>0]=k,$=$+1|0,Z=S[N>>0]|0,K=(Z&1)==0,$>>>0<(K?(Z&255)>>>1:e[oe>>2]|0)>>>0?(K=S[(K?ce:e[ne>>2]|0)+$>>0]|0,K=K<<24>>24==127?-1:K<<24>>24,P=0):(K=P,P=0)),G=G+-1|0,O=S[G>>0]|0,Z=e[o>>2]|0,e[o>>2]=Z+1,S[Z>>0]=O,(G|0)!=(c|0);)P=P+1|0}else O=U0[e[(e[d>>2]|0)+28>>2]&63](d,48)|0,Z=e[o>>2]|0,e[o>>2]=Z+1,S[Z>>0]=O;if(K=e[o>>2]|0,(Q|0)!=(K|0)&&(Ee=K+-1|0,Q>>>0>>0)){K=Ee;do Z=S[Q>>0]|0,S[Q>>0]=S[K>>0]|0,S[K>>0]=Z,Q=Q+1|0,K=K+-1|0;while(Q>>>0>>0)}break}default:}ie=ie+1|0}while((ie|0)!=4);if(K=S[_>>0]|0,c=(K&1)==0,K=c?(K&255)>>>1:e[Kt>>2]|0,K>>>0>1){if(Q=c?At:e[dt>>2]|0,G=Q+K|0,c=e[o>>2]|0,(K|0)!=1){Q=Q+1|0;do S[c>>0]=S[Q>>0]|0,c=c+1|0,Q=Q+1|0;while((Q|0)!=(G|0))}e[o>>2]=c}switch(l&176|0){case 32:{e[r>>2]=e[o>>2];break}case 16:break;default:e[r>>2]=t}}function Sh(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0;Z=b,b=b+176|0,_=Z+56|0,oe=Z+52|0,P=Z+64|0,K=Z+61|0,O=Z+60|0,ne=Z+40|0,ke=Z+28|0,ce=Z+16|0,D=Z+12|0,R=Z+68|0,$=Z+8|0,G=Z+4|0,U=Z,t=f0(l)|0,e[oe>>2]=t,g=0,Q=be(37,oe|0,44220)|0,N=g,g=0;do if(N&1)Ee=13;else{if(k=S[h>>0]|0,d=(k&1)==0,N=h+4|0,!((d?(k&255)>>>1:e[N>>2]|0)|0))k=0;else{if(d=S[(d?h+1|0:e[h+8>>2]|0)>>0]|0,g=0,w=be(e[(e[Q>>2]|0)+28>>2]|0,Q|0,45)|0,k=g,g=0,k&1){Ee=13;break}k=d<<24>>24==w<<24>>24}if(e[ne>>2]=0,e[ne+4>>2]=0,e[ne+8>>2]=0,e[ke>>2]=0,e[ke+4>>2]=0,e[ke+8>>2]=0,e[ce>>2]=0,e[ce+4>>2]=0,e[ce+8>>2]=0,g=0,I0(3,o|0,k|0,oe|0,P|0,K|0,O|0,ne|0,ke|0,ce|0,D|0),C=g,g=0,C&1)d=j()|0;else{if(C=S[h>>0]|0,o=e[N>>2]|0,d=C&1?o:(C&255)>>>1,D=e[D>>2]|0,(d|0)>(D|0)?(Te=S[ce>>0]|0,w=S[ke>>0]|0,d=(d-D<<1|1)+D+(Te&1?e[ce+4>>2]|0:(Te&255)>>>1)+(w&1?e[ke+4>>2]|0:(w&255)>>>1)|0):(Te=S[ce>>0]|0,d=S[ke>>0]|0,d=D+2+(Te&1?e[ce+4>>2]|0:(Te&255)>>>1)+(d&1?e[ke+4>>2]|0:(d&255)>>>1)|0),d>>>0>100?(d=E0(d)|0,w=d,d?Ee=17:(g=0,Nt(6),Te=g,g=0,Te&1||(C=S[h>>0]|0,o=e[N>>2]|0,d=0,Ee=17))):(w=0,d=R,Ee=17),(Ee|0)==17&&(Te=(C&1)==0,h=Te?h+1|0:e[h+8>>2]|0,g=0,Zt(1,d|0,$|0,G|0,e[l+4>>2]|0,h|0,h+(Te?(C&255)>>>1:o)|0,Q|0,k|0,P|0,S[K>>0]|0,S[O>>0]|0,ne|0,ke|0,ce|0,D|0),Te=g,g=0,!(Te&1)&&(e[U>>2]=e[r>>2],Te=e[$>>2]|0,ie=e[G>>2]|0,g=0,e[_>>2]=e[U>>2],ie=Vt(39,_|0,d|0,Te|0,ie|0,l|0,c|0)|0,Te=g,g=0,!(Te&1))))return w&&(n0(w),t=e[oe>>2]|0),de(ce),de(ke),de(ne),Bt(t)|0,b=Z,ie|0;d=j()|0,w&&(n0(w),t=e[oe>>2]|0)}de(ce),de(ke),de(ne)}while(!1);return(Ee|0)==13&&(d=j()|0),Bt(t)|0,le(d|0),0}function Ah(t){t=t|0}function vh(t){t=t|0,he(t)}function xh(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=+h;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0;ne=b,b=b+992|0,K=ne+8|0,d=ne,C=ne+888|0,D=ne+880|0,w=ne+480|0,ke=ne+76|0,Z=ne+884|0,$=ne+72|0,ie=ne+68|0,Ee=ne+56|0,it=ne+44|0,Te=ne+32|0,k=ne+28|0,Q=ne+80|0,O=ne+24|0,P=ne+20|0,G=ne+16|0,e[D>>2]=C,B[K>>3]=h,C=Mo(C,100,59018,K)|0;do if(C>>>0>99)if(g=0,t=Ce(3)|0,oe=g,g=0,!(oe&1)&&(g=0,B[d>>3]=h,_=Pe(17,D|0,t|0,59018,d|0)|0,oe=g,g=0,!(oe&1))){if(t=e[D>>2]|0,!t){if(g=0,Nt(6),oe=g,g=0,oe&1){t=0,d=0,oe=7;break}t=e[D>>2]|0}w=E0(_<<2)|0,d=w,w?(U=w,oe=10):(g=0,Nt(6),oe=g,g=0,oe&1?oe=7:(U=0,oe=10))}else t=0,d=0,oe=7;else d=0,t=0,U=w,_=C,oe=10;while(!1);if((oe|0)==10)if(g=0,w=ge(68,l|0)|0,R=g,g=0,R&1)oe=7;else{if(e[ke>>2]=w,g=0,R=be(37,ke|0,44212)|0,N=g,g=0,!(N&1)&&(N=e[D>>2]|0,g=0,Pe(e[(e[R>>2]|0)+48>>2]|0,R|0,N|0,N+_|0,U|0)|0,N=g,g=0,!(N&1))){if(_?N=(S[e[D>>2]>>0]|0)==45:N=0,e[Ee>>2]=0,e[Ee+4>>2]=0,e[Ee+8>>2]=0,e[it>>2]=0,e[it+4>>2]=0,e[it+8>>2]=0,e[Te>>2]=0,e[Te+4>>2]=0,e[Te+8>>2]=0,g=0,I0(4,o|0,N|0,ke|0,Z|0,$|0,ie|0,Ee|0,it|0,Te|0,k|0),o=g,g=0,o&1)C=j()|0;else{if(k=e[k>>2]|0,(_|0)>(k|0)?(o=S[Te>>0]|0,C=S[it>>0]|0,C=(_-k<<1|1)+k+(o&1?e[Te+4>>2]|0:(o&255)>>>1)+(C&1?e[it+4>>2]|0:(C&255)>>>1)|0):(o=S[Te>>0]|0,C=S[it>>0]|0,C=k+2+(o&1?e[Te+4>>2]|0:(o&255)>>>1)+(C&1?e[it+4>>2]|0:(C&255)>>>1)|0),C>>>0>100?(C=E0(C<<2)|0,D=C,C?oe=26:(g=0,Nt(6),Q=g,g=0,Q&1||(C=0,oe=26))):(D=0,C=Q,oe=26),(oe|0)==26&&(g=0,Zt(2,C|0,O|0,P|0,e[l+4>>2]|0,U|0,U+(_<<2)|0,R|0,N|0,Z|0,e[$>>2]|0,e[ie>>2]|0,Ee|0,it|0,Te|0,k|0),ie=g,g=0,!(ie&1)&&(e[G>>2]=e[r>>2],r=e[O>>2]|0,ce=e[P>>2]|0,g=0,e[K>>2]=e[G>>2],ce=Vt(40,K|0,C|0,r|0,ce|0,l|0,c|0)|0,r=g,g=0,!(r&1))))return D&&(n0(D),w=e[ke>>2]|0),Pt(Te),Pt(it),de(Ee),Bt(w)|0,d&&n0(d),t&&n0(t),b=ne,ce|0;C=j()|0,D&&(n0(D),w=e[ke>>2]|0)}Pt(Te),Pt(it),de(Ee)}else C=j()|0;Bt(w)|0}return(oe|0)==7&&(C=j()|0),d&&n0(d),t&&n0(t),le(C|0),0}function wh(t,r,o,l,c,h,d,w,C,D){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0;var k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0;oe=b,b=b+112|0,k=oe+108|0,N=oe+96|0,U=oe+92|0,Q=oe+80|0,K=oe+68|0,G=oe+56|0,$=oe+52|0,P=oe+40|0,O=oe+36|0,Z=oe+24|0,R=oe+12|0,_=oe;do if(t){t=O0(o,43956)|0,o=e[t>>2]|0;do if(r)if(t0[e[o+44>>2]&127](k,t),r=e[k>>2]|0,S[l>>0]=r,S[l+1>>0]=r>>8,S[l+2>>0]=r>>16,S[l+3>>0]=r>>24,t0[e[(e[t>>2]|0)+32>>2]&127](N,t),S[C>>0]&1?e[e[C+8>>2]>>2]=0:S[C>>0]=0,e[C+4>>2]=0,g=0,Ae(93,C|0,0),l=g,g=0,l&1)C=j(0)|0,$t(C);else{e[C>>2]=e[N>>2],e[C+4>>2]=e[N+4>>2],e[C+8>>2]=e[N+8>>2],e[N>>2]=0,e[N+4>>2]=0,e[N+8>>2]=0,Pt(N);break}else if(t0[e[o+40>>2]&127](U,t),r=e[U>>2]|0,S[l>>0]=r,S[l+1>>0]=r>>8,S[l+2>>0]=r>>16,S[l+3>>0]=r>>24,t0[e[(e[t>>2]|0)+28>>2]&127](Q,t),S[C>>0]&1?e[e[C+8>>2]>>2]=0:S[C>>0]=0,e[C+4>>2]=0,g=0,Ae(93,C|0,0),l=g,g=0,l&1)C=j(0)|0,$t(C);else{e[C>>2]=e[Q>>2],e[C+4>>2]=e[Q+4>>2],e[C+8>>2]=e[Q+8>>2],e[Q>>2]=0,e[Q+4>>2]=0,e[Q+8>>2]=0,Pt(Q);break}while(!1);if(C=Dt[e[(e[t>>2]|0)+12>>2]&127](t)|0,e[c>>2]=C,C=Dt[e[(e[t>>2]|0)+16>>2]&127](t)|0,e[h>>2]=C,t0[e[(e[t>>2]|0)+20>>2]&127](K,t),S[d>>0]&1?(S[e[d+8>>2]>>0]=0,e[d+4>>2]=0):(S[d+1>>0]=0,S[d>>0]=0),g=0,Ae(91,d|0,0),h=g,g=0,h&1&&(h=j(0)|0,$t(h)),e[d>>2]=e[K>>2],e[d+4>>2]=e[K+4>>2],e[d+8>>2]=e[K+8>>2],e[K>>2]=0,e[K+4>>2]=0,e[K+8>>2]=0,de(K),t0[e[(e[t>>2]|0)+24>>2]&127](G,t),S[w>>0]&1?e[e[w+8>>2]>>2]=0:S[w>>0]=0,e[w+4>>2]=0,g=0,Ae(93,w|0,0),h=g,g=0,h&1)h=j(0)|0,$t(h);else{e[w>>2]=e[G>>2],e[w+4>>2]=e[G+4>>2],e[w+8>>2]=e[G+8>>2],e[G>>2]=0,e[G+4>>2]=0,e[G+8>>2]=0,Pt(G),ie=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0;break}}else{t=O0(o,43892)|0,o=e[t>>2]|0;do if(r)if(t0[e[o+44>>2]&127]($,t),r=e[$>>2]|0,S[l>>0]=r,S[l+1>>0]=r>>8,S[l+2>>0]=r>>16,S[l+3>>0]=r>>24,t0[e[(e[t>>2]|0)+32>>2]&127](P,t),S[C>>0]&1?e[e[C+8>>2]>>2]=0:S[C>>0]=0,e[C+4>>2]=0,g=0,Ae(93,C|0,0),l=g,g=0,l&1)C=j(0)|0,$t(C);else{e[C>>2]=e[P>>2],e[C+4>>2]=e[P+4>>2],e[C+8>>2]=e[P+8>>2],e[P>>2]=0,e[P+4>>2]=0,e[P+8>>2]=0,Pt(P);break}else if(t0[e[o+40>>2]&127](O,t),r=e[O>>2]|0,S[l>>0]=r,S[l+1>>0]=r>>8,S[l+2>>0]=r>>16,S[l+3>>0]=r>>24,t0[e[(e[t>>2]|0)+28>>2]&127](Z,t),S[C>>0]&1?e[e[C+8>>2]>>2]=0:S[C>>0]=0,e[C+4>>2]=0,g=0,Ae(93,C|0,0),l=g,g=0,l&1)C=j(0)|0,$t(C);else{e[C>>2]=e[Z>>2],e[C+4>>2]=e[Z+4>>2],e[C+8>>2]=e[Z+8>>2],e[Z>>2]=0,e[Z+4>>2]=0,e[Z+8>>2]=0,Pt(Z);break}while(!1);if(C=Dt[e[(e[t>>2]|0)+12>>2]&127](t)|0,e[c>>2]=C,C=Dt[e[(e[t>>2]|0)+16>>2]&127](t)|0,e[h>>2]=C,t0[e[(e[t>>2]|0)+20>>2]&127](R,t),S[d>>0]&1?(S[e[d+8>>2]>>0]=0,e[d+4>>2]=0):(S[d+1>>0]=0,S[d>>0]=0),g=0,Ae(91,d|0,0),h=g,g=0,h&1&&(h=j(0)|0,$t(h)),e[d>>2]=e[R>>2],e[d+4>>2]=e[R+4>>2],e[d+8>>2]=e[R+8>>2],e[R>>2]=0,e[R+4>>2]=0,e[R+8>>2]=0,de(R),t0[e[(e[t>>2]|0)+24>>2]&127](_,t),S[w>>0]&1?e[e[w+8>>2]>>2]=0:S[w>>0]=0,e[w+4>>2]=0,g=0,Ae(93,w|0,0),h=g,g=0,h&1)h=j(0)|0,$t(h);else{e[w>>2]=e[_>>2],e[w+4>>2]=e[_+4>>2],e[w+8>>2]=e[_+8>>2],e[_>>2]=0,e[_+4>>2]=0,e[_+8>>2]=0,Pt(_),ie=Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0;break}}while(!1);e[D>>2]=ie,b=oe}function yh(t,r,o,l,c,h,d,w,C,D,k,N,R,_,U){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0,k=k|0,N=N|0,R=R|0,_=_|0,U=U|0;var Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0,jt=0,Gt=0,s0=0,i0=0,zt=0;e[o>>2]=t,i0=_+4|0,zt=_+8|0,ke=R+4|0,Ee=(l&512|0)==0,Te=R+8|0,it=(U|0)>0,jt=N+4|0,Gt=N+8|0,s0=N+1|0,ne=(U|0)>0,oe=0;do{switch(S[C+oe>>0]|0){case 0:{e[r>>2]=e[o>>2];break}case 1:{e[r>>2]=e[o>>2],Z=U0[e[(e[d>>2]|0)+44>>2]&63](d,32)|0,ie=e[o>>2]|0,e[o>>2]=ie+4,e[ie>>2]=Z;break}case 3:{ie=S[_>>0]|0,Q=(ie&1)==0,(Q?(ie&255)>>>1:e[i0>>2]|0)|0&&(Z=e[(Q?i0:e[zt>>2]|0)>>2]|0,ie=e[o>>2]|0,e[o>>2]=ie+4,e[ie>>2]=Z);break}case 2:{if(P=S[R>>0]|0,Q=(P&1)==0,P=Q?(P&255)>>>1:e[ke>>2]|0,!(Ee|(P|0)==0)){if(Q=Q?ke:e[Te>>2]|0,G=Q+(P<<2)|0,$=e[o>>2]|0,P)for(K=$;e[K>>2]=e[Q>>2],Q=Q+4|0,(Q|0)!=(G|0);)K=K+4|0;e[o>>2]=$+(P<<2)}break}case 4:{Q=e[o>>2]|0,c=w?c+4|0:c;e:do if(c>>>0>>0){K=c;do{if(!(Yt[e[(e[d>>2]|0)+12>>2]&63](d,2048,e[K>>2]|0)|0))break e;K=K+4|0}while(K>>>0>>0)}else K=c;while(!1);if(it){if(K>>>0>c>>>0&ne){for(P=e[o>>2]|0,$=U;;)if(K=K+-4|0,G=P+4|0,e[P>>2]=e[K>>2],O=$+-1|0,$=($|0)>1,K>>>0>c>>>0&$)P=G,$=O;else{P=O;break}e[o>>2]=G,G=P}else $=ne,G=U;if($?O=U0[e[(e[d>>2]|0)+44>>2]&63](d,48)|0:O=0,Z=e[o>>2]|0,$=G+((G|0)<0?~G:-1)|0,(G|0)>0)for(P=Z;e[P>>2]=O,(G|0)>1;)P=P+4|0,G=G+-1|0;e[o>>2]=Z+($+2<<2),e[Z+($+1<<2)>>2]=D}if((K|0)==(c|0))Z=U0[e[(e[d>>2]|0)+44>>2]&63](d,48)|0,ie=e[o>>2]|0,K=ie+4|0,e[o>>2]=K,e[ie>>2]=Z;else{if(Z=S[N>>0]|0,G=(Z&1)==0,ie=e[jt>>2]|0,(G?(Z&255)>>>1:ie)|0?G=S[(G?s0:e[Gt>>2]|0)>>0]|0:G=-1,(K|0)!=(c|0))for(O=0,Z=0;$=e[o>>2]|0,(Z|0)==(G|0)?(P=$+4|0,e[o>>2]=P,e[$>>2]=k,O=O+1|0,$=S[N>>0]|0,G=($&1)==0,O>>>0<(G?($&255)>>>1:ie)>>>0?(G=S[(G?s0:e[Gt>>2]|0)+O>>0]|0,$=P,G=G<<24>>24==127?-1:G<<24>>24,P=0):($=P,G=Z,P=0)):P=Z,K=K+-4|0,Z=e[K>>2]|0,e[o>>2]=$+4,e[$>>2]=Z,(K|0)!=(c|0);)Z=P+1|0;K=e[o>>2]|0}if((Q|0)!=(K|0)&&(ce=K+-4|0,Q>>>0>>0)){K=ce;do ie=e[Q>>2]|0,e[Q>>2]=e[K>>2],e[K>>2]=ie,Q=Q+4|0,K=K+-4|0;while(Q>>>0>>0)}break}default:}oe=oe+1|0}while((oe|0)!=4);if(Q=S[_>>0]|0,c=(Q&1)==0,Q=c?(Q&255)>>>1:e[i0>>2]|0,Q>>>0>1){if(K=c?i0:e[zt>>2]|0,c=K+4|0,K=K+(Q<<2)|0,G=e[o>>2]|0,$=K-c|0,(Q|0)!=1)for(Q=G;e[Q>>2]=e[c>>2],c=c+4|0,(c|0)!=(K|0);)Q=Q+4|0;e[o>>2]=G+($>>>2<<2)}switch(l&176|0){case 32:{e[r>>2]=e[o>>2];break}case 16:break;default:e[r>>2]=t}}function Ch(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0;Z=b,b=b+480|0,R=Z+468|0,oe=Z+464|0,P=Z+472|0,K=Z+56|0,O=Z+52|0,ne=Z+40|0,ke=Z+28|0,ce=Z+16|0,D=Z+12|0,N=Z+64|0,$=Z+8|0,G=Z+4|0,_=Z,t=f0(l)|0,e[oe>>2]=t,g=0,U=be(37,oe|0,44212)|0,Q=g,g=0;do if(Q&1)Ee=13;else{if(k=S[h>>0]|0,d=(k&1)==0,Q=h+4|0,!((d?(k&255)>>>1:e[Q>>2]|0)|0))k=0;else{if(d=e[(d?Q:e[h+8>>2]|0)>>2]|0,g=0,w=be(e[(e[U>>2]|0)+44>>2]|0,U|0,45)|0,k=g,g=0,k&1){Ee=13;break}k=(d|0)==(w|0)}if(e[ne>>2]=0,e[ne+4>>2]=0,e[ne+8>>2]=0,e[ke>>2]=0,e[ke+4>>2]=0,e[ke+8>>2]=0,e[ce>>2]=0,e[ce+4>>2]=0,e[ce+8>>2]=0,g=0,I0(4,o|0,k|0,oe|0,P|0,K|0,O|0,ne|0,ke|0,ce|0,D|0),C=g,g=0,C&1)d=j()|0;else{if(C=S[h>>0]|0,o=e[Q>>2]|0,d=C&1?o:(C&255)>>>1,D=e[D>>2]|0,(d|0)>(D|0)?(Te=S[ce>>0]|0,w=S[ke>>0]|0,d=(d-D<<1|1)+D+(Te&1?e[ce+4>>2]|0:(Te&255)>>>1)+(w&1?e[ke+4>>2]|0:(w&255)>>>1)|0):(Te=S[ce>>0]|0,d=S[ke>>0]|0,d=D+2+(Te&1?e[ce+4>>2]|0:(Te&255)>>>1)+(d&1?e[ke+4>>2]|0:(d&255)>>>1)|0),d>>>0>100?(d=E0(d<<2)|0,w=d,d?Ee=17:(g=0,Nt(6),Te=g,g=0,Te&1||(C=S[h>>0]|0,o=e[Q>>2]|0,d=0,Ee=17))):(w=0,d=N,Ee=17),(Ee|0)==17&&(Te=(C&1)==0,h=Te?Q:e[h+8>>2]|0,g=0,Zt(2,d|0,$|0,G|0,e[l+4>>2]|0,h|0,h+((Te?(C&255)>>>1:o)<<2)|0,U|0,k|0,P|0,e[K>>2]|0,e[O>>2]|0,ne|0,ke|0,ce|0,D|0),Te=g,g=0,!(Te&1)&&(e[_>>2]=e[r>>2],Te=e[$>>2]|0,ie=e[G>>2]|0,g=0,e[R>>2]=e[_>>2],ie=Vt(40,R|0,d|0,Te|0,ie|0,l|0,c|0)|0,Te=g,g=0,!(Te&1))))return w&&(n0(w),t=e[oe>>2]|0),Pt(ce),Pt(ke),de(ne),Bt(t)|0,b=Z,ie|0;d=j()|0,w&&(n0(w),t=e[oe>>2]|0)}Pt(ce),Pt(ke),de(ne)}while(!1);return(Ee|0)==13&&(d=j()|0),Bt(t)|0,le(d|0),0}function Th(t){t=t|0}function Ih(t){t=t|0,he(t)}function Eh(t,r,o){return t=t|0,r=r|0,o=o|0,t=yo(S[r>>0]&1?e[r+8>>2]|0:r+1|0,1)|0,t>>>((t|0)!=-1&1)|0}function kh(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0;w=b,b=b+16|0,C=w,e[C>>2]=0,e[C+4>>2]=0,e[C+8>>2]=0,d=S[h>>0]|0,D=(d&1)==0,r=D?h+1|0:e[h+8>>2]|0,d=D?(d&255)>>>1:e[h+4>>2]|0,h=r+d|0;e:do if((d|0)>0){for(;g=0,Ae(67,C|0,S[r>>0]|0),D=g,g=0,!(D&1);)if(r=r+1|0,r>>>0>=h>>>0){d=4;break e}r=j()|0,d=7}else d=4;while(!1);e:do if((d|0)==4){if(g=0,r=Pe(19,((o|0)==-1?-1:o<<1)|0,l|0,c|0,(S[C>>0]&1?e[C+8>>2]|0:C+1|0)|0)|0,D=g,g=0,D&1){r=j()|0,d=7;break}e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,D=$i(r)|0,h=r+D|0;t:do if((D|0)>0){for(;g=0,Ae(67,t|0,S[r>>0]|0),D=g,g=0,!(D&1);)if(r=r+1|0,r>>>0>=h>>>0)break t;r=j()|0,de(t);break e}while(!1);de(C),b=w;return}while(!1);de(C),le(r|0)}function Dh(t,r){t=t|0,r=r|0}function bh(t){t=t|0}function Nh(t){t=t|0,he(t)}function Fh(t,r,o){return t=t|0,r=r|0,o=o|0,t=yo(S[r>>0]&1?e[r+8>>2]|0:r+1|0,1)|0,t>>>((t|0)!=-1&1)|0}function Rh(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;$=b,b=b+224|0,N=$+184|0,k=$+192|0,D=$+180|0,R=$+176|0,K=$+168|0,Q=$+40|0,U=$+32|0,G=$+28|0,P=$+16|0,C=$+8|0,_=$,e[P>>2]=0,e[P+4>>2]=0,e[P+8>>2]=0,e[C+4>>2]=0,e[C>>2]=44696,w=S[h>>0]|0,O=(w&1)==0,d=h+4|0,r=O?d:e[h+8>>2]|0,h=O?(w&255)>>>1:e[d>>2]|0,d=r+(h<<2)|0,w=k+32|0;e:do if((h|0)>0){t:for(;;){if(e[R>>2]=r,g=0,h=Xt(e[(e[C>>2]|0)+12>>2]|0,C|0,N|0,r|0,d|0,R|0,k|0,w|0,D|0)|0,O=g,g=0,O&1){h=12;break}if((h|0)==2||(e[R>>2]|0)==(r|0)){h=5;break}if(k>>>0<(e[D>>2]|0)>>>0){r=k;do{if(g=0,Ae(67,P|0,S[r>>0]|0),O=g,g=0,O&1){h=11;break t}r=r+1|0}while(r>>>0<(e[D>>2]|0)>>>0)}if(r=e[R>>2]|0,!((h|0)!=2&r>>>0>>0)){h=9;break e}}(h|0)==5?(g=0,ue(190,58955),g=0,r=j()|0):((h|0)==11||(h|0)==12)&&(r=j()|0)}else h=9;while(!1);e:do if((h|0)==9){if(g=0,r=Pe(19,((o|0)==-1?-1:o<<1)|0,l|0,c|0,(S[P>>0]&1?e[P+8>>2]|0:P+1|0)|0)|0,O=g,g=0,O&1){r=j()|0;break}e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[_+4>>2]=0,e[_>>2]=44744,O=$i(r)|0,d=r+O|0,w=d,C=Q+128|0;t:do if((O|0)>0){i:for(;;){if(e[G>>2]=r,g=0,h=Xt(e[(e[_>>2]|0)+16>>2]|0,_|0,K|0,r|0,((w-r|0)>32?r+32|0:d)|0,G|0,Q|0,C|0,U|0)|0,O=g,g=0,O&1){h=24;break}if((h|0)==2||(e[G>>2]|0)==(r|0)){h=18;break}if(Q>>>0<(e[U>>2]|0)>>>0){r=Q;do{if(g=0,Ae(92,t|0,e[r>>2]|0),O=g,g=0,O&1){h=23;break i}r=r+4|0}while(r>>>0<(e[U>>2]|0)>>>0)}if(r=e[G>>2]|0,!((h|0)!=2&r>>>0>>0))break t}(h|0)==18?(g=0,ue(190,58955),g=0,r=j()|0):((h|0)==23||(h|0)==24)&&(r=j()|0),Pt(t);break e}while(!1);de(P),b=$;return}while(!1);de(P),le(r|0)}function Mh(t,r){t=t|0,r=r|0}function _h(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0;if(e[t+4>>2]=r+-1,e[t>>2]=44196,h=t+8|0,g=0,Ae(94,h|0,28),c=g,g=0,c&1)r=j()|0;else{if(c=t+144|0,g=0,xe(5,c|0,58885,1),l=g,g=0,l&1)r=j()|0;else{if(o=e[h>>2]|0,l=t+12|0,r=e[l>>2]|0,(r|0)!=(o|0)){do r=r+-4|0;while((r|0)!=(o|0));e[l>>2]=r}e[495]=0,e[494]=43124,g=0,Ae(95,t|0,1976),l=g,g=0;do if(!(l&1)&&(e[497]=0,e[496]=43164,g=0,Ae(96,t|0,1984),l=g,g=0,!(l&1))&&(e[499]=0,e[498]=44236,e[500]=0,S[2004]=0,l=nn()|0,e[500]=l,g=0,Ae(97,t|0,1992),l=g,g=0,!(l&1))&&(e[503]=0,e[502]=44484,g=0,Ae(98,t|0,2008),l=g,g=0,!(l&1))&&(e[505]=0,e[504]=44552,g=0,Ae(99,t|0,2016),l=g,g=0,!(l&1))&&(g=0,Ae(100,2024,1),l=g,g=0,!(l&1))&&(g=0,Ae(101,t|0,2024),l=g,g=0,!(l&1))&&(e[511]=0,e[510]=44600,g=0,Ae(102,t|0,2040),l=g,g=0,!(l&1))&&(e[513]=0,e[512]=44648,g=0,Ae(103,t|0,2048),l=g,g=0,!(l&1))&&(i4(2056,1),g=0,Ae(104,t|0,2056),l=g,g=0,!(l&1))&&(n4(2080,1),g=0,Ae(105,t|0,2080),l=g,g=0,!(l&1))&&(e[529]=0,e[528]=43204,g=0,Ae(106,t|0,2112),l=g,g=0,!(l&1))&&(e[531]=0,e[530]=43276,g=0,Ae(107,t|0,2120),l=g,g=0,!(l&1))&&(e[533]=0,e[532]=43348,g=0,Ae(108,t|0,2128),l=g,g=0,!(l&1))){if(e[535]=0,e[534]=43408,g=0,Ae(109,t|0,2136),l=g,g=0,l&1){d=42;break}if(e[537]=0,e[536]=43716,g=0,Ae(110,t|0,2144),l=g,g=0,l&1){d=42;break}if(e[539]=0,e[538]=43780,g=0,Ae(111,t|0,2152),l=g,g=0,l&1){d=42;break}if(e[541]=0,e[540]=43844,g=0,Ae(112,t|0,2160),l=g,g=0,l&1){d=42;break}if(e[543]=0,e[542]=43908,g=0,Ae(113,t|0,2168),l=g,g=0,l&1){d=42;break}if(e[545]=0,e[544]=43972,g=0,Ae(114,t|0,2176),l=g,g=0,l&1){d=42;break}if(e[547]=0,e[546]=44008,g=0,Ae(115,t|0,2184),l=g,g=0,l&1){d=42;break}if(e[549]=0,e[548]=44044,g=0,Ae(116,t|0,2192),l=g,g=0,l&1){d=42;break}if(e[551]=0,e[550]=44080,g=0,Ae(117,t|0,2200),l=g,g=0,l&1){d=42;break}if(e[553]=0,e[552]=43468,e[554]=43516,g=0,Ae(118,t|0,2208),l=g,g=0,l&1){d=42;break}if(e[557]=0,e[556]=43560,e[558]=43608,g=0,Ae(119,t|0,2224),l=g,g=0,l&1){d=42;break}if(e[561]=0,e[560]=44464,g=0,r=Ce(3)|0,l=g,g=0,l&1){r=j()|0;break}if(e[562]=r,e[560]=43652,g=0,Ae(120,t|0,2240),l=g,g=0,l&1){d=42;break}if(e[565]=0,e[564]=44464,g=0,r=Ce(3)|0,l=g,g=0,l&1){r=j()|0;break}if(e[566]=r,e[564]=43684,g=0,Ae(121,t|0,2256),d=g,g=0,d&1){d=42;break}if(e[569]=0,e[568]=44116,g=0,Ae(122,t|0,2272),d=g,g=0,d&1){d=42;break}if(e[571]=0,e[570]=44156,g=0,Ae(123,t|0,2280),d=g,g=0,d&1){d=42;break}return}else d=42;while(!1);(d|0)==42&&(r=j()|0),de(c)}yr(h)}le(r|0)}function Ph(){var t=0;do if(!(S[2288]|0)&&kt(2288)|0)if(g=0,Ce(4)|0,t=g,g=0,t&1)t=j()|0,W0(2288),le(t|0);else{e[11246]=44980,bt(2288);break}while(!1);return e[11246]|0}function w0(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;pn(r),c=t+8|0,l=e[c>>2]|0;do if((e[t+12>>2]|0)-l>>2>>>0<=o>>>0){if(g=0,Ae(124,c|0,o+1|0),t=g,g=0,!(t&1)){l=e[c>>2]|0;break}l=j()|0,r&&Bt(r)|0,le(l|0)}while(!1);t=e[l+(o<<2)>>2]|0,t&&(Bt(t)|0,l=e[c>>2]|0),e[l+(o<<2)>>2]=r}function Rs(t){t=t|0;var r=0,o=0,l=0,c=0;if(e[t>>2]=44196,l=t+8|0,c=t+12|0,r=e[l>>2]|0,(e[c>>2]|0)!=(r|0)){o=0;do r=e[r+(o<<2)>>2]|0,r&&Bt(r)|0,o=o+1|0,r=e[l>>2]|0;while(o>>>0<(e[c>>2]|0)-r>>2>>>0)}de(t+144|0),yr(l)}function Lh(t){t=t|0,Rs(t),he(t)}function Oh(t,r){return t=t|0,r=r|0,P3(t,r)|0?e[(e[t+8>>2]|0)+(r<<2)>>2]|0:(t=Ct(4)|0,B6(t),Qt(t|0,640,82),0)}function $h(){return _h(2296,1),e[11245]=2296,44980}function Bh(){var t=0;return t=Ph()|0,t=e[t>>2]|0,e[11247]=t,pn(t),44988}function Vh(){var t=0;do if(!(S[2456]|0)&&kt(2456)|0)if(g=0,Ce(5)|0,t=g,g=0,t&1)t=j()|0,W0(2456),le(t|0);else{e[11248]=44988,bt(2456);break}while(!1);return e[11248]|0}function ur(t){t=t|0;var r=0,o=0;if(g=0,r=Ce(6)|0,o=g,g=0,o&1)o=j(0)|0,$t(o);else{o=e[r>>2]|0,e[t>>2]=o,pn(o);return}}function tn(t,r){t=t|0,r=r|0,r=e[r>>2]|0,e[t>>2]=r,pn(r)}function _0(t){t=t|0,Bt(e[t>>2]|0)|0}function x0(t){t=t|0;var r=0,o=0;return o=b,b=b+16|0,r=o,(e[t>>2]|0)!=-1&&(e[r>>2]=t,e[r+4>>2]=191,e[r+8>>2]=0,gp(t,r,192)),b=o,(e[t+4>>2]|0)+-1|0}function O0(t,r){return t=t|0,r=r|0,t=e[t>>2]|0,Oh(t,x0(r)|0)|0}function Uh(t){t=t|0,he(t)}function Gh(t){t=t|0,t&&Mt[e[(e[t>>2]|0)+4>>2]&255](t)}function qh(t){t=t|0;var r=0;r=e[11052]|0,e[11052]=r+1,e[t+4>>2]=r+1}function Wh(t){t=t|0,he(t)}function Hh(t,r,o){return t=t|0,r=r|0,o=o|0,o>>>0<128?(o=(nn()|0)+(o<<1)|0,o=(E[o>>1]&r)<<16>>16!=0):o=0,o|0}function nn(){var t=0,r=0;if(g=0,t=Ce(7)|0,r=g,g=0,r&1)r=j(0)|0,$t(r);else return e[t>>2]|0;return 0}function Qh(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;if(h=(o-r|0)>>>2,(r|0)!=(o|0))for(c=r;t=e[c>>2]|0,t>>>0<128?(t=(nn()|0)+(t<<1)|0,t=M[t>>1]|0):t=0,E[l>>1]=t,c=c+4|0,(c|0)!=(o|0);)l=l+2|0;return r+(h<<2)|0}function Kh(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;e:do if((o|0)==(l|0))o=l;else for(;;){if(t=e[o>>2]|0,t>>>0<128&&(t=(nn()|0)+(t<<1)|0,(E[t>>1]&r)<<16>>16!=0))break e;if(o=o+4|0,(o|0)==(l|0)){o=l;break}}while(!1);return o|0}function Yh(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;e:do if((o|0)==(l|0))o=l;else for(;;){if(t=e[o>>2]|0,t>>>0>=128||(t=(nn()|0)+(t<<1)|0,!((E[t>>1]&r)<<16>>16)))break e;if(o=o+4|0,(o|0)==(l|0)){o=l;break}}while(!1);return o|0}function jh(t,r){return t=t|0,r=r|0,r>>>0<128&&(r=(hn()|0)+(r<<2)|0,r=e[r>>2]|0),r|0}function hn(){var t=0,r=0;if(g=0,t=Ce(8)|0,r=g,g=0,r&1)r=j(0)|0,$t(r);else return e[t>>2]|0;return 0}function Xh(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;if(c=(o-r|0)>>>2,(r|0)!=(o|0)){l=r;do t=e[l>>2]|0,t>>>0<128&&(t=(hn()|0)+(t<<2)|0,t=e[t>>2]|0),e[l>>2]=t,l=l+4|0;while((l|0)!=(o|0))}return r+(c<<2)|0}function Zh(t,r){return t=t|0,r=r|0,r>>>0<128&&(r=(dn()|0)+(r<<2)|0,r=e[r>>2]|0),r|0}function dn(){var t=0,r=0;if(g=0,t=Ce(9)|0,r=g,g=0,r&1)r=j(0)|0,$t(r);else return e[t>>2]|0;return 0}function Jh(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;if(c=(o-r|0)>>>2,(r|0)!=(o|0)){l=r;do t=e[l>>2]|0,t>>>0<128&&(t=(dn()|0)+(t<<2)|0,t=e[t>>2]|0),e[l>>2]=t,l=l+4|0;while((l|0)!=(o|0))}return r+(c<<2)|0}function ed(t,r){return t=t|0,r=r|0,r<<24>>24|0}function id(t,r,o,l){if(t=t|0,r=r|0,o=o|0,l=l|0,(r|0)!=(o|0))for(;e[l>>2]=S[r>>0],r=r+1|0,(r|0)!=(o|0);)l=l+4|0;return o|0}function nd(t,r,o){return t=t|0,r=r|0,o=o|0,(r>>>0<128?r&255:o)|0}function rd(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;if(d=(o-r|0)>>>2,(r|0)!=(o|0))for(h=r,t=c;c=e[h>>2]|0,S[t>>0]=c>>>0<128?c&255:l,h=h+4|0,(h|0)!=(o|0);)t=t+1|0;return r+(d<<2)|0}function Ms(t){t=t|0;var r=0;e[t>>2]=44236,r=e[t+8>>2]|0,r|0&&S[t+12>>0]|0&&N6(r)}function sd(t){t=t|0,Ms(t),he(t)}function od(t,r){return t=t|0,r=r|0,r<<24>>24>-1&&(r=(hn()|0)+((r&255)<<2)|0,r=e[r>>2]&255),r|0}function ad(t,r,o){if(t=t|0,r=r|0,o=o|0,(r|0)!=(o|0)){t=r;do r=S[t>>0]|0,r<<24>>24>-1&&(r=(hn()|0)+(r<<24>>24<<2)|0,r=e[r>>2]&255),S[t>>0]=r,t=t+1|0;while((t|0)!=(o|0))}return o|0}function ld(t,r){return t=t|0,r=r|0,r<<24>>24>-1&&(r=(dn()|0)+(r<<24>>24<<2)|0,r=e[r>>2]&255),r|0}function ud(t,r,o){if(t=t|0,r=r|0,o=o|0,(r|0)!=(o|0)){t=r;do r=S[t>>0]|0,r<<24>>24>-1&&(r=(dn()|0)+(r<<24>>24<<2)|0,r=e[r>>2]&255),S[t>>0]=r,t=t+1|0;while((t|0)!=(o|0))}return o|0}function cd(t,r){return t=t|0,r=r|0,r|0}function hd(t,r,o,l){if(t=t|0,r=r|0,o=o|0,l=l|0,(r|0)!=(o|0))for(;S[l>>0]=S[r>>0]|0,r=r+1|0,(r|0)!=(o|0);)l=l+1|0;return o|0}function dd(t,r,o){return t=t|0,r=r|0,o=o|0,(r<<24>>24>-1?r:o)|0}function pd(t,r,o,l,c){if(t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,(r|0)!=(o|0))for(;t=S[r>>0]|0,S[c>>0]=t<<24>>24>-1?t:l,r=r+1|0,(r|0)!=(o|0);)c=c+1|0;return o|0}function md(t){t=t|0,he(t)}function gd(t,r,o,l,c,h,d,w){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,e[c>>2]=o,e[w>>2]=h,3}function Sd(t,r,o,l,c,h,d,w){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,e[c>>2]=o,e[w>>2]=h,3}function Ad(t,r,o,l,c){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,e[c>>2]=o,3}function vd(t){return t=t|0,1}function xd(t){return t=t|0,1}function wd(t,r,o,l,c){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,t=l-o|0,(t>>>0>>0?t:c)|0}function yd(t){return t=t|0,1}function Cd(t,r){t=t|0,r=r|0;var o=0;if(e[t+4>>2]=r+-1,e[t>>2]=44304,g=0,r=Ce(3)|0,o=g,g=0,o&1)o=j()|0,le(o|0);else{e[t+8>>2]=r;return}}function Td(t){t=t|0,io(t),he(t)}function cr(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0,jt=0,Gt=0,s0=0,i0=0,zt=0,gt=0,Kt=0,dt=0,At=0,y0=0,T0=0,g0=0,Oe=0,yt=0,qt=0,c0=0,a0=0,h0=0,D0=0,A0=0,Ti=0,F0=0,Si=0;Si=b,b=b+624|0,h0=Si+24|0,A0=Si+16|0,D0=Si+588|0,Oe=Si+576|0,a0=Si,y0=Si+536|0,F0=Si+8|0,Ti=Si+528|0,jt=(t|0)!=0,Gt=y0+40|0,At=Gt,y0=y0+39|0,T0=F0+4|0,g0=Oe+12|0,Oe=Oe+11|0,yt=D0,qt=g0,c0=qt-yt|0,s0=-2-yt|0,i0=qt+2|0,zt=h0+288|0,gt=D0+9|0,Kt=gt,dt=D0+8|0,h=0,Q=r,d=0,r=0;e:for(;;){do if((h|0)>-1)if((d|0)>(2147483647-h|0)){h=S0()|0,e[h>>2]=75,h=-1;break}else{h=d+h|0;break}while(!1);if(d=S[Q>>0]|0,d<<24>>24)w=Q;else{it=245;break}t:for(;;){switch(d<<24>>24){case 37:{d=w,it=9;break t}case 0:{d=w;break t}default:}Te=w+1|0,d=S[Te>>0]|0,w=Te}t:do if((it|0)==9)for(;;){if(it=0,(S[d+1>>0]|0)!=37)break t;if(w=w+1|0,d=d+2|0,(S[d>>0]|0)==37)it=9;else break}while(!1);if(G=w-Q|0,jt&&!(e[t>>2]&32|0)&&B0(Q,G,t)|0,(w|0)!=(Q|0)){Q=d,d=G;continue}k=d+1|0,w=S[k>>0]|0,C=(w<<24>>24)+-48|0,C>>>0<10?(Te=(S[d+2>>0]|0)==36,k=Te?d+3|0:k,w=S[k>>0]|0,_=Te?C:-1,r=Te?1:r):_=-1,d=w<<24>>24;t:do if((d&-32|0)==32)for(C=0;;){if(!(1<>24)+-32|C,k=k+1|0,w=S[k>>0]|0,d=w<<24>>24,(d&-32|0)!=32){N=C,d=k;break}}else N=0,d=k;while(!1);do if(w<<24>>24==42){if(C=d+1|0,w=(S[C>>0]|0)+-48|0,w>>>0<10&&(S[d+2>>0]|0)==36)e[c+(w<<2)>>2]=10,r=1,d=d+3|0,w=e[l+((S[C>>0]|0)+-48<<3)>>2]|0;else{if(r){h=-1;break e}if(!jt){K=N,d=C,r=0,Te=0;break}r=(e[o>>2]|0)+3&-4,w=e[r>>2]|0,e[o>>2]=r+4,r=0,d=C}(w|0)<0?(K=N|8192,Te=0-w|0):(K=N,Te=w)}else if(C=(w<<24>>24)+-48|0,C>>>0<10){w=0;do w=(w*10|0)+C|0,d=d+1|0,C=(S[d>>0]|0)+-48|0;while(C>>>0<10);if((w|0)<0){h=-1;break e}else K=N,Te=w}else K=N,Te=0;while(!1);t:do if((S[d>>0]|0)==46){if(C=d+1|0,w=S[C>>0]|0,w<<24>>24!=42){if(k=(w<<24>>24)+-48|0,k>>>0<10)d=C,w=0;else{d=C,k=0;break}for(;;)if(w=(w*10|0)+k|0,d=d+1|0,k=(S[d>>0]|0)+-48|0,k>>>0>=10){k=w;break t}}if(C=d+2|0,w=(S[C>>0]|0)+-48|0,w>>>0<10&&(S[d+3>>0]|0)==36){e[c+(w<<2)>>2]=10,d=d+4|0,k=e[l+((S[C>>0]|0)+-48<<3)>>2]|0;break}if(r){h=-1;break e}jt?(d=(e[o>>2]|0)+3&-4,k=e[d>>2]|0,e[o>>2]=d+4,d=C):(d=C,k=0)}else k=-1;while(!1);for(R=0;;){if(w=(S[d>>0]|0)+-65|0,w>>>0>57){h=-1;break e}if(C=d+1|0,w=S[56223+(R*58|0)+w>>0]|0,N=w&255,(N+-1|0)>>>0<8)d=C,R=N;else{Ee=C;break}}if(!(w<<24>>24)){h=-1;break}C=(_|0)>-1;do if(w<<24>>24==19)if(C){h=-1;break e}else it=52;else{if(C){e[c+(_<<2)>>2]=N,ce=l+(_<<3)|0,ke=e[ce+4>>2]|0,it=a0,e[it>>2]=e[ce>>2],e[it+4>>2]=ke,it=52;break}if(!jt){h=0;break e}Ps(a0,N,o)}while(!1);if((it|0)==52&&(it=0,!jt)){Q=Ee,d=G;continue}_=S[d>>0]|0,_=(R|0)!=0&(_&15|0)==3?_&-33:_,C=K&-65537,ke=K&8192|0?C:K;t:do switch(_|0){case 110:switch(R|0){case 0:{e[e[a0>>2]>>2]=h,Q=Ee,d=G;continue e}case 1:{e[e[a0>>2]>>2]=h,Q=Ee,d=G;continue e}case 2:{Q=e[a0>>2]|0,e[Q>>2]=h,e[Q+4>>2]=((h|0)<0)<<31>>31,Q=Ee,d=G;continue e}case 3:{E[e[a0>>2]>>1]=h,Q=Ee,d=G;continue e}case 4:{S[e[a0>>2]>>0]=h,Q=Ee,d=G;continue e}case 6:{e[e[a0>>2]>>2]=h,Q=Ee,d=G;continue e}case 7:{Q=e[a0>>2]|0,e[Q>>2]=h,e[Q+4>>2]=((h|0)<0)<<31>>31,Q=Ee,d=G;continue e}default:{Q=Ee,d=G;continue e}}case 112:{R=ke|8,k=k>>>0>8?k:8,_=120,it=64;break}case 88:case 120:{R=ke,it=64;break}case 111:{if(C=a0,w=e[C>>2]|0,C=e[C+4>>2]|0,(w|0)==0&(C|0)==0)d=Gt;else{d=Gt;do d=d+-1|0,S[d>>0]=w&7|48,w=Di(w|0,C|0,3)|0,C=ye;while(!((w|0)==0&(C|0)==0))}ke&8?(R=At-d+1|0,w=ke,k=(k|0)<(R|0)?R:k,R=0,N=56703,it=77):(w=ke,R=0,N=56703,it=77);break}case 105:case 100:{if(w=a0,d=e[w>>2]|0,w=e[w+4>>2]|0,(w|0)<0){d=ii(0,0,d|0,w|0)|0,w=ye,C=a0,e[C>>2]=d,e[C+4>>2]=w,C=1,N=56703,it=76;break t}ke&2048?(C=1,N=56704,it=76):(N=ke&1,C=N,N=N|0?56705:56703,it=76);break}case 117:{w=a0,d=e[w>>2]|0,w=e[w+4>>2]|0,C=0,N=56703,it=76;break}case 99:{S[y0>>0]=e[a0>>2],Q=y0,w=1,R=0,_=56703,d=Gt;break}case 109:{d=S0()|0,d=vo(e[d>>2]|0)|0,it=82;break}case 115:{d=e[a0>>2]|0,d=d|0?d:56713,it=82;break}case 67:{e[F0>>2]=e[a0>>2],e[T0>>2]=0,e[a0>>2]=F0,k=-1,it=86;break}case 83:{k?it=86:(z0(t,32,Te,0,ke),d=0,it=98);break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{D=+B[a0>>3],e[A0>>2]=0,B[q>>3]=D,(e[q+4>>2]|0)>=0?ke&2048?(ne=1,ce=56723):(ce=ke&1,ne=ce,ce=ce|0?56726:56721):(D=-D,ne=1,ce=56720),B[q>>3]=D,oe=e[q+4>>2]&2146435072;do if(oe>>>0<2146435072|(oe|0)==2146435072&!1){if(U=+yS(D,A0)*2,w=U!=0,w&&(e[A0>>2]=(e[A0>>2]|0)+-1),Z=_|32,(Z|0)==97){Q=_&32,G=Q|0?ce+9|0:ce,K=ne|2,d=12-k|0;do if(k>>>0>11|(d|0)==0)D=U;else{D=8;do d=d+-1|0,D=D*16;while(d|0);if((S[G>>0]|0)==45){D=-(D+(-U-D));break}else{D=U+D-D;break}}while(!1);for(w=e[A0>>2]|0,d=(w|0)<0?0-w|0:w,d=zi(d,((d|0)<0)<<31>>31,g0)|0,(d|0)==(g0|0)&&(S[Oe>>0]=48,d=Oe),S[d+-1>>0]=(w>>31&2)+43,R=d+-2|0,S[R>>0]=_+15,N=(k|0)<1,C=(ke&8|0)==0,w=D0;;){ce=~~D,d=w+1|0,S[w>>0]=F[56687+ce>>0]|Q,D=(D-+(ce|0))*16;do if((d-yt|0)==1){if(C&(N&D==0))break;S[d>>0]=46,d=w+2|0}while(!1);if(D==0)break;w=d}k=(k|0)!=0&(s0+d|0)<(k|0)?i0+k-R|0:c0-R+d|0,C=k+K|0,z0(t,32,Te,C,ke),e[t>>2]&32||B0(G,K,t)|0,z0(t,48,Te,C,ke^65536),d=d-yt|0,e[t>>2]&32||B0(D0,d,t)|0,w=qt-R|0,z0(t,48,k-(d+w)|0,0,0),e[t>>2]&32||B0(R,w,t)|0,z0(t,32,Te,C,ke^8192),d=(C|0)<(Te|0)?Te:C;break}d=(k|0)<0?6:k,w?(w=(e[A0>>2]|0)+-28|0,e[A0>>2]=w,D=U*268435456):(D=U,w=e[A0>>2]|0),oe=(w|0)<0?h0:zt,ie=oe,w=oe;do O=~~D>>>0,e[w>>2]=O,w=w+4|0,D=(D-+(O>>>0))*1e9;while(D!=0);if(C=w,w=e[A0>>2]|0,(w|0)>0)for(N=oe;;){R=(w|0)>29?29:w,k=C+-4|0;do if(k>>>0>>0)k=N;else{w=0;do O=v0(e[k>>2]|0,0,R|0)|0,O=$0(O|0,ye|0,w|0,0)|0,w=ye,P=Cr(O|0,w|0,1e9,0)|0,e[k>>2]=P,w=xn(O|0,w|0,1e9,0)|0,k=k+-4|0;while(k>>>0>=N>>>0);if(!w){k=N;break}k=N+-4|0,e[k>>2]=w}while(!1);for(;!(C>>>0<=k>>>0);)if(w=C+-4|0,!(e[w>>2]|0))C=w;else break;if(w=(e[A0>>2]|0)-R|0,e[A0>>2]=w,(w|0)>0)N=k;else break}else k=oe;if((w|0)<0)for(G=((d+25|0)/9|0)+1|0,$=(Z|0)==102,Q=k;;){K=0-w|0,K=(K|0)>9?9:K;do if(Q>>>0>>0){w=(1<>>K,k=0,R=Q;do O=e[R>>2]|0,e[R>>2]=(O>>>K)+k,k=ee(O&w,N)|0,R=R+4|0;while(R>>>0>>0);if(w=e[Q>>2]|0?Q:Q+4|0,!k){k=w;break}e[C>>2]=k,k=w,C=C+4|0}else k=e[Q>>2]|0?Q:Q+4|0;while(!1);if(w=$?oe:k,C=(C-w>>2|0)>(G|0)?w+(G<<2)|0:C,w=(e[A0>>2]|0)+K|0,e[A0>>2]=w,(w|0)>=0){Q=k;break}else Q=k}else Q=k;do if(Q>>>0>>0){if(w=(ie-Q>>2)*9|0,N=e[Q>>2]|0,N>>>0<10)break;k=10;do k=k*10|0,w=w+1|0;while(N>>>0>=k>>>0)}else w=0;while(!1);if(P=(Z|0)==103,O=(d|0)!=0,k=d-((Z|0)!=102?w:0)+((O&P)<<31>>31)|0,(k|0)<(((C-ie>>2)*9|0)+-9|0)){if(R=k+9216|0,$=(R|0)/9|0,k=oe+($+-1023<<2)|0,R=((R|0)%9|0)+1|0,(R|0)<9){N=10;do N=N*10|0,R=R+1|0;while((R|0)!=9)}else N=10;K=e[k>>2]|0,G=(K>>>0)%(N>>>0)|0,!(G|0)&&(oe+($+-1022<<2)|0)==(C|0)?N=Q:it=163;do if((it|0)==163){it=0,U=((K>>>0)/(N>>>0)|0)&1|0?9007199254740994:9007199254740992,R=(N|0)/2|0;do if(G>>>0>>0)D=.5;else{if((G|0)==(R|0)&&(oe+($+-1022<<2)|0)==(C|0)){D=1;break}D=1.5}while(!1);do if(ne){if((S[ce>>0]|0)!=45)break;U=-U,D=-D}while(!1);if(R=K-G|0,e[k>>2]=R,U+D==U){N=Q;break}if(Z=R+N|0,e[k>>2]=Z,Z>>>0>999999999)for(w=Q;;)if(N=k+-4|0,e[k>>2]=0,N>>>0>>0&&(w=w+-4|0,e[w>>2]=0),Z=(e[N>>2]|0)+1|0,e[N>>2]=Z,Z>>>0>999999999)k=N;else{Q=w,k=N;break}if(w=(ie-Q>>2)*9|0,R=e[Q>>2]|0,R>>>0<10){N=Q;break}else N=10;do N=N*10|0,w=w+1|0;while(R>>>0>=N>>>0);N=Q}while(!1);Z=k+4|0,Q=N,C=C>>>0>Z>>>0?Z:C}for(G=0-w|0;;){if(C>>>0<=Q>>>0){$=0,Z=C;break}if(k=C+-4|0,!(e[k>>2]|0))C=k;else{$=1,Z=C;break}}do if(P){if(d=(O&1^1)+d|0,(d|0)>(w|0)&(w|0)>-5?(_=_+-1|0,d=d+-1-w|0):(_=_+-2|0,d=d+-1|0),C=ke&8,C)break;do if($){if(C=e[Z+-4>>2]|0,!C){k=9;break}if(!((C>>>0)%10|0))N=10,k=0;else{k=0;break}do N=N*10|0,k=k+1|0;while(!((C>>>0)%(N>>>0)|0|0))}else k=9;while(!1);if(C=((Z-ie>>2)*9|0)+-9|0,(_|32|0)==102){C=C-k|0,C=(C|0)<0?0:C,d=(d|0)<(C|0)?d:C,C=0;break}else{C=C+w-k|0,C=(C|0)<0?0:C,d=(d|0)<(C|0)?d:C,C=0;break}}else C=ke&8;while(!1);if(K=d|C,N=(K|0)!=0&1,R=(_|32|0)==102,R)w=(w|0)>0?w:0,_=0;else{if(k=(w|0)<0?G:w,k=zi(k,((k|0)<0)<<31>>31,g0)|0,(qt-k|0)<2)do k=k+-1|0,S[k>>0]=48;while((qt-k|0)<2);S[k+-1>>0]=(w>>31&2)+43,ie=k+-2|0,S[ie>>0]=_,w=qt-ie|0,_=ie}G=ne+1+d+N+w|0,z0(t,32,Te,G,ke),e[t>>2]&32||B0(ce,ne,t)|0,z0(t,48,Te,G,ke^65536);do if(R){k=Q>>>0>oe>>>0?oe:Q,w=k;do{C=zi(e[w>>2]|0,0,gt)|0;do if((w|0)==(k|0)){if((C|0)!=(gt|0))break;S[dt>>0]=48,C=dt}else{if(C>>>0<=D0>>>0)break;do C=C+-1|0,S[C>>0]=48;while(C>>>0>D0>>>0)}while(!1);e[t>>2]&32||B0(C,Kt-C|0,t)|0,w=w+4|0}while(w>>>0<=oe>>>0);do if(K){if(e[t>>2]&32)break;B0(56755,1,t)|0}while(!1);if((d|0)>0&w>>>0>>0)for(C=w;;){if(w=zi(e[C>>2]|0,0,gt)|0,w>>>0>D0>>>0)do w=w+-1|0,S[w>>0]=48;while(w>>>0>D0>>>0);if(e[t>>2]&32||B0(w,(d|0)>9?9:d,t)|0,C=C+4|0,w=d+-9|0,(d|0)>9&C>>>0>>0)d=w;else{d=w;break}}z0(t,48,d+9|0,9,0)}else{if(R=$?Z:Q+4|0,(d|0)>-1){N=(C|0)==0,k=Q;do{w=zi(e[k>>2]|0,0,gt)|0,(w|0)==(gt|0)&&(S[dt>>0]=48,w=dt);do if((k|0)==(Q|0)){if(C=w+1|0,e[t>>2]&32||B0(w,1,t)|0,N&(d|0)<1){w=C;break}if(e[t>>2]&32){w=C;break}B0(56755,1,t)|0,w=C}else{if(w>>>0<=D0>>>0)break;do w=w+-1|0,S[w>>0]=48;while(w>>>0>D0>>>0)}while(!1);C=Kt-w|0,e[t>>2]&32||B0(w,(d|0)>(C|0)?C:d,t)|0,d=d-C|0,k=k+4|0}while(k>>>0>>0&(d|0)>-1)}if(z0(t,48,d+18|0,18,0),e[t>>2]&32)break;B0(_,qt-_|0,t)|0}while(!1);z0(t,32,Te,G,ke^8192),d=(G|0)<(Te|0)?Te:G}else R=(_&32|0)!=0,N=D!=D|!1,w=N?0:ne,k=w+3|0,z0(t,32,Te,k,C),d=e[t>>2]|0,d&32||(B0(ce,w,t)|0,d=e[t>>2]|0),d&32||B0(N?R?56747:56751:R?56739:56743,3,t)|0,z0(t,32,Te,k,ke^8192),d=(k|0)<(Te|0)?Te:k;while(!1);Q=Ee;continue e}default:C=ke,w=k,R=0,_=56703,d=Gt}while(!1);t:do if((it|0)==64)if(C=a0,w=e[C>>2]|0,C=e[C+4>>2]|0,N=_&32,(w|0)==0&(C|0)==0)d=Gt,w=R,R=0,N=56703,it=77;else{d=Gt;do d=d+-1|0,S[d>>0]=F[56687+(w&15)>>0]|N,w=Di(w|0,C|0,4)|0,C=ye;while(!((w|0)==0&(C|0)==0));it=a0,(R&8|0)==0|(e[it>>2]|0)==0&(e[it+4>>2]|0)==0?(w=R,R=0,N=56703,it=77):(w=R,R=2,N=56703+(_>>4)|0,it=77)}else if((it|0)==76)d=zi(d,w,Gt)|0,w=ke,R=C,it=77;else if((it|0)==82)it=0,ke=Oo(d,0,k)|0,ce=(ke|0)==0,Q=d,w=ce?k:ke-d|0,R=0,_=56703,d=ce?d+k|0:ke;else if((it|0)==86){for(it=0,w=0,d=0,N=e[a0>>2]|0;C=e[N>>2]|0,!(!C||(d=Do(Ti,C)|0,(d|0)<0|d>>>0>(k-w|0)>>>0));)if(w=d+w|0,k>>>0>w>>>0)N=N+4|0;else break;if((d|0)<0){h=-1;break e}if(z0(t,32,Te,w,ke),!w)d=0,it=98;else for(C=0,k=e[a0>>2]|0;;){if(d=e[k>>2]|0,!d){d=w,it=98;break t}if(d=Do(Ti,d)|0,C=d+C|0,(C|0)>(w|0)){d=w,it=98;break t}if(e[t>>2]&32||B0(Ti,d,t)|0,C>>>0>=w>>>0){d=w,it=98;break}else k=k+4|0}}while(!1);if((it|0)==98){it=0,z0(t,32,Te,d,ke^8192),Q=Ee,d=(Te|0)>(d|0)?Te:d;continue}(it|0)==77&&(it=0,C=(k|0)>-1?w&-65537:w,w=a0,w=(e[w>>2]|0)!=0|(e[w+4>>2]|0)!=0,(k|0)!=0|w?(w=(w&1^1)+(At-d)|0,Q=d,w=(k|0)>(w|0)?k:w,_=N,d=Gt):(Q=Gt,w=0,_=N,d=Gt)),N=d-Q|0,w=(w|0)<(N|0)?N:w,k=R+w|0,d=(Te|0)<(k|0)?k:Te,z0(t,32,d,k,C),e[t>>2]&32||B0(_,R,t)|0,z0(t,48,d,k,C^65536),z0(t,48,w,N,0),e[t>>2]&32||B0(Q,N,t)|0,z0(t,32,d,k,C^8192),Q=Ee}e:do if((it|0)==245&&!t)if(r){for(h=1;r=e[c+(h<<2)>>2]|0,!!r;)if(Ps(l+(h<<3)|0,r,o),h=h+1|0,(h|0)>=10){h=1;break e}if((h|0)<10)for(;;){if(e[c+(h<<2)>>2]|0){h=-1;break e}if(h=h+1|0,(h|0)>=10){h=1;break}}else h=1}else h=0;while(!1);return b=Si,h|0}function Id(t,r,o){return t=t|0,r=r|0,o=o|0,_S(t,r,o)|0}function Ed(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0;w=b,b=b+112|0,d=w,c=d,h=c+112|0;do e[c>>2]=0,c=c+4|0;while((c|0)<(h|0));return c=d+4|0,e[c>>2]=t,h=d+8|0,e[h>>2]=-1,e[d+44>>2]=t,e[d+76>>2]=-1,oi(d,0),l=+xo(d,o,1),o=(e[c>>2]|0)-(e[h>>2]|0)+(e[d+108>>2]|0)|0,r&&(e[r>>2]=o|0?t+o|0:t),b=w,+l}function _s(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0;return C=b,b=b+112|0,w=C,e[w>>2]=0,h=w+4|0,e[h>>2]=t,e[w+44>>2]=t,d=w+8|0,e[d>>2]=(t|0)<0?-1:t+2147483647|0,e[w+76>>2]=-1,oi(w,0),l=wo(w,o,1,l,c)|0,r&&(e[r>>2]=t+((e[h>>2]|0)+(e[w+108>>2]|0)-(e[d>>2]|0))),b=C,l|0}function kd(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;return l=t+20|0,c=e[l>>2]|0,t=(e[t+16>>2]|0)-c|0,t=t>>>0>o>>>0?o:t,o0(c|0,r|0,t|0)|0,e[l>>2]=(e[l>>2]|0)+t,o|0}function Ps(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0;e:do if(r>>>0<=20)do switch(r|0){case 9:{l=(e[o>>2]|0)+3&-4,r=e[l>>2]|0,e[o>>2]=l+4,e[t>>2]=r;break e}case 10:{l=(e[o>>2]|0)+3&-4,r=e[l>>2]|0,e[o>>2]=l+4,l=t,e[l>>2]=r,e[l+4>>2]=((r|0)<0)<<31>>31;break e}case 11:{l=(e[o>>2]|0)+3&-4,r=e[l>>2]|0,e[o>>2]=l+4,l=t,e[l>>2]=r,e[l+4>>2]=0;break e}case 12:{l=(e[o>>2]|0)+7&-8,r=l,c=e[r>>2]|0,r=e[r+4>>2]|0,e[o>>2]=l+8,l=t,e[l>>2]=c,e[l+4>>2]=r;break e}case 13:{c=(e[o>>2]|0)+3&-4,l=e[c>>2]|0,e[o>>2]=c+4,l=(l&65535)<<16>>16,c=t,e[c>>2]=l,e[c+4>>2]=((l|0)<0)<<31>>31;break e}case 14:{c=(e[o>>2]|0)+3&-4,l=e[c>>2]|0,e[o>>2]=c+4,c=t,e[c>>2]=l&65535,e[c+4>>2]=0;break e}case 15:{c=(e[o>>2]|0)+3&-4,l=e[c>>2]|0,e[o>>2]=c+4,l=(l&255)<<24>>24,c=t,e[c>>2]=l,e[c+4>>2]=((l|0)<0)<<31>>31;break e}case 16:{c=(e[o>>2]|0)+3&-4,l=e[c>>2]|0,e[o>>2]=c+4,c=t,e[c>>2]=l&255,e[c+4>>2]=0;break e}case 17:{c=(e[o>>2]|0)+7&-8,h=+B[c>>3],e[o>>2]=c+8,B[t>>3]=h;break e}case 18:{c=(e[o>>2]|0)+7&-8,h=+B[c>>3],e[o>>2]=c+8,B[t>>3]=h;break e}default:break e}while(!1);while(!1)}function zi(t,r,o){t=t|0,r=r|0,o=o|0;var l=0;if(r>>>0>0|(r|0)==0&t>>>0>4294967295)for(;;)if(l=Cr(t|0,r|0,10,0)|0,o=o+-1|0,S[o>>0]=l|48,l=xn(t|0,r|0,10,0)|0,r>>>0>9|(r|0)==9&t>>>0>4294967295)t=l,r=ye;else{t=l;break}if(t)for(;o=o+-1|0,S[o>>0]=(t>>>0)%10|0|48,!(t>>>0<10);)t=(t>>>0)/10|0;return o|0}function z0(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0;w=b,b=b+256|0,d=w;do if((o|0)>(l|0)&(c&73728|0)==0){if(c=o-l|0,Jt(d|0,r|0,(c>>>0>256?256:c)|0)|0,r=e[t>>2]|0,h=(r&32|0)==0,c>>>0>255){l=o-l|0;do h&&(B0(d,256,t)|0,r=e[t>>2]|0),c=c+-256|0,h=(r&32|0)==0;while(c>>>0>255);if(h)c=l&255;else break}else if(!h)break;B0(d,c,t)|0}while(!1);b=w}function E0(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0,jt=0,Gt=0,s0=0,i0=0,zt=0,gt=0,Kt=0,dt=0;do if(t>>>0<245){if(_=t>>>0<11?16:t+11&-8,t=_>>>3,w=e[10218]|0,o=w>>>t,o&3){t=(o&1^1)+t|0,l=t<<1,o=40912+(l<<2)|0,l=40912+(l+2<<2)|0,c=e[l>>2]|0,h=c+8|0,d=e[h>>2]|0;do if((o|0)!=(d|0))if(d>>>0<(e[10222]|0)>>>0&&St(),r=d+12|0,(e[r>>2]|0)==(c|0)){e[r>>2]=o,e[l>>2]=d;break}else St();else e[10218]=w&~(1<>2]=dt|3,dt=c+(dt|4)|0,e[dt>>2]=e[dt>>2]|1,dt=h,dt|0}if(d=e[10220]|0,_>>>0>d>>>0){if(o){l=2<>>12&16,l=l>>>C,c=l>>>5&8,l=l>>>c,h=l>>>2&4,l=l>>>h,o=l>>>1&2,l=l>>>o,t=l>>>1&1,t=(c|C|h|o|t)+(l>>>t)|0,l=t<<1,o=40912+(l<<2)|0,l=40912+(l+2<<2)|0,h=e[l>>2]|0,C=h+8|0,c=e[C>>2]|0;do if((o|0)!=(c|0))if(c>>>0<(e[10222]|0)>>>0&&St(),r=c+12|0,(e[r>>2]|0)==(h|0)){e[r>>2]=o,e[l>>2]=c,D=e[10220]|0;break}else St();else e[10218]=w&~(1<>2]=_|3,w=h+_|0,e[h+(_|4)>>2]=d|1,e[h+dt>>2]=d,D&&(c=e[10223]|0,o=D>>>3,r=o<<1,l=40912+(r<<2)|0,t=e[10218]|0,o=1<>2]|0,r>>>0<(e[10222]|0)>>>0?St():(k=t,N=r)):(e[10218]=t|o,k=40912+(r+2<<2)|0,N=l),e[k>>2]=c,e[N+12>>2]=c,e[c+8>>2]=N,e[c+12>>2]=l),e[10220]=d,e[10223]=w,dt=C,dt|0}if(t=e[10219]|0,t){for(o=(t&0-t)+-1|0,Kt=o>>>12&16,o=o>>>Kt,gt=o>>>5&8,o=o>>>gt,dt=o>>>2&4,o=o>>>dt,t=o>>>1&2,o=o>>>t,l=o>>>1&1,l=e[41176+((gt|Kt|dt|t|l)+(o>>>l)<<2)>>2]|0,o=(e[l+4>>2]&-8)-_|0,t=l;;){if(r=e[t+16>>2]|0,!r&&(r=e[t+20>>2]|0,!r)){C=o;break}t=(e[r+4>>2]&-8)-_|0,dt=t>>>0>>0,o=dt?t:o,t=r,l=dt?r:l}h=e[10222]|0,l>>>0>>0&&St(),w=l+_|0,l>>>0>=w>>>0&&St(),d=e[l+24>>2]|0,o=e[l+12>>2]|0;do if((o|0)==(l|0)){if(t=l+20|0,r=e[t>>2]|0,!r&&(t=l+16|0,r=e[t>>2]|0,!r)){R=0;break}for(;;){if(o=r+20|0,c=e[o>>2]|0,c){r=c,t=o;continue}if(o=r+16|0,c=e[o>>2]|0,c)r=c,t=o;else break}if(t>>>0>>0)St();else{e[t>>2]=0,R=r;break}}else if(c=e[l+8>>2]|0,c>>>0>>0&&St(),r=c+12|0,(e[r>>2]|0)!=(l|0)&&St(),t=o+8|0,(e[t>>2]|0)==(l|0)){e[r>>2]=o,e[t>>2]=c,R=o;break}else St();while(!1);do if(d){if(r=e[l+28>>2]|0,t=41176+(r<<2)|0,(l|0)==(e[t>>2]|0)){if(e[t>>2]=R,!R){e[10219]=e[10219]&~(1<>>0<(e[10222]|0)>>>0&&St(),r=d+16|0,(e[r>>2]|0)==(l|0)?e[r>>2]=R:e[d+20>>2]=R,!R)break;t=e[10222]|0,R>>>0>>0&&St(),e[R+24>>2]=d,r=e[l+16>>2]|0;do if(r)if(r>>>0>>0)St();else{e[R+16>>2]=r,e[r+24>>2]=R;break}while(!1);if(r=e[l+20>>2]|0,r)if(r>>>0<(e[10222]|0)>>>0)St();else{e[R+20>>2]=r,e[r+24>>2]=R;break}}while(!1);return C>>>0<16?(dt=C+_|0,e[l+4>>2]=dt|3,dt=l+(dt+4)|0,e[dt>>2]=e[dt>>2]|1):(e[l+4>>2]=_|3,e[l+(_|4)>>2]=C|1,e[l+(C+_)>>2]=C,r=e[10220]|0,r&&(h=e[10223]|0,o=r>>>3,r=o<<1,c=40912+(r<<2)|0,t=e[10218]|0,o=1<>2]|0,t>>>0<(e[10222]|0)>>>0?St():(U=r,Q=t)):(e[10218]=t|o,U=40912+(r+2<<2)|0,Q=c),e[U>>2]=h,e[Q+12>>2]=h,e[h+8>>2]=Q,e[h+12>>2]=c),e[10220]=C,e[10223]=w),dt=l+8|0,dt|0}else Q=_}else Q=_}else if(t>>>0<=4294967231)if(t=t+11|0,N=t&-8,k=e[10219]|0,k){o=0-N|0,t=t>>>8,t?N>>>0>16777215?D=31:(Q=(t+1048320|0)>>>16&8,O=t<>>16&4,O=O<>>16&2,D=14-(U|Q|D)+(O<>>15)|0,D=N>>>(D+7|0)&1|D<<1):D=0,t=e[41176+(D<<2)>>2]|0;e:do if(!t)c=0,t=0,O=86;else for(d=o,c=0,w=N<<((D|0)==31?0:25-(D>>>1)|0),C=t,t=0;;){if(h=e[C+4>>2]&-8,o=h-N|0,o>>>0>>0)if((h|0)==(N|0)){h=C,t=C,O=90;break e}else t=C;else o=d;if(O=e[C+20>>2]|0,C=e[C+16+(w>>>31<<2)>>2]|0,c=(O|0)==0|(O|0)==(C|0)?c:O,C)d=o,w=w<<1;else{O=86;break}}while(!1);if((O|0)==86){if((c|0)==0&(t|0)==0){if(t=2<>>12&16,t=t>>>R,k=t>>>5&8,t=t>>>k,U=t>>>2&4,t=t>>>U,Q=t>>>1&2,t=t>>>Q,c=t>>>1&1,c=e[41176+((k|R|U|Q|c)+(t>>>c)<<2)>>2]|0,t=0}c?(h=c,O=90):(w=o,C=t)}if((O|0)==90)for(;;){if(O=0,Q=(e[h+4>>2]&-8)-N|0,c=Q>>>0>>0,o=c?Q:o,t=c?h:t,c=e[h+16>>2]|0,c){h=c,O=90;continue}if(h=e[h+20>>2]|0,h)O=90;else{w=o,C=t;break}}if(C|0&&w>>>0<((e[10220]|0)-N|0)>>>0){c=e[10222]|0,C>>>0>>0&&St(),d=C+N|0,C>>>0>=d>>>0&&St(),h=e[C+24>>2]|0,o=e[C+12>>2]|0;do if((o|0)==(C|0)){if(t=C+20|0,r=e[t>>2]|0,!r&&(t=C+16|0,r=e[t>>2]|0,!r)){_=0;break}for(;;){if(o=r+20|0,l=e[o>>2]|0,l){r=l,t=o;continue}if(o=r+16|0,l=e[o>>2]|0,l)r=l,t=o;else break}if(t>>>0>>0)St();else{e[t>>2]=0,_=r;break}}else if(l=e[C+8>>2]|0,l>>>0>>0&&St(),r=l+12|0,(e[r>>2]|0)!=(C|0)&&St(),t=o+8|0,(e[t>>2]|0)==(C|0)){e[r>>2]=o,e[t>>2]=l,_=o;break}else St();while(!1);do if(h){if(r=e[C+28>>2]|0,t=41176+(r<<2)|0,(C|0)==(e[t>>2]|0)){if(e[t>>2]=_,!_){e[10219]=e[10219]&~(1<>>0<(e[10222]|0)>>>0&&St(),r=h+16|0,(e[r>>2]|0)==(C|0)?e[r>>2]=_:e[h+20>>2]=_,!_)break;t=e[10222]|0,_>>>0>>0&&St(),e[_+24>>2]=h,r=e[C+16>>2]|0;do if(r)if(r>>>0>>0)St();else{e[_+16>>2]=r,e[r+24>>2]=_;break}while(!1);if(r=e[C+20>>2]|0,r)if(r>>>0<(e[10222]|0)>>>0)St();else{e[_+20>>2]=r,e[r+24>>2]=_;break}}while(!1);e:do if(w>>>0>=16){if(e[C+4>>2]=N|3,e[C+(N|4)>>2]=w|1,e[C+(w+N)>>2]=w,r=w>>>3,w>>>0<256){t=r<<1,l=40912+(t<<2)|0,o=e[10218]|0,r=1<>2]|0,t>>>0<(e[10222]|0)>>>0?St():(G=r,$=t)):(e[10218]=o|r,G=40912+(t+2<<2)|0,$=l),e[G>>2]=d,e[$+12>>2]=d,e[C+(N+8)>>2]=$,e[C+(N+12)>>2]=l;break}if(r=w>>>8,r?w>>>0>16777215?l=31:(Kt=(r+1048320|0)>>>16&8,dt=r<>>16&4,dt=dt<>>16&2,l=14-(gt|Kt|l)+(dt<>>15)|0,l=w>>>(l+7|0)&1|l<<1):l=0,r=41176+(l<<2)|0,e[C+(N+28)>>2]=l,e[C+(N+20)>>2]=0,e[C+(N+16)>>2]=0,t=e[10219]|0,o=1<>2]=d,e[C+(N+24)>>2]=r,e[C+(N+12)>>2]=d,e[C+(N+8)>>2]=d;break}r=e[r>>2]|0;t:do if((e[r+4>>2]&-8|0)!=(w|0)){for(l=w<<((l|0)==31?0:25-(l>>>1)|0);t=r+16+(l>>>31<<2)|0,o=e[t>>2]|0,!!o;)if((e[o+4>>2]&-8|0)==(w|0)){oe=o;break t}else l=l<<1,r=o;if(t>>>0<(e[10222]|0)>>>0)St();else{e[t>>2]=d,e[C+(N+24)>>2]=r,e[C+(N+12)>>2]=d,e[C+(N+8)>>2]=d;break e}}else oe=r;while(!1);if(r=oe+8|0,t=e[r>>2]|0,dt=e[10222]|0,t>>>0>=dt>>>0&oe>>>0>=dt>>>0){e[t+12>>2]=d,e[r>>2]=d,e[C+(N+8)>>2]=t,e[C+(N+12)>>2]=oe,e[C+(N+24)>>2]=0;break}else St()}else dt=w+N|0,e[C+4>>2]=dt|3,dt=C+(dt+4)|0,e[dt>>2]=e[dt>>2]|1;while(!1);return dt=C+8|0,dt|0}else Q=N}else Q=N;else Q=-1;while(!1);if(o=e[10220]|0,o>>>0>=Q>>>0)return r=o-Q|0,t=e[10223]|0,r>>>0>15?(e[10223]=t+Q,e[10220]=r,e[t+(Q+4)>>2]=r|1,e[t+o>>2]=r,e[t+4>>2]=Q|3):(e[10220]=0,e[10223]=0,e[t+4>>2]=o|3,dt=t+(o+4)|0,e[dt>>2]=e[dt>>2]|1),dt=t+8|0,dt|0;if(t=e[10221]|0,t>>>0>Q>>>0)return Kt=t-Q|0,e[10221]=Kt,dt=e[10224]|0,e[10224]=dt+Q,e[dt+(Q+4)>>2]=Kt|1,e[dt+4>>2]=Q|3,dt=dt+8|0,dt|0;do if(!(e[10336]|0))if(t=Wo(30)|0,t+-1&t)St();else{e[10338]=t,e[10337]=t,e[10339]=-1,e[10340]=-1,e[10341]=0,e[10329]=0,oe=(ea(0)|0)&-16^1431655768,e[10336]=oe;break}while(!1);if(C=Q+48|0,w=e[10338]|0,D=Q+47|0,d=w+D|0,w=0-w|0,k=d&w,k>>>0<=Q>>>0||(t=e[10328]|0,t|0&&($=e[10326]|0,oe=$+k|0,oe>>>0<=$>>>0|oe>>>0>t>>>0)))return dt=0,dt|0;e:do if(e[10329]&4)t=0,O=191;else{t=e[10224]|0;t:do if(t){for(c=41320;;){if(o=e[c>>2]|0,o>>>0<=t>>>0&&(K=c+4|0,(o+(e[K>>2]|0)|0)>>>0>t>>>0)){h=c,t=K;break}if(c=e[c+8>>2]|0,!c){O=174;break t}}if(o=d-(e[10221]|0)&w,o>>>0<2147483647)if(c=Mi(o|0)|0,oe=(c|0)==((e[h>>2]|0)+(e[t>>2]|0)|0),t=oe?o:0,oe){if((c|0)!=-1){Z=c,U=t,O=194;break e}}else O=184;else t=0}else O=174;while(!1);do if((O|0)==174)if(h=Mi(0)|0,(h|0)!=-1)if(t=h,o=e[10337]|0,c=o+-1|0,c&t?o=k-t+(c+t&0-o)|0:o=k,t=e[10326]|0,c=t+o|0,o>>>0>Q>>>0&o>>>0<2147483647){if(oe=e[10328]|0,oe|0&&c>>>0<=t>>>0|c>>>0>oe>>>0){t=0;break}if(c=Mi(o|0)|0,oe=(c|0)==(h|0),t=oe?o:0,oe){Z=h,U=t,O=194;break e}else O=184}else t=0;else t=0;while(!1);t:do if((O|0)==184){h=0-o|0;do if(C>>>0>o>>>0&(o>>>0<2147483647&(c|0)!=-1)&&(P=e[10338]|0,P=D-o+P&0-P,P>>>0<2147483647))if((Mi(P|0)|0)==-1){Mi(h|0)|0;break t}else{o=P+o|0;break}while(!1);if((c|0)!=-1){Z=c,U=o,O=194;break e}}while(!1);e[10329]=e[10329]|4,O=191}while(!1);if((O|0)==191&&k>>>0<2147483647&&(Z=Mi(k|0)|0,ie=Mi(0)|0,Z>>>0>>0&((Z|0)!=-1&(ie|0)!=-1))&&(ne=ie-Z|0,ce=ne>>>0>(Q+40|0)>>>0,ce)&&(U=ce?ne:t,O=194),(O|0)==194){t=(e[10326]|0)+U|0,e[10326]=t,t>>>0>(e[10327]|0)>>>0&&(e[10327]=t),d=e[10224]|0;e:do if(d){h=41320;do{if(t=e[h>>2]|0,o=h+4|0,c=e[o>>2]|0,(Z|0)==(t+c|0)){ke=t,Ee=o,Te=c,it=h,O=204;break}h=e[h+8>>2]|0}while(h|0);if((O|0)==204&&!(e[it+12>>2]&8|0)&&d>>>0>>0&d>>>0>=ke>>>0){e[Ee>>2]=Te+U,dt=(e[10221]|0)+U|0,Kt=d+8|0,Kt=Kt&7|0?0-Kt&7:0,gt=dt-Kt|0,e[10224]=d+Kt,e[10221]=gt,e[d+(Kt+4)>>2]=gt|1,e[d+(dt+4)>>2]=40,e[10225]=e[10340];break}for(t=e[10222]|0,Z>>>0>>0&&(e[10222]=Z,t=Z),o=Z+U|0,h=41320;;){if((e[h>>2]|0)==(o|0)){c=h,o=h,O=212;break}if(h=e[h+8>>2]|0,!h){o=41320;break}}if((O|0)==212)if(e[o+12>>2]&8)o=41320;else{e[c>>2]=Z,R=o+4|0,e[R>>2]=(e[R>>2]|0)+U,R=Z+8|0,R=R&7|0?0-R&7:0,D=Z+(U+8)|0,D=D&7|0?0-D&7:0,r=Z+(D+U)|0,N=R+Q|0,_=Z+N|0,k=r-(Z+R)-Q|0,e[Z+(R+4)>>2]=Q|3;t:do if((r|0)!=(d|0)){if((r|0)==(e[10223]|0)){dt=(e[10220]|0)+k|0,e[10220]=dt,e[10223]=_,e[Z+(N+4)>>2]=dt|1,e[Z+(dt+N)>>2]=dt;break}if(w=U+4|0,o=e[Z+(w+D)>>2]|0,(o&3|0)==1){C=o&-8,h=o>>>3;i:do if(o>>>0>=256){d=e[Z+((D|24)+U)>>2]|0,l=e[Z+(U+12+D)>>2]|0;do if((l|0)==(r|0)){if(c=D|16,l=Z+(w+c)|0,o=e[l>>2]|0,!o&&(l=Z+(c+U)|0,o=e[l>>2]|0,!o)){zt=0;break}for(;;){if(c=o+20|0,h=e[c>>2]|0,h){o=h,l=c;continue}if(c=o+16|0,h=e[c>>2]|0,h)o=h,l=c;else break}if(l>>>0>>0)St();else{e[l>>2]=0,zt=o;break}}else if(c=e[Z+((D|8)+U)>>2]|0,c>>>0>>0&&St(),t=c+12|0,(e[t>>2]|0)!=(r|0)&&St(),o=l+8|0,(e[o>>2]|0)==(r|0)){e[t>>2]=l,e[o>>2]=c,zt=l;break}else St();while(!1);if(!d)break;t=e[Z+(U+28+D)>>2]|0,o=41176+(t<<2)|0;do if((r|0)!=(e[o>>2]|0)){if(d>>>0<(e[10222]|0)>>>0&&St(),t=d+16|0,(e[t>>2]|0)==(r|0)?e[t>>2]=zt:e[d+20>>2]=zt,!zt)break i}else{if(e[o>>2]=zt,zt)break;e[10219]=e[10219]&~(1<>>0>>0&&St(),e[zt+24>>2]=d,r=D|16,t=e[Z+(r+U)>>2]|0;do if(t)if(t>>>0>>0)St();else{e[zt+16>>2]=t,e[t+24>>2]=zt;break}while(!1);if(r=e[Z+(w+r)>>2]|0,!r)break;if(r>>>0<(e[10222]|0)>>>0)St();else{e[zt+20>>2]=r,e[r+24>>2]=zt;break}}else{l=e[Z+((D|8)+U)>>2]|0,c=e[Z+(U+12+D)>>2]|0,o=40912+(h<<1<<2)|0;do if((l|0)!=(o|0)){if(l>>>0>>0&&St(),(e[l+12>>2]|0)==(r|0))break;St()}while(!1);if((c|0)==(l|0)){e[10218]=e[10218]&~(1<>>0>>0&&St(),t=c+8|0,(e[t>>2]|0)==(r|0)){jt=t;break}St()}while(!1);e[l+12>>2]=c,e[jt>>2]=l}while(!1);r=Z+((C|D)+U)|0,c=C+k|0}else c=k;if(r=r+4|0,e[r>>2]=e[r>>2]&-2,e[Z+(N+4)>>2]=c|1,e[Z+(c+N)>>2]=c,r=c>>>3,c>>>0<256){t=r<<1,l=40912+(t<<2)|0,o=e[10218]|0,r=1<>2]|0,t>>>0>=(e[10222]|0)>>>0){gt=r,Kt=t;break}St()}while(!1);e[gt>>2]=_,e[Kt+12>>2]=_,e[Z+(N+8)>>2]=Kt,e[Z+(N+12)>>2]=l;break}r=c>>>8;do if(!r)l=0;else{if(c>>>0>16777215){l=31;break}gt=(r+1048320|0)>>>16&8,Kt=r<>>16&4,Kt=Kt<>>16&2,l=14-(zt|gt|l)+(Kt<>>15)|0,l=c>>>(l+7|0)&1|l<<1}while(!1);if(r=41176+(l<<2)|0,e[Z+(N+28)>>2]=l,e[Z+(N+20)>>2]=0,e[Z+(N+16)>>2]=0,t=e[10219]|0,o=1<>2]=_,e[Z+(N+24)>>2]=r,e[Z+(N+12)>>2]=_,e[Z+(N+8)>>2]=_;break}r=e[r>>2]|0;i:do if((e[r+4>>2]&-8|0)!=(c|0)){for(l=c<<((l|0)==31?0:25-(l>>>1)|0);t=r+16+(l>>>31<<2)|0,o=e[t>>2]|0,!!o;)if((e[o+4>>2]&-8|0)==(c|0)){dt=o;break i}else l=l<<1,r=o;if(t>>>0<(e[10222]|0)>>>0)St();else{e[t>>2]=_,e[Z+(N+24)>>2]=r,e[Z+(N+12)>>2]=_,e[Z+(N+8)>>2]=_;break t}}else dt=r;while(!1);if(r=dt+8|0,t=e[r>>2]|0,Kt=e[10222]|0,t>>>0>=Kt>>>0&dt>>>0>=Kt>>>0){e[t+12>>2]=_,e[r>>2]=_,e[Z+(N+8)>>2]=t,e[Z+(N+12)>>2]=dt,e[Z+(N+24)>>2]=0;break}else St()}else dt=(e[10221]|0)+k|0,e[10221]=dt,e[10224]=_,e[Z+(N+4)>>2]=dt|1;while(!1);return dt=Z+(R|8)|0,dt|0}for(;t=e[o>>2]|0,!(t>>>0<=d>>>0&&(r=e[o+4>>2]|0,l=t+r|0,l>>>0>d>>>0));)o=e[o+8>>2]|0;if(c=t+(r+-39)|0,t=t+(r+-47+(c&7|0?0-c&7:0))|0,c=d+16|0,t=t>>>0>>0?d:t,r=t+8|0,o=Z+8|0,o=o&7|0?0-o&7:0,dt=U+-40-o|0,e[10224]=Z+o,e[10221]=dt,e[Z+(o+4)>>2]=dt|1,e[Z+(U+-36)>>2]=40,e[10225]=e[10340],o=t+4|0,e[o>>2]=27,e[r>>2]=e[10330],e[r+4>>2]=e[10331],e[r+8>>2]=e[10332],e[r+12>>2]=e[10333],e[10330]=Z,e[10331]=U,e[10333]=0,e[10332]=r,r=t+28|0,e[r>>2]=7,(t+32|0)>>>0>>0)do dt=r,r=r+4|0,e[r>>2]=7;while((dt+8|0)>>>0>>0);if((t|0)!=(d|0)){if(h=t-d|0,e[o>>2]=e[o>>2]&-2,e[d+4>>2]=h|1,e[t>>2]=h,r=h>>>3,h>>>0<256){t=r<<1,l=40912+(t<<2)|0,o=e[10218]|0,r=1<>2]|0,t>>>0<(e[10222]|0)>>>0?St():(Gt=r,s0=t)):(e[10218]=o|r,Gt=40912+(t+2<<2)|0,s0=l),e[Gt>>2]=d,e[s0+12>>2]=d,e[d+8>>2]=s0,e[d+12>>2]=l;break}if(r=h>>>8,r?h>>>0>16777215?l=31:(Kt=(r+1048320|0)>>>16&8,dt=r<>>16&4,dt=dt<>>16&2,l=14-(gt|Kt|l)+(dt<>>15)|0,l=h>>>(l+7|0)&1|l<<1):l=0,o=41176+(l<<2)|0,e[d+28>>2]=l,e[d+20>>2]=0,e[c>>2]=0,r=e[10219]|0,t=1<>2]=d,e[d+24>>2]=o,e[d+12>>2]=d,e[d+8>>2]=d;break}r=e[o>>2]|0;t:do if((e[r+4>>2]&-8|0)!=(h|0)){for(l=h<<((l|0)==31?0:25-(l>>>1)|0);t=r+16+(l>>>31<<2)|0,o=e[t>>2]|0,!!o;)if((e[o+4>>2]&-8|0)==(h|0)){i0=o;break t}else l=l<<1,r=o;if(t>>>0<(e[10222]|0)>>>0)St();else{e[t>>2]=d,e[d+24>>2]=r,e[d+12>>2]=d,e[d+8>>2]=d;break e}}else i0=r;while(!1);if(r=i0+8|0,t=e[r>>2]|0,dt=e[10222]|0,t>>>0>=dt>>>0&i0>>>0>=dt>>>0){e[t+12>>2]=d,e[r>>2]=d,e[d+8>>2]=t,e[d+12>>2]=i0,e[d+24>>2]=0;break}else St()}}else{dt=e[10222]|0,(dt|0)==0|Z>>>0
>>0&&(e[10222]=Z),e[10330]=Z,e[10331]=U,e[10333]=0,e[10227]=e[10336],e[10226]=-1,r=0;do dt=r<<1,Kt=40912+(dt<<2)|0,e[40912+(dt+3<<2)>>2]=Kt,e[40912+(dt+2<<2)>>2]=Kt,r=r+1|0;while((r|0)!=32);dt=Z+8|0,dt=dt&7|0?0-dt&7:0,Kt=U+-40-dt|0,e[10224]=Z+dt,e[10221]=Kt,e[Z+(dt+4)>>2]=Kt|1,e[Z+(U+-36)>>2]=40,e[10225]=e[10340]}while(!1);if(r=e[10221]|0,r>>>0>Q>>>0)return Kt=r-Q|0,e[10221]=Kt,dt=e[10224]|0,e[10224]=dt+Q,e[dt+(Q+4)>>2]=Kt|1,e[dt+4>>2]=Q|3,dt=dt+8|0,dt|0}return dt=S0()|0,e[dt>>2]=12,dt=0,dt|0}function n0(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0;if(t){r=t+-8|0,w=e[10222]|0,r>>>0>>0&&St(),o=e[t+-4>>2]|0,l=o&3,(l|0)==1&&St(),_=o&-8,Q=t+(_+-8)|0;do if(o&1)P=r,h=_;else{if(r=e[r>>2]|0,!l)return;if(C=-8-r|0,k=t+C|0,N=r+_|0,k>>>0>>0&&St(),(k|0)==(e[10223]|0)){if(r=t+(_+-4)|0,o=e[r>>2]|0,(o&3|0)!=3){P=k,h=N;break}e[10220]=N,e[r>>2]=o&-2,e[t+(C+4)>>2]=N|1,e[Q>>2]=N;return}if(c=r>>>3,r>>>0<256){if(l=e[t+(C+8)>>2]|0,o=e[t+(C+12)>>2]|0,r=40912+(c<<1<<2)|0,(l|0)!=(r|0)&&(l>>>0>>0&&St(),(e[l+12>>2]|0)!=(k|0)&&St()),(o|0)==(l|0)){e[10218]=e[10218]&~(1<>>0>>0&&St(),r=o+8|0,(e[r>>2]|0)==(k|0)?d=r:St()):d=o+8|0,e[l+12>>2]=o,e[d>>2]=l,P=k,h=N;break}d=e[t+(C+24)>>2]|0,l=e[t+(C+12)>>2]|0;do if((l|0)==(k|0)){if(o=t+(C+20)|0,r=e[o>>2]|0,!r&&(o=t+(C+16)|0,r=e[o>>2]|0,!r)){D=0;break}for(;;){if(l=r+20|0,c=e[l>>2]|0,c){r=c,o=l;continue}if(l=r+16|0,c=e[l>>2]|0,c)r=c,o=l;else break}if(o>>>0>>0)St();else{e[o>>2]=0,D=r;break}}else if(c=e[t+(C+8)>>2]|0,c>>>0>>0&&St(),r=c+12|0,(e[r>>2]|0)!=(k|0)&&St(),o=l+8|0,(e[o>>2]|0)==(k|0)){e[r>>2]=l,e[o>>2]=c,D=l;break}else St();while(!1);if(d){if(r=e[t+(C+28)>>2]|0,o=41176+(r<<2)|0,(k|0)==(e[o>>2]|0)){if(e[o>>2]=D,!D){e[10219]=e[10219]&~(1<>>0<(e[10222]|0)>>>0&&St(),r=d+16|0,(e[r>>2]|0)==(k|0)?e[r>>2]=D:e[d+20>>2]=D,!D){P=k,h=N;break}o=e[10222]|0,D>>>0>>0&&St(),e[D+24>>2]=d,r=e[t+(C+16)>>2]|0;do if(r)if(r>>>0>>0)St();else{e[D+16>>2]=r,e[r+24>>2]=D;break}while(!1);if(r=e[t+(C+20)>>2]|0,r)if(r>>>0<(e[10222]|0)>>>0)St();else{e[D+20>>2]=r,e[r+24>>2]=D,P=k,h=N;break}else P=k,h=N}else P=k,h=N}while(!1);if(P>>>0>=Q>>>0&&St(),r=t+(_+-4)|0,o=e[r>>2]|0,o&1||St(),o&2)e[r>>2]=o&-2,e[P+4>>2]=h|1,e[P+h>>2]=h;else{if((Q|0)==(e[10224]|0)){if($=(e[10221]|0)+h|0,e[10221]=$,e[10224]=P,e[P+4>>2]=$|1,(P|0)!=(e[10223]|0))return;e[10223]=0,e[10220]=0;return}if((Q|0)==(e[10223]|0)){$=(e[10220]|0)+h|0,e[10220]=$,e[10223]=P,e[P+4>>2]=$|1,e[P+$>>2]=$;return}h=(o&-8)+h|0,c=o>>>3;do if(o>>>0>=256){d=e[t+(_+16)>>2]|0,r=e[t+(_|4)>>2]|0;do if((r|0)==(Q|0)){if(o=t+(_+12)|0,r=e[o>>2]|0,!r&&(o=t+(_+8)|0,r=e[o>>2]|0,!r)){U=0;break}for(;;){if(l=r+20|0,c=e[l>>2]|0,c){r=c,o=l;continue}if(l=r+16|0,c=e[l>>2]|0,c)r=c,o=l;else break}if(o>>>0<(e[10222]|0)>>>0)St();else{e[o>>2]=0,U=r;break}}else if(o=e[t+_>>2]|0,o>>>0<(e[10222]|0)>>>0&&St(),l=o+12|0,(e[l>>2]|0)!=(Q|0)&&St(),c=r+8|0,(e[c>>2]|0)==(Q|0)){e[l>>2]=r,e[c>>2]=o,U=r;break}else St();while(!1);if(d){if(r=e[t+(_+20)>>2]|0,o=41176+(r<<2)|0,(Q|0)==(e[o>>2]|0)){if(e[o>>2]=U,!U){e[10219]=e[10219]&~(1<>>0<(e[10222]|0)>>>0&&St(),r=d+16|0,(e[r>>2]|0)==(Q|0)?e[r>>2]=U:e[d+20>>2]=U,!U)break;o=e[10222]|0,U>>>0>>0&&St(),e[U+24>>2]=d,r=e[t+(_+8)>>2]|0;do if(r)if(r>>>0>>0)St();else{e[U+16>>2]=r,e[r+24>>2]=U;break}while(!1);if(r=e[t+(_+12)>>2]|0,r)if(r>>>0<(e[10222]|0)>>>0)St();else{e[U+20>>2]=r,e[r+24>>2]=U;break}}}else{if(l=e[t+_>>2]|0,o=e[t+(_|4)>>2]|0,r=40912+(c<<1<<2)|0,(l|0)!=(r|0)&&(l>>>0<(e[10222]|0)>>>0&&St(),(e[l+12>>2]|0)!=(Q|0)&&St()),(o|0)==(l|0)){e[10218]=e[10218]&~(1<>>0<(e[10222]|0)>>>0&&St(),r=o+8|0,(e[r>>2]|0)==(Q|0)?R=r:St()):R=o+8|0,e[l+12>>2]=o,e[R>>2]=l}while(!1);if(e[P+4>>2]=h|1,e[P+h>>2]=h,(P|0)==(e[10223]|0)){e[10220]=h;return}}if(r=h>>>3,h>>>0<256){o=r<<1,c=40912+(o<<2)|0,l=e[10218]|0,r=1<>2]|0,o>>>0<(e[10222]|0)>>>0?St():(K=r,G=o)):(e[10218]=l|r,K=40912+(o+2<<2)|0,G=c),e[K>>2]=P,e[G+12>>2]=P,e[P+8>>2]=G,e[P+12>>2]=c;return}r=h>>>8,r?h>>>0>16777215?c=31:(K=(r+1048320|0)>>>16&8,G=r<>>16&4,G=G<>>16&2,c=14-(Q|K|c)+(G<>>15)|0,c=h>>>(c+7|0)&1|c<<1):c=0,r=41176+(c<<2)|0,e[P+28>>2]=c,e[P+20>>2]=0,e[P+16>>2]=0,o=e[10219]|0,l=1<>2]|0;t:do if((e[r+4>>2]&-8|0)!=(h|0)){for(c=h<<((c|0)==31?0:25-(c>>>1)|0);o=r+16+(c>>>31<<2)|0,l=e[o>>2]|0,!!l;)if((e[l+4>>2]&-8|0)==(h|0)){$=l;break t}else c=c<<1,r=l;if(o>>>0<(e[10222]|0)>>>0)St();else{e[o>>2]=P,e[P+24>>2]=r,e[P+12>>2]=P,e[P+8>>2]=P;break e}}else $=r;while(!1);if(r=$+8|0,o=e[r>>2]|0,G=e[10222]|0,o>>>0>=G>>>0&$>>>0>=G>>>0){e[o+12>>2]=P,e[r>>2]=P,e[P+8>>2]=o,e[P+12>>2]=$,e[P+24>>2]=0;break}else St()}else e[10219]=o|l,e[r>>2]=P,e[P+24>>2]=r,e[P+12>>2]=P,e[P+8>>2]=P;while(!1);if(P=(e[10226]|0)+-1|0,e[10226]=P,!P)r=41328;else return;for(;r=e[r>>2]|0,r;)r=r+8|0;e[10226]=-1}}function Dd(t,r){t=t|0,r=r|0;var o=0;return t?(o=ee(r,t)|0,(r|t)>>>0>65535&&(o=((o>>>0)/(t>>>0)|0|0)==(r|0)?o:-1)):o=0,r=E0(o)|0,!r||!(e[r+-4>>2]&3)||Jt(r|0,0,o|0)|0,r|0}function Gi(t,r){t=t|0,r=r|0;var o=0,l=0;return t?r>>>0>4294967231?(t=S0()|0,e[t>>2]=12,t=0,t|0):(o=bd(t+-8|0,r>>>0<11?16:r+11&-8)|0,o?(t=o+8|0,t|0):(o=E0(r)|0,o?(l=e[t+-4>>2]|0,l=(l&-8)-(l&3|0?4:8)|0,o0(o|0,t|0,(l>>>0>>0?l:r)|0)|0,n0(t),t=o,t|0):(t=0,t|0))):(t=E0(r)|0,t|0)}function bd(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(_=t+4|0,U=e[_>>2]|0,C=U&-8,k=t+C|0,w=e[10222]|0,o=U&3,(o|0)!=1&t>>>0>=w>>>0&t>>>0>>0||St(),l=t+(C|4)|0,c=e[l>>2]|0,c&1||St(),!o)return r>>>0<256?(t=0,t|0):(C>>>0>=(r+4|0)>>>0&&(C-r|0)>>>0<=e[10338]<<1>>>0||(t=0),t|0);if(C>>>0>=r>>>0)return o=C-r|0,o>>>0<=15||(e[_>>2]=U&1|r|2,e[t+(r+4)>>2]=o|3,e[l>>2]=e[l>>2]|1,Ls(t+r|0,o)),t|0;if((k|0)==(e[10224]|0))return o=(e[10221]|0)+C|0,o>>>0<=r>>>0?(t=0,t|0):(R=o-r|0,e[_>>2]=U&1|r|2,e[t+(r+4)>>2]=R|1,e[10224]=t+r,e[10221]=R,t|0);if((k|0)==(e[10223]|0))return l=(e[10220]|0)+C|0,l>>>0>>0?(t=0,t|0):(o=l-r|0,o>>>0>15?(e[_>>2]=U&1|r|2,e[t+(r+4)>>2]=o|1,e[t+l>>2]=o,l=t+(l+4)|0,e[l>>2]=e[l>>2]&-2,l=t+r|0):(e[_>>2]=U&1|l|2,l=t+(l+4)|0,e[l>>2]=e[l>>2]|1,l=0,o=0),e[10220]=o,e[10223]=l,t|0);if(c&2||(N=(c&-8)+C|0,N>>>0>>0))return t=0,t|0;R=N-r|0,h=c>>>3;do if(c>>>0>=256){d=e[t+(C+24)>>2]|0,h=e[t+(C+12)>>2]|0;do if((h|0)==(k|0)){if(l=t+(C+20)|0,o=e[l>>2]|0,!o&&(l=t+(C+16)|0,o=e[l>>2]|0,!o)){D=0;break}for(;;){if(c=o+20|0,h=e[c>>2]|0,h){o=h,l=c;continue}if(c=o+16|0,h=e[c>>2]|0,h)o=h,l=c;else break}if(l>>>0>>0)St();else{e[l>>2]=0,D=o;break}}else if(c=e[t+(C+8)>>2]|0,c>>>0>>0&&St(),o=c+12|0,(e[o>>2]|0)!=(k|0)&&St(),l=h+8|0,(e[l>>2]|0)==(k|0)){e[o>>2]=h,e[l>>2]=c,D=h;break}else St();while(!1);if(d){if(o=e[t+(C+28)>>2]|0,l=41176+(o<<2)|0,(k|0)==(e[l>>2]|0)){if(e[l>>2]=D,!D){e[10219]=e[10219]&~(1<>>0<(e[10222]|0)>>>0&&St(),o=d+16|0,(e[o>>2]|0)==(k|0)?e[o>>2]=D:e[d+20>>2]=D,!D)break;l=e[10222]|0,D>>>0>>0&&St(),e[D+24>>2]=d,o=e[t+(C+16)>>2]|0;do if(o)if(o>>>0>>0)St();else{e[D+16>>2]=o,e[o+24>>2]=D;break}while(!1);if(o=e[t+(C+20)>>2]|0,o)if(o>>>0<(e[10222]|0)>>>0)St();else{e[D+20>>2]=o,e[o+24>>2]=D;break}}}else{if(c=e[t+(C+8)>>2]|0,l=e[t+(C+12)>>2]|0,o=40912+(h<<1<<2)|0,(c|0)!=(o|0)&&(c>>>0>>0&&St(),(e[c+12>>2]|0)!=(k|0)&&St()),(l|0)==(c|0)){e[10218]=e[10218]&~(1<>>0>>0&&St(),o=l+8|0,(e[o>>2]|0)==(k|0)?d=o:St()):d=l+8|0,e[c+12>>2]=l,e[d>>2]=c}while(!1);return R>>>0<16?(e[_>>2]=N|U&1|2,r=t+(N|4)|0,e[r>>2]=e[r>>2]|1,t|0):(e[_>>2]=U&1|r|2,e[t+(r+4)>>2]=R|3,U=t+(N|4)|0,e[U>>2]=e[U>>2]|1,Ls(t+r|0,R),t|0)}function Ls(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0;Q=t+r|0,o=e[t+4>>2]|0;do if(o&1)$=t,d=r;else{if(D=e[t>>2]|0,!(o&3))return;if(R=t+(0-D)|0,N=D+r|0,C=e[10222]|0,R>>>0>>0&&St(),(R|0)==(e[10223]|0)){if(l=t+(r+4)|0,o=e[l>>2]|0,(o&3|0)!=3){$=R,d=N;break}e[10220]=N,e[l>>2]=o&-2,e[t+(4-D)>>2]=N|1,e[Q>>2]=N;return}if(h=D>>>3,D>>>0<256){if(c=e[t+(8-D)>>2]|0,l=e[t+(12-D)>>2]|0,o=40912+(h<<1<<2)|0,(c|0)!=(o|0)&&(c>>>0>>0&&St(),(e[c+12>>2]|0)!=(R|0)&&St()),(l|0)==(c|0)){e[10218]=e[10218]&~(1<>>0>>0&&St(),o=l+8|0,(e[o>>2]|0)==(R|0)?w=o:St()):w=l+8|0,e[c+12>>2]=l,e[w>>2]=c,$=R,d=N;break}w=e[t+(24-D)>>2]|0,c=e[t+(12-D)>>2]|0;do if((c|0)==(R|0)){if(c=16-D|0,l=t+(c+4)|0,o=e[l>>2]|0,!o&&(l=t+c|0,o=e[l>>2]|0,!o)){k=0;break}for(;;){if(c=o+20|0,h=e[c>>2]|0,h){o=h,l=c;continue}if(c=o+16|0,h=e[c>>2]|0,h)o=h,l=c;else break}if(l>>>0>>0)St();else{e[l>>2]=0,k=o;break}}else if(h=e[t+(8-D)>>2]|0,h>>>0>>0&&St(),o=h+12|0,(e[o>>2]|0)!=(R|0)&&St(),l=c+8|0,(e[l>>2]|0)==(R|0)){e[o>>2]=c,e[l>>2]=h,k=c;break}else St();while(!1);if(w){if(o=e[t+(28-D)>>2]|0,l=41176+(o<<2)|0,(R|0)==(e[l>>2]|0)){if(e[l>>2]=k,!k){e[10219]=e[10219]&~(1<>>0<(e[10222]|0)>>>0&&St(),o=w+16|0,(e[o>>2]|0)==(R|0)?e[o>>2]=k:e[w+20>>2]=k,!k){$=R,d=N;break}c=e[10222]|0,k>>>0>>0&&St(),e[k+24>>2]=w,o=16-D|0,l=e[t+o>>2]|0;do if(l)if(l>>>0>>0)St();else{e[k+16>>2]=l,e[l+24>>2]=k;break}while(!1);if(o=e[t+(o+4)>>2]|0,o)if(o>>>0<(e[10222]|0)>>>0)St();else{e[k+20>>2]=o,e[o+24>>2]=k,$=R,d=N;break}else $=R,d=N}else $=R,d=N}while(!1);if(C=e[10222]|0,Q>>>0>>0&&St(),o=t+(r+4)|0,l=e[o>>2]|0,l&2)e[o>>2]=l&-2,e[$+4>>2]=d|1,e[$+d>>2]=d;else{if((Q|0)==(e[10224]|0)){if(G=(e[10221]|0)+d|0,e[10221]=G,e[10224]=$,e[$+4>>2]=G|1,($|0)!=(e[10223]|0))return;e[10223]=0,e[10220]=0;return}if((Q|0)==(e[10223]|0)){G=(e[10220]|0)+d|0,e[10220]=G,e[10223]=$,e[$+4>>2]=G|1,e[$+G>>2]=G;return}d=(l&-8)+d|0,h=l>>>3;do if(l>>>0>=256){w=e[t+(r+24)>>2]|0,c=e[t+(r+12)>>2]|0;do if((c|0)==(Q|0)){if(l=t+(r+20)|0,o=e[l>>2]|0,!o&&(l=t+(r+16)|0,o=e[l>>2]|0,!o)){U=0;break}for(;;){if(c=o+20|0,h=e[c>>2]|0,h){o=h,l=c;continue}if(c=o+16|0,h=e[c>>2]|0,h)o=h,l=c;else break}if(l>>>0>>0)St();else{e[l>>2]=0,U=o;break}}else if(h=e[t+(r+8)>>2]|0,h>>>0>>0&&St(),o=h+12|0,(e[o>>2]|0)!=(Q|0)&&St(),l=c+8|0,(e[l>>2]|0)==(Q|0)){e[o>>2]=c,e[l>>2]=h,U=c;break}else St();while(!1);if(w){if(o=e[t+(r+28)>>2]|0,l=41176+(o<<2)|0,(Q|0)==(e[l>>2]|0)){if(e[l>>2]=U,!U){e[10219]=e[10219]&~(1<>>0<(e[10222]|0)>>>0&&St(),o=w+16|0,(e[o>>2]|0)==(Q|0)?e[o>>2]=U:e[w+20>>2]=U,!U)break;l=e[10222]|0,U>>>0>>0&&St(),e[U+24>>2]=w,o=e[t+(r+16)>>2]|0;do if(o)if(o>>>0>>0)St();else{e[U+16>>2]=o,e[o+24>>2]=U;break}while(!1);if(o=e[t+(r+20)>>2]|0,o)if(o>>>0<(e[10222]|0)>>>0)St();else{e[U+20>>2]=o,e[o+24>>2]=U;break}}}else{if(c=e[t+(r+8)>>2]|0,l=e[t+(r+12)>>2]|0,o=40912+(h<<1<<2)|0,(c|0)!=(o|0)&&(c>>>0>>0&&St(),(e[c+12>>2]|0)!=(Q|0)&&St()),(l|0)==(c|0)){e[10218]=e[10218]&~(1<>>0>>0&&St(),o=l+8|0,(e[o>>2]|0)==(Q|0)?_=o:St()):_=l+8|0,e[c+12>>2]=l,e[_>>2]=c}while(!1);if(e[$+4>>2]=d|1,e[$+d>>2]=d,($|0)==(e[10223]|0)){e[10220]=d;return}}if(o=d>>>3,d>>>0<256){l=o<<1,h=40912+(l<<2)|0,c=e[10218]|0,o=1<>2]|0,l>>>0<(e[10222]|0)>>>0?St():(K=o,G=l)):(e[10218]=c|o,K=40912+(l+2<<2)|0,G=h),e[K>>2]=$,e[G+12>>2]=$,e[$+8>>2]=G,e[$+12>>2]=h;return}if(o=d>>>8,o?d>>>0>16777215?h=31:(K=(o+1048320|0)>>>16&8,G=o<>>16&4,G=G<>>16&2,h=14-(Q|K|h)+(G<>>15)|0,h=d>>>(h+7|0)&1|h<<1):h=0,o=41176+(h<<2)|0,e[$+28>>2]=h,e[$+20>>2]=0,e[$+16>>2]=0,l=e[10219]|0,c=1<>2]=$,e[$+24>>2]=o,e[$+12>>2]=$,e[$+8>>2]=$;return}o=e[o>>2]|0;e:do if((e[o+4>>2]&-8|0)!=(d|0)){for(h=d<<((h|0)==31?0:25-(h>>>1)|0);l=o+16+(h>>>31<<2)|0,c=e[l>>2]|0,!!c;)if((e[c+4>>2]&-8|0)==(d|0)){o=c;break e}else h=h<<1,o=c;l>>>0<(e[10222]|0)>>>0&&St(),e[l>>2]=$,e[$+24>>2]=o,e[$+12>>2]=$,e[$+8>>2]=$;return}while(!1);l=o+8|0,c=e[l>>2]|0,G=e[10222]|0,c>>>0>=G>>>0&o>>>0>=G>>>0||St(),e[c+12>>2]=$,e[l>>2]=$,e[$+8>>2]=c,e[$+12>>2]=o,e[$+24>>2]=0}function Nd(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0;if(l=e[9321]|0,_d(42048,l,42104),e[10342]=42892,e[10344]=42912,e[10343]=0,t=e[10720]|0,g=0,Ae(62,41368+t|0,42048),h=g,g=0,h&1&&(h=j()|0,tt(41376),le(h|0)),e[41368+(t+72)>>2]=0,e[41368+(t+76)>>2]=-1,c=e[9322]|0,Os(42152,c,42112),e[10364]=42972,e[10365]=42992,o=e[10740]|0,g=0,Ae(62,41456+o|0,42152),h=g,g=0,h&1&&(h=j()|0,tt(41460),le(h|0)),t=o+72|0,e[41456+t>>2]=0,r=o+76|0,e[41456+r>>2]=-1,h=e[9320]|0,Os(42200,h,42120),e[10385]=42972,e[10386]=42992,g=0,Ae(62,41540+o|0,42200),d=g,g=0,d&1&&(d=j()|0,tt(41544),le(d|0)),e[41540+t>>2]=0,e[41540+r>>2]=-1,d=e[41540+((e[(e[10385]|0)+-12>>2]|0)+24)>>2]|0,e[10406]=42972,e[10407]=42992,g=0,Ae(62,41624+o|0,d|0),d=g,g=0,d&1&&(d=j()|0,tt(41628),le(d|0)),e[41624+t>>2]=0,e[41624+r>>2]=-1,e[41368+((e[(e[10342]|0)+-12>>2]|0)+72)>>2]=41456,t=41540+((e[(e[10385]|0)+-12>>2]|0)+4)|0,e[t>>2]=e[t>>2]|8192,e[41540+((e[(e[10385]|0)+-12>>2]|0)+72)>>2]=41456,Pd(42248,l,42128),e[10427]=42932,e[10429]=42952,e[10428]=0,t=e[10730]|0,g=0,Ae(62,41708+t|0,42248),d=g,g=0,d&1&&(d=j()|0,mn(41716),le(d|0)),e[41708+(t+72)>>2]=0,e[41708+(t+76)>>2]=-1,$s(42304,c,42136),e[10449]=43012,e[10450]=43032,o=e[10750]|0,g=0,Ae(62,41796+o|0,42304),d=g,g=0,d&1&&(d=j()|0,mn(41800),le(d|0)),t=o+72|0,e[41796+t>>2]=0,r=o+76|0,e[41796+r>>2]=-1,$s(42352,h,42144),e[10470]=43012,e[10471]=43032,g=0,Ae(62,41880+o|0,42352),d=g,g=0,d&1&&(d=j()|0,mn(41884),le(d|0)),e[41880+t>>2]=0,e[41880+r>>2]=-1,d=e[41880+((e[(e[10470]|0)+-12>>2]|0)+24)>>2]|0,e[10491]=43012,e[10492]=43032,g=0,Ae(62,41964+o|0,d|0),d=g,g=0,d&1)d=j()|0,mn(41968),le(d|0);else{e[41964+t>>2]=0,e[41964+r>>2]=-1,e[41708+((e[(e[10427]|0)+-12>>2]|0)+72)>>2]=41796,d=41880+((e[(e[10470]|0)+-12>>2]|0)+4)|0,e[d>>2]=e[d>>2]|8192,e[41880+((e[(e[10470]|0)+-12>>2]|0)+72)>>2]=41796;return}}function Fd(t){t=t|0,g=0,ge(70,41456)|0,t=g,g=0,!(!(t&1)&&(g=0,ge(70,41624)|0,t=g,g=0,!(t&1))&&(g=0,ge(71,41796)|0,t=g,g=0,!(t&1))&&(g=0,ge(71,41964)|0,t=g,g=0,!(t&1)))&&(t=j(0)|0,$t(t))}function Rd(){Nd(0),Ft(187,56757,H|0)|0}function Md(){}function _d(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0;if(c=b,b=b+16|0,h=c+4|0,l=c,Sr(t),e[t>>2]=42600,e[t+32>>2]=r,e[t+40>>2]=o,e[t+48>>2]=-1,S[t+52>>0]=0,tn(h,t+4|0),e[l>>2]=e[h>>2],g=0,Ae(23,t|0,l|0),o=g,g=0,o&1)h=j()|0,_0(l),wt(t),le(h|0);else{_0(l),b=c;return}}function Os(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0;if(c=b,b=b+16|0,h=c+4|0,l=c,Sr(t),e[t>>2]=42536,e[t+32>>2]=r,tn(h,t+4|0),e[l>>2]=e[h>>2],g=0,r=be(37,l|0,44280)|0,h=g,g=0,h&1)h=j()|0,_0(l),wt(t),le(h|0);else{_0(l),e[t+36>>2]=r,e[t+40>>2]=o,h=(Dt[e[(e[r>>2]|0)+28>>2]&127](r)|0)&1,S[t+44>>0]=h,b=c;return}}function Pd(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0;if(c=b,b=b+16|0,h=c+4|0,l=c,Hs(t),e[t>>2]=42472,e[t+32>>2]=r,e[t+40>>2]=o,e[t+48>>2]=-1,S[t+52>>0]=0,tn(h,t+4|0),e[l>>2]=e[h>>2],g=0,Ae(21,t|0,l|0),o=g,g=0,o&1)h=j()|0,_0(l),rn(t),le(h|0);else{_0(l),b=c;return}}function $s(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0;if(c=b,b=b+16|0,h=c+4|0,l=c,Hs(t),e[t>>2]=42408,e[t+32>>2]=r,tn(h,t+4|0),e[l>>2]=e[h>>2],g=0,r=be(37,l|0,44288)|0,h=g,g=0,h&1)h=j()|0,_0(l),rn(t),le(h|0);else{_0(l),e[t+36>>2]=r,e[t+40>>2]=o,h=(Dt[e[(e[r>>2]|0)+28>>2]&127](r)|0)&1,S[t+44>>0]=h,b=c;return}}function Ld(t){t=t|0,rn(t),he(t)}function Od(t,r){t=t|0,r=r|0,Dt[e[(e[t>>2]|0)+24>>2]&127](t)|0,r=O0(r,44288)|0,e[t+36>>2]=r,r=(Dt[e[(e[r>>2]|0)+28>>2]&127](r)|0)&1,S[t+44>>0]=r}function $d(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;D=b,b=b+16|0,w=D+8|0,d=D,o=t+36|0,l=t+40|0,c=w+8|0,h=w,r=t+32|0;e:for(;;){if(t=e[o>>2]|0,t=an[e[(e[t>>2]|0)+20>>2]&31](t,e[l>>2]|0,w,c,d)|0,k=(e[d>>2]|0)-h|0,(gi(w,1,k,e[r>>2]|0)|0)!=(k|0)){t=-1;break}switch(t|0){case 1:break;case 2:{t=-1;break e}default:{C=4;break e}}}return(C|0)==4&&(t=((Nr(e[r>>2]|0)|0)!=0)<<31>>31),b=D,t|0}function Bd(t,r,o){t=t|0,r=r|0,o=o|0;var l=0;e:do if(S[t+44>>0]|0)r=gi(r,4,o,e[t+32>>2]|0)|0;else if((o|0)>0)for(l=r,r=0;;){if((U0[e[(e[t>>2]|0)+52>>2]&63](t,e[l>>2]|0)|0)==-1)break e;if(r=r+1|0,(r|0)<(o|0))l=l+4|0;else break}else r=0;while(!1);return r|0}function Vd(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;Q=b,b=b+32|0,R=Q+16|0,o=Q+8|0,N=Q+4|0,k=Q,_=(r|0)==-1;e:do if(_)U=11;else{if(e[o>>2]=r,S[t+44>>0]|0)if((gi(o,4,1,e[t+32>>2]|0)|0)==1){U=11;break}else{o=-1;break}for(e[N>>2]=R,C=o+4|0,D=t+36|0,c=t+40|0,h=R+8|0,d=R,w=t+32|0;;){if(t=e[D>>2]|0,t=Ci[e[(e[t>>2]|0)+12>>2]&15](t,e[c>>2]|0,o,C,k,R,h,N)|0,(e[k>>2]|0)==(o|0)){o=-1;break e}if((t|0)==3)break;if(l=(t|0)==1,t>>>0>=2){o=-1;break e}if(t=(e[N>>2]|0)-d|0,(gi(R,1,t,e[w>>2]|0)|0)!=(t|0)){o=-1;break e}if(l)o=l?e[k>>2]|0:o;else{U=11;break e}}(gi(o,1,1,e[w>>2]|0)|0)!=1?o=-1:U=11}while(!1);return(U|0)==11&&(o=_?0:r),b=Q,o|0}function Ud(t,r){t=t|0,r=r|0;var o=0,l=0;l=O0(r,44288)|0,o=t+36|0,e[o>>2]=l,l=Dt[e[(e[l>>2]|0)+24>>2]&127](l)|0,r=t+44|0,e[r>>2]=l,o=e[o>>2]|0,o=(Dt[e[(e[o>>2]|0)+28>>2]&127](o)|0)&1,S[t+53>>0]=o,(e[r>>2]|0)>8&&fn(56783)}function zd(t){t=t|0,rn(t),he(t)}function Gd(t){return t=t|0,Bs(t,0)|0}function qd(t){return t=t|0,Bs(t,1)|0}function Wd(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;D=b,b=b+32|0,C=D+16|0,w=D+8|0,l=D+4|0,c=D,h=t+52|0,o=(S[h>>0]|0)!=0;e:do if((r|0)==-1)o?r=-1:(r=e[t+48>>2]|0,S[h>>0]=(r|0)!=-1&1);else{d=t+48|0;t:do if(o){switch(e[l>>2]=e[d>>2],o=e[t+36>>2]|0,Ci[e[(e[o>>2]|0)+12>>2]&15](o,e[t+40>>2]|0,l,l+4|0,c,C,C+8|0,w)|0){case 1:case 2:{r=-1;break e}case 3:{S[C>>0]=e[d>>2],e[w>>2]=C+1;break}default:}for(o=t+32|0;;){if(l=e[w>>2]|0,l>>>0<=C>>>0)break t;if(t=l+-1|0,e[w>>2]=t,(Rn(S[t>>0]|0,e[o>>2]|0)|0)==-1){r=-1;break e}}}while(!1);e[d>>2]=r,S[h>>0]=1}while(!1);return b=D,r|0}function Bs(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0;U=b,b=b+32|0,_=U+16|0,R=U+8|0,D=U+4|0,k=U,c=t+52|0;e:do if(S[c>>0]|0)l=t+48|0,o=e[l>>2]|0,r&&(e[l>>2]=-1,S[c>>0]=0);else{if(o=e[t+44>>2]|0,o=(o|0)>1?o:1,N=t+32|0,(o|0)>0){c=0;do{if(l=Fn(e[N>>2]|0)|0,(l|0)==-1){o=-1;break e}S[_+c>>0]=l,c=c+1|0}while((c|0)<(o|0))}t:do if(S[t+53>>0]|0)e[R>>2]=S[_>>0];else{d=t+40|0,w=t+36|0,C=R+4|0;i:for(;;){switch(Q=e[d>>2]|0,c=Q,l=e[c>>2]|0,c=e[c+4>>2]|0,K=e[w>>2]|0,h=_+o|0,Ci[e[(e[K>>2]|0)+16>>2]&15](K,Q,_,h,D,R,C,k)|0){case 2:{o=-1;break e}case 3:break i;case 1:break;default:break t}if(K=e[d>>2]|0,e[K>>2]=l,e[K+4>>2]=c,(o|0)==8){o=-1;break e}if(l=Fn(e[N>>2]|0)|0,(l|0)==-1){o=-1;break e}S[h>>0]=l,o=o+1|0}e[R>>2]=S[_>>0]}while(!1);if(r){o=e[R>>2]|0,e[t+48>>2]=o;break}for(;!((o|0)<=0);)if(o=o+-1|0,(Rn(S[_+o>>0]|0,e[N>>2]|0)|0)==-1){o=-1;break e}o=e[R>>2]|0}while(!1);return b=U,o|0}function Hd(t){t=t|0,wt(t),he(t)}function Qd(t,r){t=t|0,r=r|0,Dt[e[(e[t>>2]|0)+24>>2]&127](t)|0,r=O0(r,44280)|0,e[t+36>>2]=r,r=(Dt[e[(e[r>>2]|0)+28>>2]&127](r)|0)&1,S[t+44>>0]=r}function Kd(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;D=b,b=b+16|0,w=D+8|0,d=D,o=t+36|0,l=t+40|0,c=w+8|0,h=w,r=t+32|0;e:for(;;){if(t=e[o>>2]|0,t=an[e[(e[t>>2]|0)+20>>2]&31](t,e[l>>2]|0,w,c,d)|0,k=(e[d>>2]|0)-h|0,(gi(w,1,k,e[r>>2]|0)|0)!=(k|0)){t=-1;break}switch(t|0){case 1:break;case 2:{t=-1;break e}default:{C=4;break e}}}return(C|0)==4&&(t=((Nr(e[r>>2]|0)|0)!=0)<<31>>31),b=D,t|0}function Yd(t,r,o){t=t|0,r=r|0,o=o|0;var l=0;e:do if(S[t+44>>0]|0)r=gi(r,1,o,e[t+32>>2]|0)|0;else if((o|0)>0)for(l=r,r=0;;){if((U0[e[(e[t>>2]|0)+52>>2]&63](t,F[l>>0]|0)|0)==-1)break e;if(r=r+1|0,(r|0)<(o|0))l=l+1|0;else break}else r=0;while(!1);return r|0}function jd(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;Q=b,b=b+32|0,R=Q+16|0,o=Q+8|0,N=Q+4|0,k=Q,_=(r|0)==-1;e:do if(_)U=11;else{if(S[o>>0]=r,S[t+44>>0]|0)if((gi(o,1,1,e[t+32>>2]|0)|0)==1){U=11;break}else{o=-1;break}for(e[N>>2]=R,D=o+1|0,c=t+36|0,h=t+40|0,d=R+8|0,w=R,C=t+32|0;;){if(t=e[c>>2]|0,t=Ci[e[(e[t>>2]|0)+12>>2]&15](t,e[h>>2]|0,o,D,k,R,d,N)|0,(e[k>>2]|0)==(o|0)){o=-1;break e}if((t|0)==3)break;if(l=(t|0)==1,t>>>0>=2){o=-1;break e}if(t=(e[N>>2]|0)-w|0,(gi(R,1,t,e[C>>2]|0)|0)!=(t|0)){o=-1;break e}if(l)o=l?e[k>>2]|0:o;else{U=11;break e}}(gi(o,1,1,e[C>>2]|0)|0)!=1?o=-1:U=11}while(!1);return(U|0)==11&&(o=_?0:r),b=Q,o|0}function Xd(t,r){t=t|0,r=r|0;var o=0,l=0;l=O0(r,44280)|0,o=t+36|0,e[o>>2]=l,l=Dt[e[(e[l>>2]|0)+24>>2]&127](l)|0,r=t+44|0,e[r>>2]=l,o=e[o>>2]|0,o=(Dt[e[(e[o>>2]|0)+28>>2]&127](o)|0)&1,S[t+53>>0]=o,(e[r>>2]|0)>8&&fn(56783)}function Zd(t){t=t|0,wt(t),he(t)}function Jd(t){return t=t|0,Vs(t,0)|0}function ep(t){return t=t|0,Vs(t,1)|0}function tp(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;D=b,b=b+32|0,C=D+16|0,w=D+4|0,l=D+8|0,c=D,h=t+52|0,o=(S[h>>0]|0)!=0;e:do if((r|0)==-1)o?r=-1:(r=e[t+48>>2]|0,S[h>>0]=(r|0)!=-1&1);else{d=t+48|0;t:do if(o){switch(S[l>>0]=e[d>>2],o=e[t+36>>2]|0,Ci[e[(e[o>>2]|0)+12>>2]&15](o,e[t+40>>2]|0,l,l+1|0,c,C,C+8|0,w)|0){case 1:case 2:{r=-1;break e}case 3:{S[C>>0]=e[d>>2],e[w>>2]=C+1;break}default:}for(o=t+32|0;;){if(l=e[w>>2]|0,l>>>0<=C>>>0)break t;if(t=l+-1|0,e[w>>2]=t,(Rn(S[t>>0]|0,e[o>>2]|0)|0)==-1){r=-1;break e}}}while(!1);e[d>>2]=r,S[h>>0]=1}while(!1);return b=D,r|0}function Vs(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0;U=b,b=b+32|0,_=U+16|0,R=U+8|0,D=U+4|0,k=U,c=t+52|0;e:do if(S[c>>0]|0)l=t+48|0,o=e[l>>2]|0,r&&(e[l>>2]=-1,S[c>>0]=0);else{if(o=e[t+44>>2]|0,o=(o|0)>1?o:1,N=t+32|0,(o|0)>0){c=0;do{if(l=Fn(e[N>>2]|0)|0,(l|0)==-1){o=-1;break e}S[_+c>>0]=l,c=c+1|0}while((c|0)<(o|0))}t:do if(S[t+53>>0]|0)S[R>>0]=S[_>>0]|0;else{d=t+40|0,w=t+36|0,C=R+1|0;i:for(;;){switch(Q=e[d>>2]|0,c=Q,l=e[c>>2]|0,c=e[c+4>>2]|0,K=e[w>>2]|0,h=_+o|0,Ci[e[(e[K>>2]|0)+16>>2]&15](K,Q,_,h,D,R,C,k)|0){case 2:{o=-1;break e}case 3:break i;case 1:break;default:break t}if(K=e[d>>2]|0,e[K>>2]=l,e[K+4>>2]=c,(o|0)==8){o=-1;break e}if(l=Fn(e[N>>2]|0)|0,(l|0)==-1){o=-1;break e}S[h>>0]=l,o=o+1|0}S[R>>0]=S[_>>0]|0}while(!1);if(r)o=S[R>>0]|0,e[t+48>>2]=o&255;else{for(;!((o|0)<=0);)if(o=o+-1|0,(Rn(F[_+o>>0]|0,e[N>>2]|0)|0)==-1){o=-1;break e}o=S[R>>0]|0}o=o&255}while(!1);return b=U,o|0}function pA(t){t=t|0}function pn(t){t=t|0,t=t+4|0,e[t>>2]=(e[t>>2]|0)+1}function Bt(t){t=t|0;var r=0,o=0;return o=t+4|0,r=e[o>>2]|0,e[o>>2]=r+-1,r?t=0:(Mt[e[(e[t>>2]|0)+8>>2]&255](t),t=1),t|0}function ip(t,r){if(t=t|0,r=r|0,e[t>>2]=36868,g=0,Ae(86,t+4|0,(S[r>>0]&1?e[r+8>>2]|0:r+1|0)|0),t=g,g=0,t&1)t=j()|0,le(t|0);else return}function np(t,r){if(t=t|0,r=r|0,e[t>>2]=36868,g=0,Ae(86,t+4|0,r|0),t=g,g=0,t&1)t=j()|0,le(t|0);else return}function rp(t,r){t=t|0,r=r|0;var o=0,l=0;l=$i(r)|0,o=Xe(l+13|0)|0,e[o>>2]=l,e[o+4>>2]=l,e[o+8>>2]=0,o=o+12|0,o0(o|0,r|0,l+1|0)|0,e[t>>2]=o}function sp(t,r,o){t=t|0,r=r|0,o=o|0,e[t>>2]=o,e[t+4>>2]=r}function ap(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;return c=b,b=b+16|0,l=c,Ln[e[(e[t>>2]|0)+12>>2]&15](l,t,r),(e[l+4>>2]|0)==(e[o+4>>2]|0)?l=(e[l>>2]|0)==(e[o>>2]|0):l=0,b=c,l|0}function lp(t,r,o){return t=t|0,r=r|0,o=o|0,((e[r>>2]|0)==(o|0)?(e[r+4>>2]|0)==(t|0):0)|0}function up(t,r,o){t=t|0,r=r|0,o=o|0,r=vo(o)|0,yi(t,r,$i(r)|0)}function cp(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;d=b,b=b+16|0,h=d,l=e[r>>2]|0;do if(l)if(c=S[o>>0]|0,c&1?c=e[o+4>>2]|0:c=(c&255)>>>1,c&&(wp(o,56990)|0,l=e[r>>2]|0),r=e[r+4>>2]|0,Ln[e[(e[r>>2]|0)+24>>2]&15](h,r,l),r=S[h>>0]|0,c=(r&1)==0,g=0,Ve(30,o|0,(c?h+1|0:e[h+8>>2]|0)|0,(c?(r&255)>>>1:e[h+4>>2]|0)|0)|0,r=g,g=0,r&1)d=j()|0,de(h),le(d|0);else{de(h);break}while(!1);e[t>>2]=e[o>>2],e[t+4>>2]=e[o+4>>2],e[t+8>>2]=e[o+8>>2],e[o>>2]=0,e[o+4>>2]=0,e[o+8>>2]=0,b=d}function fp(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0;c=b,b=b+32|0,l=c+12|0,h=c,yi(h,o,$i(o)|0),g=0,xe(10,l|0,r|0,h|0),o=g,g=0;do if(o&1)l=j()|0;else if(g=0,Ae(87,t|0,l|0),o=g,g=0,o&1){c=j()|0,de(l),l=c;break}else{de(l),de(h),e[t>>2]=42664,o=e[r+4>>2]|0,h=t+8|0,e[h>>2]=e[r>>2],e[h+4>>2]=o,b=c;return}while(!1);de(h),le(l|0)}function hp(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0;h=b,b=b+48|0,c=h+24|0,w=h+16|0,d=h,e[w>>2]=r,e[w+4>>2]=o,hr(d,l),g=0,xe(10,c|0,w|0,d|0),l=g,g=0;do if(l&1)c=j()|0;else if(g=0,Ae(87,t|0,c|0),w=g,g=0,w&1){w=j()|0,de(c),c=w;break}else{de(c),de(d),e[t>>2]=42664,e[t+8>>2]=r,e[t+12>>2]=o,b=h;return}while(!1);de(d),le(c|0)}function dp(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;c=b,b=b+48|0,l=c+24|0,d=c+16|0,h=c,e[d>>2]=r,e[d+4>>2]=o,yi(h,58898,0),g=0,xe(10,l|0,d|0,h|0),d=g,g=0;do if(d&1)l=j()|0;else if(g=0,Ae(87,t|0,l|0),d=g,g=0,d&1){d=j()|0,de(l),l=d;break}else{de(l),de(h),e[t>>2]=42664,e[t+8>>2]=r,e[t+12>>2]=o,b=c;return}while(!1);de(h),le(l|0)}function fr(t){t=t|0,In(t)}function pp(t){t=t|0,In(t),he(t)}function mp(t){t=t|0}function gp(t,r,o){t=t|0,r=r|0,o=o|0;var l=0;if(Gr(42676)|0,(e[t>>2]|0)==1)do Q0(42704,42676)|0;while((e[t>>2]|0)==1);do if(e[t>>2]|0)Br(42676)|0;else{if(e[t>>2]=1,g=0,ge(72,42676)|0,l=g,g=0,!(l&1)&&(g=0,ue(o|0,r|0),l=g,g=0,!(l&1))&&(g=0,ge(73,42676)|0,l=g,g=0,!(l&1))&&(e[t>>2]=-1,g=0,ge(72,42676)|0,l=g,g=0,!(l&1))&&(g=0,ge(74,42704)|0,l=g,g=0,!(l&1)))break;l=j(0)|0,K0(l|0)|0,g=0,ge(73,42676)|0,l=g,g=0,!(l&1)&&(e[t>>2]=0,g=0,ge(72,42676)|0,l=g,g=0,!(l&1))&&(g=0,ge(74,42704)|0,l=g,g=0,!(l&1))&&(g=0,Nt(5),g=0),r=j()|0,g=0,Nt(3),l=g,g=0,l&1?(l=j(0)|0,$t(l)):le(r|0)}while(!1)}function hr(t,r){t=t|0,r=r|0,S[r>>0]&1?yi(t,e[r+8>>2]|0,e[r+4>>2]|0):(e[t>>2]=e[r>>2],e[t+4>>2]=e[r+4>>2],e[t+8>>2]=e[r+8>>2])}function yi(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;o>>>0>4294967279&&si(t),o>>>0<11?(S[t>>0]=o<<1,t=t+1|0):(c=o+16&-16,l=Xe(c)|0,e[t+8>>2]=l,e[t>>2]=c|1,e[t+4>>2]=o,t=l),o0(t|0,r|0,o|0)|0,S[t+o>>0]=0}function dr(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;r>>>0>4294967279&&si(t),r>>>0<11?(S[t>>0]=r<<1,t=t+1|0):(c=r+16&-16,l=Xe(c)|0,e[t+8>>2]=l,e[t>>2]=c|1,e[t+4>>2]=r,t=l),Jt(t|0,o|0,r|0)|0,S[t+r>>0]=0}function de(t){t=t|0,S[t>>0]&1&&he(e[t+8>>2]|0)}function Sp(t,r){t=t|0,r=r|0;var o=0,l=0;return(t|0)!=(r|0)&&(o=S[r>>0]|0,l=(o&1)==0,Us(t,l?r+1|0:e[r+8>>2]|0,l?(o&255)>>>1:e[r+4>>2]|0)|0),t|0}function Ap(t,r){return t=t|0,r=r|0,Us(t,r,$i(r)|0)|0}function Us(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0;l=S[t>>0]|0,l&1?(l=e[t>>2]|0,h=(l&-2)+-1|0,l=l&255):h=10,c=(l&1)==0;do if(h>>>0>=o>>>0)if(c?l=t+1|0:l=e[t+8>>2]|0,vn(l|0,r|0,o|0)|0,S[l+o>>0]=0,S[t>>0]&1){e[t+4>>2]=o;break}else{S[t>>0]=o<<1;break}else c?l=(l&255)>>>1:l=e[t+4>>2]|0,qs(t,h,o-h|0,l,0,l,o,r);while(!1);return t|0}function zs(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;l=S[t>>0]|0,c=(l&1)==0,c?l=(l&255)>>>1:l=e[t+4>>2]|0;do if(l>>>0>=r>>>0)if(c){S[t+1+r>>0]=0,S[t>>0]=r<<1;break}else{S[(e[t+8>>2]|0)+r>>0]=0,e[t+4>>2]=r;break}else vp(t,r-l|0,o)|0;while(!1)}function vp(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0;return r&&(l=S[t>>0]|0,l&1?(l=e[t>>2]|0,c=(l&-2)+-1|0,l=l&255):c=10,l&1?h=e[t+4>>2]|0:h=(l&255)>>>1,(c-h|0)>>>0>>0&&(pr(t,c,r-c+h|0,h,h,0,0),l=S[t>>0]|0),l&1?c=e[t+8>>2]|0:c=t+1|0,Jt(c+h|0,o|0,r|0)|0,l=h+r|0,S[t>>0]&1?e[t+4>>2]=l:S[t>>0]=l<<1,S[c+l>>0]=0),t|0}function xp(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0;r>>>0>4294967279&&si(t),o=S[t>>0]|0,o&1?(o=e[t>>2]|0,l=(o&-2)+-1|0,o=o&255):l=10,o&1?w=e[t+4>>2]|0:w=(o&255)>>>1,r=w>>>0>r>>>0?w:r,r>>>0<11?d=10:d=(r+16&-16)+-1|0;e:do if((d|0)!=(l|0)){do if((d|0)!=10){if(r=d+1|0,d>>>0<=l>>>0){if(g=0,r=ge(67,r|0)|0,h=g,g=0,h&1){t=j(0)|0,K0(t|0)|0,ei();break e}}else r=Xe(r)|0;if(o&1){l=1,c=e[t+8>>2]|0,h=1;break}else{l=1,c=t+1|0,h=0;break}}else r=t+1|0,l=0,c=e[t+8>>2]|0,h=1;while(!1);if(o&1?o=e[t+4>>2]|0:o=(o&255)>>>1,o0(r|0,c|0,o+1|0)|0,h&&he(c),l){e[t>>2]=d+1|1,e[t+4>>2]=w,e[t+8>>2]=r;break}else{S[t>>0]=w<<1;break}}while(!1)}function wp(t,r){return t=t|0,r=r|0,Gs(t,r,$i(r)|0)|0}function yp(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0;o=S[t>>0]|0,l=(o&1)!=0,l?(c=(e[t>>2]&-2)+-1|0,h=e[t+4>>2]|0):(c=10,h=(o&255)>>>1),(h|0)==(c|0)?(pr(t,c,1,c,c,0,0),S[t>>0]&1?c=8:c=7):l?c=8:c=7,(c|0)==7?(S[t>>0]=(h<<1)+2,o=t+1|0,l=h+1|0):(c|0)==8&&(o=e[t+8>>2]|0,l=h+1|0,e[t+4>>2]=l),S[o+h>>0]=r,S[o+l>>0]=0}function Gs(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0;return l=S[t>>0]|0,l&1?(l=e[t>>2]|0,c=(l&-2)+-1|0,l=l&255):c=10,l&1?h=e[t+4>>2]|0:h=(l&255)>>>1,(c-h|0)>>>0>=o>>>0?o&&(l&1?c=e[t+8>>2]|0:c=t+1|0,o0(c+h|0,r|0,o|0)|0,l=h+o|0,S[t>>0]&1?e[t+4>>2]=l:S[t>>0]=l<<1,S[c+l>>0]=0):qs(t,c,o-c+h|0,h,h,0,o,r),t|0}function qs(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0,D=0,k=0;(-18-r|0)>>>0>>0&&si(t),S[t>>0]&1?k=e[t+8>>2]|0:k=t+1|0,r>>>0<2147483623?(C=o+r|0,D=r<<1,C=C>>>0>>0?D:C,C=C>>>0<11?11:C+16&-16):C=-17,D=Xe(C)|0,c&&o0(D|0,k|0,c|0)|0,d&&o0(D+c|0,w|0,d|0)|0,o=l-h|0,(o|0)!=(c|0)&&o0(D+(d+c)|0,k+(h+c)|0,o-c|0)|0,(r|0)!=10&&he(k),e[t+8>>2]=D,e[t>>2]=C|1,r=o+d|0,e[t+4>>2]=r,S[D+r>>0]=0}function pr(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0,D=0;(-17-r|0)>>>0>>0&&si(t),S[t>>0]&1?D=e[t+8>>2]|0:D=t+1|0,r>>>0<2147483623?(w=o+r|0,C=r<<1,w=w>>>0>>0?C:w,w=w>>>0<11?11:w+16&-16):w=-17,C=Xe(w)|0,c&&o0(C|0,D|0,c|0)|0,o=l-h|0,(o|0)!=(c|0)&&o0(C+(d+c)|0,D+(h+c)|0,o-c|0)|0,(r|0)!=10&&he(D),e[t+8>>2]=C,e[t>>2]=w|1}function mr(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;o>>>0>1073741807&&si(t),o>>>0<2?(S[t>>0]=o<<1,t=t+4|0):(c=o+4&-4,l=Xe(c<<2)|0,e[t+8>>2]=l,e[t>>2]=c|1,e[t+4>>2]=o,t=l),Bi(t,r,o)|0,e[t+(o<<2)>>2]=0}function gr(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;r>>>0>1073741807&&si(t),r>>>0<2?(S[t>>0]=r<<1,t=t+4|0):(c=r+4&-4,l=Xe(c<<2)|0,e[t+8>>2]=l,e[t>>2]=c|1,e[t+4>>2]=r,t=l),GS(t,o,r)|0,e[t+(r<<2)>>2]=0}function Pt(t){t=t|0,S[t>>0]&1&&he(e[t+8>>2]|0)}function Cp(t,r){return t=t|0,r=r|0,Tp(t,r,_n(r)|0)|0}function Tp(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0;l=S[t>>0]|0,l&1?(l=e[t>>2]|0,h=(l&-2)+-1|0,l=l&255):h=1,c=(l&1)==0;do if(h>>>0>=o>>>0)if(c?l=t+4|0:l=e[t+8>>2]|0,zS(l,r,o)|0,e[l+(o<<2)>>2]=0,S[t>>0]&1){e[t+4>>2]=o;break}else{S[t>>0]=o<<1;break}else c?l=(l&255)>>>1:l=e[t+4>>2]|0,kp(t,h,o-h|0,l,0,l,o,r);while(!1);return t|0}function Ip(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0;r>>>0>1073741807&&si(t),o=S[t>>0]|0,o&1?(o=e[t>>2]|0,l=(o&-2)+-1|0,o=o&255):l=1,o&1?w=e[t+4>>2]|0:w=(o&255)>>>1,r=w>>>0>r>>>0?w:r,r>>>0<2?d=1:d=(r+4&-4)+-1|0;e:do if((d|0)!=(l|0)){do if((d|0)!=1){if(r=(d<<2)+4|0,d>>>0<=l>>>0){if(g=0,r=ge(67,r|0)|0,h=g,g=0,h&1){t=j(0)|0,K0(t|0)|0,ei();break e}}else r=Xe(r)|0;if(o&1){l=1,c=e[t+8>>2]|0,h=1;break}else{l=1,c=t+4|0,h=0;break}}else r=t+4|0,l=0,c=e[t+8>>2]|0,h=1;while(!1);if(o&1?o=e[t+4>>2]|0:o=(o&255)>>>1,Bi(r,c,o+1|0)|0,h&&he(c),l){e[t>>2]=d+1|1,e[t+4>>2]=w,e[t+8>>2]=r;break}else{S[t>>0]=w<<1;break}}while(!1)}function Ep(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0;o=S[t>>0]|0,l=(o&1)!=0,l?(c=(e[t>>2]&-2)+-1|0,h=e[t+4>>2]|0):(c=1,h=(o&255)>>>1),(h|0)==(c|0)?(Ws(t,c,1,c,c,0,0),S[t>>0]&1?c=8:c=7):l?c=8:c=7,(c|0)==7?(S[t>>0]=(h<<1)+2,o=t+4|0,l=h+1|0):(c|0)==8&&(o=e[t+8>>2]|0,l=h+1|0,e[t+4>>2]=l),e[o+(h<<2)>>2]=r,e[o+(l<<2)>>2]=0}function kp(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0,D=0,k=0;(1073741806-r|0)>>>0>>0&&si(t),S[t>>0]&1?k=e[t+8>>2]|0:k=t+4|0,r>>>0<536870887?(C=o+r|0,D=r<<1,C=C>>>0>>0?D:C,C=C>>>0<2?2:C+4&-4):C=1073741807,D=Xe(C<<2)|0,c&&Bi(D,k,c)|0,d&&Bi(D+(c<<2)|0,w,d)|0,o=l-h|0,(o|0)!=(c|0)&&Bi(D+(d+c<<2)|0,k+(h+c<<2)|0,o-c|0)|0,(r|0)!=1&&he(k),e[t+8>>2]=D,e[t>>2]=C|1,r=o+d|0,e[t+4>>2]=r,e[D+(r<<2)>>2]=0}function Ws(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0,D=0;(1073741807-r|0)>>>0>>0&&si(t),S[t>>0]&1?D=e[t+8>>2]|0:D=t+4|0,r>>>0<536870887?(w=o+r|0,C=r<<1,w=w>>>0>>0?C:w,w=w>>>0<2?2:w+4&-4):w=1073741807,C=Xe(w<<2)|0,c&&Bi(C,D,c)|0,o=l-h|0,(o|0)!=(c|0)&&Bi(C+(d+c<<2)|0,D+(h+c<<2)|0,o-c|0)|0,(r|0)!=1&&he(D),e[t+8>>2]=C,e[t>>2]=w|1}function Dp(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;if(c=r,l=o-c|0,l>>>0>4294967279&&si(t),l>>>0<11?(S[t>>0]=l<<1,h=t+1|0):(d=l+16&-16,h=Xe(d)|0,e[t+8>>2]=h,e[t>>2]=d|1,e[t+4>>2]=l),t=o-c|0,(r|0)!=(o|0))for(l=h;S[l>>0]=S[r>>0]|0,r=r+1|0,(r|0)!=(o|0);)l=l+1|0;S[h+t>>0]=0}function bp(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;if(h=r,l=o-h|0,c=l>>2,c>>>0>1073741807&&si(t),c>>>0<2?(S[t>>0]=l>>>1,t=t+4|0):(d=c+4&-4,l=Xe(d<<2)|0,e[t+8>>2]=l,e[t>>2]=d|1,e[t+4>>2]=c,t=l),c=(o-h|0)>>>2,(r|0)!=(o|0))for(l=t;e[l>>2]=e[r>>2],r=r+4|0,(r|0)!=(o|0);)l=l+4|0;e[t+(c<<2)>>2]=0}function Np(t,r){t=t|0,r=r|0;var o=0,l=0,c=0;if(o=b,b=b+16|0,l=o,c=(e[t+24>>2]|0)==0,e[t+16>>2]=c&1|r,!((c&1|r)&e[t+20>>2])){b=o;return}r=Ct(16)|0,Tm()|0,e[l>>2]=1,e[l+4>>2]=43112,g=0,xe(11,r|0,57437,l|0),c=g,g=0,c&1?(c=j()|0,Tt(r|0),le(c|0)):Qt(r|0,864,112)}function G0(t){t=t|0;var r=0;if(e[t>>2]=43068,g=0,Ae(88,t|0,0),r=g,g=0,r&1)r=j(0)|0,$t(r);else{_0(t+28|0),n0(e[t+32>>2]|0),n0(e[t+36>>2]|0),n0(e[t+48>>2]|0),n0(e[t+60>>2]|0);return}}function tt(t){t=t|0,G0(t)}function mA(t){t=t|0,G0(t),he(t)}function Fp(t,r){t=t|0,r=r|0;var o=0,l=0,c=0;if(o=e[t+40>>2]|0,l=t+32|0,c=t+36|0,o)do o=o+-1|0,Ln[e[(e[l>>2]|0)+(o<<2)>>2]&15](r,t,e[(e[c>>2]|0)+(o<<2)>>2]|0);while(o|0)}function f0(t){t=t|0;var r=0,o=0;return o=b,b=b+16|0,r=o,tn(r,t+28|0),b=o,e[r>>2]|0}function Rp(t,r){t=t|0,r=r|0;var o=0;e[t+24>>2]=r,e[t+16>>2]=(r|0)==0&1,e[t+20>>2]=0,e[t+4>>2]=4098,e[t+12>>2]=0,e[t+8>>2]=6,o=t+28|0,r=t+32|0,t=r+40|0;do e[r>>2]=0,r=r+4|0;while((r|0)<(t|0));ur(o)}function mn(t){t=t|0,G0(t)}function gA(t){t=t|0,G0(t),he(t)}function wt(t){t=t|0,e[t>>2]=42760,_0(t+4|0)}function Mp(t){t=t|0,e[t>>2]=42760,_0(t+4|0),he(t)}function Sr(t){t=t|0,e[t>>2]=42760,ur(t+4|0),t=t+8|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[t+16>>2]=0,e[t+20>>2]=0}function _p(t,r){t=t|0,r=r|0}function Pp(t,r,o){return t=t|0,r=r|0,o=o|0,t|0}function Lp(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,r=t,e[r>>2]=0,e[r+4>>2]=0,r=t+8|0,e[r>>2]=-1,e[r+4>>2]=-1}function Op(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0,r=t,e[r>>2]=0,e[r+4>>2]=0,r=t+8|0,e[r>>2]=-1,e[r+4>>2]=-1}function $p(t){return t=t|0,0}function Bp(t){return t=t|0,0}function Vp(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;h=t+12|0,d=t+16|0;e:do if((o|0)>0)for(c=r,r=0;;){if(l=e[h>>2]|0,l>>>0<(e[d>>2]|0)>>>0)e[h>>2]=l+1,l=S[l>>0]|0;else{if(l=Dt[e[(e[t>>2]|0)+40>>2]&127](t)|0,(l|0)==-1)break e;l=l&255}if(S[c>>0]=l,r=r+1|0,(r|0)<(o|0))c=c+1|0;else break}else r=0;while(!1);return r|0}function Up(t){return t=t|0,-1}function zp(t){t=t|0;var r=0;return(Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0)==-1?t=-1:(r=t+12|0,t=e[r>>2]|0,e[r>>2]=t+1,t=F[t>>0]|0),t|0}function Gp(t,r){return t=t|0,r=r|0,-1}function qp(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0;h=t+24|0,d=t+28|0;e:do if((o|0)>0)for(c=r,r=0;;){if(l=e[h>>2]|0,l>>>0>=(e[d>>2]|0)>>>0){if((U0[e[(e[t>>2]|0)+52>>2]&63](t,F[c>>0]|0)|0)==-1)break e}else w=S[c>>0]|0,e[h>>2]=l+1,S[l>>0]=w;if(r=r+1|0,(r|0)<(o|0))c=c+1|0;else break}else r=0;while(!1);return r|0}function Wp(t,r){return t=t|0,r=r|0,-1}function rn(t){t=t|0,e[t>>2]=42824,_0(t+4|0)}function Hp(t){t=t|0,e[t>>2]=42824,_0(t+4|0),he(t)}function Hs(t){t=t|0,e[t>>2]=42824,ur(t+4|0),t=t+8|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[t+16>>2]=0,e[t+20>>2]=0}function Qp(t,r){t=t|0,r=r|0}function Kp(t,r,o){return t=t|0,r=r|0,o=o|0,t|0}function Yp(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,r=t,e[r>>2]=0,e[r+4>>2]=0,r=t+8|0,e[r>>2]=-1,e[r+4>>2]=-1}function jp(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0,r=t,e[r>>2]=0,e[r+4>>2]=0,r=t+8|0,e[r>>2]=-1,e[r+4>>2]=-1}function Xp(t){return t=t|0,0}function Zp(t){return t=t|0,0}function Jp(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;h=t+12|0,d=t+16|0;e:do if((o|0)>0)for(c=r,r=0;;){if(l=e[h>>2]|0,l>>>0>=(e[d>>2]|0)>>>0){if(l=Dt[e[(e[t>>2]|0)+40>>2]&127](t)|0,(l|0)==-1)break e}else e[h>>2]=l+4,l=e[l>>2]|0;if(e[c>>2]=l,r=r+1|0,(r|0)<(o|0))c=c+4|0;else break}else r=0;while(!1);return r|0}function em(t){return t=t|0,-1}function tm(t){t=t|0;var r=0;return(Dt[e[(e[t>>2]|0)+36>>2]&127](t)|0)==-1?t=-1:(r=t+12|0,t=e[r>>2]|0,e[r>>2]=t+4,t=e[t>>2]|0),t|0}function im(t,r){return t=t|0,r=r|0,-1}function nm(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0;h=t+24|0,d=t+28|0;e:do if((o|0)>0)for(c=r,r=0;;){if(l=e[h>>2]|0,l>>>0>=(e[d>>2]|0)>>>0){if((U0[e[(e[t>>2]|0)+52>>2]&63](t,e[c>>2]|0)|0)==-1)break e}else w=e[c>>2]|0,e[h>>2]=l+4,e[l>>2]=w;if(r=r+1|0,(r|0)<(o|0))c=c+4|0;else break}else r=0;while(!1);return r|0}function rm(t,r){return t=t|0,r=r|0,-1}function sm(t){t=t|0,G0(t+8|0)}function om(t){t=t|0,G0(t+((e[(e[t>>2]|0)+-12>>2]|0)+8)|0)}function Qs(t){t=t|0,G0(t+8|0),he(t)}function am(t){t=t|0,Qs(t+(e[(e[t>>2]|0)+-12>>2]|0)|0)}function Ks(t){t=t|0;var r=0,o=0,l=0,c=0;l=b,b=b+16|0,o=l;e:do if(e[t+((e[(e[t>>2]|0)+-12>>2]|0)+24)>>2]|0){g=0,Ae(65,o|0,t|0),r=g,g=0;t:do if(r&1)r=j(0)|0;else{do if(S[o>>0]|0){if(r=e[t+((e[(e[t>>2]|0)+-12>>2]|0)+24)>>2]|0,g=0,r=ge(e[(e[r>>2]|0)+24>>2]|0,r|0)|0,c=g,g=0,!(c&1)&&((r|0)!=-1||(c=e[(e[t>>2]|0)+-12>>2]|0,g=0,Ae(66,t+c|0,e[t+(c+16)>>2]|1|0),c=g,g=0,!(c&1))))break;r=j(0)|0,Ei(o);break t}while(!1);Ei(o);break e}while(!1);if(K0(r|0)|0,g=0,ue(181,t+(e[(e[t>>2]|0)+-12>>2]|0)|0),c=g,g=0,!(c&1)){ei();break}r=j()|0,g=0,Nt(3),c=g,g=0,c&1?(c=j(0)|0,$t(c)):le(r|0)}while(!1);return b=l,t|0}function lm(t){t=t|0;var r=0;if(r=t+16|0,e[r>>2]=e[r>>2]|1,e[t+20>>2]&1)Ur();else return}function um(t){t=t|0,G0(t+8|0)}function cm(t){t=t|0,G0(t+((e[(e[t>>2]|0)+-12>>2]|0)+8)|0)}function Ys(t){t=t|0,G0(t+8|0),he(t)}function fm(t){t=t|0,Ys(t+(e[(e[t>>2]|0)+-12>>2]|0)|0)}function js(t){t=t|0;var r=0,o=0,l=0,c=0;l=b,b=b+16|0,o=l;e:do if(e[t+((e[(e[t>>2]|0)+-12>>2]|0)+24)>>2]|0){g=0,Ae(89,o|0,t|0),r=g,g=0;t:do if(r&1)r=j(0)|0;else{do if(S[o>>0]|0){if(r=e[t+((e[(e[t>>2]|0)+-12>>2]|0)+24)>>2]|0,g=0,r=ge(e[(e[r>>2]|0)+24>>2]|0,r|0)|0,c=g,g=0,!(c&1)&&((r|0)!=-1||(c=e[(e[t>>2]|0)+-12>>2]|0,g=0,Ae(66,t+c|0,e[t+(c+16)>>2]|1|0),c=g,g=0,!(c&1))))break;r=j(0)|0,Js(o);break t}while(!1);Js(o);break e}while(!1);if(K0(r|0)|0,g=0,ue(181,t+(e[(e[t>>2]|0)+-12>>2]|0)|0),c=g,g=0,!(c&1)){ei();break}r=j()|0,g=0,Nt(3),c=g,g=0,c&1?(c=j(0)|0,$t(c)):le(r|0)}while(!1);return b=l,t|0}function SA(t,r){t=t|0,r=r|0}function hm(t){t=t|0,G0(t+4|0)}function dm(t){t=t|0,G0(t+((e[(e[t>>2]|0)+-12>>2]|0)+4)|0)}function Xs(t){t=t|0,G0(t+4|0),he(t)}function pm(t){t=t|0,Xs(t+(e[(e[t>>2]|0)+-12>>2]|0)|0)}function mm(t,r){t=t|0,r=r|0;var o=0;S[t>>0]=0,e[t+4>>2]=r,o=e[(e[r>>2]|0)+-12>>2]|0,e[r+(o+16)>>2]|0||(o=e[r+(o+72)>>2]|0,o&&Ks(o)|0,S[t>>0]=1)}function Ei(t){t=t|0;var r=0,o=0;t=t+4|0,o=e[t>>2]|0,r=e[(e[o>>2]|0)+-12>>2]|0;do if(e[o+(r+24)>>2]|0&&!(e[o+(r+16)>>2]|0)&&e[o+(r+4)>>2]&8192|0&&!(Or()|0)){if(r=e[t>>2]|0,r=e[r+((e[(e[r>>2]|0)+-12>>2]|0)+24)>>2]|0,g=0,r=ge(e[(e[r>>2]|0)+24>>2]|0,r|0)|0,o=g,g=0,!(o&1)&&((r|0)!=-1||(r=e[t>>2]|0,o=e[(e[r>>2]|0)+-12>>2]|0,g=0,Ae(66,r+o|0,e[r+(o+16)>>2]|1|0),o=g,g=0,!(o&1))))break;o=j(0)|0,K0(o|0)|0,g=0,Nt(3),o=g,g=0,o&1&&(o=j(0)|0,$t(o))}while(!1)}function gm(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;R=b,b=b+32|0,w=R+20|0,C=R+16|0,k=R+8|0,o=R,g=0,Ae(65,k|0,t|0),D=g,g=0;e:do if(D&1)o=j(0)|0,l=t,c=t,N=19;else{do if(S[k>>0]|0){if(D=f0(t+(e[(e[t>>2]|0)+-12>>2]|0)|0)|0,e[o>>2]=D,g=0,D=be(37,o|0,43392)|0,d=g,g=0,d&1)N=j(0)|0,_0(o),o=N;else{_0(o),c=e[(e[t>>2]|0)+-12>>2]|0,d=e[t+(c+24)>>2]|0,l=t+c|0,c=t+(c+76)|0,o=e[c>>2]|0;do if((o|0)==-1){if(o=f0(l)|0,e[w>>2]=o,g=0,o=be(37,w|0,44220)|0,_=g,g=0,!(_&1)&&(g=0,h=be(e[(e[o>>2]|0)+28>>2]|0,o|0,32)|0,_=g,g=0,!(_&1))){_0(w),o=h<<24>>24,e[c>>2]=o,N=10;break}o=j(0)|0,_0(w)}else N=10;while(!1);if((N|0)==10){if(_=e[(e[D>>2]|0)+16>>2]|0,e[C>>2]=d,g=0,e[w>>2]=e[C>>2],o=se(_|0,D|0,w|0,l|0,o&255|0,r|0)|0,_=g,g=0,!(_&1)&&(o||(_=e[(e[t>>2]|0)+-12>>2]|0,g=0,Ae(66,t+_|0,e[t+(_+16)>>2]|5|0),_=g,g=0,!(_&1))))break;o=j(0)|0}}Ei(k),l=t,c=t,N=19;break e}while(!1);Ei(k)}while(!1);do if((N|0)==19){if(K0(o|0)|0,g=0,ue(181,l+(e[(e[c>>2]|0)+-12>>2]|0)|0),_=g,g=0,!(_&1)){ei();break}o=j()|0,g=0,Nt(3),_=g,g=0,_&1?(_=j(0)|0,$t(_)):le(o|0)}while(!1);return b=R,t|0}function Sm(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;R=b,b=b+32|0,w=R+20|0,C=R+16|0,k=R+8|0,o=R,g=0,Ae(65,k|0,t|0),D=g,g=0;e:do if(D&1)o=j(0)|0,l=t,c=t,N=19;else{do if(S[k>>0]|0){if(D=f0(t+(e[(e[t>>2]|0)+-12>>2]|0)|0)|0,e[o>>2]=D,g=0,D=be(37,o|0,43392)|0,d=g,g=0,d&1)N=j(0)|0,_0(o),o=N;else{_0(o),c=e[(e[t>>2]|0)+-12>>2]|0,d=e[t+(c+24)>>2]|0,l=t+c|0,c=t+(c+76)|0,o=e[c>>2]|0;do if((o|0)==-1){if(o=f0(l)|0,e[w>>2]=o,g=0,o=be(37,w|0,44220)|0,_=g,g=0,!(_&1)&&(g=0,h=be(e[(e[o>>2]|0)+28>>2]|0,o|0,32)|0,_=g,g=0,!(_&1))){_0(w),o=h<<24>>24,e[c>>2]=o,N=10;break}o=j(0)|0,_0(w)}else N=10;while(!1);if((N|0)==10){if(_=e[(e[D>>2]|0)+24>>2]|0,e[C>>2]=d,g=0,e[w>>2]=e[C>>2],o=se(_|0,D|0,w|0,l|0,o&255|0,r|0)|0,_=g,g=0,!(_&1)&&(o||(_=e[(e[t>>2]|0)+-12>>2]|0,g=0,Ae(66,t+_|0,e[t+(_+16)>>2]|5|0),_=g,g=0,!(_&1))))break;o=j(0)|0}}Ei(k),l=t,c=t,N=19;break e}while(!1);Ei(k)}while(!1);do if((N|0)==19){if(K0(o|0)|0,g=0,ue(181,l+(e[(e[c>>2]|0)+-12>>2]|0)|0),_=g,g=0,!(_&1)){ei();break}o=j()|0,g=0,Nt(3),_=g,g=0,_&1?(_=j(0)|0,$t(_)):le(o|0)}while(!1);return b=R,t|0}function Am(t){t=t|0,G0(t+4|0)}function vm(t){t=t|0,G0(t+((e[(e[t>>2]|0)+-12>>2]|0)+4)|0)}function Zs(t){t=t|0,G0(t+4|0),he(t)}function xm(t){t=t|0,Zs(t+(e[(e[t>>2]|0)+-12>>2]|0)|0)}function wm(t,r){t=t|0,r=r|0;var o=0;S[t>>0]=0,e[t+4>>2]=r,o=e[(e[r>>2]|0)+-12>>2]|0,e[r+(o+16)>>2]|0||(o=e[r+(o+72)>>2]|0,o&&js(o)|0,S[t>>0]=1)}function Js(t){t=t|0;var r=0,o=0;t=t+4|0,o=e[t>>2]|0,r=e[(e[o>>2]|0)+-12>>2]|0;do if(e[o+(r+24)>>2]|0&&!(e[o+(r+16)>>2]|0)&&e[o+(r+4)>>2]&8192|0&&!(Or()|0)){if(r=e[t>>2]|0,r=e[r+((e[(e[r>>2]|0)+-12>>2]|0)+24)>>2]|0,g=0,r=ge(e[(e[r>>2]|0)+24>>2]|0,r|0)|0,o=g,g=0,!(o&1)&&((r|0)!=-1||(r=e[t>>2]|0,o=e[(e[r>>2]|0)+-12>>2]|0,g=0,Ae(66,r+o|0,e[r+(o+16)>>2]|1|0),o=g,g=0,!(o&1))))break;o=j(0)|0,K0(o|0)|0,g=0,Nt(3),o=g,g=0,o&1&&(o=j(0)|0,$t(o))}while(!1)}function ym(t){return t=t|0,57453}function Cm(t,r,o){t=t|0,r=r|0,o=o|0,(o|0)!=1&(o|0)<257?up(t,r,o):yi(t,57462,35)}function Tm(){return!(S[1048]|0)&&kt(1048)|0&&(e[10778]=43084,Ft(72,43112,H|0)|0,bt(1048)),43112}function Im(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0;l=b,b=b+16|0,c=l+8|0,h=l,w=o,d=e[w+4>>2]|0,o=h,e[o>>2]=e[w>>2],e[o+4>>2]=d,e[c>>2]=e[h>>2],e[c+4>>2]=e[h+4>>2],fp(t,c,r),e[t>>2]=43048,b=l}function Em(t){t=t|0,fr(t)}function km(t){t=t|0,fr(t),he(t)}function Dm(t){t=t|0,G0(t),he(t)}function bm(t){t=t|0,he(t)}function Nm(t){t=t|0}function Fm(t){t=t|0}function Rm(t){t=t|0,he(t)}function Mm(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;e:do if((l|0)==(c|0))d=6;else for(;;){if((r|0)==(o|0)){r=-1;break e}if(t=S[r>>0]|0,h=S[l>>0]|0,t<<24>>24>24){r=-1;break e}if(h<<24>>24>24){r=1;break e}if(r=r+1|0,l=l+1|0,(l|0)==(c|0)){d=6;break}}while(!1);return(d|0)==6&&(r=(r|0)!=(o|0)&1),r|0}function _m(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0,Dp(t,o,l)}function Pm(t,r,o){t=t|0,r=r|0,o=o|0;var l=0;if((r|0)==(o|0))t=0;else{t=0;do t=(S[r>>0]|0)+(t<<4)|0,l=t&-268435456,t=(l>>>24|l)^t,r=r+1|0;while((r|0)!=(o|0))}return t|0}function Lm(t){t=t|0}function Om(t){t=t|0,he(t)}function $m(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;e:do if((l|0)==(c|0))d=6;else for(;;){if((r|0)==(o|0)){r=-1;break e}if(t=e[r>>2]|0,h=e[l>>2]|0,(t|0)<(h|0)){r=-1;break e}if((h|0)<(t|0)){r=1;break e}if(r=r+4|0,l=l+4|0,(l|0)==(c|0)){d=6;break}}while(!1);return(d|0)==6&&(r=(r|0)!=(o|0)&1),r|0}function Bm(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0,bp(t,o,l)}function Vm(t,r,o){t=t|0,r=r|0,o=o|0;var l=0;if((r|0)==(o|0))t=0;else{t=0;do t=(e[r>>2]|0)+(t<<4)|0,l=t&-268435456,t=(l>>>24|l)^t,r=r+4|0;while((r|0)!=(o|0))}return t|0}function Um(t){t=t|0}function zm(t){t=t|0,he(t)}function Gm(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;U=b,b=b+64|0,R=U+56|0,d=U+52|0,k=U+48|0,w=U+44|0,C=U+40|0,D=U+36|0,N=U+32|0,Q=U+8|0,_=U;e:do if(e[l+4>>2]&1){d=f0(l)|0,e[D>>2]=d,g=0,t=be(37,D|0,44220)|0,k=g,g=0;do if(k&1)Q=j()|0,Bt(d)|0,d=Q;else{if(Bt(d)|0,d=f0(l)|0,e[N>>2]=d,g=0,C=be(37,N|0,44360)|0,N=g,g=0,N&1){Q=j()|0,Bt(d)|0,d=Q;break}if(Bt(d)|0,g=0,Ae(e[(e[C>>2]|0)+24>>2]|0,Q|0,C|0),N=g,g=0,N&1)w=Q;else if(w=Q+12|0,g=0,Ae(e[(e[C>>2]|0)+28>>2]|0,w|0,C|0),N=g,g=0,!(N&1))if(e[_>>2]=e[o>>2],g=0,e[R>>2]=e[_>>2],d=vt(7,r|0,R|0,Q|0,Q+24|0,t|0,c|0,1)|0,c=g,g=0,c&1){d=j()|0,de(Q+12|0),de(Q);break}else{S[h>>0]=(d|0)==(Q|0)&1,d=e[r>>2]|0,de(Q+12|0),de(Q);break e}if(d=j()|0,C=ye,(Q|0)!=(w|0))do w=w+-12|0,de(w);while((w|0)!=(Q|0))}while(!1);le(d|0)}else switch(e[k>>2]=-1,Q=e[(e[t>>2]|0)+16>>2]|0,e[w>>2]=e[r>>2],e[C>>2]=e[o>>2],e[d>>2]=e[w>>2],e[R>>2]=e[C>>2],d=on[Q&63](t,d,R,l,c,k)|0,e[r>>2]=d,e[k>>2]|0){case 0:{S[h>>0]=0;break e}case 1:{S[h>>0]=1;break e}default:{S[h>>0]=1,e[c>>2]=4;break e}}while(!1);return b=U,d|0}function qm(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=M4(t,C,w,l,c,h)|0,b=d,t|0}function Wm(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=_4(t,C,w,l,c,h)|0,b=d,t|0}function Hm(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=P4(t,C,w,l,c,h)|0,b=d,t|0}function Qm(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=L4(t,C,w,l,c,h)|0,b=d,t|0}function Km(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=O4(t,C,w,l,c,h)|0,b=d,t|0}function Ym(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=$4(t,C,w,l,c,h)|0,b=d,t|0}function jm(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=B4(t,C,w,l,c,h)|0,b=d,t|0}function Xm(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=V4(t,C,w,l,c,h)|0,b=d,t|0}function Zm(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=U4(t,C,w,l,c,h)|0,b=d,t|0}function Jm(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0;oe=b,b=b+240|0,$=oe,_=oe+208|0,ce=oe+32|0,t=oe+28|0,ne=oe+16|0,G=oe+12|0,Q=oe+48|0,K=oe+8|0,U=oe+4|0,e[ce>>2]=0,e[ce+4>>2]=0,e[ce+8>>2]=0,g=0,l=ge(68,l|0)|0,R=g,g=0;do if(R&1)t=j()|0;else{if(e[t>>2]=l,g=0,t=be(37,t|0,44220)|0,R=g,g=0,!(R&1)&&(g=0,Pe(e[(e[t>>2]|0)+32>>2]|0,t|0,57498,57524,_|0)|0,R=g,g=0,!(R&1))){Bt(l)|0,e[ne>>2]=0,e[ne+4>>2]=0,e[ne+8>>2]=0,S[ne>>0]&1?t=(e[ne>>2]&-2)+-1|0:t=10,g=0,xe(8,ne|0,t|0,0),R=g,g=0;e:do if(R&1)ke=30;else{N=ne+8|0,R=ne+1|0,l=S[ne>>0]&1?e[N>>2]|0:R,e[G>>2]=l,e[K>>2]=Q,e[U>>2]=0,k=ne+4|0,t=e[r>>2]|0;t:for(;;){if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,d=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,D=g,g=0,D&1){ke=29;break}(d|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;w=(t|0)==0,d=e[o>>2]|0;do if(d){if((e[d+12>>2]|0)!=(e[d+16>>2]|0)){if(w)break;break t}if(g=0,C=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,D=g,g=0,D&1){ke=29;break t}if((C|0)!=-1){if(w)break;break t}else{e[o>>2]=0,ke=19;break}}else ke=19;while(!1);if((ke|0)==19)if(ke=0,w){d=0;break}else d=0;if(w=S[ne>>0]|0,w=w&1?e[k>>2]|0:(w&255)>>>1,(e[G>>2]|0)==(l+w|0)){if(g=0,xe(8,ne|0,w<<1|0,0),D=g,g=0,D&1){ke=29;break}if(S[ne>>0]&1?l=(e[ne>>2]&-2)+-1|0:l=10,g=0,xe(8,ne|0,l|0,0),D=g,g=0,D&1){ke=29;break}l=S[ne>>0]&1?e[N>>2]|0:R,e[G>>2]=l+w}if(C=t+12|0,w=e[C>>2]|0,D=t+16|0,(w|0)==(e[D>>2]|0)){if(g=0,w=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,Ee=g,g=0,Ee&1){ke=29;break}}else w=F[w>>0]|0;if(_i(w&255,16,l,G,U,0,ce,Q,K,_)|0)break;if(d=e[C>>2]|0,(d|0)==(e[D>>2]|0))if(g=0,ge(e[(e[t>>2]|0)+40>>2]|0,t|0)|0,Ee=g,g=0,Ee&1){ke=29;break}else continue;else{e[C>>2]=d+1;continue}}if((ke|0)==29){t=j()|0;break}if(g=0,xe(8,ne|0,(e[G>>2]|0)-l|0,0),Ee=g,g=0,!(Ee&1)&&(P=S[ne>>0]|0,O=e[N>>2]|0,g=0,Z=Ce(3)|0,Ee=g,g=0,!(Ee&1))&&(g=0,e[$>>2]=h,ie=Pe(16,(P&1?O:R)|0,Z|0,58882,$|0)|0,Ee=g,g=0,!(Ee&1))){if((ie|0)!=1&&(e[c>>2]=4),t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,l=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,Ee=g,g=0,Ee&1){ke=30;break}(l|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;l=(t|0)==0;do if(d){if((e[d+12>>2]|0)==(e[d+16>>2]|0)){if(g=0,t=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,Ee=g,g=0,Ee&1){ke=30;break e}if((t|0)==-1){e[o>>2]=0,ke=55;break}}l||(ke=56)}else ke=55;while(!1);return(ke|0)==55&&l&&(ke=56),(ke|0)==56&&(e[c>>2]=e[c>>2]|2),Ee=e[r>>2]|0,de(ne),de(ce),b=oe,Ee|0}else ke=30}while(!1);(ke|0)==30&&(t=j()|0),de(ne);break}t=j()|0,Bt(l)|0}while(!1);return de(ce),le(t|0),0}function _i(t,r,o,l,c,h,d,w,C,D){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0;var k=0,N=0,R=0,_=0;R=e[l>>2]|0,_=(R|0)==(o|0);do if(_){if(k=(S[D+24>>0]|0)==t<<24>>24,!k&&(S[D+25>>0]|0)!=t<<24>>24){N=5;break}e[l>>2]=o+1,S[o>>0]=k?43:45,e[c>>2]=0,k=0}else N=5;while(!1);e:do if((N|0)==5){if(N=S[d>>0]|0,t<<24>>24==h<<24>>24&&(N&1?e[d+4>>2]|0:(N&255)>>>1)|0){if(k=e[C>>2]|0,(k-w|0)>=160){k=0;break}r=e[c>>2]|0,e[C>>2]=k+4,e[k>>2]=r,e[c>>2]=0,k=0;break}for(d=D+26|0,k=D;(S[k>>0]|0)!=t<<24>>24;)if(k=k+1|0,(k|0)==(d|0)){k=d;break}if(k=k-D|0,(k|0)>23)k=-1;else{switch(r|0){case 10:case 8:{if((k|0)>=(r|0)){k=-1;break e}break}case 16:{if((k|0)>=22){if(_){k=-1;break e}if((R-o|0)>=3){k=-1;break e}if((S[R+-1>>0]|0)!=48){k=-1;break e}e[c>>2]=0,k=S[57498+k>>0]|0,e[l>>2]=R+1,S[R>>0]=k,k=0;break e}break}default:}k=S[57498+k>>0]|0,e[l>>2]=R+1,S[R>>0]=k,e[c>>2]=(e[c>>2]|0)+1,k=0}}while(!1);return k|0}function b0(){var t=0,r=0;do if(!(S[1968]|0)&&kt(1968)|0)if(g=0,t=Ve(31,2147483647,58885,0)|0,r=g,g=0,r&1)r=j()|0,W0(1968),le(r|0);else{e[11196]=t,bt(1968);break}while(!1);return e[11196]|0}function eg(t){t=t|0}function tg(t){t=t|0,he(t)}function ig(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;U=b,b=b+64|0,R=U+56|0,d=U+52|0,k=U+48|0,w=U+44|0,C=U+40|0,D=U+36|0,N=U+32|0,Q=U+8|0,_=U;e:do if(e[l+4>>2]&1){d=f0(l)|0,e[D>>2]=d,g=0,t=be(37,D|0,44212)|0,k=g,g=0;do if(k&1)Q=j()|0,Bt(d)|0,d=Q;else{if(Bt(d)|0,d=f0(l)|0,e[N>>2]=d,g=0,C=be(37,N|0,44368)|0,N=g,g=0,N&1){Q=j()|0,Bt(d)|0,d=Q;break}if(Bt(d)|0,g=0,Ae(e[(e[C>>2]|0)+24>>2]|0,Q|0,C|0),N=g,g=0,N&1)w=Q;else if(w=Q+12|0,g=0,Ae(e[(e[C>>2]|0)+28>>2]|0,w|0,C|0),N=g,g=0,!(N&1))if(e[_>>2]=e[o>>2],g=0,e[R>>2]=e[_>>2],d=vt(8,r|0,R|0,Q|0,Q+24|0,t|0,c|0,1)|0,c=g,g=0,c&1){d=j()|0,Pt(Q+12|0),Pt(Q);break}else{S[h>>0]=(d|0)==(Q|0)&1,d=e[r>>2]|0,Pt(Q+12|0),Pt(Q);break e}if(d=j()|0,C=ye,(Q|0)!=(w|0))do w=w+-12|0,Pt(w);while((w|0)!=(Q|0))}while(!1);le(d|0)}else switch(e[k>>2]=-1,Q=e[(e[t>>2]|0)+16>>2]|0,e[w>>2]=e[r>>2],e[C>>2]=e[o>>2],e[d>>2]=e[w>>2],e[R>>2]=e[C>>2],d=on[Q&63](t,d,R,l,c,k)|0,e[r>>2]=d,e[k>>2]|0){case 0:{S[h>>0]=0;break e}case 1:{S[h>>0]=1;break e}default:{S[h>>0]=1,e[c>>2]=4;break e}}while(!1);return b=U,d|0}function ng(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=G4(t,C,w,l,c,h)|0,b=d,t|0}function rg(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=q4(t,C,w,l,c,h)|0,b=d,t|0}function sg(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=W4(t,C,w,l,c,h)|0,b=d,t|0}function og(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=H4(t,C,w,l,c,h)|0,b=d,t|0}function ag(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=Q4(t,C,w,l,c,h)|0,b=d,t|0}function lg(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=K4(t,C,w,l,c,h)|0,b=d,t|0}function ug(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=Y4(t,C,w,l,c,h)|0,b=d,t|0}function cg(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=j4(t,C,w,l,c,h)|0,b=d,t|0}function fg(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0;return d=b,b=b+16|0,w=d+12|0,C=d+8|0,k=d+4|0,D=d,e[k>>2]=e[r>>2],e[D>>2]=e[o>>2],e[C>>2]=e[k>>2],e[w>>2]=e[D>>2],t=X4(t,C,w,l,c,h)|0,b=d,t|0}function hg(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0;oe=b,b=b+320|0,$=oe,_=oe+208|0,ce=oe+32|0,t=oe+28|0,ne=oe+16|0,G=oe+12|0,Q=oe+48|0,K=oe+8|0,U=oe+4|0,e[ce>>2]=0,e[ce+4>>2]=0,e[ce+8>>2]=0,g=0,l=ge(68,l|0)|0,R=g,g=0;do if(R&1)t=j()|0;else{if(e[t>>2]=l,g=0,t=be(37,t|0,44212)|0,R=g,g=0,!(R&1)&&(g=0,Pe(e[(e[t>>2]|0)+48>>2]|0,t|0,57498,57524,_|0)|0,R=g,g=0,!(R&1))){Bt(l)|0,e[ne>>2]=0,e[ne+4>>2]=0,e[ne+8>>2]=0,S[ne>>0]&1?t=(e[ne>>2]&-2)+-1|0:t=10,g=0,xe(8,ne|0,t|0,0),R=g,g=0;e:do if(R&1)ke=31;else{N=ne+8|0,R=ne+1|0,t=S[ne>>0]&1?e[N>>2]|0:R,e[G>>2]=t,e[K>>2]=Q,e[U>>2]=0,k=ne+4|0,d=e[r>>2]|0;t:for(;;){if(d){if(l=e[d+12>>2]|0,(l|0)==(e[d+16>>2]|0)){if(g=0,l=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,D=g,g=0,D&1){ke=30;break}}else l=e[l>>2]|0;(l|0)==-1?(e[r>>2]=0,l=0,w=1):(l=d,w=0)}else l=0,w=1;C=e[o>>2]|0;do if(C){if(d=e[C+12>>2]|0,(d|0)==(e[C+16>>2]|0)){if(g=0,d=ge(e[(e[C>>2]|0)+36>>2]|0,C|0)|0,D=g,g=0,D&1){ke=30;break t}}else d=e[d>>2]|0;if((d|0)!=-1)if(w){d=C;break}else{d=C;break t}else{e[o>>2]=0,ke=20;break}}else ke=20;while(!1);if((ke|0)==20)if(ke=0,w){d=0;break}else d=0;if(w=S[ne>>0]|0,w=w&1?e[k>>2]|0:(w&255)>>>1,(e[G>>2]|0)==(t+w|0)){if(g=0,xe(8,ne|0,w<<1|0,0),D=g,g=0,D&1){ke=30;break}if(S[ne>>0]&1?t=(e[ne>>2]&-2)+-1|0:t=10,g=0,xe(8,ne|0,t|0,0),D=g,g=0,D&1){ke=30;break}t=S[ne>>0]&1?e[N>>2]|0:R,e[G>>2]=t+w}if(C=l+12|0,w=e[C>>2]|0,D=l+16|0,(w|0)==(e[D>>2]|0)){if(g=0,w=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,Ee=g,g=0,Ee&1){ke=30;break}}else w=e[w>>2]|0;if(Pi(w,16,t,G,U,0,ce,Q,K,_)|0)break;if(d=e[C>>2]|0,(d|0)==(e[D>>2]|0))if(g=0,ge(e[(e[l>>2]|0)+40>>2]|0,l|0)|0,Ee=g,g=0,Ee&1){ke=30;break}else{d=l;continue}else{e[C>>2]=d+4,d=l;continue}}if((ke|0)==30){t=j()|0;break}if(g=0,xe(8,ne|0,(e[G>>2]|0)-t|0,0),Ee=g,g=0,!(Ee&1)&&(P=S[ne>>0]|0,O=e[N>>2]|0,g=0,Z=Ce(3)|0,Ee=g,g=0,!(Ee&1))&&(g=0,e[$>>2]=h,ie=Pe(16,(P&1?O:R)|0,Z|0,58882,$|0)|0,Ee=g,g=0,!(Ee&1))){if((ie|0)!=1&&(e[c>>2]=4),l){if(t=e[l+12>>2]|0,(t|0)==(e[l+16>>2]|0)){if(g=0,t=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,Ee=g,g=0,Ee&1){ke=31;break}}else t=e[t>>2]|0;(t|0)==-1?(e[r>>2]=0,l=1):l=0}else l=1;do if(d){if(t=e[d+12>>2]|0,(t|0)==(e[d+16>>2]|0)){if(g=0,t=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,Ee=g,g=0,Ee&1){ke=31;break e}}else t=e[t>>2]|0;if((t|0)!=-1){if(l)break;ke=59;break}else{e[o>>2]=0,ke=57;break}}else ke=57;while(!1);return(ke|0)==57&&l&&(ke=59),(ke|0)==59&&(e[c>>2]=e[c>>2]|2),Ee=e[r>>2]|0,de(ne),de(ce),b=oe,Ee|0}else ke=31}while(!1);(ke|0)==31&&(t=j()|0),de(ne);break}t=j()|0,Bt(l)|0}while(!1);return de(ce),le(t|0),0}function Pi(t,r,o,l,c,h,d,w,C,D){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0;var k=0,N=0,R=0,_=0;R=e[l>>2]|0,_=(R|0)==(o|0);do if(_){if(k=(e[D+96>>2]|0)==(t|0),!k&&(e[D+100>>2]|0)!=(t|0)){N=5;break}e[l>>2]=o+1,S[o>>0]=k?43:45,e[c>>2]=0,k=0}else N=5;while(!1);e:do if((N|0)==5){if(N=S[d>>0]|0,(t|0)==(h|0)&&(N&1?e[d+4>>2]|0:(N&255)>>>1)|0){if(k=e[C>>2]|0,(k-w|0)>=160){k=0;break}r=e[c>>2]|0,e[C>>2]=k+4,e[k>>2]=r,e[c>>2]=0,k=0;break}for(d=D+104|0,k=D;(e[k>>2]|0)!=(t|0);)if(k=k+4|0,(k|0)==(d|0)){k=d;break}if(k=k-D|0,d=k>>2,(k|0)>92)k=-1;else{switch(r|0){case 10:case 8:{if((d|0)>=(r|0)){k=-1;break e}break}case 16:{if((k|0)>=88){if(_){k=-1;break e}if((R-o|0)>=3){k=-1;break e}if((S[R+-1>>0]|0)!=48){k=-1;break e}e[c>>2]=0,k=S[57498+d>>0]|0,e[l>>2]=R+1,S[R>>0]=k,k=0;break e}break}default:}k=S[57498+d>>0]|0,e[l>>2]=R+1,S[R>>0]=k,e[c>>2]=(e[c>>2]|0)+1,k=0}}while(!1);return k|0}function qi(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0;if(C=b,b=b+16|0,w=C,r=f0(r)|0,e[w>>2]=r,g=0,c=be(37,w|0,44220)|0,D=g,g=0,!(D&1)&&(g=0,Pe(e[(e[c>>2]|0)+32>>2]|0,c|0,57498,57524,o|0)|0,D=g,g=0,!(D&1))&&(g=0,d=be(37,w|0,44360)|0,D=g,g=0,!(D&1))&&(g=0,h=ge(e[(e[d>>2]|0)+16>>2]|0,d|0)|0,D=g,g=0,!(D&1))&&(S[l>>0]=h,g=0,Ae(e[(e[d>>2]|0)+20>>2]|0,t|0,d|0),D=g,g=0,!(D&1))){Bt(r)|0,b=C;return}D=j()|0,Bt(r)|0,le(D|0)}function Ar(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0;if(k=b,b=b+16|0,D=k,r=f0(r)|0,e[D>>2]=r,g=0,h=be(37,D|0,44220)|0,N=g,g=0,!(N&1)&&(g=0,Pe(e[(e[h>>2]|0)+32>>2]|0,h|0,57498,57530,o|0)|0,N=g,g=0,!(N&1))&&(g=0,C=be(37,D|0,44360)|0,N=g,g=0,!(N&1))&&(g=0,d=ge(e[(e[C>>2]|0)+12>>2]|0,C|0)|0,N=g,g=0,!(N&1))&&(S[l>>0]=d,g=0,w=ge(e[(e[C>>2]|0)+16>>2]|0,C|0)|0,N=g,g=0,!(N&1))&&(S[c>>0]=w,g=0,Ae(e[(e[C>>2]|0)+20>>2]|0,t|0,C|0),N=g,g=0,!(N&1))){Bt(r)|0,b=k;return}N=j()|0,Bt(r)|0,le(N|0)}function vr(t,r,o,l,c,h,d,w,C,D,k,N){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0,k=k|0,N=N|0;var R=0,_=0;e:do if(t<<24>>24==h<<24>>24)S[r>>0]|0?(S[r>>0]=0,o=e[c>>2]|0,e[c>>2]=o+1,S[o>>0]=46,o=S[w>>0]|0,(o&1?e[w+4>>2]|0:(o&255)>>>1)|0&&(R=e[D>>2]|0,(R-C|0)<160)&&(C=e[k>>2]|0,e[D>>2]=R+4,e[R>>2]=C),R=0):R=-1;else{if(t<<24>>24==d<<24>>24&&(d=S[w>>0]|0,((d&1?e[w+4>>2]|0:(d&255)>>>1)|0)!=0)){if(!(S[r>>0]|0)){R=-1;break}if(R=e[D>>2]|0,(R-C|0)>=160){R=0;break}C=e[k>>2]|0,e[D>>2]=R+4,e[R>>2]=C,e[k>>2]=0,R=0;break}for(h=N+32|0,R=N;(S[R>>0]|0)!=t<<24>>24;)if(R=R+1|0,(R|0)==(h|0)){R=h;break}if(h=R-N|0,(h|0)>31)R=-1;else switch(d=S[57498+h>>0]|0,h|0){case 24:case 25:{if(R=e[c>>2]|0,(R|0)!=(l|0)&&(F[R+-1>>0]&95|0)!=(F[o>>0]&127|0)){R=-1;break e}e[c>>2]=R+1,S[R>>0]=d,R=0;break e}case 23:case 22:{S[o>>0]=80,R=e[c>>2]|0,e[c>>2]=R+1,S[R>>0]=d,R=0;break e}default:{if(R=d&95,(R|0)==(S[o>>0]|0)&&(S[o>>0]=R|128,(S[r>>0]|0)!=0)&&(S[r>>0]=0,o=S[w>>0]|0,((o&1?e[w+4>>2]|0:(o&255)>>>1)|0)!=0)&&(_=e[D>>2]|0,(_-C|0)<160)&&(C=e[k>>2]|0,e[D>>2]=_+4,e[_>>2]=C),D=e[c>>2]|0,e[c>>2]=D+1,S[D>>0]=d,(h|0)>21){R=0;break e}e[k>>2]=(e[k>>2]|0)+1,R=0;break e}}}while(!1);return R|0}function Wi(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0;if(C=b,b=b+16|0,w=C,r=f0(r)|0,e[w>>2]=r,g=0,c=be(37,w|0,44212)|0,D=g,g=0,!(D&1)&&(g=0,Pe(e[(e[c>>2]|0)+48>>2]|0,c|0,57498,57524,o|0)|0,D=g,g=0,!(D&1))&&(g=0,d=be(37,w|0,44368)|0,D=g,g=0,!(D&1))&&(g=0,h=ge(e[(e[d>>2]|0)+16>>2]|0,d|0)|0,D=g,g=0,!(D&1))&&(e[l>>2]=h,g=0,Ae(e[(e[d>>2]|0)+20>>2]|0,t|0,d|0),D=g,g=0,!(D&1))){Bt(r)|0,b=C;return}D=j()|0,Bt(r)|0,le(D|0)}function xr(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0;if(k=b,b=b+16|0,D=k,r=f0(r)|0,e[D>>2]=r,g=0,h=be(37,D|0,44212)|0,N=g,g=0,!(N&1)&&(g=0,Pe(e[(e[h>>2]|0)+48>>2]|0,h|0,57498,57530,o|0)|0,N=g,g=0,!(N&1))&&(g=0,C=be(37,D|0,44368)|0,N=g,g=0,!(N&1))&&(g=0,d=ge(e[(e[C>>2]|0)+12>>2]|0,C|0)|0,N=g,g=0,!(N&1))&&(e[l>>2]=d,g=0,w=ge(e[(e[C>>2]|0)+16>>2]|0,C|0)|0,N=g,g=0,!(N&1))&&(e[c>>2]=w,g=0,Ae(e[(e[C>>2]|0)+20>>2]|0,t|0,C|0),N=g,g=0,!(N&1))){Bt(r)|0,b=k;return}N=j()|0,Bt(r)|0,le(N|0)}function wr(t,r,o,l,c,h,d,w,C,D,k,N){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0,k=k|0,N=N|0;var R=0,_=0;e:do if((t|0)==(h|0))S[r>>0]|0?(S[r>>0]=0,o=e[c>>2]|0,e[c>>2]=o+1,S[o>>0]=46,o=S[w>>0]|0,(o&1?e[w+4>>2]|0:(o&255)>>>1)|0&&(R=e[D>>2]|0,(R-C|0)<160)&&(C=e[k>>2]|0,e[D>>2]=R+4,e[R>>2]=C),R=0):R=-1;else{if((t|0)==(d|0)&&(d=S[w>>0]|0,((d&1?e[w+4>>2]|0:(d&255)>>>1)|0)!=0)){if(!(S[r>>0]|0)){R=-1;break}if(R=e[D>>2]|0,(R-C|0)>=160){R=0;break}C=e[k>>2]|0,e[D>>2]=R+4,e[R>>2]=C,e[k>>2]=0,R=0;break}for(h=N+128|0,R=N;(e[R>>2]|0)!=(t|0);)if(R=R+4|0,(R|0)==(h|0)){R=h;break}if(h=R-N|0,R=h>>2,(h|0)<=124){switch(d=S[57498+R>>0]|0,R|0){case 24:case 25:{if(R=e[c>>2]|0,(R|0)!=(l|0)&&(F[R+-1>>0]&95|0)!=(F[o>>0]&127|0)){R=-1;break e}e[c>>2]=R+1,S[R>>0]=d,R=0;break e}case 23:case 22:{S[o>>0]=80;break}default:R=d&95,(R|0)==(S[o>>0]|0)&&(S[o>>0]=R|128,(S[r>>0]|0)!=0)&&(S[r>>0]=0,o=S[w>>0]|0,((o&1?e[w+4>>2]|0:(o&255)>>>1)|0)!=0)&&(_=e[D>>2]|0,(_-C|0)<160)&&(C=e[k>>2]|0,e[D>>2]=_+4,e[_>>2]=C)}D=e[c>>2]|0,e[c>>2]=D+1,S[D>>0]=d,(h|0)>84||(e[k>>2]=(e[k>>2]|0)+1),R=0}else R=-1}while(!1);return R|0}function dg(t){t=t|0}function pg(t){t=t|0,he(t)}function mg(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0;k=b,b=b+32|0,h=k+20|0,d=k+16|0,w=k+12|0,D=k;e:do if(!(e[o+4>>2]&1))D=e[(e[t>>2]|0)+24>>2]|0,e[d>>2]=e[r>>2],e[h>>2]=e[d>>2],h=an[D&31](t,h,o,l,c&1)|0;else{h=f0(o)|0,e[w>>2]=h,g=0,d=be(37,w|0,44360)|0,C=g,g=0;t:do if(C&1)k=j()|0,Bt(h)|0,h=k;else{Bt(h)|0,h=e[d>>2]|0,c?t0[e[h+24>>2]&127](D,d):t0[e[h+28>>2]&127](D,d),t=S[D>>0]|0,C=(t&1)==0,h=D+1|0,c=D+8|0,w=C?h:D+1|0,h=C?h:e[D+8>>2]|0,C=D+4|0,o=(t&1)==0;i:do if((h|0)!=((o?w:e[c>>2]|0)+(o?(t&255)>>>1:e[C>>2]|0)|0)){n:for(;;){d=S[h>>0]|0,l=e[r>>2]|0;do if(l){if(o=l+24|0,t=e[o>>2]|0,(t|0)!=(e[l+28>>2]|0)){e[o>>2]=t+1,S[t>>0]=d;break}if(g=0,d=be(e[(e[l>>2]|0)+52>>2]|0,l|0,d&255|0)|0,t=g,g=0,t&1)break n;(d|0)==-1&&(e[r>>2]=0)}while(!1);if(h=h+1|0,t=S[D>>0]|0,o=(t&1)==0,(h|0)==((o?w:e[c>>2]|0)+(o?(t&255)>>>1:e[C>>2]|0)|0))break i}h=j()|0,de(D);break t}while(!1);h=e[r>>2]|0,de(D);break e}while(!1);le(h|0)}while(!1);return b=k,h|0}function gg(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(k=b,b=b+64|0,h=k,R=k+56|0,_=k+44|0,w=k+20|0,D=k+16|0,C=k+12|0,N=k+8|0,d=k+4|0,S[R>>0]=S[58887]|0,S[R+1>>0]=S[58888]|0,S[R+2>>0]=S[58889]|0,S[R+3>>0]=S[58890]|0,S[R+4>>0]=S[58891]|0,S[R+5>>0]=S[58892]|0,ki(R+1|0,58893,1,e[o+4>>2]|0),t=b0()|0,e[h>>2]=c,c=_+(q0(_,12,t,R,h)|0)|0,R=ri(_,c,o)|0,t=f0(o)|0,e[N>>2]=t,g=0,ht(1,_|0,R|0,c|0,w|0,D|0,C|0,N|0),c=g,g=0,c&1)_=j()|0,Bt(t)|0,le(_|0);else return Bt(t)|0,e[d>>2]=e[r>>2],R=e[D>>2]|0,_=e[C>>2]|0,e[h>>2]=e[d>>2],_=Ui(h,w,R,_,o,l)|0,b=k,_|0;return 0}function ki(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;if(l&2048&&(S[t>>0]=43,t=t+1|0),l&512&&(S[t>>0]=35,t=t+1|0),c=S[r>>0]|0,c<<24>>24)for(h=r;;)if(h=h+1|0,r=t+1|0,S[t>>0]=c,c=S[h>>0]|0,c<<24>>24)t=r;else{t=r;break}e:do switch(l&74|0){case 64:{S[t>>0]=111;break}case 8:if(l&16384){S[t>>0]=88;break e}else{S[t>>0]=120;break e}default:if(o){S[t>>0]=100;break e}else{S[t>>0]=117;break e}}while(!1)}function ri(t,r,o){t=t|0,r=r|0,o=o|0;var l=0;e:do switch(e[o+4>>2]&176|0){case 16:{switch(o=S[t>>0]|0,o<<24>>24){case 43:case 45:{t=t+1|0;break e}default:}if((r-t|0)>1&o<<24>>24==48){switch(S[t+1>>0]|0){case 88:case 120:break;default:{l=7;break e}}t=t+2|0}else l=7;break}case 32:{t=r;break}default:l=7}while(!1);return t|0}function Sg(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0;G=b,b=b+16|0,$=G,Q=O0(d,44220)|0,D=O0(d,44360)|0,t0[e[(e[D>>2]|0)+20>>2]&127]($,D),_=S[$>>0]|0,U=$+4|0;e:do if(!((_&1?e[U>>2]|0:(_&255)>>>1)|0))g=0,Pe(e[(e[Q>>2]|0)+32>>2]|0,Q|0,t|0,o|0,l|0)|0,K=g,g=0,K&1?K=5:(d=l+(o-t)|0,e[h>>2]=d,K=29);else{switch(e[h>>2]=l,d=S[t>>0]|0,d<<24>>24){case 43:case 45:{if(g=0,d=be(e[(e[Q>>2]|0)+28>>2]|0,Q|0,d|0)|0,_=g,g=0,_&1){K=5;break e}C=e[h>>2]|0,e[h>>2]=C+1,S[C>>0]=d,C=t+1|0;break}default:C=t}t:do if((o-C|0)>1&&(S[C>>0]|0)==48){switch(d=C+1|0,S[d>>0]|0){case 88:case 120:break;default:break t}if(g=0,w=be(e[(e[Q>>2]|0)+28>>2]|0,Q|0,48)|0,_=g,g=0,_&1){K=5;break e}if(_=e[h>>2]|0,e[h>>2]=_+1,S[_>>0]=w,g=0,d=be(e[(e[Q>>2]|0)+28>>2]|0,Q|0,S[d>>0]|0)|0,_=g,g=0,_&1){K=5;break e}_=e[h>>2]|0,e[h>>2]=_+1,S[_>>0]=d,C=C+2|0}while(!1);if((C|0)!=(o|0)&&(k=o+-1|0,C>>>0>>0)){w=C,d=k;do _=S[w>>0]|0,S[w>>0]=S[d>>0]|0,S[d>>0]=_,w=w+1|0,d=d+-1|0;while(w>>>0>>0)}if(g=0,k=ge(e[(e[D>>2]|0)+16>>2]|0,D|0)|0,_=g,g=0,_&1)K=5;else{N=$+8|0,R=$+1|0;t:do if(C>>>0>>0){for(d=0,w=0,_=C;D=S[(S[$>>0]&1?e[N>>2]|0:R)+w>>0]|0,D<<24>>24!=0&(d|0)==(D<<24>>24|0)?(d=e[h>>2]|0,e[h>>2]=d+1,S[d>>0]=k,d=S[$>>0]|0,D=0,w=(w>>>0<((d&1?e[U>>2]|0:(d&255)>>>1)+-1|0)>>>0&1)+w|0):D=d,g=0,d=be(e[(e[Q>>2]|0)+28>>2]|0,Q|0,S[_>>0]|0)|0,P=g,g=0,!(P&1);){if(P=e[h>>2]|0,e[h>>2]=P+1,S[P>>0]=d,_=_+1|0,_>>>0>=o>>>0)break t;d=D+1|0}d=j()|0;break e}while(!1);if(w=t,d=l+(C-w)|0,t=e[h>>2]|0,(d|0)==(t|0))t=w,K=29;else{if(t=t+-1|0,d>>>0>>0)do P=S[d>>0]|0,S[d>>0]=S[t>>0]|0,S[t>>0]=P,d=d+1|0,t=t+-1|0;while(d>>>0>>0);t=w,d=e[h>>2]|0,K=29}}}while(!1);if((K|0)==5)d=j()|0;else if((K|0)==29){e[c>>2]=(r|0)==(o|0)?d:l+(r-t)|0,de($),b=G;return}de($),le(d|0)}function Ag(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;if(N=b,b=b+96|0,d=N+8|0,t=N,_=N+74|0,C=N+32|0,k=N+28|0,D=N+24|0,R=N+20|0,w=N+16|0,U=t,e[U>>2]=37,e[U+4>>2]=0,ki(t+1|0,58895,1,e[o+4>>2]|0),U=b0()|0,Q=d,e[Q>>2]=c,e[Q+4>>2]=h,h=_+(q0(_,22,U,t,d)|0)|0,c=ri(_,h,o)|0,t=f0(o)|0,e[R>>2]=t,g=0,ht(1,_|0,c|0,h|0,C|0,k|0,D|0,R|0),h=g,g=0,h&1)Q=j()|0,Bt(t)|0,le(Q|0);else return Bt(t)|0,e[w>>2]=e[r>>2],U=e[k>>2]|0,Q=e[D>>2]|0,e[d>>2]=e[w>>2],Q=Ui(d,C,U,Q,o,l)|0,b=N,Q|0;return 0}function vg(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(k=b,b=b+64|0,h=k,R=k+56|0,_=k+44|0,w=k+20|0,D=k+16|0,C=k+12|0,N=k+8|0,d=k+4|0,S[R>>0]=S[58887]|0,S[R+1>>0]=S[58888]|0,S[R+2>>0]=S[58889]|0,S[R+3>>0]=S[58890]|0,S[R+4>>0]=S[58891]|0,S[R+5>>0]=S[58892]|0,ki(R+1|0,58893,0,e[o+4>>2]|0),t=b0()|0,e[h>>2]=c,c=_+(q0(_,12,t,R,h)|0)|0,R=ri(_,c,o)|0,t=f0(o)|0,e[N>>2]=t,g=0,ht(1,_|0,R|0,c|0,w|0,D|0,C|0,N|0),c=g,g=0,c&1)_=j()|0,Bt(t)|0,le(_|0);else return Bt(t)|0,e[d>>2]=e[r>>2],R=e[D>>2]|0,_=e[C>>2]|0,e[h>>2]=e[d>>2],_=Ui(h,w,R,_,o,l)|0,b=k,_|0;return 0}function xg(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;if(N=b,b=b+112|0,d=N+8|0,t=N,_=N+75|0,C=N+32|0,k=N+28|0,D=N+24|0,R=N+20|0,w=N+16|0,U=t,e[U>>2]=37,e[U+4>>2]=0,ki(t+1|0,58895,0,e[o+4>>2]|0),U=b0()|0,Q=d,e[Q>>2]=c,e[Q+4>>2]=h,h=_+(q0(_,23,U,t,d)|0)|0,c=ri(_,h,o)|0,t=f0(o)|0,e[R>>2]=t,g=0,ht(1,_|0,c|0,h|0,C|0,k|0,D|0,R|0),h=g,g=0,h&1)Q=j()|0,Bt(t)|0,le(Q|0);else return Bt(t)|0,e[w>>2]=e[r>>2],U=e[k>>2]|0,Q=e[D>>2]|0,e[d>>2]=e[w>>2],Q=Ui(d,C,U,Q,o,l)|0,b=N,Q|0;return 0}function wg(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=+c;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0;Z=b,b=b+176|0,K=Z+84|0,R=Z+48|0,N=Z+32|0,C=Z+24|0,h=Z+8|0,k=Z,U=Z+88|0,Q=Z+80|0,w=Z+118|0,O=Z+76|0,P=Z+72|0,G=Z+68|0,$=Z+64|0,D=k,e[D>>2]=37,e[D+4>>2]=0,D=gn(k+1|0,58898,e[o+4>>2]|0)|0,e[Q>>2]=U,t=b0()|0,D?(e[h>>2]=e[o+8>>2],B[h+8>>3]=c,h=q0(U,30,t,k,h)|0):(B[C>>3]=c,h=q0(U,30,t,k,C)|0);e:do if((h|0)>29){g=0,t=Ce(3)|0,h=g,g=0,h=h&1,D?!h&&(g=0,e[N>>2]=e[o+8>>2],B[N+8>>3]=c,d=Pe(17,Q|0,t|0,k|0,N|0)|0,_=g,g=0,!(_&1))&&(ie=12):!h&&(g=0,e[R>>2]=e[o+8>>2],B[R+8>>3]=c,_=Pe(17,Q|0,t|0,k|0,R|0)|0,R=g,g=0,!(R&1))&&(d=_,ie=12);do if((ie|0)==12){if(t=e[Q>>2]|0,t)h=t;else{if(g=0,Nt(6),_=g,g=0,_&1)break;h=e[Q>>2]|0}t=h,k=h,ie=16;break e}while(!1);t=j()|0}else t=e[Q>>2]|0,k=0,d=h,ie=16;while(!1);if((ie|0)==16){C=t+d|0,D=ri(t,C,o)|0;do if((t|0)==(U|0))t=U,h=0,ie=22;else{if(d=E0(d<<1)|0,!d){if(g=0,Nt(6),ie=g,g=0,ie&1){h=0,ie=20;break}t=e[Q>>2]|0}h=d,w=d,ie=22}while(!1);do if((ie|0)==22)if(g=0,d=ge(68,o|0)|0,Q=g,g=0,Q&1)ie=20;else{if(e[G>>2]=d,g=0,ht(2,t|0,D|0,C|0,w|0,O|0,P|0,G|0),G=g,g=0,G&1){t=j()|0,Bt(d)|0;break}if(Bt(d)|0,e[$>>2]=e[r>>2],ie=e[O>>2]|0,t=e[P>>2]|0,g=0,e[K>>2]=e[$>>2],t=Vt(39,K|0,w|0,ie|0,t|0,o|0,l|0)|0,ie=g,g=0,ie&1)ie=20;else return e[r>>2]=t,h&&n0(h),k&&n0(k),b=Z,t|0}while(!1);(ie|0)==20&&(t=j()|0),h&&n0(h),k&&n0(k)}return le(t|0),0}function gn(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0;if(o&2048&&(S[t>>0]=43,t=t+1|0),o&1024&&(S[t>>0]=35,t=t+1|0),d=o&260,c=o>>>14,w=(d|0)==260,w?h=0:(S[t>>0]=46,S[t+1>>0]=42,t=t+2|0,h=1),o=S[r>>0]|0,o<<24>>24)for(l=t;r=r+1|0,t=l+1|0,S[l>>0]=o,o=S[r>>0]|0,o<<24>>24;)l=t;e:do switch(d|0){case 4:if(c&1){S[t>>0]=70;break e}else{S[t>>0]=102;break e}case 256:if(c&1){S[t>>0]=69;break e}else{S[t>>0]=101;break e}default:if(o=(c&1|0)!=0,w)if(o){S[t>>0]=65;break e}else{S[t>>0]=97;break e}else if(o){S[t>>0]=71;break e}else{S[t>>0]=103;break e}}while(!1);return h|0}function yg(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0;switch(Z=b,b=b+16|0,ie=Z,O=O0(d,44220)|0,$=O0(d,44360)|0,t0[e[(e[$>>2]|0)+20>>2]&127](ie,$),e[h>>2]=l,d=S[t>>0]|0,d<<24>>24){case 43:case 45:{g=0,d=be(e[(e[O>>2]|0)+28>>2]|0,O|0,d|0)|0,P=g,g=0,P&1?G=8:(k=e[h>>2]|0,e[h>>2]=k+1,S[k>>0]=d,k=t+1|0,G=10);break}default:k=t,G=10}e:do if((G|0)==10){P=o;t:do if((P-k|0)>1&&(S[k>>0]|0)==48){switch(C=k+1|0,S[C>>0]|0){case 88:case 120:break;default:{G=11;break t}}if(g=0,d=be(e[(e[O>>2]|0)+28>>2]|0,O|0,48)|0,K=g,g=0,K&1){G=8;break e}if(K=e[h>>2]|0,e[h>>2]=K+1,S[K>>0]=d,k=k+2|0,g=0,d=be(e[(e[O>>2]|0)+28>>2]|0,O|0,S[C>>0]|0)|0,K=g,g=0,K&1){G=8;break e}if(K=e[h>>2]|0,e[h>>2]=K+1,S[K>>0]=d,k>>>0>>0){for(d=k;C=S[d>>0]|0,g=0,D=Ce(3)|0,K=g,g=0,!(K&1||(g=0,C=be(39,C<<24>>24|0,D|0)|0,K=g,g=0,K&1));){if(!C){K=k;break t}if(d=d+1|0,d>>>0>=o>>>0){K=k;break t}}d=j()|0;break e}else K=k,d=k}else G=11;while(!1);t:do if((G|0)==11)if(k>>>0>>0){for(d=k;C=S[d>>0]|0,g=0,D=Ce(3)|0,K=g,g=0,!(K&1||(g=0,C=be(40,C<<24>>24|0,D|0)|0,K=g,g=0,K&1));){if(!C){K=k;break t}if(d=d+1|0,d>>>0>=o>>>0){K=k;break t}}d=j()|0;break e}else K=k,d=k;while(!1);if(U=S[ie>>0]|0,Q=ie+4|0,(U&1?e[Q>>2]|0:(U&255)>>>1)|0){if((K|0)!=(d|0)&&(N=d+-1|0,K>>>0>>0)){D=K,C=N;do U=S[D>>0]|0,S[D>>0]=S[C>>0]|0,S[C>>0]=U,D=D+1|0,C=C+-1|0;while(D>>>0>>0)}if(g=0,N=ge(e[(e[$>>2]|0)+16>>2]|0,$|0)|0,U=g,g=0,U&1){G=8;break}R=ie+8|0,_=ie+1|0;t:do if(K>>>0>>0){for(C=0,D=0,U=K;k=S[(S[ie>>0]&1?e[R>>2]|0:_)+D>>0]|0,k<<24>>24>0&(C|0)==(k<<24>>24|0)?(C=e[h>>2]|0,e[h>>2]=C+1,S[C>>0]=N,C=S[ie>>0]|0,k=0,D=(D>>>0<((C&1?e[Q>>2]|0:(C&255)>>>1)+-1|0)>>>0&1)+D|0):k=C,g=0,C=be(e[(e[O>>2]|0)+28>>2]|0,O|0,S[U>>0]|0)|0,oe=g,g=0,!(oe&1);){if(oe=e[h>>2]|0,e[h>>2]=oe+1,S[oe>>0]=C,U=U+1|0,U>>>0>=d>>>0)break t;C=k+1|0}d=j()|0;break e}while(!1);if(C=l+(K-t)|0,D=e[h>>2]|0,(C|0)!=(D|0)&&(w=D+-1|0,C>>>0>>0)){do oe=S[C>>0]|0,S[C>>0]=S[w>>0]|0,S[w>>0]=oe,C=C+1|0,w=w+-1|0;while(C>>>0>>0);C=O}else C=O}else{if(g=0,Pe(e[(e[O>>2]|0)+32>>2]|0,O|0,K|0,d|0,e[h>>2]|0)|0,oe=g,g=0,oe&1){G=8;break}e[h>>2]=(e[h>>2]|0)+(d-K),C=O}t:do if(d>>>0>>0){for(;w=S[d>>0]|0,w<<24>>24!=46;){if(g=0,w=be(e[(e[C>>2]|0)+28>>2]|0,O|0,w|0)|0,oe=g,g=0,oe&1){G=4;break}if(oe=e[h>>2]|0,e[h>>2]=oe+1,S[oe>>0]=w,d=d+1|0,d>>>0>=o>>>0)break t}if((G|0)==4){d=j()|0;break e}if(g=0,w=ge(e[(e[$>>2]|0)+12>>2]|0,$|0)|0,oe=g,g=0,oe&1){G=8;break e}oe=e[h>>2]|0,e[h>>2]=oe+1,S[oe>>0]=w,d=d+1|0}while(!1);if(g=0,Pe(e[(e[O>>2]|0)+32>>2]|0,O|0,d|0,o|0,e[h>>2]|0)|0,oe=g,g=0,oe&1)G=8;else{oe=(e[h>>2]|0)+(P-d)|0,e[h>>2]=oe,e[c>>2]=(r|0)==(o|0)?oe:l+(r-t)|0,de(ie),b=Z;return}}while(!1);(G|0)==8&&(d=j()|0),de(ie),le(d|0)}function Cg(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=+c;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0;Z=b,b=b+176|0,K=Z+76|0,R=Z+48|0,N=Z+32|0,C=Z+24|0,h=Z+8|0,k=Z,U=Z+80|0,Q=Z+72|0,w=Z+110|0,O=Z+68|0,P=Z+64|0,G=Z+60|0,$=Z+56|0,D=k,e[D>>2]=37,e[D+4>>2]=0,D=gn(k+1|0,58899,e[o+4>>2]|0)|0,e[Q>>2]=U,t=b0()|0,D?(e[h>>2]=e[o+8>>2],B[h+8>>3]=c,h=q0(U,30,t,k,h)|0):(B[C>>3]=c,h=q0(U,30,t,k,C)|0);e:do if((h|0)>29){g=0,t=Ce(3)|0,h=g,g=0,h=h&1,D?!h&&(g=0,e[N>>2]=e[o+8>>2],B[N+8>>3]=c,d=Pe(17,Q|0,t|0,k|0,N|0)|0,_=g,g=0,!(_&1))&&(ie=12):!h&&(g=0,B[R>>3]=c,_=Pe(17,Q|0,t|0,k|0,R|0)|0,R=g,g=0,!(R&1))&&(d=_,ie=12);do if((ie|0)==12){if(t=e[Q>>2]|0,t)h=t;else{if(g=0,Nt(6),_=g,g=0,_&1)break;h=e[Q>>2]|0}t=h,k=h,ie=16;break e}while(!1);t=j()|0}else t=e[Q>>2]|0,k=0,d=h,ie=16;while(!1);if((ie|0)==16){C=t+d|0,D=ri(t,C,o)|0;do if((t|0)==(U|0))t=U,h=0,ie=22;else{if(d=E0(d<<1)|0,!d){if(g=0,Nt(6),ie=g,g=0,ie&1){h=0,ie=20;break}t=e[Q>>2]|0}h=d,w=d,ie=22}while(!1);do if((ie|0)==22)if(g=0,d=ge(68,o|0)|0,Q=g,g=0,Q&1)ie=20;else{if(e[G>>2]=d,g=0,ht(2,t|0,D|0,C|0,w|0,O|0,P|0,G|0),G=g,g=0,G&1){t=j()|0,Bt(d)|0;break}if(Bt(d)|0,e[$>>2]=e[r>>2],ie=e[O>>2]|0,t=e[P>>2]|0,g=0,e[K>>2]=e[$>>2],t=Vt(39,K|0,w|0,ie|0,t|0,o|0,l|0)|0,ie=g,g=0,ie&1)ie=20;else return e[r>>2]=t,h&&n0(h),k&&n0(k),b=Z,t|0}while(!1);(ie|0)==20&&(t=j()|0),h&&n0(h),k&&n0(k)}return le(t|0),0}function Tg(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(R=b,b=b+80|0,C=R,t=R+70|0,k=R+12|0,N=R+32|0,w=R+8|0,D=R+4|0,S[t>>0]=S[58901]|0,S[t+1>>0]=S[58902]|0,S[t+2>>0]=S[58903]|0,S[t+3>>0]=S[58904]|0,S[t+4>>0]=S[58905]|0,S[t+5>>0]=S[58906]|0,h=b0()|0,e[C>>2]=c,t=q0(k,20,h,t,C)|0,c=k+t|0,h=ri(k,c,o)|0,d=f0(o)|0,e[w>>2]=d,g=0,w=be(37,w|0,44220)|0,_=g,g=0,_&1)_=j()|0,Bt(d)|0,le(_|0);else return Bt(d)|0,_r[e[(e[w>>2]|0)+32>>2]&31](w,k,c,N)|0,_=N+t|0,e[D>>2]=e[r>>2],e[C>>2]=e[D>>2],_=Ui(C,N,(h|0)==(c|0)?_:N+(h-k)|0,_,o,l)|0,b=R,_|0;return 0}function Ig(t){t=t|0}function Eg(t){t=t|0,he(t)}function kg(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0;D=b,b=b+32|0,h=D+20|0,d=D+16|0,w=D+12|0,C=D;e:do if(!(e[o+4>>2]&1))C=e[(e[t>>2]|0)+24>>2]|0,e[d>>2]=e[r>>2],e[h>>2]=e[d>>2],h=an[C&31](t,h,o,l,c&1)|0;else{h=f0(o)|0,e[w>>2]=h,g=0,d=be(37,w|0,44368)|0,w=g,g=0;t:do if(w&1)D=j()|0,Bt(h)|0,h=D;else{Bt(h)|0,h=e[d>>2]|0,c?t0[e[h+24>>2]&127](C,d):t0[e[h+28>>2]&127](C,d),t=S[C>>0]|0,o=(t&1)==0,h=C+4|0,c=C+8|0,w=o?h:C+4|0,h=o?h:e[C+8>>2]|0,o=(t&1)==0;i:do if((h|0)!=((o?w:e[c>>2]|0)+((o?(t&255)>>>1:e[w>>2]|0)<<2)|0)){for(;;){if(d=e[h>>2]|0,l=e[r>>2]|0,l){if(o=l+24|0,t=e[o>>2]|0,(t|0)==(e[l+28>>2]|0)){if(g=0,d=be(e[(e[l>>2]|0)+52>>2]|0,l|0,d|0)|0,t=g,g=0,t&1)break}else e[o>>2]=t+4,e[t>>2]=d;(d|0)==-1&&(e[r>>2]=0)}if(h=h+4|0,t=S[C>>0]|0,o=(t&1)==0,(h|0)==((o?w:e[c>>2]|0)+((o?(t&255)>>>1:e[w>>2]|0)<<2)|0))break i}h=j()|0,Pt(C);break t}while(!1);h=e[r>>2]|0,Pt(C);break e}while(!1);le(h|0)}while(!1);return b=D,h|0}function Dg(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if(k=b,b=b+128|0,h=k,R=k+116|0,_=k+104|0,w=k+20|0,D=k+16|0,C=k+12|0,N=k+8|0,d=k+4|0,S[R>>0]=S[58887]|0,S[R+1>>0]=S[58888]|0,S[R+2>>0]=S[58889]|0,S[R+3>>0]=S[58890]|0,S[R+4>>0]=S[58891]|0,S[R+5>>0]=S[58892]|0,ki(R+1|0,58893,1,e[o+4>>2]|0),t=b0()|0,e[h>>2]=c,c=_+(q0(_,12,t,R,h)|0)|0,R=ri(_,c,o)|0,t=f0(o)|0,e[N>>2]=t,g=0,ht(3,_|0,R|0,c|0,w|0,D|0,C|0,N|0),c=g,g=0,c&1)_=j()|0,Bt(t)|0,le(_|0);else return Bt(t)|0,e[d>>2]=e[r>>2],R=e[D>>2]|0,_=e[C>>2]|0,e[h>>2]=e[d>>2],_=Hi(h,w,R,_,o,l)|0,b=k,_|0;return 0}function bg(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0;G=b,b=b+16|0,$=G,Q=O0(d,44212)|0,D=O0(d,44368)|0,t0[e[(e[D>>2]|0)+20>>2]&127]($,D),_=S[$>>0]|0,U=$+4|0;e:do if(!((_&1?e[U>>2]|0:(_&255)>>>1)|0))g=0,Pe(e[(e[Q>>2]|0)+48>>2]|0,Q|0,t|0,o|0,l|0)|0,K=g,g=0,K&1?K=5:(d=l+(o-t<<2)|0,e[h>>2]=d,K=28);else{switch(e[h>>2]=l,d=S[t>>0]|0,d<<24>>24){case 43:case 45:{if(g=0,d=be(e[(e[Q>>2]|0)+44>>2]|0,Q|0,d|0)|0,_=g,g=0,_&1){K=5;break e}C=e[h>>2]|0,e[h>>2]=C+4,e[C>>2]=d,C=t+1|0;break}default:C=t}t:do if((o-C|0)>1&&(S[C>>0]|0)==48){switch(d=C+1|0,S[d>>0]|0){case 88:case 120:break;default:{_=C;break t}}if(g=0,w=be(e[(e[Q>>2]|0)+44>>2]|0,Q|0,48)|0,_=g,g=0,_&1){K=5;break e}if(_=e[h>>2]|0,e[h>>2]=_+4,e[_>>2]=w,g=0,d=be(e[(e[Q>>2]|0)+44>>2]|0,Q|0,S[d>>0]|0)|0,_=g,g=0,_&1){K=5;break e}_=e[h>>2]|0,e[h>>2]=_+4,e[_>>2]=d,_=C+2|0}else _=C;while(!1);if((_|0)!=(o|0)&&(k=o+-1|0,_>>>0>>0)){w=_,d=k;do R=S[w>>0]|0,S[w>>0]=S[d>>0]|0,S[d>>0]=R,w=w+1|0,d=d+-1|0;while(w>>>0>>0)}if(g=0,D=ge(e[(e[D>>2]|0)+16>>2]|0,D|0)|0,R=g,g=0,R&1)K=5;else{k=$+8|0,N=$+1|0;t:do if(_>>>0>>0){for(d=0,w=0,R=_;C=S[(S[$>>0]&1?e[k>>2]|0:N)+w>>0]|0,C<<24>>24!=0&(d|0)==(C<<24>>24|0)?(d=e[h>>2]|0,e[h>>2]=d+4,e[d>>2]=D,d=S[$>>0]|0,C=0,w=(w>>>0<((d&1?e[U>>2]|0:(d&255)>>>1)+-1|0)>>>0&1)+w|0):C=d,g=0,d=be(e[(e[Q>>2]|0)+44>>2]|0,Q|0,S[R>>0]|0)|0,P=g,g=0,!(P&1);){if(P=e[h>>2]|0,e[h>>2]=P+4,e[P>>2]=d,R=R+1|0,R>>>0>=o>>>0)break t;d=C+1|0}d=j()|0;break e}while(!1);if(C=t,d=l+(_-C<<2)|0,w=e[h>>2]|0,(d|0)!=(w|0))if(t=w+-4|0,d>>>0>>0){do P=e[d>>2]|0,e[d>>2]=e[t>>2],e[t>>2]=P,d=d+4|0,t=t+-4|0;while(d>>>0>>0);t=C,d=w,K=28}else t=C,d=w,K=28;else t=C,K=28}}while(!1);if((K|0)==5)d=j()|0;else if((K|0)==28){e[c>>2]=(r|0)==(o|0)?d:l+(r-t<<2)|0,de($),b=G;return}de($),le(d|0)}function Ng(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;if(N=b,b=b+224|0,d=N+8|0,t=N,_=N+196|0,C=N+32|0,k=N+28|0,D=N+24|0,R=N+20|0,w=N+16|0,U=t,e[U>>2]=37,e[U+4>>2]=0,ki(t+1|0,58895,1,e[o+4>>2]|0),U=b0()|0,Q=d,e[Q>>2]=c,e[Q+4>>2]=h,h=_+(q0(_,22,U,t,d)|0)|0,c=ri(_,h,o)|0,t=f0(o)|0,e[R>>2]=t,g=0,ht(3,_|0,c|0,h|0,C|0,k|0,D|0,R|0),h=g,g=0,h&1)Q=j()|0,Bt(t)|0,le(Q|0);else return Bt(t)|0,e[w>>2]=e[r>>2],U=e[k>>2]|0,Q=e[D>>2]|0,e[d>>2]=e[w>>2],Q=Hi(d,C,U,Q,o,l)|0,b=N,Q|0;return 0}function Fg(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0;K=b,b=b+16|0,U=K,R=K+8|0;e:do if((o|0)==(l|0))C=l;else for(C=o;;){if(!(e[C>>2]|0))break e;if(C=C+4|0,(C|0)==(l|0)){C=l;break}}while(!1);e[w>>2]=h,e[c>>2]=o,k=d,_=t+8|0;e:do if((h|0)==(d|0)|(o|0)==(l|0))G=47;else{t=h,D=C;t:for(;;){if($=r,h=e[$+4>>2]|0,C=U,e[C>>2]=e[$>>2],e[C+4>>2]=h,C=ai(e[_>>2]|0)|0,g=0,h=se(21,t|0,c|0,D-o>>2|0,k-t|0,r|0)|0,$=g,g=0,$&1){G=9;break}if(C|0&&(g=0,ge(75,C|0)|0,$=g,g=0,$&1)){G=8;break}switch(h|0){case 0:{N=1;break e}case-1:{C=t,G=14;break t}default:}if(C=(e[w>>2]|0)+h|0,e[w>>2]=C,(C|0)==(d|0)){G=27;break}if((D|0)==(l|0))o=e[c>>2]|0,t=C,C=l;else{if(C=ai(e[_>>2]|0)|0,g=0,o=Ve(34,R|0,0,r|0)|0,$=g,g=0,$&1){G=35;break}if(C|0&&(g=0,ge(75,C|0)|0,$=g,g=0,$&1)){G=34;break}if((o|0)==-1){N=2;break e}if(o>>>0>(k-(e[w>>2]|0)|0)>>>0){N=1;break e}if(o)for(C=R;D=S[C>>0]|0,$=e[w>>2]|0,e[w>>2]=$+1,S[$>>0]=D,o=o+-1|0,o;)C=C+1|0;o=(e[c>>2]|0)+4|0,e[c>>2]=o;i:do if((o|0)==(l|0))C=l;else for(C=o;;){if(!(e[C>>2]|0))break i;if(C=C+4|0,(C|0)==(l|0)){C=l;break}}while(!1);t=e[w>>2]|0}if((t|0)==(d|0)|(o|0)==(l|0)){G=47;break e}else D=C}if((G|0)==8)$=j(0)|0,$t($);else if((G|0)==9)o=j()|0,C|0&&(g=0,ge(75,C|0)|0,$=g,g=0,$&1)&&($=j(0)|0,$t($)),le(o|0);else if((G|0)==14){e[w>>2]=C;t:do if((o|0)!=(e[c>>2]|0)){for(;;){if($=e[o>>2]|0,t=ai(e[_>>2]|0)|0,g=0,C=Ve(34,C|0,$|0,U|0)|0,$=g,g=0,$&1){Q=t;break}if(t|0&&(g=0,ge(75,t|0)|0,$=g,g=0,$&1)){G=18;break}if((C|0)==-1||(C=(e[w>>2]|0)+C|0,e[w>>2]=C,o=o+4|0,(o|0)==(e[c>>2]|0)))break t}(G|0)==18&&($=j(0)|0,$t($)),o=j()|0,Q|0&&(g=0,ge(75,Q|0)|0,$=g,g=0,$&1)&&($=j(0)|0,$t($)),le(o|0)}while(!1);e[c>>2]=o,N=2;break}else if((G|0)==27){o=e[c>>2]|0,G=47;break}else(G|0)==34?($=j(0)|0,$t($)):(G|0)==35&&(o=j()|0,C|0&&(g=0,ge(75,C|0)|0,$=g,g=0,$&1)&&($=j(0)|0,$t($)),le(o|0))}while(!1);return(G|0)==47&&(N=(o|0)!=(l|0)&1),b=K,N|0}function Rg(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0;K=b,b=b+16|0,Q=K;e:do if((o|0)==(l|0))C=l;else for(C=o;;){if(!(S[C>>0]|0))break e;if(C=C+1|0,(C|0)==(l|0)){C=l;break}}while(!1);e[w>>2]=h,e[c>>2]=o,N=d,_=t+8|0;e:do if((h|0)==(d|0)|(o|0)==(l|0))G=47;else{t=h,k=C;t:for(;;){if(D=r,C=e[D+4>>2]|0,h=Q,e[h>>2]=e[D>>2],e[h+4>>2]=C,h=k,C=ai(e[_>>2]|0)|0,g=0,D=se(22,t|0,c|0,h-o|0,N-t>>2|0,r|0)|0,$=g,g=0,$&1){G=9;break}if(C|0&&(g=0,ge(75,C|0)|0,$=g,g=0,$&1)){G=8;break}switch(D|0){case 0:{R=2;break e}case-1:{C=t,G=14;break t}default:}if(t=(e[w>>2]|0)+(D<<2)|0,e[w>>2]=t,(t|0)==(d|0)){G=31;break}if(o=e[c>>2]|0,(k|0)==(l|0))C=l;else{if(C=ai(e[_>>2]|0)|0,g=0,o=Pe(20,t|0,o|0,1,r|0)|0,$=g,g=0,$&1){G=38;break}if(C|0&&(g=0,ge(75,C|0)|0,$=g,g=0,$&1)){G=37;break}if(o){R=2;break e}e[w>>2]=(e[w>>2]|0)+4,o=(e[c>>2]|0)+1|0,e[c>>2]=o;i:do if((o|0)==(l|0))C=l;else for(C=o;;){if(!(S[C>>0]|0))break i;if(C=C+1|0,(C|0)==(l|0)){C=l;break}}while(!1);t=e[w>>2]|0}if((t|0)==(d|0)|(o|0)==(l|0)){G=47;break e}else k=C}if((G|0)==8)$=j(0)|0,$t($);else if((G|0)==9)o=j()|0,C|0&&(g=0,ge(75,C|0)|0,$=g,g=0,$&1)&&($=j(0)|0,$t($)),le(o|0);else if((G|0)==14){e[w>>2]=C;t:do if((o|0)!=(e[c>>2]|0)){t=C;i:for(;;){if(C=ai(e[_>>2]|0)|0,g=0,t=Pe(20,t|0,o|0,h-o|0,Q|0)|0,$=g,g=0,$&1){G=19;break}if(C|0&&(g=0,ge(75,C|0)|0,$=g,g=0,$&1)){G=18;break}switch(t|0){case-1:{G=25;break i}case-2:{G=26;break i}case 0:{o=o+1|0;break}default:o=o+t|0}if(t=(e[w>>2]|0)+4|0,e[w>>2]=t,(o|0)==(e[c>>2]|0)){U=o;break t}}if((G|0)==18)$=j(0)|0,$t($);else if((G|0)==19)o=j()|0,C|0&&(g=0,ge(75,C|0)|0,$=g,g=0,$&1)&&($=j(0)|0,$t($)),le(o|0);else if((G|0)==25){e[c>>2]=o,R=2;break e}else if((G|0)==26){e[c>>2]=o,R=1;break e}}else U=o;while(!1);e[c>>2]=U,R=(U|0)!=(l|0)&1;break}else if((G|0)==31){o=e[c>>2]|0,G=47;break}else(G|0)==37?($=j(0)|0,$t($)):(G|0)==38&&(o=j()|0,C|0&&(g=0,ge(75,C|0)|0,$=g,g=0,$&1)&&($=j(0)|0,$t($)),le(o|0))}while(!1);return(G|0)==47&&(R=(o|0)!=(l|0)&1),b=K,R|0}function Mg(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;switch(d=b,b=b+16|0,h=d,e[c>>2]=o,o=ai(e[t+8>>2]|0)|0,g=0,t=Ve(34,h|0,0,r|0)|0,r=g,g=0,r&1&&(h=j()|0,o|0&&(g=0,ge(75,o|0)|0,d=g,g=0,d&1)&&(d=j(0)|0,$t(d)),le(h|0)),o|0&&(g=0,ge(75,o|0)|0,r=g,g=0,r&1)&&(r=j(0)|0,$t(r)),t|0){case 0:case-1:{h=2;break}default:if(t=t+-1|0,t>>>0<=(l-(e[c>>2]|0)|0)>>>0)if(!t)h=0;else for(;;)if(r=S[h>>0]|0,l=e[c>>2]|0,e[c>>2]=l+1,S[l>>0]=r,t=t+-1|0,t)h=h+1|0;else{h=0;break}else h=1}return b=d,h|0}function _g(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0;r=t+8|0,g=0,o=ge(75,e[r>>2]|0)|0,l=g,g=0;do if(l&1)c=16;else{if(g=0,l=Ve(35,0,0,4)|0,t=g,g=0,t&1){if(t=j(0)|0,!o||(g=0,ge(75,o|0)|0,d=g,g=0,!(d&1)))break;d=j(0)|0,$t(d)}if(o|0&&(g=0,ge(75,o|0)|0,d=g,g=0,d&1)&&(d=j(0)|0,$t(d)),l)h=-1;else if(t=e[r>>2]|0,t){if(g=0,t=ge(75,t|0)|0,d=g,g=0,d&1){c=16;break}t|0&&(g=0,ge(75,t|0)|0,d=g,g=0,d&1)?(d=j(0)|0,$t(d)):h=0}else h=1;return h|0}while(!1);return(c|0)==16&&(t=j(0)|0),$t(t),0}function Pg(t){return t=t|0,0}function Lg(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;D=l,C=t+8|0;e:do if((o|0)==(l|0)|(c|0)==0)t=0;else{for(t=0,w=0;;){if(d=ai(e[C>>2]|0)|0,g=0,h=Ve(36,o|0,D-o|0,r|0)|0,R=g,g=0,R&1){N=d;break}if(d|0&&(g=0,ge(75,d|0)|0,R=g,g=0,R&1)){k=5;break}switch(h|0){case-2:case-1:break e;case 0:{o=o+1|0,h=1;break}default:o=o+h|0}if(t=h+t|0,w=w+1|0,(o|0)==(l|0)|w>>>0>=c>>>0)break e}(k|0)==5&&(R=j(0)|0,$t(R)),t=j()|0,N|0&&(g=0,ge(75,N|0)|0,R=g,g=0,R&1)&&(R=j(0)|0,$t(R)),le(t|0)}while(!1);return t|0}function Og(t){t=t|0;var r=0,o=0;return t=e[t+8>>2]|0,t?(g=0,t=ge(75,t|0)|0,o=g,g=0,o&1&&(o=j(0)|0,$t(o)),t|0&&(g=0,ge(75,t|0)|0,o=g,g=0,o&1)?(o=j(0)|0,$t(o)):r=4):r=1,r|0}function $g(t){t=t|0,he(t)}function Bg(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0;return t=b,b=b+16|0,C=t+4|0,r=t,e[C>>2]=o,e[r>>2]=h,d=O3(o,l,C,h,d,r,1114111,0)|0,e[c>>2]=e[C>>2],e[w>>2]=e[r>>2],b=t,d|0}function Vg(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0;return t=b,b=b+16|0,C=t+4|0,r=t,e[C>>2]=o,e[r>>2]=h,d=$3(o,l,C,h,d,r,1114111,0)|0,e[c>>2]=e[C>>2],e[w>>2]=e[r>>2],b=t,d|0}function Ug(t,r,o,l,c){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,e[c>>2]=o,3}function zg(t){return t=t|0,0}function Gg(t){return t=t|0,0}function qg(t,r,o,l,c){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,B3(o,l,c,1114111,0)|0}function Wg(t){return t=t|0,4}function Hg(t){t=t|0,he(t)}function Qg(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0;return t=b,b=b+16|0,C=t+4|0,r=t,e[C>>2]=o,e[r>>2]=h,d=V3(o,l,C,h,d,r,1114111,0)|0,e[c>>2]=e[C>>2],e[w>>2]=e[r>>2],b=t,d|0}function Kg(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0;return t=b,b=b+16|0,C=t+4|0,r=t,e[C>>2]=o,e[r>>2]=h,d=U3(o,l,C,h,d,r,1114111,0)|0,e[c>>2]=e[C>>2],e[w>>2]=e[r>>2],b=t,d|0}function Yg(t,r,o,l,c){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,e[c>>2]=o,3}function jg(t){return t=t|0,0}function Xg(t){return t=t|0,0}function Zg(t,r,o,l,c){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,z3(o,l,c,1114111,0)|0}function Jg(t){return t=t|0,4}function e4(t){t=t|0,he(t)}function t4(t){t=t|0,he(t)}function i4(t,r){t=t|0,r=r|0,e[t+4>>2]=r+-1,e[t>>2]=44384,S[t+8>>0]=46,S[t+9>>0]=44,t=t+12|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function n4(t,r){t=t|0,r=r|0,e[t+4>>2]=r+-1,e[t>>2]=44424,e[t+8>>2]=46,e[t+12>>2]=44,t=t+16|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0}function eo(t){t=t|0,e[t>>2]=44384,de(t+12|0)}function r4(t){t=t|0,eo(t),he(t)}function to(t){t=t|0,e[t>>2]=44424,de(t+16|0)}function s4(t){t=t|0,to(t),he(t)}function o4(t){return t=t|0,S[t+8>>0]|0}function l4(t){return t=t|0,e[t+8>>2]|0}function u4(t){return t=t|0,S[t+9>>0]|0}function c4(t){return t=t|0,e[t+12>>2]|0}function f4(t,r){t=t|0,r=r|0,hr(t,r+12|0)}function h4(t,r){t=t|0,r=r|0,hr(t,r+16|0)}function d4(t,r){t=t|0,r=r|0,yi(t,59024,4)}function p4(t,r){t=t|0,r=r|0,mr(t,44996,_n(44996)|0)}function m4(t,r){t=t|0,r=r|0,yi(t,59029,5)}function g4(t,r){t=t|0,r=r|0,mr(t,45016,_n(45016)|0)}function li(t){switch(t=t|0,e[t+4>>2]&74|0){case 64:{t=8;break}case 8:{t=16;break}case 0:{t=0;break}default:t=10}return t|0}function S4(t){t=t|0;do if(!(S[2464]|0)&&kt(2464)|0){if(!(S[2472]|0)&&kt(2472)|0){t=45040;do e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,t=t+12|0;while((t|0)!=45208);Ft(193,0,H|0)|0,bt(2472)}if(g=0,be(41,45040,59035)|0,t=g,g=0,!(t&1)&&(g=0,be(41,45052,59042)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45064,59049)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45076,59057)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45088,59067)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45100,59076)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45112,59083)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45124,59092)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45136,59096)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45148,59100)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45160,59104)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45172,59108)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45184,59112)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45196,59116)|0,t=g,g=0,!(t&1))){e[11302]=45040,bt(2464);break}t=j()|0,W0(2464),le(t|0)}while(!1);return e[11302]|0}function A4(t){t=t|0;do if(!(S[2480]|0)&&kt(2480)|0){if(!(S[2488]|0)&&kt(2488)|0){t=45212;do e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,t=t+12|0;while((t|0)!=45380);Ft(194,0,H|0)|0,bt(2488)}if(g=0,be(42,45212,45380)|0,t=g,g=0,!(t&1)&&(g=0,be(42,45224,45408)|0,t=g,g=0,!(t&1))&&(g=0,be(42,45236,45436)|0,t=g,g=0,!(t&1))&&(g=0,be(42,45248,45468)|0,t=g,g=0,!(t&1))&&(g=0,be(42,45260,45508)|0,t=g,g=0,!(t&1))&&(g=0,be(42,45272,45544)|0,t=g,g=0,!(t&1))&&(g=0,be(42,45284,45572)|0,t=g,g=0,!(t&1))&&(g=0,be(42,45296,45608)|0,t=g,g=0,!(t&1))&&(g=0,be(42,45308,45624)|0,t=g,g=0,!(t&1))&&(g=0,be(42,45320,45640)|0,t=g,g=0,!(t&1))&&(g=0,be(42,45332,45656)|0,t=g,g=0,!(t&1))&&(g=0,be(42,45344,45672)|0,t=g,g=0,!(t&1))&&(g=0,be(42,45356,45688)|0,t=g,g=0,!(t&1))&&(g=0,be(42,45368,45704)|0,t=g,g=0,!(t&1))){e[11430]=45212,bt(2480);break}t=j()|0,W0(2480),le(t|0)}while(!1);return e[11430]|0}function x4(t){t=t|0;e:do if(!(S[2496]|0)&&kt(2496)|0){if(!(S[2504]|0)&&kt(2504)|0){t=45724;do e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,t=t+12|0;while((t|0)!=46012);Ft(195,0,H|0)|0,bt(2504)}g=0,be(41,45724,59120)|0,t=g,g=0;do if(!(t&1)&&(g=0,be(41,45736,59128)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45748,59137)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45760,59143)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45772,59149)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45784,59153)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45796,59158)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45808,59163)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45820,59170)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45832,59180)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45844,59188)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45856,59197)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45868,59206)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45880,59210)|0,t=g,g=0,!(t&1))&&(g=0,be(41,45892,59214)|0,t=g,g=0,!(t&1))){if(g=0,be(41,45904,59218)|0,t=g,g=0,t&1||(g=0,be(41,45916,59149)|0,t=g,g=0,t&1)||(g=0,be(41,45928,59222)|0,t=g,g=0,t&1)||(g=0,be(41,45940,59226)|0,t=g,g=0,t&1)||(g=0,be(41,45952,59230)|0,t=g,g=0,t&1)||(g=0,be(41,45964,59234)|0,t=g,g=0,t&1)||(g=0,be(41,45976,59238)|0,t=g,g=0,t&1)||(g=0,be(41,45988,59242)|0,t=g,g=0,t&1)||(g=0,be(41,46e3,59246)|0,t=g,g=0,t&1))break;e[11503]=45724,bt(2496);break e}while(!1);t=j()|0,W0(2496),le(t|0)}while(!1);return e[11503]|0}function w4(t){t=t|0;e:do if(!(S[2512]|0)&&kt(2512)|0){if(!(S[2520]|0)&&kt(2520)|0){t=46016;do e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,t=t+12|0;while((t|0)!=46304);Ft(196,0,H|0)|0,bt(2520)}g=0,be(42,46016,46304)|0,t=g,g=0;do if(!(t&1)&&(g=0,be(42,46028,46336)|0,t=g,g=0,!(t&1))&&(g=0,be(42,46040,46372)|0,t=g,g=0,!(t&1))&&(g=0,be(42,46052,46396)|0,t=g,g=0,!(t&1))&&(g=0,be(42,46064,46420)|0,t=g,g=0,!(t&1))&&(g=0,be(42,46076,46436)|0,t=g,g=0,!(t&1))&&(g=0,be(42,46088,46456)|0,t=g,g=0,!(t&1))&&(g=0,be(42,46100,46476)|0,t=g,g=0,!(t&1))&&(g=0,be(42,46112,46504)|0,t=g,g=0,!(t&1))&&(g=0,be(42,46124,46544)|0,t=g,g=0,!(t&1))&&(g=0,be(42,46136,46576)|0,t=g,g=0,!(t&1))&&(g=0,be(42,46148,46612)|0,t=g,g=0,!(t&1))&&(g=0,be(42,46160,46648)|0,t=g,g=0,!(t&1))&&(g=0,be(42,46172,46664)|0,t=g,g=0,!(t&1))&&(g=0,be(42,46184,46680)|0,t=g,g=0,!(t&1))){if(g=0,be(42,46196,46696)|0,t=g,g=0,t&1||(g=0,be(42,46208,46420)|0,t=g,g=0,t&1)||(g=0,be(42,46220,46712)|0,t=g,g=0,t&1)||(g=0,be(42,46232,46728)|0,t=g,g=0,t&1)||(g=0,be(42,46244,46744)|0,t=g,g=0,t&1)||(g=0,be(42,46256,46760)|0,t=g,g=0,t&1)||(g=0,be(42,46268,46776)|0,t=g,g=0,t&1)||(g=0,be(42,46280,46792)|0,t=g,g=0,t&1)||(g=0,be(42,46292,46808)|0,t=g,g=0,t&1))break;e[11706]=46016,bt(2512);break e}while(!1);t=j()|0,W0(2512),le(t|0)}while(!1);return e[11706]|0}function y4(t){t=t|0;do if(!(S[2528]|0)&&kt(2528)|0){if(!(S[2536]|0)&&kt(2536)|0){t=46828;do e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,t=t+12|0;while((t|0)!=47116);Ft(197,0,H|0)|0,bt(2536)}if(g=0,be(41,46828,59250)|0,t=g,g=0,!(t&1)&&(g=0,be(41,46840,59253)|0,t=g,g=0,!(t&1))){e[11779]=46828,bt(2528);break}t=j()|0,W0(2528),le(t|0)}while(!1);return e[11779]|0}function C4(t){t=t|0;do if(!(S[2544]|0)&&kt(2544)|0){if(!(S[2552]|0)&&kt(2552)|0){t=47120;do e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,t=t+12|0;while((t|0)!=47408);Ft(198,0,H|0)|0,bt(2552)}if(g=0,be(42,47120,47408)|0,t=g,g=0,!(t&1)&&(g=0,be(42,47132,47420)|0,t=g,g=0,!(t&1))){e[11858]=47120,bt(2544);break}t=j()|0,W0(2544),le(t|0)}while(!1);return e[11858]|0}function T4(t){t=t|0;do if(!(S[2560]|0)&&kt(2560)|0)if(g=0,xe(5,47436,59256,8),t=g,g=0,t&1)t=j()|0,W0(2560),le(t|0);else{Ft(199,47436,H|0)|0,bt(2560);break}while(!1);return 47436}function I4(t){t=t|0;var r=0;do if(!(S[2568]|0)&&kt(2568)|0){if(g=0,t=ge(76,47448)|0,r=g,g=0,!(r&1)&&(g=0,xe(15,47484,47448,t|0),r=g,g=0,!(r&1))){Ft(200,47484,H|0)|0,bt(2568);break}r=j()|0,W0(2568),le(r|0)}while(!1);return 47484}function E4(t){t=t|0;do if(!(S[2576]|0)&&kt(2576)|0)if(g=0,xe(5,47496,59265,8),t=g,g=0,t&1)t=j()|0,W0(2576),le(t|0);else{Ft(199,47496,H|0)|0,bt(2576);break}while(!1);return 47496}function k4(t){t=t|0;var r=0;do if(!(S[2584]|0)&&kt(2584)|0){if(g=0,t=ge(76,47508)|0,r=g,g=0,!(r&1)&&(g=0,xe(15,47544,47508,t|0),r=g,g=0,!(r&1))){Ft(200,47544,H|0)|0,bt(2584);break}r=j()|0,W0(2584),le(r|0)}while(!1);return 47544}function D4(t){t=t|0;do if(!(S[2592]|0)&&kt(2592)|0)if(g=0,xe(5,47556,59274,20),t=g,g=0,t&1)t=j()|0,W0(2592),le(t|0);else{Ft(199,47556,H|0)|0,bt(2592);break}while(!1);return 47556}function N4(t){t=t|0;var r=0;do if(!(S[2600]|0)&&kt(2600)|0){if(g=0,t=ge(76,47568)|0,r=g,g=0,!(r&1)&&(g=0,xe(15,47652,47568,t|0),r=g,g=0,!(r&1))){Ft(200,47652,H|0)|0,bt(2600);break}r=j()|0,W0(2600),le(r|0)}while(!1);return 47652}function F4(t){t=t|0;do if(!(S[2608]|0)&&kt(2608)|0)if(g=0,xe(5,47664,59295,11),t=g,g=0,t&1)t=j()|0,W0(2608),le(t|0);else{Ft(199,47664,H|0)|0,bt(2608);break}while(!1);return 47664}function R4(t){t=t|0;var r=0;do if(!(S[2616]|0)&&kt(2616)|0){if(g=0,t=ge(76,47676)|0,r=g,g=0,!(r&1)&&(g=0,xe(15,47724,47676,t|0),r=g,g=0,!(r&1))){Ft(200,47724,H|0)|0,bt(2616);break}r=j()|0,W0(2616),le(r|0)}while(!1);return 47724}function io(t){t=t|0;var r=0,o=0,l=0;e[t>>2]=44304,t=t+8|0,r=e[t>>2]|0,g=0,o=Ce(3)|0,l=g,g=0;do if(!(l&1)){if((r|0)!=(o|0)&&(g=0,ue(188,e[t>>2]|0),l=g,g=0,l&1))break;return}while(!1);l=j(0)|0,$t(l)}function Sn(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0;O=b,b=b+112|0,C=O,k=(l-o|0)/12|0;do if(k>>>0>100){if(C=E0(k)|0,!(C|0)&&(g=0,Nt(6),P=g,g=0,P&1)){w=0,_=6;break}w=C,_=11}else w=0,_=11;while(!1);e:do if((_|0)==11){if((o|0)==(l|0))D=0;else for(_=o,N=0,R=C;D=S[_>>0]|0,D&1?D=e[_+4>>2]|0:D=(D&255)>>>1,D?(S[R>>0]=1,D=N):(S[R>>0]=2,D=N+1|0,k=k+-1|0),_=_+12|0,(_|0)!=(l|0);)N=D,R=R+1|0;$=(o|0)==(l|0),P=(o|0)==(l|0),G=0,U=D;t:for(;;){D=e[t>>2]|0;do if(D){if((e[D+12>>2]|0)==(e[D+16>>2]|0)){if(g=0,D=ge(e[(e[D>>2]|0)+36>>2]|0,D|0)|0,K=g,g=0,K&1){_=5;break t}if((D|0)==-1){e[t>>2]=0,D=0;break}else{D=e[t>>2]|0;break}}}else D=0;while(!1);if(_=(D|0)==0,N=e[r>>2]|0,N){if((e[N+12>>2]|0)==(e[N+16>>2]|0)){if(g=0,D=ge(e[(e[N>>2]|0)+36>>2]|0,N|0)|0,K=g,g=0,K&1){_=5;break}(D|0)==-1&&(e[r>>2]=0,N=0)}}else N=0;if(R=(N|0)==0,D=e[t>>2]|0,!((k|0)!=0&(_^R))){_=64;break}if(N=e[D+12>>2]|0,(N|0)==(e[D+16>>2]|0)){if(g=0,D=ge(e[(e[D>>2]|0)+36>>2]|0,D|0)|0,K=g,g=0,K&1){_=5;break}}else D=F[N>>0]|0;if(D=D&255,!d&&(g=0,D=be(e[(e[c>>2]|0)+12>>2]|0,c|0,D|0)|0,K=g,g=0,K&1)){_=5;break}if(K=G+1|0,$)D=0,_=U;else for(R=0,Q=o,_=U,U=C;;){do if((S[U>>0]|0)==1){if(S[Q>>0]&1?N=e[Q+8>>2]|0:N=Q+1|0,N=S[N+G>>0]|0,!d&&(g=0,N=be(e[(e[c>>2]|0)+12>>2]|0,c|0,N|0)|0,Z=g,g=0,Z&1)){_=4;break t}if(D<<24>>24!=N<<24>>24){S[U>>0]=0,N=R,k=k+-1|0;break}N=S[Q>>0]|0,N&1?N=e[Q+4>>2]|0:N=(N&255)>>>1,(N|0)==(K|0)?(S[U>>0]=2,N=1,_=_+1|0,k=k+-1|0):N=1}else N=R;while(!1);if(Q=Q+12|0,(Q|0)==(l|0)){D=N;break}else R=N,U=U+1|0}if(!D){G=K,U=_;continue}if(D=e[t>>2]|0,N=D+12|0,R=e[N>>2]|0,(R|0)==(e[D+16>>2]|0)){if(g=0,ge(e[(e[D>>2]|0)+40>>2]|0,D|0)|0,Z=g,g=0,Z&1){_=5;break}}else e[N>>2]=R+1;if((_+k|0)>>>0<2|P){G=K,U=_;continue}else D=o,R=_,_=C;for(;;)if((S[_>>0]|0)==2&&(N=S[D>>0]|0,N&1?N=e[D+4>>2]|0:N=(N&255)>>>1,(N|0)!=(K|0)&&(S[_>>0]=0,R=R+-1|0)),D=D+12|0,(D|0)==(l|0)){G=K,U=R;continue t}else _=_+1|0}if((_|0)==4){o=j()|0;break}else if((_|0)==5){o=j()|0;break}else if((_|0)==64){do if(D){if((e[D+12>>2]|0)==(e[D+16>>2]|0)){if(g=0,D=ge(e[(e[D>>2]|0)+36>>2]|0,D|0)|0,Z=g,g=0,Z&1){_=6;break e}if((D|0)==-1){e[t>>2]=0,D=0;break}else{D=e[t>>2]|0;break}}}else D=0;while(!1);k=(D|0)==0;do if(R)_=76;else{if((e[N+12>>2]|0)==(e[N+16>>2]|0)){if(g=0,D=ge(e[(e[N>>2]|0)+36>>2]|0,N|0)|0,Z=g,g=0,Z&1){_=6;break e}if((D|0)==-1){e[r>>2]=0,_=76;break}}k||(_=77)}while(!1);(_|0)==76&&k&&(_=77),(_|0)==77&&(e[h>>2]=e[h>>2]|2);t:do if((o|0)==(l|0))_=81;else for(;;){if((S[C>>0]|0)==2)break t;if(o=o+12|0,(o|0)==(l|0)){_=81;break}else C=C+1|0}while(!1);return(_|0)==81&&(e[h>>2]=e[h>>2]|4,o=l),w&&n0(w),b=O,o|0}}while(!1);return(_|0)==6&&(o=j()|0),w&&n0(w),le(o|0),0}function M4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;Z=b,b=b+240|0,U=Z+202|0,d=Z+200|0,oe=Z+24|0,ie=Z+12|0,K=Z+8|0,P=Z+40|0,O=Z+4|0,G=Z,Q=li(l)|0,qi(oe,l,U,d),e[ie>>2]=0,e[ie+4>>2]=0,e[ie+8>>2]=0,S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),_=g,g=0;e:do if(_&1)ne=25;else{N=ie+8|0,R=ie+1|0,l=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=l,e[O>>2]=P,e[G>>2]=0,_=ie+4|0,k=S[d>>0]|0,t=e[r>>2]|0;t:for(;;){if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,d=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,D=g,g=0,D&1){ne=24;break}(d|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;w=(t|0)==0,d=e[o>>2]|0;do if(d){if((e[d+12>>2]|0)!=(e[d+16>>2]|0)){if(w)break;break t}if(g=0,C=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,D=g,g=0,D&1){ne=24;break t}if((C|0)!=-1){if(w)break;break t}else{e[o>>2]=0,ne=16;break}}else ne=16;while(!1);if((ne|0)==16)if(ne=0,w){d=0;break}else d=0;if(w=S[ie>>0]|0,w=w&1?e[_>>2]|0:(w&255)>>>1,(e[K>>2]|0)==(l+w|0)){if(g=0,xe(8,ie|0,w<<1|0,0),D=g,g=0,D&1){ne=24;break}if(S[ie>>0]&1?l=(e[ie>>2]&-2)+-1|0:l=10,g=0,xe(8,ie|0,l|0,0),D=g,g=0,D&1){ne=24;break}l=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=l+w}if(C=t+12|0,w=e[C>>2]|0,D=t+16|0,(w|0)==(e[D>>2]|0)){if(g=0,w=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=24;break}}else w=F[w>>0]|0;if(_i(w&255,Q,l,K,G,k,oe,P,O,U)|0)break;if(d=e[C>>2]|0,(d|0)==(e[D>>2]|0))if(g=0,ge(e[(e[t>>2]|0)+40>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=24;break}else continue;else{e[C>>2]=d+1;continue}}if((ne|0)==24){t=j()|0;break}if(ce=S[oe>>0]|0,(ce&1?e[oe+4>>2]|0:(ce&255)>>>1)|0&&($=e[O>>2]|0,($-P|0)<160)&&(ce=e[G>>2]|0,e[O>>2]=$+4,e[$>>2]=ce),g=0,l=Pe(21,l|0,e[K>>2]|0,c|0,Q|0)|0,ce=g,g=0,ce&1)ne=25;else{if(e[h>>2]=l,V0(oe,P,e[O>>2]|0,c),t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,l=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=25;break}(l|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;l=(t|0)==0;do if(d){if((e[d+12>>2]|0)==(e[d+16>>2]|0)){if(g=0,t=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=25;break e}if((t|0)==-1){e[o>>2]=0,ne=49;break}}l||(ne=50)}else ne=49;while(!1);return(ne|0)==49&&l&&(ne=50),(ne|0)==50&&(e[c>>2]=e[c>>2]|2),ce=e[r>>2]|0,de(ie),de(oe),b=Z,ce|0}}while(!1);return(ne|0)==25&&(t=j()|0),de(ie),de(oe),le(t|0),0}function _4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;Z=b,b=b+240|0,U=Z+202|0,d=Z+200|0,oe=Z+24|0,ie=Z+12|0,K=Z+8|0,P=Z+40|0,O=Z+4|0,G=Z,Q=li(l)|0,qi(oe,l,U,d),e[ie>>2]=0,e[ie+4>>2]=0,e[ie+8>>2]=0,S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),_=g,g=0;e:do if(_&1)ne=25;else{N=ie+8|0,R=ie+1|0,l=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=l,e[O>>2]=P,e[G>>2]=0,_=ie+4|0,k=S[d>>0]|0,t=e[r>>2]|0;t:for(;;){if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,d=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,D=g,g=0,D&1){ne=24;break}(d|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;d=(t|0)==0,w=e[o>>2]|0;do if(w){if((e[w+12>>2]|0)!=(e[w+16>>2]|0)){if(d)break;break t}if(g=0,C=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,D=g,g=0,D&1){ne=24;break t}if((C|0)!=-1){if(d)break;break t}else{e[o>>2]=0,ne=16;break}}else ne=16;while(!1);if((ne|0)==16)if(ne=0,d){w=0;break}else w=0;if(d=S[ie>>0]|0,d=d&1?e[_>>2]|0:(d&255)>>>1,(e[K>>2]|0)==(l+d|0)){if(g=0,xe(8,ie|0,d<<1|0,0),D=g,g=0,D&1){ne=24;break}if(S[ie>>0]&1?l=(e[ie>>2]&-2)+-1|0:l=10,g=0,xe(8,ie|0,l|0,0),D=g,g=0,D&1){ne=24;break}l=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=l+d}if(C=t+12|0,d=e[C>>2]|0,D=t+16|0,(d|0)==(e[D>>2]|0)){if(g=0,d=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=24;break}}else d=F[d>>0]|0;if(_i(d&255,Q,l,K,G,k,oe,P,O,U)|0)break;if(d=e[C>>2]|0,(d|0)==(e[D>>2]|0))if(g=0,ge(e[(e[t>>2]|0)+40>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=24;break}else continue;else{e[C>>2]=d+1;continue}}if((ne|0)==24){t=j()|0;break}if(ce=S[oe>>0]|0,(ce&1?e[oe+4>>2]|0:(ce&255)>>>1)|0&&($=e[O>>2]|0,($-P|0)<160)&&(ce=e[G>>2]|0,e[O>>2]=$+4,e[$>>2]=ce),g=0,l=Pe(22,l|0,e[K>>2]|0,c|0,Q|0)|0,d=ye,ce=g,g=0,ce&1)ne=25;else{if(ce=h,e[ce>>2]=l,e[ce+4>>2]=d,V0(oe,P,e[O>>2]|0,c),t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,l=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=25;break}(l|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;l=(t|0)==0;do if(w){if((e[w+12>>2]|0)==(e[w+16>>2]|0)){if(g=0,t=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,ce=g,g=0,ce&1){ne=25;break e}if((t|0)==-1){e[o>>2]=0,ne=49;break}}l||(ne=50)}else ne=49;while(!1);return(ne|0)==49&&l&&(ne=50),(ne|0)==50&&(e[c>>2]=e[c>>2]|2),ce=e[r>>2]|0,de(ie),de(oe),b=Z,ce|0}}while(!1);return(ne|0)==25&&(t=j()|0),de(ie),de(oe),le(t|0),0}function P4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;Z=b,b=b+240|0,U=Z+202|0,d=Z+200|0,oe=Z+24|0,ie=Z+12|0,K=Z+8|0,P=Z+40|0,O=Z+4|0,G=Z,Q=li(l)|0,qi(oe,l,U,d),e[ie>>2]=0,e[ie+4>>2]=0,e[ie+8>>2]=0,S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),_=g,g=0;e:do if(_&1)ne=25;else{N=ie+8|0,R=ie+1|0,l=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=l,e[O>>2]=P,e[G>>2]=0,_=ie+4|0,k=S[d>>0]|0,t=e[r>>2]|0;t:for(;;){if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,d=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,D=g,g=0,D&1){ne=24;break}(d|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;w=(t|0)==0,d=e[o>>2]|0;do if(d){if((e[d+12>>2]|0)!=(e[d+16>>2]|0)){if(w)break;break t}if(g=0,C=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,D=g,g=0,D&1){ne=24;break t}if((C|0)!=-1){if(w)break;break t}else{e[o>>2]=0,ne=16;break}}else ne=16;while(!1);if((ne|0)==16)if(ne=0,w){d=0;break}else d=0;if(w=S[ie>>0]|0,w=w&1?e[_>>2]|0:(w&255)>>>1,(e[K>>2]|0)==(l+w|0)){if(g=0,xe(8,ie|0,w<<1|0,0),D=g,g=0,D&1){ne=24;break}if(S[ie>>0]&1?l=(e[ie>>2]&-2)+-1|0:l=10,g=0,xe(8,ie|0,l|0,0),D=g,g=0,D&1){ne=24;break}l=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=l+w}if(C=t+12|0,w=e[C>>2]|0,D=t+16|0,(w|0)==(e[D>>2]|0)){if(g=0,w=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=24;break}}else w=F[w>>0]|0;if(_i(w&255,Q,l,K,G,k,oe,P,O,U)|0)break;if(d=e[C>>2]|0,(d|0)==(e[D>>2]|0))if(g=0,ge(e[(e[t>>2]|0)+40>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=24;break}else continue;else{e[C>>2]=d+1;continue}}if((ne|0)==24){t=j()|0;break}if(ce=S[oe>>0]|0,(ce&1?e[oe+4>>2]|0:(ce&255)>>>1)|0&&($=e[O>>2]|0,($-P|0)<160)&&(ce=e[G>>2]|0,e[O>>2]=$+4,e[$>>2]=ce),g=0,l=Pe(23,l|0,e[K>>2]|0,c|0,Q|0)|0,ce=g,g=0,ce&1)ne=25;else{if(E[h>>1]=l,V0(oe,P,e[O>>2]|0,c),t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,l=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=25;break}(l|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;l=(t|0)==0;do if(d){if((e[d+12>>2]|0)==(e[d+16>>2]|0)){if(g=0,t=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=25;break e}if((t|0)==-1){e[o>>2]=0,ne=49;break}}l||(ne=50)}else ne=49;while(!1);return(ne|0)==49&&l&&(ne=50),(ne|0)==50&&(e[c>>2]=e[c>>2]|2),ce=e[r>>2]|0,de(ie),de(oe),b=Z,ce|0}}while(!1);return(ne|0)==25&&(t=j()|0),de(ie),de(oe),le(t|0),0}function L4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;Z=b,b=b+240|0,U=Z+202|0,d=Z+200|0,oe=Z+24|0,ie=Z+12|0,K=Z+8|0,P=Z+40|0,O=Z+4|0,G=Z,Q=li(l)|0,qi(oe,l,U,d),e[ie>>2]=0,e[ie+4>>2]=0,e[ie+8>>2]=0,S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),_=g,g=0;e:do if(_&1)ne=25;else{N=ie+8|0,R=ie+1|0,l=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=l,e[O>>2]=P,e[G>>2]=0,_=ie+4|0,k=S[d>>0]|0,t=e[r>>2]|0;t:for(;;){if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,d=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,D=g,g=0,D&1){ne=24;break}(d|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;w=(t|0)==0,d=e[o>>2]|0;do if(d){if((e[d+12>>2]|0)!=(e[d+16>>2]|0)){if(w)break;break t}if(g=0,C=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,D=g,g=0,D&1){ne=24;break t}if((C|0)!=-1){if(w)break;break t}else{e[o>>2]=0,ne=16;break}}else ne=16;while(!1);if((ne|0)==16)if(ne=0,w){d=0;break}else d=0;if(w=S[ie>>0]|0,w=w&1?e[_>>2]|0:(w&255)>>>1,(e[K>>2]|0)==(l+w|0)){if(g=0,xe(8,ie|0,w<<1|0,0),D=g,g=0,D&1){ne=24;break}if(S[ie>>0]&1?l=(e[ie>>2]&-2)+-1|0:l=10,g=0,xe(8,ie|0,l|0,0),D=g,g=0,D&1){ne=24;break}l=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=l+w}if(C=t+12|0,w=e[C>>2]|0,D=t+16|0,(w|0)==(e[D>>2]|0)){if(g=0,w=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=24;break}}else w=F[w>>0]|0;if(_i(w&255,Q,l,K,G,k,oe,P,O,U)|0)break;if(d=e[C>>2]|0,(d|0)==(e[D>>2]|0))if(g=0,ge(e[(e[t>>2]|0)+40>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=24;break}else continue;else{e[C>>2]=d+1;continue}}if((ne|0)==24){t=j()|0;break}if(ce=S[oe>>0]|0,(ce&1?e[oe+4>>2]|0:(ce&255)>>>1)|0&&($=e[O>>2]|0,($-P|0)<160)&&(ce=e[G>>2]|0,e[O>>2]=$+4,e[$>>2]=ce),g=0,l=Pe(24,l|0,e[K>>2]|0,c|0,Q|0)|0,ce=g,g=0,ce&1)ne=25;else{if(e[h>>2]=l,V0(oe,P,e[O>>2]|0,c),t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,l=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=25;break}(l|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;l=(t|0)==0;do if(d){if((e[d+12>>2]|0)==(e[d+16>>2]|0)){if(g=0,t=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=25;break e}if((t|0)==-1){e[o>>2]=0,ne=49;break}}l||(ne=50)}else ne=49;while(!1);return(ne|0)==49&&l&&(ne=50),(ne|0)==50&&(e[c>>2]=e[c>>2]|2),ce=e[r>>2]|0,de(ie),de(oe),b=Z,ce|0}}while(!1);return(ne|0)==25&&(t=j()|0),de(ie),de(oe),le(t|0),0}function O4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;Z=b,b=b+240|0,U=Z+202|0,d=Z+200|0,oe=Z+24|0,ie=Z+12|0,K=Z+8|0,P=Z+40|0,O=Z+4|0,G=Z,Q=li(l)|0,qi(oe,l,U,d),e[ie>>2]=0,e[ie+4>>2]=0,e[ie+8>>2]=0,S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),_=g,g=0;e:do if(_&1)ne=25;else{N=ie+8|0,R=ie+1|0,l=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=l,e[O>>2]=P,e[G>>2]=0,_=ie+4|0,k=S[d>>0]|0,t=e[r>>2]|0;t:for(;;){if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,d=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,D=g,g=0,D&1){ne=24;break}(d|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;w=(t|0)==0,d=e[o>>2]|0;do if(d){if((e[d+12>>2]|0)!=(e[d+16>>2]|0)){if(w)break;break t}if(g=0,C=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,D=g,g=0,D&1){ne=24;break t}if((C|0)!=-1){if(w)break;break t}else{e[o>>2]=0,ne=16;break}}else ne=16;while(!1);if((ne|0)==16)if(ne=0,w){d=0;break}else d=0;if(w=S[ie>>0]|0,w=w&1?e[_>>2]|0:(w&255)>>>1,(e[K>>2]|0)==(l+w|0)){if(g=0,xe(8,ie|0,w<<1|0,0),D=g,g=0,D&1){ne=24;break}if(S[ie>>0]&1?l=(e[ie>>2]&-2)+-1|0:l=10,g=0,xe(8,ie|0,l|0,0),D=g,g=0,D&1){ne=24;break}l=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=l+w}if(C=t+12|0,w=e[C>>2]|0,D=t+16|0,(w|0)==(e[D>>2]|0)){if(g=0,w=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=24;break}}else w=F[w>>0]|0;if(_i(w&255,Q,l,K,G,k,oe,P,O,U)|0)break;if(d=e[C>>2]|0,(d|0)==(e[D>>2]|0))if(g=0,ge(e[(e[t>>2]|0)+40>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=24;break}else continue;else{e[C>>2]=d+1;continue}}if((ne|0)==24){t=j()|0;break}if(ce=S[oe>>0]|0,(ce&1?e[oe+4>>2]|0:(ce&255)>>>1)|0&&($=e[O>>2]|0,($-P|0)<160)&&(ce=e[G>>2]|0,e[O>>2]=$+4,e[$>>2]=ce),g=0,l=Pe(25,l|0,e[K>>2]|0,c|0,Q|0)|0,ce=g,g=0,ce&1)ne=25;else{if(e[h>>2]=l,V0(oe,P,e[O>>2]|0,c),t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,l=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=25;break}(l|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;l=(t|0)==0;do if(d){if((e[d+12>>2]|0)==(e[d+16>>2]|0)){if(g=0,t=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=25;break e}if((t|0)==-1){e[o>>2]=0,ne=49;break}}l||(ne=50)}else ne=49;while(!1);return(ne|0)==49&&l&&(ne=50),(ne|0)==50&&(e[c>>2]=e[c>>2]|2),ce=e[r>>2]|0,de(ie),de(oe),b=Z,ce|0}}while(!1);return(ne|0)==25&&(t=j()|0),de(ie),de(oe),le(t|0),0}function $4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;Z=b,b=b+240|0,U=Z+202|0,d=Z+200|0,oe=Z+24|0,ie=Z+12|0,K=Z+8|0,P=Z+40|0,O=Z+4|0,G=Z,Q=li(l)|0,qi(oe,l,U,d),e[ie>>2]=0,e[ie+4>>2]=0,e[ie+8>>2]=0,S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),_=g,g=0;e:do if(_&1)ne=25;else{N=ie+8|0,R=ie+1|0,l=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=l,e[O>>2]=P,e[G>>2]=0,_=ie+4|0,k=S[d>>0]|0,t=e[r>>2]|0;t:for(;;){if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,d=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,D=g,g=0,D&1){ne=24;break}(d|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;d=(t|0)==0,w=e[o>>2]|0;do if(w){if((e[w+12>>2]|0)!=(e[w+16>>2]|0)){if(d)break;break t}if(g=0,C=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,D=g,g=0,D&1){ne=24;break t}if((C|0)!=-1){if(d)break;break t}else{e[o>>2]=0,ne=16;break}}else ne=16;while(!1);if((ne|0)==16)if(ne=0,d){w=0;break}else w=0;if(d=S[ie>>0]|0,d=d&1?e[_>>2]|0:(d&255)>>>1,(e[K>>2]|0)==(l+d|0)){if(g=0,xe(8,ie|0,d<<1|0,0),D=g,g=0,D&1){ne=24;break}if(S[ie>>0]&1?l=(e[ie>>2]&-2)+-1|0:l=10,g=0,xe(8,ie|0,l|0,0),D=g,g=0,D&1){ne=24;break}l=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=l+d}if(C=t+12|0,d=e[C>>2]|0,D=t+16|0,(d|0)==(e[D>>2]|0)){if(g=0,d=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=24;break}}else d=F[d>>0]|0;if(_i(d&255,Q,l,K,G,k,oe,P,O,U)|0)break;if(d=e[C>>2]|0,(d|0)==(e[D>>2]|0))if(g=0,ge(e[(e[t>>2]|0)+40>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=24;break}else continue;else{e[C>>2]=d+1;continue}}if((ne|0)==24){t=j()|0;break}if(ce=S[oe>>0]|0,(ce&1?e[oe+4>>2]|0:(ce&255)>>>1)|0&&($=e[O>>2]|0,($-P|0)<160)&&(ce=e[G>>2]|0,e[O>>2]=$+4,e[$>>2]=ce),g=0,l=Pe(26,l|0,e[K>>2]|0,c|0,Q|0)|0,d=ye,ce=g,g=0,ce&1)ne=25;else{if(ce=h,e[ce>>2]=l,e[ce+4>>2]=d,V0(oe,P,e[O>>2]|0,c),t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,l=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,ce=g,g=0,ce&1){ne=25;break}(l|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;l=(t|0)==0;do if(w){if((e[w+12>>2]|0)==(e[w+16>>2]|0)){if(g=0,t=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,ce=g,g=0,ce&1){ne=25;break e}if((t|0)==-1){e[o>>2]=0,ne=49;break}}l||(ne=50)}else ne=49;while(!1);return(ne|0)==49&&l&&(ne=50),(ne|0)==50&&(e[c>>2]=e[c>>2]|2),ce=e[r>>2]|0,de(ie),de(oe),b=Z,ce|0}}while(!1);return(ne|0)==25&&(t=j()|0),de(ie),de(oe),le(t|0),0}function B4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0;ne=b,b=b+240|0,K=ne+208|0,w=ne+203|0,C=ne+202|0,ke=ne+24|0,ce=ne+12|0,$=ne+8|0,ie=ne+40|0,oe=ne+4|0,P=ne,O=ne+201|0,G=ne+200|0,Ar(ke,l,K,w,C),e[ce>>2]=0,e[ce+4>>2]=0,e[ce+8>>2]=0,S[ce>>0]&1?t=(e[ce>>2]&-2)+-1|0:t=10,g=0,xe(8,ce|0,t|0,0),Q=g,g=0;e:do if(Q&1)Ee=25;else{_=ce+8|0,U=ce+1|0,l=S[ce>>0]&1?e[_>>2]|0:U,e[$>>2]=l,e[oe>>2]=ie,e[P>>2]=0,S[O>>0]=1,S[G>>0]=69,Q=ce+4|0,R=S[w>>0]|0,N=S[C>>0]|0,t=e[r>>2]|0;t:for(;;){if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,w=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,k=g,g=0,k&1){Ee=24;break}(w|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;C=(t|0)==0,w=e[o>>2]|0;do if(w){if((e[w+12>>2]|0)!=(e[w+16>>2]|0)){if(C)break;break t}if(g=0,D=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,k=g,g=0,k&1){Ee=24;break t}if((D|0)!=-1){if(C)break;break t}else{e[o>>2]=0,Ee=16;break}}else Ee=16;while(!1);if((Ee|0)==16)if(Ee=0,C){w=0;break}else w=0;if(C=S[ce>>0]|0,C=C&1?e[Q>>2]|0:(C&255)>>>1,(e[$>>2]|0)==(l+C|0)){if(g=0,xe(8,ce|0,C<<1|0,0),k=g,g=0,k&1){Ee=24;break}if(S[ce>>0]&1?l=(e[ce>>2]&-2)+-1|0:l=10,g=0,xe(8,ce|0,l|0,0),k=g,g=0,k&1){Ee=24;break}l=S[ce>>0]&1?e[_>>2]|0:U,e[$>>2]=l+C}if(D=t+12|0,C=e[D>>2]|0,k=t+16|0,(C|0)==(e[k>>2]|0)){if(g=0,C=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,Te=g,g=0,Te&1){Ee=24;break}}else C=F[C>>0]|0;if(vr(C&255,O,G,l,$,R,N,ke,ie,oe,P,K)|0)break;if(w=e[D>>2]|0,(w|0)==(e[k>>2]|0))if(g=0,ge(e[(e[t>>2]|0)+40>>2]|0,t|0)|0,Te=g,g=0,Te&1){Ee=24;break}else continue;else{e[D>>2]=w+1;continue}}if((Ee|0)==24){t=j()|0;break}if(Te=S[ke>>0]|0,!(!(S[O>>0]|0)||!((Te&1?e[ke+4>>2]|0:(Te&255)>>>1)|0))&&(Z=e[oe>>2]|0,(Z-ie|0)<160)&&(Te=e[P>>2]|0,e[oe>>2]=Z+4,e[Z>>2]=Te),g=0,d=+lt(1,l|0,e[$>>2]|0,c|0),Te=g,g=0,Te&1)Ee=25;else{if(V[h>>2]=d,V0(ke,ie,e[oe>>2]|0,c),t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,l=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,Te=g,g=0,Te&1){Ee=25;break}(l|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;l=(t|0)==0;do if(w){if((e[w+12>>2]|0)==(e[w+16>>2]|0)){if(g=0,t=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,Te=g,g=0,Te&1){Ee=25;break e}if((t|0)==-1){e[o>>2]=0,Ee=49;break}}l||(Ee=50)}else Ee=49;while(!1);return(Ee|0)==49&&l&&(Ee=50),(Ee|0)==50&&(e[c>>2]=e[c>>2]|2),Te=e[r>>2]|0,de(ce),de(ke),b=ne,Te|0}}while(!1);return(Ee|0)==25&&(t=j()|0),de(ce),de(ke),le(t|0),0}function V4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0;ne=b,b=b+240|0,K=ne+208|0,w=ne+203|0,C=ne+202|0,ke=ne+24|0,ce=ne+12|0,$=ne+8|0,ie=ne+40|0,oe=ne+4|0,P=ne,O=ne+201|0,G=ne+200|0,Ar(ke,l,K,w,C),e[ce>>2]=0,e[ce+4>>2]=0,e[ce+8>>2]=0,S[ce>>0]&1?t=(e[ce>>2]&-2)+-1|0:t=10,g=0,xe(8,ce|0,t|0,0),Q=g,g=0;e:do if(Q&1)Ee=25;else{_=ce+8|0,U=ce+1|0,l=S[ce>>0]&1?e[_>>2]|0:U,e[$>>2]=l,e[oe>>2]=ie,e[P>>2]=0,S[O>>0]=1,S[G>>0]=69,Q=ce+4|0,R=S[w>>0]|0,N=S[C>>0]|0,t=e[r>>2]|0;t:for(;;){if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,w=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,k=g,g=0,k&1){Ee=24;break}(w|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;C=(t|0)==0,w=e[o>>2]|0;do if(w){if((e[w+12>>2]|0)!=(e[w+16>>2]|0)){if(C)break;break t}if(g=0,D=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,k=g,g=0,k&1){Ee=24;break t}if((D|0)!=-1){if(C)break;break t}else{e[o>>2]=0,Ee=16;break}}else Ee=16;while(!1);if((Ee|0)==16)if(Ee=0,C){w=0;break}else w=0;if(C=S[ce>>0]|0,C=C&1?e[Q>>2]|0:(C&255)>>>1,(e[$>>2]|0)==(l+C|0)){if(g=0,xe(8,ce|0,C<<1|0,0),k=g,g=0,k&1){Ee=24;break}if(S[ce>>0]&1?l=(e[ce>>2]&-2)+-1|0:l=10,g=0,xe(8,ce|0,l|0,0),k=g,g=0,k&1){Ee=24;break}l=S[ce>>0]&1?e[_>>2]|0:U,e[$>>2]=l+C}if(D=t+12|0,C=e[D>>2]|0,k=t+16|0,(C|0)==(e[k>>2]|0)){if(g=0,C=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,Te=g,g=0,Te&1){Ee=24;break}}else C=F[C>>0]|0;if(vr(C&255,O,G,l,$,R,N,ke,ie,oe,P,K)|0)break;if(w=e[D>>2]|0,(w|0)==(e[k>>2]|0))if(g=0,ge(e[(e[t>>2]|0)+40>>2]|0,t|0)|0,Te=g,g=0,Te&1){Ee=24;break}else continue;else{e[D>>2]=w+1;continue}}if((Ee|0)==24){t=j()|0;break}if(Te=S[ke>>0]|0,!(!(S[O>>0]|0)||!((Te&1?e[ke+4>>2]|0:(Te&255)>>>1)|0))&&(Z=e[oe>>2]|0,(Z-ie|0)<160)&&(Te=e[P>>2]|0,e[oe>>2]=Z+4,e[Z>>2]=Te),g=0,d=+lt(2,l|0,e[$>>2]|0,c|0),Te=g,g=0,Te&1)Ee=25;else{if(B[h>>3]=d,V0(ke,ie,e[oe>>2]|0,c),t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,l=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,Te=g,g=0,Te&1){Ee=25;break}(l|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;l=(t|0)==0;do if(w){if((e[w+12>>2]|0)==(e[w+16>>2]|0)){if(g=0,t=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,Te=g,g=0,Te&1){Ee=25;break e}if((t|0)==-1){e[o>>2]=0,Ee=49;break}}l||(Ee=50)}else Ee=49;while(!1);return(Ee|0)==49&&l&&(Ee=50),(Ee|0)==50&&(e[c>>2]=e[c>>2]|2),Te=e[r>>2]|0,de(ce),de(ke),b=ne,Te|0}}while(!1);return(Ee|0)==25&&(t=j()|0),de(ce),de(ke),le(t|0),0}function U4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0;ne=b,b=b+240|0,K=ne+208|0,w=ne+203|0,C=ne+202|0,ke=ne+24|0,ce=ne+12|0,$=ne+8|0,ie=ne+40|0,oe=ne+4|0,P=ne,O=ne+201|0,G=ne+200|0,Ar(ke,l,K,w,C),e[ce>>2]=0,e[ce+4>>2]=0,e[ce+8>>2]=0,S[ce>>0]&1?t=(e[ce>>2]&-2)+-1|0:t=10,g=0,xe(8,ce|0,t|0,0),Q=g,g=0;e:do if(Q&1)Ee=25;else{_=ce+8|0,U=ce+1|0,l=S[ce>>0]&1?e[_>>2]|0:U,e[$>>2]=l,e[oe>>2]=ie,e[P>>2]=0,S[O>>0]=1,S[G>>0]=69,Q=ce+4|0,R=S[w>>0]|0,N=S[C>>0]|0,t=e[r>>2]|0;t:for(;;){if(t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,w=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,k=g,g=0,k&1){Ee=24;break}(w|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;C=(t|0)==0,w=e[o>>2]|0;do if(w){if((e[w+12>>2]|0)!=(e[w+16>>2]|0)){if(C)break;break t}if(g=0,D=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,k=g,g=0,k&1){Ee=24;break t}if((D|0)!=-1){if(C)break;break t}else{e[o>>2]=0,Ee=16;break}}else Ee=16;while(!1);if((Ee|0)==16)if(Ee=0,C){w=0;break}else w=0;if(C=S[ce>>0]|0,C=C&1?e[Q>>2]|0:(C&255)>>>1,(e[$>>2]|0)==(l+C|0)){if(g=0,xe(8,ce|0,C<<1|0,0),k=g,g=0,k&1){Ee=24;break}if(S[ce>>0]&1?l=(e[ce>>2]&-2)+-1|0:l=10,g=0,xe(8,ce|0,l|0,0),k=g,g=0,k&1){Ee=24;break}l=S[ce>>0]&1?e[_>>2]|0:U,e[$>>2]=l+C}if(D=t+12|0,C=e[D>>2]|0,k=t+16|0,(C|0)==(e[k>>2]|0)){if(g=0,C=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,Te=g,g=0,Te&1){Ee=24;break}}else C=F[C>>0]|0;if(vr(C&255,O,G,l,$,R,N,ke,ie,oe,P,K)|0)break;if(w=e[D>>2]|0,(w|0)==(e[k>>2]|0))if(g=0,ge(e[(e[t>>2]|0)+40>>2]|0,t|0)|0,Te=g,g=0,Te&1){Ee=24;break}else continue;else{e[D>>2]=w+1;continue}}if((Ee|0)==24){t=j()|0;break}if(Te=S[ke>>0]|0,!(!(S[O>>0]|0)||!((Te&1?e[ke+4>>2]|0:(Te&255)>>>1)|0))&&(Z=e[oe>>2]|0,(Z-ie|0)<160)&&(Te=e[P>>2]|0,e[oe>>2]=Z+4,e[Z>>2]=Te),g=0,d=+lt(3,l|0,e[$>>2]|0,c|0),Te=g,g=0,Te&1)Ee=25;else{if(B[h>>3]=d,V0(ke,ie,e[oe>>2]|0,c),t){if((e[t+12>>2]|0)==(e[t+16>>2]|0)){if(g=0,l=ge(e[(e[t>>2]|0)+36>>2]|0,t|0)|0,Te=g,g=0,Te&1){Ee=25;break}(l|0)==-1&&(e[r>>2]=0,t=0)}}else t=0;l=(t|0)==0;do if(w){if((e[w+12>>2]|0)==(e[w+16>>2]|0)){if(g=0,t=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,Te=g,g=0,Te&1){Ee=25;break e}if((t|0)==-1){e[o>>2]=0,Ee=49;break}}l||(Ee=50)}else Ee=49;while(!1);return(Ee|0)==49&&l&&(Ee=50),(Ee|0)==50&&(e[c>>2]=e[c>>2]|2),Te=e[r>>2]|0,de(ce),de(ke),b=ne,Te|0}}while(!1);return(Ee|0)==25&&(t=j()|0),de(ce),de(ke),le(t|0),0}function z4(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;return c=b,b=b+16|0,h=c,e[h>>2]=l,l=ai(r)|0,r=Lo(t,o,h)|0,l|0&&(g=0,ge(75,l|0)|0,h=g,g=0,h&1)&&(h=j(0)|0,$t(h)),b=c,r|0}function An(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0;var w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0;O=b,b=b+112|0,C=O,k=(l-o|0)/12|0;do if(k>>>0>100){if(C=E0(k)|0,!(C|0)&&(g=0,Nt(6),P=g,g=0,P&1)){w=0,R=6;break}w=C,R=11}else w=0,R=11;while(!1);e:do if((R|0)==11){if((o|0)==(l|0))D=0;else for(_=o,N=0,R=C;D=S[_>>0]|0,D&1?D=e[_+4>>2]|0:D=(D&255)>>>1,D?(S[R>>0]=1,D=N):(S[R>>0]=2,D=N+1|0,k=k+-1|0),_=_+12|0,(_|0)!=(l|0);)N=D,R=R+1|0;$=(o|0)==(l|0),P=(o|0)==(l|0),G=0,U=k;t:for(;;){k=e[t>>2]|0;do if(k){if(N=e[k+12>>2]|0,(N|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,K=g,g=0,K&1){R=5;break t}}else k=e[N>>2]|0;if((k|0)==-1){e[t>>2]=0,_=1;break}else{_=(e[t>>2]|0)==0;break}}else _=1;while(!1);if(N=e[r>>2]|0,N){if(k=e[N+12>>2]|0,(k|0)==(e[N+16>>2]|0)){if(g=0,k=ge(e[(e[N>>2]|0)+36>>2]|0,N|0)|0,K=g,g=0,K&1){R=5;break}}else k=e[k>>2]|0;(k|0)==-1?(e[r>>2]=0,N=0,R=1):R=0}else N=0,R=1;if(k=e[t>>2]|0,!((U|0)!=0&(_^R))){R=66;break}if(N=e[k+12>>2]|0,(N|0)==(e[k+16>>2]|0)){if(g=0,k=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,K=g,g=0,K&1){R=5;break}}else k=e[N>>2]|0;if(!d&&(g=0,k=be(e[(e[c>>2]|0)+28>>2]|0,c|0,k|0)|0,K=g,g=0,K&1)){R=5;break}if(K=G+1|0,$)k=0,_=U;else for(_=0,Q=o,R=U,U=C;;){do if((S[U>>0]|0)==1){if(S[Q>>0]&1?N=e[Q+8>>2]|0:N=Q+4|0,N=e[N+(G<<2)>>2]|0,!d&&(g=0,N=be(e[(e[c>>2]|0)+28>>2]|0,c|0,N|0)|0,Z=g,g=0,Z&1)){R=4;break t}if((k|0)!=(N|0)){S[U>>0]=0,N=_,R=R+-1|0;break}N=S[Q>>0]|0,N&1?N=e[Q+4>>2]|0:N=(N&255)>>>1,(N|0)==(K|0)?(S[U>>0]=2,N=1,D=D+1|0,R=R+-1|0):N=1}else N=_;while(!1);if(Q=Q+12|0,(Q|0)==(l|0)){k=N,_=R;break}else _=N,U=U+1|0}if(!k){G=K,U=_;continue}if(k=e[t>>2]|0,N=k+12|0,R=e[N>>2]|0,(R|0)==(e[k+16>>2]|0)){if(g=0,ge(e[(e[k>>2]|0)+40>>2]|0,k|0)|0,Z=g,g=0,Z&1){R=5;break}}else e[N>>2]=R+4;if((D+_|0)>>>0<2|P){G=K,U=_;continue}else k=o,R=C;for(;;)if((S[R>>0]|0)==2&&(N=S[k>>0]|0,N&1?N=e[k+4>>2]|0:N=(N&255)>>>1,(N|0)!=(K|0)&&(S[R>>0]=0,D=D+-1|0)),k=k+12|0,(k|0)==(l|0)){G=K,U=_;continue t}else R=R+1|0}if((R|0)==4){o=j()|0;break}else if((R|0)==5){o=j()|0;break}else if((R|0)==66){do if(k){if(D=e[k+12>>2]|0,(D|0)==(e[k+16>>2]|0)){if(g=0,D=ge(e[(e[k>>2]|0)+36>>2]|0,k|0)|0,Z=g,g=0,Z&1){R=6;break e}}else D=e[D>>2]|0;if((D|0)==-1){e[t>>2]=0,k=1;break}else{k=(e[t>>2]|0)==0;break}}else k=1;while(!1);do if(N){if(D=e[N+12>>2]|0,(D|0)==(e[N+16>>2]|0)){if(g=0,D=ge(e[(e[N>>2]|0)+36>>2]|0,N|0)|0,Z=g,g=0,Z&1){R=6;break e}}else D=e[D>>2]|0;if((D|0)!=-1){if(k)break;R=81;break}else{e[r>>2]=0,R=79;break}}else R=79;while(!1);(R|0)==79&&k&&(R=81),(R|0)==81&&(e[h>>2]=e[h>>2]|2);t:do if((o|0)==(l|0))R=85;else for(;;){if((S[C>>0]|0)==2)break t;if(o=o+12|0,(o|0)==(l|0)){R=85;break}else C=C+1|0}while(!1);return(R|0)==85&&(e[h>>2]=e[h>>2]|4,o=l),w&&n0(w),b=O,o|0}}while(!1);return(R|0)==6&&(o=j()|0),w&&n0(w),le(o|0),0}function G4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;Z=b,b=b+320|0,U=Z+208|0,d=Z+200|0,oe=Z+24|0,ie=Z+12|0,K=Z+8|0,P=Z+40|0,O=Z+4|0,G=Z,Q=li(l)|0,Wi(oe,l,U,d),e[ie>>2]=0,e[ie+4>>2]=0,e[ie+8>>2]=0,S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),_=g,g=0;e:do if(_&1)ne=26;else{N=ie+8|0,R=ie+1|0,t=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=t,e[O>>2]=P,e[G>>2]=0,_=ie+4|0,k=e[d>>2]|0,d=e[r>>2]|0;t:for(;;){if(d){if(l=e[d+12>>2]|0,(l|0)==(e[d+16>>2]|0)){if(g=0,l=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,D=g,g=0,D&1){ne=25;break}}else l=e[l>>2]|0;(l|0)==-1?(e[r>>2]=0,l=0,w=1):(l=d,w=0)}else l=0,w=1;C=e[o>>2]|0;do if(C){if(d=e[C+12>>2]|0,(d|0)==(e[C+16>>2]|0)){if(g=0,d=ge(e[(e[C>>2]|0)+36>>2]|0,C|0)|0,D=g,g=0,D&1){ne=25;break t}}else d=e[d>>2]|0;if((d|0)!=-1){if(w)break;d=C;break t}else{e[o>>2]=0,ne=17;break}}else ne=17;while(!1);if((ne|0)==17)if(ne=0,w){d=0;break}else C=0;if(d=S[ie>>0]|0,d=d&1?e[_>>2]|0:(d&255)>>>1,(e[K>>2]|0)==(t+d|0)){if(g=0,xe(8,ie|0,d<<1|0,0),D=g,g=0,D&1){ne=25;break}if(S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),D=g,g=0,D&1){ne=25;break}t=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=t+d}if(w=l+12|0,d=e[w>>2]|0,D=l+16|0,(d|0)==(e[D>>2]|0)){if(g=0,d=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,ce=g,g=0,ce&1){ne=25;break}}else d=e[d>>2]|0;if(Pi(d,Q,t,K,G,k,oe,P,O,U)|0){d=C;break}if(d=e[w>>2]|0,(d|0)==(e[D>>2]|0))if(g=0,ge(e[(e[l>>2]|0)+40>>2]|0,l|0)|0,ce=g,g=0,ce&1){ne=25;break}else{d=l;continue}else{e[w>>2]=d+4,d=l;continue}}if((ne|0)==25){t=j()|0;break}if(ce=S[oe>>0]|0,(ce&1?e[oe+4>>2]|0:(ce&255)>>>1)|0&&($=e[O>>2]|0,($-P|0)<160)&&(ce=e[G>>2]|0,e[O>>2]=$+4,e[$>>2]=ce),g=0,t=Pe(21,t|0,e[K>>2]|0,c|0,Q|0)|0,ce=g,g=0,ce&1)ne=26;else{if(e[h>>2]=t,V0(oe,P,e[O>>2]|0,c),l){if(t=e[l+12>>2]|0,(t|0)==(e[l+16>>2]|0)){if(g=0,t=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,ce=g,g=0,ce&1){ne=26;break}}else t=e[t>>2]|0;(t|0)==-1?(e[r>>2]=0,l=1):l=0}else l=1;do if(d){if(t=e[d+12>>2]|0,(t|0)==(e[d+16>>2]|0)){if(g=0,t=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=26;break e}}else t=e[t>>2]|0;if((t|0)!=-1){if(l)break;ne=53;break}else{e[o>>2]=0,ne=51;break}}else ne=51;while(!1);return(ne|0)==51&&l&&(ne=53),(ne|0)==53&&(e[c>>2]=e[c>>2]|2),ce=e[r>>2]|0,de(ie),de(oe),b=Z,ce|0}}while(!1);return(ne|0)==26&&(t=j()|0),de(ie),de(oe),le(t|0),0}function q4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;Z=b,b=b+320|0,U=Z+208|0,d=Z+200|0,oe=Z+24|0,ie=Z+12|0,K=Z+8|0,P=Z+40|0,O=Z+4|0,G=Z,Q=li(l)|0,Wi(oe,l,U,d),e[ie>>2]=0,e[ie+4>>2]=0,e[ie+8>>2]=0,S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),_=g,g=0;e:do if(_&1)ne=26;else{N=ie+8|0,R=ie+1|0,t=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=t,e[O>>2]=P,e[G>>2]=0,_=ie+4|0,k=e[d>>2]|0,d=e[r>>2]|0;t:for(;;){if(d){if(l=e[d+12>>2]|0,(l|0)==(e[d+16>>2]|0)){if(g=0,l=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,D=g,g=0,D&1){ne=25;break}}else l=e[l>>2]|0;(l|0)==-1?(e[r>>2]=0,d=0,C=1):C=0}else d=0,C=1;w=e[o>>2]|0;do if(w){if(l=e[w+12>>2]|0,(l|0)==(e[w+16>>2]|0)){if(g=0,l=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,D=g,g=0,D&1){ne=25;break t}}else l=e[l>>2]|0;if((l|0)!=-1){if(C)break;break t}else{e[o>>2]=0,ne=17;break}}else ne=17;while(!1);if((ne|0)==17)if(ne=0,C){w=0;break}else w=0;if(l=S[ie>>0]|0,l=l&1?e[_>>2]|0:(l&255)>>>1,(e[K>>2]|0)==(t+l|0)){if(g=0,xe(8,ie|0,l<<1|0,0),D=g,g=0,D&1){ne=25;break}if(S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),D=g,g=0,D&1){ne=25;break}t=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=t+l}if(C=d+12|0,l=e[C>>2]|0,D=d+16|0,(l|0)==(e[D>>2]|0)){if(g=0,l=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=25;break}}else l=e[l>>2]|0;if(Pi(l,Q,t,K,G,k,oe,P,O,U)|0)break;if(l=e[C>>2]|0,(l|0)==(e[D>>2]|0))if(g=0,ge(e[(e[d>>2]|0)+40>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=25;break}else continue;else{e[C>>2]=l+4;continue}}if((ne|0)==25){t=j()|0;break}if(ce=S[oe>>0]|0,(ce&1?e[oe+4>>2]|0:(ce&255)>>>1)|0&&($=e[O>>2]|0,($-P|0)<160)&&(ce=e[G>>2]|0,e[O>>2]=$+4,e[$>>2]=ce),g=0,t=Pe(22,t|0,e[K>>2]|0,c|0,Q|0)|0,l=ye,ce=g,g=0,ce&1)ne=26;else{if(ce=h,e[ce>>2]=t,e[ce+4>>2]=l,V0(oe,P,e[O>>2]|0,c),d){if(t=e[d+12>>2]|0,(t|0)==(e[d+16>>2]|0)){if(g=0,t=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=26;break}}else t=e[t>>2]|0;(t|0)==-1?(e[r>>2]=0,l=1):l=0}else l=1;do if(w){if(t=e[w+12>>2]|0,(t|0)==(e[w+16>>2]|0)){if(g=0,t=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,ce=g,g=0,ce&1){ne=26;break e}}else t=e[t>>2]|0;if((t|0)!=-1){if(l)break;ne=53;break}else{e[o>>2]=0,ne=51;break}}else ne=51;while(!1);return(ne|0)==51&&l&&(ne=53),(ne|0)==53&&(e[c>>2]=e[c>>2]|2),ce=e[r>>2]|0,de(ie),de(oe),b=Z,ce|0}}while(!1);return(ne|0)==26&&(t=j()|0),de(ie),de(oe),le(t|0),0}function W4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;Z=b,b=b+320|0,U=Z+208|0,d=Z+200|0,oe=Z+24|0,ie=Z+12|0,K=Z+8|0,P=Z+40|0,O=Z+4|0,G=Z,Q=li(l)|0,Wi(oe,l,U,d),e[ie>>2]=0,e[ie+4>>2]=0,e[ie+8>>2]=0,S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),_=g,g=0;e:do if(_&1)ne=26;else{N=ie+8|0,R=ie+1|0,t=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=t,e[O>>2]=P,e[G>>2]=0,_=ie+4|0,k=e[d>>2]|0,d=e[r>>2]|0;t:for(;;){if(d){if(l=e[d+12>>2]|0,(l|0)==(e[d+16>>2]|0)){if(g=0,l=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,D=g,g=0,D&1){ne=25;break}}else l=e[l>>2]|0;(l|0)==-1?(e[r>>2]=0,l=0,w=1):(l=d,w=0)}else l=0,w=1;C=e[o>>2]|0;do if(C){if(d=e[C+12>>2]|0,(d|0)==(e[C+16>>2]|0)){if(g=0,d=ge(e[(e[C>>2]|0)+36>>2]|0,C|0)|0,D=g,g=0,D&1){ne=25;break t}}else d=e[d>>2]|0;if((d|0)!=-1){if(w)break;d=C;break t}else{e[o>>2]=0,ne=17;break}}else ne=17;while(!1);if((ne|0)==17)if(ne=0,w){d=0;break}else C=0;if(d=S[ie>>0]|0,d=d&1?e[_>>2]|0:(d&255)>>>1,(e[K>>2]|0)==(t+d|0)){if(g=0,xe(8,ie|0,d<<1|0,0),D=g,g=0,D&1){ne=25;break}if(S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),D=g,g=0,D&1){ne=25;break}t=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=t+d}if(w=l+12|0,d=e[w>>2]|0,D=l+16|0,(d|0)==(e[D>>2]|0)){if(g=0,d=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,ce=g,g=0,ce&1){ne=25;break}}else d=e[d>>2]|0;if(Pi(d,Q,t,K,G,k,oe,P,O,U)|0){d=C;break}if(d=e[w>>2]|0,(d|0)==(e[D>>2]|0))if(g=0,ge(e[(e[l>>2]|0)+40>>2]|0,l|0)|0,ce=g,g=0,ce&1){ne=25;break}else{d=l;continue}else{e[w>>2]=d+4,d=l;continue}}if((ne|0)==25){t=j()|0;break}if(ce=S[oe>>0]|0,(ce&1?e[oe+4>>2]|0:(ce&255)>>>1)|0&&($=e[O>>2]|0,($-P|0)<160)&&(ce=e[G>>2]|0,e[O>>2]=$+4,e[$>>2]=ce),g=0,t=Pe(23,t|0,e[K>>2]|0,c|0,Q|0)|0,ce=g,g=0,ce&1)ne=26;else{if(E[h>>1]=t,V0(oe,P,e[O>>2]|0,c),l){if(t=e[l+12>>2]|0,(t|0)==(e[l+16>>2]|0)){if(g=0,t=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,ce=g,g=0,ce&1){ne=26;break}}else t=e[t>>2]|0;(t|0)==-1?(e[r>>2]=0,l=1):l=0}else l=1;do if(d){if(t=e[d+12>>2]|0,(t|0)==(e[d+16>>2]|0)){if(g=0,t=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=26;break e}}else t=e[t>>2]|0;if((t|0)!=-1){if(l)break;ne=53;break}else{e[o>>2]=0,ne=51;break}}else ne=51;while(!1);return(ne|0)==51&&l&&(ne=53),(ne|0)==53&&(e[c>>2]=e[c>>2]|2),ce=e[r>>2]|0,de(ie),de(oe),b=Z,ce|0}}while(!1);return(ne|0)==26&&(t=j()|0),de(ie),de(oe),le(t|0),0}function H4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;Z=b,b=b+320|0,U=Z+208|0,d=Z+200|0,oe=Z+24|0,ie=Z+12|0,K=Z+8|0,P=Z+40|0,O=Z+4|0,G=Z,Q=li(l)|0,Wi(oe,l,U,d),e[ie>>2]=0,e[ie+4>>2]=0,e[ie+8>>2]=0,S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),_=g,g=0;e:do if(_&1)ne=26;else{N=ie+8|0,R=ie+1|0,t=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=t,e[O>>2]=P,e[G>>2]=0,_=ie+4|0,k=e[d>>2]|0,d=e[r>>2]|0;t:for(;;){if(d){if(l=e[d+12>>2]|0,(l|0)==(e[d+16>>2]|0)){if(g=0,l=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,D=g,g=0,D&1){ne=25;break}}else l=e[l>>2]|0;(l|0)==-1?(e[r>>2]=0,l=0,w=1):(l=d,w=0)}else l=0,w=1;C=e[o>>2]|0;do if(C){if(d=e[C+12>>2]|0,(d|0)==(e[C+16>>2]|0)){if(g=0,d=ge(e[(e[C>>2]|0)+36>>2]|0,C|0)|0,D=g,g=0,D&1){ne=25;break t}}else d=e[d>>2]|0;if((d|0)!=-1){if(w)break;d=C;break t}else{e[o>>2]=0,ne=17;break}}else ne=17;while(!1);if((ne|0)==17)if(ne=0,w){d=0;break}else C=0;if(d=S[ie>>0]|0,d=d&1?e[_>>2]|0:(d&255)>>>1,(e[K>>2]|0)==(t+d|0)){if(g=0,xe(8,ie|0,d<<1|0,0),D=g,g=0,D&1){ne=25;break}if(S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),D=g,g=0,D&1){ne=25;break}t=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=t+d}if(w=l+12|0,d=e[w>>2]|0,D=l+16|0,(d|0)==(e[D>>2]|0)){if(g=0,d=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,ce=g,g=0,ce&1){ne=25;break}}else d=e[d>>2]|0;if(Pi(d,Q,t,K,G,k,oe,P,O,U)|0){d=C;break}if(d=e[w>>2]|0,(d|0)==(e[D>>2]|0))if(g=0,ge(e[(e[l>>2]|0)+40>>2]|0,l|0)|0,ce=g,g=0,ce&1){ne=25;break}else{d=l;continue}else{e[w>>2]=d+4,d=l;continue}}if((ne|0)==25){t=j()|0;break}if(ce=S[oe>>0]|0,(ce&1?e[oe+4>>2]|0:(ce&255)>>>1)|0&&($=e[O>>2]|0,($-P|0)<160)&&(ce=e[G>>2]|0,e[O>>2]=$+4,e[$>>2]=ce),g=0,t=Pe(24,t|0,e[K>>2]|0,c|0,Q|0)|0,ce=g,g=0,ce&1)ne=26;else{if(e[h>>2]=t,V0(oe,P,e[O>>2]|0,c),l){if(t=e[l+12>>2]|0,(t|0)==(e[l+16>>2]|0)){if(g=0,t=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,ce=g,g=0,ce&1){ne=26;break}}else t=e[t>>2]|0;(t|0)==-1?(e[r>>2]=0,l=1):l=0}else l=1;do if(d){if(t=e[d+12>>2]|0,(t|0)==(e[d+16>>2]|0)){if(g=0,t=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=26;break e}}else t=e[t>>2]|0;if((t|0)!=-1){if(l)break;ne=53;break}else{e[o>>2]=0,ne=51;break}}else ne=51;while(!1);return(ne|0)==51&&l&&(ne=53),(ne|0)==53&&(e[c>>2]=e[c>>2]|2),ce=e[r>>2]|0,de(ie),de(oe),b=Z,ce|0}}while(!1);return(ne|0)==26&&(t=j()|0),de(ie),de(oe),le(t|0),0}function Q4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;Z=b,b=b+320|0,U=Z+208|0,d=Z+200|0,oe=Z+24|0,ie=Z+12|0,K=Z+8|0,P=Z+40|0,O=Z+4|0,G=Z,Q=li(l)|0,Wi(oe,l,U,d),e[ie>>2]=0,e[ie+4>>2]=0,e[ie+8>>2]=0,S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),_=g,g=0;e:do if(_&1)ne=26;else{N=ie+8|0,R=ie+1|0,t=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=t,e[O>>2]=P,e[G>>2]=0,_=ie+4|0,k=e[d>>2]|0,d=e[r>>2]|0;t:for(;;){if(d){if(l=e[d+12>>2]|0,(l|0)==(e[d+16>>2]|0)){if(g=0,l=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,D=g,g=0,D&1){ne=25;break}}else l=e[l>>2]|0;(l|0)==-1?(e[r>>2]=0,l=0,w=1):(l=d,w=0)}else l=0,w=1;C=e[o>>2]|0;do if(C){if(d=e[C+12>>2]|0,(d|0)==(e[C+16>>2]|0)){if(g=0,d=ge(e[(e[C>>2]|0)+36>>2]|0,C|0)|0,D=g,g=0,D&1){ne=25;break t}}else d=e[d>>2]|0;if((d|0)!=-1){if(w)break;d=C;break t}else{e[o>>2]=0,ne=17;break}}else ne=17;while(!1);if((ne|0)==17)if(ne=0,w){d=0;break}else C=0;if(d=S[ie>>0]|0,d=d&1?e[_>>2]|0:(d&255)>>>1,(e[K>>2]|0)==(t+d|0)){if(g=0,xe(8,ie|0,d<<1|0,0),D=g,g=0,D&1){ne=25;break}if(S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),D=g,g=0,D&1){ne=25;break}t=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=t+d}if(w=l+12|0,d=e[w>>2]|0,D=l+16|0,(d|0)==(e[D>>2]|0)){if(g=0,d=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,ce=g,g=0,ce&1){ne=25;break}}else d=e[d>>2]|0;if(Pi(d,Q,t,K,G,k,oe,P,O,U)|0){d=C;break}if(d=e[w>>2]|0,(d|0)==(e[D>>2]|0))if(g=0,ge(e[(e[l>>2]|0)+40>>2]|0,l|0)|0,ce=g,g=0,ce&1){ne=25;break}else{d=l;continue}else{e[w>>2]=d+4,d=l;continue}}if((ne|0)==25){t=j()|0;break}if(ce=S[oe>>0]|0,(ce&1?e[oe+4>>2]|0:(ce&255)>>>1)|0&&($=e[O>>2]|0,($-P|0)<160)&&(ce=e[G>>2]|0,e[O>>2]=$+4,e[$>>2]=ce),g=0,t=Pe(25,t|0,e[K>>2]|0,c|0,Q|0)|0,ce=g,g=0,ce&1)ne=26;else{if(e[h>>2]=t,V0(oe,P,e[O>>2]|0,c),l){if(t=e[l+12>>2]|0,(t|0)==(e[l+16>>2]|0)){if(g=0,t=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,ce=g,g=0,ce&1){ne=26;break}}else t=e[t>>2]|0;(t|0)==-1?(e[r>>2]=0,l=1):l=0}else l=1;do if(d){if(t=e[d+12>>2]|0,(t|0)==(e[d+16>>2]|0)){if(g=0,t=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=26;break e}}else t=e[t>>2]|0;if((t|0)!=-1){if(l)break;ne=53;break}else{e[o>>2]=0,ne=51;break}}else ne=51;while(!1);return(ne|0)==51&&l&&(ne=53),(ne|0)==53&&(e[c>>2]=e[c>>2]|2),ce=e[r>>2]|0,de(ie),de(oe),b=Z,ce|0}}while(!1);return(ne|0)==26&&(t=j()|0),de(ie),de(oe),le(t|0),0}function K4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;Z=b,b=b+320|0,U=Z+208|0,d=Z+200|0,oe=Z+24|0,ie=Z+12|0,K=Z+8|0,P=Z+40|0,O=Z+4|0,G=Z,Q=li(l)|0,Wi(oe,l,U,d),e[ie>>2]=0,e[ie+4>>2]=0,e[ie+8>>2]=0,S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),_=g,g=0;e:do if(_&1)ne=26;else{N=ie+8|0,R=ie+1|0,t=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=t,e[O>>2]=P,e[G>>2]=0,_=ie+4|0,k=e[d>>2]|0,d=e[r>>2]|0;t:for(;;){if(d){if(l=e[d+12>>2]|0,(l|0)==(e[d+16>>2]|0)){if(g=0,l=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,D=g,g=0,D&1){ne=25;break}}else l=e[l>>2]|0;(l|0)==-1?(e[r>>2]=0,d=0,C=1):C=0}else d=0,C=1;w=e[o>>2]|0;do if(w){if(l=e[w+12>>2]|0,(l|0)==(e[w+16>>2]|0)){if(g=0,l=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,D=g,g=0,D&1){ne=25;break t}}else l=e[l>>2]|0;if((l|0)!=-1){if(C)break;break t}else{e[o>>2]=0,ne=17;break}}else ne=17;while(!1);if((ne|0)==17)if(ne=0,C){w=0;break}else w=0;if(l=S[ie>>0]|0,l=l&1?e[_>>2]|0:(l&255)>>>1,(e[K>>2]|0)==(t+l|0)){if(g=0,xe(8,ie|0,l<<1|0,0),D=g,g=0,D&1){ne=25;break}if(S[ie>>0]&1?t=(e[ie>>2]&-2)+-1|0:t=10,g=0,xe(8,ie|0,t|0,0),D=g,g=0,D&1){ne=25;break}t=S[ie>>0]&1?e[N>>2]|0:R,e[K>>2]=t+l}if(C=d+12|0,l=e[C>>2]|0,D=d+16|0,(l|0)==(e[D>>2]|0)){if(g=0,l=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=25;break}}else l=e[l>>2]|0;if(Pi(l,Q,t,K,G,k,oe,P,O,U)|0)break;if(l=e[C>>2]|0,(l|0)==(e[D>>2]|0))if(g=0,ge(e[(e[d>>2]|0)+40>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=25;break}else continue;else{e[C>>2]=l+4;continue}}if((ne|0)==25){t=j()|0;break}if(ce=S[oe>>0]|0,(ce&1?e[oe+4>>2]|0:(ce&255)>>>1)|0&&($=e[O>>2]|0,($-P|0)<160)&&(ce=e[G>>2]|0,e[O>>2]=$+4,e[$>>2]=ce),g=0,t=Pe(26,t|0,e[K>>2]|0,c|0,Q|0)|0,l=ye,ce=g,g=0,ce&1)ne=26;else{if(ce=h,e[ce>>2]=t,e[ce+4>>2]=l,V0(oe,P,e[O>>2]|0,c),d){if(t=e[d+12>>2]|0,(t|0)==(e[d+16>>2]|0)){if(g=0,t=ge(e[(e[d>>2]|0)+36>>2]|0,d|0)|0,ce=g,g=0,ce&1){ne=26;break}}else t=e[t>>2]|0;(t|0)==-1?(e[r>>2]=0,l=1):l=0}else l=1;do if(w){if(t=e[w+12>>2]|0,(t|0)==(e[w+16>>2]|0)){if(g=0,t=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,ce=g,g=0,ce&1){ne=26;break e}}else t=e[t>>2]|0;if((t|0)!=-1){if(l)break;ne=53;break}else{e[o>>2]=0,ne=51;break}}else ne=51;while(!1);return(ne|0)==51&&l&&(ne=53),(ne|0)==53&&(e[c>>2]=e[c>>2]|2),ce=e[r>>2]|0,de(ie),de(oe),b=Z,ce|0}}while(!1);return(ne|0)==26&&(t=j()|0),de(ie),de(oe),le(t|0),0}function Y4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0;ne=b,b=b+352|0,K=ne+208|0,w=ne+40|0,C=ne+36|0,ke=ne+24|0,ce=ne+12|0,$=ne+8|0,ie=ne+48|0,oe=ne+4|0,P=ne,O=ne+337|0,G=ne+336|0,xr(ke,l,K,w,C),e[ce>>2]=0,e[ce+4>>2]=0,e[ce+8>>2]=0,S[ce>>0]&1?t=(e[ce>>2]&-2)+-1|0:t=10,g=0,xe(8,ce|0,t|0,0),Q=g,g=0;e:do if(Q&1)Ee=26;else{_=ce+8|0,U=ce+1|0,t=S[ce>>0]&1?e[_>>2]|0:U,e[$>>2]=t,e[oe>>2]=ie,e[P>>2]=0,S[O>>0]=1,S[G>>0]=69,Q=ce+4|0,R=e[w>>2]|0,N=e[C>>2]|0,l=e[r>>2]|0;t:for(;;){if(l){if(w=e[l+12>>2]|0,(w|0)==(e[l+16>>2]|0)){if(g=0,w=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,k=g,g=0,k&1){Ee=25;break}}else w=e[w>>2]|0;(w|0)==-1?(e[r>>2]=0,l=0,D=1):D=0}else l=0,D=1;w=e[o>>2]|0;do if(w){if(C=e[w+12>>2]|0,(C|0)==(e[w+16>>2]|0)){if(g=0,C=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,k=g,g=0,k&1){Ee=25;break t}}else C=e[C>>2]|0;if((C|0)!=-1){if(D)break;break t}else{e[o>>2]=0,Ee=17;break}}else Ee=17;while(!1);if((Ee|0)==17)if(Ee=0,D){w=0;break}else w=0;if(C=S[ce>>0]|0,C=C&1?e[Q>>2]|0:(C&255)>>>1,(e[$>>2]|0)==(t+C|0)){if(g=0,xe(8,ce|0,C<<1|0,0),k=g,g=0,k&1){Ee=25;break}if(S[ce>>0]&1?t=(e[ce>>2]&-2)+-1|0:t=10,g=0,xe(8,ce|0,t|0,0),k=g,g=0,k&1){Ee=25;break}t=S[ce>>0]&1?e[_>>2]|0:U,e[$>>2]=t+C}if(D=l+12|0,C=e[D>>2]|0,k=l+16|0,(C|0)==(e[k>>2]|0)){if(g=0,C=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,Te=g,g=0,Te&1){Ee=25;break}}else C=e[C>>2]|0;if(wr(C,O,G,t,$,R,N,ke,ie,oe,P,K)|0)break;if(w=e[D>>2]|0,(w|0)==(e[k>>2]|0))if(g=0,ge(e[(e[l>>2]|0)+40>>2]|0,l|0)|0,Te=g,g=0,Te&1){Ee=25;break}else continue;else{e[D>>2]=w+4;continue}}if((Ee|0)==25){t=j()|0;break}if(Te=S[ke>>0]|0,!(!(S[O>>0]|0)||!((Te&1?e[ke+4>>2]|0:(Te&255)>>>1)|0))&&(Z=e[oe>>2]|0,(Z-ie|0)<160)&&(Te=e[P>>2]|0,e[oe>>2]=Z+4,e[Z>>2]=Te),g=0,d=+lt(1,t|0,e[$>>2]|0,c|0),Te=g,g=0,Te&1)Ee=26;else{if(V[h>>2]=d,V0(ke,ie,e[oe>>2]|0,c),l){if(t=e[l+12>>2]|0,(t|0)==(e[l+16>>2]|0)){if(g=0,t=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,Te=g,g=0,Te&1){Ee=26;break}}else t=e[t>>2]|0;(t|0)==-1?(e[r>>2]=0,l=1):l=0}else l=1;do if(w){if(t=e[w+12>>2]|0,(t|0)==(e[w+16>>2]|0)){if(g=0,t=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,Te=g,g=0,Te&1){Ee=26;break e}}else t=e[t>>2]|0;if((t|0)!=-1){if(l)break;Ee=53;break}else{e[o>>2]=0,Ee=51;break}}else Ee=51;while(!1);return(Ee|0)==51&&l&&(Ee=53),(Ee|0)==53&&(e[c>>2]=e[c>>2]|2),Te=e[r>>2]|0,de(ce),de(ke),b=ne,Te|0}}while(!1);return(Ee|0)==26&&(t=j()|0),de(ce),de(ke),le(t|0),0}function j4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0;ne=b,b=b+352|0,K=ne+208|0,w=ne+40|0,C=ne+36|0,ke=ne+24|0,ce=ne+12|0,$=ne+8|0,ie=ne+48|0,oe=ne+4|0,P=ne,O=ne+337|0,G=ne+336|0,xr(ke,l,K,w,C),e[ce>>2]=0,e[ce+4>>2]=0,e[ce+8>>2]=0,S[ce>>0]&1?t=(e[ce>>2]&-2)+-1|0:t=10,g=0,xe(8,ce|0,t|0,0),Q=g,g=0;e:do if(Q&1)Ee=26;else{_=ce+8|0,U=ce+1|0,t=S[ce>>0]&1?e[_>>2]|0:U,e[$>>2]=t,e[oe>>2]=ie,e[P>>2]=0,S[O>>0]=1,S[G>>0]=69,Q=ce+4|0,R=e[w>>2]|0,N=e[C>>2]|0,l=e[r>>2]|0;t:for(;;){if(l){if(w=e[l+12>>2]|0,(w|0)==(e[l+16>>2]|0)){if(g=0,w=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,k=g,g=0,k&1){Ee=25;break}}else w=e[w>>2]|0;(w|0)==-1?(e[r>>2]=0,l=0,D=1):D=0}else l=0,D=1;w=e[o>>2]|0;do if(w){if(C=e[w+12>>2]|0,(C|0)==(e[w+16>>2]|0)){if(g=0,C=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,k=g,g=0,k&1){Ee=25;break t}}else C=e[C>>2]|0;if((C|0)!=-1){if(D)break;break t}else{e[o>>2]=0,Ee=17;break}}else Ee=17;while(!1);if((Ee|0)==17)if(Ee=0,D){w=0;break}else w=0;if(C=S[ce>>0]|0,C=C&1?e[Q>>2]|0:(C&255)>>>1,(e[$>>2]|0)==(t+C|0)){if(g=0,xe(8,ce|0,C<<1|0,0),k=g,g=0,k&1){Ee=25;break}if(S[ce>>0]&1?t=(e[ce>>2]&-2)+-1|0:t=10,g=0,xe(8,ce|0,t|0,0),k=g,g=0,k&1){Ee=25;break}t=S[ce>>0]&1?e[_>>2]|0:U,e[$>>2]=t+C}if(D=l+12|0,C=e[D>>2]|0,k=l+16|0,(C|0)==(e[k>>2]|0)){if(g=0,C=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,Te=g,g=0,Te&1){Ee=25;break}}else C=e[C>>2]|0;if(wr(C,O,G,t,$,R,N,ke,ie,oe,P,K)|0)break;if(w=e[D>>2]|0,(w|0)==(e[k>>2]|0))if(g=0,ge(e[(e[l>>2]|0)+40>>2]|0,l|0)|0,Te=g,g=0,Te&1){Ee=25;break}else continue;else{e[D>>2]=w+4;continue}}if((Ee|0)==25){t=j()|0;break}if(Te=S[ke>>0]|0,!(!(S[O>>0]|0)||!((Te&1?e[ke+4>>2]|0:(Te&255)>>>1)|0))&&(Z=e[oe>>2]|0,(Z-ie|0)<160)&&(Te=e[P>>2]|0,e[oe>>2]=Z+4,e[Z>>2]=Te),g=0,d=+lt(2,t|0,e[$>>2]|0,c|0),Te=g,g=0,Te&1)Ee=26;else{if(B[h>>3]=d,V0(ke,ie,e[oe>>2]|0,c),l){if(t=e[l+12>>2]|0,(t|0)==(e[l+16>>2]|0)){if(g=0,t=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,Te=g,g=0,Te&1){Ee=26;break}}else t=e[t>>2]|0;(t|0)==-1?(e[r>>2]=0,l=1):l=0}else l=1;do if(w){if(t=e[w+12>>2]|0,(t|0)==(e[w+16>>2]|0)){if(g=0,t=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,Te=g,g=0,Te&1){Ee=26;break e}}else t=e[t>>2]|0;if((t|0)!=-1){if(l)break;Ee=53;break}else{e[o>>2]=0,Ee=51;break}}else Ee=51;while(!1);return(Ee|0)==51&&l&&(Ee=53),(Ee|0)==53&&(e[c>>2]=e[c>>2]|2),Te=e[r>>2]|0,de(ce),de(ke),b=ne,Te|0}}while(!1);return(Ee|0)==26&&(t=j()|0),de(ce),de(ke),le(t|0),0}function X4(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0;ne=b,b=b+352|0,K=ne+208|0,w=ne+40|0,C=ne+36|0,ke=ne+24|0,ce=ne+12|0,$=ne+8|0,ie=ne+48|0,oe=ne+4|0,P=ne,O=ne+337|0,G=ne+336|0,xr(ke,l,K,w,C),e[ce>>2]=0,e[ce+4>>2]=0,e[ce+8>>2]=0,S[ce>>0]&1?t=(e[ce>>2]&-2)+-1|0:t=10,g=0,xe(8,ce|0,t|0,0),Q=g,g=0;e:do if(Q&1)Ee=26;else{_=ce+8|0,U=ce+1|0,t=S[ce>>0]&1?e[_>>2]|0:U,e[$>>2]=t,e[oe>>2]=ie,e[P>>2]=0,S[O>>0]=1,S[G>>0]=69,Q=ce+4|0,R=e[w>>2]|0,N=e[C>>2]|0,l=e[r>>2]|0;t:for(;;){if(l){if(w=e[l+12>>2]|0,(w|0)==(e[l+16>>2]|0)){if(g=0,w=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,k=g,g=0,k&1){Ee=25;break}}else w=e[w>>2]|0;(w|0)==-1?(e[r>>2]=0,l=0,D=1):D=0}else l=0,D=1;w=e[o>>2]|0;do if(w){if(C=e[w+12>>2]|0,(C|0)==(e[w+16>>2]|0)){if(g=0,C=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,k=g,g=0,k&1){Ee=25;break t}}else C=e[C>>2]|0;if((C|0)!=-1){if(D)break;break t}else{e[o>>2]=0,Ee=17;break}}else Ee=17;while(!1);if((Ee|0)==17)if(Ee=0,D){w=0;break}else w=0;if(C=S[ce>>0]|0,C=C&1?e[Q>>2]|0:(C&255)>>>1,(e[$>>2]|0)==(t+C|0)){if(g=0,xe(8,ce|0,C<<1|0,0),k=g,g=0,k&1){Ee=25;break}if(S[ce>>0]&1?t=(e[ce>>2]&-2)+-1|0:t=10,g=0,xe(8,ce|0,t|0,0),k=g,g=0,k&1){Ee=25;break}t=S[ce>>0]&1?e[_>>2]|0:U,e[$>>2]=t+C}if(D=l+12|0,C=e[D>>2]|0,k=l+16|0,(C|0)==(e[k>>2]|0)){if(g=0,C=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,Te=g,g=0,Te&1){Ee=25;break}}else C=e[C>>2]|0;if(wr(C,O,G,t,$,R,N,ke,ie,oe,P,K)|0)break;if(w=e[D>>2]|0,(w|0)==(e[k>>2]|0))if(g=0,ge(e[(e[l>>2]|0)+40>>2]|0,l|0)|0,Te=g,g=0,Te&1){Ee=25;break}else continue;else{e[D>>2]=w+4;continue}}if((Ee|0)==25){t=j()|0;break}if(Te=S[ke>>0]|0,!(!(S[O>>0]|0)||!((Te&1?e[ke+4>>2]|0:(Te&255)>>>1)|0))&&(Z=e[oe>>2]|0,(Z-ie|0)<160)&&(Te=e[P>>2]|0,e[oe>>2]=Z+4,e[Z>>2]=Te),g=0,d=+lt(3,t|0,e[$>>2]|0,c|0),Te=g,g=0,Te&1)Ee=26;else{if(B[h>>3]=d,V0(ke,ie,e[oe>>2]|0,c),l){if(t=e[l+12>>2]|0,(t|0)==(e[l+16>>2]|0)){if(g=0,t=ge(e[(e[l>>2]|0)+36>>2]|0,l|0)|0,Te=g,g=0,Te&1){Ee=26;break}}else t=e[t>>2]|0;(t|0)==-1?(e[r>>2]=0,l=1):l=0}else l=1;do if(w){if(t=e[w+12>>2]|0,(t|0)==(e[w+16>>2]|0)){if(g=0,t=ge(e[(e[w>>2]|0)+36>>2]|0,w|0)|0,Te=g,g=0,Te&1){Ee=26;break e}}else t=e[t>>2]|0;if((t|0)!=-1){if(l)break;Ee=53;break}else{e[o>>2]=0,Ee=51;break}}else Ee=51;while(!1);return(Ee|0)==51&&l&&(Ee=53),(Ee|0)==53&&(e[c>>2]=e[c>>2]|2),Te=e[r>>2]|0,de(ce),de(ke),b=ne,Te|0}}while(!1);return(Ee|0)==26&&(t=j()|0),de(ce),de(ke),le(t|0),0}function q0(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;return h=b,b=b+16|0,d=h,e[d>>2]=c,c=ai(o)|0,o=Mn(t,r,l,d)|0,c|0&&(g=0,ge(75,c|0)|0,d=g,g=0,d&1)&&(d=j(0)|0,$t(d)),b=h,o|0}function Z4(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;if(c=b,b=b+16|0,h=c,e[h>>2]=l,l=ai(r)|0,g=0,r=Ve(37,t|0,o|0,h|0)|0,t=g,g=0,t&1)r=j()|0,l|0&&(g=0,ge(75,l|0)|0,h=g,g=0,h&1)&&(h=j(0)|0,$t(h)),le(r|0);else return l|0&&(g=0,ge(75,l|0)|0,h=g,g=0,h&1)&&(h=j(0)|0,$t(h)),b=c,r|0;return 0}function Hi(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0;N=b,b=b+16|0,k=N,d=e[t>>2]|0;e:do if(!d)d=0;else{if(R=r,C=l-R>>2,D=c+12|0,w=e[D>>2]|0,C=(w|0)>(C|0)?w-C|0:0,w=o,R=w-R|0,c=R>>2,(R|0)>0&&(Yt[e[(e[d>>2]|0)+48>>2]&63](d,r,c)|0)!=(c|0)){e[t>>2]=0,d=0;break}do if((C|0)>0)if(gr(k,C,h),g=0,c=Ve(e[(e[d>>2]|0)+48>>2]|0,d|0,(S[k>>0]&1?e[k+8>>2]|0:k+4|0)|0,C|0)|0,R=g,g=0,R&1&&(R=j()|0,Pt(k),le(R|0)),(c|0)==(C|0)){Pt(k);break}else{e[t>>2]=0,Pt(k),d=0;break e}while(!1);if(R=l-w|0,l=R>>2,(R|0)>0&&(Yt[e[(e[d>>2]|0)+48>>2]&63](d,o,l)|0)!=(l|0)){e[t>>2]=0,d=0;break}e[D>>2]=0}while(!1);return b=N,d|0}function fi(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;h=e[t>>2]|0;do if(h){if((e[h+12>>2]|0)==(e[h+16>>2]|0))if((Dt[e[(e[h>>2]|0)+36>>2]&127](h)|0)==-1){e[t>>2]=0,h=0;break}else{h=e[t>>2]|0;break}}else h=0;while(!1);d=(h|0)==0,h=e[r>>2]|0;do if(h){if((e[h+12>>2]|0)==(e[h+16>>2]|0)&&(Dt[e[(e[h>>2]|0)+36>>2]&127](h)|0)==-1){e[r>>2]=0,U=11;break}d?U=13:U=12}else U=11;while(!1);(U|0)==11&&(d?U=12:(h=0,U=13));e:do if((U|0)==12)e[o>>2]=e[o>>2]|6,h=0;else if((U|0)==13){if(d=e[t>>2]|0,w=e[d+12>>2]|0,(w|0)==(e[d+16>>2]|0)?d=Dt[e[(e[d>>2]|0)+36>>2]&127](d)|0:d=F[w>>0]|0,w=d&255,w<<24>>24>-1&&(_=l+8|0,(E[(e[_>>2]|0)+(d<<24>>24<<1)>>1]&2048)!=0)){for(D=(Yt[e[(e[l>>2]|0)+36>>2]&63](l,w,0)|0)<<24>>24,d=e[t>>2]|0,w=d+12|0,C=e[w>>2]|0,(C|0)==(e[d+16>>2]|0)?(Dt[e[(e[d>>2]|0)+40>>2]&127](d)|0,N=c,k=h,c=h,h=D):(e[w>>2]=C+1,N=c,k=h,c=h,h=D);;){h=h+-48|0,R=N+-1|0,d=e[t>>2]|0;do if(d){if((e[d+12>>2]|0)==(e[d+16>>2]|0))if((Dt[e[(e[d>>2]|0)+36>>2]&127](d)|0)==-1){e[t>>2]=0,d=0;break}else{d=e[t>>2]|0;break}}else d=0;while(!1);if(C=(d|0)==0,c?(e[c+12>>2]|0)==(e[c+16>>2]|0)?(Dt[e[(e[c>>2]|0)+36>>2]&127](c)|0)==-1?(e[r>>2]=0,w=0,c=0):(w=k,c=k):w=k:(w=k,c=0),d=e[t>>2]|0,!((N|0)>1&(C^(c|0)==0)))break;if(C=e[d+12>>2]|0,(C|0)==(e[d+16>>2]|0)?d=Dt[e[(e[d>>2]|0)+36>>2]&127](d)|0:d=F[C>>0]|0,C=d&255,C<<24>>24<=-1||!(E[(e[_>>2]|0)+(d<<24>>24<<1)>>1]&2048))break e;if(h=((Yt[e[(e[l>>2]|0)+36>>2]&63](l,C,0)|0)<<24>>24)+(h*10|0)|0,d=e[t>>2]|0,C=d+12|0,D=e[C>>2]|0,(D|0)==(e[d+16>>2]|0)){Dt[e[(e[d>>2]|0)+40>>2]&127](d)|0,N=R,k=w;continue}else{e[C>>2]=D+1,N=R,k=w;continue}}do if(d){if((e[d+12>>2]|0)==(e[d+16>>2]|0))if((Dt[e[(e[d>>2]|0)+36>>2]&127](d)|0)==-1){e[t>>2]=0,d=0;break}else{d=e[t>>2]|0;break}}else d=0;while(!1);d=(d|0)==0;do if(w){if((e[w+12>>2]|0)==(e[w+16>>2]|0)&&(Dt[e[(e[w>>2]|0)+36>>2]&127](w)|0)==-1){e[r>>2]=0,U=50;break}if(d)break e}else U=50;while(!1);if((U|0)==50&&!d)break;e[o>>2]=e[o>>2]|2;break}e[o>>2]=e[o>>2]|4,h=0}while(!1);return h|0}function hi(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;h=e[t>>2]|0;do if(h)if(d=e[h+12>>2]|0,(d|0)==(e[h+16>>2]|0)?h=Dt[e[(e[h>>2]|0)+36>>2]&127](h)|0:h=e[d>>2]|0,(h|0)==-1){e[t>>2]=0,w=1;break}else{w=(e[t>>2]|0)==0;break}else w=1;while(!1);d=e[r>>2]|0;do if(d)if(h=e[d+12>>2]|0,(h|0)==(e[d+16>>2]|0)?h=Dt[e[(e[d>>2]|0)+36>>2]&127](d)|0:h=e[h>>2]|0,(h|0)!=-1)if(w){_=17;break}else{_=16;break}else{e[r>>2]=0,_=14;break}else _=14;while(!1);(_|0)==14&&(w?_=16:(d=0,_=17));e:do if((_|0)==16)e[o>>2]=e[o>>2]|6,h=0;else if((_|0)==17){if(h=e[t>>2]|0,w=e[h+12>>2]|0,(w|0)==(e[h+16>>2]|0)?h=Dt[e[(e[h>>2]|0)+36>>2]&127](h)|0:h=e[w>>2]|0,!(Yt[e[(e[l>>2]|0)+12>>2]&63](l,2048,h)|0)){e[o>>2]=e[o>>2]|4,h=0;break}for(h=(Yt[e[(e[l>>2]|0)+52>>2]&63](l,h,0)|0)<<24>>24,w=e[t>>2]|0,C=w+12|0,D=e[C>>2]|0,(D|0)==(e[w+16>>2]|0)?(Dt[e[(e[w>>2]|0)+40>>2]&127](w)|0,N=c,k=d,C=d):(e[C>>2]=D+4,N=c,k=d,C=d);;){h=h+-48|0,R=N+-1|0,d=e[t>>2]|0;do if(d)if(w=e[d+12>>2]|0,(w|0)==(e[d+16>>2]|0)?d=Dt[e[(e[d>>2]|0)+36>>2]&127](d)|0:d=e[w>>2]|0,(d|0)==-1){e[t>>2]=0,D=1;break}else{D=(e[t>>2]|0)==0;break}else D=1;while(!1);do if(C)if(d=e[C+12>>2]|0,(d|0)==(e[C+16>>2]|0)?d=Dt[e[(e[C>>2]|0)+36>>2]&127](C)|0:d=e[d>>2]|0,(d|0)==-1){e[r>>2]=0,C=0,c=0,d=1;break}else{C=k,c=k,d=(k|0)==0;break}else C=k,c=0,d=1;while(!1);if(w=e[t>>2]|0,!((N|0)>1&(D^d)))break;if(d=e[w+12>>2]|0,(d|0)==(e[w+16>>2]|0)?d=Dt[e[(e[w>>2]|0)+36>>2]&127](w)|0:d=e[d>>2]|0,!(Yt[e[(e[l>>2]|0)+12>>2]&63](l,2048,d)|0))break e;if(h=((Yt[e[(e[l>>2]|0)+52>>2]&63](l,d,0)|0)<<24>>24)+(h*10|0)|0,d=e[t>>2]|0,w=d+12|0,D=e[w>>2]|0,(D|0)==(e[d+16>>2]|0)){Dt[e[(e[d>>2]|0)+40>>2]&127](d)|0,N=R,k=C,C=c;continue}else{e[w>>2]=D+4,N=R,k=C,C=c;continue}}do if(w)if(d=e[w+12>>2]|0,(d|0)==(e[w+16>>2]|0)?d=Dt[e[(e[w>>2]|0)+36>>2]&127](w)|0:d=e[d>>2]|0,(d|0)==-1){e[t>>2]=0,w=1;break}else{w=(e[t>>2]|0)==0;break}else w=1;while(!1);do if(C)if(d=e[C+12>>2]|0,(d|0)==(e[C+16>>2]|0)?d=Dt[e[(e[C>>2]|0)+36>>2]&127](C)|0:d=e[d>>2]|0,(d|0)!=-1){if(w)break e;break}else{e[r>>2]=0,_=60;break}else _=60;while(!1);if((_|0)==60&&!w)break;e[o>>2]=e[o>>2]|2}while(!1);return h|0}function J4(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0;h=t+4|0,l=(e[h>>2]|0)!=189,w=e[t>>2]|0,d=w,c=(e[o>>2]|0)-d|0,c=c>>>0<2147483647?c<<1:-1,d=(e[r>>2]|0)-d|0,w=Gi(l?w:0,c)|0,w||kn();do if(l)e[t>>2]=w,C=w;else if(l=e[t>>2]|0,e[t>>2]=w,l)if(g=0,ue(e[h>>2]|0,l|0),w=g,g=0,w&1)w=j(0)|0,$t(w);else{C=e[t>>2]|0;break}else C=w;while(!1);e[h>>2]=201,e[r>>2]=C+d,e[o>>2]=(e[t>>2]|0)+c}function e3(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0;h=t+4|0,l=(e[h>>2]|0)!=189,w=e[t>>2]|0,d=w,c=(e[o>>2]|0)-d|0,c=c>>>0<2147483647?c<<1:-1,d=(e[r>>2]|0)-d>>2,w=Gi(l?w:0,c)|0,w||kn();do if(l)e[t>>2]=w,C=w;else if(l=e[t>>2]|0,e[t>>2]=w,l)if(g=0,ue(e[h>>2]|0,l|0),w=g,g=0,w&1)w=j(0)|0,$t(w);else{C=e[t>>2]|0;break}else C=w;while(!1);e[h>>2]=201,e[r>>2]=C+(d<<2),e[o>>2]=(e[t>>2]|0)+(c>>>2<<2)}function t3(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0;h=r,l=S[t>>0]|0,l&1?(l=e[t>>2]|0,c=(l&-2)+-1|0,C=e[t+4>>2]|0,l=l&255):(c=10,C=(l&255)>>>1),w=o-h|0;do if((o|0)!=(r|0)){if((c-C|0)>>>0>>0&&(pr(t,c,C+w-c|0,C,C,0,0),l=S[t>>0]|0),l&1?d=e[t+8>>2]|0:d=t+1|0,h=o+(C-h)|0,(r|0)!=(o|0))for(l=r,c=d+C|0;S[c>>0]=S[l>>0]|0,l=l+1|0,(l|0)!=(o|0);)c=c+1|0;if(S[d+h>>0]=0,l=C+w|0,S[t>>0]&1){e[t+4>>2]=l;break}else{S[t>>0]=l<<1;break}}while(!1);return t|0}function i3(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0;h=t+4|0,l=(e[h>>2]|0)!=189,w=e[t>>2]|0,d=w,c=(e[o>>2]|0)-d|0,c=c>>>0<2147483647?c<<1:-1,d=(e[r>>2]|0)-d>>2,w=Gi(l?w:0,c)|0,w||kn();do if(l)e[t>>2]=w,C=w;else if(l=e[t>>2]|0,e[t>>2]=w,l)if(g=0,ue(e[h>>2]|0,l|0),w=g,g=0,w&1)w=j(0)|0,$t(w);else{C=e[t>>2]|0;break}else C=w;while(!1);e[h>>2]=201,e[r>>2]=C+(d<<2),e[o>>2]=(e[t>>2]|0)+(c>>>2<<2)}function n3(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0;h=r,l=S[t>>0]|0,l&1?(l=e[t>>2]|0,c=(l&-2)+-1|0,C=e[t+4>>2]|0,l=l&255):(c=1,C=(l&255)>>>1),w=o-h>>2;do if(w){if((c-C|0)>>>0>>0&&(Ws(t,c,C+w-c|0,C,C,0,0),l=S[t>>0]|0),l&1?d=e[t+8>>2]|0:d=t+4|0,h=C+((o-h|0)>>>2)|0,(r|0)!=(o|0))for(l=r,c=d+(C<<2)|0;e[c>>2]=e[l>>2],l=l+4|0,(l|0)!=(o|0);)c=c+4|0;if(e[d+(h<<2)>>2]=0,l=C+w|0,S[t>>0]&1){e[t+4>>2]=l;break}else{S[t>>0]=l<<1;break}}while(!1);return t|0}function r3(t,r){t=t|0,r=r|0;var o=0;e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,S[t+128>>0]=0;do if(r)if(g=0,Ae(125,t|0,r|0),o=g,g=0,o&1)o=j()|0,yr(t),le(o|0);else{no(t,r);break}while(!1)}function s3(t,r){t=t|0,r=r|0,w0(t,r,x0(43148)|0)}function o3(t,r){t=t|0,r=r|0,w0(t,r,x0(43188)|0)}function l3(t,r){t=t|0,r=r|0,w0(t,r,x0(44220)|0)}function u3(t,r){t=t|0,r=r|0,w0(t,r,x0(44212)|0)}function c3(t,r){t=t|0,r=r|0,w0(t,r,x0(44280)|0)}function f3(t,r){t=t|0,r=r|0,w0(t,r,x0(44288)|0)}function h3(t,r){t=t|0,r=r|0,w0(t,r,x0(44344)|0)}function d3(t,r){t=t|0,r=r|0,w0(t,r,x0(44352)|0)}function p3(t,r){t=t|0,r=r|0,w0(t,r,x0(44360)|0)}function m3(t,r){t=t|0,r=r|0,w0(t,r,x0(44368)|0)}function g3(t,r){t=t|0,r=r|0,w0(t,r,x0(43260)|0)}function S3(t,r){t=t|0,r=r|0,w0(t,r,x0(43332)|0)}function A3(t,r){t=t|0,r=r|0,w0(t,r,x0(43392)|0)}function v3(t,r){t=t|0,r=r|0,w0(t,r,x0(43452)|0)}function x3(t,r){t=t|0,r=r|0,w0(t,r,x0(43764)|0)}function w3(t,r){t=t|0,r=r|0,w0(t,r,x0(43828)|0)}function y3(t,r){t=t|0,r=r|0,w0(t,r,x0(43892)|0)}function C3(t,r){t=t|0,r=r|0,w0(t,r,x0(43956)|0)}function T3(t,r){t=t|0,r=r|0,w0(t,r,x0(43992)|0)}function I3(t,r){t=t|0,r=r|0,w0(t,r,x0(44028)|0)}function E3(t,r){t=t|0,r=r|0,w0(t,r,x0(44064)|0)}function k3(t,r){t=t|0,r=r|0,w0(t,r,x0(44100)|0)}function D3(t,r){t=t|0,r=r|0,w0(t,r,x0(43544)|0)}function b3(t,r){t=t|0,r=r|0,w0(t,r,x0(43636)|0)}function N3(t,r){t=t|0,r=r|0,w0(t,r,x0(43668)|0)}function F3(t,r){t=t|0,r=r|0,w0(t,r,x0(43700)|0)}function R3(t,r){t=t|0,r=r|0,w0(t,r,x0(44140)|0)}function M3(t,r){t=t|0,r=r|0,w0(t,r,x0(44180)|0)}function yr(t){t=t|0;var r=0,o=0,l=0;o=e[t>>2]|0;do if(o){if(l=t+4|0,r=e[l>>2]|0,(r|0)!=(o|0)){do r=r+-4|0;while((r|0)!=(o|0));e[l>>2]=r}if((t+16|0)==(o|0)){S[t+128>>0]=0;break}else{he(o);break}}while(!1)}function _3(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0;if(d=t+4|0,o=e[d>>2]|0,l=e[t>>2]|0,c=o-l>>2,c>>>0>=r>>>0){if(c>>>0>r>>>0&&(h=l+(r<<2)|0,(o|0)!=(h|0))){do o=o+-4|0;while((o|0)!=(h|0));e[d>>2]=o}}else Y3(t,r-c|0)}function P3(t,r){t=t|0,r=r|0;var o=0;return o=e[t+8>>2]|0,(e[t+12>>2]|0)-o>>2>>>0>r>>>0?o=(e[o+(r<<2)>>2]|0)!=0:o=0,o|0}function L3(t){t=t|0;var r=0,o=0;o=t+4|0,r=e[o>>2]|0,o=e[o+4>>2]|0,t=(e[t>>2]|0)+(o>>1)|0,o&1&&(r=e[(e[t>>2]|0)+r>>2]|0),Mt[r&255](t)}function O3(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0,D=0;e[o>>2]=t,e[h>>2]=l,w&2?(c-l|0)<3?t=1:(e[h>>2]=l+1,S[l>>0]=-17,C=e[h>>2]|0,e[h>>2]=C+1,S[C>>0]=-69,C=e[h>>2]|0,e[h>>2]=C+1,S[C>>0]=-65,C=4):C=4;e:do if((C|0)==4)if(D=r,t=e[o>>2]|0,t>>>0>>0)for(;;){if(w=E[t>>1]|0,C=w&65535,C>>>0>d>>>0){t=2;break e}do if((w&65535)<128){if(t=e[h>>2]|0,(c-t|0)<1){t=1;break e}e[h>>2]=t+1,S[t>>0]=w}else{if((w&65535)<2048){if(t=e[h>>2]|0,(c-t|0)<2){t=1;break e}e[h>>2]=t+1,S[t>>0]=C>>>6|192,l=e[h>>2]|0,e[h>>2]=l+1,S[l>>0]=C&63|128;break}if((w&65535)<55296){if(t=e[h>>2]|0,(c-t|0)<3){t=1;break e}e[h>>2]=t+1,S[t>>0]=C>>>12|224,l=e[h>>2]|0,e[h>>2]=l+1,S[l>>0]=C>>>6&63|128,l=e[h>>2]|0,e[h>>2]=l+1,S[l>>0]=C&63|128;break}if((w&65535)>=56320){if((w&65535)<57344){t=2;break e}if(t=e[h>>2]|0,(c-t|0)<3){t=1;break e}e[h>>2]=t+1,S[t>>0]=C>>>12|224,l=e[h>>2]|0,e[h>>2]=l+1,S[l>>0]=C>>>6&63|128,l=e[h>>2]|0,e[h>>2]=l+1,S[l>>0]=C&63|128;break}if((D-t|0)<4){t=1;break e}if(t=t+2|0,w=M[t>>1]|0,(w&64512|0)!=56320){t=2;break e}if((c-(e[h>>2]|0)|0)<4){t=1;break e}if(l=C&960,((l<<10)+65536|C<<10&64512|w&1023)>>>0>d>>>0){t=2;break e}e[o>>2]=t,t=(l>>>6)+1|0,l=e[h>>2]|0,e[h>>2]=l+1,S[l>>0]=t>>>2|240,l=e[h>>2]|0,e[h>>2]=l+1,S[l>>0]=C>>>2&15|t<<4&48|128,l=e[h>>2]|0,e[h>>2]=l+1,S[l>>0]=C<<4&48|w>>>6&15|128,C=e[h>>2]|0,e[h>>2]=C+1,S[C>>0]=w&63|128}while(!1);if(t=(e[o>>2]|0)+2|0,e[o>>2]=t,t>>>0>=r>>>0){t=0;break}}else t=0;while(!1);return t|0}function $3(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0,D=0,k=0,N=0,R=0,_=0;e[o>>2]=t,e[h>>2]=l,w&4?(t=e[o>>2]|0,w=r,(w-t|0)>2&&(S[t>>0]|0)==-17&&(S[t+1>>0]|0)==-69&&(S[t+2>>0]|0)==-65?(e[o>>2]=t+3,C=e[h>>2]|0):C=l):(C=l,w=r),R=c,l=e[o>>2]|0,t=l>>>0>>0;e:do if(t&C>>>0>>0)for(;;){if(t=S[l>>0]|0,k=t&255,k>>>0>d>>>0){t=2;break e}do if(t<<24>>24>-1)E[C>>1]=t&255,e[o>>2]=l+1;else{if((t&255)<194){t=2;break e}if((t&255)<224){if((w-l|0)<2){t=1;break e}if(t=F[l+1>>0]|0,(t&192|0)!=128){t=2;break e}if(t=t&63|k<<6&1984,t>>>0>d>>>0){t=2;break e}E[C>>1]=t,e[o>>2]=l+2;break}if((t&255)<240){if((w-l|0)<3){t=1;break e}switch(D=S[l+1>>0]|0,t=S[l+2>>0]|0,k|0){case 224:{if((D&-32)<<24>>24!=-96){t=2;break e}break}case 237:{if((D&-32)<<24>>24!=-128){t=2;break e}break}default:if((D&-64)<<24>>24!=-128){t=2;break e}}if(t=t&255,(t&192|0)!=128){t=2;break e}if(t=(D&255)<<6&4032|k<<12|t&63,(t&65535)>>>0>d>>>0){t=2;break e}E[C>>1]=t,e[o>>2]=l+3;break}if((t&255)>=245){t=2;break e}if((w-l|0)<4){t=1;break e}switch(D=S[l+1>>0]|0,t=S[l+2>>0]|0,l=S[l+3>>0]|0,k|0){case 240:{if((D+112&255)>=48){t=2;break e}break}case 244:{if((D&-16)<<24>>24!=-128){t=2;break e}break}default:if((D&-64)<<24>>24!=-128){t=2;break e}}if(N=t&255,(N&192|0)!=128){t=2;break e}if(t=l&255,(t&192|0)!=128){t=2;break e}if((R-C|0)<4){t=1;break e}if(k=k&7,l=D&255,D=N<<6,t=t&63,(l<<12&258048|k<<18|D&4032|t)>>>0>d>>>0){t=2;break e}E[C>>1]=l<<2&60|N>>>4&3|((l>>>4&3|k<<2)<<6)+16320|55296,N=C+2|0,e[h>>2]=N,E[N>>1]=t|D&960|56320,e[o>>2]=(e[o>>2]|0)+4}while(!1);if(C=(e[h>>2]|0)+2|0,e[h>>2]=C,l=e[o>>2]|0,t=l>>>0>>0,!(t&C>>>0>>0)){_=39;break}}else _=39;while(!1);return(_|0)==39&&(t=t&1),t|0}function B3(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0;N=r,c&4|0&&(N-t|0)>2&&(S[t>>0]|0)==-17&&(S[t+1>>0]|0)==-69?c=(S[t+2>>0]|0)==-65?t+3|0:t:c=t;e:do if((o|0)!=0&c>>>0>>0){k=c,h=0;t:for(;;){if(c=S[k>>0]|0,D=c&255,D>>>0>l>>>0){c=k,h=42;break e}do if(c<<24>>24>-1)c=k+1|0;else{if((c&255)<194){c=k,h=42;break e}if((c&255)<224){if((N-k|0)<2){c=k,h=42;break e}if(c=F[k+1>>0]|0,(c&192|0)!=128){c=k,h=42;break e}if((c&63|D<<6&1984)>>>0>l>>>0){c=k,h=42;break e}c=k+2|0;break}if((c&255)<240){if(c=k,(N-c|0)<3){c=k,h=42;break e}switch(w=S[k+1>>0]|0,d=S[k+2>>0]|0,D|0){case 224:{if((w&-32)<<24>>24!=-96){h=20;break t}break}case 237:{if((w&-32)<<24>>24!=-128){h=22;break t}break}default:if((w&-64)<<24>>24!=-128){h=24;break t}}if(c=d&255,(c&192|0)!=128){c=k,h=42;break e}if(((w&255)<<6&4032|D<<12&61440|c&63)>>>0>l>>>0){c=k,h=42;break e}c=k+3|0;break}if((c&255)>=245){c=k,h=42;break e}if(c=k,(o-h|0)>>>0<2|(N-c|0)<4){c=k,h=42;break e}switch(C=S[k+1>>0]|0,d=S[k+2>>0]|0,w=S[k+3>>0]|0,D|0){case 240:{if((C+112&255)>=48){h=32;break t}break}case 244:{if((C&-16)<<24>>24!=-128){h=34;break t}break}default:if((C&-64)<<24>>24!=-128){h=36;break t}}if(d=d&255,(d&192|0)!=128){c=k,h=42;break e}if(c=w&255,(c&192|0)!=128){c=k,h=42;break e}if(((C&255)<<12&258048|D<<18&1835008|d<<6&4032|c&63)>>>0>l>>>0){c=k,h=42;break e}c=k+4|0,h=h+1|0}while(!1);if(h=h+1|0,h>>>0>>0&c>>>0>>0)k=c;else{h=42;break e}}if((h|0)==20){c=c-t|0;break}else if((h|0)==22){c=c-t|0;break}else if((h|0)==24){c=c-t|0;break}else if((h|0)==32){c=c-t|0;break}else if((h|0)==34){c=c-t|0;break}else if((h|0)==36){c=c-t|0;break}}else h=42;while(!1);return(h|0)==42&&(c=c-t|0),c|0}function V3(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0,D=0;e[o>>2]=t,e[h>>2]=l,D=c,w&2?(D-l|0)<3?t=1:(e[h>>2]=l+1,S[l>>0]=-17,C=e[h>>2]|0,e[h>>2]=C+1,S[C>>0]=-69,C=e[h>>2]|0,e[h>>2]=C+1,S[C>>0]=-65,C=4):C=4;e:do if((C|0)==4)if(t=e[o>>2]|0,t>>>0>>0)for(;;){if(w=e[t>>2]|0,w>>>0>d>>>0|(w&-2048|0)==55296){t=2;break e}do if(w>>>0>=128){if(w>>>0<2048){if(t=e[h>>2]|0,(D-t|0)<2){t=1;break e}e[h>>2]=t+1,S[t>>0]=w>>>6|192,C=e[h>>2]|0,e[h>>2]=C+1,S[C>>0]=w&63|128;break}if(t=e[h>>2]|0,c=D-t|0,w>>>0<65536){if((c|0)<3){t=1;break e}e[h>>2]=t+1,S[t>>0]=w>>>12|224,C=e[h>>2]|0,e[h>>2]=C+1,S[C>>0]=w>>>6&63|128,C=e[h>>2]|0,e[h>>2]=C+1,S[C>>0]=w&63|128;break}else{if((c|0)<4){t=1;break e}e[h>>2]=t+1,S[t>>0]=w>>>18|240,C=e[h>>2]|0,e[h>>2]=C+1,S[C>>0]=w>>>12&63|128,C=e[h>>2]|0,e[h>>2]=C+1,S[C>>0]=w>>>6&63|128,C=e[h>>2]|0,e[h>>2]=C+1,S[C>>0]=w&63|128;break}}else{if(t=e[h>>2]|0,(D-t|0)<1){t=1;break e}e[h>>2]=t+1,S[t>>0]=w}while(!1);if(t=(e[o>>2]|0)+4|0,e[o>>2]=t,t>>>0>=r>>>0){t=0;break}}else t=0;while(!1);return t|0}function U3(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0;var C=0,D=0,k=0,N=0,R=0,_=0;e[o>>2]=t,e[h>>2]=l,w&4?(t=e[o>>2]|0,w=r,(w-t|0)>2&&(S[t>>0]|0)==-17&&(S[t+1>>0]|0)==-69&&(S[t+2>>0]|0)==-65&&(e[o>>2]=t+3,l=e[h>>2]|0),R=w):R=r,w=e[o>>2]|0,t=w>>>0>>0;e:do if(t&l>>>0>>0)for(;;){t=S[w>>0]|0,N=t&255;do if(t<<24>>24>-1){if(N>>>0>d>>>0){t=2;break e}e[l>>2]=N,e[o>>2]=w+1}else{if((t&255)<194){t=2;break e}if((t&255)<224){if((R-w|0)<2){t=1;break e}if(t=F[w+1>>0]|0,(t&192|0)!=128){t=2;break e}if(t=t&63|N<<6&1984,t>>>0>d>>>0){t=2;break e}e[l>>2]=t,e[o>>2]=w+2;break}if((t&255)<240){if((R-w|0)<3){t=1;break e}switch(C=S[w+1>>0]|0,t=S[w+2>>0]|0,N|0){case 224:{if((C&-32)<<24>>24!=-96){t=2;break e}break}case 237:{if((C&-32)<<24>>24!=-128){t=2;break e}break}default:if((C&-64)<<24>>24!=-128){t=2;break e}}if(t=t&255,(t&192|0)!=128){t=2;break e}if(t=(C&255)<<6&4032|N<<12&61440|t&63,t>>>0>d>>>0){t=2;break e}e[l>>2]=t,e[o>>2]=w+3;break}if((t&255)>=245){t=2;break e}if((R-w|0)<4){t=1;break e}switch(k=S[w+1>>0]|0,t=S[w+2>>0]|0,C=S[w+3>>0]|0,N|0){case 240:{if((k+112&255)>=48){t=2;break e}break}case 244:{if((k&-16)<<24>>24!=-128){t=2;break e}break}default:if((k&-64)<<24>>24!=-128){t=2;break e}}if(D=t&255,(D&192|0)!=128){t=2;break e}if(t=C&255,(t&192|0)!=128){t=2;break e}if(t=(k&255)<<12&258048|N<<18&1835008|D<<6&4032|t&63,t>>>0>d>>>0){t=2;break e}e[l>>2]=t,e[o>>2]=w+4}while(!1);if(l=(e[h>>2]|0)+4|0,e[h>>2]=l,w=e[o>>2]|0,t=w>>>0>>0,!(t&l>>>0>>0)){_=38;break}}else _=38;while(!1);return(_|0)==38&&(t=t&1),t|0}function z3(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0;N=r,c&4|0&&(N-t|0)>2&&(S[t>>0]|0)==-17&&(S[t+1>>0]|0)==-69?c=(S[t+2>>0]|0)==-65?t+3|0:t:c=t;e:do if((o|0)!=0&c>>>0>>0){D=c,k=0;t:for(;;){c=S[D>>0]|0,C=c&255;do if(c<<24>>24>-1){if(C>>>0>l>>>0){c=D,h=42;break e}c=D+1|0}else{if((c&255)<194){c=D,h=42;break e}if((c&255)<224){if((N-D|0)<2){c=D,h=42;break e}if(c=F[D+1>>0]|0,(c&192|0)!=128){c=D,h=42;break e}if((c&63|C<<6&1984)>>>0>l>>>0){c=D,h=42;break e}c=D+2|0;break}if((c&255)<240){if(c=D,(N-c|0)<3){c=D,h=42;break e}switch(d=S[D+1>>0]|0,h=S[D+2>>0]|0,C|0){case 224:{if((d&-32)<<24>>24!=-96){h=20;break t}break}case 237:{if((d&-32)<<24>>24!=-128){h=22;break t}break}default:if((d&-64)<<24>>24!=-128){h=24;break t}}if(c=h&255,(c&192|0)!=128){c=D,h=42;break e}if(((d&255)<<6&4032|C<<12&61440|c&63)>>>0>l>>>0){c=D,h=42;break e}c=D+3|0;break}if((c&255)>=245){c=D,h=42;break e}if(c=D,(N-c|0)<4){c=D,h=42;break e}switch(w=S[D+1>>0]|0,h=S[D+2>>0]|0,d=S[D+3>>0]|0,C|0){case 240:{if((w+112&255)>=48){h=32;break t}break}case 244:{if((w&-16)<<24>>24!=-128){h=34;break t}break}default:if((w&-64)<<24>>24!=-128){h=36;break t}}if(h=h&255,(h&192|0)!=128){c=D,h=42;break e}if(c=d&255,(c&192|0)!=128){c=D,h=42;break e}if(((w&255)<<12&258048|C<<18&1835008|h<<6&4032|c&63)>>>0>l>>>0){c=D,h=42;break e}c=D+4|0}while(!1);if(k=k+1|0,k>>>0>>0&c>>>0>>0)D=c;else{h=42;break e}}if((h|0)==20){c=c-t|0;break}else if((h|0)==22){c=c-t|0;break}else if((h|0)==24){c=c-t|0;break}else if((h|0)==32){c=c-t|0;break}else if((h|0)==34){c=c-t|0;break}else if((h|0)==36){c=c-t|0;break}}else h=42;while(!1);return(h|0)==42&&(c=c-t|0),c|0}function G3(t){t=t|0,de(45196),de(45184),de(45172),de(45160),de(45148),de(45136),de(45124),de(45112),de(45100),de(45088),de(45076),de(45064),de(45052),de(45040)}function q3(t){t=t|0,Pt(45368),Pt(45356),Pt(45344),Pt(45332),Pt(45320),Pt(45308),Pt(45296),Pt(45284),Pt(45272),Pt(45260),Pt(45248),Pt(45236),Pt(45224),Pt(45212)}function W3(t){t=t|0,de(46e3),de(45988),de(45976),de(45964),de(45952),de(45940),de(45928),de(45916),de(45904),de(45892),de(45880),de(45868),de(45856),de(45844),de(45832),de(45820),de(45808),de(45796),de(45784),de(45772),de(45760),de(45748),de(45736),de(45724)}function H3(t){t=t|0,Pt(46292),Pt(46280),Pt(46268),Pt(46256),Pt(46244),Pt(46232),Pt(46220),Pt(46208),Pt(46196),Pt(46184),Pt(46172),Pt(46160),Pt(46148),Pt(46136),Pt(46124),Pt(46112),Pt(46100),Pt(46088),Pt(46076),Pt(46064),Pt(46052),Pt(46040),Pt(46028),Pt(46016)}function Q3(t){t=t|0,de(47104),de(47092),de(47080),de(47068),de(47056),de(47044),de(47032),de(47020),de(47008),de(46996),de(46984),de(46972),de(46960),de(46948),de(46936),de(46924),de(46912),de(46900),de(46888),de(46876),de(46864),de(46852),de(46840),de(46828)}function K3(t){t=t|0,Pt(47396),Pt(47384),Pt(47372),Pt(47360),Pt(47348),Pt(47336),Pt(47324),Pt(47312),Pt(47300),Pt(47288),Pt(47276),Pt(47264),Pt(47252),Pt(47240),Pt(47228),Pt(47216),Pt(47204),Pt(47192),Pt(47180),Pt(47168),Pt(47156),Pt(47144),Pt(47132),Pt(47120)}function Y3(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;C=b,b=b+32|0,w=C,h=e[t+8>>2]|0,o=e[t+4>>2]|0,h-o>>2>>>0>>0?(l=e[t>>2]|0,d=o-l>>2,c=d+r|0,c>>>0>1073741823&&pi(t),o=h-l|0,o>>2>>>0<536870911?(o=o>>1,o=o>>>0>>0?c:o):o=1073741823,j3(w,o,d,t+16|0),d=w+8|0,h=e[d>>2]|0,Jt(h|0,0,r<<2|0)|0,e[d>>2]=h+(r<<2),X3(t,w),Z3(w)):no(t,r),b=C}function no(t,r){t=t|0,r=r|0;var o=0;o=t+4|0,t=r,r=e[o>>2]|0;do e[r>>2]=0,r=(e[o>>2]|0)+4|0,e[o>>2]=r,t=t+-1|0;while(t|0)}function j3(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0;e[t+12>>2]=0,e[t+16>>2]=l;do if(r)if(c=l+112|0,r>>>0<29&(S[c>>0]|0)==0){S[c>>0]=1;break}else{l=Xe(r<<2)|0;break}else l=0;while(!1);e[t>>2]=l,o=l+(o<<2)|0,e[t+8>>2]=o,e[t+4>>2]=o,e[t+12>>2]=l+(r<<2)}function X3(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0;l=e[t>>2]|0,h=t+4|0,o=r+4|0,c=(e[h>>2]|0)-l|0,d=(e[o>>2]|0)+(0-(c>>2)<<2)|0,e[o>>2]=d,o0(d|0,l|0,c|0)|0,c=e[t>>2]|0,e[t>>2]=e[o>>2],e[o>>2]=c,c=r+8|0,l=e[h>>2]|0,e[h>>2]=e[c>>2],e[c>>2]=l,c=t+8|0,t=r+12|0,l=e[c>>2]|0,e[c>>2]=e[t>>2],e[t>>2]=l,e[r>>2]=e[o>>2]}function Z3(t){t=t|0;var r=0,o=0,l=0;if(o=e[t+4>>2]|0,l=t+8|0,r=e[l>>2]|0,(r|0)!=(o|0)){do r=r+-4|0;while((r|0)!=(o|0));e[l>>2]=r}o=e[t>>2]|0;do if(o)if(r=e[t+16>>2]|0,(r|0)==(o|0)){S[r+112>>0]=0;break}else{he(o);break}while(!1)}function J3(t,r){t=t|0,r=r|0;var o=0;r>>>0>1073741823&&pi(t),o=t+128|0,r>>>0<29&(S[o>>0]|0)==0?(S[o>>0]=1,o=t+16|0):o=Xe(r<<2)|0,e[t+4>>2]=o,e[t>>2]=o,e[t+8>>2]=o+(r<<2)}function e5(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0;w=b,b=b+16|0,d=w;do if((t|0)!=(r|0)){if(c=S0()|0,h=e[c>>2]|0,e[c>>2]=0,l=+Fr(t,d,b0()|0),t=e[c>>2]|0,t||(e[c>>2]=h),(e[d>>2]|0)!=(r|0)){e[o>>2]=4,l=0;break}(t|0)==34&&(e[o>>2]=4)}else e[o>>2]=4,l=0;while(!1);return b=w,+l}function t5(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0;w=b,b=b+16|0,d=w;do if((t|0)!=(r|0)){if(c=S0()|0,h=e[c>>2]|0,e[c>>2]=0,l=+Fr(t,d,b0()|0),t=e[c>>2]|0,t||(e[c>>2]=h),(e[d>>2]|0)!=(r|0)){e[o>>2]=4,l=0;break}(t|0)==34&&(e[o>>2]=4)}else e[o>>2]=4,l=0;while(!1);return b=w,+l}function i5(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0;w=b,b=b+16|0,d=w;do if((t|0)==(r|0))e[o>>2]=4,l=0;else{if(c=S0()|0,h=e[c>>2]|0,e[c>>2]=0,l=+Fr(t,d,b0()|0),t=e[c>>2]|0,t||(e[c>>2]=h),(e[d>>2]|0)!=(r|0)){e[o>>2]=4,l=0;break}(t|0)==34&&(e[o>>2]=4)}while(!1);return b=w,+l}function n5(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0;w=b,b=b+16|0,d=w;do if((t|0)!=(r|0)){if((S[t>>0]|0)==45){e[o>>2]=4,l=0,t=0;break}if(c=S0()|0,h=e[c>>2]|0,e[c>>2]=0,t=Dn(t,d,l,b0()|0)|0,l=e[c>>2]|0,l||(e[c>>2]=h),(e[d>>2]|0)!=(r|0)){e[o>>2]=4,l=0,t=0;break}(l|0)==34?(e[o>>2]=4,l=-1,t=-1):l=ye}else e[o>>2]=4,l=0,t=0;while(!1);return ye=l,b=w,t|0}function r5(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;C=b,b=b+16|0,w=C;do if((t|0)!=(r|0)){if((S[t>>0]|0)==45){e[o>>2]=4,t=0;break}if(h=S0()|0,d=e[h>>2]|0,e[h>>2]=0,t=Dn(t,w,l,b0()|0)|0,l=ye,c=e[h>>2]|0,c||(e[h>>2]=d),(e[w>>2]|0)!=(r|0)){e[o>>2]=4,t=0;break}if(l>>>0>0|(l|0)==0&t>>>0>4294967295|(c|0)==34){e[o>>2]=4,t=-1;break}else break}else e[o>>2]=4,t=0;while(!1);return b=C,t|0}function s5(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;C=b,b=b+16|0,w=C;do if((t|0)!=(r|0)){if((S[t>>0]|0)==45){e[o>>2]=4,t=0;break}if(h=S0()|0,d=e[h>>2]|0,e[h>>2]=0,t=Dn(t,w,l,b0()|0)|0,l=ye,c=e[h>>2]|0,c||(e[h>>2]=d),(e[w>>2]|0)!=(r|0)){e[o>>2]=4,t=0;break}if(l>>>0>0|(l|0)==0&t>>>0>4294967295|(c|0)==34){e[o>>2]=4,t=-1;break}else break}else e[o>>2]=4,t=0;while(!1);return b=C,t|0}function o5(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;C=b,b=b+16|0,w=C;do if((t|0)!=(r|0)){if((S[t>>0]|0)==45){e[o>>2]=4,t=0;break}if(h=S0()|0,d=e[h>>2]|0,e[h>>2]=0,t=Dn(t,w,l,b0()|0)|0,l=ye,c=e[h>>2]|0,c||(e[h>>2]=d),(e[w>>2]|0)!=(r|0)){e[o>>2]=4,t=0;break}if(l>>>0>0|(l|0)==0&t>>>0>65535|(c|0)==34){e[o>>2]=4,t=-1;break}else{t=t&65535;break}}else e[o>>2]=4,t=0;while(!1);return b=C,t|0}function l5(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;C=b,b=b+16|0,w=C;do if((t|0)!=(r|0)){if(h=S0()|0,d=e[h>>2]|0,e[h>>2]=0,t=Ao(t,w,l,b0()|0)|0,l=ye,c=e[h>>2]|0,c||(e[h>>2]=d),(e[w>>2]|0)!=(r|0)){e[o>>2]=4,l=0,t=0;break}if((c|0)==34)return e[o>>2]=4,w=(l|0)>0|(l|0)==0&t>>>0>0,ye=w?2147483647:-2147483648,b=C,(w?-1:0)|0}else e[o>>2]=4,l=0,t=0;while(!1);return ye=l,b=C,t|0}function u5(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0;C=b,b=b+16|0,w=C;e:do if((t|0)==(r|0))e[o>>2]=4,t=0;else{if(h=S0()|0,d=e[h>>2]|0,e[h>>2]=0,t=Ao(t,w,l,b0()|0)|0,l=ye,c=e[h>>2]|0,c||(e[h>>2]=d),(e[w>>2]|0)!=(r|0)){e[o>>2]=4,t=0;break}do if((c|0)==34){if(e[o>>2]=4,(l|0)>0|(l|0)==0&t>>>0>0){t=2147483647;break e}}else{if((l|0)<-1|(l|0)==-1&t>>>0<2147483648){e[o>>2]=4;break}if((l|0)>0|(l|0)==0&t>>>0>2147483647){e[o>>2]=4,t=2147483647;break e}else break e}while(!1);t=-2147483648}while(!1);return b=C,t|0}function c5(){}function ii(t,r,o,l){return t=t|0,r=r|0,o=o|0,l=l|0,l=r-l-(o>>>0>t>>>0|0)>>>0,ye=l,t-o>>>0|0|0}function Jt(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;if(l=t+o|0,(o|0)>=20){if(r=r&255,h=t&3,d=r|r<<8|r<<16|r<<24,c=l&-4,h)for(h=t+4-h|0;(t|0)<(h|0);)S[t>>0]=r,t=t+1|0;for(;(t|0)<(c|0);)e[t>>2]=d,t=t+4|0}for(;(t|0)<(l|0);)S[t>>0]=r,t=t+1|0;return t-o|0}function $0(t,r,o,l){return t=t|0,r=r|0,o=o|0,l=l|0,o=t+o>>>0,ye=r+l+(o>>>0>>0|0)>>>0,o|0|0}function Di(t,r,o){return t=t|0,r=r|0,o=o|0,(o|0)<32?(ye=r>>>o,t>>>o|(r&(1<>>o-32|0)}function o0(t,r,o){t=t|0,r=r|0,o=o|0;var l=0;if((o|0)>=4096)return qo(t|0,r|0,o|0)|0;if(l=t|0,(t&3)==(r&3)){for(;t&3;){if(!o)return l|0;S[t>>0]=S[r>>0]|0,t=t+1|0,r=r+1|0,o=o-1|0}for(;(o|0)>=4;)e[t>>2]=e[r>>2],t=t+4|0,r=r+4|0,o=o-4|0}for(;(o|0)>0;)S[t>>0]=S[r>>0]|0,t=t+1|0,r=r+1|0,o=o-1|0;return l|0}function v0(t,r,o){return t=t|0,r=r|0,o=o|0,(o|0)<32?(ye=r<>>32-o,t<0;)t=t-1|0,r=r-1|0,o=o-1|0,S[t>>0]=S[r>>0]|0;t=l}else o0(t,r,o)|0;return t|0}function AA(t,r,o){return t=t|0,r=r|0,o=o|0,(o|0)<32?(ye=r>>o,t>>>o|(r&(1<>o-32|0)}function ro(t){t=t|0;var r=0;return r=S[X+(t&255)>>0]|0,(r|0)<8?r|0:(r=S[X+(t>>8&255)>>0]|0,(r|0)<8?r+8|0:(r=S[X+(t>>16&255)>>0]|0,(r|0)<8?r+16|0:(S[X+(t>>>24)>>0]|0)+24|0))}function f5(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0;return h=t&65535,c=r&65535,o=ee(c,h)|0,l=t>>>16,t=(o>>>16)+(ee(c,l)|0)|0,c=r>>>16,r=ee(c,h)|0,ye=(t>>>16)+(ee(c,l)|0)+(((t&65535)+r|0)>>>16)|0,t+r<<16|o&65535|0|0}function vA(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0;return D=r>>31|((r|0)<0?-1:0)<<1,C=((r|0)<0?-1:0)>>31|((r|0)<0?-1:0)<<1,h=l>>31|((l|0)<0?-1:0)<<1,c=((l|0)<0?-1:0)>>31|((l|0)<0?-1:0)<<1,w=ii(D^t,C^r,D,C)|0,d=ye,t=h^D,r=c^C,ii((wn(w,d,ii(h^o,c^l,h,c)|0,ye,0)|0)^t,ye^r,t,r)|0}function xA(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0;return c=b,b=b+16|0,w=c|0,d=r>>31|((r|0)<0?-1:0)<<1,h=((r|0)<0?-1:0)>>31|((r|0)<0?-1:0)<<1,D=l>>31|((l|0)<0?-1:0)<<1,C=((l|0)<0?-1:0)>>31|((l|0)<0?-1:0)<<1,t=ii(d^t,h^r,d,h)|0,r=ye,wn(t,r,ii(D^o,C^l,D,C)|0,ye,w)|0,l=ii(e[w>>2]^d,e[w+4>>2]^h,d,h)|0,o=ye,b=c,ye=o,l|0}function Qi(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;return c=t,h=o,o=f5(c,h)|0,t=ye,ye=(ee(r,h)|0)+(ee(l,c)|0)+t|t&0,o|0|0|0}function xn(t,r,o,l){return t=t|0,r=r|0,o=o|0,l=l|0,wn(t,r,o,l,0)|0}function Cr(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;return h=b,b=b+16|0,c=h|0,wn(t,r,o,l,c)|0,b=h,ye=e[c+4>>2]|0,e[c>>2]|0|0}function wn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(k=t,C=r,D=C,d=o,R=l,w=R,!D)return h=(c|0)!=0,w?h?(e[c>>2]=t|0,e[c+4>>2]=r&0,R=0,c=0,ye=R,c|0):(R=0,c=0,ye=R,c|0):(h&&(e[c>>2]=(k>>>0)%(d>>>0),e[c+4>>2]=0),R=0,c=(k>>>0)/(d>>>0)>>>0,ye=R,c|0);h=(w|0)==0;do if(d){if(!h){if(h=(st(w|0)|0)-(st(D|0)|0)|0,h>>>0<=31){N=h+1|0,w=31-h|0,r=h-31>>31,d=N,t=k>>>(N>>>0)&r|D<>>(N>>>0)&r,h=0,w=k<>2]=t|0,e[c+4>>2]=C|r&0,R=0,c=0,ye=R,c|0):(R=0,c=0,ye=R,c|0)}if(h=d-1|0,h&d){w=(st(d|0)|0)+33-(st(D|0)|0)|0,U=64-w|0,N=32-w|0,C=N>>31,_=w-32|0,r=_>>31,d=w,t=N-1>>31&D>>>(_>>>0)|(D<>>(w>>>0))&r,r=r&D>>>(w>>>0),h=k<>>(_>>>0))&C|k<>31;break}return c&&(e[c>>2]=h&k,e[c+4>>2]=0),(d|0)==1?(_=C|r&0,U=t|0|0,ye=_,U|0):(U=ro(d|0)|0,_=D>>>(U>>>0)|0,U=D<<32-U|k>>>(U>>>0)|0,ye=_,U|0)}else{if(h)return c&&(e[c>>2]=(D>>>0)%(d>>>0),e[c+4>>2]=0),_=0,U=(D>>>0)/(d>>>0)>>>0,ye=_,U|0;if(!k)return c&&(e[c>>2]=0,e[c+4>>2]=(D>>>0)%(w>>>0)),_=0,U=(D>>>0)/(w>>>0)>>>0,ye=_,U|0;if(h=w-1|0,!(h&w))return c&&(e[c>>2]=t|0,e[c+4>>2]=h&D|r&0),_=0,U=D>>>((ro(w|0)|0)>>>0),ye=_,U|0;if(h=(st(w|0)|0)-(st(D|0)|0)|0,h>>>0<=30){r=h+1|0,w=31-h|0,d=r,t=D<>>(r>>>0),r=D>>>(r>>>0),h=0,w=k<>2]=t|0,e[c+4>>2]=C|r&0,_=0,U=0,ye=_,U|0):(_=0,U=0,ye=_,U|0)}while(!1);if(!d)D=w,C=0,w=0;else{N=o|0|0,k=R|l&0,D=$0(N|0,k|0,-1,-1)|0,o=ye,C=w,w=0;do l=C,C=h>>>31|C<<1,h=w|h<<1,l=t<<1|l>>>31|0,R=t>>>31|r<<1|0,ii(D,o,l,R)|0,U=ye,_=U>>31|((U|0)<0?-1:0)<<1,w=_&1,t=ii(l,R,_&N,(((U|0)<0?-1:0)>>31|((U|0)<0?-1:0)<<1)&k)|0,r=ye,d=d-1|0;while(d|0);D=C,C=0}return d=0,c&&(e[c>>2]=t,e[c+4>>2]=r),_=(h|0)>>>31|(D|d)<<1|(d<<1|h>>>31)&0|C,U=(h<<1|0)&-2|w,ye=_,U|0}function h5(t,r,o,l,c,h,d,w){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,HS[t&15](r|0,o|0,l|0,c|0,h|0,d|0,w|0)|0}function d5(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,Pn[t&15](r|0,o|0,l|0,c|0,h|0)}function p5(t,r,o,l,c,h,d){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=+d,QS[t&3](r|0,o|0,l|0,c|0,h|0,+d)|0}function m5(t,r){t=t|0,r=r|0,Mt[t&255](r|0)}function g5(t,r,o){t=t|0,r=r|0,o=o|0,t0[t&127](r|0,o|0)}function S5(t,r,o,l,c,h,d){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,on[t&63](r|0,o|0,l|0,c|0,h|0,d|0)|0}function A5(t,r){return t=t|0,r=r|0,Dt[t&127](r|0)|0}function v5(t,r,o,l,c,h,d,w,C,D,k,N){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0,k=k|0,N=N|0,KS[t&3](r|0,o|0,l|0,c|0,h|0,d|0,w|0,C|0,D|0,k|0,N|0)|0}function x5(t,r,o,l){return t=t|0,r=r|0,o=o|0,l=l|0,Yt[t&63](r|0,o|0,l|0)|0}function w5(t,r,o,l,c,h,d,w,C,D,k,N,R,_,U,Q){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0,k=k|0,N=N|0,R=R|0,_=_|0,U=U|0,Q=Q|0,YS[t&3](r|0,o|0,l|0,c|0,h|0,d|0,w|0,C|0,D|0,k|0,N|0,R|0,_|0,U|0,Q|0)}function y5(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,Vi[t&15](r|0,o|0,l|0,c|0,h|0,d|0)}function C5(t,r,o,l,c,h,d,w){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,jS[t&7](r|0,o|0,l|0,c|0,h|0,d|0,w|0)}function T5(t,r,o,l,c,h,d,w,C,D,k){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0,k=k|0,XS[t&7](r|0,o|0,l|0,c|0,h|0,d|0,w|0,C|0,D|0,k|0)}function I5(t,r,o){return t=t|0,r=r|0,o=o|0,U0[t&63](r|0,o|0)|0}function E5(t,r,o,l,c,h){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,an[t&31](r|0,o|0,l|0,c|0,h|0)|0}function k5(t,r,o,l){return t=t|0,r=r|0,o=o|0,l=l|0,+ZS[t&3](r|0,o|0,l|0)}function D5(t){return t=t|0,JS[t&15]()|0}function b5(t,r,o,l,c){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,_r[t&31](r|0,o|0,l|0,c|0)|0}function N5(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0,Ln[t&15](r|0,o|0,l|0)}function F5(t){t=t|0,Vo[t&7]()}function R5(t,r,o,l,c,h,d,w,C){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,Ci[t&15](r|0,o|0,l|0,c|0,h|0,d|0,w|0,C|0)|0}function M5(t,r,o,l,c,h){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=+h,eA[t&7](r|0,o|0,l|0,c|0,+h)|0}function _5(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,On[t&63](r|0,o|0,l|0,c|0)}function bi(t,r,o,l,c,h,d){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,Ke(0),0}function sn(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,Ke(1)}function so(t,r,o,l,c,h){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=+h,Ke(2),0}function e0(t){t=t|0,Ke(3)}function Tr(t,r){t=t|0,r=r|0,Ke(4)}function N0(t,r,o,l,c,h){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,Ke(5),0}function r0(t){return t=t|0,Ke(6),0}function P5(t){return t=t|0,Br(t|0)|0}function L5(t){return t=t|0,Gr(t|0)|0}function O5(t){return t=t|0,jo(t|0)|0}function oo(t,r,o,l,c,h,d,w,C,D,k){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0,k=k|0,Ke(7),0}function C0(t,r,o){return t=t|0,r=r|0,o=o|0,Ke(8),0}function ao(t,r,o,l,c,h,d,w,C,D,k,N,R,_,U){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0,k=k|0,N=N|0,R=R|0,_=_|0,U=U|0,Ke(9)}function Ni(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,Ke(10)}function yn(t,r,o,l,c,h,d){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,Ke(11)}function Cn(t,r,o,l,c,h,d,w,C,D){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0,Ke(12)}function L0(t,r){return t=t|0,r=r|0,Ke(13),0}function di(t,r,o,l,c){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,Ke(14),0}function $5(t,r,o){return t=t|0,r=r|0,o=o|0,Ke(15),0}function Li(){return Ke(16),0}function Ki(t,r,o,l){return t=t|0,r=r|0,o=o|0,l=l|0,Ke(17),0}function B5(t,r,o){t=t|0,r=r|0,o=o|0,Ke(18)}function V5(t,r,o){t=t|0,r=r|0,o=o|0,Qt(t|0,r|0,o|0)}function lo(){Ke(19)}function U5(){Jo()}function z5(){ei()}function G5(){Ur()}function Yi(t,r,o,l,c,h,d,w){return t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,Ke(20),0}function Tn(t,r,o,l,c){return t=t|0,r=r|0,o=o|0,l=l|0,c=+c,Ke(21),0}function H0(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0,Ke(22)}function q5(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(D=b,b=b+32|0,w=D,m0(w,255,0),C=t+152|0,(e[w+4>>2]|0)==(e[C>>2]|0)&&(e[w+8>>2]|0)==(e[t+156>>2]|0)&&(e[w+12>>2]|0)==(e[t+160>>2]|0)){C=e[8900]|0,e[t+4580>>2]=C+(((e[8901]|0)-C|0)>>>1),b=D;return}for(o=t+4584|0,l=t+4588|0,c=e[l>>2]|0,r=e[o>>2]|0,h=c-r|0,h>>>0>=512?h>>>0>512&&(d=r+512|0,(c|0)!=(d|0))&&(e[l>>2]=d):(j0(o,512-h|0),r=e[o>>2]|0),w=t+4580|0,e[w>>2]=r+256,d=t+160|0,c=t+156|0,h=-256;;){if(r=e[d>>2]|0,(h|0)>(0-r|0))if(o=e[c>>2]|0,(h|0)>(0-o|0))if(l=e[C>>2]|0,(h|0)>(0-l|0))if((h|0)>=0){if((h|0)<1){S[(e[w>>2]|0)+h>>0]=0,h=1;continue}(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1}else r=-1;else r=-2;else r=-3;else r=-4;if(S[(e[w>>2]|0)+h>>0]=r,h=h+1|0,(h|0)==256)break}b=D}function W5(t){t=t|0;var r=0,o=0;e[t>>2]=35660,r=e[t+4608>>2]|0,r&&(o=t+4612|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),t=t+88|0,r=e[t>>2]|0,e[t>>2]=0,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r)}function H5(t){t=t|0;var r=0,o=0;if(e[t>>2]=35660,r=e[t+4608>>2]|0,r&&(o=t+4612|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),e[t>>2]=36736,r=e[t+92>>2]|0,r&&(o=t+96|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r)),o=t+88|0,r=e[o>>2]|0,e[o>>2]=0,!r){he(t);return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),he(t)}function Q5(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;if(G=b,b=b+352|0,$=G+328|0,P=G+192|0,o=G+343|0,l=G+342|0,c=G+341|0,h=G+340|0,R=G+176|0,w=G+168|0,C=G+160|0,D=G+152|0,K=G,U=G+136|0,e[t+28>>2]|0&&(e[t+20>>2]|0)!=1){if(_=t+4|0,Q=t+32|0,d=e[Q>>2]|0,!d){if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[o>>0]|0,$e(44,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}if(t=e[t+12>>2]|0,(t|0)==8)switch(d|0){case 1:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[l>>0]|0,$e(45,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[c>>0]|0,$e(46,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(48)|0,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],S[$>>0]=S[h>>0]|0,$e(47,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=P+56|0,c=P+4|0,e[P>>2]=36160,e[d>>2]=36180,g=0,Ae(62,P+56|0,c|0),G=g,g=0,G&1&&(O=j()|0,tt(d),le(O|0)),e[P+128>>2]=0,e[P+132>>2]=-1,e[P>>2]=36200,e[P+56>>2]=36220,g=0,ue(180,c|0),G=g,g=0;do if(G&1)t=j()|0;else{if(e[c>>2]=36236,h=P+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[P+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),G=g,g=0,G&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,P|0,49007,21)|0,$=g,g=0;do if(!($&1)&&(g=0,k=be(36,t|0,e[Q>>2]|0)|0,$=g,g=0,!($&1))&&(g=0,Ve(28,k|0,50997,18)|0,$=g,g=0,!($&1))){if(l=Ct(16)|0,g=0,Ae(64,R|0,c|0),$=g,g=0,$&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,R|0),$=g,g=0,$&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(R),!o)break;Tt(l|0)}else O=34;while(!1);(O|0)==34&&(t=j()|0),e[P>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}switch((t|0)<=8&&(t=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,t|0,8,35648),O=g,g=0,O&1||Qt(t|0,824,96),O=j()|0,Tt(t|0),le(O|0)),o=16-t|0,d|0){case 1:{if(t=Xe(60)|0,e[w>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[w>>2],e[$+4>>2]=e[w+4>>2],$e(41,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 2:{if(t=Xe(60)|0,e[C>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[C>>2],e[$+4>>2]=e[C+4>>2],$e(42,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}case 3:{if(t=Xe(60)|0,e[D>>2]=o,g=0,e[P>>2]=e[r>>2],e[P+4>>2]=e[r+4>>2],e[P+8>>2]=e[r+8>>2],e[$>>2]=e[D>>2],e[$+4>>2]=e[D+4>>2],$e(43,t|0,P|0,_|0,$|0),O=g,g=0,!(O&1))return O=t,b=G,O|0;O=j()|0,he(t),le(O|0)}default:{d=K+56|0,c=K+4|0,e[K>>2]=36160,e[d>>2]=36180,g=0,Ae(62,K+56|0,c|0),P=g,g=0,P&1&&(O=j()|0,tt(d),le(O|0)),e[K+128>>2]=0,e[K+132>>2]=-1,e[K>>2]=36200,e[K+56>>2]=36220,g=0,ue(180,c|0),P=g,g=0;do if(P&1)t=j()|0;else{if(e[c>>2]=36236,h=K+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[K+52>>2]=16,e[$>>2]=0,e[$+4>>2]=0,e[$+8>>2]=0,g=0,Ae(63,c|0,$|0),P=g,g=0,P&1){t=j()|0,de($),de(h),wt(c);break}de($),g=0,t=Ve(28,K|0,49007,21)|0,P=g,g=0;do if(!(P&1)&&(g=0,N=be(36,t|0,e[Q>>2]|0)|0,P=g,g=0,!(P&1))&&(g=0,Ve(28,N|0,50997,18)|0,P=g,g=0,!(P&1))){if(l=Ct(16)|0,g=0,Ae(64,U|0,c|0),P=g,g=0,P&1)t=j()|0;else if(!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,$e(36,l|0,9,35648,U|0),P=g,g=0,P&1?o=1:(g=0,xe(6,l|0,824,96),g=0,o=0),t=j()|0,de(U),!o)break;Tt(l|0)}else O=64;while(!1);(O|0)==64&&(t=j()|0),e[K>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),O=t,le(O|0)}while(!1);O=t,tt(d),le(O|0)}}}return o=e[r+4>>2]|0,l=Xe(16)|0,t=e[t+16>>2]|0,o?(e[l>>2]=36108,e[l+4>>2]=o,e[l+8>>2]=1,e[l+12>>2]=t,O=l,b=G,O|0):(O=e[r>>2]|0,e[l>>2]=36132,e[l+4>>2]=O,e[l+8>>2]=1,e[l+12>>2]=t,O=l,b=G,O|0)}function K5(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;d=b,b=b+32|0,C=d,m0(C,e[t+128>>2]|0,e[t+136>>2]|0),w=e[r+4>>2]|0,h=e[r+8>>2]|0,h=h|0?h:e[C+8>>2]|0,c=e[r+12>>2]|0,c=c|0?c:e[C+12>>2]|0,o=e[r+16>>2]|0,l=e[C+16>>2]|0,e[t+176>>2]=w|0?w:e[C+4>>2]|0,e[t+180>>2]=h,e[t+184>>2]=c,t6(t),c=t+132|0,r=(e[c>>2]|0)+32|0,r=(r|0)<128?2:(r|0)/64|0,h=0;do e[t+188+(h*12|0)>>2]=r,e[t+188+(h*12|0)+4>>2]=0,E[t+188+(h*12|0)+8>>1]=0,E[t+188+(h*12|0)+10>>1]=1,h=h+1|0;while((h|0)!=365);w=(e[c>>2]|0)+32|0,w=(w|0)<128?2:(w|0)/64|0,C=(o|0?o:l)&255,e[t+4568>>2]=w,e[t+4572>>2]=0,S[t+4576>>0]=C,S[t+4577>>0]=1,S[t+4578>>0]=0,e[t+4580>>2]=w,e[t+4584>>2]=1,S[t+4588>>0]=C,S[t+4589>>0]=1,S[t+4590>>0]=0,e[t+4592>>2]=0,b=d}function Y5(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;for(d=t+88|0,h=e[r>>2]|0,e[r>>2]=0,r=e[d>>2]|0,e[d>>2]=h,r&&Mt[e[(e[r>>2]|0)+4>>2]&255](r),d=l+4|0,h=e[d>>2]|0,S[t+4620>>0]=c&1,r=t+156|0,e[r>>2]=e[o>>2],e[r+4>>2]=e[o+4>>2],e[r+8>>2]=e[o+8>>2],e[r+12>>2]=e[o+12>>2],Y0(t,l),j5(t),r=e[t+116>>2]|0,t=e[t+112>>2]|0;c=r+-1|0,o=(S[c>>0]|0)==-1?7:8,!((t|0)<(o|0));)r=c,t=t-o|0;r=r-h|0,c=e[d>>2]|0,c&&(e[d>>2]=c+r,l=l+8|0,e[l>>2]=(e[l>>2]|0)-r)}function j5(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0;ie=b,b=b+32|0,ne=ie+12|0,Z=ie,w=t+172|0,O=(e[w>>2]|0)+4|0,(e[t+28>>2]|0)==1?C=e[t+20>>2]|0:C=1,r=ee(C<<1,O)|0,e[ne>>2]=0,ce=ne+4|0,e[ce>>2]=0,e[ne+8>>2]=0;e:do if(r){if((r|0)<0&&(g=0,ue(178,ne|0),oe=g,g=0,oe&1)||(P=6),(P|0)==6&&(g=0,o=ge(67,r|0)|0,oe=g,g=0,!(oe&1))){for(e[ce>>2]=o,e[ne>>2]=o,e[ne+8>>2]=o+r;;)if(S[o>>0]=0,o=(e[ce>>2]|0)+1|0,e[ce>>2]=o,r=r+-1|0,!r)break e}o=j()|0,r=e[ne>>2]|0,r||le(o|0),(e[ce>>2]|0)!=(r|0)&&(e[ce>>2]=r),he(r),le(o|0)}while(!1);e[Z>>2]=0,oe=Z+4|0,e[oe>>2]=0,e[Z+8>>2]=0;do if(!C)P=19;else{if(C>>>0>1073741823&&(g=0,ue(178,Z|0),$=g,g=0,$&1)||(P=17),(P|0)==17&&(l=C<<2,g=0,c=ge(67,l|0)|0,$=g,g=0,!($&1))){e[Z>>2]=c,P=c+(C<<2)|0,e[Z+8>>2]=P,Jt(c|0,0,l|0)|0,e[oe>>2]=P,P=19;break}o=j()|0,r=e[Z>>2]|0,l=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-l|0)>>>2)<<2)),he(r))}while(!1);if((P|0)==19){D=t+8|0,r=e[D>>2]|0;e:do if((r|0)>0){if(k=t+4596|0,N=ee(C,O)|0,R=N+1|0,_=t+4600|0,U=t+160|0,Q=t+168|0,K=t+164|0,G=t+156|0,$=t+88|0,d=t+4592|0,(C|0)>0)h=0;else{for(h=0;;){if(c=e[ne>>2]|0,o=c+1|0,e[k>>2]=o,l=c+R|0,e[_>>2]=l,h&1?(e[k>>2]=l,e[_>>2]=o,o=1):o=R,C=e[U>>2]|0,(C|0)<=(h|0)&&(h|0)<((e[Q>>2]|0)+C|0)){if(C=e[$>>2]|0,g=0,$e(e[(e[C>>2]|0)+8>>2]|0,C|0,c+(o+((e[G>>2]|0)-N))|0,e[K>>2]|0,O|0),C=g,g=0,C&1)break;r=e[D>>2]|0}if(h=h+1|0,(h|0)>=(r|0)){P=50;break e}}o=j()|0;break}t:for(;;){o=e[ne>>2]|0,r=o+1|0,e[k>>2]=r,o=o+R|0,e[_>>2]=o,h&1&&(e[k>>2]=o,e[_>>2]=r,r=o),c=e[Z>>2]|0,o=r,l=0;do{if(e[d>>2]=e[c+(l<<2)>>2],P=e[w>>2]|0,S[o+P>>0]=S[o+(P+-1)>>0]|0,S[(e[_>>2]|0)+-1>>0]=S[e[k>>2]>>0]|0,g=0,Ae(83,t|0,0),P=g,g=0,P&1){P=38;break t}c=e[Z>>2]|0,e[c+(l<<2)>>2]=e[d>>2],o=(e[k>>2]|0)+O|0,e[k>>2]=o,r=e[_>>2]|0,e[_>>2]=r+O,l=l+1|0}while((l|0)<(C|0));if(P=e[U>>2]|0,(P|0)<=(h|0)&&(h|0)<((e[Q>>2]|0)+P|0)&&(P=e[$>>2]|0,g=0,$e(e[(e[P>>2]|0)+8>>2]|0,P|0,r+(O+((e[G>>2]|0)-N))|0,e[K>>2]|0,O|0),P=g,g=0,P&1)){P=30;break}if(h=h+1|0,(h|0)>=(e[D>>2]|0)){P=50;break e}}if((P|0)==30){o=j()|0;break}else if((P|0)==38){o=j()|0;break}}else P=50;while(!1);do if((P|0)==50){if(g=0,ue(183,t|0),t=g,g=0,t&1){o=j()|0;break}if(r=e[Z>>2]|0,o=r,r&&(l=e[oe>>2]|0,(l|0)!=(r|0)&&(e[oe>>2]=l+(~((l+-4-o|0)>>>2)<<2)),he(r)),r=e[ne>>2]|0,!r){b=ie;return}(e[ce>>2]|0)!=(r|0)&&(e[ce>>2]=r),he(r),b=ie;return}while(!1);r=e[Z>>2]|0,l=r,r&&(c=e[oe>>2]|0,(c|0)!=(r|0)&&(e[oe>>2]=c+(~((c+-4-l|0)>>>2)<<2)),he(r))}r=e[ne>>2]|0,r||le(o|0),(e[ce>>2]|0)!=(r|0)&&(e[ce>>2]=r),he(r),le(o|0)}function X5(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0;if(R=t+4596|0,o=e[R>>2]|0,K=t+172|0,r=e[K>>2]|0,!((r|0)<=0))for(_=t+4600|0,U=t+4604|0,Q=t+4592|0,w=o,h=F[o+-1>>0]|0,o=F[o>>0]|0,N=0;D=e[_>>2]|0,d=S[D+(N+-1)>>0]|0,k=d&255,c=N+1|0,l=F[w+c>>0]|0,C=e[U>>2]|0,w=o-h|0,h=h-k|0,C=((((S[C+(l-o)>>0]|0)*9|0)+(S[C+w>>0]|0)|0)*9|0)+(S[C+h>>0]|0)|0,D=D+N|0,C?(r=o-k>>31,(r^h|0)<0?r=o:r=k+((r^w|0)<0?0:w)|0,k=Z5(t,C,F[D>>0]|0,r,0)|0,S[(e[_>>2]|0)+N>>0]=k):(r=J5(t,d,D,r-N|0)|0,o=r+N|0,(o|0)!=(e[K>>2]|0)&&(k=e6(t,k,F[(e[R>>2]|0)+o>>0]|0)|0,S[(e[_>>2]|0)+o>>0]=k,k=e[Q>>2]|0,e[Q>>2]=(k|0)<1?0:k+-1|0,r=r+1|0),c=r+N|0,l=e[R>>2]|0,o=F[l+(c+-1)>>0]|0,l=F[l+c>>0]|0),r=e[K>>2]|0,!((r|0)<=(c|0));)w=e[R>>2]|0,h=o,o=l,N=c}function Z5(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(U=r>>31,C=(U^r)-U|0,R=t+188+(C*12|0)+10|0,o=E[R>>1]|0,N=t+188+(C*12|0)|0,c=e[N>>2]|0,(o|0)<(c|0))if((o<<1|0)<(c|0))if((o<<2|0)<(c|0))if((o<<3|0)<(c|0))if((o<<4|0)<(c|0))for(r=5;(o<>1]^U)-U+l|0,_=t+128|0,c=e[_>>2]|0,(o&c|0)==(o|0)?D=o:D=c&~(o>>31),o=t+112|0,(e[o>>2]|0)<8&&P0(t),c=t+108|0,l=e[c>>2]|0,h=l>>>24,d=e[2832+(r<<11)+(h<<3)+4>>2]|0,d?(e[o>>2]=(e[o>>2]|0)-d,e[c>>2]=l<>2]|0):(w=e[t+148>>2]|0,c=e[t+140>>2]|0,o=X0(t)|0,(o|0)<(w+-1-c|0)?r&&(o=(l0(t,r)|0)+(o<>31^o>>1,(((o|0)>-1?o:0-o|0)|0)>65535&&(o=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,o|0,5,35648),t=g,g=0,t&1?(t=j()|0,Tt(o|0),le(t|0)):Qt(o|0,824,96))),w=t+136|0,l=e[w>>2]|0,r?d=o:(l?c=0:c=(e[t+188+(C*12|0)+4>>2]<<1)+-1+(E[R>>1]|0)>>31,d=c^o),r=e[t+152>>2]|0,c=(e[N>>2]|0)+((d|0)>-1?d:0-d|0)|0,h=t+188+(C*12|0)+4|0,o=(e[h>>2]|0)+(ee(l<<1|1,d)|0)|0,l=E[R>>1]|0,(l|0)==(r|0)&&(c=c>>1,o=o>>1,l=r>>1),e[N>>2]=c,r=l+1|0,E[R>>1]=r,c=r+o|0,(c|0)>=1?(o|0)>0&&(o=o-r|0,R=E[k>>1]|0,E[k>>1]=(R<<16>>16<127&1)+(R&65535),o=(o|0)>0?0:o):(o=E[k>>1]|0,E[k>>1]=(o&65535)-(o<<16>>16>-128&1),o=(c|0)>(~l|0)?c:0-l|0),e[h>>2]=o,r=e[w>>2]|0,l=r<<1|1,c=(ee(l,(d^U)-U|0)|0)+D|0,(c|0)>=(0-r|0)?(o=e[_>>2]|0,(o+r|0)<(c|0)&&(c=c-(ee(e[t+132>>2]|0,l)|0)|0)):(c=(ee(e[t+132>>2]|0,l)|0)+c|0,o=e[_>>2]|0),(c&o|0)==(c|0)?(t=c,t=t&255,t|0):(t=o&~(c>>31),t=t&255,t|0)}function J5(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;for(w=t+112|0,C=t+108|0,D=t+4592|0,c=e[w>>2]|0,h=0;;){if((c|0)<1&&(P0(t),c=e[w>>2]|0),d=e[C>>2]|0,c=c+-1|0,e[w>>2]=c,e[C>>2]=d<<1,(d|0)>=0){k=8;break}if(d=e[D>>2]|0,N=1<>2],R=l-h|0,R=(N|0)<(R|0)?N:R,h=R+h|0,(R|0)==(N|0)&&(e[D>>2]=(d|0)>30?31:d+1|0),(h|0)==(l|0)){c=l;break}}return(k|0)==8&&((h|0)!=(l|0)?(c=e[D>>2]|0,(c+-4|0)>>>0<28?c=l0(t,e[36476+(c<<2)>>2]|0)|0:c=0,c=c+h|0,(c|0)>(l|0)&&(c=Ct(16)|0,!(S[8]|0)&&kt(8)|0&&(Ft(72,35648,H|0)|0,bt(8)),g=0,xe(7,c|0,5,35648),R=g,g=0,R&1?(R=j()|0,Tt(c|0),le(R|0)):Qt(c|0,824,96))):c=l),(c|0)<=0||Jt(o|0,r|0,c|0)|0,c|0}function e6(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;return h=r-o|0,d=t+128|0,l=t+136|0,(((h|0)>-1?h:0-h|0)|0)>(e[l>>2]|0)?(r=ee(uo(t,t+4568|0)|0,o-r>>31|1)|0,c=e[l>>2]|0,h=c<<1|1,r=(ee(r,h)|0)+o|0,(r|0)>=(0-c|0)?(l=e[d>>2]|0,(l+c|0)<(r|0)&&(r=r-(ee(e[t+132>>2]|0,h)|0)|0)):(r=(ee(e[t+132>>2]|0,h)|0)+r|0,l=e[d>>2]|0),(r&l|0)==(r|0)?(t=r,t=t&255,t|0):(t=l&~(r>>31),t=t&255,t|0)):(o=uo(t,t+4580|0)|0,h=e[l>>2]|0,c=h<<1|1,r=(ee(c,o)|0)+r|0,(r|0)>=(0-h|0)?(l=e[d>>2]|0,(l+h|0)<(r|0)&&(r=r-(ee(e[t+132>>2]|0,c)|0)|0)):(r=(ee(e[t+132>>2]|0,c)|0)+r|0,l=e[d>>2]|0),(r&l|0)==(r|0)?(t=r,t=t&255,t|0):(t=l&~(r>>31),t=t&255,t|0))}function uo(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0;if(D=r+9|0,o=F[D>>0]|0,h=r+4|0,c=(ee(o>>>1,e[h>>2]|0)|0)+(e[r>>2]|0)|0,(o|0)<(c|0)){l=0;do o=o<<1,l=l+1|0;while((o|0)<(c|0))}else l=0;d=e[t+148>>2]|0,w=e[36476+(e[t+4592>>2]<<2)>>2]|0,o=e[t+140>>2]|0,c=X0(t)|0;do if((c|0)<(d+-2-w-o|0))if(l){w=(l0(t,l)|0)+(c<>2]|0,c=w+l|0,d=c&1,o=d,h=1,c=(d+c|0)/2|0;break}else{l=e[h>>2]|0,t=l+c|0,o=t&1,t=(o+t|0)/2|0,C=8;break}else c=(l0(t,o)|0)+1|0,d=e[h>>2]|0,t=c+d|0,o=t&1,t=(o+t|0)/2|0,l?(w=c,h=1,c=t,l=d):(l=d,C=8);while(!1);return(C|0)==8&&(w=c,h=F[r+10>>0]<<1>>>0>=(F[D>>0]|0)>>>0,c=t),c=(o|0)!=0^h?c:0-c|0,(c|0)<0&&(C=r+10|0,S[C>>0]=(F[C>>0]|0)+1),o=(w+1-l>>1)+(e[r>>2]|0)|0,e[r>>2]=o,l=S[D>>0]|0,l<<24>>24!=(S[r+8>>0]|0)?(r=l,r=r&255,r=r+1|0,r=r&255,S[D>>0]=r,c|0):(e[r>>2]=o>>1,C=(l&255)>>>1,S[D>>0]=C,r=r+10|0,S[r>>0]=(F[r>>0]|0)>>>1,r=C,r=r&255,r=r+1|0,r=r&255,S[D>>0]=r,c|0)}function t6(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;R=b,b=b+32|0,l=R,N=t+136|0;e:do if(e[N>>2]|0)r=t+144|0;else if(o=e[t+128>>2]|0,r=t+144|0,(o|0)==((1<>2])+-1|0)&&(m0(l,o,0),(e[l+4>>2]|0)==(e[t+176>>2]|0))&&(e[l+8>>2]|0)==(e[t+180>>2]|0)&&(e[l+12>>2]|0)==(e[t+184>>2]|0))switch(e[r>>2]|0){case 8:{N=e[8900]|0,e[t+4604>>2]=N+(((e[8901]|0)-N|0)>>>1),b=R;return}case 10:{N=e[8903]|0,e[t+4604>>2]=N+(((e[8904]|0)-N|0)>>>1),b=R;return}case 12:{N=e[8906]|0,e[t+4604>>2]=N+(((e[8907]|0)-N|0)>>>1),b=R;return}case 16:{N=e[8909]|0,e[t+4604>>2]=N+(((e[8910]|0)-N|0)>>>1),b=R;return}default:break e}while(!1);if(k=1<>2],o=t+4608|0,l=k<<1,c=t+4612|0,h=e[c>>2]|0,r=e[o>>2]|0,d=h-r|0,l>>>0<=d>>>0?l>>>0>>0&&(w=r+l|0,(h|0)!=(w|0))&&(e[c>>2]=w):(j0(o,l-d|0),r=e[o>>2]|0),D=t+4604|0,e[D>>2]=r+k,r=0-k|0,(k|0)<=(r|0)){b=R;return}w=t+184|0,C=t+180|0,d=t+176|0,h=r;do r=e[w>>2]|0,(h|0)>(0-r|0)?(o=e[C>>2]|0,(h|0)>(0-o|0)?(l=e[d>>2]|0,(h|0)>(0-l|0)?(c=e[N>>2]|0,(h|0)>=(0-c|0)?(c|0)<(h|0)?(l|0)<=(h|0)?(o|0)>(h|0)?r=2:r=(r|0)>(h|0)?3:4:r=1:r=0:r=-1):r=-2):r=-3):r=-4,S[(e[D>>2]|0)+h>>0]=r,h=h+1|0;while((h|0)!=(k|0));b=R}function i6(t){t=t|0,he(t)}function n6(t){return t=t|0,50767}function r6(t,r,o){t=t|0,r=r|0,o=o|0,yi(t,50754,12)}function s6(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0;U=b,b=b+16|0,Q=U,e[Q>>2]=0,K=Q+4|0,e[K>>2]=0,e[Q+8>>2]=0,R=Q+8|0,g=0,c=ge(67,1)|0,N=g,g=0;e:do if(!(N&1)&&(N=c+1|0,S[c>>0]=o,e[Q>>2]=c,e[K>>2]=N,e[R>>2]=N,g=0,Ae(84,Q|0,r&65535|0),N=g,g=0,!(N&1))&&(g=0,Ae(84,Q|0,t&65535|0),N=g,g=0,!(N&1))){if(D=l&255,c=e[K>>2]|0,o=e[R>>2]|0,c>>>0>=o>>>0){if(r=e[Q>>2]|0,t=r,d=c-t+1|0,(d|0)<0){if(g=0,ue(178,Q|0),N=g,g=0,N&1){_=52;break}t=e[Q>>2]|0,o=e[R>>2]|0,r=t}if(C=r,c=o-C|0,c>>>0<1073741823?(c=c<<1,c=c>>>0>>0?d:c,o=e[K>>2]|0,w=o-C|0,c?_=12:(c=0,d=0)):(w=e[K>>2]|0,c=2147483647,o=w,w=w-C|0,_=12),(_|0)==12&&(g=0,d=ge(67,c|0)|0,N=g,g=0,N&1)){_=52;break}S[d+w>>0]=D,k=o-C|0,N=d+(w-k)|0,o0(N|0,r|0,k|0)|0,e[Q>>2]=N,e[K>>2]=d+(w+1),e[R>>2]=d+c,t&&he(t)}else S[c>>0]=D,e[K>>2]=(e[K>>2]|0)+1;t:do if((l|0)>0){for(N=0;;){if(N=N+1|0,k=N&255,c=e[K>>2]|0,r=e[R>>2]|0,c>>>0>=r>>>0){if(t=e[Q>>2]|0,o=t,d=c-o+1|0,(d|0)<0){if(g=0,ue(178,Q|0),D=g,g=0,D&1)break;t=e[Q>>2]|0,o=t,r=e[R>>2]|0}if(D=t,c=r-D|0,c>>>0<1073741823?(c=c<<1,c=c>>>0>>0?d:c,r=e[K>>2]|0,w=r-D|0,c?_=25:(C=0,d=0)):(w=e[K>>2]|0,c=2147483647,r=w,w=w-D|0,_=25),(_|0)==25){if(_=0,g=0,d=ge(67,c|0)|0,C=g,g=0,C&1)break;C=c}S[d+w>>0]=k,c=d+(w+1)|0,D=r-D|0,k=d+(w-D)|0,o0(k|0,t|0,D|0)|0,e[Q>>2]=k,e[K>>2]=c,e[R>>2]=d+C,o&&(he(o),c=e[K>>2]|0)}else S[c>>0]=k,c=(e[K>>2]|0)+1|0,e[K>>2]=c;if(o=e[R>>2]|0,c>>>0>=o>>>0){if(r=e[Q>>2]|0,t=r,d=c-t+1|0,(d|0)<0){if(g=0,ue(178,Q|0),k=g,g=0,k&1)break;t=e[Q>>2]|0,o=e[R>>2]|0,r=t}if(D=r,c=o-D|0,c>>>0<1073741823?(c=c<<1,c=c>>>0>>0?d:c,d=e[K>>2]|0,w=d-D|0,c?_=36:(C=0,o=0)):(w=e[K>>2]|0,c=2147483647,d=w,w=w-D|0,_=36),(_|0)==36){if(_=0,g=0,o=ge(67,c|0)|0,k=g,g=0,k&1)break;C=c}S[o+w>>0]=17,c=o+(w+1)|0,D=d-D|0,k=o+(w-D)|0,o0(k|0,r|0,D|0)|0,e[Q>>2]=k,e[K>>2]=c,e[R>>2]=o+C,t&&(he(t),c=e[K>>2]|0)}else S[c>>0]=17,c=(e[K>>2]|0)+1|0,e[K>>2]=c;if(o=e[R>>2]|0,c>>>0>=o>>>0){if(r=e[Q>>2]|0,t=r,d=c-t+1|0,(d|0)<0){if(g=0,ue(178,Q|0),k=g,g=0,k&1)break;t=e[Q>>2]|0,o=e[R>>2]|0,r=t}if(C=r,c=o-C|0,c>>>0<1073741823?(c=c<<1,c=c>>>0>>0?d:c,o=e[K>>2]|0,w=o-C|0,c?_=48:(c=0,d=0)):(w=e[K>>2]|0,c=2147483647,o=w,w=w-C|0,_=48),(_|0)==48&&(_=0,g=0,d=ge(67,c|0)|0,k=g,g=0,k&1))break;S[d+w>>0]=0,D=o-C|0,k=d+(w-D)|0,o0(k|0,r|0,D|0)|0,e[Q>>2]=k,e[K>>2]=d+(w+1),e[R>>2]=d+c,t&&he(t)}else S[c>>0]=0,e[K>>2]=(e[K>>2]|0)+1;if((N|0)>=(l|0))break t}h=j()|0;break e}while(!1);if(g=0,w=ge(67,20)|0,l=g,g=0,l&1)_=52;else{e[w>>2]=36800,S[w+4>>0]=-9,t=w+8|0,e[t>>2]=0,d=w+12|0,e[d>>2]=0,o=w+16|0,e[o>>2]=0,c=e[K>>2]|0,l=e[Q>>2]|0,r=c-l|0;do if((c|0)!=(l|0)){if((r|0)<0&&(g=0,ue(178,t|0),l=g,g=0,l&1)||(_=62),(_|0)==62&&(g=0,h=ge(67,r|0)|0,l=g,g=0,!(l&1))){if(e[d>>2]=h,e[t>>2]=h,e[o>>2]=h+r,c=e[Q>>2]|0,o=e[K>>2]|0,(c|0)==(o|0))break;do S[h>>0]=S[c>>0]|0,h=(e[d>>2]|0)+1|0,e[d>>2]=h,c=c+1|0;while((c|0)!=(o|0));c=e[Q>>2]|0;break}h=j()|0,c=e[t>>2]|0,c&&((e[d>>2]|0)!=(c|0)&&(e[d>>2]=c),he(c)),he(w);break e}while(!1);return c?((e[K>>2]|0)!=(c|0)&&(e[K>>2]=c),he(c),b=U,w|0):(b=U,w|0)}}else _=52;while(!1);return(_|0)==52&&(h=j()|0),c=e[Q>>2]|0,c||le(h|0),(e[K>>2]|0)!=(c|0)&&(e[K>>2]=c),he(c),le(h|0),0}function o6(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0;K=b,b=b+32|0,_=K+28|0,$=K+16|0,Q=K+4|0,U=K,e[$>>2]=0,P=$+4|0,e[P>>2]=0,e[$+8>>2]=0,N=Xe(5)|0,e[$>>2]=N,R=$+8|0,e[R>>2]=N+5,S[N>>0]=74,S[N+1>>0]=70,S[N+2>>0]=73,S[N+3>>0]=70,S[N+4>>0]=0,e[P>>2]=N+5,g=0,Ae(84,$|0,e[t>>2]&65535|0),N=g,g=0;e:do if(N&1)G=43;else{if(D=e[t+4>>2]&255,r=e[P>>2]|0,l=e[R>>2]|0,r>>>0>=l>>>0){if(c=e[$>>2]|0,h=c,d=r-h+1|0,(d|0)<0){if(g=0,ue(178,$|0),N=g,g=0,N&1){G=43;break}h=e[$>>2]|0,l=e[R>>2]|0,c=h}if(C=c,r=l-C|0,r>>>0<1073741823?(r=r<<1,r=r>>>0>>0?d:r,l=e[P>>2]|0,w=l-C|0,r?G=10:(r=0,d=0)):(w=e[P>>2]|0,r=2147483647,l=w,w=w-C|0,G=10),(G|0)==10&&(g=0,d=ge(67,r|0)|0,N=g,g=0,N&1)){G=43;break}S[d+w>>0]=D,k=l-C|0,N=d+(w-k)|0,o0(N|0,c|0,k|0)|0,e[$>>2]=N,e[P>>2]=d+(w+1),e[R>>2]=d+r,h&&he(h)}else S[r>>0]=D,e[P>>2]=(e[P>>2]|0)+1;if(g=0,Ae(84,$|0,e[t+8>>2]&65535|0),N=g,g=0,!(N&1)&&(g=0,Ae(84,$|0,e[t+12>>2]&65535|0),N=g,g=0,!(N&1))){if(N=t+16|0,k=e[N>>2]&255,r=e[P>>2]|0,c=e[R>>2]|0,r>>>0>=c>>>0){if(h=e[$>>2]|0,l=h,d=r-l+1|0,(d|0)<0){if(g=0,ue(178,$|0),D=g,g=0,D&1){G=43;break}h=e[$>>2]|0,l=h,c=e[R>>2]|0}if(D=h,r=c-D|0,r>>>0<1073741823?(r=r<<1,r=r>>>0>>0?d:r,d=e[P>>2]|0,w=d-D|0,r?G=23:(C=0,c=0)):(w=e[P>>2]|0,r=2147483647,d=w,w=w-D|0,G=23),(G|0)==23)if(g=0,c=ge(67,r|0)|0,C=g,g=0,C&1){G=43;break}else C=r;S[c+w>>0]=k,r=c+(w+1)|0,D=d-D|0,k=c+(w-D)|0,o0(k|0,h|0,D|0)|0,e[$>>2]=k,e[P>>2]=r,e[R>>2]=c+C,l&&(he(l),r=e[P>>2]|0)}else S[r>>0]=k,r=(e[P>>2]|0)+1|0,e[P>>2]=r;if(k=t+20|0,D=e[k>>2]&255,l=e[R>>2]|0,r>>>0>=l>>>0){if(c=e[$>>2]|0,h=c,d=r-h+1|0,(d|0)<0){if(g=0,ue(178,$|0),C=g,g=0,C&1){G=43;break}h=e[$>>2]|0,l=e[R>>2]|0,c=h}if(C=c,r=l-C|0,r>>>0<1073741823?(r=r<<1,r=r>>>0>>0?d:r,l=e[P>>2]|0,w=l-C|0,r?G=34:(r=0,d=0)):(w=e[P>>2]|0,r=2147483647,l=w,w=w-C|0,G=34),(G|0)==34&&(g=0,d=ge(67,r|0)|0,O=g,g=0,O&1)){G=43;break}S[d+w>>0]=D,D=l-C|0,O=d+(w-D)|0,o0(O|0,c|0,D|0)|0,e[$>>2]=O,e[P>>2]=d+(w+1),e[R>>2]=d+r,h&&he(h)}else S[r>>0]=D,e[P>>2]=(e[P>>2]|0)+1;r=e[N>>2]|0;do if((r|0)>0){if(!(e[t+24>>2]|0))if(e[U>>2]=e[P>>2],O=0+(ee(r*3|0,e[k>>2]|0)|0)|0,g=0,e[_>>2]=e[U>>2],Pe(15,$|0,_|0,0,O|0)|0,O=g,g=0,O&1){G=43;break e}else break;if(l=Ct(16)|0,g=0,xe(5,Q|0,50792,57),O=g,g=0,O&1)r=j()|0;else if(g=0,r=Ce(1)|0,O=g,g=0,!(O&1)&&(g=0,$e(36,l|0,1,r|0,Q|0),O=g,g=0,!(O&1))?(g=0,xe(6,l|0,824,96),g=0,o=0):o=1,r=j()|0,de(Q),!o){o=r;break e}Tt(l|0),o=r;break e}while(!1);if(g=0,w=ge(67,20)|0,O=g,g=0,O&1)G=43;else{e[w>>2]=36800,S[w+4>>0]=-32,h=w+8|0,e[h>>2]=0,d=w+12|0,e[d>>2]=0,l=w+16|0,e[l>>2]=0,r=e[P>>2]|0,O=e[$>>2]|0,c=r-O|0;do if((r|0)!=(O|0)){if((c|0)<0&&(g=0,ue(178,h|0),O=g,g=0,O&1)||(G=53),(G|0)==53&&(g=0,o=ge(67,c|0)|0,O=g,g=0,!(O&1))){if(e[d>>2]=o,e[h>>2]=o,e[l>>2]=o+c,r=e[$>>2]|0,l=e[P>>2]|0,(r|0)==(l|0))break;do S[o>>0]=S[r>>0]|0,o=(e[d>>2]|0)+1|0,e[d>>2]=o,r=r+1|0;while((r|0)!=(l|0));r=e[$>>2]|0;break}r=j()|0,o=e[h>>2]|0,o&&((e[d>>2]|0)!=(o|0)&&(e[d>>2]=o),he(o)),he(w),G=44;break e}while(!1);return r?((e[P>>2]|0)!=(r|0)&&(e[P>>2]=r),he(r),b=K,w|0):(b=K,w|0)}}else G=43}while(!1);return(G|0)==43&&(r=j()|0,G=44),(G|0)==44&&(o=r),r=e[$>>2]|0,r||le(o|0),(e[P>>2]|0)!=(r|0)&&(e[P>>2]=r),he(r),le(o|0),0}function co(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0;w=b,b=b+16|0,D=w,e[D>>2]=0,k=D+4|0,e[k>>2]=0,e[D+8>>2]=0,g=0,r=ge(67,1)|0,d=g,g=0;e:do if(!(d&1)&&(d=r+1|0,S[r>>0]=1,e[D>>2]=r,e[k>>2]=d,e[D+8>>2]=d,g=0,Ae(84,D|0,e[t>>2]&65535|0),d=g,g=0,!(d&1))&&(g=0,Ae(84,D|0,e[t+4>>2]&65535|0),d=g,g=0,!(d&1))&&(g=0,Ae(84,D|0,e[t+8>>2]&65535|0),d=g,g=0,!(d&1))&&(g=0,Ae(84,D|0,e[t+12>>2]&65535|0),d=g,g=0,!(d&1))&&(g=0,Ae(84,D|0,e[t+16>>2]&65535|0),d=g,g=0,!(d&1))&&(g=0,C=ge(67,20)|0,d=g,g=0,!(d&1))){e[C>>2]=36800,S[C+4>>0]=-8,c=C+8|0,e[c>>2]=0,d=C+12|0,e[d>>2]=0,t=C+16|0,e[t>>2]=0,r=e[k>>2]|0,N=e[D>>2]|0,l=r-N|0;do if((r|0)!=(N|0)){if((l|0)<0&&(g=0,ue(178,c|0),N=g,g=0,N&1)||(h=11),(h|0)==11&&(g=0,o=ge(67,l|0)|0,N=g,g=0,!(N&1))){if(e[d>>2]=o,e[c>>2]=o,e[t>>2]=o+l,r=e[D>>2]|0,t=e[k>>2]|0,(r|0)==(t|0))break;do S[o>>0]=S[r>>0]|0,o=(e[d>>2]|0)+1|0,e[d>>2]=o,r=r+1|0;while((r|0)!=(t|0));r=e[D>>2]|0;break}o=j()|0,r=e[c>>2]|0,r&&((e[d>>2]|0)!=(r|0)&&(e[d>>2]=r),he(r)),he(C);break e}while(!1);return r?((e[k>>2]|0)!=(r|0)&&(e[k>>2]=r),he(r),b=w,C|0):(b=w,C|0)}else h=25;while(!1);return(h|0)==25&&(o=j()|0),r=e[D>>2]|0,r||le(o|0),(e[k>>2]|0)!=(r|0)&&(e[k>>2]=r),he(r),le(o|0),0}function a6(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0;return h=Xe(5)|0,S[h>>0]=109,S[h+1>>0]=114,S[h+2>>0]=102,S[h+3>>0]=120,S[h+4>>0]=t,g=0,c=ge(67,20)|0,l=g,g=0,l&1&&(c=j()|0,he(h),le(c|0)),e[c>>2]=36800,S[c+4>>0]=-24,t=c+8|0,e[t>>2]=0,r=c+12|0,e[r>>2]=0,o=c+16|0,e[o>>2]=0,g=0,l=ge(67,5)|0,d=g,g=0,d&1?(d=j()|0,he(c),he(h),le(d|0),0):(e[r>>2]=l,e[t>>2]=l,e[o>>2]=l+5,S[l>>0]=109,d=(e[r>>2]|0)+1|0,e[r>>2]=d,l=h+1|0,S[d>>0]=S[l>>0]|0,d=(e[r>>2]|0)+1|0,e[r>>2]=d,l=l+1|0,S[d>>0]=S[l>>0]|0,d=(e[r>>2]|0)+1|0,e[r>>2]=d,l=l+1|0,S[d>>0]=S[l>>0]|0,d=(e[r>>2]|0)+1|0,e[r>>2]=d,S[d>>0]=S[l+1>>0]|0,e[r>>2]=(e[r>>2]|0)+1,he(h),c|0)}function l6(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0;G=b,b=b+16|0,$=G,e[$>>2]=0,P=$+4|0,e[P>>2]=0,e[$+8>>2]=0,Q=$+8|0,g=0,c=ge(67,1)|0,U=g,g=0;e:do if(U&1)K=29;else{if(w=c+1|0,U=w,S[c>>0]=r,e[$>>2]=c,e[P>>2]=U,e[Q>>2]=U,(r|0)>0){d=w,U=0;do{if(_=U+t&255,d>>>0>=w>>>0){if(c=e[$>>2]|0,C=c,d=d-C+1|0,(d|0)<0){if(g=0,ue(178,$|0),R=g,g=0,R&1){K=28;break}C=e[$>>2]|0,w=e[Q>>2]|0,R=C}else R=c;if(N=R,c=w-N|0,c>>>0<1073741823?(c=c<<1,c=c>>>0>>0?d:c,w=e[P>>2]|0,D=w-N|0,c?K=13:(k=0,d=0)):(D=e[P>>2]|0,c=2147483647,w=D,D=D-N|0,K=13),(K|0)==13)if(K=0,g=0,d=ge(67,c|0)|0,k=g,g=0,k&1){K=28;break}else k=c;S[d+D>>0]=_,c=d+(D+1)|0,N=w-N|0,_=d+(D-N)|0,o0(_|0,R|0,N|0)|0,e[$>>2]=_,e[P>>2]=c,e[Q>>2]=d+k,C&&(he(C),c=e[P>>2]|0)}else S[d>>0]=_,c=(e[P>>2]|0)+1|0,e[P>>2]=c;if(w=e[Q>>2]|0,c>>>0>=w>>>0){if(C=e[$>>2]|0,d=C,D=c-d+1|0,(D|0)<0){if(g=0,ue(178,$|0),_=g,g=0,_&1){K=28;break}C=e[$>>2]|0,d=C,w=e[Q>>2]|0}if(N=C,c=w-N|0,c>>>0<1073741823?(c=c<<1,c=c>>>0>>0?D:c,D=e[P>>2]|0,w=D-N|0,c?K=24:(c=0,k=0)):(w=e[P>>2]|0,c=2147483647,D=w,w=w-N|0,K=24),(K|0)==24&&(K=0,g=0,k=ge(67,c|0)|0,_=g,g=0,_&1)){K=28;break}S[k+w>>0]=0,R=D-N|0,_=k+(w-R)|0,o0(_|0,C|0,R|0)|0,e[$>>2]=_,e[P>>2]=k+(w+1),e[Q>>2]=k+c,d&&he(d)}else S[c>>0]=0,e[P>>2]=(e[P>>2]|0)+1;U=U+1|0,d=e[P>>2]|0,w=e[Q>>2]|0}while((U|0)<(r|0));if((K|0)==28){h=j()|0;break}c=o&255,d>>>0>>0?(S[d>>0]=c,d=(e[P>>2]|0)+1|0,e[P>>2]=d):K=37}else d=w,c=o&255,K=37;if((K|0)==37){if(C=e[$>>2]|0,D=C,k=d-D+1|0,(k|0)<0){if(g=0,ue(178,$|0),o=g,g=0,o&1){K=29;break}D=e[$>>2]|0,w=e[Q>>2]|0,C=D}if(_=C,d=w-_|0,d>>>0<1073741823?(d=d<<1,d=d>>>0>>0?k:d,k=e[P>>2]|0,N=k-_|0,d?K=43:(R=0,w=0)):(N=e[P>>2]|0,d=2147483647,k=N,N=N-_|0,K=43),(K|0)==43)if(g=0,w=ge(67,d|0)|0,o=g,g=0,o&1){K=29;break}else R=d;S[w+N>>0]=c,d=w+(N+1)|0,t=k-_|0,o=w+(N-t)|0,o0(o|0,C|0,t|0)|0,e[$>>2]=o,e[P>>2]=d,e[Q>>2]=w+R,D&&(he(D),d=e[P>>2]|0)}if(_=l&255,c=e[Q>>2]|0,d>>>0>=c>>>0){if(w=e[$>>2]|0,C=w,d=d-C+1|0,(d|0)<0){if(g=0,ue(178,$|0),l=g,g=0,l&1){K=29;break}C=e[$>>2]|0,c=e[Q>>2]|0,w=C}if(R=w,c=c-R|0,c>>>0<1073741823?(c=c<<1,c=c>>>0>>0?d:c,D=e[P>>2]|0,k=D-R|0,c?K=54:(N=0,d=0)):(k=e[P>>2]|0,c=2147483647,D=k,k=k-R|0,K=54),(K|0)==54)if(g=0,d=ge(67,c|0)|0,l=g,g=0,l&1){K=29;break}else N=c;S[d+k>>0]=_,c=d+(k+1)|0,o=D-R|0,l=d+(k-o)|0,o0(l|0,w|0,o|0)|0,e[$>>2]=l,e[P>>2]=c,e[Q>>2]=d+N,C&&(he(C),c=e[P>>2]|0)}else S[d>>0]=_,c=(e[P>>2]|0)+1|0,e[P>>2]=c;if(d=e[Q>>2]|0,c>>>0>=d>>>0){if(w=e[$>>2]|0,C=w,D=c-C+1|0,(D|0)<0){if(g=0,ue(178,$|0),l=g,g=0,l&1){K=29;break}C=e[$>>2]|0,d=e[Q>>2]|0,w=C}if(N=w,c=d-N|0,c>>>0<1073741823?(c=c<<1,c=c>>>0>>0?D:c,d=e[P>>2]|0,k=d-N|0,c?K=65:(c=0,D=0)):(k=e[P>>2]|0,c=2147483647,d=k,k=k-N|0,K=65),(K|0)==65&&(g=0,D=ge(67,c|0)|0,l=g,g=0,l&1)){K=29;break}S[D+k>>0]=0,o=d-N|0,l=D+(k-o)|0,o0(l|0,w|0,o|0)|0,e[$>>2]=l,e[P>>2]=D+(k+1),e[Q>>2]=D+c,C&&he(C)}else S[c>>0]=0,e[P>>2]=(e[P>>2]|0)+1;if(g=0,k=ge(67,20)|0,Q=g,g=0,Q&1)K=29;else{e[k>>2]=36800,S[k+4>>0]=-38,C=k+8|0,e[C>>2]=0,D=k+12|0,e[D>>2]=0,d=k+16|0,e[d>>2]=0,c=e[P>>2]|0,Q=e[$>>2]|0,w=c-Q|0;do if((c|0)!=(Q|0)){if((w|0)<0&&(g=0,ue(178,C|0),Q=g,g=0,Q&1)||(K=72),(K|0)==72&&(g=0,h=ge(67,w|0)|0,Q=g,g=0,!(Q&1))){if(e[D>>2]=h,e[C>>2]=h,e[d>>2]=h+w,c=e[$>>2]|0,d=e[P>>2]|0,(c|0)==(d|0))break;do S[h>>0]=S[c>>0]|0,h=(e[D>>2]|0)+1|0,e[D>>2]=h,c=c+1|0;while((c|0)!=(d|0));c=e[$>>2]|0;break}h=j()|0,c=e[C>>2]|0,c&&((e[D>>2]|0)!=(c|0)&&(e[D>>2]=c),he(c)),he(k);break e}while(!1);return c?((e[P>>2]|0)!=(c|0)&&(e[P>>2]=c),he(c),b=G,k|0):(b=G,k|0)}}while(!1);return(K|0)==29&&(h=j()|0),c=e[$>>2]|0,c||le(h|0),(e[P>>2]|0)!=(c|0)&&(e[P>>2]=c),he(c),le(h|0),0}function u6(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;if(N=(r&65535)>>>8&255,R=t+4|0,o=e[R>>2]|0,_=t+8|0,l=e[_>>2]|0,o>>>0>=l>>>0?(c=e[t>>2]|0,h=c,d=o-h+1|0,(d|0)<0&&(pi(t),h=e[t>>2]|0,l=e[_>>2]|0,c=h),k=c,o=l-k|0,o>>>0<1073741823?(o=o<<1,o=o>>>0>>0?d:o,d=e[R>>2]|0,l=d-k|0,o?U=8:(D=0,C=0,w=l,o=d)):(l=e[R>>2]|0,o=2147483647,d=l,l=l-k|0,U=8),(U|0)==8&&(D=o,C=Xe(o)|0,w=l,o=d),S[C+w>>0]=N,l=C+(w+1)|0,k=o-k|0,N=C+(w-k)|0,o0(N|0,c|0,k|0)|0,e[t>>2]=N,e[R>>2]=l,e[_>>2]=C+D,h&&(he(h),l=e[R>>2]|0)):(S[o>>0]=N,l=(e[R>>2]|0)+1|0,e[R>>2]=l),k=r&255,o=e[_>>2]|0,l>>>0>>0){S[l>>0]=k,e[R>>2]=(e[R>>2]|0)+1;return}c=e[t>>2]|0,h=c,l=l-h+1|0,(l|0)<0&&(pi(t),h=e[t>>2]|0,o=e[_>>2]|0,c=h),D=c,o=o-D|0,o>>>0<1073741823?(o=o<<1,o=o>>>0>>0?l:o,d=e[R>>2]|0,l=d-D|0,o?U=18:(C=0,w=0,o=d)):(l=e[R>>2]|0,o=2147483647,d=l,l=l-D|0,U=18),(U|0)==18&&(C=o,w=Xe(o)|0,o=d),S[w+l>>0]=k,r=o-D|0,U=w+(l-r)|0,o0(U|0,c|0,r|0)|0,e[t>>2]=U,e[R>>2]=w+(l+1),e[_>>2]=w+C,h&&he(h)}function c6(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;if(c=e[t>>2]|0,U=e[r>>2]|0,_=U,C=c,N=o,D=l-N|0,(D|0)<=0)return Q=U,Q|0;if(R=t+8|0,r=e[R>>2]|0,Q=t+4|0,k=e[Q>>2]|0,h=k,(D|0)<=(r-h|0)){if(w=h-_|0,(D|0)>(w|0)){if(d=o+w|0,(d|0)==(l|0))r=k;else{h=d,r=k;do S[r>>0]=S[h>>0]|0,r=(e[Q>>2]|0)+1|0,e[Q>>2]=r,h=h+1|0;while((h|0)!=(l|0))}if((w|0)>0)w=r;else return Q=U,Q|0}else w=k,d=l;if(c=w-(c+(D-C+_))|0,r=U+c|0,r>>>0>>0){h=w;do S[h>>0]=S[r>>0]|0,r=r+1|0,h=(e[Q>>2]|0)+1|0,e[Q>>2]=h;while((r|0)!=(k|0))}return vn(w+(0-c)|0,U|0,c|0)|0,vn(U|0,o|0,d-N|0)|0,Q=U,Q|0}if(h=h-C+D|0,(h|0)<0&&(pi(t),r=e[R>>2]|0,c=e[t>>2]|0),d=c,r=r-d|0,r>>>0<1073741823?(r=r<<1,r=r>>>0>>0?h:r,h=_-d|0,r?w=15:(d=0,D=0)):(r=2147483647,h=_-d|0,w=15),(w|0)==15&&(d=r,D=Xe(r)|0),C=D+h|0,r=C,w=D+d|0,(o|0)!=(l|0)){c=o,d=C;do S[d>>0]=S[c>>0]|0,d=r+1|0,r=d,c=c+1|0;while((c|0)!=(l|0));c=e[t>>2]|0}return o=_-c|0,l=D+(h-o)|0,o0(l|0,c|0,o|0)|0,_=(e[Q>>2]|0)-_|0,o=r,o0(o|0,U|0,_|0)|0,r=e[t>>2]|0,e[t>>2]=l,e[Q>>2]=o+_,e[R>>2]=w,r?(he(r),Q=C,Q|0):(Q=C,Q|0)}function f6(t){t=t|0;var r=0;e[t>>2]=36800,r=e[t+8>>2]|0,r&&(t=t+12|0,(e[t>>2]|0)!=(r|0)&&(e[t>>2]=r),he(r))}function h6(t){t=t|0;var r=0,o=0;if(e[t>>2]=36800,r=e[t+8>>2]|0,!r){he(t);return}o=t+12|0,(e[o>>2]|0)!=(r|0)&&(e[o>>2]=r),he(r),he(t)}function d6(t,r){t=t|0,r=r|0;var o=0,l=0,c=0;if(ui(r,-1),ui(r,S[t+4>>0]|0),c=t+12|0,l=t+8|0,t=(e[c>>2]|0)-(e[l>>2]|0)+2|0,ui(r,(t&65535)>>>8&255),ui(r,t&255),t=e[l>>2]|0,(e[c>>2]|0)!=(t|0)){o=0;do ui(r,S[t+o>>0]|0),o=o+1|0,t=e[l>>2]|0;while(o>>>0<((e[c>>2]|0)-t|0)>>>0)}}function ui(t,r){t=t|0,r=r|0;var o=0,l=0,c=0;if(c=e[t+4>>2]|0,c)if(o=c+24|0,l=e[o>>2]|0,(l|0)==(e[c+28>>2]|0)){U0[e[(e[c>>2]|0)+52>>2]&63](c,r&255)|0;return}else{e[o>>2]=l+1,S[l>>0]=r;return}if(o=t+16|0,l=e[o>>2]|0,l>>>0<(e[t+12>>2]|0)>>>0){e[o>>2]=l+1,S[(e[t+8>>2]|0)+l>>0]=r;return}o=Ct(16)|0,g=0,l=Ce(1)|0,r=g,g=0,r&1&&(r=j()|0,Tt(o|0),le(r|0)),g=0,xe(7,o|0,4,l|0),r=g,g=0,r&1?(r=j()|0,Tt(o|0),le(r|0)):Qt(o|0,824,96)}function m0(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0;e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,c=(r|0)<4095?(r+128|0)/256|0:16,h=(o*3|0)+2+c|0,l=o+1|0,h=(h|0)<(l|0)|(h|0)>(r|0)?l:h,e[t+4>>2]=h,l=(c<<2|3)+(o*5|0)|0,l=(l|0)>(r|0)|(l|0)<(h|0)?h:l,e[t+8>>2]=l,o=(o*7|0)+4+(c*17|0)|0,e[t+12>>2]=(o|0)>(r|0)|(o|0)<(l|0)?l:o,e[t>>2]=r,e[t+16>>2]=64}function p6(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;D=b,b=b+128|0,w=D+100|0,l=D+16|0,o=D+112|0,C=D+4|0,k=D,c=l,h=t+20|0,d=c+84|0;do e[c>>2]=e[h>>2],c=c+4|0,h=h+4|0;while((c|0)<(d|0));e[l+16>>2]=e[t+4>>2],h=wa(o,l,t+56|0)|0,o=e[(e[h>>2]|0)+16>>2]|0,t=t+8|0,g=0,e[w>>2]=e[t>>2],e[w+4>>2]=e[t+4>>2],e[w+8>>2]=e[t+8>>2],o=be(o|0,h|0,w|0)|0,t=g,g=0;do if(t&1)o=j()|0;else{if(c=r+4|0,e[C>>2]=e[c>>2],e[C+4>>2]=e[c+4>>2],e[C+8>>2]=e[c+8>>2],c=r+16|0,t=e[c>>2]|0,w=C+8|0,e[w>>2]=(e[w>>2]|0)-t,w=C+4|0,e[w>>2]=(e[w>>2]|0)+t,w=e[(e[h>>2]|0)+12>>2]|0,e[k>>2]=o,g=0,o=Pe(w|0,h|0,k|0,C|0,(S[r>>0]|0?(e[r+8>>2]|0)+t|0:0)|0)|0,C=g,g=0,C&1){if(o=j()|0,l=e[k>>2]|0,e[k>>2]=0,!l)break;Mt[e[(e[l>>2]|0)+4>>2]&255](l);break}if(l=e[k>>2]|0,e[k>>2]=0,l&&Mt[e[(e[l>>2]|0)+4>>2]&255](l),e[r+4>>2]|0||(e[c>>2]=(e[c>>2]|0)+o),!h){b=D;return}Mt[e[(e[h>>2]|0)+4>>2]&255](h),b=D;return}while(!1);h||le(o|0),Mt[e[(e[h>>2]|0)+4>>2]&255](h),le(o|0)}function m6(t,r){t=t|0,r=r|0,e[t>>2]=e[r>>2],e[t+4>>2]=e[r+4>>2],e[t+8>>2]=e[r+8>>2],S[t+12>>0]=0,r=t+16|0,t=r+100|0;do e[r>>2]=0,r=r+4|0;while((r|0)<(t|0))}function g6(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0;G=b,b=b+32|0,K=G+4|0,R=G+16|0,$=G,fo(t),_=t+16|0,c=e[t+24>>2]|0;e:do if((c+-2|0)>>>0<=14)if(U=t+40|0,o=e[U>>2]|0,o>>>0>2)o=5;else{switch(Q=t+32|0,h=e[Q>>2]|0,h|0){case 0:{o=1;break e}case 4:{if((o|0)==2){o=2;break e}break}case 3:break;default:if(o){o=2;break e}}if(N=t+100|0,o=t+108|0,l=e[o>>2]|0,(l|0)<1?(l=e[_>>2]|0,e[o>>2]=l,o=e[t+20>>2]|0,e[t+112>>2]=o):o=e[t+112>>2]|0,C=Qi(o|0,((o|0)<0)<<31>>31|0,l|0,((l|0)<0)<<31>>31|0)|0,w=(c+7|0)/8|0,w=Qi(C|0,ye|0,w|0,((w|0)<0)<<31>>31|0)|0,C=r+4|0,o=e[C>>2]|0,d=r+8|0,o|0&&(D=e[d>>2]|0,k=Qi(h|0,((h|0)<0)<<31>>31|0,w|0,ye|0)|0,c=ye,0<(c|0)|(c|0)==0&D>>>0>>0)&&(o=Ct(16)|0,g=0,l=Ce(1)|0,$=g,g=0,!($&1)&&(g=0,xe(7,o|0,3,l|0),$=g,g=0,!($&1))&&Qt(o|0,824,96),$=j()|0,Tt(o|0),le($|0)),D=t+52|0,k=t+12|0,(h|0)>0)h=0;else{b=G;return}for(;;){if(ho(t,(h|0)==0),l=va(R,_,D)|0,c=e[(e[l>>2]|0)+8>>2]|0,g=0,e[K>>2]=e[r>>2],e[K+4>>2]=e[r+4>>2],e[K+8>>2]=e[r+8>>2],c=be(c|0,l|0,K|0)|0,P=g,g=0,P&1){c=32;break}if(P=e[(e[l>>2]|0)+16>>2]|0,e[$>>2]=c,g=0,Re(P|0,l|0,$|0,N|0,t|0,(S[k>>0]|0)!=0|0),P=g,g=0,P&1){c=30;break}if(c=e[$>>2]|0,e[$>>2]=0,c&&Mt[e[(e[c>>2]|0)+4>>2]&255](c),o?(o=o+w|0,e[C>>2]=o,e[d>>2]=(e[d>>2]|0)-w):o=0,c=(e[U>>2]|0)==0,h=(c&1)+h|0,l&&Mt[e[(e[l>>2]|0)+4>>2]&255](l),!c){c=34;break}if((h|0)>=(e[Q>>2]|0)){c=34;break}}if((c|0)==30)o=j()|0,c=e[$>>2]|0,e[$>>2]=0,c&&Mt[e[(e[c>>2]|0)+4>>2]&255](c);else if((c|0)==32)o=j()|0,l||(P=o,le(P|0));else if((c|0)==34){b=G;return}Mt[e[(e[l>>2]|0)+4>>2]&255](l),P=o,le(P|0)}else o=2;while(!1);l=Ct(16)|0,g=0,c=Ce(1)|0,P=g,g=0,!(P&1)&&(g=0,xe(7,l|0,o|0,c|0),P=g,g=0,!(P&1))&&Qt(l|0,824,96),P=j()|0,Tt(l|0),le(P|0)}function fo(t){t=t|0;var r=0,o=0,l=0,c=0;if((Ir(t)|0)<<24>>24!=-40&&(r=Ct(16)|0,g=0,o=Ce(1)|0,c=g,g=0,!(c&1)&&(g=0,xe(7,r|0,5,o|0),c=g,g=0,!(c&1))&&Qt(r|0,824,96),c=j()|0,Tt(r|0),le(c|0)),r=Ir(t)|0,r<<24>>24!=-38){for(;l=((d0(t)|0)&255)<<8,l=l|(d0(t)|0)&255,r=A6(t,r)|0,o=-2-r+l|0,!((o|0)<0);){if((o|0)>0){r=l+-2-r|0,o=0;do d0(t)|0,o=o+1|0;while((o|0)!=(r|0))}if(r=Ir(t)|0,r<<24>>24==-38){c=8;break}}(c|0)!=8&&(r=Ct(16)|0,g=0,o=Ce(1)|0,c=g,g=0,!(c&1)&&(g=0,xe(7,r|0,5,o|0),c=g,g=0,!(c&1))&&Qt(r|0,824,96),c=j()|0,Tt(r|0),le(c|0))}}function ho(t,r){t=t|0,r=r|0;var o=0,l=0,c=0;r||((d0(t)|0)<<24>>24!=-1&&(r=Ct(16)|0,g=0,o=Ce(1)|0,t=g,g=0,!(t&1)&&(g=0,xe(7,r|0,12,o|0),t=g,g=0,!(t&1))&&Qt(r|0,824,96),t=j()|0,Tt(r|0),le(t|0)),(d0(t)|0)<<24>>24!=-38&&(r=Ct(16)|0,g=0,o=Ce(1)|0,t=g,g=0,!(t&1)&&(g=0,xe(7,r|0,5,o|0),t=g,g=0,!(t&1))&&Qt(r|0,824,96),t=j()|0,Tt(r|0),le(t|0))),d0(t)|0,d0(t)|0,o=d0(t)|0,l=o&255;do if(o<<24>>24==1)d0(t)|0,o=0,c=20;else{if((l|0)==(e[t+32>>2]|0))if(r=d0(t)|0,o<<24>>24){o=0,c=20;break}else break;r=Ct(16)|0,g=0,o=Ce(1)|0,t=g,g=0,!(t&1)&&(g=0,xe(7,r|0,2,o|0),t=g,g=0,!(t&1))&&Qt(r|0,824,96),t=j()|0,Tt(r|0),le(t|0)}while(!1);if((c|0)==20)for(;d0(t)|0,o=o+1|0,r=d0(t)|0,(o|0)!=(l|0);)c=20;e[t+36>>2]=r&255,c=d0(t)|0,o=t+40|0,e[o>>2]=c&255,(c&255)>=3&&(r=Ct(16)|0,g=0,o=Ce(1)|0,t=g,g=0,!(t&1)&&(g=0,xe(7,r|0,5,o|0),t=g,g=0,!(t&1))&&Qt(r|0,824,96),t=j()|0,Tt(r|0),le(t|0)),(d0(t)|0)<<24>>24&&(r=Ct(16)|0,g=0,o=Ce(1)|0,t=g,g=0,!(t&1)&&(g=0,xe(7,r|0,5,o|0),t=g,g=0,!(t&1))&&Qt(r|0,824,96),t=j()|0,Tt(r|0),le(t|0)),l=t+28|0,!(e[l>>2]|0)&&(r=e[t+108>>2]|0,r||(r=e[t+16>>2]|0),e[o>>2]|0?o=e[t+32>>2]|0:o=1,c=ee(o,r)|0,t=ee(c,((e[t+24>>2]|0)+7|0)/8|0)|0,e[l>>2]=t)}function S6(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;if(!((o|0)<=0)){N=r+4|0,R=r+8|0,U=0;do _=d0(t)|0,l=e[N>>2]|0,c=e[R>>2]|0,l>>>0>=c>>>0?(h=e[r>>2]|0,d=h,w=l-d+1|0,(w|0)<0&&(pi(r),d=e[r>>2]|0,c=e[R>>2]|0,h=d),k=h,l=c-k|0,l>>>0<1073741823?(l=l<<1,l=l>>>0>>0?w:l,w=e[N>>2]|0,c=w-k|0,l?Q=10:(D=0,C=0,l=w)):(c=e[N>>2]|0,l=2147483647,w=c,c=c-k|0,Q=10),(Q|0)==10&&(Q=0,D=l,C=Xe(l)|0,l=w),S[C+c>>0]=_,k=l-k|0,_=C+(c-k)|0,o0(_|0,h|0,k|0)|0,e[r>>2]=_,e[N>>2]=C+(c+1),e[R>>2]=C+D,d&&he(d)):(S[l>>0]=_,e[N>>2]=(e[N>>2]|0)+1),U=U+1|0;while((U|0)!=(o|0))}}function d0(t){t=t|0;var r=0,o=0,l=0,c=0;return o=e[t>>2]|0,o?(t=o+12|0,r=e[t>>2]|0,(r|0)==(e[o+16>>2]|0)?t=Dt[e[(e[o>>2]|0)+40>>2]&127](o)|0:(e[t>>2]=r+1,t=F[r>>0]|0),c=t&255,c|0):(l=t+8|0,c=e[l>>2]|0,c?(t=t+4|0,r=e[t>>2]|0,o=S[r>>0]|0,r?(e[t>>2]=r+1,e[l>>2]=c+-1,c=o,c|0):(c=o,c|0)):(t=Ct(16)|0,g=0,r=Ce(1)|0,c=g,g=0,c&1&&(c=j()|0,Tt(t|0),le(c|0)),g=0,xe(7,t|0,4,r|0),c=g,g=0,c&1?(c=j()|0,Tt(t|0),le(c|0)):Qt(t|0,824,96),0))}function Ir(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0,w=0,C=0;if(o=b,b=b+176|0,r=o+152|0,C=o+16|0,d=o,w=d0(t)|0,l=w&255,w<<24>>24==-1){do r=d0(t)|0;while(r<<24>>24==-1);return b=o,r|0}w=C+56|0,h=C+4|0,e[C>>2]=36160,e[w>>2]=36180,g=0,Ae(62,C+56|0,h|0),c=g,g=0,c&1&&(C=j()|0,tt(w),le(C|0)),e[C+128>>2]=0,e[C+132>>2]=-1,e[C>>2]=36200,e[C+56>>2]=36220,g=0,ue(180,h|0),c=g,g=0;do if(c&1)r=j()|0;else{if(e[h>>2]=36236,c=C+36|0,e[c>>2]=0,e[c+4>>2]=0,e[c+8>>2]=0,e[c+12>>2]=0,e[C+52>>2]=16,e[r>>2]=0,e[r+4>>2]=0,e[r+8>>2]=0,g=0,Ae(63,h|0,r|0),o=g,g=0,o&1){C=j()|0,de(r),de(c),wt(h),r=C;break}de(r),e[C+((e[(e[C>>2]|0)+-12>>2]|0)+76)>>2]=48,g=0,r=Ve(28,C|0,50907,62)|0,o=g,g=0,!(o&1)&&(o=r+((e[(e[r>>2]|0)+-12>>2]|0)+4)|0,e[o>>2]=e[o>>2]&-75|8,o=r+((e[(e[r>>2]|0)+-12>>2]|0)+4)|0,e[o>>2]=e[o>>2]|16384,e[r+((e[(e[r>>2]|0)+-12>>2]|0)+12)>>2]=2,g=0,be(38,r|0,l|0)|0,l=g,g=0,!(l&1))&&(o=Ct(16)|0,g=0,Ae(64,d|0,h|0),l=g,g=0,l&1?r=j()|0:(g=0,r=Ce(1)|0,l=g,g=0,!(l&1)&&(g=0,$e(36,o|0,12,r|0,d|0),l=g,g=0,!(l&1))?(g=0,xe(6,o|0,824,96),g=0,t=0):t=1,r=j()|0,de(d),t||(d=r,e[C>>2]=36200,e[w>>2]=36220,e[h>>2]=36236,de(c),wt(h),tt(w),le(d|0))),Tt(o|0),d=r,e[C>>2]=36200,e[w>>2]=36220,e[h>>2]=36236,de(c),wt(h),tt(w),le(d|0)),d=j()|0,e[C>>2]=36200,e[w>>2]=36220,e[h>>2]=36236,de(c),wt(h),tt(w),le(d|0)}while(!1);return C=r,tt(w),le(C|0),0}function A6(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;switch(o=b,b=b+320|0,w=o+300|0,k=o+152|0,C=o+288|0,N=o+16|0,D=o,r<<24>>24){case-9:return R=(d0(t)|0)&255,e[t+24>>2]=R,R=((d0(t)|0)&255)<<8|(d0(t)|0)&255,N=((d0(t)|0)&255)<<8|(d0(t)|0)&255,e[t+16>>2]=N,e[t+20>>2]=R,R=(d0(t)|0)&255,e[t+32>>2]=R,R=6,b=o,R|0;case-8:return R=v6(t)|0,b=o,R|0;case-24:return R=x6(t)|0,b=o,R|0;case-53:case-54:case-55:case-57:case-58:case-59:case-61:case-62:case-63:case-64:{d=k+56|0,c=k+4|0,e[k>>2]=36160,e[d>>2]=36180,g=0,Ae(62,k+56|0,c|0),N=g,g=0,N&1&&(R=j()|0,tt(d),le(R|0)),e[k+128>>2]=0,e[k+132>>2]=-1,e[k>>2]=36200,e[k+56>>2]=36220,g=0,ue(180,c|0),N=g,g=0;do if(N&1)t=j()|0;else{if(e[c>>2]=36236,h=k+36|0,e[h>>2]=0,e[h+4>>2]=0,e[h+8>>2]=0,e[h+12>>2]=0,e[k+52>>2]=16,e[w>>2]=0,e[w+4>>2]=0,e[w+8>>2]=0,g=0,Ae(63,c|0,w|0),N=g,g=0,N&1){t=j()|0,de(w),de(h),wt(c);break}de(w),g=0,t=Ve(28,k|0,50970,26)|0,N=g,g=0;do if(!(N&1)&&(g=0,l=be(38,t|0,r&255|0)|0,N=g,g=0,!(N&1))&&(g=0,Ve(28,l|0,50997,18)|0,N=g,g=0,!(N&1))){if(l=Ct(16)|0,g=0,Ae(64,C|0,c|0),N=g,g=0,N&1)t=j()|0;else if(g=0,t=Ce(1)|0,N=g,g=0,!(N&1)&&(g=0,$e(36,l|0,10,t|0,C|0),N=g,g=0,!(N&1))?(g=0,xe(6,l|0,824,96),g=0,o=0):o=1,t=j()|0,de(C),!o)break;Tt(l|0)}else R=20;while(!1);(R|0)==20&&(t=j()|0),e[k>>2]=36200,e[d>>2]=36220,e[c>>2]=36236,de(h),wt(c),tt(d),R=t,le(R|0)}while(!1);R=t,tt(d),le(R|0)}case-25:case-32:case-2:return R=0,b=o,R|0;default:{C=N+56|0,h=N+4|0,e[N>>2]=36160,e[C>>2]=36180,g=0,Ae(62,N+56|0,h|0),k=g,g=0,k&1&&(R=j()|0,tt(C),le(R|0)),e[N+128>>2]=0,e[N+132>>2]=-1,e[N>>2]=36200,e[N+56>>2]=36220,g=0,ue(180,h|0),k=g,g=0;do if(k&1)t=j()|0;else{if(e[h>>2]=36236,d=N+36|0,e[d>>2]=0,e[d+4>>2]=0,e[d+8>>2]=0,e[d+12>>2]=0,e[N+52>>2]=16,e[w>>2]=0,e[w+4>>2]=0,e[w+8>>2]=0,g=0,Ae(63,h|0,w|0),k=g,g=0,k&1){t=j()|0,de(w),de(d),wt(h);break}de(w),g=0,t=Ve(28,N|0,51016,20)|0,k=g,g=0;do if(!(k&1)&&(g=0,c=be(38,t|0,r&255|0)|0,k=g,g=0,!(k&1))&&(g=0,Ve(28,c|0,51037,13)|0,k=g,g=0,!(k&1))){if(l=Ct(16)|0,g=0,Ae(64,D|0,h|0),k=g,g=0,k&1)t=j()|0;else if(g=0,t=Ce(1)|0,k=g,g=0,!(k&1)&&(g=0,$e(36,l|0,11,t|0,D|0),k=g,g=0,!(k&1))?(g=0,xe(6,l|0,824,96),g=0,o=0):o=1,t=j()|0,de(D),!o)break;Tt(l|0)}else R=40;while(!1);(R|0)==40&&(t=j()|0),e[N>>2]=36200,e[C>>2]=36220,e[h>>2]=36236,de(d),wt(h),tt(C),R=t,le(R|0)}while(!1);R=t,tt(C),le(R|0)}}return 0}function v6(t){t=t|0;var r=0;return(d0(t)|0)<<24>>24!=1?(t=1,t|0):(r=((d0(t)|0)&255)<<8,r=r|(d0(t)|0)&255,e[t+52>>2]=r,r=((d0(t)|0)&255)<<8,r=r|(d0(t)|0)&255,e[t+56>>2]=r,r=((d0(t)|0)&255)<<8,r=r|(d0(t)|0)&255,e[t+60>>2]=r,r=((d0(t)|0)&255)<<8,r=r|(d0(t)|0)&255,e[t+64>>2]=r,r=((d0(t)|0)&255)<<8,r=r|(d0(t)|0)&255,e[t+68>>2]=r,t=11,t|0)}function x6(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0;o=b,b=b+16|0,c=o,e[c>>2]=0,h=c+4|0,e[h>>2]=0,e[c+8>>2]=0,g=0,xe(9,t|0,c|0,4),r=g,g=0;e:do if(r&1)l=3;else{r=e[c>>2]|0;t:do if(US(r,51051,4)|0)t=4;else{if(g=0,r=ge(69,t|0)|0,d=g,g=0,d&1){l=3;break e}switch(r=r&255,r|0){case 3:case 2:case 1:case 0:{e[t+44>>2]=r,t=5,r=e[c>>2]|0;break t}case 5:case 4:{if(r=Ct(16)|0,g=0,t=Ce(1)|0,d=g,g=0,!(d&1)&&(g=0,xe(7,r|0,7,t|0),d=g,g=0,!(d&1))){g=0,xe(6,r|0,824,96),g=0,l=3;break e}t=j()|0,Tt(r|0);break e}default:{if(r=Ct(16)|0,g=0,t=Ce(1)|0,d=g,g=0,!(d&1)&&(g=0,xe(7,r|0,5,t|0),d=g,g=0,!(d&1))){g=0,xe(6,r|0,824,96),g=0,l=3;break e}t=j()|0,Tt(r|0);break e}}}while(!1);return r?((e[h>>2]|0)!=(r|0)&&(e[h>>2]=r),he(r),b=o,t|0):(b=o,t|0)}while(!1);return(l|0)==3&&(t=j()|0),r=e[c>>2]|0,r||le(t|0),(e[h>>2]|0)!=(r|0)&&(e[h>>2]=r),he(r),le(t|0),0}function w6(t){t=t|0;var r=0,o=0,l=0;l=e[(e[t>>2]|0)+-12>>2]|0,e[t+l>>2]=36200,r=t+(l+56)|0,e[r>>2]=36220,o=t+(l+4)|0,e[o>>2]=36236,de(t+(l+36)|0),wt(o),tt(r)}function y6(t){t=t|0}function C6(t){t=t|0,he(t)}function T6(t){t=t|0,S[t>>0]=0,t=t+4|0,e[t>>2]=0,e[t+4>>2]=0,e[t+8>>2]=0,e[t+12>>2]=0,e[t+16>>2]=0,e[t+20>>2]=0,e[t+24>>2]=0,e[t+28>>2]=0}function I6(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0;if(c=b,b=b+16|0,h=c,r=a6(r)|0,e[h>>2]=r,o=t+28|0,l=e[o>>2]|0,l>>>0<(e[t+32>>2]|0)>>>0){e[l>>2]=r,e[o>>2]=l+4,e[h>>2]=0,b=c;return}if(g=0,Ae(57,t+24|0,h|0),t=g,g=0,t&1)r=j()|0,o=e[h>>2]|0,e[h>>2]=0,o||le(r|0),Mt[e[(e[o>>2]|0)+4>>2]&255](o),le(r|0);else{if(r=e[h>>2]|0,e[h>>2]=0,!r){b=c;return}Mt[e[(e[r>>2]|0)+4>>2]&255](r),b=c;return}}function E6(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0;if(l=t+4|0,e[l>>2]=e[r>>2],e[l+4>>2]=e[r+4>>2],e[l+8>>2]=e[r+8>>2],ui(t,-1),ui(t,-40),l=t+28|0,c=t+24|0,r=e[c>>2]|0,(e[l>>2]|0)==(r|0))return ui(t,-1),ui(t,-39),t=t+16|0,t=e[t>>2]|0,t|0;o=0;do h=e[r+(o<<2)>>2]|0,t0[e[(e[h>>2]|0)+8>>2]&127](h,t),o=o+1|0,r=e[c>>2]|0;while(o>>>0<(e[l>>2]|0)-r>>2>>>0);return ui(t,-1),ui(t,-39),h=t+16|0,h=e[h>>2]|0,h|0}function k6(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;N=b,b=b+48|0,w=N+32|0,c=N+12|0,C=N+8|0,k=N+4|0,R=N,l=o+36|0;do if(!(e[l>>2]|0)&&!(e[o+40>>2]|0)&&!(e[o+44>>2]|0)&&!(e[o+48>>2]|0)&&!(e[o+52>>2]|0)){if(l=e[o+8>>2]|0,(l|0)<=12){h=t+28|0,d=t+32|0;break}if(m0(c,(1<>2]|0),l=co(c)|0,e[C>>2]=l,h=t+28|0,c=e[h>>2]|0,d=t+32|0,c>>>0<(e[d>>2]|0)>>>0){e[c>>2]=l,e[h>>2]=c+4,e[C>>2]=0;break}if(g=0,Ae(57,t+24|0,C|0),w=g,g=0,!(w&1)){if(l=e[C>>2]|0,e[C>>2]=0,!l)break;Mt[e[(e[l>>2]|0)+4>>2]&255](l);break}o=j()|0,l=e[C>>2]|0,e[C>>2]=0,l||(R=o,le(R|0)),Mt[e[(e[l>>2]|0)+4>>2]&255](l),R=o,le(R|0)}else D=6;while(!1);do if((D|0)==6){if(l=co(l)|0,e[w>>2]=l,h=t+28|0,c=e[h>>2]|0,d=t+32|0,c>>>0<(e[d>>2]|0)>>>0){e[c>>2]=l,e[h>>2]=c+4,e[w>>2]=0;break}if(g=0,Ae(57,t+24|0,w|0),D=g,g=0,!(D&1)){if(l=e[w>>2]|0,e[w>>2]=0,!l)break;Mt[e[(e[l>>2]|0)+4>>2]&255](l);break}o=j()|0,l=e[w>>2]|0,e[w>>2]=0,l||(R=o,le(R|0)),Mt[e[(e[l>>2]|0)+4>>2]&255](l),R=o,le(R|0)}while(!1);l=t+20|0,c=(e[l>>2]|0)+1|0,e[l>>2]=c,l=e[o+24>>2]|0,w=l|0?e[o+16>>2]|0:1,l=l6(c,w,e[o+20>>2]|0,l)|0,e[k>>2]=l,c=e[h>>2]|0;do if(c>>>0<(e[d>>2]|0)>>>0)e[c>>2]=l,e[h>>2]=c+4,e[k>>2]=0;else{if(g=0,Ae(57,t+24|0,k|0),D=g,g=0,!(D&1)){if(l=e[k>>2]|0,e[k>>2]=0,!l)break;Mt[e[(e[l>>2]|0)+4>>2]&255](l);break}o=j()|0,l=e[k>>2]|0,e[k>>2]=0,l||(R=o,le(R|0)),Mt[e[(e[l>>2]|0)+4>>2]&255](l),R=o,le(R|0)}while(!1);C=Xe(104)|0,e[C>>2]=36820,e[C+4>>2]=w,c=C+8|0,e[c>>2]=e[r>>2],e[c+4>>2]=e[r+4>>2],e[c+8>>2]=e[r+8>>2],c=C+20|0,l=c+84|0;do e[c>>2]=e[o>>2],c=c+4|0,o=o+4|0;while((c|0)<(l|0));if(e[R>>2]=C,o=e[h>>2]|0,o>>>0<(e[d>>2]|0)>>>0){e[o>>2]=C,e[h>>2]=o+4,e[R>>2]=0,b=N;return}if(g=0,Ae(57,t+24|0,R|0),t=g,g=0,t&1)o=j()|0,l=e[R>>2]|0,e[R>>2]=0,l||(R=o,le(R|0)),Mt[e[(e[l>>2]|0)+4>>2]&255](l),R=o,le(R|0);else{if(o=e[R>>2]|0,e[R>>2]=0,!o){b=N;return}Mt[e[(e[o>>2]|0)+4>>2]&255](o),b=N;return}}function D6(t,r,o,l,c,h,d,w,C,D,k){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0,D=D|0,k=k|0;var N=0,R=0,_=0,U=0,Q=0,K=0,G=0;return _=b,b=b+96|0,R=_,N=ma(t,r,R,0)|0,N?(c=N,b=_,c|0):(S[R+32>>0]=0,Q=e[R+8>>2]|0,G=e[R>>2]|0,K=e[R+4>>2]|0,N=ee(K,G)|0,U=e[R+16>>2]|0,N=ee(ee(N,(Q|0)<9?1:2)|0,U)|0,e[l>>2]=N,N=E0(N)|0,e[o>>2]=N,e[c>>2]=G,e[h>>2]=K,e[d>>2]=Q,e[w>>2]=e[R+12>>2],e[C>>2]=U,e[D>>2]=e[R+20>>2],e[k>>2]=e[R+24>>2],c=ga(N,e[l>>2]|0,t,r,0,0)|0,b=_,c|0)}function b6(t,r,o,l,c,h,d,w,C){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,d=d|0,w=w|0,C=C|0;var D=0,k=0,N=0,R=0;N=b,b=b+96|0,D=N+4|0,d=N,k=D,R=k+84|0;do e[k>>2]=0,k=k+4|0;while((k|0)<(R|0));return e[D+16>>2]=h,e[D+8>>2]=c,e[D>>2]=o,e[D+4>>2]=l,o=E0(r)|0,e[w>>2]=o,e[d>>2]=0,o=pa(w,r,d,t,r,D,0)|0,e[C>>2]=e[d>>2],b=N,o|0}function Fi(t,r){t=t|0,r=r|0;var o=0;o=b,b=b+16|0,e[o>>2]=r,r=e[9320]|0,Po(r,t,o)|0,PS(10,r)|0,St()}function si(t){t=t|0,Lr(51337,51366,1164,51442)}function pi(t){t=t|0,Lr(51463,51486,303,51442)}function po(){var t=0,r=0;if(t=b,b=b+16|0,Qo(37024,4)|0)Fi(51562,t);else return r=Ho(e[9255]|0)|0,b=t,r|0;return 0}function Xe(t){t=t|0;var r=0;r=t|0?t:1,t=E0(r)|0;e:do if(!t){for(;t=L6()|0,!!t;)if(Vo[t&7](),t=E0(r)|0,t)break e;r=Ct(4)|0,e[r>>2]=36844,Qt(r|0,592,78)}while(!1);return t|0}function he(t){t=t|0,n0(t)}function N6(t){t=t|0,he(t)}function F6(t){t=t|0,e[t>>2]=36844}function R6(t){t=t|0}function M6(t){t=t|0,he(t)}function _6(t){return t=t|0,51611}function mo(t){t=t|0;var r=0;r=b,b=b+16|0,g=0,Nt(t|0),t=g,g=0,t&1||(g=0,Ae(85,51626,r|0),g=0),t=j(0)|0,K0(t|0)|0,g=0,Ae(85,51666,r+8|0),g=0,t=j(0)|0,g=0,Nt(3),r=g,g=0,r&1?(r=j(0)|0,$t(r)):$t(t)}function P6(){var t=0,r=0,o=0;g=0,t=Ce(2)|0,o=g,g=0,o&1&&(o=j(0)|0,$t(o)),t|0&&(r=e[t>>2]|0,(r|0)!=0)&&(o=r+48|0,(e[o>>2]&-256|0)==1126902528?(e[o+4>>2]|0)==1129074247:0)&&mo(e[r+12>>2]|0),o=e[9208]|0,e[9208]=o+0,mo(o)}function L6(){var t=0;return t=e[9214]|0,e[9214]=t+0,t|0}function wA(t){t=t|0}function In(t){t=t|0,e[t>>2]=36868,uS(t+4|0)}function O6(t){t=t|0,In(t),he(t)}function $6(t){return t=t|0,e[t+4>>2]|0}function yA(t){t=t|0}function B6(t){t=t|0,e[t>>2]=36888}function V6(t){t=t|0}function U6(t){t=t|0,he(t)}function z6(t){return t=t|0,51716}function G6(t){t=t|0}function q6(t){t=t|0}function W6(t){t=t|0}function H6(t){t=t|0,he(t)}function Q6(t){t=t|0,he(t)}function K6(t){t=t|0,he(t)}function Y6(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;if(d=b,b=b+64|0,h=d,(t|0)!=(r|0))if(r|0&&(c=So(r,656,672,0)|0,(c|0)!=0)){r=h,l=r+56|0;do e[r>>2]=0,r=r+4|0;while((r|0)<(l|0));e[h>>2]=c,e[h+8>>2]=t,e[h+12>>2]=-1,e[h+48>>2]=1,On[e[(e[c>>2]|0)+28>>2]&63](c,h,e[o>>2]|0,1),(e[h+24>>2]|0)==1?(e[o>>2]=e[h+16>>2],r=1):r=0}else r=0;else r=1;return b=d,r|0}function Er(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0;t=r+16|0,c=e[t>>2]|0;do if(c){if((c|0)!=(o|0)){l=r+36|0,e[l>>2]=(e[l>>2]|0)+1,e[r+24>>2]=2,S[r+54>>0]=1;break}t=r+24|0,(e[t>>2]|0)==2&&(e[t>>2]=l)}else e[t>>2]=o,e[r+24>>2]=l,e[r+36>>2]=1;while(!1)}function j6(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0,(t|0)==(e[r+8>>2]|0)&&Er(0,r,o,l)}function X6(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0,(t|0)==(e[r+8>>2]|0)?Er(0,r,o,l):(t=e[t+8>>2]|0,On[e[(e[t>>2]|0)+28>>2]&63](t,r,o,l))}function go(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;h=e[t+4>>2]|0,c=h>>8,h&1&&(c=e[(e[o>>2]|0)+c>>2]|0),t=e[t>>2]|0,On[e[(e[t>>2]|0)+28>>2]&63](t,r,o+c|0,h&2|0?l:2)}function Z6(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;e:do if((t|0)!=(e[r+8>>2]|0)){if(h=e[t+12>>2]|0,c=t+16+(h<<3)|0,go(t+16|0,r,o,l),(h|0)>1){h=r+54|0,t=t+24|0;do{if(go(t,r,o,l),S[h>>0]|0)break e;t=t+8|0}while(t>>>0>>0)}}else Er(0,r,o,l);while(!1)}function So(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;_=b,b=b+64|0,R=_,N=e[t>>2]|0,k=t+(e[N+-8>>2]|0)|0,N=e[N+-4>>2]|0,e[R>>2]=o,e[R+4>>2]=t,e[R+8>>2]=r,e[R+12>>2]=l,l=R+16|0,t=R+20|0,r=R+24|0,c=R+28|0,h=R+32|0,d=R+40|0,w=(N|0)==(o|0),C=l,D=C+36|0;do e[C>>2]=0,C=C+4|0;while((C|0)<(D|0));E[l+36>>1]=0,S[l+38>>0]=0;e:do if(w)e[R+48>>2]=1,Vi[e[(e[o>>2]|0)+20>>2]&15](o,R,k,k,1,0),l=(e[r>>2]|0)==1?k:0;else{switch(Pn[e[(e[N>>2]|0)+24>>2]&15](N,R,k,1,0),e[R+36>>2]|0){case 0:{l=(e[d>>2]|0)==1&(e[c>>2]|0)==1&(e[h>>2]|0)==1?e[t>>2]|0:0;break e}case 1:break;default:{l=0;break e}}if((e[r>>2]|0)!=1&&!((e[d>>2]|0)==0&(e[c>>2]|0)==1&(e[h>>2]|0)==1)){l=0;break}l=e[l>>2]|0}while(!1);return b=_,l|0}function kr(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,S[r+53>>0]=1;do if((e[r+4>>2]|0)==(l|0)){if(S[r+52>>0]=1,l=r+16|0,t=e[l>>2]|0,!t){if(e[l>>2]=o,e[r+24>>2]=c,e[r+36>>2]=1,!((c|0)==1&&(e[r+48>>2]|0)==1))break;S[r+54>>0]=1;break}if((t|0)!=(o|0)){c=r+36|0,e[c>>2]=(e[c>>2]|0)+1,S[r+54>>0]=1;break}t=r+24|0,l=e[t>>2]|0,(l|0)==2&&(e[t>>2]=c,l=c),(l|0)==1&&(e[r+48>>2]|0)==1&&(S[r+54>>0]=1)}while(!1)}function J6(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;e:do if((t|0)==(e[r+8>>2]|0))(e[r+4>>2]|0)==(o|0)&&(h=r+28|0,(e[h>>2]|0)!=1)&&(e[h>>2]=l);else{if((t|0)!=(e[r>>2]|0)){if(U=e[t+12>>2]|0,w=t+16+(U<<3)|0,En(t+16|0,r,o,l,c),h=t+24|0,(U|0)<=1)break;if(d=e[t+8>>2]|0,!(d&2|0)&&(C=r+36|0,(e[C>>2]|0)!=1)){if(!(d&1)){for(d=r+54|0;;)if(S[d>>0]|0||(e[C>>2]|0)==1||(En(h,r,o,l,c),h=h+8|0,h>>>0>=w>>>0))break e}for(d=r+24|0,t=r+54|0;;)if(S[t>>0]|0||(e[C>>2]|0)==1&&(e[d>>2]|0)==1||(En(h,r,o,l,c),h=h+8|0,h>>>0>=w>>>0))break e}for(d=r+54|0;;)if(S[d>>0]|0||(En(h,r,o,l,c),h=h+8|0,h>>>0>=w>>>0))break e}if((e[r+16>>2]|0)!=(o|0)&&(_=r+20|0,(e[_>>2]|0)!=(o|0))){if(e[r+32>>2]=l,k=r+44|0,(e[k>>2]|0)==4)break;d=e[t+12>>2]|0,w=t+16+(d<<3)|0,C=r+52|0,l=r+53|0,N=r+54|0,D=t+8|0,R=r+24|0;t:do if((d|0)>0)for(d=0,h=0,t=t+16|0;;){if(S[C>>0]=0,S[l>>0]=0,Dr(t,r,o,o,1,c),S[N>>0]|0){U=20;break t}do if(S[l>>0]|0){if(!(S[C>>0]|0))if(e[D>>2]&1){h=1;break}else{h=1,U=20;break t}if((e[R>>2]|0)==1)break t;if(e[D>>2]&2)d=1,h=1;else break t}while(!1);if(t=t+8|0,t>>>0>=w>>>0){U=20;break}}else d=0,h=0,U=20;while(!1);do if((U|0)==20){if(!d&&(e[_>>2]=o,o=r+40|0,e[o>>2]=(e[o>>2]|0)+1,(e[r+36>>2]|0)==1)&&(e[R>>2]|0)==2){if(S[N>>0]=1,h)break}else U=24;if((U|0)==24&&h)break;e[k>>2]=4;break e}while(!1);e[k>>2]=3;break}(l|0)==1&&(e[r+32>>2]=1)}while(!1)}function Dr(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0;w=e[t+4>>2]|0,d=w>>8,w&1&&(d=e[(e[l>>2]|0)+d>>2]|0),t=e[t>>2]|0,Vi[e[(e[t>>2]|0)+20>>2]&15](t,r,o,l+d|0,w&2|0?c:2,h)}function En(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;d=e[t+4>>2]|0,h=d>>8,d&1&&(h=e[(e[o>>2]|0)+h>>2]|0),t=e[t>>2]|0,Pn[e[(e[t>>2]|0)+24>>2]&15](t,r,o+h|0,d&2|0?l:2,c)}function eS(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0;e:do if((t|0)==(e[r+8>>2]|0))(e[r+4>>2]|0)==(o|0)&&(h=r+28|0,(e[h>>2]|0)!=1)&&(e[h>>2]=l);else{if((t|0)!=(e[r>>2]|0)){w=e[t+8>>2]|0,Pn[e[(e[w>>2]|0)+24>>2]&15](w,r,o,l,c);break}if((e[r+16>>2]|0)!=(o|0)&&(d=r+20|0,(e[d>>2]|0)!=(o|0))){if(e[r+32>>2]=l,l=r+44|0,(e[l>>2]|0)==4)break;h=r+52|0,S[h>>0]=0,C=r+53|0,S[C>>0]=0,t=e[t+8>>2]|0,Vi[e[(e[t>>2]|0)+20>>2]&15](t,r,o,o,1,c),S[C>>0]|0?S[h>>0]|0||(h=1,w=13):(h=0,w=13);do if((w|0)==13){if(e[d>>2]=o,C=r+40|0,e[C>>2]=(e[C>>2]|0)+1,(e[r+36>>2]|0)==1&&(e[r+24>>2]|0)==2){if(S[r+54>>0]=1,h)break}else w=16;if((w|0)==16&&h)break;e[l>>2]=4;break e}while(!1);e[l>>2]=3;break}(l|0)==1&&(e[r+32>>2]=1)}while(!1)}function tS(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0;do if((t|0)==(e[r+8>>2]|0))(e[r+4>>2]|0)==(o|0)&&(d=r+28|0,(e[d>>2]|0)!=1)&&(e[d>>2]=l);else if((t|0)==(e[r>>2]|0)){if((e[r+16>>2]|0)!=(o|0)&&(h=r+20|0,(e[h>>2]|0)!=(o|0))){e[r+32>>2]=l,e[h>>2]=o,c=r+40|0,e[c>>2]=(e[c>>2]|0)+1,(e[r+36>>2]|0)==1&&(e[r+24>>2]|0)==2&&(S[r+54>>0]=1),e[r+44>>2]=4;break}(l|0)==1&&(e[r+32>>2]=1)}while(!1)}function iS(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0;var d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;if((t|0)==(e[r+8>>2]|0))kr(0,r,o,l,c);else{k=r+52|0,N=S[k>>0]|0,R=r+53|0,_=S[R>>0]|0,D=e[t+12>>2]|0,d=t+16+(D<<3)|0,S[k>>0]=0,S[R>>0]=0,Dr(t+16|0,r,o,l,c,h);e:do if((D|0)>1){w=r+24|0,C=t+8|0,D=r+54|0,t=t+24|0;do{if(S[D>>0]|0)break e;if(S[k>>0]|0){if((e[w>>2]|0)==1||!(e[C>>2]&2))break e}else if(S[R>>0]|0&&!(e[C>>2]&1|0))break e;S[k>>0]=0,S[R>>0]=0,Dr(t,r,o,l,c,h),t=t+8|0}while(t>>>0>>0)}while(!1);S[k>>0]=N,S[R>>0]=_}}function nS(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,(t|0)==(e[r+8>>2]|0)?kr(0,r,o,l,c):(t=e[t+8>>2]|0,Vi[e[(e[t>>2]|0)+20>>2]&15](t,r,o,l,c,h))}function rS(t,r,o,l,c,h){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0,h=h|0,(t|0)==(e[r+8>>2]|0)&&kr(0,r,o,l,c)}function sS(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;return c=b,b=b+16|0,l=c,e[l>>2]=e[o>>2],t=Yt[e[(e[t>>2]|0)+16>>2]&63](t,r,l)|0,t&&(e[o>>2]=e[l>>2]),b=c,t&1|0}function oS(t){return t=t|0,t?t=(So(t,656,704,0)|0)!=0:t=0,t&1|0}function kn(){var t=0;t=Ct(4)|0,F6(t),Qt(t|0,592,78)}function aS(){var t=0,r=0,o=0,l=0,c=0,h=0,d=0,w=0;c=b,b=b+48|0,d=c+32|0,o=c+24|0,w=c+16|0,h=c,c=c+36|0,t=po()|0,t|0&&(l=e[t>>2]|0,(l|0)!=0)&&(t=l+48|0,r=e[t>>2]|0,t=e[t+4>>2]|0,(r&-256|0)==1126902528&(t|0)==1129074247||(e[o>>2]=e[9257],Fi(51919,o)),(r|0)==1126902529&(t|0)==1129074247?t=e[l+44>>2]|0:t=l+80|0,e[c>>2]=t,l=e[l>>2]|0,t=e[l+4>>2]|0,Yt[e[(e[152]|0)+16>>2]&63](608,l,c)|0?(w=e[c>>2]|0,c=e[9257]|0,w=Dt[e[(e[w>>2]|0)+8>>2]&127](w)|0,e[h>>2]=c,e[h+4>>2]=t,e[h+8>>2]=w,Fi(51833,h)):(e[w>>2]=e[9257],e[w+4>>2]=t,Fi(51878,w))),Fi(51957,d)}function lS(){var t=0;if(t=b,b=b+16|0,ni(37020,184)|0)Fi(51730,t);else{b=t;return}}function uS(t){t=t|0;var r=0,o=0;o=(e[t>>2]|0)+-4|0,r=e[o>>2]|0,e[o>>2]=r+-1,(r+-1|0)<0&&he((e[t>>2]|0)+-12|0)}function cS(t){t=t|0;var r=0;if(r=b,b=b+16|0,n0(t),Xo(e[9255]|0,0)|0)Fi(51780,r);else{b=r;return}}function Dn(t,r,o,l){return t=t|0,r=r|0,o=o|0,l=l|0,t=$S(t,r,o)|0,t|0}function Ao(t,r,o,l){return t=t|0,r=r|0,o=o|0,l=l|0,t=BS(t,r,o)|0,t|0}function fS(){return 37296}function hS(){return 37300}function dS(){return 37304}function ji(t){return t=t|0,((t|0)==32|(t+-9|0)>>>0<5)&1|0}function pS(t){return t=t|0,(t+-48|0)>>>0<10?t=1:t=((t|32)+-97|0)>>>0<6,t&1|0}function S0(){var t=0;return e[9258]|0?(t=($r()|0)+60|0,t=e[t>>2]|0):t=37308,t|0}function vo(t){t=t|0;var r=0,o=0;for(r=0;;){if((F[51978+r>>0]|0)==(t|0)){o=2;break}if(r=r+1|0,(r|0)==87){r=87,t=52066,o=5;break}}if((o|0)==2&&(r?(t=52066,o=5):t=52066),(o|0)==5)for(;;){for(o=t;t=o+1|0,S[o>>0]|0;)o=t;if(r=r+-1|0,r)o=5;else break}return t|0}function xo(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0,jt=0,Gt=0;switch(jt=b,b=b+512|0,ke=jt,r|0){case 0:{it=24,Te=-149,O=4;break}case 1:{it=53,Te=-1074,O=4;break}case 2:{it=53,Te=-1074,O=4;break}default:l=0}e:do if((O|0)==4){oe=t+4|0,ie=t+100|0;do r=e[oe>>2]|0,r>>>0<(e[ie>>2]|0)>>>0?(e[oe>>2]=r+1,r=F[r>>0]|0):r=u0(t)|0;while(ji(r)|0);t:do switch(r|0){case 43:case 45:if(c=1-(((r|0)==45&1)<<1)|0,r=e[oe>>2]|0,r>>>0<(e[ie>>2]|0)>>>0){e[oe>>2]=r+1,r=F[r>>0]|0,Ee=c;break t}else{r=u0(t)|0,Ee=c;break t}default:Ee=1}while(!1);c=r,r=0;do{if((c|32|0)!=(S[53870+r>>0]|0))break;do if(r>>>0<7)if(c=e[oe>>2]|0,c>>>0<(e[ie>>2]|0)>>>0){e[oe>>2]=c+1,c=F[c>>0]|0;break}else{c=u0(t)|0;break}while(!1);r=r+1|0}while(r>>>0<8);t:do switch(r|0){case 8:break;case 3:{O=23;break}default:{if(d=(o|0)!=0,d&r>>>0>3){if((r|0)==8)break t;O=23;break t}i:do if(!r){r=0;do{if((c|32|0)!=(S[56747+r>>0]|0))break i;do if(r>>>0<2)if(c=e[oe>>2]|0,c>>>0<(e[ie>>2]|0)>>>0){e[oe>>2]=c+1,c=F[c>>0]|0;break}else{c=u0(t)|0;break}while(!1);r=r+1|0}while(r>>>0<3)}while(!1);switch(r|0){case 3:{if(r=e[oe>>2]|0,r>>>0<(e[ie>>2]|0)>>>0?(e[oe>>2]=r+1,r=F[r>>0]|0):r=u0(t)|0,(r|0)==40)r=1;else{if(!(e[ie>>2]|0)){l=fe;break e}e[oe>>2]=(e[oe>>2]|0)+-1,l=fe;break e}for(;c=e[oe>>2]|0,c>>>0<(e[ie>>2]|0)>>>0?(e[oe>>2]=c+1,c=F[c>>0]|0):c=u0(t)|0,!(!((c+-48|0)>>>0<10|(c+-65|0)>>>0<26)&&!((c|0)==95|(c+-97|0)>>>0<26));)r=r+1|0;if((c|0)==41){l=fe;break e}if(c=(e[ie>>2]|0)==0,c||(e[oe>>2]=(e[oe>>2]|0)+-1),!d){it=S0()|0,e[it>>2]=22,oi(t,0),l=0;break e}if(!r){l=fe;break e}for(;;)if(r=r+-1|0,c||(e[oe>>2]=(e[oe>>2]|0)+-1),!r){l=fe;break e}}case 0:{do if((c|0)==48){if(r=e[oe>>2]|0,r>>>0<(e[ie>>2]|0)>>>0?(e[oe>>2]=r+1,r=F[r>>0]|0):r=u0(t)|0,(r|32|0)!=120){if(!(e[ie>>2]|0)){r=48;break}e[oe>>2]=(e[oe>>2]|0)+-1,r=48;break}r=e[oe>>2]|0,r>>>0<(e[ie>>2]|0)>>>0?(e[oe>>2]=r+1,r=F[r>>0]|0,d=0):(r=u0(t)|0,d=0);i:for(;;){switch(r|0){case 46:{O=74;break i}case 48:break;default:{$=0,w=0,G=0,c=0,D=d,k=0,K=0,C=1,d=0,l=0;break i}}if(r=e[oe>>2]|0,r>>>0<(e[ie>>2]|0)>>>0){e[oe>>2]=r+1,r=F[r>>0]|0,d=1;continue}else{r=u0(t)|0,d=1;continue}}if((O|0)==74)if(r=e[oe>>2]|0,r>>>0<(e[ie>>2]|0)>>>0?(e[oe>>2]=r+1,r=F[r>>0]|0):r=u0(t)|0,(r|0)==48){d=0,c=0;do r=e[oe>>2]|0,r>>>0<(e[ie>>2]|0)>>>0?(e[oe>>2]=r+1,r=F[r>>0]|0):r=u0(t)|0,d=$0(d|0,c|0,-1,-1)|0,c=ye;while((r|0)==48);$=0,w=0,G=d,D=1,k=1,K=0,C=1,d=0,l=0}else $=0,w=0,G=0,c=0,D=d,k=1,K=0,C=1,d=0,l=0;for(;;){if(U=r+-48|0,N=r|32,U>>>0>=10){if(Q=(r|0)==46,!(Q|(N+-97|0)>>>0<6)){N=G,U=$;break}if(Q)if(!k)Q=w,c=$,U=$,k=1,N=K,h=C;else{N=G,U=$,r=46;break}else O=86}else O=86;if((O|0)==86){O=0,r=(r|0)>57?N+-87|0:U;do if(($|0)<0|($|0)==0&w>>>0<8)N=K,h=C,d=r+(d<<4)|0;else{if(($|0)<0|($|0)==0&w>>>0<14){_=C*.0625,N=K,h=_,l=l+_*+(r|0);break}(K|0)!=0|(r|0)==0?(N=K,h=C):(N=1,h=C,l=l+C*.5)}while(!1);w=$0(w|0,$|0,1,0)|0,Q=G,U=ye,D=1}if(r=e[oe>>2]|0,r>>>0<(e[ie>>2]|0)>>>0){e[oe>>2]=r+1,$=U,G=Q,r=F[r>>0]|0,K=N,C=h;continue}else{$=U,G=Q,r=u0(t)|0,K=N,C=h;continue}}if(!D){r=(e[ie>>2]|0)==0,r||(e[oe>>2]=(e[oe>>2]|0)+-1),o?!r&&(P=e[oe>>2]|0,e[oe>>2]=P+-1,(k|0)!=0)&&(e[oe>>2]=P+-2):oi(t,0),l=+(Ee|0)*0;break e}if(D=(k|0)==0,k=D?w:N,D=D?U:c,(U|0)<0|(U|0)==0&w>>>0<8){c=U;do d=d<<4,w=$0(w|0,c|0,1,0)|0,c=ye;while((c|0)<0|(c|0)==0&w>>>0<8)}if((r|32|0)==112){if(c=Bo(t,o)|0,r=ye,(c|0)==0&(r|0)==-2147483648){if(!o){oi(t,0),l=0;break e}e[ie>>2]|0?(e[oe>>2]=(e[oe>>2]|0)+-1,c=0,r=0):(c=0,r=0)}}else e[ie>>2]|0?(e[oe>>2]=(e[oe>>2]|0)+-1,c=0,r=0):(c=0,r=0);if(ke=v0(k|0,D|0,2)|0,ke=$0(ke|0,ye|0,-32,-1)|0,r=$0(ke|0,ye|0,c|0,r|0)|0,c=ye,!d){l=+(Ee|0)*0;break e}if((c|0)>0|(c|0)==0&r>>>0>(0-Te|0)>>>0){it=S0()|0,e[it>>2]=34,l=+(Ee|0)*17976931348623157e292*17976931348623157e292;break e}if(ke=Te+-106|0,ce=((ke|0)<0)<<31>>31,(c|0)<(ce|0)|(c|0)==(ce|0)&r>>>0>>0){it=S0()|0,e[it>>2]=34,l=+(Ee|0)*22250738585072014e-324*22250738585072014e-324;break e}if((d|0)>-1){do ce=!(l>=.5),ke=ce&1|d<<1,d=ke^1,l=l+(ce?l:l+-1),r=$0(r|0,c|0,-1,-1)|0,c=ye;while((ke|0)>-1);w=r,C=l}else w=r,C=l;r=ii(32,0,Te|0,((Te|0)<0)<<31>>31|0)|0,r=$0(w|0,c|0,r|0,ye|0)|0,Te=ye,0>(Te|0)|(Te|0)==0&it>>>0>r>>>0?(r|0)<0?(r=0,O=127):O=125:(r=it,O=125),(O|0)==125&&((r|0)<53?O=127:(c=r,h=+(Ee|0),l=0)),(O|0)==127&&(l=+(Ee|0),c=r,h=l,l=+Co(+bn(1,84-r|0),l)),it=(d&1|0)==0&(C!=0&(c|0)<32),l=h*(it?0:C)+(l+h*+(((it&1)+d|0)>>>0))-l,l==0&&(it=S0()|0,e[it>>2]=34),l=+Eo(l,w);break e}else r=c;while(!1);ne=Te+it|0,ce=0-ne|0,d=0;i:for(;;){switch(r|0){case 46:{O=138;break i}case 48:break;default:{c=0,N=0,k=0;break i}}if(r=e[oe>>2]|0,r>>>0<(e[ie>>2]|0)>>>0){e[oe>>2]=r+1,r=F[r>>0]|0,d=1;continue}else{r=u0(t)|0,d=1;continue}}if((O|0)==138)if(r=e[oe>>2]|0,r>>>0<(e[ie>>2]|0)>>>0?(e[oe>>2]=r+1,r=F[r>>0]|0):r=u0(t)|0,(r|0)==48)for(c=0,r=0;;)if(c=$0(c|0,r|0,-1,-1)|0,d=ye,r=e[oe>>2]|0,r>>>0<(e[ie>>2]|0)>>>0?(e[oe>>2]=r+1,r=F[r>>0]|0):r=u0(t)|0,(r|0)==48)r=d;else{N=d,d=1,k=1;break}else c=0,N=0,k=1;e[ke>>2]=0,D=r+-48|0,w=(r|0)==46;i:do if(w|D>>>0<10){Z=ke+496|0,$=0,Q=0,K=w,O=N,U=d,P=k,d=0,w=0,k=0;n:for(;;){do if(K)if(!P)c=$,N=Q,P=1;else{N=O,r=$,D=Q;break n}else{if(K=$0($|0,Q|0,1,0)|0,Q=ye,G=(r|0)!=48,(w|0)>=125){if(!G){N=O,$=K;break}e[Z>>2]=e[Z>>2]|1,N=O,$=K;break}N=ke+(w<<2)|0,d&&(D=r+-48+((e[N>>2]|0)*10|0)|0),e[N>>2]=D,d=d+1|0,D=(d|0)==9,N=O,$=K,U=1,d=D?0:d,w=(D&1)+w|0,k=G?K:k}while(!1);if(r=e[oe>>2]|0,r>>>0<(e[ie>>2]|0)>>>0?(e[oe>>2]=r+1,r=F[r>>0]|0):r=u0(t)|0,D=r+-48|0,K=(r|0)==46,K|D>>>0<10)O=N;else{D=P,O=161;break i}}U=(U|0)!=0,O=169}else $=0,Q=0,U=d,D=k,d=0,w=0,k=0,O=161;while(!1);do if((O|0)==161){if(Z=(D|0)==0,c=Z?$:c,N=Z?Q:N,U=(U|0)!=0,!((r|32|0)==101&U))if((r|0)>-1){r=$,D=Q,O=169;break}else{r=$,D=Q,O=171;break}if(D=Bo(t,o)|0,r=ye,(D|0)==0&(r|0)==-2147483648){if(!o){oi(t,0),l=0;break}e[ie>>2]|0?(e[oe>>2]=(e[oe>>2]|0)+-1,D=0,r=0):(D=0,r=0)}c=$0(D|0,r|0,c|0,N|0)|0,U=$,N=ye,D=Q,O=173}while(!1);(O|0)==169&&(e[ie>>2]|0?(e[oe>>2]=(e[oe>>2]|0)+-1,U?(U=r,O=173):O=172):O=171),(O|0)==171&&(U?(U=r,O=173):O=172);do if((O|0)==172)it=S0()|0,e[it>>2]=22,oi(t,0),l=0;else if((O|0)==173){if(r=e[ke>>2]|0,!r){l=+(Ee|0)*0;break}if(((D|0)<0|(D|0)==0&U>>>0<10)&((c|0)==(U|0)&(N|0)==(D|0))&&it>>>0>30|(r>>>it|0)==0){l=+(Ee|0)*+(r>>>0);break}if(t=(Te|0)/-2|0,oe=((t|0)<0)<<31>>31,(N|0)>(oe|0)|(N|0)==(oe|0)&c>>>0>t>>>0){it=S0()|0,e[it>>2]=34,l=+(Ee|0)*17976931348623157e292*17976931348623157e292;break}if(t=Te+-106|0,oe=((t|0)<0)<<31>>31,(N|0)<(oe|0)|(N|0)==(oe|0)&c>>>0>>0){it=S0()|0,e[it>>2]=34,l=+(Ee|0)*22250738585072014e-324*22250738585072014e-324;break}if(d){if((d|0)<9){D=ke+(w<<2)|0,r=e[D>>2]|0;do r=r*10|0,d=d+1|0;while((d|0)!=9);e[D>>2]=r}w=w+1|0}if((k|0)<9&&(k|0)<=(c|0)&(c|0)<18){if((c|0)==9){l=+(Ee|0)*+((e[ke>>2]|0)>>>0);break}if((c|0)<9){l=+(Ee|0)*+((e[ke>>2]|0)>>>0)/+(e[37312+(8-c<<2)>>2]|0);break}if(t=it+27+(ee(c,-3)|0)|0,r=e[ke>>2]|0,(t|0)>30|(r>>>t|0)==0){l=+(Ee|0)*+(r>>>0)*+(e[37312+(c+-10<<2)>>2]|0);break}}if(r=(c|0)%9|0,!r)d=0,r=0;else{if(U=(c|0)>-1?r:r+9|0,D=e[37312+(8-U<<2)>>2]|0,w){k=1e9/(D|0)|0,d=0,r=0,N=0;do ie=ke+(N<<2)|0,oe=e[ie>>2]|0,t=((oe>>>0)/(D>>>0)|0)+r|0,e[ie>>2]=t,r=ee((oe>>>0)%(D>>>0)|0,k)|0,t=(N|0)==(d|0)&(t|0)==0,N=N+1|0,c=t?c+-9|0:c,d=t?N&127:d;while((N|0)!=(w|0));r&&(e[ke+(w<<2)>>2]=r,w=w+1|0)}else d=0,w=0;r=0,c=9-U+c|0}i:for(;;){Q=(c|0)<18,K=(c|0)==18,G=ke+(d<<2)|0;do{if(!Q){if(!K)break i;if((e[G>>2]|0)>>>0>=9007199){c=18;break i}}for(D=0,k=w+127|0;U=k&127,N=ke+(U<<2)|0,k=v0(e[N>>2]|0,0,29)|0,k=$0(k|0,ye|0,D|0,0)|0,D=ye,D>>>0>0|(D|0)==0&k>>>0>1e9?(t=xn(k|0,D|0,1e9,0)|0,k=Cr(k|0,D|0,1e9,0)|0,D=t):D=0,e[N>>2]=k,t=(U|0)==(d|0),w=(U|0)!=(w+127&127|0)|t||k|0?w:U,!t;)k=U+-1|0;r=r+-29|0}while(!(D|0));d=d+127&127,(d|0)==(w|0)&&(t=w+127&127,w=ke+((w+126&127)<<2)|0,e[w>>2]=e[w>>2]|e[ke+(t<<2)>>2],w=t),e[ke+(d<<2)>>2]=D,c=c+9|0}i:for(;;){for($=w+1&127,G=ke+((w+127&127)<<2)|0;;){for(Q=(c|0)==18,K=(c|0)>27?9:1,U=Q^1;;){k=d&127,N=(k|0)==(w|0);do if(N)O=219;else{if(D=e[ke+(k<<2)>>2]|0,D>>>0<9007199){O=219;break}if(D>>>0>9007199)break;if(D=d+1&127,(D|0)==(w|0)){O=219;break}if(D=e[ke+(D<<2)>>2]|0,D>>>0<254740991){O=219;break}if(!(D>>>0>254740991|U)){c=k;break i}}while(!1);if((O|0)==219&&(O=0,Q)){O=220;break i}if(r=r+K|0,(d|0)==(w|0))d=w;else break}for(U=(1<>>K,k=d,D=0,N=d;oe=ke+(N<<2)|0,t=e[oe>>2]|0,d=(t>>>K)+D|0,e[oe>>2]=d,D=ee(t&U,Q)|0,d=(N|0)==(k|0)&(d|0)==0,N=N+1&127,c=d?c+-9|0:c,d=d?N:k,(N|0)!=(w|0);)k=d;if(D){if(($|0)!=(d|0))break;e[G>>2]=e[G>>2]|1}}e[ke+(w<<2)>>2]=D,w=$}(O|0)==220&&(N?(e[ke+($+-1<<2)>>2]=0,c=w,w=$):c=k),l=+((e[ke+(c<<2)>>2]|0)>>>0),c=d+1&127,(c|0)==(w|0)&&(w=d+2&127,e[ke+(w+-1<<2)>>2]=0),_=+(Ee|0),h=_*(l*1e9+ +((e[ke+(c<<2)>>2]|0)>>>0)),Q=r+53|0,N=Q-Te|0,U=(N|0)<(it|0),c=U&1,k=U?(N|0)<0?0:N:it,(k|0)<53?(Gt=+Co(+bn(1,105-k|0),h),C=+To(h,+bn(1,53-k|0)),R=Gt,l=C,C=Gt+(h-C)):(R=0,l=0,C=h),D=d+2&127;do if((D|0)==(w|0))h=l;else{D=e[ke+(D<<2)>>2]|0;do if(D>>>0>=5e8){if(D>>>0>5e8){l=_*.75+l;break}if((d+3&127|0)==(w|0)){l=_*.5+l;break}else{l=_*.75+l;break}}else{if(!(D|0)&&(d+3&127|0)==(w|0))break;l=_*.25+l}while(!1);if((53-k|0)<=1){h=l;break}if(+To(l,1)!=0){h=l;break}h=l+1}while(!1);l=C+h-R;do if((Q&2147483647|0)>(-2-ne|0)){if(+Ie(+l)>=9007199254740992&&(c=U&(k|0)==(N|0)?0:c,r=r+1|0,l=l*.5),(r+50|0)<=(ce|0)&&!(h!=0&(c|0)!=0))break;it=S0()|0,e[it>>2]=34}while(!1);l=+Eo(l,r)}while(!1);break e}default:{e[ie>>2]|0&&(e[oe>>2]=(e[oe>>2]|0)+-1),it=S0()|0,e[it>>2]=22,oi(t,0),l=0;break e}}}}while(!1);if((O|0)==23&&(c=(e[ie>>2]|0)==0,c||(e[oe>>2]=(e[oe>>2]|0)+-1),(o|0)!=0&r>>>0>3))do c||(e[oe>>2]=(e[oe>>2]|0)+-1),r=r+-1|0;while(r>>>0>3);l=+(Ee|0)*pe}while(!1);return b=jt,+l}function wo(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;e:do if(r>>>0>36)c=S0()|0,e[c>>2]=22,c=0,l=0;else{U=t+4|0,_=t+100|0;do h=e[U>>2]|0,h>>>0<(e[_>>2]|0)>>>0?(e[U>>2]=h+1,h=F[h>>0]|0):h=u0(t)|0;while(ji(h)|0);t:do switch(h|0){case 43:case 45:if(d=((h|0)==45)<<31>>31,h=e[U>>2]|0,h>>>0<(e[_>>2]|0)>>>0){e[U>>2]=h+1,h=F[h>>0]|0,R=d;break t}else{h=u0(t)|0,R=d;break t}default:R=0}while(!1);d=(r|0)==0;do if((r&-17|0)==0&(h|0)==48){if(h=e[U>>2]|0,h>>>0<(e[_>>2]|0)>>>0?(e[U>>2]=h+1,h=F[h>>0]|0):h=u0(t)|0,(h|32|0)!=120)if(d){r=8,k=46;break}else{k=32;break}if(r=e[U>>2]|0,r>>>0<(e[_>>2]|0)>>>0?(e[U>>2]=r+1,h=F[r>>0]|0):h=u0(t)|0,(F[53879+(h+1)>>0]|0)>15){if(l=(e[_>>2]|0)==0,l||(e[U>>2]=(e[U>>2]|0)+-1),!o){oi(t,0),c=0,l=0;break e}if(l){c=0,l=0;break e}e[U>>2]=(e[U>>2]|0)+-1,c=0,l=0;break e}else r=16,k=46}else if(r=d?10:r,(F[53879+(h+1)>>0]|0)>>>0>>0)k=32;else{e[_>>2]|0&&(e[U>>2]=(e[U>>2]|0)+-1),oi(t,0),c=S0()|0,e[c>>2]=22,c=0,l=0;break e}while(!1);if((k|0)==32)if((r|0)==10){if(r=h+-48|0,r>>>0<10){for(h=0;;)if(d=(h*10|0)+r|0,r=e[U>>2]|0,r>>>0<(e[_>>2]|0)>>>0?(e[U>>2]=r+1,h=F[r>>0]|0):h=u0(t)|0,r=h+-48|0,r>>>0<10&d>>>0<429496729)h=d;else{r=d;break}d=0}else r=0,d=0;if(o=h+-48|0,o>>>0<10){for(;;){if(w=Qi(r|0,d|0,10,0)|0,C=ye,D=((o|0)<0)<<31>>31,N=~D,C>>>0>N>>>0|(C|0)==(N|0)&w>>>0>~o>>>0){w=r;break}if(r=$0(w|0,C|0,o|0,D|0)|0,d=ye,h=e[U>>2]|0,h>>>0<(e[_>>2]|0)>>>0?(e[U>>2]=h+1,h=F[h>>0]|0):h=u0(t)|0,o=h+-48|0,!(o>>>0<10&(d>>>0<429496729|(d|0)==429496729&r>>>0<2576980378))){w=r;break}}o>>>0>9?(h=w,r=R):(r=10,k=72)}else h=r,r=R}else k=46;t:do if((k|0)==46){if(!(r+-1&r)){if(k=S[54136+((r*23|0)>>>5&7)>>0]|0,d=S[53879+(h+1)>>0]|0,o=d&255,o>>>0>>0){for(h=0;w=o|h<>2]|0,h>>>0<(e[_>>2]|0)>>>0?(e[U>>2]=h+1,h=F[h>>0]|0):h=u0(t)|0,d=S[53879+(h+1)>>0]|0,o=d&255,w>>>0<134217728&o>>>0>>0;)h=w;o=0}else o=0,w=0;if(C=Di(-1,-1,k|0)|0,D=ye,(d&255)>>>0>=r>>>0|(o>>>0>D>>>0|(o|0)==(D|0)&w>>>0>C>>>0)){d=o,k=72;break}else h=o;for(;;)if(w=v0(w|0,h|0,k|0)|0,o=ye,w=d&255|w,h=e[U>>2]|0,h>>>0<(e[_>>2]|0)>>>0?(e[U>>2]=h+1,h=F[h>>0]|0):h=u0(t)|0,d=S[53879+(h+1)>>0]|0,(d&255)>>>0>=r>>>0|(o>>>0>D>>>0|(o|0)==(D|0)&w>>>0>C>>>0)){d=o,k=72;break t}else h=o}if(d=S[53879+(h+1)>>0]|0,o=d&255,o>>>0>>0){for(h=0;w=o+(ee(h,r)|0)|0,h=e[U>>2]|0,h>>>0<(e[_>>2]|0)>>>0?(e[U>>2]=h+1,h=F[h>>0]|0):h=u0(t)|0,d=S[53879+(h+1)>>0]|0,o=d&255,w>>>0<119304647&o>>>0>>0;)h=w;o=0}else w=0,o=0;if((d&255)>>>0>>0)for(k=xn(-1,-1,r|0,0)|0,N=ye,D=o;;){if(D>>>0>N>>>0|(D|0)==(N|0)&w>>>0>k>>>0){d=D,k=72;break t}if(o=Qi(w|0,D|0,r|0,0)|0,C=ye,d=d&255,C>>>0>4294967295|(C|0)==-1&o>>>0>~d>>>0){d=D,k=72;break t}if(w=$0(d|0,0,o|0,C|0)|0,o=ye,h=e[U>>2]|0,h>>>0<(e[_>>2]|0)>>>0?(e[U>>2]=h+1,h=F[h>>0]|0):h=u0(t)|0,d=S[53879+(h+1)>>0]|0,(d&255)>>>0>=r>>>0){d=o,k=72;break}else D=o}else d=o,k=72}while(!1);if((k|0)==72)if((F[53879+(h+1)>>0]|0)>>>0>>0){do h=e[U>>2]|0,h>>>0<(e[_>>2]|0)>>>0?(e[U>>2]=h+1,h=F[h>>0]|0):h=u0(t)|0;while((F[53879+(h+1)>>0]|0)>>>0>>0);d=S0()|0,e[d>>2]=34,d=c,h=l,r=(l&1|0)==0&!0?R:0}else h=w,r=R;if(e[_>>2]|0&&(e[U>>2]=(e[U>>2]|0)+-1),!(d>>>0>>0|(d|0)==(c|0)&h>>>0>>0)){if(!((l&1|0)!=0|!1|(r|0)!=0)){U=S0()|0,e[U>>2]=34,l=$0(l|0,c|0,-1,-1)|0,c=ye;break}if(d>>>0>c>>>0|(d|0)==(c|0)&h>>>0>l>>>0){U=S0()|0,e[U>>2]=34;break}}l=((r|0)<0)<<31>>31,l=ii(h^r|0,d^l|0,r|0,l|0)|0,c=ye}while(!1);return ye=c,l|0}function oi(t,r){t=t|0,r=r|0;var o=0,l=0,c=0;e[t+104>>2]=r,o=e[t+4>>2]|0,l=e[t+8>>2]|0,c=l-o|0,e[t+108>>2]=c,(r|0)!=0&(c|0)>(r|0)?e[t+100>>2]=o+r:e[t+100>>2]=l}function u0(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0;return o=t+104|0,h=e[o>>2]|0,h|0&&(e[t+108>>2]|0)>=(h|0)?d=4:(r=br(t)|0,(r|0)>=0?(c=e[o>>2]|0,o=t+8|0,c?(l=e[o>>2]|0,h=e[t+4>>2]|0,o=l,c=c-(e[t+108>>2]|0)+-1|0,(o-h|0)>(c|0)?e[t+100>>2]=h+c:d=9):(l=e[o>>2]|0,o=l,d=9),(d|0)==9&&(e[t+100>>2]=o),o=e[t+4>>2]|0,l&&(t=t+108|0,e[t>>2]=l+1-o+(e[t>>2]|0)),o=o+-1|0,(F[o>>0]|0|0)!=(r|0)&&(S[o>>0]=r)):d=4),(d|0)==4&&(e[t+100>>2]=0,r=-1),r|0}function Xi(t){t=t|0;var r=0;return t>>>0>4294963200&&(r=S0()|0,e[r>>2]=0-t,t=-1),t|0}function CA(t){return t=t|0,0}function mS(t,r,o,l){return t=t|0,r=r|0,o=o|0,l=l|0,l|0}function yo(t,r){return t=t|0,r=r|0,-1}function gS(t){t=t|0,n0(t)}function SS(t,r){return t=t|0,r=r|0,(t+-48|0)>>>0<10|0}function AS(t,r){return t=t|0,r=r|0,pS(t)|0}function vS(t,r,o){return t=t|0,r=r|0,o=o|0,S[r>>0]|0&&$o(r,58885)|0&&$o(r,54145)|0?o=0:o||(o=Dd(1,4)|0),o|0}function ai(t){t=t|0;var r=0,o=0;return r=($r()|0)+176|0,o=e[r>>2]|0,t&&(e[r>>2]=t),o|0}function xS(t,r){t=+t,r=+r;var o=0,l=0;return B[q>>3]=t,l=e[q>>2]|0,o=e[q+4>>2]|0,B[q>>3]=r,o=e[q+4>>2]&-2147483648|o&2147483647,e[q>>2]=l,e[q+4>>2]=o,+ +B[q>>3]}function Co(t,r){return t=+t,r=+r,+ +xS(t,r)}function wS(t,r){t=+t,r=+r;var o=0,l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;B[q>>3]=t,o=e[q>>2]|0,D=e[q+4>>2]|0,B[q>>3]=r,k=e[q>>2]|0,N=e[q+4>>2]|0,l=Di(o|0,D|0,52)|0,l=l&2047,w=Di(k|0,N|0,52)|0,w=w&2047,R=D&-2147483648,d=v0(k|0,N|0,1)|0,C=ye;e:do if(!((d|0)==0&(C|0)==0)&&(h=N&2147483647,!(h>>>0>2146435072|(h|0)==2146435072&k>>>0>0|(l|0)==2047))){if(c=v0(o|0,D|0,1)|0,h=ye,!(h>>>0>C>>>0|(h|0)==(C|0)&c>>>0>d>>>0))return+((c|0)==(d|0)&(h|0)==(C|0)?t*0:t);if(l)c=D&1048575|1048576;else{if(l=v0(o|0,D|0,12)|0,c=ye,(c|0)>-1|(c|0)==-1&l>>>0>4294967295){h=l,l=0;do l=l+-1|0,h=v0(h|0,c|0,1)|0,c=ye;while((c|0)>-1|(c|0)==-1&h>>>0>4294967295)}else l=0;o=v0(o|0,D|0,1-l|0)|0,c=ye}if(w)D=N&1048575|1048576;else{if(h=v0(k|0,N|0,12)|0,d=ye,(d|0)>-1|(d|0)==-1&h>>>0>4294967295){w=0;do w=w+-1|0,h=v0(h|0,d|0,1)|0,d=ye;while((d|0)>-1|(d|0)==-1&h>>>0>4294967295)}else w=0;k=v0(k|0,N|0,1-w|0)|0,D=ye}C=ii(o|0,c|0,k|0,D|0)|0,d=ye,h=(d|0)>-1|(d|0)==-1&C>>>0>4294967295;t:do if((l|0)>(w|0)){for(;;){if(h){if((o|0)==(k|0)&(c|0)==(D|0))break;o=C,c=d}if(o=v0(o|0,c|0,1)|0,c=ye,l=l+-1|0,C=ii(o|0,c|0,k|0,D|0)|0,d=ye,h=(d|0)>-1|(d|0)==-1&C>>>0>4294967295,(l|0)<=(w|0))break t}r=t*0;break e}while(!1);if(h)if((o|0)==(k|0)&(c|0)==(D|0)){r=t*0;break}else c=d,o=C;if(c>>>0<1048576|(c|0)==1048576&o>>>0<0)do o=v0(o|0,c|0,1)|0,c=ye,l=l+-1|0;while(c>>>0<1048576|(c|0)==1048576&o>>>0<0);(l|0)>0?(N=$0(o|0,c|0,0,-1048576)|0,o=ye,l=v0(l|0,0,52)|0,o=o|ye,l=N|l):(l=Di(o|0,c|0,1-l|0)|0,o=ye),e[q>>2]=l,e[q+4>>2]=o|R,r=+B[q>>3]}else _=3;while(!1);return(_|0)==3&&(r=t*r,r=r/r),+r}function To(t,r){return t=+t,r=+r,+ +wS(t,r)}function Io(t,r){t=+t,r=r|0;var o=0,l=0,c=0;switch(B[q>>3]=t,o=e[q>>2]|0,l=e[q+4>>2]|0,c=Di(o|0,l|0,52)|0,c=c&2047,c|0){case 0:{t!=0?(t=+Io(t*18446744073709552e3,r),o=(e[r>>2]|0)+-64|0):o=0,e[r>>2]=o;break}case 2047:break;default:e[r>>2]=c+-1022,e[q>>2]=o,e[q+4>>2]=l&-2146435073|1071644672,t=+B[q>>3]}return+t}function yS(t,r){return t=+t,r=r|0,+ +Io(t,r)}function bn(t,r){t=+t,r=r|0;var o=0;return(r|0)>1023?(t=t*898846567431158e293,o=r+-1023|0,(o|0)>1023&&(o=r+-2046|0,o=(o|0)>1023?1023:o,t=t*898846567431158e293)):(r|0)<-1022?(t=t*22250738585072014e-324,o=r+1022|0,(o|0)<-1022&&(o=r+2044|0,o=(o|0)<-1022?-1022:o,t=t*22250738585072014e-324)):o=r,o=v0(o+1023|0,0,52)|0,r=ye,e[q>>2]=o,e[q+4>>2]=r,+(t*+B[q>>3])}function Eo(t,r){return t=+t,r=r|0,+ +bn(t,r)}function CS(t,r,o){return t=t|0,r=r|0,o=o|0,Nn(0,t,r,o|0?o:37344)|0}function Nn(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0;C=b,b=b+16|0,c=C,d=l|0?l:37348,l=e[d>>2]|0;e:do if(!r)l?w=15:l=0;else if(h=t|0?t:c,!o)l=-2;else{if(l)c=o,w=9;else{if(l=S[r>>0]|0,c=l&255,l<<24>>24>-1){e[h>>2]=c,l=l<<24>>24!=0&1;break}if(l=c+-194|0,l>>>0>50){w=15;break}l=e[37076+(l<<2)>>2]|0,c=o+-1|0,c&&(r=r+1|0,w=9)}t:do if((w|0)==9){if(t=S[r>>0]|0,D=(t&255)>>>3,(D+-16|D+(l>>26))>>>0>7){w=15;break e}for(;r=r+1|0,l=(t&255)+-128|l<<6,c=c+-1|0,!((l|0)>=0);){if(!c)break t;if(t=S[r>>0]|0,(t&-64)<<24>>24!=-128){w=15;break e}}e[d>>2]=0,e[h>>2]=l,l=o-c|0;break e}while(!1);e[d>>2]=l,l=-2}while(!1);return(w|0)==15&&(e[d>>2]=0,l=S0()|0,e[l>>2]=84,l=-1),b=C,l|0}function TS(t){return t=t|0,t?t=(e[t>>2]|0)==0:t=1,t&1|0}function IS(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0;R=b,b=b+1040|0,D=R+8|0,N=R,C=e[r>>2]|0,e[N>>2]=C,k=(t|0)!=0,l=k?l:256,t=k?t:D,h=C;e:do if((l|0)!=0&(C|0)!=0){for(w=l,C=h,l=0;;){if(h=o>>>2,d=h>>>0>=w>>>0,!(o>>>0>131|d)){h=C;break e}if(h=d?w:h,o=o-h|0,h=ko(t,N,h,c)|0,(h|0)==-1){l=o;break}if(_=(t|0)==(D|0),C=_?0:h,d=w-C|0,t=_?t:t+(h<<2)|0,l=h+l|0,h=e[N>>2]|0,(w|0)!=(C|0)&(h|0)!=0)w=d,C=h;else{w=d;break e}}o=l,w=0,h=e[N>>2]|0,l=-1}else w=l,l=0;while(!1);e:do if(h|0&&(w|0)!=0&(o|0)!=0){for(d=h,h=t;t=Nn(h,d,o,c)|0,!((t+2|0)>>>0<3);)if(d=(e[N>>2]|0)+t|0,e[N>>2]=d,w=w+-1|0,l=l+1|0,(w|0)!=0&(o|0)!=(t|0))o=o-t|0,h=h+4|0;else break e;switch(t|0){case-1:{l=-1;break e}case 0:{e[N>>2]=0;break e}default:{e[c>>2]=0;break e}}}while(!1);return k&&(e[r>>2]=e[N>>2]),b=R,l|0}function ko(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0;c=e[r>>2]|0,l|0&&(h=e[l>>2]|0,(h|0)!=0)?t?(e[l>>2]=0,C=t,l=o,w=h,D=37):(l=o,d=c,D=16):t?(h=t,l=o,D=6):(l=o,D=7);e:for(;;)if((D|0)==6){if(l)t=h;else{D=26;break}for(;;){h=S[c>>0]|0;do if(((h&255)+-1|0)>>>0<127&&l>>>0>4&(c&3|0)==0){for(d=c;;){if(c=e[d>>2]|0,(c+-16843009|c)&-2139062144){h=c,c=d,D=32;break}if(e[t>>2]=c&255,e[t+4>>2]=F[d+1>>0],e[t+8>>2]=F[d+2>>0],c=d+4|0,h=t+16|0,e[t+12>>2]=F[d+3>>0],l=l+-4|0,l>>>0>4)t=h,d=c;else{D=31;break}}if((D|0)==31){t=h,h=S[c>>0]|0;break}else if((D|0)==32){h=h&255;break}}while(!1);if(h=h&255,(h+-1|0)>>>0>=127)break;if(c=c+1|0,e[t>>2]=h,l=l+-1|0,l)t=t+4|0;else{D=26;break e}}if(h=h+-194|0,h>>>0>50){D=48;break}C=t,w=e[37076+(h<<2)>>2]|0,c=c+1|0,D=37;continue}else if((D|0)==7){if(h=S[c>>0]|0,((h&255)+-1|0)>>>0<127&&!(c&3|0)){if(h=e[c>>2]|0,!((h+-16843009|h)&-2139062144))do c=c+4|0,l=l+-4|0,h=e[c>>2]|0;while(!((h+-16843009|h)&-2139062144|0));h=h&255}if(h=h&255,(h+-1|0)>>>0<127){l=l+-1|0,c=c+1|0,D=7;continue}if(h=h+-194|0,h>>>0>50){D=48;break}h=e[37076+(h<<2)>>2]|0,d=c+1|0,D=16;continue}else if((D|0)==16){if(D=(F[d>>0]|0)>>>3,(D+-16|D+(h>>26))>>>0>7){D=17;break}if(c=d+1|0,h&33554432){if((S[c>>0]&-64)<<24>>24!=-128){D=20;break}if(c=d+2|0,h&524288){if((S[c>>0]&-64)<<24>>24!=-128){D=23;break}c=d+3|0}}l=l+-1|0,D=7;continue}else if((D|0)==37){if(h=F[c>>0]|0,D=h>>>3,(D+-16|D+(w>>26))>>>0>7){D=38;break}if(d=c+1|0,t=h+-128|w<<6,(t|0)<0){if(h=F[d>>0]|0,(h&192|0)!=128){D=41;break}if(d=c+2|0,t=h+-128|t<<6,(t|0)<0){if(h=F[d>>0]|0,(h&192|0)!=128){D=44;break}t=h+-128|t<<6,c=c+3|0}else c=d}else c=d;e[C>>2]=t,h=C+4|0,l=l+-1|0,D=6;continue}return(D|0)==17||(D|0)==20||(D|0)==23?(c=d+-1|0,D=47):(D|0)==26?e[r>>2]=c:(D|0)==38?(t=C,h=w,c=c+-1|0,D=47):((D|0)==41||(D|0)==44)&&(l=C,o=c+-1|0,D=52),(D|0)==47&&(h?(l=t,o=c,D=52):D=48),(D|0)==48&&(S[c>>0]|0?(l=t,o=c,D=52):(t&&(e[t>>2]=0,e[r>>2]=0),o=o-l|0)),(D|0)==52&&(D=S0()|0,e[D>>2]=84,l&&(e[r>>2]=o),o=-1),o|0}function ES(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;d=b,b=b+16|0,l=d;e:do if(!r)l=0;else{do if(o){if(h=t|0?t:l,l=S[r>>0]|0,t=l&255,l<<24>>24>-1){e[h>>2]=t,l=l<<24>>24!=0&1;break e}if(l=t+-194|0,l>>>0<=50){if(t=r+1|0,c=e[37076+(l<<2)>>2]|0,o>>>0<4&&c&-2147483648>>>((o*6|0)+-6|0)|0)break;if(l=F[t>>0]|0,o=l>>>3,(o+-16|o+(c>>26))>>>0<=7){if(l=l+-128|c<<6,(l|0)>=0){e[h>>2]=l,l=2;break e}if(t=F[r+2>>0]|0,(t&192|0)==128){if(t=t+-128|l<<6,(t|0)>=0){e[h>>2]=t,l=3;break e}if(l=F[r+3>>0]|0,(l&192|0)==128){e[h>>2]=l+-128|t<<6,l=4;break e}}}}}while(!1);l=S0()|0,e[l>>2]=84,l=-1}while(!1);return b=d,l|0}function Oi(t,r,o){t=t|0,r=r|0,o=o|0;do if(t){if(r>>>0<128){S[t>>0]=r,t=1;break}if(r>>>0<2048){S[t>>0]=r>>>6|192,S[t+1>>0]=r&63|128,t=2;break}if(r>>>0<55296|(r&-8192|0)==57344){S[t>>0]=r>>>12|224,S[t+1>>0]=r>>>6&63|128,S[t+2>>0]=r&63|128,t=3;break}if((r+-65536|0)>>>0<1048576){S[t>>0]=r>>>18|240,S[t+1>>0]=r>>>12&63|128,S[t+2>>0]=r>>>6&63|128,S[t+3>>0]=r&63|128,t=4;break}else{t=S0()|0,e[t>>2]=84,t=-1;break}}else t=1;while(!1);return t|0}function kS(t,r,o,l,c){t=t|0,r=r|0,o=o|0,l=l|0,c=c|0;var h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0;k=b,b=b+272|0,w=k+8|0,D=k,d=e[r>>2]|0,e[D>>2]=d,C=(t|0)!=0,c=C?l:256,l=C?t:w,t=d;e:do if((c|0)!=0&(d|0)!=0){for(d=c,h=t,c=0;;){if(t=o>>>0>=d>>>0,!(t|o>>>0>32)){t=h;break e}if(t=t?d:o,o=o-t|0,t=DS(l,D,t,0)|0,(t|0)==-1){c=o;break}if(R=(l|0)==(w|0),N=R?0:t,h=d-N|0,l=R?l:l+t|0,c=t+c|0,t=e[D>>2]|0,(d|0)!=(N|0)&(t|0)!=0)d=h,h=t;else{d=h;break e}}o=c,d=0,t=e[D>>2]|0,c=-1}else d=c,c=0;while(!1);e:do if(t|0&&(d|0)!=0&(o|0)!=0){for(h=t,t=l;l=Oi(t,e[h>>2]|0,0)|0,!((l+1|0)>>>0<2);)if(h=(e[D>>2]|0)+4|0,e[D>>2]=h,o=o+-1|0,c=c+1|0,(d|0)!=(l|0)&(o|0)!=0)d=d-l|0,t=t+l|0;else break e;l?c=-1:e[D>>2]=0}while(!1);return C&&(e[r>>2]=e[D>>2]),b=k,c|0}function DS(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0;w=b,b=b+16|0,d=w;e:do if(t){t:do if(o>>>0>3){for(l=o,c=e[r>>2]|0;;){if(h=e[c>>2]|0,(h+-1|0)>>>0>126){if(!h)break;if(h=Oi(t,h,0)|0,(h|0)==-1){o=-1;break e}t=t+h|0,l=l-h|0}else S[t>>0]=h,t=t+1|0,l=l+-1|0,c=e[r>>2]|0;if(c=c+4|0,e[r>>2]=c,l>>>0<=3)break t}S[t>>0]=0,e[r>>2]=0,o=o-l|0;break e}else l=o;while(!1);if(l){for(c=e[r>>2]|0;;){if(h=e[c>>2]|0,(h+-1|0)>>>0>126){if(!h){c=19;break}if(h=Oi(d,h,0)|0,(h|0)==-1){o=-1;break e}if(l>>>0>>0){c=22;break}Oi(t,e[c>>2]|0,0)|0,t=t+h|0,l=l-h|0}else S[t>>0]=h,t=t+1|0,l=l+-1|0,c=e[r>>2]|0;if(c=c+4|0,e[r>>2]=c,!l)break e}if((c|0)==19){S[t>>0]=0,e[r>>2]=0,o=o-l|0;break}else if((c|0)==22){o=o-l|0;break}}}else if(t=e[r>>2]|0,l=e[t>>2]|0,!l)o=0;else{o=0;do{if(l>>>0>127){if(l=Oi(d,l,0)|0,(l|0)==-1){o=-1;break e}}else l=1;o=l+o|0,t=t+4|0,l=e[t>>2]|0}while(l|0)}while(!1);return b=w,o|0}function Do(t,r){return t=t|0,r=r|0,t?t=Oi(t,r,0)|0:t=0,t|0}function Ri(t){return t=t|0,0}function mi(t){t=t|0}function bo(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0,C=0;C=b,b=b+16|0,w=C,d=r&255,S[w>>0]=d,l=t+16|0,c=e[l>>2]|0,c?h=4:Ro(t)|0?o=-1:(c=e[l>>2]|0,h=4);do if((h|0)==4){if(l=t+20|0,h=e[l>>2]|0,h>>>0>>0&&(o=r&255,(o|0)!=(S[t+75>>0]|0))){e[l>>2]=h+1,S[h>>0]=d;break}(Yt[e[t+36>>2]&63](t,w,1)|0)==1?o=F[w>>0]|0:o=-1}while(!1);return b=C,o|0}function bS(t){t=t|0;var r=0,o=0;return r=b,b=b+16|0,o=r,e[o>>2]=e[t+60>>2],t=Xi(Zo(6,o|0)|0)|0,b=r,t|0}function NS(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0;return D=b,b=b+48|0,h=D+16|0,c=D,l=D+32|0,e[l>>2]=r,d=l+4|0,C=t+48|0,k=e[C>>2]|0,e[d>>2]=o-((k|0)!=0&1),w=t+44|0,e[l+8>>2]=e[w>>2],e[l+12>>2]=k,e[9258]|0?(zr(185,t|0),e[c>>2]=e[t+60>>2],e[c+4>>2]=l,e[c+8>>2]=2,l=Xi(Wr(145,c|0)|0)|0,Vr(0)):(e[h>>2]=e[t+60>>2],e[h+4>>2]=l,e[h+8>>2]=2,l=Xi(Wr(145,h|0)|0)|0),(l|0)>=1?(d=e[d>>2]|0,l>>>0>d>>>0&&(h=e[w>>2]|0,c=t+4|0,e[c>>2]=h,e[t+8>>2]=h+(l-d),e[C>>2]|0&&(e[c>>2]=h+1,S[r+(o+-1)>>0]=S[h>>0]|0),l=o)):(e[t>>2]=e[t>>2]|l&48^16,e[t+8>>2]=0,e[t+4>>2]=0),b=D,l|0}function RS(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0;return c=b,b=b+32|0,h=c,l=c+20|0,e[h>>2]=e[t+60>>2],e[h+4>>2]=0,e[h+8>>2]=r,e[h+12>>2]=l,e[h+16>>2]=o,(Xi(ta(140,h|0)|0)|0)<0?(e[l>>2]=-1,t=-1):t=e[l>>2]|0,b=c,t|0}function No(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0;for(U=b,b=b+48|0,N=U+16|0,k=U,l=U+32|0,R=t+28|0,c=e[R>>2]|0,e[l>>2]=c,_=t+20|0,c=(e[_>>2]|0)-c|0,e[l+4>>2]=c,e[l+8>>2]=r,e[l+12>>2]=o,C=t+60|0,D=t+44|0,r=2,c=c+o|0;;){if(e[9258]|0?(zr(186,t|0),e[k>>2]=e[C>>2],e[k+4>>2]=l,e[k+8>>2]=r,d=Xi(Hr(146,k|0)|0)|0,Vr(0)):(e[N>>2]=e[C>>2],e[N+4>>2]=l,e[N+8>>2]=r,d=Xi(Hr(146,N|0)|0)|0),(c|0)==(d|0)){c=6;break}if((d|0)<0){c=8;break}c=c-d|0,h=e[l+4>>2]|0,d>>>0<=h>>>0?(r|0)==2?(e[R>>2]=(e[R>>2]|0)+d,w=h,r=2):w=h:(w=e[D>>2]|0,e[R>>2]=w,e[_>>2]=w,w=e[l+12>>2]|0,d=d-h|0,l=l+8|0,r=r+-1|0),e[l>>2]=(e[l>>2]|0)+d,e[l+4>>2]=w-d}return(c|0)==6?(N=e[D>>2]|0,e[t+16>>2]=N+(e[t+48>>2]|0),t=N,e[R>>2]=t,e[_>>2]=t):(c|0)==8&&(e[t+16>>2]=0,e[R>>2]=0,e[_>>2]=0,e[t>>2]=e[t>>2]|32,(r|0)==2?o=0:o=o-(e[l+4>>2]|0)|0),b=U,o|0}function MS(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;return c=b,b=b+80|0,l=c,e[t+36>>2]=8,!(e[t>>2]&64|0)&&(e[l>>2]=e[t+60>>2],e[l+4>>2]=21505,e[l+8>>2]=c+12,(Ko(54,l|0)|0)!=0)&&(S[t+75>>0]=-1),l=No(t,r,o)|0,b=c,l|0}function _S(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;return l=t+84|0,h=e[l>>2]|0,d=o+256|0,c=Oo(h,0,d)|0,c=c|0?c-h|0:d,o=c>>>0>>0?c:o,o0(r|0,h|0,o|0)|0,e[t+4>>2]=h+o,r=h+c|0,e[t+8>>2]=r,e[l>>2]=r,o|0}function Fo(t){t=t|0;var r=0,o=0;return r=t+74|0,o=S[r>>0]|0,S[r>>0]=o+255|o,r=t+20|0,o=t+44|0,(e[r>>2]|0)>>>0>(e[o>>2]|0)>>>0&&Yt[e[t+36>>2]&63](t,0,0)|0,e[t+16>>2]=0,e[t+28>>2]=0,e[r>>2]=0,r=e[t>>2]|0,r&20?(r&4&&(e[t>>2]=r|32),r=-1):(r=e[o>>2]|0,e[t+8>>2]=r,e[t+4>>2]=r,r=0),r|0}function Ro(t){t=t|0;var r=0,o=0;return r=t+74|0,o=S[r>>0]|0,S[r>>0]=o+255|o,r=e[t>>2]|0,r&8?(e[t>>2]=r|32,r=-1):(e[t+8>>2]=0,e[t+4>>2]=0,r=e[t+44>>2]|0,e[t+28>>2]=r,e[t+20>>2]=r,e[t+16>>2]=r+(e[t+48>>2]|0),r=0),r|0}function br(t){t=t|0;var r=0,o=0;return o=b,b=b+16|0,r=o,!(e[t+8>>2]|0)&&Fo(t)|0?r=-1:(Yt[e[t+32>>2]&63](t,r,1)|0)==1?r=F[r>>0]|0:r=-1,b=o,r|0}function Nr(t){t=t|0;var r=0,o=0;do if(t){if((e[t+76>>2]|0)<=-1){r=Mr(t)|0;break}o=(Ri(t)|0)==0,r=Mr(t)|0,o||mi(t)}else{if(e[9323]|0?r=Nr(e[9323]|0)|0:r=0,M0(37060),t=e[9264]|0,t)do(e[t+76>>2]|0)>-1?o=Ri(t)|0:o=0,(e[t+20>>2]|0)>>>0>(e[t+28>>2]|0)>>>0&&(r=Mr(t)|0|r),o&&mi(t),t=e[t+56>>2]|0;while(t|0);Yo(37060)}while(!1);return r|0}function PS(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0;(e[r+76>>2]|0)>=0&&Ri(r)|0?((S[r+75>>0]|0)!=(t|0)&&(l=r+20|0,c=e[l>>2]|0,c>>>0<(e[r+16>>2]|0)>>>0)?(e[l>>2]=c+1,S[c>>0]=t,o=t&255):o=bo(r,t)|0,mi(r)):d=3;do if((d|0)==3){if((S[r+75>>0]|0)!=(t|0)&&(h=r+20|0,o=e[h>>2]|0,o>>>0<(e[r+16>>2]|0)>>>0)){e[h>>2]=o+1,S[o>>0]=t,o=t&255;break}o=bo(r,t)|0}while(!1);return o|0}function B0(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;l=o+16|0,c=e[l>>2]|0,c?h=4:Ro(o)|0?l=0:(c=e[l>>2]|0,h=4);e:do if((h|0)==4){if(d=o+20|0,h=e[d>>2]|0,(c-h|0)>>>0>>0){l=Yt[e[o+36>>2]&63](o,t,r)|0;break}t:do if((S[o+75>>0]|0)>-1){for(l=r;;){if(!l){c=h,l=0;break t}if(c=l+-1|0,(S[t+c>>0]|0)==10)break;l=c}if((Yt[e[o+36>>2]&63](o,t,l)|0)>>>0>>0)break e;r=r-l|0,t=t+l|0,c=e[d>>2]|0}else c=h,l=0;while(!1);o0(c|0,t|0,r|0)|0,e[d>>2]=(e[d>>2]|0)+r,l=l+r|0}while(!1);return l|0}function gi(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;return c=ee(o,r)|0,(e[l+76>>2]|0)>-1?(h=(Ri(l)|0)==0,t=B0(t,c,l)|0,h||mi(l)):t=B0(t,c,l)|0,(t|0)!=(c|0)&&(o=(t>>>0)/(r>>>0)|0),o|0}function Fn(t){t=t|0;var r=0,o=0,l=0;(e[t+76>>2]|0)>=0&&Ri(t)|0?(r=t+4|0,o=e[r>>2]|0,o>>>0<(e[t+8>>2]|0)>>>0?(e[r>>2]=o+1,r=F[o>>0]|0):r=br(t)|0):l=3;do if((l|0)==3)if(r=t+4|0,o=e[r>>2]|0,o>>>0<(e[t+8>>2]|0)>>>0){e[r>>2]=o+1,r=F[o>>0]|0;break}else{r=br(t)|0;break}while(!1);return r|0}function Mo(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0;return c=b,b=b+16|0,h=c,e[h>>2]=l,l=Mn(t,r,o,h)|0,b=c,l|0}function _o(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;return l=b,b=b+16|0,c=l,e[c>>2]=o,o=Lo(t,r,c)|0,b=l,o|0}function Rn(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0;do if((t|0)!=-1){if((e[r+76>>2]|0)>-1?c=Ri(r)|0:c=0,!(e[r+8>>2]|0)&&Fo(r)|0||(h=6),(h|0)==6&&(o=r+4|0,l=e[o>>2]|0,l>>>0>((e[r+44>>2]|0)+-8|0)>>>0)){if(h=l+-1|0,e[o>>2]=h,S[h>>0]=t,e[r>>2]=e[r>>2]&-17,!c)break;mi(r);break}c&&mi(r),t=-1}else t=-1;while(!1);return t|0}function LS(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0;w=b,b=b+16|0,l=w,c=E0(240)|0;do if(c){if(e[l>>2]=e[o>>2],l=Mn(c,240,r,l)|0,l>>>0<240){r=Gi(c,l+1|0)|0,e[t>>2]=r|0?r:c;break}n0(c),(l|0)>=0&&(d=l+1|0,h=E0(d)|0,e[t>>2]=h,(h|0)!=0)?l=Mn(h,d,r,o)|0:l=-1}else l=-1;while(!1);return b=w,l|0}function Po(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0;Q=b,b=b+224|0,N=Q+80|0,U=Q+96|0,_=Q,R=Q+136|0,l=U,c=l+40|0;do e[l>>2]=0,l=l+4|0;while((l|0)<(c|0));return e[N>>2]=e[o>>2],(cr(0,r,N,_,U)|0)<0?o=-1:((e[t+76>>2]|0)>-1?D=Ri(t)|0:D=0,o=e[t>>2]|0,k=o&32,(S[t+74>>0]|0)<1&&(e[t>>2]=o&-33),o=t+48|0,e[o>>2]|0?l=cr(t,r,N,_,U)|0:(c=t+44|0,h=e[c>>2]|0,e[c>>2]=R,d=t+28|0,e[d>>2]=R,w=t+20|0,e[w>>2]=R,e[o>>2]=80,C=t+16|0,e[C>>2]=R+80,l=cr(t,r,N,_,U)|0,h&&(Yt[e[t+36>>2]&63](t,0,0)|0,l=e[w>>2]|0?l:-1,e[c>>2]=h,e[o>>2]=0,e[C>>2]=0,e[d>>2]=0,e[w>>2]=0)),o=e[t>>2]|0,e[t>>2]=o|k,D&&mi(t),o=o&32|0?-1:l),b=Q,o|0}function OS(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0,w=0,C=0,D=0,k=0,N=0,R=0,_=0,U=0,Q=0,K=0,G=0,$=0,P=0,O=0,Z=0,ie=0,oe=0,ne=0,ce=0,ke=0,Ee=0,Te=0,it=0,jt=0,Gt=0,s0=0,i0=0,zt=0;i0=b,b=b+304|0,ce=i0+16|0,Ee=i0+8|0,ke=i0+33|0,Te=i0,G=i0+32|0,(e[t+76>>2]|0)>-1?s0=Ri(t)|0:s0=0,l=S[r>>0]|0;e:do if(l<<24>>24){it=t+4|0,jt=t+100|0,ne=t+108|0,$=t+8|0,P=ke+10|0,O=ke+33|0,Z=Ee+4|0,ie=ke+46|0,oe=ke+94|0,h=l,l=0,d=r,N=0,c=0,r=0;t:for(;;){i:do if(ji(h&255)|0){for(;h=d+1|0,ji(F[h>>0]|0)|0;)d=h;oi(t,0);do h=e[it>>2]|0,h>>>0<(e[jt>>2]|0)>>>0?(e[it>>2]=h+1,h=F[h>>0]|0):h=u0(t)|0;while(ji(h)|0);h=e[it>>2]|0,e[jt>>2]|0&&(h=h+-1|0,e[it>>2]=h),w=(e[ne>>2]|0)+N+h-(e[$>>2]|0)|0}else{h=(S[d>>0]|0)==37;n:do if(h){D=d+1|0,w=S[D>>0]|0;r:do switch(w<<24>>24){case 37:break n;case 42:{K=0,w=d+2|0;break}default:{if(w=(w&255)+-48|0,w>>>0<10&&(S[d+2>>0]|0)==36){for(e[ce>>2]=e[o>>2];K=(e[ce>>2]|0)+3&-4,h=e[K>>2]|0,e[ce>>2]=K+4,w>>>0>1;)w=w+-1|0;K=h,w=d+3|0;break r}w=(e[o>>2]|0)+3&-4,K=e[w>>2]|0,e[o>>2]=w+4,w=D}}while(!1);if(h=S[w>>0]|0,d=h&255,(d+-48|0)>>>0<10)for(h=0;D=(h*10|0)+-48+d|0,w=w+1|0,h=S[w>>0]|0,d=h&255,!((d+-48|0)>>>0>=10);)h=D;else D=0;switch(h<<24>>24==109?(w=w+1|0,k=S[w>>0]|0,h=(K|0)!=0&1,c=0,r=0):(k=h,h=0),d=w+1|0,k&255|0){case 104:{Q=(S[d>>0]|0)==104,d=Q?w+2|0:d,w=Q?-2:-1;break}case 108:{Q=(S[d>>0]|0)==108,d=Q?w+2|0:d,w=Q?3:1;break}case 106:{w=3;break}case 116:case 122:{w=1;break}case 76:{w=2;break}case 110:case 112:case 67:case 83:case 91:case 99:case 115:case 88:case 71:case 70:case 69:case 65:case 103:case 102:case 101:case 97:case 120:case 117:case 111:case 105:case 100:{d=w,w=0;break}default:{Gt=152;break t}}switch(k=F[d>>0]|0,R=(k&47|0)==3,k=R?k|32:k,R=R?1:w,k|0){case 99:{Q=N,U=(D|0)<1?1:D;break}case 91:{Q=N,U=D;break}case 110:{if(!K){w=N;break i}switch(R|0){case-2:{S[K>>0]=N,w=N;break i}case-1:{E[K>>1]=N,w=N;break i}case 0:{e[K>>2]=N,w=N;break i}case 1:{e[K>>2]=N,w=N;break i}case 3:{w=K,e[w>>2]=N,e[w+4>>2]=((N|0)<0)<<31>>31,w=N;break i}default:{w=N;break i}}}default:{oi(t,0);do w=e[it>>2]|0,w>>>0<(e[jt>>2]|0)>>>0?(e[it>>2]=w+1,w=F[w>>0]|0):w=u0(t)|0;while(ji(w)|0);w=e[it>>2]|0,e[jt>>2]|0&&(w=w+-1|0,e[it>>2]=w),Q=(e[ne>>2]|0)+N+w-(e[$>>2]|0)|0,U=D}}if(oi(t,U),w=e[it>>2]|0,D=e[jt>>2]|0,w>>>0>>0)e[it>>2]=w+1;else{if((u0(t)|0)<0){Gt=152;break t}D=e[jt>>2]|0}D&&(e[it>>2]=(e[it>>2]|0)+-1);r:do switch(k|0){case 91:case 99:case 115:{_=(k|0)==99;s:do if((k&239|0)==99)Jt(ke|0,-1,257)|0,S[ke>>0]=0,(k|0)==115&&(S[O>>0]=0,S[P>>0]=0,S[P+1>>0]=0,S[P+2>>0]=0,S[P+3>>0]=0,S[P+4>>0]=0);else{switch(zt=d+1|0,N=(S[zt>>0]|0)==94,w=N&1,k=N?zt:d,d=N?d+2|0:zt,Jt(ke|0,N&1|0,257)|0,S[ke>>0]=0,S[d>>0]|0){case 45:{N=(w^1)&255,S[ie>>0]=N,d=k+2|0;break}case 93:{N=(w^1)&255,S[oe>>0]=N,d=k+2|0;break}default:N=(w^1)&255}for(;;){w=S[d>>0]|0;o:do switch(w<<24>>24){case 0:{Gt=152;break t}case 93:break s;case 45:{switch(k=d+1|0,w=S[k>>0]|0,w<<24>>24){case 93:case 0:{w=45;break o}default:}if(d=S[d+-1>>0]|0,(d&255)<(w&255)){d=d&255;do d=d+1|0,S[ke+d>>0]=N,w=S[k>>0]|0;while((d|0)<(w&255|0));d=k}else d=k;break}default:}while(!1);S[ke+((w&255)+1)>>0]=N,d=d+1|0}}while(!1);k=_?U+1|0:31,N=(R|0)==1,R=(h|0)!=0;s:do if(N){if(R){if(r=E0(k<<2)|0,!r){c=0,Gt=152;break t}}else r=K;e[Ee>>2]=0,e[Z>>2]=0,c=0;o:for(;;){D=(r|0)==0;do{a:for(;;){if(w=e[it>>2]|0,w>>>0<(e[jt>>2]|0)>>>0?(e[it>>2]=w+1,w=F[w>>0]|0):w=u0(t)|0,!(S[ke+(w+1)>>0]|0))break o;switch(S[G>>0]=w,Nn(Te,G,1,Ee)|0){case-1:{c=0,Gt=152;break t}case-2:break;default:break a}}D||(e[r+(c<<2)>>2]=e[Te>>2],c=c+1|0)}while(!(R&(c|0)==(k|0)));if(c=k<<1|1,w=Gi(r,c<<2)|0,!w){c=0,Gt=152;break t}zt=k,k=c,r=w,c=zt}if(TS(Ee)|0)D=c,c=0;else{c=0,Gt=152;break t}}else{if(R){if(c=E0(k)|0,c)w=0;else{c=0,r=0,Gt=152;break t}for(;;){do{if(r=e[it>>2]|0,r>>>0<(e[jt>>2]|0)>>>0?(e[it>>2]=r+1,r=F[r>>0]|0):r=u0(t)|0,!(S[ke+(r+1)>>0]|0)){D=w,r=0;break s}S[c+w>>0]=r,w=w+1|0}while((w|0)!=(k|0));if(r=k<<1|1,w=Gi(c,r)|0,w)zt=k,k=r,c=w,w=zt;else{r=0,Gt=152;break t}}}if(K)for(c=0;;){if(r=e[it>>2]|0,r>>>0>>0?(e[it>>2]=r+1,r=F[r>>0]|0):r=u0(t)|0,!(S[ke+(r+1)>>0]|0)){D=c,c=K,r=0;break s}S[K+c>>0]=r,D=e[jt>>2]|0,c=c+1|0}else for(c=D;;){if(r=e[it>>2]|0,r>>>0>>0?(e[it>>2]=r+1,r=F[r>>0]|0):r=u0(t)|0,!(S[ke+(r+1)>>0]|0)){D=0,c=0,r=0;break s}c=e[jt>>2]|0}}while(!1);if(w=e[it>>2]|0,e[jt>>2]|0&&(w=w+-1|0,e[it>>2]=w),w=w-(e[$>>2]|0)+(e[ne>>2]|0)|0,!w||!((w|0)==(U|0)|_^1))break t;do if(R)if(N){e[K>>2]=r;break}else{e[K>>2]=c;break}while(!1);if(!_){if(r&&(e[r+(D<<2)>>2]=0),!c){c=0;break r}S[c+D>>0]=0}break}case 120:case 88:case 112:{w=16,Gt=134;break}case 111:{w=8,Gt=134;break}case 117:case 100:{w=10,Gt=134;break}case 105:{w=0,Gt=134;break}case 71:case 103:case 70:case 102:case 69:case 101:case 65:case 97:{if(C=+xo(t,R,0),(e[ne>>2]|0)==((e[$>>2]|0)-(e[it>>2]|0)|0))break t;if(K)switch(R|0){case 0:{V[K>>2]=C;break r}case 1:{B[K>>3]=C;break r}case 2:{B[K>>3]=C;break r}default:break r}break}default:}while(!1);r:do if((Gt|0)==134){if(Gt=0,w=wo(t,w,0,-1,-1)|0,(e[ne>>2]|0)==((e[$>>2]|0)-(e[it>>2]|0)|0))break t;if((K|0)!=0&(k|0)==112){e[K>>2]=w;break}if(K)switch(R|0){case-2:{S[K>>0]=w;break r}case-1:{E[K>>1]=w;break r}case 0:{e[K>>2]=w;break r}case 1:{e[K>>2]=w;break r}case 3:{zt=K,e[zt>>2]=w,e[zt+4>>2]=ye;break r}default:break r}}while(!1);l=((K|0)!=0&1)+l|0,w=(e[ne>>2]|0)+Q+(e[it>>2]|0)-(e[$>>2]|0)|0;break i}while(!1);if(d=d+(h&1)|0,oi(t,0),h=e[it>>2]|0,h>>>0<(e[jt>>2]|0)>>>0?(e[it>>2]=h+1,h=F[h>>0]|0):h=u0(t)|0,(h|0)!=(F[d>>0]|0)){Gt=21;break t}w=N+1|0}while(!1);if(d=d+1|0,h=S[d>>0]|0,h<<24>>24)N=w;else break e}if((Gt|0)==21){if(e[jt>>2]|0&&(e[it>>2]=(e[it>>2]|0)+-1),(l|0)!=0|(h|0)>-1)break;l=0,Gt=153}else(Gt|0)==152&&(l||(l=h,Gt=153));(Gt|0)==153&&(h=l,l=-1),h&&(n0(c),n0(r))}else l=0;while(!1);return s0&&mi(t),b=i0,l|0}function Mn(t,r,o,l){t=t|0,r=r|0,o=o|0,l=l|0;var c=0,h=0,d=0,w=0,C=0,D=0,k=0;k=b,b=b+128|0,c=k+112|0,D=k,h=D,d=37352,w=h+112|0;do e[h>>2]=e[d>>2],h=h+4|0,d=d+4|0;while((h|0)<(w|0));return(r+-1|0)>>>0>2147483646?r?(r=S0()|0,e[r>>2]=75,r=-1):(r=1,C=4):(c=t,C=4),(C|0)==4&&(C=-2-c|0,C=r>>>0>C>>>0?C:r,e[D+48>>2]=C,t=D+20|0,e[t>>2]=c,e[D+44>>2]=c,r=c+C|0,c=D+16|0,e[c>>2]=r,e[D+28>>2]=r,r=Po(D,o,l)|0,C&&(o=e[t>>2]|0,S[o+(((o|0)==(e[c>>2]|0))<<31>>31)>>0]=0)),b=k,r|0}function Lo(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;h=b,b=b+112|0,l=h,c=l,d=c+112|0;do e[c>>2]=0,c=c+4|0;while((c|0)<(d|0));return e[l+32>>2]=29,e[l+44>>2]=t,e[l+76>>2]=-1,e[l+84>>2]=t,d=OS(l,r,o)|0,b=h,d|0}function Fr(t,r,o){return t=t|0,r=r|0,o=o|0,+ +Ed(t,r,2)}function $S(t,r,o){return t=t|0,r=r|0,o=o|0,t=_s(t,r,o,-1,-1)|0,t|0}function BS(t,r,o){return t=t|0,r=r|0,o=o|0,t=_s(t,r,o,0,-2147483648)|0,t|0}function Oo(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0,h=0,d=0;h=r&255,l=(o|0)!=0;e:do if(l&(t&3|0)!=0)for(c=r&255;;){if((S[t>>0]|0)==c<<24>>24){d=6;break e}if(t=t+1|0,o=o+-1|0,l=(o|0)!=0,!(l&(t&3|0)!=0)){d=5;break}}else d=5;while(!1);(d|0)==5&&(l?d=6:o=0);e:do if((d|0)==6&&(c=r&255,(S[t>>0]|0)!=c<<24>>24)){l=ee(h,16843009)|0;t:do if(o>>>0>3){for(;h=e[t>>2]^l,!((h&-2139062144^-2139062144)&h+-16843009);)if(t=t+4|0,o=o+-4|0,o>>>0<=3){d=11;break t}}else d=11;while(!1);if((d|0)==11&&!o){o=0;break}for(;;){if((S[t>>0]|0)==c<<24>>24)break e;if(t=t+1|0,o=o+-1|0,!o){o=0;break}}}while(!1);return(o|0?t:0)|0}function VS(t,r){t=t|0,r=r|0;var o=0,l=0;o=r;e:do if((o^t)&3)l=8;else{if(o&3)do{if(o=S[r>>0]|0,S[t>>0]=o,!(o<<24>>24))break e;r=r+1|0,t=t+1|0}while(r&3|0);if(o=e[r>>2]|0,!((o&-2139062144^-2139062144)&o+-16843009))for(l=t;r=r+4|0,t=l+4|0,e[l>>2]=o,o=e[r>>2]|0,!((o&-2139062144^-2139062144)&o+-16843009);)l=t;l=8}while(!1);if((l|0)==8&&(l=S[r>>0]|0,S[t>>0]=l,l<<24>>24))do r=r+1|0,t=t+1|0,l=S[r>>0]|0,S[t>>0]=l;while(l<<24>>24);return t|0}function $o(t,r){t=t|0,r=r|0;var o=0,l=0;if(l=S[t>>0]|0,o=S[r>>0]|0,!(l<<24>>24)||l<<24>>24!=o<<24>>24)r=l;else{do t=t+1|0,r=r+1|0,l=S[t>>0]|0,o=S[r>>0]|0;while(!(!(l<<24>>24)||l<<24>>24!=o<<24>>24));r=l}return(r&255)-(o&255)|0}function Rr(t,r){return t=t|0,r=r|0,VS(t,r)|0,t|0}function $i(t){t=t|0;var r=0,o=0,l=0;l=t;e:do if(!(l&3))o=4;else for(r=t,t=l;;){if(!(S[r>>0]|0))break e;if(r=r+1|0,t=r,!(t&3)){t=r,o=4;break}}while(!1);if((o|0)==4){for(;r=e[t>>2]|0,!((r&-2139062144^-2139062144)&r+-16843009);)t=t+4|0;if((r&255)<<24>>24)do t=t+1|0;while(S[t>>0]|0)}return t-l|0}function US(t,r,o){t=t|0,r=r|0,o=o|0;var l=0,c=0;if(!o)r=0;else{l=S[t>>0]|0;e:do if(!(l<<24>>24))l=0;else for(;;){if(o=o+-1|0,c=S[r>>0]|0,!(l<<24>>24==c<<24>>24&((o|0)!=0&c<<24>>24!=0)))break e;if(t=t+1|0,r=r+1|0,l=S[t>>0]|0,!(l<<24>>24)){l=0;break}}while(!1);r=(l&255)-(F[r>>0]|0)|0}return r|0}function _n(t){t=t|0;var r=0;for(r=t;e[r>>2]|0;)r=r+4|0;return r-t>>2|0}function Bi(t,r,o){t=t|0,r=r|0,o=o|0;var l=0;if(o)for(l=t;o=o+-1|0,e[l>>2]=e[r>>2],o;)r=r+4|0,l=l+4|0;return t|0}function zS(t,r,o){t=t|0,r=r|0,o=o|0;var l=0;if(l=(o|0)==0,t-r>>2>>>0>>0){if(!l)do o=o+-1|0,e[t+(o<<2)>>2]=e[r+(o<<2)>>2];while(o|0)}else if(!l)for(l=r,r=t;o=o+-1|0,e[r>>2]=e[l>>2],o;)l=l+4|0,r=r+4|0;return t|0}function GS(t,r,o){t=t|0,r=r|0,o=o|0;var l=0;if(o)for(l=t;o=o+-1|0,e[l>>2]=r,o;)l=l+4|0;return t|0}function Bo(t,r){t=t|0,r=r|0;var o=0,l=0,c=0,h=0,d=0,w=0;switch(d=t+4|0,o=e[d>>2]|0,w=t+100|0,o>>>0<(e[w>>2]|0)>>>0?(e[d>>2]=o+1,o=F[o>>0]|0):o=u0(t)|0,o|0){case 43:case 45:{l=(o|0)==45&1,o=e[d>>2]|0,o>>>0<(e[w>>2]|0)>>>0?(e[d>>2]=o+1,o=F[o>>0]|0):o=u0(t)|0,(r|0)!=0&(o+-48|0)>>>0>9&&e[w>>2]|0&&(e[d>>2]=(e[d>>2]|0)+-1),h=l;break}default:h=0}if((o+-48|0)>>>0>9)e[w>>2]|0?(e[d>>2]=(e[d>>2]|0)+-1,l=-2147483648,o=0):(l=-2147483648,o=0);else{l=0;do l=o+-48+(l*10|0)|0,o=e[d>>2]|0,o>>>0<(e[w>>2]|0)>>>0?(e[d>>2]=o+1,o=F[o>>0]|0):o=u0(t)|0;while((o+-48|0)>>>0<10&(l|0)<214748364);if(r=((l|0)<0)<<31>>31,(o+-48|0)>>>0<10){do r=Qi(l|0,r|0,10,0)|0,l=ye,o=$0(o|0,((o|0)<0)<<31>>31|0,-48,-1)|0,l=$0(o|0,ye|0,r|0,l|0)|0,r=ye,o=e[d>>2]|0,o>>>0<(e[w>>2]|0)>>>0?(e[d>>2]=o+1,o=F[o>>0]|0):o=u0(t)|0;while((o+-48|0)>>>0<10&((r|0)<21474836|(r|0)==21474836&l>>>0<2061584302));c=l}else c=l;if((o+-48|0)>>>0<10)do o=e[d>>2]|0,o>>>0<(e[w>>2]|0)>>>0?(e[d>>2]=o+1,o=F[o>>0]|0):o=u0(t)|0;while((o+-48|0)>>>0<10);e[w>>2]|0&&(e[d>>2]=(e[d>>2]|0)+-1),t=(h|0)!=0,o=ii(0,0,c|0,r|0)|0,l=t?ye:r,o=t?o:c}return ye=l,o|0}function qS(t){t=t|0,e[t+68>>2]|0||mi(t)}function WS(t){t=t|0,e[t+68>>2]|0||mi(t)}function Mr(t){t=t|0;var r=0,o=0,l=0,c=0,h=0,d=0;return r=t+20|0,h=t+28|0,(e[r>>2]|0)>>>0>(e[h>>2]|0)>>>0&&(Yt[e[t+36>>2]&63](t,0,0)|0,(e[r>>2]|0)==0)?r=-1:(d=t+4|0,o=e[d>>2]|0,l=t+8|0,c=e[l>>2]|0,o>>>0>>0&&Yt[e[t+40>>2]&63](t,o-c|0,1)|0,e[t+16>>2]=0,e[h>>2]=0,e[r>>2]=0,e[l>>2]=0,e[d>>2]=0,r=0),r|0}var HS=[bi,nf,of,eh,nh,ah,uh,Sn,An,bi,bi,bi,bi,bi,bi,bi],Pn=[sn,Y5,Ju,zu,Fu,xu,cu,eu,V2,tS,eS,J6,sn,sn,sn,sn],QS=[so,ph,xh,so],Mt=[e0,W5,H5,Yu,ju,$u,Bu,ku,Du,gu,Su,ou,au,j2,X2,L2,O2,T2,I2,m2,g2,r2,s2,K1,Y1,$1,B1,n1,r1,Kl,Yl,Ia,Ea,Ml,Ol,_l,hm,Xs,dm,pm,ul,cl,w6,hl,il,nl,Ua,za,Ha,Qa,Xa,Za,dl,pl,Al,vl,Cl,Tl,Dl,bl,Hl,Ql,d1,p1,A1,v1,C1,T1,b1,N1,K2,Y2,mp,i6,f6,h6,y6,C6,R6,M6,In,O6,V6,U6,G6,H6,q6,W6,Q6,K6,rn,Ld,zd,wt,Hd,Zd,fr,pp,Mp,Hp,sm,Qs,om,am,um,Ys,cm,fm,Am,Zs,vm,xm,Em,km,G0,Dm,bm,Nm,Rm,Gh,Lm,Om,Um,zm,eg,tg,dg,pg,Ig,Eg,hc,dc,Mc,_c,ef,tf,rf,sf,lf,uf,vf,xf,Nf,Ff,Uf,zf,Zf,Jf,sh,oh,hh,dh,Ah,vh,Th,Ih,bh,Nh,Rs,Lh,Ms,sd,io,Td,eo,r4,to,s4,Fm,Uh,Wh,md,$g,Hg,e4,t4,T6,fo,pi,Ta,Sr,lm,Ul,G2,cS,qS,WS,Fd,gS,th,fn,qh,L3,G3,q3,W3,H3,Q3,K3,de,Pt,n0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0,e0],t0=[Tr,K5,Zu,Uu,Nu,vu,uu,J2,B2,E2,S2,o2,j1,V1,s1,jl,ka,_p,d6,p6,Od,Ud,Qd,Xd,Qp,hf,df,pf,mf,Sf,Af,Cf,Tf,If,Ef,Df,bf,_f,Pf,Lf,Of,Bf,Vf,Wf,Hf,Qf,Kf,jf,Xf,Dh,Mh,f4,d4,m4,h4,p4,g4,Sa,I6,m6,g6,ho,Rp,Pa,Oa,mm,Np,yp,Vl,Jl,_1,G1,J1,c2,x2,F2,z2,iu,hu,yu,Mu,qu,ic,X5,u6,Fi,rp,ip,Fp,wm,np,xp,Ep,Ip,r3,s3,o3,l3,u3,c3,Cd,f3,h3,d3,p3,m3,g3,S3,A3,v3,x3,w3,y3,C3,T3,I3,E3,k3,D3,b3,N3,F3,R3,M3,_3,J3,Tr,Tr],on=[N0,Gm,qm,Wm,Hm,Qm,Km,Ym,jm,Xm,Zm,Jm,ig,ng,rg,sg,og,ag,lg,ug,cg,fg,hg,Ag,xg,Ng,oc,mc,gc,Sc,Ac,vc,Lc,Oc,$c,Bc,Vc,Sh,Ch,Ui,Hi,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0],Dt=[r0,$p,Bp,ol,zp,n6,_6,$6,z6,bS,$d,Zp,em,tm,Xp,Gd,qd,Kd,Up,Jd,ep,ym,pc,S4,x4,y4,D4,F4,T4,E4,Pc,A4,w4,C4,N4,R4,I4,k4,cf,ff,gf,wf,yf,kf,Rf,Mf,$f,Gf,qf,Yf,_g,Pg,Og,o4,u4,l4,c4,vd,xd,yd,zg,Gg,Wg,jg,Xg,Jg,o6,Xe,f0,d0,Ks,js,P5,L5,O5,ai,_n,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0,r0],KS=[oo,ih,lh,oo],Yt=[C0,Pp,Vp,qp,ap,lp,Y6,kd,No,RS,NS,MS,Kp,Jp,Bd,nm,Yd,Pm,Vm,Eh,Fh,ad,ud,dd,Hh,Xh,Jh,nd,La,Id,Gs,vS,t3,n3,Oi,ES,CS,LS,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0,C0],YS=[ao,gh,yh,ao],Vi=[Ni,rl,rS,nS,iS,Yp,Lp,kh,Rh,Ni,Ni,Ni,Ni,Ni,Ni,Ni],jS=[yn,Sg,yg,bg,uc,yn,yn,yn],XS=[Cn,rh,fh,mh,wh,Cn,Cn,Cn],U0=[L0,Q5,Xu,Vu,bu,Au,lu,Z2,$2,N2,v2,u2,Z1,z1,l1,Zl,ba,al,ll,im,Vd,Wd,rm,Gp,jd,tp,Wp,od,ld,cd,jh,Zh,ed,E6,xa,ya,gm,O0,Sm,AS,SS,Ap,Cp,L0,L0,L0,L0,L0,L0,L0,L0,L0,L0,L0,L0,L0,L0,L0,L0,L0,L0,L0,L0,L0],an=[di,Mm,$m,mg,gg,vg,Tg,kg,Dg,sc,fc,pd,Mg,Lg,rd,Ad,wd,Ug,qg,Yg,Zg,kS,IS,di,di,di,di,di,di,di,di,di],ZS=[$5,i5,t5,e5],JS=[Li,Aa,po,b0,$h,Bh,Vh,fS,dS,hS,Li,Li,Li,Li,Li,Li],_r=[Ki,D2,A2,l2,X1,U1,o1,Xl,Da,hd,Qh,Kh,Yh,id,s6,c6,z4,Z4,ko,mS,Nn,u5,l5,o5,s5,r5,n5,Ki,Ki,Ki,Ki,Ki],Ln=[B5,sp,r6,Cm,k6,yi,V5,dp,zs,S6,cp,Im,J4,e3,i3,mr],Vo=[lo,U5,aS,z5,lS,G5,kn,lo],Ci=[Yi,xc,Uc,Fg,Rg,gd,Sd,Bg,Vg,Qg,Kg,Yi,Yi,Yi,Yi,Yi],eA=[Tn,wg,Cg,ac,cc,Tn,Tn,Tn],On=[H0,$l,Bl,Pl,Ll,sl,Ga,qa,Ka,Ya,Ja,el,ml,gl,xl,wl,Il,El,Nl,Fl,m1,g1,x1,w1,I1,E1,F1,R1,j6,X6,Z6,jp,Op,_m,Bm,fa,hp,Na,Fa,Ra,Ma,$a,Ba,Va,u1,c1,f1,h1,H0,H0,H0,H0,H0,H0,H0,H0,H0,H0,H0,H0,H0,H0,H0,H0];return{_jpegls_encode:b6,___cxa_can_catch:sS,_free:n0,_jpegls_decode:D6,___cxa_is_pointer_type:oS,_i64Add:$0,_memmove:vn,_i64Subtract:ii,_memset:Jt,_malloc:E0,_memcpy:o0,_bitshift64Lshr:Di,_bitshift64Shl:v0,__GLOBAL__I_000101:Rd,__GLOBAL__sub_I_jpegls_cpp:Ca,__GLOBAL__sub_I_iostream_cpp:Md,runPostSets:c5,_emscripten_replace_memory:ia,stackAlloc:na,stackSave:ra,stackRestore:sa,establishStackSpace:oa,setThrew:aa,setTempRet0:la,getTempRet0:ua,dynCall_iiiiiiii:h5,dynCall_viiiii:d5,dynCall_iiiiiid:p5,dynCall_vi:m5,dynCall_vii:g5,dynCall_iiiiiii:S5,dynCall_ii:A5,dynCall_iiiiiiiiiiii:v5,dynCall_iiii:x5,dynCall_viiiiiiiiiiiiiii:w5,dynCall_viiiiii:y5,dynCall_viiiiiii:C5,dynCall_viiiiiiiiii:T5,dynCall_iii:I5,dynCall_iiiiii:E5,dynCall_diii:k5,dynCall_i:D5,dynCall_iiiii:b5,dynCall_viii:N5,dynCall_v:F5,dynCall_iiiiiiiii:R5,dynCall_iiiiid:M5,dynCall_viiii:_5}}(Module.asmGlobalArg,Module.asmLibraryArg,buffer);Module._jpegls_encode=asm._jpegls_encode,Module.___cxa_can_catch=asm.___cxa_can_catch;var _free=Module._free=asm._free;Module._jpegls_decode=asm._jpegls_decode,Module.___cxa_is_pointer_type=asm.___cxa_is_pointer_type;var _i64Add=Module._i64Add=asm._i64Add,_memmove=Module._memmove=asm._memmove,_i64Subtract=Module._i64Subtract=asm._i64Subtract,_memset=Module._memset=asm._memset,_malloc=Module._malloc=asm._malloc,_memcpy=Module._memcpy=asm._memcpy,_emscripten_replace_memory=Module._emscripten_replace_memory=asm._emscripten_replace_memory;Module.runPostSets=asm.runPostSets,Module.__GLOBAL__sub_I_iostream_cpp=asm.__GLOBAL__sub_I_iostream_cpp;var _bitshift64Lshr=Module._bitshift64Lshr=asm._bitshift64Lshr,__GLOBAL__sub_I_jpegls_cpp=Module.__GLOBAL__sub_I_jpegls_cpp=asm.__GLOBAL__sub_I_jpegls_cpp,__GLOBAL__I_000101=Module.__GLOBAL__I_000101=asm.__GLOBAL__I_000101,_bitshift64Shl=Module._bitshift64Shl=asm._bitshift64Shl;Module.dynCall_iiiiiiii=asm.dynCall_iiiiiiii,Module.dynCall_viiiii=asm.dynCall_viiiii,Module.dynCall_iiiiiid=asm.dynCall_iiiiiid,Module.dynCall_vi=asm.dynCall_vi,Module.dynCall_vii=asm.dynCall_vii,Module.dynCall_iiiiiii=asm.dynCall_iiiiiii,Module.dynCall_ii=asm.dynCall_ii,Module.dynCall_iiiiiiiiiiii=asm.dynCall_iiiiiiiiiiii,Module.dynCall_iiii=asm.dynCall_iiii,Module.dynCall_viiiiiiiiiiiiiii=asm.dynCall_viiiiiiiiiiiiiii,Module.dynCall_viiiiii=asm.dynCall_viiiiii,Module.dynCall_viiiiiii=asm.dynCall_viiiiiii,Module.dynCall_viiiiiiiiii=asm.dynCall_viiiiiiiiii,Module.dynCall_iii=asm.dynCall_iii,Module.dynCall_iiiiii=asm.dynCall_iiiiii,Module.dynCall_diii=asm.dynCall_diii,Module.dynCall_i=asm.dynCall_i,Module.dynCall_iiiii=asm.dynCall_iiiii,Module.dynCall_viii=asm.dynCall_viii,Module.dynCall_v=asm.dynCall_v,Module.dynCall_iiiiiiiii=asm.dynCall_iiiiiiiii,Module.dynCall_iiiiid=asm.dynCall_iiiiid,Module.dynCall_viiii=asm.dynCall_viiii,Runtime.stackAlloc=asm.stackAlloc,Runtime.stackSave=asm.stackSave,Runtime.stackRestore=asm.stackRestore,Runtime.establishStackSpace=asm.establishStackSpace,Runtime.setTempRet0=asm.setTempRet0,Runtime.getTempRet0=asm.getTempRet0;function ExitStatus(a){this.name="ExitStatus",this.message="Program terminated with exit("+a+")",this.status=a}ExitStatus.prototype=new Error,ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;dependenciesFulfilled=function a(){Module.calledRun||run(),Module.calledRun||(dependenciesFulfilled=a)},Module.callMain=Module.callMain=function a(n){assert(runDependencies==0,"cannot call main when async dependencies remain! (listen on __ATMAIN__)"),assert(__ATPRERUN__.length==0,"cannot call main when preRun functions remain to be called"),n=n||[],ensureInitRuntime();var s=n.length+1;function u(){for(var v=0;v<3;v++)f.push(0)}var f=[allocate(intArrayFromString(Module.thisProgram),"i8",ALLOC_NORMAL)];u();for(var m=0;m0||(preRun(),runDependencies>0)||Module.calledRun)return;function n(){Module.calledRun||(Module.calledRun=!0,!ABORT&&(ensureInitRuntime(),preMain(),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),Module._main&&shouldRunNow&&Module.callMain(a),postRun()))}Module.setStatus?(Module.setStatus("Running..."),setTimeout(function(){setTimeout(function(){Module.setStatus("")},1),n()},1)):n()}Module.run=Module.run=run;function exit(a,n){if(!(n&&Module.noExitRuntime))throw Module.noExitRuntime||(ABORT=!0,STACKTOP=initialStackTop,exitRuntime(),Module.onExit&&Module.onExit(a)),ENVIRONMENT_IS_NODE?(process.stdout.once("drain",function(){process.exit(a)}),console.log(" "),setTimeout(function(){process.exit(a)},500)):ENVIRONMENT_IS_SHELL&&typeof quit=="function"&&quit(a),new ExitStatus(a)}Module.exit=Module.exit=exit;var abortDecorators=[];function abort(a){a!==void 0?(Module.print(a),Module.printErr(a),a=JSON.stringify(a)):a="",ABORT=!0;var n=` If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.`,s="abort("+a+") at "+stackTrace()+n;throw abortDecorators&&abortDecorators.forEach(function(u){s=u(s,a)}),s}if(Module.abort=Module.abort=abort,Module.preInit)for(typeof Module.preInit=="function"&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();var shouldRunNow=!0;return Module.noInitialRun&&(shouldRunNow=!1),run(),Module};module.exports&&(module.exports=CharLS)}(charLSDynamicMemoryBrowser)),charLSDynamicMemoryBrowser.exports}var hasRequiredJpegLs;function requireJpegLs(){return hasRequiredJpegLs||(hasRequiredJpegLs=1,function(a){var n=n||(typeof commonjsRequire<"u"?requireCharLSDynamicMemoryBrowser():null),s=function(){var u;function f(){}f.prototype={decodeJPEGLS:function(y,T){return v(y,T)}};function m(y,T){var I=u._malloc(y.length);u.writeArrayToMemory(y,I);var S=u._malloc(4),E=u._malloc(4),e=u._malloc(4),F=u._malloc(4),M=u._malloc(4),L=u._malloc(4),V=u._malloc(4),B=u._malloc(4),z=u._malloc(4),b=u.ccall("jpegls_decode","number",["number","number","number","number","number","number","number","number","number","number","number"],[I,y.length,S,E,e,F,M,L,B,V,z]),W={result:b,width:u.getValue(e,"i32"),height:u.getValue(F,"i32"),bitsPerSample:u.getValue(M,"i32"),stride:u.getValue(L,"i32"),components:u.getValue(B,"i32"),allowedLossyError:u.getValue(V,"i32"),interleaveMode:u.getValue(z,"i32"),pixelData:void 0},q=u.getValue(S,"*");return W.bitsPerSample<=8?(W.pixelData=new Uint8Array(W.width*W.height*W.components),W.pixelData.set(new Uint8Array(u.HEAP8.buffer,q,W.pixelData.length))):T?(W.pixelData=new Int16Array(W.width*W.height*W.components),W.pixelData.set(new Int16Array(u.HEAP16.buffer,q,W.pixelData.length))):(W.pixelData=new Uint16Array(W.width*W.height*W.components),W.pixelData.set(new Uint16Array(u.HEAP16.buffer,q,W.pixelData.length))),u._free(I),u._free(q),u._free(S),u._free(E),u._free(e),u._free(F),u._free(M),u._free(L),u._free(B),u._free(z),W}function A(){if(typeof n>"u")throw"No JPEG-LS decoder loaded";if(!u&&(u=n(),!u||!u._jpegls_decode))throw"JPEG-LS failed to initialize"}function v(y,T){A();var I=m(y,T);if(I.result!==0&&I.result!==6)throw"JPEG-LS decoder failed to decode frame (error code "+I.result+")";var S={};return S.columns=I.width,S.rows=I.height,S.pixelData=I.pixelData,S}return f}();a.exports&&(a.exports=s)}(jpegLs)),jpegLs.exports}var parser={exports:{}},pako={},deflate$1={},deflate={},trees={},hasRequiredTrees;function requireTrees(){if(hasRequiredTrees)return trees;hasRequiredTrees=1;const a=4,n=0,s=1,u=2;function f(ee){let Be=ee.length;for(;--Be>=0;)ee[Be]=0}const m=0,A=1,v=2,y=3,T=258,I=29,S=256,E=S+1+I,e=30,F=19,M=2*E+1,L=15,V=16,B=7,z=256,b=16,W=17,q=18,Y=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),X=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),H=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),g=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),J=512,re=new Array((E+2)*2);f(re);const ae=new Array(e*2);f(ae);const fe=new Array(J);f(fe);const pe=new Array(T-y+1);f(pe);const me=new Array(I);f(me);const Se=new Array(e);f(Se);function ve(ee,Be,st,Ke,ft){this.static_tree=ee,this.extra_bits=Be,this.extra_base=st,this.elems=Ke,this.max_length=ft,this.has_stree=ee&&ee.length}let we,Ne,De;function je(ee,Be){this.dyn_tree=ee,this.max_code=0,this.stat_desc=Be}const nt=ee=>ee<256?fe[ee]:fe[256+(ee>>>7)],Ue=(ee,Be)=>{ee.pending_buf[ee.pending++]=Be&255,ee.pending_buf[ee.pending++]=Be>>>8&255},ye=(ee,Be,st)=>{ee.bi_valid>V-st?(ee.bi_buf|=Be<>V-ee.bi_valid,ee.bi_valid+=st-V):(ee.bi_buf|=Be<{ye(ee,st[Be*2],st[Be*2+1])},pt=(ee,Be)=>{let st=0;do st|=ee&1,ee>>>=1,st<<=1;while(--Be>0);return st>>>1},It=ee=>{ee.bi_valid===16?(Ue(ee,ee.bi_buf),ee.bi_buf=0,ee.bi_valid=0):ee.bi_valid>=8&&(ee.pending_buf[ee.pending++]=ee.bi_buf&255,ee.bi_buf>>=8,ee.bi_valid-=8)},Lt=(ee,Be)=>{const st=Be.dyn_tree,Ke=Be.max_code,ft=Be.stat_desc.static_tree,vt=Be.stat_desc.has_stree,Re=Be.stat_desc.extra_bits,Ye=Be.stat_desc.extra_base,ue=Be.stat_desc.max_length;let Ae,Vt,ge,Ut,Ve,Zt,ot=0;for(Ut=0;Ut<=L;Ut++)ee.bl_count[Ut]=0;for(st[ee.heap[ee.heap_max]*2+1]=0,Ae=ee.heap_max+1;Aeue&&(Ut=ue,ot++),st[Vt*2+1]=Ut,!(Vt>Ke)&&(ee.bl_count[Ut]++,Ve=0,Vt>=Ye&&(Ve=Re[Vt-Ye]),Zt=st[Vt*2],ee.opt_len+=Zt*(Ut+Ve),vt&&(ee.static_len+=Zt*(ft[Vt*2+1]+Ve)));if(ot!==0){do{for(Ut=ue-1;ee.bl_count[Ut]===0;)Ut--;ee.bl_count[Ut]--,ee.bl_count[Ut+1]+=2,ee.bl_count[ue]--,ot-=2}while(ot>0);for(Ut=ue;Ut!==0;Ut--)for(Vt=ee.bl_count[Ut];Vt!==0;)ge=ee.heap[--Ae],!(ge>Ke)&&(st[ge*2+1]!==Ut&&(ee.opt_len+=(Ut-st[ge*2+1])*st[ge*2],st[ge*2+1]=Ut),Vt--)}},Ot=(ee,Be,st)=>{const Ke=new Array(L+1);let ft=0,vt,Re;for(vt=1;vt<=L;vt++)ft=ft+st[vt-1]<<1,Ke[vt]=ft;for(Re=0;Re<=Be;Re++){let Ye=ee[Re*2+1];Ye!==0&&(ee[Re*2]=pt(Ke[Ye]++,Ye))}},Et=()=>{let ee,Be,st,Ke,ft;const vt=new Array(L+1);for(st=0,Ke=0;Ke>=7;Ke{let Be;for(Be=0;Be{ee.bi_valid>8?Ue(ee,ee.bi_buf):ee.bi_valid>0&&(ee.pending_buf[ee.pending++]=ee.bi_buf),ee.bi_buf=0,ee.bi_valid=0},Me=(ee,Be,st,Ke)=>{const ft=Be*2,vt=st*2;return ee[ft]{const Ke=ee.heap[st];let ft=st<<1;for(;ft<=ee.heap_len&&(ft{let Ke,ft,vt=0,Re,Ye;if(ee.sym_next!==0)do Ke=ee.pending_buf[ee.sym_buf+vt++]&255,Ke+=(ee.pending_buf[ee.sym_buf+vt++]&255)<<8,ft=ee.pending_buf[ee.sym_buf+vt++],Ke===0?ut(ee,ft,Be):(Re=pe[ft],ut(ee,Re+S+1,Be),Ye=Y[Re],Ye!==0&&(ft-=me[Re],ye(ee,ft,Ye)),Ke--,Re=nt(Ke),ut(ee,Re,st),Ye=X[Re],Ye!==0&&(Ke-=Se[Re],ye(ee,Ke,Ye)));while(vt{const st=Be.dyn_tree,Ke=Be.stat_desc.static_tree,ft=Be.stat_desc.has_stree,vt=Be.stat_desc.elems;let Re,Ye,ue=-1,Ae;for(ee.heap_len=0,ee.heap_max=M,Re=0;Re>1;Re>=1;Re--)Qe(ee,st,Re);Ae=vt;do Re=ee.heap[1],ee.heap[1]=ee.heap[ee.heap_len--],Qe(ee,st,1),Ye=ee.heap[1],ee.heap[--ee.heap_max]=Re,ee.heap[--ee.heap_max]=Ye,st[Ae*2]=st[Re*2]+st[Ye*2],ee.depth[Ae]=(ee.depth[Re]>=ee.depth[Ye]?ee.depth[Re]:ee.depth[Ye])+1,st[Re*2+1]=st[Ye*2+1]=Ae,ee.heap[1]=Ae++,Qe(ee,st,1);while(ee.heap_len>=2);ee.heap[--ee.heap_max]=ee.heap[1],Lt(ee,Be),Ot(st,ue,ee.bl_count)},at=(ee,Be,st)=>{let Ke,ft=-1,vt,Re=Be[0*2+1],Ye=0,ue=7,Ae=4;for(Re===0&&(ue=138,Ae=3),Be[(st+1)*2+1]=65535,Ke=0;Ke<=st;Ke++)vt=Re,Re=Be[(Ke+1)*2+1],!(++Ye{let Ke,ft=-1,vt,Re=Be[0*2+1],Ye=0,ue=7,Ae=4;for(Re===0&&(ue=138,Ae=3),Ke=0;Ke<=st;Ke++)if(vt=Re,Re=Be[(Ke+1)*2+1],!(++Ye{let Be;for(at(ee,ee.dyn_ltree,ee.l_desc.max_code),at(ee,ee.dyn_dtree,ee.d_desc.max_code),Fe(ee,ee.bl_desc),Be=F-1;Be>=3&&ee.bl_tree[g[Be]*2+1]===0;Be--);return ee.opt_len+=3*(Be+1)+5+5+4,Be},qe=(ee,Be,st,Ke)=>{let ft;for(ye(ee,Be-257,5),ye(ee,st-1,5),ye(ee,Ke-4,4),ft=0;ft{let Be=4093624447,st;for(st=0;st<=31;st++,Be>>>=1)if(Be&1&&ee.dyn_ltree[st*2]!==0)return n;if(ee.dyn_ltree[9*2]!==0||ee.dyn_ltree[10*2]!==0||ee.dyn_ltree[13*2]!==0)return s;for(st=32;st{Je||(Et(),Je=!0),ee.l_desc=new je(ee.dyn_ltree,we),ee.d_desc=new je(ee.dyn_dtree,Ne),ee.bl_desc=new je(ee.bl_tree,De),ee.bi_buf=0,ee.bi_valid=0,Rt(ee)},Ge=(ee,Be,st,Ke)=>{ye(ee,(m<<1)+(Ke?1:0),3),Ze(ee),Ue(ee,st),Ue(ee,~st),st&&ee.pending_buf.set(ee.window.subarray(Be,Be+st),ee.pending),ee.pending+=st},xt=ee=>{ye(ee,A<<1,3),ut(ee,z,re),It(ee)},He=(ee,Be,st,Ke)=>{let ft,vt,Re=0;ee.level>0?(ee.strm.data_type===u&&(ee.strm.data_type=_e(ee)),Fe(ee,ee.l_desc),Fe(ee,ee.d_desc),Re=Le(ee),ft=ee.opt_len+3+7>>>3,vt=ee.static_len+3+7>>>3,vt<=ft&&(ft=vt)):ft=vt=st+5,st+4<=ft&&Be!==-1?Ge(ee,Be,st,Ke):ee.strategy===a||vt===ft?(ye(ee,(A<<1)+(Ke?1:0),3),Ie(ee,re,ae)):(ye(ee,(v<<1)+(Ke?1:0),3),qe(ee,ee.l_desc.max_code+1,ee.d_desc.max_code+1,Re+1),Ie(ee,ee.dyn_ltree,ee.dyn_dtree)),Rt(ee),Ke&&Ze(ee)},rt=(ee,Be,st)=>(ee.pending_buf[ee.sym_buf+ee.sym_next++]=Be,ee.pending_buf[ee.sym_buf+ee.sym_next++]=Be>>8,ee.pending_buf[ee.sym_buf+ee.sym_next++]=st,Be===0?ee.dyn_ltree[st*2]++:(ee.matches++,Be--,ee.dyn_ltree[(pe[st]+S+1)*2]++,ee.dyn_dtree[nt(Be)*2]++),ee.sym_next===ee.sym_end);return trees._tr_init=We,trees._tr_stored_block=Ge,trees._tr_flush_block=He,trees._tr_tally=rt,trees._tr_align=xt,trees}var adler32_1,hasRequiredAdler32;function requireAdler32(){return hasRequiredAdler32||(hasRequiredAdler32=1,adler32_1=(n,s,u,f)=>{let m=n&65535|0,A=n>>>16&65535|0,v=0;for(;u!==0;){v=u>2e3?2e3:u,u-=v;do m=m+s[f++]|0,A=A+m|0;while(--v);m%=65521,A%=65521}return m|A<<16|0}),adler32_1}var crc32_1,hasRequiredCrc32;function requireCrc32(){if(hasRequiredCrc32)return crc32_1;hasRequiredCrc32=1;const a=()=>{let u,f=[];for(var m=0;m<256;m++){u=m;for(var A=0;A<8;A++)u=u&1?3988292384^u>>>1:u>>>1;f[m]=u}return f},n=new Uint32Array(a());return crc32_1=(u,f,m,A)=>{const v=n,y=A+m;u^=-1;for(let T=A;T>>8^v[(u^f[T])&255];return u^-1},crc32_1}var messages,hasRequiredMessages;function requireMessages(){return hasRequiredMessages||(hasRequiredMessages=1,messages={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}),messages}var constants,hasRequiredConstants;function requireConstants(){return hasRequiredConstants||(hasRequiredConstants=1,constants={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}),constants}var hasRequiredDeflate$1;function requireDeflate$1(){if(hasRequiredDeflate$1)return deflate;hasRequiredDeflate$1=1;const{_tr_init:a,_tr_stored_block:n,_tr_flush_block:s,_tr_tally:u,_tr_align:f}=requireTrees(),m=requireAdler32(),A=requireCrc32(),v=requireMessages(),{Z_NO_FLUSH:y,Z_PARTIAL_FLUSH:T,Z_FULL_FLUSH:I,Z_FINISH:S,Z_BLOCK:E,Z_OK:e,Z_STREAM_END:F,Z_STREAM_ERROR:M,Z_DATA_ERROR:L,Z_BUF_ERROR:V,Z_DEFAULT_COMPRESSION:B,Z_FILTERED:z,Z_HUFFMAN_ONLY:b,Z_RLE:W,Z_FIXED:q,Z_DEFAULT_STRATEGY:Y,Z_UNKNOWN:X,Z_DEFLATED:H}=requireConstants(),g=9,J=15,re=8,pe=256+1+29,me=30,Se=19,ve=2*pe+1,we=15,Ne=3,De=258,je=De+Ne+1,nt=32,Ue=42,ye=57,ut=69,pt=73,It=91,Lt=103,Ot=113,Et=666,Rt=1,Ze=2,Me=3,Qe=4,Ie=3,Fe=(se,lt)=>(se.msg=v[lt],lt),at=se=>se*2-(se>4?9:0),ze=se=>{let lt=se.length;for(;--lt>=0;)se[lt]=0},Le=se=>{let lt,Ce,Pe,xe=se.w_size;lt=se.hash_size,Pe=lt;do Ce=se.head[--Pe],se.head[Pe]=Ce>=xe?Ce-xe:0;while(--lt);lt=xe,Pe=lt;do Ce=se.prev[--Pe],se.prev[Pe]=Ce>=xe?Ce-xe:0;while(--lt)};let _e=(se,lt,Ce)=>(lt<{const lt=se.state;let Ce=lt.pending;Ce>se.avail_out&&(Ce=se.avail_out),Ce!==0&&(se.output.set(lt.pending_buf.subarray(lt.pending_out,lt.pending_out+Ce),se.next_out),se.next_out+=Ce,lt.pending_out+=Ce,se.total_out+=Ce,se.avail_out-=Ce,lt.pending-=Ce,lt.pending===0&&(lt.pending_out=0))},We=(se,lt)=>{s(se,se.block_start>=0?se.block_start:-1,se.strstart-se.block_start,lt),se.block_start=se.strstart,Je(se.strm)},Ge=(se,lt)=>{se.pending_buf[se.pending++]=lt},xt=(se,lt)=>{se.pending_buf[se.pending++]=lt>>>8&255,se.pending_buf[se.pending++]=lt&255},He=(se,lt,Ce,Pe)=>{let xe=se.avail_in;return xe>Pe&&(xe=Pe),xe===0?0:(se.avail_in-=xe,lt.set(se.input.subarray(se.next_in,se.next_in+xe),Ce),se.state.wrap===1?se.adler=m(se.adler,lt,xe,Ce):se.state.wrap===2&&(se.adler=A(se.adler,lt,xe,Ce)),se.next_in+=xe,se.total_in+=xe,xe)},rt=(se,lt)=>{let Ce=se.max_chain_length,Pe=se.strstart,xe,Nt,Xt=se.prev_length,Wt=se.nice_match;const $e=se.strstart>se.w_size-je?se.strstart-(se.w_size-je):0,p0=se.window,R0=se.w_mask,Q0=se.prev,M0=se.strstart+De;let ni=p0[Pe+Xt-1],St=p0[Pe+Xt];se.prev_length>=se.good_match&&(Ce>>=2),Wt>se.lookahead&&(Wt=se.lookahead);do if(xe=lt,!(p0[xe+Xt]!==St||p0[xe+Xt-1]!==ni||p0[xe]!==p0[Pe]||p0[++xe]!==p0[Pe+1])){Pe+=2,xe++;do;while(p0[++Pe]===p0[++xe]&&p0[++Pe]===p0[++xe]&&p0[++Pe]===p0[++xe]&&p0[++Pe]===p0[++xe]&&p0[++Pe]===p0[++xe]&&p0[++Pe]===p0[++xe]&&p0[++Pe]===p0[++xe]&&p0[++Pe]===p0[++xe]&&PeXt){if(se.match_start=lt,Xt=Nt,Nt>=Wt)break;ni=p0[Pe+Xt-1],St=p0[Pe+Xt]}}while((lt=Q0[lt&R0])>$e&&--Ce!==0);return Xt<=se.lookahead?Xt:se.lookahead},ee=se=>{const lt=se.w_size;let Ce,Pe,xe;do{if(Pe=se.window_size-se.lookahead-se.strstart,se.strstart>=lt+(lt-je)&&(se.window.set(se.window.subarray(lt,lt+lt-Pe),0),se.match_start-=lt,se.strstart-=lt,se.block_start-=lt,se.insert>se.strstart&&(se.insert=se.strstart),Le(se),Pe+=lt),se.strm.avail_in===0)break;if(Ce=He(se.strm,se.window,se.strstart+se.lookahead,Pe),se.lookahead+=Ce,se.lookahead+se.insert>=Ne)for(xe=se.strstart-se.insert,se.ins_h=se.window[xe],se.ins_h=_e(se,se.ins_h,se.window[xe+1]);se.insert&&(se.ins_h=_e(se,se.ins_h,se.window[xe+Ne-1]),se.prev[xe&se.w_mask]=se.head[se.ins_h],se.head[se.ins_h]=xe,xe++,se.insert--,!(se.lookahead+se.insert{let Ce=se.pending_buf_size-5>se.w_size?se.w_size:se.pending_buf_size-5,Pe,xe,Nt,Xt=0,Wt=se.strm.avail_in;do{if(Pe=65535,Nt=se.bi_valid+42>>3,se.strm.avail_outxe+se.strm.avail_in&&(Pe=xe+se.strm.avail_in),Pe>Nt&&(Pe=Nt),Pe>8,se.pending_buf[se.pending-2]=~Pe,se.pending_buf[se.pending-1]=~Pe>>8,Je(se.strm),xe&&(xe>Pe&&(xe=Pe),se.strm.output.set(se.window.subarray(se.block_start,se.block_start+xe),se.strm.next_out),se.strm.next_out+=xe,se.strm.avail_out-=xe,se.strm.total_out+=xe,se.block_start+=xe,Pe-=xe),Pe&&(He(se.strm,se.strm.output,se.strm.next_out,Pe),se.strm.next_out+=Pe,se.strm.avail_out-=Pe,se.strm.total_out+=Pe)}while(Xt===0);return Wt-=se.strm.avail_in,Wt&&(Wt>=se.w_size?(se.matches=2,se.window.set(se.strm.input.subarray(se.strm.next_in-se.w_size,se.strm.next_in),0),se.strstart=se.w_size,se.insert=se.strstart):(se.window_size-se.strstart<=Wt&&(se.strstart-=se.w_size,se.window.set(se.window.subarray(se.w_size,se.w_size+se.strstart),0),se.matches<2&&se.matches++,se.insert>se.strstart&&(se.insert=se.strstart)),se.window.set(se.strm.input.subarray(se.strm.next_in-Wt,se.strm.next_in),se.strstart),se.strstart+=Wt,se.insert+=Wt>se.w_size-se.insert?se.w_size-se.insert:Wt),se.block_start=se.strstart),se.high_waterNt&&se.block_start>=se.w_size&&(se.block_start-=se.w_size,se.strstart-=se.w_size,se.window.set(se.window.subarray(se.w_size,se.w_size+se.strstart),0),se.matches<2&&se.matches++,Nt+=se.w_size,se.insert>se.strstart&&(se.insert=se.strstart)),Nt>se.strm.avail_in&&(Nt=se.strm.avail_in),Nt&&(He(se.strm,se.window,se.strstart,Nt),se.strstart+=Nt,se.insert+=Nt>se.w_size-se.insert?se.w_size-se.insert:Nt),se.high_water>3,Nt=se.pending_buf_size-Nt>65535?65535:se.pending_buf_size-Nt,Ce=Nt>se.w_size?se.w_size:Nt,xe=se.strstart-se.block_start,(xe>=Ce||(xe||lt===S)&<!==y&&se.strm.avail_in===0&&xe<=Nt)&&(Pe=xe>Nt?Nt:xe,Xt=lt===S&&se.strm.avail_in===0&&Pe===xe?1:0,n(se,se.block_start,Pe,Xt),se.block_start+=Pe,Je(se.strm)),Xt?Me:Rt)},st=(se,lt)=>{let Ce,Pe;for(;;){if(se.lookahead=Ne&&(se.ins_h=_e(se,se.ins_h,se.window[se.strstart+Ne-1]),Ce=se.prev[se.strstart&se.w_mask]=se.head[se.ins_h],se.head[se.ins_h]=se.strstart),Ce!==0&&se.strstart-Ce<=se.w_size-je&&(se.match_length=rt(se,Ce)),se.match_length>=Ne)if(Pe=u(se,se.strstart-se.match_start,se.match_length-Ne),se.lookahead-=se.match_length,se.match_length<=se.max_lazy_match&&se.lookahead>=Ne){se.match_length--;do se.strstart++,se.ins_h=_e(se,se.ins_h,se.window[se.strstart+Ne-1]),Ce=se.prev[se.strstart&se.w_mask]=se.head[se.ins_h],se.head[se.ins_h]=se.strstart;while(--se.match_length!==0);se.strstart++}else se.strstart+=se.match_length,se.match_length=0,se.ins_h=se.window[se.strstart],se.ins_h=_e(se,se.ins_h,se.window[se.strstart+1]);else Pe=u(se,0,se.window[se.strstart]),se.lookahead--,se.strstart++;if(Pe&&(We(se,!1),se.strm.avail_out===0))return Rt}return se.insert=se.strstart{let Ce,Pe,xe;for(;;){if(se.lookahead=Ne&&(se.ins_h=_e(se,se.ins_h,se.window[se.strstart+Ne-1]),Ce=se.prev[se.strstart&se.w_mask]=se.head[se.ins_h],se.head[se.ins_h]=se.strstart),se.prev_length=se.match_length,se.prev_match=se.match_start,se.match_length=Ne-1,Ce!==0&&se.prev_length4096)&&(se.match_length=Ne-1)),se.prev_length>=Ne&&se.match_length<=se.prev_length){xe=se.strstart+se.lookahead-Ne,Pe=u(se,se.strstart-1-se.prev_match,se.prev_length-Ne),se.lookahead-=se.prev_length-1,se.prev_length-=2;do++se.strstart<=xe&&(se.ins_h=_e(se,se.ins_h,se.window[se.strstart+Ne-1]),Ce=se.prev[se.strstart&se.w_mask]=se.head[se.ins_h],se.head[se.ins_h]=se.strstart);while(--se.prev_length!==0);if(se.match_available=0,se.match_length=Ne-1,se.strstart++,Pe&&(We(se,!1),se.strm.avail_out===0))return Rt}else if(se.match_available){if(Pe=u(se,0,se.window[se.strstart-1]),Pe&&We(se,!1),se.strstart++,se.lookahead--,se.strm.avail_out===0)return Rt}else se.match_available=1,se.strstart++,se.lookahead--}return se.match_available&&(Pe=u(se,0,se.window[se.strstart-1]),se.match_available=0),se.insert=se.strstart{let Ce,Pe,xe,Nt;const Xt=se.window;for(;;){if(se.lookahead<=De){if(ee(se),se.lookahead<=De&<===y)return Rt;if(se.lookahead===0)break}if(se.match_length=0,se.lookahead>=Ne&&se.strstart>0&&(xe=se.strstart-1,Pe=Xt[xe],Pe===Xt[++xe]&&Pe===Xt[++xe]&&Pe===Xt[++xe])){Nt=se.strstart+De;do;while(Pe===Xt[++xe]&&Pe===Xt[++xe]&&Pe===Xt[++xe]&&Pe===Xt[++xe]&&Pe===Xt[++xe]&&Pe===Xt[++xe]&&Pe===Xt[++xe]&&Pe===Xt[++xe]&&xese.lookahead&&(se.match_length=se.lookahead)}if(se.match_length>=Ne?(Ce=u(se,1,se.match_length-Ne),se.lookahead-=se.match_length,se.strstart+=se.match_length,se.match_length=0):(Ce=u(se,0,se.window[se.strstart]),se.lookahead--,se.strstart++),Ce&&(We(se,!1),se.strm.avail_out===0))return Rt}return se.insert=0,lt===S?(We(se,!0),se.strm.avail_out===0?Me:Qe):se.sym_next&&(We(se,!1),se.strm.avail_out===0)?Rt:Ze},vt=(se,lt)=>{let Ce;for(;;){if(se.lookahead===0&&(ee(se),se.lookahead===0)){if(lt===y)return Rt;break}if(se.match_length=0,Ce=u(se,0,se.window[se.strstart]),se.lookahead--,se.strstart++,Ce&&(We(se,!1),se.strm.avail_out===0))return Rt}return se.insert=0,lt===S?(We(se,!0),se.strm.avail_out===0?Me:Qe):se.sym_next&&(We(se,!1),se.strm.avail_out===0)?Rt:Ze};function Re(se,lt,Ce,Pe,xe){this.good_length=se,this.max_lazy=lt,this.nice_length=Ce,this.max_chain=Pe,this.func=xe}const Ye=[new Re(0,0,0,0,Be),new Re(4,4,8,4,st),new Re(4,5,16,8,st),new Re(4,6,32,32,st),new Re(4,4,16,16,Ke),new Re(8,16,32,32,Ke),new Re(8,16,128,128,Ke),new Re(8,32,128,256,Ke),new Re(32,128,258,1024,Ke),new Re(32,258,258,4096,Ke)],ue=se=>{se.window_size=2*se.w_size,ze(se.head),se.max_lazy_match=Ye[se.level].max_lazy,se.good_match=Ye[se.level].good_length,se.nice_match=Ye[se.level].nice_length,se.max_chain_length=Ye[se.level].max_chain,se.strstart=0,se.block_start=0,se.lookahead=0,se.insert=0,se.match_length=se.prev_length=Ne-1,se.match_available=0,se.ins_h=0};function Ae(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=H,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(ve*2),this.dyn_dtree=new Uint16Array((2*me+1)*2),this.bl_tree=new Uint16Array((2*Se+1)*2),ze(this.dyn_ltree),ze(this.dyn_dtree),ze(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(we+1),this.heap=new Uint16Array(2*pe+1),ze(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*pe+1),ze(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Vt=se=>{if(!se)return 1;const lt=se.state;return!lt||lt.strm!==se||lt.status!==Ue&<.status!==ye&<.status!==ut&<.status!==pt&<.status!==It&<.status!==Lt&<.status!==Ot&<.status!==Et?1:0},ge=se=>{if(Vt(se))return Fe(se,M);se.total_in=se.total_out=0,se.data_type=X;const lt=se.state;return lt.pending=0,lt.pending_out=0,lt.wrap<0&&(lt.wrap=-lt.wrap),lt.status=lt.wrap===2?ye:lt.wrap?Ue:Ot,se.adler=lt.wrap===2?0:1,lt.last_flush=-2,a(lt),e},Ut=se=>{const lt=ge(se);return lt===e&&ue(se.state),lt},Ve=(se,lt)=>Vt(se)||se.state.wrap!==2?M:(se.state.gzhead=lt,e),Zt=(se,lt,Ce,Pe,xe,Nt)=>{if(!se)return M;let Xt=1;if(lt===B&&(lt=6),Pe<0?(Xt=0,Pe=-Pe):Pe>15&&(Xt=2,Pe-=16),xe<1||xe>g||Ce!==H||Pe<8||Pe>15||lt<0||lt>9||Nt<0||Nt>q||Pe===8&&Xt!==1)return Fe(se,M);Pe===8&&(Pe=9);const Wt=new Ae;return se.state=Wt,Wt.strm=se,Wt.status=Ue,Wt.wrap=Xt,Wt.gzhead=null,Wt.w_bits=Pe,Wt.w_size=1<Zt(se,lt,H,J,re,Y),ht=(se,lt)=>{if(Vt(se)||lt>E||lt<0)return se?Fe(se,M):M;const Ce=se.state;if(!se.output||se.avail_in!==0&&!se.input||Ce.status===Et&<!==S)return Fe(se,se.avail_out===0?V:M);const Pe=Ce.last_flush;if(Ce.last_flush=lt,Ce.pending!==0){if(Je(se),se.avail_out===0)return Ce.last_flush=-1,e}else if(se.avail_in===0&&at(lt)<=at(Pe)&<!==S)return Fe(se,V);if(Ce.status===Et&&se.avail_in!==0)return Fe(se,V);if(Ce.status===Ue&&Ce.wrap===0&&(Ce.status=Ot),Ce.status===Ue){let xe=H+(Ce.w_bits-8<<4)<<8,Nt=-1;if(Ce.strategy>=b||Ce.level<2?Nt=0:Ce.level<6?Nt=1:Ce.level===6?Nt=2:Nt=3,xe|=Nt<<6,Ce.strstart!==0&&(xe|=nt),xe+=31-xe%31,xt(Ce,xe),Ce.strstart!==0&&(xt(Ce,se.adler>>>16),xt(Ce,se.adler&65535)),se.adler=1,Ce.status=Ot,Je(se),Ce.pending!==0)return Ce.last_flush=-1,e}if(Ce.status===ye){if(se.adler=0,Ge(Ce,31),Ge(Ce,139),Ge(Ce,8),Ce.gzhead)Ge(Ce,(Ce.gzhead.text?1:0)+(Ce.gzhead.hcrc?2:0)+(Ce.gzhead.extra?4:0)+(Ce.gzhead.name?8:0)+(Ce.gzhead.comment?16:0)),Ge(Ce,Ce.gzhead.time&255),Ge(Ce,Ce.gzhead.time>>8&255),Ge(Ce,Ce.gzhead.time>>16&255),Ge(Ce,Ce.gzhead.time>>24&255),Ge(Ce,Ce.level===9?2:Ce.strategy>=b||Ce.level<2?4:0),Ge(Ce,Ce.gzhead.os&255),Ce.gzhead.extra&&Ce.gzhead.extra.length&&(Ge(Ce,Ce.gzhead.extra.length&255),Ge(Ce,Ce.gzhead.extra.length>>8&255)),Ce.gzhead.hcrc&&(se.adler=A(se.adler,Ce.pending_buf,Ce.pending,0)),Ce.gzindex=0,Ce.status=ut;else if(Ge(Ce,0),Ge(Ce,0),Ge(Ce,0),Ge(Ce,0),Ge(Ce,0),Ge(Ce,Ce.level===9?2:Ce.strategy>=b||Ce.level<2?4:0),Ge(Ce,Ie),Ce.status=Ot,Je(se),Ce.pending!==0)return Ce.last_flush=-1,e}if(Ce.status===ut){if(Ce.gzhead.extra){let xe=Ce.pending,Nt=(Ce.gzhead.extra.length&65535)-Ce.gzindex;for(;Ce.pending+Nt>Ce.pending_buf_size;){let Wt=Ce.pending_buf_size-Ce.pending;if(Ce.pending_buf.set(Ce.gzhead.extra.subarray(Ce.gzindex,Ce.gzindex+Wt),Ce.pending),Ce.pending=Ce.pending_buf_size,Ce.gzhead.hcrc&&Ce.pending>xe&&(se.adler=A(se.adler,Ce.pending_buf,Ce.pending-xe,xe)),Ce.gzindex+=Wt,Je(se),Ce.pending!==0)return Ce.last_flush=-1,e;xe=0,Nt-=Wt}let Xt=new Uint8Array(Ce.gzhead.extra);Ce.pending_buf.set(Xt.subarray(Ce.gzindex,Ce.gzindex+Nt),Ce.pending),Ce.pending+=Nt,Ce.gzhead.hcrc&&Ce.pending>xe&&(se.adler=A(se.adler,Ce.pending_buf,Ce.pending-xe,xe)),Ce.gzindex=0}Ce.status=pt}if(Ce.status===pt){if(Ce.gzhead.name){let xe=Ce.pending,Nt;do{if(Ce.pending===Ce.pending_buf_size){if(Ce.gzhead.hcrc&&Ce.pending>xe&&(se.adler=A(se.adler,Ce.pending_buf,Ce.pending-xe,xe)),Je(se),Ce.pending!==0)return Ce.last_flush=-1,e;xe=0}Ce.gzindexxe&&(se.adler=A(se.adler,Ce.pending_buf,Ce.pending-xe,xe)),Ce.gzindex=0}Ce.status=It}if(Ce.status===It){if(Ce.gzhead.comment){let xe=Ce.pending,Nt;do{if(Ce.pending===Ce.pending_buf_size){if(Ce.gzhead.hcrc&&Ce.pending>xe&&(se.adler=A(se.adler,Ce.pending_buf,Ce.pending-xe,xe)),Je(se),Ce.pending!==0)return Ce.last_flush=-1,e;xe=0}Ce.gzindexxe&&(se.adler=A(se.adler,Ce.pending_buf,Ce.pending-xe,xe))}Ce.status=Lt}if(Ce.status===Lt){if(Ce.gzhead.hcrc){if(Ce.pending+2>Ce.pending_buf_size&&(Je(se),Ce.pending!==0))return Ce.last_flush=-1,e;Ge(Ce,se.adler&255),Ge(Ce,se.adler>>8&255),se.adler=0}if(Ce.status=Ot,Je(se),Ce.pending!==0)return Ce.last_flush=-1,e}if(se.avail_in!==0||Ce.lookahead!==0||lt!==y&&Ce.status!==Et){let xe=Ce.level===0?Be(Ce,lt):Ce.strategy===b?vt(Ce,lt):Ce.strategy===W?ft(Ce,lt):Ye[Ce.level].func(Ce,lt);if((xe===Me||xe===Qe)&&(Ce.status=Et),xe===Rt||xe===Me)return se.avail_out===0&&(Ce.last_flush=-1),e;if(xe===Ze&&(lt===T?f(Ce):lt!==E&&(n(Ce,0,0,!1),lt===I&&(ze(Ce.head),Ce.lookahead===0&&(Ce.strstart=0,Ce.block_start=0,Ce.insert=0))),Je(se),se.avail_out===0))return Ce.last_flush=-1,e}return lt!==S?e:Ce.wrap<=0?F:(Ce.wrap===2?(Ge(Ce,se.adler&255),Ge(Ce,se.adler>>8&255),Ge(Ce,se.adler>>16&255),Ge(Ce,se.adler>>24&255),Ge(Ce,se.total_in&255),Ge(Ce,se.total_in>>8&255),Ge(Ce,se.total_in>>16&255),Ge(Ce,se.total_in>>24&255)):(xt(Ce,se.adler>>>16),xt(Ce,se.adler&65535)),Je(se),Ce.wrap>0&&(Ce.wrap=-Ce.wrap),Ce.pending!==0?e:F)},I0=se=>{if(Vt(se))return M;const lt=se.state.status;return se.state=null,lt===Ot?Fe(se,L):e},be=(se,lt)=>{let Ce=lt.length;if(Vt(se))return M;const Pe=se.state,xe=Pe.wrap;if(xe===2||xe===1&&Pe.status!==Ue||Pe.lookahead)return M;if(xe===1&&(se.adler=m(se.adler,lt,Ce,0)),Pe.wrap=0,Ce>=Pe.w_size){xe===0&&(ze(Pe.head),Pe.strstart=0,Pe.block_start=0,Pe.insert=0);let $e=new Uint8Array(Pe.w_size);$e.set(lt.subarray(Ce-Pe.w_size,Ce),0),lt=$e,Ce=Pe.w_size}const Nt=se.avail_in,Xt=se.next_in,Wt=se.input;for(se.avail_in=Ce,se.next_in=0,se.input=lt,ee(Pe);Pe.lookahead>=Ne;){let $e=Pe.strstart,p0=Pe.lookahead-(Ne-1);do Pe.ins_h=_e(Pe,Pe.ins_h,Pe.window[$e+Ne-1]),Pe.prev[$e&Pe.w_mask]=Pe.head[Pe.ins_h],Pe.head[Pe.ins_h]=$e,$e++;while(--p0);Pe.strstart=$e,Pe.lookahead=Ne-1,ee(Pe)}return Pe.strstart+=Pe.lookahead,Pe.block_start=Pe.strstart,Pe.insert=Pe.lookahead,Pe.lookahead=0,Pe.match_length=Pe.prev_length=Ne-1,Pe.match_available=0,se.next_in=Xt,se.input=Wt,se.avail_in=Nt,Pe.wrap=xe,e};return deflate.deflateInit=ot,deflate.deflateInit2=Zt,deflate.deflateReset=Ut,deflate.deflateResetKeep=ge,deflate.deflateSetHeader=Ve,deflate.deflate=ht,deflate.deflateEnd=I0,deflate.deflateSetDictionary=be,deflate.deflateInfo="pako deflate (from Nodeca project)",deflate}var common={},hasRequiredCommon;function requireCommon(){if(hasRequiredCommon)return common;hasRequiredCommon=1;const a=(n,s)=>Object.prototype.hasOwnProperty.call(n,s);return common.assign=function(n){const s=Array.prototype.slice.call(arguments,1);for(;s.length;){const u=s.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(const f in u)a(u,f)&&(n[f]=u[f])}}return n},common.flattenChunks=n=>{let s=0;for(let f=0,m=n.length;f=252?6:u>=248?5:u>=240?4:u>=224?3:u>=192?2:1;n[254]=n[254]=1,strings.string2buf=u=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(u);let f,m,A,v,y,T=u.length,I=0;for(v=0;v>>6,f[y++]=128|m&63):m<65536?(f[y++]=224|m>>>12,f[y++]=128|m>>>6&63,f[y++]=128|m&63):(f[y++]=240|m>>>18,f[y++]=128|m>>>12&63,f[y++]=128|m>>>6&63,f[y++]=128|m&63);return f};const s=(u,f)=>{if(f<65534&&u.subarray&&a)return String.fromCharCode.apply(null,u.length===f?u:u.subarray(0,f));let m="";for(let A=0;A{const m=f||u.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(u.subarray(0,f));let A,v;const y=new Array(m*2);for(v=0,A=0;A4){y[v++]=65533,A+=I-1;continue}for(T&=I===2?31:I===3?15:7;I>1&&A1){y[v++]=65533;continue}T<65536?y[v++]=T:(T-=65536,y[v++]=55296|T>>10&1023,y[v++]=56320|T&1023)}return s(y,v)},strings.utf8border=(u,f)=>{f=f||u.length,f>u.length&&(f=u.length);let m=f-1;for(;m>=0&&(u[m]&192)===128;)m--;return m<0||m===0?f:m+n[u[m]]>f?m:f},strings}var zstream,hasRequiredZstream;function requireZstream(){if(hasRequiredZstream)return zstream;hasRequiredZstream=1;function a(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}return zstream=a,zstream}var hasRequiredDeflate;function requireDeflate(){if(hasRequiredDeflate)return deflate$1;hasRequiredDeflate=1;const a=requireDeflate$1(),n=requireCommon(),s=requireStrings(),u=requireMessages(),f=requireZstream(),m=Object.prototype.toString,{Z_NO_FLUSH:A,Z_SYNC_FLUSH:v,Z_FULL_FLUSH:y,Z_FINISH:T,Z_OK:I,Z_STREAM_END:S,Z_DEFAULT_COMPRESSION:E,Z_DEFAULT_STRATEGY:e,Z_DEFLATED:F}=requireConstants();function M(z){this.options=n.assign({level:E,method:F,chunkSize:16384,windowBits:15,memLevel:8,strategy:e},z||{});let b=this.options;b.raw&&b.windowBits>0?b.windowBits=-b.windowBits:b.gzip&&b.windowBits>0&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new f,this.strm.avail_out=0;let W=a.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(W!==I)throw new Error(u[W]);if(b.header&&a.deflateSetHeader(this.strm,b.header),b.dictionary){let q;if(typeof b.dictionary=="string"?q=s.string2buf(b.dictionary):m.call(b.dictionary)==="[object ArrayBuffer]"?q=new Uint8Array(b.dictionary):q=b.dictionary,W=a.deflateSetDictionary(this.strm,q),W!==I)throw new Error(u[W]);this._dict_set=!0}}M.prototype.push=function(z,b){const W=this.strm,q=this.options.chunkSize;let Y,X;if(this.ended)return!1;for(b===~~b?X=b:X=b===!0?T:A,typeof z=="string"?W.input=s.string2buf(z):m.call(z)==="[object ArrayBuffer]"?W.input=new Uint8Array(z):W.input=z,W.next_in=0,W.avail_in=W.input.length;;){if(W.avail_out===0&&(W.output=new Uint8Array(q),W.next_out=0,W.avail_out=q),(X===v||X===y)&&W.avail_out<=6){this.onData(W.output.subarray(0,W.next_out)),W.avail_out=0;continue}if(Y=a.deflate(W,X),Y===S)return W.next_out>0&&this.onData(W.output.subarray(0,W.next_out)),Y=a.deflateEnd(this.strm),this.onEnd(Y),this.ended=!0,Y===I;if(W.avail_out===0){this.onData(W.output);continue}if(X>0&&W.next_out>0){this.onData(W.output.subarray(0,W.next_out)),W.avail_out=0;continue}if(W.avail_in===0)break}return!0},M.prototype.onData=function(z){this.chunks.push(z)},M.prototype.onEnd=function(z){z===I&&(this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=z,this.msg=this.strm.msg};function L(z,b){const W=new M(b);if(W.push(z,!0),W.err)throw W.msg||u[W.err];return W.result}function V(z,b){return b=b||{},b.raw=!0,L(z,b)}function B(z,b){return b=b||{},b.gzip=!0,L(z,b)}return deflate$1.Deflate=M,deflate$1.deflate=L,deflate$1.deflateRaw=V,deflate$1.gzip=B,deflate$1.constants=requireConstants(),deflate$1}var inflate$1={},inflate={},inffast,hasRequiredInffast;function requireInffast(){if(hasRequiredInffast)return inffast;hasRequiredInffast=1;const a=16209,n=16191;return inffast=function(u,f){let m,A,v,y,T,I,S,E,e,F,M,L,V,B,z,b,W,q,Y,X,H,g,J,re;const ae=u.state;m=u.next_in,J=u.input,A=m+(u.avail_in-5),v=u.next_out,re=u.output,y=v-(f-u.avail_out),T=v+(u.avail_out-257),I=ae.dmax,S=ae.wsize,E=ae.whave,e=ae.wnext,F=ae.window,M=ae.hold,L=ae.bits,V=ae.lencode,B=ae.distcode,z=(1<>>24,M>>>=q,L-=q,q=W>>>16&255,q===0)re[v++]=W&65535;else if(q&16){Y=W&65535,q&=15,q&&(L>>=q,L-=q),L<15&&(M+=J[m++]<>>24,M>>>=q,L-=q,q=W>>>16&255,q&16){if(X=W&65535,q&=15,LI){u.msg="invalid distance too far back",ae.mode=a;break e}if(M>>>=q,L-=q,q=v-y,X>q){if(q=X-q,q>E&&ae.sane){u.msg="invalid distance too far back",ae.mode=a;break e}if(H=0,g=F,e===0){if(H+=S-q,q2;)re[v++]=g[H++],re[v++]=g[H++],re[v++]=g[H++],Y-=3;Y&&(re[v++]=g[H++],Y>1&&(re[v++]=g[H++]))}else{H=v-X;do re[v++]=re[H++],re[v++]=re[H++],re[v++]=re[H++],Y-=3;while(Y>2);Y&&(re[v++]=re[H++],Y>1&&(re[v++]=re[H++]))}}else if(q&64){u.msg="invalid distance code",ae.mode=a;break e}else{W=B[(W&65535)+(M&(1<>3,m-=Y,L-=Y<<3,M&=(1<{const z=B.bits;let b=0,W=0,q=0,Y=0,X=0,H=0,g=0,J=0,re=0,ae=0,fe,pe,me,Se,ve,we=null,Ne;const De=new Uint16Array(a+1),je=new Uint16Array(a+1);let nt=null,Ue,ye,ut;for(b=0;b<=a;b++)De[b]=0;for(W=0;W=1&&De[Y]===0;Y--);if(X>Y&&(X=Y),Y===0)return M[L++]=1<<24|64<<16|0,M[L++]=1<<24|64<<16|0,B.bits=1,0;for(q=1;q0&&(S===u||Y!==1))return-1;for(je[1]=0,b=1;bn||S===m&&re>s)return 1;for(;;){Ue=b-g,V[W]+1=Ne?(ye=nt[V[W]-Ne],ut=we[V[W]-Ne]):(ye=96,ut=0),fe=1<>g)+pe]=Ue<<24|ye<<16|ut|0;while(pe!==0);for(fe=1<>=1;if(fe!==0?(ae&=fe-1,ae+=fe):ae=0,W++,--De[b]===0){if(b===Y)break;b=E[e+V[W]]}if(b>X&&(ae&Se)!==me){for(g===0&&(g=X),ve+=q,H=b-g,J=1<n||S===m&&re>s)return 1;me=ae&Se,M[me]=X<<24|H<<16|ve-L|0}}return ae!==0&&(M[ve+ae]=b-g<<24|64<<16|0),B.bits=X,0},inftrees}var hasRequiredInflate$1;function requireInflate$1(){if(hasRequiredInflate$1)return inflate;hasRequiredInflate$1=1;const a=requireAdler32(),n=requireCrc32(),s=requireInffast(),u=requireInftrees(),f=0,m=1,A=2,{Z_FINISH:v,Z_BLOCK:y,Z_TREES:T,Z_OK:I,Z_STREAM_END:S,Z_NEED_DICT:E,Z_STREAM_ERROR:e,Z_DATA_ERROR:F,Z_MEM_ERROR:M,Z_BUF_ERROR:L,Z_DEFLATED:V}=requireConstants(),B=16180,z=16181,b=16182,W=16183,q=16184,Y=16185,X=16186,H=16187,g=16188,J=16189,re=16190,ae=16191,fe=16192,pe=16193,me=16194,Se=16195,ve=16196,we=16197,Ne=16198,De=16199,je=16200,nt=16201,Ue=16202,ye=16203,ut=16204,pt=16205,It=16206,Lt=16207,Ot=16208,Et=16209,Rt=16210,Ze=16211,Me=852,Qe=592,Fe=15,at=Re=>(Re>>>24&255)+(Re>>>8&65280)+((Re&65280)<<8)+((Re&255)<<24);function ze(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Le=Re=>{if(!Re)return 1;const Ye=Re.state;return!Ye||Ye.strm!==Re||Ye.modeZe?1:0},qe=Re=>{if(Le(Re))return e;const Ye=Re.state;return Re.total_in=Re.total_out=Ye.total=0,Re.msg="",Ye.wrap&&(Re.adler=Ye.wrap&1),Ye.mode=B,Ye.last=0,Ye.havedict=0,Ye.flags=-1,Ye.dmax=32768,Ye.head=null,Ye.hold=0,Ye.bits=0,Ye.lencode=Ye.lendyn=new Int32Array(Me),Ye.distcode=Ye.distdyn=new Int32Array(Qe),Ye.sane=1,Ye.back=-1,I},_e=Re=>{if(Le(Re))return e;const Ye=Re.state;return Ye.wsize=0,Ye.whave=0,Ye.wnext=0,qe(Re)},Je=(Re,Ye)=>{let ue;if(Le(Re))return e;const Ae=Re.state;return Ye<0?(ue=0,Ye=-Ye):(ue=(Ye>>4)+5,Ye<48&&(Ye&=15)),Ye&&(Ye<8||Ye>15)?e:(Ae.window!==null&&Ae.wbits!==Ye&&(Ae.window=null),Ae.wrap=ue,Ae.wbits=Ye,_e(Re))},We=(Re,Ye)=>{if(!Re)return e;const ue=new ze;Re.state=ue,ue.strm=Re,ue.window=null,ue.mode=B;const Ae=Je(Re,Ye);return Ae!==I&&(Re.state=null),Ae},Ge=Re=>We(Re,Fe);let xt=!0,He,rt;const ee=Re=>{if(xt){He=new Int32Array(512),rt=new Int32Array(32);let Ye=0;for(;Ye<144;)Re.lens[Ye++]=8;for(;Ye<256;)Re.lens[Ye++]=9;for(;Ye<280;)Re.lens[Ye++]=7;for(;Ye<288;)Re.lens[Ye++]=8;for(u(m,Re.lens,0,288,He,0,Re.work,{bits:9}),Ye=0;Ye<32;)Re.lens[Ye++]=5;u(A,Re.lens,0,32,rt,0,Re.work,{bits:5}),xt=!1}Re.lencode=He,Re.lenbits=9,Re.distcode=rt,Re.distbits=5},Be=(Re,Ye,ue,Ae)=>{let Vt;const ge=Re.state;return ge.window===null&&(ge.wsize=1<=ge.wsize?(ge.window.set(Ye.subarray(ue-ge.wsize,ue),0),ge.wnext=0,ge.whave=ge.wsize):(Vt=ge.wsize-ge.wnext,Vt>Ae&&(Vt=Ae),ge.window.set(Ye.subarray(ue-Ae,ue-Ae+Vt),ge.wnext),Ae-=Vt,Ae?(ge.window.set(Ye.subarray(ue-Ae,ue),0),ge.wnext=Ae,ge.whave=ge.wsize):(ge.wnext+=Vt,ge.wnext===ge.wsize&&(ge.wnext=0),ge.whave{let ue,Ae,Vt,ge,Ut,Ve,Zt,ot,ht,I0,be,se,lt,Ce,Pe=0,xe,Nt,Xt,Wt,$e,p0,R0,Q0;const M0=new Uint8Array(4);let ni,St;const kt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Le(Re)||!Re.output||!Re.input&&Re.avail_in!==0)return e;ue=Re.state,ue.mode===ae&&(ue.mode=fe),Ut=Re.next_out,Vt=Re.output,Zt=Re.avail_out,ge=Re.next_in,Ae=Re.input,Ve=Re.avail_in,ot=ue.hold,ht=ue.bits,I0=Ve,be=Zt,Q0=I;e:for(;;)switch(ue.mode){case B:if(ue.wrap===0){ue.mode=fe;break}for(;ht<16;){if(Ve===0)break e;Ve--,ot+=Ae[ge++]<>>8&255,ue.check=n(ue.check,M0,2,0),ot=0,ht=0,ue.mode=z;break}if(ue.head&&(ue.head.done=!1),!(ue.wrap&1)||(((ot&255)<<8)+(ot>>8))%31){Re.msg="incorrect header check",ue.mode=Et;break}if((ot&15)!==V){Re.msg="unknown compression method",ue.mode=Et;break}if(ot>>>=4,ht-=4,R0=(ot&15)+8,ue.wbits===0&&(ue.wbits=R0),R0>15||R0>ue.wbits){Re.msg="invalid window size",ue.mode=Et;break}ue.dmax=1<>8&1),ue.flags&512&&ue.wrap&4&&(M0[0]=ot&255,M0[1]=ot>>>8&255,ue.check=n(ue.check,M0,2,0)),ot=0,ht=0,ue.mode=b;case b:for(;ht<32;){if(Ve===0)break e;Ve--,ot+=Ae[ge++]<>>8&255,M0[2]=ot>>>16&255,M0[3]=ot>>>24&255,ue.check=n(ue.check,M0,4,0)),ot=0,ht=0,ue.mode=W;case W:for(;ht<16;){if(Ve===0)break e;Ve--,ot+=Ae[ge++]<>8),ue.flags&512&&ue.wrap&4&&(M0[0]=ot&255,M0[1]=ot>>>8&255,ue.check=n(ue.check,M0,2,0)),ot=0,ht=0,ue.mode=q;case q:if(ue.flags&1024){for(;ht<16;){if(Ve===0)break e;Ve--,ot+=Ae[ge++]<>>8&255,ue.check=n(ue.check,M0,2,0)),ot=0,ht=0}else ue.head&&(ue.head.extra=null);ue.mode=Y;case Y:if(ue.flags&1024&&(se=ue.length,se>Ve&&(se=Ve),se&&(ue.head&&(R0=ue.head.extra_len-ue.length,ue.head.extra||(ue.head.extra=new Uint8Array(ue.head.extra_len)),ue.head.extra.set(Ae.subarray(ge,ge+se),R0)),ue.flags&512&&ue.wrap&4&&(ue.check=n(ue.check,Ae,se,ge)),Ve-=se,ge+=se,ue.length-=se),ue.length))break e;ue.length=0,ue.mode=X;case X:if(ue.flags&2048){if(Ve===0)break e;se=0;do R0=Ae[ge+se++],ue.head&&R0&&ue.length<65536&&(ue.head.name+=String.fromCharCode(R0));while(R0&&se>9&1,ue.head.done=!0),Re.adler=ue.check=0,ue.mode=ae;break;case J:for(;ht<32;){if(Ve===0)break e;Ve--,ot+=Ae[ge++]<>>=ht&7,ht-=ht&7,ue.mode=It;break}for(;ht<3;){if(Ve===0)break e;Ve--,ot+=Ae[ge++]<>>=1,ht-=1,ot&3){case 0:ue.mode=pe;break;case 1:if(ee(ue),ue.mode=De,Ye===T){ot>>>=2,ht-=2;break e}break;case 2:ue.mode=ve;break;case 3:Re.msg="invalid block type",ue.mode=Et}ot>>>=2,ht-=2;break;case pe:for(ot>>>=ht&7,ht-=ht&7;ht<32;){if(Ve===0)break e;Ve--,ot+=Ae[ge++]<>>16^65535)){Re.msg="invalid stored block lengths",ue.mode=Et;break}if(ue.length=ot&65535,ot=0,ht=0,ue.mode=me,Ye===T)break e;case me:ue.mode=Se;case Se:if(se=ue.length,se){if(se>Ve&&(se=Ve),se>Zt&&(se=Zt),se===0)break e;Vt.set(Ae.subarray(ge,ge+se),Ut),Ve-=se,ge+=se,Zt-=se,Ut+=se,ue.length-=se;break}ue.mode=ae;break;case ve:for(;ht<14;){if(Ve===0)break e;Ve--,ot+=Ae[ge++]<>>=5,ht-=5,ue.ndist=(ot&31)+1,ot>>>=5,ht-=5,ue.ncode=(ot&15)+4,ot>>>=4,ht-=4,ue.nlen>286||ue.ndist>30){Re.msg="too many length or distance symbols",ue.mode=Et;break}ue.have=0,ue.mode=we;case we:for(;ue.have>>=3,ht-=3}for(;ue.have<19;)ue.lens[kt[ue.have++]]=0;if(ue.lencode=ue.lendyn,ue.lenbits=7,ni={bits:ue.lenbits},Q0=u(f,ue.lens,0,19,ue.lencode,0,ue.work,ni),ue.lenbits=ni.bits,Q0){Re.msg="invalid code lengths set",ue.mode=Et;break}ue.have=0,ue.mode=Ne;case Ne:for(;ue.have>>24,Nt=Pe>>>16&255,Xt=Pe&65535,!(xe<=ht);){if(Ve===0)break e;Ve--,ot+=Ae[ge++]<>>=xe,ht-=xe,ue.lens[ue.have++]=Xt;else{if(Xt===16){for(St=xe+2;ht>>=xe,ht-=xe,ue.have===0){Re.msg="invalid bit length repeat",ue.mode=Et;break}R0=ue.lens[ue.have-1],se=3+(ot&3),ot>>>=2,ht-=2}else if(Xt===17){for(St=xe+3;ht>>=xe,ht-=xe,R0=0,se=3+(ot&7),ot>>>=3,ht-=3}else{for(St=xe+7;ht>>=xe,ht-=xe,R0=0,se=11+(ot&127),ot>>>=7,ht-=7}if(ue.have+se>ue.nlen+ue.ndist){Re.msg="invalid bit length repeat",ue.mode=Et;break}for(;se--;)ue.lens[ue.have++]=R0}}if(ue.mode===Et)break;if(ue.lens[256]===0){Re.msg="invalid code -- missing end-of-block",ue.mode=Et;break}if(ue.lenbits=9,ni={bits:ue.lenbits},Q0=u(m,ue.lens,0,ue.nlen,ue.lencode,0,ue.work,ni),ue.lenbits=ni.bits,Q0){Re.msg="invalid literal/lengths set",ue.mode=Et;break}if(ue.distbits=6,ue.distcode=ue.distdyn,ni={bits:ue.distbits},Q0=u(A,ue.lens,ue.nlen,ue.ndist,ue.distcode,0,ue.work,ni),ue.distbits=ni.bits,Q0){Re.msg="invalid distances set",ue.mode=Et;break}if(ue.mode=De,Ye===T)break e;case De:ue.mode=je;case je:if(Ve>=6&&Zt>=258){Re.next_out=Ut,Re.avail_out=Zt,Re.next_in=ge,Re.avail_in=Ve,ue.hold=ot,ue.bits=ht,s(Re,be),Ut=Re.next_out,Vt=Re.output,Zt=Re.avail_out,ge=Re.next_in,Ae=Re.input,Ve=Re.avail_in,ot=ue.hold,ht=ue.bits,ue.mode===ae&&(ue.back=-1);break}for(ue.back=0;Pe=ue.lencode[ot&(1<>>24,Nt=Pe>>>16&255,Xt=Pe&65535,!(xe<=ht);){if(Ve===0)break e;Ve--,ot+=Ae[ge++]<>Wt)],xe=Pe>>>24,Nt=Pe>>>16&255,Xt=Pe&65535,!(Wt+xe<=ht);){if(Ve===0)break e;Ve--,ot+=Ae[ge++]<>>=Wt,ht-=Wt,ue.back+=Wt}if(ot>>>=xe,ht-=xe,ue.back+=xe,ue.length=Xt,Nt===0){ue.mode=pt;break}if(Nt&32){ue.back=-1,ue.mode=ae;break}if(Nt&64){Re.msg="invalid literal/length code",ue.mode=Et;break}ue.extra=Nt&15,ue.mode=nt;case nt:if(ue.extra){for(St=ue.extra;ht>>=ue.extra,ht-=ue.extra,ue.back+=ue.extra}ue.was=ue.length,ue.mode=Ue;case Ue:for(;Pe=ue.distcode[ot&(1<>>24,Nt=Pe>>>16&255,Xt=Pe&65535,!(xe<=ht);){if(Ve===0)break e;Ve--,ot+=Ae[ge++]<>Wt)],xe=Pe>>>24,Nt=Pe>>>16&255,Xt=Pe&65535,!(Wt+xe<=ht);){if(Ve===0)break e;Ve--,ot+=Ae[ge++]<>>=Wt,ht-=Wt,ue.back+=Wt}if(ot>>>=xe,ht-=xe,ue.back+=xe,Nt&64){Re.msg="invalid distance code",ue.mode=Et;break}ue.offset=Xt,ue.extra=Nt&15,ue.mode=ye;case ye:if(ue.extra){for(St=ue.extra;ht>>=ue.extra,ht-=ue.extra,ue.back+=ue.extra}if(ue.offset>ue.dmax){Re.msg="invalid distance too far back",ue.mode=Et;break}ue.mode=ut;case ut:if(Zt===0)break e;if(se=be-Zt,ue.offset>se){if(se=ue.offset-se,se>ue.whave&&ue.sane){Re.msg="invalid distance too far back",ue.mode=Et;break}se>ue.wnext?(se-=ue.wnext,lt=ue.wsize-se):lt=ue.wnext-se,se>ue.length&&(se=ue.length),Ce=ue.window}else Ce=Vt,lt=Ut-ue.offset,se=ue.length;se>Zt&&(se=Zt),Zt-=se,ue.length-=se;do Vt[Ut++]=Ce[lt++];while(--se);ue.length===0&&(ue.mode=je);break;case pt:if(Zt===0)break e;Vt[Ut++]=ue.length,Zt--,ue.mode=je;break;case It:if(ue.wrap){for(;ht<32;){if(Ve===0)break e;Ve--,ot|=Ae[ge++]<{if(Le(Re))return e;let Ye=Re.state;return Ye.window&&(Ye.window=null),Re.state=null,I},ft=(Re,Ye)=>{if(Le(Re))return e;const ue=Re.state;return ue.wrap&2?(ue.head=Ye,Ye.done=!1,I):e},vt=(Re,Ye)=>{const ue=Ye.length;let Ae,Vt,ge;return Le(Re)||(Ae=Re.state,Ae.wrap!==0&&Ae.mode!==re)?e:Ae.mode===re&&(Vt=1,Vt=a(Vt,Ye,ue,0),Vt!==Ae.check)?F:(ge=Be(Re,Ye,ue,ue),ge?(Ae.mode=Rt,M):(Ae.havedict=1,I))};return inflate.inflateReset=_e,inflate.inflateReset2=Je,inflate.inflateResetKeep=qe,inflate.inflateInit=Ge,inflate.inflateInit2=We,inflate.inflate=st,inflate.inflateEnd=Ke,inflate.inflateGetHeader=ft,inflate.inflateSetDictionary=vt,inflate.inflateInfo="pako inflate (from Nodeca project)",inflate}var gzheader,hasRequiredGzheader;function requireGzheader(){if(hasRequiredGzheader)return gzheader;hasRequiredGzheader=1;function a(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}return gzheader=a,gzheader}var hasRequiredInflate;function requireInflate(){if(hasRequiredInflate)return inflate$1;hasRequiredInflate=1;const a=requireInflate$1(),n=requireCommon(),s=requireStrings(),u=requireMessages(),f=requireZstream(),m=requireGzheader(),A=Object.prototype.toString,{Z_NO_FLUSH:v,Z_FINISH:y,Z_OK:T,Z_STREAM_END:I,Z_NEED_DICT:S,Z_STREAM_ERROR:E,Z_DATA_ERROR:e,Z_MEM_ERROR:F}=requireConstants();function M(B){this.options=n.assign({chunkSize:1024*64,windowBits:15,to:""},B||{});const z=this.options;z.raw&&z.windowBits>=0&&z.windowBits<16&&(z.windowBits=-z.windowBits,z.windowBits===0&&(z.windowBits=-15)),z.windowBits>=0&&z.windowBits<16&&!(B&&B.windowBits)&&(z.windowBits+=32),z.windowBits>15&&z.windowBits<48&&(z.windowBits&15||(z.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new f,this.strm.avail_out=0;let b=a.inflateInit2(this.strm,z.windowBits);if(b!==T)throw new Error(u[b]);if(this.header=new m,a.inflateGetHeader(this.strm,this.header),z.dictionary&&(typeof z.dictionary=="string"?z.dictionary=s.string2buf(z.dictionary):A.call(z.dictionary)==="[object ArrayBuffer]"&&(z.dictionary=new Uint8Array(z.dictionary)),z.raw&&(b=a.inflateSetDictionary(this.strm,z.dictionary),b!==T)))throw new Error(u[b])}M.prototype.push=function(B,z){const b=this.strm,W=this.options.chunkSize,q=this.options.dictionary;let Y,X,H;if(this.ended)return!1;for(z===~~z?X=z:X=z===!0?y:v,A.call(B)==="[object ArrayBuffer]"?b.input=new Uint8Array(B):b.input=B,b.next_in=0,b.avail_in=b.input.length;;){for(b.avail_out===0&&(b.output=new Uint8Array(W),b.next_out=0,b.avail_out=W),Y=a.inflate(b,X),Y===S&&q&&(Y=a.inflateSetDictionary(b,q),Y===T?Y=a.inflate(b,X):Y===e&&(Y=S));b.avail_in>0&&Y===I&&b.state.wrap>0&&B[b.next_in]!==0;)a.inflateReset(b),Y=a.inflate(b,X);switch(Y){case E:case e:case S:case F:return this.onEnd(Y),this.ended=!0,!1}if(H=b.avail_out,b.next_out&&(b.avail_out===0||Y===I))if(this.options.to==="string"){let g=s.utf8border(b.output,b.next_out),J=b.next_out-g,re=s.buf2string(b.output,g);b.next_out=J,b.avail_out=W-J,J&&b.output.set(b.output.subarray(g,g+J),0),this.onData(re)}else this.onData(b.output.length===b.next_out?b.output:b.output.subarray(0,b.next_out));if(!(Y===T&&H===0)){if(Y===I)return Y=a.inflateEnd(this.strm),this.onEnd(Y),this.ended=!0,!0;if(b.avail_in===0)break}}return!0},M.prototype.onData=function(B){this.chunks.push(B)},M.prototype.onEnd=function(B){B===T&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=B,this.msg=this.strm.msg};function L(B,z){const b=new M(z);if(b.push(B),b.err)throw b.msg||u[b.err];return b.result}function V(B,z){return z=z||{},z.raw=!0,L(B,z)}return inflate$1.Inflate=M,inflate$1.inflate=L,inflate$1.inflateRaw=V,inflate$1.ungzip=L,inflate$1.constants=requireConstants(),inflate$1}var hasRequiredPako;function requirePako(){if(hasRequiredPako)return pako;hasRequiredPako=1;const{Deflate:a,deflate:n,deflateRaw:s,gzip:u}=requireDeflate(),{Inflate:f,inflate:m,inflateRaw:A,ungzip:v}=requireInflate(),y=requireConstants();return pako.Deflate=a,pako.deflate=n,pako.deflateRaw=s,pako.gzip=u,pako.Inflate=f,pako.inflate=m,pako.inflateRaw=A,pako.ungzip=v,pako.constants=y,pako}var hasRequiredParser;function requireParser(){return hasRequiredParser||(hasRequiredParser=1,function(a){var n=n||{};n.Tag=n.Tag||(typeof commonjsRequire<"u"?requireTag():null),n.Utils=n.Utils||(typeof commonjsRequire<"u"?requireUtilities():null),n.Dictionary=n.Dictionary||(typeof commonjsRequire<"u"?requireDictionary():null),n.Image=n.Image||(typeof commonjsRequire<"u"?requireImage():null);var s=s||(typeof commonjsRequire<"u"?requirePako():null);n.Parser=n.Parser||function(){this.littleEndian=!0,this.explicit=!0,this.metaFound=!1,this.metaFinished=!1,this.metaFinishedOffset=-1,this.needsDeflate=!1,this.inflated=null,this.encapsulation=!1,this.level=0,this.error=null},n.Parser.verbose=!1,n.Parser.MAGIC_COOKIE_OFFSET=128,n.Parser.MAGIC_COOKIE=[68,73,67,77],n.Parser.VRS=["AE","AS","AT","CS","DA","DS","DT","FL","FD","IS","LO","LT","OB","OD","OF","OW","PN","SH","SL","SS","ST","TM","UI","UL","UN","US","UT","UC"],n.Parser.DATA_VRS=["OB","OW","OF","SQ","UT","UN","UC"],n.Parser.RAW_DATA_VRS=["OB","OD","OF","OW","UN"],n.Parser.TRANSFER_SYNTAX_IMPLICIT_LITTLE="1.2.840.10008.1.2",n.Parser.TRANSFER_SYNTAX_EXPLICIT_LITTLE="1.2.840.10008.1.2.1",n.Parser.TRANSFER_SYNTAX_EXPLICIT_BIG="1.2.840.10008.1.2.2",n.Parser.TRANSFER_SYNTAX_COMPRESSION_JPEG="1.2.840.10008.1.2.4",n.Parser.TRANSFER_SYNTAX_COMPRESSION_JPEG_LOSSLESS="1.2.840.10008.1.2.4.57",n.Parser.TRANSFER_SYNTAX_COMPRESSION_JPEG_LOSSLESS_SEL1="1.2.840.10008.1.2.4.70",n.Parser.TRANSFER_SYNTAX_COMPRESSION_JPEG_BASELINE_8BIT="1.2.840.10008.1.2.4.50",n.Parser.TRANSFER_SYNTAX_COMPRESSION_JPEG_BASELINE_12BIT="1.2.840.10008.1.2.4.51",n.Parser.TRANSFER_SYNTAX_COMPRESSION_JPEG_LS_LOSSLESS="1.2.840.10008.1.2.4.80",n.Parser.TRANSFER_SYNTAX_COMPRESSION_JPEG_LS="1.2.840.10008.1.2.4.81",n.Parser.TRANSFER_SYNTAX_COMPRESSION_JPEG_2000_LOSSLESS="1.2.840.10008.1.2.4.90",n.Parser.TRANSFER_SYNTAX_COMPRESSION_JPEG_2000="1.2.840.10008.1.2.4.91",n.Parser.TRANSFER_SYNTAX_COMPRESSION_RLE="1.2.840.10008.1.2.5",n.Parser.TRANSFER_SYNTAX_COMPRESSION_DEFLATE="1.2.840.10008.1.2.1.99",n.Parser.UNDEFINED_LENGTH=4294967295,n.Parser.isMagicCookieFound=function(u){var f=n.Parser.MAGIC_COOKIE_OFFSET,m=n.Parser.MAGIC_COOKIE.length,A;for(A=0;A=this.metaFinishedOffset&&(this.needsDeflate=!1,v=u.buffer.slice(0,A.offsetEnd),y=u.buffer.slice(A.offsetEnd),this.inflated=n.Utils.concatArrayBuffers(v,s.inflateRaw(y)),u=new DataView(this.inflated)),A=this.getNextTag(u,A.offsetEnd)}catch(T){this.error=T}return f!==null&&(f.littleEndian=this.littleEndian),f},n.Parser.prototype.parseEncapsulated=function(u){var f=0,m,A=[];this.encapsulation=!0;try{for(m=this.getNextTag(u,f);m!==null;)m.isSublistItem()&&A.push(m),n.Parser.verbose&&console.log(m.toString()),m=this.getNextTag(u,m.offsetEnd)}catch(v){this.error=v}return A},n.Parser.prototype.testForValidTag=function(u){var f,m=null;try{f=this.findFirstTagOffset(u),m=this.getNextTag(u,f,!1)}catch(A){this.error=A}return m},n.Parser.prototype.getNextTag=function(u,f,m){var A=0,v,y=null,T=f,I,S=0,E=!0,e=null,F;if(f>=u.byteLength)return null;this.metaFinished?(E=this.littleEndian,A=u.getUint16(f,E)):(A=u.getUint16(f,!0),this.metaFinishedOffset!==-1&&f>=this.metaFinishedOffset||A!==2?(this.metaFinished=!0,E=this.littleEndian,A=u.getUint16(f,E)):E=!0),!this.metaFound&&A===2&&(this.metaFound=!0),f+=2,v=u.getUint16(f,E),f+=2,this.explicit||!this.metaFinished?(e=n.Utils.getStringAt(u,f,2),!this.metaFound&&this.metaFinished&&n.Parser.VRS.indexOf(e)===-1?(e=n.Dictionary.getVR(A,v),S=u.getUint32(f,E),f+=4,this.explicit=!1):(f+=2,n.Parser.DATA_VRS.indexOf(e)!==-1?(f+=2,S=u.getUint32(f,E),f+=4):(S=u.getUint16(f,E),f+=2))):(e=n.Dictionary.getVR(A,v),S=u.getUint32(f,E),S===n.Parser.UNDEFINED_LENGTH&&(e="SQ"),f+=4),I=f;var M=A===n.Tag.TAG_PIXEL_DATA[0]&&v===n.Tag.TAG_PIXEL_DATA[1],L=A===40&&v>=4609&&v<4864;if(e==="SQ"||!L&&!M&&!this.encapsulation&&n.Parser.DATA_VRS.indexOf(e)!==-1&&e!=="UC"?(y=this.parseSublist(u,f,S,e!=="SQ"),S===n.Parser.UNDEFINED_LENGTH&&(S=y[y.length-1].offsetEnd-f)):S>0&&!m&&(S===n.Parser.UNDEFINED_LENGTH&&M&&(S=u.byteLength-f),y=u.buffer.slice(f,f+S)),f+=S,F=new n.Tag(A,v,e,y,T,I,f,this.littleEndian,this.charset),F.value){if(F.isTransformSyntax())this.transformSyntaxAlreadyExist=!0,F.value[0]===n.Parser.TRANSFER_SYNTAX_IMPLICIT_LITTLE?(this.explicit=!1,this.littleEndian=!0):F.value[0]===n.Parser.TRANSFER_SYNTAX_EXPLICIT_BIG?(this.explicit=!0,this.littleEndian=!1):F.value[0]===n.Parser.TRANSFER_SYNTAX_COMPRESSION_DEFLATE?(this.needsDeflate=!0,this.explicit=!0,this.littleEndian=!0):(this.explicit=!0,this.littleEndian=!0);else if(F.isMetaLength())this.metaFinishedOffset=F.value[0]+f;else if(F.isCharset()){var V=F.value;V.length==2?V=(V[0]||"ISO 2022 IR 6")+"\\"+V[1]:V.length==1&&(V=V[0]),this.charset=V}}return F},n.Parser.prototype.parseSublist=function(u,f,m,A){var v,y=f+m,T=[];if(this.level++,m===n.Parser.UNDEFINED_LENGTH){for(v=this.parseSublistItem(u,f,A);!v.isSequenceDelim();)T.push(v),f=v.offsetEnd,v=this.parseSublistItem(u,f,A);T.push(v)}else for(;fn.Image.OBLIQUITY_THRESHOLD_COSINE_VALUE&&e>F&&e>M?T=I:F>n.Image.OBLIQUITY_THRESHOLD_COSINE_VALUE&&F>e&&F>M?T=S:M>n.Image.OBLIQUITY_THRESHOLD_COSINE_VALUE&&M>e&&M>F?T=E:T=null,T},n.Image.prototype.getCols=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_COLS[0],n.Tag.TAG_COLS[1]),0)},n.Image.prototype.getRows=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_ROWS[0],n.Tag.TAG_ROWS[1]),0)},n.Image.prototype.getSeriesDescription=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_SERIES_DESCRIPTION[0],n.Tag.TAG_SERIES_DESCRIPTION[1]),0)},n.Image.prototype.getSeriesInstanceUID=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_SERIES_INSTANCE_UID[0],n.Tag.TAG_SERIES_INSTANCE_UID[1]),0)},n.Image.prototype.getSeriesNumber=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_SERIES_NUMBER[0],n.Tag.TAG_SERIES_NUMBER[1]),0)},n.Image.prototype.getEchoNumber=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_ECHO_NUMBER[0],n.Tag.TAG_ECHO_NUMBER[1]),0)},n.Image.prototype.getImagePosition=function(){return n.Image.getValueSafely(this.getTag(n.Tag.TAG_IMAGE_POSITION[0],n.Tag.TAG_IMAGE_POSITION[1]))},n.Image.prototype.getImageDirections=function(){return n.Image.getValueSafely(this.getTag(n.Tag.TAG_IMAGE_ORIENTATION[0],n.Tag.TAG_IMAGE_ORIENTATION[1]))},n.Image.prototype.getImagePositionSliceDir=function(A){var v=n.Image.getValueSafely(this.getTag(n.Tag.TAG_IMAGE_POSITION[0],n.Tag.TAG_IMAGE_POSITION[1]));return v&&A>=0?v[A]:0},n.Image.prototype.getModality=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_MODALITY[0],n.Tag.TAG_MODALITY[1]),0)},n.Image.prototype.getSliceLocation=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_SLICE_LOCATION[0],n.Tag.TAG_SLICE_LOCATION[1]),0)},n.Image.prototype.getSliceLocationVector=function(){return n.Image.getValueSafely(this.getTag(n.Tag.TAG_SLICE_LOCATION_VECTOR[0],n.Tag.TAG_SLICE_LOCATION_VECTOR[1]))},n.Image.prototype.getImageNumber=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_IMAGE_NUM[0],n.Tag.TAG_IMAGE_NUM[1]),0)},n.Image.prototype.getTemporalPosition=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_TEMPORAL_POSITION[0],n.Tag.TAG_TEMPORAL_POSITION[1]),0)},n.Image.prototype.getTemporalNumber=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_NUMBER_TEMPORAL_POSITIONS[0],n.Tag.TAG_NUMBER_TEMPORAL_POSITIONS[1]),0)},n.Image.prototype.getSliceGap=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_SLICE_GAP[0],n.Tag.TAG_SLICE_GAP[1]),0)},n.Image.prototype.getSliceThickness=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_SLICE_THICKNESS[0],n.Tag.TAG_SLICE_THICKNESS[1]),0)},n.Image.prototype.getImageMax=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_IMAGE_MAX[0],n.Tag.TAG_IMAGE_MAX[1]),0)},n.Image.prototype.getImageMin=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_IMAGE_MIN[0],n.Tag.TAG_IMAGE_MIN[1]),0)},n.Image.prototype.getDataScaleSlope=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_DATA_SCALE_SLOPE[0],n.Tag.TAG_DATA_SCALE_SLOPE[1]),0)},n.Image.prototype.getDataScaleIntercept=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_DATA_SCALE_INTERCEPT[0],n.Tag.TAG_DATA_SCALE_INTERCEPT[1]),0)},n.Image.prototype.getDataScaleElscint=function(){var A=n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_DATA_SCALE_ELSCINT[0],n.Tag.TAG_DATA_SCALE_ELSCINT[1]),0);A||(A=1);var v=this.getPixelBandwidth();return A=Math.sqrt(v)/(10*A),A<=0&&(A=1),A},n.Image.prototype.getWindowWidth=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_WINDOW_WIDTH[0],n.Tag.TAG_WINDOW_WIDTH[1]),0)},n.Image.prototype.getWindowCenter=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_WINDOW_CENTER[0],n.Tag.TAG_WINDOW_CENTER[1]),0)},n.Image.prototype.getPixelBandwidth=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_PIXEL_BANDWIDTH[0],n.Tag.TAG_PIXEL_BANDWIDTH[1]),0)},n.Image.prototype.getSeriesId=function(){var A=this.getSeriesDescription(),v=this.getSeriesInstanceUID(),y=this.getSeriesNumber(),T=this.getEchoNumber(),I=this.getOrientation(),S=this.getCols(),E=this.getRows(),e="";return A!==null&&(e+=" "+A),v!==null&&(e+=" "+v),y!==null&&(e+=" "+y),T!==null&&(e+=" "+T),I!==null&&(e+=" "+I),e+=" ("+S+" x "+E+")",e},n.Image.prototype.getPixelSpacing=function(){return n.Image.getValueSafely(this.getTag(n.Tag.TAG_PIXEL_SPACING[0],n.Tag.TAG_PIXEL_SPACING[1]))},n.Image.prototype.getImageType=function(){return n.Image.getValueSafely(this.getTag(n.Tag.TAG_IMAGE_TYPE[0],n.Tag.TAG_IMAGE_TYPE[1]))},n.Image.prototype.getBitsStored=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_BITS_STORED[0],n.Tag.TAG_BITS_STORED[1]),0)},n.Image.prototype.getBitsAllocated=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_BITS_ALLOCATED[0],n.Tag.TAG_BITS_ALLOCATED[1]),0)},n.Image.prototype.getFrameTime=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_FRAME_TIME[0],n.Tag.TAG_FRAME_TIME[1]),0)},n.Image.prototype.getAcquisitionMatrix=function(){var A,v,y,T,I;return A=[0,0],A[0]=n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_ACQUISITION_MATRIX[0],n.Tag.TAG_ACQUISITION_MATRIX[1]),0),this.privateDataAll===null&&(this.privateDataAll=this.getAllInterpretedPrivateData()),this.privateDataAll!==null&&this.privateDataAll.length>0&&(y=this.privateDataAll.indexOf("AcquisitionMatrixText"),y!==-1&&(T=this.privateDataAll.indexOf(` `,y),T!==-1&&(I=this.privateDataAll.substring(y,T),v=I.match(/\d+/g),v!==null&&v.length===2?(A[0]=v[0],A[1]=v[1]):v!==null&&v.length===1&&(A[0]=v[0])))),A[1]===0&&(A[1]=A[0]),A},n.Image.prototype.getTR=function(){return n.Image.getSingleValueSafely(this.getTag(n.Tag.TAG_TR,n.Tag.TAG_TR[1]),0)},n.Image.prototype.putTag=function(A){this.tags[A.id]&&this.tags[A.id].value[0]!==A.value[0]||(this.tags[A.id]=A,this.putFlattenedTag(this.tagsFlat,A))},n.Image.prototype.putFlattenedTag=function(A,v){var y;if(v.sublist)for(y=0;yz&&(z=b,q=fe);return v?{data:e,min:B,minIndex:W,max:z,maxIndex:q,numCols:this.getCols(),numRows:this.getRows()}:e},n.Image.prototype.convertPalette=function(){var A,v,y,T,I,S,E,e,F,M,L,V;if(A=this.tags[n.Tag.createId(n.Tag.TAG_PIXEL_DATA[0],n.Tag.TAG_PIXEL_DATA[1])].value,v=this.getPalleteValues(n.Tag.TAG_PALETTE_RED),y=this.getPalleteValues(n.Tag.TAG_PALETTE_GREEN),T=this.getPalleteValues(n.Tag.TAG_PALETTE_BLUE),v!==null&&v.length>0&&y!==null&&y.length>0&&T!==null&&T.length>0&&!this.convertedPalette){if(I=new DataView(new ArrayBuffer(this.getRows()*this.getCols()*this.getNumberOfFrames()*3)),S=parseInt(Math.ceil(this.getBitsAllocated()/8)),E=A.byteLength/S,S===1)for(e=0;eF&&(F=Math.abs(v[y]),E=y);for(F=0;y<6;y+=1)Math.abs(v[y])>F&&(F=Math.abs(v[y]),e=y);switch(E){case 0:M+="X",e===4?M+="YZ":M+="ZY";break;case 1:M+="Y",e===3?M+="XZ":M+="ZX";break;case 2:M+="Z",e===3?M+="XY":M+="YX";break}switch(E){case 0:v[E]>0?M+="-":M+="+",e===4?v[e]>0?M+="-":M+="+":v[e]>0?M+="+":M+="-";break;case 1:v[E]>0?M+="-":M+="+",e===3?v[e]>0?M+="-":M+="+":v[e]>0?M+="+":M+="-";break;case 2:v[E]>0?M+="+":M+="-",v[e]>0?M+="-":M+="+";break}if(I===0)M+="+",A=M;else{if(S)switch(M.charAt(2)){case"X":I>0?M+="-":M+="+";break;case"Y":case"Z":I>0?M+="+":M+="-";break}else switch(M.charAt(2)){case"X":I>0?M+="+":M+="-";break;case"Y":case"Z":I>0?M+="-":M+="+";break}A=M}return A},n.Image.prototype.isMosaic=function(){var A,v=!1,y,T,I;if(A=this.getImageType(),A!==null){for(T=0;T0&&(I[0]1?S[y]=n.Utils.concatArrayBuffers2(I[y]):S[y]=I[y][0],I[y]=null;return S},n.Image.prototype.getRLE=function(){var A,v,y,T=[];if(A=this.getEncapsulatedData(),A)for(v=A.length,y=1;y");return T=T.replace(/\n\s*\n/g,` -`),T=T.replace(/(?:\r\n|\r|\n)/g,"
"),T},n.Image.prototype.getPalleteValues=function(A){var v,y,T,I,S,E,e,F,M,L,V;if(v=null,y=null,T=n.Image.getValueSafely(this.getTag(A[0],A[1])),T!==null){for(I=T.buffer.byteLength/2,v=[],y=[],S=0;S255||v<0)for(I=255/(y-v),S=v,T=0;T1&&s[0].getTemporalPosition()!==null,T=u>1&&s[0].getTemporalNumber()!==null&&s[0].getTemporalNumber()===u,y&&T)for(I=0;I1||this.isMosaic&&this.images[0].length>1,this.isMultiFrameVolume=!1,this.isMultiFrameTimeseries=!1,this.isImplicitTimeseries=!1,this.isMultiFrame&&(s=this.images[0].getFrameTime()>0,this.isMosaic?this.isMultiFrameTimeseries=!0:s?this.isMultiFrameTimeseries=!0:this.numberOfFramesInFile>1?(this.isMultiFrameTimeseries=!0,this.numberOfFrames=this.images.length):this.isMultiFrameVolume=!0),!this.isMosaic&&this.numberOfFrames<=1){for(S=this.images[0].getImagePosition()||[],f=S.toString(),this.numberOfFrames=0,u=0;u1&&(this.isImplicitTimeseries=!0)}this.sliceDir=this.images[0].getAcquiredSliceDirection(),n.Series.useExplicitOrdering?m=this.images.slice():m=n.Series.orderDicoms(this.images,this.numberOfFrames,this.sliceDir),A=m[0].getImagePositionSliceDir(this.sliceDir),v=m[m.length-1].getImagePositionSliceDir(this.sliceDir),y=v-A,n.Series.useExplicitOrdering?this.sliceSense=!1:this.isMosaic?this.sliceSense=!0:this.isMultiFrame?(T=m[0].getSliceLocationVector(),T!==null?(I=m[0].getOrientation(),I.charAt(2)==="Z"?this.sliceSense=T[0]-T[T.length-1]<0:this.sliceSense=T[0]-T[T.length-1]>0):this.sliceSense=!(A<0)):this.sliceDir===n.Image.SLICE_DIRECTION_SAGITTAL||this.sliceDir===n.Image.SLICE_DIRECTION_CORONAL?y>0?this.sliceSense=!1:this.sliceSense=!0:y>0?this.sliceSense=!0:this.sliceSense=!1,this.imagesOriginalOrder=this.images,this.images=m},n.Series.prototype.concatenateImageData=function(s,u){var f,m,A;this.isMosaic?m=this.getMosaicData(this.images[0],this.images[0].getPixelDataBytes()):m=this.images[0].getPixelDataBytes(),A=this.validatePixelDataLength(this.images[0]),this.images[0].clearPixelData(),f=new Uint8Array(new ArrayBuffer(A*this.images.length)),f.set(new Uint8Array(m,0,A),0),setTimeout(n.Utils.bind(this,function(){this.concatenateNextImageData(f,A,s,1,u)}),0)},n.Series.prototype.concatenateNextImageData=function(s,u,f,m,A){var v,y;m>=this.images.length?(f&&f.drawProgress(1,"Reading DICOM Images"),A(s.buffer)):(f&&f.drawProgress(m/this.images.length,"Reading DICOM Images"),this.isMosaic?v=this.getMosaicData(this.images[m],this.images[m].getPixelDataBytes()):v=this.images[m].getPixelDataBytes(),y=this.validatePixelDataLength(this.images[m]),this.images[m].clearPixelData(),s.set(new Uint8Array(v,0,y),u*m),setTimeout(n.Utils.bind(this,function(){this.concatenateNextImageData(s,u,f,m+1,A)}),0))},n.Series.prototype.validatePixelDataLength=function(s){var u=s.getPixelDataBytes().byteLength,f=s.getCols()*s.getRows();return u%f===0?u:f*s.getNumberOfFrames()*s.getNumberOfSamplesPerPixel()*(s.getBitsAllocated()/8)},n.Series.prototype.getMosaicData=function(s,u){var f,m,A,v,y,T,I,S,E,e,F,M,L,V,B,z,b,W=0;for(I=parseInt(this.images[0].getBitsAllocated()/8),F=this.images[0].getMosaicCols()*this.images[0].getMosaicRows(),M=parseInt(this.images[0].getRows()/this.images[0].getMosaicRows()),L=parseInt(this.images[0].getCols()/this.images[0].getMosaicCols()),f=this.images[0].getCols(),m=this.images[0].getRows(),A=this.images[0].getMosaicRows(),v=this.images[0].getMosaicCols(),y=parseInt(m/A),T=parseInt(f/v),V=new Uint8Array(new ArrayBuffer(F*M*L*I)),B=new Uint8Array(u),S=0;Sn in a?__defProp(a,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[n]=s,__export=(a,n)=>{for(var s in n)__defProp(a,s,{get:n[s],enumerable:!0})},__publicField=(a,n,s)=>(__defNormalProp(a,typeof n!="symbol"?n+"":n,s),s),version$1="0.42.0",_Log=class ci{constructor({name:n="niivue",level:s="info"}={}){__publicField(this,"level"),__publicField(this,"name"),this.name=`${n}`,this.level=s}debug(...n){ci.levels[this.level]>ci.levels.debug||console.debug(`${this.name}-debug`,...n)}info(...n){ci.levels[this.level]>ci.levels.info||console.info(`${this.name}-info`,...n)}warn(...n){ci.levels[this.level]>ci.levels.warn||console.warn(`${this.name}-warn`,...n)}error(...n){ci.levels[this.level]>ci.levels.error||console.error(`${this.name}-error`,...n)}fatal(...n){ci.levels[this.level]>ci.levels.fatal||console.error(`${this.name}-fatal`,...n)}setLogLevel(n){this.level=n}setName(n){this.name=n}};__publicField(_Log,"levels",{debug:0,info:1,warn:2,error:3,fatal:4,silent:1/0});var Log$1=_Log,log$4=new Log$1({name:"niivue",level:"info"}),compileShader=function(a,n,s){const u=a.createShader(a.VERTEX_SHADER);if(u===null)throw new Error("could not create vertex shader");if(a.shaderSource(u,n),a.compileShader(u),!a.getShaderParameter(u,a.COMPILE_STATUS))throw log$4.error(a.getShaderInfoLog(u)),new Error("Vertex shader failed to compile, see console for log");const f=a.createShader(a.FRAGMENT_SHADER);if(f===null)throw new Error("could not create fragment shader");if(a.shaderSource(f,s),a.compileShader(f),!a.getShaderParameter(f,a.COMPILE_STATUS))throw log$4.error(a.getShaderInfoLog(f)),new Error("Fragment shader failed to compile, see console for log");const m=a.createProgram();if(m===null)throw new Error("could not create GL program");if(a.attachShader(m,u),a.attachShader(m,f),a.linkProgram(m),!a.getProgramParameter(m,a.LINK_STATUS))throw log$4.error(a.getProgramInfoLog(m)),new Error("Shader failed to link, see console for log");return m},Shader=class{constructor(a,n,s){__publicField(this,"program"),__publicField(this,"uniforms",{}),__publicField(this,"isMatcap"),this.program=compileShader(a,n,s);const u=/uniform[^;]+[ ](\w+);/g,f=/uniform[^;]+[ ](\w+);/,m=n.match(u),A=s.match(u);m&&m.forEach(v=>{const y=v.match(f);this.uniforms[y[1]]=-1}),A&&A.forEach(v=>{const y=v.match(f);this.uniforms[y[1]]=-1});for(const v in this.uniforms)this.uniforms[v]=a.getUniformLocation(this.program,v)}use(a){a.useProgram(this.program)}},vertRenderShader=`#version 300 es +`),T=T.replace(/(?:\r\n|\r|\n)/g,"
"),T},n.Image.prototype.getPalleteValues=function(A){var v,y,T,I,S,E,e,F,M,L,V;if(v=null,y=null,T=n.Image.getValueSafely(this.getTag(A[0],A[1])),T!==null){for(I=T.buffer.byteLength/2,v=[],y=[],S=0;S255||v<0)for(I=255/(y-v),S=v,T=0;T1&&s[0].getTemporalPosition()!==null,T=u>1&&s[0].getTemporalNumber()!==null&&s[0].getTemporalNumber()===u,y&&T)for(I=0;I1||this.isMosaic&&this.images[0].length>1,this.isMultiFrameVolume=!1,this.isMultiFrameTimeseries=!1,this.isImplicitTimeseries=!1,this.isMultiFrame&&(s=this.images[0].getFrameTime()>0,this.isMosaic?this.isMultiFrameTimeseries=!0:s?this.isMultiFrameTimeseries=!0:this.numberOfFramesInFile>1?(this.isMultiFrameTimeseries=!0,this.numberOfFrames=this.images.length):this.isMultiFrameVolume=!0),!this.isMosaic&&this.numberOfFrames<=1){for(S=this.images[0].getImagePosition()||[],f=S.toString(),this.numberOfFrames=0,u=0;u1&&(this.isImplicitTimeseries=!0)}this.sliceDir=this.images[0].getAcquiredSliceDirection(),n.Series.useExplicitOrdering?m=this.images.slice():m=n.Series.orderDicoms(this.images,this.numberOfFrames,this.sliceDir),A=m[0].getImagePositionSliceDir(this.sliceDir),v=m[m.length-1].getImagePositionSliceDir(this.sliceDir),y=v-A,n.Series.useExplicitOrdering?this.sliceSense=!1:this.isMosaic?this.sliceSense=!0:this.isMultiFrame?(T=m[0].getSliceLocationVector(),T!==null?(I=m[0].getOrientation(),I.charAt(2)==="Z"?this.sliceSense=T[0]-T[T.length-1]<0:this.sliceSense=T[0]-T[T.length-1]>0):this.sliceSense=!(A<0)):this.sliceDir===n.Image.SLICE_DIRECTION_SAGITTAL||this.sliceDir===n.Image.SLICE_DIRECTION_CORONAL?y>0?this.sliceSense=!1:this.sliceSense=!0:y>0?this.sliceSense=!0:this.sliceSense=!1,this.imagesOriginalOrder=this.images,this.images=m},n.Series.prototype.concatenateImageData=function(s,u){var f,m,A;this.isMosaic?m=this.getMosaicData(this.images[0],this.images[0].getPixelDataBytes()):m=this.images[0].getPixelDataBytes(),A=this.validatePixelDataLength(this.images[0]),this.images[0].clearPixelData(),f=new Uint8Array(new ArrayBuffer(A*this.images.length)),f.set(new Uint8Array(m,0,A),0),setTimeout(n.Utils.bind(this,function(){this.concatenateNextImageData(f,A,s,1,u)}),0)},n.Series.prototype.concatenateNextImageData=function(s,u,f,m,A){var v,y;m>=this.images.length?(f&&f.drawProgress(1,"Reading DICOM Images"),A(s.buffer)):(f&&f.drawProgress(m/this.images.length,"Reading DICOM Images"),this.isMosaic?v=this.getMosaicData(this.images[m],this.images[m].getPixelDataBytes()):v=this.images[m].getPixelDataBytes(),y=this.validatePixelDataLength(this.images[m]),this.images[m].clearPixelData(),s.set(new Uint8Array(v,0,y),u*m),setTimeout(n.Utils.bind(this,function(){this.concatenateNextImageData(s,u,f,m+1,A)}),0))},n.Series.prototype.validatePixelDataLength=function(s){var u=s.getPixelDataBytes().byteLength,f=s.getCols()*s.getRows();return u%f===0?u:f*s.getNumberOfFrames()*s.getNumberOfSamplesPerPixel()*(s.getBitsAllocated()/8)},n.Series.prototype.getMosaicData=function(s,u){var f,m,A,v,y,T,I,S,E,e,F,M,L,V,B,z,b,W=0;for(I=parseInt(this.images[0].getBitsAllocated()/8),F=this.images[0].getMosaicCols()*this.images[0].getMosaicRows(),M=parseInt(this.images[0].getRows()/this.images[0].getMosaicRows()),L=parseInt(this.images[0].getCols()/this.images[0].getMosaicCols()),f=this.images[0].getCols(),m=this.images[0].getRows(),A=this.images[0].getMosaicRows(),v=this.images[0].getMosaicCols(),y=parseInt(m/A),T=parseInt(f/v),V=new Uint8Array(new ArrayBuffer(F*M*L*I)),B=new Uint8Array(u),S=0;Sn in a?__defProp(a,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[n]=s,__export=(a,n)=>{for(var s in n)__defProp(a,s,{get:n[s],enumerable:!0})},__publicField=(a,n,s)=>(__defNormalProp(a,typeof n!="symbol"?n+"":n,s),s),version$1="0.43.0",_Log=class ci{constructor({name:n="niivue",level:s="info"}={}){__publicField(this,"level"),__publicField(this,"name"),this.name=`${n}`,this.level=s}debug(...n){ci.levels[this.level]>ci.levels.debug||console.debug(`${this.name}-debug`,...n)}info(...n){ci.levels[this.level]>ci.levels.info||console.info(`${this.name}-info`,...n)}warn(...n){ci.levels[this.level]>ci.levels.warn||console.warn(`${this.name}-warn`,...n)}error(...n){ci.levels[this.level]>ci.levels.error||console.error(`${this.name}-error`,...n)}fatal(...n){ci.levels[this.level]>ci.levels.fatal||console.error(`${this.name}-fatal`,...n)}setLogLevel(n){this.level=n}setName(n){this.name=n}};__publicField(_Log,"levels",{debug:0,info:1,warn:2,error:3,fatal:4,silent:1/0});var Log$1=_Log,log$4=new Log$1({name:"niivue",level:"info"}),compileShader=function(a,n,s){const u=a.createShader(a.VERTEX_SHADER);if(u===null)throw new Error("could not create vertex shader");if(a.shaderSource(u,n),a.compileShader(u),!a.getShaderParameter(u,a.COMPILE_STATUS))throw log$4.error(a.getShaderInfoLog(u)),new Error("Vertex shader failed to compile, see console for log");const f=a.createShader(a.FRAGMENT_SHADER);if(f===null)throw new Error("could not create fragment shader");if(a.shaderSource(f,s),a.compileShader(f),!a.getShaderParameter(f,a.COMPILE_STATUS))throw log$4.error(a.getShaderInfoLog(f)),new Error("Fragment shader failed to compile, see console for log");const m=a.createProgram();if(m===null)throw new Error("could not create GL program");if(a.attachShader(m,u),a.attachShader(m,f),a.linkProgram(m),!a.getProgramParameter(m,a.LINK_STATUS))throw log$4.error(a.getProgramInfoLog(m)),new Error("Shader failed to link, see console for log");return m},Shader=class{constructor(a,n,s){__publicField(this,"program"),__publicField(this,"uniforms",{}),__publicField(this,"isMatcap"),this.program=compileShader(a,n,s);const u=/uniform[^;]+[ ](\w+);/g,f=/uniform[^;]+[ ](\w+);/,m=n.match(u),A=s.match(u);m&&m.forEach(v=>{const y=v.match(f);this.uniforms[y[1]]=-1}),A&&A.forEach(v=>{const y=v.match(f);this.uniforms[y[1]]=-1});for(const v in this.uniforms)this.uniforms[v]=a.getUniformLocation(this.program,v)}use(a){a.useProgram(this.program)}},vertRenderShader=`#version 300 es #line 4 layout(location=0) in vec3 pos; layout(location=1) in vec3 texCoords; @@ -1611,7 +1611,7 @@ void main(void) { `);if(!f[0].startsWith("solid"))throw new Error("Not a valid STL file");const m=[];for(let T=1;T=3e3&&E<=3099&&T>580){let L=function(){for(;H"))return me;for(;H");)me+=L();return me},B=function(me,Se=!1){const ve=g.indexOf(me);if(ve<0)return 1;const we=g.indexOf('"',ve)+1,Ne=g.indexOf('"',we),De=g.slice(we,Ne);return Se?De:parseInt(De)},z=0,b=0,W=0,q="",Y=new Uint32Array;const X=new Uint8Array(n);let H=552,g;const J=M[5],re=new Float32Array(s*J);for(;H"));)if(g.includes("")||(g=V()),!g.startsWith("")||!g.endsWith(""))return log$4.warn("Unable to find CIfTI "),re;g=g.slice(15,-16);const we=g.trim().split(/\s+/);we.length4)&&log$4.warn("Not a valid MGH file");const F=v*y*T*I;let M=[];if(F%s!==0)return log$4.warn("Vertices in NIfTI ("+F+") is not a multiple of number of vertices ("+s+")"),M;if(S===3){M=new Float32Array(F);for(let Y=0;Y0)return log$4.warn("unsupported CTABreadFromBinaryV1"),M;if(H=-H,H!==2)return log$4.warn("CTABreadFromBinary: unknown version"),M;const g=f.getInt32(E+=4,e);if(g<0)return log$4.warn("CTABreadFromBinaryV2: nentries was ",g),M;const J=f.getInt32(E+=4,e);E+=J;const re=f.getInt32(E+=4,e);if(re<0)return M;const ae={R:[],G:[],B:[],A:[],I:[],labels:[]};for(let fe=0;fe"))if(A.startsWith(""))for(;f");)A+=m();else for(;f");)A+=m();const z=v("USE");if(z.length>1){z in V?M=V[z]:log$4.warn("Unable to find DEF for "+z);return}const b=y("diffuseColor");if(b.length<3)return;M[0]=Math.round(b[0]*255),M[1]=Math.round(b[1]*255),M[2]=Math.round(b[2]*255);const W=v("DEF");W.length<1||(V[W]=M)}for(;f=0?(I.push(W[J]+Y),I.push(W[X-1]+Y),I.push(W[X-0]+Y),X+=1):(X+=3,J=X-2)}else for(;X=0?(I.push(W[X-2]+Y),I.push(W[X-1]+Y),I.push(W[X-0]+Y),X+=1):X+=3;T=[...T,...q];const H=Math.floor(q.length/3),g=Array(H).fill(M).flat();if(E.length===H*3){let J=0,re=0;for(let ae=0;ae";)m++;if(re=f[m-1]==="/",ae+1=u)break}const fe=new TextDecoder().decode(n.slice(ae+1,m)).trim(),pe=fe.split(" ")[0].trim(),me=m;let Se=m,ve=m;if(f[ae+1]!=="?"&&f[ae+1]!=="!"){const we="";Se=f.indexOf(we,me),ve=Se+we.length-1}return{name:fe,startPos:ae,contentStartPos:me,contentEndPos:Se,endPos:ve}}let v=A();if(!v.name.startsWith("?xml"))throw new Error("readGII: Invalid XML file");for(;!v.name.startsWith("GIFTI")&&v.endPos1;){if(v=A(),v.name.startsWith("Label Key")&&(Y=v.name,g.I.push(X("Key=")),g.R.push(Math.round(255*X("Red=",!0))),g.G.push(Math.round(255*X("Green=",!0))),g.B.push(Math.round(255*X("Blue=",!0))),g.A.push(Math.round(255*X("Alpha",!0))),Y=new TextDecoder().decode(n.slice(v.contentStartPos+1,v.contentEndPos)).trim(),g.labels.push(H(""u"){let ae=function(fe){const pe=atob(fe),me=pe.length,Se=new Uint8Array(me);for(let ve=0;ve1&&(J=cmapper.makeLabelLut(g)),s>0)return{scalars:I,colormapLabel:J,anatomicalStructurePrimary:S};if(y.length>2&&!q&&(V[0]!==0||V[1]!==0||V[2]!==0)){W=Math.floor(y.length/3);let re=0;for(let ae=0;ae1?1:m,this.visible=A,this.meshShaderIndex=0,this.indexBuffer=v.createBuffer(),this.vertexBuffer=v.createBuffer(),this.vao=v.createVertexArray(),v.bindVertexArray(this.vao),v.bindBuffer(v.ELEMENT_ARRAY_BUFFER,this.indexBuffer),v.bindBuffer(v.ARRAY_BUFFER,this.vertexBuffer),v.enableVertexAttribArray(0),v.enableVertexAttribArray(1),this.f32PerVertex!==7?(v.vertexAttribPointer(0,3,v.FLOAT,!1,20,0),v.vertexAttribPointer(1,4,v.BYTE,!0,20,12),v.enableVertexAttribArray(2),v.vertexAttribPointer(2,4,v.UNSIGNED_BYTE,!0,20,16)):(v.vertexAttribPointer(0,3,v.FLOAT,!1,28,0),v.vertexAttribPointer(1,3,v.FLOAT,!1,28,12),v.enableVertexAttribArray(2),v.vertexAttribPointer(2,4,v.UNSIGNED_BYTE,!0,28,24)),v.bindVertexArray(null),this.vaoFiber=v.createVertexArray(),this.offsetPt0=null,this.hasConnectome=!1,this.colormapInvert=!1,this.fiberGroupColormap=null,this.pts=n,this.layers=[],this.type="mesh",f[3]<1){this.rgba255=f,this.fiberLength=2,this.fiberDither=.1,this.fiberColor="Global",this.fiberDecimationStride=1,this.fiberMask=[],this.colormap=y,this.dpg=T,this.dps=I,this.dpv=S,T&&this.initValuesArray(T),I&&this.initValuesArray(I),S&&this.initValuesArray(S),this.offsetPt0=s,this.updateFibers(v),v.bindVertexArray(this.vaoFiber),v.bindBuffer(v.ELEMENT_ARRAY_BUFFER,this.indexBuffer),v.bindBuffer(v.ARRAY_BUFFER,this.vertexBuffer),v.enableVertexAttribArray(0),v.vertexAttribPointer(0,3,v.FLOAT,!1,16,0),v.enableVertexAttribArray(1),v.vertexAttribPointer(1,4,v.UNSIGNED_BYTE,!0,16,12),v.bindVertexArray(null);return}if(y){this.connectome=y,this.hasConnectome=!0;const L=Object.keys(y);for(let V=0,B=L.length;VMath.min(m,A)),f=n[s].vals.reduce((m,A)=>Math.max(m,A));n[s].global_min=u,n[s].global_max=f,n[s].cal_min=u,n[s].cal_max=f}return n}linesToCylinders(n,s,u){function f(H){return fromValues$2(H[0],H[1],H[2])}const m=Math.pow(2,32)-1,A=u.length;let v=0,y=0;for(let H=0;H 1 requires f32PerVertex == 5");const E=new Float32Array(I*S),e=new Uint8Array(E.buffer);let F=0,M=create$1(),L=create$1(),V=create$1();const B=create$2();let z=create$2(),b=0;const W=this.fiberRadius;for(let H=0;H0){const q=parseInt(F.substring(3));q0){const q=parseInt(F.substring(3));q=this.dpg.length||X.A[H]<1||(Y[g]=!0,g*=4,q[g]=X.R[H],q[g+1]=X.G[H],q[g+2]=X.B[H],q[g+3]=255)}V.fill(-1);for(let H=0;H2&&this.fiberRadius>0?this.linesToCylinders(n,A,b):(this.indexCount=b.length,n.bindBuffer(n.ARRAY_BUFFER,this.vertexBuffer),n.bufferData(n.ARRAY_BUFFER,Uint32Array.from(v),n.STATIC_DRAW),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.indexBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,Uint32Array.from(b),n.STATIC_DRAW))}indexNearestXYZmm(n,s,u){const f=this.pts,m=this.pts.length/3;let A=0,v=1/0,y=0;for(let T=0;T0)for(let T=0;TI.cal_max)continue;if(I.outlineBorder===void 0&&(I.outlineBorder=0),I.isAdditiveBlend===void 0&&(I.isAdditiveBlend=!1),I.colormapLabel&&I.colormapLabel.R&&!I.colormapLabel.lut&&(I.colormapLabel=cmapper.makeLabelLut(I.colormapLabel)),I.colormapLabel&&I.colormapLabel.lut){const z=I.colormapLabel.lut,b=Math.floor(z.length/4),W=Math.min(Math.max(I.frame4D,0),I.nFrame4D-1),q=m*W,Y=new Uint8Array(m*4);let X=0;for(let g=0;g0&&(H=NVMeshUtilities.getClusterBoundary(Y,this.tris)),X=0;for(let g=0;g0&&(z=NVMeshUtilities.getClusterBoundary(B,this.tris));let b=0;for(let W=0;W0)for(let T=0;T"u"){const L=new Float32Array([0,0,0,0,0,0]),V=new Uint32Array([0]);I={pts:L,offsetPt0:V},log$4.error("Creating empty tracts")}return m[3]=0,new Ii(I.pts,I.offsetPt0,s,m,f,A,u,"inferno",I.dpg||null,I.dps||null,I.dpv||null)}if(E==="GII")I=NVMeshLoaders.readGII(n);else if(E==="MZ3")I=NVMeshLoaders.readMZ3(n),(I instanceof Float32Array||I.positions===null)&&log$4.warn("MZ3 does not have positions (statistical overlay?)");else if(E==="ASC")I=NVMeshLoaders.readASC(n);else if(E==="DFS")I=NVMeshLoaders.readDFS(n);else if(E==="BYU"||E==="G")I=NVMeshLoaders.readGEO(n);else if(E==="GEO")I=NVMeshLoaders.readGEO(n,!0);else if(E==="ICO"||E==="TRI")I=NVMeshLoaders.readICO(n);else if(E==="OFF")I=NVMeshLoaders.readOFF(n);else if(E==="NV")I=NVMeshLoaders.readNV(n);else if(E==="OBJ")I=NVMeshLoaders.readOBJ(n);else if(E==="PLY")I=NVMeshLoaders.readPLY(n);else if(E==="X3D")I=NVMeshLoaders.readX3D(n);else if(E==="FIB"||E==="VTK"){if(I=NVMeshLoaders.readVTK(n),"offsetPt0"in I)return m[3]=0,new Ii(I.pts,I.offsetPt0,s,m,f,A,u,"inferno")}else E==="SRF"?I=NVMeshLoaders.readSRF(n):E==="STL"?I=NVMeshLoaders.readSTL(n):I=NVMeshLoaders.readFreeSurfer(n);if(I.anatomicalStructurePrimary&&(T=I.anatomicalStructurePrimary),I instanceof Float32Array)throw new Error("fatal: unknown mesh type loaded");if(!I.positions)throw new Error("positions not loaded");if(!I.indices)throw new Error("indices not loaded");if(y=I.positions,v=I.indices,"rgba255"in I&&I.rgba255.length>0&&(m=I.rgba255),"colors"in I&&I.colors&&I.colors.length===y.length){const L=y.length/3;m=new Uint8Array(L*4);let V=0,B=0;for(let z=0;z0&&(NVMeshLoaders.readLayer(s,n,M,f,"gray"),M.updateMesh(u)),M}static async loadLayer(n,s){let u;function f(e){const F=window.atob(e),M=F.length,L=new Uint8Array(M);for(let V=0;V-1&&(m=m.slice(0,m.indexOf("?")));let v=.5;"opacity"in n&&(v=n.opacity);let y="warm";"colormap"in n&&(y=n.colormap);let T="winter";"colormapNegative"in n&&(T=n.colormapNegative);let I=!1;"useNegativeCmap"in n&&(I=n.useNegativeCmap);let S=null;"cal_min"in n&&(S=n.cal_min);let E=null;"cal_max"in n&&(E=n.cal_max),NVMeshLoaders.readLayer(m,u,s,v,y,T,I,S,E)}static async loadFromUrl({url:n="",headers:s={},gl:u,name:f="",opacity:m=1,rgba255:A=[255,255,255,255],visible:v=!0,layers:y=[]}={}){let T=n.split("/");if(f===""){try{T=new URL(n).pathname.split("/")}catch{T=n.split("/")}f=T.slice(-1)[0],f.indexOf("?")>-1&&(f=f.slice(0,f.indexOf("?")))}if(n==="")throw Error("url must not be empty");if(!u)throw Error("gl context is null");const I=await fetch(n,{headers:s});if(!I.ok)throw Error(I.statusText);const S=await I.arrayBuffer(),E=await this.readMesh(S,f,u,m,new Uint8Array(A),v);if(!y||y.length<1)return E;for(let e=0;e{const f=new FileReader;f.onload=()=>{s(f.result)},f.onerror=u,f.readAsArrayBuffer(n)})}static async loadFromFile({file:n,gl:s,name:u="",opacity:f=1,rgba255:m=[255,255,255,255],visible:A=!0,layers:v=[]}={}){if(!n)throw new Error("file must be set");if(!s)throw new Error("rendering context must be set");const y=await Ii.readFileAsync(n),T=Ii.readMesh(y,u,s,f,new Uint8Array(m),A);if(!v||v.length<1)return T;for(let I=0;I>18,y=(S&258048)>>12,T=(S&4032)>>6,I=S&63,s+=u[v]+u[y]+u[T]+u[I];return m===1?(S=n[A],v=(S&252)>>2,y=(S&3)<<4,s+=u[v]+u[y]+"=="):m===2&&(S=n[A]<<8|n[A+1],v=(S&64512)>>10,y=(S&1008)>>4,T=(S&15)<<2,s+=u[v]+u[y]+u[T]+"="),s}static download(n,s,u){const f=document.createElement("a"),m=new Blob([n],{type:u});f.href=URL.createObjectURL(m),f.download=s,f.click()}static readFileAsync(n){return new Promise((s,u)=>{const f=new FileReader;f.onload=()=>{s(f.result)},f.onerror=u,f.readAsArrayBuffer(n)})}static blobToBase64(n){return new Promise(s=>{const u=new FileReader;u.onloadend=()=>s(u.result),u.readAsDataURL(n)})}static decompressBase64String(n){const s=atob(n),u=new ArrayBuffer(s.length),f=new Uint8Array(u);for(let v=0;vn+m*u)}static sph2cartDeg(n,s){const u=-s*(Math.PI/180),f=(n-90)%360*(Math.PI/180),m=[Math.cos(u)*Math.cos(f),Math.cos(u)*Math.sin(f),Math.sin(u)],A=Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2]);return A<=0||(m[0]/=A,m[1]/=A,m[2]/=A),m}static vox2mm(n,s){const u=clone$3(s);transpose$3(u,u);const f=fromValues$1(n[0],n[1],n[2],1);return transformMat4(f,f,u),fromValues$2(f[0],f[1],f[2])}},isPlatformLittleEndian=()=>{const a=new ArrayBuffer(2);return new DataView(a).setInt16(0,256,!0),new Int16Array(a)[0]===256},ImageType=(a=>(a[a.UNKNOWN=0]="UNKNOWN",a[a.NII=1]="NII",a[a.DCM=2]="DCM",a[a.DCM_MANIFEST=3]="DCM_MANIFEST",a[a.MIH=4]="MIH",a[a.MIF=5]="MIF",a[a.NHDR=6]="NHDR",a[a.NRRD=7]="NRRD",a[a.MHD=8]="MHD",a[a.MHA=9]="MHA",a[a.MGH=10]="MGH",a[a.MGZ=11]="MGZ",a[a.V=12]="V",a[a.V16=13]="V16",a[a.VMR=14]="VMR",a[a.HEAD=15]="HEAD",a[a.DCM_FOLDER=16]="DCM_FOLDER",a))(ImageType||{}),NVIMAGE_TYPE=Object.freeze({...ImageType,parse:a=>{let n=0;switch(a.toUpperCase()){case"":case"DCM":n=2;break;case"TXT":n=3;break;case"NII":n=1;break;case"MIH":n=4;break;case"MIF":n=5;break;case"NHDR":n=6;break;case"NRRD":n=7;break;case"MHD":n=8;break;case"MHA":n=9;break;case"MGH":n=10;break;case"MGZ":n=11;break;case"V":n=12;break;case"V16":n=13;break;case"VMR":n=14;break;case"HEAD":n=15;break}return n}}),NVImageFromUrlOptions=(a,n="",s="",u="gray",f=1,m=NaN,A=NaN,v=!0,y=.02,T=!1,I=!1,S="",E=0,e=NVIMAGE_TYPE.UNKNOWN,F=NaN,M=NaN,L=!0,V=!1,B=[])=>({url:a,urlImageData:n,name:s,colormap:u,colorMap:u,opacity:f,cal_min:m,cal_max:A,trustCalMinMax:v,percentileFrac:y,ignoreZeroVoxels:T,useQFormNotSForm:I,colormapNegative:S,imageType:e,cal_minNeg:F,cal_maxNeg:M,colorbarVisible:L,frame4D:E,alphaThreshold:V,colormapLabel:B});function getBestTransform(a,n,s){const u=a;let f=null;if(u){const m={colSize:n[0],rowSize:n[1],sliceSize:n[2]},A=s,v=[u[0],u[1],u[2]],y=[u[3],u[4],u[5]],T=[v[1]*y[2]-v[2]*y[1],v[2]*y[0]-v[0]*y[2],v[0]*y[1]-v[1]*y[0]];f=[[v[0]*m.colSize*-1,y[0]*m.rowSize*-1,T[0]*m.sliceSize*-1,-1*A[0]],[v[1]*m.colSize*-1,y[1]*m.rowSize*-1,T[1]*m.sliceSize*-1,-1*A[1]],[v[2]*m.colSize,y[2]*m.rowSize,T[2]*m.sliceSize,A[2]],[0,0,0,1]]}return f}function str2Buffer(a){const n=[];for(let s=0;s=v)break;let E=!0;for(let e=0;e<3;++e)f[e]>u[e]&&(E=!1),m[e]{}),__publicField(this,"onOpacityChange",()=>{}),__publicField(this,"mm000"),__publicField(this,"mm100"),__publicField(this,"mm010"),__publicField(this,"mm001"),__publicField(this,"cal_min"),__publicField(this,"cal_max"),__publicField(this,"robust_min"),__publicField(this,"robust_max"),__publicField(this,"global_min"),__publicField(this,"global_max"),__publicField(this,"urlImgData"),__publicField(this,"isManifest"),__publicField(this,"limitFrames4D"),this.name=s,this.id=v4(),this._colormap=u,this._opacity=f>1?1:f,this.percentileFrac=T,this.ignoreZeroVoxels=I,this.trustCalMinMax=y,this.colormapNegative=E,this.colormapLabel=B,this.frame4D=e,this.cal_minNeg=M,this.cal_maxNeg=L,this.colorbarVisible=V,this.useQFormNotSForm=S,!n)return;const z=/(?:\.([^.]+))?$/;let b=z.exec(s)[1]||"";b=b.toUpperCase(),b==="GZ"&&(b=z.exec(s.slice(0,-3))[1],b=b.toUpperCase());let W=null;switch(F===NVIMAGE_TYPE.UNKNOWN&&(F=NVIMAGE_TYPE.parse(b)),this.imageType=F,F){case NVIMAGE_TYPE.DCM_FOLDER:case NVIMAGE_TYPE.DCM_MANIFEST:case NVIMAGE_TYPE.DCM:W=this.readDICOM(n);break;case NVIMAGE_TYPE.MIH:case NVIMAGE_TYPE.MIF:W=this.readMIF(n,m);break;case NVIMAGE_TYPE.NHDR:case NVIMAGE_TYPE.NRRD:W=this.readNRRD(n,m);break;case NVIMAGE_TYPE.MHD:case NVIMAGE_TYPE.MHA:W=this.readMHA(n,m);break;case NVIMAGE_TYPE.MGH:case NVIMAGE_TYPE.MGZ:W=this.readMGH(n);break;case NVIMAGE_TYPE.V:W=this.readECAT(n);break;case NVIMAGE_TYPE.V16:W=this.readV16(n);break;case NVIMAGE_TYPE.VMR:W=this.readVMR(n);break;case NVIMAGE_TYPE.HEAD:W=this.readHEAD(n,m);break;case NVIMAGE_TYPE.NII:this.hdr=nifti.readHeader(n),this.hdr!==null&&(this.hdr.cal_min===0&&this.hdr.cal_max===255&&(this.hdr.cal_max=0),nifti.isCompressed(n)?W=nifti.readImage(this.hdr,nifti.decompress(n)):W=nifti.readImage(this.hdr,n));break;default:throw new Error("Image type not supported")}if(this.hdr&&typeof this.hdr.magic=="number"&&(this.hdr.magic="n+1"),this.nFrame4D=1,this.hdr)for(let H=4;H<7;H++)this.hdr.dims[H]>1&&(this.nFrame4D*=this.hdr.dims[H]);if(this.frame4D=Math.min(this.frame4D,this.nFrame4D-1),this.nTotalFrame4D=this.nFrame4D,!this.hdr||!W)return;this.nVox3D=this.hdr.dims[1]*this.hdr.dims[2]*this.hdr.dims[3];const q=this.nVox3D*(this.hdr.numBitsPerVoxel/8),Y=W.byteLength/q;if(Y!==this.nFrame4D&&(Y>0&&Y*q===W.byteLength?log$4.debug("Loading the first "+Y+" of "+this.nFrame4D+" volumes"):log$4.warn("This header does not match voxel data",this.hdr,W.byteLength),this.nFrame4D=Y),(this.hdr.intent_code===1007||this.hdr.intent_code===2003)&&this.nFrame4D===3&&this.hdr.datatypeCode===16){const g=new Float32Array(W).slice();this.hdr.datatypeCode=2304,this.nFrame4D=1;for(let pe=4;pe<7;pe++)this.hdr.dims[pe]=1;this.hdr.dims[0]=3,W=new Uint8Array(this.nVox3D*4);let J=1;for(let pe=0;pe0)*1,Ne=+(Se>0)*2,De=+(ve>0)*4;let je=248+we+Ne+De;Math.abs(me)+Math.abs(Se)+Math.abs(ve)<.1&&(je=0),W[fe+3]=je,fe+=4}}(this.hdr.pixDims[1]===0||this.hdr.pixDims[2]===0||this.hdr.pixDims[3]===0)&&log$4.error("pixDims not plausible",this.hdr),(isNaN(this.hdr.scl_slope)||this.hdr.scl_slope===0)&&(this.hdr.scl_slope=1),isNaN(this.hdr.scl_inter)&&(this.hdr.scl_inter=0);let X=isAffineOK(this.hdr.affine);if(S||!X||this.hdr.qform_code>this.hdr.sform_code){log$4.debug("spatial transform based on QForm");const H=this.hdr.quatern_b,g=this.hdr.quatern_c,J=this.hdr.quatern_d,re=Math.sqrt(1-(Math.pow(H,2)+Math.pow(g,2)+Math.pow(J,2))),ae=this.hdr.pixDims[0]===0?1:this.hdr.pixDims[0],fe=[[re*re+H*H-g*g-J*J,2*H*g-2*re*J,2*H*J+2*re*g],[2*H*g+2*re*J,re*re+g*g-H*H-J*J,2*g*J-2*re*H],[2*H*J-2*re*g,2*g*J+2*re*H,re*re+J*J-g*g-H*H]],pe=this.hdr.affine;for(let me=0;me<3;me+=1)for(let Se=0;Se<3;Se+=1)pe[me][Se]=fe[me][Se]*this.hdr.pixDims[Se+1],Se===2&&(pe[me][Se]*=ae);pe[0][3]=this.hdr.qoffset_x,pe[1][3]=this.hdr.qoffset_y,pe[2][3]=this.hdr.qoffset_z,this.hdr.affine=pe}if(X=isAffineOK(this.hdr.affine),!X){log$4.debug("Defective NIfTI: spatial transform does not make sense");let H=this.hdr.pixDims[1],g=this.hdr.pixDims[2],J=this.hdr.pixDims[3];(isNaN(H)||H===0)&&(H=1),(isNaN(g)||g===0)&&(g=1),(isNaN(J)||J===0)&&(J=1),this.hdr.pixDims[1]=H,this.hdr.pixDims[2]=g,this.hdr.pixDims[3]=J;const re=[[H,0,0,0],[0,g,0,0],[0,0,J,0],[0,0,0,1]];this.hdr.affine=re}if(this.hdr.datatypeCode!==128&&this.hdr.datatypeCode!==2304&&this.hdr.littleEndian!==isPlatformLittleEndian()&&this.hdr.numBitsPerVoxel>8){if(this.hdr.numBitsPerVoxel===16){const H=new Uint16Array(W);for(let g=0;g>8&255)<<16>>16}}else if(this.hdr.numBitsPerVoxel===32){const H=new Uint32Array(W);for(let g=0;g>8&65280|J>>24&255}}else if(this.hdr.numBitsPerVoxel===64){const H=this.hdr.numBitsPerVoxel/8,g=new Uint8Array(W);for(let J=0;J.01?log$4.warn("Warning voxels not aligned with world space: "+I+` degrees from plumb. `):I=0,I}calculateOblique(){if(!this.matRAS)throw new Error("matRAS not defined");if(this.pixDimsRAS===void 0)throw new Error("pixDimsRAS not defined");if(!this.dimsRAS)throw new Error("dimsRAS not defined");this.oblique_angle=this.computeObliqueAngle(this.matRAS);const n=this.vox2mm([0,0,0],this.matRAS),s=this.vox2mm([1/this.pixDimsRAS[1],0,0],this.matRAS),u=this.vox2mm([0,1/this.pixDimsRAS[2],0],this.matRAS),f=this.vox2mm([0,0,1/this.pixDimsRAS[3]],this.matRAS);subtract$1(s,s,n),subtract$1(u,u,n),subtract$1(f,f,n);const m=fromValues$3(s[0],s[1],s[2],0,u[0],u[1],u[2],0,f[0],f[1],f[2],0,0,0,0,1);this.obliqueRAS=clone$3(m);const A=Math.abs(90-angle(s,u)*(180/Math.PI)),v=Math.abs(90-angle(s,f)*(180/Math.PI)),y=Math.abs(90-angle(u,f)*(180/Math.PI));this.maxShearDeg=Math.max(Math.max(A,v),y),this.maxShearDeg>.1&&log$4.warn("Warning: voxels are rhomboidal, maximum shear is %f degrees.",this.maxShearDeg);const T=fromValues$1(this.dimsRAS[1],this.dimsRAS[2],this.dimsRAS[3],1),I=clone$3(this.matRAS);transpose$3(I,I);const S=fromValues$1(-.5,-.5,-.5,0);translate(I,I,fromValues$2(S[0],S[1],S[2])),I[0]*=T[0],I[1]*=T[0],I[2]*=T[0],I[4]*=T[1],I[5]*=T[1],I[6]*=T[1],I[8]*=T[2],I[9]*=T[2],I[10]*=T[2],this.frac2mm=clone$3(I);const E=this.pixDimsRAS[1],e=this.pixDimsRAS[2],F=this.pixDimsRAS[3],M=clone$3(I);M[0]=E*T[0],M[1]=0,M[2]=0,M[4]=0,M[5]=e*T[1],M[6]=0,M[8]=0,M[9]=0,M[10]=F*T[2];const L=this.mm2vox([0,0,0],!0);M[12]=(-L[0]-.5)*E,M[13]=(-L[1]-.5)*e,M[14]=(-L[2]-.5)*F,this.frac2mmOrtho=clone$3(M),this.extentsMinOrtho=[M[12],M[13],M[14]],this.extentsMaxOrtho=[M[0]+M[12],M[5]+M[13],M[10]+M[14]],this.mm2ortho=create$3(),invert(this.mm2ortho,m)}THD_daxes_to_NIFTI(n,s,u){const f=this.hdr;if(f===null)throw new Error("HDR is not set");f.sform_code=2;const m="xxyyzzg";let A=-1,v=-1,y=-1;const T=["x","y","z"];T[0]=m[u[0]],T[1]=m[u[1]],T[2]=m[u[2]];const I=n.slice(0,3),S=s.slice(0,3);for(let E=0;E<3;E++)T[E]==="x"?A=E:T[E]==="y"?v=E:y=E;A<0||v<0||y<0||A===v||A===y||v===y||(f.pixDims[1]=Math.abs(I[0]),f.pixDims[2]=Math.abs(I[1]),f.pixDims[3]=Math.abs(I[2]),f.affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],f.affine[0][A]=-I[A],f.affine[1][v]=-I[v],f.affine[2][y]=I[y],f.affine[0][3]=-S[A],f.affine[1][3]=-S[v],f.affine[2][3]=S[y])}SetPixDimFromSForm(){if(!this.hdr)throw new Error("hdr not defined");const n=this.hdr.affine,s=fromValues$3(n[0][0],n[0][1],n[0][2],n[0][3],n[1][0],n[1][1],n[1][2],n[1][3],n[2][0],n[2][1],n[2][2],n[2][3],n[3][0],n[3][1],n[3][2],n[3][3]),u=this.vox2mm([0,0,0],s),f=this.vox2mm([1,0,0],s);subtract$1(f,f,u);const m=this.vox2mm([0,1,0],s);subtract$1(m,m,u);const A=this.vox2mm([0,0,1],s);subtract$1(A,A,u),this.hdr.pixDims[1]=length$1(f),this.hdr.pixDims[2]=length$1(m),this.hdr.pixDims[3]=length$1(A)}readDICOM(n){if(this.series=new daikon.Series,Array.isArray(n))for(let S=0;S1&&(s.dims[3]>1&&log$4.debug("To Do: multiple slices per file and multiple files (XA30 DWI)"),s.dims[3]=this.series.images.length);const u=this.series.images[0].getPixelSpacing();if(s.pixDims[1]=u[0],s.pixDims[2]=u[1],this.series.images.length>1){const S=fromValues$2(...this.series.images[0].getImagePosition()),E=fromValues$2(...this.series.images[1].getImagePosition()),e=fromValues$2(0,0,0);subtract$1(e,S,E),s.pixDims[3]=length$1(e)}else s.pixDims[3]=this.series.images[0].getSliceThickness();s.pixDims[4]=this.series.images[0].getTR()/1e3;const f=this.series.images[0].getDataType(),m=this.series.images[0].getBitsAllocated();s.numBitsPerVoxel=m,this.hdr.littleEndian=this.series.images[0].littleEndian,m===8&&f===2?s.datatypeCode=256:m===8&&f===3?s.datatypeCode=2:m===16&&f===2?s.datatypeCode=4:m===16&&f===3?s.datatypeCode=512:m===32&&f===2?s.datatypeCode=8:m===32&&f===3?s.datatypeCode=768:m===32&&f===4?s.datatypeCode=16:m===64&&f===4?s.datatypeCode=64:m===1?s.datatypeCode=1:log$4.warn("Unsupported DICOM format: "+f+" "+m);const A=s.pixDims.slice(1,4),v=getBestTransform(this.series.images[0].getImageDirections(),A,this.series.images[0].getImagePosition());v&&(s.sform_code=1,s.affine=[[v[0][0],v[0][1],v[0][2],v[0][3]],[v[1][0],v[1][1],v[1][2],v[1][3]],[v[2][0],v[2][1],v[2][2],v[2][3]],[0,0,0,1]]);let y,T=this.series.validatePixelDataLength(this.series.images[0]);const I=new Uint8Array(new ArrayBuffer(T*this.series.images.length));for(let S=0;S14)throw new Error("Not a valid ECAT file");let A=512,v=0;const y=[];let T=new Float32Array;for(;;){const I=u.getInt32(A,!1),S=u.getInt32(A+12,!1);if(I+S!==31)break;let E=A+20,e=0,F=0;for(;e<31&&(F=u.getInt32(E,!1),E+=16,F!==0);){e++;let M=F*512;const L=M-512,V=u.getUint16(L,!1);s.dims[1]=u.getUint16(L+4,!1),s.dims[2]=u.getUint16(L+6,!1),s.dims[3]=u.getUint16(L+8,!1);const B=u.getFloat32(L+26,!1);s.pixDims[1]=u.getFloat32(L+34,!1)*10,s.pixDims[2]=u.getFloat32(L+38,!1)*10,s.pixDims[3]=u.getFloat32(L+42,!1)*10,s.pixDims[4]=u.getUint32(L+46,!1)/1e3,y.push(s.pixDims[4]);const z=s.dims[1]*s.dims[2]*s.dims[3],b=new Float32Array(z);if(V===1)for(let q=0;q1){s.dims[0]=4;let I=!1;for(let S=0;S=4){let A=8+m;const v=u.getUint32(A+88,!0);if(A=A+92,v>0){const y=n.byteLength;for(let T=0;T4)&&log$4.warn("Not a valid MGH file"),I===0?(s.numBitsPerVoxel=8,s.datatypeCode=2):I===4?(s.numBitsPerVoxel=16,s.datatypeCode=4):I===1?(s.numBitsPerVoxel=32,s.datatypeCode=8):I===3&&(s.numBitsPerVoxel=32,s.datatypeCode=16),s.dims[1]=A,s.dims[2]=v,s.dims[3]=y,s.dims[4]=T,T>1&&(s.dims[0]=4),s.pixDims[1]=S,s.pixDims[2]=E,s.pixDims[3]=e,s.vox_offset=284,s.sform_code=1;const g=fromValues$3(F*s.pixDims[1],V*s.pixDims[2],b*s.pixDims[3],0,M*s.pixDims[1],B*s.pixDims[2],W*s.pixDims[3],0,L*s.pixDims[1],z*s.pixDims[2],q*s.pixDims[3],0,0,0,0,1),J=[s.dims[1]/2,s.dims[2]/2,s.dims[3]/2,1],re=[0,0,0,0];for(let fe=0;fe<3;fe++){re[fe]=0;for(let pe=0;pe<3;pe++)re[fe]=re[fe]+g[pe+fe*4]*J[pe]}s.affine=[[g[0],g[1],g[2],Y-re[0]],[g[4],g[5],g[6],X-re[1]],[g[8],g[9],g[10],H-re[2]],[0,0,0,1]];const ae=s.dims[1]*s.dims[2]*s.dims[3]*s.dims[4]*(s.numBitsPerVoxel/8);return u.slice(s.vox_offset,s.vox_offset+ae)}readHEAD(n,s){this.hdr=new nifti.NIFTI1;const u=this.hdr;u.dims[0]=3,u.pixDims=[1,1,1,1,1,0,0,0];let f=[0,0,0],m=[0,0,0],A=[1,1,1];const y=new TextDecoder().decode(n).split(/\r?\n/),T=(n.byteLength+8)%16,I=n.byteLength+(16-T);log$4.debug(n.byteLength,"len",I);const S=new Uint8Array(I);S.fill(0),S.set(new Uint8Array(n));const E=new nifti.NIFTIEXTENSION(I+8,42,S,!0);u.addExtension(E),u.extensionCode=42,u.extensionFlag[0]=1,u.extensionSize=I+8;const e=y.length;let F=0,M=!1;for(;F2&&(M=M.slice(2)),y.startsWith("BinaryDataByteOrderMSB")&&M[0].includes("False")&&(T.littleEndian=!0),y.startsWith("BinaryDataByteOrderMSB")&&M[0].includes("True")&&(T.littleEndian=!1),y.startsWith("CompressedData")&&M[0].includes("True")&&(I=!0),y.startsWith("TransformMatrix"))for(let L=0;L<9;L++)E[L]=parseFloat(M[L]);if(y.startsWith("Offset"))for(let L=0;L2||J.length!==4)break;u.affine[I][0]=parseFloat(J[0]),u.affine[I][1]=parseFloat(J[1]),u.affine[I][2]=parseFloat(J[2]),u.affine[I][3]=parseFloat(J[3]),I++;break;case"RepetitionTime":S=parseFloat(J[0]);break;case"file":E=!J[0].startsWith(". "),E||(J=J[0].split(" "),u.vox_offset=parseInt(J[1]));break}}const e=u.dims[0];e>5&&log$4.warn("reader only designed for a maximum of 5 dimensions (XYZTD)");let F=1;for(let J=0;J0&&(u.pixDims[4]=S),E&&!s&&log$4.warn("MIH header provided without paired image data");let M;s&&E?M=s.slice(0):M=n.slice(u.vox_offset,u.vox_offset+F*(u.numBitsPerVoxel/8)),T.length!==u.dims[0]&&log$4.warn("dims does not match layout");let L=1;const V=[1,1,1,1,1],B=[!1,!1,!1,!1,!1];for(let J=0;Ju[0]&&(f[0]=2),u[6]>u[0]&&u[6]>u[3]&&(f[0]=3),f[1]=1,f[0]===1?u[4]>u[7]?f[1]=2:f[1]=3:f[0]===2?u[1]>u[7]?f[1]=1:f[1]=3:u[1]>u[4]?f[1]=1:f[1]=2,f[2]=6-f[1]-f[0];let m=[1,2,3];m[f[0]-1]=1,m[f[1]-1]=2,m[f[2]-1]=3;let A=fromValues$3(n[0][0],n[0][1],n[0][2],n[0][3],n[1][0],n[1][1],n[1][2],n[1][3],n[2][0],n[2][1],n[2][2],n[2][3],0,0,0,1);this.mm000=this.vox2mm([-.5,-.5,-.5],A),this.mm100=this.vox2mm([s.dims[1]-.5,-.5,-.5],A),this.mm010=this.vox2mm([-.5,s.dims[2]-.5,-.5],A),this.mm001=this.vox2mm([-.5,-.5,s.dims[3]-.5],A);const v=create$3();copy$1(v,A);for(let L=0;L<3;L++)for(let V=0;V<3;V++)v[L*4+V]=A[L*4+m[V]-1];const y=[0,0,0];v[0]<0&&(y[0]=1),v[5]<0&&(y[1]=1),v[10]<0&&(y[2]=1),this.dimsRAS=[s.dims[0],s.dims[m[0]],s.dims[m[1]],s.dims[m[2]]],this.pixDimsRAS=[s.pixDims[0],s.pixDims[m[0]],s.pixDims[m[1]],s.pixDims[m[2]]],this.permRAS=m.slice();for(let L=0;L<3;L++)y[L]===1&&(this.permRAS[L]=-this.permRAS[L]);if(this.arrayEquals(m,[1,2,3])&&this.arrayEquals(y,[0,0,0])){this.toRAS=create$3(),this.matRAS=clone$3(A),this.calculateOblique(),this.img2RASstep=[1,this.dimsRAS[1],this.dimsRAS[1]*this.dimsRAS[2]],this.img2RASstart=[0,0,0];return}identity$2(A),A[0+0*4]=1-y[0]*2,A[1+1*4]=1-y[1]*2,A[2+2*4]=1-y[2]*2,A[3+0*4]=(s.dims[m[0]]-1)*y[0],A[3+1*4]=(s.dims[m[1]]-1)*y[1],A[3+2*4]=(s.dims[m[2]]-1)*y[2];const T=create$3();invert(T,A),multiply$2(T,T,v),this.matRAS=clone$3(T),A=fromValues$3(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1),A[m[0]-1+0*4]=-y[0]*2+1,A[m[1]-1+1*4]=-y[1]*2+1,A[m[2]-1+2*4]=-y[2]*2+1,A[3+0*4]=y[0],A[3+1*4]=y[1],A[3+2*4]=y[2],this.toRAS=clone$3(A),A[3]=0,A[7]=0,A[11]=0,A[12]=0,(this.permRAS[0]===-1||this.permRAS[1]===-1||this.permRAS[2]===-1)&&(A[12]=s.dims[1]-1),A[13]=0,(this.permRAS[0]===-2||this.permRAS[1]===-2||this.permRAS[2]===-2)&&(A[13]=s.dims[2]-1),A[14]=0,(this.permRAS[0]===-3||this.permRAS[1]===-3||this.permRAS[2]===-3)&&(A[14]=s.dims[3]-1),this.toRASvox=clone$3(A),log$4.debug(this.hdr.dims),log$4.debug(this.dimsRAS);const I=this.hdr;m=this.permRAS;const S=[Math.abs(m[0]),Math.abs(m[1]),Math.abs(m[2])],E=[I.dims[S[0]],I.dims[S[1]],I.dims[S[2]]],e=[1,I.dims[1],I.dims[1]*I.dims[2]],F=[e[S[0]-1],e[S[1]-1],e[S[2]-1]],M=[0,0,0];for(let L=0;L<3;L++)m[L]<0&&(M[L]=F[L]*(E[L]-1),F[L]=-F[L]);this.img2RASstep=F,this.img2RASstart=M,this.calculateOblique()}img2RAS(){if(!this.permRAS)throw new Error("permRAS undefined");if(!this.img)throw new Error("img undefined");if(!this.hdr)throw new Error("hdr undefined");const n=this.permRAS.slice();if(n[0]===1&&n[1]===2&&n[2]===3)return this.img;const s=this.hdr,u=this.img.slice(0,s.dims[1]*s.dims[1]*s.dims[2]*s.dims[3]),f=[Math.abs(n[0]),Math.abs(n[1]),Math.abs(n[2])],m=[s.dims[f[0]],s.dims[f[1]],s.dims[f[2]]],A=[1,s.dims[1],s.dims[1]*s.dims[2]],v=[A[f[0]-1],A[f[1]-1],A[f[2]-1]],y=[0,0,0];for(let I=0;I<3;I++)n[I]<0&&(y[I]=v[I]*(m[I]-1),v[I]=-v[I]);let T=0;for(let I=0;Iu===s[f])}setColormap(n){this._colormap=n,this.calMinMax(),this.onColormapChange&&this.onColormapChange(this)}setColormapLabel(n){this.colormapLabel=cmapper.makeLabelLut(n)}async setColormapLabelFromUrl(n){this.colormapLabel=await cmapper.makeLabelLutFromUrl(n)}get colormap(){return this._colormap}get colorMap(){return this._colormap}set colormap(n){this.setColormap(n)}set colorMap(n){this.setColormap(n)}get opacity(){return this._opacity}set opacity(n){this._opacity=n,this.onOpacityChange&&this.onOpacityChange(this)}calMinMax(){if(!this.hdr)throw new Error("hdr undefined");if(!this.img)throw new Error("img undefined");let n=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,u=0,f=0;const m=this.img.length,A=this.img.constructor!==Float64Array&&this.img.constructor!==Float32Array&&this.ignoreZeroVoxels;if(A)for(let Y=0;Ythis.hdr.cal_min)return this.cal_min=this.hdr.cal_min,this.cal_max=this.hdr.cal_max,this.robust_min=this.cal_min,this.robust_max=this.cal_max,this.global_min=v,this.global_max=y,[this.hdr.cal_min,this.hdr.cal_max,this.hdr.cal_min,this.hdr.cal_max];if(I!==S)return this.cal_min=I,this.cal_max=S,this.robust_min=this.cal_min,this.robust_max=this.cal_max,[I,S,I,S];const E=100*u/m;let e=!1;E>60&&!this.ignoreZeroVoxels&&(log$4.warn(`${Math.round(E)}% of voxels are zero: ignoring zeros for cal_max`),e=!0,this.ignoreZeroVoxels=!0),this.ignoreZeroVoxels||(u=0),u+=f;const F=Math.round((m-u)*this.percentileFrac);if(F<1||n===s)return log$4.debug("no variability in image intensity?"),this.cal_min=v,this.cal_max=y,this.robust_min=this.cal_min,this.robust_max=this.cal_max,this.global_min=v,this.global_max=y,[v,y,v,y];const M=1001,L=(M-1)/(s-n),V=new Array(M);for(let Y=0;Y0&&(z--,V[z]>0&&(Y=0)),Y!==0&&b0&&(Y=0)),z===0&&b===M-1&&(Y=0)}let W=this.intensityRaw2Scaled(z/L+n),q=this.intensityRaw2Scaled(b/L+n);return this.hdr.cal_min=v&&this.hdr.cal_max<=y&&(W=this.hdr.cal_min,q=this.hdr.cal_max),e&&(W=Math.min(W,0)),this.cal_min=W,this.cal_max=q,this.robust_min=this.cal_min,this.robust_max=this.cal_max,this.global_min=v,this.global_max=y,[W,q,v,y]}intensityRaw2Scaled(n){if(!this.hdr)throw new Error("hdr undefined");return this.hdr.scl_slope===0&&(this.hdr.scl_slope=1),n*this.hdr.scl_slope+this.hdr.scl_inter}intensityScaled2Raw(n){if(!this.hdr)throw new Error("hdr undefined");return this.hdr.scl_slope===0&&(this.hdr.scl_slope=1),(n-this.hdr.scl_inter)/this.hdr.scl_slope}saveToUint8Array(n,s=null){if(!this.hdr)throw new Error("hdr undefined");if(!this.img)throw new Error("img undefined");const u=s!==null,f=hdrToArrayBuffer(this.hdr,u),m=new Uint8Array(4);let A=new Uint8Array(this.img.buffer);u&&(A=new Uint8Array(s.buffer));const v=new Uint8Array(f.length+m.length+A.length);v.set(f),v.set(m,f.length),v.set(A,f.length+m.length);let y=null;return n.endsWith(".gz")?y=gzipSync$1(v,{filename:n,mtime:Date.now(),level:6}):y=v,y}saveToDisk(n="",s=null){const u=this.saveToUint8Array(n,s);if(n==="")return log$4.debug("saveToDisk: empty file name, returning data as Uint8Array rather than triggering download"),u;const f=new Blob([u.buffer],{type:"application/octet-stream"}),m=URL.createObjectURL(f),A=document.createElement("a");return A.setAttribute("href",m),A.setAttribute("download",n),A.style.visibility="hidden",document.body.appendChild(A),A.click(),document.body.removeChild(A),u}static async fetchDicomData(n,s={}){if(n==="")throw Error("url must not be empty");let f=/^(?:[a-z+]+:)?\/\//i.test(n)?n:new URL(n,window.location.href);/(?:.([^.]+))?$/.exec(f.pathname)||(f=new URL("niivue-manifest.txt",n));let v=await fetch(f,{headers:s});if(!v.ok)throw Error(v.statusText);const T=(await v.text()).split(` -`),S=/(.*\/).*/.exec(f)[0],E=[];for(const e of T){const F=new URL(e,S);if(v=await fetch(F,{headers:s}),!v.ok)throw Error(v.statusText);const M=await v.arrayBuffer();E.push(M)}return E}static async fetchPartial(n,s,u={}){try{return await fetch(n,{headers:{range:`bytes=0-'${s}`,stream:"true",...u}})}catch(f){return log$4.error(f),log$4.error("fetchPartial failed, trying again without range header"),await fetch(n,{headers:u})}}static async loadFromUrl({url:n="",urlImgData:s="",headers:u={},name:f="",colormap:m="gray",opacity:A=1,cal_min:v=NaN,cal_max:y=NaN,trustCalMinMax:T=!0,percentileFrac:I=.02,ignoreZeroVoxels:S=!1,useQFormNotSForm:E=!1,colormapNegative:e="",frame4D:F=0,isManifest:M=!1,limitFrames4D:L=NaN,imageType:V=NVIMAGE_TYPE.UNKNOWN,colorbarVisible:B=!0}={}){if(n==="")throw Error("url must not be empty");let z=null,b=null;if(n instanceof Uint8Array&&(n=n.buffer),n instanceof ArrayBuffer){b=n,n="array.nii";const H=new Uint8Array(b);H[0]===31&&H[1]===139&&(n="array.nii.gz")}if(!isNaN(L)){let H=await this.fetchPartial(n,512,u);b=await H.arrayBuffer();let g=new Uint8Array(b),J=!1;g[0]===31&&g[1]===139&&(J=!0,new Decompress$1(fe=>{g=fe}).push(g),b=g.buffer);let re=g[0]===92&&g[1]===1;if(re||(re=g[1]===92&&g[0]===1),!re)b=null;else{const ae=nifti.readHeader(b);if(ae===null)throw new Error("could not read nifti header");const fe=ae.numBitsPerVoxel/8;let pe=1;for(let we=1;we<4;we++)ae.dims[we]>1&&(pe*=ae.dims[we]);let me=1;for(let we=4;we<7;we++)ae.dims[we]>1&&(me*=ae.dims[we]);const Se=Math.max(Math.min(L,me),1),ve=ae.vox_offset+Se*pe*fe;if(b.byteLength{we=De}).push(we),b=we.buffer}b.byteLength-1&&(f=f.slice(0,f.indexOf("?")))}let X=null;if(s.length>0){let H=await fetch(s,{headers:u});H.status===404&&s.lastIndexOf("BRIK")!==-1&&(H=await fetch(s+".gz",{headers:u})),X=await H.arrayBuffer()}if(!b)throw new Error("Unable to load buffer properly from volume");return z=new Zi(b,f,m,A,X,v,y,T,I,S,E,e,F,V),z.url=n,z.colorbarVisible=B,z}static readFileAsync(n,s=NaN){return new Promise((u,f)=>{const m=new FileReader;m.onload=()=>{n.name.lastIndexOf("gz")!==-1&&isNaN(s)?u(nifti.decompress(m.result)):u(m.result)},m.onerror=f,isNaN(s)?m.readAsArrayBuffer(n):m.readAsArrayBuffer(n.slice(0,s))})}static async loadFromFile({file:n,name:s="",colormap:u="gray",opacity:f=1,urlImgData:m=null,cal_min:A=NaN,cal_max:v=NaN,trustCalMinMax:y=!0,percentileFrac:T=.02,ignoreZeroVoxels:I=!1,useQFormNotSForm:S=!1,colormapNegative:E="",frame4D:e=0,limitFrames4D:F=NaN,imageType:M=NVIMAGE_TYPE.UNKNOWN}){let L=null,V=[];try{if(Array.isArray(n))for(let z=0;z{z=Y}).push(z),V=z.buffer);let W=z[0]===92&&z[1]===1;if(W||(W=z[1]===92&&z[0]===1),!W)V=await this.readFileAsync(n);else{const q=nifti.readHeader(V);if(!q)throw new Error("could not read nifti header");const Y=q.numBitsPerVoxel/8;let X=1;for(let re=1;re<4;re++)q.dims[re]>1&&(X*=q.dims[re]);let H=1;for(let re=4;re<7;re++)q.dims[re]>1&&(H*=q.dims[re]);const g=Math.max(Math.min(F,H),1),J=q.vox_offset+g*X*Y;if(V.byteLength{re=fe}).push(re),V=re.buffer}if(V.byteLength"u")return m;if(!s){const v=clone$3(this.frac2mmOrtho);return invert(v,v),transformMat4(u,u,v),m[0]=u[0],m[1]=u[1],m[2]=u[2],m}if(f[1]<1||f[2]<1||f[3]<1)return m;const A=clone$3(this.matRAS);return invert(A,A),transpose$3(A,A),transformMat4(u,u,A),m[0]=(u[0]+.5)/f[1],m[1]=(u[1]+.5)/f[2],m[2]=(u[2]+.5)/f[3],m}},DRAG_MODE=(a=>(a[a.none=0]="none",a[a.contrast=1]="contrast",a[a.measurement=2]="measurement",a[a.pan=3]="pan",a[a.slicer3D=4]="slicer3D",a[a.callbackOnly=5]="callbackOnly",a))(DRAG_MODE||{}),DEFAULT_OPTIONS={textHeight:.06,colorbarHeight:.05,crosshairWidth:1,crosshairGap:0,rulerWidth:4,show3Dcrosshair:!1,backColor:[0,0,0,1],crosshairColor:[1,0,0,1],fontColor:[.5,.5,.5,1],selectionBoxColor:[1,1,1,.5],clipPlaneColor:[.7,0,.7,.5],rulerColor:[1,0,0,.8],colorbarMargin:.05,trustCalMinMax:!0,clipPlaneHotKey:"KeyC",viewModeHotKey:"KeyV",doubleTouchTimeout:500,longTouchTimeout:1e3,keyDebounceTime:50,isNearestInterpolation:!1,isResizeCanvas:!0,atlasOutline:0,isRuler:!1,isColorbar:!1,isOrientCube:!1,multiplanarPadPixels:0,multiplanarForceRender:!1,isRadiologicalConvention:!1,meshThicknessOn2D:1/0,dragMode:1,yoke3Dto2DZoom:!1,isDepthPickMesh:!1,isCornerOrientationText:!1,sagittalNoseLeft:!1,isSliceMM:!1,isV1SliceShader:!1,isHighResolutionCapable:!0,logLevel:"info",loadingText:"waiting for images...",isForceMouseClickToVoxelCenters:!1,dragAndDropEnabled:!0,drawingEnabled:!1,penValue:1,floodFillNeighbors:6,isFilledPen:!1,thumbnail:"",maxDrawUndoBitmaps:8,sliceType:3,meshXRay:0,isAntiAlias:null,limitFrames4D:NaN,isAdditiveBlend:!1,showLegend:!0,legendBackgroundColor:[.3,.3,.3,.5],legendTextColor:[1,1,1,1],multiplanarLayout:0,renderOverlayBlend:1},NVDocument=class Ji{constructor(){__publicField(this,"data",{title:"Untitled document",imageOptionsArray:[],meshOptionsArray:[],opts:{...DEFAULT_OPTIONS},previewImageDataURL:"",labels:[],encodedImageBlobs:[],encodedDrawingBlob:""}),__publicField(this,"scene"),__publicField(this,"volumes",[]),__publicField(this,"meshDataObjects"),__publicField(this,"meshes",[]),__publicField(this,"drawBitmap",null),__publicField(this,"imageOptionsMap",new Map),__publicField(this,"meshOptionsMap",new Map),this.scene={onAzimuthElevationChange:()=>{},onZoom3DChange:()=>{},sceneData:{azimuth:110,elevation:10,crosshairPos:[.5,.5,.5],clipPlane:[0,0,0,0],clipPlaneDepthAziElev:[2,0,0],volScaleMultiplier:1,pan2Dxyzmm:[0,0,0,1]},get renderAzimuth(){return this.sceneData.azimuth},set renderAzimuth(n){this.sceneData.azimuth=n,this.onAzimuthElevationChange&&this.onAzimuthElevationChange(this.sceneData.azimuth,this.sceneData.elevation)},get renderElevation(){return this.sceneData.elevation},set renderElevation(n){this.sceneData.elevation=n,this.onAzimuthElevationChange&&this.onAzimuthElevationChange(this.sceneData.azimuth,this.sceneData.elevation)},get volScaleMultiplier(){return this.sceneData.volScaleMultiplier},set volScaleMultiplier(n){this.sceneData.volScaleMultiplier=n,this.onZoom3DChange(n)},get crosshairPos(){return this.sceneData.crosshairPos},set crosshairPos(n){this.sceneData.crosshairPos=n},get clipPlane(){return this.sceneData.clipPlane},set clipPlane(n){this.sceneData.clipPlane=n},get clipPlaneDepthAziElev(){return this.sceneData.clipPlaneDepthAziElev},set clipPlaneDepthAziElev(n){this.sceneData.clipPlaneDepthAziElev=n},get pan2Dxyzmm(){return this.sceneData.pan2Dxyzmm},set pan2Dxyzmm(n){this.sceneData.pan2Dxyzmm=n}}}get title(){return this.data.title}get previewImageDataURL(){return this.data.previewImageDataURL}set previewImageDataURL(n){this.data.previewImageDataURL=n}set title(n){this.data.title=n}get imageOptionsArray(){return this.data.imageOptionsArray}get encodedImageBlobs(){return this.data.encodedImageBlobs}get encodedDrawingBlob(){return this.data.encodedDrawingBlob}get opts(){return this.data.opts}set opts(n){this.data.opts={...n}}get labels(){return this.data.labels}set labels(n){this.data.labels=n}hasImage(n){return this.volumes.find(s=>s.id===n.id)!==void 0}hasImageFromUrl(n){return this.data.imageOptionsArray.find(s=>s.url===n)!==void 0}addImageOptions(n,s){if(!this.hasImage(n)&&!s.name)if(s.url){const f=/^(?:[a-z+]+:)?\/\//i.test(s.url)?new URL(s.url):new URL(s.url,window.location.href);s.name=f.pathname.split("/").pop(),s.name.toLowerCase().endsWith(".gz")&&(s.name=s.name.slice(0,-3)),s.name.toLowerCase().endsWith(".nii")||(s.name+=".nii")}else s.name="untitled.nii";s.imageType=NVIMAGE_TYPE.NII,this.data.imageOptionsArray.push(s),this.imageOptionsMap.set(n.id,this.data.imageOptionsArray.length-1)}removeImage(n){if(this.imageOptionsMap.has(n.id)){const s=this.imageOptionsMap.get(n.id);this.data.imageOptionsArray.length>s&&this.data.imageOptionsArray.splice(s,1),this.imageOptionsMap.delete(n.id)}this.volumes=this.volumes.filter(s=>s.id!==n.id)}getImageOptions(n){return this.imageOptionsMap.has(n.id)?this.data.imageOptionsArray[this.imageOptionsMap.get(n.id)]:null}json(){const n={encodedImageBlobs:[],previewImageDataURL:this.data.previewImageDataURL,imageOptionsMap:new Map},s=[];if(n.sceneData={...this.scene.sceneData},n.opts={...this.opts},this.opts.meshThicknessOn2D===1/0&&(n.opts.meshThicknessOn2D="infinity"),n.labels=[...this.data.labels],this.volumes.length){let f=this.imageOptionsArray[0];if(f||(log$4.debug("no image options for base image"),f={name:"",colormap:"gray",opacity:1,pairedImgData:null,cal_min:NaN,cal_max:NaN,trustCalMinMax:!0,percentileFrac:.02,ignoreZeroVoxels:!1,useQFormNotSForm:!1,colormapNegative:"",colormapLabel:[],imageType:NVIMAGE_TYPE.NII,frame4D:0,limitFrames4D:NaN,url:"",urlImageData:"",alphaThreshold:!1,cal_minNeg:NaN,cal_maxNeg:NaN,colorbarVisible:!0}),f.colormap=this.volumes[0].colormap,f.opacity=this.volumes[0].opacity,f.cal_max=this.volumes[0].cal_max||NaN,f.cal_min=this.volumes[0].cal_min||NaN,f){s.push(f);const m=NVUtilities.uint8tob64(this.volumes[0].toUint8Array());n.encodedImageBlobs.push(m),this.drawBitmap&&(n.encodedDrawingBlob=NVUtilities.uint8tob64(this.volumes[0].toUint8Array(this.drawBitmap))),n.imageOptionsMap.set(this.volumes[0].id,0)}else throw new Error("image options for base layer not found");for(let m=1;m({values:A.values,nFrame4D:A.nFrame4D,frame4D:0,outlineBorder:A.outlineBorder,global_min:A.global_min,global_max:A.global_max,cal_min:A.cal_min,cal_max:A.cal_max,opacity:A.opacity,colormap:A.colormap,colormapNegative:A.colormapNegative,colormapLabel:A.colormapLabel,useNegativeCmap:A.useNegativeCmap})),hasConnectome:f.hasConnectome,edgeColormap:f.edgeColormap,edgeColormapNegative:f.edgeColormapNegative,edgeMax:f.edgeMax,edgeMin:f.edgeMin,edges:f.edges&&Array.isArray(f.edges)?[...f.edges]:[],extentsMax:f.extentsMax,extentsMin:f.extentsMin,fiberGroupColormap:f.fiberGroupColormap,furthestVertexFromOrigin:f.furthestVertexFromOrigin,nodeColormap:f.nodeColormap,nodeColormapNegative:f.nodeColormapNegative,nodeMaxColor:f.nodeMaxColor,nodeMinColor:f.nodeMinColor,nodeScale:f.nodeScale,legendLineThickness:f.legendLineThickness,offsetPt0:f.offsetPt0,nodes:f.nodes};u.push(m)}return n.meshesString=JSON.stringify(serialize(u)),n}download(n){const s=this.json();NVUtilities.download(JSON.stringify(s),n,"application/json")}static deserializeMeshDataObjects(n){if(n.data.meshesString){n.meshDataObjects=deserialize$1(JSON.parse(n.data.meshesString));for(const s of n.meshDataObjects)for(const u of s.layers)"colorMap"in u&&(u.colormap=u.colorMap,delete u.colorMap),"colorMapNegative"in u&&(u.colormapNegative=u.colorMapNegative,delete u.colorMapNegative)}}static async loadFromUrl(n){const u=await(await fetch(n)).json();return Ji.loadFromJSON(u)}static async loadFromFile(n){const s=await NVUtilities.readFileAsync(n),u=new Ji,m=new TextDecoder().decode(s);return u.data=JSON.parse(m),Ji.deserializeMeshDataObjects(u),u}static loadFromJSON(n){const s=new Ji;return s.data=n,s.data.opts.meshThicknessOn2D==="infinity"&&(s.data.opts.meshThicknessOn2D=1/0),s.scene.sceneData=n.sceneData,Ji.deserializeMeshDataObjects(s),s}},NVLabel3D=class{constructor(a,n,s){__publicField(this,"text"),__publicField(this,"style"),__publicField(this,"points"),this.text=a,this.style=n,this.points=s}},defaultOptions={name:"untitled connectome",nodeColormap:"warm",nodeColormapNegative:"winter",nodeMinColor:0,nodeMaxColor:4,nodeScale:3,edgeColormap:"warm",edgeColormapNegative:"winter",edgeMin:2,edgeMax:6,edgeScale:1,legendLineThickness:0},NVConnectome=class Uo extends NVMesh{constructor(n,s){super(new Float32Array([]),new Uint32Array([]),s.name,new Uint8Array([]),1,!0,n,s),__publicField(this,"gl"),__publicField(this,"nodesChanged"),this.gl=n,this.type="connectome",this.nodes&&this.updateLabels(),this.nodesChanged=new EventTarget}static convertLegacyConnectome(n){const s={nodes:[],edges:[],...defaultOptions};for(const f in n)if(f in defaultOptions){const m=f;s[m]=n[m]}const u=n.nodes;for(let f=0;f({name:Array.isArray(A.comments)&&A.comments.length>0&&"text"in A.comments[0]?A.comments[0].text:"",x:A.coordinates.x,y:A.coordinates.y,z:A.coordinates.z,colorValue:1,sizeValue:1,metadata:A.comments}));return{...defaultOptions,nodeColormap:s,edgeColormap:s,nodes:f,edges:[]}}updateLabels(){const n=this.nodes;if(n&&n.length>0){const s=n.reduce((T,I)=>T.sizeValue>I.sizeValue?T:I).sizeValue,u=this.nodeMinColor?this.nodeMinColor:n.reduce((T,I)=>T.colorValueT.colorValue>I.colorValue?T:I).colorValue,m=cmapper.colormap(this.nodeColormap,this.colormapInvert),A=cmapper.colormap(this.nodeColormapNegative,this.colormapInvert),v="nodeColormapNegative"in this,y=this.legendLineThickness?this.legendLineThickness:0;for(let T=0;Te/255),log$4.debug("adding label for ",n[T]),n[T].label=new NVLabel3D(n[T].name,{textColor:E,bulletScale:n[T].sizeValue/s,bulletColor:E,lineWidth:y,lineColor:E,textScale:1,textAlignment:"left",lineTerminator:"none"},[n[T].x,n[T].y,n[T].z]),log$4.debug("label for node:",n[T].label)}}}addConnectomeNode(n){if(log$4.debug("adding node",n),!this.nodes)throw new Error("nodes not defined");this.nodes.push(n),this.updateLabels(),this.nodesChanged.dispatchEvent(new CustomEvent("nodeAdded",{detail:{node:n}}))}deleteConnectomeNode(n){const s=this.nodes.indexOf(n),u=this.edges;u&&(this.edges=u.filter(f=>f.first!==s&&f.second!==s)),this.nodes=this.nodes.filter(f=>f!==n),this.updateLabels(),this.updateConnectome(this.gl),this.nodesChanged.dispatchEvent(new CustomEvent("nodeDeleted",{detail:{node:n}}))}updateConnectomeNodeByIndex(n,s){this.nodes[n]=s,this.updateLabels(),this.updateConnectome(this.gl),this.nodesChanged.dispatchEvent(new CustomEvent("nodeChanged",{detail:{node:s}}))}updateConnectomeNodeByPoint(n,s){const u=this.nodes;if(!u)throw new Error("Node to update does not exist");const f=u.find(A=>NVUtilities.arraysAreEqual([A.x,A.y,A.z],n));if(!f)throw new Error(`Node with point ${n} to update does not exist`);const m=u.findIndex(A=>A===f);this.updateConnectomeNodeByIndex(m,s)}addConnectomeEdge(n,s,u){const f=this.edges;let m=f.find(A=>(A.first===n||A.second===n)&&A.first+A.second===n+s);return m||(m={first:n,second:s,colorValue:u},f.push(m),this.updateConnectome(this.gl),m)}deleteConnectomeEdge(n,s){const u=this.edges,f=u.find(m=>(m.first===n||m.first===s)&&m.first+m.second===n+s);if(f)this.edges=u.filter(m=>m!==f);else throw new Error(`edge between ${n} and ${s} not found`);return this.updateConnectome(this.gl),f}findClosestConnectomeNode(n,s){const u=this.nodes;if(!u||u.length===0)return null;const f=u.map((m,A)=>({node:m,distance:Math.sqrt(Math.pow(m.x-n[0],2)+Math.pow(m.y-n[1],2)+Math.pow(m.z-n[2],2)),index:A})).filter(m=>m.distancem.distance-A.distance);return f.length>0?f[0].node:null}updateConnectome(n){const s=[],u=[],f=[];let m=cmapper.colormap(this.nodeColormap,this.colormapInvert),A=cmapper.colormap(this.nodeColormapNegative,this.colormapInvert),v="nodeColormapNegative"in this;if(this.nodeMinColor===void 0||this.nodeMaxColor===void 0)throw new Error("nodeMinColor or nodeMaxColor is undefined");if(this.edgeMin===void 0||this.edgeMax===void 0)throw new Error("edgeMin or edgeMax undefined");let y=this.nodeMinColor,T=this.nodeMaxColor;const I=this.nodes,S=I.length;for(let V=0;Vm&&([f,m]=[m,f]),[f,m]}function swizzleVec3(a,n=[0,1,2]){const s=create$2();return s[0]=a[n[0]],s[1]=a[n[1]],s[2]=a[n[2]],s}function isRadiological(a){const n=fromValues$1(1,0,0,0),s=create$1();return transformMat4(s,n,a),s[0]}function unProject(a,n,s,u){const f=fromValues$1(a,n,s,1),m=clone$3(u);invert(m,m),f[0]=f[0]*2-1,f[1]=f[1]*2-1,f[2]=f[2]*2-1;const A=create$1();return transformMat4(A,f,m),A[3]===0||(A[0]/=A[3],A[1]/=A[3],A[2]/=A[3]),A}function unpackFloatFromVec4i(a){const n=[5960464477539063e-23,152587890625e-16,.00390625,1];return(a[0]*n[0]+a[1]*n[1]+a[2]*n[2]+a[3]*n[3])/255}function clamp$1(a,n,s){return Math.min(Math.max(a,n),s)}function encodeRLE(a){const n=a.length;let s=0;const u=new Uint8Array(n+Math.ceil(.01*n)),f=new Int8Array(u.buffer);let m=0;for(;s1){f[m]=-v+1,m++,u[m]=A,m++;continue}for(;s127||s+2 "+m+" bytes (x"+n/m+")"),u.slice(0,m)}function decodeRLE(a,n){const s=new Uint8Array(a.buffer),u=new Int8Array(s.buffer);let f=0;const m=new Uint8Array(n);let A=0;for(;f{}),__publicField(this,"onMouseUp",()=>{}),__publicField(this,"onLocationChange",()=>{}),__publicField(this,"onIntensityChange",()=>{}),__publicField(this,"onImageLoaded",()=>{}),__publicField(this,"onMeshLoaded",()=>{}),__publicField(this,"onFrameChange",()=>{}),__publicField(this,"onError",()=>{}),__publicField(this,"onColormapChange",()=>{}),__publicField(this,"onInfo",()=>{}),__publicField(this,"onWarn",()=>{}),__publicField(this,"onDebug",()=>{}),__publicField(this,"onVolumeAddedFromUrl",()=>{}),__publicField(this,"onVolumeWithUrlRemoved",()=>{}),__publicField(this,"onVolumeUpdated",()=>{}),__publicField(this,"onMeshAddedFromUrl",()=>{}),__publicField(this,"onMeshAdded",()=>{}),__publicField(this,"onMeshWithUrlRemoved",()=>{}),__publicField(this,"onZoom3DChange",()=>{}),__publicField(this,"onAzimuthElevationChange",()=>{}),__publicField(this,"onClipPlaneChange",()=>{}),__publicField(this,"onCustomMeshShaderAdded",()=>{}),__publicField(this,"onMeshShaderChanged",()=>{}),__publicField(this,"onMeshPropertyChanged",()=>{}),__publicField(this,"onDocumentLoaded",()=>{}),__publicField(this,"document",new NVDocument),__publicField(this,"opts",{...DEFAULT_OPTIONS}),__publicField(this,"scene",{...this.document.scene}),__publicField(this,"mediaUrlMap",new Map),__publicField(this,"initialized",!1),__publicField(this,"currentDrawUndoBitmap"),__publicField(this,"loadingText");for(const s in n)typeof n[s]=="function"?this[s]=n[s]:this.opts[s]=DEFAULT_OPTIONS[s]===void 0?DEFAULT_OPTIONS[s]:n[s];this.opts.isHighResolutionCapable?this.uiData.dpr=window.devicePixelRatio||1:this.uiData.dpr=1,this.currentDrawUndoBitmap=this.opts.maxDrawUndoBitmaps,this.opts.drawingEnabled&&this.createEmptyDrawing(),this.opts.thumbnail.length>0&&(this.thumbnailVisible=!0),this.loadingText=this.opts.loadingText,log$4.setLogLevel(this.opts.logLevel)}get volumes(){return this.document.volumes}set volumes(n){this.document.volumes=n}get meshes(){return this.document.meshes}set meshes(n){this.document.meshes=n}get drawBitmap(){return this.document.drawBitmap}set drawBitmap(n){this.document.drawBitmap=n}get volScaleMultiplier(){return this.scene.volScaleMultiplier}set volScaleMultiplier(n){this.setScale(n)}async saveScene(n="niivue.png"){function s(f,m){const A=document.createElement("a");document.body.appendChild(A),A.style.display="none";const v=window.URL.createObjectURL(f);A.href=v,A.download=m,A.click(),A.remove()}const u=this.canvas;if(!u)throw new Error("canvas not defined");this.drawScene(),u.toBlob(f=>{f&&(n===""&&(n=`niivue-screenshot-${new Date().toString()}.png`,n=n.replace(/\s/g,"_")),s(f,n))})}async attachTo(n,s=null){return await this.attachToCanvas(document.getElementById(n),s),log$4.debug("attached to element with id: ",n),this}async attachToCanvas(n,s=null){return this.canvas=n,s===null&&(s=navigator.hardwareConcurrency>6,log$4.debug("AntiAlias ",s," Threads ",navigator.hardwareConcurrency)),this.gl=this.canvas.getContext("webgl2",{alpha:!0,antialias:s}),log$4.info("NIIVUE VERSION ",version$1),this.canvas.parentElement.style.backgroundColor="black",this.opts.isResizeCanvas&&(this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.display="block",this.canvas.width=this.canvas.offsetWidth,this.canvas.height=this.canvas.offsetHeight,window.addEventListener("resize",this.resizeListener.bind(this)),this.resizeObserver=new ResizeObserver(this.resizeListener.bind(this)),this.resizeObserver.observe(this.canvas.parentElement)),this.registerInteractions(),await this.init(),this.drawScene(),this}syncWith(n,s={"2d":!0,"3d":!0}){this.otherNV=n,this.syncOpts=s}broadcastTo(n,s={"2d":!0,"3d":!0}){this.otherNV=n,this.syncOpts=s}sync(){if(!this.gl||!this.otherNV||typeof this.otherNV>"u"||!this.gl.canvas.matches(":focus"))return;const n=this.frac2mm(this.scene.crosshairPos);if(this.otherNV instanceof zo)this.syncOpts["2d"]&&(this.otherNV.scene.crosshairPos=this.otherNV.mm2frac(n)),this.syncOpts["3d"]&&(this.otherNV.scene.renderAzimuth=this.scene.renderAzimuth,this.otherNV.scene.renderElevation=this.scene.renderElevation),this.otherNV.drawScene(),this.otherNV.createOnLocationChange();else if(Array.isArray(this.otherNV))for(let s=0;su===s[f])}resizeListener(){if(!(!this.canvas||!this.gl)){if(!this.opts.isResizeCanvas){this.opts.isHighResolutionCapable&&(log$4.warn("isHighResolutionCapable requires isResizeCanvas"),this.opts.isHighResolutionCapable=!1),this.uiData.dpr=1,this.drawScene();return}this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.display="block",this.opts.isHighResolutionCapable?(this.uiData.dpr=window.devicePixelRatio||1,log$4.debug("devicePixelRatio: "+this.uiData.dpr)):this.uiData.dpr=1,"width"in this.canvas.parentElement?(this.canvas.width=this.canvas.parentElement.width*this.uiData.dpr,this.canvas.height=this.canvas.parentElement.height*this.uiData.dpr):(this.canvas.width=this.canvas.offsetWidth*this.uiData.dpr,this.canvas.height=this.canvas.offsetHeight*this.uiData.dpr),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.drawScene()}}getRelativeMousePosition(n,s){if(s=s||n.target,!s)return;const u=s.getBoundingClientRect();return{x:n.clientX-u.left,y:n.clientY-u.top}}getNoPaddingNoBorderCanvasRelativeMousePosition(n,s){return s=s||n.target,this.getRelativeMousePosition(n,s)}mouseContextMenuListener(n){n.preventDefault()}mouseDownListener(n){n.preventDefault(),this.drawPenLocation=[NaN,NaN,NaN],this.drawPenAxCorSag=-1,this.uiData.mousedown=!0,log$4.debug("mouse down"),log$4.debug(n);const s=this.getNoPaddingNoBorderCanvasRelativeMousePosition(n,this.gl.canvas);if(!s)return;const[u,f]=[s.x*this.uiData.dpr,s.y*this.uiData.dpr],m=this.getLabelAtPoint([u,f]);if(m){for(const A of this.meshes)if(A.type==="connectome")for(const v of A.nodes)v.label===m&&(this.scene.crosshairPos=this.mm2frac([v.x,v.y,v.z]),this.updateGLVolume(),this.drawScene())}this.uiData.clickedTile=this.tileIndex(u,f),n.button===LEFT_MOUSE_BUTTON&&n.shiftKey?(this.uiData.mouseButtonCenterDown=!0,this.mouseCenterButtonHandler(n)):n.button===LEFT_MOUSE_BUTTON?(this.uiData.mouseButtonLeftDown=!0,this.mouseLeftButtonHandler(n)):n.button===RIGHT_MOUSE_BUTTON?(this.uiData.mouseButtonRightDown=!0,this.mouseRightButtonHandler(n)):n.button===CENTER_MOUSE_BUTTON&&(this.uiData.mouseButtonCenterDown=!0,this.mouseCenterButtonHandler(n))}mouseLeftButtonHandler(n){const s=this.getNoPaddingNoBorderCanvasRelativeMousePosition(n,this.gl.canvas);this.mouseDown(s.x,s.y),this.mouseClick(s.x,s.y)}mouseCenterButtonHandler(n){const s=this.getNoPaddingNoBorderCanvasRelativeMousePosition(n,this.gl.canvas);this.mousePos=[s.x*this.uiData.dpr,s.y*this.uiData.dpr],this.opts.dragMode!==0&&(this.setDragStart(s.x,s.y),this.uiData.isDragging||(this.uiData.pan2DxyzmmAtMouseDown=clone$1(this.scene.pan2Dxyzmm)),this.uiData.isDragging=!0,this.uiData.dragClipPlaneStartDepthAziElev=this.scene.clipPlaneDepthAziElev)}mouseRightButtonHandler(n){const s=this.getNoPaddingNoBorderCanvasRelativeMousePosition(n,this.gl.canvas);this.mousePos=[s.x*this.uiData.dpr,s.y*this.uiData.dpr],this.opts.dragMode!==0&&(this.setDragStart(s.x,s.y),this.uiData.isDragging||(this.uiData.pan2DxyzmmAtMouseDown=clone$1(this.scene.pan2Dxyzmm)),this.uiData.isDragging=!0,this.uiData.dragClipPlaneStartDepthAziElev=this.scene.clipPlaneDepthAziElev)}calculateMinMaxVoxIdx(n){if(n.length>2)throw new Error("array must not contain more than two values");return[Math.floor(Math.min(n[0],n[1])),Math.floor(Math.max(n[0],n[1]))]}calculateNewRange({volIdx:n=0}={}){if(this.opts.sliceType===4&&this.sliceMosaicString.length<1||this.uiData.dragStart[0]===this.uiData.dragEnd[0]&&this.uiData.dragStart[1]===this.uiData.dragEnd[1])return;let s=this.canvasPos2frac([this.uiData.dragStart[0],this.uiData.dragStart[1]]);if(s[0]<0)return;const u=this.frac2vox(s,n);if(s=this.canvasPos2frac([this.uiData.dragEnd[0],this.uiData.dragEnd[1]]),s[0]<0)return;const f=this.frac2vox(s,n);let m=-Number.MAX_VALUE,A=Number.MAX_VALUE;const v=this.calculateMinMaxVoxIdx([u[0],f[0]]),y=this.calculateMinMaxVoxIdx([u[1],f[1]]),T=this.calculateMinMaxVoxIdx([u[2],f[2]]);u[0]-f[0]===0?v[1]=u[0]+1:u[1]-f[1]===0?y[1]=u[1]+1:u[2]-f[2]===0&&(T[1]=u[2]+1);const I=this.volumes[n].hdr,S=this.volumes[n].img;if(!I||!S)return;const E=I.dims[1],e=I.dims[2];for(let L=T[0];LS[W]&&(A=S[W]),m=m)return;const F=intensityRaw2Scaled(I,A),M=intensityRaw2Scaled(I,m);this.volumes[n].cal_min=F,this.volumes[n].cal_max=M,this.onIntensityChange(this.volumes[n])}generateMouseUpCallback(n,s){const u=this.tileIndex(this.uiData.dragStart[0],this.uiData.dragStart[1]),f=this.tileIndex(this.uiData.dragEnd[0],this.uiData.dragEnd[1]);let m=-1;u===f&&(m=f);let A=-1;m>=0&&(A=this.screenSlices[m].axCorSag);const v=this.frac2mm(n),y=this.frac2mm(s),T=create$2();sub$4(T,fromValues$2(v[0],v[1],v[2]),fromValues$2(y[0],y[1],y[2]));const I=len(T),S=this.frac2vox(n),E=this.frac2vox(s);this.onDragRelease({fracStart:n,fracEnd:s,voxStart:S,voxEnd:E,mmStart:v,mmEnd:y,mmLength:I,tileIdx:m,axCorSag:A})}mouseUpListener(){function n(f){return Object.prototype.toString.call(f).indexOf("Function")>-1}const s={mouseButtonRightDown:this.uiData.mouseButtonRightDown,mouseButtonCenterDown:this.uiData.mouseButtonCenterDown,isDragging:this.uiData.isDragging,mousePos:this.mousePos,fracPos:this.canvasPos2frac(this.mousePos)};this.uiData.mousedown=!1,this.uiData.mouseButtonRightDown=!1;const u=this.uiData.mouseButtonCenterDown;if(this.uiData.mouseButtonCenterDown=!1,this.uiData.mouseButtonLeftDown=!1,this.drawPenFillPts.length>0?this.drawPenFilled():this.drawPenAxCorSag>=0&&this.drawAddUndoBitmap(),this.drawPenLocation=[NaN,NaN,NaN],this.drawPenAxCorSag=-1,n(this.onMouseUp)&&this.onMouseUp(s),this.uiData.isDragging){this.uiData.isDragging=!1,this.opts.dragMode===5&&this.drawScene();const f=this.canvasPos2frac([this.uiData.dragStart[0],this.uiData.dragStart[1]]),m=this.canvasPos2frac([this.uiData.dragEnd[0],this.uiData.dragEnd[1]]);if(this.generateMouseUpCallback(f,m),this.opts.dragMode!==1||u||this.uiData.dragStart[0]===this.uiData.dragEnd[0]&&this.uiData.dragStart[1]===this.uiData.dragEnd[1])return;this.calculateNewRange({volIdx:0}),this.refreshLayers(this.volumes[0],0)}this.drawScene()}checkMultitouch(n){if(this.uiData.touchdown&&!this.uiData.multiTouchGesture){const s=this.canvas.getBoundingClientRect();this.mouseDown(n.touches[0].clientX-s.left,n.touches[0].clientY-s.top),this.mouseClick(n.touches[0].clientX-s.left,n.touches[0].clientY-s.top)}}touchStartListener(n){n.preventDefault(),this.uiData.touchTimer||(this.uiData.touchTimer=setTimeout(()=>{this.resetBriCon(n)},this.opts.longTouchTimeout)),this.uiData.touchdown=!0,this.uiData.currentTouchTime=new Date().getTime();const s=this.uiData.currentTouchTime-this.uiData.lastTouchTime;if(s0){this.uiData.doubleTouch=!0,this.setDragStart(n.targetTouches[0].clientX-n.target.getBoundingClientRect().left,n.targetTouches[0].clientY-n.target.getBoundingClientRect().top),this.resetBriCon(n),this.uiData.lastTouchTime=this.uiData.currentTouchTime;return}else this.uiData.doubleTouch=!1,this.setDragStart(0,0),this.setDragEnd(0,0),this.uiData.lastTouchTime=this.uiData.currentTouchTime;this.uiData.touchdown&&n.touches.length<2?this.uiData.multiTouchGesture=!1:this.uiData.multiTouchGesture=!0,setTimeout(this.checkMultitouch.bind(this),1,n)}touchEndListener(n){if(n.preventDefault(),this.uiData.touchdown=!1,this.uiData.lastTwoTouchDistance=0,this.uiData.multiTouchGesture=!1,this.uiData.touchTimer&&(clearTimeout(this.uiData.touchTimer),this.uiData.touchTimer=null),this.uiData.isDragging){this.uiData.isDragging=!1,this.opts.dragMode===1&&(this.calculateNewRange(),this.refreshLayers(this.volumes[0],0));const s=this.canvasPos2frac([this.uiData.dragStart[0],this.uiData.dragStart[1]]),u=this.canvasPos2frac([this.uiData.dragEnd[0],this.uiData.dragEnd[1]]);this.generateMouseUpCallback(s,u)}this.mouseUpListener()}mouseMoveListener(n){if(this.uiData.mousedown){const s=this.getNoPaddingNoBorderCanvasRelativeMousePosition(n,this.gl.canvas);if(!s)return;const u=s.x*this.uiData.dpr,f=s.y*this.uiData.dpr;if(this.tileIndex(u,f)!==this.uiData.clickedTile)return;this.uiData.mouseButtonLeftDown?(this.mouseMove(s.x,s.y),this.mouseClick(s.x,s.y)):(this.uiData.mouseButtonRightDown||this.uiData.mouseButtonCenterDown)&&this.setDragEnd(s.x,s.y),this.drawScene(),this.uiData.prevX=this.uiData.currX,this.uiData.prevY=this.uiData.currY}}resetBriCon(n=null){if(this.uiData.isDragging)return;let s=!1;this.opts.sliceType===4&&(s=!0);let u=0,f=0;if(n!==null&&("targetTouches"in n?(u=n.targetTouches[0].clientX-n.target.getBoundingClientRect().left,f=n.targetTouches[0].clientY-n.target.getBoundingClientRect().top):(u=n.offsetX,f=n.offsetY),u*=this.uiData.dpr,f*=this.uiData.dpr,this.inRenderTile(u,f)>=0&&(s=!0)),s){this.uiData.mouseDepthPicker=!0,this.drawScene(),this.drawScene();return}this.opts.dragMode!==4&&(this.volumes.length<1||this.uiData.doubleTouch||(this.volumes[0].cal_min=this.volumes[0].robust_min,this.volumes[0].cal_max=this.volumes[0].robust_max,this.onIntensityChange(this.volumes[0]),this.refreshLayers(this.volumes[0],0),this.drawScene()))}setDragStart(n,s){n*=this.uiData.dpr,s*=this.uiData.dpr,this.uiData.dragStart[0]=n,this.uiData.dragStart[1]=s}setDragEnd(n,s){n*=this.uiData.dpr,s*=this.uiData.dpr,this.uiData.dragEnd[0]=n,this.uiData.dragEnd[1]=s}touchMoveListener(n){if(this.uiData.touchdown&&n.touches.length<2){const s=this.canvas.getBoundingClientRect();if(this.uiData.isDragging||(this.uiData.pan2DxyzmmAtMouseDown=clone$1(this.scene.pan2Dxyzmm)),this.uiData.isDragging=!0,this.uiData.doubleTouch&&this.uiData.isDragging){this.setDragEnd(n.targetTouches[0].clientX-n.target.getBoundingClientRect().left,n.targetTouches[0].clientY-n.target.getBoundingClientRect().top),this.drawScene();return}this.mouseClick(n.touches[0].clientX-s.left,n.touches[0].clientY-s.top),this.mouseMove(n.touches[0].clientX-s.left,n.touches[0].clientY-s.top)}else this.handlePinchZoom(n)}handlePinchZoom(n){if(n.targetTouches.length===2&&n.changedTouches.length===2){const s=Math.hypot(n.touches[0].pageX-n.touches[1].pageX,n.touches[0].pageY-n.touches[1].pageY),u=this.canvas.getBoundingClientRect();this.mousePos=[n.touches[0].clientX-u.left,n.touches[0].clientY-u.top],sthis.opts.keyDebounceTime){switch(this.currentClipPlaneIndex=(this.currentClipPlaneIndex+1)%7,this.currentClipPlaneIndex){case 0:this.scene.clipPlaneDepthAziElev=[2,0,0];break;case 1:this.scene.clipPlaneDepthAziElev=[0,270,0];break;case 2:this.scene.clipPlaneDepthAziElev=[0,90,0];break;case 3:this.scene.clipPlaneDepthAziElev=[0,0,0];break;case 4:this.scene.clipPlaneDepthAziElev=[0,180,0];break;case 5:this.scene.clipPlaneDepthAziElev=[0,0,-90];break;case 6:this.scene.clipPlaneDepthAziElev=[0,0,90];break}this.setClipPlane(this.scene.clipPlaneDepthAziElev)}this.lastCalled=s}else if(n.code===this.opts.viewModeHotKey){const s=new Date().getTime();s-this.lastCalled>this.opts.keyDebounceTime&&(this.setSliceType((this.opts.sliceType+1)%5),this.lastCalled=s)}}keyDownListener(n){n.code==="KeyH"&&this.opts.sliceType===4?this.setRenderAzimuthElevation(this.scene.renderAzimuth-1,this.scene.renderElevation):n.code==="KeyL"&&this.opts.sliceType===4?this.setRenderAzimuthElevation(this.scene.renderAzimuth+1,this.scene.renderElevation):n.code==="KeyJ"&&this.opts.sliceType===4?this.setRenderAzimuthElevation(this.scene.renderAzimuth,this.scene.renderElevation+1):n.code==="KeyK"&&this.opts.sliceType===4?this.setRenderAzimuthElevation(this.scene.renderAzimuth,this.scene.renderElevation-1):n.code==="KeyH"&&this.opts.sliceType!==4?this.moveCrosshairInVox(-1,0,0):n.code==="KeyL"&&this.opts.sliceType!==4?this.moveCrosshairInVox(1,0,0):n.code==="KeyU"&&this.opts.sliceType!==4&&n.ctrlKey?this.moveCrosshairInVox(0,0,1):n.code==="KeyD"&&this.opts.sliceType!==4&&n.ctrlKey?this.moveCrosshairInVox(0,0,-1):n.code==="KeyJ"&&this.opts.sliceType!==4?this.moveCrosshairInVox(0,-1,0):n.code==="KeyK"&&this.opts.sliceType!==4?this.moveCrosshairInVox(0,1,0):n.code==="KeyM"&&this.opts.sliceType!==4?(this.opts.dragMode++,this.opts.dragMode>=4&&(this.opts.dragMode=0),log$4.info("drag mode changed to ",DRAG_MODE[this.opts.dragMode])):n.code==="ArrowLeft"?this.setFrame4D(this.volumes[0].id,this.volumes[0].frame4D-1):n.code==="ArrowRight"?this.setFrame4D(this.volumes[0].id,this.volumes[0].frame4D+1):n.code==="Slash"&&n.shiftKey&&alert(`NIIVUE VERSION: ${version$1}`)}wheelListener(n){if(n.preventDefault(),n.stopPropagation(),this.thumbnailVisible)return;const s=this.canvas.getBoundingClientRect();n.deltaY<0?this.sliceScroll2D(-.01,n.clientX-s.left,n.clientY-s.top):this.sliceScroll2D(.01,n.clientX-s.left,n.clientY-s.top)}registerInteractions(){if(!this.canvas)throw new Error("canvas undefined");this.canvas.addEventListener("mousedown",this.mouseDownListener.bind(this)),this.canvas.addEventListener("mouseup",this.mouseUpListener.bind(this)),this.canvas.addEventListener("mousemove",this.mouseMoveListener.bind(this)),this.canvas.addEventListener("touchstart",this.touchStartListener.bind(this)),this.canvas.addEventListener("touchend",this.touchEndListener.bind(this)),this.canvas.addEventListener("touchmove",this.touchMoveListener.bind(this)),this.canvas.addEventListener("wheel",this.wheelListener.bind(this)),this.canvas.addEventListener("contextmenu",this.mouseContextMenuListener.bind(this)),this.canvas.addEventListener("dblclick",this.resetBriCon.bind(this)),this.canvas.addEventListener("dragenter",this.dragEnterListener.bind(this),!1),this.canvas.addEventListener("dragover",this.dragOverListener.bind(this),!1),this.canvas.addEventListener("drop",this.dropListener.bind(this),!1),this.canvas.setAttribute("tabindex","0"),this.canvas.addEventListener("keyup",this.keyUpListener.bind(this),!1),this.canvas.addEventListener("keydown",this.keyDownListener.bind(this),!1)}dragEnterListener(n){n.stopPropagation(),n.preventDefault()}dragOverListener(n){n.stopPropagation(),n.preventDefault()}getFileExt(n,s=!0){log$4.debug("fullname: ",n);const u=/(?:\.([^.]+))?$/;let f=u.exec(n)[1];return f=f.toUpperCase(),f==="GZ"&&(f=u.exec(n.slice(0,-3))[1],f=f.toUpperCase()),s?f:f.toLowerCase()}async addVolumeFromUrl(n){const s=await NVImage.loadFromUrl(n);return this.document.addImageOptions(s,n),s.onColormapChange=this.onColormapChange,this.mediaUrlMap.set(s,n.url),this.onVolumeAddedFromUrl&&this.onVolumeAddedFromUrl(n,s),this.addVolume(s),s}getMediaByUrl(n){return[...this.mediaUrlMap.entries()].filter(s=>s[1]===n).map(s=>s[0]).pop()}removeVolumeByUrl(n){const s=this.getMediaByUrl(n);if(s)this.removeVolume(s);else throw new Error("No volume with URL present")}readDirectory(n){const s=n.createReader();let u=[];const f=async A=>{const v=[],y=async T=>new Promise((I,S)=>T.file(I,S));for(let T=0;T{s.readEntries(A=>{A.length?(u=u.concat(A),m()):f(u).then(v=>{NVImage.loadFromFile({file:v,name:n.name,urlImgData:null,imageType:NVIMAGE_TYPE.DCM_FOLDER}).then(y=>this.addVolume(y)).catch(y=>{throw y})}).catch(v=>{throw v})})};return m(),u}isMeshExt(n){const s=this.getFileExt(n);return log$4.debug("dropped ext"),log$4.debug(s),MESH_EXTENSIONS.includes(s)}dropListener(n){if(n.stopPropagation(),n.preventDefault(),!this.opts.dragAndDropEnabled)return;const s=n.dataTransfer;if(!s)return;const u=s.getData("text/uri-list");if(u){const f=NVImageFromUrlOptions(u),m=this.getFileExt(u);log$4.debug("dropped ext"),log$4.debug(m),MESH_EXTENSIONS.includes(m)?this.addMeshFromUrl({url:u}).catch(A=>{throw A}):m==="NVD"?this.loadDocumentFromUrl(u).catch(A=>{throw A}):this.addVolumeFromUrl(f).catch(A=>{throw A})}else{const f=s.items;if(f.length>0){!n.shiftKey&&!n.altKey&&(this.volumes=[],this.overlays=[],this.meshes=[]),this.closeDrawing();for(const m of Array.from(f)){const A=m.webkitGetAsEntry();if(log$4.debug(A),!A)throw new Error("could not get entry from file");if(A.isFile){const v=this.getFileExt(A.name);if(v==="PNG"){A.file(T=>{this.loadBmpTexture(T).catch(I=>{throw I})});continue}let y;if(A.name.lastIndexOf("HEAD")!==-1)for(const T of Array.from(f)){const I=T.webkitGetAsEntry();if(!I)throw new Error("could not get paired entry");const S=A.name.substring(0,A.name.lastIndexOf("HEAD")),E=I.name.substring(0,I.name.lastIndexOf("BRIK"));S===E&&(y=I)}if(A.name.lastIndexOf("BRIK")!==-1)continue;if(MESH_EXTENSIONS.includes(v)){A.file(T=>{NVMesh.loadFromFile({file:T,gl:this.gl,name:T.name}).then(I=>{this.addMesh(I)}).catch(I=>{throw I})});continue}else if(v==="NVD"){A.file(T=>{NVDocument.loadFromFile(T).then(I=>{this.loadDocument(I),log$4.debug("loaded document")}).catch(I=>{throw I})});break}A.file(T=>{y?y.file(I=>{NVImage.loadFromFile({file:T,urlImgData:I,limitFrames4D:this.opts.limitFrames4D}).then(S=>{this.addVolume(S)}).catch(S=>{throw S})}):NVImage.loadFromFile({file:T,urlImgData:y,limitFrames4D:this.opts.limitFrames4D}).then(I=>{n.altKey?(log$4.debug("alt key detected: assuming this is a drawing overlay"),this.drawClearAllUndoBitmaps(),this.loadDrawing(I)):this.addVolume(I)}).catch(I=>{throw I})})}else A.isDirectory&&this.readDirectory(A)}}}this.drawScene()}setMultiplanarPadPixels(n){this.opts.multiplanarPadPixels=n,this.drawScene()}setMultiplanarLayout(n){typeof n=="string"&&(n=parseInt(n)),this.opts.multiplanarLayout=n,this.drawScene()}setCornerOrientationText(n){this.opts.isCornerOrientationText=n,this.updateGLVolume()}setRadiologicalConvention(n){this.opts.isRadiologicalConvention=n,this.updateGLVolume()}setDefaults(n={},s=!1){this.opts={...DEFAULT_OPTIONS},this.scene={...this.document.scene};for(const u in n)typeof n[u]=="function"?this[u]=n[u]:this.opts[u]=DEFAULT_OPTIONS[u]===void 0?DEFAULT_OPTIONS[u]:n[u];if(this.scene.pan2Dxyzmm=[0,0,0,1],s&&this.volumes&&this.volumes.length>0)for(let u=0;u=this.opts.maxDrawUndoBitmaps&&(this.currentDrawUndoBitmap=0),this.drawUndoBitmaps[this.currentDrawUndoBitmap]=encodeRLE(this.drawBitmap)}drawClearAllUndoBitmaps(){if(this.currentDrawUndoBitmap=this.opts.maxDrawUndoBitmaps,!(!this.drawUndoBitmaps||this.drawUndoBitmaps.length<1))for(let n=this.drawUndoBitmaps.length-1;n>=0;n--)this.drawUndoBitmaps[n]=new Uint8Array}drawUndo(){if(this.drawUndoBitmaps.length<1){log$4.debug("undo bitmaps not loaded");return}if(this.currentDrawUndoBitmap--,this.currentDrawUndoBitmap<0&&(this.currentDrawUndoBitmap=this.drawUndoBitmaps.length-1),this.currentDrawUndoBitmap>=this.drawUndoBitmaps.length&&(this.currentDrawUndoBitmap=0),this.drawUndoBitmaps[this.currentDrawUndoBitmap].length<2){log$4.debug("drawUndo is misbehaving");return}this.drawBitmap=decodeRLE(this.drawUndoBitmaps[this.currentDrawUndoBitmap],this.drawBitmap.length),this.refreshDrawing(!0)}loadDrawing(n){if(this.drawBitmap&&log$4.debug("Overwriting open drawing!"),!this.back)throw new Error("back undefined");this.drawClearAllUndoBitmaps();const s=n.hdr.dims;if(s[1]!==this.back.hdr.dims[1]||s[2]!==this.back.hdr.dims[2]||s[3]!==this.back.hdr.dims[3])return log$4.debug("drawing dimensions do not match background image"),!1;n.img.constructor!==Uint8Array&&log$4.debug("Drawings should be UINT8");const u=n.permRAS,f=s[1]*s[2]*s[3];this.drawBitmap=new Uint8Array(f),this.drawTexture=this.r8Tex(this.drawTexture,TEXTURE7_DRAW,this.back.dims,!0);const m=[0,0,0];for(let M=0;M<3;M++)for(let L=0;L<3;L++)Math.abs(u[M])-1===L&&(m[L]=M*Math.sign(u[M]));let A=1;const v=[1,1,1],y=[!1,!1,!1];for(let M=0;MArray(f).fill(0)),M=Array(f).fill(0).map(()=>Array(f).fill(0));for(let B=1;B3)for(let B=0;BL&&(V[0]=B,V[1]=z,V[2]=b,L=W)}else if(n===3)for(let B=0;BL&&(V[0]=B,V[1]=z,L=b)}else for(let B=0;BL&&(V[0]=B,L=z)}return[I(V[0]),I(V[1]),I(V[2])]}drawOtsu(n=2){if(this.volumes.length===0)return;const s=this.volumes[0].img.length,u=this.findOtsu(n);if(u.length<3)return;this.drawBitmap||this.createEmptyDrawing();const f=this.drawBitmap,m=this.volumes[0].img;for(let A=0;Au[0]&&(f[A]=1),v>u[1]&&(f[A]=2),v>u[2]&&(f[A]=3)}this.drawAddUndoBitmap(),this.refreshDrawing(!0)}removeHaze(n=5,s=0){const u=this.volumes[s].img,f=this.volumes[s].hdr,m=u.length;let A=2;(n===5||n===1)&&(A=4),(n===4||n===2)&&(A=3);const v=this.findOtsu(A);if(v.length<3)return;let y=v[0];n===1&&(y=v[2]),n===2&&(y=v[1]);const T=f.scl_inter,I=f.scl_slope,S=this.volumes[s].global_min;for(let E=0;E=this.meshes.length?-1:n;const s=this.meshes.length;for(let u=0;uu)return;const f=this.getVolumeIndexByID(n.id);s===0?(this.volumes.splice(f,1),this.volumes.unshift(n),this.back=this.volumes[0],this.overlays=this.volumes.slice(1)):s<0?(this.volumes.splice(this.getVolumeIndexByID(n.id),1),this.back=this.volumes[0],this.volumes.length>1?this.overlays=this.volumes.slice(1):this.overlays=[]):(this.volumes.splice(f,1),this.volumes.splice(s,0,n),this.overlays=this.volumes.slice(1),this.back=this.volumes[0]),this.updateGLVolume()}setMesh(n,s=0){this.meshes.forEach(m=>{log$4.debug("MESH: ",m.name)});const u=this.meshes.length;if(s>u)return;const f=this.getMeshIndexByID(n.id);s===0?(this.meshes.splice(f,1),this.meshes.unshift(n)):s<0?this.meshes.splice(this.getMeshIndexByID(n.id),1):(this.meshes.splice(f,1),this.meshes.splice(s,0,n)),this.updateGLVolume(),this.meshes.forEach(m=>{log$4.debug(m.name)})}removeVolume(n){if(this.setVolume(n,-1),this.mediaUrlMap.has(n)){const s=this.mediaUrlMap.get(n);this.onVolumeWithUrlRemoved(s),this.mediaUrlMap.delete(n)}this.drawScene()}removeVolumeByIndex(n){if(n>=this.volumes.length)throw new Error("Index of volume out of bounds");this.removeVolume(this.volumes[n])}removeMesh(n){if(this.setMesh(n,-1),this.mediaUrlMap.has(n)){const s=this.mediaUrlMap.get(n);this.onMeshWithUrlRemoved(s),this.mediaUrlMap.delete(n)}}removeMeshByUrl(n){const s=this.getMediaByUrl(n);s&&(this.removeMesh(s),this.mediaUrlMap.delete(s),this.onMeshWithUrlRemoved(n))}moveVolumeToBottom(n){this.setVolume(n,0)}moveVolumeUp(n){const s=this.getVolumeIndexByID(n.id);this.setVolume(n,s+1)}moveVolumeDown(n){const s=this.getVolumeIndexByID(n.id);this.setVolume(n,s-1)}moveVolumeToTop(n){this.setVolume(n,this.volumes.length-1)}mouseDown(n,s){n*=this.uiData.dpr,s*=this.uiData.dpr,this.mousePos=[n,s]}mouseMove(n,s){n*=this.uiData.dpr,s*=this.uiData.dpr;const u=(n-this.mousePos[0])/this.uiData.dpr,f=(s-this.mousePos[1])/this.uiData.dpr;this.mousePos=[n,s],!(this.inRenderTile(n,s)<0)&&(Math.abs(u)<1&&Math.abs(f)<1||(this.scene.renderAzimuth+=u,this.scene.renderElevation+=f,this.drawScene()))}sph2cartDeg(n,s){const u=-s*(Math.PI/180),f=(n-90)%360*(Math.PI/180),m=[Math.cos(u)*Math.cos(f),Math.cos(u)*Math.sin(f),Math.sin(u)],A=Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2]);return A<=0||(m[0]/=A,m[1]/=A,m[2]/=A),m}setClipPlane(n){const s=this.sph2cartDeg(n[1]+180,n[2]);this.scene.clipPlane=[s[0],s[1],s[2],n[0]],this.scene.clipPlaneDepthAziElev=n,this.onClipPlaneChange(this.scene.clipPlane),this.drawScene()}setCrosshairColor(n){this.opts.crosshairColor=n,this.drawScene()}setCrosshairWidth(n){this.opts.crosshairWidth=n,this.crosshairs3D&&(this.crosshairs3D.mm[0]=NaN),this.drawScene()}setDrawColormap(n){this.drawLut=cmapper.makeDrawLut(n),this.updateGLVolume()}setDrawingEnabled(n){this.opts.drawingEnabled=n,this.opts.drawingEnabled&&(this.drawBitmap||this.createEmptyDrawing()),this.drawScene()}setPenValue(n,s=!1){this.opts.penValue=n,this.opts.isFilledPen=s,this.drawScene()}setDrawOpacity(n){this.drawOpacity=n,this.drawScene()}setSelectionBoxColor(n){this.opts.selectionBoxColor=n}sliceScroll2D(n,s,u,f=!0){if(this.inGraphTile(s,u)){let m=this.volumes[0].frame4D;n>0&&m++,n<0&&m--,this.setFrame4D(this.volumes[0].id,m);return}if(n!==0&&this.opts.dragMode===3&&this.inRenderTile(this.uiData.dpr*s,this.uiData.dpr*u)===-1){let m=this.scene.pan2Dxyzmm[3]*(1+10*n);m=Math.round(m*10)/10;const A=this.scene.pan2Dxyzmm[3]-m;this.opts.yoke3Dto2DZoom&&(this.scene.volScaleMultiplier=m),this.scene.pan2Dxyzmm[3]=m;const v=this.frac2mm(this.scene.crosshairPos);this.scene.pan2Dxyzmm[0]+=A*v[0],this.scene.pan2Dxyzmm[1]+=A*v[1],this.scene.pan2Dxyzmm[2]+=A*v[2],this.drawScene();return}this.mouseClick(s,u,n,f)}setSliceType(n){return this.opts.sliceType=n,this.drawScene(),this}setOpacity(n,s){if(this.volumes[n].opacity=s,n===0){this.drawScene();return}this.updateGLVolume()}setScale(n){this.scene.volScaleMultiplier=n,this.drawScene()}setClipPlaneColor(n){this.opts.clipPlaneColor=n,this.renderShader.use(this.gl),this.gl.uniform4fv(this.renderShader.uniforms.clipPlaneColor,this.opts.clipPlaneColor),this.drawScene()}async setVolumeRenderIllumination(n=0){this.renderShader=this.renderVolumeShader,n>0&&(this.renderShader=this.renderGradientShader),n<0&&(this.renderShader=this.renderSliceShader),this.initRenderShader(this.renderShader,n),this.renderShader.use(this.gl),this.setClipPlaneColor(this.opts.clipPlaneColor),this.gradientTextureAmount=n,this.refreshLayers(this.volumes[0],0),this.drawScene()}overlayRGBA(n){const s=n.hdr,u=s.dims[1]*s.dims[2]*s.dims[3],f=new Uint8ClampedArray(u*4),m=.2*Math.min(Math.min(s.dims[1],s.dims[2]),s.dims[3]),A=.5*s.dims[1],v=.5*s.dims[2],y=.5*s.dims[3];let T=0;for(let I=0;I0&&(this.back=this.volumes[0]);const u=n.encodedDrawingBlob;if(u){const f=n.imageOptionsArray[0],m=NVImage.loadFromBase64({base64:u,...f});m&&this.loadDrawing(m)}for(const f of n.meshDataObjects??[]){const m={gl:this.gl,...f};log$4.debug(m);const A=new NVMesh(m.pts,m.tris,m.name,m.rgba255,m.opacity,m.visible,this.gl,m.connectome,m.dpg,m.dps,m.dpv);A.meshShaderIndex=m.meshShaderIndex,A.layers=m.layers,A.updateMesh(this.gl),log$4.debug(A),this.addMesh(A)}if(n.data.connectomes)for(const f of n.data.connectomes){const m=JSON.parse(f);this.loadConnectome(m)}return this.scene={...this.scene,...n.scene.sceneData},this.opts={...this.opts,...n.opts},this.updateGLVolume(),this.drawScene(),this.onDocumentLoaded(n),this}generateLoadDocumentJavaScript(n,s){const u=this.json(),f=NVUtilities.compressToBase64String(JSON.stringify(u));return` +`),S=/(.*\/).*/.exec(f)[0],E=[];for(const e of T){const F=new URL(e,S);if(v=await fetch(F,{headers:s}),!v.ok)throw Error(v.statusText);const M=await v.arrayBuffer();E.push(M)}return E}static async fetchPartial(n,s,u={}){try{return await fetch(n,{headers:{range:`bytes=0-'${s}`,stream:"true",...u}})}catch(f){return log$4.error(f),log$4.error("fetchPartial failed, trying again without range header"),await fetch(n,{headers:u})}}static async loadFromUrl({url:n="",urlImgData:s="",headers:u={},name:f="",colormap:m="gray",opacity:A=1,cal_min:v=NaN,cal_max:y=NaN,trustCalMinMax:T=!0,percentileFrac:I=.02,ignoreZeroVoxels:S=!1,useQFormNotSForm:E=!1,colormapNegative:e="",frame4D:F=0,isManifest:M=!1,limitFrames4D:L=NaN,imageType:V=NVIMAGE_TYPE.UNKNOWN,colorbarVisible:B=!0}={}){if(n==="")throw Error("url must not be empty");let z=null,b=null;if(n instanceof Uint8Array&&(n=n.buffer),n instanceof ArrayBuffer){b=n,n="array.nii";const H=new Uint8Array(b);H[0]===31&&H[1]===139&&(n="array.nii.gz")}if(!isNaN(L)){let H=await this.fetchPartial(n,512,u);b=await H.arrayBuffer();let g=new Uint8Array(b),J=!1;g[0]===31&&g[1]===139&&(J=!0,new Decompress$1(fe=>{g=fe}).push(g),b=g.buffer);let re=g[0]===92&&g[1]===1;if(re||(re=g[1]===92&&g[0]===1),!re)b=null;else{const ae=nifti.readHeader(b);if(ae===null)throw new Error("could not read nifti header");const fe=ae.numBitsPerVoxel/8;let pe=1;for(let we=1;we<4;we++)ae.dims[we]>1&&(pe*=ae.dims[we]);let me=1;for(let we=4;we<7;we++)ae.dims[we]>1&&(me*=ae.dims[we]);const Se=Math.max(Math.min(L,me),1),ve=ae.vox_offset+Se*pe*fe;if(b.byteLength{we=De}).push(we),b=we.buffer}b.byteLength-1&&(f=f.slice(0,f.indexOf("?")))}let X=null;if(s.length>0){let H=await fetch(s,{headers:u});H.status===404&&s.lastIndexOf("BRIK")!==-1&&(H=await fetch(s+".gz",{headers:u})),X=await H.arrayBuffer()}if(!b)throw new Error("Unable to load buffer properly from volume");return z=new Zi(b,f,m,A,X,v,y,T,I,S,E,e,F,V),z.url=n,z.colorbarVisible=B,z}static readFileAsync(n,s=NaN){return new Promise((u,f)=>{const m=new FileReader;m.onload=()=>{n.name.lastIndexOf("gz")!==-1&&isNaN(s)?u(nifti.decompress(m.result)):u(m.result)},m.onerror=f,isNaN(s)?m.readAsArrayBuffer(n):m.readAsArrayBuffer(n.slice(0,s))})}static async loadFromFile({file:n,name:s="",colormap:u="gray",opacity:f=1,urlImgData:m=null,cal_min:A=NaN,cal_max:v=NaN,trustCalMinMax:y=!0,percentileFrac:T=.02,ignoreZeroVoxels:I=!1,useQFormNotSForm:S=!1,colormapNegative:E="",frame4D:e=0,limitFrames4D:F=NaN,imageType:M=NVIMAGE_TYPE.UNKNOWN}){let L=null,V=[];try{if(Array.isArray(n))for(let z=0;z{z=Y}).push(z),V=z.buffer);let W=z[0]===92&&z[1]===1;if(W||(W=z[1]===92&&z[0]===1),!W)V=await this.readFileAsync(n);else{const q=nifti.readHeader(V);if(!q)throw new Error("could not read nifti header");const Y=q.numBitsPerVoxel/8;let X=1;for(let re=1;re<4;re++)q.dims[re]>1&&(X*=q.dims[re]);let H=1;for(let re=4;re<7;re++)q.dims[re]>1&&(H*=q.dims[re]);const g=Math.max(Math.min(F,H),1),J=q.vox_offset+g*X*Y;if(V.byteLength{re=fe}).push(re),V=re.buffer}if(V.byteLength"u")return m;if(!s){const v=clone$3(this.frac2mmOrtho);return invert(v,v),transformMat4(u,u,v),m[0]=u[0],m[1]=u[1],m[2]=u[2],m}if(f[1]<1||f[2]<1||f[3]<1)return m;const A=clone$3(this.matRAS);return invert(A,A),transpose$3(A,A),transformMat4(u,u,A),m[0]=(u[0]+.5)/f[1],m[1]=(u[1]+.5)/f[2],m[2]=(u[2]+.5)/f[3],m}},DRAG_MODE=(a=>(a[a.none=0]="none",a[a.contrast=1]="contrast",a[a.measurement=2]="measurement",a[a.pan=3]="pan",a[a.slicer3D=4]="slicer3D",a[a.callbackOnly=5]="callbackOnly",a))(DRAG_MODE||{}),DEFAULT_OPTIONS={textHeight:.06,colorbarHeight:.05,crosshairWidth:1,crosshairGap:0,rulerWidth:4,show3Dcrosshair:!1,backColor:[0,0,0,1],crosshairColor:[1,0,0,1],fontColor:[.5,.5,.5,1],selectionBoxColor:[1,1,1,.5],clipPlaneColor:[.7,0,.7,.5],rulerColor:[1,0,0,.8],colorbarMargin:.05,trustCalMinMax:!0,clipPlaneHotKey:"KeyC",viewModeHotKey:"KeyV",doubleTouchTimeout:500,longTouchTimeout:1e3,keyDebounceTime:50,isNearestInterpolation:!1,isResizeCanvas:!0,atlasOutline:0,isRuler:!1,isColorbar:!1,isOrientCube:!1,multiplanarPadPixels:0,multiplanarForceRender:!1,isRadiologicalConvention:!1,meshThicknessOn2D:1/0,dragMode:1,yoke3Dto2DZoom:!1,isDepthPickMesh:!1,isCornerOrientationText:!1,sagittalNoseLeft:!1,isSliceMM:!1,isV1SliceShader:!1,isHighResolutionCapable:!0,logLevel:"info",loadingText:"waiting for images...",isForceMouseClickToVoxelCenters:!1,dragAndDropEnabled:!0,drawingEnabled:!1,penValue:1,floodFillNeighbors:6,isFilledPen:!1,thumbnail:"",maxDrawUndoBitmaps:8,sliceType:3,meshXRay:0,isAntiAlias:null,limitFrames4D:NaN,isAdditiveBlend:!1,showLegend:!0,legendBackgroundColor:[.3,.3,.3,.5],legendTextColor:[1,1,1,1],multiplanarLayout:0,renderOverlayBlend:1,sliceMosaicString:""},INITIAL_SCENE_DATA={azimuth:110,elevation:10,crosshairPos:fromValues$2(.5,.5,.5),clipPlane:[0,0,0,0],clipPlaneDepthAziElev:[2,0,0],volScaleMultiplier:1,pan2Dxyzmm:fromValues$1(0,0,0,1)},NVDocument=class Ji{constructor(){__publicField(this,"data",{title:"Untitled document",imageOptionsArray:[],meshOptionsArray:[],opts:{...DEFAULT_OPTIONS},previewImageDataURL:"",labels:[],encodedImageBlobs:[],encodedDrawingBlob:""}),__publicField(this,"scene"),__publicField(this,"volumes",[]),__publicField(this,"meshDataObjects"),__publicField(this,"meshes",[]),__publicField(this,"drawBitmap",null),__publicField(this,"imageOptionsMap",new Map),__publicField(this,"meshOptionsMap",new Map),this.scene={onAzimuthElevationChange:()=>{},onZoom3DChange:()=>{},sceneData:INITIAL_SCENE_DATA,get renderAzimuth(){return this.sceneData.azimuth},set renderAzimuth(n){this.sceneData.azimuth=n,this.onAzimuthElevationChange&&this.onAzimuthElevationChange(this.sceneData.azimuth,this.sceneData.elevation)},get renderElevation(){return this.sceneData.elevation},set renderElevation(n){this.sceneData.elevation=n,this.onAzimuthElevationChange&&this.onAzimuthElevationChange(this.sceneData.azimuth,this.sceneData.elevation)},get volScaleMultiplier(){return this.sceneData.volScaleMultiplier},set volScaleMultiplier(n){this.sceneData.volScaleMultiplier=n,this.onZoom3DChange(n)},get crosshairPos(){return this.sceneData.crosshairPos},set crosshairPos(n){this.sceneData.crosshairPos=n},get clipPlane(){return this.sceneData.clipPlane},set clipPlane(n){this.sceneData.clipPlane=n},get clipPlaneDepthAziElev(){return this.sceneData.clipPlaneDepthAziElev},set clipPlaneDepthAziElev(n){this.sceneData.clipPlaneDepthAziElev=n},get pan2Dxyzmm(){return this.sceneData.pan2Dxyzmm},set pan2Dxyzmm(n){this.sceneData.pan2Dxyzmm=n}}}get title(){return this.data.title}get previewImageDataURL(){return this.data.previewImageDataURL}set previewImageDataURL(n){this.data.previewImageDataURL=n}set title(n){this.data.title=n}get imageOptionsArray(){return this.data.imageOptionsArray}get encodedImageBlobs(){return this.data.encodedImageBlobs}get encodedDrawingBlob(){return this.data.encodedDrawingBlob}get opts(){return this.data.opts}set opts(n){this.data.opts={...n}}get labels(){return this.data.labels}set labels(n){this.data.labels=n}hasImage(n){return this.volumes.find(s=>s.id===n.id)!==void 0}hasImageFromUrl(n){return this.data.imageOptionsArray.find(s=>s.url===n)!==void 0}addImageOptions(n,s){if(!this.hasImage(n)&&!s.name)if(s.url){const f=/^(?:[a-z+]+:)?\/\//i.test(s.url)?new URL(s.url):new URL(s.url,window.location.href);s.name=f.pathname.split("/").pop(),s.name.toLowerCase().endsWith(".gz")&&(s.name=s.name.slice(0,-3)),s.name.toLowerCase().endsWith(".nii")||(s.name+=".nii")}else s.name="untitled.nii";s.imageType=NVIMAGE_TYPE.NII,this.data.imageOptionsArray.push(s),this.imageOptionsMap.set(n.id,this.data.imageOptionsArray.length-1)}removeImage(n){if(this.imageOptionsMap.has(n.id)){const s=this.imageOptionsMap.get(n.id);this.data.imageOptionsArray.length>s&&this.data.imageOptionsArray.splice(s,1),this.imageOptionsMap.delete(n.id)}this.volumes=this.volumes.filter(s=>s.id!==n.id)}getImageOptions(n){return this.imageOptionsMap.has(n.id)?this.data.imageOptionsArray[this.imageOptionsMap.get(n.id)]:null}json(){const n={encodedImageBlobs:[],previewImageDataURL:this.data.previewImageDataURL,imageOptionsMap:new Map},s=[];if(n.sceneData={...this.scene.sceneData},n.opts={...this.opts},this.opts.meshThicknessOn2D===1/0&&(n.opts.meshThicknessOn2D="infinity"),n.labels=[...this.data.labels],this.volumes.length){let f=this.imageOptionsArray[0];if(f||(log$4.debug("no image options for base image"),f={name:"",colormap:"gray",opacity:1,pairedImgData:null,cal_min:NaN,cal_max:NaN,trustCalMinMax:!0,percentileFrac:.02,ignoreZeroVoxels:!1,useQFormNotSForm:!1,colormapNegative:"",colormapLabel:[],imageType:NVIMAGE_TYPE.NII,frame4D:0,limitFrames4D:NaN,url:"",urlImageData:"",alphaThreshold:!1,cal_minNeg:NaN,cal_maxNeg:NaN,colorbarVisible:!0}),f.colormap=this.volumes[0].colormap,f.opacity=this.volumes[0].opacity,f.cal_max=this.volumes[0].cal_max||NaN,f.cal_min=this.volumes[0].cal_min||NaN,f){s.push(f);const m=NVUtilities.uint8tob64(this.volumes[0].toUint8Array());n.encodedImageBlobs.push(m),this.drawBitmap&&(n.encodedDrawingBlob=NVUtilities.uint8tob64(this.volumes[0].toUint8Array(this.drawBitmap))),n.imageOptionsMap.set(this.volumes[0].id,0)}else throw new Error("image options for base layer not found");for(let m=1;m({values:A.values,nFrame4D:A.nFrame4D,frame4D:0,outlineBorder:A.outlineBorder,global_min:A.global_min,global_max:A.global_max,cal_min:A.cal_min,cal_max:A.cal_max,opacity:A.opacity,colormap:A.colormap,colormapNegative:A.colormapNegative,colormapLabel:A.colormapLabel,useNegativeCmap:A.useNegativeCmap})),hasConnectome:f.hasConnectome,edgeColormap:f.edgeColormap,edgeColormapNegative:f.edgeColormapNegative,edgeMax:f.edgeMax,edgeMin:f.edgeMin,edges:f.edges&&Array.isArray(f.edges)?[...f.edges]:[],extentsMax:f.extentsMax,extentsMin:f.extentsMin,fiberGroupColormap:f.fiberGroupColormap,furthestVertexFromOrigin:f.furthestVertexFromOrigin,nodeColormap:f.nodeColormap,nodeColormapNegative:f.nodeColormapNegative,nodeMaxColor:f.nodeMaxColor,nodeMinColor:f.nodeMinColor,nodeScale:f.nodeScale,legendLineThickness:f.legendLineThickness,offsetPt0:f.offsetPt0,nodes:f.nodes};u.push(m)}return n.meshesString=JSON.stringify(serialize(u)),n}download(n){const s=this.json();NVUtilities.download(JSON.stringify(s),n,"application/json")}static deserializeMeshDataObjects(n){if(n.data.meshesString){n.meshDataObjects=deserialize$1(JSON.parse(n.data.meshesString));for(const s of n.meshDataObjects)for(const u of s.layers)"colorMap"in u&&(u.colormap=u.colorMap,delete u.colorMap),"colorMapNegative"in u&&(u.colormapNegative=u.colorMapNegative,delete u.colorMapNegative)}}static async loadFromUrl(n){const u=await(await fetch(n)).json();return Ji.loadFromJSON(u)}static async loadFromFile(n){const s=await NVUtilities.readFileAsync(n),u=new Ji,m=new TextDecoder().decode(s);return u.data=JSON.parse(m),Ji.deserializeMeshDataObjects(u),u}static loadFromJSON(n){const s=new Ji;return s.data=n,s.data.opts.meshThicknessOn2D==="infinity"&&(s.data.opts.meshThicknessOn2D=1/0),s.scene.sceneData=n.sceneData,Ji.deserializeMeshDataObjects(s),s}},NVLabel3D=class{constructor(a,n,s){__publicField(this,"text"),__publicField(this,"style"),__publicField(this,"points"),this.text=a,this.style=n,this.points=s}},defaultOptions={name:"untitled connectome",nodeColormap:"warm",nodeColormapNegative:"winter",nodeMinColor:0,nodeMaxColor:4,nodeScale:3,edgeColormap:"warm",edgeColormapNegative:"winter",edgeMin:2,edgeMax:6,edgeScale:1,legendLineThickness:0},NVConnectome=class Uo extends NVMesh{constructor(n,s){super(new Float32Array([]),new Uint32Array([]),s.name,new Uint8Array([]),1,!0,n,s),__publicField(this,"gl"),__publicField(this,"nodesChanged"),this.gl=n,this.type="connectome",this.nodes&&this.updateLabels(),this.nodesChanged=new EventTarget}static convertLegacyConnectome(n){const s={nodes:[],edges:[],...defaultOptions};for(const f in n)if(f in defaultOptions){const m=f;s[m]=n[m]}const u=n.nodes;for(let f=0;f({name:Array.isArray(A.comments)&&A.comments.length>0&&"text"in A.comments[0]?A.comments[0].text:"",x:A.coordinates.x,y:A.coordinates.y,z:A.coordinates.z,colorValue:1,sizeValue:1,metadata:A.comments}));return{...defaultOptions,nodeColormap:s,edgeColormap:s,nodes:f,edges:[]}}updateLabels(){const n=this.nodes;if(n&&n.length>0){const s=n.reduce((T,I)=>T.sizeValue>I.sizeValue?T:I).sizeValue,u=this.nodeMinColor?this.nodeMinColor:n.reduce((T,I)=>T.colorValueT.colorValue>I.colorValue?T:I).colorValue,m=cmapper.colormap(this.nodeColormap,this.colormapInvert),A=cmapper.colormap(this.nodeColormapNegative,this.colormapInvert),v="nodeColormapNegative"in this,y=this.legendLineThickness?this.legendLineThickness:0;for(let T=0;Te/255),log$4.debug("adding label for ",n[T]),n[T].label=new NVLabel3D(n[T].name,{textColor:E,bulletScale:n[T].sizeValue/s,bulletColor:E,lineWidth:y,lineColor:E,textScale:1,textAlignment:"left",lineTerminator:"none"},[n[T].x,n[T].y,n[T].z]),log$4.debug("label for node:",n[T].label)}}}addConnectomeNode(n){if(log$4.debug("adding node",n),!this.nodes)throw new Error("nodes not defined");this.nodes.push(n),this.updateLabels(),this.nodesChanged.dispatchEvent(new CustomEvent("nodeAdded",{detail:{node:n}}))}deleteConnectomeNode(n){const s=this.nodes.indexOf(n),u=this.edges;u&&(this.edges=u.filter(f=>f.first!==s&&f.second!==s)),this.nodes=this.nodes.filter(f=>f!==n),this.updateLabels(),this.updateConnectome(this.gl),this.nodesChanged.dispatchEvent(new CustomEvent("nodeDeleted",{detail:{node:n}}))}updateConnectomeNodeByIndex(n,s){this.nodes[n]=s,this.updateLabels(),this.updateConnectome(this.gl),this.nodesChanged.dispatchEvent(new CustomEvent("nodeChanged",{detail:{node:s}}))}updateConnectomeNodeByPoint(n,s){const u=this.nodes;if(!u)throw new Error("Node to update does not exist");const f=u.find(A=>NVUtilities.arraysAreEqual([A.x,A.y,A.z],n));if(!f)throw new Error(`Node with point ${n} to update does not exist`);const m=u.findIndex(A=>A===f);this.updateConnectomeNodeByIndex(m,s)}addConnectomeEdge(n,s,u){const f=this.edges;let m=f.find(A=>(A.first===n||A.second===n)&&A.first+A.second===n+s);return m||(m={first:n,second:s,colorValue:u},f.push(m),this.updateConnectome(this.gl),m)}deleteConnectomeEdge(n,s){const u=this.edges,f=u.find(m=>(m.first===n||m.first===s)&&m.first+m.second===n+s);if(f)this.edges=u.filter(m=>m!==f);else throw new Error(`edge between ${n} and ${s} not found`);return this.updateConnectome(this.gl),f}findClosestConnectomeNode(n,s){const u=this.nodes;if(!u||u.length===0)return null;const f=u.map((m,A)=>({node:m,distance:Math.sqrt(Math.pow(m.x-n[0],2)+Math.pow(m.y-n[1],2)+Math.pow(m.z-n[2],2)),index:A})).filter(m=>m.distancem.distance-A.distance);return f.length>0?f[0].node:null}updateConnectome(n){const s=[],u=[],f=[];let m=cmapper.colormap(this.nodeColormap,this.colormapInvert),A=cmapper.colormap(this.nodeColormapNegative,this.colormapInvert),v="nodeColormapNegative"in this;if(this.nodeMinColor===void 0||this.nodeMaxColor===void 0)throw new Error("nodeMinColor or nodeMaxColor is undefined");if(this.edgeMin===void 0||this.edgeMax===void 0)throw new Error("edgeMin or edgeMax undefined");let y=this.nodeMinColor,T=this.nodeMaxColor;const I=this.nodes,S=I.length;for(let V=0;Vm&&([f,m]=[m,f]),[f,m]}function swizzleVec3(a,n=[0,1,2]){const s=create$2();return s[0]=a[n[0]],s[1]=a[n[1]],s[2]=a[n[2]],s}function isRadiological(a){const n=fromValues$1(1,0,0,0),s=create$1();return transformMat4(s,n,a),s[0]}function unProject(a,n,s,u){const f=fromValues$1(a,n,s,1),m=clone$3(u);invert(m,m),f[0]=f[0]*2-1,f[1]=f[1]*2-1,f[2]=f[2]*2-1;const A=create$1();return transformMat4(A,f,m),A[3]===0||(A[0]/=A[3],A[1]/=A[3],A[2]/=A[3]),A}function unpackFloatFromVec4i(a){const n=[5960464477539063e-23,152587890625e-16,.00390625,1];return(a[0]*n[0]+a[1]*n[1]+a[2]*n[2]+a[3]*n[3])/255}function clamp$1(a,n,s){return Math.min(Math.max(a,n),s)}function encodeRLE(a){const n=a.length;let s=0;const u=new Uint8Array(n+Math.ceil(.01*n)),f=new Int8Array(u.buffer);let m=0;for(;s1){f[m]=-v+1,m++,u[m]=A,m++;continue}for(;s127||s+2 "+m+" bytes (x"+n/m+")"),u.slice(0,m)}function decodeRLE(a,n){const s=new Uint8Array(a.buffer),u=new Int8Array(s.buffer);let f=0;const m=new Uint8Array(n);let A=0;for(;f{}),__publicField(this,"onMouseUp",()=>{}),__publicField(this,"onLocationChange",()=>{}),__publicField(this,"onIntensityChange",()=>{}),__publicField(this,"onImageLoaded",()=>{}),__publicField(this,"onMeshLoaded",()=>{}),__publicField(this,"onFrameChange",()=>{}),__publicField(this,"onError",()=>{}),__publicField(this,"onColormapChange",()=>{}),__publicField(this,"onInfo",()=>{}),__publicField(this,"onWarn",()=>{}),__publicField(this,"onDebug",()=>{}),__publicField(this,"onVolumeAddedFromUrl",()=>{}),__publicField(this,"onVolumeWithUrlRemoved",()=>{}),__publicField(this,"onVolumeUpdated",()=>{}),__publicField(this,"onMeshAddedFromUrl",()=>{}),__publicField(this,"onMeshAdded",()=>{}),__publicField(this,"onMeshWithUrlRemoved",()=>{}),__publicField(this,"onZoom3DChange",()=>{}),__publicField(this,"onAzimuthElevationChange",()=>{}),__publicField(this,"onClipPlaneChange",()=>{}),__publicField(this,"onCustomMeshShaderAdded",()=>{}),__publicField(this,"onMeshShaderChanged",()=>{}),__publicField(this,"onMeshPropertyChanged",()=>{}),__publicField(this,"onDocumentLoaded",()=>{}),__publicField(this,"document",new NVDocument),__publicField(this,"mediaUrlMap",new Map),__publicField(this,"initialized",!1),__publicField(this,"currentDrawUndoBitmap"),__publicField(this,"loadingText");for(const s in n)typeof n[s]=="function"?this[s]=n[s]:this.opts[s]=DEFAULT_OPTIONS[s]===void 0?DEFAULT_OPTIONS[s]:n[s];this.opts.isHighResolutionCapable?this.uiData.dpr=window.devicePixelRatio||1:this.uiData.dpr=1,this.currentDrawUndoBitmap=this.opts.maxDrawUndoBitmaps,this.opts.drawingEnabled&&this.createEmptyDrawing(),this.opts.thumbnail.length>0&&(this.thumbnailVisible=!0),this.loadingText=this.opts.loadingText,log$4.setLogLevel(this.opts.logLevel)}get scene(){return this.document.scene}get opts(){return this.document.opts}get sliceMosaicString(){return this.document.opts.sliceMosaicString||""}set sliceMosaicString(n){this.document.opts.sliceMosaicString=n}get volumes(){return this.document.volumes}set volumes(n){this.document.volumes=n}get meshes(){return this.document.meshes}set meshes(n){this.document.meshes=n}get drawBitmap(){return this.document.drawBitmap}set drawBitmap(n){this.document.drawBitmap=n}get volScaleMultiplier(){return this.scene.volScaleMultiplier}set volScaleMultiplier(n){this.setScale(n)}async saveScene(n="niivue.png"){function s(f,m){const A=document.createElement("a");document.body.appendChild(A),A.style.display="none";const v=window.URL.createObjectURL(f);A.href=v,A.download=m,A.click(),A.remove()}const u=this.canvas;if(!u)throw new Error("canvas not defined");this.drawScene(),u.toBlob(f=>{f&&(n===""&&(n=`niivue-screenshot-${new Date().toString()}.png`,n=n.replace(/\s/g,"_")),s(f,n))})}async attachTo(n,s=null){return await this.attachToCanvas(document.getElementById(n),s),log$4.debug("attached to element with id: ",n),this}async attachToCanvas(n,s=null){return this.canvas=n,s===null&&(s=navigator.hardwareConcurrency>6,log$4.debug("AntiAlias ",s," Threads ",navigator.hardwareConcurrency)),this.gl=this.canvas.getContext("webgl2",{alpha:!0,antialias:s}),log$4.info("NIIVUE VERSION ",version$1),this.canvas.parentElement.style.backgroundColor="black",this.opts.isResizeCanvas&&(this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.display="block",this.canvas.width=this.canvas.offsetWidth,this.canvas.height=this.canvas.offsetHeight,window.addEventListener("resize",this.resizeListener.bind(this)),this.resizeObserver=new ResizeObserver(this.resizeListener.bind(this)),this.resizeObserver.observe(this.canvas.parentElement)),this.registerInteractions(),await this.init(),this.drawScene(),this}syncWith(n,s={"2d":!0,"3d":!0}){this.otherNV=n,this.syncOpts=s}broadcastTo(n,s={"2d":!0,"3d":!0}){this.otherNV=n,this.syncOpts=s}sync(){if(!this.gl||!this.otherNV||typeof this.otherNV>"u"||!this.gl.canvas.matches(":focus"))return;const n=this.frac2mm(this.scene.crosshairPos);if(this.otherNV instanceof zo)this.syncOpts["2d"]&&(this.otherNV.scene.crosshairPos=this.otherNV.mm2frac(n)),this.syncOpts["3d"]&&(this.otherNV.scene.renderAzimuth=this.scene.renderAzimuth,this.otherNV.scene.renderElevation=this.scene.renderElevation),this.otherNV.drawScene(),this.otherNV.createOnLocationChange();else if(Array.isArray(this.otherNV))for(let s=0;su===s[f])}resizeListener(){if(!(!this.canvas||!this.gl)){if(!this.opts.isResizeCanvas){this.opts.isHighResolutionCapable&&(log$4.warn("isHighResolutionCapable requires isResizeCanvas"),this.opts.isHighResolutionCapable=!1),this.uiData.dpr=1,this.drawScene();return}this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.display="block",this.opts.isHighResolutionCapable?(this.uiData.dpr=window.devicePixelRatio||1,log$4.debug("devicePixelRatio: "+this.uiData.dpr)):this.uiData.dpr=1,"width"in this.canvas.parentElement?(this.canvas.width=this.canvas.parentElement.width*this.uiData.dpr,this.canvas.height=this.canvas.parentElement.height*this.uiData.dpr):(this.canvas.width=this.canvas.offsetWidth*this.uiData.dpr,this.canvas.height=this.canvas.offsetHeight*this.uiData.dpr),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.drawScene()}}getRelativeMousePosition(n,s){if(s=s||n.target,!s)return;const u=s.getBoundingClientRect();return{x:n.clientX-u.left,y:n.clientY-u.top}}getNoPaddingNoBorderCanvasRelativeMousePosition(n,s){return s=s||n.target,this.getRelativeMousePosition(n,s)}mouseContextMenuListener(n){n.preventDefault()}mouseDownListener(n){n.preventDefault(),this.drawPenLocation=[NaN,NaN,NaN],this.drawPenAxCorSag=-1,this.uiData.mousedown=!0,log$4.debug("mouse down"),log$4.debug(n);const s=this.getNoPaddingNoBorderCanvasRelativeMousePosition(n,this.gl.canvas);if(!s)return;const[u,f]=[s.x*this.uiData.dpr,s.y*this.uiData.dpr],m=this.getLabelAtPoint([u,f]);if(m){for(const A of this.meshes)if(A.type==="connectome")for(const v of A.nodes)v.label===m&&(this.scene.crosshairPos=this.mm2frac([v.x,v.y,v.z]),this.updateGLVolume(),this.drawScene())}this.uiData.clickedTile=this.tileIndex(u,f),n.button===LEFT_MOUSE_BUTTON&&n.shiftKey?(this.uiData.mouseButtonCenterDown=!0,this.mouseCenterButtonHandler(n)):n.button===LEFT_MOUSE_BUTTON?(this.uiData.mouseButtonLeftDown=!0,this.mouseLeftButtonHandler(n)):n.button===RIGHT_MOUSE_BUTTON?(this.uiData.mouseButtonRightDown=!0,this.mouseRightButtonHandler(n)):n.button===CENTER_MOUSE_BUTTON&&(this.uiData.mouseButtonCenterDown=!0,this.mouseCenterButtonHandler(n))}mouseLeftButtonHandler(n){const s=this.getNoPaddingNoBorderCanvasRelativeMousePosition(n,this.gl.canvas);this.mouseDown(s.x,s.y),this.mouseClick(s.x,s.y)}mouseCenterButtonHandler(n){const s=this.getNoPaddingNoBorderCanvasRelativeMousePosition(n,this.gl.canvas);this.mousePos=[s.x*this.uiData.dpr,s.y*this.uiData.dpr],this.opts.dragMode!==0&&(this.setDragStart(s.x,s.y),this.uiData.isDragging||(this.uiData.pan2DxyzmmAtMouseDown=clone$1(this.scene.pan2Dxyzmm)),this.uiData.isDragging=!0,this.uiData.dragClipPlaneStartDepthAziElev=this.scene.clipPlaneDepthAziElev)}mouseRightButtonHandler(n){const s=this.getNoPaddingNoBorderCanvasRelativeMousePosition(n,this.gl.canvas);this.mousePos=[s.x*this.uiData.dpr,s.y*this.uiData.dpr],this.opts.dragMode!==0&&(this.setDragStart(s.x,s.y),this.uiData.isDragging||(this.uiData.pan2DxyzmmAtMouseDown=clone$1(this.scene.pan2Dxyzmm)),this.uiData.isDragging=!0,this.uiData.dragClipPlaneStartDepthAziElev=this.scene.clipPlaneDepthAziElev)}calculateMinMaxVoxIdx(n){if(n.length>2)throw new Error("array must not contain more than two values");return[Math.floor(Math.min(n[0],n[1])),Math.floor(Math.max(n[0],n[1]))]}calculateNewRange({volIdx:n=0}={}){if(this.opts.sliceType===4&&this.sliceMosaicString.length<1||this.uiData.dragStart[0]===this.uiData.dragEnd[0]&&this.uiData.dragStart[1]===this.uiData.dragEnd[1])return;let s=this.canvasPos2frac([this.uiData.dragStart[0],this.uiData.dragStart[1]]);if(s[0]<0)return;const u=this.frac2vox(s,n);if(s=this.canvasPos2frac([this.uiData.dragEnd[0],this.uiData.dragEnd[1]]),s[0]<0)return;const f=this.frac2vox(s,n);let m=-Number.MAX_VALUE,A=Number.MAX_VALUE;const v=this.calculateMinMaxVoxIdx([u[0],f[0]]),y=this.calculateMinMaxVoxIdx([u[1],f[1]]),T=this.calculateMinMaxVoxIdx([u[2],f[2]]);u[0]-f[0]===0?v[1]=u[0]+1:u[1]-f[1]===0?y[1]=u[1]+1:u[2]-f[2]===0&&(T[1]=u[2]+1);const I=this.volumes[n].hdr,S=this.volumes[n].img;if(!I||!S)return;const E=I.dims[1],e=I.dims[2];for(let L=T[0];LS[W]&&(A=S[W]),m=m)return;const F=intensityRaw2Scaled(I,A),M=intensityRaw2Scaled(I,m);this.volumes[n].cal_min=F,this.volumes[n].cal_max=M,this.onIntensityChange(this.volumes[n])}generateMouseUpCallback(n,s){const u=this.tileIndex(this.uiData.dragStart[0],this.uiData.dragStart[1]),f=this.tileIndex(this.uiData.dragEnd[0],this.uiData.dragEnd[1]);let m=-1;u===f&&(m=f);let A=-1;m>=0&&(A=this.screenSlices[m].axCorSag);const v=this.frac2mm(n),y=this.frac2mm(s),T=create$2();sub$4(T,fromValues$2(v[0],v[1],v[2]),fromValues$2(y[0],y[1],y[2]));const I=len(T),S=this.frac2vox(n),E=this.frac2vox(s);this.onDragRelease({fracStart:n,fracEnd:s,voxStart:S,voxEnd:E,mmStart:v,mmEnd:y,mmLength:I,tileIdx:m,axCorSag:A})}mouseUpListener(){function n(f){return Object.prototype.toString.call(f).indexOf("Function")>-1}const s={mouseButtonRightDown:this.uiData.mouseButtonRightDown,mouseButtonCenterDown:this.uiData.mouseButtonCenterDown,isDragging:this.uiData.isDragging,mousePos:this.mousePos,fracPos:this.canvasPos2frac(this.mousePos)};this.uiData.mousedown=!1,this.uiData.mouseButtonRightDown=!1;const u=this.uiData.mouseButtonCenterDown;if(this.uiData.mouseButtonCenterDown=!1,this.uiData.mouseButtonLeftDown=!1,this.drawPenFillPts.length>0?this.drawPenFilled():this.drawPenAxCorSag>=0&&this.drawAddUndoBitmap(),this.drawPenLocation=[NaN,NaN,NaN],this.drawPenAxCorSag=-1,n(this.onMouseUp)&&this.onMouseUp(s),this.uiData.isDragging){this.uiData.isDragging=!1,this.opts.dragMode===5&&this.drawScene();const f=this.canvasPos2frac([this.uiData.dragStart[0],this.uiData.dragStart[1]]),m=this.canvasPos2frac([this.uiData.dragEnd[0],this.uiData.dragEnd[1]]);if(this.generateMouseUpCallback(f,m),this.opts.dragMode!==1||u||this.uiData.dragStart[0]===this.uiData.dragEnd[0]&&this.uiData.dragStart[1]===this.uiData.dragEnd[1])return;this.calculateNewRange({volIdx:0}),this.refreshLayers(this.volumes[0],0)}this.drawScene()}checkMultitouch(n){if(this.uiData.touchdown&&!this.uiData.multiTouchGesture){const s=this.canvas.getBoundingClientRect();this.mouseDown(n.touches[0].clientX-s.left,n.touches[0].clientY-s.top),this.mouseClick(n.touches[0].clientX-s.left,n.touches[0].clientY-s.top)}}touchStartListener(n){n.preventDefault(),this.uiData.touchTimer||(this.uiData.touchTimer=setTimeout(()=>{this.resetBriCon(n)},this.opts.longTouchTimeout)),this.uiData.touchdown=!0,this.uiData.currentTouchTime=new Date().getTime();const s=this.uiData.currentTouchTime-this.uiData.lastTouchTime;if(s0){this.uiData.doubleTouch=!0,this.setDragStart(n.targetTouches[0].clientX-n.target.getBoundingClientRect().left,n.targetTouches[0].clientY-n.target.getBoundingClientRect().top),this.resetBriCon(n),this.uiData.lastTouchTime=this.uiData.currentTouchTime;return}else this.uiData.doubleTouch=!1,this.setDragStart(0,0),this.setDragEnd(0,0),this.uiData.lastTouchTime=this.uiData.currentTouchTime;this.uiData.touchdown&&n.touches.length<2?this.uiData.multiTouchGesture=!1:this.uiData.multiTouchGesture=!0,setTimeout(this.checkMultitouch.bind(this),1,n)}touchEndListener(n){if(n.preventDefault(),this.uiData.touchdown=!1,this.uiData.lastTwoTouchDistance=0,this.uiData.multiTouchGesture=!1,this.uiData.touchTimer&&(clearTimeout(this.uiData.touchTimer),this.uiData.touchTimer=null),this.uiData.isDragging){this.uiData.isDragging=!1,this.opts.dragMode===1&&(this.calculateNewRange(),this.refreshLayers(this.volumes[0],0));const s=this.canvasPos2frac([this.uiData.dragStart[0],this.uiData.dragStart[1]]),u=this.canvasPos2frac([this.uiData.dragEnd[0],this.uiData.dragEnd[1]]);this.generateMouseUpCallback(s,u)}this.mouseUpListener()}mouseMoveListener(n){if(this.uiData.mousedown){const s=this.getNoPaddingNoBorderCanvasRelativeMousePosition(n,this.gl.canvas);if(!s)return;const u=s.x*this.uiData.dpr,f=s.y*this.uiData.dpr;if(this.tileIndex(u,f)!==this.uiData.clickedTile)return;this.uiData.mouseButtonLeftDown?(this.mouseMove(s.x,s.y),this.mouseClick(s.x,s.y)):(this.uiData.mouseButtonRightDown||this.uiData.mouseButtonCenterDown)&&this.setDragEnd(s.x,s.y),this.drawScene(),this.uiData.prevX=this.uiData.currX,this.uiData.prevY=this.uiData.currY}}resetBriCon(n=null){if(this.uiData.isDragging)return;let s=!1;this.opts.sliceType===4&&(s=!0);let u=0,f=0;if(n!==null&&("targetTouches"in n?(u=n.targetTouches[0].clientX-n.target.getBoundingClientRect().left,f=n.targetTouches[0].clientY-n.target.getBoundingClientRect().top):(u=n.offsetX,f=n.offsetY),u*=this.uiData.dpr,f*=this.uiData.dpr,this.inRenderTile(u,f)>=0&&(s=!0)),s){this.uiData.mouseDepthPicker=!0,this.drawScene(),this.drawScene();return}this.opts.dragMode!==4&&(this.volumes.length<1||this.uiData.doubleTouch||(this.volumes[0].cal_min=this.volumes[0].robust_min,this.volumes[0].cal_max=this.volumes[0].robust_max,this.onIntensityChange(this.volumes[0]),this.refreshLayers(this.volumes[0],0),this.drawScene()))}setDragStart(n,s){n*=this.uiData.dpr,s*=this.uiData.dpr,this.uiData.dragStart[0]=n,this.uiData.dragStart[1]=s}setDragEnd(n,s){n*=this.uiData.dpr,s*=this.uiData.dpr,this.uiData.dragEnd[0]=n,this.uiData.dragEnd[1]=s}touchMoveListener(n){if(this.uiData.touchdown&&n.touches.length<2){const s=this.canvas.getBoundingClientRect();if(this.uiData.isDragging||(this.uiData.pan2DxyzmmAtMouseDown=clone$1(this.scene.pan2Dxyzmm)),this.uiData.isDragging=!0,this.uiData.doubleTouch&&this.uiData.isDragging){this.setDragEnd(n.targetTouches[0].clientX-n.target.getBoundingClientRect().left,n.targetTouches[0].clientY-n.target.getBoundingClientRect().top),this.drawScene();return}this.mouseClick(n.touches[0].clientX-s.left,n.touches[0].clientY-s.top),this.mouseMove(n.touches[0].clientX-s.left,n.touches[0].clientY-s.top)}else this.handlePinchZoom(n)}handlePinchZoom(n){if(n.targetTouches.length===2&&n.changedTouches.length===2){const s=Math.hypot(n.touches[0].pageX-n.touches[1].pageX,n.touches[0].pageY-n.touches[1].pageY),u=this.canvas.getBoundingClientRect();this.mousePos=[n.touches[0].clientX-u.left,n.touches[0].clientY-u.top],sthis.opts.keyDebounceTime){switch(this.currentClipPlaneIndex=(this.currentClipPlaneIndex+1)%7,this.currentClipPlaneIndex){case 0:this.scene.clipPlaneDepthAziElev=[2,0,0];break;case 1:this.scene.clipPlaneDepthAziElev=[0,270,0];break;case 2:this.scene.clipPlaneDepthAziElev=[0,90,0];break;case 3:this.scene.clipPlaneDepthAziElev=[0,0,0];break;case 4:this.scene.clipPlaneDepthAziElev=[0,180,0];break;case 5:this.scene.clipPlaneDepthAziElev=[0,0,-90];break;case 6:this.scene.clipPlaneDepthAziElev=[0,0,90];break}this.setClipPlane(this.scene.clipPlaneDepthAziElev)}this.lastCalled=s}else if(n.code===this.opts.viewModeHotKey){const s=new Date().getTime();s-this.lastCalled>this.opts.keyDebounceTime&&(this.setSliceType((this.opts.sliceType+1)%5),this.lastCalled=s)}}keyDownListener(n){n.code==="KeyH"&&this.opts.sliceType===4?this.setRenderAzimuthElevation(this.scene.renderAzimuth-1,this.scene.renderElevation):n.code==="KeyL"&&this.opts.sliceType===4?this.setRenderAzimuthElevation(this.scene.renderAzimuth+1,this.scene.renderElevation):n.code==="KeyJ"&&this.opts.sliceType===4?this.setRenderAzimuthElevation(this.scene.renderAzimuth,this.scene.renderElevation+1):n.code==="KeyK"&&this.opts.sliceType===4?this.setRenderAzimuthElevation(this.scene.renderAzimuth,this.scene.renderElevation-1):n.code==="KeyH"&&this.opts.sliceType!==4?this.moveCrosshairInVox(-1,0,0):n.code==="KeyL"&&this.opts.sliceType!==4?this.moveCrosshairInVox(1,0,0):n.code==="KeyU"&&this.opts.sliceType!==4&&n.ctrlKey?this.moveCrosshairInVox(0,0,1):n.code==="KeyD"&&this.opts.sliceType!==4&&n.ctrlKey?this.moveCrosshairInVox(0,0,-1):n.code==="KeyJ"&&this.opts.sliceType!==4?this.moveCrosshairInVox(0,-1,0):n.code==="KeyK"&&this.opts.sliceType!==4?this.moveCrosshairInVox(0,1,0):n.code==="KeyM"&&this.opts.sliceType!==4?(this.opts.dragMode++,this.opts.dragMode>=4&&(this.opts.dragMode=0),log$4.info("drag mode changed to ",DRAG_MODE[this.opts.dragMode])):n.code==="ArrowLeft"?this.setFrame4D(this.volumes[0].id,this.volumes[0].frame4D-1):n.code==="ArrowRight"?this.setFrame4D(this.volumes[0].id,this.volumes[0].frame4D+1):n.code==="Slash"&&n.shiftKey&&alert(`NIIVUE VERSION: ${version$1}`)}wheelListener(n){if(n.preventDefault(),n.stopPropagation(),this.thumbnailVisible)return;const s=this.canvas.getBoundingClientRect();n.deltaY<0?this.sliceScroll2D(-.01,n.clientX-s.left,n.clientY-s.top):this.sliceScroll2D(.01,n.clientX-s.left,n.clientY-s.top)}registerInteractions(){if(!this.canvas)throw new Error("canvas undefined");this.canvas.addEventListener("mousedown",this.mouseDownListener.bind(this)),this.canvas.addEventListener("mouseup",this.mouseUpListener.bind(this)),this.canvas.addEventListener("mousemove",this.mouseMoveListener.bind(this)),this.canvas.addEventListener("touchstart",this.touchStartListener.bind(this)),this.canvas.addEventListener("touchend",this.touchEndListener.bind(this)),this.canvas.addEventListener("touchmove",this.touchMoveListener.bind(this)),this.canvas.addEventListener("wheel",this.wheelListener.bind(this)),this.canvas.addEventListener("contextmenu",this.mouseContextMenuListener.bind(this)),this.canvas.addEventListener("dblclick",this.resetBriCon.bind(this)),this.canvas.addEventListener("dragenter",this.dragEnterListener.bind(this),!1),this.canvas.addEventListener("dragover",this.dragOverListener.bind(this),!1),this.canvas.addEventListener("drop",this.dropListener.bind(this),!1),this.canvas.setAttribute("tabindex","0"),this.canvas.addEventListener("keyup",this.keyUpListener.bind(this),!1),this.canvas.addEventListener("keydown",this.keyDownListener.bind(this),!1)}dragEnterListener(n){n.stopPropagation(),n.preventDefault()}dragOverListener(n){n.stopPropagation(),n.preventDefault()}getFileExt(n,s=!0){log$4.debug("fullname: ",n);const u=/(?:\.([^.]+))?$/;let f=u.exec(n)[1];return f=f.toUpperCase(),f==="GZ"&&(f=u.exec(n.slice(0,-3))[1],f=f.toUpperCase()),s?f:f.toLowerCase()}async addVolumeFromUrl(n){const s=await NVImage.loadFromUrl(n);return this.document.addImageOptions(s,n),s.onColormapChange=this.onColormapChange,this.mediaUrlMap.set(s,n.url),this.onVolumeAddedFromUrl&&this.onVolumeAddedFromUrl(n,s),this.addVolume(s),s}getMediaByUrl(n){return[...this.mediaUrlMap.entries()].filter(s=>s[1]===n).map(s=>s[0]).pop()}removeVolumeByUrl(n){const s=this.getMediaByUrl(n);if(s)this.removeVolume(s);else throw new Error("No volume with URL present")}readDirectory(n){const s=n.createReader();let u=[];const f=async A=>{const v=[],y=async T=>new Promise((I,S)=>T.file(I,S));for(let T=0;T{s.readEntries(A=>{A.length?(u=u.concat(A),m()):f(u).then(v=>{NVImage.loadFromFile({file:v,name:n.name,urlImgData:null,imageType:NVIMAGE_TYPE.DCM_FOLDER}).then(y=>this.addVolume(y)).catch(y=>{throw y})}).catch(v=>{throw v})})};return m(),u}isMeshExt(n){const s=this.getFileExt(n);return log$4.debug("dropped ext"),log$4.debug(s),MESH_EXTENSIONS.includes(s)}dropListener(n){if(n.stopPropagation(),n.preventDefault(),!this.opts.dragAndDropEnabled)return;const s=n.dataTransfer;if(!s)return;const u=s.getData("text/uri-list");if(u){const f=NVImageFromUrlOptions(u),m=this.getFileExt(u);log$4.debug("dropped ext"),log$4.debug(m),MESH_EXTENSIONS.includes(m)?this.addMeshFromUrl({url:u}).catch(A=>{throw A}):m==="NVD"?this.loadDocumentFromUrl(u).catch(A=>{throw A}):this.addVolumeFromUrl(f).catch(A=>{throw A})}else{const f=s.items;if(f.length>0){!n.shiftKey&&!n.altKey&&(this.volumes=[],this.overlays=[],this.meshes=[]),this.closeDrawing();for(const m of Array.from(f)){const A=m.webkitGetAsEntry();if(log$4.debug(A),!A)throw new Error("could not get entry from file");if(A.isFile){const v=this.getFileExt(A.name);if(v==="PNG"){A.file(T=>{this.loadBmpTexture(T).catch(I=>{throw I})});continue}let y;if(A.name.lastIndexOf("HEAD")!==-1)for(const T of Array.from(f)){const I=T.webkitGetAsEntry();if(!I)throw new Error("could not get paired entry");const S=A.name.substring(0,A.name.lastIndexOf("HEAD")),E=I.name.substring(0,I.name.lastIndexOf("BRIK"));S===E&&(y=I)}if(A.name.lastIndexOf("BRIK")!==-1)continue;if(MESH_EXTENSIONS.includes(v)){A.file(T=>{NVMesh.loadFromFile({file:T,gl:this.gl,name:T.name}).then(I=>{this.addMesh(I)}).catch(I=>{throw I})});continue}else if(v==="NVD"){A.file(T=>{NVDocument.loadFromFile(T).then(I=>{this.loadDocument(I),log$4.debug("loaded document")}).catch(I=>{throw I})});break}A.file(T=>{y?y.file(I=>{NVImage.loadFromFile({file:T,urlImgData:I,limitFrames4D:this.opts.limitFrames4D}).then(S=>{this.addVolume(S)}).catch(S=>{throw S})}):NVImage.loadFromFile({file:T,urlImgData:y,limitFrames4D:this.opts.limitFrames4D}).then(I=>{n.altKey?(log$4.debug("alt key detected: assuming this is a drawing overlay"),this.drawClearAllUndoBitmaps(),this.loadDrawing(I)):this.addVolume(I)}).catch(I=>{throw I})})}else A.isDirectory&&this.readDirectory(A)}}}this.drawScene()}setMultiplanarPadPixels(n){this.opts.multiplanarPadPixels=n,this.drawScene()}setMultiplanarLayout(n){typeof n=="string"&&(n=parseInt(n)),this.opts.multiplanarLayout=n,this.drawScene()}setCornerOrientationText(n){this.opts.isCornerOrientationText=n,this.updateGLVolume()}setRadiologicalConvention(n){this.opts.isRadiologicalConvention=n,this.updateGLVolume()}setDefaults(n={},s=!1){this.document.opts={...DEFAULT_OPTIONS},this.scene.sceneData={...INITIAL_SCENE_DATA};for(const u in n)typeof n[u]=="function"?this[u]=n[u]:this.opts[u]=DEFAULT_OPTIONS[u]===void 0?DEFAULT_OPTIONS[u]:n[u];if(this.scene.pan2Dxyzmm=[0,0,0,1],s&&this.volumes&&this.volumes.length>0)for(let u=0;u=this.opts.maxDrawUndoBitmaps&&(this.currentDrawUndoBitmap=0),this.drawUndoBitmaps[this.currentDrawUndoBitmap]=encodeRLE(this.drawBitmap)}drawClearAllUndoBitmaps(){if(this.currentDrawUndoBitmap=this.opts.maxDrawUndoBitmaps,!(!this.drawUndoBitmaps||this.drawUndoBitmaps.length<1))for(let n=this.drawUndoBitmaps.length-1;n>=0;n--)this.drawUndoBitmaps[n]=new Uint8Array}drawUndo(){if(this.drawUndoBitmaps.length<1){log$4.debug("undo bitmaps not loaded");return}if(this.currentDrawUndoBitmap--,this.currentDrawUndoBitmap<0&&(this.currentDrawUndoBitmap=this.drawUndoBitmaps.length-1),this.currentDrawUndoBitmap>=this.drawUndoBitmaps.length&&(this.currentDrawUndoBitmap=0),this.drawUndoBitmaps[this.currentDrawUndoBitmap].length<2){log$4.debug("drawUndo is misbehaving");return}this.drawBitmap=decodeRLE(this.drawUndoBitmaps[this.currentDrawUndoBitmap],this.drawBitmap.length),this.refreshDrawing(!0)}loadDrawing(n){if(this.drawBitmap&&log$4.debug("Overwriting open drawing!"),!this.back)throw new Error("back undefined");this.drawClearAllUndoBitmaps();const s=n.hdr.dims;if(s[1]!==this.back.hdr.dims[1]||s[2]!==this.back.hdr.dims[2]||s[3]!==this.back.hdr.dims[3])return log$4.debug("drawing dimensions do not match background image"),!1;n.img.constructor!==Uint8Array&&log$4.debug("Drawings should be UINT8");const u=n.permRAS,f=s[1]*s[2]*s[3];this.drawBitmap=new Uint8Array(f),this.drawTexture=this.r8Tex(this.drawTexture,TEXTURE7_DRAW,this.back.dims,!0);const m=[0,0,0];for(let M=0;M<3;M++)for(let L=0;L<3;L++)Math.abs(u[M])-1===L&&(m[L]=M*Math.sign(u[M]));let A=1;const v=[1,1,1],y=[!1,!1,!1];for(let M=0;MArray(f).fill(0)),M=Array(f).fill(0).map(()=>Array(f).fill(0));for(let B=1;B3)for(let B=0;BL&&(V[0]=B,V[1]=z,V[2]=b,L=W)}else if(n===3)for(let B=0;BL&&(V[0]=B,V[1]=z,L=b)}else for(let B=0;BL&&(V[0]=B,L=z)}return[I(V[0]),I(V[1]),I(V[2])]}drawOtsu(n=2){if(this.volumes.length===0)return;const s=this.volumes[0].img.length,u=this.findOtsu(n);if(u.length<3)return;this.drawBitmap||this.createEmptyDrawing();const f=this.drawBitmap,m=this.volumes[0].img;for(let A=0;Au[0]&&(f[A]=1),v>u[1]&&(f[A]=2),v>u[2]&&(f[A]=3)}this.drawAddUndoBitmap(),this.refreshDrawing(!0)}removeHaze(n=5,s=0){const u=this.volumes[s].img,f=this.volumes[s].hdr,m=u.length;let A=2;(n===5||n===1)&&(A=4),(n===4||n===2)&&(A=3);const v=this.findOtsu(A);if(v.length<3)return;let y=v[0];n===1&&(y=v[2]),n===2&&(y=v[1]);const T=f.scl_inter,I=f.scl_slope,S=this.volumes[s].global_min;for(let E=0;E=this.meshes.length?-1:n;const s=this.meshes.length;for(let u=0;uu)return;const f=this.getVolumeIndexByID(n.id);s===0?(this.volumes.splice(f,1),this.volumes.unshift(n),this.back=this.volumes[0],this.overlays=this.volumes.slice(1)):s<0?(this.volumes.splice(this.getVolumeIndexByID(n.id),1),this.back=this.volumes[0],this.volumes.length>1?this.overlays=this.volumes.slice(1):this.overlays=[]):(this.volumes.splice(f,1),this.volumes.splice(s,0,n),this.overlays=this.volumes.slice(1),this.back=this.volumes[0]),this.updateGLVolume()}setMesh(n,s=0){this.meshes.forEach(m=>{log$4.debug("MESH: ",m.name)});const u=this.meshes.length;if(s>u)return;const f=this.getMeshIndexByID(n.id);s===0?(this.meshes.splice(f,1),this.meshes.unshift(n)):s<0?this.meshes.splice(this.getMeshIndexByID(n.id),1):(this.meshes.splice(f,1),this.meshes.splice(s,0,n)),this.updateGLVolume(),this.meshes.forEach(m=>{log$4.debug(m.name)})}removeVolume(n){if(this.setVolume(n,-1),this.mediaUrlMap.has(n)){const s=this.mediaUrlMap.get(n);this.onVolumeWithUrlRemoved(s),this.mediaUrlMap.delete(n)}this.drawScene()}removeVolumeByIndex(n){if(n>=this.volumes.length)throw new Error("Index of volume out of bounds");this.removeVolume(this.volumes[n])}removeMesh(n){if(this.setMesh(n,-1),this.mediaUrlMap.has(n)){const s=this.mediaUrlMap.get(n);this.onMeshWithUrlRemoved(s),this.mediaUrlMap.delete(n)}}removeMeshByUrl(n){const s=this.getMediaByUrl(n);s&&(this.removeMesh(s),this.mediaUrlMap.delete(s),this.onMeshWithUrlRemoved(n))}moveVolumeToBottom(n){this.setVolume(n,0)}moveVolumeUp(n){const s=this.getVolumeIndexByID(n.id);this.setVolume(n,s+1)}moveVolumeDown(n){const s=this.getVolumeIndexByID(n.id);this.setVolume(n,s-1)}moveVolumeToTop(n){this.setVolume(n,this.volumes.length-1)}mouseDown(n,s){n*=this.uiData.dpr,s*=this.uiData.dpr,this.mousePos=[n,s]}mouseMove(n,s){n*=this.uiData.dpr,s*=this.uiData.dpr;const u=(n-this.mousePos[0])/this.uiData.dpr,f=(s-this.mousePos[1])/this.uiData.dpr;this.mousePos=[n,s],!(this.inRenderTile(n,s)<0)&&(Math.abs(u)<1&&Math.abs(f)<1||(this.scene.renderAzimuth+=u,this.scene.renderElevation+=f,this.drawScene()))}sph2cartDeg(n,s){const u=-s*(Math.PI/180),f=(n-90)%360*(Math.PI/180),m=[Math.cos(u)*Math.cos(f),Math.cos(u)*Math.sin(f),Math.sin(u)],A=Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2]);return A<=0||(m[0]/=A,m[1]/=A,m[2]/=A),m}setClipPlane(n){const s=this.sph2cartDeg(n[1]+180,n[2]);this.scene.clipPlane=[s[0],s[1],s[2],n[0]],this.scene.clipPlaneDepthAziElev=n,this.onClipPlaneChange(this.scene.clipPlane),this.drawScene()}setCrosshairColor(n){this.opts.crosshairColor=n,this.drawScene()}setCrosshairWidth(n){this.opts.crosshairWidth=n,this.crosshairs3D&&(this.crosshairs3D.mm[0]=NaN),this.drawScene()}setDrawColormap(n){this.drawLut=cmapper.makeDrawLut(n),this.updateGLVolume()}setDrawingEnabled(n){this.opts.drawingEnabled=n,this.opts.drawingEnabled&&(this.drawBitmap||this.createEmptyDrawing()),this.drawScene()}setPenValue(n,s=!1){this.opts.penValue=n,this.opts.isFilledPen=s,this.drawScene()}setDrawOpacity(n){this.drawOpacity=n,this.drawScene()}setSelectionBoxColor(n){this.opts.selectionBoxColor=n}sliceScroll2D(n,s,u,f=!0){if(this.inGraphTile(s,u)){let m=this.volumes[0].frame4D;n>0&&m++,n<0&&m--,this.setFrame4D(this.volumes[0].id,m);return}if(n!==0&&this.opts.dragMode===3&&this.inRenderTile(this.uiData.dpr*s,this.uiData.dpr*u)===-1){let m=this.scene.pan2Dxyzmm[3]*(1+10*n);m=Math.round(m*10)/10;const A=this.scene.pan2Dxyzmm[3]-m;this.opts.yoke3Dto2DZoom&&(this.scene.volScaleMultiplier=m),this.scene.pan2Dxyzmm[3]=m;const v=this.frac2mm(this.scene.crosshairPos);this.scene.pan2Dxyzmm[0]+=A*v[0],this.scene.pan2Dxyzmm[1]+=A*v[1],this.scene.pan2Dxyzmm[2]+=A*v[2],this.drawScene();return}this.mouseClick(s,u,n,f)}setSliceType(n){return this.opts.sliceType=n,this.drawScene(),this}setOpacity(n,s){if(this.volumes[n].opacity=s,n===0){this.drawScene();return}this.updateGLVolume()}setScale(n){this.scene.volScaleMultiplier=n,this.drawScene()}setClipPlaneColor(n){this.opts.clipPlaneColor=n,this.renderShader.use(this.gl),this.gl.uniform4fv(this.renderShader.uniforms.clipPlaneColor,this.opts.clipPlaneColor),this.drawScene()}async setVolumeRenderIllumination(n=0){this.renderShader=this.renderVolumeShader,n>0&&(this.renderShader=this.renderGradientShader),n<0&&(this.renderShader=this.renderSliceShader),this.initRenderShader(this.renderShader,n),this.renderShader.use(this.gl),this.setClipPlaneColor(this.opts.clipPlaneColor),this.gradientTextureAmount=n,this.refreshLayers(this.volumes[0],0),this.drawScene()}overlayRGBA(n){const s=n.hdr,u=s.dims[1]*s.dims[2]*s.dims[3],f=new Uint8ClampedArray(u*4),m=.2*Math.min(Math.min(s.dims[1],s.dims[2]),s.dims[3]),A=.5*s.dims[1],v=.5*s.dims[2],y=.5*s.dims[3];let T=0;for(let I=0;I0&&(this.back=this.volumes[0]);const f=n.encodedDrawingBlob;if(f){const m=n.imageOptionsArray[0],A=NVImage.loadFromBase64({base64:f,...m});A&&this.loadDrawing(A)}for(const m of n.meshDataObjects??[]){const A={gl:this.gl,...m};log$4.debug(A);const v=new NVMesh(A.pts,A.tris,A.name,A.rgba255,A.opacity,A.visible,this.gl,A.connectome,A.dpg,A.dps,A.dpv);v.meshShaderIndex=A.meshShaderIndex,v.layers=A.layers,v.updateMesh(this.gl),log$4.debug(v),this.addMesh(v)}if(n.data.connectomes)for(const m of n.data.connectomes){const A=JSON.parse(m);this.loadConnectome(A)}return this.updateGLVolume(),this.drawScene(),this.onDocumentLoaded(n),this}generateLoadDocumentJavaScript(n,s){const u=this.json(),f=NVUtilities.compressToBase64String(JSON.stringify(u));return` ${s} function saveNiivueAsHtml(pageName) { @@ -1700,7 +1700,7 @@ void main(void) { <\/script> `}saveHTML(n="untitled.html",s="gl1",u){const f=this.generateHTML(s,u);NVUtilities.download(f,n,"application/html")}json(){this.document.opts=this.opts,this.document.scene=this.scene,this.document.volumes=this.volumes,this.document.meshes=this.meshes,this.drawScene(),this.document.previewImageDataURL=this.canvas.toDataURL();const n=this.document.json();return n.sceneData={...this.scene},n}async saveDocument(n="untitled.nvd"){this.document.opts=this.opts,this.document.scene=this.scene,this.document.title=n,log$4.debug("saveDocument",this.volumes[0]),this.drawScene(),this.document.previewImageDataURL=this.canvas.toDataURL(),this.document.download(n)}async loadVolumes(n){if(this.loadingText="loading...",this.drawScene(),this.thumbnailVisible)return this.deferredVolumes=n,this;this.volumes=[],this.gl.clearColor(0,0,0,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT);for(let s=0;s0&&(m[W]=T);const I=this.r16Tex(null,TEXTURE12_GC_STRENGTH0,this.back.dims,m),S=this.r16Tex(null,TEXTURE13_GC_STRENGTH1,this.back.dims,m);s.bindVertexArray(this.genericVAO);const E=this.growCutShader;E.use(s);const e=128;s.uniform1i(E.uniforms.finalPass,0),s.uniform1i(E.uniforms.backTex,11);for(let W=0;Wn[0]&&(v=1),s[1]>n[1]&&(y=1),s[2]>n[2]&&(T=1);let I=n[0],S=n[1],E=n[2];const e=s[0],F=s[1],M=s[2];if(f>=m&&f>=A){let L=2*m-f,V=2*A-f;for(;I!==e;)I+=v,L>=0&&(S+=y,L-=2*f),V>=0&&(E+=T,V-=2*f),L+=2*m,V+=2*A,this.drawPt(I,S,E,u)}else if(m>=f&&m>=A){let L=2*f-m,V=2*A-m;for(;S!==F;)S+=y,L>=0&&(I+=v,L-=2*m),V>=0&&(E+=T,V-=2*m),L+=2*f,V+=2*A,this.drawPt(I,S,E,u)}else{let L=2*m-A,V=2*f-A;for(;E!==M;)E+=T,L>=0&&(S+=y,L-=2*A),V>=0&&(I+=v,V-=2*A),L+=2*m,V+=2*f,this.drawPt(I,S,E,u)}}drawFloodFillCore(n,s,u=6){var I;if(!((I=this.back)!=null&&I.dims))throw new Error("back.dims undefined");const f=[this.back.dims[1],this.back.dims[2],this.back.dims[3]],m=f[0],A=m*f[1];function v(S){return S[0]+S[1]*m+S[2]*A}function y(S){const E=Math.floor(S/A),e=Math.floor((S-E*A)/m);return[Math.floor(S%m),e,E]}const T=[];for(T.push(s),n[s]=2;T.length>0;){let S=function(F){const M=e.slice();if(M[0]+=F[0],M[1]+=F[1],M[2]+=F[2],M[0]<0||M[1]<0||M[2]<0||M[0]>=f[0]||M[1]>=f[1]||M[2]>=f[2])return;const L=v(M);n[L]===1&&(n[L]=2,T.push(L))};const E=T[0];T.shift();const e=y(E);S([0,0,-1]),S([0,0,1]),S([0,-1,0]),S([0,1,0]),S([-1,0,0]),S([1,0,0]),!(u<=6)&&(S([-1,-1,0]),S([1,1,0]),S([-1,1,0]),S([1,1,0]),S([0,-1,-1]),S([0,1,-1]),S([-1,0,-1]),S([1,0,-1]),S([0,-1,1]),S([0,1,1]),S([-1,0,1]),S([1,0,1]),!(u<=18)&&(S([-1,-1,-1]),S([1,-1,-1]),S([-1,1,-1]),S([1,1,-1]),S([-1,-1,1]),S([1,-1,1]),S([-1,1,1]),S([1,1,1])))}}drawFloodFill(n,s=0,u=0,f=NaN,m=NaN,A=6){var M;if(!this.drawBitmap)throw new Error("drawBitmap undefined");if(!((M=this.back)!=null&&M.dims))throw new Error("back.dims undefined");s=Math.abs(s);const v=[this.back.dims[1],this.back.dims[2],this.back.dims[3]];if(n[0]<0||n[1]<0||n[2]<0||n[0]>=v[0]||n[1]>=v[1]||n[2]>=v[2])return;const y=v[0],T=y*v[1],I=T*v[2],S=this.drawBitmap.slice();if(S.length!==T*v[2])return;function E(L){return L[0]+L[1]*y+L[2]*T}const e=E(n),F=S[e];if(F===s){u!==0?log$4.debug("drawFloodFill selected voxel is not part of a drawing"):log$4.debug("drawFloodFill selected voxel is already desired color");return}for(let L=1;L=B&&L[z]<=V&&(S[z]=1);this.drawFloodFillCore(S,e,A),s=F}for(let L=1;LM[0]&&(z=1),L[1]>M[1]&&(b=1);let W=M[0],q=M[1];const Y=L[0],X=L[1];if(V>=B){let H=2*B-V;for(;W!==Y;)W+=z,H>=0&&(q+=b,H-=2*V),H+=2*B,A[W+q*m[0]]=v}else{let H=2*V-B;for(;q!==X;)q+=b,H>=0&&(W+=z,H-=2*B),H+=2*V,A[W+q*m[0]]=v}}const T=[this.drawPenFillPts[0][u],this.drawPenFillPts[0][f]];let I=T;for(let M=1;M=m[0]||M[1]>=m[1])return;const L=M[0]+M[1]*m[0];A[L]===0&&(S.push(M),A[L]=2)}for(let M=0;M0;){const M=S.shift();E([M[0]-1,M[1]]),E([M[0]+1,M[1]]),E([M[0],M[1]-1]),E([M[0],M[1]+1])}v=this.opts.penValue;const e=this.drawPenFillPts[0][3-(u+f)];if(!this.drawBitmap)throw new Error("drawBitmap undefined");if(s===0){const M=e*m[0]*m[1];for(let L=0;L0){const M=this.drawBitmap.length,L=decodeRLE(this.drawUndoBitmaps[this.currentDrawUndoBitmap],M);for(let V=0;V{const m=new Image;m.onload=()=>{if(!this.bmpShader)return;let A;s===4?(this.bmpTexture!==null&&this.gl.deleteTexture(this.bmpTexture),this.bmpTexture=this.gl.createTexture(),A=this.bmpTexture,this.bmpTextureWH=m.width/m.height,this.gl.activeTexture(TEXTURE4_THUMBNAIL),this.bmpShader.use(this.gl),this.gl.uniform1i(this.bmpShader.uniforms.bmpTexture,4)):s===5?(this.gl.activeTexture(TEXTURE5_MATCAP),this.matCapTexture!==null&&this.gl.deleteTexture(this.matCapTexture),this.matCapTexture=this.gl.createTexture(),A=this.matCapTexture):(this.fontShader.use(this.gl),this.gl.activeTexture(TEXTURE3_FONT),this.gl.uniform1i(this.fontShader.uniforms.fontTexture,3),this.fontTexture!==null&&this.gl.deleteTexture(this.fontTexture),this.fontTexture=this.gl.createTexture(),A=this.fontTexture),this.gl.bindTexture(this.gl.TEXTURE_2D,A),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,m),u(A),s!==4&&this.drawScene()},m.onerror=f,this.requestCORSIfNotSameOrigin(m,n),m.src=n})}async loadFontTexture(n){return this.loadPngAsTexture(n,3)}async loadBmpTexture(n){return this.loadPngAsTexture(n,4)}async loadMatCapTexture(n){return this.loadPngAsTexture(n,5)}initFontMets(){if(!this.fontMetrics)throw new Error("fontMetrics undefined");this.fontMets={distanceRange:this.fontMetrics.atlas.distanceRange,size:this.fontMetrics.atlas.size,mets:{}};for(let u=0;u<256;u++)this.fontMets.mets[u]={xadv:0,uv_lbwh:[0,0,0,0],lbwh:[0,0,0,0]};const n=this.fontMetrics.atlas.width,s=this.fontMetrics.atlas.height;for(let u=0;u=this.meshes.length){log$4.debug("Unable to change shader until mesh is loaded (maybe you need async)");return}this.meshes[f].meshShaderIndex=u,this.updateGLVolume(),this.onMeshShaderChanged(f,u)}createCustomMeshShader(n,s="Custom"){if(!n)throw new Error("Need fragment shader");const u=this.meshShaderNameToNumber(s);u>=0&&(this.gl.deleteProgram(this.meshShaders[u].shader.program),this.meshShaders.splice(u,1));const f=new Shader(this.gl,vertMeshShader,n);return f.use(this.gl),{Name:s,Frag:n,shader:f}}setCustomMeshShader(n="",s="Custom"){const u=this.createCustomMeshShader(n,s);return this.meshShaders.push(u),this.onCustomMeshShaderAdded(n,s),this.meshShaders.length-1}meshShaderNames(n=!0){const s=[];for(let u=0;u0&&(await this.loadBmpTexture(this.opts.thumbnail),this.thumbnailVisible=!0),this.updateGLVolume(),this.initialized=!0,this.resizeListener(),this.drawScene(),this}gradientGL(n){const s=this.gl,u=[0,0,0,0,1,0,1,0,0,1,1,0],f=s.createVertexArray();s.bindVertexArray(f);const m=s.createBuffer();s.bindBuffer(s.ARRAY_BUFFER,m),s.bufferData(s.ARRAY_BUFFER,new Float32Array(u),s.STATIC_DRAW),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,3,s.FLOAT,!1,0,0);const A=s.createFramebuffer();s.bindFramebuffer(s.FRAMEBUFFER,A),s.disable(s.CULL_FACE),s.viewport(0,0,n.dims[1],n.dims[2]),s.disable(s.BLEND);const v=this.rgbaTex(null,TEXTURE8_GRADIENT_TEMP,n.dims),y=this.blurShader;y.use(s),s.activeTexture(TEXTURE0_BACK_VOL),s.bindTexture(s.TEXTURE_3D,this.volumeTexture);const T=.7;s.uniform1i(y.uniforms.intensityVol,0),s.uniform1f(y.uniforms.dX,T/n.dims[1]),s.uniform1f(y.uniforms.dY,T/n.dims[2]),s.uniform1f(y.uniforms.dZ,T/n.dims[3]),s.bindVertexArray(f);for(let E=0;E0&&(this.furthestVertexFromOrigin=this.volumeObject3D.furthestVertexFromOrigin),this.meshes)for(let u=0;u0)for(let Y=0;Y0&&n.frame4D1&&m===0)return;let A=null;if(!this.back)throw new Error("back undefined");this.gl.bindVertexArray(this.unusedVAO),this.crosshairs3D&&(this.crosshairs3D.mm[0]=NaN);let v=clone$3(n.toRAS);if(s===0){this.volumeObject3D=n.toNiivueObject3D(this.VOLUME_ID,this.gl),invert(v,v),this.back.matRAS=n.matRAS,this.back.dims=n.dimsRAS,this.back.pixDims=n.pixDimsRAS,A=this.rgbaTex(this.volumeTexture,TEXTURE0_BACK_VOL,n.dimsRAS);const{volScale:q,vox:Y}=this.sliceScale(!0);if(this.volScale=q,this.vox=Y,this.volumeObject3D.scale=q,!this.renderShader)throw new Error("renderShader undefined");this.renderShader.use(this.gl),this.gl.uniform3fv(this.renderShader.uniforms.texVox,Y),this.gl.uniform3fv(this.renderShader.uniforms.volScale,q);const X=this.pickingImageShader;X.use(this.gl),this.gl.uniform1i(X.uniforms.volume,0),this.gl.uniform1i(X.uniforms.colormap,1),this.gl.uniform1i(X.uniforms.overlay,2),this.gl.uniform3fv(X.uniforms.volScale,q),log$4.debug(this.volumeObject3D)}else{((W=this.back)==null?void 0:W.dims)===void 0&&log$4.error("Fatal error: Unable to render overlay: background dimensions not defined!");const q=this.mm2frac(n.mm000,0,!0);let Y=this.mm2frac(n.mm100,0,!0),X=this.mm2frac(n.mm010,0,!0),H=this.mm2frac(n.mm001,0,!0);Y=subtract$1(Y,Y,q),X=subtract$1(X,X,q),H=subtract$1(H,H,q),v=fromValues$3(Y[0],X[0],H[0],q[0],Y[1],X[1],H[1],q[1],Y[2],X[2],H[2],q[2],0,0,0,1),invert(v,v),s===1?(A=this.rgbaTex(this.overlayTexture,TEXTURE2_OVERLAY_VOL,this.back.dims),this.overlayTexture=A,this.overlayTextureID=A):A=this.overlayTextureID}const y=this.gl.createFramebuffer();this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,y),this.gl.disable(this.gl.CULL_FACE),this.gl.viewport(0,0,this.back.dims[1],this.back.dims[2]),this.gl.disable(this.gl.BLEND);const T=this.gl.createTexture();this.gl.activeTexture(TEXTURE9_ORIENT),this.gl.bindTexture(this.gl.TEXTURE_3D,T),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_WRAP_R,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1);let I=this.orientShaderU;if(!u)throw new Error("hdr undefined");if(!f)throw new Error("img undefined");if(u.datatypeCode===2)u.intent_code===1002&&(I=this.orientShaderAtlasU),this.gl.texStorage3D(this.gl.TEXTURE_3D,1,this.gl.R8UI,u.dims[1],u.dims[2],u.dims[3]),this.gl.texSubImage3D(this.gl.TEXTURE_3D,0,0,0,0,u.dims[1],u.dims[2],u.dims[3],this.gl.RED_INTEGER,this.gl.UNSIGNED_BYTE,f);else if(u.datatypeCode===4)I=this.orientShaderI,u.intent_code===1002&&(I=this.orientShaderAtlasI),this.gl.texStorage3D(this.gl.TEXTURE_3D,1,this.gl.R16I,u.dims[1],u.dims[2],u.dims[3]),this.gl.texSubImage3D(this.gl.TEXTURE_3D,0,0,0,0,u.dims[1],u.dims[2],u.dims[3],this.gl.RED_INTEGER,this.gl.SHORT,f);else if(u.datatypeCode===16)this.gl.texStorage3D(this.gl.TEXTURE_3D,1,this.gl.R32F,u.dims[1],u.dims[2],u.dims[3]),this.gl.texSubImage3D(this.gl.TEXTURE_3D,0,0,0,0,u.dims[1],u.dims[2],u.dims[3],this.gl.RED,this.gl.FLOAT,f),I=this.orientShaderF;else if(u.datatypeCode===64){let q=new Float32Array;q=Float32Array.from(f),this.gl.texStorage3D(this.gl.TEXTURE_3D,1,this.gl.R32F,u.dims[1],u.dims[2],u.dims[3]),this.gl.texSubImage3D(this.gl.TEXTURE_3D,0,0,0,0,u.dims[1],u.dims[2],u.dims[3],this.gl.RED,this.gl.FLOAT,q),I=this.orientShaderF}else u.datatypeCode===128?(I=this.orientShaderRGBU,I.use(this.gl),this.gl.uniform1i(I.uniforms.hasAlpha,0),this.gl.texStorage3D(this.gl.TEXTURE_3D,1,this.gl.RGB8UI,u.dims[1],u.dims[2],u.dims[3]),this.gl.texSubImage3D(this.gl.TEXTURE_3D,0,0,0,0,u.dims[1],u.dims[2],u.dims[3],this.gl.RGB_INTEGER,this.gl.UNSIGNED_BYTE,f)):u.datatypeCode===512?(u.intent_code===1002&&(I=this.orientShaderAtlasU),this.gl.texStorage3D(this.gl.TEXTURE_3D,1,this.gl.R16UI,u.dims[1],u.dims[2],u.dims[3]),this.gl.texSubImage3D(this.gl.TEXTURE_3D,0,0,0,0,u.dims[1],u.dims[2],u.dims[3],this.gl.RED_INTEGER,this.gl.UNSIGNED_SHORT,f)):u.datatypeCode===2304&&(I=this.orientShaderRGBU,I.use(this.gl),this.gl.uniform1i(I.uniforms.hasAlpha,1),this.gl.texStorage3D(this.gl.TEXTURE_3D,1,this.gl.RGBA8UI,u.dims[1],u.dims[2],u.dims[3]),this.gl.texSubImage3D(this.gl.TEXTURE_3D,0,0,0,0,u.dims[1],u.dims[2],u.dims[3],this.gl.RGBA_INTEGER,this.gl.UNSIGNED_BYTE,f));n.global_min===void 0&&n.calMinMax();let S=null;if(this.gl.bindVertexArray(this.genericVAO),s>1){if(!this.back.dims)throw new Error("back.dims undefined");S=this.rgbaTex(S,TEXTURE10_BLEND,this.back.dims),this.gl.bindTexture(this.gl.TEXTURE_3D,S);const q=this.passThroughShader;q.use(this.gl),this.gl.uniform1i(q.uniforms.in3D,2);for(let Y=0;Y7){const q=n.colormapLabel.max-n.colormapLabel.min+1;E=this.createColormapTexture(E,1,q),this.gl.texSubImage2D(this.gl.TEXTURE_2D,0,0,0,q,1,this.gl.RGBA,this.gl.UNSIGNED_BYTE,n.colormapLabel.lut),this.gl.uniform1f(I.uniforms.cal_min,n.colormapLabel.min-.5),this.gl.uniform1f(I.uniforms.cal_max,n.colormapLabel.max+.5),this.gl.bindTexture(this.gl.TEXTURE_2D,E)}else this.gl.bindTexture(this.gl.TEXTURE_2D,this.colormapTexture),this.gl.uniform1f(I.uniforms.cal_min,n.cal_min),this.gl.uniform1f(I.uniforms.cal_max,n.cal_max);this.gl.uniform1i(I.uniforms.isAlphaThreshold,n.alphaThreshold),this.gl.uniform1i(I.uniforms.isAdditiveBlend,this.opts.isAdditiveBlend?1:0);let e=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY;if(n.colormapNegative.length>0&&(e=Math.min(-n.cal_min,-n.cal_max),F=Math.max(-n.cal_min,-n.cal_max),isFinite(n.cal_minNeg)&&isFinite(n.cal_maxNeg)&&(e=Math.min(n.cal_minNeg,n.cal_maxNeg),F=Math.max(n.cal_minNeg,n.cal_maxNeg))),!I)throw new Error("orientShader undefined");this.gl.uniform1f(I.uniforms.layer??null,s),this.gl.uniform1f(I.uniforms.cal_minNeg??null,e),this.gl.uniform1f(I.uniforms.cal_maxNeg??null,F),this.gl.bindTexture(this.gl.TEXTURE_3D,T),this.gl.uniform1i(I.uniforms.intensityVol??null,9),this.gl.uniform1i(I.uniforms.blend3D??null,10),this.gl.uniform1i(I.uniforms.colormap??null,1),this.gl.uniform1f(I.uniforms.scl_inter??null,u.scl_inter),this.gl.uniform1f(I.uniforms.scl_slope??null,u.scl_slope),this.gl.uniform1f(I.uniforms.opacity??null,m),this.gl.uniform1i(I.uniforms.modulationVol??null,7);let M=null;if(n.modulationImage!==null&&n.modulationImage>=0&&n.modulationImage0;let fe=this.volumes[n.modulationImage].cal_min,pe=this.volumes[n.modulationImage].cal_max;isFinite(this.volumes[n.modulationImage].cal_minNeg)&&isFinite(this.volumes[n.modulationImage].cal_maxNeg)&&(fe=this.volumes[n.modulationImage].cal_minNeg,pe=this.volumes[n.modulationImage].cal_minNeg),fe=Math.abs(fe),pe=Math.abs(pe),fe>pe&&([fe,pe]=[pe,fe]);const me=1/(pe-fe);let Se=Math.abs(n.modulateAlpha);Se=Math.max(Se,1);const ve=this.volumes[n.modulationImage].frame4D*Y;for(let we=0;we0?this.gradientGL(u):(this.gradientTexture!==null&&this.gl.deleteTexture(this.gradientTexture),this.gradientTexture=null)),!this.renderShader)throw new Error("renderShader undefined");this.renderShader.use(this.gl);const V=this.sliceScale(!0),B=V.vox,z=V.volScale;if(this.gl.uniform1f(this.renderShader.uniforms.overlays,this.overlays),this.gl.uniform4fv(this.renderShader.uniforms.clipPlaneColor,this.opts.clipPlaneColor),this.gl.uniform1f(this.renderShader.uniforms.backOpacity,this.volumes[0].opacity),this.gl.uniform1f(this.renderShader.uniforms.renderOverlayBlend,this.opts.renderOverlayBlend),this.gl.uniform4fv(this.renderShader.uniforms.clipPlane,this.scene.clipPlane),this.gl.uniform3fv(this.renderShader.uniforms.texVox,B),this.gl.uniform3fv(this.renderShader.uniforms.volScale,z),!this.pickingImageShader)throw new Error("pickingImageShader undefined");this.pickingImageShader.use(this.gl),this.gl.uniform1f(this.pickingImageShader.uniforms.overlays,this.overlays.length),this.gl.uniform3fv(this.pickingImageShader.uniforms.texVox,B);let b=this.sliceMMShader;if(this.opts.isV1SliceShader&&(b=this.sliceV1Shader),!b)throw new Error("slice shader undefined");b.use(this.gl),this.gl.uniform1f(b.uniforms.overlays,this.overlays.length),this.gl.uniform1f(b.uniforms.drawOpacity,this.drawOpacity),E!==null&&(this.gl.deleteTexture(E),this.gl.activeTexture(TEXTURE1_COLORMAPS),this.gl.bindTexture(this.gl.TEXTURE_2D,this.colormapTexture)),this.gl.uniform1i(b.uniforms.drawing,7),this.gl.activeTexture(TEXTURE7_DRAW),this.gl.bindTexture(this.gl.TEXTURE_3D,this.drawTexture),this.updateInterpolation(s)}colormaps(){return cmapper.colormaps()}addColormap(n,s){cmapper.addColormap(n,s)}setColormap(n,s){const u=this.getVolumeIndexByID(n);this.volumes[u].colormap=s,this.updateGLVolume()}idx(n,s,u,f){return u*f[0]*f[1]+s*f[0]+n}check_previous_slice(n,s,u,f,m,A,v,y){const T=new Uint32Array(27);let I=0;if(!m)return 0;const S=n[this.idx(u,f,m,A)];if(v>=6){const E=this.idx(u,f,m-1,A);S===n[E]&&(T[I++]=s[E])}if(v>=18){if(u){const E=this.idx(u-1,f,m-1,A);S===n[E]&&(T[I++]=s[E])}if(f){const E=this.idx(u,f-1,m-1,A);S===n[E]&&(T[I++]=s[E])}if(u=6){if(E){const M=this.idx(E-1,S,I,s);F===n[M]&&(T[e++]=y[M])}if(S){const M=this.idx(E,S-1,I,s);F===n[M]&&(T[e++]=y[M])}}if(u>=18){if(S&&E){const M=this.idx(E-1,S-1,I,s);F===n[M]&&(T[e++]=y[M])}if(S&&E=A){A+=m;const M=new Uint32Array(A);M.set(v),v=M}v[f-1]=f,f++}}}for(let I=0;I100){log$4.info(` -Ooh no!!`);break}m[y]=T,v=Math.min(v,T)}for(let y=0;y=1e-15&&I++;const S=1e3,E=(v-A)/S,e=new Array(S).fill(0);for(let z=0;z=M);)L++;const V=A;for(A=L*E+V,M=T-Math.floor((1-m)*I),L=0;L=M);)L++;v=L*E+V;let B=1;return A!==v&&(B=(u-s)/(v-A)),log$4.info(" Rescale: min: "+A+" max: "+v+" scale: "+B),[A,B]}conformVox2Vox(n,s,u=256,f=1,m=!1){const A=s.flat(),v=fromValues$3(A[0],A[1],A[2],A[3],A[4],A[5],A[6],A[7],A[8],A[9],A[10],A[11],A[12],A[13],A[14],A[15]),y=fromValues$1(n[1]/2,n[2]/2,n[3]/2,1),T=create$1(),I=create$3();transpose$3(I,v),transformMat4(T,y,I);const S=fromValues$2(T[0],T[1],T[2]),E=fromValues$2(f,f,f);let e=fromValues$3(-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);m&&(e=fromValues$3(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)),transpose$3(e,e);const F=fromValues$1(u,u,u,1),M=create$3();scale$4(M,e,E);const L=fromValues$1(F[0],F[1],F[2],1);transformMat4(L,L,M),scale$2(L,L,.5);const V=create$2();subtract$1(V,S,fromValues$2(L[0],L[1],L[2]));const B=create$3();transpose$3(B,M),B[3]=V[0],B[7]=V[1],B[11]=V[2];const z=create$3();invert(z,B);const b=create$3();mul$1(b,v,z);const W=create$3();return invert(W,b),[B,b,W]}async createNiftiArray(n=[256,256,256],s=[1,1,1],u=[1,0,0,-128,0,1,0,-128,0,0,1,-128,0,0,0,1],f=2,m=new Uint8Array){return await NVImage.createNiftiArray(n,s,u,f,m)}async niftiArray2NVImage(n=new Uint8Array){return await NVImage.loadFromUrl({url:n})}async loadFromUrl(n){return await NVImage.loadFromUrl({url:n})}async conform(n,s=!1,u=!0,f=!1){const v=this.conformVox2Vox(n.hdr.dims,n.hdr.affine.flat(),256,1,s),y=v[0],T=v[2],I=256*256*256,S=new Float32Array(I),E=new Float32Array(n.img),e=n.hdr.dims[1]*n.hdr.dims[2]*n.hdr.dims[3];if(n.hdr.scl_slope!==1||n.hdr.scl_inter!==0)for(let H=0;H=F||je>=M||nt>=L)continue;const Ue=pe-ve,ye=me-we,ut=Se-Ne,pt=1-Ue,It=1-ye,Lt=1-ut,Ot=z(ve,we,Ne);let Et=0;Et+=E[Ot]*pt*It*Lt,Et+=E[Ot+V]*pt*It*ut,Et+=E[Ot+F]*pt*ye*Lt,Et+=E[Ot+F+V]*pt*ye*ut,Et+=E[Ot+1]*Ue*It*Lt,Et+=E[Ot+1+V]*Ue*It*ut,Et+=E[Ot+1+F]*Ue*ye*Lt,Et+=E[Ot+1+F+V]*Ue*ye*ut,S[B]=Et}}else for(let H=0;H<256;H++)for(let g=0;g<256;g++){const J=g*T[1]+H*T[2]+T[3],re=g*T[5]+H*T[6]+T[7],ae=g*T[9]+H*T[10]+T[11];for(let fe=0;fe<256;fe++){const pe=Math.round(fe*b+J),me=Math.round(fe*W+re),Se=Math.round(fe*q+ae);B++,!(pe<0||me<0||Se<0)&&(pe>=F||me>=M||Se>=L||(S[B]=E[z(pe,me,Se)]))}}let Y=new Uint8Array;if(f){const H=await this.getScale(n,0,1),g=await this.scalecropFloat32(S,0,1,H[0],H[1]);Y=await this.createNiftiArray([256,256,256],[1,1,1],Array.from(y),16,new Uint8Array(g.buffer))}else{const H=await this.getScale(n,0,255),g=await this.scalecropUint8(S,0,255,H[0],H[1]);Y=await this.createNiftiArray([256,256,256],[1,1,1],Array.from(y),2,g)}return await this.niftiArray2NVImage(Y)}setRenderDrawAmbientOcclusion(n){if(!this.renderShader)throw new Error("renderShader undefined");this.renderDrawAmbientOcclusion=n,this.renderShader.use(this.gl),this.gl.uniform1fv(this.renderShader.uniforms.renderDrawAmbientOcclusion,[this.renderDrawAmbientOcclusion,1]),this.drawScene()}setColorMap(n,s){this.setColormap(n,s)}setColormapNegative(n,s){const u=this.getVolumeIndexByID(n);this.volumes[u].colormapNegative=s,this.updateGLVolume()}setModulationImage(n,s,u=0){const f=this.getVolumeIndexByID(n);let m=null;s.length>0&&(m=this.getVolumeIndexByID(s)),this.volumes[f].modulationImage=m,this.volumes[f].modulateAlpha=u,this.updateGLVolume()}setGamma(n=1){cmapper.gamma=n,this.updateGLVolume()}async loadDeferred4DVolumes(n){const s=this.getVolumeIndexByID(n),u=this.volumes[s];if(u.nTotalFrame4D<=u.nFrame4D)return;let f;u.fileObject?f=await NVImage.loadFromFile({file:u.fileObject}):f=await NVImage.loadFromUrl({url:u.url}),f&&(u.img=f.img.slice(),u.nTotalFrame4D=f.nTotalFrame4D,u.nFrame4D=f.nFrame4D,this.updateGLVolume())}setFrame4D(n,s){const u=this.getVolumeIndexByID(n),f=this.volumes[u];s>f.nFrame4D-1&&(s=f.nFrame4D-1),s<0&&(s=0),s!==f.frame4D&&(f.frame4D=s,this.updateGLVolume(),this.onFrameChange(f,s),this.createOnLocationChange())}getFrame4D(n){const s=this.getVolumeIndexByID(n);return this.volumes[s].frame4D}colormapFromKey(n){return cmapper.colormapFromKey(n)}colormap(n="",s=!1){return cmapper.colormap(n,s)}createColormapTexture(n=null,s=0,u=256){return n!==null&&this.gl.deleteTexture(n),s<1||u<1?null:(n=this.gl.createTexture(),this.gl.activeTexture(TEXTURE1_COLORMAPS),this.gl.bindTexture(this.gl.TEXTURE_2D,n),this.gl.texStorage2D(this.gl.TEXTURE_2D,1,this.gl.RGBA8,u,s),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_R,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),n)}addColormapList(n="",s=NaN,u=NaN,f=!1,m=!1,A=!0,v=!1){n.length<1&&(A=!1),this.colormapLists.push({name:n,min:s,max:u,alphaThreshold:f,negative:m,visible:A,invert:v})}refreshColormaps(){if(this.colormapLists=[],this.volumes.length<1&&this.meshes.length<1)return;const n=this.volumes.length;if(n>0)for(let A=0;A0)for(let A=0;Af[0]&&s>f[1]&&n=0&&this.screenSlices[u].axCorSag===4?u:-1}sliceScroll3D(n=0){if(n!==0){if(this.volumes.length>0&&this.scene.clipPlaneDepthAziElev[0]<1.8){const s=this.scene.clipPlaneDepthAziElev.slice();return n>0&&(s[0]=Math.min(1.5,s[0]+.025)),n<0&&(s[0]=Math.max(-1.5,s[0]-.025)),s[0]!==this.scene.clipPlaneDepthAziElev[0]?(this.scene.clipPlaneDepthAziElev=s,this.setClipPlane(this.scene.clipPlaneDepthAziElev)):void 0}n>0&&(this.scene.volScaleMultiplier=Math.min(2,this.scene.volScaleMultiplier*1.1)),n<0&&(this.scene.volScaleMultiplier=Math.max(.5,this.scene.volScaleMultiplier*.9)),this.drawScene()}}deleteThumbnail(){this.bmpTexture&&(this.gl.deleteTexture(this.bmpTexture),this.bmpTexture=null,this.thumbnailVisible=!1)}inGraphTile(n,s){if(this.graph.opacity<=0||this.volumes.length<1||this.volumes[0].nFrame4D<1||!this.graph.plotLTWH||this.graph.plotLTWH[2]<1||this.graph.plotLTWH[3]<1)return!1;const u=[(n-this.graph.LTWH[0])/this.graph.LTWH[2],(s-this.graph.LTWH[1])/this.graph.LTWH[3]];return u[0]>0&&u[1]>0&&u[0]<=1&&u[1]<=1}mouseClick(n,s,u=0,f=!0){if(n*=this.uiData.dpr,s*=this.uiData.dpr,this.canvas.focus(),this.thumbnailVisible){this.thumbnailVisible=!1,Promise.all([this.loadVolumes(this.deferredVolumes),this.loadMeshes(this.deferredMeshes)]).catch(m=>{throw m});return}if(this.inGraphTile(n,s)){if(!this.graph.plotLTWH)throw new Error("plotLTWH undefined");const m=[(n-this.graph.plotLTWH[0])/this.graph.plotLTWH[2],(s-this.graph.plotLTWH[1])/this.graph.plotLTWH[3]];if(m[0]>0&&m[1]>0&&m[0]<=1&&m[1]<=1){const A=Math.round(m[0]*(this.volumes[0].nFrame4D-1));this.setFrame4D(this.volumes[0].id,A);return}m[0]>.5&&m[1]>1&&this.loadDeferred4DVolumes(this.volumes[0].id).catch(A=>{throw A});return}if(this.inRenderTile(n,s)>=0){this.sliceScroll3D(u),this.drawScene();return}if(!(this.screenSlices.length<1||this.gl.canvas.height<1||this.gl.canvas.width<1))for(let m=0;m=0&&this.drawPenAxCorSag!==A||A>2)continue;const v=this.screenXY2TextureFrac(n,s,m,!1);if(!(v[0]<0)){if(!f){this.scene.crosshairPos[2-A]=u,this.drawScene();return}if(u!==0){let y=1;u<0&&(y=-1);const T=[0,0,0];T[2-A]=y,this.moveCrosshairInVox(T[0],T[1],T[2]),this.drawScene(),this.createOnLocationChange(A);return}if(this.opts.isForceMouseClickToVoxelCenters?this.scene.crosshairPos=clone$2(this.vox2frac(this.frac2vox(v))):this.scene.crosshairPos=clone$2(v),this.opts.drawingEnabled){const y=this.frac2vox(this.scene.crosshairPos);if(!isFinite(this.opts.penValue)||this.opts.penValue<0||Object.is(this.opts.penValue,-0)){isFinite(this.opts.penValue)?this.drawFloodFill(y,Math.abs(this.opts.penValue),this.opts.floodFillNeighbors):this.drawFloodFill(y,0,this.opts.penValue,this.opts.floodFillNeighbors);return}if(isNaN(this.drawPenLocation[0]))this.drawPenAxCorSag=A,this.drawPenFillPts=[],this.drawPt(...y,this.opts.penValue);else{if(y[0]===this.drawPenLocation[0]&&y[1]===this.drawPenLocation[1]&&y[2]===this.drawPenLocation[2])return;this.drawPenLine(y,this.drawPenLocation,this.opts.penValue)}this.drawPenLocation=y,this.opts.isFilledPen&&this.drawPenFillPts.push(y),this.refreshDrawing(!1)}this.drawScene(),this.createOnLocationChange(A);return}}}drawRuler(){let n=[],s=[];for(let y=0;y1){s=this.screenSlices[y].leftTopWidthHeight,n=this.screenSlices[y].fovMM;break}if(s.length<4)return;const f=100/n[0]*s[2],m=s[0]+.5*s[2]-.5*f,A=s[1]+s[3]-2*this.opts.rulerWidth,v=[m,A,m+f,A];this.drawRuler10cm(v)}drawRuler10cm(n){if(!this.lineShader)throw new Error("lineShader undefined");this.gl.bindVertexArray(this.genericVAO),this.lineShader.use(this.gl),this.gl.uniform4fv(this.lineShader.uniforms.lineColor,this.opts.rulerColor),this.gl.uniform2fv(this.lineShader.uniforms.canvasWidthHeight,[this.gl.canvas.width,this.gl.canvas.height]),this.gl.uniform1f(this.lineShader.uniforms.thickness,this.opts.rulerWidth),this.gl.uniform4fv(this.lineShader.uniforms.startXYendXY,n),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4);const s=-.1*(n[0]-n[2]),u=n[1],f=u-2*this.opts.rulerWidth,m=u-4*this.opts.rulerWidth;for(let A=0;A<11;A++){const v=n[0]+A*s,y=[v,u,v,f];A%5===0&&(y[3]=m),this.gl.uniform4fv(this.lineShader.uniforms.startXYendXY,y),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}this.gl.bindVertexArray(this.unusedVAO)}screenXY2mm(n,s,u=-1){let f;for(let m=0;m=0&&(A=u),this.screenSlices[A].axCorSag>2)continue;const y=this.screenSlices[A].leftTopWidthHeight;if(ny[0]+y[2]||s>y[1]+y[3]||(f=this.screenXY2TextureFrac(n,s,A,!1),f[0]<0))continue;const T=this.frac2mm(f);return fromValues$1(T[0],T[1],T[2],A)}return fromValues$1(NaN,NaN,NaN,NaN)}dragForPanZoom(n){const s=this.screenXY2mm(n[2],n[3]);if(isNaN(s[0]))return;const u=this.screenXY2mm(n[0],n[1],s[3]);if(isNaN(u[0])||isNaN(s[0])||isNaN(s[3]))return;const f=create$1(),m=this.uiData.pan2DxyzmmAtMouseDown[3];sub$3(f,s,u),this.scene.pan2Dxyzmm[0]=this.uiData.pan2DxyzmmAtMouseDown[0]+m*f[0],this.scene.pan2Dxyzmm[1]=this.uiData.pan2DxyzmmAtMouseDown[1]+m*f[1],this.scene.pan2Dxyzmm[2]=this.uiData.pan2DxyzmmAtMouseDown[2]+m*f[2]}dragForCenterButton(n){this.dragForPanZoom(n)}dragForSlicer3D(n){let s=this.uiData.pan2DxyzmmAtMouseDown[3];const u=n[3]-n[1];s+=u*.01,s=Math.max(s,.1),s=Math.min(s,10);const m=this.scene.pan2Dxyzmm[3]-s;this.opts.yoke3Dto2DZoom&&(this.scene.volScaleMultiplier=s),this.scene.pan2Dxyzmm[3]=s;const A=this.frac2mm(this.scene.crosshairPos);this.scene.pan2Dxyzmm[0]+=m*A[0],this.scene.pan2Dxyzmm[1]+=m*A[1],this.scene.pan2Dxyzmm[2]+=m*A[2]}drawMeasurementTool(n){const s=this.gl;if(s.bindVertexArray(this.genericVAO),s.depthFunc(s.ALWAYS),s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),!this.lineShader)throw new Error("lineShader undefined");this.lineShader.use(this.gl),s.uniform4fv(this.lineShader.uniforms.lineColor,this.opts.rulerColor),s.uniform2fv(this.lineShader.uniforms.canvasWidthHeight,[s.canvas.width,s.canvas.height]),s.uniform1f(this.lineShader.uniforms.thickness,this.opts.rulerWidth),s.uniform4fv(this.lineShader.uniforms.startXYendXY,n),s.drawArrays(s.TRIANGLE_STRIP,0,4);const u=this.opts.rulerColor;u[3]=1,s.uniform4fv(this.lineShader.uniforms.lineColor,u);const f=this.opts.rulerWidth;s.uniform1f(this.lineShader.uniforms.thickness,f*2);let m=[n[0],n[1]-f,n[0],n[1]+f];s.uniform4fv(this.lineShader.uniforms.startXYendXY,m),s.drawArrays(s.TRIANGLE_STRIP,0,4),m=[n[2],n[3]-f,n[2],n[3]+f],s.uniform4fv(this.lineShader.uniforms.startXYendXY,m),s.drawArrays(s.TRIANGLE_STRIP,0,4);let A=this.canvasPos2frac([n[0],n[1]]),v=this.canvasPos2frac([n[2],n[3]]);if(A[0]>=0&&v[0]>=0){const y=this.frac2mm(A);A=fromValues$2(y[0],y[1],y[2]);const T=this.frac2mm(v);v=fromValues$2(T[0],T[1],T[2]);const I=create$2();sub$4(I,A,v);const S=len(I);let E=2;S>9&&(E=1),S>99&&(E=0);const e=S.toFixed(E);this.drawTextBetween(n,e,1,u)}s.bindVertexArray(this.unusedVAO)}drawRect(n,s=[1,0,0,-1]){if(s[3]<0&&(s=this.opts.crosshairColor),!this.rectShader)throw new Error("rectShader undefined");this.rectShader.use(this.gl),this.gl.enable(this.gl.BLEND),this.gl.uniform4fv(this.rectShader.uniforms.lineColor,s),this.gl.uniform2fv(this.rectShader.uniforms.canvasWidthHeight,[this.gl.canvas.width,this.gl.canvas.height]),this.gl.uniform4f(this.rectShader.uniforms.leftTopWidthHeight,n[0],n[1],n[2],n[3]),this.gl.bindVertexArray(this.genericVAO),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.gl.bindVertexArray(this.unusedVAO)}drawCircle(n,s=this.opts.fontColor,u=1){if(!this.circleShader)throw new Error("circleShader undefined");this.circleShader.use(this.gl),this.gl.enable(this.gl.BLEND),this.gl.uniform4fv(this.circleShader.uniforms.circleColor,s),this.gl.uniform2fv(this.circleShader.uniforms.canvasWidthHeight,[this.gl.canvas.width,this.gl.canvas.height]),this.gl.uniform4f(this.circleShader.uniforms.leftTopWidthHeight,n[0],n[1],n[2],n[3]),this.gl.uniform1f(this.circleShader.uniforms.fillPercent,u),this.gl.uniform4fv(this.circleShader.uniforms.circleColor,s),this.gl.bindVertexArray(this.genericVAO),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.gl.bindVertexArray(this.unusedVAO)}drawSelectionBox(n){this.drawRect(n,this.opts.selectionBoxColor)}effectiveCanvasHeight(){return this.gl.canvas.height-this.colorbarHeight}effectiveCanvasWidth(){return this.gl.canvas.width-this.getLegendPanelWidth()}getAllLabels(){const f=this.meshes.filter(A=>A.type==="connectome").flatMap(A=>A.nodes).map(A=>A.label).filter(A=>A!==void 0);return[...this.document.labels,...f]}getBulletMarginWidth(){let n=0;const s=this.getAllLabels();if(s.length===0)return 0;const u=s.length===1?s[0].style.bulletScale:s.reduce((A,v)=>A.style.bulletScale>v.style.bulletScale?A:v).style.bulletScale,f=s.length===1?s[0]:s.reduce((A,v)=>{const y=this.opts.textHeight*this.gl.canvas.height*A.style.textScale,T=this.opts.textHeight*this.gl.canvas.height*v.style.textScale;return this.textHeight(y,A.text)>this.textHeight(T,v.text)?A:v}),m=this.opts.textHeight*this.gl.canvas.height*f.style.textScale;return n=this.textHeight(m,f.text)*u,n+=m,n}getLegendPanelWidth(){const n=this.getAllLabels();if(!this.opts.showLegend||n.length===0)return 0;const u=this.opts.textHeight*this.gl.canvas.height*1;let f=0;const m=n.reduce((T,I)=>{const S=this.opts.textHeight*this.gl.canvas.height*T.style.textScale,E=this.opts.textHeight*this.gl.canvas.height*I.style.textScale;return this.textWidth(S,T.text)>this.textWidth(E,I.text)?T:I}),A=this.opts.textHeight*this.gl.canvas.height*m.style.textScale,v=this.textWidth(A,m.text),y=this.getBulletMarginWidth();return v&&(f=y+v,f+=u*2),f}getLegendPanelHeight(){const n=this.getAllLabels();let s=0;const f=this.opts.textHeight*this.gl.canvas.height*1;for(const m of n){const A=this.opts.textHeight*this.gl.canvas.height*m.style.textScale,v=this.textHeight(A,m.text);s+=v}return s&&(s+=f/2*(n.length+1)),s}reserveColorbarPanel(){let n=Math.max(this.opts.textHeight,.01);n=n*Math.min(this.gl.canvas.height,this.gl.canvas.width);const s=3*n,u=[0,this.gl.canvas.height-s,this.gl.canvas.width,s];return this.colorbarHeight=u[3]+1,u}drawColorbarCore(n=0,s=[0,0,0,0],u=!1,f=0,m=1,A){if(s[2]<=0||s[3]<=0)return;let v=Math.max(this.opts.textHeight,.01);v=v*Math.min(this.gl.canvas.height,this.gl.canvas.width);let y=v;const T=3*v;let I=v;if(s[3]0&&(F=f,f=0),f===m||v<1)return;const M=Math.abs(m-f);let[L,V]=tickSpacing(f,m);Vf.includes(y)).reduce((v,y)=>v.lbwh[3]>y.lbwh[3]?v:y).lbwh[3];return n*A}drawChar(n,s,u){if(!this.fontShader)throw new Error("fontShader undefined");const f=this.fontMets.mets[u],m=n[0]+s*f.lbwh[0],A=-(s*f.lbwh[1]),v=s*f.lbwh[2],y=s*f.lbwh[3],T=n[1]+(A-y)+s;return this.gl.uniform4f(this.fontShader.uniforms.leftTopWidthHeight,m,T,v,y),this.gl.uniform4fv(this.fontShader.uniforms.uvLeftTopWidthHeight,f.uv_lbwh),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),s*f.xadv}drawLoadingText(n){if(!this.canvas)throw new Error("canvas undefined");this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.gl.enable(this.gl.CULL_FACE),this.gl.enable(this.gl.BLEND),this.drawTextBelow([this.canvas.width/2,this.canvas.height/2],n,3)}drawText(n,s,u=1,f=null){if(this.opts.textHeight<=0)return;if(!this.fontShader)throw new Error("fontShader undefined");this.fontShader.use(this.gl);const m=this.opts.textHeight*Math.min(this.gl.canvas.height,this.gl.canvas.width)*u;this.gl.enable(this.gl.BLEND),this.gl.uniform2f(this.fontShader.uniforms.canvasWidthHeight,this.gl.canvas.width,this.gl.canvas.height),f===null&&(f=this.opts.fontColor),this.gl.uniform4fv(this.fontShader.uniforms.fontColor,f);let A=m/this.fontMets.size*this.fontMets.distanceRange;A=Math.max(A,1),this.gl.uniform1f(this.fontShader.uniforms.screenPxRange,A);const v=new TextEncoder().encode(s);this.gl.bindVertexArray(this.genericVAO);for(let y=0;y.8?T=[0,0,0,.5]:T=[1,1,1,.5],this.drawRect(y,T),this.drawText(m,s,u,f)}drawTextBelow(n,s,u=1,f=null){if(this.opts.textHeight<=0)return;if(!this.canvas)throw new Error("canvas undefined");let m=this.opts.textHeight*this.gl.canvas.height*u,A=this.textWidth(m,s);A>this.canvas.width&&(u*=(this.canvas.width-2)/A,m=this.opts.textHeight*this.gl.canvas.height*u,A=this.textWidth(m,s)),n[0]-=.5*this.textWidth(m,s),n[0]=Math.max(n[0],1),n[0]=Math.min(n[0],this.canvas.width-A-1),this.drawText(n,s,u,f)}updateInterpolation(n,s=!1){let u=this.gl.LINEAR;!s&&this.opts.isNearestInterpolation&&(u=this.gl.NEAREST),n===0?this.gl.activeTexture(TEXTURE0_BACK_VOL):this.gl.activeTexture(TEXTURE2_OVERLAY_VOL),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_MIN_FILTER,u),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_MAG_FILTER,u)}setAtlasOutline(n){this.opts.atlasOutline=n,this.updateGLVolume(),this.drawScene()}setInterpolation(n){this.opts.isNearestInterpolation=n;const s=this.volumes.length;if(!(s<1)){for(let u=0;u0){this.opts.meshThicknessOn2D!==1/0&&(M=this.calculateMvpMatrix2D(n,m.mnMM,m.mxMM,this.opts.meshThicknessOn2D,F,T,y,v));const V=clone$3(M.modelViewProjectionMatrix);multiply$2(V,V,A),this.drawMesh3D(!0,1,V,M.modelMatrix,M.normalMatrix)}isNaN(u)&&this.drawCrosshairs3D(!1,.15,M.modelViewProjectionMatrix,!0,this.opts.isSliceMM),this.drawSliceOrientationText(n,s),this.readyForSync=!0}calculateMvpMatrix(n,s=[0,0,0,0],u,f){(s[2]===0||s[3]===0)&&(s=[0,0,this.gl.canvas.width,this.gl.canvas.height]);const m=s[2]/s[3];let A=this.furthestFromPivot;const v=this.pivot3D,y=create$3();A=.8*A/this.scene.volScaleMultiplier,m<1?ortho(y,-A,A,-A/m,A/m,A*.01,A*8):ortho(y,-A*m,A*m,-A,A,A*.01,A*8);const T=create$3();T[0]=-1;const I=fromValues$2(0,0,-A*1.8);translate(T,T,I),this.position&&translate(T,T,this.position),rotateX(T,T,deg2rad(270-f)),rotateZ(T,T,deg2rad(u-180)),translate(T,T,[-v[0],-v[1],-v[2]]);const S=create$3();invert(S,T);const E=create$3();transpose$3(E,S);const e=create$3();return multiply$2(e,y,T),[e,T,E]}calculateModelMatrix(n,s){if(!this.back)throw new Error("back undefined");const u=create$3();if(u[0]=-1,rotateX(u,u,deg2rad(270-s)),rotateZ(u,u,deg2rad(n-180)),this.back.obliqueRAS){const f=clone$3(this.back.obliqueRAS);multiply$2(u,u,f)}return u}calculateRayDirection(n,s){const u=this.calculateModelMatrix(n,s),f=fromValues$3(1,0,0,0,0,-1,0,0,0,0,-1,0,0,0,0,1),m=create$3();multiply$2(m,f,u);const A=create$3();invert(A,m);const v=fromValues$1(0,0,-1,1);transformMat4(v,v,A);const y=fromValues$2(v[0],v[1],v[2]);normalize$1(y,y);const T=5e-5;return Math.abs(y[0])0){if(!this.volumeObject3D)throw new Error("volumeObject3D undefined");s=fromValues$2(this.volumeObject3D.extentsMin[0],this.volumeObject3D.extentsMin[1],this.volumeObject3D.extentsMin[2]),u=fromValues$2(this.volumeObject3D.extentsMax[0],this.volumeObject3D.extentsMax[1],this.volumeObject3D.extentsMax[2]),n||(s=fromValues$2(this.volumes[0].extentsMinOrtho[0],this.volumes[0].extentsMinOrtho[1],this.volumes[0].extentsMinOrtho[2]),u=fromValues$2(this.volumes[0].extentsMaxOrtho[0],this.volumes[0].extentsMaxOrtho[1],this.volumes[0].extentsMaxOrtho[2]))}if(this.meshes.length>0){if(this.volumes.length<1){const m=this.meshes[0].extentsMin,A=this.meshes[0].extentsMax;s=fromValues$2(m[0],m[1],m[2]),u=fromValues$2(A[0],A[1],A[2])}for(let m=0;mthis.gl.canvas.width||n.LTWH[1]+n.LTWH[3]>this.gl.canvas.height)return;n.backColor=[.15,.15,.15,n.opacity],n.lineColor=[1,1,1,1],this.opts.backColor[0]+this.opts.backColor[1]+this.opts.backColor[2]>1.5&&(n.backColor=[.95,.95,.95,n.opacity],n.lineColor=[0,0,0,1]),n.textColor=n.lineColor.slice(),n.lineThickness=4,n.lineAlpha=1,n.lines=[];const u=[];if(n.vols.length<1)this.volumes[0]!=null&&u.push(0);else for(let re=0;rem){const re=A-m;for(let ae=0;ae=A&&(A=m+1),this.drawRect(n.LTWH,n.backColor);const[v,y,T]=tickSpacing(m,A),I=Math.max(0,-1*Math.floor(Math.log(v)/Math.log(10)));m=Math.min(y,m),A=Math.max(T,A);function S(re){return re.toFixed(6).replace(/\.?0*$/,"")}const e=.07*(Math.min(n.LTWH[2],n.LTWH[3])/(this.fontMets.size*this.uiData.dpr));let F=this.opts.textHeight*this.gl.canvas.height*e;F<16&&(F=0);let M=0,L=y;if(F>0)for(;L<=A;){const re=L.toFixed(I),ae=this.textWidth(F,re);M=Math.max(ae,M),L+=v}const V=.05,B=Math.abs(n.LTWH[2]),z=Math.abs(n.LTWH[3]),b=[n.LTWH[0]+V*B+M,n.LTWH[1]+V*z,n.LTWH[2]-M-2*V*B,n.LTWH[3]-F-2*V*z];this.graph.LTWH=n.LTWH,this.graph.plotLTWH=b,this.drawRect(b,this.opts.backColor);const W=A-m,q=b[3]/W,Y=b[2]/(n.lines[0].length-1),X=b[1]+b[3];L=y+.5*v;const H=n.lineColor.slice();for(H[3]=.25*n.lineColor[3];L<=A;){const re=X-(L-m)*q;this.drawLine([b[0],re,b[0]+b[2],re],.5*n.lineThickness,H),L+=v}L=y;const g=.5*n.lineThickness;for(;L<=A;){const re=X-(L-m)*q;this.drawLine([b[0]-g,re,b[0]+b[2]+n.lineThickness,re],n.lineThickness,n.lineColor);const ae=L.toFixed(I);F>0&&this.drawTextLeft([b[0]-6,re],ae,e,n.textColor),L+=v}let J=1;for(;n.lines[0].length/J>20;)J*=5;for(let re=0;re0&&this.drawTextBelow([ae,2+b[1]+b[3]],pe,e,n.textColor),this.drawLine([ae,b[1],ae,b[1]+b[3]],fe,n.lineColor)}}for(let re=0;re=0&&n.selectedColumnE/255);return}const v=unpackFloatFromVec4i(A);if(v>1)return;const y=(this.mousePos[0]-n[0])/n[2],T=(u.canvas.height-this.mousePos[1]-n[1])/n[3],I=unProject(y,T,v,s),S=this.mm2frac(I,0,!0);S[0]<0||S[0]>1||S[1]<0||S[1]>1||S[2]<0||S[2]>1||(this.scene.crosshairPos=this.mm2frac(I,0,!0))}drawImage3D(n,s,u){if(this.volumes.length===0)return;const f=this.gl,m=this.calculateRayDirection(s,u),A=this.volumeObject3D;if(A){f.enable(f.BLEND),f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA),f.enable(f.CULL_FACE),f.cullFace(f.FRONT);let v=this.renderShader;if(this.uiData.mouseDepthPicker&&(v=this.pickingImageShader),v.use(this.gl),f.uniform1i(v.uniforms.backgroundMasksOverlays,this.backgroundMasksOverlays),this.gradientTextureAmount>0){f.activeTexture(TEXTURE6_GRADIENT),f.bindTexture(f.TEXTURE_3D,this.gradientTexture);const y=this.calculateModelMatrix(s,u),T=create$3();invert(T,y);const I=create$3();transpose$3(I,T),f.uniformMatrix4fv(v.uniforms.normMtx,!1,I)}this.drawBitmap&&this.drawBitmap.length>8?f.uniform2f(v.uniforms.renderDrawAmbientOcclusionXY,this.renderDrawAmbientOcclusion,this.drawOpacity):f.uniform2f(v.uniforms.renderDrawAmbientOcclusionXY,this.renderDrawAmbientOcclusion,0),f.uniformMatrix4fv(v.uniforms.mvpMtx,!1,n),f.uniformMatrix4fv(v.uniforms.matRAS,!1,this.back.matRAS),f.uniform3fv(v.uniforms.rayDir,m),this.gradientTextureAmount<0?f.uniform4fv(v.uniforms.clipPlane,[this.scene.crosshairPos[0],this.scene.crosshairPos[1],this.scene.crosshairPos[2],30]):f.uniform4fv(v.uniforms.clipPlane,this.scene.clipPlane),f.uniform1f(v.uniforms.drawOpacity,1),f.bindVertexArray(A.vao),f.drawElements(A.mode,A.indexCount,f.UNSIGNED_SHORT,0),f.bindVertexArray(this.unusedVAO)}}drawOrientationCube(n,s=0,u=0){if(!this.opts.isOrientCube)return;const f=.05*Math.min(n[2],n[3]);if(f<5)return;const m=this.gl;m.enable(m.CULL_FACE),m.cullFace(m.BACK),this.orientCubeShader.use(this.gl),m.bindVertexArray(this.orientCubeShaderVAO);const A=create$3(),v=create$3();ortho(v,0,m.canvas.width,0,m.canvas.height,-10*f,10*f);let y=0;n[1]===0&&(y=m.canvas.height-this.effectiveCanvasHeight()),translate(A,A,[1.8*f+n[0],y+1.8*f+n[1],0]),scale$4(A,A,[f,f,f]),rotateX(A,A,deg2rad(270-u)),rotateZ(A,A,deg2rad(-s));const T=create$3();multiply$2(T,v,A),m.uniformMatrix4fv(this.orientCubeShader.uniforms.u_matrix,!1,T),m.drawArrays(m.TRIANGLE_STRIP,0,168),m.bindVertexArray(this.unusedVAO),this.gl.disable(this.gl.CULL_FACE)}createOnLocationChange(n=NaN){const[s,u,f]=this.sceneExtentsMinMax(!0),m=Math.max(Math.max(f[0],f[1]),f[2]);function A(E){return Math.max(0,-Math.ceil(Math.log10(Math.abs(E))))}let v=A(m*.001);const y=this.frac2mm(this.scene.crosshairPos,0,!0);function T(E,e=0){return parseFloat(E.toFixed(e))}let I=T(y[0],v)+"×"+T(y[1],v)+"×"+T(y[2],v);if(this.volumes.length>0&&this.volumes[0].nFrame4D>0&&(I+="×"+T(this.volumes[0].frame4D)),this.volumes.length>0){let E=" = ";for(let M=0;M=0&&B=0&&(E+="+"),E+=T(V,v)),E+=" "}I+=E;const e=this.back.dimsRAS,F=e[1]*e[2]*e[3];if(this.drawBitmap&&this.drawBitmap.length===F){const M=this.frac2vox(this.scene.crosshairPos),L=M[0]+M[1]*e[1]+M[2]*e[1]*e[2];I+=" "+this.drawLut.labels[this.drawBitmap[L]]}}const S={mm:this.frac2mm(this.scene.crosshairPos,0,!0),axCorSag:n,vox:this.frac2vox(this.scene.crosshairPos),frac:this.scene.crosshairPos,xy:[this.mousePos[0],this.mousePos[1]],values:this.volumes.map(E=>{const e=this.frac2mm(this.scene.crosshairPos,0,!0),F=E.mm2vox(e),M=E.getValue(F[0],F[1],F[2],E.frame4D);return{name:E.name,value:M,id:E.id,mm:e,vox:F}}),string:I};this.onLocationChange(S)}addLabel(n,s,u){const f={textColor:this.opts.legendTextColor,textScale:1,textAlignment:"left",lineWidth:0,lineColor:this.opts.legendTextColor,lineTerminator:"none",bulletScale:0,bulletColor:this.opts.legendTextColor},m=s?{...f,...s}:{...f},A=new NVLabel3D(n,m,u);return this.document.labels.push(A),A}calculateScreenPoint(n,s,u){const f=create$1();return transformMat4(f,[...n,1],s),f[3]!==0&&(f[0]=(f[0]/f[3]+1)*.5*u[2],f[1]=(1-f[1]/f[3])*.5*u[3],f[2]/=f[3],f[0]+=u[0],f[1]+=u[1]),f}getLabelAtPoint(n){log$4.debug("screenPoint",n);const s=this.getLegendPanelHeight(),u=this.getLegendPanelWidth(),f=this.gl.canvas.width-u;let m=(this.canvas.height-s)/2;if(log$4.debug("panelrect",f,m,f+u,m+s),n[0]f+u||n[1]>m+s)return null;const v=this.opts.textHeight*Math.min(this.gl.canvas.height,this.gl.canvas.width)*1,y=this.getAllLabels();for(const T of y){const I=this.opts.textHeight*this.gl.canvas.height*T.style.textScale,S=this.textHeight(I,T.text);if(n[1]>=m&&n[1]<=m+S+v/2)return T;m+=S,m+=v/2}return null}drawLabelLine(n,s,u,f,m=!1){const A=Array.isArray(n.points)&&Array.isArray(n.points[0])?n.points:[n.points];for(const v of A){const y=this.calculateScreenPoint(v,u,f);m?this.drawDottedLine([...s,y[0],y[1]],n.style.lineWidth,n.style.lineColor):this.draw3DLine(s,[y[0],y[1],y[2]],n.style.lineWidth,n.style.lineColor)}}draw3DLabel(n,s,u,f,m=0,A,v=!1){const y=n.text,T=s[0],I=s[1],S=this.opts.textHeight*Math.min(this.gl.canvas.height,this.gl.canvas.width)*1,E=this.textHeight(n.style.textScale,y)*S;if(n.style.lineWidth>0&&Array.isArray(n.points)&&this.drawLabelLine(n,[T,I+E],u,f,v),n.style.bulletScale){const F=n.style.bulletScale*E,M=E-F,L=I+M/2+F/2,V=T+(m-F)/2;this.drawCircle([V,L,F,F],n.style.bulletColor)}let e=T;if(n.style.textAlignment!=="left"){const F=this.textWidth(n.style.textScale,n.text)*S;if(n.style.textAlignment==="right")e=T+A-S*1.5-F;else{const M=A-(m||S);e+=(M-F)/2}}else e+=m;this.drawText([e,I],y,n.style.textScale,n.style.textColor)}draw3DLabels(n,s,u=!1){const f=this.getAllLabels();if(!this.opts.showLegend||f.length===0)return;if(!this.canvas)throw new Error("canvas undefined");const m=this.gl;m.disable(m.CULL_FACE),m.viewport(0,0,this.canvas.width,this.canvas.height);const v=this.opts.textHeight*Math.min(this.gl.canvas.height,this.gl.canvas.width)*1,y=this.getBulletMarginWidth(),T=this.getLegendPanelHeight(),I=this.getLegendPanelWidth(),S=m.canvas.width-I;let E=(this.canvas.height-T)/2;this.drawRect([m.canvas.width-I,E,I-v,T],this.opts.legendBackgroundColor);const e=m.getParameter(m.BLEND),F=m.getParameter(m.DEPTH_FUNC);u||(m.disable(m.BLEND),m.depthFunc(m.GREATER));for(const M of f){this.draw3DLabel(M,[S,E],n,s,y,I,u);const L=this.opts.textHeight*this.gl.canvas.height*M.style.textScale,V=this.textHeight(L,M.text);E+=V,E+=v/2}u||(m.depthFunc(F),e&&m.enable(m.BLEND))}draw3D(n=[0,0,0,0],s=null,u=null,f=null,m=null,A=0){const v=m!==null;this.setPivot3D(),v||(m=this.scene.renderAzimuth,A=this.scene.renderElevation);const y=this.gl;s===null&&([s,u,f]=this.calculateMvpMatrix(null,n,m,A));let T=[...n];if(n[2]===0||n[3]===0?(n=[0,0,y.canvas.width,y.canvas.height],T=[...n],this.screenSlices.push({leftTopWidthHeight:n,axCorSag:4,sliceFrac:0,AxyzMxy:[],leftTopMM:[],fovMM:[isRadiological(u),0]})):(this.screenSlices.push({leftTopWidthHeight:n.slice(),axCorSag:4,sliceFrac:0,AxyzMxy:[],leftTopMM:[],fovMM:[isRadiological(u),0]}),n[1]=y.canvas.height-n[3]-n[1]),y.enable(y.DEPTH_TEST),y.depthFunc(y.ALWAYS),y.depthMask(!0),y.clearDepth(0),this.draw3DLabels(s,T,!1),y.viewport(n[0],n[1],n[2],n[3]),this.updateInterpolation(0,!0),this.volumes.length>0&&this.drawImage3D(s,m,A),this.updateInterpolation(0),v||this.drawCrosshairs3D(!0,1,s),this.drawMesh3D(!0,1,s,u,f),this.uiData.mouseDepthPicker){this.depthPicker(n,s),this.createOnLocationChange(),this.draw3D(n,s,u,f,m,A);return}this.opts.meshXRay>0&&this.drawMesh3D(!1,this.opts.meshXRay,s,u,f),this.draw3DLabels(s,T,!1),y.viewport(n[0],n[1],n[2],n[3]),v||this.drawCrosshairs3D(!1,.15,s),y.viewport(0,0,y.canvas.width,y.canvas.height),this.drawOrientationCube(n,m,A);const I="azimuth: "+this.scene.renderAzimuth.toFixed(0)+" elevation: "+this.scene.renderElevation.toFixed(0);return this.readyForSync=!0,this.sync(),this.draw3DLabels(s,T,!0),I}drawMesh3D(n=!0,s=1,u,f,m){if(this.meshes.length<1)return;const A=this.gl;u||([u,f,m]=this.calculateMvpMatrix(this.volumeObject3D,void 0,this.scene.renderAzimuth,this.scene.renderElevation)),A.enable(A.DEPTH_TEST),A.blendFunc(A.SRC_ALPHA,A.ONE_MINUS_SRC_ALPHA),A.disable(A.BLEND),A.depthFunc(A.GREATER),A.disable(A.CULL_FACE),n?(A.disable(A.BLEND),A.depthFunc(A.GREATER)):(A.enable(A.BLEND),A.depthFunc(A.ALWAYS),A.enable(A.CULL_FACE)),A.cullFace(A.BACK);let v=this.meshShaders[0].shader,y=!1;for(let T=0;T=3&&this.meshes[T].fiberRadius>0||(A.bindVertexArray(this.meshes[T].vaoFiber),A.drawElements(A.LINE_STRIP,this.meshes[T].indexCount,A.UNSIGNED_INT,0),A.bindVertexArray(this.unusedVAO)));A.enable(A.BLEND),A.depthFunc(A.ALWAYS),this.readyForSync=!0}drawCrosshairs3D(n=!0,s=1,u=null,f=!1,m=!0){if(!this.opts.show3Dcrosshair&&!f||this.opts.crosshairWidth<=0&&f)return;const A=this.gl,v=this.frac2mm(this.scene.crosshairPos,0,m);if(this.crosshairs3D===null||this.crosshairs3D.mm[0]!==v[0]||this.crosshairs3D.mm[1]!==v[1]||this.crosshairs3D.mm[2]!==v[2]){this.crosshairs3D!==null&&(A.deleteBuffer(this.crosshairs3D.indexBuffer),A.deleteBuffer(this.crosshairs3D.vertexBuffer));const[I,S,E]=this.sceneExtentsMinMax(m);let e=1;if(this.volumes.length>0){if(!this.back)throw new Error("back undefined");e=.5*Math.min(Math.min(this.back.pixDims[1],this.back.pixDims[2]),this.back.pixDims[3])}else(E[0]<50||E[0]>1e3)&&(e=E[0]*.02);e*=this.opts.crosshairWidth,this.crosshairs3D=NiivueObject3D.generateCrosshairs(this.gl,1,v,I,S,e,20,this.opts.crosshairGap),this.crosshairs3D.mm=v}if(!this.surfaceShader)throw new Error("surfaceShader undefined");const y=this.surfaceShader;y.use(this.gl),u==null&&([u]=this.calculateMvpMatrix(this.crosshairs3D,void 0,this.scene.renderAzimuth,this.scene.renderElevation)),A.uniformMatrix4fv(y.uniforms.mvpMtx,!1,u),A.bindBuffer(A.ELEMENT_ARRAY_BUFFER,this.crosshairs3D.indexBuffer),A.enable(A.DEPTH_TEST);const T=[...this.opts.crosshairColor];n?(A.disable(A.BLEND),A.depthFunc(A.GREATER)):(A.enable(A.BLEND),A.blendFunc(A.SRC_ALPHA,A.ONE_MINUS_SRC_ALPHA),A.depthFunc(A.ALWAYS)),T[3]=s,A.uniform4fv(y.uniforms.surfaceColor,T),A.bindVertexArray(this.crosshairs3D.vao),A.drawElements(A.TRIANGLES,this.crosshairs3D.indexCount,A.UNSIGNED_INT,0),A.bindVertexArray(this.unusedVAO)}mm2frac(n,s=0,u=!1){if(this.volumes.length<1){const f=fromValues$2(.1,.5,.5),[m,A,v]=this.sceneExtentsMinMax();return f[0]=(n[0]-m[0])/v[0],f[1]=(n[1]-m[1])/v[1],f[2]=(n[2]-m[2])/v[2],isFinite(f)||(isFinite(f[0])||(f[0]=.5),isFinite(f[1])||(f[1]=.5),isFinite(f[2])||(f[2]=.5),this.meshes.length<1&&log$4.error("mm2frac() not finite: objects not (yet) loaded.")),f}return this.volumes[s].convertMM2Frac(n,u||this.opts.isSliceMM)}vox2frac(n,s=0){return this.volumes[s].convertVox2Frac(n)}frac2vox(n,s=0){return this.volumes.length<=s?[0,0,0]:this.volumes[s].convertFrac2Vox(n)}moveCrosshairInVox(n,s,u){const f=this.frac2vox(this.scene.crosshairPos);f[0]+=n,f[1]+=s,f[2]+=u,f[0]=clamp$1(f[0],0,this.volumes[0].dimsRAS[1]-1),f[1]=clamp$1(f[1],0,this.volumes[0].dimsRAS[2]-1),f[2]=clamp$1(f[2],0,this.volumes[0].dimsRAS[3]-1),this.scene.crosshairPos=this.vox2frac(f),this.createOnLocationChange(),this.drawScene()}frac2mm(n,s=0,u=!1){const f=fromValues$1(n[0],n[1],n[2],1);if(this.volumes.length>0)return this.volumes[s].convertFrac2MM(n,u||this.opts.isSliceMM);{const[m,A]=this.sceneExtentsMinMax(),v=(y,T,I)=>y*(1-I)+T*I;f[0]=v(m[0],A[0],n[0]),f[1]=v(m[1],A[1],n[1]),f[2]=v(m[2],A[2],n[2])}return f}screenXY2TextureFrac(n,s,u,f=!0){const m=fromValues$2(-1,-1,-1),A=this.screenSlices[u].axCorSag;if(A>2)return m;const v=this.screenSlices[u].leftTopWidthHeight.slice();let y=!1;v[2]<0&&(y=!0,v[0]+=v[2],v[2]=-v[2]);let T=(n-v[0])/v[2];y&&(T=1-T);const I=1-(s-v[1])/v[3];if(T<0||T>1||I<0||I>1||this.screenSlices[u].AxyzMxy.length<4)return m;let S=fromValues$2(0,0,0);S[0]=this.screenSlices[u].leftTopMM[0]+T*this.screenSlices[u].fovMM[0],S[1]=this.screenSlices[u].leftTopMM[1]+I*this.screenSlices[u].fovMM[1];const E=this.screenSlices[u].AxyzMxy;S[2]=E[2]+E[4]*(S[1]-E[1])-E[3]*(S[0]-E[0]),A===1&&(S=swizzleVec3(S,[0,2,1])),A===2&&(S=swizzleVec3(S,[2,0,1]));const e=this.mm2frac(S);return f&&(e[0]<0||e[0]>1||e[1]<0||e[1]>1||e[2]<0||e[2]>1)?m:e}canvasPos2frac(n){for(let s=0;s=0)return u}return[-1,-1,-1]}scaleSlice(n,s,u=0,f=0){const m=this.effectiveCanvasWidth()-u,A=this.effectiveCanvasHeight()-f;let v=m/n;s*v>A&&(v=A/s);const y=n*v,T=s*v;return[(m-y)*.5,(A-T)*.5,y,T,v]}drawThumbnail(){if(!this.bmpShader)throw new Error("bmpShader undefined");this.bmpShader.use(this.gl),this.gl.uniform2f(this.bmpShader.uniforms.canvasWidthHeight,this.gl.canvas.width,this.gl.canvas.height);let n=this.gl.canvas.height,s=this.gl.canvas.height*this.bmpTextureWH;s>this.gl.canvas.width&&(n=this.gl.canvas.width/this.bmpTextureWH,s=this.gl.canvas.width),this.gl.uniform4f(this.bmpShader.uniforms.leftTopWidthHeight,0,0,s,n),this.gl.bindVertexArray(this.genericVAO),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.gl.bindVertexArray(this.unusedVAO)}drawLine(n,s=1,u=[1,0,0,-1]){if(this.gl.bindVertexArray(this.genericVAO),!this.lineShader)throw new Error("lineShader undefined");this.lineShader.use(this.gl),u[3]<0&&(u=this.opts.crosshairColor),this.gl.uniform4fv(this.lineShader.uniforms.lineColor,u),this.gl.uniform2fv(this.lineShader.uniforms.canvasWidthHeight,[this.gl.canvas.width,this.gl.canvas.height]),this.gl.uniform1f(this.lineShader.uniforms.thickness,s),this.gl.uniform4fv(this.lineShader.uniforms.startXYendXY,n),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.gl.bindVertexArray(this.unusedVAO)}draw3DLine(n,s,u=1,f=[1,0,0,-1]){if(this.gl.bindVertexArray(this.genericVAO),!this.line3DShader)throw new Error("line3DShader undefined");this.line3DShader.use(this.gl),f[3]<0&&(f=this.opts.crosshairColor),this.gl.uniform4fv(this.line3DShader.uniforms.lineColor,f),this.gl.uniform2fv(this.line3DShader.uniforms.canvasWidthHeight,[this.gl.canvas.width,this.gl.canvas.height]),this.gl.uniform1f(this.line3DShader.uniforms.thickness,u),this.gl.uniform2fv(this.line3DShader.uniforms.startXY,n),this.gl.uniform3fv(this.line3DShader.uniforms.endXYZ,s),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.gl.bindVertexArray(this.unusedVAO)}drawDottedLine(n,s=1,u=[1,0,0,-1]){if(this.gl.bindVertexArray(this.genericVAO),!this.lineShader)throw new Error("lineShader undefined");this.lineShader.use(this.gl);const f=u[3]<0?[...this.opts.crosshairColor]:[...u];f[3]=.3;const m=fromValues(n[2]-n[0],n[3]-n[1]),A=length(m);normalize(m,m);const y=this.opts.textHeight*Math.min(this.gl.canvas.height,this.gl.canvas.width)*1;scale$1(m,m,y/2);const T=length(m);let I=Math.floor(A/T);A%T&&I++;const S=[n[0],n[1]];this.gl.uniform4fv(this.lineShader.uniforms.lineColor,f),this.gl.uniform2fv(this.lineShader.uniforms.canvasWidthHeight,[this.gl.canvas.width,this.gl.canvas.height]),this.gl.uniform1f(this.lineShader.uniforms.thickness,s);for(let E=0;E0&&s===0){const e=v,F=1;for(let M=0;M0&&s===1){const e=v,F=2;for(let M=0;M0&&s===2){const e=v,F=2;for(let M=0;M0&&s===0){const e=v,F=0;for(let M=0;M0&&s===1){const e=v,F=0;for(let M=0;M0&&s===2){const e=v,F=1;for(let M=0;M0){const T=A.leftTopWidthHeight.slice();let I=2;s===0&&(I=1);const S=this.frac2mm([.5,.5,.5]);for(let E=0;E0){const T=A.leftTopWidthHeight.slice(),I=A.fovMM[0]<0;let S=0;s===2&&(S=1);const E=this.frac2mm([.5,.5,.5]);for(let e=0;e"u"){if(this.meshes.length>0){this.screenSlices=[],this.opts.sliceType=4,this.draw3D(),this.opts.isColorbar&&this.drawColorbar();return}this.drawLoadingText(this.loadingText);return}if(this.back===null)return;if(this.uiData.isDragging&&this.scene.clipPlaneDepthAziElev[0]<1.8&&this.inRenderTile(this.uiData.dragStart[0],this.uiData.dragStart[1])>=0){const m=this.uiData.dragStart[0]-this.uiData.dragEnd[0],A=this.uiData.dragStart[1]-this.uiData.dragEnd[1],v=this.uiData.dragClipPlaneStartDepthAziElev.slice();if(v[1]-=m,v[1]=v[1]%360,v[2]+=A,v[1]!==this.scene.clipPlaneDepthAziElev[1]||v[2]!==this.scene.clipPlaneDepthAziElev[2])return this.scene.clipPlaneDepthAziElev=v,this.setClipPlane(this.scene.clipPlaneDepthAziElev)}if(this.sliceMosaicString.length<1&&this.opts.sliceType===4){this.opts.isColorbar&&this.reserveColorbarPanel(),this.screenSlices=[],this.draw3D(),this.opts.isColorbar&&this.drawColorbar();return}this.opts.isColorbar&&this.reserveColorbarPanel();const s=this.getMaxVols(),u=this.opts.sliceType===3&&s>1&&this.graph.autoSizeMultiplanar&&this.graph.opacity>0;if(this.sliceMosaicString.length>0)this.drawMosaic(this.sliceMosaicString);else if(this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.screenSlices=[],this.opts.sliceType===0)this.draw2D([0,0,0,0],0);else if(this.opts.sliceType===1)this.draw2D([0,0,0,0],1);else if(this.opts.sliceType===2)this.draw2D([0,0,0,0],2);else{const m=isFinite(this.drawPenLocation[0])&&this.opts.drawingEnabled,{volScale:A}=this.sliceScale();typeof this.opts.multiplanarPadPixels!="number"&&log$4.debug("multiplanarPadPixels must be numeric");const v=parseFloat(`${this.opts.multiplanarPadPixels}`),y=this.scaleSlice(A[0]+A[1],A[1]+A[2],v*1,v*1),T=Math.max(Math.max(A[1],A[2]),A[0]),I=this.scaleSlice(A[0]+A[0]+A[1],Math.max(A[1],A[2]),v*2),S=this.scaleSlice(A[0]+A[0]+A[1]+T,Math.max(A[1],A[2]),v*3),E=this.scaleSlice(T,A[1]+A[2]+A[2],0,v*2),e=this.scaleSlice(T,A[1]+A[2]+A[2]+T,0,v*3);let F=!m&&(s<2||!u),M=!1,L=!1,V=!1;if(this.opts.multiplanarLayout===1?M=!0:this.opts.multiplanarLayout===2?L=!0:this.opts.multiplanarLayout===3?V=!0:E[4]>I[4]&&E[4]>y[4]?M=!0:I[4]>y[4]?V=!0:L=!0,M){let B=E;this.opts.multiplanarForceRender||e[4]>=E[4]?B=e:F=!1;const z=A[0]*B[4],b=A[1]*B[4],W=A[2]*B[4],q=T*B[4];this.draw2D([B[0],B[1],z,b],0),this.draw2D([B[0],B[1]+b+v,z,W],1),this.draw2D([B[0],B[1]+b+v+W+v,b,W],2),F&&this.draw3D([B[0],B[1]+b+W+W+v*3,q,q])}else if(V){let B=I;this.opts.multiplanarForceRender||S[4]>=I[4]?B=S:F=!1;const z=A[0]*B[4],b=A[1]*B[4],W=A[2]*B[4];this.draw2D([B[0],B[1],z,b],0),this.draw2D([B[0]+z+v,B[1],z,W],1),this.draw2D([B[0]+z+z+v*2,B[1],b,W],2),F&&this.draw3D([B[0]+z+z+b+v*3,B[1],B[3],B[3]])}else if(L){const B=y,z=A[0]*B[4],b=A[1]*B[4],W=A[2]*B[4];this.draw2D([B[0],B[1]+W+v,z,b],0),this.draw2D([B[0],B[1],z,W],1),this.draw2D([B[0]+z+v,B[1],b,W],2),F&&this.draw3D([B[0]+z+v,B[1]+W+v,b,b])}}if(this.opts.isRuler&&this.drawRuler(),this.opts.isColorbar&&this.drawColorbar(),u&&this.drawGraph(),this.uiData.isDragging){if(this.uiData.mouseButtonCenterDown){this.dragForCenterButton([this.uiData.dragStart[0],this.uiData.dragStart[1],this.uiData.dragEnd[0],this.uiData.dragEnd[1]]);return}if(this.opts.dragMode===4){this.dragForSlicer3D([this.uiData.dragStart[0],this.uiData.dragStart[1],this.uiData.dragEnd[0],this.uiData.dragEnd[1]]);return}if(this.opts.dragMode===3){this.dragForPanZoom([this.uiData.dragStart[0],this.uiData.dragStart[1],this.uiData.dragEnd[0],this.uiData.dragEnd[1]]);return}if(this.inRenderTile(this.uiData.dragStart[0],this.uiData.dragStart[1])>=0)return;if(this.opts.dragMode===2){this.drawMeasurementTool([this.uiData.dragStart[0],this.uiData.dragStart[1],this.uiData.dragEnd[0],this.uiData.dragEnd[1]]);return}const m=Math.abs(this.uiData.dragStart[0]-this.uiData.dragEnd[0]),A=Math.abs(this.uiData.dragStart[1]-this.uiData.dragEnd[1]);this.drawSelectionBox([Math.min(this.uiData.dragStart[0],this.uiData.dragEnd[0]),Math.min(this.uiData.dragStart[1],this.uiData.dragEnd[1]),m,A])}const f=this.frac2mm([this.scene.crosshairPos[0],this.scene.crosshairPos[1],this.scene.crosshairPos[2]]);return n=f[0].toFixed(2)+"×"+f[1].toFixed(2)+"×"+f[2].toFixed(2),this.readyForSync=!0,this.sync(),n}drawScene(){if(this.isBusy){this.needsRefresh=!0;return}this.isBusy=!1,this.needsRefresh=!1;let n=this.drawSceneCore();return this._gl!==null&&this.gl.finish(),this.needsRefresh&&(n=this.drawScene()),n}get gl(){if(!this._gl)throw new Error("unable to get WebGL context. Maybe the browser doesn't support WebGL2.");return this._gl}set gl(n){this._gl=n}};/** +Ooh no!!`);break}m[y]=T,v=Math.min(v,T)}for(let y=0;y=1e-15&&I++;const S=1e3,E=(v-A)/S,e=new Array(S).fill(0);for(let z=0;z=M);)L++;const V=A;for(A=L*E+V,M=T-Math.floor((1-m)*I),L=0;L=M);)L++;v=L*E+V;let B=1;return A!==v&&(B=(u-s)/(v-A)),log$4.info(" Rescale: min: "+A+" max: "+v+" scale: "+B),[A,B]}conformVox2Vox(n,s,u=256,f=1,m=!1){const A=s.flat(),v=fromValues$3(A[0],A[1],A[2],A[3],A[4],A[5],A[6],A[7],A[8],A[9],A[10],A[11],A[12],A[13],A[14],A[15]),y=fromValues$1(n[1]/2,n[2]/2,n[3]/2,1),T=create$1(),I=create$3();transpose$3(I,v),transformMat4(T,y,I);const S=fromValues$2(T[0],T[1],T[2]),E=fromValues$2(f,f,f);let e=fromValues$3(-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);m&&(e=fromValues$3(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)),transpose$3(e,e);const F=fromValues$1(u,u,u,1),M=create$3();scale$4(M,e,E);const L=fromValues$1(F[0],F[1],F[2],1);transformMat4(L,L,M),scale$2(L,L,.5);const V=create$2();subtract$1(V,S,fromValues$2(L[0],L[1],L[2]));const B=create$3();transpose$3(B,M),B[3]=V[0],B[7]=V[1],B[11]=V[2];const z=create$3();invert(z,B);const b=create$3();mul$1(b,v,z);const W=create$3();return invert(W,b),[B,b,W]}async createNiftiArray(n=[256,256,256],s=[1,1,1],u=[1,0,0,-128,0,1,0,-128,0,0,1,-128,0,0,0,1],f=2,m=new Uint8Array){return await NVImage.createNiftiArray(n,s,u,f,m)}async niftiArray2NVImage(n=new Uint8Array){return await NVImage.loadFromUrl({url:n})}async loadFromUrl(n){return await NVImage.loadFromUrl({url:n})}async conform(n,s=!1,u=!0,f=!1){const v=this.conformVox2Vox(n.hdr.dims,n.hdr.affine.flat(),256,1,s),y=v[0],T=v[2],I=256*256*256,S=new Float32Array(I),E=new Float32Array(n.img),e=n.hdr.dims[1]*n.hdr.dims[2]*n.hdr.dims[3];if(n.hdr.scl_slope!==1||n.hdr.scl_inter!==0)for(let H=0;H=F||je>=M||nt>=L)continue;const Ue=pe-ve,ye=me-we,ut=Se-Ne,pt=1-Ue,It=1-ye,Lt=1-ut,Ot=z(ve,we,Ne);let Et=0;Et+=E[Ot]*pt*It*Lt,Et+=E[Ot+V]*pt*It*ut,Et+=E[Ot+F]*pt*ye*Lt,Et+=E[Ot+F+V]*pt*ye*ut,Et+=E[Ot+1]*Ue*It*Lt,Et+=E[Ot+1+V]*Ue*It*ut,Et+=E[Ot+1+F]*Ue*ye*Lt,Et+=E[Ot+1+F+V]*Ue*ye*ut,S[B]=Et}}else for(let H=0;H<256;H++)for(let g=0;g<256;g++){const J=g*T[1]+H*T[2]+T[3],re=g*T[5]+H*T[6]+T[7],ae=g*T[9]+H*T[10]+T[11];for(let fe=0;fe<256;fe++){const pe=Math.round(fe*b+J),me=Math.round(fe*W+re),Se=Math.round(fe*q+ae);B++,!(pe<0||me<0||Se<0)&&(pe>=F||me>=M||Se>=L||(S[B]=E[z(pe,me,Se)]))}}let Y=new Uint8Array;if(f){const H=await this.getScale(n,0,1),g=await this.scalecropFloat32(S,0,1,H[0],H[1]);Y=await this.createNiftiArray([256,256,256],[1,1,1],Array.from(y),16,new Uint8Array(g.buffer))}else{const H=await this.getScale(n,0,255),g=await this.scalecropUint8(S,0,255,H[0],H[1]);Y=await this.createNiftiArray([256,256,256],[1,1,1],Array.from(y),2,g)}return await this.niftiArray2NVImage(Y)}setRenderDrawAmbientOcclusion(n){if(!this.renderShader)throw new Error("renderShader undefined");this.renderDrawAmbientOcclusion=n,this.renderShader.use(this.gl),this.gl.uniform1fv(this.renderShader.uniforms.renderDrawAmbientOcclusion,[this.renderDrawAmbientOcclusion,1]),this.drawScene()}setColorMap(n,s){this.setColormap(n,s)}setColormapNegative(n,s){const u=this.getVolumeIndexByID(n);this.volumes[u].colormapNegative=s,this.updateGLVolume()}setModulationImage(n,s,u=0){const f=this.getVolumeIndexByID(n);let m=null;s.length>0&&(m=this.getVolumeIndexByID(s)),this.volumes[f].modulationImage=m,this.volumes[f].modulateAlpha=u,this.updateGLVolume()}setGamma(n=1){cmapper.gamma=n,this.updateGLVolume()}async loadDeferred4DVolumes(n){const s=this.getVolumeIndexByID(n),u=this.volumes[s];if(u.nTotalFrame4D<=u.nFrame4D)return;let f;u.fileObject?f=await NVImage.loadFromFile({file:u.fileObject}):f=await NVImage.loadFromUrl({url:u.url}),f&&(u.img=f.img.slice(),u.nTotalFrame4D=f.nTotalFrame4D,u.nFrame4D=f.nFrame4D,this.updateGLVolume())}setFrame4D(n,s){const u=this.getVolumeIndexByID(n),f=this.volumes[u];s>f.nFrame4D-1&&(s=f.nFrame4D-1),s<0&&(s=0),s!==f.frame4D&&(f.frame4D=s,this.updateGLVolume(),this.onFrameChange(f,s),this.createOnLocationChange())}getFrame4D(n){const s=this.getVolumeIndexByID(n);return this.volumes[s].frame4D}colormapFromKey(n){return cmapper.colormapFromKey(n)}colormap(n="",s=!1){return cmapper.colormap(n,s)}createColormapTexture(n=null,s=0,u=256){return n!==null&&this.gl.deleteTexture(n),s<1||u<1?null:(n=this.gl.createTexture(),this.gl.activeTexture(TEXTURE1_COLORMAPS),this.gl.bindTexture(this.gl.TEXTURE_2D,n),this.gl.texStorage2D(this.gl.TEXTURE_2D,1,this.gl.RGBA8,u,s),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_R,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),n)}addColormapList(n="",s=NaN,u=NaN,f=!1,m=!1,A=!0,v=!1){n.length<1&&(A=!1),this.colormapLists.push({name:n,min:s,max:u,alphaThreshold:f,negative:m,visible:A,invert:v})}refreshColormaps(){if(this.colormapLists=[],this.volumes.length<1&&this.meshes.length<1)return;const n=this.volumes.length;if(n>0)for(let A=0;A0)for(let A=0;Af[0]&&s>f[1]&&n=0&&this.screenSlices[u].axCorSag===4?u:-1}sliceScroll3D(n=0){if(n!==0){if(this.volumes.length>0&&this.scene.clipPlaneDepthAziElev[0]<1.8){const s=this.scene.clipPlaneDepthAziElev.slice();return n>0&&(s[0]=Math.min(1.5,s[0]+.025)),n<0&&(s[0]=Math.max(-1.5,s[0]-.025)),s[0]!==this.scene.clipPlaneDepthAziElev[0]?(this.scene.clipPlaneDepthAziElev=s,this.setClipPlane(this.scene.clipPlaneDepthAziElev)):void 0}n>0&&(this.scene.volScaleMultiplier=Math.min(2,this.scene.volScaleMultiplier*1.1)),n<0&&(this.scene.volScaleMultiplier=Math.max(.5,this.scene.volScaleMultiplier*.9)),this.drawScene()}}deleteThumbnail(){this.bmpTexture&&(this.gl.deleteTexture(this.bmpTexture),this.bmpTexture=null,this.thumbnailVisible=!1)}inGraphTile(n,s){if(this.graph.opacity<=0||this.volumes.length<1||this.volumes[0].nFrame4D<1||!this.graph.plotLTWH||this.graph.plotLTWH[2]<1||this.graph.plotLTWH[3]<1)return!1;const u=[(n-this.graph.LTWH[0])/this.graph.LTWH[2],(s-this.graph.LTWH[1])/this.graph.LTWH[3]];return u[0]>0&&u[1]>0&&u[0]<=1&&u[1]<=1}mouseClick(n,s,u=0,f=!0){if(n*=this.uiData.dpr,s*=this.uiData.dpr,this.canvas.focus(),this.thumbnailVisible){this.thumbnailVisible=!1,Promise.all([this.loadVolumes(this.deferredVolumes),this.loadMeshes(this.deferredMeshes)]).catch(m=>{throw m});return}if(this.inGraphTile(n,s)){if(!this.graph.plotLTWH)throw new Error("plotLTWH undefined");const m=[(n-this.graph.plotLTWH[0])/this.graph.plotLTWH[2],(s-this.graph.plotLTWH[1])/this.graph.plotLTWH[3]];if(m[0]>0&&m[1]>0&&m[0]<=1&&m[1]<=1){const A=Math.round(m[0]*(this.volumes[0].nFrame4D-1));this.setFrame4D(this.volumes[0].id,A);return}m[0]>.5&&m[1]>1&&this.loadDeferred4DVolumes(this.volumes[0].id).catch(A=>{throw A});return}if(this.inRenderTile(n,s)>=0){this.sliceScroll3D(u),this.drawScene();return}if(!(this.screenSlices.length<1||this.gl.canvas.height<1||this.gl.canvas.width<1))for(let m=0;m=0&&this.drawPenAxCorSag!==A||A>2)continue;const v=this.screenXY2TextureFrac(n,s,m,!1);if(!(v[0]<0)){if(!f){this.scene.crosshairPos[2-A]=u,this.drawScene();return}if(u!==0){let y=1;u<0&&(y=-1);const T=[0,0,0];T[2-A]=y,this.moveCrosshairInVox(T[0],T[1],T[2]),this.drawScene(),this.createOnLocationChange(A);return}if(this.opts.isForceMouseClickToVoxelCenters?this.scene.crosshairPos=clone$2(this.vox2frac(this.frac2vox(v))):this.scene.crosshairPos=clone$2(v),this.opts.drawingEnabled){const y=this.frac2vox(this.scene.crosshairPos);if(!isFinite(this.opts.penValue)||this.opts.penValue<0||Object.is(this.opts.penValue,-0)){isFinite(this.opts.penValue)?this.drawFloodFill(y,Math.abs(this.opts.penValue),this.opts.floodFillNeighbors):this.drawFloodFill(y,0,this.opts.penValue,this.opts.floodFillNeighbors);return}if(isNaN(this.drawPenLocation[0]))this.drawPenAxCorSag=A,this.drawPenFillPts=[],this.drawPt(...y,this.opts.penValue);else{if(y[0]===this.drawPenLocation[0]&&y[1]===this.drawPenLocation[1]&&y[2]===this.drawPenLocation[2])return;this.drawPenLine(y,this.drawPenLocation,this.opts.penValue)}this.drawPenLocation=y,this.opts.isFilledPen&&this.drawPenFillPts.push(y),this.refreshDrawing(!1)}this.drawScene(),this.createOnLocationChange(A);return}}}drawRuler(){let n=[],s=[];for(let y=0;y1){s=this.screenSlices[y].leftTopWidthHeight,n=this.screenSlices[y].fovMM;break}if(s.length<4)return;const f=100/n[0]*s[2],m=s[0]+.5*s[2]-.5*f,A=s[1]+s[3]-2*this.opts.rulerWidth,v=[m,A,m+f,A];this.drawRuler10cm(v)}drawRuler10cm(n){if(!this.lineShader)throw new Error("lineShader undefined");this.gl.bindVertexArray(this.genericVAO),this.lineShader.use(this.gl),this.gl.uniform4fv(this.lineShader.uniforms.lineColor,this.opts.rulerColor),this.gl.uniform2fv(this.lineShader.uniforms.canvasWidthHeight,[this.gl.canvas.width,this.gl.canvas.height]),this.gl.uniform1f(this.lineShader.uniforms.thickness,this.opts.rulerWidth),this.gl.uniform4fv(this.lineShader.uniforms.startXYendXY,n),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4);const s=-.1*(n[0]-n[2]),u=n[1],f=u-2*this.opts.rulerWidth,m=u-4*this.opts.rulerWidth;for(let A=0;A<11;A++){const v=n[0]+A*s,y=[v,u,v,f];A%5===0&&(y[3]=m),this.gl.uniform4fv(this.lineShader.uniforms.startXYendXY,y),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}this.gl.bindVertexArray(this.unusedVAO)}screenXY2mm(n,s,u=-1){let f;for(let m=0;m=0&&(A=u),this.screenSlices[A].axCorSag>2)continue;const y=this.screenSlices[A].leftTopWidthHeight;if(ny[0]+y[2]||s>y[1]+y[3]||(f=this.screenXY2TextureFrac(n,s,A,!1),f[0]<0))continue;const T=this.frac2mm(f);return fromValues$1(T[0],T[1],T[2],A)}return fromValues$1(NaN,NaN,NaN,NaN)}dragForPanZoom(n){const s=this.screenXY2mm(n[2],n[3]);if(isNaN(s[0]))return;const u=this.screenXY2mm(n[0],n[1],s[3]);if(isNaN(u[0])||isNaN(s[0])||isNaN(s[3]))return;const f=create$1(),m=this.uiData.pan2DxyzmmAtMouseDown[3];sub$3(f,s,u),this.scene.pan2Dxyzmm[0]=this.uiData.pan2DxyzmmAtMouseDown[0]+m*f[0],this.scene.pan2Dxyzmm[1]=this.uiData.pan2DxyzmmAtMouseDown[1]+m*f[1],this.scene.pan2Dxyzmm[2]=this.uiData.pan2DxyzmmAtMouseDown[2]+m*f[2]}dragForCenterButton(n){this.dragForPanZoom(n)}dragForSlicer3D(n){let s=this.uiData.pan2DxyzmmAtMouseDown[3];const u=n[3]-n[1];s+=u*.01,s=Math.max(s,.1),s=Math.min(s,10);const m=this.scene.pan2Dxyzmm[3]-s;this.opts.yoke3Dto2DZoom&&(this.scene.volScaleMultiplier=s),this.scene.pan2Dxyzmm[3]=s;const A=this.frac2mm(this.scene.crosshairPos);this.scene.pan2Dxyzmm[0]+=m*A[0],this.scene.pan2Dxyzmm[1]+=m*A[1],this.scene.pan2Dxyzmm[2]+=m*A[2]}drawMeasurementTool(n){const s=this.gl;if(s.bindVertexArray(this.genericVAO),s.depthFunc(s.ALWAYS),s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),!this.lineShader)throw new Error("lineShader undefined");this.lineShader.use(this.gl),s.uniform4fv(this.lineShader.uniforms.lineColor,this.opts.rulerColor),s.uniform2fv(this.lineShader.uniforms.canvasWidthHeight,[s.canvas.width,s.canvas.height]),s.uniform1f(this.lineShader.uniforms.thickness,this.opts.rulerWidth),s.uniform4fv(this.lineShader.uniforms.startXYendXY,n),s.drawArrays(s.TRIANGLE_STRIP,0,4);const u=this.opts.rulerColor;u[3]=1,s.uniform4fv(this.lineShader.uniforms.lineColor,u);const f=this.opts.rulerWidth;s.uniform1f(this.lineShader.uniforms.thickness,f*2);let m=[n[0],n[1]-f,n[0],n[1]+f];s.uniform4fv(this.lineShader.uniforms.startXYendXY,m),s.drawArrays(s.TRIANGLE_STRIP,0,4),m=[n[2],n[3]-f,n[2],n[3]+f],s.uniform4fv(this.lineShader.uniforms.startXYendXY,m),s.drawArrays(s.TRIANGLE_STRIP,0,4);let A=this.canvasPos2frac([n[0],n[1]]),v=this.canvasPos2frac([n[2],n[3]]);if(A[0]>=0&&v[0]>=0){const y=this.frac2mm(A);A=fromValues$2(y[0],y[1],y[2]);const T=this.frac2mm(v);v=fromValues$2(T[0],T[1],T[2]);const I=create$2();sub$4(I,A,v);const S=len(I);let E=2;S>9&&(E=1),S>99&&(E=0);const e=S.toFixed(E);this.drawTextBetween(n,e,1,u)}s.bindVertexArray(this.unusedVAO)}drawRect(n,s=[1,0,0,-1]){if(s[3]<0&&(s=this.opts.crosshairColor),!this.rectShader)throw new Error("rectShader undefined");this.rectShader.use(this.gl),this.gl.enable(this.gl.BLEND),this.gl.uniform4fv(this.rectShader.uniforms.lineColor,s),this.gl.uniform2fv(this.rectShader.uniforms.canvasWidthHeight,[this.gl.canvas.width,this.gl.canvas.height]),this.gl.uniform4f(this.rectShader.uniforms.leftTopWidthHeight,n[0],n[1],n[2],n[3]),this.gl.bindVertexArray(this.genericVAO),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.gl.bindVertexArray(this.unusedVAO)}drawCircle(n,s=this.opts.fontColor,u=1){if(!this.circleShader)throw new Error("circleShader undefined");this.circleShader.use(this.gl),this.gl.enable(this.gl.BLEND),this.gl.uniform4fv(this.circleShader.uniforms.circleColor,s),this.gl.uniform2fv(this.circleShader.uniforms.canvasWidthHeight,[this.gl.canvas.width,this.gl.canvas.height]),this.gl.uniform4f(this.circleShader.uniforms.leftTopWidthHeight,n[0],n[1],n[2],n[3]),this.gl.uniform1f(this.circleShader.uniforms.fillPercent,u),this.gl.uniform4fv(this.circleShader.uniforms.circleColor,s),this.gl.bindVertexArray(this.genericVAO),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.gl.bindVertexArray(this.unusedVAO)}drawSelectionBox(n){this.drawRect(n,this.opts.selectionBoxColor)}effectiveCanvasHeight(){return this.gl.canvas.height-this.colorbarHeight}effectiveCanvasWidth(){return this.gl.canvas.width-this.getLegendPanelWidth()}getAllLabels(){const f=this.meshes.filter(A=>A.type==="connectome").flatMap(A=>A.nodes).map(A=>A.label).filter(A=>A!==void 0);return[...this.document.labels,...f]}getBulletMarginWidth(){let n=0;const s=this.getAllLabels();if(s.length===0)return 0;const u=s.length===1?s[0].style.bulletScale:s.reduce((A,v)=>A.style.bulletScale>v.style.bulletScale?A:v).style.bulletScale,f=s.length===1?s[0]:s.reduce((A,v)=>{const y=this.opts.textHeight*this.gl.canvas.height*A.style.textScale,T=this.opts.textHeight*this.gl.canvas.height*v.style.textScale;return this.textHeight(y,A.text)>this.textHeight(T,v.text)?A:v}),m=this.opts.textHeight*this.gl.canvas.height*f.style.textScale;return n=this.textHeight(m,f.text)*u,n+=m,n}getLegendPanelWidth(){const n=this.getAllLabels();if(!this.opts.showLegend||n.length===0)return 0;const u=this.opts.textHeight*this.gl.canvas.height*1;let f=0;const m=n.reduce((T,I)=>{const S=this.opts.textHeight*this.gl.canvas.height*T.style.textScale,E=this.opts.textHeight*this.gl.canvas.height*I.style.textScale;return this.textWidth(S,T.text)>this.textWidth(E,I.text)?T:I}),A=this.opts.textHeight*this.gl.canvas.height*m.style.textScale,v=this.textWidth(A,m.text),y=this.getBulletMarginWidth();return v&&(f=y+v,f+=u*2),f}getLegendPanelHeight(){const n=this.getAllLabels();let s=0;const f=this.opts.textHeight*this.gl.canvas.height*1;for(const m of n){const A=this.opts.textHeight*this.gl.canvas.height*m.style.textScale,v=this.textHeight(A,m.text);s+=v}return s&&(s+=f/2*(n.length+1)),s}reserveColorbarPanel(){let n=Math.max(this.opts.textHeight,.01);n=n*Math.min(this.gl.canvas.height,this.gl.canvas.width);const s=3*n,u=[0,this.gl.canvas.height-s,this.gl.canvas.width,s];return this.colorbarHeight=u[3]+1,u}drawColorbarCore(n=0,s=[0,0,0,0],u=!1,f=0,m=1,A){if(s[2]<=0||s[3]<=0)return;let v=Math.max(this.opts.textHeight,.01);v=v*Math.min(this.gl.canvas.height,this.gl.canvas.width);let y=v;const T=3*v;let I=v;if(s[3]0&&(F=f,f=0),f===m||v<1)return;const M=Math.abs(m-f);let[L,V]=tickSpacing(f,m);Vf.includes(y)).reduce((v,y)=>v.lbwh[3]>y.lbwh[3]?v:y).lbwh[3];return n*A}drawChar(n,s,u){if(!this.fontShader)throw new Error("fontShader undefined");const f=this.fontMets.mets[u],m=n[0]+s*f.lbwh[0],A=-(s*f.lbwh[1]),v=s*f.lbwh[2],y=s*f.lbwh[3],T=n[1]+(A-y)+s;return this.gl.uniform4f(this.fontShader.uniforms.leftTopWidthHeight,m,T,v,y),this.gl.uniform4fv(this.fontShader.uniforms.uvLeftTopWidthHeight,f.uv_lbwh),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),s*f.xadv}drawLoadingText(n){if(!this.canvas)throw new Error("canvas undefined");this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.gl.enable(this.gl.CULL_FACE),this.gl.enable(this.gl.BLEND),this.drawTextBelow([this.canvas.width/2,this.canvas.height/2],n,3)}drawText(n,s,u=1,f=null){if(this.opts.textHeight<=0)return;if(!this.fontShader)throw new Error("fontShader undefined");this.fontShader.use(this.gl);const m=this.opts.textHeight*Math.min(this.gl.canvas.height,this.gl.canvas.width)*u;this.gl.enable(this.gl.BLEND),this.gl.uniform2f(this.fontShader.uniforms.canvasWidthHeight,this.gl.canvas.width,this.gl.canvas.height),f===null&&(f=this.opts.fontColor),this.gl.uniform4fv(this.fontShader.uniforms.fontColor,f);let A=m/this.fontMets.size*this.fontMets.distanceRange;A=Math.max(A,1),this.gl.uniform1f(this.fontShader.uniforms.screenPxRange,A);const v=new TextEncoder().encode(s);this.gl.bindVertexArray(this.genericVAO);for(let y=0;y.8?T=[0,0,0,.5]:T=[1,1,1,.5],this.drawRect(y,T),this.drawText(m,s,u,f)}drawTextBelow(n,s,u=1,f=null){if(this.opts.textHeight<=0)return;if(!this.canvas)throw new Error("canvas undefined");let m=this.opts.textHeight*this.gl.canvas.height*u,A=this.textWidth(m,s);A>this.canvas.width&&(u*=(this.canvas.width-2)/A,m=this.opts.textHeight*this.gl.canvas.height*u,A=this.textWidth(m,s)),n[0]-=.5*this.textWidth(m,s),n[0]=Math.max(n[0],1),n[0]=Math.min(n[0],this.canvas.width-A-1),this.drawText(n,s,u,f)}updateInterpolation(n,s=!1){let u=this.gl.LINEAR;!s&&this.opts.isNearestInterpolation&&(u=this.gl.NEAREST),n===0?this.gl.activeTexture(TEXTURE0_BACK_VOL):this.gl.activeTexture(TEXTURE2_OVERLAY_VOL),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_MIN_FILTER,u),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_MAG_FILTER,u)}setAtlasOutline(n){this.opts.atlasOutline=n,this.updateGLVolume(),this.drawScene()}setInterpolation(n){this.opts.isNearestInterpolation=n;const s=this.volumes.length;if(!(s<1)){for(let u=0;u0){this.opts.meshThicknessOn2D!==1/0&&(M=this.calculateMvpMatrix2D(n,m.mnMM,m.mxMM,this.opts.meshThicknessOn2D,F,T,y,v));const V=clone$3(M.modelViewProjectionMatrix);multiply$2(V,V,A),this.drawMesh3D(!0,1,V,M.modelMatrix,M.normalMatrix)}isNaN(u)&&this.drawCrosshairs3D(!1,.15,M.modelViewProjectionMatrix,!0,this.opts.isSliceMM),this.drawSliceOrientationText(n,s),this.readyForSync=!0}calculateMvpMatrix(n,s=[0,0,0,0],u,f){(s[2]===0||s[3]===0)&&(s=[0,0,this.gl.canvas.width,this.gl.canvas.height]);const m=s[2]/s[3];let A=this.furthestFromPivot;const v=this.pivot3D,y=create$3();A=.8*A/this.scene.volScaleMultiplier,m<1?ortho(y,-A,A,-A/m,A/m,A*.01,A*8):ortho(y,-A*m,A*m,-A,A,A*.01,A*8);const T=create$3();T[0]=-1;const I=fromValues$2(0,0,-A*1.8);translate(T,T,I),this.position&&translate(T,T,this.position),rotateX(T,T,deg2rad(270-f)),rotateZ(T,T,deg2rad(u-180)),translate(T,T,[-v[0],-v[1],-v[2]]);const S=create$3();invert(S,T);const E=create$3();transpose$3(E,S);const e=create$3();return multiply$2(e,y,T),[e,T,E]}calculateModelMatrix(n,s){if(!this.back)throw new Error("back undefined");const u=create$3();if(u[0]=-1,rotateX(u,u,deg2rad(270-s)),rotateZ(u,u,deg2rad(n-180)),this.back.obliqueRAS){const f=clone$3(this.back.obliqueRAS);multiply$2(u,u,f)}return u}calculateRayDirection(n,s){const u=this.calculateModelMatrix(n,s),f=fromValues$3(1,0,0,0,0,-1,0,0,0,0,-1,0,0,0,0,1),m=create$3();multiply$2(m,f,u);const A=create$3();invert(A,m);const v=fromValues$1(0,0,-1,1);transformMat4(v,v,A);const y=fromValues$2(v[0],v[1],v[2]);normalize$1(y,y);const T=5e-5;return Math.abs(y[0])0){if(!this.volumeObject3D)throw new Error("volumeObject3D undefined");s=fromValues$2(this.volumeObject3D.extentsMin[0],this.volumeObject3D.extentsMin[1],this.volumeObject3D.extentsMin[2]),u=fromValues$2(this.volumeObject3D.extentsMax[0],this.volumeObject3D.extentsMax[1],this.volumeObject3D.extentsMax[2]),n||(s=fromValues$2(this.volumes[0].extentsMinOrtho[0],this.volumes[0].extentsMinOrtho[1],this.volumes[0].extentsMinOrtho[2]),u=fromValues$2(this.volumes[0].extentsMaxOrtho[0],this.volumes[0].extentsMaxOrtho[1],this.volumes[0].extentsMaxOrtho[2]))}if(this.meshes.length>0){if(this.volumes.length<1){const m=this.meshes[0].extentsMin,A=this.meshes[0].extentsMax;s=fromValues$2(m[0],m[1],m[2]),u=fromValues$2(A[0],A[1],A[2])}for(let m=0;mthis.gl.canvas.width||n.LTWH[1]+n.LTWH[3]>this.gl.canvas.height)return;n.backColor=[.15,.15,.15,n.opacity],n.lineColor=[1,1,1,1],this.opts.backColor[0]+this.opts.backColor[1]+this.opts.backColor[2]>1.5&&(n.backColor=[.95,.95,.95,n.opacity],n.lineColor=[0,0,0,1]),n.textColor=n.lineColor.slice(),n.lineThickness=4,n.lineAlpha=1,n.lines=[];const u=[];if(n.vols.length<1)this.volumes[0]!=null&&u.push(0);else for(let re=0;rem){const re=A-m;for(let ae=0;ae=A&&(A=m+1),this.drawRect(n.LTWH,n.backColor);const[v,y,T]=tickSpacing(m,A),I=Math.max(0,-1*Math.floor(Math.log(v)/Math.log(10)));m=Math.min(y,m),A=Math.max(T,A);function S(re){return re.toFixed(6).replace(/\.?0*$/,"")}const e=.07*(Math.min(n.LTWH[2],n.LTWH[3])/(this.fontMets.size*this.uiData.dpr));let F=this.opts.textHeight*this.gl.canvas.height*e;F<16&&(F=0);let M=0,L=y;if(F>0)for(;L<=A;){const re=L.toFixed(I),ae=this.textWidth(F,re);M=Math.max(ae,M),L+=v}const V=.05,B=Math.abs(n.LTWH[2]),z=Math.abs(n.LTWH[3]),b=[n.LTWH[0]+V*B+M,n.LTWH[1]+V*z,n.LTWH[2]-M-2*V*B,n.LTWH[3]-F-2*V*z];this.graph.LTWH=n.LTWH,this.graph.plotLTWH=b,this.drawRect(b,this.opts.backColor);const W=A-m,q=b[3]/W,Y=b[2]/(n.lines[0].length-1),X=b[1]+b[3];L=y+.5*v;const H=n.lineColor.slice();for(H[3]=.25*n.lineColor[3];L<=A;){const re=X-(L-m)*q;this.drawLine([b[0],re,b[0]+b[2],re],.5*n.lineThickness,H),L+=v}L=y;const g=.5*n.lineThickness;for(;L<=A;){const re=X-(L-m)*q;this.drawLine([b[0]-g,re,b[0]+b[2]+n.lineThickness,re],n.lineThickness,n.lineColor);const ae=L.toFixed(I);F>0&&this.drawTextLeft([b[0]-6,re],ae,e,n.textColor),L+=v}let J=1;for(;n.lines[0].length/J>20;)J*=5;for(let re=0;re0&&this.drawTextBelow([ae,2+b[1]+b[3]],pe,e,n.textColor),this.drawLine([ae,b[1],ae,b[1]+b[3]],fe,n.lineColor)}}for(let re=0;re=0&&n.selectedColumnE/255);return}const v=unpackFloatFromVec4i(A);if(v>1)return;const y=(this.mousePos[0]-n[0])/n[2],T=(u.canvas.height-this.mousePos[1]-n[1])/n[3],I=unProject(y,T,v,s),S=this.mm2frac(I,0,!0);S[0]<0||S[0]>1||S[1]<0||S[1]>1||S[2]<0||S[2]>1||(this.scene.crosshairPos=this.mm2frac(I,0,!0))}drawImage3D(n,s,u){if(this.volumes.length===0)return;const f=this.gl,m=this.calculateRayDirection(s,u),A=this.volumeObject3D;if(A){f.enable(f.BLEND),f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA),f.enable(f.CULL_FACE),f.cullFace(f.FRONT);let v=this.renderShader;if(this.uiData.mouseDepthPicker&&(v=this.pickingImageShader),v.use(this.gl),f.uniform1i(v.uniforms.backgroundMasksOverlays,this.backgroundMasksOverlays),this.gradientTextureAmount>0){f.activeTexture(TEXTURE6_GRADIENT),f.bindTexture(f.TEXTURE_3D,this.gradientTexture);const y=this.calculateModelMatrix(s,u),T=create$3();invert(T,y);const I=create$3();transpose$3(I,T),f.uniformMatrix4fv(v.uniforms.normMtx,!1,I)}this.drawBitmap&&this.drawBitmap.length>8?f.uniform2f(v.uniforms.renderDrawAmbientOcclusionXY,this.renderDrawAmbientOcclusion,this.drawOpacity):f.uniform2f(v.uniforms.renderDrawAmbientOcclusionXY,this.renderDrawAmbientOcclusion,0),f.uniformMatrix4fv(v.uniforms.mvpMtx,!1,n),f.uniformMatrix4fv(v.uniforms.matRAS,!1,this.back.matRAS),f.uniform3fv(v.uniforms.rayDir,m),this.gradientTextureAmount<0?f.uniform4fv(v.uniforms.clipPlane,[this.scene.crosshairPos[0],this.scene.crosshairPos[1],this.scene.crosshairPos[2],30]):f.uniform4fv(v.uniforms.clipPlane,this.scene.clipPlane),f.uniform1f(v.uniforms.drawOpacity,1),f.bindVertexArray(A.vao),f.drawElements(A.mode,A.indexCount,f.UNSIGNED_SHORT,0),f.bindVertexArray(this.unusedVAO)}}drawOrientationCube(n,s=0,u=0){if(!this.opts.isOrientCube)return;const f=.05*Math.min(n[2],n[3]);if(f<5)return;const m=this.gl;m.enable(m.CULL_FACE),m.cullFace(m.BACK),this.orientCubeShader.use(this.gl),m.bindVertexArray(this.orientCubeShaderVAO);const A=create$3(),v=create$3();ortho(v,0,m.canvas.width,0,m.canvas.height,-10*f,10*f);let y=0;n[1]===0&&(y=m.canvas.height-this.effectiveCanvasHeight()),translate(A,A,[1.8*f+n[0],y+1.8*f+n[1],0]),scale$4(A,A,[f,f,f]),rotateX(A,A,deg2rad(270-u)),rotateZ(A,A,deg2rad(-s));const T=create$3();multiply$2(T,v,A),m.uniformMatrix4fv(this.orientCubeShader.uniforms.u_matrix,!1,T),m.drawArrays(m.TRIANGLE_STRIP,0,168),m.bindVertexArray(this.unusedVAO),this.gl.disable(this.gl.CULL_FACE)}createOnLocationChange(n=NaN){const[s,u,f]=this.sceneExtentsMinMax(!0),m=Math.max(Math.max(f[0],f[1]),f[2]);function A(E){return Math.max(0,-Math.ceil(Math.log10(Math.abs(E))))}let v=A(m*.001);const y=this.frac2mm(this.scene.crosshairPos,0,!0);function T(E,e=0){return parseFloat(E.toFixed(e))}let I=T(y[0],v)+"×"+T(y[1],v)+"×"+T(y[2],v);if(this.volumes.length>0&&this.volumes[0].nFrame4D>0&&(I+="×"+T(this.volumes[0].frame4D)),this.volumes.length>0){let E=" = ";for(let M=0;M=0&&B=0&&(E+="+"),E+=T(V,v)),E+=" "}I+=E;const e=this.back.dimsRAS,F=e[1]*e[2]*e[3];if(this.drawBitmap&&this.drawBitmap.length===F){const M=this.frac2vox(this.scene.crosshairPos),L=M[0]+M[1]*e[1]+M[2]*e[1]*e[2];I+=" "+this.drawLut.labels[this.drawBitmap[L]]}}const S={mm:this.frac2mm(this.scene.crosshairPos,0,!0),axCorSag:n,vox:this.frac2vox(this.scene.crosshairPos),frac:this.scene.crosshairPos,xy:[this.mousePos[0],this.mousePos[1]],values:this.volumes.map(E=>{const e=this.frac2mm(this.scene.crosshairPos,0,!0),F=E.mm2vox(e),M=E.getValue(F[0],F[1],F[2],E.frame4D);return{name:E.name,value:M,id:E.id,mm:e,vox:F}}),string:I};this.onLocationChange(S)}addLabel(n,s,u){const f={textColor:this.opts.legendTextColor,textScale:1,textAlignment:"left",lineWidth:0,lineColor:this.opts.legendTextColor,lineTerminator:"none",bulletScale:0,bulletColor:this.opts.legendTextColor},m=s?{...f,...s}:{...f},A=new NVLabel3D(n,m,u);return this.document.labels.push(A),A}calculateScreenPoint(n,s,u){const f=create$1();return transformMat4(f,[...n,1],s),f[3]!==0&&(f[0]=(f[0]/f[3]+1)*.5*u[2],f[1]=(1-f[1]/f[3])*.5*u[3],f[2]/=f[3],f[0]+=u[0],f[1]+=u[1]),f}getLabelAtPoint(n){log$4.debug("screenPoint",n);const s=this.getLegendPanelHeight(),u=this.getLegendPanelWidth(),f=this.gl.canvas.width-u;let m=(this.canvas.height-s)/2;if(log$4.debug("panelrect",f,m,f+u,m+s),n[0]f+u||n[1]>m+s)return null;const v=this.opts.textHeight*Math.min(this.gl.canvas.height,this.gl.canvas.width)*1,y=this.getAllLabels();for(const T of y){const I=this.opts.textHeight*this.gl.canvas.height*T.style.textScale,S=this.textHeight(I,T.text);if(n[1]>=m&&n[1]<=m+S+v/2)return T;m+=S,m+=v/2}return null}drawLabelLine(n,s,u,f,m=!1){const A=Array.isArray(n.points)&&Array.isArray(n.points[0])?n.points:[n.points];for(const v of A){const y=this.calculateScreenPoint(v,u,f);m?this.drawDottedLine([...s,y[0],y[1]],n.style.lineWidth,n.style.lineColor):this.draw3DLine(s,[y[0],y[1],y[2]],n.style.lineWidth,n.style.lineColor)}}draw3DLabel(n,s,u,f,m=0,A,v=!1){const y=n.text,T=s[0],I=s[1],S=this.opts.textHeight*Math.min(this.gl.canvas.height,this.gl.canvas.width)*1,E=this.textHeight(n.style.textScale,y)*S;if(n.style.lineWidth>0&&Array.isArray(n.points)&&this.drawLabelLine(n,[T,I+E],u,f,v),n.style.bulletScale){const F=n.style.bulletScale*E,M=E-F,L=I+M/2+F/2,V=T+(m-F)/2;this.drawCircle([V,L,F,F],n.style.bulletColor)}let e=T;if(n.style.textAlignment!=="left"){const F=this.textWidth(n.style.textScale,n.text)*S;if(n.style.textAlignment==="right")e=T+A-S*1.5-F;else{const M=A-(m||S);e+=(M-F)/2}}else e+=m;this.drawText([e,I],y,n.style.textScale,n.style.textColor)}draw3DLabels(n,s,u=!1){const f=this.getAllLabels();if(!this.opts.showLegend||f.length===0)return;if(!this.canvas)throw new Error("canvas undefined");const m=this.gl;m.disable(m.CULL_FACE),m.viewport(0,0,this.canvas.width,this.canvas.height);const v=this.opts.textHeight*Math.min(this.gl.canvas.height,this.gl.canvas.width)*1,y=this.getBulletMarginWidth(),T=this.getLegendPanelHeight(),I=this.getLegendPanelWidth(),S=m.canvas.width-I;let E=(this.canvas.height-T)/2;this.drawRect([m.canvas.width-I,E,I-v,T],this.opts.legendBackgroundColor);const e=m.getParameter(m.BLEND),F=m.getParameter(m.DEPTH_FUNC);u||(m.disable(m.BLEND),m.depthFunc(m.GREATER));for(const M of f){this.draw3DLabel(M,[S,E],n,s,y,I,u);const L=this.opts.textHeight*this.gl.canvas.height*M.style.textScale,V=this.textHeight(L,M.text);E+=V,E+=v/2}u||(m.depthFunc(F),e&&m.enable(m.BLEND))}draw3D(n=[0,0,0,0],s=null,u=null,f=null,m=null,A=0){const v=m!==null;this.setPivot3D(),v||(m=this.scene.renderAzimuth,A=this.scene.renderElevation);const y=this.gl;s===null&&([s,u,f]=this.calculateMvpMatrix(null,n,m,A));let T=[...n];if(n[2]===0||n[3]===0?(n=[0,0,y.canvas.width,y.canvas.height],T=[...n],this.screenSlices.push({leftTopWidthHeight:n,axCorSag:4,sliceFrac:0,AxyzMxy:[],leftTopMM:[],fovMM:[isRadiological(u),0]})):(this.screenSlices.push({leftTopWidthHeight:n.slice(),axCorSag:4,sliceFrac:0,AxyzMxy:[],leftTopMM:[],fovMM:[isRadiological(u),0]}),n[1]=y.canvas.height-n[3]-n[1]),y.enable(y.DEPTH_TEST),y.depthFunc(y.ALWAYS),y.depthMask(!0),y.clearDepth(0),this.draw3DLabels(s,T,!1),y.viewport(n[0],n[1],n[2],n[3]),this.volumes.length>0&&(this.updateInterpolation(0,!0),this.updateInterpolation(1,!0),this.drawImage3D(s,m,A)),this.updateInterpolation(0),this.updateInterpolation(1),v||this.drawCrosshairs3D(!0,1,s),this.drawMesh3D(!0,1,s,u,f),this.uiData.mouseDepthPicker){this.depthPicker(n,s),this.createOnLocationChange(),this.draw3D(n,s,u,f,m,A);return}this.opts.meshXRay>0&&this.drawMesh3D(!1,this.opts.meshXRay,s,u,f),this.draw3DLabels(s,T,!1),y.viewport(n[0],n[1],n[2],n[3]),v||this.drawCrosshairs3D(!1,.15,s),y.viewport(0,0,y.canvas.width,y.canvas.height),this.drawOrientationCube(n,m,A);const I="azimuth: "+this.scene.renderAzimuth.toFixed(0)+" elevation: "+this.scene.renderElevation.toFixed(0);return this.readyForSync=!0,this.sync(),this.draw3DLabels(s,T,!0),I}drawMesh3D(n=!0,s=1,u,f,m){if(this.meshes.length<1)return;const A=this.gl;u||([u,f,m]=this.calculateMvpMatrix(this.volumeObject3D,void 0,this.scene.renderAzimuth,this.scene.renderElevation)),A.enable(A.DEPTH_TEST),A.blendFunc(A.SRC_ALPHA,A.ONE_MINUS_SRC_ALPHA),A.disable(A.BLEND),A.depthFunc(A.GREATER),A.disable(A.CULL_FACE),n?(A.disable(A.BLEND),A.depthFunc(A.GREATER)):(A.enable(A.BLEND),A.depthFunc(A.ALWAYS),A.enable(A.CULL_FACE)),A.cullFace(A.BACK);let v=this.meshShaders[0].shader,y=!1;for(let T=0;T=3&&this.meshes[T].fiberRadius>0||(A.bindVertexArray(this.meshes[T].vaoFiber),A.drawElements(A.LINE_STRIP,this.meshes[T].indexCount,A.UNSIGNED_INT,0),A.bindVertexArray(this.unusedVAO)));A.enable(A.BLEND),A.depthFunc(A.ALWAYS),this.readyForSync=!0}drawCrosshairs3D(n=!0,s=1,u=null,f=!1,m=!0){if(!this.opts.show3Dcrosshair&&!f||this.opts.crosshairWidth<=0&&f)return;const A=this.gl,v=this.frac2mm(this.scene.crosshairPos,0,m);if(this.crosshairs3D===null||this.crosshairs3D.mm[0]!==v[0]||this.crosshairs3D.mm[1]!==v[1]||this.crosshairs3D.mm[2]!==v[2]){this.crosshairs3D!==null&&(A.deleteBuffer(this.crosshairs3D.indexBuffer),A.deleteBuffer(this.crosshairs3D.vertexBuffer));const[I,S,E]=this.sceneExtentsMinMax(m);let e=1;if(this.volumes.length>0){if(!this.back)throw new Error("back undefined");e=.5*Math.min(Math.min(this.back.pixDims[1],this.back.pixDims[2]),this.back.pixDims[3])}else(E[0]<50||E[0]>1e3)&&(e=E[0]*.02);e*=this.opts.crosshairWidth,this.crosshairs3D=NiivueObject3D.generateCrosshairs(this.gl,1,v,I,S,e,20,this.opts.crosshairGap),this.crosshairs3D.mm=v}if(!this.surfaceShader)throw new Error("surfaceShader undefined");const y=this.surfaceShader;y.use(this.gl),u==null&&([u]=this.calculateMvpMatrix(this.crosshairs3D,void 0,this.scene.renderAzimuth,this.scene.renderElevation)),A.uniformMatrix4fv(y.uniforms.mvpMtx,!1,u),A.bindBuffer(A.ELEMENT_ARRAY_BUFFER,this.crosshairs3D.indexBuffer),A.enable(A.DEPTH_TEST);const T=[...this.opts.crosshairColor];n?(A.disable(A.BLEND),A.depthFunc(A.GREATER)):(A.enable(A.BLEND),A.blendFunc(A.SRC_ALPHA,A.ONE_MINUS_SRC_ALPHA),A.depthFunc(A.ALWAYS)),T[3]=s,A.uniform4fv(y.uniforms.surfaceColor,T),A.bindVertexArray(this.crosshairs3D.vao),A.drawElements(A.TRIANGLES,this.crosshairs3D.indexCount,A.UNSIGNED_INT,0),A.bindVertexArray(this.unusedVAO)}mm2frac(n,s=0,u=!1){if(this.volumes.length<1){const f=fromValues$2(.1,.5,.5),[m,A,v]=this.sceneExtentsMinMax();return f[0]=(n[0]-m[0])/v[0],f[1]=(n[1]-m[1])/v[1],f[2]=(n[2]-m[2])/v[2],isFinite(f)||(isFinite(f[0])||(f[0]=.5),isFinite(f[1])||(f[1]=.5),isFinite(f[2])||(f[2]=.5),this.meshes.length<1&&log$4.error("mm2frac() not finite: objects not (yet) loaded.")),f}return this.volumes[s].convertMM2Frac(n,u||this.opts.isSliceMM)}vox2frac(n,s=0){return this.volumes[s].convertVox2Frac(n)}frac2vox(n,s=0){return this.volumes.length<=s?[0,0,0]:this.volumes[s].convertFrac2Vox(n)}moveCrosshairInVox(n,s,u){const f=this.frac2vox(this.scene.crosshairPos);f[0]+=n,f[1]+=s,f[2]+=u,f[0]=clamp$1(f[0],0,this.volumes[0].dimsRAS[1]-1),f[1]=clamp$1(f[1],0,this.volumes[0].dimsRAS[2]-1),f[2]=clamp$1(f[2],0,this.volumes[0].dimsRAS[3]-1),this.scene.crosshairPos=this.vox2frac(f),this.createOnLocationChange(),this.drawScene()}frac2mm(n,s=0,u=!1){const f=fromValues$1(n[0],n[1],n[2],1);if(this.volumes.length>0)return this.volumes[s].convertFrac2MM(n,u||this.opts.isSliceMM);{const[m,A]=this.sceneExtentsMinMax(),v=(y,T,I)=>y*(1-I)+T*I;f[0]=v(m[0],A[0],n[0]),f[1]=v(m[1],A[1],n[1]),f[2]=v(m[2],A[2],n[2])}return f}screenXY2TextureFrac(n,s,u,f=!0){const m=fromValues$2(-1,-1,-1),A=this.screenSlices[u].axCorSag;if(A>2)return m;const v=this.screenSlices[u].leftTopWidthHeight.slice();let y=!1;v[2]<0&&(y=!0,v[0]+=v[2],v[2]=-v[2]);let T=(n-v[0])/v[2];y&&(T=1-T);const I=1-(s-v[1])/v[3];if(T<0||T>1||I<0||I>1||this.screenSlices[u].AxyzMxy.length<4)return m;let S=fromValues$2(0,0,0);S[0]=this.screenSlices[u].leftTopMM[0]+T*this.screenSlices[u].fovMM[0],S[1]=this.screenSlices[u].leftTopMM[1]+I*this.screenSlices[u].fovMM[1];const E=this.screenSlices[u].AxyzMxy;S[2]=E[2]+E[4]*(S[1]-E[1])-E[3]*(S[0]-E[0]),A===1&&(S=swizzleVec3(S,[0,2,1])),A===2&&(S=swizzleVec3(S,[2,0,1]));const e=this.mm2frac(S);return f&&(e[0]<0||e[0]>1||e[1]<0||e[1]>1||e[2]<0||e[2]>1)?m:e}canvasPos2frac(n){for(let s=0;s=0)return u}return[-1,-1,-1]}scaleSlice(n,s,u=0,f=0){const m=this.effectiveCanvasWidth()-u,A=this.effectiveCanvasHeight()-f;let v=m/n;s*v>A&&(v=A/s);const y=n*v,T=s*v;return[(m-y)*.5,(A-T)*.5,y,T,v]}drawThumbnail(){if(!this.bmpShader)throw new Error("bmpShader undefined");this.bmpShader.use(this.gl),this.gl.uniform2f(this.bmpShader.uniforms.canvasWidthHeight,this.gl.canvas.width,this.gl.canvas.height);let n=this.gl.canvas.height,s=this.gl.canvas.height*this.bmpTextureWH;s>this.gl.canvas.width&&(n=this.gl.canvas.width/this.bmpTextureWH,s=this.gl.canvas.width),this.gl.uniform4f(this.bmpShader.uniforms.leftTopWidthHeight,0,0,s,n),this.gl.bindVertexArray(this.genericVAO),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.gl.bindVertexArray(this.unusedVAO)}drawLine(n,s=1,u=[1,0,0,-1]){if(this.gl.bindVertexArray(this.genericVAO),!this.lineShader)throw new Error("lineShader undefined");this.lineShader.use(this.gl),u[3]<0&&(u=this.opts.crosshairColor),this.gl.uniform4fv(this.lineShader.uniforms.lineColor,u),this.gl.uniform2fv(this.lineShader.uniforms.canvasWidthHeight,[this.gl.canvas.width,this.gl.canvas.height]),this.gl.uniform1f(this.lineShader.uniforms.thickness,s),this.gl.uniform4fv(this.lineShader.uniforms.startXYendXY,n),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.gl.bindVertexArray(this.unusedVAO)}draw3DLine(n,s,u=1,f=[1,0,0,-1]){if(this.gl.bindVertexArray(this.genericVAO),!this.line3DShader)throw new Error("line3DShader undefined");this.line3DShader.use(this.gl),f[3]<0&&(f=this.opts.crosshairColor),this.gl.uniform4fv(this.line3DShader.uniforms.lineColor,f),this.gl.uniform2fv(this.line3DShader.uniforms.canvasWidthHeight,[this.gl.canvas.width,this.gl.canvas.height]),this.gl.uniform1f(this.line3DShader.uniforms.thickness,u),this.gl.uniform2fv(this.line3DShader.uniforms.startXY,n),this.gl.uniform3fv(this.line3DShader.uniforms.endXYZ,s),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.gl.bindVertexArray(this.unusedVAO)}drawDottedLine(n,s=1,u=[1,0,0,-1]){if(this.gl.bindVertexArray(this.genericVAO),!this.lineShader)throw new Error("lineShader undefined");this.lineShader.use(this.gl);const f=u[3]<0?[...this.opts.crosshairColor]:[...u];f[3]=.3;const m=fromValues(n[2]-n[0],n[3]-n[1]),A=length(m);normalize(m,m);const y=this.opts.textHeight*Math.min(this.gl.canvas.height,this.gl.canvas.width)*1;scale$1(m,m,y/2);const T=length(m);let I=Math.floor(A/T);A%T&&I++;const S=[n[0],n[1]];this.gl.uniform4fv(this.lineShader.uniforms.lineColor,f),this.gl.uniform2fv(this.lineShader.uniforms.canvasWidthHeight,[this.gl.canvas.width,this.gl.canvas.height]),this.gl.uniform1f(this.lineShader.uniforms.thickness,s);for(let E=0;E0&&s===0){const e=v,F=1;for(let M=0;M0&&s===1){const e=v,F=2;for(let M=0;M0&&s===2){const e=v,F=2;for(let M=0;M0&&s===0){const e=v,F=0;for(let M=0;M0&&s===1){const e=v,F=0;for(let M=0;M0&&s===2){const e=v,F=1;for(let M=0;M0){const T=A.leftTopWidthHeight.slice();let I=2;s===0&&(I=1);const S=this.frac2mm([.5,.5,.5]);for(let E=0;E0){const T=A.leftTopWidthHeight.slice(),I=A.fovMM[0]<0;let S=0;s===2&&(S=1);const E=this.frac2mm([.5,.5,.5]);for(let e=0;e"u"){if(this.meshes.length>0){this.screenSlices=[],this.opts.sliceType=4,this.draw3D(),this.opts.isColorbar&&this.drawColorbar();return}this.drawLoadingText(this.loadingText);return}if(this.back===null)return;if(this.uiData.isDragging&&this.scene.clipPlaneDepthAziElev[0]<1.8&&this.inRenderTile(this.uiData.dragStart[0],this.uiData.dragStart[1])>=0){const m=this.uiData.dragStart[0]-this.uiData.dragEnd[0],A=this.uiData.dragStart[1]-this.uiData.dragEnd[1],v=this.uiData.dragClipPlaneStartDepthAziElev.slice();if(v[1]-=m,v[1]=v[1]%360,v[2]+=A,v[1]!==this.scene.clipPlaneDepthAziElev[1]||v[2]!==this.scene.clipPlaneDepthAziElev[2])return this.scene.clipPlaneDepthAziElev=v,this.setClipPlane(this.scene.clipPlaneDepthAziElev)}if(this.sliceMosaicString.length<1&&this.opts.sliceType===4){this.opts.isColorbar&&this.reserveColorbarPanel(),this.screenSlices=[],this.draw3D(),this.opts.isColorbar&&this.drawColorbar();return}this.opts.isColorbar&&this.reserveColorbarPanel();const s=this.getMaxVols(),u=this.opts.sliceType===3&&s>1&&this.graph.autoSizeMultiplanar&&this.graph.opacity>0;if(this.sliceMosaicString.length>0)this.drawMosaic(this.sliceMosaicString);else if(this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.screenSlices=[],this.opts.sliceType===0)this.draw2D([0,0,0,0],0);else if(this.opts.sliceType===1)this.draw2D([0,0,0,0],1);else if(this.opts.sliceType===2)this.draw2D([0,0,0,0],2);else{const m=isFinite(this.drawPenLocation[0])&&this.opts.drawingEnabled,{volScale:A}=this.sliceScale();typeof this.opts.multiplanarPadPixels!="number"&&log$4.debug("multiplanarPadPixels must be numeric");const v=parseFloat(`${this.opts.multiplanarPadPixels}`),y=this.scaleSlice(A[0]+A[1],A[1]+A[2],v*1,v*1),T=Math.max(Math.max(A[1],A[2]),A[0]),I=this.scaleSlice(A[0]+A[0]+A[1],Math.max(A[1],A[2]),v*2),S=this.scaleSlice(A[0]+A[0]+A[1]+T,Math.max(A[1],A[2]),v*3),E=this.scaleSlice(T,A[1]+A[2]+A[2],0,v*2),e=this.scaleSlice(T,A[1]+A[2]+A[2]+T,0,v*3);let F=!m&&(s<2||!u),M=!1,L=!1,V=!1;if(this.opts.multiplanarLayout===1?M=!0:this.opts.multiplanarLayout===2?L=!0:this.opts.multiplanarLayout===3?V=!0:E[4]>I[4]&&E[4]>y[4]?M=!0:I[4]>y[4]?V=!0:L=!0,M){let B=E;this.opts.multiplanarForceRender||e[4]>=E[4]?B=e:F=!1;const z=A[0]*B[4],b=A[1]*B[4],W=A[2]*B[4],q=T*B[4];this.draw2D([B[0],B[1],z,b],0),this.draw2D([B[0],B[1]+b+v,z,W],1),this.draw2D([B[0],B[1]+b+v+W+v,b,W],2),F&&this.draw3D([B[0],B[1]+b+W+W+v*3,q,q])}else if(V){let B=I;this.opts.multiplanarForceRender||S[4]>=I[4]?B=S:F=!1;const z=A[0]*B[4],b=A[1]*B[4],W=A[2]*B[4];this.draw2D([B[0],B[1],z,b],0),this.draw2D([B[0]+z+v,B[1],z,W],1),this.draw2D([B[0]+z+z+v*2,B[1],b,W],2),F&&this.draw3D([B[0]+z+z+b+v*3,B[1],B[3],B[3]])}else if(L){const B=y,z=A[0]*B[4],b=A[1]*B[4],W=A[2]*B[4];this.draw2D([B[0],B[1]+W+v,z,b],0),this.draw2D([B[0],B[1],z,W],1),this.draw2D([B[0]+z+v,B[1],b,W],2),F&&this.draw3D([B[0]+z+v,B[1]+W+v,b,b])}}if(this.opts.isRuler&&this.drawRuler(),this.opts.isColorbar&&this.drawColorbar(),u&&this.drawGraph(),this.uiData.isDragging){if(this.uiData.mouseButtonCenterDown){this.dragForCenterButton([this.uiData.dragStart[0],this.uiData.dragStart[1],this.uiData.dragEnd[0],this.uiData.dragEnd[1]]);return}if(this.opts.dragMode===4){this.dragForSlicer3D([this.uiData.dragStart[0],this.uiData.dragStart[1],this.uiData.dragEnd[0],this.uiData.dragEnd[1]]);return}if(this.opts.dragMode===3){this.dragForPanZoom([this.uiData.dragStart[0],this.uiData.dragStart[1],this.uiData.dragEnd[0],this.uiData.dragEnd[1]]);return}if(this.inRenderTile(this.uiData.dragStart[0],this.uiData.dragStart[1])>=0)return;if(this.opts.dragMode===2){this.drawMeasurementTool([this.uiData.dragStart[0],this.uiData.dragStart[1],this.uiData.dragEnd[0],this.uiData.dragEnd[1]]);return}const m=Math.abs(this.uiData.dragStart[0]-this.uiData.dragEnd[0]),A=Math.abs(this.uiData.dragStart[1]-this.uiData.dragEnd[1]);this.drawSelectionBox([Math.min(this.uiData.dragStart[0],this.uiData.dragEnd[0]),Math.min(this.uiData.dragStart[1],this.uiData.dragEnd[1]),m,A])}const f=this.frac2mm([this.scene.crosshairPos[0],this.scene.crosshairPos[1],this.scene.crosshairPos[2]]);return n=f[0].toFixed(2)+"×"+f[1].toFixed(2)+"×"+f[2].toFixed(2),this.readyForSync=!0,this.sync(),n}drawScene(){if(this.isBusy){this.needsRefresh=!0;return}this.isBusy=!1,this.needsRefresh=!1;let n=this.drawSceneCore();return this._gl!==null&&this.gl.finish(),this.needsRefresh&&(n=this.drawScene()),n}get gl(){if(!this._gl)throw new Error("unable to get WebGL context. Maybe the browser doesn't support WebGL2.");return this._gl}set gl(n){this._gl=n}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9374,7 +9374,7 @@ Ooh no!!`);break}m[y]=T,v=Math.min(v,T)}for(let y=0;yminimum$2(6,relu$2(n)))}}Relu6.className="relu6";registerClass(Relu6);class Linear extends Activation$1{apply(n){return n}}Linear.className="linear";registerClass(Linear);class Sigmoid extends Activation$1{apply(n){return sigmoid$2(n)}}Sigmoid.className="sigmoid";registerClass(Sigmoid);class HardSigmoid extends Activation$1{apply(n){return hardSigmoid(n)}}HardSigmoid.className="hardSigmoid";registerClass(HardSigmoid);class Softplus extends Activation$1{apply(n){return softplus$2(n)}}Softplus.className="softplus";registerClass(Softplus);class Softsign extends Activation$1{apply(n){return softsign(n)}}Softsign.className="softsign";registerClass(Softsign);class Tanh extends Activation$1{apply(n){return tanh$2(n)}}Tanh.className="tanh";registerClass(Tanh);let Softmax$1=class extends Activation$1{apply(n,s=-1){return softmax$2(n,s)}};Softmax$1.className="softmax";registerClass(Softmax$1);class LogSoftmax extends Activation$1{apply(n,s=-1){return logSoftmax(n,s)}}LogSoftmax.className="logSoftmax";registerClass(LogSoftmax);class Swish extends Activation$1{apply(n,s=1){return tidy(()=>mul(sigmoid$2(mul(n,s)),n))}}Swish.className="swish";registerClass(Swish);class Mish extends Activation$1{apply(n){return tidy(()=>mul(n,tanh$2(softplus$2(n))))}}Mish.className="mish";registerClass(Mish);function serializeActivation(a){return a.getClassName()}function deserializeActivation(a,n={}){return deserializeKerasObject(a,SerializationMap.getMap().classNameMap,n,"activation")}function getActivation(a){if(a==null){const n={};return n.className="linear",n.config={},deserializeActivation(n)}if(typeof a=="string"){const n={};return n.className=a,n.config={},deserializeActivation(n)}else return a instanceof Activation$1?a:deserializeActivation(a)}/** + */let Activation$1=class extends Serializable{getConfig(){return{}}};class Elu extends Activation$1{apply(n,s=1){return elu$2(n,s)}}Elu.className="elu";registerClass(Elu);class Selu extends Activation$1{apply(n){return selu$2(n)}}Selu.className="selu";registerClass(Selu);class Relu extends Activation$1{apply(n){return relu$2(n)}}Relu.className="relu";registerClass(Relu);class Relu6 extends Activation$1{apply(n){return tidy(()=>minimum$2(6,relu$2(n)))}}Relu6.className="relu6";registerClass(Relu6);class Linear extends Activation$1{apply(n){return n}}Linear.className="linear";registerClass(Linear);class Sigmoid extends Activation$1{apply(n){return sigmoid$2(n)}}Sigmoid.className="sigmoid";registerClass(Sigmoid);class HardSigmoid extends Activation$1{apply(n){return hardSigmoid(n)}}HardSigmoid.className="hardSigmoid";registerClass(HardSigmoid);class Softplus extends Activation$1{apply(n){return softplus$2(n)}}Softplus.className="softplus";registerClass(Softplus);class Softsign extends Activation$1{apply(n){return softsign(n)}}Softsign.className="softsign";registerClass(Softsign);class Tanh extends Activation$1{apply(n){return tanh$2(n)}}Tanh.className="tanh";registerClass(Tanh);let Softmax$1=class extends Activation$1{apply(n,s=-1){return softmax$2(n,s)}};Softmax$1.className="softmax";registerClass(Softmax$1);class LogSoftmax extends Activation$1{apply(n,s=-1){return logSoftmax(n,s)}}LogSoftmax.className="logSoftmax";registerClass(LogSoftmax);class Gelu extends Activation$1{apply(n){return tidy(()=>tidy(()=>{const s=Math.sqrt(2),u=mul(.5,add$1(1,erf$2(div$1(n,s))));return mul(n,u)}))}}Gelu.className="gelu";registerClass(Gelu);class GeluNew extends Activation$1{apply(n){return tidy(()=>mul(.5,mul(n,add$1(1,tanh$2(mul(sqrt$2(div$1(2,Math.PI)),add$1(n,mul(.044715,pow$2(n,3)))))))))}}GeluNew.className="gelu_new";registerClass(GeluNew);class Mish extends Activation$1{apply(n){return tidy(()=>mul(n,tanh$2(softplus$2(n))))}}Mish.className="mish";registerClass(Mish);class Swish extends Activation$1{apply(n,s=1){return tidy(()=>mul(sigmoid$2(mul(n,s)),n))}}Swish.className="swish";registerClass(Swish);function serializeActivation(a){return a.getClassName()}function deserializeActivation(a,n={}){return deserializeKerasObject(a,SerializationMap.getMap().classNameMap,n,"activation")}function getActivation(a){if(a==null){const n={};return n.className="linear",n.config={},deserializeActivation(n)}if(typeof a=="string"){const n={};return n.className=a,n.config={},deserializeActivation(n)}else return a instanceof Activation$1?a:deserializeActivation(a)}/** * @license * Copyright 2018 Google LLC * @@ -9462,7 +9462,7 @@ Ooh no!!`);break}m[y]=T,v=Math.min(v,T)}for(let y=0;y(checkDataFormat(n),n==="channelsFirst"?transpose$2(a,[0,2,3,1]):a))}function preprocessConv3DInput(a,n){return tidy(()=>(checkDataFormat(n),n==="channelsFirst"?transpose$2(a,[0,2,3,4,1]):a))}function conv1dWithBias(a,n,s,u=1,f="valid",m,A=1){return tidy(()=>{if(m==null&&(m=imageDataFormat()),checkDataFormat(m),a.shape.length!==3)throw new ValueError(`The input of a conv1dWithBias operation should be 3, but is ${a.shape.length} instead.`);if(n.shape.length!==3)throw new ValueError(`The kernel for a conv1dWithBias operation should be 3, but is ${n.shape.length} instead`);if(s!=null&&s.shape.length!==1)throw new ValueError(`The bias for a conv1dWithBias operation should be 1, but is ${n.shape.length} instead`);if(m==="channelsFirst"&&(a=transpose$2(a,[0,2,1])),f==="causal")throw new NotImplementedError("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let v=conv1d(a,n,u,f==="same"?"same":"valid","NWC",A);return s!=null&&(v=biasAdd(v,s)),v})}function conv2dWithBiasActivation(a,n,s,u=[1,1],f="valid",m,A,v=null){return tidy(()=>{if(m==null&&(m=imageDataFormat()),checkDataFormat(m),a.rank!==3&&a.rank!==4)throw new ValueError(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${a.rank}.`);if(n.rank!==3&&n.rank!==4)throw new ValueError(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${a.rank}.`);let y=preprocessConv2DInput(a,m);if(f==="causal")throw new NotImplementedError("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return y=conv2d$1({x:y,filter:n,strides:u,pad:f==="same"?"same":"valid",dilations:A,dataFormat:"NHWC",bias:s,activation:v}),m==="channelsFirst"&&(y=transpose$2(y,[0,3,1,2])),y})}function conv3dWithBias(a,n,s,u=[1,1,1],f="valid",m,A){return tidy(()=>{if(m==null&&(m=imageDataFormat()),checkDataFormat(m),a.rank!==4&&a.rank!==5)throw new ValueError(`conv3dWithBias expects input to be of rank 4 or 5, but received ${a.rank}.`);if(n.rank!==4&&n.rank!==5)throw new ValueError(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${a.rank}.`);let v=preprocessConv3DInput(a,m);if(f==="causal")throw new NotImplementedError("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return v=conv3d(v,n,u,f==="same"?"same":"valid","NDHWC",A),s!=null&&(v=biasAdd(v,s)),m==="channelsFirst"&&(v=transpose$2(v,[0,4,1,2,3])),v})}class BaseConv extends Layer{constructor(n,s){if(super(s),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",BaseConv.verifyArgs(s),this.rank=n,assertPositiveInteger(this.rank,"rank"),this.rank!==1&&this.rank!==2&&this.rank!==3)throw new NotImplementedError(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=normalizeArray(s.kernelSize,n,"kernelSize"),this.strides=normalizeArray(s.strides==null?1:s.strides,n,"strides"),this.padding=s.padding==null?"valid":s.padding,checkPaddingMode(this.padding),this.dataFormat=s.dataFormat==null?"channelsLast":s.dataFormat,checkDataFormat(this.dataFormat),this.activation=getActivation(s.activation),this.useBias=s.useBias==null?!0:s.useBias,this.biasInitializer=getInitializer(s.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=getConstraint(s.biasConstraint),this.biasRegularizer=getRegularizer(s.biasRegularizer),this.activityRegularizer=getRegularizer(s.activityRegularizer),this.dilationRate=normalizeArray(s.dilationRate==null?1:s.dilationRate,n,"dilationRate"),this.rank===1&&Array.isArray(this.dilationRate)&&this.dilationRate.length!==1)throw new ValueError(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(this.rank===2){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==2)throw new ValueError(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(this.rank===3){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==3)throw new ValueError(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}}static verifyArgs(n){if(assert("kernelSize"in n,"required key 'kernelSize' not in config"),typeof n.kernelSize!="number"&&!checkArrayTypeAndLength(n.kernelSize,"number",1,3))throw new ValueError(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(n.kernelSize)}.`)}getConfig(){const n={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:serializeActivation(this.activation),useBias:this.useBias,biasInitializer:serializeInitializer(this.biasInitializer),biasRegularizer:serializeRegularizer(this.biasRegularizer),activityRegularizer:serializeRegularizer(this.activityRegularizer),biasConstraint:serializeConstraint(this.biasConstraint)},s=super.getConfig();return Object.assign(n,s),n}}class Conv extends BaseConv{constructor(n,s){super(n,s),this.kernel=null,Conv.verifyArgs(s),this.filters=s.filters,assertPositiveInteger(this.filters,"filters"),this.kernelInitializer=getInitializer(s.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=getConstraint(s.kernelConstraint),this.kernelRegularizer=getRegularizer(s.kernelRegularizer)}build(n){n=getExactlyOneShape(n);const s=this.dataFormat==="channelsFirst"?1:n.length-1;if(n[s]==null)throw new ValueError(`The channel dimension of the input should be defined. Found ${n[s]}`);const u=n[s],f=this.kernelSize.concat([u,this.filters]);this.kernel=this.addWeight("kernel",f,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[s]:u}}],this.built=!0}call(n,s){return tidy(()=>{n=getExactlyOneTensor(n);let u;const f=this.bias==null?null:this.bias.read(),m=mapActivationToFusedKernel(this.activation.getClassName());if(m!=null&&this.rank===2)u=conv2dWithBiasActivation(n,this.kernel.read(),f,this.strides,this.padding,this.dataFormat,this.dilationRate,m);else{if(this.rank===1)u=conv1dWithBias(n,this.kernel.read(),f,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(this.rank===2)u=conv2dWithBiasActivation(n,this.kernel.read(),f,this.strides,this.padding,this.dataFormat,this.dilationRate);else if(this.rank===3)u=conv3dWithBias(n,this.kernel.read(),f,this.strides,this.padding,this.dataFormat,this.dilationRate);else throw new NotImplementedError("convolutions greater than 3D are not implemented yet.");this.activation!=null&&(u=this.activation.apply(u))}return u})}computeOutputShape(n){n=getExactlyOneShape(n);const s=[],u=this.dataFormat==="channelsLast"?n.slice(1,n.length-1):n.slice(2);for(let m=0;m 0 but got ${JSON.stringify(n.filters)}`)}}class Conv2D extends Conv{constructor(n){super(2,n),Conv2D.verifyArgs(n)}getConfig(){const n=super.getConfig();return delete n.rank,n}static verifyArgs(n){if(typeof n.kernelSize!="number"&&!checkArrayTypeAndLength(n.kernelSize,"number",1,2))throw new ValueError(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(n.kernelSize)}.`)}}Conv2D.className="Conv2D";registerClass(Conv2D);class Conv3D extends Conv{constructor(n){super(3,n),Conv3D.verifyArgs(n)}getConfig(){const n=super.getConfig();return delete n.rank,n}static verifyArgs(n){if(typeof n.kernelSize!="number"&&!(Array.isArray(n.kernelSize)&&(n.kernelSize.length===1||n.kernelSize.length===3)))throw new ValueError(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(n.kernelSize)}.`)}}Conv3D.className="Conv3D";registerClass(Conv3D);class Conv2DTranspose extends Conv2D{constructor(n){if(super(n),this.inputSpec=[new InputSpec({ndim:4})],this.padding!=="same"&&this.padding!=="valid")throw new ValueError(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(n){if(n=getExactlyOneShape(n),n.length!==4)throw new ValueError("Input should have rank 4; Received input shape: "+JSON.stringify(n));const s=this.dataFormat==="channelsFirst"?1:n.length-1;if(n[s]==null)throw new ValueError("The channel dimension of the inputs should be defined. Found `None`.");const u=n[s],f=this.kernelSize.concat([this.filters,u]);this.kernel=this.addWeight("kernel",f,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new InputSpec({ndim:4,axes:{[s]:u}})],this.built=!0}call(n,s){return tidy(()=>{let u=getExactlyOneTensor(n);if(u.shape.length!==4)throw new ValueError(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${u.shape.length}`);const f=u.shape,m=f[0];let A,v;this.dataFormat==="channelsFirst"?(A=2,v=3):(A=1,v=2);const y=f[A],T=f[v],I=this.kernelSize[0],S=this.kernelSize[1],E=this.strides[0],e=this.strides[1],F=deconvLength(y,E,I,this.padding),M=deconvLength(T,e,S,this.padding),L=[m,F,M,this.filters];this.dataFormat!=="channelsLast"&&(u=transpose$2(u,[0,2,3,1]));let V=conv2dTranspose(u,this.kernel.read(),L,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(V=transpose$2(V,[0,3,1,2])),this.bias!=null&&(V=biasAdd(V,this.bias.read(),this.dataFormat)),this.activation!=null&&(V=this.activation.apply(V)),V})}computeOutputShape(n){n=getExactlyOneShape(n);const s=n.slice();let u,f,m;this.dataFormat==="channelsFirst"?(u=1,f=2,m=3):(u=3,f=1,m=2);const A=this.kernelSize[0],v=this.kernelSize[1],y=this.strides[0],T=this.strides[1];return s[u]=this.filters,s[f]=deconvLength(s[f],y,A,this.padding),s[m]=deconvLength(s[m],T,v,this.padding),s}getConfig(){const n=super.getConfig();return delete n.dilationRate,n}}Conv2DTranspose.className="Conv2DTranspose";registerClass(Conv2DTranspose);class Conv3DTranspose extends Conv3D{constructor(n){if(super(n),this.inputSpec=[new InputSpec({ndim:5})],this.padding!=="same"&&this.padding!=="valid")throw new ValueError(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(n){if(n=getExactlyOneShape(n),n.length!==5)throw new ValueError("Input should have rank 5; Received input shape: "+JSON.stringify(n));const s=this.dataFormat==="channelsFirst"?1:n.length-1;if(n[s]==null)throw new ValueError("The channel dimension of the inputs should be defined. Found `None`.");const u=n[s],f=this.kernelSize.concat([this.filters,u]);this.kernel=this.addWeight("kernel",f,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new InputSpec({ndim:5,axes:{[s]:u}})],this.built=!0}call(n,s){return tidy(()=>{let u=getExactlyOneTensor(n);if(u.shape.length!==5)throw new ValueError(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${u.shape.length}`);const f=u.shape,m=f[0];let A,v,y;this.dataFormat==="channelsFirst"?(y=2,A=3,v=4):(y=1,A=2,v=3);const T=f[y],I=f[A],S=f[v],E=this.kernelSize[0],e=this.kernelSize[1],F=this.kernelSize[2],M=this.strides[0],L=this.strides[1],V=this.strides[2],B=deconvLength(T,M,E,this.padding),z=deconvLength(I,L,e,this.padding),b=deconvLength(S,V,F,this.padding),W=[m,B,z,b,this.filters];this.dataFormat!=="channelsLast"&&(u=transpose$2(u,[0,2,3,4,1]));let q=conv3dTranspose(u,this.kernel.read(),W,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(q=transpose$2(q,[0,4,1,2,3])),this.bias!==null&&(q=biasAdd(q,this.bias.read(),this.dataFormat)),this.activation!==null&&(q=this.activation.apply(q)),q})}computeOutputShape(n){n=getExactlyOneShape(n);const s=n.slice();let u,f,m,A;this.dataFormat==="channelsFirst"?(u=1,f=2,m=3,A=4):(u=4,f=1,m=2,A=3);const v=this.kernelSize[0],y=this.kernelSize[1],T=this.kernelSize[2],I=this.strides[0],S=this.strides[1],E=this.strides[2];return s[u]=this.filters,s[f]=deconvLength(s[f],I,v,this.padding),s[m]=deconvLength(s[m],S,y,this.padding),s[A]=deconvLength(s[A],E,T,this.padding),s}getConfig(){const n=super.getConfig();return delete n.dilationRate,n}}Conv3DTranspose.className="Conv3DTranspose";registerClass(Conv3DTranspose);class SeparableConv extends Conv{constructor(n,s){if(super(n,s),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,s.filters==null)throw new ValueError("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(s.kernelInitializer!=null||s.kernelRegularizer!=null||s.kernelConstraint!=null)throw new ValueError("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(s.padding!=null&&s.padding!=="same"&&s.padding!=="valid")throw new ValueError(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(s.padding)}`);this.depthMultiplier=s.depthMultiplier==null?1:s.depthMultiplier,this.depthwiseInitializer=getInitializer(s.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=getRegularizer(s.depthwiseRegularizer),this.depthwiseConstraint=getConstraint(s.depthwiseConstraint),this.pointwiseInitializer=getInitializer(s.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=getRegularizer(s.pointwiseRegularizer),this.pointwiseConstraint=getConstraint(s.pointwiseConstraint)}build(n){if(n=getExactlyOneShape(n),n.length{n=getExactlyOneTensor(n);let u;if(this.rank===1)throw new NotImplementedError("1D separable convolution is not implemented yet.");return this.rank===2&&(this.dataFormat==="channelsFirst"&&(n=transpose$2(n,[0,2,3,1])),u=separableConv2d(n,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(u=biasAdd(u,this.bias.read(),this.dataFormat)),this.activation!=null&&(u=this.activation.apply(u)),this.dataFormat==="channelsFirst"&&(u=transpose$2(u,[0,3,1,2])),u})}getConfig(){const n=super.getConfig();return delete n.rank,delete n.kernelInitializer,delete n.kernelRegularizer,delete n.kernelConstraint,n.depthwiseInitializer=serializeInitializer(this.depthwiseInitializer),n.pointwiseInitializer=serializeInitializer(this.pointwiseInitializer),n.depthwiseRegularizer=serializeRegularizer(this.depthwiseRegularizer),n.pointwiseRegularizer=serializeRegularizer(this.pointwiseRegularizer),n.depthwiseConstraint=serializeConstraint(this.depthwiseConstraint),n.pointwiseConstraint=serializeConstraint(this.pointwiseConstraint),n}}SeparableConv.className="SeparableConv";class SeparableConv2D extends SeparableConv{constructor(n){super(2,n)}}SeparableConv2D.className="SeparableConv2D";registerClass(SeparableConv2D);class Conv1D extends Conv{constructor(n){super(1,n),Conv1D.verifyArgs(n),this.inputSpec=[{ndim:3}]}getConfig(){const n=super.getConfig();return delete n.rank,delete n.dataFormat,n}static verifyArgs(n){if(typeof n.kernelSize!="number"&&!checkArrayTypeAndLength(n.kernelSize,"number",1,1))throw new ValueError(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(n.kernelSize)}.`)}}Conv1D.className="Conv1D";registerClass(Conv1D);class Cropping2D extends Layer{constructor(n){super(n),typeof n.cropping=="number"?this.cropping=[[n.cropping,n.cropping],[n.cropping,n.cropping]]:typeof n.cropping[0]=="number"?this.cropping=[[n.cropping[0],n.cropping[0]],[n.cropping[1],n.cropping[1]]]:this.cropping=n.cropping,this.dataFormat=n.dataFormat===void 0?"channelsLast":n.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(n){return this.dataFormat==="channelsFirst"?[n[0],n[1],n[2]-this.cropping[0][0]-this.cropping[0][1],n[3]-this.cropping[1][0]-this.cropping[1][1]]:[n[0],n[1]-this.cropping[0][0]-this.cropping[0][1],n[2]-this.cropping[1][0]-this.cropping[1][1],n[3]]}call(n,s){return tidy(()=>{if(n=getExactlyOneTensor(n),this.dataFormat==="channelsLast"){const u=sliceAlongAxis(n,this.cropping[0][0],n.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return sliceAlongAxis(u,this.cropping[1][0],n.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}else{const u=sliceAlongAxis(n,this.cropping[0][0],n.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return sliceAlongAxis(u,this.cropping[1][0],n.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}})}getConfig(){const n={cropping:this.cropping,dataFormat:this.dataFormat},s=super.getConfig();return Object.assign(n,s),n}}Cropping2D.className="Cropping2D";registerClass(Cropping2D);class UpSampling2D extends Layer{constructor(n){super(n),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=n.size==null?this.DEFAULT_SIZE:n.size,this.dataFormat=n.dataFormat==null?"channelsLast":n.dataFormat,checkDataFormat(this.dataFormat),this.interpolation=n.interpolation==null?"nearest":n.interpolation,checkInterpolationFormat(this.interpolation)}computeOutputShape(n){if(this.dataFormat==="channelsFirst"){const s=n[2]==null?null:this.size[0]*n[2],u=n[3]==null?null:this.size[1]*n[3];return[n[0],n[1],s,u]}else{const s=n[1]==null?null:this.size[0]*n[1],u=n[2]==null?null:this.size[1]*n[2];return[n[0],s,u,n[3]]}}call(n,s){return tidy(()=>{let u=getExactlyOneTensor(n);const f=u.shape;if(this.dataFormat==="channelsFirst"){u=transpose$2(u,[0,2,3,1]);const m=this.size[0]*f[2],A=this.size[1]*f[3],v=this.interpolation==="nearest"?image.resizeNearestNeighbor(u,[m,A]):image.resizeBilinear(u,[m,A]);return transpose$2(v,[0,3,1,2])}else{const m=this.size[0]*f[1],A=this.size[1]*f[2];return this.interpolation==="nearest"?image.resizeNearestNeighbor(u,[m,A]):image.resizeBilinear(u,[m,A])}})}getConfig(){const n={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},s=super.getConfig();return Object.assign(n,s),n}}UpSampling2D.className="UpSampling2D";registerClass(UpSampling2D);/** + */function preprocessConv2DInput(a,n){return tidy(()=>(checkDataFormat(n),n==="channelsFirst"?transpose$2(a,[0,2,3,1]):a))}function preprocessConv3DInput(a,n){return tidy(()=>(checkDataFormat(n),n==="channelsFirst"?transpose$2(a,[0,2,3,4,1]):a))}function conv1dWithBias(a,n,s,u=1,f="valid",m,A=1){return tidy(()=>{if(m==null&&(m=imageDataFormat()),checkDataFormat(m),a.shape.length!==3)throw new ValueError(`The input of a conv1dWithBias operation should be 3, but is ${a.shape.length} instead.`);if(n.shape.length!==3)throw new ValueError(`The kernel for a conv1dWithBias operation should be 3, but is ${n.shape.length} instead`);if(s!=null&&s.shape.length!==1)throw new ValueError(`The bias for a conv1dWithBias operation should be 1, but is ${s.shape.length} instead`);if(m==="channelsFirst"&&(a=transpose$2(a,[0,2,1])),f==="causal")throw new NotImplementedError("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let v=conv1d(a,n,u,f==="same"?"same":"valid","NWC",A);return s!=null&&(v=biasAdd(v,s)),v})}function conv2dWithBiasActivation(a,n,s,u=[1,1],f="valid",m,A,v=null){return tidy(()=>{if(m==null&&(m=imageDataFormat()),checkDataFormat(m),a.rank!==3&&a.rank!==4)throw new ValueError(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${a.rank}.`);if(n.rank!==3&&n.rank!==4)throw new ValueError(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${a.rank}.`);let y=preprocessConv2DInput(a,m);if(f==="causal")throw new NotImplementedError("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return y=conv2d$1({x:y,filter:n,strides:u,pad:f==="same"?"same":"valid",dilations:A,dataFormat:"NHWC",bias:s,activation:v}),m==="channelsFirst"&&(y=transpose$2(y,[0,3,1,2])),y})}function conv3dWithBias(a,n,s,u=[1,1,1],f="valid",m,A){return tidy(()=>{if(m==null&&(m=imageDataFormat()),checkDataFormat(m),a.rank!==4&&a.rank!==5)throw new ValueError(`conv3dWithBias expects input to be of rank 4 or 5, but received ${a.rank}.`);if(n.rank!==4&&n.rank!==5)throw new ValueError(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${a.rank}.`);let v=preprocessConv3DInput(a,m);if(f==="causal")throw new NotImplementedError("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return v=conv3d(v,n,u,f==="same"?"same":"valid","NDHWC",A),s!=null&&(v=biasAdd(v,s)),m==="channelsFirst"&&(v=transpose$2(v,[0,4,1,2,3])),v})}class BaseConv extends Layer{constructor(n,s){if(super(s),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",BaseConv.verifyArgs(s),this.rank=n,assertPositiveInteger(this.rank,"rank"),this.rank!==1&&this.rank!==2&&this.rank!==3)throw new NotImplementedError(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=normalizeArray(s.kernelSize,n,"kernelSize"),this.strides=normalizeArray(s.strides==null?1:s.strides,n,"strides"),this.padding=s.padding==null?"valid":s.padding,checkPaddingMode(this.padding),this.dataFormat=s.dataFormat==null?"channelsLast":s.dataFormat,checkDataFormat(this.dataFormat),this.activation=getActivation(s.activation),this.useBias=s.useBias==null?!0:s.useBias,this.biasInitializer=getInitializer(s.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=getConstraint(s.biasConstraint),this.biasRegularizer=getRegularizer(s.biasRegularizer),this.activityRegularizer=getRegularizer(s.activityRegularizer),this.dilationRate=normalizeArray(s.dilationRate==null?1:s.dilationRate,n,"dilationRate"),this.rank===1&&Array.isArray(this.dilationRate)&&this.dilationRate.length!==1)throw new ValueError(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(this.rank===2){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==2)throw new ValueError(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(this.rank===3){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==3)throw new ValueError(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}}static verifyArgs(n){if(assert("kernelSize"in n,"required key 'kernelSize' not in config"),typeof n.kernelSize!="number"&&!checkArrayTypeAndLength(n.kernelSize,"number",1,3))throw new ValueError(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(n.kernelSize)}.`)}getConfig(){const n={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:serializeActivation(this.activation),useBias:this.useBias,biasInitializer:serializeInitializer(this.biasInitializer),biasRegularizer:serializeRegularizer(this.biasRegularizer),activityRegularizer:serializeRegularizer(this.activityRegularizer),biasConstraint:serializeConstraint(this.biasConstraint)},s=super.getConfig();return Object.assign(n,s),n}}class Conv extends BaseConv{constructor(n,s){super(n,s),this.kernel=null,Conv.verifyArgs(s),this.filters=s.filters,assertPositiveInteger(this.filters,"filters"),this.kernelInitializer=getInitializer(s.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=getConstraint(s.kernelConstraint),this.kernelRegularizer=getRegularizer(s.kernelRegularizer)}build(n){n=getExactlyOneShape(n);const s=this.dataFormat==="channelsFirst"?1:n.length-1;if(n[s]==null)throw new ValueError(`The channel dimension of the input should be defined. Found ${n[s]}`);const u=n[s],f=this.kernelSize.concat([u,this.filters]);this.kernel=this.addWeight("kernel",f,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[s]:u}}],this.built=!0}call(n,s){return tidy(()=>{n=getExactlyOneTensor(n);let u;const f=this.bias==null?null:this.bias.read(),m=mapActivationToFusedKernel(this.activation.getClassName());if(m!=null&&this.rank===2)u=conv2dWithBiasActivation(n,this.kernel.read(),f,this.strides,this.padding,this.dataFormat,this.dilationRate,m);else{if(this.rank===1)u=conv1dWithBias(n,this.kernel.read(),f,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(this.rank===2)u=conv2dWithBiasActivation(n,this.kernel.read(),f,this.strides,this.padding,this.dataFormat,this.dilationRate);else if(this.rank===3)u=conv3dWithBias(n,this.kernel.read(),f,this.strides,this.padding,this.dataFormat,this.dilationRate);else throw new NotImplementedError("convolutions greater than 3D are not implemented yet.");this.activation!=null&&(u=this.activation.apply(u))}return u})}computeOutputShape(n){n=getExactlyOneShape(n);const s=[],u=this.dataFormat==="channelsLast"?n.slice(1,n.length-1):n.slice(2);for(let m=0;m 0 but got ${JSON.stringify(n.filters)}`)}}class Conv2D extends Conv{constructor(n){super(2,n),Conv2D.verifyArgs(n)}getConfig(){const n=super.getConfig();return delete n.rank,n}static verifyArgs(n){if(typeof n.kernelSize!="number"&&!checkArrayTypeAndLength(n.kernelSize,"number",1,2))throw new ValueError(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(n.kernelSize)}.`)}}Conv2D.className="Conv2D";registerClass(Conv2D);class Conv3D extends Conv{constructor(n){super(3,n),Conv3D.verifyArgs(n)}getConfig(){const n=super.getConfig();return delete n.rank,n}static verifyArgs(n){if(typeof n.kernelSize!="number"&&!(Array.isArray(n.kernelSize)&&(n.kernelSize.length===1||n.kernelSize.length===3)))throw new ValueError(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(n.kernelSize)}.`)}}Conv3D.className="Conv3D";registerClass(Conv3D);class Conv2DTranspose extends Conv2D{constructor(n){if(super(n),this.inputSpec=[new InputSpec({ndim:4})],this.padding!=="same"&&this.padding!=="valid")throw new ValueError(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(n){if(n=getExactlyOneShape(n),n.length!==4)throw new ValueError("Input should have rank 4; Received input shape: "+JSON.stringify(n));const s=this.dataFormat==="channelsFirst"?1:n.length-1;if(n[s]==null)throw new ValueError("The channel dimension of the inputs should be defined. Found `None`.");const u=n[s],f=this.kernelSize.concat([this.filters,u]);this.kernel=this.addWeight("kernel",f,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new InputSpec({ndim:4,axes:{[s]:u}})],this.built=!0}call(n,s){return tidy(()=>{let u=getExactlyOneTensor(n);if(u.shape.length!==4)throw new ValueError(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${u.shape.length}`);const f=u.shape,m=f[0];let A,v;this.dataFormat==="channelsFirst"?(A=2,v=3):(A=1,v=2);const y=f[A],T=f[v],I=this.kernelSize[0],S=this.kernelSize[1],E=this.strides[0],e=this.strides[1],F=deconvLength(y,E,I,this.padding),M=deconvLength(T,e,S,this.padding),L=[m,F,M,this.filters];this.dataFormat!=="channelsLast"&&(u=transpose$2(u,[0,2,3,1]));let V=conv2dTranspose(u,this.kernel.read(),L,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(V=transpose$2(V,[0,3,1,2])),this.bias!=null&&(V=biasAdd(V,this.bias.read(),this.dataFormat)),this.activation!=null&&(V=this.activation.apply(V)),V})}computeOutputShape(n){n=getExactlyOneShape(n);const s=n.slice();let u,f,m;this.dataFormat==="channelsFirst"?(u=1,f=2,m=3):(u=3,f=1,m=2);const A=this.kernelSize[0],v=this.kernelSize[1],y=this.strides[0],T=this.strides[1];return s[u]=this.filters,s[f]=deconvLength(s[f],y,A,this.padding),s[m]=deconvLength(s[m],T,v,this.padding),s}getConfig(){const n=super.getConfig();return delete n.dilationRate,n}}Conv2DTranspose.className="Conv2DTranspose";registerClass(Conv2DTranspose);class Conv3DTranspose extends Conv3D{constructor(n){if(super(n),this.inputSpec=[new InputSpec({ndim:5})],this.padding!=="same"&&this.padding!=="valid")throw new ValueError(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(n){if(n=getExactlyOneShape(n),n.length!==5)throw new ValueError("Input should have rank 5; Received input shape: "+JSON.stringify(n));const s=this.dataFormat==="channelsFirst"?1:n.length-1;if(n[s]==null)throw new ValueError("The channel dimension of the inputs should be defined. Found `None`.");const u=n[s],f=this.kernelSize.concat([this.filters,u]);this.kernel=this.addWeight("kernel",f,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new InputSpec({ndim:5,axes:{[s]:u}})],this.built=!0}call(n,s){return tidy(()=>{let u=getExactlyOneTensor(n);if(u.shape.length!==5)throw new ValueError(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${u.shape.length}`);const f=u.shape,m=f[0];let A,v,y;this.dataFormat==="channelsFirst"?(y=2,A=3,v=4):(y=1,A=2,v=3);const T=f[y],I=f[A],S=f[v],E=this.kernelSize[0],e=this.kernelSize[1],F=this.kernelSize[2],M=this.strides[0],L=this.strides[1],V=this.strides[2],B=deconvLength(T,M,E,this.padding),z=deconvLength(I,L,e,this.padding),b=deconvLength(S,V,F,this.padding),W=[m,B,z,b,this.filters];this.dataFormat!=="channelsLast"&&(u=transpose$2(u,[0,2,3,4,1]));let q=conv3dTranspose(u,this.kernel.read(),W,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(q=transpose$2(q,[0,4,1,2,3])),this.bias!==null&&(q=biasAdd(q,this.bias.read(),this.dataFormat)),this.activation!==null&&(q=this.activation.apply(q)),q})}computeOutputShape(n){n=getExactlyOneShape(n);const s=n.slice();let u,f,m,A;this.dataFormat==="channelsFirst"?(u=1,f=2,m=3,A=4):(u=4,f=1,m=2,A=3);const v=this.kernelSize[0],y=this.kernelSize[1],T=this.kernelSize[2],I=this.strides[0],S=this.strides[1],E=this.strides[2];return s[u]=this.filters,s[f]=deconvLength(s[f],I,v,this.padding),s[m]=deconvLength(s[m],S,y,this.padding),s[A]=deconvLength(s[A],E,T,this.padding),s}getConfig(){const n=super.getConfig();return delete n.dilationRate,n}}Conv3DTranspose.className="Conv3DTranspose";registerClass(Conv3DTranspose);class SeparableConv extends Conv{constructor(n,s){if(super(n,s),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,s.filters==null)throw new ValueError("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(s.kernelInitializer!=null||s.kernelRegularizer!=null||s.kernelConstraint!=null)throw new ValueError("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(s.padding!=null&&s.padding!=="same"&&s.padding!=="valid")throw new ValueError(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(s.padding)}`);this.depthMultiplier=s.depthMultiplier==null?1:s.depthMultiplier,this.depthwiseInitializer=getInitializer(s.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=getRegularizer(s.depthwiseRegularizer),this.depthwiseConstraint=getConstraint(s.depthwiseConstraint),this.pointwiseInitializer=getInitializer(s.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=getRegularizer(s.pointwiseRegularizer),this.pointwiseConstraint=getConstraint(s.pointwiseConstraint)}build(n){if(n=getExactlyOneShape(n),n.length{n=getExactlyOneTensor(n);let u;if(this.rank===1)throw new NotImplementedError("1D separable convolution is not implemented yet.");return this.rank===2&&(this.dataFormat==="channelsFirst"&&(n=transpose$2(n,[0,2,3,1])),u=separableConv2d(n,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(u=biasAdd(u,this.bias.read(),this.dataFormat)),this.activation!=null&&(u=this.activation.apply(u)),this.dataFormat==="channelsFirst"&&(u=transpose$2(u,[0,3,1,2])),u})}getConfig(){const n=super.getConfig();return delete n.rank,delete n.kernelInitializer,delete n.kernelRegularizer,delete n.kernelConstraint,n.depthwiseInitializer=serializeInitializer(this.depthwiseInitializer),n.pointwiseInitializer=serializeInitializer(this.pointwiseInitializer),n.depthwiseRegularizer=serializeRegularizer(this.depthwiseRegularizer),n.pointwiseRegularizer=serializeRegularizer(this.pointwiseRegularizer),n.depthwiseConstraint=serializeConstraint(this.depthwiseConstraint),n.pointwiseConstraint=serializeConstraint(this.pointwiseConstraint),n}}SeparableConv.className="SeparableConv";class SeparableConv2D extends SeparableConv{constructor(n){super(2,n)}}SeparableConv2D.className="SeparableConv2D";registerClass(SeparableConv2D);class Conv1D extends Conv{constructor(n){super(1,n),Conv1D.verifyArgs(n),this.inputSpec=[{ndim:3}]}getConfig(){const n=super.getConfig();return delete n.rank,delete n.dataFormat,n}static verifyArgs(n){if(typeof n.kernelSize!="number"&&!checkArrayTypeAndLength(n.kernelSize,"number",1,1))throw new ValueError(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(n.kernelSize)}.`)}}Conv1D.className="Conv1D";registerClass(Conv1D);class Cropping2D extends Layer{constructor(n){super(n),typeof n.cropping=="number"?this.cropping=[[n.cropping,n.cropping],[n.cropping,n.cropping]]:typeof n.cropping[0]=="number"?this.cropping=[[n.cropping[0],n.cropping[0]],[n.cropping[1],n.cropping[1]]]:this.cropping=n.cropping,this.dataFormat=n.dataFormat===void 0?"channelsLast":n.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(n){return this.dataFormat==="channelsFirst"?[n[0],n[1],n[2]-this.cropping[0][0]-this.cropping[0][1],n[3]-this.cropping[1][0]-this.cropping[1][1]]:[n[0],n[1]-this.cropping[0][0]-this.cropping[0][1],n[2]-this.cropping[1][0]-this.cropping[1][1],n[3]]}call(n,s){return tidy(()=>{if(n=getExactlyOneTensor(n),this.dataFormat==="channelsLast"){const u=sliceAlongAxis(n,this.cropping[0][0],n.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return sliceAlongAxis(u,this.cropping[1][0],n.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}else{const u=sliceAlongAxis(n,this.cropping[0][0],n.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return sliceAlongAxis(u,this.cropping[1][0],n.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}})}getConfig(){const n={cropping:this.cropping,dataFormat:this.dataFormat},s=super.getConfig();return Object.assign(n,s),n}}Cropping2D.className="Cropping2D";registerClass(Cropping2D);class UpSampling2D extends Layer{constructor(n){super(n),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=n.size==null?this.DEFAULT_SIZE:n.size,this.dataFormat=n.dataFormat==null?"channelsLast":n.dataFormat,checkDataFormat(this.dataFormat),this.interpolation=n.interpolation==null?"nearest":n.interpolation,checkInterpolationFormat(this.interpolation)}computeOutputShape(n){if(this.dataFormat==="channelsFirst"){const s=n[2]==null?null:this.size[0]*n[2],u=n[3]==null?null:this.size[1]*n[3];return[n[0],n[1],s,u]}else{const s=n[1]==null?null:this.size[0]*n[1],u=n[2]==null?null:this.size[1]*n[2];return[n[0],s,u,n[3]]}}call(n,s){return tidy(()=>{let u=getExactlyOneTensor(n);const f=u.shape;if(this.dataFormat==="channelsFirst"){u=transpose$2(u,[0,2,3,1]);const m=this.size[0]*f[2],A=this.size[1]*f[3],v=this.interpolation==="nearest"?image.resizeNearestNeighbor(u,[m,A]):image.resizeBilinear(u,[m,A]);return transpose$2(v,[0,3,1,2])}else{const m=this.size[0]*f[1],A=this.size[1]*f[2];return this.interpolation==="nearest"?image.resizeNearestNeighbor(u,[m,A]):image.resizeBilinear(u,[m,A])}})}getConfig(){const n={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},s=super.getConfig();return Object.assign(n,s),n}}UpSampling2D.className="UpSampling2D";registerClass(UpSampling2D);/** * @license * Copyright 2018 Google LLC * @@ -21956,7 +21956,7 @@ return a / b;`,DIV_PACKED=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const kernelConfigs=[_fusedMatMulConfig,absConfig,acosConfig,acoshConfig,addConfig,addNConfig,allConfig,anyConfig,argMaxConfig,argMinConfig,asinConfig,asinhConfig,atanConfig,atan2Config,atanhConfig,avgPoolConfig,avgPool3DConfig,avgPool3DGradConfig,avgPoolGradConfig,batchMatMulConfig,batchNormConfig,batchToSpaceNDConfig,bincountConfig,bitwiseAndConfig,broadcastArgsConfig,castConfig,ceilConfig,clipByValueConfig,complexConfig,complexAbsConfig,concatConfig,conv2DConfig,conv2DBackpropFilterConfig,conv2DBackpropInputConfig,conv3DConfig,conv3DBackpropFilterV2Config,conv3DBackpropInputConfig,cosConfig,coshConfig,cropAndResizeConfig,cumprodConfig,cumsumConfig,denseBincountConfig,depthToSpaceConfig,depthwiseConv2dNativeConfig,depthwiseConv2dNativeBackpropFilterConfig,depthwiseConv2dNativeBackpropInputConfig,diagConfig,dilation2DConfig,einsumConfig,eluConfig,eluGradConfig,equalConfig,erfConfig,expConfig,expandDimsConfig,expm1Config,fftConfig,fillConfig,flipLeftRightConfig,floorConfig,floorDivConfig,fromPixelsConfig,fusedConv2DConfig,fusedDepthwiseConv2DConfig,gatherNdConfig,gatherV2Config,greaterConfig,greaterEqualConfig,identityConfig,ifftConfig,imagConfig,isFiniteConfig,isInfConfig,isNaNConfig,leakyReluConfig,lessConfig,lessEqualConfig,linSpaceConfig,logConfig,log1pConfig,logicalAndConfig,logicalNotConfig,logicalOrConfig,LRNConfig,LRNGradConfig,maxConfig,maximumConfig,maxPoolConfig,maxPool3DConfig,maxPool3DGradConfig,maxPoolGradConfig,maxPoolWithArgmaxConfig,meanConfig,minConfig,minimumConfig,mirrorPadConfig,modConfig,multinomialConfig,multiplyConfig,negConfig,nonMaxSuppressionV3Config,nonMaxSuppressionV4Config,nonMaxSuppressionV5Config,notEqualConfig,oneHotConfig,onesLikeConfig,packConfig,padV2Config,powConfig,preluConfig,prodConfig,raggedGatherConfig,raggedRangeConfig,raggedTensorToTensorConfig,rangeConfig,realConfig,realDivConfig,reciprocalConfig,reluConfig,relu6Config,reshapeConfig,resizeBilinearConfig,resizeBilinearGradConfig,resizeNearestNeighborConfig,resizeNearestNeighborGradConfig,reverseConfig,rotateWithOffsetConfig,roundConfig,rsqrtConfig,scatterNdConfig,searchSortedConfig,selectConfig,seluConfig,sigmoidConfig,signConfig,sinConfig,sinhConfig,sliceConfig,softmaxConfig,softplusConfig,spaceToBatchNDConfig,sparseFillEmptyRowsConfig,sparseReshapeConfig,sparseSegmentMeanConfig,sparseSegmentSumConfig,sparseToDenseConfig,splitVConfig,sqrtConfig,squareConfig,squaredDifferenceConfig,staticRegexReplaceConfig,stepConfig,stridedSliceConfig,stringNGramsConfig,stringSplitConfig,stringToHashBucketFastConfig,subConfig,sumConfig,tanConfig,tanhConfig,tensorScatterUpdateConfig,tileConfig,topKConfig,transformConfig,transposeConfig,uniqueConfig,unpackConfig,unsortedSegmentSumConfig,zerosLikeConfig];for(const a of kernelConfigs)registerKernel(a);class BWLabeler{idx(n,s,u,f){return u*f[0]*f[1]+s*f[0]+n}check_previous_slice(n,s,u,f,m,A,v,y,T,I){let S=0;if(!m)return 0;const E=n[this.idx(u,f,m,A)];if(v>=6){const e=this.idx(u,f,m-1,A);E===n[e]&&(T[S++]=s[e])}if(v>=18){if(u){const e=this.idx(u-1,f,m-1,A);E===n[e]&&(T[S++]=s[e])}if(f){const e=this.idx(u,f-1,m-1,A);E===n[e]&&(T[S++]=s[e])}if(u=6){if(F){const V=this.idx(F-1,e,E,s);L===n[V]&&(S[M++]=I[V])}if(e){const V=this.idx(F,e-1,E,s);L===n[V]&&(S[M++]=I[V])}}if(u>=18){if(e&&F){const V=this.idx(F-1,e-1,E,s);L===n[V]&&(S[M++]=I[V])}if(e&&F=y){y+=v;const V=new Uint32Array(y);V.set(T),T=V}T[A-1]=A,A++}}}for(let E=0;E.",inferenceDelay:100,description:"Gray and white matter segmentation model. Operates on full T1 image in a single pass but needs a dedicated graphics card to operate. Provides the best accuracy with hard cropping for better speed"},{id:3,type:"Segmentation",path:"/models/model20chan3cls/model.json",modelName:"🔪 Tissue GWM (High Acc, Low Mem)",labelsPath:"./models/model20chan3cls/labels.json",colorsPath:"./models/model20chan3cls/colorLUT.json",colormapPath:"./models/model20chan3cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Gray and white matter segmentation model. Operates on full T1 image in a single pass but needs a dedicated graphics card to operate. Provides high accuracy and fit low memory available but slower"},{id:4,type:"Atlas",path:"/models/model30chan18cls/model.json",modelName:"🪓 Subcortical + GWM (High Mem, Fast)",labelsPath:"./models/model30chan18cls/labels.json",colorsPath:"./models/model30chan18cls/colorLUT.json",colormapPath:"./models/model30chan18cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is a robust model able to handle range of data quality, including varying saturation, and even clinical scans. It may work on infant brains, but your mileage may vary."},{id:5,type:"Atlas",path:"/models/model30chan18cls/model.json",modelName:"🪓 Subcortical + GWM (Low Mem, Slow)",labelsPath:"./models/model30chan18cls/labels.json",colorsPath:"./models/model30chan18cls/colorLUT.json",colormapPath:"./models/model30chan18cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is a robust model able to handle range of data quality, including varying saturation, and even clinical scans. It may work on infant brains, but your mileage may vary."},{id:6,type:"Atlas",path:"/models/model18cls/model.json",modelName:"🪓 Subcortical + GWM (Low Mem, Faster)",labelsPath:"./models/model18cls/labels.json",colorsPath:"./models/model18cls/colorLUT.json",colormapPath:"./models/model18cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is a robust model able to handle range of data quality, including varying saturation, and even clinical scans. It may work on infant brains, but your mileage may vary."},{id:7,type:"Atlas",path:"/models/model30chan18cls/model.json",modelName:"🔪🪓 Subcortical + GWM (Failsafe, Less Acc)",labelsPath:"./models/model30chan18cls/labels.json",colorsPath:"./models/model30chan18cls/colorLUT.json",colormapPath:"./models/model30chan18cls/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is not a robust model, it may work on low data quality, including varying saturation, and even clinical scans. It may work also on infant brains, but your mileage may vary."},{id:8,type:"Atlas",path:"/models/model30chan50cls/model.json",modelName:"🔪 Aparc+Aseg 50 (High Mem, Fast)",labelsPath:"./models/model30chan50cls/labels.json",colorsPath:"./models/model30chan50cls/colorLUT.json",colormapPath:"./models/model30chan50cls/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"This is a 50-class model, that segments the brain into the Aparc+Aseg Freesurfer Atlas but one where cortical homologues are merged into a single class."},{id:9,type:"Atlas",path:"/models/model30chan50cls/model.json",modelName:"🔪 Aparc+Aseg 50 (Low Mem, Slow)",labelsPath:"./models/model30chan50cls/labels.json",colorsPath:"./models/model30chan50cls/colorLUT.json",colormapPath:"./models/model30chan50cls/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"This is a 50-class model, that segments the brain into the Aparc+Aseg Freesurfer Atlas but one where cortical homologues are merged into a single class. The model use sequential convolution for inference to overcome browser memory limitations but leads to longer computation time."},{id:10,type:"Brain_Extraction",path:"/models/model5_gw_ae/model.json",modelName:"⚡ Extract the Brain (FAST)",labelsPath:null,colorsPath:null,preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:18,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:null,inferenceDelay:100,description:"Extract the brain fast model operates on full T1 image in a single pass, but uses only 5 filters per layer. Can work on integrated graphics cards but is barely large enough to provide good accuracy. Still more accurate than the failsafe version."},{id:11,type:"Brain_Extraction",path:"/models/model11_gw_ae/model.json",modelName:"🔪 Extract the Brain (High Acc, Slow)",labelsPath:null,colorsPath:null,preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Extract the brain high accuracy model operates on full T1 image in a single pass, but uses only 11 filters per layer. Can work on dedicated graphics cards. Still more accurate than the fast version."},{id:12,type:"Brain_Masking",path:"/models/model5_gw_ae/model.json",modelName:"⚡ Brain Mask (FAST)",labelsPath:null,colorsPath:null,colormapPath:"./models/model5_gw_ae/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:17,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:null,inferenceDelay:100,description:"This fast masking model operates on full T1 image in a single pass, but uses only 5 filters per layer. Can work on integrated graphics cards but is barely large enough to provide good accuracy. Still more accurate than failsafe version."},{id:13,type:"Brain_Masking",path:"/models/model11_gw_ae/model.json",modelName:"🔪 Brain Mask (High Acc, Low Mem)",labelsPath:null,colorsPath:null,preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"This masking model operates on full T1 image in a single pass, but uses 11 filters per layer. Can work on dedicated graphics cards. Still more accurate than fast version."},{id:14,type:"Atlas",path:"/models/model21_104class/model.json",modelName:"🔪 Aparc+Aseg 104 (High Mem, Fast)",labelsPath:"./models/model21_104class/labels.json",colorsPath:"./models/model21_104class/colorLUT.json",colormapPath:"./models/model21_104class/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"FreeSurfer aparc+aseg atlas 104 parcellate brain areas into 104 regions. It contains a combination of the Desikan-Killiany atlas for cortical area and also segmentation of subcortical regions."},{id:15,type:"Atlas",path:"/models/model21_104class/model.json",modelName:"🔪 Aparc+Aseg 104 (Low Mem, Slow)",labelsPath:"./models/model21_104class/labels.json",colorsPath:"./models/model21_104class/colorLUT.json",colormapPath:"./models/model21_104class/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"FreeSurfer aparc+aseg atlas 104 parcellate brain areas into 104 regions. It contains a combination of the Desikan-Killiany atlas for cortical area and also segmentation of subcortical regions. The model use sequential convolution for inference to overcome browser memory limitations but leads to longer computation time. "}];async function getModelNumParameters(a){let n=0;for(let s=0;se-F);const m=tensor1d(f),A=m.shape[0],v=Math.floor(A*n),y=Math.ceil(A*s)-1,T=m.slice(v,1),I=m.slice(y,1),S=(await T.array())[0],E=(await I.array())[0];return u.dispose(),m.dispose(),T.dispose(),I.dispose(),{qmin:S,qmax:E}}async function quantileNormalizeVolumeData(a,n=.05,s=.95){const{qmin:u,qmax:f}=await calculateQuantiles(a,n,s),m=scalar(u),A=scalar(f),v=a.sub(m).div(A.sub(m));return m.dispose(),A.dispose(),v}async function minMaxNormalizeVolumeData(a){const n=a.max(),s=a.min();return await a.sub(s).div(n.sub(s))}async function inferenceFullVolumeSeqCovLayer(a,n,s,u,f,m,A){window.alert("inferenceFullVolumeSeqCovLayer() is not dead code?")}async function inferenceFullVolume(a,n,s,u,f,m,A){window.alert("inferenceFullVolume() is not dead code?")}async function inferenceSubVolumes(a,n,s,u,f,m=null){window.alert("inferenceSubVolumes() is not dead code?")}async function tensor2LightBuffer(a,n){window.alert("tensor2LightBuffer() is not dead code?")}async function draw3dObjBoundingVolume(a){window.alert("draw3dObjBoundingVolume() is not dead code?")}async function argMaxLarge(a,n,s,u,f,m="float32"){window.alert("argMaxLarge() is not dead code?")}async function addZeroPaddingTo3dTensor(a,n=[1,1],s=[1,1],u=[1,1]){if(a.rank!==3)throw new Error("Tensor must be 3D");return a.pad([n,s,u])}async function removeZeroPaddingFrom3dTensor(a,n=1,s=1,u=1){if(a.rank!==3)throw new Error("Tensor must be 3D");let f,m,A;return[f,m,A]=a.shape,a.slice([n,s,u],[f-2*n,m-2*s,A-2*u])}async function resizeWithZeroPadding(a,n,s,u,f,m){const A=f[0],v=f[1],y=f[2],T=A+m[0]-1,I=v+m[1]-1,S=y+m[2]-1,E=s-T-1>0?s-T-1:0,e=u-I-1>0?u-I-1:0,F=n-S-1>0?n-S-1:0;return a.pad([[A,E],[v,e],[y,F]])}async function applyMriThreshold(a,n){const s=a.max(),u=s.mul(n),f=await u.data();return s.dispose(),u.dispose(),tidy(()=>a.clone().greater(f[0]))}async function binarizeVolumeDataTensor(a){return a.step(0)}async function generateBrainMask(a,n,s,u,f,m,A,v,y=!0){console.log("Generate Brain Masking ... ");let T=[];for(let F=0;F{const F="postProcessSlices3D() should be upgraded to BWLabeler";A(F,-1,F)}),console.log("Post processing done ")):console.log("Phase-1 Post processing disabled ... ");const S=new Array(T[0].length*T.length);let E=0;for(let F=0;F{const z=a.slice([0,0,0,0,L],[-1,-1,-1,-1,V-L]),b=n.slice([0,0,0,L,I],[-1,-1,-1,V-L,1]);return conv3d(z,b,u,f,"NDHWC",m)});if(e===null)e=B;else{const z=e.add(B);e.dispose(),B.dispose(),e=z}}}const F=e.add(E);if(e.dispose(),E.dispose(),T==null)T=F;else{const M=await concat$2([T,F],4);F.dispose(),T.dispose(),T=M}}return T}function processTensorInChunks(a,n,s){const A=a.shape[4],v=Math.ceil(A/s);let y=null;for(let T=0;Ta.slice([0,0,0,0,I],[-1,-1,-1,-1,E])),F=tidy(()=>n.slice([0,0,0,I,0],[-1,-1,-1,E,-1])),M=conv3d(e,F,1,0,"NDHWC",1);e.dispose(),F.dispose();const L=squeeze(M);if(M.dispose(),y===null)y=L;else{const V=y.add(L);y.dispose(),y!==L&&L.dispose(),y=V}tidy(()=>{matMul$1(zeros$1([1,1]),zeros$1([1,1]))})}return y}class SequentialConvLayer{constructor(n,s,u,f){this.model=n,this.outChannels=n.outputLayers[0].kernel.shape[4],this.chunkSize=s,this.isChannelLast=u,this.callbackUI=f}async apply(n){const s=ENV$4.get("WEBGL_DELETE_TEXTURE_THRESHOLD");ENV$4.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0);const u=this;return new Promise(f=>{const m=performance.now(),A=u.model.layers[u.model.layers.length-1],v=A.getWeights()[0],y=A.getWeights()[1],T=u.isChannelLast?n.shape.slice(1,-1):n.shape.slice(2);let I=mul(ones(T),-1e4),S=zeros$1(T),E=0;console.log(" channel loop");const e=window.setInterval(async function(){engine().startScope(),console.log("=======================");const F=await memory();console.log(`| Number of Tensors: ${F.numTensors}`),console.log(`| Number of Data Buffers: ${F.numDataBuffers}`),console.log("Channel : ",E);const M=await tidy(()=>{const V=v.slice([0,0,0,0,E],[-1,-1,-1,-1,1]),B=y.slice([E],[1]),z=processTensorInChunks(n,V,Math.min(u.chunkSize,u.outChannels)).add(B),b=greater$2(z,I),W=where(b,z,I),q=where(b,fill$2(S.shape,E),S);return dispose([I,S,V,B,z,b]),tidy(()=>matMul$1(ones([1,1]),ones([1,1]))),[q,W]});console.log("=======================");const L=await memory();if(u.callbackUI(`Iteration ${E}`,E/u.outChannels),console.log(`Number of Tensors: ${L.numTensors}`),console.log(`Number of Data Buffers: ${L.numDataBuffers}`),console.log(`Megabytes In Use: ${(L.numBytes/1048576).toFixed(3)} MB`),L.unreliable&&console.log(`Unreliable: ${L.unreliable}`),typeof S<"u"&&S.dispose(),typeof I<"u"&&I.dispose(),S=keep(M[0]),I=keep(M[1]),engine().endScope(),E===u.outChannels-1){window.clearInterval(e),dispose(I);const B=performance.now()-m;console.log(`Execution time for output layer: ${B} milliseconds`),ENV$4.set("WEBGL_DELETE_TEXTURE_THRESHOLD",s),f(S)}else{E++;const V=S.shape,B=S.dataSync(),z=S.shape,b=I.dataSync();S.dispose(),I.dispose(),S=tensor(B,V),I=tensor(b,z)}await new Promise(V=>setTimeout(V,300))},0)})}}async function generateOutputSlicesV2(a,n,s,u,f,m,A,v,y,T){if(y.isPostProcessEnable){const E=new BWLabeler,e=new Uint32Array(n),F=26,M=!0,L=!0,[V,B]=E.bwlabel(a,e,F,M,L);for(let z=0;z0&&re<=1?e=await applyMriThreshold(u,re):(console.log("No valid crop threshold value"),e=await u.greater([0]).asType("bool"))}else e=await v.greater([0]).asType("bool");console.log(" mask_3d shape : ",e.shape);const F=await whereAsync(e);e.dispose();const M=F.arraySync();let L=m,V=0,B=A,z=0,b=f,W=0;for(let re=0;reM[re][0]?L=M[re][0]:VM[re][1]?B=M[re][1]:zM[re][2]?b=M[re][2]:Where'),memory().unreliable){const ae="unreliable reasons :"+memory().reasons;y(ae,NaN,ae)}}}async function inferenceFullVolumePhase2(a,n,s,u,f,m,A,v,y,T,I,S){let E=[];console.log(" ---- Start FullVolume inference phase-II ---- "),A.enableQuantileNorm?(console.log("preModel Quantile normalization enabled"),n=await quantileNormalizeVolumeData(n)):(console.log("preModel Min Max normalization enabled"),n=await minMaxNormalizeVolumeData(n));let F;if(m==null){const pe=A.autoThreshold;pe>0&&pe<=1?F=await applyMriThreshold(n,pe):(console.log("No valid crop threshold value"),F=await n.greater([0]).asType("bool"))}else F=m.greater([0]).asType("bool");console.log(" mask_3d shape : ",F.shape);const M=await whereAsync(F);F.dispose();const L=M.arraySync();let V=u,B=0,z=f,b=0,W=s,q=0;for(let pe=0;peL[pe][0]?V=L[pe][0]:BL[pe][1]?z=L[pe][1]:bL[pe][2]?W=L[pe][2]:qhere')}}async function inferenceFullVolumePhase1(a,n,s,u,f,m,A,v,y,T,I,S){if(v.No_SubVolumes=1,A.preModelId){const E=await load_model(y.rootURL+inferenceModelsList[A.preModelId-1].path),e=inferenceModelsList[A.preModelId-1].enableTranspose,F=inferenceModelsList[A.preModelId-1].enableQuantileNorm;let M=null;F?(console.log("preModel Quantile normalization enabled"),M=await quantileNormalizeVolumeData(n)):(console.log("preModel Min Max normalization enabled"),M=await minMaxNormalizeVolumeData(n)),e?(M=await M.transpose(),console.log("Input transposed for pre-model")):console.log("Transpose not enabled for pre-model"),v.Brainchop_Ver="PreModel_FV";const L=await E;try{const V=performance.now(),B=L,z=B.layers[0].batchInputShape;if(console.log(" Pre-Model batch input shape : ",z),z.length!==5){const Se="The pre-model input shape must be 5D ";return I(Se,-1,Se),0}const b=isModelChnlLast(B),W=y.batchSize,q=y.numOfChan;let Y,X,H,g;if(b){if(console.log("Pre-Model Channel Last"),isNaN(z[4])||z[4]!==1){const Se="The number of channels for pre-model input shape must be 1";return I(Se,-1,Se),0}Y=z[1],X=z[2],H=z[3],g=[W,Y,X,H,q]}else{if(console.log("Pre-Model Channel First"),isNaN(z[1])||z[1]!==1){const Se="The number of channels for pre-model input shape must be 1";return I(Se,-1,Se),0}Y=z[2],X=z[3],H=z[4],g=[W,q,Y,X,H]}v.Input_Shape=JSON.stringify(g),v.Output_Shape=JSON.stringify(B.output.shape),v.Channel_Last=b,v.Model_Param=await getModelNumParameters(B),v.Model_Layers=await getModelNumLayers(B);let J=0;const re=inferenceModelsList[A.preModelId-1].inferenceDelay;let ae=1;const fe=L.layers.length,pe=[];pe[0]=M.reshape(g),dispose(M);const me=window.setInterval(async function(){try{pe[ae]=L.layers[ae].apply(pe[ae-1])}catch(Se){const ve="Your graphics card (e.g. Intel) may not be compatible with WebGL. "+Se.message;return I(ve,-1,ve),window.clearInterval(me),engine().endScope(),engine().disposeVariables(),v.Inference_t=1/0,v.Postprocess_t=1/0,v.Status="Fail",v.Error_Type=Se.message,v.Extra_Err_Info="PreModel Failed while model layer "+ae+" apply",I("",-1,"",v),0}if(L.layers[ae].dispose(),pe[ae-1].dispose(),I("Layer "+ae.toString(),(ae+1)/fe),memory().unreliable){const Se="unreliable reasons :"+memory().reasons;I(Se,NaN,Se)}if(ae===fe-1){window.clearInterval(me);const Se=b?-1:1;console.log(" find argmax "),console.log("last Tensor shape : ",pe[ae].shape);const ve=b?pe[ae].shape[4]:pe[ae].shape[1];let we;try{console.log(" Try tf.argMax for fullVolume .."),we=await argMax$2(pe[ae],Se)}catch(pt){if(Se===-1)try{const It=performance.now();console.log(" tf.argMax failed .. try argMaxLarge ..");const Lt=tensor2LightBuffer(pe[ae].reshape([s,u,f,ve]),"float16");we=argMaxLarge(Lt,s,u,f,ve,"float16"),console.log("argMaxLarge for fullVolume takes : ",((performance.now()-It)/1e3).toFixed(4))}catch(It){const Lt="argMax buffer couldn't be created due to limited memory resources.";return I(Lt,-1,Lt),we.dispose(),window.clearInterval(me),engine().endScope(),engine().disposeVariables(),v.Inference_t=1/0,v.Postprocess_t=1/0,v.Status="Fail",v.Error_Type=It.message,v.Extra_Err_Info="preModel prediction_argmax from argMaxLarge failed",I("",-1,"",v),0}else{const It="argMax buffer couldn't be created due to limited memory resources.";return I(It,-1,It),we.dispose(),window.clearInterval(me),engine().endScope(),engine().disposeVariables(),v.Inference_t=1/0,v.Postprocess_t=1/0,v.Status="Fail",v.Error_Type=pt.message,v.Extra_Err_Info="preModel prediction_argmax from argMaxLarge not support yet channel first",I("",-1,"",v),0}}console.log(" Pre-model prediction_argmax shape : ",we.shape);const Ne=((performance.now()-V)/1e3).toFixed(4);dispose(pe[ae]),console.log(" Pre-model find array max ");const De=await we.max().dataSync()[0];Jhere')}}else console.log("--- No pre-model is selected ---"),console.log("------ Run voxel cropping ------"),m?A.enableSeqConv?(console.log("------ Seq Convoluton ------"),await inferenceFullVolumeSeqCovLayerPhase2(y,A,a,n,s,u,f,null,I,T,v,S)):inferenceFullVolumePhase2(a,n,s,u,f,null,A,v,y,T,I,S):inferenceSubVolumes(a,n,s,u,f,null)}async function enableProductionMode(a=!0){await enableProdMode(),env().set("DEBUG",!1),env().set("WEBGL_FORCE_F16_TEXTURES",a),env().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0),await ready(),console.log("tf env() flags :",env().flags),console.log("tf env() features :",env().features),console.log("tf env total features: ",Object.keys(env().features).length),console.log(getBackend())}async function runInference(a,n,s,u,f,m){const A=[];A.startTime=performance.now(),m("Segmentation started",0),performance.now();const v=a.batchSize,y=a.numOfChan;if(isNaN(v)||v!==1){const H="The batch Size for input shape must be 1";return m(H,-1,H),0}if(isNaN(y)||y!==1){const H="The number of channels for input shape must be 1";return m(H,-1,H),0}engine().startScope(),console.log("Batch size: ",v),console.log("Num of Channels: ",y);const T=await load_model(a.rootURL+n.path);await enableProductionMode(!0),A.TF_Backend=getBackend();const I=T;let S=[];if(S=I.layers[0].batchInputShape,console.log(" Model batch input shape : ",S),S.length!==5){const H="The model input shape must be 5D";return m(H,-1,H),0}let E,e,F;const M=s.dims[1],L=s.dims[2],V=s.dims[3];if(await isModelChnlLast(I)){if(console.log("Model Channel Last"),isNaN(S[4])||S[4]!==1){const H="The number of channels for input shape must be 1";return m(H,-1,H),0}E=S[1],e=S[2],F=S[3]}else{if(console.log("Model Channel First"),isNaN(S[1])||S[1]!==1){const H="The number of channels for input shape must be 1";return m(H,-1,H),0}E=S[2],e=S[3],F=S[4]}let z;E===256&&e===256&&F===256?z=!0:z=!1,A.isModelFullVol=z;let b=await getAllSlicesData1D(V,s,u);const W=await getAllSlices2D(b,L,M);b=null;let q=await getSlices3D(W);dispose(W);const Y=n.enableTranspose,X=n.enableCrop;z&&(X?await inferenceFullVolumePhase1(T,q,V,L,M,z,n,A,a,f,m,u):(console.log("Cropping Disabled"),Y?(q=q.transpose(),console.log("Input transposed")):console.log("Transpose NOT Enabled"),n.enableSeqConv?(console.log("Seq Convoluton Enabled"),await inferenceFullVolumeSeqCovLayer()):(console.log("Seq Convoluton Disabled"),await inferenceFullVolume())))}async function detectBrowser(){return navigator.userAgent.indexOf("OPR/")>-1?"Opera":navigator.userAgent.indexOf("Edg/")>-1?"Edge":navigator.userAgent.indexOf("Falkon/")>-1?"Falkon":navigator.userAgent.indexOf("Chrome/")>-1?"Chrome":navigator.userAgent.indexOf("Firefox/")>-1?"Firefox":navigator.userAgent.indexOf("Safari/")>-1?"Safari":navigator.userAgent.indexOf("MSIE/")>-1||navigator.userAgent.indexOf("rv:")>-1?"IExplorer":"Unknown"}async function detectBrowserVersion(){return navigator.userAgent.indexOf("OPR/")>-1?parseInt(navigator.userAgent.split("OPR/")[1]):navigator.userAgent.indexOf("Edg/")>-1?parseInt(navigator.userAgent.split("Edg/")[1]):navigator.userAgent.indexOf("Falkon/")>-1?parseInt(navigator.userAgent.split("Falkon/")[1]):navigator.userAgent.indexOf("Chrome/")>-1?parseInt(navigator.userAgent.split("Chrome/")[1]):navigator.userAgent.indexOf("Firefox/")>-1?parseInt(navigator.userAgent.split("Firefox/")[1]):navigator.userAgent.indexOf("Safari/")>-1?parseInt(navigator.userAgent.split("Safari/")[1]):navigator.userAgent.indexOf("MSIE/")>-1||navigator.userAgent.indexOf("rv:")>-1?parseInt(navigator.userAgent.split("MSIE/")[1]):1/0}async function detectOperatingSys(){return navigator.userAgent.indexOf("Win")>-1?"Windows":navigator.userAgent.indexOf("Mac")>-1?"MacOS":navigator.userAgent.indexOf("Linux")>-1?"Linux":navigator.userAgent.indexOf("UNIX")>-1?"UNIX":"Unknown"}async function checkWebGl2(a){return a?(console.log("WebGl2 is enabled"),!0):(typeof WebGL2RenderingContext<"u"||console.log("WebGL2 is not supported"),!1)}async function detectGPUVendor(a){let n;if(a&&(n=a.getExtension("WEBGL_debug_renderer_info"),n)){const s=a.getParameter(n.UNMASKED_VENDOR_WEBGL);return s.indexOf("(")>-1&&s.indexOf(")")>-1?s.substring(s.indexOf("(")+1,s.indexOf(")")):s}return null}async function detectGPUVendor_v0(a){if(a){const n=a.getExtension("WEBGL_debug_renderer_info");return n?a.getParameter(n.UNMASKED_VENDOR_WEBGL):null}else return null}async function detectGPUCardType_v0(a){if(a){if(detectBrowser()==="Firefox")return a.getParameter(a.RENDERER);const n=a.getExtension("WEBGL_debug_renderer_info");return n?a.getParameter(n.UNMASKED_RENDERER_WEBGL):null}else return null}async function detectGPUCardType(a){let n;if(a){if(detectBrowser()==="Firefox")return a.getParameter(a.RENDERER);if(n=a.getExtension("WEBGL_debug_renderer_info"),n){let s=a.getParameter(n.UNMASKED_RENDERER_WEBGL);return s.indexOf("(")>-1&&s.indexOf(")")>-1&&s.indexOf("(R)")===-1&&(s=s.substring(s.indexOf("(")+1,s.indexOf(")")),s.split(",").length===3)?s.split(",")[1].trim():s}}return null}async function getCPUNumCores(){return navigator.hardwareConcurrency}async function isChrome(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}async function localSystemDetails(a,n=null){const s=((performance.now()-a.startTime)/1e3).toFixed(4),u=new Date;if(a.isModelFullVol?a.Brainchop_Ver="FullVolume":a.Brainchop_Ver="SubVolumes",a.Date=parseInt(u.getMonth()+1)+"/"+u.getDate()+"/"+u.getFullYear(),a.Time_Elapsed=s,a.Browser=await detectBrowser(),a.Browser_Ver=await detectBrowserVersion(),a.OS=await detectOperatingSys(),a.WebGL2=await checkWebGl2(n),a.GPU_Vendor=await detectGPUVendor(n),a.GPU_Card=await detectGPUCardType(n),a.GPU_Vendor_Full=await detectGPUVendor_v0(n),a.GPU_Card_Full=await detectGPUCardType_v0(n),a.CPU_Cores=await getCPUNumCores(),a.Which_Brainchop="latest",await isChrome()&&(a.Heap_Size_MB=window.performance.memory.totalJSHeapSize/(1024*1024).toFixed(2),a.Used_Heap_MB=window.performance.memory.usedJSHeapSize/(1024*1024).toFixed(2),a.Heap_Limit_MB=window.performance.memory.jsHeapSizeLimit/(1024*1024).toFixed(2)),n){console.log("MAX_TEXTURE_SIZE :",n.getParameter(n.MAX_TEXTURE_SIZE)),console.log("MAX_RENDERBUFFER_SIZE :",n.getParameter(n.MAX_RENDERBUFFER_SIZE));const f=n.getExtension("WEBGL_debug_renderer_info");console.log("VENDOR WEBGL:",n.getParameter(f.UNMASKED_VENDOR_WEBGL)),a.Texture_Size=n.getParameter(n.MAX_TEXTURE_SIZE)}else a.Texture_Size=null;return a}function WorkerWrapper(a){return new Worker(""+new URL("brainchop-webworker-IyBSiRBQ.js",import.meta.url).href,{name:a==null?void 0:a.name})}async function main(){aboutBtn.onclick=function(){window.alert("BrainChop models https://github.com/neuroneural/brainchop")},diagnosticsBtn.onclick=function(){if(y.length<1){window.alert("No diagnostic string generated: run a model to create diagnostics");return}navigator.clipboard.writeText(y),window.alert(`Diagnostics copied to clipboard -`+y)},opacitySlider0.oninput=function(){I.setOpacity(0,opacitySlider0.value/255),I.updateGLVolume()},opacitySlider1.oninput=function(){I.setOpacity(1,opacitySlider1.value/255)};async function a(){let E=I.volumes[0],e=E.dims[1]===256&&E.dims[2]===256&&E.dims[3]===256;if((E.permRAS[0]!==-1||E.permRAS[1]!==3||E.permRAS[2]!==-2)&&(e=!1),e)return;let F=await I.conform(E,!1);I.removeVolume(I.volumes[0]),I.addVolume(F)}async function n(){for(;I.volumes.length>1;)await I.removeVolume(I.volumes[1])}modelSelect.onchange=async function(){this.selectedIndex<0&&(modelSelect.selectedIndex=11),await n(),await a();let E=inferenceModelsList[this.selectedIndex],e=brainChopOpts;if(e.rootURL=location.href,!!(window.location.hostname==="localhost"||window.location.hostname==="[::1]"||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/))&&(e.rootURL=location.protocol+"//"+location.host),workerCheck.checked){if(typeof T<"u"){console.log("Unable to start new segmentation: previous call has not completed");return}T=await new WorkerWrapper({type:"module"});let M={datatypeCode:I.volumes[0].hdr.datatypeCode,dims:I.volumes[0].hdr.dims},L={opts:e,modelEntry:E,niftiHeader:M,niftiImage:I.volumes[0].img};T.postMessage(L),T.onmessage=function(V){let B=V.data.cmd;B==="ui"&&(V.data.modalMessage!==""&&(T.terminate(),T=void 0),m(V.data.message,V.data.progressFrac,V.data.modalMessage,V.data.statData)),B==="img"&&(T.terminate(),T=void 0,u(V.data.img,V.data.opts,V.data.modelEntry))}}else runInference(e,E,I.volumes[0].hdr,I.volumes[0].img,u,m)},saveBtn.onclick=function(){I.volumes[1].saveToDisk("Custom.nii")},workerCheck.onchange=function(){modelSelect.onchange()},clipCheck.onchange=function(){clipCheck.checked?I.setClipPlane([0,0,90]):I.setClipPlane([2,0,90])};async function s(E){return await(await fetch(E)).json()}async function u(E,e,F){n();let M=await I.volumes[0].clone();if(M.zeroImage(),M.hdr.scl_inter=0,M.hdr.scl_slope=1,M.img=new Uint8Array(E),F.colormapPath){let L=await s(F.colormapPath);M.setColormapLabel(L)}else{let L=e.atlasSelectedColorTable.toLowerCase();I.colormaps().includes(L)||(L="actc"),M.colormap=L}M.opacity=opacitySlider1.value/255,await I.addVolume(M)}async function f(E){(typeof E=="string"||E instanceof String)&&(E=function(M){const L=JSON.parse(M),V=[];for(const B in L)V[B]=L[B];return V}(E)),E=await localSystemDetails(E,I.gl),y=`:: Diagnostics can help resolve issues https://github.com/neuroneural/brainchop/issues :: + */const kernelConfigs=[_fusedMatMulConfig,absConfig,acosConfig,acoshConfig,addConfig,addNConfig,allConfig,anyConfig,argMaxConfig,argMinConfig,asinConfig,asinhConfig,atanConfig,atan2Config,atanhConfig,avgPoolConfig,avgPool3DConfig,avgPool3DGradConfig,avgPoolGradConfig,batchMatMulConfig,batchNormConfig,batchToSpaceNDConfig,bincountConfig,bitwiseAndConfig,broadcastArgsConfig,castConfig,ceilConfig,clipByValueConfig,complexConfig,complexAbsConfig,concatConfig,conv2DConfig,conv2DBackpropFilterConfig,conv2DBackpropInputConfig,conv3DConfig,conv3DBackpropFilterV2Config,conv3DBackpropInputConfig,cosConfig,coshConfig,cropAndResizeConfig,cumprodConfig,cumsumConfig,denseBincountConfig,depthToSpaceConfig,depthwiseConv2dNativeConfig,depthwiseConv2dNativeBackpropFilterConfig,depthwiseConv2dNativeBackpropInputConfig,diagConfig,dilation2DConfig,einsumConfig,eluConfig,eluGradConfig,equalConfig,erfConfig,expConfig,expandDimsConfig,expm1Config,fftConfig,fillConfig,flipLeftRightConfig,floorConfig,floorDivConfig,fromPixelsConfig,fusedConv2DConfig,fusedDepthwiseConv2DConfig,gatherNdConfig,gatherV2Config,greaterConfig,greaterEqualConfig,identityConfig,ifftConfig,imagConfig,isFiniteConfig,isInfConfig,isNaNConfig,leakyReluConfig,lessConfig,lessEqualConfig,linSpaceConfig,logConfig,log1pConfig,logicalAndConfig,logicalNotConfig,logicalOrConfig,LRNConfig,LRNGradConfig,maxConfig,maximumConfig,maxPoolConfig,maxPool3DConfig,maxPool3DGradConfig,maxPoolGradConfig,maxPoolWithArgmaxConfig,meanConfig,minConfig,minimumConfig,mirrorPadConfig,modConfig,multinomialConfig,multiplyConfig,negConfig,nonMaxSuppressionV3Config,nonMaxSuppressionV4Config,nonMaxSuppressionV5Config,notEqualConfig,oneHotConfig,onesLikeConfig,packConfig,padV2Config,powConfig,preluConfig,prodConfig,raggedGatherConfig,raggedRangeConfig,raggedTensorToTensorConfig,rangeConfig,realConfig,realDivConfig,reciprocalConfig,reluConfig,relu6Config,reshapeConfig,resizeBilinearConfig,resizeBilinearGradConfig,resizeNearestNeighborConfig,resizeNearestNeighborGradConfig,reverseConfig,rotateWithOffsetConfig,roundConfig,rsqrtConfig,scatterNdConfig,searchSortedConfig,selectConfig,seluConfig,sigmoidConfig,signConfig,sinConfig,sinhConfig,sliceConfig,softmaxConfig,softplusConfig,spaceToBatchNDConfig,sparseFillEmptyRowsConfig,sparseReshapeConfig,sparseSegmentMeanConfig,sparseSegmentSumConfig,sparseToDenseConfig,splitVConfig,sqrtConfig,squareConfig,squaredDifferenceConfig,staticRegexReplaceConfig,stepConfig,stridedSliceConfig,stringNGramsConfig,stringSplitConfig,stringToHashBucketFastConfig,subConfig,sumConfig,tanConfig,tanhConfig,tensorScatterUpdateConfig,tileConfig,topKConfig,transformConfig,transposeConfig,uniqueConfig,unpackConfig,unsortedSegmentSumConfig,zerosLikeConfig];for(const a of kernelConfigs)registerKernel(a);class BWLabeler{idx(n,s,u,f){return u*f[0]*f[1]+s*f[0]+n}check_previous_slice(n,s,u,f,m,A,v,y,T,I){let S=0;if(!m)return 0;const E=n[this.idx(u,f,m,A)];if(v>=6){const e=this.idx(u,f,m-1,A);E===n[e]&&(T[S++]=s[e])}if(v>=18){if(u){const e=this.idx(u-1,f,m-1,A);E===n[e]&&(T[S++]=s[e])}if(f){const e=this.idx(u,f-1,m-1,A);E===n[e]&&(T[S++]=s[e])}if(u=6){if(F){const V=this.idx(F-1,e,E,s);L===n[V]&&(S[M++]=I[V])}if(e){const V=this.idx(F,e-1,E,s);L===n[V]&&(S[M++]=I[V])}}if(u>=18){if(e&&F){const V=this.idx(F-1,e-1,E,s);L===n[V]&&(S[M++]=I[V])}if(e&&F=y){y+=v;const V=new Uint32Array(y);V.set(T),T=V}T[A-1]=A,A++}}}for(let E=0;E.",inferenceDelay:100,description:"Gray and white matter segmentation model. Operates on full T1 image in a single pass but needs a dedicated graphics card to operate. Provides the best accuracy with hard cropping for better speed"},{id:3,type:"Segmentation",path:"/models/model20chan3cls/model.json",modelName:"🔪 Tissue GWM (High Acc, Low Mem)",labelsPath:"./models/model20chan3cls/labels.json",colorsPath:"./models/model20chan3cls/colorLUT.json",colormapPath:"./models/model20chan3cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Gray and white matter segmentation model. Operates on full T1 image in a single pass but needs a dedicated graphics card to operate. Provides high accuracy and fit low memory available but slower"},{id:4,type:"Atlas",path:"/models/model30chan18cls/model.json",modelName:"🪓 Subcortical + GWM (High Mem, Fast)",labelsPath:"./models/model30chan18cls/labels.json",colorsPath:"./models/model30chan18cls/colorLUT.json",colormapPath:"./models/model30chan18cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is a robust model able to handle range of data quality, including varying saturation, and even clinical scans. It may work on infant brains, but your mileage may vary."},{id:5,type:"Atlas",path:"/models/model30chan18cls/model.json",modelName:"🪓 Subcortical + GWM (Low Mem, Slow)",labelsPath:"./models/model30chan18cls/labels.json",colorsPath:"./models/model30chan18cls/colorLUT.json",colormapPath:"./models/model30chan18cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is a robust model able to handle range of data quality, including varying saturation, and even clinical scans. It may work on infant brains, but your mileage may vary."},{id:6,type:"Atlas",path:"/models/model18cls/model.json",modelName:"🪓 Subcortical + GWM (Low Mem, Faster)",labelsPath:"./models/model18cls/labels.json",colorsPath:"./models/model18cls/colorLUT.json",colormapPath:"./models/model18cls/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:.2,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is a robust model able to handle range of data quality, including varying saturation, and even clinical scans. It may work on infant brains, but your mileage may vary."},{id:7,type:"Atlas",path:"/models/model30chan18cls/model.json",modelName:"🔪🪓 Subcortical + GWM (Failsafe, Less Acc)",labelsPath:"./models/model30chan18cls/labels.json",colorsPath:"./models/model30chan18cls/colorLUT.json",colormapPath:"./models/model30chan18cls/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Parcellation of the brain into 17 regions: gray and white matter plus subcortical areas. This is not a robust model, it may work on low data quality, including varying saturation, and even clinical scans. It may work also on infant brains, but your mileage may vary."},{id:8,type:"Atlas",path:"/models/model30chan50cls/model.json",modelName:"🔪 Aparc+Aseg 50 (High Mem, Fast)",labelsPath:"./models/model30chan50cls/labels.json",colorsPath:"./models/model30chan50cls/colorLUT.json",colormapPath:"./models/model30chan50cls/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"This is a 50-class model, that segments the brain into the Aparc+Aseg Freesurfer Atlas but one where cortical homologues are merged into a single class."},{id:9,type:"Atlas",path:"/models/model30chan50cls/model.json",modelName:"🔪 Aparc+Aseg 50 (Low Mem, Slow)",labelsPath:"./models/model30chan50cls/labels.json",colorsPath:"./models/model30chan50cls/colorLUT.json",colormapPath:"./models/model30chan50cls/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"This is a 50-class model, that segments the brain into the Aparc+Aseg Freesurfer Atlas but one where cortical homologues are merged into a single class. The model use sequential convolution for inference to overcome browser memory limitations but leads to longer computation time."},{id:10,type:"Brain_Extraction",path:"/models/model5_gw_ae/model.json",modelName:"⚡ Extract the Brain (FAST)",labelsPath:null,colorsPath:null,preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:18,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:null,inferenceDelay:100,description:"Extract the brain fast model operates on full T1 image in a single pass, but uses only 5 filters per layer. Can work on integrated graphics cards but is barely large enough to provide good accuracy. Still more accurate than the failsafe version."},{id:11,type:"Brain_Extraction",path:"/models/model11_gw_ae/model.json",modelName:"🔪 Extract the Brain (High Acc, Slow)",labelsPath:null,colorsPath:null,preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"Extract the brain high accuracy model operates on full T1 image in a single pass, but uses only 11 filters per layer. Can work on dedicated graphics cards. Still more accurate than the fast version."},{id:12,type:"Brain_Masking",path:"/models/model5_gw_ae/model.json",modelName:"⚡ Brain Mask (FAST)",labelsPath:null,colorsPath:null,colormapPath:"./models/model5_gw_ae/colormap.json",preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:17,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:null,inferenceDelay:100,description:"This fast masking model operates on full T1 image in a single pass, but uses only 5 filters per layer. Can work on integrated graphics cards but is barely large enough to provide good accuracy. Still more accurate than failsafe version."},{id:13,type:"Brain_Masking",path:"/models/model11_gw_ae/model.json",modelName:"🔪 Brain Mask (High Acc, Low Mem)",labelsPath:null,colorsPath:null,preModelId:null,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:0,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!0,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"This masking model operates on full T1 image in a single pass, but uses 11 filters per layer. Can work on dedicated graphics cards. Still more accurate than fast version."},{id:14,type:"Atlas",path:"/models/model21_104class/model.json",modelName:"🔪 Aparc+Aseg 104 (High Mem, Fast)",labelsPath:"./models/model21_104class/labels.json",colorsPath:"./models/model21_104class/colorLUT.json",colormapPath:"./models/model21_104class/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!1,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"FreeSurfer aparc+aseg atlas 104 parcellate brain areas into 104 regions. It contains a combination of the Desikan-Killiany atlas for cortical area and also segmentation of subcortical regions."},{id:15,type:"Atlas",path:"/models/model21_104class/model.json",modelName:"🔪 Aparc+Aseg 104 (Low Mem, Slow)",labelsPath:"./models/model21_104class/labels.json",colorsPath:"./models/model21_104class/colorLUT.json",colormapPath:"./models/model21_104class/colormap.json",preModelId:1,preModelPostProcess:!1,isBatchOverlapEnable:!1,numOverlapBatches:200,enableTranspose:!0,enableCrop:!0,cropPadding:0,autoThreshold:0,enableQuantileNorm:!1,filterOutWithPreMask:!1,enableSeqConv:!0,textureSize:0,warning:"This model may need dedicated graphics card. For more info please check with Browser Resources .",inferenceDelay:100,description:"FreeSurfer aparc+aseg atlas 104 parcellate brain areas into 104 regions. It contains a combination of the Desikan-Killiany atlas for cortical area and also segmentation of subcortical regions. The model use sequential convolution for inference to overcome browser memory limitations but leads to longer computation time. "}];async function getModelNumParameters(a){let n=0;for(let s=0;se-F);const m=tensor1d(f),A=m.shape[0],v=Math.floor(A*n),y=Math.ceil(A*s)-1,T=m.slice(v,1),I=m.slice(y,1),S=(await T.array())[0],E=(await I.array())[0];return u.dispose(),m.dispose(),T.dispose(),I.dispose(),{qmin:S,qmax:E}}async function quantileNormalizeVolumeData(a,n=.05,s=.95){const{qmin:u,qmax:f}=await calculateQuantiles(a,n,s),m=scalar(u),A=scalar(f),v=a.sub(m).div(A.sub(m));return m.dispose(),A.dispose(),v}async function minMaxNormalizeVolumeData(a){const n=a.max(),s=a.min();return await a.sub(s).div(n.sub(s))}async function inferenceFullVolumeSeqCovLayer(a,n,s,u,f,m,A){window.alert("inferenceFullVolumeSeqCovLayer() is not dead code?")}async function inferenceFullVolume(a,n,s,u,f,m,A){window.alert("inferenceFullVolume() is not dead code?")}async function inferenceSubVolumes(a,n,s,u,f,m=null){window.alert("inferenceSubVolumes() is not dead code?")}async function tensor2LightBuffer(a,n){window.alert("tensor2LightBuffer() is not dead code?")}async function draw3dObjBoundingVolume(a){window.alert("draw3dObjBoundingVolume() is not dead code?")}async function argMaxLarge(a,n,s,u,f,m="float32"){window.alert("argMaxLarge() is not dead code?")}async function addZeroPaddingTo3dTensor(a,n=[1,1],s=[1,1],u=[1,1]){if(a.rank!==3)throw new Error("Tensor must be 3D");return a.pad([n,s,u])}async function removeZeroPaddingFrom3dTensor(a,n=1,s=1,u=1){if(a.rank!==3)throw new Error("Tensor must be 3D");let f,m,A;return[f,m,A]=a.shape,a.slice([n,s,u],[f-2*n,m-2*s,A-2*u])}async function resizeWithZeroPadding(a,n,s,u,f,m){const A=f[0],v=f[1],y=f[2],T=A+m[0]-1,I=v+m[1]-1,S=y+m[2]-1,E=s-T-1>0?s-T-1:0,e=u-I-1>0?u-I-1:0,F=n-S-1>0?n-S-1:0;return a.pad([[A,E],[v,e],[y,F]])}async function applyMriThreshold(a,n){const s=a.max(),u=s.mul(n),f=await u.data();return s.dispose(),u.dispose(),tidy(()=>a.clone().greater(f[0]))}async function binarizeVolumeDataTensor(a){return a.step(0)}async function generateBrainMask(a,n,s,u,f,m,A,v,y=!0){console.log("Generate Brain Masking ... ");let T=[];for(let F=0;F{const F="postProcessSlices3D() should be upgraded to BWLabeler";A(F,-1,F)}),console.log("Post processing done ")):console.log("Phase-1 Post processing disabled ... ");const S=new Array(T[0].length*T.length);let E=0;for(let F=0;F{const z=a.slice([0,0,0,0,L],[-1,-1,-1,-1,V-L]),b=n.slice([0,0,0,L,I],[-1,-1,-1,V-L,1]);return conv3d(z,b,u,f,"NDHWC",m)});if(e===null)e=B;else{const z=e.add(B);e.dispose(),B.dispose(),e=z}}}const F=e.add(E);if(e.dispose(),E.dispose(),T==null)T=F;else{const M=await concat$2([T,F],4);F.dispose(),T.dispose(),T=M}}return T}function processTensorInChunks(a,n,s){const A=a.shape[4],v=Math.ceil(A/s);let y=null;for(let T=0;Ta.slice([0,0,0,0,I],[-1,-1,-1,-1,E])),F=tidy(()=>n.slice([0,0,0,I,0],[-1,-1,-1,E,-1])),M=conv3d(e,F,1,0,"NDHWC",1);e.dispose(),F.dispose();const L=squeeze(M);if(M.dispose(),y===null)y=L;else{const V=y.add(L);y.dispose(),y!==L&&L.dispose(),y=V}tidy(()=>{matMul$1(zeros$1([1,1]),zeros$1([1,1]))})}return y}class SequentialConvLayer{constructor(n,s,u,f){this.model=n,this.outChannels=n.outputLayers[0].kernel.shape[4],this.chunkSize=s,this.isChannelLast=u,this.callbackUI=f}async apply(n){const s=ENV$4.get("WEBGL_DELETE_TEXTURE_THRESHOLD");ENV$4.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0);const u=this;return new Promise(f=>{const m=performance.now(),A=u.model.layers[u.model.layers.length-1],v=A.getWeights()[0],y=A.getWeights()[1],T=u.isChannelLast?n.shape.slice(1,-1):n.shape.slice(2);let I=mul(ones(T),-1e4),S=zeros$1(T),E=0;console.log(" channel loop");const e=window.setInterval(async function(){engine().startScope(),console.log("=======================");const F=await memory();console.log(`| Number of Tensors: ${F.numTensors}`),console.log(`| Number of Data Buffers: ${F.numDataBuffers}`),console.log("Channel : ",E);const M=await tidy(()=>{const V=v.slice([0,0,0,0,E],[-1,-1,-1,-1,1]),B=y.slice([E],[1]),z=processTensorInChunks(n,V,Math.min(u.chunkSize,u.outChannels)).add(B),b=greater$2(z,I),W=where(b,z,I),q=where(b,fill$2(S.shape,E),S);return dispose([I,S,V,B,z,b]),tidy(()=>matMul$1(ones([1,1]),ones([1,1]))),[q,W]});console.log("=======================");const L=await memory();if(u.callbackUI(`Iteration ${E}`,E/u.outChannels),console.log(`Number of Tensors: ${L.numTensors}`),console.log(`Number of Data Buffers: ${L.numDataBuffers}`),console.log(`Megabytes In Use: ${(L.numBytes/1048576).toFixed(3)} MB`),L.unreliable&&console.log(`Unreliable: ${L.unreliable}`),typeof S<"u"&&S.dispose(),typeof I<"u"&&I.dispose(),S=keep(M[0]),I=keep(M[1]),engine().endScope(),E===u.outChannels-1){window.clearInterval(e),dispose(I);const B=performance.now()-m;console.log(`Execution time for output layer: ${B} milliseconds`),ENV$4.set("WEBGL_DELETE_TEXTURE_THRESHOLD",s),f(S)}else{E++;const V=S.shape,B=S.dataSync(),z=S.shape,b=I.dataSync();S.dispose(),I.dispose(),S=tensor(B,V),I=tensor(b,z)}await new Promise(V=>setTimeout(V,300))},0)})}}async function generateOutputSlicesV2(a,n,s,u,f,m,A,v,y,T){if(y.isPostProcessEnable){const E=new BWLabeler,e=new Uint32Array(n),F=26,M=!0,L=!0,[V,B]=E.bwlabel(a,e,F,M,L);for(let z=0;z0&&re<=1?e=await applyMriThreshold(u,re):(console.log("No valid crop threshold value"),e=await u.greater([0]).asType("bool"))}else e=await v.greater([0]).asType("bool");console.log(" mask_3d shape : ",e.shape);const F=await whereAsync(e);e.dispose();const M=F.arraySync();let L=m,V=0,B=A,z=0,b=f,W=0;for(let re=0;reM[re][0]?L=M[re][0]:VM[re][1]?B=M[re][1]:zM[re][2]?b=M[re][2]:Where'),memory().unreliable){const ae="unreliable reasons :"+memory().reasons;y(ae,NaN,ae)}}}async function inferenceFullVolumePhase2(a,n,s,u,f,m,A,v,y,T,I,S){let E=[];console.log(" ---- Start FullVolume inference phase-II ---- "),A.enableQuantileNorm?(console.log("preModel Quantile normalization enabled"),n=await quantileNormalizeVolumeData(n)):(console.log("preModel Min Max normalization enabled"),n=await minMaxNormalizeVolumeData(n));let F;if(m==null){const pe=A.autoThreshold;pe>0&&pe<=1?F=await applyMriThreshold(n,pe):(console.log("No valid crop threshold value"),F=await n.greater([0]).asType("bool"))}else F=m.greater([0]).asType("bool");console.log(" mask_3d shape : ",F.shape);const M=await whereAsync(F);F.dispose();const L=M.arraySync();let V=u,B=0,z=f,b=0,W=s,q=0;for(let pe=0;peL[pe][0]?V=L[pe][0]:BL[pe][1]?z=L[pe][1]:bL[pe][2]?W=L[pe][2]:qhere')}}async function inferenceFullVolumePhase1(a,n,s,u,f,m,A,v,y,T,I,S){if(v.No_SubVolumes=1,A.preModelId){const E=await load_model(y.rootURL+inferenceModelsList[A.preModelId-1].path),e=inferenceModelsList[A.preModelId-1].enableTranspose,F=inferenceModelsList[A.preModelId-1].enableQuantileNorm;let M=null;F?(console.log("preModel Quantile normalization enabled"),M=await quantileNormalizeVolumeData(n)):(console.log("preModel Min Max normalization enabled"),M=await minMaxNormalizeVolumeData(n)),e?(M=await M.transpose(),console.log("Input transposed for pre-model")):console.log("Transpose not enabled for pre-model"),v.Brainchop_Ver="PreModel_FV";const L=await E;try{const V=performance.now(),B=L,z=B.layers[0].batchInputShape;if(console.log(" Pre-Model batch input shape : ",z),z.length!==5){const Se="The pre-model input shape must be 5D ";return I(Se,-1,Se),0}const b=isModelChnlLast(B),W=y.batchSize,q=y.numOfChan;let Y,X,H,g;if(b){if(console.log("Pre-Model Channel Last"),isNaN(z[4])||z[4]!==1){const Se="The number of channels for pre-model input shape must be 1";return I(Se,-1,Se),0}Y=z[1],X=z[2],H=z[3],g=[W,Y,X,H,q]}else{if(console.log("Pre-Model Channel First"),isNaN(z[1])||z[1]!==1){const Se="The number of channels for pre-model input shape must be 1";return I(Se,-1,Se),0}Y=z[2],X=z[3],H=z[4],g=[W,q,Y,X,H]}v.Input_Shape=JSON.stringify(g),v.Output_Shape=JSON.stringify(B.output.shape),v.Channel_Last=b,v.Model_Param=await getModelNumParameters(B),v.Model_Layers=await getModelNumLayers(B);let J=0;const re=inferenceModelsList[A.preModelId-1].inferenceDelay;let ae=1;const fe=L.layers.length,pe=[];pe[0]=M.reshape(g),dispose(M);const me=window.setInterval(async function(){try{pe[ae]=L.layers[ae].apply(pe[ae-1])}catch(Se){const ve="Your graphics card (e.g. Intel) may not be compatible with WebGL. "+Se.message;return I(ve,-1,ve),window.clearInterval(me),engine().endScope(),engine().disposeVariables(),v.Inference_t=1/0,v.Postprocess_t=1/0,v.Status="Fail",v.Error_Type=Se.message,v.Extra_Err_Info="PreModel Failed while model layer "+ae+" apply",I("",-1,"",v),0}if(L.layers[ae].dispose(),pe[ae-1].dispose(),I("Layer "+ae.toString(),(ae+1)/fe),memory().unreliable){const Se="unreliable reasons :"+memory().reasons;I(Se,NaN,Se)}if(ae===fe-1){window.clearInterval(me);const Se=b?-1:1;console.log(" find argmax "),console.log("last Tensor shape : ",pe[ae].shape);const ve=b?pe[ae].shape[4]:pe[ae].shape[1];let we;try{console.log(" Try tf.argMax for fullVolume .."),we=await argMax$2(pe[ae],Se)}catch(pt){if(Se===-1)try{const It=performance.now();console.log(" tf.argMax failed .. try argMaxLarge ..");const Lt=tensor2LightBuffer(pe[ae].reshape([s,u,f,ve]),"float16");we=argMaxLarge(Lt,s,u,f,ve,"float16"),console.log("argMaxLarge for fullVolume takes : ",((performance.now()-It)/1e3).toFixed(4))}catch(It){const Lt="argMax buffer couldn't be created due to limited memory resources.";return I(Lt,-1,Lt),we.dispose(),window.clearInterval(me),engine().endScope(),engine().disposeVariables(),v.Inference_t=1/0,v.Postprocess_t=1/0,v.Status="Fail",v.Error_Type=It.message,v.Extra_Err_Info="preModel prediction_argmax from argMaxLarge failed",I("",-1,"",v),0}else{const It="argMax buffer couldn't be created due to limited memory resources.";return I(It,-1,It),we.dispose(),window.clearInterval(me),engine().endScope(),engine().disposeVariables(),v.Inference_t=1/0,v.Postprocess_t=1/0,v.Status="Fail",v.Error_Type=pt.message,v.Extra_Err_Info="preModel prediction_argmax from argMaxLarge not support yet channel first",I("",-1,"",v),0}}console.log(" Pre-model prediction_argmax shape : ",we.shape);const Ne=((performance.now()-V)/1e3).toFixed(4);dispose(pe[ae]),console.log(" Pre-model find array max ");const De=await we.max().dataSync()[0];Jhere')}}else console.log("--- No pre-model is selected ---"),console.log("------ Run voxel cropping ------"),m?A.enableSeqConv?(console.log("------ Seq Convoluton ------"),await inferenceFullVolumeSeqCovLayerPhase2(y,A,a,n,s,u,f,null,I,T,v,S)):inferenceFullVolumePhase2(a,n,s,u,f,null,A,v,y,T,I,S):inferenceSubVolumes(a,n,s,u,f,null)}async function enableProductionMode(a=!0){await enableProdMode(),env().set("DEBUG",!1),env().set("WEBGL_FORCE_F16_TEXTURES",a),env().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0),await ready(),console.log("tf env() flags :",env().flags),console.log("tf env() features :",env().features),console.log("tf env total features: ",Object.keys(env().features).length),console.log(getBackend())}async function runInference(a,n,s,u,f,m){const A=[];A.startTime=Date.now(),m("Segmentation started",0),performance.now();const v=a.batchSize,y=a.numOfChan;if(isNaN(v)||v!==1){const H="The batch Size for input shape must be 1";return m(H,-1,H),0}if(isNaN(y)||y!==1){const H="The number of channels for input shape must be 1";return m(H,-1,H),0}engine().startScope(),console.log("Batch size: ",v),console.log("Num of Channels: ",y);const T=await load_model(a.rootURL+n.path);await enableProductionMode(!0),A.TF_Backend=getBackend();const I=T;let S=[];if(S=I.layers[0].batchInputShape,console.log(" Model batch input shape : ",S),S.length!==5){const H="The model input shape must be 5D";return m(H,-1,H),0}let E,e,F;const M=s.dims[1],L=s.dims[2],V=s.dims[3];if(await isModelChnlLast(I)){if(console.log("Model Channel Last"),isNaN(S[4])||S[4]!==1){const H="The number of channels for input shape must be 1";return m(H,-1,H),0}E=S[1],e=S[2],F=S[3]}else{if(console.log("Model Channel First"),isNaN(S[1])||S[1]!==1){const H="The number of channels for input shape must be 1";return m(H,-1,H),0}E=S[2],e=S[3],F=S[4]}let z;E===256&&e===256&&F===256?z=!0:z=!1,A.isModelFullVol=z;let b=await getAllSlicesData1D(V,s,u);const W=await getAllSlices2D(b,L,M);b=null;let q=await getSlices3D(W);dispose(W);const Y=n.enableTranspose,X=n.enableCrop;z&&(X?await inferenceFullVolumePhase1(T,q,V,L,M,z,n,A,a,f,m,u):(console.log("Cropping Disabled"),Y?(q=q.transpose(),console.log("Input transposed")):console.log("Transpose NOT Enabled"),n.enableSeqConv?(console.log("Seq Convoluton Enabled"),await inferenceFullVolumeSeqCovLayer()):(console.log("Seq Convoluton Disabled"),await inferenceFullVolume())))}async function detectBrowser(){return navigator.userAgent.indexOf("OPR/")>-1?"Opera":navigator.userAgent.indexOf("Edg/")>-1?"Edge":navigator.userAgent.indexOf("Falkon/")>-1?"Falkon":navigator.userAgent.indexOf("Chrome/")>-1?"Chrome":navigator.userAgent.indexOf("Firefox/")>-1?"Firefox":navigator.userAgent.indexOf("Safari/")>-1?"Safari":navigator.userAgent.indexOf("MSIE/")>-1||navigator.userAgent.indexOf("rv:")>-1?"IExplorer":"Unknown"}async function detectBrowserVersion(){return navigator.userAgent.indexOf("OPR/")>-1?parseInt(navigator.userAgent.split("OPR/")[1]):navigator.userAgent.indexOf("Edg/")>-1?parseInt(navigator.userAgent.split("Edg/")[1]):navigator.userAgent.indexOf("Falkon/")>-1?parseInt(navigator.userAgent.split("Falkon/")[1]):navigator.userAgent.indexOf("Chrome/")>-1?parseInt(navigator.userAgent.split("Chrome/")[1]):navigator.userAgent.indexOf("Firefox/")>-1?parseInt(navigator.userAgent.split("Firefox/")[1]):navigator.userAgent.indexOf("Safari/")>-1?parseInt(navigator.userAgent.split("Safari/")[1]):navigator.userAgent.indexOf("MSIE/")>-1||navigator.userAgent.indexOf("rv:")>-1?parseInt(navigator.userAgent.split("MSIE/")[1]):1/0}async function detectOperatingSys(){return navigator.userAgent.indexOf("Win")>-1?"Windows":navigator.userAgent.indexOf("Mac")>-1?"MacOS":navigator.userAgent.indexOf("Linux")>-1?"Linux":navigator.userAgent.indexOf("UNIX")>-1?"UNIX":"Unknown"}async function checkWebGl2(a){return a?(console.log("WebGl2 is enabled"),!0):(typeof WebGL2RenderingContext<"u"||console.log("WebGL2 is not supported"),!1)}async function detectGPUVendor(a){let n;if(a&&(n=a.getExtension("WEBGL_debug_renderer_info"),n)){const s=a.getParameter(n.UNMASKED_VENDOR_WEBGL);return s.indexOf("(")>-1&&s.indexOf(")")>-1?s.substring(s.indexOf("(")+1,s.indexOf(")")):s}return null}async function detectGPUVendor_v0(a){if(a){const n=a.getExtension("WEBGL_debug_renderer_info");return n?a.getParameter(n.UNMASKED_VENDOR_WEBGL):null}else return null}async function detectGPUCardType_v0(a){if(a){if(detectBrowser()==="Firefox")return a.getParameter(a.RENDERER);const n=a.getExtension("WEBGL_debug_renderer_info");return n?a.getParameter(n.UNMASKED_RENDERER_WEBGL):null}else return null}async function detectGPUCardType(a){let n;if(a){if(detectBrowser()==="Firefox")return a.getParameter(a.RENDERER);if(n=a.getExtension("WEBGL_debug_renderer_info"),n){let s=a.getParameter(n.UNMASKED_RENDERER_WEBGL);return s.indexOf("(")>-1&&s.indexOf(")")>-1&&s.indexOf("(R)")===-1&&(s=s.substring(s.indexOf("(")+1,s.indexOf(")")),s.split(",").length===3)?s.split(",")[1].trim():s}}return null}async function getCPUNumCores(){return navigator.hardwareConcurrency}async function isChrome(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}async function localSystemDetails(a,n=null){const s=new Date;if(a.isModelFullVol?a.Brainchop_Ver="FullVolume":a.Brainchop_Ver="SubVolumes",a.Total_t=(Date.now()-a.startTime)/1e3,delete a.startTime,a.Date=parseInt(s.getMonth()+1)+"/"+s.getDate()+"/"+s.getFullYear(),a.Browser=await detectBrowser(),a.Browser_Ver=await detectBrowserVersion(),a.OS=await detectOperatingSys(),a.WebGL2=await checkWebGl2(n),a.GPU_Vendor=await detectGPUVendor(n),a.GPU_Card=await detectGPUCardType(n),a.GPU_Vendor_Full=await detectGPUVendor_v0(n),a.GPU_Card_Full=await detectGPUCardType_v0(n),a.CPU_Cores=await getCPUNumCores(),a.Which_Brainchop="latest",await isChrome()&&(a.Heap_Size_MB=window.performance.memory.totalJSHeapSize/(1024*1024).toFixed(2),a.Used_Heap_MB=window.performance.memory.usedJSHeapSize/(1024*1024).toFixed(2),a.Heap_Limit_MB=window.performance.memory.jsHeapSizeLimit/(1024*1024).toFixed(2)),n){console.log("MAX_TEXTURE_SIZE :",n.getParameter(n.MAX_TEXTURE_SIZE)),console.log("MAX_RENDERBUFFER_SIZE :",n.getParameter(n.MAX_RENDERBUFFER_SIZE));const u=n.getExtension("WEBGL_debug_renderer_info");console.log("VENDOR WEBGL:",n.getParameter(u.UNMASKED_VENDOR_WEBGL)),a.Texture_Size=n.getParameter(n.MAX_TEXTURE_SIZE)}else a.Texture_Size=null;return a}function WorkerWrapper(a){return new Worker(""+new URL("brainchop-webworker-CBK43U_A.js",import.meta.url).href,{name:a==null?void 0:a.name})}async function main(){smoothCheck.onchange=function(){I.setInterpolation(!smoothCheck.checked)},aboutBtn.onclick=function(){window.alert("BrainChop models https://github.com/neuroneural/brainchop")},diagnosticsBtn.onclick=function(){if(y.length<1){window.alert("No diagnostic string generated: run a model to create diagnostics");return}navigator.clipboard.writeText(y),window.alert(`Diagnostics copied to clipboard +`+y)},opacitySlider0.oninput=function(){I.setOpacity(0,opacitySlider0.value/255),I.updateGLVolume()},opacitySlider1.oninput=function(){I.setOpacity(1,opacitySlider1.value/255)};async function a(){let E=I.volumes[0],e=E.dims[1]===256&&E.dims[2]===256&&E.dims[3]===256;if((E.permRAS[0]!==-1||E.permRAS[1]!==3||E.permRAS[2]!==-2)&&(e=!1),e)return;let F=await I.conform(E,!1);I.removeVolume(I.volumes[0]),I.addVolume(F)}async function n(){for(;I.volumes.length>1;)await I.removeVolume(I.volumes[1])}modelSelect.onchange=async function(){this.selectedIndex<0&&(modelSelect.selectedIndex=11),await n(),await a();let E=inferenceModelsList[this.selectedIndex],e=brainChopOpts;if(e.rootURL=location.href,!!(window.location.hostname==="localhost"||window.location.hostname==="[::1]"||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/))&&(e.rootURL=location.protocol+"//"+location.host),workerCheck.checked){if(typeof T<"u"){console.log("Unable to start new segmentation: previous call has not completed");return}T=await new WorkerWrapper({type:"module"});let M={datatypeCode:I.volumes[0].hdr.datatypeCode,dims:I.volumes[0].hdr.dims},L={opts:e,modelEntry:E,niftiHeader:M,niftiImage:I.volumes[0].img};T.postMessage(L),T.onmessage=function(V){let B=V.data.cmd;B==="ui"&&(V.data.modalMessage!==""&&(T.terminate(),T=void 0),m(V.data.message,V.data.progressFrac,V.data.modalMessage,V.data.statData)),B==="img"&&(T.terminate(),T=void 0,u(V.data.img,V.data.opts,V.data.modelEntry))}}else runInference(e,E,I.volumes[0].hdr,I.volumes[0].img,u,m)},saveBtn.onclick=function(){I.volumes[1].saveToDisk("Custom.nii")},workerCheck.onchange=function(){modelSelect.onchange()},clipCheck.onchange=function(){clipCheck.checked?I.setClipPlane([0,0,90]):I.setClipPlane([2,0,90])};async function s(E){return await(await fetch(E)).json()}async function u(E,e,F){n();let M=await I.volumes[0].clone();if(M.zeroImage(),M.hdr.scl_inter=0,M.hdr.scl_slope=1,M.img=new Uint8Array(E),F.colormapPath){let L=await s(F.colormapPath);M.setColormapLabel(L),M.hdr.intent_code=1002}else{let L=e.atlasSelectedColorTable.toLowerCase();I.colormaps().includes(L)||(L="actc"),M.colormap=L}M.opacity=opacitySlider1.value/255,await I.addVolume(M)}async function f(E){(typeof E=="string"||E instanceof String)&&(E=function(M){const L=JSON.parse(M),V=[];for(const B in L)V[B]=L[B];return V}(E)),E=await localSystemDetails(E,I.gl),y=`:: Diagnostics can help resolve issues https://github.com/neuroneural/brainchop/issues :: `;for(var e in E)y+=e+": "+E[e]+` -`}function m(E="",e=-1,F="",M=[]){E!==""&&(console.log(E),document.getElementById("location").innerHTML=E),isNaN(e)?(memstatus.style.color="red",memstatus.innerHTML="Memory Issue"):e>=0&&(modelProgress.value=e*modelProgress.max),F!==""&&window.alert(F),Object.keys(M).length>0&&f(M)}function A(E){document.getElementById("location").innerHTML="  "+E.string}let v={backColor:[.4,.4,.4,1],show3Dcrosshair:!0,onLocationChange:A};var y="",T;let I=new Niivue(v);I.attachToCanvas(gl1),I.opts.dragMode=I.dragModes.pan,I.opts.multiplanarForceRender=!0,I.opts.yoke3Dto2DZoom=!0,I.opts.crosshairGap=11,await I.loadVolumes([{url:"./t1_crop.nii.gz"}]);for(let E=0;E=0&&(modelProgress.value=e*modelProgress.max),F!==""&&window.alert(F),Object.keys(M).length>0&&f(M)}function A(E){document.getElementById("location").innerHTML="  "+E.string}let v={backColor:[.4,.4,.4,1],show3Dcrosshair:!0,onLocationChange:A};var y="",T;let I=new Niivue(v);I.attachToCanvas(gl1),I.opts.dragMode=I.dragModes.pan,I.opts.multiplanarForceRender=!0,I.opts.yoke3Dto2DZoom=!0,I.opts.crosshairGap=11,smoothCheck.onchange(),await I.loadVolumes([{url:"./t1_crop.nii.gz"}]);for(let E=0;E Niivue brain chop - +
+ +