@getyoti/react-face-capture 0.6.0 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/README.md +97 -31
- package/index.css +1 -1
- package/index.js +1 -1
- package/index.js.LICENSE.txt +0 -23
- package/package.json +46 -21
- package/vanilla/index.css +1 -1
- package/vanilla/index.js +1 -1
- package/vanilla/index.js.LICENSE.txt +3 -3
- package/vanilla/index.js.map +1 -1
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=76)}([function(t,e,n){"use strict";(function(t,r,o,a){n.d(e,"a",(function(){return dt})),n.d(e,"b",(function(){return xt})),n.d(e,"c",(function(){return Ls})),n.d(e,"d",(function(){return Ku})),n.d(e,"e",(function(){return Ss})),n.d(e,"f",(function(){return kf})),n.d(e,"g",(function(){return qi})),n.d(e,"h",(function(){return gn})),n.d(e,"i",(function(){return Ru})),n.d(e,"j",(function(){return Ou})),n.d(e,"k",(function(){return zs})),n.d(e,"l",(function(){return Yi})),n.d(e,"m",(function(){return zn})),n.d(e,"n",(function(){return pn})),n.d(e,"o",(function(){return fl})),n.d(e,"p",(function(){return Ef})),n.d(e,"q",(function(){return Pu})),n.d(e,"r",(function(){return uc})),n.d(e,"s",(function(){return qu})),n.d(e,"t",(function(){return Qs})),n.d(e,"u",(function(){return ns})),n.d(e,"v",(function(){return qn})),n.d(e,"w",(function(){return gc})),n.d(e,"x",(function(){return er})),n.d(e,"y",(function(){return an})),n.d(e,"z",(function(){return Nu})),n.d(e,"A",(function(){return is})),n.d(e,"B",(function(){return Ju})),n.d(e,"C",(function(){return tc})),n.d(e,"D",(function(){return _r})),n.d(e,"E",(function(){return or})),n.d(e,"F",(function(){return ou})),n.d(e,"G",(function(){return rn})),n.d(e,"H",(function(){return sn})),n.d(e,"I",(function(){return un})),n.d(e,"J",(function(){return cn})),n.d(e,"K",(function(){return ln})),n.d(e,"L",(function(){return Pe})),n.d(e,"M",(function(){return ar})),n.d(e,"N",(function(){return xc})),n.d(e,"O",(function(){return sr})),n.d(e,"P",(function(){return hn}));var i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function s(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function u(t,e,n,r){return new(n||(n=Promise))((function(o,a){function i(t){try{u(r.next(t))}catch(t){a(t)}}function s(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){t.done?o(t.value):new n((function(e){e(t.value)})).then(i,s)}u((r=r.apply(t,e||[])).next())}))}function c(t,e){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}var l=function(){function t(t){this.global=t,this.flags={},this.flagRegistry={},this.urlFlags={},this.populateURLFlags()}return t.prototype.setPlatform=function(t,e){this.platform,this.platformName=t,this.platform=e},t.prototype.registerFlag=function(t,e,n){if(this.flagRegistry[t]={evaluationFn:e,setHook:n},null!=this.urlFlags[t]){var r=this.urlFlags[t];this.set(t,r)}},t.prototype.get=function(t){return t in this.flags||(this.flags[t]=this.evaluateFlag(t)),this.flags[t]},t.prototype.getNumber=function(t){return this.get(t)},t.prototype.getBool=function(t){return this.get(t)},t.prototype.getFlags=function(){return this.flags},Object.defineProperty(t.prototype,"features",{get:function(){return this.flags},enumerable:!0,configurable:!0}),t.prototype.set=function(t,e){if(null==this.flagRegistry[t])throw new Error("Cannot set flag "+t+" as it has not been registered.");this.flags[t]=e,null!=this.flagRegistry[t].setHook&&this.flagRegistry[t].setHook(e)},t.prototype.evaluateFlag=function(t){if(null==this.flagRegistry[t])throw new Error("Cannot evaluate flag '"+t+"': no evaluation function found.");return this.flagRegistry[t].evaluationFn()},t.prototype.setFlags=function(t){this.flags=Object.assign({},t)},t.prototype.reset=function(){this.flags={},this.urlFlags={},this.populateURLFlags()},t.prototype.populateURLFlags=function(){var t=this;if(void 0!==this.global&&void 0!==this.global.location&&void 0!==this.global.location.search){var e,n,r=(e=this.global.location.search,n={},e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return function(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"")}(n,e[0],e[1]),e.join("=")})),n);"tfjsflags"in r&&r.tfjsflags.split(",").forEach((function(e){var n=e.split(":"),r=n[0],o=n[1];t.urlFlags[r]=function(t,e){if("true"===(e=e.toLowerCase())||"false"===e)return"true"===e;if(""+ +e===e)return+e;throw new Error("Could not parse value flag value "+e+" for flag "+t+".")}(r,o)}))}},t}();function f(){return h}var h=null,p=new Map;function d(t,e){var n=g(t,e);return p.get(n)}function v(t){for(var e=p.entries(),n=[];;){var r=e.next(),o=r.done,a=r.value;if(o)break;var i=a[0],s=a[1];i.split("_")[0]===t&&n.push(s)}return n}function m(t){var e=t.kernelName,n=t.backendName,r=g(e,n);if(p.has(r))throw new Error("The kernel '"+e+"' for backend '"+n+"' is already registered");p.set(r,t)}function g(t,e){return e+"_"+t}function y(t){for(var e=t.length,n=0,r=0;e>0;)r=Math.random()*e|0,n=t[--e],t[e]=t[r],t[r]=n}function b(t,e,n){return Math.max(t,Math.min(e,n))}function x(t){return t%2==0?t:t+1}function w(t){for(var e=0,n=0;n<t.length;n++)e+=t[n];return e}function E(t,e){if(!t)throw new Error("string"==typeof e?e:e())}function C(t,e,n){void 0===n&&(n=""),E(I(t,e),(function(){return n+" Shapes "+t+" and "+e+" must match"}))}function _(t){E(null!=t,(function(){return"The input to the tensor constructor must be a non-null value."}))}function k(t,e,n){if(void 0===e&&(e=[]),void 0===n&&(n=!1),null==e&&(e=[]),Array.isArray(t)||j(t)&&!n)for(var r=0;r<t.length;++r)k(t[r],e,n);else e.push(t);return e}function R(t){if(0===t.length)return 1;for(var e=t[0],n=1;n<t.length;n++)e*=t[n];return e}function I(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function S(t){return t%1==0}function A(t){if(null!=Math.tanh)return Math.tanh(t);if(t===1/0)return 1;if(t===-1/0)return-1;var e=Math.exp(2*t);return(e-1)/(e+1)}function O(t){var e=Math.ceil(Math.sqrt(t));return[e,Math.ceil(t/e)]}function T(t,e){return e<=t.length?t:t+" ".repeat(e-t.length)}function D(t,e,n){return void 0===e&&(e=function(t){return 0}),new Promise((function(r,o){var a=0,i=function(){if(t())r();else{var s=e(++a);null!=n&&a>=n?o():setTimeout(i,s)}};i()}))}function N(t,e){for(var n=1,r=-1,o=0;o<t.length;++o)if(t[o]>=0)n*=t[o];else if(-1===t[o]){if(-1!==r)throw Error("Shapes can only have 1 implicit size. Found -1 at dim "+r+" and dim "+o);r=o}else if(t[o]<0)throw Error("Shapes can not be < 0. Found "+t[o]+" at dim "+o);if(-1===r){if(e>0&&e!==n)throw Error("Size("+e+") must match the product of shape "+t);return t}if(0===n)throw Error("Cannot infer the missing size in ["+t+"] when there are 0 elements");if(e%n!=0)throw Error("The implicit shape can't be a fractional number. Got "+e+" / "+n);var a=t.slice();return a[r]=e/n,a}function F(t,e){var n=e.length;return E((t=null==t?e.map((function(t,e){return e})):[].concat(t)).every((function(t){return t>=-n&&t<n})),(function(){return"All values in axis param must be in range [-"+n+", "+n+") but got axis "+t})),E(t.every((function(t){return S(t)})),(function(){return"All values in axis param must be integers but got axis "+t})),t.map((function(t){return t<0?n+t:t}))}function M(t,e){for(var n=[],r=[],o=null!=e&&Array.isArray(e)&&0===e.length,a=null==e||o?null:F(e,t).sort(),i=0,s=0;s<t.length;++s){if(null!=a){if(a[i]===s&&1!==t[s])throw new Error("Can't squeeze axis "+s+" since its dim '"+t[s]+"' is not 1");(null==a[i]||a[i]>s)&&1===t[s]&&(n.push(t[s]),r.push(s)),a[i]<=s&&i++}1!==t[s]&&(n.push(t[s]),r.push(s))}return{newShape:n,keptDims:r}}function P(t,e){var n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else{if("bool"!==t)throw new Error("Unknown data type "+t);n=new Uint8Array(e)}return n}function B(t,e){var n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else if("bool"===t)n=new Uint8Array(e);else{if("string"!==t)throw new Error("Unknown data type "+t);n=new Array(e)}return n}function L(t,e){for(var n=0;n<t.length;n++){var r=t[n];if(isNaN(r)||!isFinite(r))throw Error("A tensor of type "+e+" being uploaded contains "+r+".")}}function W(t){return"bool"===t||"complex64"===t||"float32"===t||"int32"===t||"string"===t}function U(t,e){return!("complex64"===e||"float32"===e&&"complex64"!==t||"int32"===e&&"float32"!==t&&"complex64"!==t||"bool"===e&&"bool"===t)}function j(t){return t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array}function z(t){if("float32"===t||"int32"===t)return 4;if("complex64"===t)return 8;if("bool"===t)return 1;throw new Error("Unknown dtype "+t)}function V(t){if(null==t)return 0;var e=0;return t.forEach((function(t){return e+=t.length})),e}function G(t){return"string"==typeof t||t instanceof String}function H(t){return"boolean"==typeof t}function q(t){return"number"==typeof t}function K(t){return Array.isArray(t)?K(t[0]):t instanceof Float32Array?"float32":t instanceof Int32Array||t instanceof Uint8Array?"int32":q(t)?"float32":G(t)?"string":H(t)?"bool":"float32"}function X(t){return!!(t&&t.constructor&&t.call&&t.apply)}function $(t,e){for(var n=e;n<t;++n)if(t%n==0)return n;return t}function Y(t){var e=t.length;if(e<2)return[];var n=new Array(e-1);n[e-2]=t[e-1];for(var r=e-3;r>=0;--r)n[r]=n[r+1]*t[r+1];return n}function J(t,e,n){if("string"===e)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(t)&&(t=k(t)),n&&L(t,e),function(t,e){return t instanceof Float32Array&&"float32"===e||t instanceof Int32Array&&"int32"===e||t instanceof Uint8Array&&"bool"===e}(t,e))return t;if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e){for(var r=new Uint8Array(t.length),o=0;o<r.length;++o)0!==Math.round(t[o])&&(r[o]=1);return r}throw new Error("Unknown data type "+e)}function Q(t,e){if(0===t.length)return e[0];var n=t.reduce((function(t,e){return t*e}));if(0===n)return[];if(n!==e.length)throw new Error("["+t+"] does not match the input size.");return function t(e,n,r){var o=new Array;if(1===n.length)for(var a=n[0],i=0;i<a;i++)o[i]=r[e+i];else{a=n[0];var s=n.slice(1),u=s.reduce((function(t,e){return t*e}));for(i=0;i<a;i++)o[i]=t(e+i*u,s,r)}return o}(0,t,e)}function Z(t,e){for(var n=tt(t,e),r=0;r<n.length;r++)n[r]=1;return n}function tt(t,e){if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e)return new Uint8Array(t);throw new Error("Unknown data type "+e)}function et(){return f().platform.now()}function nt(t){t.forEach((function(e){E(Number.isInteger(e)&&e>=0,(function(){return"Tensor must have a shape comprised of positive integers but got shape ["+t+"]."}))}))}function rt(t,e){return void 0===e&&(e="utf-8"),e=e||"utf-8",f().platform.encode(t,e)}function ot(t,e){return void 0===e&&(e="utf-8"),e=e||"utf-8",f().platform.decode(t,e)}Object.freeze({shuffle:y,clamp:b,nearestLargerEven:x,sum:w,randUniform:function(t,e){var n=Math.random();return e*n+(1-n)*t},distSquared:function(t,e){for(var n=0,r=0;r<t.length;r++){var o=Number(t[r])-Number(e[r]);n+=o*o}return n},assert:E,assertShapesMatch:C,assertNonNull:_,flatten:k,sizeFromShape:R,isScalarShape:function(t){return 0===t.length},arraysEqual:I,isInt:S,tanh:A,sizeToSquarishShape:O,createShuffledIndices:function(t){for(var e=new Uint32Array(t),n=0;n<t;++n)e[n]=n;return y(e),e},rightPad:T,repeatedTry:D,inferFromImplicitShape:N,parseAxisParam:F,squeezeShape:M,getTypedArrayFromDType:P,getArrayFromDType:B,checkConversionForErrors:L,isValidDtype:W,hasEncodingLoss:U,isTypedArray:j,bytesPerElement:z,bytesFromStringArray:V,isString:G,isBoolean:H,isNumber:q,inferDtype:K,isFunction:X,nearestDivisor:$,computeStrides:Y,toTypedArray:J,toNestedArray:Q,makeOnesTypedArray:Z,makeZerosTypedArray:tt,now:et,assertNonNegativeIntegerDimensions:nt,fetch:function(t,e){return f().platform.fetch(t,e)},encodeString:rt,decodeString:ot});var at=function(){function t(t,e){this.backendTimer=t,this.logger=e,null==e&&(this.logger=new it)}return t.prototype.profileKernel=function(t,e,n){var r,o=this,a=this.backendTimer.time((function(){r=n()}));return r.forEach((function(n){n.data().then((function(r){!function(t,e,n){if("float32"!==e)return!1;for(var r=0;r<t.length;r++){var o=t[r];if(isNaN(o)||!isFinite(o))return!0}}(r,n.dtype),a.then((function(a){var i="";null!=a.getExtraProfileInfo&&(i=a.getExtraProfileInfo()),o.logger.logKernelProfile(t,n,r,a.kernelMs,e,i)}))}))})),r},t}(),it=function(){function t(){}return t.prototype.logKernelProfile=function(t,e,n,r,o,a){T(r+"ms",9),T(t,25),e.rank,e.size,T(e.shape.toString(),14);for(var i in o){var s=o[i].shape,u=s.length;i+": "+u+"D "+(u>0?s:"")+" "}},t}();function st(t,e,n){return T(Array.isArray(t)?parseFloat(t[0].toFixed(7))+" + "+parseFloat(t[1].toFixed(7))+"j":G(t)?"'"+t+"'":"bool"===n?ut(t):parseFloat(t.toFixed(7)).toString(),e)}function ut(t){return 0===t?"false":"true"}function ct(t){for(var e=[],n=0;n<t.length;n+=2)e.push([t[n],t[n+1]]);return e}var lt=function(){function t(t,e,n){var r=this;if(this.dtype=e,this.shape=t.slice(),this.size=R(t),null!=n){var o=n.length;E(o===this.size,(function(){return"Length of values '"+o+"' does not match the size inferred by the shape '"+r.size+"'."}))}if("complex64"===e)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||B(e,this.size),this.strides=Y(t)}return t.prototype.set=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];0===n.length&&(n=[0]),E(n.length===this.rank,(function(){return"The number of provided coordinates ("+n.length+") must match the rank ("+e.rank+")"}));var o=this.locToIndex(n);this.values[o]=t},t.prototype.get=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];0===t.length&&(t=[0]);for(var n=0,r=0,o=t;r<o.length;r++){var a=o[r];if(a<0||a>=this.shape[n]){var i="Requested out of range element at "+t+". Buffer shape="+this.shape;throw new Error(i)}n++}for(var s=t[t.length-1],u=0;u<t.length-1;++u)s+=this.strides[u]*t[u];return this.values[s]},t.prototype.locToIndex=function(t){if(0===this.rank)return 0;if(1===this.rank)return t[0];for(var e=t[t.length-1],n=0;n<t.length-1;++n)e+=this.strides[n]*t[n];return e},t.prototype.indexToLoc=function(t){if(0===this.rank)return[];if(1===this.rank)return[t];for(var e=new Array(this.shape.length),n=0;n<e.length-1;++n)e[n]=Math.floor(t/this.strides[n]),t-=e[n]*this.strides[n];return e[e.length-1]=t,e},Object.defineProperty(t.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),t.prototype.toTensor=function(){return ft().makeTensor(this.values,this.shape,this.dtype)},t}(),ft=null,ht=null,pt=null,dt=function(){function t(t,e,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=t.slice(),this.dtype=e||"float32",this.size=R(t),this.strides=Y(t),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}return t.prototype.flatten=function(){return this.throwIfDisposed(),this.as1D()},t.prototype.asScalar=function(){return this.throwIfDisposed(),E(1===this.size,(function(){return"The array must have only 1 element."})),this.reshape([])},t.prototype.as1D=function(){return this.throwIfDisposed(),this.reshape([this.size])},t.prototype.as2D=function(t,e){return this.throwIfDisposed(),this.reshape([t,e])},t.prototype.as3D=function(t,e,n){return this.throwIfDisposed(),this.reshape([t,e,n])},t.prototype.as4D=function(t,e,n,r){return this.throwIfDisposed(),this.reshape([t,e,n,r])},t.prototype.as5D=function(t,e,n,r,o){return this.throwIfDisposed(),this.reshape([t,e,n,r,o])},t.prototype.asType=function(t){return this.throwIfDisposed(),ht.cast(this,t)},Object.defineProperty(t.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),t.prototype.buffer=function(){return u(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return[4,this.data()];case 1:return t=e.sent(),[2,ht.buffer(this.shape,this.dtype,t)]}}))}))},t.prototype.bufferSync=function(){return ht.buffer(this.shape,this.dtype,this.dataSync())},t.prototype.array=function(){return u(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return[4,this.data()];case 1:return t=e.sent(),[2,Q(this.shape,t)]}}))}))},t.prototype.arraySync=function(){return Q(this.shape,this.dataSync())},t.prototype.data=function(){return u(this,void 0,void 0,(function(){var t,e;return c(this,(function(n){switch(n.label){case 0:return this.throwIfDisposed(),t=ft().read(this.dataId),"string"!==this.dtype?[3,2]:[4,t];case 1:e=n.sent();try{return[2,e.map((function(t){return ot(t)}))]}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}n.label=2;case 2:return[2,t]}}))}))},t.prototype.dataSync=function(){this.throwIfDisposed();var t=ft().readSync(this.dataId);if("string"===this.dtype)try{return t.map((function(t){return ot(t)}))}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return t},t.prototype.bytes=function(){return u(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return this.throwIfDisposed(),[4,ft().read(this.dataId)];case 1:return t=e.sent(),"string"===this.dtype?[2,t]:[2,new Uint8Array(t.buffer)]}}))}))},t.prototype.dispose=function(){this.isDisposed||(ft().disposeTensor(this),this.isDisposedInternal=!0)},Object.defineProperty(t.prototype,"isDisposed",{get:function(){return this.isDisposedInternal},enumerable:!0,configurable:!0}),t.prototype.throwIfDisposed=function(){if(this.isDisposed)throw new Error("Tensor is disposed.")},t.prototype.toFloat=function(){return this.asType("float32")},t.prototype.toInt=function(){return this.asType("int32")},t.prototype.toBool=function(){return this.asType("bool")},t.prototype.print=function(t){return void 0===t&&(t=!1),ht.print(this,t)},t.prototype.reshape=function(t){return this.throwIfDisposed(),ht.reshape(this,t)},t.prototype.reshapeAs=function(t){return this.throwIfDisposed(),this.reshape(t.shape)},t.prototype.expandDims=function(t){return void 0===t&&(t=0),ht.expandDims(this,t)},t.prototype.cumsum=function(t,e,n){return void 0===t&&(t=0),void 0===e&&(e=!1),void 0===n&&(n=!1),ht.cumsum(this,t,e,n)},t.prototype.squeeze=function(t){return this.throwIfDisposed(),ht.squeeze(this,t)},t.prototype.clone=function(){return this.throwIfDisposed(),ht.clone(this)},t.prototype.oneHot=function(t,e,n){return this.throwIfDisposed(),ht.oneHot(this,t,e,n)},t.prototype.toString=function(t){return void 0===t&&(t=!1),function(t,e,n,r){var o=Y(e),a=function(t,e,n,r){var o=R(e),a=r[r.length-1],i=new Array(a).fill(0),s=e.length,u="complex64"===n?ct(t):t;if(s>1)for(var c=0;c<o/a;c++)for(var l=c*a,f=0;f<a;f++)i[f]=Math.max(i[f],st(u[l+f],0,n).length);return i}(t,e,n,o),i=e.length,s=function t(e,n,r,o,a,i){void 0===i&&(i=!0);var s="complex64"===r?2:1,u=n[0],c=n.length;if(0===c)return"complex64"===r?[st(ct(e)[0],0,r)]:"bool"===r?[ut(e[0])]:[e[0].toString()];if(1===c){if(u>20){var l=3*s,f=Array.from(e.slice(0,l)),h=Array.from(e.slice((u-3)*s,u*s));return"complex64"===r&&(f=ct(f),h=ct(h)),["["+f.map((function(t,e){return st(t,a[e],r)})).join(", ")+", ..., "+h.map((function(t,e){return st(t,a[u-3+e],r)})).join(", ")+"]"]}return["["+("complex64"===r?ct(e):Array.from(e)).map((function(t,e){return st(t,a[e],r)})).join(", ")+"]"]}var p=n.slice(1),d=o.slice(1),v=o[0]*s,m=[];if(u>20){for(var g=0;g<3;g++){var y=(b=g*v)+v;m.push.apply(m,t(e.slice(b,y),p,r,d,a,!1))}m.push("...");for(g=u-3;g<u;g++){y=(b=g*v)+v;m.push.apply(m,t(e.slice(b,y),p,r,d,a,g===u-1))}}else for(g=0;g<u;g++){var b;y=(b=g*v)+v;m.push.apply(m,t(e.slice(b,y),p,r,d,a,g===u-1))}var x=2===c?",":"";m[0]="["+m[0]+x;for(g=1;g<m.length-1;g++)m[g]=" "+m[g]+x;var w=",\n";for(g=2;g<c;g++)w+="\n";return m[m.length-1]=" "+m[m.length-1]+"]"+(i?"":w),m}(t,e,n,o,a),u=["Tensor"];return r&&(u.push(" dtype: "+n),u.push(" rank: "+i),u.push(" shape: ["+e+"]"),u.push(" values:")),u.push(s.map((function(t){return" "+t})).join("\n")),u.join("\n")}(this.dataSync(),this.shape,this.dtype,t)},t.prototype.tile=function(t){return this.throwIfDisposed(),ht.tile(this,t)},t.prototype.gather=function(t,e){return void 0===e&&(e=0),this.throwIfDisposed(),ht.gather(this,t,e)},t.prototype.matMul=function(t,e,n){return void 0===e&&(e=!1),void 0===n&&(n=!1),this.throwIfDisposed(),ht.matMul(this,t,e,n)},t.prototype.dot=function(t){return this.throwIfDisposed(),ht.dot(this,t)},t.prototype.norm=function(t,e,n){return void 0===t&&(t="euclidean"),void 0===e&&(e=null),void 0===n&&(n=!1),this.throwIfDisposed(),ht.norm(this,t,e,n)},t.prototype.slice=function(t,e){return this.throwIfDisposed(),ht.slice(this,t,e)},t.prototype.reverse=function(t){return this.throwIfDisposed(),ht.reverse(this,t)},t.prototype.concat=function(e,n){return void 0===n&&(n=0),this.throwIfDisposed(),e instanceof t&&(e=[e]),ht.concat([this].concat(e),n)},t.prototype.split=function(t,e){return void 0===e&&(e=0),this.throwIfDisposed(),ht.split(this,t,e)},t.prototype.stack=function(t,e){return void 0===e&&(e=0),ht.stack([this,t],e)},t.prototype.unstack=function(t){return void 0===t&&(t=0),ht.unstack(this,t)},t.prototype.pad=function(t,e){return void 0===e&&(e=0),ht.pad(this,t,e)},t.prototype.batchNormalization=function(t,e,n,r,o){return void 0===n&&(n=.001),pt("tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon"),this.batchNorm(t,e,o,r,n)},t.prototype.batchNorm=function(t,e,n,r,o){return void 0===o&&(o=.001),this.throwIfDisposed(),ht.batchNorm(this,t,e,n,r,o)},t.prototype.all=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),ht.all(this,t,e)},t.prototype.any=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),ht.any(this,t,e)},t.prototype.logSumExp=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),ht.logSumExp(this,t,e)},t.prototype.sum=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),ht.sum(this,t,e)},t.prototype.prod=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),ht.prod(this,t,e)},t.prototype.mean=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),ht.mean(this,t,e)},t.prototype.min=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),ht.min(this,t,e)},t.prototype.max=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),ht.max(this,t,e)},t.prototype.argMin=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),ht.argMin(this,t)},t.prototype.argMax=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),ht.argMax(this,t)},t.prototype.cast=function(t){return this.throwIfDisposed(),ht.cast(this,t)},t.prototype.add=function(t){return this.throwIfDisposed(),ht.add(this,t)},t.prototype.addStrict=function(t){return this.throwIfDisposed(),ht.addStrict(this,t)},t.prototype.atan2=function(t){return this.throwIfDisposed(),ht.atan2(this,t)},t.prototype.sub=function(t){return this.throwIfDisposed(),ht.sub(this,t)},t.prototype.subStrict=function(t){return this.throwIfDisposed(),ht.subStrict(this,t)},t.prototype.pow=function(t){return this.throwIfDisposed(),ht.pow(this,t)},t.prototype.powStrict=function(t){return this.throwIfDisposed(),ht.powStrict(this,t)},t.prototype.mul=function(t){return this.throwIfDisposed(),ht.mul(this,t)},t.prototype.mulStrict=function(t){return this.throwIfDisposed(),ht.mulStrict(this,t)},t.prototype.div=function(t){return this.throwIfDisposed(),ht.div(this,t)},t.prototype.divNoNan=function(t){return this.throwIfDisposed(),ht.divNoNan(this,t)},t.prototype.floorDiv=function(t){return this.throwIfDisposed(),ht.floorDiv(this,t)},t.prototype.divStrict=function(t){return this.throwIfDisposed(),ht.divStrict(this,t)},t.prototype.minimum=function(t){return this.throwIfDisposed(),ht.minimum(this,t)},t.prototype.minimumStrict=function(t){return this.throwIfDisposed(),ht.minimumStrict(this,t)},t.prototype.maximum=function(t){return this.throwIfDisposed(),ht.maximum(this,t)},t.prototype.maximumStrict=function(t){return this.throwIfDisposed(),ht.maximumStrict(this,t)},t.prototype.mod=function(t){return this.throwIfDisposed(),ht.mod(this,t)},t.prototype.modStrict=function(t){return this.throwIfDisposed(),ht.modStrict(this,t)},t.prototype.squaredDifference=function(t){return this.throwIfDisposed(),ht.squaredDifference(this,t)},t.prototype.squaredDifferenceStrict=function(t){return this.throwIfDisposed(),ht.squaredDifferenceStrict(this,t)},t.prototype.transpose=function(t){return this.throwIfDisposed(),ht.transpose(this,t)},t.prototype.notEqual=function(t){return this.throwIfDisposed(),ht.notEqual(this,t)},t.prototype.notEqualStrict=function(t){return this.throwIfDisposed(),ht.notEqualStrict(this,t)},t.prototype.less=function(t){return this.throwIfDisposed(),ht.less(this,t)},t.prototype.lessStrict=function(t){return this.throwIfDisposed(),ht.lessStrict(this,t)},t.prototype.equal=function(t){return this.throwIfDisposed(),ht.equal(this,t)},t.prototype.equalStrict=function(t){return this.throwIfDisposed(),ht.equalStrict(this,t)},t.prototype.lessEqual=function(t){return this.throwIfDisposed(),ht.lessEqual(this,t)},t.prototype.lessEqualStrict=function(t){return this.throwIfDisposed(),ht.lessEqualStrict(this,t)},t.prototype.greater=function(t){return this.throwIfDisposed(),ht.greater(this,t)},t.prototype.greaterStrict=function(t){return this.throwIfDisposed(),ht.greaterStrict(this,t)},t.prototype.greaterEqual=function(t){return this.throwIfDisposed(),ht.greaterEqual(this,t)},t.prototype.greaterEqualStrict=function(t){return this.throwIfDisposed(),ht.greaterEqualStrict(this,t)},t.prototype.logicalAnd=function(t){return this.throwIfDisposed(),ht.logicalAnd(this,t)},t.prototype.logicalOr=function(t){return this.throwIfDisposed(),ht.logicalOr(this,t)},t.prototype.logicalNot=function(){return this.throwIfDisposed(),ht.logicalNot(this)},t.prototype.logicalXor=function(t){return this.throwIfDisposed(),ht.logicalXor(this,t)},t.prototype.where=function(t,e){return this.throwIfDisposed(),ht.where(t,this,e)},t.prototype.neg=function(){return this.throwIfDisposed(),ht.neg(this)},t.prototype.ceil=function(){return this.throwIfDisposed(),ht.ceil(this)},t.prototype.floor=function(){return this.throwIfDisposed(),ht.floor(this)},t.prototype.sign=function(){return this.throwIfDisposed(),ht.sign(this)},t.prototype.isNaN=function(){return this.throwIfDisposed(),ht.isNaN(this)},t.prototype.isInf=function(){return this.throwIfDisposed(),ht.isInf(this)},t.prototype.isFinite=function(){return this.throwIfDisposed(),ht.isFinite(this)},t.prototype.exp=function(){return this.throwIfDisposed(),ht.exp(this)},t.prototype.expm1=function(){return this.throwIfDisposed(),ht.expm1(this)},t.prototype.log=function(){return this.throwIfDisposed(),ht.log(this)},t.prototype.log1p=function(){return this.throwIfDisposed(),ht.log1p(this)},t.prototype.sqrt=function(){return this.throwIfDisposed(),ht.sqrt(this)},t.prototype.rsqrt=function(){return this.throwIfDisposed(),ht.rsqrt(this)},t.prototype.square=function(){return this.throwIfDisposed(),ht.square(this)},t.prototype.reciprocal=function(){return this.throwIfDisposed(),ht.reciprocal(this)},t.prototype.abs=function(){return this.throwIfDisposed(),ht.abs(this)},t.prototype.clipByValue=function(t,e){return this.throwIfDisposed(),ht.clipByValue(this,t,e)},t.prototype.relu=function(){return this.throwIfDisposed(),ht.relu(this)},t.prototype.relu6=function(){return this.throwIfDisposed(),ht.relu6(this)},t.prototype.elu=function(){return this.throwIfDisposed(),ht.elu(this)},t.prototype.selu=function(){return this.throwIfDisposed(),ht.selu(this)},t.prototype.leakyRelu=function(t){return void 0===t&&(t=.2),this.throwIfDisposed(),ht.leakyRelu(this,t)},t.prototype.prelu=function(t){return this.throwIfDisposed(),ht.prelu(this,t)},t.prototype.sigmoid=function(){return this.throwIfDisposed(),ht.sigmoid(this)},t.prototype.logSigmoid=function(){return this.throwIfDisposed(),ht.logSigmoid(this)},t.prototype.softplus=function(){return this.throwIfDisposed(),ht.softplus(this)},t.prototype.zerosLike=function(){return this.throwIfDisposed(),ht.zerosLike(this)},t.prototype.onesLike=function(){return this.throwIfDisposed(),ht.onesLike(this)},t.prototype.sin=function(){return this.throwIfDisposed(),ht.sin(this)},t.prototype.cos=function(){return this.throwIfDisposed(),ht.cos(this)},t.prototype.tan=function(){return this.throwIfDisposed(),ht.tan(this)},t.prototype.asin=function(){return this.throwIfDisposed(),ht.asin(this)},t.prototype.acos=function(){return this.throwIfDisposed(),ht.acos(this)},t.prototype.atan=function(){return this.throwIfDisposed(),ht.atan(this)},t.prototype.sinh=function(){return this.throwIfDisposed(),ht.sinh(this)},t.prototype.cosh=function(){return this.throwIfDisposed(),ht.cosh(this)},t.prototype.tanh=function(){return this.throwIfDisposed(),ht.tanh(this)},t.prototype.asinh=function(){return this.throwIfDisposed(),ht.asinh(this)},t.prototype.acosh=function(){return this.throwIfDisposed(),ht.acosh(this)},t.prototype.atanh=function(){return this.throwIfDisposed(),ht.atanh(this)},t.prototype.erf=function(){return this.throwIfDisposed(),ht.erf(this)},t.prototype.round=function(){return this.throwIfDisposed(),ht.round(this)},t.prototype.step=function(t){return void 0===t&&(t=0),this.throwIfDisposed(),ht.step(this,t)},t.prototype.softmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),ht.softmax(this,t)},t.prototype.logSoftmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),ht.logSoftmax(this,t)},t.prototype.resizeBilinear=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),ht.image.resizeBilinear(this,t,e)},t.prototype.resizeNearestNeighbor=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),ht.image.resizeNearestNeighbor(this,t,e)},t.prototype.conv1d=function(t,e,n,r,o,a){return void 0===r&&(r="NWC"),void 0===o&&(o=1),this.throwIfDisposed(),ht.conv1d(this,t,e,n,r,o,a)},t.prototype.conv2d=function(t,e,n,r,o,a){return void 0===r&&(r="NHWC"),void 0===o&&(o=[1,1]),this.throwIfDisposed(),ht.conv2d(this,t,e,n,r,o,a)},t.prototype.conv2dTranspose=function(t,e,n,r,o){return this.throwIfDisposed(),ht.conv2dTranspose(this,t,e,n,r,o)},t.prototype.depthwiseConv2D=function(t,e,n,r,o,a){return void 0===r&&(r="NHWC"),void 0===o&&(o=[1,1]),this.throwIfDisposed(),ht.depthwiseConv2d(this,t,e,n,r,o,a)},t.prototype.separableConv2d=function(t,e,n,r,o,a){return void 0===o&&(o=[1,1]),void 0===a&&(a="NHWC"),this.throwIfDisposed(),ht.separableConv2d(this,t,e,n,r,o,a)},t.prototype.avgPool=function(t,e,n,r){return this.throwIfDisposed(),ht.avgPool(this,t,e,n,r)},t.prototype.maxPool=function(t,e,n,r){return this.throwIfDisposed(),ht.maxPool(this,t,e,n,r)},t.prototype.localResponseNormalization=function(t,e,n,r){return void 0===t&&(t=5),void 0===e&&(e=1),void 0===n&&(n=1),void 0===r&&(r=.5),ht.localResponseNormalization(this,t,e,n,r)},t.prototype.pool=function(t,e,n,r,o){return this.throwIfDisposed(),ht.pool(this,t,e,n,r,o)},t.prototype.variable=function(t,e,n){return void 0===t&&(t=!0),this.throwIfDisposed(),ft().makeVariable(this,t,e,n)},t.prototype.unsortedSegmentSum=function(t,e){return this.throwIfDisposed(),ht.unsortedSegmentSum(this,t,e)},t.prototype.batchToSpaceND=function(t,e){return this.throwIfDisposed(),ht.batchToSpaceND(this,t,e)},t.prototype.spaceToBatchND=function(t,e){return this.throwIfDisposed(),ht.spaceToBatchND(this,t,e)},t.prototype.topk=function(t,e){return void 0===t&&(t=1),void 0===e&&(e=!0),this.throwIfDisposed(),ht.topk(this,t,e)},t.prototype.stridedSlice=function(t,e,n,r,o,a,i,s){return void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===i&&(i=0),void 0===s&&(s=0),this.throwIfDisposed(),ht.stridedSlice(this,t,e,n,r,o,a,i,s)},t.prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),ht.depthToSpace(this,t,e)},t.prototype.fft=function(){return this.throwIfDisposed(),ht.spectral.fft(this)},t.prototype.ifft=function(){return this.throwIfDisposed(),ht.spectral.ifft(this)},t.prototype.rfft=function(){return this.throwIfDisposed(),ht.spectral.rfft(this)},t.prototype.irfft=function(){return this.throwIfDisposed(),ht.spectral.irfft(this)},t}();Object.defineProperty(dt,Symbol.hasInstance,{value:function(t){return!!t&&null!=t.dataId&&null!=t.shape&&null!=t.dtype}});var vt,mt,gt,yt,bt,xt=function(t){function e(e,n,r,o){var a=t.call(this,e.shape,e.dtype,e.dataId,o)||this;return a.trainable=n,a.name=r,a}return s(e,t),e.prototype.assign=function(t){if(t.dtype!==this.dtype)throw new Error("dtype of the new value ("+t.dtype+") and previous value ("+this.dtype+") must match");if(!I(t.shape,this.shape))throw new Error("shape of the new value ("+t.shape+") and previous value ("+this.shape+") must match");ft().disposeTensor(this),this.dataId=t.dataId,ft().incRef(this,null)},e.prototype.dispose=function(){ft().disposeVariable(this),this.isDisposedInternal=!0},e}(dt);Object.defineProperty(xt,Symbol.hasInstance,{value:function(t){return t instanceof dt&&null!=t.assign&&t.assign instanceof Function}}),function(t){t.R0="R0",t.R1="R1",t.R2="R2",t.R3="R3",t.R4="R4",t.R5="R5",t.R6="R6"}(vt||(vt={})),function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64"}(mt||(mt={})),function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64"}(gt||(gt={})),function(t){t.float32="float32",t.int32="float32",t.bool="float32",t.complex64="complex64"}(yt||(yt={})),function(t){t.float32="complex64",t.int32="complex64",t.bool="complex64",t.complex64="complex64"}(bt||(bt={}));var wt={float32:yt,int32:mt,bool:gt,complex64:bt};function Et(t,e){if("string"===t||"string"===e){if("string"===t&&"string"===e)return"string";throw new Error("Can not upcast "+t+" with "+e)}return wt[t][e]}function Ct(t){return Et(t,"int32")}function _t(t,e){if(t.dtype===e.dtype)return[t,e];var n=Et(t.dtype,e.dtype);return[t.cast(n),e.cast(n)]}function kt(t,e){E(t.dtype===e.dtype,(function(){return"The dtypes of the first("+t.dtype+") and second("+e.dtype+") input must match"}))}function Rt(t){var e=[];return function t(e,n,r){if(null!=e)if(e instanceof dt)n.push(e);else if(o=e,Array.isArray(o)||"object"==typeof o){var o,a=e;for(var i in a){var s=a[i];r.has(s)||(r.add(s),t(s,n,r))}}}(t,e,new Set),e}Object.freeze({makeTypesMatch:_t,assertTypesMatch:kt,isTensorInList:function(t,e){for(var n=0;n<e.length;n++)if(e[n].id===t.id)return!0;return!1},getTensorsInContainer:Rt});var It,St=function(){function t(){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}}return t.prototype.dispose=function(){for(var t in this.registeredVariables)this.registeredVariables[t].dispose()},t}(),At=function(){function t(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new St}return t.prototype.ready=function(){return u(this,void 0,void 0,(function(){var t,e,n;return c(this,(function(r){switch(r.label){case 0:if(null!=this.pendingBackendInit)return[2,this.pendingBackendInit.then((function(){}))];if(null!=this.backendInstance)return[2];t=this.getSortedBackends(),e=0,r.label=1;case 1:return e<t.length?(n=t[e],[4,this.initializeBackend(n).success]):[3,5];case 2:return r.sent()?[4,this.setBackend(n)]:[3,4];case 3:return r.sent(),[2];case 4:return e++,[3,1];case 5:throw new Error("Could not initialize any backends, all backend initializations failed.")}}))}))},Object.defineProperty(t.prototype,"backend",{get:function(){if(null!=this.pendingBackendInit)throw new Error("Backend '"+this.backendName+"' has not yet been initialized. Make sure to await tf.ready() before calling other methods");if(null==this.backendInstance){var t=this.initializeBackendsAndReturnBest(),e=t.name;if(t.asyncInit)throw new Error("The highest priority backend '"+e+"' has not yet been initialized. Make sure to await tf.ready() before calling other methods");this.setBackend(e)}return this.backendInstance},enumerable:!0,configurable:!0}),t.prototype.backendNames=function(){return Object.keys(this.registryFactory)},t.prototype.findBackend=function(t){if(!(t in this.registry)){if(!(t in this.registryFactory))return null;if(this.initializeBackend(t).asyncInit)return null}return this.registry[t]},t.prototype.findBackendFactory=function(t){return t in this.registryFactory?this.registryFactory[t].factory:null},t.prototype.registerBackend=function(t,e,n){return void 0===n&&(n=1),!(t in this.registryFactory)&&(this.registryFactory[t]={factory:e,priority:n},!0)},t.prototype.setBackend=function(t){return u(this,void 0,void 0,(function(){var e,n,r;return c(this,(function(o){switch(o.label){case 0:if(null==this.registryFactory[t])throw new Error("Backend name '"+t+"' not found in registry");return this.backendName=t,null!=this.registry[t]?[3,4]:(this.backendInstance=null,e=this.initializeBackend(t),n=e.success,e.asyncInit?[4,n]:[3,2]);case 1:return r=o.sent(),[3,3];case 2:r=n,o.label=3;case 3:if(!r)return[2,!1];o.label=4;case 4:return this.backendInstance=this.registry[t],this.setupRegisteredKernels(),this.profiler=new at(this.backendInstance),[2,!0]}}))}))},t.prototype.setupRegisteredKernels=function(){var t=this;v(this.backendName).forEach((function(e){null!=e.setupFunc&&e.setupFunc(t.backendInstance)}))},t.prototype.disposeRegisteredKernels=function(t){var e=this;v(t).forEach((function(n){null!=n.disposeFunc&&n.disposeFunc(e.registry[t])}))},t.prototype.initializeBackend=function(t){var e=this,n=this.registryFactory[t];if(null==n)throw new Error("Cannot initialize backend "+t+", no registration found.");try{var r=n.factory();if(Promise.resolve(r)===r){var o=++this.pendingBackendInitId,a=r.then((function(n){return!(o<e.pendingBackendInitId||(e.registry[t]=n,e.pendingBackendInit=null,0))})).catch((function(t){return!(o<e.pendingBackendInitId||(e.pendingBackendInit=null,1))}));return this.pendingBackendInit=a,{success:a,asyncInit:!0}}return this.registry[t]=r,{success:!0,asyncInit:!1}}catch(e){return{success:!1,asyncInit:!1}}},t.prototype.removeBackend=function(t){if(!(t in this.registryFactory))throw new Error(t+" backend not found in registry");this.backendName===t&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,t in this.registry&&(this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t]),delete this.registryFactory[t],this.backendName===t&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)},t.prototype.getSortedBackends=function(){var t=this;if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort((function(e,n){return t.registryFactory[n].priority-t.registryFactory[e].priority}))},t.prototype.initializeBackendsAndReturnBest=function(){for(var t=this.getSortedBackends(),e=0;e<t.length;e++){var n=t[e],r=this.initializeBackend(n),o=r.success,a=r.asyncInit;if(a||o)return{name:n,asyncInit:a}}throw new Error("Could not initialize any backends, all backend initializations failed.")},t.prototype.moveData=function(t,e){var n=this.state.tensorInfo.get(e),r=n.backend,o=this.readSync(e);r.disposeData(e),n.backend=t,t.move(e,o,n.shape,n.dtype),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++},t.prototype.tidy=function(t,e){var n,r=this,o=null;if(null==e){if("function"!=typeof t)throw new Error("Please provide a function to tidy()");e=t}else{if("string"!=typeof t&&!(t instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof e)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");o=t}return this.scopedRun((function(){return r.startScope(o)}),(function(){return r.endScope(n)}),(function(){return n=e()}))},t.prototype.scopedRun=function(t,e,n){t();try{var r=n();return e(),r}catch(t){throw e(),t}},t.prototype.nextTensorId=function(){return t.nextTensorId++},t.prototype.nextVariableId=function(){return t.nextVariableId++},t.prototype.clone=function(t){var e=this.makeTensorFromDataId(t.dataId,t.shape,t.dtype),n={x:t};return this.addTapeNode(this.state.activeScope.name,n,[e],(function(t){return{x:function(){return t.toFloat()}}}),[]),e},t.prototype.runKernel=function(t,e,n,r,o){return this.runKernelFunc(null,e,null,t,n,r,o)},t.prototype.shouldCheckForMemLeaks=function(){return this.ENV.getBool("IS_TEST")},t.prototype.checkKernelForMemLeak=function(t,e,n){var r=this.backend.numDataIds(),o=0;n.forEach((function(t){o+="complex64"===t.dtype?3:1}));var a=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=r-e-o-a;if(i>0)throw new Error("Backend '"+this.backendName+"' has an internal memory leak ("+i+" data ids) after running '"+t+"'")},t.prototype.runKernelFunc=function(t,e,n,r,o,a,i){var s,u=this;void 0===a&&(a=[]),void 0===i&&(i=[]);var c,l=[],f=this.isTapeOn(),h=null!=this.state.activeScope?this.state.activeScope.name:"",p=function(t){f&&(l=t.map((function(t){return u.keep(u.clone(t))})))},v=this.state.numBytes,m=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);var g,y=d(r,this.backendName);return c=null!=y?function(){var t=u.backend.numDataIds();g=y.kernelFunc({inputs:e,attrs:o,backend:u.backend});var n=Array.isArray(g)?g:[g];u.shouldCheckForMemLeaks()&&u.checkKernelForMemLeak(h,t,n);var r=n.map((function(t){var e=t.dataId,n=t.shape,r=t.dtype;return u.makeTensorFromDataId(e,n,r)})),s=r.filter((function(t,e){return i[e]}));return p(a.slice().concat(s)),r}:function(){var e=u.backend.numDataIds();g=u.tidy((function(){return t(u.backend,p)}));var n=Array.isArray(g)?g:[g];return u.shouldCheckForMemLeaks()&&u.checkKernelForMemLeak(h,e,n),n},this.scopedRun((function(){return u.state.kernelDepth++}),(function(){return u.state.kernelDepth--}),(function(){s=u.ENV.getBool("DEBUG")?u.profiler.profileKernel(h,e,(function(){return c()})):c()})),f&&this.addTapeNode(h,e,s,n,l),this.state.profiling&&this.state.activeProfile.kernels.push({name:h,bytesAdded:this.state.numBytes-v,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-m,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(e).map((function(t){return e[t].shape})),outputShapes:s.map((function(t){return t.shape}))}),Array.isArray(g)?s:s[0]},t.prototype.makeTensor=function(t,e,n,r){if(null==t)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;var o=t;"string"===n&&G(t[0])&&(o=t.map((function(t){return rt(t)})));var a=r.write(o,e,n),i=new dt(e,n,a,this.nextTensorId());if(this.incRef(i,r),"string"===n){var s=this.state.tensorInfo.get(a),u=V(o);this.state.numBytes+=u-s.bytes,s.bytes=u}return i},t.prototype.makeTensorFromDataId=function(t,e,n,r){var o=new dt(e,n=n||"float32",t,this.nextTensorId());return this.incRef(o,r),o},t.prototype.makeVariable=function(t,e,n,r){void 0===e&&(e=!0),n=n||this.nextVariableId().toString(),null!=r&&r!==t.dtype&&(t=t.asType(r));var o=new xt(t,e,n,this.nextTensorId());if(null!=this.state.registeredVariables[o.name])throw new Error("Variable with name "+o.name+" was already registered");return this.state.registeredVariables[o.name]=o,this.incRef(o,this.backend),o},t.prototype.incRef=function(t,e){var n=this.state.tensorInfo.has(t.dataId)?this.state.tensorInfo.get(t.dataId).refCount:0;if(this.state.numTensors++,"string"===t.dtype&&this.state.numStringTensors++,0===n){this.state.numDataBuffers++;var r=0;"complex64"!==t.dtype&&"string"!==t.dtype&&(r=t.size*z(t.dtype)),this.state.tensorInfo.set(t.dataId,{backend:e||this.backend,dtype:t.dtype,shape:t.shape,bytes:r,refCount:0}),this.state.numBytes+=r}this.state.tensorInfo.get(t.dataId).refCount++,t instanceof xt||this.track(t)},t.prototype.disposeTensor=function(t){if(this.state.tensorInfo.has(t.dataId)){this.state.numTensors--,"string"===t.dtype&&this.state.numStringTensors--;var e=this.state.tensorInfo.get(t.dataId);e.refCount<=1?("complex64"!==t.dtype&&(this.state.numBytes-=e.bytes),this.state.numDataBuffers--,e.backend.disposeData(t.dataId),this.state.tensorInfo.delete(t.dataId)):this.state.tensorInfo.get(t.dataId).refCount--}},t.prototype.disposeVariables=function(){for(var t in this.state.registeredVariables){var e=this.state.registeredVariables[t];this.disposeVariable(e)}},t.prototype.disposeVariable=function(t){this.disposeTensor(t),null!=this.state.registeredVariables[t.name]&&delete this.state.registeredVariables[t.name]},t.prototype.memory=function(){var t=this.backend.memory();return t.numTensors=this.state.numTensors,t.numDataBuffers=this.state.numDataBuffers,t.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(t.unreliable=!0,null==t.reasons&&(t.reasons=[]),t.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),t},t.prototype.profile=function(t){return u(this,void 0,void 0,(function(){var e,n;return c(this,(function(r){return this.state.profiling=!0,e=this.state.numBytes,n=this.state.numTensors,this.state.activeProfile.kernels=[],this.state.activeProfile.result=t(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max.apply(Math,this.state.activeProfile.kernels.map((function(t){return t.totalBytesSnapshot}))),this.state.activeProfile.newBytes=this.state.numBytes-e,this.state.activeProfile.newTensors=this.state.numTensors-n,[2,this.state.activeProfile]}))}))},t.prototype.isTapeOn=function(){return this.state.gradientDepth>0&&0===this.state.kernelDepth},t.prototype.addTapeNode=function(t,e,n,r,o){var a=this,i={id:this.state.nextTapeNodeId++,name:t,inputs:e,outputs:n,saved:o};null!=r&&(i.gradient=function(t){return t=t.map((function(t,e){if(null==t){var r=n[e],o=tt(r.size,r.dtype);return a.makeTensor(o,r.shape,r.dtype)}return t})),r(t.length>1?t:t[0],o)}),this.state.activeTape.push(i)},t.prototype.keep=function(t){return t.kept=!0,t},t.prototype.startTape=function(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++},t.prototype.endTape=function(){this.state.gradientDepth--},t.prototype.startScope=function(t){var e={track:[],name:"unnamed scope",id:this.state.nextScopeId++};t&&(e.name=t),this.state.scopeStack.push(e),this.state.activeScope=e},t.prototype.endScope=function(t){for(var e=this,n=Rt(t),r=new Set(n.map((function(t){return t.id}))),o=0;o<this.state.activeScope.track.length;o++){var a=this.state.activeScope.track[o];a.kept||r.has(a.id)||a.dispose()}var i=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],n.forEach((function(t){t.kept||t.scopeId!==i.id||e.track(t)}))},t.prototype.gradients=function(t,e,n,r){var o=this;if(void 0===r&&(r=!1),E(e.length>0,(function(){return"gradients() received an empty list of xs."})),null!=n&&"float32"!==n.dtype)throw new Error("dy must have 'float32' dtype, but has '"+n.dtype+"'");var a=this.scopedRun((function(){return o.startTape()}),(function(){return o.endTape()}),(function(){return o.tidy("forward",t)}));E(a instanceof dt,(function(){return"The result y returned by f() must be a tensor."}));var i=function(t,e,n){for(var r={},o={},a=0;a<e.length;a++)r[e[a].id]=!0;for(a=0;a<t.length;a++){var i=(d=t[a]).inputs;for(var s in i){for(var u=i[s],c=!1,l=0;l<e.length;l++)if(r[u.id]){d.outputs.forEach((function(t){return r[t.id]=!0})),c=!0,o[d.id]=!0;break}if(c)break}}var f={};f[n.id]=!0;var h={};for(a=t.length-1;a>=0;a--)for(i=(d=t[a]).inputs,l=0;l<d.outputs.length;l++)if(f[d.outputs[l].id]){for(var s in i)f[i[s].id]=!0,h[d.id]=!0;break}var p=[];for(a=0;a<t.length;a++){var d;if(o[(d=t[a]).id]&&h[d.id]){var v={};for(var s in d.inputs){var m=d.inputs[s];r[m.id]&&(v[s]=m)}var g=Object.assign({},d);g.inputs=v,g.outputs=d.outputs,p.push(g)}}return p}(this.state.activeTape,e,a);if(!r&&0===i.length&&e.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",(function(){var t,r,s={};s[a.id]=null==n?(r=Z(R(t=a.shape),"float32"),Ot.makeTensor(r,t,"float32")):n,function(t,e,n){for(var r=function(r){var o=e[r],a=[];if(o.outputs.forEach((function(e){var n=t[e.id];null!=n?a.push(n):a.push(null)})),null==o.gradient)throw new Error("Cannot compute gradient: gradient function not found for "+o.name+".");var i=o.gradient(a),s=function(e){if(!(e in i))throw new Error("Cannot backprop through input "+e+". Available gradients found: "+Object.keys(i)+".");var r=n((function(){return i[e]()}));if("float32"!==r.dtype)throw new Error("Error in gradient for op "+o.name+". The gradient of input "+e+" must have 'float32' dtype, but has '"+r.dtype+"'");var a=o.inputs[e];if(!I(r.shape,a.shape))throw new Error("Error in gradient for op "+o.name+". The gradient of input '"+e+"' has shape '"+r.shape+"', which does not match the shape of the input '"+a.shape+"'");if(null==t[a.id])t[a.id]=r;else{var s=t[a.id];t[a.id]=s.add(r),s.dispose()}};for(var u in o.inputs)s(u)},o=e.length-1;o>=0;o--)r(o)}(s,i,(function(t){return o.tidy(t)}));var u=e.map((function(t){return s[t.id]}));return 0===o.state.gradientDepth&&(o.state.activeTape.forEach((function(t){for(var e=0,n=t.saved;e<n.length;e++)n[e].dispose()})),o.state.activeTape=null),{value:a,grads:u}}))},t.prototype.customGrad=function(t){var e=this;return E(X(t),(function(){return"The f passed in customGrad(f) must be a function."})),function(){for(var n,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];E(r.every((function(t){return t instanceof dt})),(function(){return"The args passed in customGrad(f)(x1, x2,...) must all be tensors"}));var a={};return r.forEach((function(t,e){a[e]=t})),e.runKernelFunc((function(e,o){return E((n=t.apply(void 0,r.concat([o]))).value instanceof dt,(function(){return"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"})),E(X(n.gradFunc),(function(){return"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."})),n.value}),a,(function(t,e){var o=n.gradFunc(t,e),a=Array.isArray(o)?o:[o];E(a.length===r.length,(function(){return"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(...)."})),E(a.every((function(t){return t instanceof dt})),(function(){return"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."}));var i={};return a.forEach((function(t,e){i[e]=function(){return t}})),i}))}},t.prototype.readSync=function(t){return this.state.tensorInfo.get(t).backend.readSync(t)},t.prototype.read=function(t){return this.state.tensorInfo.get(t).backend.read(t)},t.prototype.time=function(t){return u(this,void 0,void 0,(function(){var e,n;return c(this,(function(r){switch(r.label){case 0:return e=et(),[4,this.backend.time(t)];case 1:return(n=r.sent()).wallMs=et()-e,[2,n]}}))}))},t.prototype.track=function(t){return null!=this.state.activeScope&&(t.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(t)),t},Object.defineProperty(t.prototype,"registeredVariables",{get:function(){return this.state.registeredVariables},enumerable:!0,configurable:!0}),t.prototype.reset=function(){for(var t in this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new St,this.registry)this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null},t.nextTensorId=0,t.nextVariableId=0,t}(),Ot=function(){var e=function(){if(null==It){var e=void 0;if("undefined"!=typeof window)e=window;else if(void 0!==t)e=t;else if(void 0!==r)e=r;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}It=e}return It}();if(null==e._tfengine){var n=new l(e);e._tfengine=new At(n)}return function(t){h=t}(e._tfengine.ENV),ft=function(){return e._tfengine},e._tfengine}();function Tt(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}var Dt=f();Dt.registerFlag("DEBUG",(function(){return!1}),(function(t){})),Dt.registerFlag("IS_BROWSER",(function(){return Tt()})),Dt.registerFlag("IS_NODE",(function(){return void 0!==r&&void 0!==r.versions&&void 0!==r.versions.node})),Dt.registerFlag("IS_CHROME",(function(){return"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)})),Dt.registerFlag("PROD",(function(){return!1})),Dt.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(function(){return Dt.getBool("DEBUG")})),Dt.registerFlag("DEPRECATION_WARNINGS_ENABLED",(function(){return!0})),Dt.registerFlag("IS_TEST",(function(){return!1}));var Nt,Ft,Mt,Pt={},Bt={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function Lt(t,e){Pt[t]=e}function Wt(t){t in Pt||(Pt[t]=function(t){if(1!==t&&2!==t)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");var e=function(t){if("undefined"!=typeof OffscreenCanvas&&2===t)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}(t);return e.addEventListener("webglcontextlost",(function(e){e.preventDefault(),delete Pt[t]}),!1),1===t?e.getContext("webgl",Bt)||e.getContext("experimental-webgl",Bt):e.getContext("webgl2",Bt)}(t));var e=Pt[t];return e.isContextLost()?(delete Pt[t],Wt(t)):(e.disable(e.DEPTH_TEST),e.disable(e.STENCIL_TEST),e.disable(e.BLEND),e.disable(e.DITHER),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SAMPLE_COVERAGE),e.enable(e.SCISSOR_TEST),e.enable(e.CULL_FACE),e.cullFace(e.BACK),Pt[t])}function Ut(t,e){return[e,t]}function jt(t){var e=R(t);return O(Math.ceil(e/4))}function zt(t,e){return[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(t/2))]}function Vt(t,e){var n,r,o,a,i,s,u,c,l,h=t;return 2===f().getNumber("WEBGL_VERSION")?(n=h.R32F,r=h.R16F,o=h.RGBA16F,a=h.RGBA32F,i=h.RED,s=4,u=1,c=h.HALF_FLOAT,l=h.FLOAT):(n=t.RGBA,r=t.RGBA,o=t.RGBA,a=h.RGBA,i=t.RGBA,s=4,u=4,c=null!=e?e.HALF_FLOAT_OES:null,l=t.FLOAT),{internalFormatFloat:n,internalFormatHalfFloat:r,internalFormatPackedHalfFloat:o,internalFormatPackedFloat:a,textureFormatFloat:i,downloadTextureFormat:t.RGBA,downloadUnpackNumChannels:s,defaultNumChannels:u,textureTypeHalfFloat:c,textureTypeFloat:l}}function Gt(t,e,n){var r=n();return e&&function(t){var e=t.getError();if(e!==t.NO_ERROR)throw new Error("WebGL Error: "+qt(t,e))}(t),r}!function(t){t[t.DENSE=0]="DENSE",t[t.SHARED_BATCH=1]="SHARED_BATCH"}(Nt||(Nt={})),function(t){t[t.RENDER=0]="RENDER",t[t.UPLOAD=1]="UPLOAD",t[t.PIXELS=2]="PIXELS",t[t.DOWNLOAD=3]="DOWNLOAD"}(Ft||(Ft={})),function(t){t[t.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",t[t.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",t[t.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",t[t.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",t[t.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(Mt||(Mt={}));function Ht(t){return!!(f().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===t||5.96e-8<Math.abs(t)&&Math.abs(t)<65504)}function qt(t,e){switch(e){case t.NO_ERROR:return"NO_ERROR";case t.INVALID_ENUM:return"INVALID_ENUM";case t.INVALID_VALUE:return"INVALID_VALUE";case t.INVALID_OPERATION:return"INVALID_OPERATION";case t.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case t.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case t.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"Unknown error code "+e}}function Kt(t,e,n){return me(t,e,(function(){return t.getExtension(n)}),'Extension "'+n+'" not supported on this browser.')}function Xt(t,e,n){var r=me(t,e,(function(){return t.createShader(t.VERTEX_SHADER)}),"Unable to create vertex WebGLShader.");if(Gt(t,e,(function(){return t.shaderSource(r,n)})),Gt(t,e,(function(){return t.compileShader(r)})),!1===t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error("Failed to compile vertex shader.");return r}function $t(t,e,n){var r=me(t,e,(function(){return t.createShader(t.FRAGMENT_SHADER)}),"Unable to create fragment WebGLShader.");if(Gt(t,e,(function(){return t.shaderSource(r,n)})),Gt(t,e,(function(){return t.compileShader(r)})),!1===t.getShaderParameter(r,t.COMPILE_STATUS))throw function(t,e){var n=Qt.exec(e);if(null!=n){for(var r=+n[1],o=t.split("\n"),a=o.length.toString().length+2,i=o.map((function(t,e){return T((e+1).toString(),a)+t})),s=0,u=0;u<i.length;u++)s=Math.max(i[u].length,s);i.slice(0,r-1),i.slice(r-1,r),i.slice(r)}}(n,t.getShaderInfoLog(r)),new Error("Failed to compile fragment shader.");return r}var Yt,Jt,Qt=/ERROR: [0-9]+:([0-9]+):/g;function Zt(t,e){return me(t,e,(function(){return t.createProgram()}),"Unable to create WebGLProgram.")}function te(t,e,n){if(Gt(t,e,(function(){return t.linkProgram(n)})),!1===t.getProgramParameter(n,t.LINK_STATUS))throw new Error("Failed to link vertex and fragment shaders.")}function ee(t,e,n){if(Gt(t,e,(function(){return t.validateProgram(n)})),!1===t.getProgramParameter(n,t.VALIDATE_STATUS))throw new Error("Shader program validation failed.")}function ne(t,e,n){var r=me(t,e,(function(){return t.createBuffer()}),"Unable to create WebGLBuffer");return Gt(t,e,(function(){return t.bindBuffer(t.ARRAY_BUFFER,r)})),Gt(t,e,(function(){return t.bufferData(t.ARRAY_BUFFER,n,t.STATIC_DRAW)})),r}function re(t,e,n){var r=me(t,e,(function(){return t.createBuffer()}),"Unable to create WebGLBuffer");return Gt(t,e,(function(){return t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r)})),Gt(t,e,(function(){return t.bufferData(t.ELEMENT_ARRAY_BUFFER,n,t.STATIC_DRAW)})),r}function oe(t,e){return me(t,e,(function(){return t.createTexture()}),"Unable to create WebGLTexture.")}function ae(t,e){var n=f().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t<=0||e<=0){var r="["+t+"x"+e+"]";throw new Error("Requested texture size "+r+" is invalid.")}if(t>n||e>n)throw r="["+t+"x"+e+"]",new Error("Requested texture size "+r+" greater than WebGL maximum on this browser / GPU ["+n+"x"+n+"].")}function ie(t,e){return me(t,e,(function(){return t.createFramebuffer()}),"Unable to create WebGLFramebuffer.")}function se(t,e,n,r,o,a,i,s){var u=t.getAttribLocation(n,r);return-1!==u&&(Gt(t,e,(function(){return t.bindBuffer(t.ARRAY_BUFFER,o)})),Gt(t,e,(function(){return t.vertexAttribPointer(u,a,t.FLOAT,!1,i,s)})),Gt(t,e,(function(){return t.enableVertexAttribArray(u)})),!0)}function ue(t,e,n,r){ge(t,r),Gt(t,e,(function(){return t.activeTexture(t.TEXTURE0+r)})),Gt(t,e,(function(){return t.bindTexture(t.TEXTURE_2D,n)}))}function ce(t,e,n,r){return me(t,e,(function(){return t.getUniformLocation(n,r)}),'uniform "'+r+'" not present in program.')}function le(t,e,n){return t.getUniformLocation(e,n)}function fe(t,e,n,r,o,a){Gt(t,e,(function(){return ue(t,e,r,a)})),Gt(t,e,(function(){return t.uniform1i(o,a)}))}function he(t,e,n,r){Gt(t,e,(function(){return t.bindFramebuffer(t.FRAMEBUFFER,r)})),Gt(t,e,(function(){return t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0)}))}function pe(t,e,n){Gt(t,e,(function(){return t.bindFramebuffer(t.FRAMEBUFFER,n)})),Gt(t,e,(function(){return t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,null,0)}))}function de(t){var e=t.checkFramebufferStatus(t.FRAMEBUFFER);if(e!==t.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+ve(t,e))}function ve(t,e){switch(e){case t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case t.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return"unknown error "+e}}function me(t,e,n,r){var o=Gt(t,e,(function(){return n()}));if(null==o)throw new Error(r);return o}function ge(t,e){var n=t.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=e+t.TEXTURE0;if(r<t.TEXTURE0||r>n)throw new Error("textureUnit must be in [gl.TEXTURE0, gl.TEXTURE"+n+"].")}function ye(t,e){return void 0===e&&(e=2),R(t.slice(0,t.length-e))}function be(t){if(0===t.length)throw Error("Cannot get rows and columns of an empty shape array.");return[t.length>1?t[t.length-2]:1,t[t.length-1]]}function xe(t){var e=[1,1,1];return 0===t.length||1===t.length&&1===t[0]||(e=[ye(t)].concat(be(t))),e}function we(t,e){var n;void 0===e&&(e=!1);var r=f().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e&&(r*=2,1===(t=t.map((function(e,n){return n>=t.length-2?x(t[n]):t[n]}))).length&&(t=[2,t[0]])),2!==t.length){var o=M(t);t=o.newShape}var a=R(t);if(t.length<=1&&a<=r)return[1,a];if(2===t.length&&t[0]<=r&&t[1]<=r)return t;if(3===t.length&&t[0]*t[1]<=r&&t[2]<=r)return[t[0]*t[1],t[2]];if(3===t.length&&t[0]<=r&&t[1]*t[2]<=r)return[t[0],t[1]*t[2]];if(4===t.length&&t[0]*t[1]*t[2]<=r&&t[3]<=r)return[t[0]*t[1]*t[2],t[3]];if(4===t.length&&t[0]<=r&&t[1]*t[2]*t[3]<=r)return[t[0],t[1]*t[2]*t[3]];if(e){var i=ye(t),s=2,u=2;return t.length&&(s=(n=be(t))[0],u=n[1]),O(a=i*(s/2)*(u/2)).map((function(t){return 2*t}))}return O(a)}function Ee(t){return t%2==0}function Ce(t,e){if(I(t=t.slice(-2),e=e.slice(-2)))return!0;if(!t.length||!e.length)return!0;if(0===t[0]||0===t[1]||0===e[0]||0===e[1])return!0;if(t.length!==e.length){var n=t.slice(-1)[0],r=e.slice(-1)[0];if(n===r)return!0;if(Ee(n)&&Ee(r)&&(1===t[0]||1===e[0]))return!0}return t[1]===e[1]&&Ee(t[0])&&Ee(e[0])}function _e(t){if(null==Yt){var e=Wt(t);Yt=e.getParameter(e.MAX_TEXTURE_SIZE)}return Yt}function ke(t){if(null==Jt){var e=Wt(t);Jt=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,Jt)}function Re(t){if(0===t)return 0;var e=Wt(t);return Ie(e,"EXT_disjoint_timer_query_webgl2")&&2===t?2:Ie(e,"EXT_disjoint_timer_query")?1:0}function Ie(t,e){return null!=t.getExtension(e)}function Se(t){try{if(null!=Wt(t))return!0}catch(t){return!1}return!1}function Ae(t){if(0===t)return!1;var e=Wt(t);if(1===t){if(!Ie(e,"OES_texture_float"))return!1}else if(!Ie(e,"EXT_color_buffer_float"))return!1;return Te(e)}function Oe(t){if(0===t)return!1;var e=Wt(t);if(1!==t){if(Ie(e,"EXT_color_buffer_float"))return Te(e);if(Ie(e,"EXT_color_buffer_half_float")){var n=e.getExtension("EXT_color_buffer_half_float");return function(t,e){var n=Vt(t,e),r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);var o=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,o),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);var a=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(r),t.deleteFramebuffer(o),a}(e,n)}return!1}return!!Ie(e,"OES_texture_float")&&!!Ie(e,"WEBGL_color_buffer_float")&&Te(e)}function Te(t){var e=Vt(t),n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);var r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0);var o=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(n),t.deleteFramebuffer(r),o}function De(t){return 2===t&&null!=Wt(t).fenceSync}var Ne=Object.freeze({callAndCheck:Gt,canBeRepresented:Ht,getWebGLErrorMessage:qt,getExtensionOrThrow:Kt,createVertexShader:Xt,createFragmentShader:$t,createProgram:Zt,linkProgram:te,validateProgram:ee,createStaticVertexBuffer:ne,createStaticIndexBuffer:re,getNumChannels:function(){return 2===f().getNumber("WEBGL_VERSION")?1:4},createTexture:oe,validateTextureSize:ae,createFramebuffer:ie,bindVertexBufferToProgramAttribute:se,bindTextureUnit:ue,unbindTextureUnit:function(t,e,n){ge(t,n),Gt(t,e,(function(){return t.activeTexture(t.TEXTURE0+n)})),Gt(t,e,(function(){return t.bindTexture(t.TEXTURE_2D,null)}))},getProgramUniformLocationOrThrow:ce,getProgramUniformLocation:le,bindTextureToProgramUniformSampler:fe,bindCanvasToFramebuffer:function(t,e){Gt(t,e,(function(){return t.bindFramebuffer(t.FRAMEBUFFER,null)})),Gt(t,e,(function(){return t.viewport(0,0,t.canvas.width,t.canvas.height)})),Gt(t,e,(function(){return t.scissor(0,0,t.canvas.width,t.canvas.height)}))},bindColorTextureToFramebuffer:he,unbindColorTextureFromFramebuffer:pe,validateFramebuffer:de,getFramebufferErrorMessage:ve,getBatchDim:ye,getRowsCols:be,getShapeAs3D:xe,getTextureShapeFromLogicalShape:we,isReshapeFree:Ce,getWebGLMaxTextureSize:_e,resetMaxTextureSize:function(){Yt=null},resetMaxTexturesInShader:function(){Jt=null},getMaxTexturesInShader:ke,getWebGLDisjointQueryTimerVersion:Re,hasExtension:Ie,isWebGLVersionEnabled:Se,isCapableOfRenderingToFloatTexture:Ae,isDownloadFloatTextureEnabled:Oe,isWebGLFenceEnabled:De}),Fe=f();function Me(t){f().getBool("DEPRECATION_WARNINGS_ENABLED")}function Pe(t,e){return Ot.tidy(t,e)}function Be(t){Rt(t).forEach((function(t){return t.dispose()}))}function Le(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];f().getBool("IS_TEST")}function We(t,e){var n=t;if(j(t))return"string"===e?[]:[t.length];if(!Array.isArray(t))return[];for(var r=[];Array.isArray(n)||j(n)&&"string"!==e;)r.push(n.length),n=n[0];return Array.isArray(t)&&f().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&function t(e,n,r){if(r=r||[],Array.isArray(e)||j(e)){E(n.length>0,(function(){return"Element arr["+r.join("][")+"] should be a primitive, but is an array of "+e.length+" elements"})),E(e.length===n[0],(function(){return"Element arr["+r.join("][")+"] should have "+n[0]+" elements, but has "+e.length+" elements"}));for(var o=n.slice(1),a=0;a<e.length;++a)t(e[a],o,r.concat(a))}else E(0===n.length,(function(){return"Element arr["+r.join("][")+"] is a primitive, but should be an array/TypedArray of "+n[0]+" elements"}))}(t,r,[]),r}function Ue(t,e,n,r){if(null!=t&&("numeric"!==t&&t!==e||"numeric"===t&&"string"===e))throw new Error("Argument '"+n+"' passed to '"+r+"' must be "+t+" tensor, but got "+e+" tensor")}function je(t,e,n,r){if(void 0===r&&(r="numeric"),t instanceof dt)return Ue(r,t.dtype,e,n),t;var o=K(t);if("string"!==o&&["bool","int32","float32"].indexOf(r)>=0&&(o=r),Ue(r,o,e,n),null==t||!j(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t){var a=null==t?"null":t.constructor.name;throw new Error("Argument '"+e+"' passed to '"+n+"' must be a Tensor or TensorLike, but got '"+a+"'")}var i=We(t,o);j(t)||Array.isArray(t)||(t=[t]);var s="string"!==o?J(t,o,f().getBool("DEBUG")):k(t,[],!0);return Ot.makeTensor(s,i,o)}function ze(t,e,n,r){if(void 0===r&&(r="numeric"),!Array.isArray(t))throw new Error("Argument "+e+" passed to "+n+" must be a `Tensor[]` or `TensorLike[]`");return t.map((function(t,r){return je(t,e+"["+r+"]",n)}),r)}function Ve(t,e){for(var n=0;n<t.length;++n)if(t[t.length-n-1]!==e-1-n)return!1;return!0}function Ge(t,e,n){for(var r=t.length+e.length,o=[],a=0,i=0,s=0;s<r;s++)-1===n.indexOf(s)?o.push(t[a++]):o.push(e[i++]);return o}function He(t,e){for(var n=[],r=t.length,o=0;o<r;o++)-1===e.indexOf(o)&&n.push(t[o]);return[n,e.map((function(e){return t[e]}))]}function qe(t,e){return Ge(t,e.map((function(t){return 1})),e)}function Ke(t,e,n){E(Ve(e,n),(function(){return t+" supports only inner-most axes for now. Got axes "+e+" and rank-"+n+" input."}))}function Xe(t,e){if(Ve(t,e))return null;for(var n=[],r=0;r<e;++r)-1===t.indexOf(r)&&n.push(r);return t.forEach((function(t){return n.push(t)})),n}function $e(t){return t.map((function(t,e){return[e,t]})).sort((function(t,e){return t[1]-e[1]})).map((function(t){return t[0]}))}function Ye(t,e){for(var n=[],r=e-t;r<e;++r)n.push(r);return n}function Je(t,e){var n=t[0].length;t.forEach((function(t,e){E(t.length===n,(function(){return"Error in concat"+n+"D: rank of tensors["+e+"] must be the same as the rank of the rest ("+n+")"}))})),E(e>=0&&e<n,(function(){return"Error in concat"+n+"D: axis must be between 0 and "+(n-1)+"."}));var r=t[0];t.forEach((function(t,o){for(var a=0;a<n;a++)E(a===e||t[a]===r[a],(function(){return"Error in concat"+n+"D: Shape of tensors["+o+"] ("+t+") does not match the shape of the rest ("+r+") along the non-concatenated axis "+o+"."}))}))}function Qe(t,e){for(var n=t[0].slice(),r=1;r<t.length;r++)n[e]+=t[r][e];return n}function Ze(t){var e=Object.keys(t);if(1!==e.length)throw new Error("Please provide an object with a single key (operation name) mapping to a function. Got an object with "+e.length+" keys.");var n=e[0],r=t[n];n.endsWith("_")&&(n=n.substring(0,n.length-1));var o=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Ot.startScope(n);try{var o=r.apply(void 0,t);return Ot.endScope(o),o}catch(t){throw Ot.endScope(null),t}};return Object.defineProperty(o,"name",{value:n,configurable:!0}),o}Fe.registerFlag("HAS_WEBGL",(function(){return Fe.getNumber("WEBGL_VERSION")>0})),Fe.registerFlag("WEBGL_VERSION",(function(){return Se(2)?2:Se(1)?1:0})),Fe.registerFlag("WEBGL_BUFFER_SUPPORTED",(function(){return 2===Fe.get("WEBGL_VERSION")})),Fe.registerFlag("WEBGL_CPU_FORWARD",(function(){return!0})),Fe.registerFlag("WEBGL_FORCE_F16_TEXTURES",(function(){return!1})),Fe.registerFlag("WEBGL_PACK",(function(){return Fe.getBool("HAS_WEBGL")})),Fe.registerFlag("WEBGL_PACK_NORMALIZATION",(function(){return Fe.getBool("WEBGL_PACK")})),Fe.registerFlag("WEBGL_PACK_CLIP",(function(){return Fe.getBool("WEBGL_PACK")})),Fe.registerFlag("WEBGL_PACK_DEPTHWISECONV",(function(){return!1})),Fe.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(function(){return Fe.getBool("WEBGL_PACK")})),Fe.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(function(){return Fe.getBool("WEBGL_PACK")})),Fe.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(function(){return Fe.getBool("WEBGL_PACK")})),Fe.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(function(){return Fe.getBool("WEBGL_PACK")})),Fe.registerFlag("WEBGL_PACK_REDUCE",(function(){return Fe.getBool("WEBGL_PACK")})),Fe.registerFlag("WEBGL_LAZILY_UNPACK",(function(){return Fe.getBool("WEBGL_PACK")})),Fe.registerFlag("WEBGL_CONV_IM2COL",(function(){return Fe.getBool("WEBGL_PACK")})),Fe.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(function(){return _e(Fe.getNumber("WEBGL_VERSION"))})),Fe.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(function(){return ke(Fe.getNumber("WEBGL_VERSION"))})),Fe.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(function(){var t=Fe.getNumber("WEBGL_VERSION");return 0===t?0:Re(t)})),Fe.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(function(){return Fe.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&(t=navigator.userAgent||navigator.vendor||window.opera,!(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))));var t})),Fe.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(function(){return Ae(Fe.getNumber("WEBGL_VERSION"))})),Fe.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(function(){return!Fe.getBool("WEBGL_FORCE_F16_TEXTURES")&&Fe.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")})),Fe.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(function(){return Oe(Fe.getNumber("WEBGL_VERSION"))})),Fe.registerFlag("WEBGL_FENCE_API_ENABLED",(function(){return De(Fe.getNumber("WEBGL_VERSION"))})),Fe.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(function(){return Fe.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0})),pt=Me;var tn=Ze({complex_:function(t,e){var n=je(t,"real","complex"),r=je(e,"imag","complex");return C(n.shape,r.shape,"real and imag shapes, "+n.shape+" and "+r.shape+", must match in call to tf.complex()."),Ot.runKernelFunc((function(t){return t.complex(n,r)}),{$real:n,$imag:r})}}),en=Ze({real_:function(t){var e=je(t,"input","real");return Ot.runKernelFunc((function(t){return t.real(e)}),{$input:e})}}),nn=Ze({imag_:function(t){var e=je(t,"input","imag");return Ot.runKernelFunc((function(t){return t.imag(e)}),{$input:e})}});function rn(t,e,n){return on(t,e,We(t,n),n)}function on(t,e,n,r){if(null==r&&(r=K(t)),"complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!j(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t)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(null!=e){nt(e);var o=R(e),a=R(n);E(o===a,(function(){return"Based on the provided shape, ["+e+"], the tensor should have "+o+" values but has "+a}));for(var i=0;i<n.length;++i){var s=n[i],u=i!==n.length-1||s!==R(e.slice(i));E(n[i]===e[i]||!u,(function(){return"Error creating a new Tensor. Inferred shape ("+n+") does not match the provided shape ("+e+"). "}))}}return j(t)||Array.isArray(t)||(t=[t]),e=e||n,t="string"!==r?J(t,r,f().getBool("DEBUG")):k(t,[],!0),Ot.makeTensor(t,e,r)}function an(t,e){if((j(t)&&"string"!==e||Array.isArray(t))&&"complex64"!==e)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===e&&j(t)&&!(t instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return on(t,[],[],e)}function sn(t,e){_(t);var n=We(t,e);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return on(t,null,n,e)}function un(t,e,n){if(_(t),null!=e&&2!==e.length)throw new Error("tensor2d() requires shape to have two numbers");var r=We(t,n);if(2!==r.length&&1!==r.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return on(t,e,r,n)}function cn(t,e,n){if(_(t),null!=e&&3!==e.length)throw new Error("tensor3d() requires shape to have three numbers");var r=We(t,n);if(3!==r.length&&1!==r.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return on(t,e,r,n)}function ln(t,e,n){if(_(t),null!=e&&4!==e.length)throw new Error("tensor4d() requires shape to have four numbers");var r=We(t,n);if(4!==r.length&&1!==r.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return on(t,e,r,n)}function fn(t,e){if(void 0===e&&(e="float32"),"complex64"===e){var n=fn(t,"float32"),r=hn(t,"float32");return tn(n,r)}var o=Z(R(t),e);return Ot.makeTensor(o,t,e)}function hn(t,e){if(void 0===e&&(e="float32"),"complex64"===e){var n=hn(t,"float32"),r=hn(t,"float32");return tn(n,r)}var o=tt(R(t),e);return Ot.makeTensor(o,t,e)}function pn(t,e,n){return Ot.runKernelFunc((function(r){return r.fill(t,e,n)}),{})}function dn(t,e,n,r){if(void 0===n&&(n=1),void 0===r&&(r="float32"),0===n)throw new Error("Cannot have a step of zero");if(t===e||t<e&&n<0||e<t&&n>1)return hn([0],r);var o=tt(Math.abs(Math.ceil((e-t)/n)),r);e<t&&1===n&&(n=-1),o[0]=t;for(var a=1;a<o.length;a++)o[a]=o[a-1]+n;return sn(o,r)}var vn=Ze({onesLike_:function(t){var e=je(t,"x","onesLike");if("complex64"===e.dtype){var n=vn(en(e)),r=mn(nn(e));return tn(n,r)}return Ot.runKernelFunc((function(t){return t.onesLike(e)}),{$x:e},(function(t,e){return{$x:function(){return mn(t)}}}))}}),mn=Ze({zerosLike_:function(t){var e=je(t,"x","zerosLike");return Ot.runKernelFunc((function(t){return t.zerosLike(e)}),{$x:e},(function(t,e){return{$x:function(){return mn(t)}}}))}}),gn=Ze({concat_:function(t,e){void 0===e&&(e=0),E(t.length>=1,(function(){return"Pass at least one tensor to concat"}));var n=ze(t,"tensors","concat");"complex64"===n[0].dtype&&n.forEach((function(t){if("complex64"!==t.dtype)throw new Error("Cannot concatenate complex64 tensors with a tensor\n with dtype "+t.dtype+". ")})),e=F(e,n[0].shape)[0];var r=Qe(n.map((function(t){return t.shape})),e);if(0===R(r))return rn([],r);if(1===(n=n.filter((function(t){return t.size>0}))).length)return n[0];var o=n.map((function(t){return t.shape}));Je(o,e);var a=n,i={axis:e};return Ot.runKernelFunc((function(t){return t.concat(n,e)}),a,(function(t){var n=o.map((function(t){return t[e]}));return En(t,n,e).map((function(t){return function(){return t}}))}),"Concat",i)}}),yn=Ze({concat1d_:function(t){return gn(t,0)}}),bn=Ze({concat2d_:function(t,e){return gn(t,e)}}),xn=Ze({concat3d_:function(t,e){return gn(t,e)}}),wn=Ze({concat4d_:function(t,e){return gn(t,e)}}),En=Ze({split_:function(t,e,n){void 0===n&&(n=0);var r,o=je(t,"x","split");return n=F(n,o.shape)[0],"number"==typeof e?(E(o.shape[n]%e==0,(function(){return"Number of splits must evenly divide the axis."})),r=new Array(e).fill(o.shape[n]/e)):(E(o.shape[n]===e.reduce((function(t,e){return t+e})),(function(){return"The sum of sizes must match the size of the axis dimension."})),r=e),Ot.runKernelFunc((function(t){return t.split(o,r,n)}),{$x:o},(function(t){return{$x:function(){return gn(t,n)}}}))}});function Cn(t,e){return t(e={exports:{}},e.exports),e.exports}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t||"undefined"!=typeof self&&self;var _n=Cn((function(t){!function(t,e,n){function r(t){var e,n=this,r=(e=4022871197,function(t){t=t.toString();for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null}function o(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function a(t,e){var n=new r(t),a=e&&e.state,i=n.next;return i.int32=function(){return 4294967296*n.next()|0},i.double=function(){return i()+11102230246251565e-32*(2097152*i()|0)},i.quick=i,a&&("object"==typeof a&&o(a,n),i.state=function(){return o(n,{})}),i}e&&e.exports?e.exports=a:this.alea=a}(0,t)})),kn=Cn((function(t){!function(t,e,n){function r(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),e.next()}function o(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function a(t,e){var n=new r(t),a=e&&e.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},i.int32=n.next,i.quick=i,a&&("object"==typeof a&&o(a,n),i.state=function(){return o(n,{})}),i}e&&e.exports?e.exports=a:this.xor128=a}(0,t)})),Rn=Cn((function(t){!function(t,e,n){function r(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next()}function o(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function a(t,e){var n=new r(t),a=e&&e.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},i.int32=n.next,i.quick=i,a&&("object"==typeof a&&o(a,n),i.state=function(){return o(n,{})}),i}e&&e.exports?e.exports=a:this.xorwow=a}(0,t)})),In=Cn((function(t){!function(t,e,n){function r(t){var e=this;e.next=function(){var t,n,r=e.x,o=e.i;return t=r[o],n=(t^=t>>>7)^t<<24,n^=(t=r[o+1&7])^t>>>10,n^=(t=r[o+3&7])^t>>>3,n^=(t=r[o+4&7])^t<<7,t=r[o+7&7],n^=(t^=t<<13)^t<<9,r[o]=n,e.i=o+1&7,n},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n)r[7&n]=r[7&n]<<15^e.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n?r[7]=-1:r[n],t.x=r,t.i=0,n=256;n>0;--n)t.next()}(e,t)}function o(t,e){return e.x=t.x.slice(),e.i=t.i,e}function a(t,e){null==t&&(t=+new Date);var n=new r(t),a=e&&e.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},i.int32=n.next,i.quick=i,a&&(a.x&&o(a,n),i.state=function(){return o(n,{})}),i}e&&e.exports?e.exports=a:this.xorshift7=a}(0,t)})),Sn=Cn((function(t){!function(t,e,n){function r(t){var e=this;e.next=function(){var t,n,r=e.w,o=e.X,a=e.i;return e.w=r=r+1640531527|0,n=o[a+34&127],t=o[a=a+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=o[a]=n^t,e.i=a,n+(r^r>>>16)|0},function(t,e){var n,r,o,a,i,s=[],u=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,u=Math.max(u,e.length)),o=0,a=-32;a<u;++a)e&&(r^=e.charCodeAt((a+32)%e.length)),0===a&&(i=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,a>=0&&(i=i+1640531527|0,o=0==(n=s[127&a]^=r+i)?o+1:0);for(o>=128&&(s[127&(e&&e.length||0)]=-1),o=127,a=512;a>0;--a)r=s[o+34&127],n=s[o=o+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[o]=r^n;t.w=i,t.X=s,t.i=o}(e,t)}function o(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function a(t,e){null==t&&(t=+new Date);var n=new r(t),a=e&&e.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},i.int32=n.next,i.quick=i,a&&(a.X&&o(a,n),i.state=function(){return o(n,{})}),i}e&&e.exports?e.exports=a:this.xor4096=a}(0,t)})),An=Cn((function(t){!function(t,e,n){function r(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,o=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^o,o=o-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^o,e.a=o-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++)e.b^=0|n.charCodeAt(r),e.next()}function o(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function a(t,e){var n=new r(t),a=e&&e.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},i.int32=n.next,i.quick=i,a&&("object"==typeof a&&o(a,n),i.state=function(){return o(n,{})}),i}e&&e.exports?e.exports=a:this.tychei=a}(0,t)})),On=Cn((function(t){!function(e,r){var o,a=this,i=256,s="random",u=r.pow(i,6),c=r.pow(2,52),l=2*c,f=255;function h(t,n,f){var h=[],g=v(function t(e,n){var r,o=[],a=typeof e;if(n&&"object"==a)for(r in e)try{o.push(t(e[r],n-1))}catch(t){}return o.length?o:"string"==a?e:e+"\0"}((n=1==n?{entropy:!0}:n||{}).entropy?[t,m(e)]:null==t?function(){try{var t;return o&&(t=o.randomBytes)?t=t(i):(t=new Uint8Array(i),(a.crypto||a.msCrypto).getRandomValues(t)),m(t)}catch(t){var n=a.navigator,r=n&&n.plugins;return[+new Date,a,r,a.screen,m(e)]}}():t,3),h),y=new p(h),b=function(){for(var t=y.g(6),e=u,n=0;t<c;)t=(t+n)*i,e*=i,n=y.g(1);for(;t>=l;)t/=2,e/=2,n>>>=1;return(t+n)/e};return b.int32=function(){return 0|y.g(4)},b.quick=function(){return y.g(4)/4294967296},b.double=b,v(m(y.S),e),(n.pass||f||function(t,e,n,o){return o&&(o.S&&d(o,y),t.state=function(){return d(y,{})}),n?(r[s]=t,e):t})(b,g,"global"in n?n.global:this==r,n.state)}function p(t){var e,n=t.length,r=this,o=0,a=r.i=r.j=0,s=r.S=[];for(n||(t=[n++]);o<i;)s[o]=o++;for(o=0;o<i;o++)s[o]=s[a=f&a+t[o%n]+(e=s[o])],s[a]=e;(r.g=function(t){for(var e,n=0,o=r.i,a=r.j,s=r.S;t--;)e=s[o=f&o+1],n=n*i+s[f&(s[o]=s[a=f&a+e])+(s[a]=e)];return r.i=o,r.j=a,n})(i)}function d(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function v(t,e){for(var n,r=t+"",o=0;o<r.length;)e[f&o]=f&(n^=19*e[f&o])+r.charCodeAt(o++);return m(e)}function m(t){return String.fromCharCode.apply(0,t)}if(r.seedrandom=h,v(r.random(),e),t.exports){t.exports=h;try{o=n(69)}catch(t){}}}([],Math)}));On.alea=_n,On.xor128=kn,On.xorwow=Rn,On.xorshift7=In,On.xor4096=Sn,On.tychei=An;var Tn=On.alea,Dn=function(){function t(t,e,n,r,o){this.mean=t,this.stdDev=e,this.dtype=n,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);var a=o||Math.random();this.random=Tn(a.toString())}return t.prototype.nextValue=function(){if(!isNaN(this.nextVal)){var t=this.nextVal;return this.nextVal=NaN,t}for(var e,n,r=!1;!r;){var o=void 0,a=void 0,i=void 0;do{i=(o=2*this.random()-1)*o+(a=2*this.random()-1)*a}while(i>=1||0===i);var s=Math.sqrt(-2*Math.log(i)/i);e=this.mean+this.stdDev*o*s,n=this.mean+this.stdDev*a*s,this.truncated&&!this.isValidTruncated(e)||(r=!0)}return this.truncated&&!this.isValidTruncated(n)||(this.nextVal=this.convertValue(n)),this.convertValue(e)},t.prototype.convertValue=function(t){return null==this.dtype||"float32"===this.dtype?t:Math.round(t)},t.prototype.isValidTruncated=function(t){return t<=this.upper&&t>=this.lower},t}(),Nn=function(){function t(t,e,n,r){this.alpha=t,this.beta=1/e,this.dtype=n;var o=r||Math.random();this.randu=Tn(o.toString()),this.randn=new Dn(0,1,n,!1,this.randu()),this.d=t<1?t+2/3:t-1/3,this.c=1/Math.sqrt(9*this.d)}return t.prototype.nextValue=function(){for(var t,e,n,r,o,a;;){do{r=this.randn.nextValue(),a=1+this.c*r}while(a<=0);if(a*=a*a,e=1-.331*(t=r*r)*t,n=.5*t+this.d*(1-a+Math.log(a)),(o=this.randu())<e||Math.log(o)<n)break}return a=1/this.beta*this.d*a,this.alpha<1&&(a*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(a)},t.prototype.convertValue=function(t){return"float32"===this.dtype?t:Math.round(t)},t}(),Fn=function(){function t(t,e,n,r){var o=this;if(void 0===t&&(t=0),void 0===e&&(e=1),this.canReturnFloat=function(){return null==o.dtype||"float32"===o.dtype},this.min=t,this.range=e-t,this.dtype=n,null==r&&(r=Math.random()),"number"==typeof r&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error("The difference between "+t+" - "+e+" <= 1 and dtype is not float");this.random=Tn(r)}return t.prototype.convertValue=function(t){return this.canReturnFloat()?t:Math.round(t)},t.prototype.nextValue=function(){return this.convertValue(this.min+this.range*this.random())},t}();function Mn(t,e,n){return void 0===e&&(e="float32"),e=e||"float32",nt(t),new lt(t,e,n)}var Pn=Ze({batchToSpaceND_:function(t,e,n){var r=je(t,"x","batchToSpaceND"),o=e.reduce((function(t,e){return t*e}));return E(r.rank>=1+e.length,(function(){return"input rank is "+r.rank+" but should be > than blockShape.length "+e.length})),E(n.length===e.length,(function(){return"crops.length is "+n.length+" but should be equal to blockShape.length "+e.length})),E(r.shape[0]%o==0,(function(){return"input tensor batch is "+r.shape[0]+" but is not divisible by the product of the elements of blockShape "+e.join(" * ")+" === "+o})),Ot.runKernelFunc((function(t){return t.batchToSpaceND(r,e,n)}),{$x:r},(function(t){return{$x:function(){return t.spaceToBatchND(e,n)}}}))}}),Bn=Ze({broadcastTo_:function(t,e){var n=je(t,"broadcastTo","x"),r=n.shape;if(e.some((function(t){return!(t>0)||t%1!=0})))throw new Error("broadcastTo(): Invalid broadcast shape ["+e+"].");if(e.length<n.rank)throw new Error("broadcastTo(): shape.length="+e.length+" < input.rank="+n.rank+".");if(e.length>n.rank){for(var o=n.shape.slice();o.length<e.length;)o.unshift(1);n=n.reshape(o)}for(var a=Array.from(e),i=e.length-1;i>=0;i--)if(n.shape[i]===e[i])a[i]=1;else if(1!==n.shape[i])throw new Error("broadcastTo(): ["+r+"] cannot be broadcast to ["+e+"].");var s=a.map((function(t,e){return t>1?e:-1})).filter((function(t){return t>=0}));return 0===s.length?n.clone():Ot.runKernelFunc((function(t){return t.tile(n,a)}),{input:n},(function(t){return{input:function(){return t.sum(s,!0)}}}))}}),Ln=Ze({cast_:function(t,e){var n=je(t,"x","cast");if(!W(e))throw new Error("Failed to cast to unknown dtype "+e);if("string"===e&&"string"!==n.dtype||"string"!==e&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");var r={dtype:e};return Ot.runKernelFunc((function(t){return t.cast(n,e)}),{x:n},(function(t){return{x:function(){return t.clone()}}}),"Cast",r)}}),Wn=Ze({clone_:function(t){var e=je(t,"x","clone",null);return Ot.runKernelFunc((function(){return Ot.makeTensorFromDataId(e.dataId,e.shape,e.dtype)}),{$x:e},(function(t){return{$x:function(){return t.toFloat()}}}))}}),Un=Ze({cumsum_:function(t,e,n,r){void 0===e&&(e=0),void 0===n&&(n=!1),void 0===r&&(r=!1);var o=je(t,"x","cumsum"),a=Xe([e|=0],o.rank),i=o;null!=a&&(i=o.transpose(a));var s=Ye(1,o.rank)[0],u=Ot.runKernelFunc((function(t){return t.cumsum(i,s,n,r)}),{permutedX:i},(function(t){return{permutedX:function(){return t.cumsum(e,n,!r)}}}));return null!=a&&(u=u.transpose(a)),u}}),jn=Ze({depthToSpace_:function(t,e,n){void 0===n&&(n="NHWC");var r=je(t,"x","depthToSpace"),o="NHWC"===n?r.shape[1]:r.shape[2],a="NHWC"===n?r.shape[2]:r.shape[3],i="NHWC"===n?r.shape[3]:r.shape[1];return E(o*e>=0,(function(){return"Negative dimension size caused by overflow when multiplying\n "+o+" and "+e+" for depthToSpace with input shape\n "+r.shape})),E(a*e>=0,(function(){return"Negative dimension size caused by overflow when multiplying\n "+a+" and "+e+" for depthToSpace with input shape\n "+r.shape})),E(i%(e*e)==0,(function(){return"Dimension size must be evenly divisible by "+e*e+" but is "+i+" for depthToSpace with input shape "+r.shape})),Ot.runKernelFunc((function(t){return t.depthToSpace(r,e,n)}),{$x:r})}}),zn=Ze({expandDims_:function(t,e){void 0===e&&(e=0);var n=je(t,"x","expandDims",null);E(e<=n.rank,(function(){return"Axis must be <= rank of the tensor"}));var r=n.shape.slice();return e<0&&(E(-(n.rank+1)<=e,(function(){return"Axis must be in the interval ["+-(n.rank+1)+", "+n.rank+"]"})),e=n.rank+e+1),r.splice(e,0,1),er(n,r)}}),Vn=Ze({eye_:function(t,e,n,r){void 0===r&&(r="float32"),null==e&&(e=t);for(var o=Mn([t,e],r),a=t<=e?t:e,i=0;i<a;++i)o.set(1,i,i);var s=o.toTensor().as2D(t,e);if(null==n)return s;if(1===n.length)return ar(zn(s,0),[n[0],1,1]);if(2===n.length)return ar(zn(zn(s,0),0),[n[0],n[1],1,1]);if(3===n.length)return ar(zn(zn(zn(s,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error("eye() currently supports only 1D and 2D batchShapes, but received "+n.length+"D.")}}),Gn=Ze({multinomial_:function(t,e,n,r){void 0===r&&(r=!1);var o=je(t,"logits","multinomial"),a=o.size,i=o.rank;if(a<2)throw new Error("Error in multinomial: you need at least 2 outcomes, but got "+a+".");if(i>2)throw new Error("Rank of probabilities must be 1 or 2, but is "+i);n=n||Math.random();var s=1===i?o.as2D(1,-1):o,u=Ot.runKernelFunc((function(t){return t.multinomial(s,r,e,n)}),{logits2D:s});return 1===i?u.as1D():u}}),Hn=Ze({oneHot_:function(t,e,n,r){if(void 0===n&&(n=1),void 0===r&&(r=0),e<2)throw new Error("Error in oneHot: depth must be >=2, but it is "+e);var o=je(t,"indices","oneHot","int32"),a=o.shape.concat([e]);return o=o.flatten(),Ot.runKernelFunc((function(t){return t.oneHot(o,e,n,r)}),{$indices:o},(function(t){return{$indices:function(){return hn(o.shape,"float32")}}})).reshape(a)}}),qn=Ze({pad_:function(t,e,n){void 0===n&&(n=0);var r=je(t,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");var o={paddings:e,constantValue:n};return Ot.runKernelFunc((function(t){return t.pad(r,e,n)}),{x:r},(function(t){var n=e.map((function(t){return t[0]}));return{x:function(){return t.slice(n,r.shape)}}}),"PadV2",o)}}),Kn=Ze({pad1d_:function(t,e,n){return void 0===n&&(n=0),E(2===e.length,(function(){return"Invalid number of paddings. Must be length of 2."})),qn(t,[e],n)}}),Xn=Ze({pad2d_:function(t,e,n){return void 0===n&&(n=0),E(2===e.length&&2===e[0].length&&2===e[1].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),qn(t,e,n)}}),$n=Ze({pad3d_:function(t,e,n){return void 0===n&&(n=0),E(3===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),qn(t,e,n)}}),Yn=Ze({pad4d_:function(t,e,n){return void 0===n&&(n=0),E(4===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length&&2===e[3].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),qn(t,e,n)}}),Jn=Ze({rand_:function(t,e,n){var r=R(t),o=null;if(null==n||"float32"===n)o=new Float32Array(r);else if("int32"===n)o=new Int32Array(r);else{if("bool"!==n)throw new Error("Unknown data type "+n);o=new Uint8Array(r)}for(var a=0;a<r;a++)o[a]=e();return Ot.makeTensor(o,t,n)}}),Qn=Ze({randomNormal_:function(t,e,n,r,o){if(void 0===e&&(e=0),void 0===n&&(n=1),null!=r&&"bool"===r)throw new Error("Unsupported data type "+r);for(var a=new Dn(e,n,r,!1,o),i=Mn(t,r),s=0;s<i.values.length;s++)i.values[s]=a.nextValue();return i.toTensor()}}),Zn=Ze({randomGamma_:function(t,e,n,r,o){if(void 0===n&&(n=1),void 0===r&&(r="float32"),null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error("Unsupported data type "+r);for(var a=new Nn(e,n,r,o),i=Mn(t,r),s=0;s<i.values.length;s++)i.values[s]=a.nextValue();return i.toTensor()}}),tr=Ze({randomUniform_:function(t,e,n,r,o){void 0===e&&(e=0),void 0===n&&(n=1),void 0===r&&(r="float32");for(var a=Mn(t,r),i=new Fn(e,n,null,o),s=0;s<a.values.length;s++)a.values[s]=i.nextValue();return a.toTensor()}}),er=Ze({reshape_:function(t,e){var n=je(t,"x","reshape",null);e=N(e,n.size),E(n.size===R(e),(function(){return"new shape and old shape must have the same number of elements."}));var r={shape:e};return Ot.runKernelFunc((function(t){return t.reshape(n,e)}),{x:n},(function(t){return{x:function(){return t.reshape(n.shape)}}}),"Reshape",r)}}),nr=Ze({spaceToBatchND_:function(t,e,n){var r=je(t,"x","spaceToBatchND");return E(r.rank>=1+e.length,(function(){return"input rank "+r.rank+" should be > than [blockShape] "+e.length})),E(n.length===e.length,(function(){return"paddings.shape[0] "+n.length+" must be equal to [blockShape] "+e.length})),E(r.shape.reduce((function(t,r,o){return o>0&&o<=e.length?t&&(r+n[o-1][0]+n[o-1][1])%e[o-1]==0:t}),!0),(function(){return"input spatial dimensions "+r.shape.slice(1)+" with paddings "+n.toString()+" must be divisible by blockShapes "+e.toString()})),Ot.runKernelFunc((function(t){return t.spaceToBatchND(r,e,n)}),{$x:r},(function(t){return{$x:function(){return t.batchToSpaceND(e,n)}}}))}}),rr=Ze({squeeze_:function(t,e){var n=je(t,"x","squeeze");return er(n,M(n.shape,e).newShape)}}),or=Ze({stack_:function(t,e){void 0===e&&(e=0);var n=ze(t,"tensors","stack");if(E(n.length>=1,(function(){return"Pass at least one tensor to tf.stack"})),1===n.length)return n[0].expandDims(e);var r=n[0].rank,o=n[0].shape,a=n[0].dtype;E(e<=r,(function(){return"Axis must be <= rank of the tensor"})),n.forEach((function(t){C(o,t.shape,"All tensors passed to stack must have matching shapes")})),n.forEach((function(t){E(a===t.dtype,(function(){return"All tensors passed to stack must have matching dtypes"}))}));var i=n.map((function(t){return t.expandDims(e)}));return gn(i,e)}}),ar=Ze({tile_:function(t,e){var n=je(t,"x","tile",null);return E(n.rank===e.length,(function(){return"Error in transpose: rank of input "+n.rank+" must match length of reps "+e+"."})),Ot.runKernelFunc((function(t,r){var o=t.tile(n,e);return r([n]),o}),{$x:n},(function(t,n){var r=n[0];return{$x:function(){var n=mn(r);if(1===r.rank)for(var o=0;o<e[0];++o)n=n.add(t.slice([o*r.shape[0]],[r.shape[0]]));else if(2===r.rank)for(o=0;o<e[0];++o)for(var a=0;a<e[1];++a)n=n.add(t.slice([o*r.shape[0],a*r.shape[1]],[r.shape[0],r.shape[1]]));else if(3===r.rank)for(o=0;o<e[0];++o)for(a=0;a<e[1];++a)for(var i=0;i<e[2];++i)n=n.add(t.slice([o*r.shape[0],a*r.shape[1],i*r.shape[2]],[r.shape[0],r.shape[1],r.shape[2]]));else{if(4!==r.rank)throw new Error("Gradient for tile operation is not implemented for rank-"+r.rank+" tensors yet.");for(o=0;o<e[0];++o)for(a=0;a<e[1];++a)for(i=0;i<e[2];++i)for(var s=0;s<e[3];++s)n=n.add(t.slice([o*r.shape[0],a*r.shape[1],i*r.shape[2],s*r.shape[3]],[r.shape[0],r.shape[1],r.shape[2],r.shape[3]]))}return n}}}))}}),ir=Ze({truncatedNormal_:function(t,e,n,r,o){if(void 0===e&&(e=0),void 0===n&&(n=1),null!=r&&"bool"===r)throw new Error("Unsupported data type "+r);for(var a=new Dn(e,n,r,!0,o),i=Mn(t,r),s=0;s<i.values.length;s++)i.values[s]=a.nextValue();return i.toTensor()}}),sr=Ze({unstack_:function(t,e){void 0===e&&(e=0),e=e||0;var n=je(t,"x","unstack");return E(e>=-n.shape.length&&e<n.shape.length,(function(){return"Axis = "+e+" is not in [-"+n.shape.length+", "+n.shape.length+")"})),e<0&&(e+=n.shape.length),Ot.runKernelFunc((function(t){return t.unstack(n,e)}),{$x:n},(function(t){return{$x:function(){return or(t,e)}}}))}});function ur(t,e,n,r){void 0===r&&(r=!0);var o=[];if(r)(o=o.concat(e.slice(0))).push(t[0]/n),o=o.concat(t.slice(1));else{o=o.concat(t[0]);for(var a=e.length,i=0;i<a;++i)o=o.concat([t[i+1]/e[i],e[i]]);o=o.concat(t.slice(a+1))}return o}function cr(t,e,n){void 0===n&&(n=!0);var r=[];if(n){r.push(e);for(var o=e+1;o<t;++o)o<=2*e?(r.push(o),r.push(o-(e+1))):r.push(o)}else{var a=[],i=[];for(o=1;o<t;++o)o>=2*e+1||o%2==1?i.push(o):a.push(o);r.push.apply(r,a),r.push(0),r.push.apply(r,i)}return r}function lr(t,e,n,r){void 0===r&&(r=!0);var o=[];r?o.push(t[0]/n):o.push(t[0]*n);for(var a=1;a<t.length;++a)a<=e.length?r?o.push(e[a-1]*t[a]):o.push(t[a]/e[a-1]):o.push(t[a]);return o}function fr(t,e){for(var n=[0],r=0;r<e;++r)n.push(t[r][0]);return n}function hr(t,e,n){for(var r=t.slice(0,1),o=0;o<n;++o)r.push(t[o+1]-e[o][0]-e[o][1]);return r}function pr(t,e){if(t.rank<1)throw new Error("tf.gatherND() expects the input to be rank 1 or higher, but the rank was "+t.rank+".");if(e.rank<1)throw new Error("tf.gatherND() expects the indices to be rank 1 or higher, but the rank was "+e.rank+".");if("int32"!==e.dtype)throw new Error("tf.gatherND() expects the indices to be int32 type, but the dtype was "+e.dtype+".");if(e.shape[e.rank-1]>t.rank)throw new Error("index innermost dimension length must be <= tensor rank; saw: "+e.shape[e.rank-1]+" vs. "+t.rank);if(0===t.size)throw new Error("Requested more than 0 entries, but input is empty. Input shape: "+t.shape+".");for(var n=e.shape,r=n[n.length-1],o=1,a=0;a<n.length-1;++a)o*=n[a];var i=t.shape,s=n.slice();s.pop();var u=1;for(a=r;a<t.rank;++a)u*=i[a],s.push(i[a]);var c=Y(t.shape).map((function(t){return t/u})).concat([1]).slice(0,r);return[s,o,u,c]}function dr(t){return t<=30?t:$(t,Math.floor(Math.sqrt(t)))}function vr(t,e,n){for(var r=e.rank>1?e.shape[e.rank-1]:1,o=n.length,a=1,i=r;i<o;++i)a*=n[i];var s=r<1?1:r;return{sliceRank:r,numUpdates:e.size/s,sliceSize:a,strides:Y(n.slice(0,r)).concat([1]),outputSize:R(n)}}function mr(t,e,n){E(t.rank===e.length,(function(){return"Error in slice"+t.rank+"D: Length of begin "+e+" must match the rank of the array ("+t.rank+")."})),E(t.rank===n.length,(function(){return"Error in slice"+t.rank+"D: Length of size "+n+" must match the rank of the array ("+t.rank+")."}));for(var r=function(r){E(e[r]+n[r]<=t.shape[r],(function(){return"Error in slice"+t.rank+"D: begin["+r+"] + size["+r+"] ("+(e[r]+n[r])+") would overflow input.shape["+r+"] ("+t.shape[r]+")"}))},o=0;o<t.rank;++o)r(o)}function gr(t){for(var e=[],n=0;t>0;)1&t&&e.push(n),t/=2,n++;return e}function yr(t,e,n){for(var r=[],o=0;o<t.length;o++)r[o]=Math.ceil((e[o]-t[o])/n[o]);return r}function br(t,e,n,r,o){var a=e[o],i=n[o]||1;(t&1<<o||null==a)&&(a=i>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);var s=r[o];return a<0&&(a+=s),b(0,a,s-1)}function xr(t,e,n,r,o){var a=e[o],i=n[o]||1;(t&1<<o||null==a)&&(a=i>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);var s=r[o];return a<0&&(a+=s),i>0?b(0,a,s):b(-1,a,s-1)}function wr(t,e,n){for(var r=n.length,o=0;o<n.length;o++)if(n[o]>1){r=o;break}for(o=r+1;o<n.length;o++)if(e[o]>0||n[o]!==t[o])return!1;return!0}function Er(t,e){for(var n=t.length>0?t[t.length-1]:1,r=0;r<t.length-1;r++)n+=t[r]*e[r];return n}Object.freeze({assertParamsValid:mr,maskToAxes:gr,computeOutShape:yr,startForAxis:br,stopForAxis:xr,isSliceContinous:wr,computeFlatOffset:Er});function Cr(t){return Ot.customGrad(t)}var _r=Ze({softmax_:function(t,e){void 0===e&&(e=-1);var n=je(t,"logits","softmax");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error("Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and dim was "+e);return Cr((function(t,n){var r=t.logSumExp([e],!0),o=t.toFloat().sub(r).exp();return n([o]),{value:o,gradFunc:function(t,n){var r=n[0],o=t.mul(r);return o.sub(o.sum([e],!0).mul(r))}}}))(n)}}),kr=Ze({logSoftmax_:function(t,e){void 0===e&&(e=-1);var n=je(t,"logits","logSoftmax");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error("Log Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and axis was "+e);return Cr((function(t,n){var r=t.max(e,!0),o=t.sub(r),a=o.toFloat().sub(o.exp().sum(e,!0).log());return n([a]),{value:a,gradFunc:function(t,n){var r=n[0].exp();return t.sub(t.sum(e,!0).mul(r))}}}))(n)}}),Rr=function(){function t(t,e){this.backend=t,this.dataMover=e,this.data=new WeakMap,this.dataIdsCount=0}return t.prototype.get=function(t){return this.data.has(t)||this.dataMover.moveData(this.backend,t),this.data.get(t)},t.prototype.set=function(t,e){this.dataIdsCount++,this.data.set(t,e)},t.prototype.has=function(t){return this.data.has(t)},t.prototype.delete=function(t){return this.dataIdsCount--,this.data.delete(t)},t.prototype.numDataIds=function(){return this.dataIdsCount},t}(),Ir=function(){function t(){}return t.prototype.time=function(t){return Sr("time")},t.prototype.read=function(t){return Sr("read")},t.prototype.readSync=function(t){return Sr("readSync")},t.prototype.numDataIds=function(){return Sr("numDataIds")},t.prototype.disposeData=function(t){return Sr("disposeData")},t.prototype.write=function(t,e,n){return Sr("write")},t.prototype.move=function(t,e,n,r){return Sr("move")},t.prototype.memory=function(){return Sr("memory")},t.prototype.floatPrecision=function(){return Sr("floatPrecision")},t.prototype.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4},t.prototype.batchMatMul=function(t,e,n,r){return Sr("batchMatMul")},t.prototype.fusedBatchMatMul=function(t){return t.a,t.b,t.transposeA,t.transposeB,t.bias,t.activation,t.preluActivationWeights,Sr("fusedBatchMatMul")},t.prototype.slice=function(t,e,n){return Sr("slice")},t.prototype.stridedSlice=function(t,e,n,r){return Sr("stridedSlice")},t.prototype.unstack=function(t,e){return Sr("unstack")},t.prototype.reverse=function(t,e){return Sr("reverse")},t.prototype.concat=function(t,e){return Sr("concat")},t.prototype.neg=function(t){return Sr("neg")},t.prototype.add=function(t,e){return Sr("add")},t.prototype.addN=function(t){return Sr("addN")},t.prototype.subtract=function(t,e){return Sr("subtract")},t.prototype.multiply=function(t,e){return Sr("multiply")},t.prototype.realDivide=function(t,e){return Sr("realDivide")},t.prototype.floorDiv=function(t,e){return Sr("floorDiv")},t.prototype.sum=function(t,e){return Sr("sum")},t.prototype.prod=function(t,e){return Sr("prod")},t.prototype.unsortedSegmentSum=function(t,e,n){return Sr("unsortedSegmentSum")},t.prototype.argMin=function(t,e){return Sr("argMin")},t.prototype.argMax=function(t,e){return Sr("argMax")},t.prototype.equal=function(t,e){return Sr("equal")},t.prototype.notEqual=function(t,e){return Sr("notEqual")},t.prototype.less=function(t,e){return Sr("less")},t.prototype.lessEqual=function(t,e){return Sr("lessEqual")},t.prototype.greater=function(t,e){return Sr("greater")},t.prototype.greaterEqual=function(t,e){return Sr("greaterEqual")},t.prototype.logicalNot=function(t){return Sr("logicalNot")},t.prototype.logicalAnd=function(t,e){return Sr("logicalAnd")},t.prototype.logicalOr=function(t,e){return Sr("logicalOr")},t.prototype.where=function(t){return Sr("where")},t.prototype.select=function(t,e,n){return Sr("select")},t.prototype.topk=function(t,e,n){return Sr("topk")},t.prototype.min=function(t,e){return Sr("min")},t.prototype.minimum=function(t,e){return Sr("minimum")},t.prototype.mod=function(t,e){return Sr("mod")},t.prototype.max=function(t,e){return Sr("max")},t.prototype.maximum=function(t,e){return Sr("maximum")},t.prototype.all=function(t,e){return Sr("all")},t.prototype.any=function(t,e){return Sr("any")},t.prototype.squaredDifference=function(t,e){return Sr("squaredDifference")},t.prototype.ceil=function(t){return Sr("ceil")},t.prototype.floor=function(t){return Sr("floor")},t.prototype.round=function(t){return Sr("round")},t.prototype.sign=function(t){return Sr("sign")},t.prototype.isNaN=function(t){return Sr("isNaN")},t.prototype.isInf=function(t){return Sr("isInf")},t.prototype.isFinite=function(t){return Sr("isFinite")},t.prototype.pow=function(t,e){return Sr("pow")},t.prototype.exp=function(t){return Sr("exp")},t.prototype.expm1=function(t){return Sr("expm1")},t.prototype.log=function(t){return Sr("log")},t.prototype.log1p=function(t){return Sr("log1p")},t.prototype.sqrt=function(t){return Sr("sqrt")},t.prototype.rsqrt=function(t){return Sr("rsqrt")},t.prototype.square=function(t){return Sr("square")},t.prototype.reciprocal=function(t){return Sr("reciprocal")},t.prototype.relu=function(t){return Sr("relu")},t.prototype.relu6=function(t){return Sr("relu6")},t.prototype.prelu=function(t,e){return Sr("prelu")},t.prototype.elu=function(t){return Sr("elu")},t.prototype.eluDer=function(t,e){return Sr("eluDer")},t.prototype.selu=function(t){return Sr("selu")},t.prototype.int=function(t){return Sr("int")},t.prototype.clip=function(t,e,n){return Sr("clip")},t.prototype.abs=function(t){return Sr("abs")},t.prototype.complexAbs=function(t){return Sr("complexAbs")},t.prototype.sigmoid=function(t){return Sr("sigmoid")},t.prototype.softplus=function(t){return Sr("softplus")},t.prototype.sin=function(t){return Sr("sin")},t.prototype.cos=function(t){return Sr("cos")},t.prototype.tan=function(t){return Sr("tan")},t.prototype.asin=function(t){return Sr("asin")},t.prototype.acos=function(t){return Sr("acos")},t.prototype.atan=function(t){return Sr("atan")},t.prototype.atan2=function(t,e){return Sr("atan2")},t.prototype.sinh=function(t){return Sr("sinh")},t.prototype.cosh=function(t){return Sr("cosh")},t.prototype.tanh=function(t){return Sr("tanh")},t.prototype.asinh=function(t){return Sr("asinh")},t.prototype.acosh=function(t){return Sr("acosh")},t.prototype.atanh=function(t){return Sr("atanh")},t.prototype.erf=function(t){return Sr("erf")},t.prototype.step=function(t,e){return Sr("step")},t.prototype.fusedConv2d=function(t){return t.input,t.filter,t.convInfo,t.bias,t.activation,t.preluActivationWeights,Sr("fusedConv2d")},t.prototype.conv2d=function(t,e,n){return Sr("conv2d")},t.prototype.conv2dDerInput=function(t,e,n){return Sr("conv2dDerInput")},t.prototype.conv2dDerFilter=function(t,e,n){return Sr("conv2dDerFilter")},t.prototype.fusedDepthwiseConv2D=function(t){return t.input,t.filter,t.convInfo,t.bias,t.activation,t.preluActivationWeights,Sr("fusedDepthwiseConv2D")},t.prototype.depthwiseConv2D=function(t,e,n){return Sr("depthwiseConv2D")},t.prototype.depthwiseConv2DDerInput=function(t,e,n){return Sr("depthwiseConv2DDerInput")},t.prototype.depthwiseConv2DDerFilter=function(t,e,n){return Sr("depthwiseConv2DDerFilter")},t.prototype.conv3d=function(t,e,n){return Sr("conv3d")},t.prototype.conv3dDerInput=function(t,e,n){return Sr("conv3dDerInput")},t.prototype.conv3dDerFilter=function(t,e,n){return Sr("conv3dDerFilter")},t.prototype.maxPool=function(t,e){return Sr("maxPool")},t.prototype.maxPoolBackprop=function(t,e,n,r){return Sr("maxPoolBackprop")},t.prototype.avgPool=function(t,e){return Sr("avgPool")},t.prototype.avgPoolBackprop=function(t,e,n){return Sr("avgPoolBackprop")},t.prototype.avgPool3d=function(t,e){return Sr("avgPool3d")},t.prototype.avgPool3dBackprop=function(t,e,n){return Sr("avgPool3dBackprop")},t.prototype.maxPool3d=function(t,e){return Sr("maxPool3d")},t.prototype.maxPool3dBackprop=function(t,e,n,r){return Sr("maxPool3dBackprop")},t.prototype.reshape=function(t,e){return Sr("reshape")},t.prototype.cast=function(t,e){return Sr("cast")},t.prototype.tile=function(t,e){return Sr("tile")},t.prototype.pad=function(t,e,n){return Sr("pad")},t.prototype.transpose=function(t,e){return Sr("transpose")},t.prototype.gather=function(t,e,n){return Sr("gather")},t.prototype.gatherND=function(t,e){return Sr("gatherND")},t.prototype.scatterND=function(t,e,n){return Sr("scatterND")},t.prototype.batchToSpaceND=function(t,e,n){return Sr("batchToSpaceND")},t.prototype.spaceToBatchND=function(t,e,n){return Sr("spaceToBatchND")},t.prototype.resizeBilinear=function(t,e,n,r){return Sr("resizeBilinear")},t.prototype.resizeBilinearBackprop=function(t,e,n){return Sr("resizeBilinearBackprop")},t.prototype.resizeNearestNeighbor=function(t,e,n,r){return Sr("resizeNearestNeighbor")},t.prototype.resizeNearestNeighborBackprop=function(t,e,n){return Sr("resizeNearestNeighborBackprop")},t.prototype.batchNormalization=function(t,e,n,r,o,a){return Sr("batchNormalization")},t.prototype.localResponseNormalization4D=function(t,e,n,r,o){return Sr("localResponseNormalization4D")},t.prototype.LRNGrad=function(t,e,n,r,o,a,i){return Sr("LRNGrad")},t.prototype.multinomial=function(t,e,n,r){return Sr("multinomial")},t.prototype.oneHot=function(t,e,n,r){return Sr("oneHot")},t.prototype.cumsum=function(t,e,n,r){return Sr("cumsum")},t.prototype.nonMaxSuppression=function(t,e,n,r,o){return Sr("nonMaxSuppression")},t.prototype.fft=function(t){return Sr("fft")},t.prototype.ifft=function(t){return Sr("ifft")},t.prototype.complex=function(t,e){return Sr("complex")},t.prototype.real=function(t){return Sr("real")},t.prototype.imag=function(t){return Sr("imag")},t.prototype.cropAndResize=function(t,e,n,r,o,a){return Sr("cropAndResize")},t.prototype.depthToSpace=function(t,e,n){return Sr("depthToSpace")},t.prototype.split=function(t,e,n){return Sr("split")},t.prototype.sparseToDense=function(t,e,n,r){return Sr("sparseToDense")},t.prototype.diag=function(t){return Sr("diag")},t.prototype.fill=function(t,e,n){return Sr("fill")},t.prototype.onesLike=function(t){return Sr("onesLike")},t.prototype.zerosLike=function(t){return Sr("zerosLike")},t.prototype.linspace=function(t,e,n){return Sr("linspace")},t.prototype.dispose=function(){return Sr("dispose")},t}();function Sr(t){throw new Error("'"+t+"' not yet implemented or not found in the registry. Did you forget to import the kernel?")}function Ar(t,e){for(var n=t.length,r=[],o=0;o<n;o++){var a=n-1-o,i=t[a]||1;(e[e.length-1-o]||1)>1&&1===i&&r.unshift(a)}return r}function Or(t,e){for(var n=[],r=0;r<e.length;r++){var o=t[t.length-r-1],a=e.length-r-1,i=e[a];(null==o||1===o&&i>1)&&n.unshift(a)}return n}function Tr(t,e){for(var n=[],r=Math.max(t.length,e.length),o=0;o<r;o++){var a=t[t.length-o-1];null==a&&(a=1);var i=e[e.length-o-1];if(null==i&&(i=1),1===a)n.unshift(i);else if(1===i)n.unshift(a);else{if(a!==i)throw Error("Operands could not be broadcast together with shapes "+t+" and "+e+".");n.unshift(a)}}return n}function Dr(t,e,n,r,o,a,i){void 0===i&&(i="channelsLast");var s,u=Br(e),c=u[0],l=u[1];if("channelsLast"===i)s=[c,l,t[3],t[3]];else{if("channelsFirst"!==i)throw new Error("Unknown dataFormat "+i);s=[c,l,t[1],t[1]]}return Fr(t,s,n,r,o,a,!1,i)}function Nr(t,e,n,r,o,a,i){void 0===i&&(i="NDHWC");var s,u,c=Lr(e),l=c[0],f=c[1],h=c[2];if("NDHWC"===i)u="channelsLast",s=[l,f,h,t[4],t[4]];else{if("NCDHW"!==i)throw new Error("Unknown dataFormat "+i);u="channelsFirst",s=[l,f,h,t[1],t[1]]}return Mr(t,s,n,r,o,!1,u,a)}function Fr(t,e,n,r,o,a,i,s){void 0===i&&(i=!1),void 0===s&&(s="channelsLast");var u=[-1,-1,-1,-1],c=u[0],l=u[1],f=u[2],h=u[3];if("channelsLast"===s)c=t[0],l=t[1],f=t[2],h=t[3];else{if("channelsFirst"!==s)throw new Error("Unknown dataFormat "+s);c=t[0],h=t[1],l=t[2],f=t[3]}var p,d=e[0],v=e[1],m=e[3],g=Br(n),y=g[0],b=g[1],x=Br(r),w=x[0],C=x[1],_=Wr(d,w),k=Wr(v,C),R=function(t,e,n,r,o,a,i,s){var u,c,l;if("number"==typeof t){u={top:t,bottom:t,left:t,right:t,type:0===t?"VALID":"NUMBER"};var f=function(t,e,n,r,o){null==r&&(r=Pr(t,e,n));var a=t[1],i=Ur((t[0]-e+2*r)/n+1,o);E(S(i),(function(){return"The output # of rows ("+i+") must be an integer. Change the stride and/or zero pad parameters"}));var s=Ur((a-e+2*r)/n+1,o);return E(S(s),(function(){return"The output # of columns ("+s+") must be an integer. Change the stride and/or zero pad parameters"})),[i,s]}([e,n],a,r,t,s);c=f[0],l=f[1]}else if("same"===t){c=Math.ceil(e/r),l=Math.ceil(n/o);var h=Math.max(0,(c-1)*r+a-e),p=Math.max(0,(l-1)*o+i-n),d=Math.floor(h/2),v=h-d,m=Math.floor(p/2);u={top:d,bottom:v,left:m,right:p-m,type:"SAME"}}else{if("valid"!==t)throw Error("Unknown padding parameter: "+t);u={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((e-a+1)/r),l=Math.ceil((n-i+1)/o)}return{padInfo:u,outHeight:c,outWidth:l}}(o,l,f,y,b,_,k,a),I=R.padInfo,A=R.outHeight,O=R.outWidth,T=i?m*h:m;return"channelsFirst"===s?p=[c,T,A,O]:"channelsLast"===s&&(p=[c,A,O,T]),{batchSize:c,dataFormat:s,inHeight:l,inWidth:f,inChannels:h,outHeight:A,outWidth:O,outChannels:T,padInfo:I,strideHeight:y,strideWidth:b,filterHeight:d,filterWidth:v,effectiveFilterHeight:_,effectiveFilterWidth:k,dilationHeight:w,dilationWidth:C,inShape:t,outShape:p,filterShape:e}}function Mr(t,e,n,r,o,a,i,s){void 0===a&&(a=!1),void 0===i&&(i="channelsLast");var u=[-1,-1,-1,-1,-1],c=u[0],l=u[1],f=u[2],h=u[3],p=u[4];if("channelsLast"===i)c=t[0],l=t[1],f=t[2],h=t[3],p=t[4];else{if("channelsFirst"!==i)throw new Error("Unknown dataFormat "+i);c=t[0],p=t[1],l=t[2],f=t[3],h=t[4]}var d,v=e[0],m=e[1],g=e[2],y=e[4],b=Lr(n),x=b[0],w=b[1],C=b[2],_=Lr(r),k=_[0],R=_[1],I=_[2],A=Wr(v,k),O=Wr(m,R),T=Wr(g,I),D=function(t,e,n,r,o,a,i,s,u,c,l){var f,h,p,d;if("number"==typeof t){f={top:t,bottom:t,left:t,right:t,front:t,back:t,type:0===t?"VALID":"NUMBER"};var v=function(t,e,n,r,o,a){null==o&&(o=Pr(t,e,r));var i=t[1],s=t[2],u=Ur((t[0]-e+2*o)/r+1,a);E(S(u),(function(){return"The output # of depths ("+u+") must be an integer. Change the stride and/or zero pad parameters"}));var c=Ur((i-e+2*o)/r+1,a);E(S(c),(function(){return"The output # of rows ("+c+") must be an integer. Change the stride and/or zero pad parameters"}));var l=Ur((s-e+2*o)/r+1,a);return E(S(l),(function(){return"The output # of columns ("+l+") must be an integer. Change the stride and/or zero pad parameters"})),[u,c,l,1]}([e,n,r,1],s,0,o,t,l);h=v[0],p=v[1],d=v[2]}else if("same"===t){var m=((h=Math.ceil(e/o))-1)*o+s-e,g=((p=Math.ceil(n/a))-1)*a+u-n,y=((d=Math.ceil(r/i))-1)*i+c-r,b=Math.floor(m/2),x=m-b,w=Math.floor(g/2),C=g-w,_=Math.floor(y/2);f={top:w,bottom:C,left:_,right:y-_,front:b,back:x,type:"SAME"}}else{if("valid"!==t)throw Error("Unknown padding parameter: "+t);f={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},h=Math.ceil((e-s+1)/o),p=Math.ceil((n-u+1)/a),d=Math.ceil((r-c+1)/i)}return{padInfo:f,outDepth:h,outHeight:p,outWidth:d}}(o,l,f,h,x,w,C,A,O,T,s),N=D.padInfo,F=D.outDepth,M=D.outHeight,P=D.outWidth,B=a?y*p:y;return"channelsFirst"===i?d=[c,B,F,M,P]:"channelsLast"===i&&(d=[c,F,M,P,B]),{batchSize:c,dataFormat:i,inDepth:l,inHeight:f,inWidth:h,inChannels:p,outDepth:F,outHeight:M,outWidth:P,outChannels:B,padInfo:N,strideDepth:x,strideHeight:w,strideWidth:C,filterDepth:v,filterHeight:m,filterWidth:g,effectiveFilterDepth:A,effectiveFilterHeight:O,effectiveFilterWidth:T,dilationDepth:k,dilationHeight:R,dilationWidth:I,inShape:t,outShape:d,filterShape:e}}function Pr(t,e,n,r){void 0===r&&(r=1);var o=Wr(e,r);return Math.floor((t[0]*(n-1)-n+o)/2)}function Br(t){return"number"==typeof t?[t,t,t]:2===t.length?[t[0],t[1],1]:t}function Lr(t){return"number"==typeof t?[t,t,t]:t}function Wr(t,e){return e<=1?t:t+(t-1)*(e-1)}function Ur(t,e){if(!e)return t;switch(e){case"round":return Math.round(t);case"ceil":return Math.ceil(t);case"floor":return Math.floor(t);default:throw new Error("Unknown roundingMode "+e)}}function jr(t){var e=Br(t),n=e[0],r=e[1],o=e[2];return 1===n&&1===r&&1===o}function zr(t,e){return jr(t)||jr(e)}function Vr(t){if("NHWC"===t)return"channelsLast";if("NCHW"===t)return"channelsFirst";throw new Error("Unknown dataFormat "+t)}function Gr(t,e,n){if("complex64"===e){if("complex64"===t.dtype)return t.clone();var r=hn(t.shape),o=t.toFloat(),a=n.complex(o,r);return r.dispose(),o.dispose(),a}if(!U(t.dtype,e))return Ot.makeTensorFromDataId(t.dataId,t.shape,e);if("complex64"===t.dtype){var i=n.real(t);return a=i.cast(e),i.dispose(),a}if("int32"===e)return n.int(t);if("bool"===e){var s=an(0,t.dtype);return a=n.notEqual(t,s),s.dispose(),a}throw new Error("Error in Cast: failed to cast "+t.dtype+" to "+e)}function Hr(t,e){return Ot.makeTensorFromDataId(t.dataId,e,t.dtype)}function qr(t,e,n){var r=(e-t)/(n-1),o=tt(n,"float32");o[0]=t;for(var a=1;a<o.length;a++)o[a]=o[a-1]+r;return sn(o,"float32")}Object.freeze({castTensor:Gr,reshapeTensor:Hr,linspaceImpl:qr,upcastType:Et,axesAreInnerMostDims:Ve,combineLocations:Ge,computeOutAndReduceShapes:He,expandShapeToKeepDim:qe,assertAxesAreInnerMostDims:Ke,getAxesPermutation:Xe,getUndoAxesPermutation:$e,getInnerMostAxes:Ye,getBroadcastDims:Ar,getReductionAxes:Or,assertAndGetBroadcastShape:Tr,assertParamsConsistent:Je,computeOutShape:Qe,computePool2DInfo:Dr,computePool3DInfo:Nr,computeConv2DInfo:Fr,computeConv3DInfo:Mr,computeDefaultPad:Pr,tupleValuesAreOne:jr,eitherStridesOrDilationsAreOne:zr,convertConv2DDataFormat:Vr});function Kr(t,e){if(t.length!==e.length)throw new Error("Cannot merge real and imag arrays of different lengths. real:"+t.length+", imag: "+e.length+".");for(var n=new Float32Array(2*t.length),r=0;r<n.length;r+=2)n[r]=t[r/2],n[r+1]=e[r/2];return n}function Xr(t,e){return{real:t[2*e],imag:t[2*e+1]}}function $r(t,e,n,r){t[2*r]=e,t[2*r+1]=n}function Yr(t,e,n){var r=(n?2:-2)*Math.PI*(t/e);return{real:Math.cos(r),imag:Math.sin(r)}}function Jr(t,e,n,r,o){for(var a=Array.from(e).map((function(t,e){return{score:t,boxIndex:e}})).filter((function(t){return t.score>o})).sort((function(t,e){return e.score-t.score})),i=[],s=0;s<a.length;s++){var u=a[s],c=u.score,l=u.boxIndex;if(c<o)break;for(var f=!1,h=i.length-1;h>=0;--h)if(Qr(t,l,i[h])>=r){f=!0;break}if(!f&&(i.push(l),i.length>=n))break}return sn(i,"int32")}function Qr(t,e,n){var r=t.subarray(4*e,4*e+4),o=t.subarray(4*n,4*n+4),a=Math.min(r[0],r[2]),i=Math.min(r[1],r[3]),s=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),c=Math.min(o[0],o[2]),l=Math.min(o[1],o[3]),f=Math.max(o[0],o[2]),h=Math.max(o[1],o[3]),p=(s-a)*(u-i),d=(f-c)*(h-l);if(p<=0||d<=0)return 0;var v=Math.max(a,c),m=Math.max(i,l),g=Math.min(s,f),y=Math.min(u,h),b=Math.max(g-v,0)*Math.max(y-m,0);return b/(p+d-b)}function Zr(t,e,n){var r=new Array(t.rank).fill(0),o=t.shape.slice();return e.map((function(e){o[n]=e;var a=t.slice(r,o);return r[n]+=e,a}))}function to(t,e){for(var n=new Array(t.rank),r=0;r<n.length;r++)n[r]=t.shape[r]*e[r];var o=Mn(n,t.dtype);for(r=0;r<o.values.length;++r){for(var a=o.indexToLoc(r),i=new Array(t.rank),s=0;s<i.length;s++)i[s]=a[s]%t.shape[s];var u=t.locToIndex(i);o.values[r]=t.values[u]}return o.toTensor()}function eo(t,e,n,r,o){for(var a=e[e.length-1],i=[t.length/a,a],s=i[0],u=i[1],c=P(n,s*r),l=P("int32",s*r),f=0;f<s;f++){for(var h=f*u,p=t.subarray(h,h+u),d=[],v=0;v<p.length;v++)d.push({value:p[v],index:v});d.sort((function(t,e){return e.value-t.value}));var m=f*r,g=c.subarray(m,m+r),y=l.subarray(m,m+r);for(v=0;v<r;v++)g[v]=d[v].value,y[v]=d[v].index}var b=e.slice();return b[b.length-1]=r,[rn(c,b,n),rn(l,b,"int32")]}function no(t,e){for(var n=[],r=0;r<e.length;r++)e[r]&&n.push(r);var o=Mn(t,"int32"),a=Mn([n.length,t.length],"int32");for(r=0;r<n.length;r++){var i=o.indexToLoc(n[r]),s=r*t.length;a.values.set(i,s)}return a.toTensor()}var ro=function(t,e){this.outputShape=[],this.outputShape=t,this.variableNames=e.map((function(t,e){return"T"+e}));var n=[];this.variableNames.forEach((function(t){n.push("float v"+t+" = get"+t+"AtOutCoords();")}));var r=this.variableNames.map((function(t){return"v"+t})).join(" + ");this.userCode="\n void main() {\n "+n.join("\n ")+"\n\n float result = "+r+";\n setOutput(result);\n }\n "},oo=function(t,e){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.variableNames=e.map((function(t,e){return"T"+e}));var n=[];this.variableNames.forEach((function(t){n.push("vec4 v"+t+" = get"+t+"AtOutCoords();")}));var r=this.variableNames.map((function(t){return"v"+t})).join(" + ");this.userCode="\n void main() {\n "+n.join("\n ")+"\n\n vec4 result = "+r+";\n setOutput(result);\n }\n "},ao=function(t,e,n){this.variableNames=["A"];var r=t.windowSize,o=t.batchSize,a=t.inSize,i=Math.ceil(a/r);n||this.variableNames.push("bestIndicesA"),this.outputShape=[o,i];var s="max"===e?">":"<",u=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * "+r+";\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < "+r+"; i++) {\n int inIdx = "+u+";\n float candidate = getA(batch, inIdx);\n if (candidate "+s+" bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n "};function io(t,e){return["x","y","z","w","u","v"].slice(0,e).map((function(e){return t+"."+e}))}function so(t,e){return 1===e?[t]:io(t,e)}function uo(){var t,e,n,r,o,a,i,s,u,c;return 2===f().getNumber("WEBGL_VERSION")?(t="#version 300 es",e="in",n="out",r="in",o="texture",a="outputColor",i="out vec4 outputColor;",s="\n bool isnan_custom(float val) {\n return (val > 0.0 || val < 0.0) ? false : val != 0.0;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n ",u="",c="\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "):(t="",e="attribute",n="varying",r="varying",o="texture2D",a="gl_FragColor",i="",s="\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ",u="\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ",c="\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "),{version:t,attribute:e,varyingVs:n,varyingFs:r,texture2D:o,output:a,defineOutput:i,defineSpecialNaN:s,defineSpecialInf:u,defineRound:c}}function co(t,e,n){void 0===n&&(n="index");var r=Y(e);return r.map((function(e,o){return"int "+t[o]+" = "+n+" / "+e+"; "+(o===r.length-1?"int "+t[o+1]+" = "+n+" - "+t[o]+" * "+e:"index -= "+t[o]+" * "+e)+";"})).join("")}function lo(t){var e=Y(t).map((function(t){return t.toString()}));return"\n int getFlatIndex(ivec3 coords) {\n return coords.x * "+e[0]+" + coords.y * "+e[1]+" + coords.z;\n }\n"}var fo="\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n";function ho(t,e,n,r){var o=[];t.forEach((function(t){var e=R(t.shapeInfo.logicalShape);t.shapeInfo.isUniform?o.push("uniform float "+t.name+(e>1?"["+e+"]":"")+";"):(o.push("uniform sampler2D "+t.name+";"),o.push("uniform int offset"+t.name+";"))}));var a,i,s=o.join("\n"),u=t.map((function(t){return function(t,e,n){void 0===n&&(n=!1);var r="";r+=n?function t(e){var n,r,o;switch(e.shapeInfo.logicalShape.length){case 0:return n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),o=uo(),"\n vec4 "+r+"() {\n return "+o.texture2D+"("+n+", halfCR);\n }\n ";case 1:return function(t){var e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1),r=t.shapeInfo.texShape,o=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],a=uo();return"\n vec4 "+n+"(int index) {\n vec2 uv = packedUVfrom1D(\n "+o[0]+", "+o[1]+", index);\n return "+a.texture2D+"("+e+", uv);\n }\n "}(e);case 2:return function(t){var e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),o=t.shapeInfo.texShape,a=o[0],i=o[1],s=uo();if(null!=o&&I(e,o))return"\n vec4 "+r+"(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2("+i+".0, "+a+".0);\n\n return "+s.texture2D+"("+n+", uv);\n }\n ";var u=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];return"\n vec4 "+r+"(int row, int col) {\n vec2 uv = packedUVfrom2D("+Math.ceil(e[1]/2)+", "+u[0]+", "+u[1]+", row, col);\n return "+s.texture2D+"("+n+", uv);\n }\n "}(e);case 3:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,o="get"+r.charAt(0).toUpperCase()+r.slice(1),a=e.shapeInfo.texShape,i=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)];if(1===n[0]){var s=wo(e,n.slice(1));return"\n "+t(s)+"\n vec4 "+o+"(int b, int row, int col) {\n return "+o+"("+Eo(["b","row","col"],[1,2])+");\n }\n "}var u=i[0],c=i[1],l=Math.ceil(n[2]/2);return"\n vec4 "+o+"(int b, int row, int col) {\n vec2 uv = packedUVfrom3D(\n "+u+", "+c+", "+l*Math.ceil(n[1]/2)+", "+l+", b, row, col);\n return "+uo().texture2D+"("+r+", uv);\n }\n "}(e);default:return function(t){for(var e=t.shapeInfo.logicalShape,n=e.length,r=t.name,o="get"+r.charAt(0).toUpperCase()+r.slice(1),a=t.shapeInfo.texShape,i=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)],s=i[0],u=i[1],c=Math.ceil(e[n-1]/2),l=c*Math.ceil(e[n-2]/2),f="int b, int row, int col",h="b * "+l+" + (row / 2) * "+c+" + (col / 2)",p=2;p<n-1;p++)f="int b"+p+", "+f,h="b"+p+" * "+(l*=e[n-p-1])+" + "+h;return"\n vec4 "+o+"("+f+") {\n int index = "+h+";\n int texR = index / "+u+";\n int texC = index - texR * "+u+";\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+u+", "+s+");\n return "+uo().texture2D+"("+r+", uv);\n }\n "}(e)}}(t):function t(e){var n=e.shapeInfo.logicalShape;switch(n.length){case 0:return function(t){var e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1);if(t.shapeInfo.isUniform)return"float "+n+"() {return "+e+";}";var r=t.shapeInfo.texShape,o=r[0],a=r[1];if(1===o&&1===a)return"\n float "+n+"() {\n return sampleTexture("+e+", halfCR);\n }\n ";var i=t.shapeInfo.texShape;return"\n float "+n+"() {\n vec2 uv = uvFromFlat("+i[0]+", "+i[1]+", "+yo(e)+");\n return sampleTexture("+e+", uv);\n }\n "}(e);case 1:return function(t){var e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1);if(t.shapeInfo.isUniform)return"\n float "+n+"(int index) {\n "+bo(t)+"\n }\n ";var r=t.shapeInfo.texShape,o=r[0],a=r[1];if(1===a&&1===o)return"\n float "+n+"(int index) {\n return sampleTexture("+e+", halfCR);\n }\n ";var i=yo(e);return 1===a?"\n float "+n+"(int index) {\n vec2 uv = vec2(0.5, (float(index + "+i+") + 0.5) / "+o+".0);\n return sampleTexture("+e+", uv);\n }\n ":1===o?"\n float "+n+"(int index) {\n vec2 uv = vec2((float(index + "+i+") + 0.5) / "+a+".0, 0.5);\n return sampleTexture("+e+", uv);\n }\n ":"\n float "+n+"(int index) {\n vec2 uv = uvFromFlat("+o+", "+a+", index + "+i+");\n return sampleTexture("+e+", uv);\n }\n "}(e);case 2:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,o="get"+r.charAt(0).toUpperCase()+r.slice(1),a=e.shapeInfo.texShape;if(null!=a&&I(n,a)){var i=a[0];return"\n float "+o+"(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2("+a[1]+".0, "+i+".0);\n return sampleTexture("+r+", uv);\n }\n "}var s=M(n),u=s.newShape,c=s.keptDims,l=u;if(l.length<n.length){var f=wo(e,l);return"\n "+t(f)+"\n float "+o+"(int row, int col) {\n return "+o+"("+Eo(["row","col"],c)+");\n }\n "}if(e.shapeInfo.isUniform)return"\n float "+o+"(int row, int col) {\n int index = round(dot(vec2(row, col), vec2("+n[1]+", 1)));\n "+bo(e)+"\n }\n ";var h=a[0],p=a[1],d=yo(r);return 1===p?"\n float "+o+"(int row, int col) {\n float index = dot(vec3(row, col, "+d+"), vec3("+n[1]+", 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / "+h+".0);\n return sampleTexture("+r+", uv);\n }\n ":1===h?"\n float "+o+"(int row, int col) {\n float index = dot(vec3(row, col, "+d+"), vec3("+n[1]+", 1, 1));\n vec2 uv = vec2((index + 0.5) / "+p+".0, 0.5);\n return sampleTexture("+r+", uv);\n }\n ":"\n float "+o+"(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+n[1]+" + col + "+d+";\n vec2 uv = uvFromFlat("+h+", "+p+", index);\n return sampleTexture("+r+", uv);\n }\n"}(e);case 3:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,o="get"+r.charAt(0).toUpperCase()+r.slice(1),a=n[1]*n[2],i=n[2],s=M(n),u=s.newShape,c=s.keptDims,l=u;if(l.length<n.length){var f=wo(e,l);return"\n "+t(f)+"\n float "+o+"(int row, int col, int depth) {\n return "+o+"("+Eo(["row","col","depth"],c)+");\n }\n "}if(e.shapeInfo.isUniform)return"\n float "+o+"(int row, int col, int depth) {\n int index = round(dot(vec3(row, col, depth),\n vec3("+a+", "+i+", 1)));\n "+bo(e)+"\n }\n ";var h=e.shapeInfo.texShape,p=h[0],d=h[1],v=e.shapeInfo.flatOffset;return d===a&&null==v?"\n float "+o+"(int row, int col, int depth) {\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2("+i+", 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+d+".0, "+p+".0);\n return sampleTexture("+r+", uv);\n }\n ":d===i&&null==v?"\n float "+o+"(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2("+n[1]+", 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+d+".0, "+p+".0);\n return sampleTexture("+r+", uv);\n }\n ":"\n float "+o+"(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+a+" + col * "+i+" + depth + "+yo(r)+";\n vec2 uv = uvFromFlat("+p+", "+d+", index);\n return sampleTexture("+r+", uv);\n }\n "}(e);case 4:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,o="get"+r.charAt(0).toUpperCase()+r.slice(1),a=n[3],i=n[2]*a,s=n[1]*i,u=M(n),c=u.newShape,l=u.keptDims;if(c.length<n.length){var f=wo(e,c);return"\n "+t(f)+"\n float "+o+"(int row, int col, int depth, int depth2) {\n return "+o+"("+Eo(["row","col","depth","depth2"],l)+");\n }\n "}if(e.shapeInfo.isUniform)return"\n float "+o+"(int row, int col, int depth, int depth2) {\n int index = round(dot(vec4(row, col, depth, depth2),\n vec4("+s+", "+i+", "+a+", 1)));\n "+bo(e)+"\n }\n ";var h=e.shapeInfo.flatOffset,p=e.shapeInfo.texShape,d=p[0],v=p[1];return v===s&&null==h?"\n float "+o+"(int row, int col, int depth, int depth2) {\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3("+i+", "+a+", 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+v+".0, "+d+".0);\n return sampleTexture("+r+", uv);\n }\n ":v===a&&null==h?"\n float "+o+"(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3("+n[1]*n[2]+", "+n[2]+", 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+v+".0, "+d+".0);\n return sampleTexture("+r+", uv);\n }\n ":"\n float "+o+"(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+s+" + col * "+i+" +\n depth * "+a+" + depth2;\n vec2 uv = uvFromFlat("+d+", "+v+", index + "+yo(r)+");\n return sampleTexture("+r+", uv);\n }\n "}(e);case 5:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,o="get"+r.charAt(0).toUpperCase()+r.slice(1),a=n[4],i=n[3]*a,s=n[2]*i,u=n[1]*s,c=M(n),l=c.newShape,f=c.keptDims;if(l.length<n.length){var h=wo(e,l);return"\n "+t(h)+"\n float "+o+"(int row, int col, int depth, int depth2, int depth3) {\n return "+o+"("+Eo(["row","col","depth","depth2","depth3"],f)+");\n }\n "}if(e.shapeInfo.isUniform)return"\n float "+o+"(int row, int col, int depth, int depth2, int depth3) {\n float index = dot(\n vec4(row, col, depth, depth2),\n vec4("+u+", "+s+", "+i+", "+a+")) +\n depth3;\n "+bo(e)+"\n }\n ";var p=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,v=d[0],m=d[1];return m===u&&null==p?"\n float "+o+"(int row, int col, int depth, int depth2, int depth3) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4("+s+", "+i+", "+a+", 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+m+".0, "+v+".0);\n return sampleTexture("+r+", uv);\n }\n ":m===a&&null==p?"\n float "+o+"(int row, int col, int depth, int depth2, int depth3) {\n float texR = dot(\n vec4(row, col, depth, depth2),\n vec4("+n[1]*n[2]*n[3]+",\n "+n[2]*n[3]+", "+n[3]+", 1));\n int texC = depth3;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+m+".0, "+v+".0);\n return sampleTexture("+r+", uv);\n }\n ":"\n float "+o+"(int row, int col, int depth, int depth2, int depth3) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+u+" + col * "+s+" + depth * "+i+" +\n depth2 * "+a+" + depth3 + "+yo(r)+";\n vec2 uv = uvFromFlat("+v+", "+m+", index);\n return sampleTexture("+r+", uv);\n }\n "}(e);case 6:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,o="get"+r.charAt(0).toUpperCase()+r.slice(1),a=M(n),i=a.newShape,s=a.keptDims;if(i.length<n.length){var u=wo(e,i);return"\n "+t(u)+"\n float "+o+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n return "+o+"("+Eo(["row","col","depth","depth2","depth3","depth4"],s)+");\n }\n "}var c=n[5],l=n[4]*c,f=n[3]*l,h=n[2]*f,p=n[1]*h;if(e.shapeInfo.isUniform)return"\n float "+o+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int index = round(dot(\n vec4(row, col, depth, depth2),\n vec4("+p+", "+h+", "+f+", "+l+")) +\n dot(\n vec2(depth3, depth4),\n vec2("+c+", 1)));\n "+bo(e)+"\n }\n ";var d=e.shapeInfo.flatOffset,v=e.shapeInfo.texShape,m=v[0],g=v[1];return g===p&&null==d?"\n float "+o+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4("+h+", "+f+", "+l+", "+c+")) +\n float(depth4);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+g+".0, "+m+".0);\n return sampleTexture("+r+", uv);\n }\n ":g===c&&null==d?"\n float "+o+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n float texR = dot(vec4(row, col, depth, depth2),\n vec4("+n[1]*n[2]*n[3]*n[4]+",\n "+n[2]*n[3]*n[4]+",\n "+n[3]*n[4]+",\n "+n[4]+")) + float(depth3);\n int texC = depth4;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+g+".0, "+m+".0);\n return sampleTexture("+r+", uv);\n }\n ":"\n float "+o+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+p+" + col * "+h+" + depth * "+f+" +\n depth2 * "+l+" + depth3 * "+c+" + depth4 + "+yo(r)+";\n vec2 uv = uvFromFlat("+m+", "+g+", index);\n return sampleTexture("+r+", uv);\n }\n "}(e);default:throw new Error(n.length+"-D input sampling is not yet supported")}}(t);var o=t.shapeInfo.logicalShape,a=e.logicalShape;return o.length<=a.length&&(r+=n?function(t,e){var n,r=t.name,o=r.charAt(0).toUpperCase()+r.slice(1),a="get"+o+"AtOutCoords",i=t.shapeInfo.logicalShape.length,s=e.logicalShape.length,u=Ar(t.shapeInfo.logicalShape,e.logicalShape),c=xo(s),l=s-i,f=["x","y","z","w","u","v"];n=0===i?"":s<2&&u.length>=1?"coords = 0;":u.map((function(t){return"coords."+f[t+l]+" = 0;"})).join("\n");var h;h=s<2&&i>0?"coords":t.shapeInfo.logicalShape.map((function(t,e){return"coords."+f[e+l]})).join(", ");var p="return outputValue;",d=1===R(t.shapeInfo.logicalShape),v=1===R(e.logicalShape);if(1!==i||d||v){if(d&&!v)p=1===s?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(u.length){var m=i-2,g=i-1;u.indexOf(m)>-1&&u.indexOf(g)>-1?p="return vec4(outputValue.x);":u.indexOf(m)>-1?p="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":u.indexOf(g)>-1&&(p="return vec4(outputValue.xx, outputValue.zz);")}}else p="\n return vec4(outputValue.xy, outputValue.xy);\n ";return"\n vec4 "+a+"() {\n "+c+" coords = getOutputCoords();\n "+n+"\n vec4 outputValue = get"+o+"("+h+");\n "+p+"\n }\n "}(t,e):function(t,e){var n=t.name,r=n.charAt(0).toUpperCase()+n.slice(1),o="get"+r+"AtOutCoords",a=e.texShape,i=t.shapeInfo.texShape,s=t.shapeInfo.logicalShape.length,u=e.logicalShape.length;if(!t.shapeInfo.isUniform&&s===u&&null==t.shapeInfo.flatOffset&&I(i,a))return"\n float "+o+"() {\n return sampleTexture("+n+", resultUV);\n }\n ";var c=xo(u),l=Ar(t.shapeInfo.logicalShape,e.logicalShape),f=u-s,h=["x","y","z","w","u","v"];return"\n float "+o+"() {\n "+c+" coords = getOutputCoords();\n "+(0===s?"":u<2&&l.length>=1?"coords = 0;":l.map((function(t){return"coords."+h[t+f]+" = 0;"})).join("\n"))+"\n return get"+r+"("+(u<2&&s>0?"coords":t.shapeInfo.logicalShape.map((function(t,e){return"coords."+h[e+f]})).join(", "))+");\n }\n "}(t,e)),r}(t,e,r)})).join("\n"),c=e.texShape,l=uo(),f=function(t){return"\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return "+t.texture2D+"(textureSampler, uv).r;\n }\n "}(l),h=function(t){return t.version+"\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n "+t.varyingFs+" vec2 resultUV;\n "+t.defineOutput+"\n const vec2 halfCR = vec2(0.5, 0.5);\n\n struct ivec5\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n };\n\n struct ivec6\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n int v;\n };\n\n uniform float NAN;\n "+t.defineSpecialNaN+"\n "+t.defineSpecialInf+"\n "+t.defineRound+"\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n int idiv(int a, int b, float sign) {\n int res = a / b;\n int mod = imod(a, b);\n if (sign < 0. && mod != 0) {\n res -= 1;\n }\n return res;\n }\n\n //Based on the work of Dave Hoskins\n //https://www.shadertoy.com/view/4djSRW\n #define HASHSCALE1 443.8975\n float random(float seed){\n vec2 p = resultUV * seed;\n vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n }\n\n "+po+"\n "+vo+"\n "+mo+"\n "}(l);return e.isPacked?(a=function(t,e){switch(t.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(t,e){var n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];return 1===n[0]?"\n int getOutputCoords() {\n return 2 * int(resultUV.x * "+n[1]+".0);\n }\n ":1===n[1]?"\n int getOutputCoords() {\n return 2 * int(resultUV.y * "+n[0]+".0);\n }\n ":"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+n[0]+", "+n[1]+"));\n return 2 * (resTexRC.x * "+n[1]+" + resTexRC.y);\n }\n "}(0,e);case 2:return function(t,e){var n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(I(t,e))return"\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2("+n[0]+", "+n[1]+"));\n }\n ";var r=Math.ceil(t[1]/2);return"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+n[0]+", "+n[1]+"));\n\n int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n int r = 2 * (index / "+r+");\n int c = imod(index, "+r+") * 2;\n\n return ivec2(r, c);\n }\n "}(t,e);case 3:return n=t,r=e,o=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],i=(a=Math.ceil(n[2]/2))*Math.ceil(n[1]/2),"\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+o[0]+", "+o[1]+"));\n int index = resTexRC.x * "+o[1]+" + resTexRC.y;\n\n int b = index / "+i+";\n index -= b * "+i+";\n\n int r = 2 * (index / "+a+");\n int c = imod(index, "+a+") * 2;\n\n return ivec3(b, r, c);\n }\n ";default:return function(t,e){for(var n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],r=Math.ceil(t[t.length-1]/2),o=r*Math.ceil(t[t.length-2]/2),a=o,i="",s="b, r, c",u=2;u<t.length-1;u++)i="\n int b"+u+" = index / "+(a*=t[t.length-u-1])+";\n index -= b"+u+" * "+a+";\n "+i,s="b"+u+", "+s;return"\n ivec"+t.length+" getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+n[0]+", "+n[1]+"));\n int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n\n "+i+"\n\n int b = index / "+o+";\n index -= b * "+o+";\n\n int r = 2 * (index / "+r+");\n int c = imod(index, "+r+") * 2;\n\n return ivec"+t.length+"("+s+");\n }\n "}(t,e)}var n,r,o,a,i}(e.logicalShape,c),i=function(t){return"\n void setOutput(vec4 val) {\n "+t.output+" = val;\n }\n "}(l)):(a=function(t,e){switch(t.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(t,e){return 1===e[0]?"\n int getOutputCoords() {\n return int(resultUV.x * "+e[1]+".0);\n }\n ":1===e[1]?"\n int getOutputCoords() {\n return int(resultUV.y * "+e[0]+".0);\n }\n ":"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n return resTexRC.x * "+e[1]+" + resTexRC.y;\n }\n "}(0,e);case 2:return function(t,e){return I(t,e)?"\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2("+e[0]+", "+e[1]+"));\n }\n ":1===t[1]?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n return ivec2(index, 0);\n }\n ":1===t[0]?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n return ivec2(0, index);\n }\n ":"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n int r = index / "+t[1]+";\n int c = index - r * "+t[1]+";\n return ivec2(r, c);\n }\n "}(t,e);case 3:return n=e,r=co(["r","c","d"],t),"\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+n[0]+", "+n[1]+"));\n int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n "+r+"\n return ivec3(r, c, d);\n }\n ";case 4:return function(t,e){var n=co(["r","c","d","d2"],t);return"\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n "+n+"\n return ivec4(r, c, d, d2);\n }\n "}(t,e);case 5:return function(t,e){var n=co(["r","c","d","d2","d3"],t);return"\n ivec5 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2("+e[0]+",\n "+e[1]+"));\n\n int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n\n "+n+"\n\n ivec5 outShape = ivec5(r, c, d, d2, d3);\n return outShape;\n }\n "}(t,e);case 6:return function(t,e){var n=co(["r","c","d","d2","d3","d4"],t);return"\n ivec6 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n\n "+n+"\n\n ivec6 result = ivec6(r, c, d, d2, d3, d4);\n return result;\n }\n "}(t,e);default:throw new Error(t.length+"-D output sampling is not yet supported")}var n,r}(e.logicalShape,c),i=function(t){return"\n void setOutput(float val) {\n "+t.output+" = vec4(val, 0, 0, 0);\n }\n "}(l)),r&&(h+=go),[h,f,i,s,a,u,n].join("\n")}var po="\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n int texelIndex = index / 2;\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",vo="\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n int texNumC, int row, int col) {\n int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",mo="\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n int texelsInBatch, int texelsInLogicalRow, int b,\n int row, int col) {\n int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",go="\n float getChannel(vec4 frag, vec2 innerDims) {\n vec2 modCoord = mod(innerDims, 2.);\n return modCoord.x == 0. ?\n (modCoord.y == 0. ? frag.r : frag.g) :\n (modCoord.y == 0. ? frag.b : frag.a);\n }\n float getChannel(vec4 frag, int dim) {\n float modCoord = mod(float(dim), 2.);\n return modCoord == 0. ? frag.r : frag.g;\n }\n";function yo(t){return"offset"+t}function bo(t){var e=t.name,n=R(t.shapeInfo.logicalShape);return n<2?"return "+e+";":"\n for (int i = 0; i < "+n+"; i++) {\n if (i == index) {\n return "+e+"[i];\n }\n }\n "}function xo(t){if(t<=1)return"int";if(2===t)return"ivec2";if(3===t)return"ivec3";if(4===t)return"ivec4";if(5===t)return"ivec5";if(6===t)return"ivec6";throw Error("GPU for rank "+t+" is not yet supported")}function wo(t,e){var n=JSON.parse(JSON.stringify(t));return n.shapeInfo.logicalShape=e,n}function Eo(t,e){return e.map((function(e){return t[e]})).join(", ")}var Co=function(t,e,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,E(t.length>2,(function(){return"Packed arg"+(n.charAt(0).toUpperCase()+n.slice(1))+" supports only inputs with rank above 2."}));var o=t[t.length-1],a=Math.ceil(o/e);this.outputShape=t.slice(0,-1),a>1&&this.outputShape.push(a),r||this.variableNames.push("bestIndicesA");var i,s,u=this.outputShape,c=u.length,l=xo(c),f=so("coords",c);if(1===a){var h=xo(s=c+1);i="\n "+h+" sourceLocR = "+h+"("+f.join()+", 0);\n ++"+f[c-1]+";\n "+h+" sourceLocG = "+h+"("+f.join()+", 0);\n ++"+f[c-2]+";\n "+h+" sourceLocA = "+h+"("+f.join()+", 0);\n --"+f[c-1]+";\n "+h+" sourceLocB = "+h+"("+f.join()+", 0);\n --"+f[c-2]+";"}else s=c,i="\n "+l+" sourceLocR = coords;\n ++"+f[c-1]+";\n "+l+" sourceLocG = coords;\n ++"+f[c-2]+";\n "+l+" sourceLocA = coords;\n --"+f[c-1]+";\n "+l+" sourceLocB = coords;\n --"+f[c-2]+";";var p=["x","y","z","w","u","v"].slice(0,s),d="."+p[s-1],v=p.map((function(t){return"int "+t})),m=so("sourceLocR",s-1).concat("inIdx.r"),g=so("sourceLocG",s-1).concat("inIdx.g"),y=so("sourceLocB",s-1).concat("inIdx.b"),b=so("sourceLocA",s-1).concat("inIdx.a"),x="max"===n?"greaterThan":"lessThan",w=r?"":"\n inIdx = round(vec4(getBestIndicesAChannel("+m.join()+"),\n getBestIndicesAChannel("+g.join()+"),\n getBestIndicesAChannel("+y.join()+"),\n getBestIndicesAChannel("+b.join()+")));",C="vec4(\n getAChannel("+m.join()+"),\n hasNextCol ? getAChannel("+g.join()+") : 0.,\n hasNextRow ? getAChannel("+y.join()+") : 0.,\n hasNextRow && hasNextCol ? getAChannel("+b.join()+") : 0.)",_=r?"":"\n float getBestIndicesAChannel("+v.join()+") {\n return getChannel(getBestIndicesA("+p.join()+"),\n vec2("+p.slice(-2).join()+"));\n }";this.userCode="\n float getAChannel("+v.join()+") {\n return getChannel(getA("+p.join()+"),\n vec2("+p.slice(-2).join()+"));\n }\n "+_+"\n void main() {\n "+l+" coords = getOutputCoords();\n bool hasNextCol = "+f[c-1]+" < "+(u[c-1]-1)+";\n bool hasNextRow = "+f[c-2]+" < "+(u[c-2]-1)+";\n "+i+"\n ivec4 srcIdx = ivec4(sourceLocR"+d+", sourceLocG"+d+",\n sourceLocB"+d+", sourceLocA"+d+") * "+e+";\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = "+C+";\n\n for (int i = 0; i < "+e+"; i++) {\n inIdx = srcIdx;\n "+w+"\n vec4 candidate = "+C+";\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4("+x+"(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n bestValue = vec4(replace.x ? candidate.x : bestValue.x,\n replace.y ? candidate.y : bestValue.y,\n replace.z ? candidate.z : bestValue.z,\n replace.w ? candidate.w : bestValue.w);\n bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n srcIdx++;\n }\n setOutput(bestIndex);\n }\n "},_o=function(t){this.variableNames=["dy"],this.outputShape=t.inShape;var e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,o=t.strideWidth,a=t.dilationHeight,i=t.dilationWidth,s=t.effectiveFilterHeight,u=t.effectiveFilterWidth,c=s-1-t.padInfo.top,l=u-1-t.padInfo.left,f=1/(e*n);this.userCode="\n const ivec2 pads = ivec2("+c+", "+l+");\n const float avgMultiplier = float("+f+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+s+";\n wR += "+a+") {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+u+";\n wC+= "+i+") {\n float dyC = float(dyCCorner + wC) / "+o+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n setOutput(dotProd);\n }\n "},ko=function(t){this.variableNames=["dy"],this.outputShape=t.inShape;var e=t.filterDepth,n=t.filterHeight,r=t.filterWidth,o=t.strideDepth,a=t.strideHeight,i=t.strideWidth,s=t.dilationDepth,u=t.dilationHeight,c=t.dilationWidth,l=t.effectiveFilterDepth,f=t.effectiveFilterHeight,h=t.effectiveFilterWidth,p=l-1-t.padInfo.front,d=f-1-t.padInfo.top,v=h-1-t.padInfo.left,m=1/(e*n*r);this.userCode="\n const ivec3 pads = ivec3("+p+", "+d+", "+v+");\n const float avgMultiplier = float("+m+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < "+l+";\n wD += "+s+") {\n float dyD = float(dyDCorner + wD) / "+o+".0;\n\n if (dyD < 0.0 || dyD >= "+t.outDepth+".0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < "+f+";\n wR += "+u+") {\n float dyR = float(dyRCorner + wR) / "+a+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+h+";\n wC += "+c+") {\n float dyC = float(dyCCorner + wC) / "+i+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n }\n setOutput(dotProd);\n }\n "},Ro=function(t,e,n,r,o,a){this.outputShape=[],this.variableNames=["x","mean","variance"],Tr(t,e),Tr(t,n);var i="0.0";null!=r&&(Tr(t,r),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");var s="1.0";null!=o&&(Tr(t,o),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=t,this.userCode="\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = "+i+";\n float scale = "+s+";\n float inv = scale * inversesqrt(variance + float("+a+"));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n "},Io=function(t,e,n,r,o,a){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],Tr(t,e),Tr(t,n);var i="vec4(0.0)";null!=r&&(Tr(t,r),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");var s="vec4(1.0)";null!=o&&(Tr(t,o),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=t,this.userCode="\n void main() {\n vec4 offset = "+i+";\n vec4 scale = "+s+";\n\n vec4 x = getXAtOutCoords();\n vec4 mean = getMeanAtOutCoords();\n vec4 variance = getVarianceAtOutCoords();\n\n vec4 inv = scale * inversesqrt(variance + vec4("+a+"));\n\n setOutput((x - mean) * inv + offset);\n }\n "},So=function(t,e,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=Tr(e,n),this.userCode="\n float binaryOpComplex(\n float areal, float aimag, float breal, float bimag) {\n "+t+"\n }\n\n void main() {\n float areal = getARealAtOutCoords();\n float aimag = getAImagAtOutCoords();\n float breal = getBRealAtOutCoords();\n float bimag = getBImagAtOutCoords();\n setOutput(binaryOpComplex(areal, aimag, breal, bimag));\n }\n "},Ao="return a + b;",Oo="return a - b;",To="return a * b;",Do="return (a < 0.) ? b * a : a;",No=function(t,e,n){this.variableNames=["A","B"],this.outputShape=Tr(e,n),this.userCode="\n float binaryOperation(float a, float b) {\n "+t+"\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n "},Fo="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",Mo=function(t,e,n,r){void 0===r&&(r=!1),this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=Tr(e,n);var o=this.outputShape.length,a="";if(r)if(0===o||1===R(this.outputShape))a="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else if(a="\n "+xo(o)+" coords = getOutputCoords();\n ",1===o)a+="\n result.y = (coords + 1) >= "+this.outputShape[0]+" ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ";else{var i=so("coords",o);a+="\n bool nextRowOutOfBounds =\n ("+i[o-2]+" + 1) >= "+this.outputShape[o-2]+";\n bool nextColOutOfBounds =\n ("+i[o-1]+" + 1) >= "+this.outputShape[o-1]+";\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n "}this.userCode="\n vec4 binaryOperation(vec4 a, vec4 b) {\n "+t+"\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n "+a+"\n\n setOutput(result);\n }\n "},Po=function(){function t(t){this.variableNames=["A"],this.outputShape=t,this.userCode="\n uniform float minVal;\n uniform float maxVal;\n\n void main() {\n float value = getAAtOutCoords();\n if (isnan(value)) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, minVal, maxVal));\n }\n "}return t.prototype.getCustomSetupFunc=function(t,e){var n=this;return function(r,o){null==n.minLoc&&(n.minLoc=r.getUniformLocationNoThrow(o,"minVal"),n.maxLoc=r.getUniformLocationNoThrow(o,"maxVal")),r.gl.uniform1f(n.minLoc,t),r.gl.uniform1f(n.maxLoc,e)}},t}(),Bo=function(){function t(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.userCode="\n uniform float minVal;\n uniform float maxVal;\n\n void main() {\n vec4 value = getAAtOutCoords();\n\n if (any(isnan(value))) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n }\n "}return t.prototype.getCustomSetupFunc=function(t,e){var n=this;return function(r,o){null==n.minLoc&&(n.minLoc=r.getUniformLocationNoThrow(o,"minVal"),n.maxLoc=r.getUniformLocationNoThrow(o,"maxVal")),r.gl.uniform1f(n.minLoc,t),r.gl.uniform1f(n.maxLoc,e)}},t}(),Lo=function(t){this.variableNames=["real","imag"],this.outputShape=t,this.userCode="\n void main() {\n float re = abs(getRealAtOutCoords());\n float im = abs(getImagAtOutCoords());\n float mx = max(re, im);\n\n // sadly the length function in glsl is not underflow-safe\n // (at least not on Intel GPUs). So the safe solution is\n // to ensure underflow-safety in all cases.\n setOutput(\n mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n );\n }\n "},Wo=function(t){this.outputShape=[],this.outputShape=Qe(t,1),this.variableNames=t.map((function(t,e){return"T"+e}));var e=new Array(t.length-1);e[0]=t[0][1];for(var n=1;n<e.length;n++)e[n]=e[n-1]+t[n][1];var r=["if (yC < "+e[0]+") setOutput(getT0(yR, yC));"];for(n=1;n<e.length;n++){var o=e[n-1];r.push("else if (yC < "+e[n]+") setOutput(getT"+n+"(yR, yC-"+o+"));")}var a=e.length,i=e[e.length-1];r.push("else setOutput(getT"+a+"(yR, yC-"+i+"));"),this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int yR = coords.x;\n int yC = coords.y;\n\n "+r.join("\n ")+"\n }\n "},Uo=function(t,e){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=Qe(t,e);var n=this.outputShape,r=n.length,o=xo(r),a=so("coords",r),i=["x","y","z","w","u","v"].slice(0,r);this.variableNames=t.map((function(t,e){return"T"+e}));var s=new Array(t.length-1);s[0]=t[0][e];for(var u=1;u<s.length;u++)s[u]=s[u-1]+t[u][e];var c=i[e],l=i.slice(-2),f=i.join(),h="if ("+c+" < "+s[0]+") {\n return getChannel(\n getT0("+f+"), vec2("+l.join()+"));\n }";for(u=1;u<s.length;u++){var p=s[u-1];h+="\n if ("+c+" < "+s[u]+" && "+c+" >= "+s[u-1]+") {\n return getChannel(\n getT"+u+"("+jo(i,c,p)+"),\n vec2("+jo(l,c,p)+"));\n }"}var d=s.length,v=s[s.length-1];h+="\n return getChannel(\n getT"+d+"("+jo(i,c,v)+"),\n vec2("+jo(l,c,v)+"));",this.userCode="\n float getValue("+i.map((function(t){return"int "+t}))+") {\n "+h+"\n }\n\n void main() {\n "+o+" coords = getOutputCoords();\n vec4 result = vec4(getValue("+a+"), 0., 0., 0.);\n\n "+a[r-1]+" = "+a[r-1]+" + 1;\n if ("+a[r-1]+" < "+n[r-1]+") {\n result.g = getValue("+a+");\n }\n\n "+a[r-2]+" = "+a[r-2]+" + 1;\n if ("+a[r-2]+" < "+n[r-2]+") {\n result.a = getValue("+a+");\n }\n\n "+a[r-1]+" = "+a[r-1]+" - 1;\n if ("+a[r-2]+" < "+n[r-2]+" &&\n "+a[r-1]+" < "+n[r-1]+") {\n result.b = getValue("+a+");\n }\n setOutput(result);\n }\n "};function jo(t,e,n){var r=t.indexOf(e);return t.map((function(t,e){return e===r?t+" - "+n:t})).join()}var zo=function(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideHeight,n=t.strideWidth,r=t.padInfo.top,o=t.padInfo.left,a="channelsLast"===t.dataFormat;this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int d2 = coords.w;\n\n // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int b = 0; b < "+t.batchSize+"; b++) {\n for (int yR = 0; yR < "+t.outHeight+"; yR++) {\n int xR = wR + yR * "+e+" - "+r+";\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int yC = 0; yC < "+t.outWidth+"; yC++) {\n int xC = wC + yC * "+n+" - "+o+";\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n if ("+a+") {\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n } else {\n float dyValue = getDy(b, d2, yR, yC);\n float xValue = getX(b, d1, xR, xC);\n dotProd += (xValue * dyValue);\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n "},Vo=function(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,o=t.strideWidth,a="channelsLast"===t.dataFormat,i=e-1-t.padInfo.top,s=n-1-t.padInfo.left,u=a?1:2,c=a?2:3,l=a?3:1;this.userCode="\n const ivec2 pads = ivec2("+i+", "+s+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords["+l+"];\n\n ivec2 dyCorner = ivec2(coords["+u+"], coords["+c+"]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+e+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = "+e+" - 1 - wR;\n\n for (int wC = 0; wC < "+n+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+o+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = "+n+" - 1 - wC;\n\n for (int d2 = 0; d2 < "+t.outChannels+"; d2++) {\n\n if ("+a+") {\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n } else {\n float xValue = getDy(batch, d2, idyR, idyC);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n "},Go=function(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideDepth,n=t.strideHeight,r=t.strideWidth,o=t.padInfo.front,a=t.padInfo.top,i=t.padInfo.left;this.userCode="\n void main() {\n ivec5 coords = getOutputCoords();\n int wF = coords.x;\n int wR = coords.y;\n int wC = coords.z;\n int d1 = coords.w;\n int d2 = coords.u;\n\n float dotProd = 0.0;\n\n for (int b = 0; b < "+t.batchSize+"; b++) {\n for (int yF = 0; yF < "+t.outDepth+"; yF++) {\n int xF = wF + yF * "+e+" - "+o+";\n\n if (xF < 0 || xF >= "+t.inDepth+") {\n continue;\n }\n\n for (int yR = 0; yR < "+t.outHeight+"; yR++) {\n int xR = wR + yR * "+n+" - "+a+";\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int yC = 0; yC < "+t.outWidth+"; yC++) {\n int xC = wC + yC * "+r+" - "+i+";\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n float dyValue = getDy(b, yF, yR, yC, d2);\n float xValue = getX(b, xF, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n "},Ho=function(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterDepth,n=t.filterHeight,r=t.filterWidth,o=t.strideDepth,a=t.strideHeight,i=t.strideWidth,s=e-1-t.padInfo.front,u=n-1-t.padInfo.top,c=r-1-t.padInfo.left;this.userCode="\n const ivec3 pads = ivec3("+s+", "+u+", "+c+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.u;\n\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyFCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n float dotProd = 0.0;\n for (int wF = 0; wF < "+e+"; wF++) {\n float dyF = float(dyFCorner + wF) / "+o+".0;\n\n if (dyF < 0.0 || dyF >= "+t.outDepth+".0 || fract(dyF) > 0.0) {\n continue;\n }\n int idyF = int(dyF);\n\n int wFPerm = "+e+" - 1 - wF;\n\n for (int wR = 0; wR < "+n+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+a+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = "+n+" - 1 - wR;\n\n for (int wC = 0; wC < "+r+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+i+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = "+r+" - 1 - wC;\n\n for (int d2 = 0; d2 < "+t.outChannels+"; d2++) {\n float xValue = getDy(batch, idyF, idyR, idyC, d2);\n float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n }\n }\n }\n setOutput(dotProd);\n }\n "},qo=function(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideHeight,n=t.strideWidth,r=t.padInfo.top,o=t.padInfo.left,a=t.outChannels/t.inChannels;this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int dm = coords.w;\n int d2 = d1 * "+a+" + dm;\n\n float dotProd = 0.0;\n\n // TO DO: Vec4 over the batch size\n for (int b = 0; b < "+t.batchSize+"; b++) {\n for (int yR = 0; yR < "+t.outHeight+"; yR++) {\n int xR = wR + yR * "+e+" - "+r+";\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int yC = 0; yC < "+t.outWidth+"; yC++) {\n int xC = wC + yC * "+n+" - "+o+";\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n setOutput(dotProd);\n }\n "},Ko=function(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,o=t.strideWidth,a=e-1-t.padInfo.top,i=n-1-t.padInfo.left,s=t.outChannels/t.inChannels;this.userCode="\n const ivec2 pads = ivec2("+a+", "+i+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n ivec2 dyCorner = coords.yz - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n float dotProd = 0.0;\n\n for (int wR = 0; wR < "+e+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = "+e+" - 1 - wR;\n\n for (int wC = 0; wC < "+n+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+o+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = "+n+" - 1 - wC;\n\n // TO DO: Vec4 over the channelMul\n for (int dm = 0; dm < "+s+"; dm++) {\n int d2 = d1 * "+s+" + dm;\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, dm);\n dotProd += xValue * wValue;\n }\n }\n }\n setOutput(dotProd);\n }\n "},Xo=function(t,e,n,r){void 0===e&&(e=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.outputShape=t.outShape;var o=t.padInfo.top,a=t.padInfo.left,i=t.strideHeight,s=t.strideWidth,u=t.dilationHeight,c=t.dilationWidth,l=t.filterHeight,f=t.filterWidth,h=4*Math.floor(t.inChannels/4),p=t.inChannels%4,d="channelsLast"===t.dataFormat,v=d?1:2,m=d?2:3,g=d?3:1,y="",b="";n&&(y=r?"float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n "+n+"\n }":"\n float activation(float x) {\n "+n+"\n }\n ",b="result = activation(result);");var x=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n "+y+"\n\n const ivec2 strides = ivec2("+i+", "+s+");\n const ivec2 pads = ivec2("+o+", "+a+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords["+g+"];\n\n ivec2 xRCCorner =\n ivec2(coords["+v+"], coords["+m+"]) * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+l+"; wR++) {\n int xR = xRCorner + wR * "+u+";\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+f+"; wC++) {\n int xC = xCCorner + wC * "+c+";\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n for (int d1 = 0; d1 < "+h+"; d1 += 4) {\n vec4 wValues = vec4(\n getW(wR, wC, d1, d2),\n getW(wR, wC, d1 + 1, d2),\n getW(wR, wC, d1 + 2, d2),\n getW(wR, wC, d1 + 3, d2)\n );\n\n if ("+d+") {\n vec4 xValues = vec4(\n getX(batch, xR, xC, d1),\n getX(batch, xR, xC, d1 + 1),\n getX(batch, xR, xC, d1 + 2),\n getX(batch, xR, xC, d1 + 3)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec4 xValues = vec4(\n getX(batch, d1, xR, xC),\n getX(batch, d1 + 1, xR, xC),\n getX(batch, d1 + 2, xR, xC),\n getX(batch, d1 + 3, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n\n if ("+(1===p)+") {\n\n if ("+d+") {\n dotProd +=\n getX(batch, xR, xC, "+h+") *\n getW(wR, wC, "+h+", d2);\n } else {\n dotProd +=\n getX(batch, "+h+", xR, xC) *\n getW(wR, wC, "+h+", d2);\n }\n\n } else if ("+(2===p)+") {\n vec2 wValues = vec2(\n getW(wR, wC, "+h+", d2),\n getW(wR, wC, "+h+" + 1, d2)\n );\n\n if ("+d+") {\n vec2 xValues = vec2(\n getX(batch, xR, xC, "+h+"),\n getX(batch, xR, xC, "+h+" + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, "+h+", xR, xC),\n getX(batch, "+h+" + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if ("+(3===p)+") {\n vec3 wValues = vec3(\n getW(wR, wC, "+h+", d2),\n getW(wR, wC, "+h+" + 1, d2),\n getW(wR, wC, "+h+" + 2, d2)\n );\n\n if ("+d+") {\n vec3 xValues = vec3(\n getX(batch, xR, xC, "+h+"),\n getX(batch, xR, xC, "+h+" + 1),\n getX(batch, xR, xC, "+h+" + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, "+h+", xR, xC),\n getX(batch, "+h+" + 1, xR, xC),\n getX(batch, "+h+" + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n "+x+"\n "+b+"\n setOutput(result);\n }\n "},$o=function(t){this.variableNames=["x","W"],this.outputShape=t.outShape;var e=t.padInfo.front,n=t.padInfo.top,r=t.padInfo.left,o=t.strideDepth,a=t.strideHeight,i=t.strideWidth,s=t.dilationDepth,u=t.dilationHeight,c=t.dilationWidth,l=t.filterDepth,f=t.filterHeight,h=t.filterWidth,p=4*Math.floor(t.inChannels/4),d=t.inChannels%4;this.userCode="\n const ivec3 strides = ivec3("+o+", "+a+", "+i+");\n const ivec3 pads = ivec3("+e+", "+n+", "+r+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d2 = coords.u;\n\n ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xFCorner = xFRCCorner.x;\n int xRCorner = xFRCCorner.y;\n int xCCorner = xFRCCorner.z;\n\n // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n // y(yF, yR, yC, d2). ? = to be determined. : = across all\n // values in that axis.\n float dotProd = 0.0;\n for (int wF = 0; wF < "+l+"; wF++) {\n int xF = xFCorner + wF * "+s+";\n\n if (xF < 0 || xF >= "+t.inDepth+") {\n continue;\n }\n\n for (int wR = 0; wR < "+f+"; wR++) {\n int xR = xRCorner + wR * "+u+";\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+h+"; wC++) {\n int xC = xCCorner + wC * "+c+";\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n for (int d1 = 0; d1 < "+p+"; d1 += 4) {\n vec4 xValues = vec4(\n getX(batch, xF, xR, xC, d1),\n getX(batch, xF, xR, xC, d1 + 1),\n getX(batch, xF, xR, xC, d1 + 2),\n getX(batch, xF, xR, xC, d1 + 3)\n );\n vec4 wValues = vec4(\n getW(wF, wR, wC, d1, d2),\n getW(wF, wR, wC, d1 + 1, d2),\n getW(wF, wR, wC, d1 + 2, d2),\n getW(wF, wR, wC, d1 + 3, d2)\n );\n\n dotProd += dot(xValues, wValues);\n }\n\n if ("+(1===d)+") {\n dotProd +=\n getX(batch, xF, xR, xC, "+p+") *\n getW(wF, wR, wC, "+p+", d2);\n } else if ("+(2===d)+") {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, "+p+"),\n getX(batch, xF, xR, xC, "+p+" + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, "+p+", d2),\n getW(wF, wR, wC, "+p+" + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if ("+(3===d)+") {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, "+p+"),\n getX(batch, xF, xR, xC, "+p+" + 1),\n getX(batch, xF, xR, xC, "+p+" + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, "+p+", d2),\n getW(wF, wR, wC, "+p+" + 1, d2),\n getW(wF, wR, wC, "+p+" + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n "},Yo=function(t,e,n,r){void 0===e&&(e=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.outputShape=t.outShape;var o=t.inHeight,a=t.inWidth,i=t.padInfo.top,s=t.padInfo.left,u=t.strideHeight,c=t.strideWidth,l=t.dilationHeight,f=t.dilationWidth,h=t.filterHeight,p=t.filterWidth,d=t.outChannels/t.inChannels,v="",m="";n&&(v=r?"float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n "+n+"\n }":"\n float activation(float x) {\n "+n+"\n }\n ",m="result = activation(result);");var g=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n "+v+"\n\n const ivec2 strides = ivec2("+u+", "+c+");\n const ivec2 pads = ivec2("+i+", "+s+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / "+d+";\n int q = d2 - d1 * "+d+";\n\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n for (int wR = 0; wR < "+h+"; wR++) {\n int xR = xRCorner + wR * "+l+";\n\n if (xR < 0 || xR >= "+o+") {\n continue;\n }\n\n for (int wC = 0; wC < "+p+"; wC++) {\n int xC = xCCorner + wC * "+f+";\n\n if (xC < 0 || xC >= "+a+") {\n continue;\n }\n\n float xVal = getX(batch, xR, xC, d1);\n float wVal = getW(wR, wC, d1, q);\n dotProd += xVal * wVal;\n }\n }\n\n float result = dotProd;\n "+g+"\n "+m+"\n setOutput(result);\n }\n "},Jo=function(t,e,n,r){void 0===e&&(e=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.outShape;for(var o=t.inHeight,a=t.inWidth,i=t.padInfo.top,s=t.padInfo.left,u=t.strideHeight,c=t.strideWidth,l=t.dilationHeight,f=t.dilationWidth,h=t.filterHeight,p=t.filterWidth,d=p,v="int xR; int xC; int xCOffset;",m=0;m<h;m++)for(var g=0;g<p;g++)v+="\n vec4 xTexelR"+m+"C"+2*g+" = vec4(0.);\n vec4 wR"+m+"C"+g+" = vec4(0.);\n vec4 xR"+m+"C"+g+" = vec4(0.);";for(m=0;m<h;m++)for(var y=0;y<d;y++){if(v+="\n xR = xRCorner + "+m*l+";\n xC = xCCorner + "+(g=2*y)*f+";\n ",1===c){if(g<p&&(v+=s%2==1?"\n xCOffset = xC + 1;\n if(xR >= 0 && xR < "+o+" && xCOffset >= 0 && xCOffset < "+a+") {\n xTexelR"+m+"C"+g+" = getX(batch, xR, xCOffset, d1);\n } else {\n xTexelR"+m+"C"+g+" = vec4(0.);\n }\n\n xCOffset = xC + 1 - 2;\n if(xR >= 0 && xR < "+o+" && xCOffset >= 0 && xCOffset < "+a+") {\n vec4 previous = getX(batch, xR, xCOffset, d1);\n xR"+m+"C"+g+" = vec4(previous.zw, xTexelR"+m+"C"+g+".xy);\n } else {\n xR"+m+"C"+g+" = vec4(0, 0, xTexelR"+m+"C"+g+".xy);\n }\n ":"\n if(xR >= 0 && xR < "+o+" && xC >= 0 && xC < "+a+") {\n xTexelR"+m+"C"+g+" = getX(batch, xR, xC, d1);\n } else {\n xTexelR"+m+"C"+g+" = vec4(0.);\n }\n\n xR"+m+"C"+g+" = xTexelR"+m+"C"+g+";\n ",g+1<p)){var b=s%2==0?x(f):f;f%2==0&&s%2==1||f%2!=0&&s%2!=1?(v+="\n xCOffset = xC + "+s%2+" + "+b+";\n\n if(xR >= 0 && xR < "+o+" &&\n xCOffset >= 0 && xCOffset < "+a+") {\n xTexelR"+m+"C"+(g+2)+" = getX(batch, xR, xCOffset, d1);\n }\n ",f>1&&(v+="\n xCOffset -= 2;\n if(xR >= 0 && xR < "+o+" &&\n xCOffset >= 0 && xCOffset < "+a+") {\n xTexelR"+m+"C"+g+" = getX(batch, xR, xCOffset, d1);\n } else {\n xTexelR"+m+"C"+g+" = vec4(0.);\n }\n "),v+="\n xR"+m+"C"+(g+1)+" = vec4(\n xTexelR"+m+"C"+g+".zw, xTexelR"+m+"C"+(g+2)+".xy);\n "):v+="\n xCOffset = xC + "+b+";\n\n if(xR >= 0 && xR < "+o+" &&\n xCOffset >= 0 && xCOffset < "+a+") {\n xTexelR"+m+"C"+(g+2)+" = getX(batch, xR, xCOffset, d1);\n }\n\n xR"+m+"C"+(g+1)+" = xTexelR"+m+"C"+(g+2)+";\n "}}else g<p&&(v+="\n if(xR >= 0 && xR < "+o+") {\n ",s%2==1?(v+="\n xCOffset = xC + 1 - "+c+";\n if(xCOffset >= 0 && xCOffset < "+a+") {\n xTexelR"+m+"C"+g+" = getX(batch, xR, xCOffset, d1);\n } else {\n xTexelR"+m+"C"+g+" = vec4(0.);\n }\n\n if(xC + 1 >= 0 && xC + 1 < "+a+") {\n xTexelR"+m+"C"+(g+2)+" = getX(batch, xR, xC + 1, d1);\n } else {\n xTexelR"+m+"C"+(g+2)+" = vec4(0.);\n }\n\n xR"+m+"C"+g+" = vec4(\n xTexelR"+m+"C"+g+".zw, xTexelR"+m+"C"+(g+2)+".zw);\n ",g+1<p&&(v+="\n vec4 final = vec4(0.);\n xCOffset = xC + 1 + "+c+";\n if(xCOffset >= 0 && xCOffset < "+a+") {\n final = getX(batch, xR, xCOffset, d1);\n }\n xR"+m+"C"+(g+1)+" = vec4(xTexelR"+m+"C"+(g+2)+".xy, final.xy);\n ")):(v+="\n if(xC >= 0 && xC < "+a+") {\n xTexelR"+m+"C"+g+" = getX(batch, xR, xC, d1);\n } else {\n xTexelR"+m+"C"+g+" = vec4(0.);\n }\n\n xCOffset = xC + "+c+";\n if(xCOffset >= 0 && xCOffset < "+a+") {\n xTexelR"+m+"C"+(g+2)+" = getX(batch, xR, xCOffset, d1);\n } else {\n xTexelR"+m+"C"+(g+2)+" = vec4(0.);\n }\n\n xR"+m+"C"+g+" = vec4(\n xTexelR"+m+"C"+g+".xy, xTexelR"+m+"C"+(g+2)+".xy);\n ",g+1<p&&(v+="\n xR"+m+"C"+(g+1)+" = vec4(\n xTexelR"+m+"C"+g+".zw, xTexelR"+m+"C"+(g+2)+".zw);\n ")),v+="}");g<p&&(v+="\n vec4 wTexelR"+m+"C"+g+" = getW("+m+", "+g+", d1, q);\n wR"+m+"C"+g+" = vec4(wTexelR"+m+"C"+g+".xz, wTexelR"+m+"C"+g+".xz);\n ",g+1<p&&(v+="\n vec4 wTexelR"+m+"C"+(g+1)+" = getW("+m+", "+(g+1)+", d1, q);\n wR"+m+"C"+(g+1)+" =\n vec4(wTexelR"+m+"C"+(g+1)+".xz, wTexelR"+m+"C"+(g+1)+".xz);"))}for(m=0;m<h;m++)for(g=0;g<p;g++)v+="dotProd += xR"+m+"C"+g+" * wR"+m+"C"+g+";";var w="",E="";n&&(w=r?"vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n "+n+"\n }":"vec4 activation(vec4 x) {\n "+n+"\n }",E="result = activation(result);");var C=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n "+w+"\n\n const ivec2 strides = ivec2("+u+", "+c+");\n const ivec2 pads = ivec2("+i+", "+s+");\n\n void main() {\n\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2;\n int q = 0;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n vec4 dotProd = vec4(0.);\n\n "+v+"\n\n vec4 result = dotProd;\n "+C+"\n "+E+"\n setOutput(result);\n }\n "},Qo=function(t,e,n,r,o){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];var a=t[0],i=t[1],s=t[2],u=t[3],c=e[0],l=n[0],f=n[1];this.outputShape=[c,l,f,u];var h="bilinear"===r?1:0,p=[i-1+".0",s-1+".0"],d=p[0],v=p[1],m=l>1?[""+(i-1)/(l-1),"(y2-y1) * height_ratio","y1*"+d+" + float(y)*(height_scale)"]:["0.0","0.0","0.5 * (y1+y2) * "+d],g=m[0],y=m[1],b=m[2],x=f>1?[""+(s-1)/(f-1),"(x2-x1) * width_ratio","x1*"+v+" + float(x)*(width_scale)"]:["0.0","0.0","0.5 * (x1+x2) * "+v],w=x[0],E=x[1],C=x[2];this.userCode="\n const float height_ratio = float("+g+");\n const float width_ratio = float("+w+");\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int y = coords[1];\n int x = coords[2];\n int d = coords[3];\n\n // get box vals\n float y1 = getBoxes(b,0);\n float x1 = getBoxes(b,1);\n float y2 = getBoxes(b,2);\n float x2 = getBoxes(b,3);\n\n // get image in batch index\n int bInd = round(getBoxInd(b));\n if(bInd < 0 || bInd >= "+a+") {\n return;\n }\n\n float height_scale = "+y+";\n float width_scale = "+E+";\n\n float in_y = "+b+";\n if( in_y < 0.0 || in_y > "+d+" ) {\n setOutput(float("+o+"));\n return;\n }\n float in_x = "+C+";\n if( in_x < 0.0 || in_x > "+v+" ) {\n setOutput(float("+o+"));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if("+h+" == 1) {\n // Compute the four integer indices.\n ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n float top = topLeft + (topRight - topLeft) * fracCR.x;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n float newValue = top + (bottom - top) * fracCR.y;\n setOutput(newValue);\n } else {\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestCR = ivec2(floor(\n sourceFracIndexCR + vec2(0.5,0.5)));\n float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n setOutput(newValue);\n }\n }\n "},Zo=function(t,e,n){this.variableNames=["x"],this.outputShape=t;var r=t.length,o=t[t.length-1],a=n?"<":">";this.userCode="\n int getIndex(int i) {\n "+(n?"return "+o+" -i - 1;":"return i;")+"\n }\n\n void main() {\n "+xo(r)+" coords = getOutputCoords();\n int end = "+ta(r,"coords")+";\n float val = 0.0;\n for (int i = "+o+" - 1; i >= 0; i -= 1) {\n int idx = getIndex(i);\n if (idx "+a+" end) {\n continue;\n }\n if (idx == end && "+e+") {\n continue;\n }\n "+ta(r,"coords")+" = idx;\n val += getX("+function(t,e){if(1===t)return""+e;if(2===t)return e+".x, "+e+".y";if(3===t)return e+".x, "+e+".y, "+e+".z";if(4===t)return e+".x, "+e+".y, "+e+".z, "+e+".w";throw Error("Cumulative sum for rank "+t+" is not yet supported")}(r,"coords")+");\n }\n setOutput(val);\n }\n "};function ta(t,e){if(1===t)return""+e;if(2===t)return e+".y";if(3===t)return e+".z";if(4===t)return e+".w";throw Error("Cumulative sum for rank "+t+" is not yet supported")}var ea=function(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=Nt.DENSE;var e=jt(t),n=uo();this.outputShape=t,this.userCode="\n ivec3 outCoordsFromFlatIndex(int index) {\n "+co(["r","c","d"],t)+"\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = 4 * (resTexRC.x * "+e[1]+" + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getA(rc.x, rc.y, rc.z);\n }\n\n "+n.output+" = result;\n }\n "},na=function(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=Nt.DENSE;var e=jt(t),n=uo();this.outputShape=t,this.userCode="\n ivec3 outCoordsFromFlatIndex(int index) {\n "+co(["r","c","d"],t)+"\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = 4 * (resTexRC.x * "+e[1]+" + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n }\n\n "+n.output+" = result;\n }\n "},ra=function(){function t(t,e,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=t,this.blockSize=e,this.dataFormat=n,this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int h = "+this.getHeightCoordString()+";\n int w = "+this.getWidthCoordString()+";\n int d = "+this.getDepthCoordString()+";\n\n int in_h = h / "+e+";\n int offset_h = imod(h, "+e+");\n int in_w = w / "+e+";\n int offset_w = imod(w, "+e+");\n int offset_d = (offset_h * "+e+" + offset_w) *\n "+this.getOutputDepthSize()+";\n int in_d = d + offset_d;\n\n float result = "+this.getInputSamplingString()+";\n setOutput(result);\n }\n "}return t.prototype.getHeightCoordString=function(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"},t.prototype.getWidthCoordString=function(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"},t.prototype.getDepthCoordString=function(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"},t.prototype.getOutputDepthSize=function(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]},t.prototype.getInputSamplingString=function(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"},t}(),oa=function(t){this.variableNames=["X"],this.outputShape=[t,t],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n setOutput(val);\n }\n "},aa=function(t){this.variableNames=["A"],this.outTexUsage=Ft.DOWNLOAD;var e=uo();this.outputShape=t,this.userCode="\n "+fo+"\n\n void main() {\n float x = getAAtOutCoords();\n "+e.output+" = encode_float(x);\n }\n "},ia=function(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=Ft.DOWNLOAD;var e=uo();this.outputShape=t,this.userCode="\n "+fo+"\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n "+e.output+" = encode_float(x);\n }\n "},sa=function(t,e,n){void 0===n&&(n=!1),this.variableNames=["A"];var r=uo(),o=e[0],a=e[1];this.outputShape=t;var i="result";n&&(i="floor(result * 255. + 0.5)"),this.userCode="\n "+lo(t)+"\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n int flatIndex = getFlatIndex(coords);\n int offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n \n int r = flatIndex / "+a+";\n int c = imod(flatIndex, "+a+");\n vec2 uv = (vec2(c, r) + halfCR) / vec2("+a+".0, "+o+".0);\n vec4 values = "+r.texture2D+"(A, uv);\n\n float result;\n\n if(offset == 0) {\n result = values[0];\n } else if(offset == 1) {\n result = values[1];\n } else if(offset == 2) {\n result = values[2];\n } else {\n result = values[3];\n }\n\n "+r.output+" = vec4("+i+", 0., 0., 0.);\n }\n "},ua=function(t,e,n){void 0===n&&(n=!1),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var r=uo(),o=e[0],a=e[1];this.outputShape=t;var i="",s="result";n&&(s="floor(result * 255. + 0.5)");for(var u=0;u<=1;u++)for(var c=0;c<=1;c++){var l=2*u+c;i+="\n localCoords = coords;\n if(localCoords[2] + "+c+" < "+t[2]+") {\n localCoords[2] += "+c+";\n if(localCoords[1] + "+u+" < "+t[1]+") {\n localCoords[1] += "+u+";\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n r = flatIndex / "+a+";\n c = imod(flatIndex, "+a+");\n uv = (vec2(c, r) + halfCR) / vec2("+a+".0, "+o+".0);\n values = "+r.texture2D+"(A, uv);\n\n if(offset == 0) {\n result["+l+"] = values[0];\n } else if(offset == 1) {\n result["+l+"] = values[1];\n } else if(offset == 2) {\n result["+l+"] = values[2];\n } else {\n result["+l+"] = values[3];\n }\n }\n }\n "}this.userCode="\n "+lo(t)+"\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n vec4 result = vec4(0.);\n int flatIndex, r, c, offset;\n ivec3 localCoords;\n vec2 uv;\n vec4 values;\n\n "+i+"\n\n "+r.output+" = "+s+";\n }\n "},ca=function(t,e,n){this.variableNames=["real","imag"];var r=e[1];this.outputShape=e;var o=n?"2.0 * "+Math.PI:"-2.0 * "+Math.PI,a=n?r+".0":"1.0";this.userCode="\n const float exponentMultiplier = "+o+";\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n "+t+"\n }\n\n float mulMatDFT(int batch, int index) {\n float indexRatio = float(index) / float("+r+");\n float exponentMultiplierTimesIndexRatio =\n exponentMultiplier * indexRatio;\n\n float result = 0.0;\n\n for (int i = 0; i < "+r+"; i++) {\n // x = (-2|2 * PI / N) * index * i;\n float x = exponentMultiplierTimesIndexRatio * float(i);\n float expR = cos(x);\n float expI = sin(x);\n float real = getReal(batch, i);\n float imag = getImag(batch, i);\n\n result +=\n unaryOpComplex(real, expR, imag, expI) / "+a+";\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n "},la=function(){function t(t,e){this.outputShape=[],this.variableNames=["x"],this.outputShape=t,this.userCode="\n uniform float value;\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "}return t.prototype.getCustomSetupFunc=function(t){var e=this;return function(n,r){null==e.valueLoc&&(e.valueLoc=n.getUniformLocationNoThrow(r,"value")),n.gl.uniform1f(e.valueLoc,t)}},t}(),fa=function(t,e,n){this.variableNames=["A","indices"];var r=t.slice();r[n]=e,this.outputShape=r,this.rank=r.length;var o=xo(this.rank),a=function(t,e){var n=t.length;if(n>4)throw Error("Gather for rank "+n+" is not yet supported");if(1===n)return"int(getIndices(resRC))";for(var r=["resRC.x","resRC.y","resRC.z","resRC.w"],o=[],a=0;a<t.length;a++)a===e?o.push("int(getIndices("+r[a]+"))"):o.push(""+r[a]);return o.join()}(t,n);this.userCode="\n void main() {\n "+o+" resRC = getOutputCoords();\n setOutput(getA("+a+"));\n }\n "},ha=function(t,e,n){this.sliceDim=t,this.strides=e,this.variableNames=["x","indices"],this.outputShape=n;var r=xo(e.length),o=xo(n.length),a=this.sliceDim>1?"strides[j]":"strides";this.userCode="\n "+r+" strides = "+r+"("+this.strides+");\n void main() {\n "+o+" coords = getOutputCoords();\n int flattenIndex = 0;\n for (int j = 0; j < "+this.sliceDim+"; j++) {\n int index = round(getIndices(coords[0], j));\n flattenIndex += index * "+a+";\n }\n setOutput(getX(flattenIndex, coords[1]));\n }\n "};function pa(t,e){var n=uo();return Xt(t,e,n.version+"\n precision highp float;\n "+n.attribute+" vec3 clipSpacePos;\n "+n.attribute+" vec2 uv;\n "+n.varyingVs+" vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }")}function da(t,e){return ne(t,e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}function va(t,e){return re(t,e,new Uint16Array([0,1,2,2,1,3]))}function ma(t,e,n,r,o,a,i){ae(n,r);var s=oe(t,e),u=t.TEXTURE_2D;return Gt(t,e,(function(){return t.bindTexture(u,s)})),Gt(t,e,(function(){return t.texParameteri(u,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE)})),Gt(t,e,(function(){return t.texParameteri(u,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)})),Gt(t,e,(function(){return t.texParameteri(u,t.TEXTURE_MIN_FILTER,t.NEAREST)})),Gt(t,e,(function(){return t.texParameteri(u,t.TEXTURE_MAG_FILTER,t.NEAREST)})),Gt(t,e,(function(){return t.texImage2D(u,0,o,n,r,0,a,i,null)})),Gt(t,e,(function(){return t.bindTexture(t.TEXTURE_2D,null)})),s}function ga(t,e,n,r,o){var a=Ut(n,r);return ma(t,e,a[0],a[1],o.internalFormatFloat,o.textureFormatFloat,t.FLOAT)}function ya(t,e,n,r,o){var a=Ut(n,r);return ma(t,e,a[0],a[1],o.internalFormatHalfFloat,o.textureFormatFloat,o.textureTypeHalfFloat)}function ba(t,e,n,r,o){var a=Ut(n,r);return ma(t,e,a[0],a[1],t.RGBA,t.RGBA,t.UNSIGNED_BYTE)}function xa(t,e,n,r,o){var a=zt(n,r);return ma(t,e,a[0],a[1],o.internalFormatPackedFloat,t.RGBA,t.FLOAT)}function wa(t,e,n,r,o){var a=zt(n,r);return ma(t,e,a[0],a[1],o.internalFormatPackedHalfFloat,t.RGBA,o.textureTypeHalfFloat)}function Ea(t,e,n,r){return Gt(t,e,(function(){return t.bindBuffer(t.ARRAY_BUFFER,r)})),se(t,e,n,"clipSpacePos",r,3,20,0)&&se(t,e,n,"uv",r,2,20,12)}function Ca(t,e,n,r,o,a,i){var s,u,c;Gt(t,e,(function(){return t.bindTexture(t.TEXTURE_2D,n)})),a instanceof Uint8Array?(s=new Uint8Array(r*o*4),u=t.UNSIGNED_BYTE,c=t.RGBA):(s=new Float32Array(r*o*4),u=t.FLOAT,c=i.internalFormatPackedFloat),s.set(a),Gt(t,e,(function(){return t.texImage2D(t.TEXTURE_2D,0,c,r,o,0,t.RGBA,u,s)})),Gt(t,e,(function(){return t.bindTexture(t.TEXTURE_2D,null)}))}function _a(t,e,n,r){Gt(t,e,(function(){return t.bindTexture(t.TEXTURE_2D,n)})),r.data instanceof Uint8Array?Gt(t,e,(function(){return t.texImage2D(t.TEXTURE_2D,0,t.RGBA,r.width,r.height,0,t.RGBA,t.UNSIGNED_BYTE,r.data)})):Gt(t,e,(function(){return t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r)})),Gt(t,e,(function(){return t.bindTexture(t.TEXTURE_2D,null)}))}function ka(t,e,n,r,o){var a=t.createBuffer();Gt(t,e,(function(){return t.bindBuffer(t.PIXEL_PACK_BUFFER,a)}));var i=16*n*r;return Gt(t,e,(function(){return t.bufferData(t.PIXEL_PACK_BUFFER,i,t.STREAM_READ)})),Gt(t,e,(function(){return t.readPixels(0,0,r,n,t.RGBA,t.FLOAT,0)})),Gt(t,e,(function(){return t.bindBuffer(t.PIXEL_PACK_BUFFER,null)})),a}function Ra(t,e,n){var r=t,o=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,e),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,o),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),o}function Ia(t,e,n,r,o){var a=Ut(n,r),i=a[0],s=a[1],u=new Uint8Array(n*r*4);return Gt(t,e,(function(){return t.readPixels(0,0,i,s,o.downloadTextureFormat,t.UNSIGNED_BYTE,u)})),new Float32Array(u.buffer)}function Sa(t,e,n,r,o,a,i,s){var u=t,c=new Float32Array(function(t,e){var n=zt(t,e);return n[0]*n[1]*4}(a,i));return u.bindBuffer(u.PIXEL_PACK_BUFFER,e),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,c),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),c}function Aa(t,e,n,r){var o=new Float32Array(n*r*4);return Gt(t,e,(function(){return t.readPixels(0,0,r,n,t.RGBA,t.FLOAT,o)})),o}var Oa=Object.freeze({createVertexShader:pa,createVertexBuffer:da,createIndexBuffer:va,createFloat32MatrixTexture:ga,createFloat16MatrixTexture:ya,createUnsignedBytesMatrixTexture:ba,createPackedMatrixTexture:xa,createFloat16PackedMatrixTexture:wa,bindVertexProgramAttributeStreams:Ea,uploadDenseMatrixToTexture:Ca,uploadPixelDataToTexture:_a,createBufferFromOutputTexture:ka,downloadFloat32MatrixFromBuffer:Ra,downloadByteEncodedFloatMatrixFromOutputTexture:Ia,downloadPackedMatrixFromBuffer:Sa,downloadMatrixFromPackedOutputTexture:Aa}),Ta=function(){function t(t){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];var e=f().getNumber("WEBGL_VERSION");null!=t?(this.gl=t,Lt(e,t)):this.gl=Wt(e);var n="WEBGL_color_buffer_float";if(1===f().getNumber("WEBGL_VERSION")){if(this.textureFloatExtension=Kt(this.gl,this.debug,"OES_texture_float"),Ie(this.gl,"OES_texture_half_float"))this.textureHalfFloatExtension=Kt(this.gl,this.debug,"OES_texture_half_float");else if(f().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(n),Ie(this.gl,"EXT_color_buffer_half_float"))this.colorBufferHalfFloatExtension=Kt(this.gl,this.debug,"EXT_color_buffer_half_float");else if(f().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(n="EXT_color_buffer_float",Ie(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!Ie(this.gl,"EXT_color_buffer_half_float"))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension("EXT_color_buffer_half_float")}this.vertexBuffer=da(this.gl,this.debug),this.indexBuffer=va(this.gl,this.debug),this.framebuffer=ie(this.gl,this.debug),this.textureConfig=Vt(this.gl,this.textureHalfFloatExtension)}return Object.defineProperty(t.prototype,"debug",{get:function(){return f().getBool("DEBUG")},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){var t=this;if(!this.disposed){this.program,this.outputTexture;var e=this.gl;Gt(e,this.debug,(function(){return e.finish()})),Gt(e,this.debug,(function(){return e.bindFramebuffer(e.FRAMEBUFFER,null)})),Gt(e,this.debug,(function(){return e.deleteFramebuffer(t.framebuffer)})),Gt(e,this.debug,(function(){return e.bindBuffer(e.ARRAY_BUFFER,null)})),Gt(e,this.debug,(function(){return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)})),Gt(e,this.debug,(function(){return e.deleteBuffer(t.indexBuffer)})),this.disposed=!0}},t.prototype.createFloat32MatrixTexture=function(t,e){return this.throwIfDisposed(),ga(this.gl,this.debug,t,e,this.textureConfig)},t.prototype.createFloat16MatrixTexture=function(t,e){return this.throwIfDisposed(),ya(this.gl,this.debug,t,e,this.textureConfig)},t.prototype.createUnsignedBytesMatrixTexture=function(t,e){return this.throwIfDisposed(),ba(this.gl,this.debug,t,e,this.textureConfig)},t.prototype.uploadPixelDataToTexture=function(t,e){this.throwIfDisposed(),_a(this.gl,this.debug,t,e)},t.prototype.uploadDenseMatrixToTexture=function(t,e,n,r){this.throwIfDisposed(),Ca(this.gl,this.debug,t,e,n,r,this.textureConfig)},t.prototype.createFloat16PackedMatrixTexture=function(t,e){return this.throwIfDisposed(),wa(this.gl,this.debug,t,e,this.textureConfig)},t.prototype.createPackedMatrixTexture=function(t,e){return this.throwIfDisposed(),xa(this.gl,this.debug,t,e,this.textureConfig)},t.prototype.deleteMatrixTexture=function(t){var e=this;this.throwIfDisposed(),this.outputTexture===t&&(pe(this.gl,this.debug,this.framebuffer),this.outputTexture=null),Gt(this.gl,this.debug,(function(){return e.gl.deleteTexture(t)}))},t.prototype.downloadByteEncodedFloatMatrixFromOutputTexture=function(t,e,n){var r=this;return this.downloadMatrixDriver(t,(function(){return Ia(r.gl,r.debug,e,n,r.textureConfig)}))},t.prototype.downloadPackedMatrixFromBuffer=function(t,e,n,r,o,a){return Sa(this.gl,t,0,0,0,o,a,this.textureConfig)},t.prototype.downloadFloat32MatrixFromBuffer=function(t,e){return Ra(this.gl,t,e)},t.prototype.createBufferFromTexture=function(t,e,n){this.bindTextureToFrameBuffer(t);var r=ka(this.gl,this.debug,e,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r},t.prototype.createAndWaitForFence=function(){var t=this.createFence(this.gl);return this.pollFence(t)},t.prototype.createFence=function(t){var e,n,r=this;if(f().getBool("WEBGL_FENCE_API_ENABLED")){var o=t,a=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);t.flush(),n=function(){var t=o.clientWaitSync(a,0,0);return t===o.ALREADY_SIGNALED||t===o.CONDITION_SATISFIED},e=a}else f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(e=this.beginQuery(),this.endQuery(),n=function(){return r.isQueryAvailable(e,f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}):n=function(){return!0};return{query:e,isFencePassed:n}},t.prototype.downloadMatrixFromPackedTexture=function(t,e,n){var r=this;return this.downloadMatrixDriver(t,(function(){return Aa(r.gl,r.debug,e,n)}))},t.prototype.createProgram=function(t){this.throwIfDisposed();var e=this.gl,n=$t(e,this.debug,t),r=pa(e,this.debug),o=Zt(e,this.debug);return Gt(e,this.debug,(function(){return e.attachShader(o,r)})),Gt(e,this.debug,(function(){return e.attachShader(o,n)})),te(e,this.debug,o),this.debug&&ee(e,this.debug,o),this.vertexAttrsAreBound||(this.setProgram(o),this.vertexAttrsAreBound=Ea(e,this.debug,this.program,this.vertexBuffer)),o},t.prototype.deleteProgram=function(t){var e=this;this.throwIfDisposed(),t===this.program&&(this.program=null),null!=t&&Gt(this.gl,this.debug,(function(){return e.gl.deleteProgram(t)}))},t.prototype.setProgram=function(t){var e=this;this.throwIfDisposed(),this.program=t,null!=this.program&&this.debug&&ee(this.gl,this.debug,this.program),Gt(this.gl,this.debug,(function(){return e.gl.useProgram(t)}))},t.prototype.getUniformLocation=function(t,e,n){return void 0===n&&(n=!0),this.throwIfDisposed(),n?ce(this.gl,this.debug,t,e):le(this.gl,t,e)},t.prototype.getAttributeLocation=function(t,e){var n=this;return this.throwIfDisposed(),Gt(this.gl,this.debug,(function(){return n.gl.getAttribLocation(t,e)}))},t.prototype.getUniformLocationNoThrow=function(t,e){return this.throwIfDisposed(),this.gl.getUniformLocation(t,e)},t.prototype.setInputMatrixTexture=function(t,e,n){this.throwIfDisposed(),this.throwIfNoProgram(),fe(this.gl,this.debug,this.program,t,e,n)},t.prototype.setOutputMatrixTexture=function(t,e,n){this.setOutputMatrixTextureDriver(t,n,e)},t.prototype.setOutputPackedMatrixTexture=function(t,e,n){this.throwIfDisposed();var r=zt(e,n),o=r[0],a=r[1];this.setOutputMatrixTextureDriver(t,o,a)},t.prototype.setOutputMatrixWriteRegion=function(t,e,n,r){this.setOutputMatrixWriteRegionDriver(n,t,r,e)},t.prototype.setOutputPackedMatrixWriteRegion=function(t,e,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")},t.prototype.debugValidate=function(){null!=this.program&&ee(this.gl,this.debug,this.program),de(this.gl)},t.prototype.executeProgram=function(){this.throwIfDisposed(),this.throwIfNoProgram();var t=this.gl;this.debug&&this.debugValidate(),Gt(t,this.debug,(function(){return t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0)}))},t.prototype.blockUntilAllProgramsCompleted=function(){var t=this;this.throwIfDisposed(),Gt(this.gl,this.debug,(function(){return t.gl.finish()}))},t.prototype.getQueryTimerExtension=function(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=Kt(this.gl,this.debug,2===f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension},t.prototype.getQueryTimerExtensionWebGL2=function(){return this.getQueryTimerExtension()},t.prototype.getQueryTimerExtensionWebGL1=function(){return this.getQueryTimerExtension()},t.prototype.beginQuery=function(){if(2===f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var t=this.gl,e=this.getQueryTimerExtensionWebGL2(),n=t.createQuery();return t.beginQuery(e.TIME_ELAPSED_EXT,n),n}var r=this.getQueryTimerExtensionWebGL1(),o=r.createQueryEXT();return r.beginQueryEXT(r.TIME_ELAPSED_EXT,o),o},t.prototype.endQuery=function(){if(2!==f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var t=this.getQueryTimerExtensionWebGL1();t.endQueryEXT(t.TIME_ELAPSED_EXT)}else{var e=this.gl,n=this.getQueryTimerExtensionWebGL2();e.endQuery(n.TIME_ELAPSED_EXT)}},t.prototype.waitForQueryAndGetTime=function(t){return u(this,void 0,void 0,(function(){var e=this;return c(this,(function(n){switch(n.label){case 0:return[4,D((function(){return e.disposed||e.isQueryAvailable(t,f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}))];case 1:return n.sent(),[2,this.getQueryTime(t,f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))]}}))}))},t.prototype.getQueryTime=function(t,e){if(0===e)return null;if(2===e){var n=this.gl;return n.getQueryParameter(t,n.QUERY_RESULT)/1e6}var r=this.getQueryTimerExtensionWebGL1();return r.getQueryObjectEXT(t,r.QUERY_RESULT_EXT)/1e6},t.prototype.isQueryAvailable=function(t,e){if(0===e)return!0;if(2===e){var n=this.gl,r=this.getQueryTimerExtensionWebGL2(),o=n.getQueryParameter(t,n.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),o&&!this.disjoint}return o=(r=this.getQueryTimerExtensionWebGL1()).getQueryObjectEXT(t,r.QUERY_RESULT_AVAILABLE_EXT),null==this.disjoint&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),o&&!this.disjoint},t.prototype.pollFence=function(t){var e=this;return new Promise((function(n){e.addItemToPoll((function(){return t.isFencePassed()}),(function(){return n()}))}))},t.prototype.pollItems=function(){for(var t=function(t){for(var e=0;e<t.length;++e){if(!t[e]())break}return e-1}(this.itemsToPoll.map((function(t){return t.isDoneFn}))),e=0;e<=t;++e)(0,this.itemsToPoll[e].resolveFn)();this.itemsToPoll=this.itemsToPoll.slice(t+1)},t.prototype.addItemToPoll=function(t,e){var n=this;this.itemsToPoll.push({isDoneFn:t,resolveFn:e}),this.itemsToPoll.length>1||D((function(){return n.pollItems(),0===n.itemsToPoll.length}))},t.prototype.bindTextureToFrameBuffer=function(t){this.throwIfDisposed(),he(this.gl,this.debug,t,this.framebuffer),this.debug&&de(this.gl)},t.prototype.unbindTextureToFrameBuffer=function(){null!=this.outputTexture?(he(this.gl,this.debug,this.outputTexture,this.framebuffer),this.debug&&de(this.gl)):pe(this.gl,this.debug,this.framebuffer)},t.prototype.downloadMatrixDriver=function(t,e){this.bindTextureToFrameBuffer(t);var n=e();return this.unbindTextureToFrameBuffer(),n},t.prototype.setOutputMatrixTextureDriver=function(t,e,n){this.throwIfDisposed();var r=this.gl;he(r,this.debug,t,this.framebuffer),this.debug&&de(r),this.outputTexture=t,Gt(r,this.debug,(function(){return r.viewport(0,0,e,n)})),Gt(r,this.debug,(function(){return r.scissor(0,0,e,n)}))},t.prototype.setOutputMatrixWriteRegionDriver=function(t,e,n,r){var o=this;this.throwIfDisposed(),Gt(this.gl,this.debug,(function(){return o.gl.scissor(t,e,n,r)}))},t.prototype.throwIfDisposed=function(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")},t.prototype.throwIfNoProgram=function(){if(null==this.program)throw new Error("No GPU program is currently set.")},t}();function Da(t,e){if(t.length!==e.length)throw Error("Binary was compiled with "+t.length+" inputs, but was executed with "+e.length+" inputs");t.forEach((function(t,n){var r=t.logicalShape,o=e[n],a=o.shape;if(!I(r,a))throw Error("Binary was compiled with different shapes than the current args. Shapes "+r+" and "+a+" must match");if(!t.isUniform||!o.isUniform){var i=t.texShape,s=o.isUniform?null:o.texData.texShape;if(!I(i,s))throw Error("Binary was compiled with different texture shapes than the current args. Shape "+i+" and "+s+" must match")}}))}var Na=function(t,e,n){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;for(var r=n.filterWidth,o=n.inChannels,a=n.strideWidth,i=n.strideHeight,s=n.padInfo,u=n.outWidth,c=n.dilationWidth,l=n.dilationHeight,f=n.dataFormat,h=s.left,p=s.top,d=o*r,v=uo(),m="channelsLast"===f,g=m?0:1,y=m?1:2,b="",x=0;x<=1;x++)for(var w=0;w<=1;w++)b+="\n blockIndex = rc.y + "+w+";\n pos = rc.x + "+x+";\n\n if(blockIndex < "+t[1]+" && pos < "+t[0]+") {\n offsetY = int(blockIndex / ("+u+")) * "+i+" - "+p+";\n d0 = offsetY + "+l+" * (pos / "+d+");\n\n if(d0 < "+e[g]+" && d0 >= 0) {\n\n offsetX = int(mod(float(blockIndex), "+u+".) * "+a+". - "+h+".);\n d1 = offsetX + "+c+" * (int(mod(float(pos), "+d+".) / "+o+".));\n\n if(d1 < "+e[y]+" && d1 >= 0) {\n\n ch = int(mod(float(pos), "+o+".));\n\n if ("+m+") {\n innerDims = vec2(d1, ch);\n result["+(2*x+w)+"] = getChannel(\n getA(d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result["+(2*x+w)+"] = getChannel(\n getA(ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n ";this.userCode="\n void main() {\n ivec2 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n "+b+"\n\n "+v.output+" = result;\n }\n "},Fa=function(t,e,n,r,o){this.variableNames=["x"],this.outputShape=[];var a,i=e,s=t[3]-1;this.outputShape=t;var u="float("+n+") + float("+r+") * sum";a=.5===o?"inversesqrt("+u+")":1===o?"1.0/("+u+")":"exp(log("+u+") * float(-"+o+"));",this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n int d = coords[3];\n float x = getX(b, r, c, d);\n float sum = 0.0;\n for (int j = -"+i+"; j <= "+i+"; j++) {\n int idx = d + j;\n if (idx >= 0 && idx <= "+s+") {\n float z = getX(b, r, c, idx);\n sum += z * z;\n }\n }\n float val = x * "+a+";\n setOutput(val);\n }\n "},Ma=function(t,e,n,r,o){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=t,this.depth=t[3],this.depthRadius=e,this.bias=n,this.alpha=r,this.beta=o,this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n\n float result = 0.0;\n for (int d = 0; d < "+this.depth+"; ++d) {\n int depthBegin = int(max(0.0, float(d - "+e+")));\n int depthEnd = int(min(float("+this.depth+"),\n float(d + "+e+" + 1)));\n\n const int MIN_DEPTH_BEGIN = 0;\n const int MAX_DEPTH_END = "+this.depth+";\n\n float norm = 0.0;\n for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd) {\n norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n }\n else {\n break;\n }\n }\n\n norm = float("+r+") * norm + float("+n+");\n\n for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd){\n float dyi = -2.0 * float("+r+")\n * float("+o+")\n * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * "+o+");\n }\n if (k == coords[3]) {\n dyi *= getDy(b, r, c, d);\n result += dyi;\n }\n }\n else {\n break;\n }\n }\n }\n setOutput(result);\n }\n "},Pa=function(t,e,n,r,o){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;var a,i=e,s=t[3]-1;this.outputShape=t;var u="float("+n+") + float("+r+") * sum";a=.5===o?"inversesqrt("+u+")":1===o?"1.0/("+u+")":"exp(log("+u+") * float(-"+o+"));",this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords.x;\n int r = coords.y;\n int c = coords.z;\n int d = coords.w;\n\n bool hasNextCol = d < "+this.outputShape[3]+";\n bool hasNextRow = c < "+this.outputShape[2]+";\n\n vec4 sum = vec4(0.);\n vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n vec4 xAtOutputCoords = vec4(\n getChannel(xFragAtOutputCoords, vec2(c, d)),\n hasNextCol ?\n getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n hasNextRow ?\n getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n (hasNextRow && hasNextCol) ?\n getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n );\n\n int firstChannel = d - "+i+";\n vec2 cache = vec2(0.);\n if(firstChannel >= 0){\n vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n if(hasNextRow){\n cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n }\n }\n\n ivec2 depth = ivec2(d, d + 1);\n for (int j = - "+i+"; j <= "+i+"; j++) {\n ivec2 idx = depth + j;\n bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n bvec2 belowUpperBound = lessThanEqual(idx, ivec2("+s+"));\n\n bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n if(depthInRange || depthPlusOneInRange){\n vec4 z = vec4(0.);\n vec4 xFragAtCurrentDepth;\n z.xz = cache.xy;\n if(depthPlusOneInRange && hasNextCol){\n xFragAtCurrentDepth = idx.y != d ?\n getX(b, r, c, idx.y) : xFragAtOutputCoords;\n z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n if(hasNextRow){\n z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n }\n }\n cache.xy = z.yw;\n sum += z * z;\n }\n }\n vec4 result = xAtOutputCoords * "+a+";\n setOutput(result);\n }\n "},Ba=function(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;var e=t.strideHeight,n=t.strideWidth,r=t.dilationHeight,o=t.effectiveFilterHeight,a=t.effectiveFilterWidth,i=o-1-t.padInfo.top,s=a-1-t.padInfo.left,u=o*a-1;this.userCode="\n const ivec2 pads = ivec2("+i+", "+s+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+o+";\n wR += "+r+") {\n float dyR = float(dyRCorner + wR) / "+e+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+a+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+n+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n int maxPosValue = "+u+" - int(getMaxPos(b, idyR, idyC, d));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue = wR * "+a+" + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n "},La=function(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;var e=t.strideDepth,n=t.strideHeight,r=t.strideWidth,o=t.dilationDepth,a=t.dilationHeight,i=t.dilationWidth,s=t.effectiveFilterDepth,u=t.effectiveFilterHeight,c=t.effectiveFilterWidth,l=s-1-t.padInfo.front,f=u-1-t.padInfo.top,h=c-1-t.padInfo.left,p=s*u*c-1;this.userCode="\n const ivec3 pads = ivec3("+l+", "+f+", "+h+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < "+s+";\n wD += "+o+") {\n float dyD = float(dyDCorner + wD) / "+e+".0;\n\n if (dyD < 0.0 || dyD >= "+t.outDepth+".0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < "+u+";\n wR += "+a+") {\n float dyR = float(dyRCorner + wR) / "+n+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+c+";\n wC += "+i+") {\n float dyC = float(dyCCorner + wC) / "+r+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n int maxPosValue = "+p+" -\n int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue =\n wD * "+u+" * "+c+" +\n wR * "+c+" + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n }\n setOutput(dotProd);\n }\n "},Wa=function(t,e,n,r,o,a,i){void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===a&&(a=null),void 0===i&&(i=!1),this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;var s=n?t[1]:t[2],u=Math.ceil(s/2),c=n?"i * 2, rc.y":"rc.y, i * 2",l=r?"rc.z, i * 2":"i * 2, rc.z",f=n?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],h=r?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],p="",d="";a&&(p=i?"vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n "+a+"\n }":"vec4 activation(vec4 x) {\n "+a+"\n }",d="result = activation(result);");var v=o?"result += getBiasAtOutCoords();":"";o&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),this.userCode="\n "+p+"\n\n const float sharedDimension = "+u+".0;\n\n vec4 dot2x2ARowBCol(ivec3 rc) {\n vec4 result = vec4(0);\n for (int i = 0; i < "+u+"; i++) {\n vec4 a = getMatrixA(rc.x, "+c+");\n vec4 b = getMatrixB(rc.x, "+l+");\n\n // These swizzled products need to be separately added.\n // See: https://github.com/tensorflow/tfjs/issues/1735\n result += ("+f[0]+" * "+h[0]+");\n result += ("+f[1]+" * "+h[1]+");\n }\n return result;\n }\n\n void main() {\n ivec3 rc = getOutputCoords();\n vec4 result = dot2x2ARowBCol(rc);\n\n "+v+"\n\n "+d+"\n\n setOutput(result);\n }\n "},Ua=function(){function t(t,e,n){this.variableNames=["probs"],this.outputShape=[t,n],this.userCode="\n uniform float seed;\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n\n float r = random(seed);\n float cdf = 0.0;\n\n for (int i = 0; i < "+(e-1)+"; i++) {\n cdf += getProbs(batch, i);\n\n if (r < cdf) {\n setOutput(float(i));\n return;\n }\n }\n\n // If no other event happened, last event happened.\n setOutput(float("+(e-1)+"));\n }\n "}return t.prototype.getCustomSetupFunc=function(t){var e=this;return function(n,r){null==e.seedLoc&&(e.seedLoc=n.getUniformLocation(r,"seed")),n.gl.uniform1f(e.seedLoc,t)}},t}(),ja=function(t,e,n,r){this.variableNames=["indices"],this.outputShape=[t,e],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int index = round(getIndices(coords.x));\n setOutput(mix(float("+r+"), float("+n+"),\n float(index == coords.y)));\n }\n "},za=function(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=t;var e=t.length;if(0===e)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{var n=so("rc",e),r=xo(e),o=function(t,e,n){if(1===t)return"rc > "+e[0];for(var r="",o=t-2;o<t;o++)r+=n[o]+" >= "+e[o],o<t-1&&(r+="||");return r}(e,t,n),a=function(t,e,n,r){if(1===t)return"";var o=r.slice(-2);return"\n int r = "+o[0]+";\n int c = "+o[1]+";\n int rp1 = r + 1;\n int cp1 = c + 1;\n\n bool cEdge = cp1 >= "+e+";\n bool rEdge = rp1 >= "+n+";\n "}(e,t[t.length-1],t[t.length-2],n),i=function(t,e){var n=t.length,r=function(t,e){for(var n=[],r=0;r<=1;r++)for(var o=0;o<=1;o++){for(var a=(0===r?"r":"rp1")+", "+(0===o?"c":"cp1"),i=2;i<t;i++)a=e[e.length-1-i]+","+a;n.push(a)}return n}(n,e);return 1===n?"getA(rc),\n rc + 1 >= "+t[0]+" ? 0. : getA(rc + 1),\n 0, 0":"getA("+r[0]+"),\n cEdge ? 0. : getA("+r[1]+"),\n rEdge ? 0. : getA("+r[2]+"),\n rEdge || cEdge ? 0. : getA("+r[3]+")"}(t,n);this.userCode="\n void main() {\n "+r+" rc = getOutputCoords();\n\n if("+o+") {\n setOutput(vec4(0));\n } else {\n "+a+"\n\n setOutput(vec4("+i+"));\n }\n }\n "}},Va=function(t,e,n){this.variableNames=["x"],this.outputShape=e.map((function(e,n){return e[0]+t[n]+e[1]}));var r=t.length,o=xo(r),a=e.map((function(t){return t[0]})).join(","),i=e.map((function(e,n){return e[0]+t[n]})).join(","),s=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?"\n "+o+" start = "+o+"("+a+");\n "+o+" end = "+o+"("+i+");\n\n void main() {\n "+o+" outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(float("+n+"));\n } else {\n "+o+" coords = outC - start;\n setOutput(getX("+s+"));\n }\n }\n ":"\n int start = "+a+";\n int end = "+i+";\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(float("+n+"));\n } else {\n setOutput(getX(outC - start));\n }\n }\n "},Ga=function(t,e,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.map((function(e,n){return e[0]+t[n]+e[1]}));for(var r=t.length,o=xo(r),a=e.map((function(t){return t[0]})).join(","),i=e.map((function(e,n){return e[0]+t[n]})).join(","),s=so("rc",r),u=so("source",r),c=s[r-1]+" < "+this.outputShape[r-1],l=1===r?"source":"vec2("+u.slice(-2).join()+")",f=[o+" rc = outputLoc;",s[r-1]+" += 1;\n if("+c+") {\n ",1===r?"":"}\n rc = outputLoc;\n "+s[r-2]+" += 1;\n if("+s[r-2]+" < "+this.outputShape[r-2]+") {",1===r?"":" "+s[r-1]+" += 1;\n if("+c+") {"],h=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",p="",d=0,v=1===r?2:4;d<v;d++)p+="\n "+f[d]+"\n if ("+h+") {\n result["+d+"] = float("+n+");\n } else {\n "+o+" source = rc - start;\n result["+d+"] = getChannel(getX("+u.join()+"), "+l+");\n }\n ";p+=1===r?"} ":"}}",this.userCode="\n const "+o+" start = "+o+"("+a+");\n const "+o+" end = "+o+"("+i+");\n\n void main() {\n "+o+" outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n "+p+"\n setOutput(result);\n }\n "},Ha=function(t,e,n){if(this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");var r=t.filterWidth,o=t.strideHeight,a=t.strideWidth,i=t.dilationHeight,s=t.dilationWidth,u=t.effectiveFilterHeight,c=t.effectiveFilterWidth,l=t.padInfo.top,f=t.padInfo.left;this.outputShape=t.outShape;var h="avg"===e,p="0.0";if(h||(p="-1.0 / 1e-20"),n)this.userCode="\n const ivec2 strides = ivec2("+o+", "+a+");\n const ivec2 pads = ivec2("+l+", "+f+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n float avgValue = 0.0;\n\n for (int wR = 0; wR < "+u+";\n wR += "+i+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+c+";\n wC += "+s+") {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value >= currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = wR * "+c+" + wC;\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n ";else{var d=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===e&&(d="avgValue / count");var v=4*Math.floor(r/4),m=r%4,g="\n if ("+h+") {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n ";this.userCode="\n const ivec2 strides = ivec2("+o+", "+a+");\n const ivec2 pads = ivec2("+l+", "+f+");\n const float initializationValue = "+p+";\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xR, int xC, int d) {\n if (xC < 0 || xC >= "+t.inWidth+") {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4("+p+");\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < "+u+";\n wR += "+i+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+v+"; wC += 4) {\n int xC = xCCorner + wC * "+s+";\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + "+s+", d),\n getValue(batch, xR, xC + 2 * "+s+", d),\n getValue(batch, xR, xC + 3 * "+s+", d)\n );\n\n "+g+"\n }\n\n int xC = xCCorner + "+v+";\n if ("+(1===m)+") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n "+g+"\n } else if ("+(2===m)+") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + "+s+", d),\n initializationValue,\n initializationValue\n );\n\n "+g+"\n } else if ("+(3===m)+") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + "+s+", d),\n getValue(batch, xR, xC + 2 * "+s+", d),\n initializationValue\n );\n\n "+g+"\n }\n }\n setOutput("+d+");\n }\n "}},qa=function(t,e,n){if(this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");var r=t.filterWidth,o=t.strideDepth,a=t.strideHeight,i=t.strideWidth,s=t.dilationDepth,u=t.dilationHeight,c=t.dilationWidth,l=t.effectiveFilterDepth,f=t.effectiveFilterHeight,h=t.effectiveFilterWidth,p=t.padInfo.front,d=t.padInfo.top,v=t.padInfo.left;this.outputShape=t.outShape;var m="avg"===e,g="0.0";if(m||(g="-1.0 / 1e-20"),n)this.userCode="\n const ivec3 strides =\n ivec3("+o+", "+a+", "+i+");\n const ivec3 pads = ivec3("+p+", "+d+", "+v+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n\n for (int wD = 0; wD < "+l+";\n wD += "+s+") {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= "+t.inDepth+") {\n continue;\n }\n\n for (int wR = 0; wR < "+f+";\n wR += "+u+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+h+";\n wC += "+c+") {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n float value = getX(batch, xD, xR, xC, ch);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value >= currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition =\n wD * "+f+" * "+h+" +\n wR * "+h+" + wC;;\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n ";else{var y=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===e&&(y="avgValue / count");var b=4*Math.floor(r/4),x=r%4,w="\n if ("+m+") {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n ";this.userCode="\n const ivec3 strides =\n ivec3("+o+", "+a+", "+i+");\n const ivec3 pads = ivec3("+p+", "+d+", "+v+");\n const float initializationValue = "+g+";\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xD, int xR, int xC, int ch) {\n if (xC < 0 || xC >= "+t.inWidth+") {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xD, xR, xC, ch);\n }\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n // ? = to be determined\n vec4 minMaxValue = vec4("+g+");\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < "+l+";\n wD += "+s+") {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= "+t.inDepth+") {\n continue;\n }\n\n for (int wR = 0; wR < "+f+";\n wR += "+u+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+b+"; wC += 4) {\n int xC = xCCorner + wC * "+c+";\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + "+c+", ch),\n getValue(batch, xD, xR, xC + 2 * "+c+", ch),\n getValue(batch, xD, xR, xC + 3 * "+c+", ch)\n );\n\n "+w+"\n }\n\n int xC = xCCorner + "+b+";\n if ("+(1===x)+") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n "+w+"\n } else if ("+(2===x)+") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + "+c+", ch),\n initializationValue,\n initializationValue\n );\n\n "+w+"\n } else if ("+(3===x)+") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + "+c+", ch),\n getValue(batch, xD, xR, xC + 2 * "+c+", ch),\n initializationValue\n );\n\n "+w+"\n }\n }\n setOutput("+y+");\n }\n }\n "}},Ka=function(t,e){this.variableNames=["x"];var n=t.windowSize,r=t.batchSize,o=t.inSize,a=Math.ceil(o/n);this.outputShape=[r,a];var i="0.0",s="";"prod"===e?i="1.0":"min"===e?(i="1.0 / 1e-20",s="min"):"max"===e&&(i="-1.0 / 1e-20",s="max");var u=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"sum"===e?u="sumValue":"prod"===e?u="prodValue":"all"===e?u="allValue":"any"===e&&(u="anyValue");var c=4*Math.floor(n/4),l=n%4,f="\n if ("+("sum"===e)+") {\n sumValue += dot(values, ones);\n } else if ("+("prod"===e)+") {\n vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n prodValue *= tmp[0] * tmp[1];\n } else {\n minMaxValue = "+s+"(values, minMaxValue);\n }\n ",h="vec4";"all"===e?(i="1.0",f="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",h="bvec4"):"any"===e&&(i="0.0",f="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",h="bvec4");var p="";o%n>0&&(p="\n if (inIdx < 0 || inIdx >= "+o+") {\n return initializationValue;\n }\n "),this.userCode="\n const float initializationValue = "+i+";\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n "+p+"\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * "+n+";\n\n vec4 minMaxValue = vec4("+i+");\n float prodValue = 1.0;\n float sumValue = 0.0;\n float allValue = 1.0;\n float anyValue = 0.0;\n\n for (int i = 0; i < "+c+"; i += 4) {\n int inIdx = inOffset + i;\n "+h+" values = "+h+"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n "+f+"\n }\n\n int inIdx = inOffset + "+c+";\n if ("+(1===l)+") {\n "+h+" values = "+h+"(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n "+f+"\n } else if ("+(2===l)+") {\n "+h+" values = "+h+"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n "+f+"\n } else if ("+(3===l)+") {\n "+h+" values = "+h+"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n "+f+"\n }\n setOutput("+u+");\n }\n "},Xa=function(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;for(var n="",r=0;r<4;r++){var o="thisRC = rc;";r%2==1&&(o+="thisRC.z += 1;"),r>1&&(o+="thisRC.y += 1;"),n+="\n "+o+"\n "+(r>0?"if(thisRC.y < rows && thisRC.z < cols){":"")+"\n int flatIndex = getFlatIndex(thisRC);\n\n ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n result["+r+"] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n "+(r>0?"}":"")+"\n "}this.userCode="\n \n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n "+co(["r","c","d"],e)+"\n return ivec3(r, c, d);\n }\n \n "+lo(t)+"\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = "+t[1]+";\n int cols = "+t[2]+";\n\n "+n+"\n\n setOutput(result);\n }\n "},$a=function(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e.shape;var r=e.shape,o=r[1],a=r[2],i=t.shape,s=i[1],u=i[2],c=[n&&s>1?o-1:o,n&&u>1?a-1:a],l=[n&&s>1?s-1:s,n&&u>1?u-1:u],f=c[0]/l[0],h=c[1]/l[1],p=1/f,d=1/h,v=2*Math.ceil(p)+2,m=2*Math.ceil(d)+2;this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float("+f+");\n const float widthScale = float("+h+");\n\n const float invHeightScale = float("+p+");\n const float invWidthScale = float("+d+");\n\n const int winHeight = int("+v+");\n const int winWidth = int("+m+");\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(startRLerp - float(winHeight / 2));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(startCLerp - float(winWidth / 2));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= "+s+") {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= "+u+") {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), "+(o-1)+".0));\n float dxRLerp = dxR - float(topDxRIndex);\n float inverseDxRLerp = 1.0 - dxRLerp;\n\n float dxC = float(dyC) * widthScale;\n int leftDxCIndex = int(floor(dxC));\n int rightDxCIndex = int(min(ceil(dxC), "+(a-1)+".0));\n float dxCLerp = dxC - float(leftDxCIndex);\n float inverseDxCLerp = 1.0 - dxCLerp;\n\n if (r == topDxRIndex && c == leftDxCIndex) {\n // topLeft\n accumulator +=\n getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n }\n\n if (r == topDxRIndex && c == rightDxCIndex) {\n // topRight\n accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n }\n\n if (r == bottomDxRIndex && c == leftDxCIndex) {\n // bottomLeft\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n }\n\n if (r == bottomDxRIndex && c == rightDxCIndex) {\n // bottomRight\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n "},Ya=function(t,e,n,r){this.variableNames=["A"],this.outputShape=[];var o=t[0],a=t[1],i=t[2],s=t[3];this.outputShape=[o,e,n,s];var u=[r&&e>1?a-1:a,r&&n>1?i-1:i],c=[r&&e>1?e-1:e,r&&n>1?n-1:n];this.userCode="\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n "+u[0]/c[0]+",\n "+u[1]/c[1]+");\n const vec2 inputShapeRC = vec2("+a+".0, "+i+".0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC;\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(sourceFracIndexRC);\n ivec2 sourceCeilRC = ivec2(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n float top = topLeft + (topRight - topLeft) * fracRC.y;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n float newValue = top + (bottom - top) * fracRC.x;\n\n setOutput(newValue);\n }\n "},Ja=function(t,e,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];var o=t[0],a=t[1],i=t[2],s=t[3];this.outputShape=[o,e,n,s];var u=[r&&e>1?a-1:a,r&&n>1?i-1:i],c=[r&&e>1?e-1:e,r&&n>1?n-1:n];this.userCode="\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n "+u[0]/c[0]+",\n "+u[1]/c[1]+",\n "+u[1]/c[1]+");\n const vec3 inputShapeRC = vec3("+a+".0, "+i+".0,\n "+i+".0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = vec3(yRC) * effectiveInputOverOutputRatioRC;\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(sourceFracIndexRC);\n ivec3 sourceCeilRC = ivec3(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < "+(s-1)+";\n bool hasNextRow = coords.z < "+(n-1)+";\n\n // In parallel, construct four corners for all four components in\n // packed 2x2 cell.\n vec4 topLeft = vec4(\n getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 bottomLeft = vec4(\n getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 topRight = vec4(\n getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec4 bottomRight = vec4(\n getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n vec4 newValue = mix(top, bottom, fracRC.x);\n\n setOutput(newValue);\n }\n "},Qa=function(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e.shape;var r=e.shape,o=r[1],a=r[2],i=t.shape,s=i[1],u=i[2],c=[n&&s>1?o-1:o,n&&u>1?a-1:a],l=[n&&s>1?s-1:s,n&&u>1?u-1:u],f=c[0]/l[0],h=c[1]/l[1],p=1/f,d=1/h,v=2*Math.ceil(p)+2,m=2*Math.ceil(d)+2;this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float("+f+");\n const float widthScale = float("+h+");\n\n const float invHeightScale = float("+p+");\n const float invWidthScale = float("+d+");\n\n const int winHeight = int("+v+");\n const int winWidth = int("+m+");\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= "+s+") {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= "+u+") {\n continue;\n }\n\n float sourceFracRow =\n float("+c[0]+") *\n (float(dyR) / float("+l[0]+"));\n\n float sourceFracCol =\n float("+c[1]+") *\n (float(dyC) / float("+l[1]+"));\n\n int sourceNearestRow = int(min(\n float(int("+o+") - 1),\n "+n+" ? float(round(sourceFracRow)) :\n float(floor(sourceFracRow))));\n\n int sourceNearestCol = int(min(\n float(int("+a+") - 1),\n "+n+" ? float(round(sourceFracCol)) :\n float(floor(sourceFracCol))));\n\n if (r == sourceNearestRow && c == sourceNearestCol) {\n accumulator += getDy(b, dyR, dyC, d);\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n "},Za=function(t,e,n,r){this.variableNames=["A"],this.outputShape=[];var o=t[0],a=t[1],i=t[2],s=t[3];this.outputShape=[o,e,n,s];var u=[r&&e>1?a-1:a,r&&n>1?i-1:i],c=[r&&e>1?e-1:e,r&&n>1?n-1:n],l=r?"0.5":"0.0";this.userCode="\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n "+u[0]/c[0]+",\n "+u[1]/c[1]+");\n const vec2 inputShapeRC = vec2("+a+".0, "+i+".0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC;\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + "+l+")));\n\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n "},ti=function(t,e){this.variableNames=["x"];var n=t.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");if(this.outputShape=t,1!==n){var r=t.map((function(n,r){return function(n){return-1!==e.indexOf(n)&&1!==t[n]?t[n]+" - coords["+n+"] - 1":"coords["+n+"]"}(r)})).join(","),o=xo(n);this.userCode="\n void main() {\n "+o+" coords = getOutputCoords();\n setOutput(getX("+r+"));\n }\n "}else this.userCode="\n void main() {\n int coord = getOutputCoords();\n setOutput(getX("+t[0]+" - coord - 1));\n }\n "},ei=function(t,e){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;var n=t.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");this.outputShape=t;var r=so("rc",n),o=r[n-1]+" + 1 < "+this.outputShape[n-1],a=r[n-2]+" + 1 < "+this.outputShape[n-2],i=xo(n);function s(n){var r=t.map((function(r,o){return function(n,r){return-1!==e.indexOf(n)&&1!==t[n]?t[n]+" - "+r[n]+" - 1":""+r[n]}(o,n)}));return"getChannel(getX("+r.join(",")+"), vec2("+r.slice(-2).join(",")+"))"}this.userCode=1===n?"\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX("+t[0]+" - rc - 1),\n "+t[0]+" - rc - 1);\n if("+o+"){\n result.g = getChannel(getX("+t[0]+" - (rc + 1) - 1),\n "+t[0]+" - (rc + 1) - 1);\n }\n setOutput(result);\n }\n ":"\n void main() {\n "+i+" rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = "+function(t){return s(t)}(r.slice())+";\n if("+o+"){\n result.g = "+function(t){return t[n-1]="("+t[n-1]+" + 1)",s(t)}(r.slice())+";\n }\n if("+a+") {\n result.b = "+function(t){return t[n-2]="("+t[n-2]+" + 1)",s(t)}(r.slice())+";\n if("+o+") {\n result.a = "+function(t){return t[n-1]="("+t[n-1]+" + 1)",t[n-2]="("+t[n-2]+" + 1)",s(t)}(r.slice())+";\n }\n }\n setOutput(result);\n }\n "},ni=function(t,e,n,r,o,a,i){void 0===i&&(i=!0),this.variableNames=["updates","indices","defaultValue"],this.outputShape=a;var s=xo(o.length),u=xo(a.length),c="";1===n?c="i":2===n&&(c="i, j");var l="getIndices("+c+")",f="";1===r?f="i":2===r&&(f="i, coords[1]");var h="getUpdates("+f+")",p=e>1?"strides[j]":"strides";this.userCode="\n "+s+" strides = "+s+"("+o+");\n\n void main() {\n "+u+" coords = getOutputCoords();\n float sum = 0.0;\n bool found = false;\n for (int i = 0; i < "+t+"; i++) {\n int flattenedIndex = 0;\n for (int j = 0; j < "+e+"; j++) {\n int index = round("+l+");\n flattenedIndex += index * "+p+";\n }\n if (flattenedIndex == coords[0]) {\n sum += "+h+";\n found = true;\n }\n }\n setOutput(mix(getDefaultValue(), sum, float(found)));\n }\n "},ri=function(t,e){this.variableNames=["x","segmentIds"];var n=t.windowSize,r=t.batchSize,o=t.inSize,a=t.numSegments,i=a*Math.ceil(o/n);this.outputShape=[r,i];var s=4*Math.floor(n/4),u=n%4,c="\n sumValue += dot(values, segFilter);\n ",l="";o%n>0&&(l="\n if (inIdx < 0 || inIdx >= "+o+") {\n return initializationValue;\n }\n ");var f="";o%n>0&&(f="\n if (inIdx < 0 || inIdx >= "+o+") {\n return -1.0;\n }\n "),this.userCode="\n const float initializationValue = 0.0;\n\n float getValue(int batch, int inIdx) {\n "+l+"\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n "+f+"\n return getSegmentIds(inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = int(floor(float(outIdx) / float(\n "+a+")) * float("+n+"));\n int currentSeg = int(mod(float(outIdx), float("+a+")));\n\n float sumValue = 0.0;\n\n for (int i = 0; i < "+s+"; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n );\n\n "+c+"\n }\n\n int inIdx = inOffset + "+s+";\n if ("+(1===u)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n 0,\n 0,\n 0\n );\n\n "+c+"\n } else if ("+(2===u)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n 0,\n 0\n );\n\n "+c+"\n } else if ("+(3===u)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n 0\n );\n\n "+c+"\n }\n setOutput(sumValue);\n }\n "},oi=function(t,e,n){var r,o;if(this.variableNames=["c","a","b"],this.outputShape=e,n>4)throw Error("Where for rank "+n+" is not yet supported");if(1===n)o="resRC",r="resRC";else{for(var a=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[],s=[],u=0;u<e.length;u++)s.push(""+a[u]),u<t&&i.push(""+a[u]);r=i.join(),o=s.join()}var c=xo(n);this.userCode="\n void main() {\n "+c+" resRC = getOutputCoords();\n float cVal = getC("+r+");\n if (cVal >= 1.0) {\n setOutput(getA("+o+"));\n } else {\n setOutput(getB("+o+"));\n }\n }\n "},ai=function(){function t(t){this.variableNames=["source"],this.outputShape=t,this.rank=t.length;var e,n=xo(this.rank),r="uniform int start["+this.rank+"];",o=function(t){if(1===t)return"sourceLoc";if(t<=6)return ii.slice(0,t).map((function(t){return"sourceLoc."+t})).join(",");throw Error("Slicing for rank "+t+" is not yet supported")}(this.rank);e="\n "+n+" sourceLoc;\n "+n+" coords = getOutputCoords();\n "+t.map((function(t,e){return"sourceLoc."+ii[e]+" = start["+e+"] + coords."+ii[e]+";"})).join("\n")+"\n ",this.userCode="\n "+r+"\n void main() {\n "+e+"\n setOutput(getSource("+o+"));\n }\n "}return t.prototype.getCustomSetupFunc=function(t){var e=this;if(t.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the length of start ("+t.length+")");return function(n,r){null==e.startLoc&&(e.startLoc=n.getUniformLocationNoThrow(r,"start"),null==e.startLoc)||n.gl.uniform1iv(e.startLoc,t)}},t}(),ii=["x","y","z","w","u","v"],si=function(){function t(t){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.rank=t.length;var e=xo(this.rank),n=so("coords",this.rank),r=so("sourceLoc",this.rank),o=1===this.rank?"sourceLoc":"vec2("+r.slice(-2).join()+")",a="getChannel(getSource("+r.join()+"), "+o+")",i="\n result.x = "+a+";\n if (++"+n[this.rank-1]+" < "+t[this.rank-1]+") {\n ++"+r[this.rank-1]+";\n result.y = "+a+";\n --"+r[this.rank-1]+";\n }\n ",s=1===this.rank?"":"\n --"+n[this.rank-1]+";\n if (++"+n[this.rank-2]+" < "+t[this.rank-2]+") {\n ++"+r[this.rank-2]+";\n result.z = "+a+";\n if (++"+n[this.rank-1]+" < "+t[this.rank-1]+") {\n ++"+r[this.rank-1]+";\n result.w = "+a+";\n }\n }\n ",u=this.rank<=4?"sourceLoc = coords +\n "+e+"("+t.map((function(t,e){return"start["+e+"]"})).join()+");":t.map((function(t,e){return r[e]+" = "+n[e]+" + start["+e+"];"})).join("\n");this.userCode="\n uniform int start["+this.rank+"];\n void main() {\n "+e+" coords = getOutputCoords();\n "+e+" sourceLoc;\n "+u+"\n vec4 result = vec4(0.);\n "+i+"\n "+s+"\n setOutput(result);\n }\n "}return t.prototype.getCustomSetupFunc=function(t){var e=this;if(t.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the length of start ("+t.length+")");return function(n,r){null==e.startLoc&&(e.startLoc=n.getUniformLocationNoThrow(r,"start"),null==e.startLoc)||n.gl.uniform1iv(e.startLoc,t)}},t}(),ui=function(t,e,n){this.variableNames=["x"],this.outputShape=n;var r=n.length,o=xo(n.length),a=xo(n.length),i="";if(1===r)i="coords * strides + begin";else{var s=0;i=n.map((function(t,e){return s++,1===n.length?"coords * strides["+e+"] + begin["+e+"]":"coords["+(s-1)+"] * strides["+e+"] + begin["+e+"]"})).join(",")}this.userCode="\n "+o+" begin = "+o+"("+t+");\n "+o+" strides = "+o+"("+e+");\n\n void main() {\n "+a+" coords = getOutputCoords();\n setOutput(getX("+i+"));\n }\n "},ci=function(){function t(t){this.gpgpu=t,this.numUsedTextures=0,this.numFreeTextures=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}return t.prototype.acquireTexture=function(t,e,n){var r,o=li(e,n),a=fi(t,o,n);if(a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]),this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this.log();var i=this.freeTextures[a].shift();return this.usedTextures[a].push(i),i}return this.numUsedTextures++,this.log(),o===Mt.PACKED_2X2_FLOAT32?r=this.gpgpu.createPackedMatrixTexture(t[0],t[1]):o===Mt.PACKED_2X2_FLOAT16?r=this.gpgpu.createFloat16PackedMatrixTexture(t[0],t[1]):o===Mt.UNPACKED_FLOAT32?r=this.gpgpu.createFloat32MatrixTexture(t[0],t[1]):o===Mt.UNPACKED_FLOAT16?r=this.gpgpu.createFloat16MatrixTexture(t[0],t[1]):o===Mt.PACKED_4X1_UNSIGNED_BYTE&&(r=this.gpgpu.createUnsignedBytesMatrixTexture(t[0],t[1])),this.usedTextures[a].push(r),r},t.prototype.releaseTexture=function(t,e,n,r){if(null!=this.freeTextures){var o=fi(e,li(n,r),r);o in this.freeTextures||(this.freeTextures[o]=[]),this.freeTextures[o].push(t),this.numFreeTextures++,this.numUsedTextures--;var a=this.usedTextures[o],i=a.indexOf(t);if(i<0)throw new Error("Cannot release a texture that was never provided by this texture manager");a.splice(i,1),this.log()}},t.prototype.log=function(){if(this.logEnabled)this.numFreeTextures,this.numUsedTextures},t.prototype.getNumUsedTextures=function(){return this.numUsedTextures},t.prototype.getNumFreeTextures=function(){return this.numFreeTextures},t.prototype.dispose=function(){var t=this;if(null!=this.freeTextures){for(var e in this.freeTextures)this.freeTextures[e].forEach((function(e){t.gpgpu.deleteMatrixTexture(e)}));for(var e in this.usedTextures)this.usedTextures[e].forEach((function(e){t.gpgpu.deleteMatrixTexture(e)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0}},t}();function li(t,e){if(t===Ft.UPLOAD)return Mt.PACKED_2X2_FLOAT32;if(t===Ft.RENDER||null==t)return function(t){return f().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?t?Mt.PACKED_2X2_FLOAT32:Mt.UNPACKED_FLOAT32:t?Mt.PACKED_2X2_FLOAT16:Mt.UNPACKED_FLOAT16}(e);if(t===Ft.DOWNLOAD||t===Ft.PIXELS)return Mt.PACKED_4X1_UNSIGNED_BYTE;throw new Error("Unknown logical texture type "+t)}function fi(t,e,n){return t[0]+"_"+t[1]+"_"+e+"_"+n}var hi=function(t,e){this.variableNames=["A"];for(var n=new Array(t.length),r=0;r<n.length;r++)n[r]=t[r]*e[r];this.outputShape=n,this.rank=n.length;var o=xo(this.rank),a=function(t){var e=t.length;if(e>5)throw Error("Tile for rank "+e+" is not yet supported");if(1===e)return"imod(resRC, "+t[0]+")";for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[],o=0;o<t.length;o++)r.push("imod("+n[o]+", "+t[o]+")");return r.join()}(t);this.userCode="\n void main() {\n "+o+" resRC = getOutputCoords();\n setOutput(getA("+a+"));\n }\n "},pi=function(t,e){this.variableNames=["A"];for(var n=new Array(t.length),r=0;r<n.length;r++)n[r]=t[e[r]];this.outputShape=n,this.rank=n.length;var o=xo(this.rank),a=function(t){var e=t.length;if(e>6)throw Error("Transpose for rank "+e+" is not yet supported");for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(e),o=0;o<t.length;o++)r[t[o]]=n[o];return r.join()}(e);this.userCode="\n void main() {\n "+o+" resRC = getOutputCoords();\n setOutput(getA("+a+"));\n }\n "},di=function(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;for(var n=new Array(t.length),r=0;r<n.length;r++)n[r]=t[e[r]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error("Packed transpose for rank "+this.rank+" is not yet supported.");var o=xo(this.rank),a=io("rc",this.rank),i=new Array(this.rank);for(r=0;r<e.length;r++)i[e[r]]=a[r];var s="vec2("+i.slice(-2).join()+")",u="++"+a[this.rank-1]+" < "+n[this.rank-1],c="getChannel(getA("+i.join()+"), "+s+")";this.userCode="\n void main() {\n "+o+" rc = getOutputCoords();\n vec4 result = vec4(0.);\n result[0] = "+c+";\n if("+u+") {\n result[1] = "+c+";\n }\n --"+a[this.rank-1]+";\n if(++"+a[this.rank-2]+" < "+n[this.rank-2]+") {\n result[2] = "+c+";\n if("+u+") {\n result[3] = "+c+";\n }\n }\n setOutput(result);\n }\n "},vi=1.7580993408473768,mi=1.0507009873554805,gi=function(t,e){this.variableNames=["A"],this.outputShape=t,this.userCode="\n float unaryOperation(float x) {\n "+e+"\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n "},yi="if (isnan(x)) return x;",bi="return abs(x);",xi=yi+"\n return (x < 0.0) ? 0.0 : x;\n",wi=yi+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",Ei="return (x >= 0.0) ? x : (exp(x) - 1.0);",Ci="return -x;",_i="return ceil(x);",ki="return floor(x);",Ri="return exp(x);",Ii="return exp(x) - 1.0;",Si="return x;",Ai="\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",Oi="\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",Ti="\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n",Di=function(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.userCode="\n vec4 unaryOperation(vec4 x) {\n "+e+"\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n "},Ni=function(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=t;var e=t.length,n=so("rc",e),r=xo(e),o=function(t,e){if(1===t)return"rc";for(var n="",r=0;r<t;r++)n+=e[r],r<t-1&&(n+=",");return n}(e,n),a=n.slice(-2),i=e<=1?"rc":"vec2("+a.join(",")+")";this.userCode="\n void main() {\n "+r+" rc = getOutputCoords();\n vec4 packedInput = getA("+o+");\n\n setOutput(getChannel(packedInput, "+i+"));\n }\n "},Fi={};function Mi(t,e){if(void 0===e&&(e=!1),"linear"===t)return"return x;";if("relu"===t)return e?Ai:xi;if("elu"===t)return e?Ti:Ei;if("relu6"===t)return e?Oi:wi;if("prelu"===t)return e?Fo:Do;throw new Error("Activation "+t+" has not been implemented for the WebGL backend.")}var Pi=function(t){function e(e){var n,r=t.call(this)||this;if(r.pendingRead=new WeakMap,r.pendingDisposal=new WeakSet,r.dataRefCount=new WeakMap,r.numBytesInGPU=0,r.uploadWaitMs=0,r.downloadWaitMs=0,r.warnedAboutMemory=!1,r.pendingDeletes=0,r.disposed=!1,!f().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(null==e){var o=Wt(f().getNumber("WEBGL_VERSION"));r.binaryCache=((n=f().getNumber("WEBGL_VERSION"))in Fi||(Fi[n]={}),Fi[n]),r.gpgpu=new Ta(o),r.canvas=o.canvas,r.gpgpuCreatedLocally=!0}else r.gpgpu=e,r.binaryCache={},r.gpgpuCreatedLocally=!1,r.canvas=e.gl.canvas;return r.textureManager=new ci(r.gpgpu),r.numMBBeforeWarning=null==f().global.screen?1024:f().global.screen.height*f().global.screen.width*window.devicePixelRatio*600/1024/1024,r.texData=new Rr(r,Ot),r}return s(e,t),e.prototype.numDataIds=function(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes},e.prototype.write=function(t,e,n){if(f().getBool("DEBUG")&&this.checkNumericalProblems(t),"complex64"===n&&null!=t)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");var r={};return this.texData.set(r,{shape:e,dtype:n,values:t,usage:Ft.UPLOAD}),r},e.prototype.move=function(t,e,n,r){if(f().getBool("DEBUG")&&this.checkNumericalProblems(e),"complex64"===r)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(t,{shape:n,dtype:r,values:e,usage:Ft.UPLOAD})},e.prototype.readSync=function(t){var e=this.texData.get(t),n=e.values,r=e.dtype,o=e.complexTensors,a=e.slice,i=e.shape,s=e.isPacked;if(null!=a){var u;u=s?new Di(i,Si):new gi(i,Si);var c=this.runWebGLProgram(u,[{dataId:t,shape:i,dtype:r}],r),l=this.readSync(c.dataId);return this.disposeData(c.dataId),l}if(null!=n)return this.convertAndCacheOnCPU(t);if("string"===r)return n;var f,h,p=null!=this.activeTimers;return p&&(f=et()),h="complex64"===r?Kr(o.real.dataSync(),o.imag.dataSync()):this.getValuesFromTexture(t),p&&(this.downloadWaitMs+=et()-f),this.convertAndCacheOnCPU(t,h)},e.prototype.read=function(t){return u(this,void 0,void 0,(function(){var e,n,r,o,a,i,s,u,l,h,p,d,v,m,g,y,b,x,w,E,C,_;return c(this,(function(c){switch(c.label){case 0:if(this.pendingRead.has(t))return e=this.pendingRead.get(t),[2,new Promise((function(t){return e.push(t)}))];if(n=this.texData.get(t),r=n.values,o=n.shape,a=n.slice,i=n.dtype,s=n.complexTensors,u=n.isPacked,null!=a)return void 0,l=u?new Di(o,Si):new gi(o,Si),h=this.runWebGLProgram(l,[{dataId:t,shape:o,dtype:i}],i),p=this.read(h.dataId),this.disposeData(h.dataId),[2,p];if(null!=r)return[2,this.convertAndCacheOnCPU(t)];if(!f().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===f().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");return d=null,"complex64"!==i&&f().get("WEBGL_BUFFER_SUPPORTED")&&(v=this.decode(t),m=this.texData.get(v.dataId),d=(_=this.gpgpu).createBufferFromTexture.apply(_,[m.texture].concat(jt(o)))),this.pendingRead.set(t,[]),"complex64"===i?[3,2]:[4,this.gpgpu.createAndWaitForFence()];case 1:c.sent(),c.label=2;case 2:return"complex64"!==i?[3,4]:[4,Promise.all([s.real.data(),s.imag.data()])];case 3:return y=c.sent(),b=y[0],x=y[1],g=Kr(b,x),[3,5];case 4:null==d?g=this.getValuesFromTexture(t):(w=R(o),g=this.gpgpu.downloadFloat32MatrixFromBuffer(d,w)),c.label=5;case 5:return null!=v&&this.disposeData(v.dataId),E=this.convertAndCacheOnCPU(t,g),C=this.pendingRead.get(t),this.pendingRead.delete(t),C.forEach((function(t){return t(E)})),this.pendingDisposal.has(t)&&(this.pendingDisposal.delete(t),this.disposeData(t),this.pendingDeletes--),[2,E]}}))}))},e.prototype.checkNumericalProblems=function(t){if(null!=t)for(var e=0;e<t.length;e++){var n=t[e];if(!Ht(n)){if(f().getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))throw Error("The value "+n+" cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'");throw Error("The value "+n+" cannot be represented on this device.")}}},e.prototype.getValuesFromTexture=function(t){var e,n=this.texData.get(t),r=n.shape,o=n.dtype,a=n.isPacked,i=R(r);if(f().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){var s=this.decode(t),u=this.texData.get(s.dataId),c=(e=this.gpgpu).downloadMatrixFromPackedTexture.apply(e,[u.texture].concat(jt(r))).subarray(0,i);return this.disposeData(s.dataId),c}var l=f().getBool("WEBGL_PACK")&&!0===a,h=l?xe(r):r,p=l?new ia(h):new aa(h),d=this.runWebGLProgram(p,[{shape:h,dtype:o,dataId:t}],"float32"),v=this.texData.get(d.dataId),m=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(v.texture,v.texShape[0],v.texShape[1]).subarray(0,i);return this.disposeData(d.dataId),m},e.prototype.time=function(t){return u(this,void 0,void 0,(function(){var e,n,r,o,a,i,s;return c(this,(function(u){switch(u.label){case 0:return e=this.activeTimers,n=[],r=!1,null==this.programTimersStack?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,t(),o=k(this.activeTimers.map((function(t){return t.query}))).filter((function(t){return null!=t})),a=k(this.activeTimers.map((function(t){return t.name}))).filter((function(t){return null!=t})),this.activeTimers=e,r&&(this.programTimersStack=null),[4,Promise.all(o)];case 1:return i=u.sent(),s={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:w(i),getExtraProfileInfo:function(){return i.map((function(t,e){return{name:a[e],ms:t}})).map((function(t){return t.name+": "+t.ms})).join(", ")},wallMs:null},this.uploadWaitMs=0,this.downloadWaitMs=0,[2,s]}}))}))},e.prototype.memory=function(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU}},e.prototype.startTimer=function(){return f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?this.gpgpu.beginQuery():{startMs:et(),endMs:null}},e.prototype.endTimer=function(t){return f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(this.gpgpu.endQuery(),t):(t.endMs=et(),t)},e.prototype.getQueryTime=function(t){return u(this,void 0,void 0,(function(){var e;return c(this,(function(n){return f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?[2,this.gpgpu.waitForQueryAndGetTime(t)]:[2,(e=t).endMs-e.startMs]}))}))},e.prototype.disposeData=function(t){if(!this.pendingDisposal.has(t)){if(this.pendingRead.has(t))return this.pendingDisposal.add(t),void this.pendingDeletes++;if(this.texData.has(t)){this.releaseGPUData(t);var e=this.texData.get(t).complexTensors;null!=e&&(e.real.dispose(),e.imag.dispose()),this.texData.delete(t)}}},e.prototype.releaseGPUData=function(t){var e=this.texData.get(t),n=e.texture,r=e.dtype,o=e.texShape,a=e.usage,i=e.isPacked,s=e.slice,u=s&&s.origDataId||t,c=this.dataRefCount.get(u);c>1?this.dataRefCount.set(u,c-1):(this.dataRefCount.delete(u),null!=n&&(this.numBytesInGPU-=this.computeBytes(o,r),this.textureManager.releaseTexture(n,o,a,i)));var l=this.texData.get(t);l.texture=null,l.texShape=null,l.isPacked=!1,l.slice=null},e.prototype.getTexture=function(t){return this.uploadToGPU(t),this.texData.get(t).texture},e.prototype.getDataInfo=function(t){return this.texData.get(t)},e.prototype.getCPUBackend=function(){return f().getBool("WEBGL_CPU_FORWARD")?(null==this.cpuBackend&&(this.cpuBackend=Ot.findBackend("cpu")),this.cpuBackend):null},e.prototype.shouldExecuteOnCPU=function(t,e){var n=this;return void 0===e&&(e=128),null!=this.getCPUBackend()&&t.every((function(t){return null==n.texData.get(t.dataId).texture&&t.size<e}))},e.prototype.getGPGPUContext=function(){return this.gpgpu},e.prototype.complex=function(t,e){var n=this.makeOutput(t.shape,"complex64");return this.texData.get(n.dataId).complexTensors={real:Ot.keep(t.clone()),imag:Ot.keep(e.clone())},n},e.prototype.real=function(t){return this.texData.get(t.dataId).complexTensors.real.clone()},e.prototype.imag=function(t){return this.texData.get(t.dataId).complexTensors.imag.clone()},e.prototype.slice=function(t,e,n){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.slice(t,e,n);if(0===R(n))return rn([],n,t.dtype);var r=this.texData.get(t.dataId).isPacked,o=wr(t.shape,e,n);if(r||!o){var a=f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new si(n):new ai(n),i=a.getCustomSetupFunc(e);return this.compileAndRun(a,[t],null,i)}return this.uploadToGPU(t.dataId),this.shallowSlice(t,e,n)},e.prototype.shallowSlice=function(t,e,n){var r=this.texData.get(t.dataId),o=this.makeOutput(n,t.dtype),a=this.texData.get(o.dataId);Object.assign(a,r),a.shape=n,a.dtype=t.dtype;var i=Er(e,t.strides);r.slice&&(i+=r.slice.flatOffset),a.slice={flatOffset:i,origDataId:r.slice&&r.slice.origDataId||t.dataId};var s=this.dataRefCount.get(a.slice.origDataId)||1;return this.dataRefCount.set(a.slice.origDataId,s+1),o},e.prototype.stridedSlice=function(t,e,n,r){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.stridedSlice(t,e,n,r);var o=yr(e,n,r);if(o.some((function(t){return 0===t})))return rn([],o);var a=new ui(e,r,o);return this.compileAndRun(a,[t])},e.prototype.reverse=function(t,e){var n=f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new ei(t.shape,e):new ti(t.shape,e);return this.compileAndRun(n,[t])},e.prototype.concat=function(t,e){if("complex64"===t[0].dtype){var n=t.map((function(t){return en(t)})),r=t.map((function(t){return nn(t)}));return tn(this.concat(n,e),this.concat(r,e))}if(this.shouldExecuteOnCPU(t))return this.cpuBackend.concat(t,e);if(1===t.length)return t[0];if(t.length>f().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){var o=Math.floor(t.length/2),a=this.concat(t.slice(0,o),e),i=this.concat(t.slice(o),e);return this.concat([a,i],e)}if(f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&t[0].rank>1){var s=new Uo(t.map((function(t){return t.shape})),e);return this.compileAndRun(s,t)}var u=Qe(t.map((function(t){return t.shape})),e),c=t.map((function(t){return t.as2D(-1,R(t.shape.slice(e)))})),l=new Wo(c.map((function(t){return t.shape})));return this.compileAndRun(l,c).reshape(u)},e.prototype.neg=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.neg(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Ci,t.dtype);var e=new gi(t.shape,Ci);return this.compileAndRun(e,[t])},e.prototype.batchMatMul=function(t,e,n,r){var o=n?t.shape[2]:t.shape[1],a=r?e.shape[1]:e.shape[2],i=n?t.shape[1]:t.shape[2],s=t.shape[0];if((1===o||1===a)&&i>1e3){n&&(t=t.transpose([0,2,1])),r&&(e=e.transpose([0,2,1]));var u=1===a?t:t.as3D(s,i,1),c=1===a?2:1,l=1===a?e.as3D(s,1,i):e;return this.multiply(u,l).sum(c,!0)}var f=Et(t.dtype,e.dtype),h=new Wa(t.shape,[s,o,a],n,r);return this.compileAndRun(h,[t,e],f)},e.prototype.fusedBatchMatMul=function(t){var e=t.a,n=t.b,r=t.transposeA,o=t.transposeB,a=t.bias,i=t.activation,s=t.preluActivationWeights,u=r?e.shape[2]:e.shape[1],c=o?n.shape[1]:n.shape[2],l=e.shape[0],f=Et(e.dtype,n.dtype),h=null!=a,p=null!=s,d=i?Mi(i,!0):null,v=new Wa(e.shape,[l,u,c],r,o,h,d,p),m=[e,n];return a&&m.push(a),s&&m.push(s),this.compileAndRun(v,m,f)},e.prototype.multiply=function(t,e){if("complex64"===t.dtype){var n=this.texData.get(t.dataId),r=this.texData.get(e.dataId),o=new So("return areal * breal - aimag * bimag;",t.shape,e.shape),a=new So("return areal * bimag + aimag * breal;",t.shape,e.shape),i=[this.makeComplexComponentTensorInfo(t,n.complexTensors.real),this.makeComplexComponentTensorInfo(t,n.complexTensors.imag),this.makeComplexComponentTensorInfo(e,r.complexTensors.real),this.makeComplexComponentTensorInfo(e,r.complexTensors.imag)],s=this.compileAndRun(o,i),u=this.compileAndRun(a,i),c=this.complex(s,u);return s.dispose(),u.dispose(),c}if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.multiply(t,e);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,To,t.dtype);var l=new No(To,t.shape,e.shape);return this.compileAndRun(l,[t,e],t.dtype)},e.prototype.batchNormalization=function(t,e,n,r,o,a){var i=[t,e,n],s=null;null!=a&&(s=a.shape,i.push(a));var u=null;if(null!=o&&(u=o.shape,i.push(o)),f().getBool("WEBGL_PACK_NORMALIZATION")){var c=new Io(t.shape,e.shape,n.shape,s,u,r);return this.compileAndRun(c,i)}var l=new Ro(t.shape,e.shape,n.shape,s,u,r);return this.compileAndRun(l,i)},e.prototype.localResponseNormalization4D=function(t,e,n,r,o){var a=f().getBool("WEBGL_PACK_NORMALIZATION")?new Pa(t.shape,e,n,r,o):new Fa(t.shape,e,n,r,o);return this.compileAndRun(a,[t])},e.prototype.LRNGrad=function(t,e,n,r,o,a,i){var s=new Ma(e.shape,r,o,a,i);return this.compileAndRun(s,[e,n,t])},e.prototype.tile=function(t,e){if("string"===t.dtype){var n=this.readSync(t.dataId).map((function(t){return ot(t)}));return to(Mn(t.shape,t.dtype,n),e)}var r=new hi(t.shape,e);return this.compileAndRun(r,[t])},e.prototype.pad=function(t,e,n){var r=f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Ga(t.shape,e,n):new Va(t.shape,e,n);return this.compileAndRun(r,[t])},e.prototype.transpose=function(t,e){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.transpose(t,e);var n=f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new di(t.shape,e):new pi(t.shape,e);return this.compileAndRun(n,[t])},e.prototype.gather=function(t,e,n){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.gather(t,e,n);var r=new fa(t.shape,e.size,n);return this.compileAndRun(r,[t,e])},e.prototype.batchToSpaceND=function(t,e,n){E(t.rank<=4,(function(){return"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"}));var r=e.reduce((function(t,e){return t*e})),o=ur(t.shape,e,r),a=cr(o.length,e.length),i=lr(t.shape,e,r),s=fr(n,e.length),u=hr(i,n,e.length);return t.reshape(o).transpose(a).reshape(i).slice(s,u)},e.prototype.spaceToBatchND=function(t,e,n){E(t.rank<=4,(function(){return"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"}));var r=e.reduce((function(t,e){return t*e})),o=[[0,0]];o.push.apply(o,n);for(var a=1+e.length;a<t.shape.length;++a)o.push([0,0]);var i=t.pad(o),s=ur(i.shape,e,r,!1),u=cr(s.length,e.length,!1),c=lr(i.shape,e,r,!1);return i.reshape(s).transpose(u).reshape(c)},e.prototype.reduce=function(t,e,n){var r=t.shape[0],o=t.shape[1],a=dr(o),i=new Ka({windowSize:a,inSize:o,batchSize:r},e),s=this.compileAndRun(i,[t],n);return 1===s.shape[1]?s:this.reduce(s,e,n)},e.prototype.argReduce=function(t,e,n){void 0===n&&(n=null);var r=t.shape[0],o=t.shape[1];null!=n&&(r=n.shape[0],o=n.shape[1]);var a=dr(o),i=new ao({windowSize:a,inSize:o,batchSize:r},e,null==n),s=[t];null!=n&&s.push(n);var u=this.compileAndRun(i,s,"int32");return 1===u.shape[1]?u:this.argReduce(t,e,u)},e.prototype.argReducePacked=function(t,e,n){void 0===n&&(n=null);var r=null!=n?n.shape:t.shape,o=dr(r[r.length-1]),a=new Co(r,o,e,null==n),i=null==n?[t]:[t,n],s=this.compileAndRun(a,i,"int32");return s.rank===t.rank?this.argReducePacked(t,e,s):s},e.prototype.sum=function(t,e){Ke("sum",e,t.rank);var n=He(t.shape,e),r=n[0],o=R(n[1]),a=t.as2D(-1,o),i=Ct(t.dtype);return this.reduce(a,"sum",i).reshape(r)},e.prototype.prod=function(t,e){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.prod(t,e);var n=He(t.shape,e),r=n[0],o=R(n[1]),a=t.as2D(-1,o),i=Ct(t.dtype);return this.reduce(a,"prod",i).reshape(r)},e.prototype.unsortedSegmentSum=function(t,e,n){var r=0,o=Xe([r],t.rank),a=t;null!=o&&(a=t.transpose(o),r=Ye(1,t.rank)[0]);var i=function(t,e,n){for(var r=[],o=t.length,a=0;a<o;a++)a!==e?r.push(t[a]):r.push(n);return r}(a.shape,r,n),s=R([a.shape[r]]),u=a.as2D(-1,s),c=Ct(t.dtype),l=this.segOpCompute(u,"unsortedSegmentSum",e,c,n).reshape(i);return null!=o&&(l=l.transpose($e(o))),l},e.prototype.segOpCompute=function(t,e,n,r,o){var a=t.shape[0],i=t.shape[1],s=function(t,e){var n,r=!1;for(t<=30?(n=t,r=!0):n=$(t,Math.floor(Math.sqrt(t)));!r;)n>e||n===t?r=!0:n=$(t,n+1);return n}(i,o),u=new ri({windowSize:s,inSize:i,batchSize:a,numSegments:o},e),c=this.compileAndRun(u,[t,n],r);return c.shape[1]===o?c:(n=dn(0,o).tile([i/s]),this.segOpCompute(c,e,n,r,o))},e.prototype.argMinMaxReduce=function(t,e,n){var r=[e];if(Ke("arg"+n.charAt(0).toUpperCase()+n.slice(1),r,t.rank),!f().getBool("WEBGL_PACK_REDUCE")||t.rank<=2){var o=He(t.shape,r),a=o[0],i=R(o[1]),s=t.as2D(-1,i);return this.argReduce(s,n).reshape(a)}return this.argReducePacked(t,n)},e.prototype.argMin=function(t,e){return this.argMinMaxReduce(t,e,"min")},e.prototype.argMax=function(t,e){return this.argMinMaxReduce(t,e,"max")},e.prototype.cumsum=function(t,e,n,r){if(e!==t.rank-1)throw new Error("WebGL cumsum shader expects an inner-most axis="+(t.rank-1)+" but got axis="+e);var o=new Zo(t.shape,n,r);return this.compileAndRun(o,[t])},e.prototype.equal=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(equal(a, b));\n","bool");var n=new No("return float(a == b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},e.prototype.notEqual=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(notEqual(a, b));\n","bool");var n=new No("return float(a != b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},e.prototype.less=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.less(t,e);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(lessThan(a, b));\n","bool");var n=new No("return float(a < b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},e.prototype.lessEqual=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(lessThanEqual(a, b));\n","bool");var n=new No("return float(a <= b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},e.prototype.greater=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.greater(t,e);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(greaterThan(a, b));\n","bool");var n=new No("return float(a > b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},e.prototype.greaterEqual=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(greaterThanEqual(a, b));\n","bool");var n=new No("return float(a >= b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},e.prototype.logicalNot=function(t){var e=new gi(t.shape,"return float(!(x >= 1.0));");return this.compileAndRun(e,[t])},e.prototype.logicalAnd=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(\n vec4(greaterThanEqual(a, vec4(1.0))) *\n vec4(greaterThanEqual(b, vec4(1.0))));\n","bool");var n=new No("return float(a >= 1.0 && b >= 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},e.prototype.logicalOr=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return min(\n vec4(greaterThanEqual(a, vec4(1.0))) +\n vec4(greaterThanEqual(b, vec4(1.0))),\n vec4(1.0));\n","bool");var n=new No("return float(a >= 1.0 || b >= 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},e.prototype.select=function(t,e,n){var r=new oi(t.rank,e.shape,e.rank);return this.compileAndRun(r,[t,e,n],Et(e.dtype,n.dtype))},e.prototype.where=function(t){Le("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");var e=t.dataSync();return no(t.shape,e)},e.prototype.topk=function(t,e,n){return eo(t.dataSync(),t.shape,t.dtype,e)},e.prototype.min=function(t,e){Ke("min",e,t.rank);var n=He(t.shape,e),r=n[0],o=R(n[1]),a=t.as2D(-1,o);return this.reduce(a,"min",a.dtype).reshape(r)},e.prototype.minimum=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.minimum(t,e);var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Mo("\n vec4 result = vec4(min(a, b));\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",t.shape,e.shape):new No("\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return min(a, b);\n",t.shape,e.shape);return this.compileAndRun(n,[t,e])},e.prototype.mod=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Mo("\n vec4 result = mod(a, b);\n vec4 isNaN = vec4(equal(b, vec4(0.0)));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",t.shape,e.shape):new No("if (b == 0.0) return NAN;\n return mod(a, b);",t.shape,e.shape);return this.compileAndRun(n,[t,e])},e.prototype.max=function(t,e){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.max(t,e);Ke("max",e,t.rank);var n=He(t.shape,e),r=n[0],o=R(n[1]),a=t.as2D(-1,o);return this.reduce(a,"max",a.dtype).reshape(r)},e.prototype.maximum=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.maximum(t,e);var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Mo("\n vec4 result = vec4(max(a, b));\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",t.shape,e.shape):new No("\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return max(a, b);\n",t.shape,e.shape);return this.compileAndRun(n,[t,e])},e.prototype.all=function(t,e){Ke("all",e,t.rank);var n=He(t.shape,e),r=n[0],o=R(n[1]),a=t.as2D(-1,o);return this.reduce(a,"all",a.dtype).reshape(r)},e.prototype.any=function(t,e){Ke("any",e,t.rank);var n=He(t.shape,e),r=n[0],o=R(n[1]),a=t.as2D(-1,o);return this.reduce(a,"any",a.dtype).reshape(r)},e.prototype.squaredDifference=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Mo("return (a - b) * (a - b);",t.shape,e.shape):new No("return (a - b) * (a - b);",t.shape,e.shape);return this.compileAndRun(n,[t,e])},e.prototype.realDivide=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n // vec4 one = vec4(equal(a, b));\n // return one + (vec4(1.0) - one) * a / b;\n vec4 result = a / b;\n if(a.x == b.x) {\n result.x = 1.;\n }\n if(a.y == b.y) {\n result.y = 1.;\n }\n if(a.z == b.z) {\n result.z = 1.;\n }\n if(a.w == b.w) {\n result.w = 1.;\n }\n\n return result;\n","float32",!0);var n=new No("\nif (a == b) {\n return 1.0;\n};\nreturn a / b;",t.shape,e.shape);return this.compileAndRun(n,[t,e],"float32")},e.prototype.floorDiv=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n ivec4 ia = round(a);\n ivec4 ib = round(b);\n bvec4 cond = notEqual(ib, ivec4(0));\n ivec4 result = ivec4(0);\n vec4 s = sign(a) * sign(b);\n\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n if (cond[0]) {\n result[0] = idiv(ia[0], ib[0], s[0]);\n }\n if (cond[1]) {\n result[1] = idiv(ia[1], ib[1], s[1]);\n }\n if (cond[2]) {\n result[2] = idiv(ia[2], ib[2], s[2]);\n }\n if (cond[3]) {\n result[3] = idiv(ia[3], ib[3], s[3]);\n }\n return vec4(result);\n","int32");var n=new No("\n float s = sign(a) * sign(b);\n int ia = round(a);\n int ib = round(b);\n if (ib != 0) {\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n return float(idiv(ia, ib, s));\n } else {\n return NAN;\n }\n",t.shape,e.shape);return this.compileAndRun(n,[t,e],"int32")},e.prototype.add=function(t,e){if("complex64"===t.dtype&&"complex64"===e.dtype)return this.complexSeparableBinaryOp(t,e,Ao);if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.add(t,e);var n=Et(t.dtype,e.dtype);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,Ao,n);var r=new No(Ao,t.shape,e.shape);return this.compileAndRun(r,[t,e],n)},e.prototype.packedUnaryOp=function(t,e,n){var r=new Di(t.shape,e);return this.compileAndRun(r,[t],n)},e.prototype.packedBinaryOp=function(t,e,n,r,o){void 0===o&&(o=!1);var a=new Mo(n,t.shape,e.shape,o);return this.compileAndRun(a,[t,e],r)},e.prototype.complexSeparableBinaryOp=function(t,e,n){var r=this,o=this.texData.get(t.dataId),a=this.texData.get(e.dataId),i=[[o.complexTensors.real,a.complexTensors.real],[o.complexTensors.imag,a.complexTensors.imag]].map((function(o){var a=o[0],i=o[1],s=r.makeComplexComponentTensorInfo(t,a),u=r.makeComplexComponentTensorInfo(e,i),c=new No(n,t.shape,e.shape);return r.compileAndRun(c,[s,u],Et(a.dtype,i.dtype))})),s=i[0],u=i[1],c=this.complex(s,u);return s.dispose(),u.dispose(),c},e.prototype.makeComplexComponentTensorInfo=function(t,e){return{dataId:e.dataId,dtype:e.dtype,shape:t.shape}},e.prototype.addN=function(t){if(1===t.length)return t[0];if(t.length>f().get("WEBGL_MAX_TEXTURES_IN_SHADER")){var e=Math.floor(t.length/2),n=this.addN(t.slice(0,e)),r=this.addN(t.slice(e));return this.addN([n,r])}var o=t.map((function(t){return t.dtype})).reduce((function(t,e){return Et(t,e)})),a=t.map((function(t){return t.shape})),i=f().getBool("WEBGL_PACK")?new oo(t[0].shape,a):new ro(t[0].shape,a);return this.compileAndRun(i,t,o)},e.prototype.subtract=function(t,e){if("complex64"===t.dtype&&"complex64"===e.dtype)return this.complexSeparableBinaryOp(t,e,Oo);if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.subtract(t,e);var n=Et(t.dtype,e.dtype);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,Oo,t.dtype);var r=new No(Oo,t.shape,e.shape);return this.compileAndRun(r,[t,e],n)},e.prototype.pow=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Mo("\n // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n vec4 result = multiplier * pow(abs(a), b);\n\n // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n bvec4 isExpZero = equal(b, vec4(0.0));\n result.r = isExpZero.r ? 1.0 : result.r;\n result.g = isExpZero.g ? 1.0 : result.g;\n result.b = isExpZero.b ? 1.0 : result.b;\n result.a = isExpZero.a ? 1.0 : result.a;\n\n vec4 isNaN = vec4(lessThan(a, vec4(0.0))) * vec4(lessThan(floor(b), b));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",t.shape,e.shape):new No("\nif(a < 0.0 && floor(b) < b){\n return NAN;\n}\nif (b == 0.0) {\n return 1.0;\n}\nreturn (round(mod(b, 2.0)) != 1) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",t.shape,e.shape),r=Et(t.dtype,e.dtype);return this.compileAndRun(n,[t,e],r)},e.prototype.ceil=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.ceil(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,_i,t.dtype);var e=new gi(t.shape,_i);return this.compileAndRun(e,[t])},e.prototype.floor=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.floor(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,ki,t.dtype);var e=new gi(t.shape,ki);return this.compileAndRun(e,[t])},e.prototype.sign=function(t){var e=new gi(t.shape,"\n if (isnan(x)) { return 0.0; }\n return sign(x);\n");return this.compileAndRun(e,[t])},e.prototype.isNaN=function(t){var e=new gi(t.shape,"return float(isnan(x));");return this.compileAndRun(e,[t],"bool")},e.prototype.isInf=function(t){var e=new gi(t.shape,"return float(isinf(x));");return this.compileAndRun(e,[t],"bool")},e.prototype.isFinite=function(t){var e=new gi(t.shape,"return float(!isnan(x) && !isinf(x));");return this.compileAndRun(e,[t],"bool")},e.prototype.round=function(t){var e=new gi(t.shape,"\n // OpenGL ES does not support round function.\n // The algorithm is based on banker's rounding.\n float base = floor(x);\n if ((x - base) < 0.5) {\n return floor(x);\n } else if ((x - base) > 0.5) {\n return ceil(x);\n } else {\n if (mod(base, 2.0) == 0.0) {\n return base;\n } else {\n return base + 1.0;\n }\n }\n");return this.compileAndRun(e,[t])},e.prototype.exp=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.exp(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Ri,t.dtype);var e=new gi(t.shape,Ri);return this.compileAndRun(e,[t])},e.prototype.expm1=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.expm1(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Ii,t.dtype);var e=new gi(t.shape,Ii);return this.compileAndRun(e,[t])},e.prototype.log=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.log(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,"\n vec4 result = log(x);\n vec4 isNaN = vec4(lessThan(x, vec4(0.0)));\n result.r = isNaN.r == 1.0 ? NAN : result.r;\n result.g = isNaN.g == 1.0 ? NAN : result.g;\n result.b = isNaN.b == 1.0 ? NAN : result.b;\n result.a = isNaN.a == 1.0 ? NAN : result.a;\n\n return result;\n",t.dtype);var e=new gi(t.shape,"if (x < 0.0) return NAN;\n return log(x);");return this.compileAndRun(e,[t])},e.prototype.log1p=function(t){var e=new gi(t.shape,"return log(1.0 + x);");return this.compileAndRun(e,[t])},e.prototype.sqrt=function(t){var e=new gi(t.shape,"return sqrt(x);");return this.compileAndRun(e,[t])},e.prototype.rsqrt=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.rsqrt(t);var e=new gi(t.shape,"return inversesqrt(x);");return this.compileAndRun(e,[t])},e.prototype.reciprocal=function(t){var e=new gi(t.shape,"return 1.0 / x;");return this.compileAndRun(e,[t])},e.prototype.relu=function(t){var e;return e=f().getBool("WEBGL_PACK")?new Di(t.shape,Ai):new gi(t.shape,xi),this.compileAndRun(e,[t])},e.prototype.relu6=function(t){var e;return e=f().getBool("WEBGL_PACK")?new Di(t.shape,Oi):new gi(t.shape,wi),this.compileAndRun(e,[t])},e.prototype.prelu=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Mo(Fo,t.shape,e.shape):new No(Do,t.shape,e.shape);return this.compileAndRun(n,[t,e])},e.prototype.elu=function(t){if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Ti,t.dtype);var e=new gi(t.shape,Ei);return this.compileAndRun(e,[t])},e.prototype.eluDer=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Mo("\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",t.shape,e.shape):new No("return (b >= 1.0) ? a : a * (b + 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e])},e.prototype.selu=function(t){var e=new gi(t.shape,"\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = 1.7580993408473768;\n float scale = 1.0507009873554805;\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n");return this.compileAndRun(e,[t])},e.prototype.int=function(t){var e=new gi(t.shape,"return float(int(x));");return this.compileAndRun(e,[t],"int32")},e.prototype.clip=function(t,e,n){var r,o=(r=f().getBool("WEBGL_PACK_CLIP")?new Bo(t.shape):new Po(t.shape)).getCustomSetupFunc(e,n);return this.compileAndRun(r,[t],null,o)},e.prototype.abs=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.abs(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,bi,t.dtype);var e=new gi(t.shape,bi);return this.compileAndRun(e,[t])},e.prototype.complexAbs=function(t){var e=this.texData.get(t.dataId),n=new Lo(t.shape),r=[this.makeComplexComponentTensorInfo(t,e.complexTensors.real),this.makeComplexComponentTensorInfo(t,e.complexTensors.imag)];return this.compileAndRun(n,r)},e.prototype.sigmoid=function(t){var e=new gi(t.shape,"return 1.0 / (1.0 + exp(-1.0 * x));");return this.compileAndRun(e,[t])},e.prototype.softplus=function(t){var e=new gi(t.shape,"\n float epsilon = 1.1920928955078125e-7;\n float threshold = log(epsilon) + 2.0;\n\n bool too_large = x > -threshold;\n bool too_small = x < threshold;\n\n float result;\n float exp_x = exp(x);\n\n if (too_large){\n result = x;\n }\n else if (too_small){\n result = exp_x;\n }\n else{\n result = log(exp_x + 1.0);\n }\n return result;\n");return this.compileAndRun(e,[t])},e.prototype.sin=function(t){var e=new gi(t.shape,"if (isnan(x)) return x;\n return sin(x);\n");return this.compileAndRun(e,[t])},e.prototype.cos=function(t){var e=new gi(t.shape,"if (isnan(x)) return x;\n return cos(x);\n");return this.compileAndRun(e,[t])},e.prototype.tan=function(t){var e=new gi(t.shape,"return tan(x);");return this.compileAndRun(e,[t])},e.prototype.asin=function(t){var e=new gi(t.shape,"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n");return this.compileAndRun(e,[t])},e.prototype.acos=function(t){var e=new gi(t.shape,"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n");return this.compileAndRun(e,[t])},e.prototype.atan=function(t){var e=new gi(t.shape,"if (isnan(x)) return x;\n return atan(x);\n");return this.compileAndRun(e,[t])},e.prototype.atan2=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Mo("\n vec4 result = atan(a, b);\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",t.shape,e.shape):new No("\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return atan(a, b);\n",t.shape,e.shape);return this.compileAndRun(n,[t,e])},e.prototype.sinh=function(t){var e=new gi(t.shape,"\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n");return this.compileAndRun(e,[t])},e.prototype.cosh=function(t){var e=new gi(t.shape,"\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n");return this.compileAndRun(e,[t])},e.prototype.tanh=function(t){var e=new gi(t.shape,"\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n");return this.compileAndRun(e,[t])},e.prototype.asinh=function(t){var e=new gi(t.shape,"if (isnan(x)) return x;return log(x + sqrt(x * x + 1.0));");return this.compileAndRun(e,[t])},e.prototype.acosh=function(t){var e=new gi(t.shape,"if (isnan(x)) return x;\n if (x < 1.0) return NAN;\n return log(x + sqrt(x * x - 1.0));");return this.compileAndRun(e,[t])},e.prototype.atanh=function(t){var e=new gi(t.shape,"if (isnan(x)) return x;\n if ((x < -1.0) || (x > 1.0)) return NAN;\n return (log(1.0 + x) - log(1.0 - x)) / 2.0;");return this.compileAndRun(e,[t])},e.prototype.erf=function(t){var e=new gi(t.shape,'\n // Error function is calculated approximately with elementary function.\n // See "Handbook of Mathematical Functions with Formulas,\n // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n float p = 0.3275911;\n float a1 = 0.254829592;\n float a2 = -0.284496736;\n float a3 = 1.421413741;\n float a4 = -1.453152027;\n float a5 = 1.061405429;\n\n float sign = sign(x);\n x = abs(x);\n float t = 1.0 / (1.0 + p * x);\n return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n');return this.compileAndRun(e,[t])},e.prototype.step=function(t,e){var n=new gi(t.shape,function(t){return void 0===t&&(t=0),yi+"\n return x > 0.0 ? 1.0 : float("+t+");\n "}(e));return this.compileAndRun(n,[t])},e.prototype.conv2dByMatMul=function(t,e,n,r,o,a){var i=t.shape,s=this.texData.get(t.dataId),u=n.inChannels,c=i[0]*i[1]*i[2],l=n.outChannels,h="channelsLast"===n.dataFormat,p=(1===c||1===l)&&u>1e3,d=i[2]%2!=0&&!!s.isPacked;if(p||!f().getBool("WEBGL_LAZILY_UNPACK")||!f().getBool("WEBGL_PACK_BINARY_OPERATIONS")||!d){var v=h?i[0]*i[1]*i[2]:i[0]*i[2]*i[3],m=this.reshape(t,[1,v,n.inChannels]),g=this.reshape(e,[1,n.inChannels,n.outChannels]);return this.reshape(this.fusedBatchMatMul({a:m,b:g,transposeA:!1,transposeB:!1,bias:r,activation:o,preluActivationWeights:a}),n.outShape)}var y=h?i[0]*i[1]*(i[2]+1):i[0]*i[2]*(i[3]+1),b={dataId:t.dataId,shape:[1,y,n.inChannels],dtype:t.dtype},x=s.shape;s.shape=s.shape.slice(),s.shape[s.shape.length-2]++,E(Ce(s.shape,b.shape),(function(){return"packed reshape "+s.shape+" to "+b.shape+" isn't free"}));var w=this.reshape(e,[1,n.inChannels,n.outChannels]),C=this.fusedBatchMatMul({a:b,b:w,transposeA:!1,transposeB:!1,bias:r,activation:o,preluActivationWeights:a}),_=this.texData.get(C.dataId);return E(_.isPacked,(function(){return"batchMatMul result is expected to be packed"})),s.shape=x,_.shape=n.outShape,Ot.makeTensorFromDataId(C.dataId,n.outShape,C.dtype)},e.prototype.conv2dWithIm2Row=function(t,e,n,r,o,a){var i=n.filterWidth,s=n.filterHeight,u=n.inChannels,c=n.outWidth,l=n.outHeight,f="channelsLast"===n.dataFormat,h=i*s*u,p=l*c,d=[h,p],v=t.squeeze([0]),m=e.reshape([1,h,-1]),g=new Na(d,v.shape,n),y=this.compileAndRun(g,[v]).reshape([1,d[0],d[1]]),b=null!=r,x=null!=a,w=o?Mi(o,!0):null,E=new Wa(y.shape,[1,p,n.outChannels],!0,!1,b,w,x),C=[y,m];r&&C.push(r),x&&C.push(a);var _=this.compileAndRun(E,C);return f?_.reshape([1,l,c,n.outChannels]):_.reshape([1,n.outChannels,l,c])},e.prototype.fusedConv2d=function(t){var e=t.input,n=t.filter,r=t.convInfo,o=t.bias,a=t.activation,i=t.preluActivationWeights;if(1===r.filterHeight&&1===r.filterWidth&&1===r.dilationHeight&&1===r.dilationWidth&&1===r.strideHeight&&1===r.strideWidth&&("SAME"===r.padInfo.type||"VALID"===r.padInfo.type))return this.conv2dByMatMul(e,n,r,o,a,i);if(f().getBool("WEBGL_CONV_IM2COL")&&1===e.shape[0])return this.conv2dWithIm2Row(e,n,r,o,a,i);var s=null!=o,u=null!=i,c=a?Mi(a,!1):null,l=new Xo(r,s,c,u),h=[e,n];return o&&h.push(o),i&&h.push(i),this.compileAndRun(l,h)},e.prototype.conv2d=function(t,e,n){if(1===n.filterHeight&&1===n.filterWidth&&1===n.dilationHeight&&1===n.dilationWidth&&1===n.strideHeight&&1===n.strideWidth&&("SAME"===n.padInfo.type||"VALID"===n.padInfo.type))return this.conv2dByMatMul(t,e,n);if(f().getBool("WEBGL_CONV_IM2COL")&&1===t.shape[0])return this.conv2dWithIm2Row(t,e,n);var r=new Xo(n);return this.compileAndRun(r,[t,e])},e.prototype.conv2dDerInput=function(t,e,n){var r=new Vo(n);return this.compileAndRun(r,[t,e])},e.prototype.conv2dDerFilter=function(t,e,n){var r=new zo(n);return this.compileAndRun(r,[t,e])},e.prototype.fusedDepthwiseConv2D=function(t){var e,n=t.input,r=t.filter,o=t.convInfo,a=t.bias,i=t.activation,s=t.preluActivationWeights,u=f().getBool("WEBGL_PACK_DEPTHWISECONV")&&o.strideWidth<=2&&o.outChannels/o.inChannels==1,c=i?Mi(i,u):null,l=[n,r],h=null!=a,p=null!=s;return h&&l.push(a),p&&l.push(s),u?(e=new Jo(o,h,c,p),this.compileAndRun(e,l)):(e=new Yo(o,h,c,p),this.compileAndRun(e,l))},e.prototype.depthwiseConv2D=function(t,e,n){var r;return f().getBool("WEBGL_PACK_DEPTHWISECONV")&&n.strideWidth<=2&&n.outChannels/n.inChannels==1?(r=new Jo(n),this.compileAndRun(r,[t,e])):(r=new Yo(n),this.compileAndRun(r,[t,e]))},e.prototype.depthwiseConv2DDerInput=function(t,e,n){var r=new Ko(n);return this.compileAndRun(r,[t,e])},e.prototype.depthwiseConv2DDerFilter=function(t,e,n){var r=new qo(n);return this.compileAndRun(r,[t,e])},e.prototype.conv3d=function(t,e,n){var r=new $o(n);return this.compileAndRun(r,[t,e])},e.prototype.conv3dDerInput=function(t,e,n){var r=new Ho(n);return this.compileAndRun(r,[t,e])},e.prototype.conv3dDerFilter=function(t,e,n){var r=new Go(n);return this.compileAndRun(r,[t,e])},e.prototype.maxPool=function(t,e){var n=new Ha(e,"max",!1);return this.compileAndRun(n,[t])},e.prototype.avgPool=function(t,e){var n=new Ha(e,"avg",!1);return this.compileAndRun(n,[t],"float32")},e.prototype.maxPoolBackprop=function(t,e,n,r){var o=new Ha(r,"max",!0),a=this.compileAndRun(o,[e]),i=new Ba(r),s=this.compileAndRun(i,[t,a],e.dtype);return a.dispose(),s},e.prototype.avgPoolBackprop=function(t,e,n){var r=new _o(n);return this.compileAndRun(r,[t],e.dtype)},e.prototype.cast=function(t,e){return Gr(t,e,this)},e.prototype.unstack=function(t,e){for(var n=t.shape[e],r=new Array(t.rank-1),o=0,a=0;a<t.rank;a++)a!==e&&(r[o++]=t.shape[a]);var i=new Array(t.rank).fill(0),s=t.shape.slice();s[e]=1;var u=new Array(n);for(a=0;a<u.length;a++)i[e]=a,u[a]=this.slice(t,i,s).reshape(r);return u},e.prototype.avgPool3d=function(t,e){var n=new qa(e,"avg",!1);return this.compileAndRun(n,[t],"float32")},e.prototype.avgPool3dBackprop=function(t,e,n){var r=new ko(n);return this.compileAndRun(r,[t],e.dtype)},e.prototype.maxPool3d=function(t,e){var n=new qa(e,"max",!1);return this.compileAndRun(n,[t],"float32")},e.prototype.maxPool3dBackprop=function(t,e,n,r){var o=new qa(r,"max",!0),a=this.compileAndRun(o,[e]),i=new La(r),s=this.compileAndRun(i,[t,a],e.dtype);return a.dispose(),s},e.prototype.reshape=function(t,e){var n=this.texData.get(t.dataId);if(n.isPacked&&!Ce(t.shape,e)&&(null===n.texture||!Ce(n.shape,e))){var r=this.packedReshape(t,e);return Ot.makeTensorFromDataId(r.dataId,r.shape,r.dtype)}return Hr(t,e)},e.prototype.resizeBilinear=function(t,e,n,r){var o=f().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Ja(t.shape,e,n,r):new Ya(t.shape,e,n,r);return this.compileAndRun(o,[t],"float32")},e.prototype.resizeBilinearBackprop=function(t,e,n){var r=new $a(t,e,n);return this.compileAndRun(r,[t])},e.prototype.resizeNearestNeighbor=function(t,e,n,r){var o=new Za(t.shape,e,n,r);return this.compileAndRun(o,[t])},e.prototype.resizeNearestNeighborBackprop=function(t,e,n){var r=new Qa(t,e,n);return this.compileAndRun(r,[t])},e.prototype.multinomial=function(t,e,n,r){var o=e?t:_r(t),a=o.shape[0],i=o.shape[1],s=new Ua(a,i,n),u=s.getCustomSetupFunc(r);return this.compileAndRun(s,[o],"int32",u)},e.prototype.oneHot=function(t,e,n,r){var o=new ja(t.size,e,n,r);return this.compileAndRun(o,[t])},e.prototype.diag=function(t){var e=new oa(t.size);return this.compileAndRun(e,[t])},e.prototype.nonMaxSuppression=function(t,e,n,r,o){return Le("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"),Jr(t.dataSync(),e.dataSync(),n,r,o)},e.prototype.cropAndResize=function(t,e,n,r,o,a){var i=new Qo(t.shape,e.shape,r,o,a);return this.compileAndRun(i,[t,e,n],"float32")},e.prototype.depthToSpace=function(t,e,n){E(e>1,(function(){return"blockSize should be > 1 for depthToSpace, but was: "+e}));var r=t.shape[0],o="NHWC"===n?t.shape[1]:t.shape[2],a="NHWC"===n?t.shape[2]:t.shape[3],i="NHWC"===n?t.shape[3]:t.shape[1],s=o*e,u=a*e,c=i/(e*e),l=new ra("NHWC"===n?[r,s,u,c]:[r,c,s,u],e,n);return this.compileAndRun(l,[t])},e.prototype.split=function(t,e,n){return Zr(t,e,n)},e.prototype.scatterND=function(t,e,n){var r=vr(0,t,n),o=r.sliceRank,a=r.numUpdates,i=r.sliceSize,s=r.strides,u=r.outputSize,c=[u/i,i],l=t.reshape([a,o]),f=e.reshape([a,i]);if(0===u)return Hr(rn([]),n);var h=an(0),p=new ni(a,o,l.rank,f.rank,s,c);return this.compileAndRun(p,[f,l,h]).reshape(n)},e.prototype.sparseToDense=function(t,e,n,r){var o=vr(0,t,n),a=o.sliceRank,i=o.numUpdates,s=o.strides,u=o.outputSize,c=new ni(i,a,t.rank,e.rank,s,[u,1],!1);return this.compileAndRun(c,[e,t,r]).reshape(n)},e.prototype.fft=function(t){return this.fftImpl(t,!1)},e.prototype.ifft=function(t){return this.fftImpl(t,!0)},e.prototype.fftImpl=function(t,e){var n=this.texData.get(t.dataId),r=new ca("return real * expR - imag * expI;",t.shape,e),o=new ca("return real * expI + imag * expR;",t.shape,e),a=[this.makeComplexComponentTensorInfo(t,n.complexTensors.real),this.makeComplexComponentTensorInfo(t,n.complexTensors.imag)],i=this.compileAndRun(r,a),s=this.compileAndRun(o,a),u=this.complex(i,s).as2D(t.shape[0],t.shape[1]);return i.dispose(),s.dispose(),u},e.prototype.gatherND=function(t,e){var n=e.shape,r=n[n.length-1],o=pr(t,e),a=o[0],i=o[1],s=o[2],u=o[3],c=e.reshape([i,r]),l=t.reshape([t.size/s,s]),f=new ha(r,u,[i,s]);return this.compileAndRun(f,[l,c]).reshape(a)},e.prototype.fill=function(t,e,n){if("string"===(n=n||K(e))){var r=B(n,R(t));return r.fill(e),Ot.makeTensor(r,t,n,this)}var o=new la(t,e),a=o.getCustomSetupFunc(e);return this.compileAndRun(o,[],n,a)},e.prototype.onesLike=function(t){if("string"===t.dtype)throw new Error("onesLike is not supported under string dtype");return this.fill(t.shape,1,t.dtype)},e.prototype.zerosLike=function(t){return this.fill(t.shape,"string"===t.dtype?"":0,t.dtype)},e.prototype.linspace=function(t,e,n){return qr(t,e,n)},e.prototype.makeTensorInfo=function(t,e){var n=this.write(null,t,e);return this.texData.get(n).usage=null,{dataId:n,shape:t,dtype:e}},e.prototype.makeOutput=function(t,e){var n=this.makeTensorInfo(t,e).dataId;return Ot.makeTensorFromDataId(n,t,e,this)},e.prototype.unpackTensor=function(t){var e=new Ni(t.shape);return this.runWebGLProgram(e,[t],t.dtype)},e.prototype.packTensor=function(t){var e=new za(t.shape);return this.runWebGLProgram(e,[t],t.dtype,null,!0)},e.prototype.packedReshape=function(t,e){var n=[ye(t.shape)].concat(be(t.shape)),r={dtype:t.dtype,shape:n,dataId:t.dataId},o=[ye(e)].concat(be(e)),a=new Xa(o,n),i=this.runWebGLProgram(a,[r],t.dtype,null,!0);return{dataId:i.dataId,shape:e,dtype:i.dtype}},e.prototype.decode=function(t){var e,n=this.texData.get(t),r=n.isPacked,o=n.shape,a=n.dtype,i=xe(o);return e=r?new na(i):new ea(i),{dtype:a,shape:o,dataId:this.runWebGLProgram(e,[{shape:i,dtype:a,dataId:t}],a,null,!0).dataId}},e.prototype.runWebGLProgram=function(t,e,n,r,o){var a=this;void 0===o&&(o=!1);var i=this.makeTensorInfo(t.outputShape,n),s=this.texData.get(i.dataId);if(t.packedOutput&&(s.isPacked=!0),t.outPackingScheme===Nt.DENSE){var u=jt(t.outputShape);s.texShape=u.map((function(t){return 2*t}))}if(null!=t.outTexUsage&&(s.usage=t.outTexUsage),0===R(i.shape))return s.values=P(i.dtype,0),i;var c=[],l=e.map((function(e){if("complex64"===e.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");var n=a.texData.get(e.dataId);if(null==n.texture){if(!t.packedInputs&&R(e.shape)<=f().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:e.shape,texData:null,isUniform:!0,uniformValues:n.values};t.packedInputs&&(n.isPacked=!0,n.shape=e.shape)}else if(!!n.isPacked!=!!t.packedInputs)e=n.isPacked?a.unpackTensor(e):a.packTensor(e),c.push(e),n=a.texData.get(e.dataId);else if(n.isPacked&&!Ce(n.shape,e.shape)){var r=e,o=e.shape;e.shape=n.shape,e=a.packedReshape(e,o),c.push(e),n=a.texData.get(e.dataId),r.shape=o}return a.uploadToGPU(e.dataId),{shape:e.shape,texData:n,isUniform:!1}}));this.uploadToGPU(i.dataId);var h,p={shape:i.shape,texData:s,isUniform:!1},d=function(t,e,n){var r="";e.concat(n).forEach((function(t){var e=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0,n=t.isUniform?"uniform":t.texData.texShape;r+=t.shape+"_"+n+"_"+e}));var o=t.userCode;return t.constructor.name+"_"+r+"_"+o}(t,l,p),v=this.getAndSaveBinary(d,(function(){return function(t,e,n,r){var o=e.userCode,a=n.map((function(t,n){var r={logicalShape:t.shape,texShape:t.isUniform?null:t.texData.texShape,isUniform:t.isUniform,isPacked:!t.isUniform&&t.texData.isPacked,flatOffset:null};return null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0&&(r.flatOffset=t.texData.slice.flatOffset),{name:e.variableNames[n],shapeInfo:r}})),i=a.map((function(t){return t.shapeInfo})),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},u=ho(a,s,o,e.packedInputs),c=t.createProgram(u),l=null,h=t.getUniformLocation(c,"NAN",!1);1===f().getNumber("WEBGL_VERSION")&&(l=t.getUniformLocation(c,"INFINITY",!1));for(var p={},d=0;d<e.variableNames.length;d++){var v=e.variableNames[d];p[v]=t.getUniformLocation(c,v,!1),p["offset"+v]=t.getUniformLocation(c,"offset"+v,!1)}return{program:e,source:u,webGLProgram:c,uniformLocations:p,inShapeInfos:i,outShapeInfo:s,infLoc:l,nanLoc:h}}(a.gpgpu,t,l,p)})),m=null!=this.activeTimers;if(m&&(h=this.startTimer()),function(t,e,n,r,o){Da(e.inShapeInfos,n),Da([e.outShapeInfo],[r]);var a=r.texData.texture,i=r.texData.texShape;r.texData.isPacked?t.setOutputPackedMatrixTexture(a,i[0],i[1]):t.setOutputMatrixTexture(a,i[0],i[1]),t.setProgram(e.webGLProgram),1===f().getNumber("WEBGL_VERSION")&&null!==e.infLoc&&t.gl.uniform1f(e.infLoc,1/0),null!==e.nanLoc&&t.gl.uniform1f(e.nanLoc,NaN),n.forEach((function(n,r){var o=e.program.variableNames[r],a=e.uniformLocations[o],i=e.uniformLocations["offset"+o];if(null!=a)if(n.isUniform)if(R(n.shape)<2)t.gl.uniform1f(a,n.uniformValues[0]);else{var s=n.uniformValues;s instanceof Float32Array||(s=new Float32Array(s)),t.gl.uniform1fv(a,s)}else null!=n.texData.slice&&null!=i&&t.gl.uniform1i(i,n.texData.slice.flatOffset),t.setInputMatrixTexture(n.texData.texture,a,r)})),null!=o&&o(t,e.webGLProgram),t.executeProgram()}(this.gpgpu,v,l,p,r),c.forEach((function(t){return a.disposeData(t.dataId)})),m&&(h=this.endTimer(h),this.activeTimers.push({name:t.constructor.name,query:this.getQueryTime(h)})),!f().getBool("WEBGL_LAZILY_UNPACK")&&s.isPacked&&!1===o){var g=this.unpackTensor(i);return this.disposeData(i.dataId),g}return i},e.prototype.compileAndRun=function(t,e,n,r,o){void 0===o&&(o=!1),n=n||e[0].dtype;var a=this.runWebGLProgram(t,e,n,r,o);return Ot.makeTensorFromDataId(a.dataId,a.shape,a.dtype)},e.prototype.getAndSaveBinary=function(t,e){return t in this.binaryCache||(this.binaryCache[t]=e()),this.binaryCache[t]},e.prototype.getTextureManager=function(){return this.textureManager},e.prototype.dispose=function(){this.disposed||(this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)},e.prototype.floatPrecision=function(){var t=this;return null==this.floatPrecisionValue&&(this.floatPrecisionValue=Pe((function(){if(!f().get("WEBGL_RENDER_FLOAT32_ENABLED")){var e=f().getBool("DEBUG");f().set("DEBUG",!1);var n=t.abs(an(1e-8)).dataSync()[0];if(f().set("DEBUG",e),n>0)return 32}return 16}))),this.floatPrecisionValue},e.prototype.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4},e.prototype.uploadToGPU=function(t){var e,n=this.texData.get(t),r=n.shape,o=n.dtype,a=n.values,i=n.texture,s=n.usage,u=n.isPacked;if(null==i){var c,l=null!=this.activeTimers;l&&(c=et());var f=n.texShape;if(null==f&&(f=we(r,u),n.texShape=f),null!=a){var h=xe(r),p=void 0,d=f[1],v=f[0],m=a instanceof Uint8Array;u?(d=(e=zt(f[0],f[1]))[0],v=e[1],p=new ua(h,[v,d],m)):p=new sa(h,[v,d],m);var g=this.makeTensorInfo([v,d],o);this.texData.get(g.dataId).usage=m?Ft.PIXELS:Ft.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(g.dataId),d,v,a);var y=this.runWebGLProgram(p,[g],o,null,!0),b=this.texData.get(y.dataId);n.texture=b.texture,n.texShape=b.texShape,n.isPacked=b.isPacked,n.usage=b.usage,this.disposeData(g.dataId),this.texData.delete(y.dataId),n.values=null,l&&(this.uploadWaitMs+=et()-c)}else{var x=this.acquireTexture(f,s,o,u);n.texture=x}}},e.prototype.convertAndCacheOnCPU=function(t,e){var n=this.texData.get(t),r=n.dtype;return this.releaseGPUData(t),null!=e&&(n.values=function(t,e){if("float32"===e||"complex64"===e)return t;if("int32"===e||"bool"===e){for(var n="int32"===e?new Int32Array(t.length):new Uint8Array(t.length),r=0;r<n.length;++r)n[r]=Math.round(t[r]);return n}throw new Error("Unknown dtype "+e)}(e,r)),n.values},e.prototype.acquireTexture=function(t,e,n,r){if(this.numBytesInGPU+=this.computeBytes(t,n),!this.warnedAboutMemory&&this.numBytesInGPU>1024*this.numMBBeforeWarning*1024){(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0}return this.textureManager.acquireTexture(t,e,r)},e.prototype.computeBytes=function(t,e){return t[0]*t[1]*z(e)},e}(Ir);Tt()&&Ot.registerBackend("webgl",(function(){return new Pi}),2);var Bi=Ze({square_:function(t){var e=je(t,"x","square"),n=[e];return Ot.runKernelFunc((function(t,n){return n([e]),t.square(e)}),{x:e},(function(t,e){var n=e[0];return{x:function(){return t.mul(n.toFloat().mul(2))}}}),"Square",{},n,[])}}),Li=Ze({abs_:function(t){var e=je(t,"x","abs");return"complex64"===e.dtype?Ot.runKernelFunc((function(t){return t.complexAbs(e)}),{$x:e}):Ot.runKernelFunc((function(t,n){var r=t.abs(e);return n([e]),r}),{x:e},(function(t,e){var n=e[0];return{x:function(){return t.mul(n.toFloat().step(-1))}}}),"Abs")}}),Wi=Ze({acos_:function(t){var e=je(t,"x","acos");return Ot.runKernelFunc((function(t,n){var r=t.acos(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.divStrict(an(1).sub(n.toFloat().square()).sqrt()).neg()}}}))}}),Ui=Ze({acosh_:function(t){var e=je(t,"x","acosh");return Ot.runKernelFunc((function(t,n){var r=t.acosh(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.divStrict(n.toFloat().square().sub(1).sqrt())}}}))}}),ji=Ze({asin_:function(t){var e=je(t,"x","asin");return Ot.runKernelFunc((function(t,n){var r=t.asin(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.divStrict(an(1).sub(n.toFloat().square()).sqrt())}}}))}}),zi=Ze({asinh_:function(t){var e=je(t,"x","asinh");return Ot.runKernelFunc((function(t,n){var r=t.asinh(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.divStrict(an(1).add(n.toFloat().square()).sqrt())}}}))}}),Vi=Ze({atan_:function(t){var e=je(t,"x","atan");return Ot.runKernelFunc((function(t,n){var r=t.atan(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(n.toFloat().square().add(1))}}}))}}),Gi=Ze({atanh_:function(t){var e=je(t,"x","atanh");return Ot.runKernelFunc((function(t,n){var r=t.atanh(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(an(1).sub(n.toFloat().square()))}}}))}}),Hi=Ze({ceil_:function(t){var e=je(t,"x","ceil");return Ot.runKernelFunc((function(t){return t.ceil(e)}),{$x:e},(function(t){return{$x:function(){return mn(t)}}}))}}),qi=Ze({clipByValue_:function(t,e,n){var r=je(t,"x","clipByValue");E(e<=n,(function(){return"Error in clip: min ("+e+") must be less than or equal to max ("+n+")."}));var o=[r],a={min:e,max:n};return Ot.runKernelFunc((function(t,o){var a=t.clip(r,e,n);return o([r]),a}),{x:r},(function(t,r){var o=r[0];return{x:function(){return t.where(o.greaterEqual(e).logicalAnd(o.lessEqual(n)),mn(t))}}}),"ClipByValue",a,o)}}),Ki=Ze({cos_:function(t){var e=je(t,"x","cos");return Ot.runKernelFunc((function(t,n){var r=t.cos(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return n.toFloat().sin().neg().mul(t)}}}))}}),Xi=Ze({cosh_:function(t){var e=je(t,"x","cosh");return Ot.runKernelFunc((function(t,n){var r=t.cosh(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return n.toFloat().sinh().mulStrict(t)}}}))}}),$i=Ze({erf_:function(t){var e=je(t,"x","erf");return E("int32"===e.dtype||"float32"===e.dtype,(function(){return"Input dtype must be `int32` or `float32`."})),"int32"===e.dtype&&(e=e.toFloat()),Ot.runKernelFunc((function(t,n){var r=t.erf(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.mul(n.square().neg().exp().mul(2/Math.sqrt(Math.PI)))}}}))}}),Yi=Ze({exp_:function(t){var e=je(t,"x","exp");return Ot.runKernelFunc((function(t,n){var r=t.exp(e);return n([r]),r}),{$x:e},(function(t,e){return{$x:function(){return t.mulStrict(e[0])}}}))}}),Ji=Ze({expm1_:function(t){var e=je(t,"x","expm1");return Ot.runKernelFunc((function(t,n){var r=t.expm1(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.mul(n.exp())}}}))}}),Qi=Ze({floor_:function(t){var e=je(t,"x","floor");return Ot.runKernelFunc((function(t){return t.floor(e)}),{$x:e},(function(t){return{$x:function(){return mn(t)}}}))}}),Zi=Ze({log_:function(t){var e=je(t,"x","log");return Ot.runKernelFunc((function(t,n){var r=t.log(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(n.toFloat())}}}))}}),ts=Ze({log1p_:function(t){var e=je(t,"x","log1p");return Ot.runKernelFunc((function(t,n){var r=t.log1p(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(n.add(1))}}}))}}),es=Ze({logSigmoid_:function(t){var e=je(t,"x","logSigmoid");return Ot.runKernelFunc((function(t,n){var r=t.softplus(e.neg()).neg();return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.mul(n.neg().sigmoid())}}}))}}),ns=Ze({neg_:function(t){var e=je(t,"x","neg");return Ot.runKernelFunc((function(t){return t.neg(e)}),{$x:e},(function(t){return{$x:function(){return t.neg()}}}))}}),rs=Ze({reciprocal_:function(t){var e=je(t,"x","reciprocal");return Ot.runKernelFunc((function(t,n){var r=t.reciprocal(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(n.square().neg())}}}))}}),os=Ze({round_:function(t){var e=je(t,"x","round");return Ot.runKernelFunc((function(t){return t.round(e)}),{$x:e},(function(t){return{$x:function(){return mn(t)}}}))}}),as=Ze({rsqrt_:function(t){var e=je(t,"x","rsqrt");return Ot.runKernelFunc((function(t,n){var r=t.rsqrt(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(n.pow(1.5).mul(2)).neg()}}}))}}),is=Ze({sigmoid_:function(t){var e=je(t,"x","sigmoid");return Ot.runKernelFunc((function(t,n){var r=t.sigmoid(e);return n([r]),r}),{x:e},(function(t,e){var n=e[0];return{x:function(){return t.mul(n.mul(an(1).sub(n)))}}}),"Sigmoid")}}),ss=Ze({sign_:function(t){var e=je(t,"x","sign");return Ot.runKernelFunc((function(t){return t.sign(e)}),{$x:e},(function(t){return{$x:function(){return mn(t)}}}))}}),us=Ze({isNaN_:function(t){var e=je(t,"x","isNaN");return Ot.runKernelFunc((function(t){return t.isNaN(e)}),{$x:e},(function(t){return{$x:function(){return mn(t)}}}))}}),cs=Ze({isInf_:function(t){var e=je(t,"x","isInf");return Ot.runKernelFunc((function(t){return t.isInf(e)}),{$x:e},(function(t){return{$x:function(){return mn(t)}}}))}}),ls=Ze({isFinite_:function(t){var e=je(t,"x","isFinite");return Ot.runKernelFunc((function(t){return t.isFinite(e)}),{$x:e},(function(t){return{$x:function(){return mn(t)}}}))}}),fs=Ze({sin_:function(t){var e=je(t,"x","sin");return Ot.runKernelFunc((function(t,n){var r=t.sin(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return n.toFloat().cos().mul(t)}}}))}}),hs=Ze({sinh_:function(t){var e=je(t,"x","sinh");return Ot.runKernelFunc((function(t,n){var r=t.sinh(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return n.toFloat().cosh().mulStrict(t)}}}))}}),ps=Ze({softplus_:function(t){var e=je(t,"x","softplus");return Ot.runKernelFunc((function(t,n){var r=t.softplus(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.mul(n.sigmoid())}}}))}}),ds=Ze({sqrt_:function(t){var e=je(t,"x","sqrt");return Ot.runKernelFunc((function(t,n){var r=t.sqrt(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(n.toFloat().sqrt().mul(2))}}}))}}),vs=Ze({step_:function(t,e){void 0===e&&(e=0);var n=je(t,"x","step");return Ot.runKernelFunc((function(t){return t.step(n,e)}),{$x:n},(function(t){return{$x:function(){return mn(t)}}}))}}),ms=Ze({tan_:function(t){var e=je(t,"x","tan");return Ot.runKernelFunc((function(t,n){var r=t.tan(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(n.cos().square())}}}))}}),gs=Ze({tanh_:function(t){var e=je(t,"x","tanh");return Ot.runKernelFunc((function(t,n){var r=t.tanh(e);return n([r]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return an(1).sub(n.square()).mulStrict(t)}}}))}});function ys(t,e,n,r,o,a){var i,s,u=je(t,"x","batchNorm"),c=je(e,"mean","batchNorm"),l=je(n,"variance","batchNorm");return null!=o&&(i=je(o,"scale","batchNorm")),null!=r&&(s=je(r,"offset","batchNorm")),E(2===u.rank,(function(){return"Error in batchNorm3D: x must be rank 3 but got rank "+u.rank+"."})),E(2===c.rank||1===c.rank,(function(){return"Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank "+c.rank+"."})),E(2===l.rank||1===l.rank,(function(){return"Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank "+l.rank+"."})),null!=i&&E(2===i.rank||1===i.rank,(function(){return"Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank "+i.rank+"."})),null!=s&&E(2===s.rank||1===s.rank,(function(){return"Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank "+s.rank+"."})),ws(u,c,l,s,i,a)}function bs(t,e,n,r,o,a){var i,s,u=je(t,"x","batchNorm"),c=je(e,"mean","batchNorm"),l=je(n,"variance","batchNorm");return null!=o&&(i=je(o,"scale","batchNorm")),null!=r&&(s=je(r,"offset","batchNorm")),E(3===u.rank,(function(){return"Error in batchNorm3D: x must be rank 3 but got rank "+u.rank+"."})),E(3===c.rank||1===c.rank,(function(){return"Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank "+c.rank+"."})),E(3===l.rank||1===l.rank,(function(){return"Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank "+l.rank+"."})),null!=i&&E(3===i.rank||1===i.rank,(function(){return"Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank "+i.rank+"."})),null!=s&&E(3===s.rank||1===s.rank,(function(){return"Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank "+s.rank+"."})),ws(u,c,l,s,i,a)}function xs(t,e,n,r,o,a){var i,s,u=je(t,"x","batchNorm"),c=je(e,"mean","batchNorm"),l=je(n,"variance","batchNorm");return null!=o&&(i=je(o,"scale","batchNorm")),null!=r&&(s=je(r,"offset","batchNorm")),E(4===u.rank,(function(){return"Error in batchNorm4D: x must be rank 4 but got rank "+u.rank+"."})),E(4===c.rank||1===c.rank,(function(){return"Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank "+c.rank+"."})),E(4===l.rank||1===l.rank,(function(){return"Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank "+l.rank+"."})),null!=i&&E(4===i.rank||1===i.rank,(function(){return"Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank "+i.rank+"."})),null!=s&&E(4===s.rank||1===s.rank,(function(){return"Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank "+s.rank+"."})),ws(u,c,l,s,i,a)}function ws(t,e,n,r,o,a){null==a&&(a=.001);var i,s,u,c=je(t,"x","batchNorm"),l=je(e,"mean","batchNorm"),f=je(n,"variance","batchNorm");null!=o&&(i=je(o,"scale","batchNorm")),null!=r&&(s=je(r,"offset","batchNorm")),E(l.rank===f.rank,(function(){return"Batch normalization gradient requires mean and variance to have equal ranks."})),E(null==s||l.rank===s.rank,(function(){return"Batch normalization gradient requires mean and offset to have equal ranks."})),E(null==i||l.rank===i.rank,(function(){return"Batch normalization gradient requires mean and scale to have equal ranks."})),u=0===c.rank||1===c.rank?c.as4D(1,1,1,c.size):2===c.rank?c.as4D(1,1,c.shape[0],c.shape[1]):3===c.rank?c.as4D(1,c.shape[0],c.shape[1],c.shape[2]):c;var h=[c,l,f,i];return Ot.runKernelFunc((function(t,e){var n=t.batchNormalization(u,Es(l),Es(f),a,Es(i),Es(s));return e([c,l,f,i]),n}),{x:c,mean:l,variance:f,scale:i,offset:s},(function(t,e){var n=e,r=n[0],o=n[1],i=n[2],s=n[3],c=null==s?an(1):s,l=Or(o.shape,u.shape),f=[];if(1===o.rank){for(var h=0;h<u.shape.length-1;++h)f.push(u.shape[h]);f.push(1)}var p=r.sub(o),d=t.mul(c),v=as(i.add(an(a))),m=v.mul(v).mul(v).mul(an(-.5));return{x:function(){return 1===o.rank?t.mul(ar(v.as4D(1,1,1,o.shape[0]),f)).mul(c).reshape(r.shape):t.mul(v).mul(c).reshape(r.shape)},mean:function(){var t=v.mul(an(-1)).mul(d);return 1===o.rank&&(t=t.sum(l)),t.reshape(o.shape)},variance:function(){var t=m.mul(p).mul(d);return 1===o.rank&&(t=t.sum(l)),t.reshape(o.shape)},scale:function(){var e=p.mul(v),n=t.mul(e);return 1===o.rank&&(n=n.sum(l)),n.reshape(o.shape)},offset:function(){var e=t;return 1===o.rank&&(e=e.sum(l)),e.reshape(o.shape)}}}),"BatchNormalization",{varianceEpsilon:a},h).reshape(c.shape)}function Es(t){return null==t?null:0===t.rank?t.as1D():1===t.rank?t:2===t.rank?t.as4D(1,1,t.shape[0],t.shape[1]):3===t.rank?t.as4D(1,t.shape[0],t.shape[1],t.shape[2]):t}function Cs(){Me()}var _s=Ze({batchNormalization2d_:function(t,e,n,r,o,a){return void 0===r&&(r=.001),Cs(),ys(t,e,n,a,o,r)}}),ks=Ze({batchNormalization3d_:function(t,e,n,r,o,a){return void 0===r&&(r=.001),Cs(),bs(t,e,n,a,o,r)}}),Rs=Ze({batchNormalization4d_:function(t,e,n,r,o,a){return void 0===r&&(r=.001),Cs(),xs(t,e,n,a,o,r)}}),Is=Ze({batchNormalization_:function(t,e,n,r,o,a){return void 0===r&&(r=.001),Cs(),ws(t,e,n,a,o,r)}}),Ss=Ze({batchNorm_:ws}),As=Ze({batchNorm2d_:ys}),Os=Ze({batchNorm3d_:bs}),Ts=Ze({batchNorm4d_:xs}),Ds=Ze({logicalAnd_:function(t,e){var n=je(t,"a","logicalAnd","bool"),r=je(e,"b","logicalAnd","bool");return Tr(n.shape,r.shape),Ot.runKernelFunc((function(t){return t.logicalAnd(n,r)}),{$a:n,$b:r})}}),Ns=Ze({logicalNot_:function(t){var e=je(t,"x","logicalNot","bool");return Ot.runKernelFunc((function(t){return t.logicalNot(e)}),{$x:e})}}),Fs=Ze({logicalOr_:function(t,e){var n=je(t,"a","logicalOr","bool"),r=je(e,"b","logicalOr","bool");return Tr(n.shape,r.shape),Ot.runKernelFunc((function(t){return t.logicalOr(n,r)}),{$a:n,$b:r})}}),Ms=Ze({logicalXor_:function(t,e){var n=je(t,"a","logicalXor","bool"),r=je(e,"b","logicalXor","bool");return Tr(n.shape,r.shape),Fs(t,e).logicalAnd(Ds(t,e).logicalNot())}}),Ps=Ze({where_:function(t,e,n){var r=je(e,"a","where"),o=je(n,"b","where"),a=je(t,"condition","where","bool");return C(r.shape,o.shape,"Error in where: "),1===a.rank?E(a.shape[0]===r.shape[0],(function(){return"The first dimension of `a` must match the size of `condition`."})):C(a.shape,o.shape,"Error in where: "),Ot.runKernelFunc((function(t,e){var n=t.select(a,r,o);return e([a]),n}),{$condition:a,$a:r,$b:o},(function(t,e){var n=e[0];return{$condition:function(){return mn(n).toFloat()},$a:function(){return t.mul(n.cast(t.dtype))},$b:function(){return t.mul(n.logicalNot().cast(t.dtype))}}}))}}),Bs=function(t){return u(this,void 0,void 0,(function(){var e,n,r;return c(this,(function(o){switch(o.label){case 0:return[4,(e=je(t,"condition","whereAsync","bool")).data()];case 1:return n=o.sent(),r=no(e.shape,n),t!==e&&e.dispose(),[2,r]}}))}))},Ls=Ze({add_:function(t,e){var n,r=je(t,"a","add"),o=je(e,"b","add");n=_t(r,o),r=n[0],o=n[1];var a=Tr(r.shape,o.shape);return Ot.runKernelFunc((function(t){return t.add(r,o)}),{a:r,b:o},(function(t){return{a:function(){var e=t,n=Or(r.shape,a);return n.length>0&&(e=e.sum(n)),e.reshape(r.shape)},b:function(){var e=t,n=Or(o.shape,a);return n.length>0&&(e=e.sum(n)),e.reshape(o.shape)}}}),"Add")}}),Ws=Ze({addN_:function(t){E(Array.isArray(t),(function(){return"The argument passed to tf.addN() must be a list of tensors"})),E(t.length>=1,(function(){return"Must pass at least one tensor to tf.addN(), but got "+t.length}));var e=t.map((function(t,e){return je(t,"tensors"+e,"addN")})),n=e[0];e.forEach((function(t){if(t.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),e.forEach((function(t){if(!I(t.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));var r=e;return Ot.runKernelFunc((function(t){return t.addN(e)}),r,(function(t){var n={};return e.forEach((function(e,r){n[r]=function(){return t.clone()}})),n}),"AddN")}}),Us=Ze({addStrict_:function(t,e){var n=je(t,"a","addStrict"),r=je(e,"b","addStrict");return C(n.shape,r.shape,"Error in addStrict: "),n.add(r)}}),js=Ze({atan2_:function(t,e){var n,r=je(t,"a","atan2"),o=je(e,"b","atan2");n=_t(r,o),r=n[0],o=n[1];var a=Tr(r.shape,o.shape);return Ot.runKernelFunc((function(t,e){var n=t.atan2(r,o);return e([r,o]),n}),{$a:r,$b:o},(function(t,e){var n=e[0],r=e[1];return{$a:function(){var e=Ls(n.square(),r.square()),o=t.mul(r.div(e)),i=Or(n.shape,a);return i.length>0&&(o=o.sum(i)),o.reshape(n.shape)},$b:function(){var e=Ls(n.square(),r.square()),o=ns(t.mul(n.div(e))),i=Or(r.shape,a);return i.length>0&&(o=o.sum(i)),o.reshape(r.shape)}}}))}}),zs=Ze({div_:function(t,e){var n,r=je(t,"a","div"),o=je(e,"b","div");if(n=_t(r,o),r=n[0],o=n[1],"int32"===r.dtype&&"int32"===o.dtype)return Hs(r,o);var a=Tr(r.shape,o.shape);return Ot.runKernelFunc((function(t,e){var n=t.realDivide(r,o);return e([r,o]),n}),{a:r,b:o},(function(t,e){var n=e[0],r=e[1];return{a:function(){var e=t.div(r.toFloat()),o=Or(n.shape,a);return o.length>0?e.sum(o).reshape(n.shape):e},b:function(){var e=t.mul(n.toFloat()),o=Or(r.shape,a);o.length>0&&(e=e.sum(o).reshape(r.shape));var i=r.square();return e.div(i.toFloat()).neg()}}}),"Div")}}),Vs=Ze({divNoNan_:function(t,e){var n,r=je(t,"a","div"),o=je(e,"b","div");r=(n=_t(r,o))[0],o=n[1];var a=zs(r,o),i=mn(a),s=o.equal(i);return Ps(s,i,a)}}),Gs=Ze({divStrict_:function(t,e){var n=je(t,"a","div"),r=je(e,"b","div");return C(n.shape,r.shape,"Error in divideStrict: "),n.div(r)}}),Hs=Ze({floorDiv_:function(t,e){var n,r=je(t,"a","floorDiv"),o=je(e,"b","floorDiv");n=_t(r,o),r=n[0],o=n[1];var a=Tr(r.shape,o.shape);return Ot.runKernelFunc((function(t,e){var n=t.floorDiv(r,o);return e([r,o]),n}),{a:r,b:o},(function(t,e){var n=e[0],r=e[1];return{a:function(){var e=t.div(r.toFloat()),o=Or(n.shape,a);return o.length>0?e.sum(o).reshape(n.shape):e},b:function(){var e=t.mul(n.toFloat()),o=Or(r.shape,a);o.length>0&&(e=e.sum(o).reshape(r.shape));var i=r.square();return e.div(i.toFloat()).neg()}}}),"FloorDiv")}}),qs=Ze({maximum_:function(t,e){var n,r=je(t,"a","maximum"),o=je(e,"b","maximum");return n=_t(r,o),r=n[0],o=n[1],"bool"===r.dtype&&(r=r.toInt(),o=o.toInt()),Tr(r.shape,o.shape),Ot.runKernelFunc((function(t,e){var n=t.maximum(r,o);return e([r,o]),n}),{$a:r,$b:o},(function(t,e){var n=e[0],r=e[1];return{$a:function(){return t.mul(n.greaterEqual(r).toFloat())},$b:function(){return t.mul(n.less(r).toFloat())}}}))}}),Ks=Ze({maximumStrict_:function(t,e){var n=je(t,"a","maximumStrict"),r=je(e,"b","maximumStrict");return C(n.shape,r.shape,"Error in maximumStrict: "),n.maximum(r)}}),Xs=Ze({minimum_:function(t,e){var n,r=je(t,"a","minimum"),o=je(e,"b","minimum");return n=_t(r,o),r=n[0],o=n[1],"bool"===r.dtype&&(r=r.toInt(),o=o.toInt()),Tr(r.shape,o.shape),Ot.runKernelFunc((function(t,e){var n=t.minimum(r,o);return e([r,o]),n}),{$a:r,$b:o},(function(t,e){var n=e[0],r=e[1];return{$a:function(){return t.mul(n.lessEqual(r).toFloat())},$b:function(){return t.mul(n.greater(r).toFloat())}}}))}}),$s=Ze({minimumStrict_:function(t,e){var n=je(t,"a","minimumStrict"),r=je(e,"b","minimumStrict");return C(n.shape,r.shape,"Error in minimumStrict: "),n.minimum(r)}}),Ys=Ze({mod_:function(t,e){var n,r=je(t,"a","mod"),o=je(e,"b","mod");n=_t(r,o),r=n[0],o=n[1];var a=Tr(r.shape,o.shape);return Ot.runKernelFunc((function(t,e){var n=t.mod(r,o);return e([r,o]),n}),{$a:r,$b:o},(function(t,e){var n=e[0],r=e[1];return{$a:function(){var e=Or(n.shape,a);return e.length>0?t.sum(e).reshape(n.shape):t},$b:function(){var e=t.mul(n.div(r).floor().neg()),o=Or(r.shape,a);return o.length>0?e.sum(o).reshape(r.shape):e}}}))}}),Js=Ze({modStrict_:function(t,e){var n=je(t,"a","modStrict"),r=je(e,"b","modStrict");return C(n.shape,r.shape,"Error in modStrict: "),n.mod(r)}}),Qs=Ze({mul_:function(t,e){var n,r=je(t,"a","mul"),o=je(e,"b","mul");n=_t(r,o),r=n[0],o=n[1];var a=Tr(r.shape,o.shape);return Ot.runKernelFunc((function(t,e){var n=t.multiply(r,o);return e([r,o]),n}),{a:r,b:o},(function(t,e){var n=e[0],r=e[1];return{a:function(){var e=t.mul(r.toFloat()),o=Or(n.shape,a);return o.length>0?e.sum(o).reshape(n.shape):e},b:function(){var e=t.mul(n.toFloat()),o=Or(r.shape,a);return o.length>0?e.sum(o).reshape(r.shape):e}}}),"Mul")}}),Zs=Ze({mulStrict_:function(t,e){var n=je(t,"a","mul"),r=je(e,"b","mul");return C(n.shape,r.shape,"Error in multiplyStrict: "),n.mul(r)}}),tu=Ze({pow_:function(t,e){var n=je(t,"base","pow"),r=je(e,"exp","pow"),o=Tr(n.shape,r.shape);return t=n.cast(Et(n.dtype,r.dtype)),e=r.cast(Et(n.dtype,r.dtype)),Ot.runKernelFunc((function(t,e){var o=t.pow(n,r);return e([n,r,o]),o}),{$base:n,$exp:r},(function(t,e){var n=e[0],r=e[1],a=e[2];return{$base:function(){var e=r.toFloat(),a=t.mul(e.mul(n.pow(e.sub(an(1))))),i=Or(n.shape,o);return i.length>0&&(a=a.sum(i)),a.reshape(n.shape)},$exp:function(){var e=n.greater(0),i=n.log().where(e,mn(n)),s=t.mul(a.mul(i)),u=Or(r.shape,o);return u.length>0&&(s=s.sum(u)),s.reshape(r.shape)}}}))}}),eu=Ze({powStrict_:function(t,e){return C(t.shape,e.shape,"Error in powStrict: "),t.pow(e)}}),nu=Ze({squaredDifference_:function(t,e){var n,r=je(t,"a","squaredDifference"),o=je(e,"b","squaredDifference");return n=_t(r,o),r=n[0],o=n[1],Tr(r.shape,o.shape),Ot.runKernelFunc((function(t,e){var n=t.squaredDifference(r,o);return e([r,o]),n}),{$a:r,$b:o},(function(t,e){var n=e[0],r=e[1],o=an(2);return{$a:function(){return t.mul(n.sub(r).mul(o))},$b:function(){return t.mul(r.sub(n).mul(o))}}}))}}),ru=Ze({squaredDifferenceStrict_:function(t,e){var n=je(t,"a","squaredDifferenceStrict"),r=je(e,"b","squaredDifferenceStrict");return C(n.shape,r.shape,"Error in squaredDifferenceStrict: "),n.squaredDifference(r)}}),ou=Ze({sub_:function(t,e){var n,r=je(t,"a","sub"),o=je(e,"b","sub");n=_t(r,o),r=n[0],o=n[1];var a=Tr(r.shape,o.shape);return Ot.runKernelFunc((function(t){return t.subtract(r,o)}),{a:r,b:o},(function(t){return{a:function(){var e=t,n=Or(r.shape,a);return n.length>0&&(e=e.sum(n)),e.reshape(r.shape)},b:function(){var e=t,n=Or(o.shape,a);return n.length>0&&(e=e.sum(n)),e.neg().reshape(o.shape)}}}),"Sub")}}),au=Ze({subStrict_:function(t,e){var n=je(t,"a","subStrict"),r=je(e,"b","subStrict");return C(n.shape,r.shape,"Error in subStrict: "),n.sub(r)}}),iu=Ze({equal_:function(t,e){var n,r=je(t,"a","equal"),o=je(e,"b","equal");return n=_t(r,o),r=n[0],o=n[1],Tr(r.shape,o.shape),Ot.runKernelFunc((function(t){return t.equal(r,o)}),{$a:r,$b:o})}}),su=Ze({equalStrict_:function(t,e){var n=je(t,"a","equalStrict"),r=je(e,"b","equalStrict");return C(n.shape,r.shape,"Error in equalStrict: "),n.equal(r)}}),uu=Ze({greater_:function(t,e){var n,r=je(t,"a","greater"),o=je(e,"b","greater");return n=_t(r,o),r=n[0],o=n[1],Tr(r.shape,o.shape),Ot.runKernelFunc((function(t){return t.greater(r,o)}),{$a:r,$b:o})}}),cu=Ze({greaterEqual_:function(t,e){var n,r=je(t,"a","greaterEqual"),o=je(e,"b","greaterEqual");return n=_t(r,o),r=n[0],o=n[1],Tr(r.shape,o.shape),Ot.runKernelFunc((function(t,e){var n=t.greaterEqual(r,o);return e([r,o]),n}),{$a:r,$b:o},(function(t,e){var n=e[0],r=e[1];return{$a:function(){return mn(n)},$b:function(){return mn(r)}}}))}}),lu=Ze({greaterEqualStrict_:function(t,e){var n=je(t,"a","greaterEqualStrict"),r=je(e,"b","greaterEqualStrict");return C(n.shape,r.shape,"Error in greaterEqualStrict: "),n.greaterEqual(r)}}),fu=Ze({greaterStrict_:function(t,e){var n=je(t,"a","greaterStrict"),r=je(e,"b","greaterStrict");return C(n.shape,r.shape,"Error in greaterStrict: "),n.greater(r)}}),hu=Ze({less_:function(t,e){var n,r=je(t,"a","less"),o=je(e,"b","less");return n=_t(r,o),r=n[0],o=n[1],Tr(r.shape,o.shape),Ot.runKernelFunc((function(t){return t.less(r,o)}),{$a:r,$b:o})}}),pu=Ze({lessEqual_:function(t,e){var n,r=je(t,"a","lessEqual"),o=je(e,"b","lessEqual");return n=_t(r,o),r=n[0],o=n[1],Tr(r.shape,o.shape),Ot.runKernelFunc((function(t){return t.lessEqual(r,o)}),{$a:r,$b:o})}}),du=Ze({lessEqualStrict_:function(t,e){var n=je(t,"a","lessEqualStrict"),r=je(e,"b","lessEqualStrict");return C(n.shape,r.shape,"Error in lessEqualStrict: "),n.lessEqual(r)}}),vu=Ze({lessStrict_:function(t,e){var n=je(t,"a","lessStrict"),r=je(e,"b","lessStrict");return C(n.shape,r.shape,"Error in lessStrict: "),n.less(r)}}),mu=Ze({notEqual_:function(t,e){var n,r=je(t,"a","notEqual"),o=je(e,"b","notEqual");return n=_t(r,o),r=n[0],o=n[1],Tr(r.shape,o.shape),Ot.runKernelFunc((function(t){return t.notEqual(r,o)}),{$a:r,$b:o})}}),gu=Ze({notEqualStrict_:function(t,e){var n=je(t,"a","notEqualStrict"),r=je(e,"b","notEqualStrict");return C(n.shape,r.shape,"Error in notEqualStrict: "),n.notEqual(r)}});function yu(t,e){for(var n=[],r=t;r<e;++r)n.push(r);return n}function bu(t){for(var e=[],n=0;n<t.length;++n)for(var r=0;r<t[n].length;++r)e.push(t[n][r]);return e}var xu=Ze({gather_:function(t,e,n){void 0===n&&(n=0);var r=je(t,"x","gather"),o=je(e,"indices","gather","int32");n=F(n,r.shape)[0];var a=function(t,e,n){for(var r=t.shape[n],o=[],a=1,i=1,s=0;s<n;s++)o.push(t.shape[s]),a*=t.shape[s];for(s=0;s<e.rank;s++)o.push(e.shape[s]);for(s=n+1;s<t.rank;s++)o.push(t.shape[s]),i*=t.shape[s];return{batchSize:a,sliceSize:i,dimSize:r,outputShape:o}}(r,o,n);return Ot.runKernelFunc((function(t,e){var a=t.gather(r,o.flatten(),n);return e([o]),a}),{$x:r},(function(t,e){var o=e[0];return{$x:function(){var e=r.shape,a=o.size,i=e.slice(0,n),s=i.length,u=e.slice(n,e.length).slice(1),c=u.length,l=yu(0,s),f=yu(s+1,s+1+c),h=bu([i,[a],u]),p=t.reshape(h),d=o.reshape([a]),v=bu([[s],l,f]),m=p.transpose(v),g=wu(m,d,r.shape[n]),y=$e(v);return g.transpose(y)}}})).reshape(a.outputShape)}}),wu=Ze({unsortedSegmentSum_:function(t,e,n){var r=je(t,"x","unsortedSegmentSum"),o=je(e,"segmentIds","unsortedSegmentSum","int32");return E(S(n),(function(){return"numSegments must be of dtype int"})),Ot.runKernelFunc((function(t,e){var a=t.unsortedSegmentSum(r,o,n);return e([o]),a}),{$x:r},(function(t,e){var n=e[0];return{$x:function(){return function(t,e){for(var n=qs(e,mn(e)),r=xu(t,n),o=cu(e,an(0,"int32")),a=r.rank-o.rank,i=0;i<a;++i)o=zn(o,i+1);o=Ds(o,fn(r.shape,"bool"));var s=mn(r);return Ps(o,r,s)}(t,n)}}}))}});function Eu(t,e,n,r,o,a,i){void 0===a&&(a="NHWC"),E(t.length===e.rank,(function(){return"Length of inShape ("+t.length+") and rank of dy ("+e.rank+") must match"}));var s=t,u=e,c=!1;3===e.rank&&(c=!0,u=e.as4D(1,e.shape[0],e.shape[1],e.shape[2]),s=[1,t[0],t[1],t[2]]),E(4===s.length,(function(){return"Error in conv2dDerInput: inShape must be length 4, but got length "+s.length+"."})),E(4===u.rank,(function(){return"Error in conv2dDerInput: dy must be rank 4, but got rank "+u.rank})),E(4===n.rank,(function(){return"Error in conv2dDerInput: filter must be rank 4, but got rank "+n.rank}));var l="NHWC"===a?s[3]:s[1],f="NHWC"===a?u.shape[3]:u.shape[1];E(l===n.shape[2],(function(){return"Error in conv2dDerInput: depth of input ("+l+") must match input depth for filter "+n.shape[2]+"."})),E(f===n.shape[3],(function(){return"Error in conv2dDerInput: depth of output ("+f+") must match output depth for filter "+n.shape[3]+"."})),null!=i&&E(S(o),(function(){return"Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+o+"."}));var h=Vr(a),p=Fr(s,n.shape,r,1,o,i,!1,h),d=Ot.runKernelFunc((function(t,e){var r=t.conv2dDerInput(u,n,p);return e([n,u]),r}),{dy4D:u,filter:n},(function(t,e){var n=e[0],s=e[1];return{dy4D:function(){return Ru(t,n,r,o,a,1,i)},filter:function(){return Su(t,s,n.shape,r,o,a,i)}}}));return c?d.as3D(d.shape[1],d.shape[2],d.shape[3]):d}function Cu(t){var e=function(t){return"number"==typeof t?[t,t,t]:2===t.length?[t[0],t[1],1]:t}(t),n=e[0],r=e[1],o=e[2];return 1===n&&1===r&&1===o}function _u(t,e,n,r,o){E(t.length===e.rank,(function(){return"Length of inShape ("+t.length+") and rank of dy ("+e.rank+") must match"}));var a=t,i=e,s=!1;4===e.rank&&(s=!0,i=e.as5D(1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]),a=[1,t[0],t[1],t[2],t[3]]);var u=a[4],c=i.shape[4];E(5===a.length,(function(){return"Error in conv3dDerInput: inShape must be length 5, but got length "+a.length+"."})),E(5===i.rank,(function(){return"Error in conv3dDerInput: dy must be rank 5, but got rank "+i.rank})),E(5===n.rank,(function(){return"Error in conv3dDerInput: filter must be rank 5, but got rank "+n.rank})),E(u===n.shape[3],(function(){return"Error in conv3dDerInput: depth of input ("+u+") must match input depth for filter "+n.shape[3]+"."})),E(c===n.shape[4],(function(){return"Error in conv3dDerInput: depth of output ("+c+") must match output depth for filter "+n.shape[4]+"."}));var l=Mr(a,n.shape,r,1,o),f=Ot.runKernelFunc((function(t){return t.conv3dDerInput(i,n,l)}),{dy5D:i});return s?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f}var ku=Ze({conv1d_:function(t,e,n,r,o,a,i){void 0===o&&(o="NWC"),void 0===a&&(a=1);var s=je(t,"x","conv1d"),u=je(e,"filter","conv1d"),c=s,l=!1;2===s.rank&&(l=!0,c=s.as3D(1,s.shape[0],s.shape[1])),E(3===c.rank,(function(){return"Error in conv1d: input must be rank 3, but got rank "+c.rank+"."})),E(3===u.rank,(function(){return"Error in conv1d: filter must be rank 3, but got rank "+u.rank+"."})),null!=i&&E(S(r),(function(){return"Error in conv1d: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+r+"."})),E(c.shape[2]===u.shape[1],(function(){return"Error in conv1d: depth of input ("+c.shape[2]+") must match input depth for filter "+u.shape[1]+"."})),E(zr(n,a),(function(){return"Error in conv1D: Either stride or dilation must be 1. Got stride "+n+" and dilation '"+a+"'"})),E("NWC"===o,(function(){return"Error in conv1d: got dataFormat of "+o+" but only NWC is currently supported."}));var f=u.as4D(1,u.shape[0],u.shape[1],u.shape[2]),h=c.as4D(c.shape[0],1,c.shape[1],c.shape[2]),p=Ru(h,f,[1,n],r,"NHWC",[1,a],i);return l?p.as2D(p.shape[2],p.shape[3]):p.as3D(p.shape[0],p.shape[2],p.shape[3])}}),Ru=Ze({conv2d_:function(t,e,n,r,o,a,i){void 0===o&&(o="NHWC"),void 0===a&&(a=[1,1]);var s=je(t,"x","conv2d"),u=je(e,"filter","conv2d"),c=s,l=!1;3===s.rank&&(l=!0,c=s.as4D(1,s.shape[0],s.shape[1],s.shape[2])),E(4===c.rank,(function(){return"Error in conv2d: input must be rank 4, but got rank "+c.rank+"."})),E(4===u.rank,(function(){return"Error in conv2d: filter must be rank 4, but got rank "+u.rank+"."})),null!=i&&E(S(r),(function(){return"Error in conv2d: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+r+"."}));var f="NHWC"===o?c.shape[3]:c.shape[1];E(f===u.shape[2],(function(){return"Error in conv2d: depth of input ("+f+") must match input depth for filter "+u.shape[2]+"."})),E(zr(n,a),(function(){return"Error in conv2D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+a+"'"}));var h=Vr(o),p=Fr(c.shape,u.shape,n,a,r,i,!1,h),d=[u,c],v=Ot.runKernelFunc((function(t,e){var n=t.conv2d(c,u,p);return e([u,c]),n}),{x:c,filter:u},(function(t,e){var i=e,s=i[0],u=i[1];return E(jr(a),(function(){return"Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+a+"'"})),{x:function(){return Au(u.shape,t,s,n,r,o)},filter:function(){return Su(u,t,s.shape,n,r,o)}}}),"Conv2D",p,d);return l?v.as3D(v.shape[1],v.shape[2],v.shape[3]):v}}),Iu=Ze({conv3d_:function(t,e,n,r,o,a){void 0===o&&(o="NDHWC"),void 0===a&&(a=[1,1,1]);var i=je(t,"x","conv3d"),s=je(e,"filter","conv3d"),u=i,c=!1;4===i.rank&&(c=!0,u=i.as5D(1,i.shape[0],i.shape[1],i.shape[2],i.shape[3])),E(5===u.rank,(function(){return"Error in conv3d: input must be rank 5, but got rank "+u.rank+"."})),E(5===s.rank,(function(){return"Error in conv3d: filter must be rank 5, but got rank "+s.rank+"."})),E(u.shape[4]===s.shape[3],(function(){return"Error in conv3d: depth of input ("+u.shape[4]+") must match input depth for filter "+s.shape[3]+"."})),E(function(t,e){return Cu(t)||Cu(e)}(n,a),(function(){return"Error in conv3D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+a+"'"})),E("NDHWC"===o,(function(){return"Error in conv3d: got dataFormat of "+o+" but only NDHWC is currently supported."}));var l=Mr(u.shape,s.shape,n,a,r),f=Ot.runKernelFunc((function(t,e){var n=t.conv3d(u,s,l);return e([u,s]),n}),{x:u,$filter:s},(function(t,e){E(Cu(a),(function(){return"Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+a+"'"}));var o=e[0],i=e[1];return{x:function(){return _u(o.shape,t,i,n,r)},$filter:function(){return function(t,e,n,r,o){var a=t;4===t.rank&&(a=t.as5D(1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]));var i=e;4===i.rank&&(i=e.as5D(1,e.shape[0],e.shape[1],e.shape[2],e.shape[3])),E(5===a.rank,(function(){return"Error in conv3dDerFilter: input must be rank 5, but got shape "+a.shape+"."})),E(5===i.rank,(function(){return"Error in conv3dDerFilter: dy must be rank 5, but got shape "+i.shape+"."})),E(5===n.length,(function(){return"Error in conv3dDerFilter: filterShape must be length 5, but got "+n+"."})),E(a.shape[4]===n[3],(function(){return"Error in conv3dDerFilter: depth of input "+a.shape[4]+") must match input depth in filter ("+n[3]+"."})),E(i.shape[4]===n[4],(function(){return"Error in conv3dDerFilter: depth of dy ("+i.shape[4]+") must match output depth for filter ("+n[4]+")."}));var s=Mr(a.shape,n,r,1,o);return Ot.runKernelFunc((function(t){return t.conv3dDerFilter(a,i,s)}),{x5D:a,dy5D:i})}(o,t,i.shape,n,r)}}}));return c?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f}}),Su=Ze({conv2dDerFilter_:function(t,e,n,r,o,a,i){void 0===a&&(a="NHWC");var s=t;3===t.rank&&(s=t.as4D(1,t.shape[0],t.shape[1],t.shape[2]));var u=e;3===u.rank&&(u=e.as4D(1,e.shape[0],e.shape[1],e.shape[2])),E(4===s.rank,(function(){return"Error in conv2dDerFilter: input must be rank 4, but got shape "+s.shape+"."})),E(4===u.rank,(function(){return"Error in conv2dDerFilter: dy must be rank 4, but got shape "+u.shape+"."})),E(4===n.length,(function(){return"Error in conv2dDerFilter: filterShape must be length 4, but got "+n+"."}));var c="NHWC"===a?s.shape[3]:s.shape[1],l="NHWC"===a?u.shape[3]:u.shape[1];E(c===n[2],(function(){return"Error in conv2dDerFilter: depth of input "+c+") must match input depth in filter ("+n[2]+"."})),E(l===n[3],(function(){return"Error in conv2dDerFilter: depth of dy ("+l+") must match output depth for filter ("+n[3]+")."})),null!=i&&E(S(o),(function(){return"Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+o+"."}));var f=Vr(a),h=Fr(s.shape,n,r,1,o,i,!1,f);return Ot.runKernelFunc((function(t){return t.conv2dDerFilter(s,u,h)}),{x4D:s,dy4D:u})}}),Au=Ze({conv2dDerInput_:Eu}),Ou=Ze({depthwiseConv2d_:function(t,e,n,r,o,a,i){void 0===o&&(o="NHWC"),void 0===a&&(a=[1,1]);var s=je(t,"x","depthwiseConv2d"),u=je(e,"filter","depthwiseConv2d"),c=s,l=!1;3===s.rank&&(l=!0,c=s.as4D(1,s.shape[0],s.shape[1],s.shape[2])),E(4===c.rank,(function(){return"Error in depthwiseConv2d: input must be rank 4, but got rank "+c.rank+"."})),E(4===u.rank,(function(){return"Error in depthwiseConv2d: filter must be rank 4, but got rank "+u.rank+"."})),E(c.shape[3]===u.shape[2],(function(){return"Error in depthwiseConv2d: number of input channels ("+c.shape[3]+") must match the inChannels dimension in filter "+u.shape[2]+"."})),null==a&&(a=[1,1]),E(zr(n,a),(function(){return"Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+a+"'"})),null!=i&&E(S(r),(function(){return"Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+r+"."}));var f=Fr(c.shape,u.shape,n,a,r,i,!0),h=[c,u],p=Ot.runKernelFunc((function(t,e){var n=t.depthwiseConv2D(c,u,f);return e([c,u]),n}),{x:c,filter:u},(function(t,e){E(jr(a),(function(){return"Error in gradient of depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '"+a+"'"}));var n=e[0],r=e[1];return{x:function(){return Tu(n.shape,t,r,f)},filter:function(){return Du(n,t,r.shape,f)}}}),"DepthwiseConv2dNative",f,h);return l?p.as3D(p.shape[1],p.shape[2],p.shape[3]):p}}),Tu=Ze({depthwiseConv2dDerInput_:function(t,e,n,r){var o=e,a=!1;3===e.rank&&(a=!0,o=e.as4D(1,e.shape[0],e.shape[1],e.shape[2]));var i=Ot.runKernelFunc((function(t){return t.depthwiseConv2DDerInput(o,n,r)}),{dy4D:o});return a?i.as3D(i.shape[1],i.shape[2],i.shape[3]):i}}),Du=Ze({depthwiseConv2dDerFilter_:function(t,e,n,r){var o=t;3===t.rank&&(o=t.as4D(1,t.shape[0],t.shape[1],t.shape[2]));var a=e;return 3===a.rank&&(a=e.as4D(1,e.shape[0],e.shape[1],e.shape[2])),Ot.runKernelFunc((function(t){return t.depthwiseConv2DDerFilter(o,a,r)}),{x4D:o,dy4D:a})}}),Nu=Ze({separableConv2d_:function(t,e,n,r,o,a,i){void 0===a&&(a=[1,1]),void 0===i&&(i="NHWC");var s=je(t,"x","separableConv2d"),u=je(e,"depthwiseFilter","separableConv2d"),c=je(n,"pointwiseFilter","separableConv2d"),l=s,f=!1;if(3===s.rank&&(f=!0,l=s.as4D(1,s.shape[0],s.shape[1],s.shape[2])),"NCHW"===i)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");E(4===l.rank,(function(){return"Error in separableConv2d: input must be rank 4, but got rank "+l.rank+"."})),E(4===u.rank,(function(){return"Error in separableConv2d: depthwise filter must be rank 4, but got rank "+u.rank+"."})),E(4===c.rank,(function(){return"Error in separableConv2d: pointwise filter must be rank 4, but got rank "+u.rank+"."})),E(1===c.shape[0],(function(){return"Error in separableConv2d: the first dimension of pointwise filter must be 1, but got "+c.shape[0]+"."})),E(1===c.shape[1],(function(){return"Error in separableConv2d: the second dimension of pointwise filter must be 1, but got "+c.shape[1]+"."}));var h=u.shape[2],p=u.shape[3];E(c.shape[2]===h*p,(function(){return"Error in separableConv2d: the third dimension of pointwise filter must be "+h*p+", but got "+c.shape[2]+"."}));var d=Ou(l,u,r,o,i,a),v=Ru(d,c,1,"valid",i);return f?v.as3D(v.shape[1],v.shape[2],v.shape[3]):v}}),Fu=Ze({conv2dTranspose_:function(t,e,n,r,o,a){return Eu(n,je(t,"x","conv2dTranspose"),je(e,"filter","conv2dTranspose"),r,o,"NHWC",a)}}),Mu=Ze({conv3dTranspose_:function(t,e,n,r,o){return _u(n,je(t,"x","conv3dTranspose"),je(e,"filter","conv3dTranspose"),r,o)}}),Pu=Ze({matMul_:function(t,e,n,r){var o;void 0===n&&(n=!1),void 0===r&&(r=!1);var a=je(t,"a","matMul"),i=je(e,"b","matMul");o=_t(a,i),a=o[0],i=o[1];var s=n?a.shape[a.rank-2]:a.shape[a.rank-1],u=r?i.shape[i.rank-1]:i.shape[i.rank-2],c=n?a.shape[a.rank-1]:a.shape[a.rank-2],l=r?i.shape[i.rank-2]:i.shape[i.rank-1],f=a.shape.slice(0,-2),h=i.shape.slice(0,-2),p=R(f),d=R(h);E(a.rank>=2&&i.rank>=2&&a.rank===i.rank,(function(){return"Error in matMul: inputs must have the same rank of at least 2, got ranks "+a.rank+" and "+i.rank+"."})),E(I(f,h),(function(){return"Error in matMul: outer dimensions ("+f+") and ("+h+") of Tensors with shapes "+a.shape+" and "+i.shape+" must match."})),E(s===u,(function(){return"Error in matMul: inner shapes ("+s+") and ("+u+") of Tensors with shapes "+a.shape+" and "+i.shape+" and transposeA="+n+" and transposeB="+r+" must match."}));var v=a.shape.slice(0,-2).concat([c,l]),m=n?a.as3D(p,s,c):a.as3D(p,c,s),g=r?i.as3D(d,l,u):i.as3D(d,u,l),y={transposeA:n,transposeB:r};return Ot.runKernelFunc((function(t,e){var o=t.batchMatMul(m,g,n,r);return e([m,g]),o}),{a:m,b:g},(function(t,e){var o=e,a=o[0],i=o[1];return n||r?!n&&r?{a:function(){return t.matMul(i,!1,!1)},b:function(){return t.matMul(a,!0,!1)}}:n&&!r?{a:function(){return i.matMul(t,!1,!0)},b:function(){return a.matMul(t,!1,!1)}}:{a:function(){return i.matMul(t,!0,!0)},b:function(){return t.matMul(a,!0,!0)}}:{a:function(){return t.matMul(i,!1,!0)},b:function(){return a.matMul(t,!0,!1)}}}),"BatchMatMul",y).reshape(v)}}),Bu=Ze({dot_:function(t,e){var n=je(t,"t1","dot"),r=je(e,"t2","dot");E(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),(function(){return"Error in dot: inputs must all be rank 1 or 2, but got ranks "+n.rank+" and "+r.rank+"."}));var o=1===n.rank?n.size:n.shape[1],a=1===r.rank?r.size:r.shape[0];return E(o===a,(function(){return"Error in dot: inner dimensions of inputs must match, but got "+o+" and "+a+"."})),1===n.rank&&1===r.rank?n.as2D(1,-1).matMul(r.as2D(-1,1)).asScalar():1===n.rank&&2===r.rank?n.as2D(1,-1).matMul(r.as2D(r.shape[0],r.shape[1])).as1D():2===n.rank&&1===r.rank?n.matMul(r.as2D(-1,1)).as1D():n.matMul(r.as2D(r.shape[0],r.shape[1]))}}),Lu=Ze({outerProduct_:function(t,e){var n=je(t,"v1","outerProduct"),r=je(e,"v2","outerProduct");return E(1===n.rank&&1===r.rank,(function(){return"Error in outerProduct: inputs must be rank 1, but got ranks "+n.rank+" and "+r.rank+"."})),n.as2D(-1,1).matMul(r.as2D(1,-1))}}),Wu=Ze({reverse_:function(t,e){var n=je(t,"x","reverse");if(0===n.rank)return n.clone();var r=F(e,n.shape);return Ot.runKernelFunc((function(t){return t.reverse(n,r)}),{$x:n},(function(t){return{$x:function(){return t.reverse(r)}}})).reshapeAs(n)}}),Uu=Ze({reverse1d_:function(t){var e=je(t,"x","reverse");return E(1===e.rank,(function(){return"Error in reverse1D: x must be rank 1 but got rank "+e.rank+"."})),Wu(e,0)}}),ju=Ze({reverse2d_:function(t,e){var n=je(t,"x","reverse");return E(2===n.rank,(function(){return"Error in reverse2D: x must be rank 2 but got rank "+n.rank+"."})),Wu(n,e)}}),zu=Ze({reverse3d_:function(t,e){var n=je(t,"x","reverse");return E(3===n.rank,(function(){return"Error in reverse3D: x must be rank 3 but got rank "+n.rank+"."})),Wu(n,e)}}),Vu=Ze({reverse4d_:function(t,e){var n=je(t,"x","reverse");return E(4===n.rank,(function(){return"Error in reverse4D: x must be rank 4 but got rank "+n.rank+"."})),Wu(n,e)}});function Gu(t,e,n,r,o,a){var i=je(t,"x","maxPool"),s=i,u=!1;3===i.rank&&(u=!0,s=i.as4D(1,i.shape[0],i.shape[1],i.shape[2])),null==r&&(r=[1,1]),E(4===s.rank,(function(){return"Error in maxPool: input must be rank 4 but got rank "+s.rank+"."})),E(zr(n,r),(function(){return"Error in maxPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+r+"'"})),null!=a&&E(S(o),(function(){return"Error in maxPool: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+o+"."}));var c=Dr(s.shape,e,n,r,o,a);if(1===c.filterWidth&&1===c.filterHeight&&I(c.inShape,c.outShape))return i.clone();var l=[s],f=Ot.runKernelFunc((function(t,e){var n=t.maxPool(s,c);return e([s,n]),n}),{x:s},(function(t,a){var i=a[0],s=a[1];return{x:function(){return function(t,e,n,r,o,a,i,s){var u=je(t,"dy","maxPoolBackprop"),c=je(e,"input","maxPoolBackprop"),l=je(n,"output","maxPoolBackprop");E(c.rank===u.rank,(function(){return"Rank of input ("+c.rank+") does not match rank of dy ("+u.rank+")"})),null==a&&(a=[1,1]),E(zr(o,a),(function(){return"Error in maxPoolBackProp: Either strides or dilations must be 1. Got strides "+o+" and dilations '"+a+"'"})),E(4===u.rank,(function(){return"Error in maxPoolBackprop: dy must be rank 4 but got rank "+u.rank+"."})),E(4===c.rank,(function(){return"Error in maxPoolBackprop: input must be rank 4 but got rank "+c.rank+"."}));var f=Dr(c.shape,r,o,a,i,s);return Ot.runKernelFunc((function(t){return t.maxPoolBackprop(u,c,l,f)}),{$dy:u,$input:c})}(t,i,s,e,n,r,o)}}}),"MaxPool",c,l);return u?f.as3D(f.shape[1],f.shape[2],f.shape[3]):f}function Hu(t,e,n,r,o,a){var i=je(t,"x","avgPool","float32");null==r&&(r=[1,1]),E(zr(n,r),(function(){return"Error in avgPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+r+"'"}));var s=i,u=!1;3===i.rank&&(u=!0,s=i.as4D(1,i.shape[0],i.shape[1],i.shape[2])),E(4===s.rank,(function(){return"Error in avgPool: x must be rank 4 but got rank "+s.rank+"."})),null!=a&&E(S(o),(function(){return"Error in avgPool: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+o+"."}));var c=Dr(s.shape,e,n,r,o,a);if(1===c.filterWidth&&1===c.filterHeight&&I(c.inShape,c.outShape))return i.clone();var l=Ot.runKernelFunc((function(t){return t.avgPool(s,c)}),{x:s},(function(t){return{x:function(){return function(t,e,n,r,o,a){var i=je(t,"dy","avgPoolBackprop"),s=je(e,"input","avgPoolBackprop");E(s.rank===i.rank,(function(){return"Rank of input ("+s.rank+") does not match rank of dy ("+i.rank+")"})),null==o&&(o=[1,1]),E(zr(r,o),(function(){return"Error in avgPoolBackprop: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+o+"'"}));var u=s,c=i,l=!1;3===s.rank&&(l=!0,u=s.as4D(1,s.shape[0],s.shape[1],s.shape[2]),c=i.as4D(1,i.shape[0],i.shape[1],i.shape[2])),E(4===c.rank,(function(){return"Error in avgPoolBackprop: dy must be rank 4 but got rank "+c.rank+"."})),E(4===u.rank,(function(){return"Error in avgPoolBackprop: input must be rank 4 but got rank "+u.rank+"."}));var f=Dr(u.shape,n,r,o,a),h=Ot.runKernelFunc((function(t){return t.avgPoolBackprop(c,u,f)}),{dy4D:c,input4D:u});return l?h.as3D(h.shape[1],h.shape[2],h.shape[3]):h}(t,s,e,n,r,o)}}}),"AvgPool",c);return l=l.cast(i.dtype),u?l.as3D(l.shape[1],l.shape[2],l.shape[3]):l}var qu=Ze({maxPool_:function(t,e,n,r,o){return Gu(t,e,n,1,r,o)}}),Ku=Ze({avgPool_:function(t,e,n,r,o){return Hu(t,e,n,1,r,o)}}),Xu=Ze({pool_:function(t,e,n,r,o,a){null==o&&(o=[1,1]),null==a&&(a=1),0===r&&(r="valid");var i=je(t,"x","maxPool"),s=i,u=!1;3===i.rank&&(u=!0,s=i.as4D(1,i.shape[0],i.shape[1],i.shape[2])),E(zr(a,o),(function(){return"Error in pool: Either strides or dilations must be 1. Got strides "+a+" and dilations '"+o+"'"}));var c,l=Dr(s.shape,e,a,o,r),f=[l.dilationHeight,l.dilationWidth];c="same"===r?function(t,e){var n=t.map((function(t,n){return t+(t-1)*(e[n]-1)})).map((function(t){return t-1})),r=n.map((function(t){return Math.floor(t/2)})),o=n.map((function(t,e){return t-r[e]}));return n.map((function(t,e){return[r[e],o[e]]}))}([l.filterHeight,l.filterWidth],f):[[0,0],[0,0]];var h=1===f[0]&&1===f[1],p=function(t,e,n){var r=n.map((function(t){return t[0]})),o=n.map((function(t){return t[1]})),a=t.concat(r,o),i=e.map((function(t,e){return(t-a[e]%t)%t})),s=o.map((function(t,e){return t+i[e]}));return[e.map((function(t,e){return[r[e],s[e]]})),e.map((function(t,e){return[0,i[e]]}))]}([l.inHeight,l.inWidth],f,c),d=p[0],v=p[1],m=h?r:"valid",g=h?s:nr(s,f,d),y=("avg"===n?function(){return Hu(g,e,a,1,m)}:function(){return Gu(g,e,a,1,m)})(),b=h?y:Pn(y,f,v);return u?b.as3D(b.shape[1],b.shape[2],b.shape[3]):b}}),$u=Ze({maxPool3d_:function(t,e,n,r,o,a,i){void 0===a&&(a="NDHWC");var s=je(t,"x","maxPool3d"),u=s,c=!1;4===s.rank&&(c=!0,u=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3])),null==i&&(i=[1,1,1]),E(5===u.rank,(function(){return"Error in maxPool3d: x must be rank 5 but got rank "+u.rank+"."})),E("NDHWC"===a,(function(){return"Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of "+a})),E(zr(n,i),(function(){return"Error in maxPool3d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+i+"'"})),null!=o&&E(S(r),(function(){return"Error in maxPool3d: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+r+"."}));var l=Nr(u.shape,e,n,i,r,o,a),f=Ot.runKernelFunc((function(t,e){var n=t.maxPool3d(u,l);return e([u,n]),n}),{x:u},(function(t,a){var s=a[0],u=a[1];return{x:function(){return function(t,e,n,r,o,a,i,s){var u=je(t,"dy","maxPool3dBackprop"),c=je(e,"input","maxPool3dBackprop"),l=je(n,"output","maxPool3dBackprop"),f=u,h=c,p=l,d=!1;4===c.rank&&(d=!0,f=u.as5D(1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]),h=c.as5D(1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]),p=l.as5D(1,l.shape[0],l.shape[1],l.shape[2],l.shape[3])),E(5===f.rank,(function(){return"Error in maxPool3dBackprop: dy must be rank 5 but got rank "+f.rank+"."})),E(5===h.rank,(function(){return"Error in maxPool3dBackprop: input must be rank 5 but got rank "+h.rank+"."})),E(5===p.rank,(function(){return"Error in maxPool3dBackprop: output must be rank 5 but got rank "+p.rank+"."})),null==a&&(a=[1,1,1]),E(zr(o,a),(function(){return"Error in maxPool3dBackprop: Either strides or dilations must be 1. Got strides "+o+" and dilations '"+a+"'"})),null!=s&&E(S(i),(function(){return"Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode "+s+" but got pad "+i+"."}));var v=Nr(h.shape,r,o,a,i,s),m=Ot.runKernelFunc((function(t){return t.maxPool3dBackprop(f,h,p,v)}),{dy5D:f,input5D:h});return d?m.as4D(m.shape[1],m.shape[2],m.shape[3],m.shape[4]):m}(t,s,u,e,n,i,r,o)}}}));return c?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f}}),Yu=Ze({avgPool3d_:function(t,e,n,r,o,a,i){void 0===a&&(a="NDHWC");var s=je(t,"x","avgPool3d","float32"),u=s,c=!1;4===s.rank&&(c=!0,u=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3])),null==i&&(i=[1,1,1]),E(5===u.rank,(function(){return"Error in avgPool3d: x must be rank 5 but got rank "+u.rank+"."})),E("NDHWC"===a,(function(){return"Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of "+a})),E(zr(n,i),(function(){return"Error in avgPool3d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+i+"'"})),null!=o&&E(S(r),(function(){return"Error in avgPool3d: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+r+"."}));var l=Nr(u.shape,e,n,i,r,o,a),f=Ot.runKernelFunc((function(t){return t.avgPool3d(u,l)}),{x:u},(function(t){return{x:function(){return function(t,e,n,r,o,a,i){var s=je(t,"dy","avgPool3dBackprop"),u=je(e,"input","avgPool3dBackprop"),c=s,l=u,f=!1;4===u.rank&&(f=!0,c=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]),l=u.as5D(1,u.shape[0],u.shape[1],u.shape[2],u.shape[3])),E(5===c.rank,(function(){return"Error in avgPool3dBackprop: dy must be rank 5 but got rank "+c.rank+"."})),E(5===l.rank,(function(){return"Error in avgPool3dBackprop: input must be rank 5 but got rank "+l.rank+"."})),null==o&&(o=[1,1,1]),E(zr(r,o),(function(){return"Error in avgPool3dBackprop: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+o+"'"})),null!=i&&E(S(a),(function(){return"Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+a+"."}));var h=Nr(l.shape,n,r,o,a,i),p=Ot.runKernelFunc((function(t){return t.avgPool3dBackprop(c,l,h)}),{dy5D:c,input5D:l});return f?p.as4D(p.shape[1],p.shape[2],p.shape[3],p.shape[4]):p}(t,u,e,n,i,r,o)}}}));return f=f.cast(u.dtype),c?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f}}),Ju=Ze({slice_:function(t,e,n){var r,o,a=je(t,"x","slice");if(0===a.rank)throw new Error("Slicing scalar is not possible");(r="number"==typeof e?[e].concat(new Array(a.rank-1).fill(0)):e.length<a.rank?e.concat(new Array(a.rank-e.length).fill(0)):e.slice()).forEach((function(t){E(-1!==t,(function(){return"slice() does not support negative begin indexing."}))})),o=(o=null==n?new Array(a.rank).fill(-1):"number"==typeof n?[n].concat(new Array(a.rank-1).fill(-1)):n.length<a.rank?n.concat(new Array(a.rank-n.length).fill(-1)):n).map((function(t,e){return t>=0?t:(E(-1===t,(function(){return"Negative size values should be exactly -1 but got "+t+" for the slice() size at index "+e+"."})),a.shape[e]-r[e])})),mr(a,r,o);var i=a.shape,s={begin:r,size:o};return Ot.runKernelFunc((function(t){return t.slice(a,r,o)}),{x:a},(function(t){for(var e=[],n=0;n<t.rank;n++)e.push([r[n],i[n]-r[n]-o[n]]);return{x:function(){return t.pad(e)}}}),"Slice",s)}}),Qu=Ze({slice1d_:function(t,e,n){var r=je(t,"x","slice1d");return E(1===r.rank,(function(){return"slice1d expects a rank-1 tensor, but got a rank-"+r.rank+" tensor"})),Ju(r,[e],[n])}}),Zu=Ze({slice2d_:function(t,e,n){var r=je(t,"x","slice2d");return E(2===r.rank,(function(){return"slice2d expects a rank-2 tensor, but got a rank-"+r.rank+" tensor"})),Ju(r,e,n)}}),tc=Ze({slice3d_:function(t,e,n){var r=je(t,"x","slice3d");return E(3===r.rank,(function(){return"slice3d expects a rank-3 tensor, but got a rank-"+r.rank+" tensor"})),Ju(r,e,n)}}),ec=Ze({slice4d_:function(t,e,n){var r=je(t,"x","slice4d");return E(4===r.rank,(function(){return"slice4d expects a rank-4 tensor, but got a rank-"+r.rank+" tensor"})),Ju(r,e,n)}});function nc(t,e,n,r,o){return e.rank<n.rank&&(e=e.reshape(qe(e.shape,r))),t.rank<n.rank&&(t=t.reshape(qe(t.shape,r))),{x:function(){var r=t.mul(n.equal(e).cast(t.dtype));return null==o?r:r.transpose(o)}}}var rc=Ze({all_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=je(t,"x","all","bool"),o=F(e,r.shape),a=o,i=Xe(a,r.rank);null!=i&&(r=r.transpose(i),a=Ye(a.length,r.rank));var s=Ot.runKernelFunc((function(t){return t.all(r,a)}),{$x:r});if(n){var u=qe(s.shape,o);return s.reshape(u)}return s}}),oc=Ze({any_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=je(t,"x","any","bool"),o=F(e,r.shape),a=o,i=Xe(a,r.rank);null!=i&&(r=r.transpose(i),a=Ye(a.length,r.rank));var s=Ot.runKernelFunc((function(t){return t.any(r,a)}),{$x:r});if(n){var u=qe(s.shape,o);return s.reshape(u)}return s}}),ac=Ze({argMax_:function(t,e){void 0===e&&(e=0);var n=je(t,"x","argMax");null==e&&(e=0);var r=F(e,n.shape),o=Xe(r,n.rank);null!=o&&(n=n.transpose(o),r=Ye(r.length,n.rank));var a={axis:r[0]},i=[n];return Ot.runKernelFunc((function(t,e){var o=t.argMax(n,r[0]);return e([n]),o}),{x:n},(function(t,e){var n=e[0];return{x:function(){return mn(n)}}}),"ArgMax",a,i)}}),ic=Ze({argMin_:function(t,e){void 0===e&&(e=0);var n=je(t,"x","argMin");null==e&&(e=0);var r=F(e,n.shape),o=Xe(r,n.rank);return null!=o&&(n=n.transpose(o),r=Ye(r.length,n.rank)),Ot.runKernelFunc((function(t,e){var o=t.argMin(n,r[0]);return e([n]),o}),{$x:n},(function(t,e){var n=e[0];return{$x:function(){return mn(n)}}}))}}),sc=Ze({logSumExp_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=je(t,"x","logSumExp"),o=F(e,r.shape),a=r.max(o,!0),i=r.sub(a).exp().sum(o).log(),s=a.reshape(i.shape).add(i);if(n){var u=qe(s.shape,o);return s.reshape(u)}return s}}),uc=Ze({max_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=je(t,"x","max"),o=r,a=F(e,r.shape),i=a,s=Xe(i,r.rank);null!=s&&(r=r.transpose(s),i=Ye(i.length,r.rank));var u=[r],c=Ot.runKernelFunc((function(t,e){var n=t.max(r,i);return e([o,n]),n}),{x:r},(function(t,e){return nc(t,e[1],e[0],a,s)}),"Max",{axes:i},u,[!0]);if(n){var l=qe(c.shape,a);c=c.reshape(l)}return c}}),cc=Ze({mean_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=je(t,"x","mean"),o=F(e,r.shape),a=R(He(r.shape,o)[1]);return Cr((function(t){var r=an(a);return{value:(r.dtype===t.dtype?t:t.cast(r.dtype)).div(r).sum(e,n),gradFunc:function(e){var n=t.shape.slice();return o.forEach((function(t){n[t]=1})),e.reshape(n).mul(fn(t.shape,"float32")).div(a)}}}))(r)}}),lc=Ze({min_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=je(t,"x","min"),o=r,a=F(e,r.shape),i=a,s=Xe(i,r.rank);null!=s&&(r=r.transpose(s),i=Ye(i.length,r.rank));var u=[r],c=Ot.runKernelFunc((function(t,e){var n=t.min(r,i);return e([o,n]),n}),{x:r},(function(t,e){return nc(t,e[1],e[0],a,s)}),"Min",{axes:i},u,[!0]);if(n){var l=qe(c.shape,a);c=c.reshape(l)}return c}}),fc=Ze({moments_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=F(e,(t=je(t,"x","moments")).shape),o=t.mean(r,n),a=o.shape;n||(a=qe(o.shape,r));var i=t.toFloat().sub(o.reshape(a)).square();return{mean:o,variance:i.mean(r,n)}}}),hc=Ze({sum_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=je(t,"x","sum");"bool"===r.dtype&&(r=r.toInt());var o=F(e,r.shape);return Cr((function(t){var e=Xe(o,t.rank),r=o,a=t;null!=e&&(a=t.transpose(e),r=Ye(r.length,t.rank));var i=Ot.runKernelFunc((function(t){return t.sum(a,r)}),{permutedX:a});if(n){var s=qe(i.shape,o);i=i.reshape(s)}return{value:i,gradFunc:function(e){var n=t.shape.slice();return o.forEach((function(t){n[t]=1})),e.reshape(n).mul(fn(t.shape,"float32"))}}}))(r)}}),pc=Ze({prod_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=je(t,"x","prod");"bool"===r.dtype&&(r=r.toInt());var o=F(e,r.shape),a=Xe(o,r.rank),i=o,s=r;null!=a&&(s=r.transpose(a),i=Ye(i.length,r.rank));var u=Ot.runKernelFunc((function(t){return t.prod(s,i)}),{permutedX:s});if(n){var c=qe(u.shape,o);u=u.reshape(c)}return u}}),dc=Ze({elu_:function(t){var e=je(t,"x","elu");return Ot.runKernelFunc((function(t,n){var r=t.elu(e);return n([r]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return Ot.runKernelFunc((function(e){return e.eluDer(t,n)}),{dy:t,y:n})}}}))}}),vc=Ze({leakyRelu_:function(t,e){void 0===e&&(e=.2);var n=je(t,"x","leakyRelu");return qs(an(e).mul(n),n)}}),mc=Ze({prelu_:function(t,e){var n=je(t,"x","prelu"),r=je(e,"alpha","prelu");return Ot.runKernelFunc((function(t,e){var o=t.prelu(n,r);return e([n,r]),o}),{x:n,alpha:r},(function(t,e){var n=e[0],r=e[1],o=n.greater(0);return{x:function(){return Ps(o,t,t.mul(r))},alpha:function(){var e=Ps(o,mn(t),t.mul(n)),a=Or(r.shape,t.shape);return a.length>0&&(e=e.sum(a)),e.reshape(r.shape)}}}),"Prelu")}}),gc=Ze({relu_:function(t){var e=je(t,"x","relu");return"bool"===e.dtype?e.toInt():Ot.runKernelFunc((function(t,n){var r=t.relu(e);return n([e]),r}),{x:e},(function(t,e){var n=e[0];return{x:function(){return t.mulStrict(n.step().toFloat())}}}),"Relu")}}),yc=Ze({relu6_:function(t){var e=je(t,"x","relu6");return"bool"===e.dtype?e.toInt():Ot.runKernelFunc((function(t,n){var r=t.relu6(e);return n([e]),r}),{x:e},(function(t,e){var n=e[0],r=n.lessEqual(6).mul(n.step());return{x:function(){return t.mulStrict(r.toFloat())}}}),"Relu6")}}),bc=Ze({selu_:function(t){var e=je(t,"x","selu");return Ot.runKernelFunc((function(t,n){var r=t.selu(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){var e=n.greater(an(0)),r=an(vi),o=an(mi),a=t.mul(o),i=t.mul(r).mul(n.toFloat().exp());return Ps(e,a,i)}}}))}}),xc=Ze({transpose_:function(t,e){var n=je(t,"x","transpose");if(null==e&&(e=n.shape.map((function(t,e){return e})).reverse()),E(n.rank===e.length,(function(){return"Error in transpose: rank of input "+n.rank+" must match length of perm "+e+"."})),e.forEach((function(t){E(t>=0&&t<n.rank,(function(){return"All entries in 'perm' must be between 0 and "+(n.rank-1)+" but got "+e}))})),n.rank<=1)return n.clone();var r={perm:e};return Ot.runKernelFunc((function(t){return t.transpose(n,e)}),{x:n},(function(t){var n=$e(e);return{x:function(){return t.transpose(n)}}}),"Transpose",r)}}),wc=Ze({localResponseNormalization_:function(t,e,n,r,o){void 0===e&&(e=5),void 0===n&&(n=1),void 0===r&&(r=1),void 0===o&&(o=.5);var a=je(t,"x","localResponseNormalization");E(4===a.rank||3===a.rank,(function(){return"Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank "+a.rank+"."})),E(S(e),(function(){return"Error in localResponseNormalization: depthRadius must be an integer but got depthRadius "+e+"."}));var i=a,s=!1;3===a.rank&&(s=!0,i=a.as4D(1,a.shape[0],a.shape[1],a.shape[2]));var u=Ot.runKernelFunc((function(t,a){var s=t.localResponseNormalization4D(i,e,n,r,o);return a([i,s]),s}),{x4D:i},(function(t,a){var i=a[0],s=a[1];return{x4D:function(){return Ot.runKernelFunc((function(a){return a.LRNGrad(t,i,s,e,n,r,o)}),{})}}}));return s?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u}}),Ec=Ze({norm_:function(t,e,n,r){void 0===e&&(e="euclidean"),void 0===n&&(n=null),void 0===r&&(r=!1);var o=function t(e,n,r){if(void 0===r&&(r=null),0===e.rank)return e.abs();if(1!==e.rank&&null===r)return t(e.reshape([-1]),n,r);if(1===e.rank||"number"==typeof r||Array.isArray(r)&&1===r.length){if(1===n)return e.abs().sum(r);if(n===1/0)return e.abs().max(r);if(n===-1/0)return e.abs().min(r);if("euclidean"===n||2===n)return e.abs().pow(an(2,"int32")).sum(r).sqrt();throw new Error("Error in norm: invalid ord value: "+n)}if(Array.isArray(r)&&2===r.length){if(1===n)return e.abs().sum(r[0]).max(r[1]-1);if(n===1/0)return e.abs().sum(r[1]).max(r[0]);if(n===-1/0)return e.abs().sum(r[1]).min(r[0]);if("fro"===n||"euclidean"===n)return e.square().sum(r).sqrt();throw new Error("Error in norm: invalid ord value: "+n)}throw new Error("Error in norm: invalid axis: "+r)}(t=je(t,"x","norm"),e,n),a=o.shape;if(r){var i=F(n,t.shape);a=qe(o.shape,i)}return o.reshape(a)}}),Cc=Ze({basicLSTMCell_:function(t,e,n,r,o,a){var i=je(t,"forgetBias","basicLSTMCell"),s=je(e,"lstmKernel","basicLSTMCell"),u=je(n,"lstmBias","basicLSTMCell"),c=je(r,"data","basicLSTMCell"),l=je(o,"c","basicLSTMCell"),f=je(a,"h","basicLSTMCell"),h=c.concat(f,1).matMul(s).add(u),p=h.shape[0],d=h.shape[1]/4,v=[p,d],m=h.slice([0,0],v),g=h.slice([0,d],v),y=h.slice([0,2*d],v),b=h.slice([0,3*d],v),x=m.sigmoid().mulStrict(g.tanh()).addStrict(l.mulStrict(i.add(y).sigmoid())),w=x.tanh().mulStrict(b.sigmoid());return[x,w]}}),_c=Ze({multiRNNCell_:function(t,e,n,r){for(var o=je(e,"data","multiRNNCell"),a=ze(n,"c","multiRNNCell"),i=ze(r,"h","multiRNNCell"),s=o,u=[],c=0;c<t.length;c++){var l=t[c](s,a[c],i[c]);u.push(l[0]),u.push(l[1]),s=l[1]}var f=[],h=[];for(c=0;c<u.length;c+=2)f.push(u[c]),h.push(u[c+1]);return[f,h]}}),kc=Ze({movingAverage_:function(t,e,n,r,o){void 0===o&&(o=!0);var a=je(t,"v","movingAverage"),i=je(e,"x","movingAverage"),s=je(n,"decay","movingAverage");kt(a,i),E(I(a.shape,i.shape),(function(){return"Shape mismatch in v and x"}));var u=an(1),c=u.sub(s),l=i.sub(a).mul(c);if(o){E(null!=r,(function(){return"When using zeroDebias: true, step is required."}));var f=je(r,"step","movingAverage");l=l.div(u.sub(tu(s,f)))}return a.add(l)}}),Rc=Ze({stridedSlice_:function(t,e,n,r,o,a,i,s,u){if(void 0===o&&(o=0),void 0===a&&(a=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===u&&(u=0),null==r&&(r=new Array(e.length)),0!==i)throw new Error("ellipsis mask is not yet supported");var c=je(t,"x","stridedSlice"),l=gr(s),f=c.shape.slice();l.forEach((function(t){e[t]=0,n[t]=1,f.splice(t,0,1)})),c=c.reshape(f);for(var h=0;h<c.rank;h++)e[h]=br(o,e,r,c.shape,h),n[h]=xr(a,n,r,c.shape,h),r[h]=r[h]||1;var p=gr(u);p.forEach((function(t){n[t]=e[t]+1,r[t]=1}));var d=yr(e,n,r),v=d.filter((function(t,e){return-1===p.indexOf(e)}));return r.every((function(t){return 1===t}))?Ju(c,e,d).reshape(v):Ot.runKernelFunc((function(t){return t.stridedSlice(c,e,n,r)}),{$x:c}).reshape(v)}}),Ic=Ze({topk_:function(t,e,n){void 0===e&&(e=1),void 0===n&&(n=!0);var r=je(t,"x","topk");if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");var o=r.shape[r.shape.length-1];if(e>o)throw new Error("'k' passed to topk() must be <= the last dimension ("+o+") but got "+e);var a=Ot.runKernelFunc((function(t){return t.topk(r,e,n)}),{$x:r});return{values:a[0],indices:a[1]}}}),Sc=Ze({scatterND_:function(t,e,n){var r=je(t,"indices","scatterND","int32"),o=je(e,"updates","scatterND");return function(t,e,n){if(e.rank<1)throw new Error("tf.scatterND() expects the indices to be rank 1 or higher, but the rank was "+e.rank+".");if(t.rank<1)throw new Error("tf.scatterND() expects the updates to be rank 1 or higher, but the rank was "+t.rank+".");if("int32"!==e.dtype)throw new Error("The dtype of 'indices' should be int32, but got dtype: "+e.dtype);if(n.length<1)throw new Error("Output rank must be greater or equal to 1, but got shape: "+n);if(0===n.length){if(0===e.size)throw new Error("Indices specified for empty output. indices shape: "+e.shape);if(0===t.size)throw new Error("Updates specified for empty output. updates shape: "+t.shape)}!function(t,e,n){var r=e.rank>1?e.shape[e.rank-1]:1,o=e.rank>1?e.rank-1:1,a="Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: "+n.shape+", indices.shape: "+e.shape+", shape: "+t+", sliceDim: "+r+", and batchDim: "+o+".";if(n.rank<o)throw new Error(a+" update.rank < "+o+". ");if(t.length<r+(n.rank-o))throw new Error(a+" Output shape length < "+(r+(n.rank-o)));if(n.rank!==o+t.length-r)throw new Error(a+" update.rank != "+(o+t.length-r));for(var i=0;i<o;++i)if(n.shape[i]!==e.shape[i])throw new Error(a+" updates.shape["+i+"] ("+n.shape[i]+") != indices.shape["+i+"] ("+e.shape[i]+").");for(i=0;i<n.rank-o;++i)if(n.shape[i+o]!==t[i+r])throw new Error(a+" updates.shape["+(i+o)+"] ("+n.shape[i+o]+") != shape["+(i+o)+"] ("+t[i+o]+")")}(n,e,t)}(o,r,n),Ot.runKernelFunc((function(t){return t.scatterND(r,o,n)}),{$indices:r,$updates:o})}}),Ac=Ze({fft_:function(t){E("complex64"===t.dtype,(function(){return"The dtype for tf.spectral.fft() must be complex64 but got "+t.dtype+"."}));var e=t.shape[t.shape.length-1],n=t.size/e,r=t.as2D(n,e);return Ot.runKernelFunc((function(t){return t.fft(r)}),{input:t}).reshape(t.shape)}}),Oc=Ze({ifft_:function(t){E("complex64"===t.dtype,(function(){return"The dtype for tf.spectral.ifft() must be complex64 but got "+t.dtype+"."}));var e=t.shape[t.shape.length-1],n=t.size/e,r=t.as2D(n,e);return Ot.runKernelFunc((function(t){return t.ifft(r)}),{input:t}).reshape(t.shape)}}),Tc=Ze({rfft_:function(t,e){E("float32"===t.dtype,(function(){return"The dtype for rfft() must be real value but got "+t.dtype}));var n,r=t.shape[t.shape.length-1],o=t.size/r;if(null!=e&&e<r){var a=t.shape.map((function(t){return 0})),i=t.shape.map((function(t){return t}));i[t.shape.length-1]=e,n=t.slice(a,i),r=e}else if(null!=e&&e>r){var s=t.shape.map((function(t){return t}));s[t.shape.length-1]=e-r,n=t.concat(hn(s),t.shape.length-1),r=e}else n=t;var u=n.zerosLike(),c=tn(n,u).as2D(o,r),l=Ac(c),f=Math.floor(r/2)+1,h=en(l),p=nn(l),d=h.split([f,r-f],h.shape.length-1),v=p.split([f,r-f],p.shape.length-1),m=n.shape.slice();return m[n.shape.length-1]=f,tn(d[0],v[0]).reshape(m)}}),Dc=Ze({irfft_:function(t){var e=t.shape[t.shape.length-1],n=t.size/e;if(e<=2){var r=t.as2D(n,e),o=Oc(r);return en(o)}var a=[n,2*(e-1)],i=en(t).as2D(n,e),s=nn(t).as2D(n,e),u=i.slice([0,1],[n,e-2]).reverse(1),c=s.slice([0,1],[n,e-2]).reverse(1).mul(an(-1)),l=i.concat(u,1),f=s.concat(c,1);return r=tn(l,f).as2D(a[0],a[1]),o=Oc(r),en(o)}}),Nc=Object.freeze({fft:Ac,ifft:Oc,rfft:Tc,irfft:Dc}),Fc=Ze({sparseToDense_:function(t,e,n,r){void 0===r&&(r=0);var o=je(t,"sparseIndices","sparseToDense","int32"),a=je(e,"sparseValues","sparseToDense"),i=je(r,"defaultValue","sparseToDense",a.dtype);return function(t,e,n,r){if("int32"!==t.dtype)throw new Error("tf.sparseToDense() expects the indices to be int32 type, but the dtype was "+t.dtype+".");if(t.rank>2)throw new Error("sparseIndices should be a scalar, vector, or matrix, but got shape "+t.shape+".");var o=t.rank>0?t.shape[0]:1,a=t.rank>1?t.shape[1]:1;if(n.length!==a)throw new Error("outputShape has incorrect number of elements:, "+n.length+", should be: "+a+".");var i=e.size;if(0!==e.rank&&(1!==e.rank||i!==o))throw new Error("sparseValues has incorrect shape "+e.shape+", should be [] or ["+o+"]");if(e.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(o,a,n,i),Ot.runKernelFunc((function(t){return t.sparseToDense(o,a,n,i)}),{$sparseIndices:o,$sparseValues:a,$defaultValue:i})}}),Mc=Ze({gatherND_:function(t,e){var n=je(e,"indices","gatherND","int32"),r=je(t,"x","gatherND");return Ot.runKernelFunc((function(t){return t.gatherND(r,n)}),{$x:r,$indices:n})}}),Pc=Ze({diag_:function(t){var e=je(t,"x","diag").flatten(),n=t.shape.concat(t.shape);return Ot.runKernelFunc((function(t){return t.diag(e)}),{$x:e}).reshape(n)}}),Bc=Ze({dropout_:function(t,e,n,r){var o=je(t,"x","dropout");if(E("float32"===o.dtype,(function(){return"x has to be a floating point tensor since it's going to be scaled, but got a "+o.dtype+" tensor instead."})),E(e>=0&&e<1,(function(){return"rate must be a float in the range [0, 1), but got "+e+"."})),0===e)return t instanceof dt?o.clone():o;var a=function(t,e){if(null==e)return t.shape.slice();if(I(t.shape,e))return e;if(t.shape.length===e.length){for(var n=[],r=0;r<t.shape.length;r++)null==e[r]&&null!=t.shape[r]?n.push(t.shape[r]):n.push(e[r]);return n}return e}(o,n),i=1-e,s=tr(a,0,1,"float32",r).add(i).floor().div(i);return o.mul(s)}});function Lc(t,e,n){for(var r=1-t%2,o=new Float32Array(t),a=0;a<t;++a){var i=2*Math.PI*a/(t+r-1);o[a]=e-n*Math.cos(i)}return sn(o,"float32")}var Wc,Uc=Ze({hannWindow_:function(t){return Lc(t,.5,.5)}}),jc=Ze({hammingWindow_:function(t){return Lc(t,.54,.46)}}),zc=Ze({frame_:function(t,e,n,r,o){void 0===r&&(r=!1),void 0===o&&(o=0);for(var a=0,i=[];a+e<=t.size;)i.push(Ju(t,a,e)),a+=n;if(r)for(;a<t.size;){var s=a+e-t.size,u=gn([Ju(t,a,e-s),pn([s],o)]);i.push(u),a+=n}return 0===i.length?un([],[0,e]):gn(i).as2D(i.length,e)}}),Vc=Ze({stft_:function(t,e,n,r,o){var a;void 0===o&&(o=Uc),null==r&&(a=e,r=Math.floor(Math.pow(2,Math.ceil(Math.log(a)/Math.log(2)))));for(var i=zc(t,e,n),s=Qs(i,o(e)),u=[],c=0;c<i.shape[0];c++)u.push(Tc(s.slice([c,0],[1,e]),r));return gn(u)}}),Gc=Object.freeze({hannWindow:Uc,hammingWindow:jc,frame:zc,stft:Vc});!function(t){t[t.NONE=0]="NONE",t[t.MEAN=1]="MEAN",t[t.SUM=2]="SUM",t[t.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(Wc||(Wc={}));var Hc=Ze({absoluteDifference_:function(t,e,n,r){void 0===r&&(r=Wc.SUM_BY_NONZERO_WEIGHTS);var o=je(t,"labels","absoluteDifference"),a=je(e,"predictions","absoluteDifference"),i=null;null!=n&&(i=je(n,"weights","absoluteDifference")),C(o.shape,a.shape,"Error in absoluteDifference: ");var s=o.sub(a).abs();return qc(s,i,r)}}),qc=Ze({computeWeightedLoss_:function(t,e,n){void 0===n&&(n=Wc.SUM_BY_NONZERO_WEIGHTS);var r=je(t,"losses","computeWeightedLoss"),o=null;null!=e&&(o=je(e,"weights","computeWeightedLoss"));var a=null==o?r:r.mul(o);if(n===Wc.NONE)return a;if(n===Wc.SUM)return a.sum();if(n===Wc.MEAN){if(null==o)return a.mean();var i=r.size/o.size,s=a.sum().div(o.sum());return i>1?s.div(an(i)):s}if(n===Wc.SUM_BY_NONZERO_WEIGHTS){if(null==o)return a.sum().div(an(r.size));var u=o.mul(fn(r.shape)).notEqual(an(0)).sum().toFloat();return a.sum().div(u)}throw Error("Unknown reduction: "+n)}}),Kc=Ze({cosineDistance_:function(t,e,n,r,o){void 0===o&&(o=Wc.SUM_BY_NONZERO_WEIGHTS);var a=je(t,"labels","cosineDistance"),i=je(e,"predictions","cosineDistance"),s=null;null!=r&&(s=je(r,"weights","cosineDistance")),C(a.shape,i.shape,"Error in cosineDistance: ");var u=an(1).sub(a.mul(i).sum(n,!0));return qc(u,s,o)}}),Xc=Ze({hingeLoss_:function(t,e,n,r){void 0===r&&(r=Wc.SUM_BY_NONZERO_WEIGHTS);var o=je(t,"labels","hingeLoss"),a=je(e,"predictions","hingeLoss"),i=null;null!=n&&(i=je(n,"weights","hingeLoss")),C(o.shape,a.shape,"Error in hingeLoss: ");var s=an(1);o=an(2).mul(o).sub(s);var u=s.sub(o.mul(a)).relu();return qc(u,i,r)}}),$c=Ze({huberLoss_:function(t,e,n,r,o){void 0===r&&(r=1),void 0===o&&(o=Wc.SUM_BY_NONZERO_WEIGHTS);var a=je(t,"labels","huberLoss"),i=je(e,"predictions","huberLoss"),s=null;null!=n&&(s=je(n,"weights","huberLoss")),C(a.shape,i.shape,"Error in huberLoss: ");var u=an(r),c=i.sub(a).abs(),l=Xs(c,u),f=c.sub(l),h=an(.5).mul(l.square()).add(u.mul(f));return qc(h,s,o)}}),Yc=Ze({logLoss_:function(t,e,n,r,o){void 0===r&&(r=1e-7),void 0===o&&(o=Wc.SUM_BY_NONZERO_WEIGHTS);var a=je(t,"labels","logLoss"),i=je(e,"predictions","logLoss"),s=null;null!=n&&(s=je(n,"weights","logLoss")),C(a.shape,i.shape,"Error in logLoss: ");var u=an(1),c=an(r),l=a.mul(i.add(c).log()).neg().sub(u.sub(a).mul(u.sub(i).add(c).log()));return qc(l,s,o)}}),Jc=Ze({meanSquaredError_:function(t,e,n,r){void 0===r&&(r=Wc.SUM_BY_NONZERO_WEIGHTS);var o=je(t,"labels","meanSquaredError"),a=je(e,"predictions","meanSquaredError"),i=null;null!=n&&(i=je(n,"weights","meanSquaredError")),C(o.shape,a.shape,"Error in meanSquaredError: ");var s=o.squaredDifference(a);return qc(s,i,r)}}),Qc=Ze({sigmoidCrossEntropy_:function(t,e,n,r,o){void 0===r&&(r=0),void 0===o&&(o=Wc.SUM_BY_NONZERO_WEIGHTS);var a=je(t,"multiClassLabels","sigmoidCrossEntropy"),i=je(e,"logits","sigmoidCrossEntropy"),s=null;if(null!=n&&(s=je(n,"weights","sigmoidCrossEntropy")),C(a.shape,i.shape,"Error in sigmoidCrossEntropy: "),r>0){var u=an(r),c=an(1),l=an(.5);a=a.mul(c.sub(u)).add(l.mul(u))}var f=function(t,e){var n=je(t,"labels","sigmoidCrossEntropyWithLogits"),r=je(e,"logits","sigmoidCrossEntropyWithLogits");C(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");var o=r.relu(),a=r.mul(n),i=r.abs().neg().exp().log1p();return o.sub(a).add(i)}(a,i);return qc(f,s,o)}}),Zc=Ze({softmaxCrossEntropy_:function(t,e,n,r,o){void 0===r&&(r=0),void 0===o&&(o=Wc.SUM_BY_NONZERO_WEIGHTS);var a=je(t,"onehotLabels","softmaxCrossEntropy"),i=je(e,"logits","softmaxCrossEntropy"),s=null;if(null!=n&&(s=je(n,"weights","softmaxCrossEntropy")),C(a.shape,i.shape,"Error in softmaxCrossEntropy: "),r>0){var u=an(r),c=an(1),l=an(a.shape[1]);a=a.mul(c.sub(u)).add(u.div(l))}var f=function(t,e,n){if(void 0===n&&(n=-1),-1===n&&(n=e.rank-1),n!==e.rank-1)throw Error("Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank "+e.rank+" and dim was "+n);return Cr((function(t,e,r){var o=e.logSumExp([n],!0),a=e.toFloat().sub(o);return r([t,a]),{value:a.mul(t).neg().sum([n]),gradFunc:function(t,e){var r=e[0],o=e[1],a=qe(t.shape,[n]);return[t.reshape(a).mul(r.toFloat().sub(o.exp())),t.reshape(a).mul(o.exp().sub(r.toFloat()))]}}}))(t,e)}(a,i);return qc(f,s,o)}}),tl=Object.freeze({get Reduction(){return Wc},absoluteDifference:Hc,computeWeightedLoss:qc,cosineDistance:Kc,hingeLoss:Xc,huberLoss:$c,logLoss:Yc,meanSquaredError:Jc,sigmoidCrossEntropy:Qc,softmaxCrossEntropy:Zc});function el(t,e){return void 0===e&&(e=!1),Ot.tidy((function(){if(2!==t.shape.length)throw new Error("qr2d() requires a 2D Tensor, but got a "+t.shape.length+"D Tensor.");for(var n=t.shape[0],r=t.shape[1],o=Vn(n),a=t.clone(),i=un([[1]],[1,1]),s=i.clone(),u=n>=r?r:n,c=function(t){var e,u=a,c=s,l=o;e=Ot.tidy((function(){var e=a.slice([t,t],[n-t,1]),u=e.norm(),c=a.slice([t,t],[1,1]),l=un([[-1]]).where(c.greater(0),un([[1]])),f=c.sub(l.mul(u)),h=e.div(f);s=1===h.shape[0]?i.clone():i.concat(h.slice([1,0],[h.shape[0]-1,h.shape[1]]),0);var p=l.matMul(f).div(u).neg(),d=a.slice([t,0],[n-t,r]),v=p.mul(s);if(0===t)a=d.sub(v.matMul(s.transpose().matMul(d)));else{var m=d.sub(v.matMul(s.transpose().matMul(d)));a=a.slice([0,0],[t,r]).concat(m,0)}var g=o.slice([0,t],[n,o.shape[1]-t]);if(0===t)o=g.sub(g.matMul(s).matMul(v.transpose()));else{var y=g.sub(g.matMul(s).matMul(v.transpose()));o=o.slice([0,0],[n,t]).concat(y,1)}return[s,a,o]})),s=e[0],a=e[1],o=e[2],Be([u,c,l])},l=0;l<u;++l)c(l);return!e&&n>r&&(o=o.slice([0,0],[n,r]),a=a.slice([0,0],[r,r])),[o,a]}))}var nl=Ze({bandPart_:function(t,e,n){if(e%1!=0)throw new Error("bandPart(): numLower must be an integer, got "+e+".");if(n%1!=0)throw new Error("bandPart(): numUpper must be an integer, got "+n+".");var r=je(t,"a","bandPart");if(r.rank<2)throw new Error("bandPart(): Rank must be at least 2, got "+r.rank+".");var o=r.shape,a=r.shape.slice(-2),i=a[0],s=a[1];if(!(e<=i))throw new Error("bandPart(): numLower ("+e+") must not be greater than the number of rows ("+i+").");if(!(n<=s))throw new Error("bandPart(): numUpper ("+n+") must not be greater than the number of columns ("+s+").");e<0&&(e=i),n<0&&(n=s);var u=dn(0,i,1,"int32").reshape([-1,1]),c=dn(0,s,1,"int32"),l=ou(u,c),f=Ds(l.lessEqual(an(+e,"int32")),l.greaterEqual(an(-n,"int32"))),h=hn([i,s],r.dtype);return or(sr(r.reshape([-1,i,s])).map((function(t){return Ps(f,t,h)}))).reshape(o)}}),rl=Ze({gramSchmidt_:function(t){var e;if(Array.isArray(t)){e=!1,E(null!=t&&t.length>0,(function(){return"Gram-Schmidt process: input must not be null, undefined, or empty"}));for(var n=t[0].shape[0],r=function(e){E(t[e].shape[0]===n,(function(){return"Gram-Schmidt: Non-unique lengths found in the input vectors: ("+t[e].shape[0]+" vs. "+n+")"}))},o=1;o<t.length;++o)r(o)}else e=!0,t=En(t,t.shape[0],0).map((function(t){return rr(t,[0])}));E(t.length<=t[0].shape[0],(function(){return"Gram-Schmidt: Number of vectors ("+t.length+") exceeds number of dimensions ("+t[0].shape[0]+")."}));var a=[],i=t,s=function(t){a.push(Ot.tidy((function(){var e=i[t];if(t>0)for(var n=0;n<t;++n){var r=hc(a[n].mulStrict(e)).mul(a[n]);e=e.sub(r)}return e.div(Ec(e,"euclidean"))})))};for(o=0;o<t.length;++o)s(o);return e?or(a,0):a}}),ol=Ze({qr_:function(t,e){if(void 0===e&&(e=!1),t.rank<2)throw new Error("qr() requires input tensor to have a rank >= 2, but got rank "+t.rank);if(2===t.rank)return el(t,e);var n=t.shape.slice(0,t.shape.length-2).reduce((function(t,e){return t*e})),r=sr(t.reshape([n,t.shape[t.shape.length-2],t.shape[t.shape.length-1]]),0),o=[],a=[];return r.forEach((function(t){var n=el(t,e),r=n[0],i=n[1];o.push(r),a.push(i)})),[or(o,0).reshape(t.shape),or(a,0).reshape(t.shape)]}}),al=Object.freeze({bandPart:nl,gramSchmidt:rl,qr:ol});function il(t,e,n,r,o){null==r&&(r=.5),null==o&&(o=Number.NEGATIVE_INFINITY);var a=t.shape[0];return n=Math.min(n,a),E(0<=r&&r<=1,(function(){return"iouThreshold must be in [0, 1], but was '"+r+"'"})),E(2===t.rank,(function(){return"boxes must be a 2D tensor, but was of rank '"+t.rank+"'"})),E(4===t.shape[1],(function(){return"boxes must have 4 columns, but 2nd dimension was "+t.shape[1]})),E(1===e.rank,(function(){return"scores must be a 1D tensor"})),E(e.shape[0]===a,(function(){return"scores has incompatible shape with boxes. Expected "+a+", but was "+e.shape[0]})),{maxOutputSize:n,iouThreshold:r,scoreThreshold:o}}var sl=Ze({resizeBilinear_:function(t,e,n){void 0===n&&(n=!1);var r=je(t,"images","resizeBilinear");E(3===r.rank||4===r.rank,(function(){return"Error in resizeBilinear: x must be rank 3 or 4, but got rank "+r.rank+"."})),E(2===e.length,(function(){return"Error in resizeBilinear: new shape must 2D, but got shape "+e+"."}));var o=r,a=!1;3===r.rank&&(a=!0,o=r.as4D(1,r.shape[0],r.shape[1],r.shape[2]));var i=e[0],s=e[1],u=Ot.runKernelFunc((function(t,e){return e([o]),t.resizeBilinear(o,i,s,n)}),{x:o},(function(t,e){return{x:function(){return Ot.runKernelFunc((function(r){return r.resizeBilinearBackprop(t,e[0],n)}),{})}}}),"ResizeBilinear",{alignCorners:n,newHeight:i,newWidth:s});return a?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u}}),ul=Ze({resizeNearestNeighbor_:function(t,e,n){void 0===n&&(n=!1);var r=je(t,"images","resizeNearestNeighbor");E(3===r.rank||4===r.rank,(function(){return"Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank "+r.rank+"."})),E(2===e.length,(function(){return"Error in resizeNearestNeighbor: new shape must 2D, but got shape "+e+"."})),E("float32"===r.dtype||"int32"===r.dtype,(function(){return"`images` must have `int32` or `float32` as dtype"}));var o=r,a=!1;3===r.rank&&(a=!0,o=r.as4D(1,r.shape[0],r.shape[1],r.shape[2]));var i=e[0],s=e[1],u=Ot.runKernelFunc((function(t,e){return e([o]),t.resizeNearestNeighbor(o,i,s,n)}),{batchImages:o},(function(t,e){return{batchImages:function(){return Ot.runKernelFunc((function(r){return r.resizeNearestNeighborBackprop(t,e[0],n)}),{})}}}));return a?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u}}),cl=Ze({nonMaxSuppression_:function(t,e,n,r,o){void 0===r&&(r=.5),void 0===o&&(o=Number.NEGATIVE_INFINITY);var a=je(t,"boxes","nonMaxSuppression"),i=je(e,"scores","nonMaxSuppression"),s=il(a,i,n,r,o);n=s.maxOutputSize,r=s.iouThreshold,o=s.scoreThreshold;var u={maxOutputSize:n,iouThreshold:r,scoreThreshold:o};return Ot.runKernelFunc((function(t){return t.nonMaxSuppression(a,i,n,r,o)}),{boxes:a,scores:i},null,"NonMaxSuppressionV3",u)}}),ll=Ze({cropAndResize_:function(t,e,n,r,o,a){var i=je(t,"image","cropAndResize"),s=je(e,"boxes","cropAndResize","float32"),u=je(n,"boxInd","cropAndResize","int32");o=o||"bilinear",a=a||0;var c=s.shape[0];return E(4===i.rank,(function(){return"Error in cropAndResize: image must be rank 4,but got rank "+i.rank+"."})),E(2===s.rank&&4===s.shape[1],(function(){return"Error in cropAndResize: boxes must be have size ["+c+",4] but had shape "+s.shape+"."})),E(1===u.rank&&u.shape[0]===c,(function(){return"Error in cropAndResize: boxInd must be have size ["+c+"] but had shape "+s.shape+"."})),E(2===r.length,(function(){return"Error in cropAndResize: cropSize must be of length 2, but got length "+r.length+"."})),E(r[0]>=1&&r[1]>=1,(function(){return"cropSize must be atleast [1,1], but was "+r})),E("bilinear"===o||"nearest"===o,(function(){return"method must be bilinear or nearest, but was "+o})),Ot.runKernelFunc((function(t,e){return t.cropAndResize(i,s,u,r,o,a)}),{images:i,boxes:s,boxInd:u},null,"CropAndResize",{method:o,extrapolationValue:a,cropSize:r})}}),fl=Object.freeze({resizeBilinear:sl,resizeNearestNeighbor:ul,nonMaxSuppression:cl,nonMaxSuppressionAsync:function(t,e,n,r,o){return void 0===r&&(r=.5),void 0===o&&(o=Number.NEGATIVE_INFINITY),u(this,void 0,void 0,(function(){var a,i,s,u,l,f,h;return c(this,(function(c){switch(c.label){case 0:return a=je(t,"boxes","nonMaxSuppressionAsync"),i=je(e,"scores","nonMaxSuppressionAsync"),s=il(a,i,n,r,o),n=s.maxOutputSize,r=s.iouThreshold,o=s.scoreThreshold,[4,Promise.all([a.data(),i.data()])];case 1:return u=c.sent(),l=u[0],f=u[1],h=Jr(l,f,n,r,o),a!==t&&a.dispose(),i!==e&&i.dispose(),[2,h]}}))}))},cropAndResize:ll}),hl=function(t,e){return!(t>0)||"linear"===e},pl=function(t,e,n){if(null==n||"linear"===n)return t;if("relu"===n)return t.mul(e.step());throw new Error("Gradient for activation "+n+" has not been implemented yet.")},dl=function(t,e){var n=e,r=Or(t.shape,e.shape);return r.length>0&&(n=n.sum(r)),n.reshape(t.shape)},vl=function(t,e,n){if("linear"===e)return t;if("relu"===e)return gc(t);if("elu"===e)return dc(t);if("relu6"===e)return yc(t);if("prelu"===e)return mc(t,n);throw new Error("Unknown fused activation "+e+".")},ml=Ze({fusedMatMul_:function(t){var e,n=t.a,r=t.b,o=t.transposeA,a=void 0!==o&&o,i=t.transposeB,s=void 0!==i&&i,u=t.bias,c=t.activation,l=void 0===c?"linear":c,f=t.preluActivationWeights;if(!1===hl(Ot.state.gradientDepth,l)){var h=Pu(n,r,a,s);return null!=u&&(h=Ls(h,u)),vl(h,l,f)}var p=je(n,"a","fused matMul"),d=je(r,"b","fused matMul");e=_t(p,d),p=e[0],d=e[1];var v=a?p.shape[p.rank-2]:p.shape[p.rank-1],m=s?d.shape[d.rank-1]:d.shape[d.rank-2],g=a?p.shape[p.rank-1]:p.shape[p.rank-2],y=s?d.shape[d.rank-2]:d.shape[d.rank-1],b=p.shape.slice(0,-2),x=d.shape.slice(0,-2),w=R(b),C=R(x);E(p.rank>=2&&d.rank>=2&&p.rank===d.rank,(function(){return"Error in fused matMul: inputs must have the same rank of at least 2, got ranks "+p.rank+" and "+d.rank+"."})),E(I(b,x),(function(){return"Error in fused matMul: outer dimensions ("+b+") and ("+x+") of Tensors with shapes "+p.shape+" and "+d.shape+" must match."})),E(v===m,(function(){return"Error in fused matMul: inner shapes ("+v+") and ("+m+") of Tensors with shapes "+p.shape+" and "+d.shape+" and transposeA="+a+" and transposeB="+s+" must match."}));var _,k,S=p.shape.slice(0,-2).concat([g,y]),A=a?p.as3D(w,v,g):p.as3D(w,g,v),O=s?d.as3D(C,y,m):d.as3D(C,m,y);null!=u&&Tr(S,(_=_t(_=je(u,"bias","fused matMul"),p)[0]).shape),null!=f&&(k=je(f,"prelu weights","fused matMul"));var T={$a:A,$b:O};return null!=u&&(T.$bias=_),null!=f&&(T.$preluActivationWeights=k),Ot.runKernelFunc((function(t,e){var n=t.fusedBatchMatMul({a:A,b:O,transposeA:a,transposeB:s,bias:_,activation:l,preluActivationWeights:k});return e([A,O,n]),n}),T,(function(t,e){var n=e[0],r=e[1],o=e[2],i=pl(t,o,l),c={};return null!=u&&(c={$bias:function(){return dl(_,i)}}),a||s?!a&&s?Object.assign({$a:function(){return i.matMul(r,!1,!1)},$b:function(){return i.matMul(n,!0,!1)}},c):a&&!s?Object.assign({$a:function(){return r.matMul(i,!1,!0)},$b:function(){return n.matMul(i,!1,!1)}},c):Object.assign({$a:function(){return r.matMul(i,!0,!0)},$b:function(){return i.matMul(n,!0,!0)}},c):Object.assign({$a:function(){return i.matMul(r,!1,!0)},$b:function(){return n.matMul(i,!0,!1)}},c)})).reshape(S)}}),gl=Ze({fusedConv2d_:function(t){var e=t.x,n=t.filter,r=t.strides,o=t.pad,a=t.dataFormat,i=void 0===a?"NHWC":a,s=t.dilations,u=void 0===s?[1,1]:s,c=t.dimRoundingMode,l=t.bias,f=t.activation,h=void 0===f?"linear":f,p=t.preluActivationWeights;if(h=h||"linear",!1===hl(Ot.state.gradientDepth,h)){var d=Ru(e,n,r,o,i,u,c);return null!=l&&(d=Ls(d,l)),vl(d,h,p)}var v=je(e,"x","conv2d"),m=je(n,"filter","conv2d"),g=v,y=!1;3===v.rank&&(y=!0,g=v.as4D(1,v.shape[0],v.shape[1],v.shape[2])),E(4===g.rank,(function(){return"Error in fused conv2d: input must be rank 4, but got rank "+g.rank+"."})),E(4===m.rank,(function(){return"Error in fused conv2d: filter must be rank 4, but got rank "+m.rank+"."})),null!=c&&E(S(o),(function(){return"Error in fused conv2d: pad must be an integer when using, dimRoundingMode "+c+" but got pad "+o+"."})),E(g.shape[3]===m.shape[2],(function(){return"Error in conv2d: depth of input ("+g.shape[3]+") must match input depth for filter "+m.shape[2]+"."})),E(zr(r,u),(function(){return"Error in conv2D: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'"})),E("NHWC"===i,(function(){return"Error in conv2d: got dataFormat of "+i+" but only NHWC is currently supported."}));var b,x,w=Fr(g.shape,m.shape,r,u,o,c);null!=l&&(b=_t(b=je(l,"bias","fused conv2d"),v)[0],Tr(w.outShape,b.shape)),null!=p&&(x=je(p,"prelu weights","fused conv2d"));var C={x:g,filter:m};null!=l&&(C.bias=b),null!=p&&(C.preluActivationWeights=x);var _=[m,g],k=Ot.runKernelFunc((function(t,e){var n=t.fusedConv2d({input:g,filter:m,convInfo:w,bias:b,activation:h,preluActivationWeights:x});return e([m,g,n]),n}),C,(function(t,e){var n=e,a=n[0],i=n[1],s=n[2],c=pl(t,s,h);E(jr(u),(function(){return"Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+u+"'"}));var f={};return null!=l&&(f={bias:function(){return dl(b,c)}}),Object.assign({x:function(){return Au(i.shape,c,a,r,o)},filter:function(){return Su(i,c,a.shape,r,o)}},f)}),"FusedConv2D",{convInfo:w,activation:h},_,[!0]);return y?k.as3D(k.shape[1],k.shape[2],k.shape[3]):k}}),yl=Ze({fusedDepthwiseConv2d_:function(t){var e=t.x,n=t.filter,r=t.strides,o=t.pad,a=t.dataFormat,i=void 0===a?"NHWC":a,s=t.dilations,u=void 0===s?[1,1]:s,c=t.dimRoundingMode,l=t.bias,f=t.activation,h=void 0===f?"linear":f,p=t.preluActivationWeights;if(!1===hl(Ot.state.gradientDepth,h)){var d=Ou(e,n,r,o,i,u,c);return null!=l&&(d=Ls(d,l)),vl(d,h,p)}var v=je(e,"x","depthwiseConv2d"),m=je(n,"filter","depthwiseConv2d"),g=v,y=!1;3===v.rank&&(y=!0,g=v.as4D(1,v.shape[0],v.shape[1],v.shape[2])),E(4===g.rank,(function(){return"Error in fused depthwiseConv2d: input must be rank 4, but got rank "+g.rank+"."})),E(4===m.rank,(function(){return"Error in fused depthwiseConv2d: filter must be rank 4, but got rank "+m.rank+"."})),E(g.shape[3]===m.shape[2],(function(){return"Error in fused depthwiseConv2d: number of input channels ("+g.shape[3]+") must match the inChannels dimension in filter "+m.shape[2]+"."})),null==u&&(u=[1,1]),E(zr(r,u),(function(){return"Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'"})),null!=c&&E(S(o),(function(){return"Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode "+c+" but got pad "+o+"."}));var b,x,w=Fr(g.shape,m.shape,r,u,o,c,!0);null!=l&&(b=_t(b=je(l,"bias","fused conv2d"),v)[0],Tr(w.outShape,b.shape)),null!=p&&(x=je(p,"prelu weights","fused depthwiseConv2d"));var C={x:g,filter:m};null!=l&&(C.bias=b),null!=p&&(C.preluActivationWeights=x);var _=[m,g],k=Ot.runKernelFunc((function(t,e){var n=t.fusedDepthwiseConv2D({input:g,filter:m,convInfo:w,bias:b,activation:h,preluActivationWeights:x});return e([m,g,n]),n}),C,(function(t,e){E(jr(u),(function(){return"Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '"+u+"'"}));var n=e[0],r=e[1],o=e[2],a=pl(t,o,h),i={};return null!=l&&(i={bias:function(){return dl(b,a)}}),Object.assign({x:function(){return Tu(r.shape,a,n,w)},filter:function(){return Du(r,a,n.shape,w)}},i)}),"FusedDepthwiseConv2D",{convInfo:w,activation:h},_,[!0]);return y?k.as3D(k.shape[1],k.shape[2],k.shape[3]):k}}),bl=Object.freeze({matMul:ml,conv2d:gl,depthwiseConv2d:yl}),xl=Object.freeze({image:fl,linalg:al,losses:tl,spectral:Nc,fused:bl,signal:Gc,square:Bi,conv1d:ku,conv2d:Ru,conv3d:Iu,depthwiseConv2d:Ou,separableConv2d:Nu,conv2dTranspose:Fu,conv3dTranspose:Mu,op:Ze,batchNormalization2d:_s,batchNormalization3d:ks,batchNormalization4d:Rs,batchNormalization:Is,batchNorm:Ss,batchNorm2d:As,batchNorm3d:Os,batchNorm4d:Ts,booleanMaskAsync:function(t,e,n){return u(this,void 0,void 0,(function(){var r,o,a,i,s,u,l,f,h,p,d,v,m;return c(this,(function(c){switch(c.label){case 0:for(r=je(t,"tensor","boolMask"),o=je(e,"mask","boolMask","bool"),a=null==n?0:n,i=o.rank,s=r.shape,E(i>0,(function(){return"mask cannot be scalar"})),C(s.slice(a,a+i),o.shape,"mask's shape must match the first K dimensions of tensor's shape,"),u=1,l=a;l<a+i;l++)u*=s[l];return f=s.slice(0,a).concat([u],s.slice(a+i)),h=r.reshape(f),p=o.reshape([-1]),[4,Bs(p)];case 1:return d=c.sent(),v=d.squeeze([1]),m=xu(h,v,a),t!==r&&r.dispose(),e!==o&&o.dispose(),v.dispose(),h.dispose(),p.dispose(),d.dispose(),[2,m]}}))}))},complex:tn,real:en,imag:nn,concat:gn,concat1d:yn,concat2d:bn,concat3d:xn,concat4d:wn,split:En,matMul:Pu,dot:Bu,outerProduct:Lu,reverse:Wu,reverse1d:Uu,reverse2d:ju,reverse3d:zu,reverse4d:Vu,maxPool:qu,avgPool:Ku,pool:Xu,maxPool3d:$u,avgPool3d:Yu,slice:Ju,slice1d:Qu,slice2d:Zu,slice3d:tc,slice4d:ec,abs:Li,acos:Wi,acosh:Ui,asin:ji,asinh:zi,atan:Vi,atanh:Gi,ceil:Hi,clipByValue:qi,cos:Ki,cosh:Xi,erf:$i,exp:Yi,expm1:Ji,floor:Qi,log:Zi,log1p:ts,logSigmoid:es,neg:ns,reciprocal:rs,round:os,rsqrt:as,sigmoid:is,sign:ss,isNaN:us,isInf:cs,isFinite:ls,sin:fs,sinh:hs,softplus:ps,sqrt:ds,step:vs,tan:ms,tanh:gs,all:rc,any:oc,argMax:ac,argMin:ic,logSumExp:sc,max:uc,mean:cc,min:lc,moments:fc,sum:hc,prod:pc,equal:iu,equalStrict:su,greater:uu,greaterEqual:cu,greaterEqualStrict:lu,greaterStrict:fu,less:hu,lessEqual:pu,lessEqualStrict:du,lessStrict:vu,notEqual:mu,notEqualStrict:gu,add:Ls,addN:Ws,addStrict:Us,atan2:js,div:zs,divNoNan:Vs,divStrict:Gs,floorDiv:Hs,maximum:qs,maximumStrict:Ks,minimum:Xs,minimumStrict:$s,mod:Ys,modStrict:Js,mul:Qs,mulStrict:Zs,pow:tu,powStrict:eu,squaredDifference:nu,squaredDifferenceStrict:ru,sub:ou,subStrict:au,elu:dc,leakyRelu:vc,prelu:mc,relu:gc,relu6:yc,selu:bc,logicalAnd:Ds,logicalNot:Ns,logicalOr:Fs,logicalXor:Ms,where:Ps,whereAsync:Bs,buffer:Mn,print:function(t,e){void 0===e&&(e=!1)},batchToSpaceND:Pn,broadcastTo:Bn,cast:Ln,clone:Wn,cumsum:Un,depthToSpace:jn,expandDims:zn,eye:Vn,multinomial:Gn,oneHot:Hn,pad:qn,pad1d:Kn,pad2d:Xn,pad3d:$n,pad4d:Yn,rand:Jn,randomNormal:Qn,randomGamma:Zn,randomUniform:tr,reshape:er,spaceToBatchND:nr,squeeze:rr,stack:or,tile:ar,truncatedNormal:ir,unstack:sr,setdiff1dAsync:function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,a,i,s,u,l,f,h;return c(this,(function(c){switch(c.label){case 0:return n=je(t,"x","setdiff1d"),r=je(e,"y","setdiff1d"),E(n.dtype===r.dtype,(function(){return"x and y should have the same dtype, but got x ("+n.dtype+") and y ("+r.dtype+")."})),E(1===n.rank,(function(){return"x should be 1D tensor, but got x ("+n.shape+")."})),E(1===r.rank,(function(){return"y should be 1D tensor, but got y ("+r.shape+")."})),[4,n.data()];case 1:return o=c.sent(),[4,r.data()];case 2:for(a=c.sent(),i=new Set(a),s=0,f=0;f<o.length;f++)i.has(o[f])||s++;for(u=new lt([s],n.dtype),l=new lt([s],"int32"),f=0,h=0;f<o.length;f++)i.has(o[f])||(u.values[h]=o[f],l.values[h]=f,h++);return[2,[u.toTensor(),l.toTensor()]]}}))}))},fill:pn,linspace:function(t,e,n){if(n<=0)throw new Error("The number of values should be positive.");return Ot.runKernelFunc((function(r){return r.linspace(t,e,n)}),{})},ones:fn,range:dn,scalar:an,tensor:rn,tensor1d:sn,tensor2d:un,tensor3d:cn,tensor4d:ln,tensor5d:function(t,e,n){if(_(t),null!=e&&5!==e.length)throw new Error("tensor5d() requires shape to have five numbers");var r=We(t,n);if(5!==r.length&&1!==r.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return on(t,e,r,n)},tensor6d:function(t,e,n){if(_(t),null!=e&&6!==e.length)throw new Error("tensor6d() requires shape to have six numbers");var r=We(t,n);if(6!==r.length&&1!==r.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return on(t,e=e||r,r,n)},variable:function(t,e,n,r){return void 0===e&&(e=!0),Ot.makeVariable(t,e,n,r)},zeros:hn,onesLike:vn,zerosLike:mn,transpose:xc,softmax:_r,logSoftmax:kr,localResponseNormalization:wc,norm:Ec,gather:xu,unsortedSegmentSum:wu,basicLSTMCell:Cc,multiRNNCell:_c,movingAverage:kc,stridedSlice:Rc,topk:Ic,scatterND:Sc,fft:Ac,ifft:Oc,rfft:Tc,irfft:Dc,sparseToDense:Fc,gatherND:Mc,diag:Pc,dropout:Bc,hannWindow:Uc,hammingWindow:jc,frame:zc,stft:Vc,inTopKAsync:function(t,e,n){return void 0===n&&(n=1),u(this,void 0,void 0,(function(){var r,o,a,i,s,u,l,f,h,p,d,v,m,g;return c(this,(function(c){switch(c.label){case 0:return r=je(t,"predictions","inTopK"),o=je(e,"targets","inTopK"),E(r.rank>1,(function(){return"inTopK() expects the predictions to be of rank 2 or higher, but got "+r.rank})),E(r.rank-1===o.rank,(function(){return"predictions rank should be 1 larger than targets rank, but got predictions rank "+r.rank+" and targets rank "+o.rank})),C(r.shape.slice(0,r.shape.length-1),o.shape,"predictions's shape should be align with the targets' shape, except the last dimension."),a=r.shape[r.shape.length-1],E(n>0&&n<=a,(function(){return"'k' passed to inTopK() must be > 0 && <= the predictions last dimension ("+a+"), but got "+n})),[4,r.data()];case 1:return i=c.sent(),[4,o.data()];case 2:for(s=c.sent(),u=[i.length/a,a],f=u[1],h=P("bool",l=u[0]),p=0;p<l;p++){for(d=p*f,v=i.subarray(d,d+f),m=[],g=0;g<v.length;g++)m.push({value:v[g],index:g});for(m.sort((function(t,e){return e.value-t.value})),h[p]=0,g=0;g<n;g++)if(m[g].index===s[p]){h[p]=1;break}}return t!==r&&r.dispose(),e!==o&&o.dispose(),[2,rn(h,o.shape,"bool")]}}))}))}});function wl(t,e){Array.isArray(t)||(t=[t]),t.forEach((function(t){null!=t&&E("complex64"!==t.dtype,(function(){return e+" does not support complex64 tensors."}))}))}function El(t,e,n,r){if("linear"===n)return t.linear(e);if("relu"===n)return t.relu(e);if("elu"===n)return t.elu(e);if("relu6"===n)return t.relu6(e);if("prelu"===n)return t.prelu(e,r);throw new Error("Activation "+n+" has not been implemented for the CPU backend.")}var Cl=function(t){function e(){var e=t.call(this)||this;return e.blockSize=48,e.firstUse=!0,e.data=new Rr(e,Ot),e}return s(e,t),e.prototype.write=function(t,e,n){this.firstUse&&(this.firstUse=!1,f().get("IS_NODE")&&Le("\n============================\nHi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.\n============================\n"));var r={};return this.data.set(r,{values:t,dtype:n}),r},e.prototype.move=function(t,e,n,r){this.data.set(t,{values:e,dtype:r})},e.prototype.numDataIds=function(){return this.data.numDataIds()},e.prototype.read=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this.readSync(t)]}))}))},e.prototype.readSync=function(t){var e=this.data.get(t),n=e.dtype,r=e.complexTensors;return"complex64"===n?Kr(this.readSync(r.real.dataId),this.readSync(r.imag.dataId)):this.data.get(t).values},e.prototype.bufferSync=function(t){var e=this.readSync(t.dataId),n=e;if("string"===t.dtype)try{n=e.map((function(t){return ot(t)}))}catch(t){throw new Error("Failed to decode encoded string bytes into utf-8")}return Mn(t.shape,t.dtype,n)},e.prototype.makeOutput=function(t,e,n){var r=this.write(t,e,n);return Ot.makeTensorFromDataId(r,e,n,this)},e.prototype.disposeData=function(t){if(this.data.has(t)){var e=this.data.get(t).complexTensors;null!=e&&(e.real.dispose(),e.imag.dispose()),this.data.delete(t)}},e.prototype.time=function(t){return u(this,void 0,void 0,(function(){var e;return c(this,(function(n){return e=et(),t(),[2,{kernelMs:et()-e}]}))}))},e.prototype.memory=function(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}},e.prototype.complex=function(t,e){var n=this.makeOutput(null,t.shape,"complex64");return this.data.get(n.dataId).complexTensors={real:Ot.keep(t.clone()),imag:Ot.keep(e.clone())},n},e.prototype.real=function(t){return this.data.get(t.dataId).complexTensors.real.clone()},e.prototype.imag=function(t){return this.data.get(t.dataId).complexTensors.imag.clone()},e.prototype.slice=function(t,e,n){if(wl(t,"slice"),wr(t.shape,e,n)){var r=Er(e,t.strides),o=R(n);return rn(this.readSync(t.dataId).subarray(r,r+o),n,t.dtype)}for(var a=Mn(n,t.dtype),i=this.bufferSync(t),s=0;s<a.size;++s){var u=a.indexToLoc(s).map((function(t,n){return t+e[n]}));a.values[s]=i.get.apply(i,u)}return a.toTensor()},e.prototype.stridedSlice=function(t,e,n,r){wl(t,"stridedSlice");var o=yr(e,n,r);if(o.some((function(t){return 0===t})))return rn([],o);for(var a=Mn(o,t.dtype),i=this.bufferSync(t),s=0;s<a.size;s++){for(var u=a.indexToLoc(s),c=new Array(u.length),l=0;l<c.length;l++)c[l]=u[l]*r[l]+e[l];a.set.apply(a,[i.get.apply(i,c)].concat(u))}return a.toTensor()},e.prototype.diag=function(t){for(var e=this.readSync(t.dataId),n=Mn([t.size,t.size],t.dtype),r=n.values,o=0;o<e.length;o++)r[o*t.size+o]=e[o];return n.toTensor()},e.prototype.unstack=function(t,e){for(var n=t.shape[e],r=new Array(t.rank-1),o=0,a=0;a<t.rank;a++)a!==e&&(r[o++]=t.shape[a]);var i=new Array(t.rank).fill(0),s=t.shape.slice();s[e]=1;var u=new Array(n);for(a=0;a<u.length;a++)i[e]=a,u[a]=this.slice(t,i,s).reshape(r);return u},e.prototype.reverse=function(t,e){wl(t,"reverse");for(var n=Mn(t.shape,t.dtype),r=this.bufferSync(t),o=function(o){var a=n.indexToLoc(o),i=a.slice();e.forEach((function(e){return i[e]=t.shape[e]-1-i[e]})),n.set.apply(n,[r.get.apply(r,i)].concat(a))},a=0;a<n.size;a++)o(a);return n.toTensor()},e.prototype.concat=function(t,e){var n=this;if("complex64"===t[0].dtype){var r=t.map((function(t){return en(t)})),o=t.map((function(t){return nn(t)}));return tn(this.concat(r,e),this.concat(o,e))}var a=t.map((function(t){var n=R(t.shape.slice(e));return t.as2D(-1,n)})),i=Qe(a.map((function(t){return t.shape})),1),s=Mn(i,t[0].dtype).values;if(1===a[0].shape[0]){var u=0;a.forEach((function(t){s.set(n.readSync(t.dataId),u),u+=t.size}))}else{var c=0;a.forEach((function(t){for(var e=n.readSync(t.dataId),r=0,o=0;o<t.shape[0];++o)for(var a=o*i[1]+c,u=0;u<t.shape[1];++u)s[a+u]=e[r++];c+=t.shape[1]}))}var l=Qe(t.map((function(t){return t.shape})),e);return rn(s,l,t[0].dtype)},e.prototype.neg=function(t){return wl(t,"neg"),this.multiply(an(-1),t)},e.prototype.add=function(t,e){return"complex64"===t.dtype||"complex64"===e.dtype?this.broadcastedBinaryComplexOp(t.cast("complex64"),e.cast("complex64"),(function(t,e,n,r){return{real:t+n,imag:e+r}})):this.broadcastedBinaryOp(t,e,Et(t.dtype,e.dtype),(function(t,e){return t+e}))},e.prototype.addN=function(t){var e=this;wl(t,"addN");for(var n=t.map((function(t){return e.readSync(t.dataId)})),r=Mn(t[0].shape,t[0].dtype),o=r.values,a=0;a<t.length;a++)for(var i=n[a],s=0;s<o.length;s++)o[s]+=i[s];return r.toTensor()},e.prototype.subtract=function(t,e){return"complex64"===t.dtype||"complex64"===e.dtype?this.broadcastedBinaryComplexOp(t.cast("complex64"),e.cast("complex64"),(function(t,e,n,r){return{real:t-n,imag:e-r}})):this.broadcastedBinaryOp(t,e,Et(t.dtype,e.dtype),(function(t,e){return t-e}))},e.prototype.pow=function(t,e){return wl([t,e],"pow"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){return Math.pow(t,e)}))},e.prototype.batchMatMul=function(t,e,n,r){wl([t,e],"matMul");for(var o=n?t.shape[1]:t.shape[2],a=n?t.shape[2]:t.shape[1],i=r?e.shape[1]:e.shape[2],s=t.shape[0],u=this.readSync(t.dataId),c=this.readSync(e.dataId),l=n?[t.strides[0],1,t.strides[1]]:[t.strides[0],t.strides[1],1],f=l[0],h=l[1],p=l[2],d=r?[1,e.strides[1],e.strides[0]]:[e.strides[1],1,e.strides[0]],v=d[0],m=d[1],g=d[2],y=a*i,b=Mn([s,a,i],t.dtype),x=b.values,w=this.blockSize,E=0;E<s;E++)for(var C=0;C<a;C+=w)for(var _=0;_<i;_+=w)for(var k=0;k<o;k+=w)for(var R=Math.min(C+w,a),I=Math.min(_+w,i),S=Math.min(k+w,o),A=C;A<R;A++)for(var O=_;O<I;O++){for(var T=0,D=k;D<S;D++)T+=u[E*f+A*h+D*p]*c[D*v+O*m+E*g];x[E*y+(A*i+O)]+=T}return b.toTensor()},e.prototype.fusedBatchMatMul=function(t){var e=t.a,n=t.b,r=t.transposeA,o=t.transposeB,a=t.bias,i=t.activation,s=t.preluActivationWeights,u=this.batchMatMul(e,n,r,o);return a&&(u=this.add(u,a)),i&&(u=El(this,u,i,s)),u},e.prototype.multiply=function(t,e){return"complex64"===t.dtype||"complex64"===e.dtype?this.broadcastedBinaryComplexOp(t.cast("complex64"),e.cast("complex64"),(function(t,e,n,r){return{real:t*n-e*r,imag:t*r+e*n}})):this.broadcastedBinaryOp(t,e,Et(t.dtype,e.dtype),(function(t,e){return t*e}))},e.prototype.realDivide=function(t,e){return wl([t,e],"realDivide"),this.broadcastedBinaryOp(t,e,"float32",(function(t,e){return t/e}))},e.prototype.floorDiv=function(t,e){return wl([t,e],"floorDiv"),this.broadcastedBinaryOp(t,e,"int32",(function(t,e){return Math.floor(t/e)}))},e.prototype.sum=function(t,e){wl(t,"sum"),Ke("sum",e,t.rank);for(var n=He(t.shape,e),r=n[0],o=n[1],a=hn(r,Et(t.dtype,"int32")),i=R(o),s=this.readSync(a.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*i,f=0,h=0;h<i;++h)f+=u[l+h];s[c]=f}return a},e.prototype.prod=function(t,e){wl(t,"sum");for(var n=He(t.shape,e),r=n[0],o=n[1],a=hn(r,Et(t.dtype,"int32")),i=R(o),s=this.readSync(a.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*i,f=1,h=0;h<i;++h)f*=u[l+h];s[c]=f}return a},e.prototype.unsortedSegmentSum=function(t,e,n){wl(t,"unsortedSegmentSum");for(var r=[],o=t.rank-e.rank,a=0;a<o;++a)e=e.expandDims(a+1);for(a=0;a<n;++a){var i=an(a,"int32"),s=iu(i,e).asType("float32").mul(t).sum(0);r.push(s)}return or(r)},e.prototype.argMin=function(t,e){wl(t,"argMin");var n=[e];Ke("argMin",n,t.rank);for(var r=He(t.shape,n),o=r[0],a=r[1],i=hn(o,"int32"),s=R(a),u=this.readSync(i.dataId),c=this.readSync(t.dataId),l=0;l<u.length;++l){for(var f=l*s,h=c[f],p=0,d=0;d<s;++d){var v=c[f+d];v<h&&(h=v,p=d)}u[l]=p}return i},e.prototype.argMax=function(t,e){wl(t,"argMax");var n=[e];Ke("argMax",n,t.rank);for(var r=He(t.shape,n),o=r[0],a=r[1],i=hn(o,"int32"),s=R(a),u=this.readSync(i.dataId),c=this.readSync(t.dataId),l=0;l<u.length;++l){for(var f=l*s,h=c[f],p=0,d=0;d<s;++d){var v=c[f+d];v>h&&(h=v,p=d)}u[l]=p}return i},e.prototype.cumsum=function(t,e,n,r){if(wl(t,"cumsum"),e!==t.rank-1)throw new Error("backend.cumsum in CPU expects an inner-most axis="+(t.rank-1)+" but got axis="+e);for(var o=Et(t.dtype,"int32"),a=hn(t.shape,o),i=this.readSync(a.dataId),s=this.readSync(t.dataId),u=t.shape[t.rank-1],c=r?function(t,e){return t+u-e-1}:function(t,e){return t+e},l=0;l<s.length;l+=u)for(var f=0;f<u;f++){var h=c(l,f);if(0===f)i[h]=n?0:s[h];else{var p=c(l,f-1);i[h]=n?s[p]+i[p]:s[h]+i[p]}}return a},e.prototype.equal=function(t,e){return wl([t,e],"equal"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t===e?1:0}))},e.prototype.notEqual=function(t,e){return wl([t,e],"notEqual"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t!==e?1:0}))},e.prototype.less=function(t,e){return wl([t,e],"less"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t<e?1:0}))},e.prototype.lessEqual=function(t,e){return wl([t,e],"lessEqual"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t<=e?1:0}))},e.prototype.greater=function(t,e){return wl([t,e],"greater"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t>e?1:0}))},e.prototype.greaterEqual=function(t,e){return wl([t,e],"greaterEqual"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t>=e?1:0}))},e.prototype.logicalNot=function(t){wl(t,"logicalNot");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r)n[r]=e[r]?0:1;return this.makeOutput(n,t.shape,"bool")},e.prototype.logicalAnd=function(t,e){return wl([t,e],"logicalAnd"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t&&e}))},e.prototype.logicalOr=function(t,e){return wl([t,e],"logicalOr"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t||e}))},e.prototype.select=function(t,e,n){wl([t,e,n],"select");for(var r=this.readSync(t.dataId),o=this.readSync(e.dataId),a=this.readSync(n.dataId),i=hn(e.shape,Et(e.dtype,n.dtype)),s=this.readSync(i.dataId),u=0,c=0===t.rank||t.rank>1||1===e.rank?1:R(e.shape.slice(1)),l=0;l<r.length;l++)for(var f=0;f<c;f++)1===r[l]?s[u++]=o[l]:s[u++]=a[l];return i},e.prototype.where=function(t){wl([t],"where");var e=this.readSync(t.dataId);return no(t.shape,e)},e.prototype.topk=function(t,e,n){return wl(t,"topk"),eo(this.readSync(t.dataId),t.shape,t.dtype,e)},e.prototype.min=function(t,e){wl(t,"min"),Ke("min",e,t.rank);for(var n=He(t.shape,e),r=n[0],o=n[1],a=hn(r,t.dtype),i=R(o),s=this.readSync(a.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*i,f=u[l],h=0;h<i;++h){var p=u[l+h];p<f&&(f=p)}s[c]=f}return a},e.prototype.minimum=function(t,e){return wl([t,e],"minimum"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){return Math.min(t,e)}))},e.prototype.mod=function(t,e){return wl([t,e],"mod"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){var n=t%e;return t<0&&e<0||t>=0&&e>=0?n:(n+e)%e}))},e.prototype.max=function(t,e){wl(t,"max"),Ke("max",e,t.rank);for(var n=He(t.shape,e),r=n[0],o=n[1],a=hn(r,t.dtype),i=R(o),s=this.readSync(a.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*i,f=u[l],h=0;h<i;++h){var p=u[l+h];p>f&&(f=p)}s[c]=f}return a},e.prototype.maximum=function(t,e){return wl([t,e],"maximum"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){return Math.max(t,e)}))},e.prototype.all=function(t,e){wl(t,"all"),Ke("all",e,t.rank);for(var n=He(t.shape,e),r=n[0],o=n[1],a=hn(r,t.dtype),i=R(o),s=this.readSync(a.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*i,f=u[l],h=0;h<i;++h){var p=u[l+h];f=f&&p}s[c]=f}return a},e.prototype.any=function(t,e){wl(t,"any"),Ke("any",e,t.rank);for(var n=He(t.shape,e),r=n[0],o=n[1],a=hn(r,t.dtype),i=R(o),s=this.readSync(a.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*i,f=u[l],h=0;h<i;++h){var p=u[l+h];f=f||p}s[c]=f}return a},e.prototype.squaredDifference=function(t,e){return wl([t,e],"squaredDifference"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){var n=t-e;return n*n}))},e.prototype.ceil=function(t){wl(t,"ceil");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r)n[r]=Math.ceil(e[r]);return this.makeOutput(n,t.shape,"float32")},e.prototype.floor=function(t){wl(t,"floor");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r)n[r]=Math.floor(e[r]);return this.makeOutput(n,t.shape,"float32")},e.prototype.sign=function(t){wl(t,"x");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r)e[r]<0?n[r]=-1:e[r]>0?n[r]=1:n[r]=0;return this.makeOutput(n,t.shape,"float32")},e.prototype.isNaN=function(t){wl(t,"x");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r)Number.isNaN(e[r])&&(n[r]=1);return this.makeOutput(n,t.shape,"bool")},e.prototype.isInf=function(t){wl(t,"x");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r)Math.abs(e[r])===1/0&&(n[r]=1);return this.makeOutput(n,t.shape,"bool")},e.prototype.isFinite=function(t){wl(t,"x");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r)Number.isFinite(e[r])&&(n[r]=1);return this.makeOutput(n,t.shape,"bool")},e.prototype.round=function(t){wl(t,"round");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var o=Math.floor(e[r]);e[r]-o<.5?n[r]=Math.floor(e[r]):e[r]-o>.5?n[r]=Math.ceil(e[r]):n[r]=o%2==0?o:o+1}return this.makeOutput(n,t.shape,"float32")},e.prototype.exp=function(t){wl(t,"exp");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r)n[r]=Math.exp(e[r]);return this.makeOutput(n,t.shape,"float32")},e.prototype.expm1=function(t){wl(t,"expm1");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r)n[r]=Math.expm1(e[r]);return this.makeOutput(n,t.shape,"float32")},e.prototype.log=function(t){wl(t,"log");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var o=e[r];n[r]=Math.log(o)}return this.makeOutput(n,t.shape,"float32")},e.prototype.log1p=function(t){wl(t,"log1p");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var o=e[r];n[r]=Math.log1p(o)}return this.makeOutput(n,t.shape,"float32")},e.prototype.sqrt=function(t){wl(t,"sqrt");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var o=e[r];n[r]=Math.sqrt(o)}return this.makeOutput(n,t.shape,"float32")},e.prototype.rsqrt=function(t){wl(t,"rsqrt");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var o=e[r];n[r]=1/Math.sqrt(o)}return this.makeOutput(n,t.shape,"float32")},e.prototype.reciprocal=function(t){wl(t,"reciprocal");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r)n[r]=1/e[r];return this.makeOutput(n,t.shape,"float32")},e.prototype.linear=function(t){return t},e.prototype.relu=function(t){wl(t,"relu");for(var e=hn(t.shape,t.dtype),n=this.readSync(e.dataId),r=this.readSync(t.dataId),o=0;o<r.length;++o)n[o]=Math.max(0,r[o]);return e},e.prototype.relu6=function(t){wl(t,"relu");for(var e=hn(t.shape,t.dtype),n=this.readSync(e.dataId),r=this.readSync(t.dataId),o=0;o<r.length;++o)n[o]=Math.min(Math.max(0,r[o]),6);return e},e.prototype.prelu=function(t,e){return wl([t,e],"prelu"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){return t<0?e*t:t}))},e.prototype.elu=function(t){wl(t,"elu");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){var o=n[r];e[r]=o>=0?o:Math.exp(o)-1}return this.makeOutput(e,t.shape,"float32")},e.prototype.eluDer=function(t,e){wl([t,e],"eluDer");for(var n=new Float32Array(e.size),r=this.readSync(e.dataId),o=this.readSync(t.dataId),a=0;a<r.length;++a){var i=r[a];n[a]=i>=1?o[a]:o[a]*(i+1)}return this.makeOutput(n,e.shape,"float32")},e.prototype.selu=function(t){wl(t,"selu");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){var o=n[r];e[r]=o>=0?1.0507009873554805*o:1.7580993408473768*(Math.exp(o)-1)}return this.makeOutput(e,t.shape,"float32")},e.prototype.clip=function(t,e,n){wl(t,"clip");for(var r=new Float32Array(t.size),o=this.readSync(t.dataId),a=0;a<o.length;++a){var i=o[a];r[a]=i>n?n:i<e?e:i}return this.makeOutput(r,t.shape,"float32")},e.prototype.abs=function(t){for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.abs(n[r]);return this.makeOutput(e,t.shape,"float32")},e.prototype.complexAbs=function(t){for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<t.size;++r){var o=n[2*r],a=n[2*r+1];e[r]=Math.hypot(o,a)}return this.makeOutput(e,t.shape,"float32")},e.prototype.int=function(t){wl(t,"int");for(var e=new Int32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=n[r];return this.makeOutput(e,t.shape,"int32")},e.prototype.sigmoid=function(t){wl(t,"sigmoid");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=1/(1+Math.exp(-n[r]));return this.makeOutput(e,t.shape,"float32")},e.prototype.softplus=function(t){wl(t,"softplus");for(var e=Math.log(1.1920928955078125e-7)+2,n=new Float32Array(t.size),r=this.readSync(t.dataId),o=0;o<r.length;++o){var a,i=r[o]>-e,s=r[o]<e,u=Math.exp(r[o]);a=s?u:i?r[o]:Math.log(1+u),n[o]=a}return this.makeOutput(n,t.shape,"float32")},e.prototype.sin=function(t){wl(t,"sin");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.sin(n[r]);return this.makeOutput(e,t.shape,"float32")},e.prototype.cos=function(t){wl(t,"cos");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.cos(n[r]);return this.makeOutput(e,t.shape,"float32")},e.prototype.tan=function(t){wl(t,"tan");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.tan(n[r]);return this.makeOutput(e,t.shape,"float32")},e.prototype.asin=function(t){wl(t,"asin");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.asin(n[r]);return this.makeOutput(e,t.shape,"float32")},e.prototype.acos=function(t){wl(t,"acos");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.acos(n[r]);return this.makeOutput(e,t.shape,"float32")},e.prototype.atan=function(t){wl(t,"atan");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.atan(n[r]);return this.makeOutput(e,t.shape,"float32")},e.prototype.atan2=function(t,e){return wl([t,e],"atan2"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){return Math.atan2(t,e)}))},e.prototype.sinh=function(t){wl(t,"sinh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.sinh(n[r]);return this.makeOutput(e,t.shape,"float32")},e.prototype.cosh=function(t){wl(t,"cosh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.cosh(n[r]);return this.makeOutput(e,t.shape,"float32")},e.prototype.tanh=function(t){wl(t,"tanh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=A(n[r]);return this.makeOutput(e,t.shape,"float32")},e.prototype.asinh=function(t){wl(t,"asinh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.asinh(n[r]);return this.makeOutput(e,t.shape,"float32")},e.prototype.acosh=function(t){wl(t,"acosh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.acosh(n[r]);return this.makeOutput(e,t.shape,"float32")},e.prototype.atanh=function(t){wl(t,"atanh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.atanh(n[r]);return this.makeOutput(e,t.shape,"float32")},e.prototype.erf=function(t){wl(t,"erf");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){var o=Math.sign(n[r]),a=Math.abs(n[r]),i=1/(1+.3275911*a);e[r]=o*(1-((((1.061405429*i-1.453152027)*i+1.421413741)*i-.284496736)*i+.254829592)*i*Math.exp(-a*a))}return this.makeOutput(e,t.shape,"float32")},e.prototype.step=function(t,e){void 0===e&&(e=0),wl(t,"step");for(var n=new Float32Array(t.size),r=this.readSync(t.dataId),o=0;o<r.length;++o){var a=r[o];isNaN(a)?n[o]=NaN:n[o]=a>0?1:e}return this.makeOutput(n,t.shape,"float32")},e.prototype.fusedConv2d=function(t){var e=t.input,n=t.filter,r=t.convInfo,o=t.bias,a=t.activation,i=t.preluActivationWeights,s=this.conv2d(e,n,r);return o&&(s=this.add(s,o)),a&&(s=El(this,s,a,i)),s},e.prototype.conv2d=function(t,e,n){wl([t,e],"conv2d");for(var r=n.filterHeight,o=n.filterWidth,a=n.dilationHeight,i=n.dilationWidth,s=n.padInfo.left,u=n.padInfo.top,c="channelsLast"===n.dataFormat,l=Mn(n.outShape,t.dtype),f=t.strides[0],h=c?t.strides[1]:t.strides[2],p=c?t.strides[2]:1,d=c?1:t.strides[1],v=l.strides[0],m=c?l.strides[1]:l.strides[2],g=c?l.strides[2]:1,y=c?1:l.strides[1],b=this.readSync(t.dataId),x=this.readSync(e.dataId),w=l.values,E=0;E<n.batchSize;++E)for(var C=E*f,_=E*v,k=0;k<n.outHeight;++k)for(var R=_+k*m,I=k*n.strideHeight-u,S=0;S<r;S++){var A=I+S*a;if(!(A<0||A>=n.inHeight))for(var O=S*e.strides[0],T=C+A*h,D=0;D<n.outWidth;++D)for(var N=R+D*g,F=D*n.strideWidth-s,M=0;M<o;M++){var P=F+M*i;if(!(P<0||P>=n.inWidth))for(var B=T+P*p,L=O+M*e.strides[1],W=0;W<n.inChannels;++W){for(var U=b[B+W*d],j=0;j<n.outChannels;++j)w[N+j*y]+=U*x[L+j];L+=n.outChannels}}}return l.toTensor()},e.prototype.conv3d=function(t,e,n){for(var r=n.filterDepth,o=n.filterHeight,a=n.filterWidth,i=n.dilationDepth,s=n.dilationHeight,u=n.dilationWidth,c=n.padInfo.front,l=n.padInfo.left,f=n.padInfo.top,h=Mn(n.outShape,t.dtype),p=this.readSync(t.dataId),d=this.readSync(e.dataId),v=h.values,m=0;m<n.batchSize;++m)for(var g=m*t.strides[0],y=m*h.strides[0],b=0;b<n.outDepth;++b)for(var x=y+b*h.strides[1],w=b*n.strideDepth-c,E=0;E<r;E++){var C=w+E*i;if(!(C<0||C>=n.inDepth))for(var _=E*e.strides[0],k=g+C*t.strides[1],R=0;R<n.outHeight;++R)for(var I=x+R*h.strides[2],S=R*n.strideHeight-f,A=0;A<o;A++){var O=S+A*s;if(!(O<0||O>=n.inHeight))for(var T=_+A*e.strides[1],D=k+O*t.strides[2],N=0;N<n.outWidth;++N)for(var F=I+N*n.outChannels,M=N*n.strideWidth-l,P=0;P<a;P++){var B=M+P*u;if(!(B<0||B>=n.inWidth))for(var L=T+P*e.strides[2],W=D+B*n.inChannels,U=L,j=0;j<n.inChannels;++j){for(var z=p[W+j],V=0;V<n.outChannels;++V)v[F+V]+=z*d[U+V];U+=n.outChannels}}}}return h.toTensor()},e.prototype.conv2dDerInput=function(t,e,n){wl([t,e],"conv2dDerInput");for(var r=Mn(n.inShape,"float32"),o=r.values,a=this.readSync(t.dataId),i=this.readSync(e.dataId),s=e.strides,u=s[0],c=s[1],l=s[2],f=n.batchSize,h=n.filterHeight,p=n.filterWidth,d=n.inChannels,v=n.inHeight,m=n.inWidth,g=n.outChannels,y=n.outHeight,b=n.outWidth,x=n.strideHeight,w=n.strideWidth,E=n.dataFormat,C=h-1-n.padInfo.top,_=p-1-n.padInfo.left,k="channelsLast"===E,R=r.strides[0],I=k?r.strides[1]:r.strides[2],S=k?r.strides[2]:1,A=k?1:r.strides[1],O=t.strides[0],T=k?t.strides[1]:t.strides[2],D=k?t.strides[2]:1,N=k?1:t.strides[1],F=0;F<f;++F)for(var M=0;M<d;++M)for(var P=0;P<v;++P)for(var B=P-C,L=Math.max(0,Math.ceil(B/x)),W=Math.min(y,(h+B)/x),U=0;U<m;++U){for(var j=U-_,z=Math.max(0,Math.ceil(j/w)),V=Math.min(b,(p+j)/w),G=0,H=L;H<W;++H)for(var q=H*x-B,K=z;K<V;++K)for(var X=O*F+T*H+D*K,$=u*(h-1-q)+c*(p-1-(K*w-j))+l*M,Y=0;Y<g;++Y)G+=a[X+N*Y]*i[$+Y];o[R*F+I*P+S*U+A*M]=G}return r.toTensor()},e.prototype.conv3dDerInput=function(t,e,n){for(var r=Mn(n.inShape,"float32"),o=r.values,a=r.strides,i=a[0],s=a[1],u=a[2],c=a[3],l=this.readSync(t.dataId),f=t.strides,h=f[0],p=f[1],d=f[2],v=f[3],m=this.readSync(e.dataId),g=e.strides,y=g[0],b=g[1],x=g[2],w=g[3],E=n.batchSize,C=n.filterDepth,_=n.filterHeight,k=n.filterWidth,R=n.inChannels,I=n.inDepth,S=n.inHeight,A=n.inWidth,O=n.outChannels,T=n.outDepth,D=n.outHeight,N=n.outWidth,F=n.strideDepth,M=n.strideHeight,P=n.strideWidth,B=C-1-n.padInfo.front,L=_-1-n.padInfo.top,W=k-1-n.padInfo.left,U=0;U<E;++U)for(var j=0;j<R;++j)for(var z=0;z<I;++z)for(var V=z-B,G=Math.max(0,Math.ceil(V/F)),H=Math.min(T,(C+V)/F),q=0;q<S;++q)for(var K=q-L,X=Math.max(0,Math.ceil(K/M)),$=Math.min(D,(_+K)/M),Y=0;Y<A;++Y){for(var J=Y-W,Q=Math.max(0,Math.ceil(J/P)),Z=Math.min(N,(k+J)/P),tt=0,et=G;et<H;++et)for(var nt=et*F-V,rt=X;rt<$;++rt)for(var ot=rt*M-K,at=Q;at<Z;++at)for(var it=h*U+p*et+d*rt+v*at,st=y*(C-1-nt)+b*(_-1-ot)+x*(k-1-(at*P-J))+w*j,ut=0;ut<O;++ut)tt+=l[it+ut]*m[st+ut];o[i*U+s*z+u*q+c*Y+j]=tt}return r.toTensor()},e.prototype.conv2dDerFilter=function(t,e,n){wl([t,e],"conv2dDerFilter");for(var r=n.strideHeight,o=n.strideWidth,a=n.filterHeight,i=n.filterWidth,s="channelsLast"===n.dataFormat,u=Mn(n.filterShape,"float32"),c=n.padInfo.left,l=n.padInfo.top,f=this.bufferSync(t),h=this.bufferSync(e),p=0;p<a;++p)for(var d=Math.max(0,Math.ceil((l-p)/r)),v=Math.min(n.outHeight,(n.inHeight+l-p)/r),m=0;m<i;++m)for(var g=Math.max(0,Math.ceil((c-m)/o)),y=Math.min(n.outWidth,(n.inWidth+c-m)/o),b=0;b<n.inChannels;++b)for(var x=0;x<n.outChannels;++x){for(var w=0,E=0;E<n.batchSize;++E)for(var C=d;C<v;++C)for(var _=p+C*r-l,k=g;k<y;++k){var R=m+k*o-c;w+=s?f.get(E,_,R,b)*h.get(E,C,k,x):f.get(E,b,_,R)*h.get(E,x,C,k)}u.set(w,p,m,b,x)}return u.toTensor()},e.prototype.conv3dDerFilter=function(t,e,n){for(var r=n.strideDepth,o=n.strideHeight,a=n.strideWidth,i=n.filterDepth,s=n.filterHeight,u=n.filterWidth,c=Mn(n.filterShape,"float32"),l=c.values,f=c.strides,h=f[0],p=f[1],d=f[2],v=f[3],m=this.readSync(e.dataId),g=e.strides,y=g[0],b=g[1],x=g[2],w=g[3],E=this.readSync(t.dataId),C=t.strides,_=C[0],k=C[1],R=C[2],I=C[3],S=n.padInfo.front,A=n.padInfo.left,O=n.padInfo.top,T=0;T<i;++T)for(var D=Math.max(0,Math.ceil((S-T)/r)),N=Math.min(n.outDepth,(n.inDepth+S-T)/r),F=T*h,M=0;M<s;++M)for(var P=Math.max(0,Math.ceil((O-M)/o)),B=Math.min(n.outHeight,(n.inHeight+O-M)/o),L=M*p+F,W=0;W<u;++W)for(var U=Math.max(0,Math.ceil((A-W)/a)),j=Math.min(n.outWidth,(n.inWidth+A-W)/a),z=W*d+L,V=0;V<n.inChannels;++V)for(var G=V*v+z,H=0;H<n.outChannels;++H){for(var q=0,K=0;K<n.batchSize;++K)for(var X=K*_,$=K*y,Y=D;Y<N;++Y)for(var J=(T+Y*r-S)*k+X,Q=Y*b+$,Z=P;Z<B;++Z)for(var tt=(M+Z*o-O)*R+J,et=Z*x+Q,nt=U;nt<j;++nt){var rt=nt*w+et;q+=E[(W+nt*a-A)*I+tt+V]*m[rt+H]}l[G+H]=q}return c.toTensor()},e.prototype.fusedDepthwiseConv2D=function(t){var e=t.input,n=t.filter,r=t.convInfo,o=t.bias,a=t.activation,i=t.preluActivationWeights,s=this.depthwiseConv2D(e,n,r);return o&&(s=this.add(s,o)),a&&(s=El(this,s,a,i)),s},e.prototype.depthwiseConv2D=function(t,e,n){wl([t,e],"depthwiseConv2D");for(var r=n.filterHeight,o=n.filterWidth,a=n.dilationHeight,i=n.dilationWidth,s=n.padInfo.left,u=n.padInfo.top,c=n.outChannels/n.inChannels,l=Mn(n.outShape,t.dtype),f=this.readSync(t.dataId),h=this.readSync(e.dataId),p=l.values,d=0;d<n.batchSize;++d)for(var v=d*t.strides[0],m=d*l.strides[0],g=0;g<n.outHeight;++g)for(var y=m+g*l.strides[1],b=g*n.strideHeight-s,x=0;x<r;++x){var w=b+x*a;if(!(w<0||w>=n.inHeight))for(var E=x*e.strides[0],C=v+w*t.strides[1],_=0;_<n.outWidth;++_)for(var k=y+_*l.strides[2],R=_*n.strideWidth-u,I=0;I<o;++I){var S=R+I*i;if(!(S<0||S>=n.inWidth))for(var A=E+I*e.strides[1],O=C+S*n.inChannels,T=k,D=A,N=0;N<n.inChannels;++N){for(var F=f[O+N],M=0;M<c;++M)p[T+M]+=F*h[D+M];T+=c,D+=c}}}return l.toTensor()},e.prototype.depthwiseConv2DDerInput=function(t,e,n){wl([t,e],"depthwiseConv2DDerInput");for(var r=Mn(n.inShape,"float32"),o=r.values,a=r.strides,i=a[0],s=a[1],u=a[2],c=this.readSync(t.dataId),l=t.strides,f=l[0],h=l[1],p=l[2],d=this.readSync(e.dataId),v=e.strides,m=v[0],g=v[1],y=v[2],b=n.batchSize,x=n.filterHeight,w=n.filterWidth,E=n.inChannels,C=n.inHeight,_=n.inWidth,k=n.outChannels,R=n.outHeight,I=n.outWidth,S=n.strideHeight,A=n.strideWidth,O=x-1-n.padInfo.top,T=w-1-n.padInfo.left,D=k/E,N=0;N<b;++N)for(var F=0;F<E;++F)for(var M=0;M<C;++M)for(var P=M-O,B=Math.max(0,Math.ceil(P/S)),L=Math.min(R,(x+P)/S),W=0;W<_;++W){for(var U=W-T,j=Math.max(0,Math.ceil(U/A)),z=Math.min(I,(w+U)/A),V=0,G=B;G<L;++G)for(var H=G*S-P,q=j;q<z;++q)for(var K=f*N+h*G+p*q,X=m*(x-1-H)+g*(w-1-(q*A-U))+y*F,$=0;$<D;++$)V+=c[K+(F*D+$)]*d[X+$];o[i*N+s*M+u*W+F]=V}return r.toTensor()},e.prototype.depthwiseConv2DDerFilter=function(t,e,n){wl([t,e],"depthwiseConv2DDerFilter");for(var r=n.strideHeight,o=n.strideWidth,a=n.filterHeight,i=n.filterWidth,s=Mn(n.filterShape,"float32"),u=n.padInfo.left,c=n.padInfo.top,l=n.outChannels/n.inChannels,f=this.bufferSync(t),h=this.bufferSync(e),p=0;p<a;++p)for(var d=Math.max(0,Math.ceil((c-p)/r)),v=Math.min(n.outHeight,(n.inHeight+c-p)/r),m=0;m<i;++m)for(var g=Math.max(0,Math.ceil((u-m)/o)),y=Math.min(n.outWidth,(n.inWidth+u-m)/o),b=0;b<n.outChannels;++b){for(var x=Math.trunc(b/l),w=b%l,E=0,C=0;C<n.batchSize;++C)for(var _=d;_<v;++_)for(var k=p+_*r-c,R=g;R<y;++R){var I=m+R*o-u;E+=f.get(C,k,I,x)*h.get(C,_,R,b)}s.set(E,p,m,x,w)}return s.toTensor()},e.prototype.tile=function(t,e){return wl(t,"tile"),to(this.bufferSync(t),e)},e.prototype.pad=function(t,e,n){wl(t,"pad");var r=e.map((function(e,n){return e[0]+t.shape[n]+e[1]})),o=e.map((function(t){return t[0]})),a=this.bufferSync(t),i=Mn(r,t.dtype);0!==n&&i.values.fill(n);for(var s=0;s<t.size;s++){var u=a.indexToLoc(s),c=u.map((function(t,e){return t+o[e]}));i.set.apply(i,[a.get.apply(a,u)].concat(c))}return i.toTensor()},e.prototype.transpose=function(t,e){wl(t,"transpose");for(var n=new Array(t.rank),r=0;r<n.length;r++)n[r]=t.shape[e[r]];var o=this.readSync(t.dataId),a=Mn(n,t.dtype),i=this.bufferSync(t);for(r=0;r<t.size;++r){for(var s=i.indexToLoc(r),u=new Array(s.length),c=0;c<u.length;c++)u[c]=s[e[c]];var l=a.locToIndex(u);a.values[l]=o[r]}return a.toTensor()},e.prototype.gather=function(t,e,n){wl([t,e],"gather");var r=t.shape.slice(),o=this.readSync(e.dataId);r[n]=o.length;for(var a=Mn(r,t.dtype),i=this.bufferSync(t),s=0;s<a.size;++s){var u=a.indexToLoc(s),c=u.slice();c[n]=o[u[n]];var l=i.locToIndex(c);a.values[s]=i.values[l]}return a.toTensor()},e.prototype.batchToSpaceND=function(t,e,n){wl([t],"batchToSpaceND");var r=e.reduce((function(t,e){return t*e})),o=ur(t.shape,e,r),a=cr(o.length,e.length),i=lr(t.shape,e,r),s=fr(n,e.length),u=hr(i,n,e.length);return t.reshape(o).transpose(a).reshape(i).slice(s,u)},e.prototype.spaceToBatchND=function(t,e,n){wl([t],"spaceToBatchND");var r=e.reduce((function(t,e){return t*e})),o=[[0,0]];o.push.apply(o,n);for(var a=1+e.length;a<t.shape.length;++a)o.push([0,0]);var i=t.pad(o),s=ur(i.shape,e,r,!1),u=cr(s.length,e.length,!1),c=lr(i.shape,e,r,!1);return i.reshape(s).transpose(u).reshape(c)},e.prototype.pool=function(t,e,n){wl(t,"pool");for(var r=e.strideHeight,o=e.strideWidth,a=e.dilationHeight,i=e.dilationWidth,s=e.effectiveFilterHeight,u=e.effectiveFilterWidth,c=e.padInfo.top,l=e.padInfo.left,f="max"===n?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,h=this.readSync(t.dataId),p=Mn(e.outShape,t.dtype),d=p.values,v=e.outShape[1]*e.outShape[2]*e.outShape[3],m=e.outShape[2]*e.outShape[3],g=e.outShape[3],y=0;y<e.batchSize;++y)for(var b=y*v,x=y*t.strides[0],w=0;w<e.inChannels;++w)for(var E=0;E<e.outHeight;++E)for(var C=E*r-c,_=Math.max(0,C),k=Math.min(e.inHeight,s+C),R=b+E*m,I=0;I<e.outWidth;++I){for(var S=I*o-l,A=Math.max(0,S),O=Math.min(e.inWidth,u+S),T=f,D=0,N=0,F=_;F<k;F+=a){for(var M=x+F*t.strides[1],P=A;P<O;P+=i){var B=h[M+P*t.strides[2]+w];"max"===n&&B>T?T=B:"avg"===n&&(D+=B,N++)}if(isNaN(T))break}d[R+I*g+w]="avg"===n?D/N:T}return p.toTensor()},e.prototype.maxPool=function(t,e){return this.pool(t,e,"max")},e.prototype.maxPoolPositions=function(t,e){for(var n=Mn(e.outShape,"int32"),r=e.strideHeight,o=e.strideWidth,a=e.dilationHeight,i=e.dilationWidth,s=e.effectiveFilterHeight,u=e.effectiveFilterWidth,c=e.padInfo.top,l=e.padInfo.left,f=this.bufferSync(t),h=0;h<e.batchSize;++h)for(var p=0;p<e.inChannels;++p)for(var d=0;d<e.outHeight;++d){for(var v=d*r-c,m=v;m<0;)m+=a;for(var g=Math.min(e.inHeight,s+v),y=0;y<e.outWidth;++y){for(var b=y*o-l,x=b;x<0;)x+=i;for(var w=Math.min(e.inWidth,u+b),E=Number.NEGATIVE_INFINITY,C=-1,_=m;_<g;_+=a)for(var k=_-v,R=x;R<w;R+=i){var I=R-b,S=f.get(h,_,R,p);S>E&&(E=S,C=k*u+I)}n.set(C,h,d,y,p)}}return n.toTensor()},e.prototype.maxPoolBackprop=function(t,e,n,r){wl([e,n],"maxPoolBackprop");for(var o=this.maxPoolPositions(e,r),a=r.strideHeight,i=r.strideWidth,s=r.dilationHeight,u=r.dilationWidth,c=r.effectiveFilterHeight,l=r.effectiveFilterWidth,f=l-1-r.padInfo.left,h=c-1-r.padInfo.top,p=Mn(e.shape,"float32"),d=this.bufferSync(o),v=this.bufferSync(t),m=0;m<r.batchSize;++m)for(var g=0;g<r.inChannels;++g)for(var y=0;y<r.inHeight;++y)for(var b=0;b<r.inWidth;++b){for(var x=y-h,w=b-f,E=0,C=0;C<c;C+=s){var _=(x+C)/a;if(!(_<0||_>=r.outHeight||Math.floor(_)!==_))for(var k=0;k<l;k+=u){var R=(w+k)/i;if(!(R<0||R>=r.outWidth||Math.floor(R)!==R)){var I=c*l-1-d.get(m,_,R,g)===C*l+k?1:0;0!==I&&(E+=v.get(m,_,R,g)*I)}}}p.set(E,m,y,b,g)}return p.toTensor()},e.prototype.avgPoolBackprop=function(t,e,n){wl([t,e],"avgPoolBackprop");for(var r=n.strideHeight,o=n.strideWidth,a=n.filterHeight,i=n.filterWidth,s=n.dilationHeight,u=n.dilationWidth,c=n.effectiveFilterHeight,l=n.effectiveFilterWidth,f=l-1-n.padInfo.left,h=c-1-n.padInfo.top,p=Mn(e.shape,"float32"),d=1/(a*i),v=this.bufferSync(t),m=0;m<n.batchSize;++m)for(var g=0;g<n.inChannels;++g)for(var y=0;y<n.inHeight;++y)for(var b=0;b<n.inWidth;++b){for(var x=y-h,w=b-f,E=0,C=0;C<c;C+=s){var _=(x+C)/r;if(!(_<0||_>=n.outHeight||Math.floor(_)!==_))for(var k=0;k<l;k+=u){var R=(w+k)/o;R<0||R>=n.outWidth||Math.floor(R)!==R||(E+=v.get(m,_,R,g))}}p.set(E*d,m,y,b,g)}return p.toTensor()},e.prototype.pool3d=function(t,e,n){wl(t,"pool3d");for(var r=e.strideDepth,o=e.strideHeight,a=e.strideWidth,i=e.dilationDepth,s=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,l=e.effectiveFilterHeight,f=e.effectiveFilterWidth,h=e.padInfo.front,p=e.padInfo.top,d=e.padInfo.left,v="max"===n?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=this.readSync(t.dataId),g=Mn(e.outShape,t.dtype),y=g.values,b=e.outShape[1]*e.outShape[2]*e.outShape[3]*e.outShape[4],x=e.outShape[2]*e.outShape[3]*e.outShape[4],w=e.outShape[3]*e.outShape[4],E=e.outShape[4],C=0;C<e.batchSize;++C)for(var _=C*b,k=C*t.strides[0],R=0;R<e.inChannels;++R)for(var I=0;I<e.outDepth;++I){for(var S=I*r-h,A=S;A<0;)A+=i;for(var O=Math.min(e.inDepth,c+S),T=_+I*x,D=0;D<e.outHeight;++D){for(var N=D*o-p,F=N;F<0;)F+=s;for(var M=Math.min(e.inHeight,l+N),P=T+D*w,B=0;B<e.outWidth;++B){for(var L=B*a-d,W=L;W<0;)W+=u;for(var U=Math.min(e.inWidth,f+L),j=P+B*E,z=v,V=0,G=0,H=A;H<O;H+=i){for(var q=k+H*t.strides[1],K=F;K<M;K+=s){for(var X=q+K*t.strides[2],$=W;$<U;$+=u){var Y=m[X+$*t.strides[3]+R];if("max"===n&&Y>z?z=Y:"avg"===n&&(V+=Y,G++),isNaN(z))break}if(isNaN(z))break}if(isNaN(z))break}y[j+R]="avg"===n?V/G:z}}}return g.toTensor()},e.prototype.avgPool3d=function(t,e){return wl(t,"avgPool3d"),this.pool3d(t,e,"avg").toFloat()},e.prototype.avgPool3dBackprop=function(t,e,n){wl([t,e],"avgPool3dBackprop");for(var r=n.strideDepth,o=n.strideHeight,a=n.strideWidth,i=n.filterDepth,s=n.filterHeight,u=n.filterWidth,c=n.dilationDepth,l=n.dilationHeight,f=n.dilationWidth,h=n.effectiveFilterDepth,p=n.effectiveFilterHeight,d=n.effectiveFilterWidth,v=h-1-n.padInfo.front,m=d-1-n.padInfo.left,g=p-1-n.padInfo.top,y=Mn(e.shape,"float32"),b=1/(i*s*u),x=this.bufferSync(t),w=0;w<n.batchSize;++w)for(var E=0;E<n.inChannels;++E)for(var C=0;C<n.inDepth;++C)for(var _=0;_<n.inHeight;++_)for(var k=0;k<n.inWidth;++k){for(var R=C-v,I=_-g,S=k-m,A=0,O=0;O<h;O+=c){var T=(R+O)/r;if(!(T<0||T>=n.outDepth||Math.floor(T)!==T))for(var D=0;D<p;D+=l){var N=(I+D)/o;if(!(N<0||N>=n.outHeight||Math.floor(N)!==N))for(var F=0;F<d;F+=f){var M=(S+F)/a;M<0||M>=n.outWidth||Math.floor(M)!==M||(A+=x.get(w,T,N,M,E))}}}y.set(A*b,w,C,_,k,E)}return y.toTensor()},e.prototype.maxPool3d=function(t,e){return wl(t,"maxPool3d"),this.pool3d(t,e,"max").toFloat()},e.prototype.maxPool3dPositions=function(t,e){for(var n=Mn(e.outShape,"int32"),r=e.strideDepth,o=e.strideHeight,a=e.strideWidth,i=e.dilationDepth,s=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,l=e.effectiveFilterHeight,f=e.effectiveFilterWidth,h=e.padInfo.front,p=e.padInfo.top,d=e.padInfo.left,v=this.bufferSync(t),m=0;m<e.batchSize;++m)for(var g=0;g<e.inChannels;++g)for(var y=0;y<e.outDepth;++y){for(var b=y*r-h,x=b;x<0;)x+=i;for(var w=Math.min(e.inDepth,c+b),E=0;E<e.outHeight;++E){for(var C=E*o-p,_=C;_<0;)_+=s;for(var k=Math.min(e.inHeight,l+C),R=0;R<e.outWidth;++R){for(var I=R*a-d,S=I;S<0;)S+=u;for(var A=Math.min(e.inWidth,f+I),O=Number.NEGATIVE_INFINITY,T=-1,D=x;D<w;D+=i)for(var N=D-b,F=_;F<k;F+=s)for(var M=F-C,P=S;P<A;P+=u){var B=P-I,L=v.get(m,D,F,P,g);L>=O&&(O=L,T=N*l*f+M*l+B)}n.set(T,m,y,E,R,g)}}}return n.toTensor()},e.prototype.maxPool3dBackprop=function(t,e,n,r){wl([e,n],"maxPool3dBackprop");for(var o=this.maxPool3dPositions(e,r),a=r.strideDepth,i=r.strideHeight,s=r.strideWidth,u=r.dilationDepth,c=r.dilationHeight,l=r.dilationWidth,f=r.effectiveFilterDepth,h=r.effectiveFilterHeight,p=r.effectiveFilterWidth,d=f-1-r.padInfo.front,v=p-1-r.padInfo.left,m=h-1-r.padInfo.top,g=Mn(e.shape,"float32"),y=this.bufferSync(o),b=this.bufferSync(t),x=0;x<r.batchSize;++x)for(var w=0;w<r.inChannels;++w)for(var E=0;E<r.inDepth;++E)for(var C=0;C<r.inHeight;++C)for(var _=0;_<r.inWidth;++_){for(var k=E-d,R=C-m,I=_-v,S=0,A=0;A<f;A+=u){var O=(k+A)/a;if(!(O<0||O>=r.outDepth||Math.floor(O)!==O))for(var T=0;T<h;T+=c){var D=(R+T)/i;if(!(D<0||D>=r.outHeight||Math.floor(D)!==D))for(var N=0;N<p;N+=l){var F=(I+N)/s;if(!(F<0||F>=r.outWidth||Math.floor(F)!==F)){var M=f*h*p-1-y.get(x,O,D,F,w)===A*h*p+T*p+N?1:0;0!==M&&(S+=b.get(x,O,D,F,w)*M)}}}}g.set(S,x,E,C,_,w)}return g.toTensor()},e.prototype.cast=function(t,e){return Gr(t,e,this)},e.prototype.reshape=function(t,e){return Hr(t,e)},e.prototype.avgPool=function(t,e){return wl(t,"avgPool"),this.pool(t,e,"avg").toFloat()},e.prototype.resizeBilinear=function(t,e,n,r){wl(t,"resizeBilinear");for(var o=t.shape,a=o[0],i=o[1],s=o[2],u=o[3],c=this.readSync(t.dataId),l=new Float32Array(R([a,e,n,u])),f=[r&&e>1?i-1:i,r&&n>1?s-1:s],h=[r&&e>1?e-1:e,r&&n>1?n-1:n],p=0,d=f[0]/h[0],v=f[1]/h[1],m=0;m<a;m++)for(var g=0;g<e;g++)for(var y=d*g,b=Math.floor(y),x=y-b,w=Math.min(i-1,Math.ceil(y)),E=m*t.strides[0]+b*t.strides[1],C=m*t.strides[0]+w*t.strides[1],_=0;_<n;_++)for(var k=v*_,I=Math.floor(k),S=k-I,A=Math.min(s-1,Math.ceil(k)),O=E+I*t.strides[2],T=C+I*t.strides[2],D=E+A*t.strides[2],N=C+A*t.strides[2],F=0;F<u;F++){var M=c[O+F],P=c[T+F],B=M+(c[D+F]-M)*S,L=B+(P+(c[N+F]-P)*S-B)*x;l[p++]=L}return rn(l,[a,e,n,u])},e.prototype.resizeBilinearBackprop=function(t,e,n){wl([t,e],"resizeBilinearBackprop");for(var r=e.shape,o=r[0],a=r[1],i=r[2],s=r[3],u=t.shape,c=u[1],l=u[2],f=new Float32Array(o*a*i*s),h=[n&&c>1?a-1:a,n&&l>1?i-1:i],p=[n&&c>1?c-1:c,n&&l>1?l-1:l],d=h[0]/p[0],v=h[1]/p[1],m=this.readSync(t.dataId),g=0,y=0;y<o;y++)for(var b=y*e.strides[0],x=0;x<c;x++)for(var w=x*d,E=Math.floor(w),C=Math.min(Math.ceil(w),a-1),_=b+E*e.strides[1],k=b+C*e.strides[1],R=w-E,I=1-R,S=0;S<l;S++)for(var A=S*v,O=Math.floor(A),T=Math.min(Math.ceil(A),i-1),D=A-O,N=1-D,F=_+O*e.strides[2],M=_+T*e.strides[2],P=k+O*e.strides[2],B=k+T*e.strides[2],L=I*N,W=I*D,U=R*N,j=R*D,z=0;z<s;z++){var V=m[g++];f[F+z]+=V*L,f[M+z]+=V*W,f[P+z]+=V*U,f[B+z]+=V*j}return ln(f,[o,i,a,s],e.dtype)},e.prototype.resizeNearestNeighbor=function(t,e,n,r){wl(t,"resizeNearestNeighbor");for(var o=t.shape,a=o[0],i=o[1],s=o[2],u=o[3],c=this.readSync(t.dataId),l=new Float32Array(a*e*n*u),f=[r&&e>1?i-1:i,r&&n>1?s-1:s],h=[r&&e>1?e-1:e,r&&n>1?n-1:n],p=f[0]/h[0],d=f[1]/h[1],v=0,m=0;m<a;m++)for(var g=m*t.strides[0],y=0;y<e;y++)for(var b=p*y,x=g+Math.min(i-1,r?Math.round(b):Math.floor(b))*t.strides[1],w=0;w<n;w++)for(var E=d*w,C=x+Math.min(s-1,r?Math.round(E):Math.floor(E))*t.strides[2],_=0;_<u;_++){var k=c[C+_];l[v++]=k}return rn(l,[a,e,n,u],t.dtype)},e.prototype.resizeNearestNeighborBackprop=function(t,e,n){wl([t,e],"resizeNearestNeighborBackprop");for(var r=e.shape,o=r[0],a=r[1],i=r[2],s=r[3],u=t.shape,c=u[1],l=u[2],f=new Float32Array(o*a*i*s),h=this.readSync(t.dataId),p=[n&&c>1?a-1:a,n&&l>1?i-1:i],d=[n&&c>1?c-1:c,n&&l>1?l-1:l],v=p[0]/d[0],m=p[1]/d[1],g=1/v,y=1/m,b=2*Math.ceil(g)+2,x=2*Math.ceil(y)+2,w=0;w<o;w++)for(var E=w*e.strides[0],C=0;C<a;C++)for(var _=E+C*e.strides[1],k=Math.floor(C*g),R=Math.floor(k-b/2),I=0;I<i;I++)for(var S=_+I*e.strides[2],A=Math.floor(I*y),O=Math.floor(A-x/2),T=0;T<s;T++){for(var D=0,N=0;N<b;N++){var F=N+R;if(!(F<0||F>=c)){var M=E+F*t.strides[1],P=F*v;if(C===Math.min(a-1,n?Math.round(P):Math.floor(P)))for(var B=0;B<x;B++){var L=B+O;if(!(L<0||L>=l)){var W=M+L*t.strides[2],U=L*m;I===Math.min(i-1,n?Math.round(U):Math.floor(U))&&(D+=h[W+T])}}}}f[S+T]=D}return ln(f,e.shape,e.dtype)},e.prototype.batchNormalization=function(t,e,n,r,o,a){wl([t,e,n,o,a],"batchNorm");for(var i=this.readSync(t.dataId),s=this.readSync(e.dataId),u=this.readSync(n.dataId),c=o?this.readSync(o.dataId):new Float32Array([1]),l=a?this.readSync(a.dataId):new Float32Array([0]),f=new Float32Array(i.length),h=l.length,p=c.length,d=u.length,v=s.length,m=0,g=0,y=0,b=0,x=0;x<i.length;++x)f[x]=l[m++]+(i[x]-s[g++])*c[y++]/Math.sqrt(u[b++]+r),m>=h&&(m=0),g>=v&&(g=0),y>=p&&(y=0),b>=d&&(b=0);return ln(f,t.shape)},e.prototype.localResponseNormalization4D=function(t,e,n,r,o){wl(t,"localResponseNormalization4D");var a=t.shape[3],i=a-1,s=this.readSync(t.dataId),u=t.size,c=new Float32Array(u);function l(t){for(var n=t%a,r=t-n+Math.max(0,n-e),o=t-n+Math.min(n+e,i),u=0;r<=o;r++){var c=s[r];u+=c*c}return u}for(var f=0;f<u;f++){var h=l(f),p=s[f]*Math.pow(n+r*h,-o);c[f]=p}return ln(c,t.shape)},e.prototype.LRNGrad=function(t,e,n,r,o,a,i){wl(t,"LRNGrad");for(var s=t.shape[3],u=this.readSync(t.dataId),c=this.readSync(e.dataId),l=this.readSync(n.dataId),f=new Float32Array(t.size),h=t.size,p=0;p<h;p++){for(var d=p%s,v=p-d+Math.max(0,d-r),m=p-d+Math.min(s,d+r+1),g=0,y=v;y<m;y++)g+=Math.pow(c[y],2);for(g=a*g+o,y=v;y<m;y++){var b=-2*a*i*c[y]*l[p]/g;p===y&&(b+=Math.pow(g,-i)),b*=u[p],f[y]+=b}}return ln(f,t.shape)},e.prototype.multinomial=function(t,e,n,r){wl(t,"multinomial");for(var o=e?t:_r(t),a=o.shape[0],i=o.shape[1],s=hn([a,n],"int32"),u=this.readSync(s.dataId),c=this.readSync(o.dataId),l=0;l<a;++l){var f=l*i,h=new Float32Array(i-1);h[0]=c[f];for(var p=1;p<h.length;++p)h[p]=h[p-1]+c[f+p];for(var d=Tn(r.toString()),v=l*n,m=0;m<n;++m){var g=d();u[v+m]=h.length;for(var y=0;y<h.length;y++)if(g<h[y]){u[v+m]=y;break}}}return s},e.prototype.oneHot=function(t,e,n,r){wl(t,"oneHot");var o=new Float32Array(t.size*e);o.fill(r);for(var a=this.readSync(t.dataId),i=0;i<t.size;++i)a[i]>=0&&a[i]<e&&(o[i*e+a[i]]=n);return un(o,[t.size,e],"int32")},e.prototype.nonMaxSuppression=function(t,e,n,r,o){return wl(t,"nonMaxSuppression"),Jr(this.readSync(t.dataId),this.readSync(e.dataId),n,r,o)},e.prototype.fft=function(t){return this.fftBatch(t,!1)},e.prototype.ifft=function(t){return this.fftBatch(t,!0)},e.prototype.fftBatch=function(t,e){for(var n=t.shape[0],r=t.shape[1],o=Mn(t.shape,"float32"),a=Mn(t.shape,"float32"),i=en(t).as2D(n,r),s=nn(t).as2D(n,r),u=0;u<n;u++)for(var c=i.slice([u,0],[1,r]),l=s.slice([u,0],[1,r]),f=tn(c,l),h=this.readSync(this.fftImpl(f,e).dataId),p=0;p<r;p++){var d=Xr(h,p);o.values[u*r+p]=d.real,a.values[u*r+p]=d.imag}return tn(o.toTensor(),a.toTensor()).as2D(n,r)},e.prototype.fftImpl=function(t,e){var n=t.as1D(),r=n.size;if(this.isExponentOf2(r)){var o=this.fftRadix2(n,r,e).as2D(t.shape[0],t.shape[1]);return e&&(o=tn(en(o).div(an(r)),nn(o).div(an(r)))),o}var a=this.readSync(t.dataId),i=function(t){for(var e=new Float32Array(t.length/2),n=new Float32Array(t.length/2),r=0;r<t.length;r+=2)e[r/2]=t[r],n[r/2]=t[r+1];return{real:e,imag:n}}(this.fourierTransformByMatmul(a,r,e));return tn(i.real,i.imag).as2D(t.shape[0],t.shape[1])},e.prototype.isExponentOf2=function(t){return 0==(t&t-1)},e.prototype.fftRadix2=function(t,e,n){if(1===e)return t;var r=this.readSync(t.dataId),o=e/2,a=function(t){for(var e=Math.ceil(t.length/4),n=new Float32Array(e),r=new Float32Array(e),o=0;o<t.length;o+=4)n[Math.floor(o/4)]=t[o],r[Math.floor(o/4)]=t[o+1];return{real:n,imag:r}}(r),i=tn(a.real,a.imag).as1D(),s=function(t){for(var e=Math.floor(t.length/4),n=new Float32Array(e),r=new Float32Array(e),o=2;o<t.length;o+=4)n[Math.floor(o/4)]=t[o],r[Math.floor(o/4)]=t[o+1];return{real:n,imag:r}}(r),u=tn(s.real,s.imag).as1D();i=this.fftRadix2(i,o,n),u=this.fftRadix2(u,o,n);var c=function(t,e){for(var n=new Float32Array(t/2),r=new Float32Array(t/2),o=0;o<Math.ceil(t/2);o++){var a=(e?2:-2)*Math.PI*(o/t);n[o]=Math.cos(a),r[o]=Math.sin(a)}return{real:n,imag:r}}(e,n),l=tn(c.real,c.imag).mul(u),f=i.add(l),h=i.sub(l),p=en(f).concat(en(h)),d=nn(f).concat(nn(h));return tn(p,d).as1D()},e.prototype.fourierTransformByMatmul=function(t,e,n){for(var r=new Float32Array(2*e),o=0;o<e;o++){for(var a=0,i=0,s=0;s<e;s++){var u=Yr(o*s,e,n),c=Xr(t,s);a+=c.real*u.real-c.imag*u.imag,i+=c.real*u.imag+c.imag*u.real}n&&(a/=e,i/=e),$r(r,a,i,o)}return r},e.prototype.depthToSpace=function(t,e,n){E("NHWC"===n,(function(){return"Only NHWC dataFormat supported on CPU for depthToSpace. Got "+n})),E(e>1,(function(){return"blockSize should be > 1 for depthToSpace, but was: "+e}));for(var r=t.shape[0],o=t.shape[1],a=t.shape[2],i=t.shape[3],s=o*e,u=a*e,c=i/(e*e),l=this.readSync(t.dataId),f=new Float32Array(r*s*u*c),h=0,p=0;p<r;++p)for(var d=0;d<s;++d)for(var v=Math.floor(d/e),m=d%e,g=0;g<u;++g)for(var y=Math.floor(g/e),b=(m*e+g%e)*c,x=0;x<c;++x){var w=x+b+i*(y+a*(v+o*p));f[h++]=l[w]}return ln(f,[r,s,u,c])},e.prototype.broadcastedBinaryOp=function(t,e,n,r){var o=Tr(t.shape,e.shape),a=Mn(o,n),i=this.readSync(t.dataId),s=this.readSync(e.dataId),u=Ar(t.shape,o),c=Ar(e.shape,o),l=a.values;if(u.length+c.length===0)for(var f=0;f<l.length;++f)l[f]=r(i[f%i.length],s[f%s.length]);else{var h=this.bufferSync(t),p=this.bufferSync(e),d=function(n){var o=a.indexToLoc(n),f=o.slice(-t.rank);u.forEach((function(t){return f[t]=0}));var d=h.locToIndex(f),v=o.slice(-e.rank);c.forEach((function(t){return v[t]=0}));var m=p.locToIndex(v);l[n]=r(i[d],s[m])};for(f=0;f<l.length;++f)d(f)}return a.toTensor()},e.prototype.broadcastedBinaryComplexOp=function(t,e,n){var r=Tr(t.shape,e.shape),o=Mn(r,"float32"),a=Mn(r,"float32"),i=this.readSync(t.dataId),s=this.readSync(e.dataId),u=Ar(t.shape,r),c=Ar(e.shape,r),l=o.values,f=a.values;if(u.length+c.length===0)for(var h=0;h<l.length;h++){var p=h%i.length,d=h%s.length,v=n(i[2*p],i[2*p+1],s[2*d],s[2*d+1]);l[h]=v.real,f[h]=v.imag}else{var m=this.bufferSync(this.data.get(t.dataId).complexTensors.real),g=this.bufferSync(this.data.get(e.dataId).complexTensors.real),y=function(r){var a=o.indexToLoc(r),h=a.slice(-t.rank);u.forEach((function(t){return h[t]=0}));var p=m.locToIndex(h),d=a.slice(-e.rank);c.forEach((function(t){return d[t]=0}));var v=g.locToIndex(d),y=n(i[2*p],i[2*p+1],s[2*v],s[2*v+1]);l[r]=y.real,f[r]=y.imag};for(h=0;h<l.length;h++)y(h)}return this.complex(o.toTensor(),a.toTensor())},e.prototype.split=function(t,e,n){return Zr(t,e,n)},e.prototype.dispose=function(){},e.prototype.floatPrecision=function(){return 32},e.prototype.epsilon=function(){return 1e-7},e.prototype.cropAndResize=function(t,e,n,r,o,a){for(var i=t.shape,s=i[0],u=i[1],c=i[2],l=i[3],f=e.shape[0],h=r[0],p=r[1],d=Mn([f,h,p,l],"float32"),v=this.readSync(e.dataId),m=this.readSync(n.dataId),g=this.readSync(t.dataId),y=t.strides,b=d.strides,x=0;x<f;x++){var w=4*x,E=v[w],C=v[w+1],_=v[w+2],k=v[w+3],R=m[x];if(!(R>=s))for(var I=h>1?(_-E)*(u-1)/(h-1):0,S=p>1?(k-C)*(c-1)/(p-1):0,A=0;A<h;A++){var O=h>1?E*(u-1)+A*I:.5*(E+_)*(u-1);if(O<0||O>u-1)for(var T=0;T<p;T++)for(var D=0;D<l;D++){var N=D+T*b[2]+A*b[1]+x*b[0];d.values[N]=a}else if("bilinear"===o){var F=Math.floor(O),M=Math.ceil(O),P=O-F;for(T=0;T<p;T++)if((H=p>1?C*(c-1)+T*S:.5*(C+k)*(c-1))<0||H>c-1)for(D=0;D<l;D++)N=D+T*b[2]+A*b[1]+x*b[0],d.values[N]=a;else{var B=Math.floor(H),L=Math.ceil(H),W=H-B;for(D=0;D<l;D++){var U=g[N=D+B*y[2]+F*y[1]+R*y[0]],j=g[N=D+L*y[2]+F*y[1]+R*y[0]],z=g[N=D+B*y[2]+M*y[1]+R*y[0]],V=U+(j-U)*W,G=z+(g[N=D+L*y[2]+M*y[1]+R*y[0]]-z)*W;N=D+T*b[2]+A*b[1]+x*b[0],d.values[N]=V+(G-V)*P}}}else for(T=0;T<p;++T){var H;if((H=p>1?C*(c-1)+T*S:.5*(C+k)*(c-1))<0||H>c-1)for(D=0;D<l;D++)N=D+T*b[2]+A*b[1]+x*b[0],d.values[N]=a;else{var q=Math.round(H),K=Math.round(O);for(D=0;D<l;D++){var X=D+q*y[2]+K*y[1]+R*y[0],$=D+T*b[2]+A*b[1]+x*b[0];d.values[$]=g[X]}}}}}return d.toTensor()},e.prototype.sparseToDense=function(t,e,n,r){var o=vr(0,t,n),a=o.sliceRank,i=o.numUpdates,s=o.sliceSize,u=o.strides,c=o.outputSize;return this.scatter(t,e,n,c,s,i,a,u,r,!1)},e.prototype.gatherND=function(t,e){var n=e.shape,r=n[n.length-1],o=pr(t,e),a=o[0],i=o[1],s=o[2],u=o[3];if(0===i)return rn([],a,t.dtype);for(var c=new lt([i,s],t.dtype),l=this.readSync(e.dataId),f=this.readSync(t.dataId),h=0;h<i;h++){for(var p=[],d=0,v=0;v<r;v++){var m=l[h*r+v];d+=m*u[v],p.push(m)}if(d<0||d>=t.size/s)throw new Error("Invalid indices: "+p+" does not index into "+t.shape);for(var g=0;g<s;g++)c.values[h*s+g]=f[d*s+g]}return c.toTensor().reshape(a)},e.prototype.scatterND=function(t,e,n){var r=vr(0,t,n),o=r.sliceRank,a=r.numUpdates,i=r.sliceSize,s=r.strides,u=r.outputSize,c=an(0);return this.scatter(t,e,n,u,i,a,o,s,c,!0)},e.prototype.fill=function(t,e,n){var r=B(n=n||K(e),R(t));return r.fill(e),Ot.makeTensor(r,t,n,this)},e.prototype.onesLike=function(t){if("string"===t.dtype)throw new Error("onesLike is not supported for string tensors");return this.fill(t.shape,1,t.dtype)},e.prototype.zerosLike=function(t){var e=B(t.dtype,R(t.shape));return this.makeOutput(e,t.shape,t.dtype)},e.prototype.linspace=function(t,e,n){return qr(t,e,n)},e.prototype.scatter=function(t,e,n,r,o,a,i,s,u,c){var l=[r/o,o],f=this.readSync(t.dataId),h=this.readSync(e.dataId);if(0===r)return rn([],n,e.dtype);var p=new lt(l,e.dtype);p.values.fill(this.readSync(u.dataId)[0]);for(var d=0;d<a;d++){for(var v=[],m=0,g=0;g<i;g++){var y=f[d*i+g];v.push(y),m+=y*s[g]}if(m<0||m>=r/o)throw new Error("Invalid indices: "+v+" does not index into "+n);for(var b=0;b<o;b++)c?p.values[m*o+b]+=h[d*o+b]:p.values[m*o+b]=0===e.rank?h[0]:h[d*o+b]}return p.toTensor().reshape(n)},e}(Ir);Ot.registerBackend("cpu",(function(){return new Cl}),1),m({kernelName:"Square",backendName:"cpu",kernelFunc:function(t){var e=t.inputs,n=t.backend,r=e.x,o=n;wl(r,"square");for(var a=o.data.get(r.dataId).values,i=new Float32Array(a.length),s=0;s<a.length;++s){var u=a[s];i[s]=u*u}return{dataId:o.write(i,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}}),m({kernelName:"Square",backendName:"webgl",kernelFunc:function(t){var e=t.inputs,n=t.backend,r=e.x,o=n,a=new gi(r.shape,"return x * x;");return o.runWebGLProgram(a,[r],r.dtype)}});var _l,kl=function(t){this.variableNames=["A"];var e=uo(),n=t[0],r=t[1];this.outputShape=t,this.userCode="\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+r+".0, "+n+".0);\n\n vec4 values = "+e.texture2D+"(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n setOutput(floor(value * 255.0 + 0.5));\n }\n "},Rl=function(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var e=uo(),n=t[0],r=t[1];this.outputShape=t,this.userCode="\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n\n vec4 result = vec4(0.);\n\n for(int row=0; row<=1; row++) {\n for(int col=0; col<=1; col++) {\n texC = coords[1] + row;\n depth = coords[2] + col;\n\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+r+".0, "+n+".0);\n vec4 values = "+e.texture2D+"(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n result[row * 2 + col] = floor(value * 255.0 + 0.5);\n }\n }\n\n "+e.output+" = result;\n }\n "};m({kernelName:"FromPixels",backendName:"webgl",kernelFunc:function(t){var e=t.inputs,n=t.backend,r=t.attrs,o=e.pixels,a=r.numChannels,i="undefined"!=typeof HTMLVideoElement&&o instanceof HTMLVideoElement,s="undefined"!=typeof HTMLImageElement&&o instanceof HTMLImageElement,u=i?[o.videoWidth,o.videoHeight]:[o.width,o.height],c=u[0],l=u[1],h=[l,c],p=[l,c,a];(s||i)&&(null==_l&&(_l=document.createElement("canvas").getContext("2d")),_l.canvas.width=c,_l.canvas.height=l,_l.drawImage(o,0,0,c,l),o=_l.canvas);var d=n.makeTensorInfo(h,"int32");n.texData.get(d.dataId).usage=Ft.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(d.dataId),o);var v=f().getBool("WEBGL_PACK")?new Rl(p):new kl(p),m=n.runWebGLProgram(v,[d],"int32");return n.disposeData(d.dataId),m}});var Il=function(){function t(){}return t.prototype.fetch=function(t,e){return fetch(t,e)},t.prototype.now=function(){return performance.now()},t.prototype.encode=function(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error("Browser's encoder only supports utf-8, but got "+e);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(t)},t.prototype.decode=function(t,e){return new TextDecoder(e).decode(t)},t}();f().get("IS_BROWSER")&&f().setPlatform("browser",new Il);var Sl,Al=function(){function t(){this.util=n(71),this.textEncoder=new this.util.TextEncoder}return t.prototype.fetch=function(t,e){return null!=f().global.fetch?f().global.fetch(t,e):(null==Sl&&(Sl=n(70)),Sl(t,e))},t.prototype.now=function(){var t=r.hrtime();return 1e3*t[0]+t[1]/1e6},t.prototype.encode=function(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error("Node built-in encoder only supports utf-8, but got "+e);return this.textEncoder.encode(t)},t.prototype.decode=function(t,e){return 0===t.length?"":new this.util.TextDecoder(e).decode(t)},t}();f().get("IS_NODE")&&f().setPlatform("node",new Al);var Ol={float32:4,int32:4,uint16:2,uint8:1,bool:1};function Tl(t,e){for(var n={},r=0,o=function(e){var o=e.name,a=e.dtype,i=e.shape,s=R(i),u=void 0;if("quantization"in e){var c=e.quantization;if("uint8"!==c.dtype&&"uint16"!==c.dtype)throw new Error("Weight "+e.name+" has unknown quantization dtype "+c.dtype+". Supported quantization dtypes are: 'uint8' and 'uint16'.");var l=Ol[c.dtype],f=t.slice(r,r+s*l),h="uint8"===c.dtype?new Uint8Array(f):new Uint16Array(f);if("float32"===a)u=Float32Array.from(h,(function(t){return t*c.scale+c.min}));else{if("int32"!==a)throw new Error("Unsupported dtype in weight '"+o+"': "+a);u=Int32Array.from(h,(function(t){return Math.round(t*c.scale+c.min)}))}r+=s*l}else if("string"===a){var p=R(e.shape);u=[];for(var d=0;d<p;d++){var v=new Uint32Array(t.slice(r,r+4))[0];r+=4;var m=new Uint8Array(t.slice(r,r+v));u.push(m),r+=v}}else{var g=Ol[a];if(f=t.slice(r,r+s*g),"float32"===a)u=new Float32Array(f);else if("int32"===a)u=new Int32Array(f);else{if("bool"!==a)throw new Error("Unsupported dtype in weight '"+o+"': "+a);u=new Uint8Array(f)}r+=s*g}n[o]=rn(u,i,a)},a=0,i=e;a<i.length;a++)o(i[a]);return n}function Dl(t){if(null===t)throw new Error("Invalid input value: "+JSON.stringify(t));var e=0,n=[];t.forEach((function(t){if(e+=t.byteLength,n.push(t.byteLength===t.buffer.byteLength?t:new t.constructor(t)),!(t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array))throw new Error("Unsupported TypedArray subtype: "+t.constructor.name)}));var r=new Uint8Array(e),o=0;return n.forEach((function(t){r.set(new Uint8Array(t.buffer),o),o+=t.byteLength})),r.buffer}var Nl=void 0!==o&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function Fl(t){return Nl?o.byteLength(t):new Blob([t]).size}function Ml(t){var e=0;t.forEach((function(t){e+=t.byteLength}));var n=new Uint8Array(e),r=0;return t.forEach((function(t){n.set(new Uint8Array(t),r),r+=t.byteLength})),n.buffer}function Pl(t){for(t=t.trim();t.endsWith("/");)t=t.slice(0,t.length-1);var e=t.split("/");return e[e.length-1]}function Bl(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==t.modelTopology?0:Fl(JSON.stringify(t.modelTopology)),weightSpecsBytes:null==t.weightSpecs?0:Fl(JSON.stringify(t.weightSpecs)),weightDataBytes:null==t.weightData?0:t.weightData.byteLength}}var Ll=function(){function t(){this.saveRouters=[],this.loadRouters=[]}return t.getInstance=function(){return null==t.instance&&(t.instance=new t),t.instance},t.registerSaveRouter=function(e){t.getInstance().saveRouters.push(e)},t.registerLoadRouter=function(e){t.getInstance().loadRouters.push(e)},t.getSaveHandlers=function(e){return t.getHandlers(e,"save")},t.getLoadHandlers=function(e,n){return t.getHandlers(e,"load",n)},t.getHandlers=function(e,n,r){var o=[];return("load"===n?t.getInstance().loadRouters:t.getInstance().saveRouters).forEach((function(t){var n=t(e,r);null!==n&&o.push(n)})),o},t}(),Wl="://",Ul=function(){function t(){this.managers={}}return t.getInstance=function(){return null==t.instance&&(t.instance=new t),t.instance},t.registerManager=function(e,n){E(null!=e,(function(){return"scheme must not be undefined or null."})),e.endsWith(Wl)&&(e=e.slice(0,e.indexOf(Wl))),E(e.length>0,(function(){return"scheme must not be an empty string."}));var r=t.getInstance();E(null==r.managers[e],(function(){return"A model store manager is already registered for scheme '"+e+"'."})),r.managers[e]=n},t.getManager=function(t){var e=this.getInstance().managers[t];if(null==e)throw new Error("Cannot find model manager for scheme '"+t+"'");return e},t.getSchemes=function(){return Object.keys(this.getInstance().managers)},t}();function jl(t){if(-1===t.indexOf(Wl))throw new Error("The url string provided does not contain a scheme. Supported schemes are: "+Ul.getSchemes().join(","));return{scheme:t.split(Wl)[0],path:t.split(Wl)[1]}}function zl(t,e,n){return void 0===n&&(n=!1),u(this,void 0,void 0,(function(){var r,o,a,i,s,u,l,f,h;return c(this,(function(c){switch(c.label){case 0:return E(t!==e,(function(){return"Old path and new path are the same: '"+t+"'"})),E((r=Ll.getLoadHandlers(t)).length>0,(function(){return"Copying failed because no load handler is found for source URL "+t+"."})),E(r.length<2,(function(){return"Copying failed because more than one ("+r.length+") load handlers for source URL "+t+"."})),o=r[0],E((a=Ll.getSaveHandlers(e)).length>0,(function(){return"Copying failed because no save handler is found for destination URL "+e+"."})),E(a.length<2,(function(){return"Copying failed because more than one ("+r.length+") save handlers for destination URL "+e+"."})),i=a[0],s=jl(t).scheme,u=jl(t).path,l=s===jl(t).scheme,[4,o.load()];case 1:return f=c.sent(),n&&l?[4,Ul.getManager(s).removeModel(u)]:[3,3];case 2:c.sent(),c.label=3;case 3:return[4,i.save(f)];case 4:return h=c.sent(),!n||l?[3,6]:[4,Ul.getManager(s).removeModel(u)];case 5:c.sent(),c.label=6;case 6:return[2,h.modelArtifactsInfo]}}))}))}var Vl="models_store",Gl="model_info_store";function Hl(){if(!f().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");var t=window,e=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB||t.shimIndexedDB;if(null==e)throw new Error("The current browser does not appear to support IndexedDB.");return e}function ql(t){var e=t.result;e.createObjectStore(Vl,{keyPath:"modelPath"}),e.createObjectStore(Gl,{keyPath:"modelPath"})}var Kl=function(){function t(t){if(this.indexedDB=Hl(),null==t||!t)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=t}return t.prototype.save=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return[2,this.databaseAction(this.modelPath,t)]}))}))},t.prototype.load=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this.databaseAction(this.modelPath)]}))}))},t.prototype.databaseAction=function(t,e){var n=this;return new Promise((function(t,r){var o=n.indexedDB.open("tensorflowjs",1);o.onupgradeneeded=function(){return ql(o)},o.onsuccess=function(){var a=o.result;if(null==e){var i=a.transaction(Vl,"readonly"),s=i.objectStore(Vl).get(n.modelPath);s.onsuccess=function(){if(null==s.result)return a.close(),r(new Error("Cannot find model with path '"+n.modelPath+"' in IndexedDB."));t(s.result.modelArtifacts)},s.onerror=function(t){return a.close(),r(s.error)},i.oncomplete=function(){return a.close()}}else{var u,c=Bl(e),l=a.transaction(Gl,"readwrite"),f=l.objectStore(Gl),h=f.put({modelPath:n.modelPath,modelArtifactsInfo:c});h.onsuccess=function(){var o=(u=a.transaction(Vl,"readwrite")).objectStore(Vl).put({modelPath:n.modelPath,modelArtifacts:e,modelArtifactsInfo:c});o.onsuccess=function(){return t({modelArtifactsInfo:c})},o.onerror=function(t){var e=(f=l.objectStore(Gl)).delete(n.modelPath);e.onsuccess=function(){return a.close(),r(o.error)},e.onerror=function(t){return a.close(),r(o.error)}}},h.onerror=function(t){return a.close(),r(h.error)},l.oncomplete=function(){null==u?a.close():u.oncomplete=function(){return a.close()}}}},o.onerror=function(t){return r(o.error)}}))},t.URL_SCHEME="indexeddb://",t}(),Xl=function(t){return f().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(Kl.URL_SCHEME)?(e=t.slice(Kl.URL_SCHEME.length),new Kl(e)):null;var e};Ll.registerSaveRouter(Xl),Ll.registerLoadRouter(Xl);var $l=function(){function t(){this.indexedDB=Hl()}return t.prototype.listModels=function(){return u(this,void 0,void 0,(function(){var t=this;return c(this,(function(e){return[2,new Promise((function(e,n){var r=t.indexedDB.open("tensorflowjs",1);r.onupgradeneeded=function(){return ql(r)},r.onsuccess=function(){var t=r.result,o=t.transaction(Gl,"readonly"),a=o.objectStore(Gl).getAll();a.onsuccess=function(){for(var t={},n=0,r=a.result;n<r.length;n++){var o=r[n];t[o.modelPath]=o.modelArtifactsInfo}e(t)},a.onerror=function(e){return t.close(),n(a.error)},o.oncomplete=function(){return t.close()}},r.onerror=function(t){return n(r.error)}}))]}))}))},t.prototype.removeModel=function(t){return u(this,void 0,void 0,(function(){var e=this;return c(this,(function(n){var r;return t=(r=t).startsWith(Kl.URL_SCHEME)?r.slice(Kl.URL_SCHEME.length):r,[2,new Promise((function(n,r){var o=e.indexedDB.open("tensorflowjs",1);o.onupgradeneeded=function(){return ql(o)},o.onsuccess=function(){var e,a=o.result,i=a.transaction(Gl,"readwrite"),s=i.objectStore(Gl),u=s.get(t);u.onsuccess=function(){if(null==u.result)return a.close(),r(new Error("Cannot find model with path '"+t+"' in IndexedDB."));var o=s.delete(t),i=function(){var o=(e=a.transaction(Vl,"readwrite")).objectStore(Vl).delete(t);o.onsuccess=function(){return n(u.result.modelArtifactsInfo)},o.onerror=function(t){return r(u.error)}};o.onsuccess=i,o.onerror=function(t){return i(),a.close(),r(u.error)}},u.onerror=function(t){return a.close(),r(u.error)},i.oncomplete=function(){null==e?a.close():e.oncomplete=function(){return a.close()}}},o.onerror=function(t){return r(o.error)}}))]}))}))},t}();if(f().getBool("IS_BROWSER"))try{Ul.registerManager(Kl.URL_SCHEME,new $l)}catch(i){}var Yl="/",Jl="tensorflowjs_models",Ql="info",Zl="model_topology",tf="weight_specs",ef="weight_data",nf="model_metadata";function rf(t){return{info:[Jl,t,Ql].join(Yl),topology:[Jl,t,Zl].join(Yl),weightSpecs:[Jl,t,tf].join(Yl),weightData:[Jl,t,ef].join(Yl),modelMetadata:[Jl,t,nf].join(Yl)}}function of(t){var e=t.split(Yl);if(e.length<3)throw new Error("Invalid key format: "+t);return e.slice(1,e.length-1).join(Yl)}var af=function(){function t(t){if(!f().getBool("IS_BROWSER")||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==t||!t)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=t,this.keys=rf(this.modelPath)}return t.prototype.save=function(t){return u(this,void 0,void 0,(function(){var e,n,r;return c(this,(function(a){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");e=JSON.stringify(t.modelTopology),n=JSON.stringify(t.weightSpecs),r=Bl(t);try{return this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,e),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,(i=t.weightData,Nl?o.from(i).toString("base64"):btoa(String.fromCharCode.apply(null,new Uint8Array(i))))),this.LS.setItem(this.keys.modelMetadata,JSON.stringify({format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,userDefinedMetadata:t.userDefinedMetadata})),[2,{modelArtifactsInfo:r}]}catch(t){throw this.LS.removeItem(this.keys.info),this.LS.removeItem(this.keys.topology),this.LS.removeItem(this.keys.weightSpecs),this.LS.removeItem(this.keys.weightData),this.LS.removeItem(this.keys.modelMetadata),new Error("Failed to save model '"+this.modelPath+"' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes="+r.modelTopologyBytes+", weightSpecsBytes="+r.weightSpecsBytes+", weightDataBytes="+r.weightDataBytes+".")}var i;return[2]}))}))},t.prototype.load=function(){return u(this,void 0,void 0,(function(){var t,e,n,r,a,i,s;return c(this,(function(u){if(null==(t=JSON.parse(this.LS.getItem(this.keys.info))))throw new Error("In local storage, there is no model with name '"+this.modelPath+"'");if("JSON"!==t.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");if(e={},null==(n=JSON.parse(this.LS.getItem(this.keys.topology))))throw new Error("In local storage, the topology of model '"+this.modelPath+"' is missing.");if(e.modelTopology=n,null==(r=JSON.parse(this.LS.getItem(this.keys.weightSpecs))))throw new Error("In local storage, the weight specs of model '"+this.modelPath+"' are missing.");if(e.weightSpecs=r,null!=(a=this.LS.getItem(this.keys.modelMetadata))&&(i=JSON.parse(a),e.format=i.format,e.generatedBy=i.generatedBy,e.convertedBy=i.convertedBy,e.userDefinedMetadata=i.userDefinedMetadata),null==(s=this.LS.getItem(this.keys.weightData)))throw new Error("In local storage, the binary weight values of model '"+this.modelPath+"' are missing.");return e.weightData=function(t){if(Nl){var e=o.from(t,"base64");return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}for(var n=atob(t),r=new Uint8Array(n.length),a=0;a<n.length;++a)r.set([n.charCodeAt(a)],a);return r.buffer}(s),[2,e]}))}))},t.URL_SCHEME="localstorage://",t}(),sf=function(t){return f().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(af.URL_SCHEME)?(e=t.slice(af.URL_SCHEME.length),new af(e)):null;var e};Ll.registerSaveRouter(sf),Ll.registerLoadRouter(sf);var uf=function(){function t(){E(f().getBool("IS_BROWSER"),(function(){return"Current environment is not a web browser"})),E(void 0!==window.localStorage,(function(){return"Current browser does not appear to support localStorage"})),this.LS=window.localStorage}return t.prototype.listModels=function(){return u(this,void 0,void 0,(function(){var t,e,n,r,o,a;return c(this,(function(i){for(t={},e=Jl+Yl,n=Yl+Ql,r=0;r<this.LS.length;++r)(o=this.LS.key(r)).startsWith(e)&&o.endsWith(n)&&(a=of(o),t[a]=JSON.parse(this.LS.getItem(o)));return[2,t]}))}))},t.prototype.removeModel=function(t){return u(this,void 0,void 0,(function(){var e,n;return c(this,(function(r){var o;if(t=(o=t).startsWith(af.URL_SCHEME)?o.slice(af.URL_SCHEME.length):o,e=rf(t),null==this.LS.getItem(e.info))throw new Error("Cannot find model at path '"+t+"'");return n=JSON.parse(this.LS.getItem(e.info)),this.LS.removeItem(e.info),this.LS.removeItem(e.topology),this.LS.removeItem(e.weightSpecs),this.LS.removeItem(e.weightData),[2,n]}))}))},t}();if(f().getBool("IS_BROWSER"))try{Ul.registerManager(af.URL_SCHEME,new uf)}catch(i){}function cf(t){return new Promise((function(t){return setTimeout(t)})).then(t)}var lf=function(){function t(e){if(!f().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(t.URL_SCHEME)&&(e=e.slice(t.URL_SCHEME.length)),null!=e&&0!==e.length||(e="model"),this.modelTopologyFileName=e+".json",this.weightDataFileName=e+".weights.bin"}return t.prototype.save=function(t){return u(this,void 0,void 0,(function(){var e,n,r,o,a,i;return c(this,(function(s){switch(s.label){case 0:if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");if(e=window.URL.createObjectURL(new Blob([t.weightData],{type:"application/octet-stream"})),!(t.modelTopology instanceof ArrayBuffer))return[3,1];throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");case 1:return n=[{paths:["./"+this.weightDataFileName],weights:t.weightSpecs}],r={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,weightsManifest:n},o=window.URL.createObjectURL(new Blob([JSON.stringify(r)],{type:"application/json"})),(a=null==this.jsonAnchor?document.createElement("a"):this.jsonAnchor).download=this.modelTopologyFileName,a.href=o,[4,cf((function(){return a.dispatchEvent(new MouseEvent("click"))}))];case 2:return s.sent(),null==t.weightData?[3,4]:((i=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor).download=this.weightDataFileName,i.href=e,[4,cf((function(){return i.dispatchEvent(new MouseEvent("click"))}))]);case 3:s.sent(),s.label=4;case 4:return[2,{modelArtifactsInfo:Bl(t)}]}}))}))},t.URL_SCHEME="downloads://",t}(),ff=function(){function t(t){if(null==t||t.length<1)throw new Error("When calling browserFiles, at least 1 file is required, but received "+t);this.files=t}return t.prototype.load=function(){return u(this,void 0,void 0,(function(){var t,e,n=this;return c(this,(function(r){return t=this.files[0],e=this.files.slice(1),[2,new Promise((function(r,o){var a=new FileReader;a.onload=function(a){var i=JSON.parse(a.target.result),s=i.modelTopology;if(null!=s){0===e.length&&r({modelTopology:s});var u=i.weightsManifest;if(null!=u){var c;try{c=n.checkManifestAndWeightFiles(u,e)}catch(t){return void o(t)}var l=[],f=[],h=[];u.forEach((function(t){t.paths.forEach((function(t){f.push(t),h.push(null)})),l.push.apply(l,t.weights)})),u.forEach((function(t){t.paths.forEach((function(t){var e=new FileReader;e.onload=function(e){var n=e.target.result,o=f.indexOf(t);h[o]=n,-1===h.indexOf(null)&&r({modelTopology:s,weightSpecs:l,weightData:Ml(h),format:i.format,generatedBy:i.generatedBy,convertedBy:i.convertedBy,userDefinedMetadata:i.userDefinedMetadata})},e.onerror=function(e){return o("Failed to weights data from file of path '"+t+"'.")},e.readAsArrayBuffer(c[t])}))}))}else o(new Error("weightManifest field is missing from file "+t.name))}else o(new Error("modelTopology field is missing from file "+t.name))},a.onerror=function(e){return o("Failed to read model topology and weights manifest JSON from file '"+t.name+"'. BrowserFiles supports loading Keras-style tf.Model artifacts only.")},a.readAsText(t)}))]}))}))},t.prototype.checkManifestAndWeightFiles=function(t,e){for(var n=[],r=e.map((function(t){return Pl(t.name)})),o={},a=0,i=t;a<i.length;a++)i[a].paths.forEach((function(t){var a=Pl(t);if(-1!==n.indexOf(a))throw new Error("Duplicate file basename found in weights manifest: '"+a+"'");if(n.push(a),-1===r.indexOf(a))throw new Error("Weight file with basename '"+a+"' is not provided.");o[t]=e[r.indexOf(a)]}));if(n.length!==e.length)throw new Error("Mismatch in the number of files in weights manifest ("+n.length+") and the number of weight files provided ("+e.length+").");return o},t}();function hf(t,e,n,r){!function(t){E(null!=t&&Array.isArray(t)&&t.length>0,(function(){return"promises must be a none empty array"}))}(t),function(t,e){E(t>=0&&t<=1,(function(){return"Progress fraction must be in range [0, 1], but got startFraction "+t})),E(e>=0&&e<=1,(function(){return"Progress fraction must be in range [0, 1], but got endFraction "+e})),E(e>=t,(function(){return"startFraction must be no more than endFraction, but got startFraction "+t+" and endFraction "+e}))}(n=null==n?0:n,r=null==r?1:r);var o=0;return Promise.all(t.map((function(a){return a.then((function(a){var i=n+ ++o/t.length*(r-n);return e(i),a})),a})))}function pf(t,e){return u(this,void 0,void 0,(function(){var n,r,o,a,i,s,u,l,h;return c(this,(function(c){switch(c.label){case 0:return null==e&&(e={}),n=null==e.fetchFunc?f().platform.fetch:e.fetchFunc,r=t.map((function(t){return n(t,e.requestInit,{isBinary:!0})})),o=0,a=.5,null!=e.onProgress?[3,2]:[4,Promise.all(r)];case 1:return i=c.sent(),[3,4];case 2:return[4,hf(r,e.onProgress,o,a)];case 3:i=c.sent(),c.label=4;case 4:return s=i.map((function(t){return t.arrayBuffer()})),u=.5,l=1,null!=e.onProgress?[3,6]:[4,Promise.all(s)];case 5:return h=c.sent(),[3,8];case 6:return[4,hf(s,e.onProgress,u,l)];case 7:h=c.sent(),c.label=8;case 8:return[2,h]}}))}))}function df(t){var e=this;return function(n,r,o){return void 0===r&&(r=""),u(e,void 0,void 0,(function(){var e,a,i,s,u,l,f,h,p,d;return c(this,(function(c){switch(c.label){case 0:if(e=n.map((function(){return!1})),a={},i=null!=o?o.map((function(){return!1})):[],s=[],n.forEach((function(t,n){var r=0;t.weights.forEach((function(t){var u="quantization"in t?t.quantization.dtype:t.dtype,c=Ol[u]*R(t.shape),l=function(){e[n]=!0,null==a[n]&&(a[n]=[]),a[n].push({manifestEntry:t,groupOffset:r,sizeBytes:c})};null!=o?o.forEach((function(e,n){e===t.name&&(l(),i[n]=!0)})):l(),s.push(t.name),r+=c}))})),!i.every((function(t){return t})))throw u=o.filter((function(t,e){return!i[e]})),new Error("Could not find weights in manifest with names: "+u.join(", ")+". \nManifest JSON has weights with names: "+s.join(", ")+".");return l=e.reduce((function(t,e,n){return e&&t.push(n),t}),[]),f=[],l.forEach((function(t){n[t].paths.forEach((function(t){var e=r+(r.endsWith("/")?"":"/")+t;f.push(e)}))})),[4,t(f)];case 1:return h=c.sent(),p={},d=0,l.forEach((function(t){for(var e=n[t].paths.length,r=0,o=0;o<e;o++)r+=h[d+o].byteLength;for(var i=new ArrayBuffer(r),s=new Uint8Array(i),u=0,c=0;c<e;c++){var l=new Uint8Array(h[d+c]);s.set(l,u),u+=l.byteLength}a[t].forEach((function(t){var e=Tl(i.slice(t.groupOffset,t.groupOffset+t.sizeBytes),[t.manifestEntry]);for(var n in e)p[n]=e[n]})),d+=e})),[2,p]}}))}))}}Ll.registerSaveRouter((function(t){return f().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(lf.URL_SCHEME)?(void 0===(e=t.slice(lf.URL_SCHEME.length))&&(e="model"),new lf(e)):null;var e}));var vf=function(){function t(t,e){if(this.DEFAULT_METHOD="POST",null==e&&(e={}),this.weightPathPrefix=e.weightPathPrefix,this.onProgress=e.onProgress,null!=e.fetchFunc?(E("function"==typeof e.fetchFunc,(function(){return"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"})),this.fetch=e.fetchFunc):this.fetch=f().platform.fetch,E(null!=t&&t.length>0,(function(){return"URL path for http must not be null, undefined or empty."})),Array.isArray(t)&&E(2===t.length,(function(){return"URL paths for http must have a length of 2, (actual length is "+t.length+")."})),this.path=t,null!=e.requestInit&&null!=e.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=e.requestInit||{}}return t.prototype.save=function(t){return u(this,void 0,void 0,(function(){var e,n,r,o;return c(this,(function(a){switch(a.label){case 0:if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");return(e=Object.assign({method:this.DEFAULT_METHOD},this.requestInit)).body=new FormData,n=[{paths:["./model.weights.bin"],weights:t.weightSpecs}],r={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,userDefinedMetadata:t.userDefinedMetadata,weightsManifest:n},e.body.append("model.json",new Blob([JSON.stringify(r)],{type:"application/json"}),"model.json"),null!=t.weightData&&e.body.append("model.weights.bin",new Blob([t.weightData],{type:"application/octet-stream"}),"model.weights.bin"),[4,this.fetch(this.path,e)];case 1:if((o=a.sent()).ok)return[2,{modelArtifactsInfo:Bl(t),responses:[o]}];throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+o.status+".")}}))}))},t.prototype.load=function(){return u(this,void 0,void 0,(function(){var t,e,n,r,o,a,i,s,u,l,f,h;return c(this,(function(c){switch(c.label){case 0:return[4,this.fetch(this.path,this.requestInit)];case 1:if(!(t=c.sent()).ok)throw new Error("Request to "+this.path+" failed with status code "+t.status+". Please verify this URL points to the model JSON of the model to load.");c.label=2;case 2:return c.trys.push([2,4,,5]),[4,t.json()];case 3:return e=c.sent(),[3,5];case 4:throw c.sent(),n="Failed to parse model JSON of response from "+this.path+".",this.path.endsWith(".pb")?n+=" 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.":n+=" Please make sure the server is serving valid JSON for this request.",new Error(n);case 5:if(r=e.modelTopology,o=e.weightsManifest,a=e.generatedBy,i=e.convertedBy,s=e.format,u=e.userDefinedMetadata,null==r&&null==o)throw new Error("The JSON from HTTP path "+this.path+" contains neither model topology or manifest for weights.");return null==o?[3,7]:[4,this.loadWeights(o)];case 6:h=c.sent(),l=h[0],f=h[1],c.label=7;case 7:return[2,{modelTopology:r,weightSpecs:l,weightData:f,userDefinedMetadata:u,generatedBy:a,convertedBy:i,format:s}]}}))}))},t.prototype.loadWeights=function(t){return u(this,void 0,void 0,(function(){var e,n,r,o,a,i,s,u,l,f,h;return c(this,(function(c){switch(c.label){case 0:for(e=Array.isArray(this.path)?this.path[1]:this.path,n=function(t){var e=t.lastIndexOf("/"),n=t.lastIndexOf("?");return[t.substring(0,e)+"/",n>e?t.substring(n):""]}(e),r=n[0],o=n[1],a=this.weightPathPrefix||r,i=[],s=0,u=t;s<u.length;s++)l=u[s],i.push.apply(i,l.weights);return f=[],t.forEach((function(t){t.paths.forEach((function(t){f.push(a+t+o)}))})),[4,pf(f,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress})];case 1:return h=c.sent(),[2,[i,Ml(h)]]}}))}))},t.URL_SCHEME_REGEX=/^https?:\/\//,t}();function mf(t){return null!=t.match(vf.URL_SCHEME_REGEX)}var gf=function(t,e){return"undefined"==typeof fetch?null:(Array.isArray(t)?t.every((function(t){return mf(t)})):mf(t))?yf(t,{onProgress:e}):null};function yf(t,e){return new vf(t,e)}Ll.registerSaveRouter(gf),Ll.registerLoadRouter(gf);var bf,xf=function(){function t(t){this.modelArtifacts=t}return t.prototype.load=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this.modelArtifacts]}))}))},t}(),wf=function(){function t(t){this.saveHandler=t}return t.prototype.save=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this.saveHandler(t)]}))}))},t}(),Ef=Object.freeze({browserFiles:function(t){return new ff(t)},browserHTTPRequest:function(t,e){return yf(t,e)},concatenateArrayBuffers:Ml,decodeWeights:Tl,encodeWeights:function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,a,i,s=this;return c(this,(function(l){switch(l.label){case 0:for(n=[],r=[],o=Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t),a=function(a){var i=o[a],l=Array.isArray(t)?t[a].tensor:t[i];if("float32"!==l.dtype&&"int32"!==l.dtype&&"bool"!==l.dtype&&"string"!==l.dtype)throw new Error("Unsupported dtype in weight '"+i+"': "+l.dtype);var f={name:i,shape:l.shape,dtype:l.dtype};if("string"===l.dtype){var h=new Promise((function(t){return u(s,void 0,void 0,(function(){var e,n,r,o,a,i,s;return c(this,(function(u){switch(u.label){case 0:return[4,l.bytes()];case 1:for(e=u.sent(),n=e.reduce((function(t,e){return t+e.length}),0)+4*e.length,r=new Uint8Array(n),o=0,a=0;a<e.length;a++)i=e[a],s=new Uint8Array(new Uint32Array([i.length]).buffer),r.set(s,o),o+=4,r.set(i,o),o+=i.length;return t(r),[2]}}))}))}));r.push(h)}else r.push(l.data());null!=e&&(f.group=e),n.push(f)},i=0;i<o.length;++i)a(i);return[4,Promise.all(r)];case 1:return[2,{data:Dl(l.sent()),specs:n}]}}))}))},fromMemory:function(t,e,n,r){return 1===arguments.length?null!=t.modelTopology||null!=t.weightSpecs?new xf(t):new xf({modelTopology:t}):new xf({modelTopology:t,weightSpecs:e,weightData:n,trainingConfig:r})},getLoadHandlers:function(t,e){return Ll.getLoadHandlers(t,e)},getModelArtifactsInfoForJSON:Bl,getSaveHandlers:function(t){return Ll.getSaveHandlers(t)},http:yf,isHTTPScheme:mf,loadWeights:function(t,e,n,r){return void 0===e&&(e=""),u(this,void 0,void 0,(function(){return c(this,(function(o){return[2,df((function(t){return pf(t,{requestInit:r})}))(t,e,n)]}))}))},registerLoadRouter:function(t){return Ll.registerLoadRouter(t)},registerSaveRouter:function(t){return Ll.registerSaveRouter(t)},weightsLoaderFactory:df,withSaveHandler:function(t){return new wf(t)},copyModel:function(t,e){return u(this,void 0,void 0,(function(){return c(this,(function(n){return[2,zl(t,e,!1)]}))}))},listModels:function(){return u(this,void 0,void 0,(function(){var t,e,n,r,o,a,i;return c(this,(function(s){switch(s.label){case 0:t=Ul.getSchemes(),e={},n=0,r=t,s.label=1;case 1:return n<r.length?(o=r[n],[4,Ul.getManager(o).listModels()]):[3,4];case 2:for(i in a=s.sent())e[o+Wl+i]=a[i];s.label=3;case 3:return n++,[3,1];case 4:return[2,e]}}))}))},moveModel:function(t,e){return u(this,void 0,void 0,(function(){return c(this,(function(n){return[2,zl(t,e,!0)]}))}))},removeModel:function(t){return u(this,void 0,void 0,(function(){var e;return c(this,(function(n){return e=jl(t),[2,Ul.getManager(e.scheme).removeModel(e.path)]}))}))}}),Cf=Ze({confusionMatrix_:function(t,e,n){var r=je(t,"labels","confusionMatrix"),o=je(e,"predictions","confusionMatrix");E(null==n||n>0&&Number.isInteger(n),(function(){return"If provided, numClasses must be a positive integer, but got "+n})),E(1===r.rank,(function(){return"Expected the rank of labels to be 1, but got "+r.rank})),E(1===o.rank,(function(){return"Expected the rank of predictions to be 1, but got "+o.rank})),E(r.shape[0]===o.shape[0],(function(){return"Mismatch in the number of examples: "+r.shape[0]+" vs. "+o.shape[0]+". Labels and predictions should have the same number of elements."})),E(n>0&&Number.isInteger(n),(function(){return"numClasses is required to be a positive integer, but got "+n}));var a=Hn(r.asType("int32"),n),i=Hn(o.asType("int32"),n);return a.transpose().matMul(i).asType("int32")}}),_f=(Object.freeze({confusionMatrix:Cf}),Ze({fromPixels_:function(t,e){if(void 0===e&&(e=3),e>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==t)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");var n=!1,r=!1,o=!1,a=!1,i=!1;if(t.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&t instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement)o=!0;else if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement)a=!0;else{if(null==t.getContext)throw new Error("pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was "+t.constructor.name);i=!0}if(o&&o&&t.readyState<2)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element.");if(null!=d("FromPixels",Ot.backendName))return Ot.runKernel("FromPixels",{pixels:t},{numChannels:e});var s,u,c=o?[t.videoWidth,t.videoHeight]:[t.width,t.height],l=c[0],f=c[1];if(i?s=t.getContext("2d").getImageData(0,0,l,f).data:r||n?s=t.data:(a||o)&&(null==bf&&(bf=document.createElement("canvas").getContext("2d")),bf.canvas.width=l,bf.canvas.height=f,bf.drawImage(t,0,0,l,f),s=bf.getImageData(0,0,l,f).data),4===e)u=new Int32Array(s);else{var h=l*f;u=new Int32Array(h*e);for(var p=0;p<h;p++)for(var v=0;v<e;++v)u[p*e+v]=s[4*p+v]}return cn(u,[f,l,e],"int32")}})),kf=Object.freeze({toPixels:function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,a,i,s,u,l,f,h,p,d,v,m,g,y,b,x,w,E,C,_,k;return c(this,(function(c){switch(c.label){case 0:if(n=je(t,"img","toPixels"),t instanceof dt||(n=n.toInt()),2!==n.rank&&3!==n.rank)throw new Error("toPixels only supports rank 2 or 3 tensors, got rank "+n.rank+".");if(r=n.shape.slice(0,2),o=r[0],a=r[1],(i=2===n.rank?1:n.shape[2])>4||2===i)throw new Error("toPixels only supports depth of size 1, 3 or 4 but got "+i);return[4,n.data()];case 1:return s=c.sent(),u=n.min(),l=n.max(),[4,Promise.all([u.data(),l.data()])];case 2:if(f=c.sent(),h=f[0],p=f[1],d=h[0],v=p[0],u.dispose(),l.dispose(),"float32"===n.dtype){if(d<0||v>1)throw new Error("Tensor values for a float32 Tensor must be in the range [0 - 1] but got range ["+d+" - "+v+"].")}else{if("int32"!==n.dtype)throw new Error("Unsupported type for toPixels: "+n.dtype+". Please use float32 or int32 tensors.");if(d<0||v>255)throw new Error("Tensor values for a int32 Tensor must be in the range [0 - 255] but got range ["+d+" - "+v+"].")}for(m="float32"===n.dtype?255:1,g=new Uint8ClampedArray(a*o*4),y=0;y<o*a;++y)b=void 0,x=void 0,w=void 0,E=void 0,1===i?(b=s[y]*m,x=s[y]*m,w=s[y]*m,E=255):3===i?(b=s[3*y]*m,x=s[3*y+1]*m,w=s[3*y+2]*m,E=255):4===i&&(b=s[4*y]*m,x=s[4*y+1]*m,w=s[4*y+2]*m,E=s[4*y+3]*m),g[0+(C=4*y)]=Math.round(b),g[C+1]=Math.round(x),g[C+2]=Math.round(w),g[C+3]=Math.round(E);return null!=e&&(e.width=a,e.height=o,_=e.getContext("2d"),k=new ImageData(g,a,o),_.putImageData(k,0,0)),n!==t&&n.dispose(),[2,g]}}))}))},fromPixels:_f}),Rf=function(){function t(){}return t.prototype.getClassName=function(){return this.constructor.className},t.fromConfig=function(t,e){return new t(e)},t}(),If=function(){function t(){this.classNameMap={}}return t.getMap=function(){return null==t.instance&&(t.instance=new t),t.instance},t.register=function(e){t.getMap().classNameMap[e.className]=[e,e.fromConfig]},t}();function Sf(t){E(null!=t.className,(function(){return"Class being registered does not have the static className property defined."})),E("string"==typeof t.className,(function(){return"className is required to be a string, but got type "+typeof t.className})),E(t.className.length>0,(function(){return"Class being registered has an empty-string as its className, which is disallowed."})),If.register(t)}Object.freeze({Serializable:Rf,SerializationMap:If,registerClass:Sf});function Af(){return 32===Ot.backend.floatPrecision()?.001:.1}function Of(t,e,n){var r=!0;if((j(t)||j(e))&&(r=!1),j(t)&&j(e)&&(r=!0),r){var o=t.constructor.name,a=e.constructor.name;if(o!==a)throw new Error("Arrays are of different type. Actual: "+o+". Expected: "+a)}if(Array.isArray(t)&&Array.isArray(e)){var i=We(t),s=We(e);if(!I(i,s))throw new Error("Arrays have different shapes. Actual: ["+i+"]. Expected: ["+s+"]")}var u=j(t)?t:k(t),c=j(e)?e:k(e);if(u.length!==c.length)throw new Error("Arrays have different lengths actual: "+u.length+" vs expected: "+c.length+".\nActual: "+u+".\nExpected: "+c+".");for(var l=0;l<c.length;++l){var f=u[l],h=c[l];if(!n(f,h))throw new Error("Arrays differ: actual["+l+"] = "+f+", expected["+l+"] = "+h+".\nActual: "+u+".\nExpected: "+c+".")}}function Tf(t,e,n){return!isFinite(t)&&!isFinite(e)||!(isNaN(t)||isNaN(e)||Math.abs(t-e)>n)}Object.freeze({TEST_EPSILON_FLOAT16:.1,expectArraysClose:function(t,e,n){return null==n&&(n=Af()),Of(t,e,(function(t,e){return Tf(t,e,n)}))},testEpsilon:Af,expectPromiseToFail:function(t,e){t().then((function(){return e.fail()}),(function(){return e()}))},expectArraysEqual:function(t,e){var n="string"==typeof e||"number"==typeof e||"boolean"==typeof e?[e]:e;return G(t)||G(t[0])||G(e)||G(e[0])?Of(t,n,(function(t,e){return t==e})):Of(t,e,(function(t,e){return Tf(t,e,0)}))},expectNumbersClose:function(t,e,n){if(null==n&&(n=Af()),!Tf(t,e,n))throw new Error("Numbers differ: actual === "+t+", expected === "+e)},expectValuesInRange:function(t,e,n){for(var r=0;r<t.length;r++)if(t[r]<e||t[r]>n)throw new Error("Value out of range:"+t[r]+" low: "+e+", high: "+n)},expectArrayBuffersEqual:function(t,e){expect(new Float32Array(t)).toEqual(new Float32Array(e))}}),Object.freeze({gpgpu_util:Oa,webgl_util:Ne,forceHalfFloat:function(){f().set("WEBGL_FORCE_F16_TEXTURES",!0)},MathBackendWebGL:Pi,setWebGLContext:Lt,GPGPUContext:Ta});var Df=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.minimize=function(t,e,n){void 0===e&&(e=!1);var r=this.computeGradients(t,n),o=r.value,a=r.grads;if(null!=n){var i=n.map((function(t){return{name:t.name,tensor:a[t.name]}}));this.applyGradients(i)}else this.applyGradients(a);return Be(a),e?o:(o.dispose(),null)},Object.defineProperty(e.prototype,"iterations",{get:function(){return null==this.iterations_&&(this.iterations_=0),this.iterations_},enumerable:!0,configurable:!0}),e.prototype.incrementIterations=function(){this.iterations_=this.iterations+1},e.prototype.computeGradients=function(t,e){return function(t,e){E(X(t),(function(){return"The f passed in variableGrads(f) must be a function"})),E(null==e||Array.isArray(e)&&e.every((function(t){return t instanceof xt})),(function(){return"The varList passed in variableGrads(f, varList) must be an array of variables"}));var n=null!=e;if(!n)for(var r in e=[],Ot.registeredVariables)e.push(Ot.registeredVariables[r]);var o=n?e.filter((function(t){return!t.trainable})):null,a=e.length;E((e=e.filter((function(t){return t.trainable}))).length>0,(function(){return"variableGrads() expects at least one of the input variables to be trainable, but none of the "+a+" variables is trainable."}));var i=Ot.gradients(t,e,null,!0),s=i.value,u=i.grads;E(u.some((function(t){return null!=t})),(function(){return"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()."})),E(0===s.rank,(function(){return"The f passed in variableGrads(f) must return a scalar, but it returned a rank-"+s.rank+" tensor"}));var c={};return e.forEach((function(t,e){null!=u[e]&&(c[t.name]=u[e])})),null!=o&&o.forEach((function(t){return c[t.name]=null})),{value:s,grads:c}}(t,e)},e.prototype.dispose=function(){null!=this.iterations_&&Be(this.iterations_)},e.prototype.saveIterations=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){return null==this.iterations_&&(this.iterations_=0),[2,{name:"iter",tensor:an(this.iterations_,"int32")}]}))}))},e.prototype.getWeights=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){throw new Error("getWeights() is not implemented for this optimizer yet.")}))}))},e.prototype.setWeights=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(t){throw new Error("setWeights() is not implemented for this optimizer class "+this.getClassName())}))}))},e.prototype.extractIterations=function(t){return u(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return e=this,[4,t[0].tensor.data()];case 1:return e.iterations_=n.sent()[0],[2,t.slice(1)]}}))}))},e}(Rf);Object.defineProperty(Df,Symbol.hasInstance,{value:function(t){return null!=t.minimize&&null!=t.computeGradients&&null!=t.applyGradients}});var Nf=function(t){function e(e,n,r){void 0===r&&(r=null);var o=t.call(this)||this;return o.learningRate=e,o.rho=n,o.epsilon=r,o.accumulatedGrads=[],o.accumulatedUpdates=[],null==r&&(o.epsilon=Ot.backend.epsilon()),o}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t)).forEach((function(n,r){var o=Ot.registeredVariables[n];null==e.accumulatedGrads[r]&&(e.accumulatedGrads[r]={originalName:n+"/accum_grad",variable:Pe((function(){return mn(o).variable(!1)}))}),null==e.accumulatedUpdates[r]&&(e.accumulatedUpdates[r]={originalName:n+"/accum_var",variable:Pe((function(){return mn(o).variable(!1)}))});var a=Array.isArray(t)?t[r].tensor:t[n];if(null!=a){var i=e.accumulatedGrads[r].variable,s=e.accumulatedUpdates[r].variable;Pe((function(){var t=i.mul(e.rho).add(a.square().mul(1-e.rho)),n=s.add(e.epsilon).sqrt().div(i.add(e.epsilon).sqrt()).mul(a),r=s.mul(e.rho).add(n.square().mul(1-e.rho));i.assign(t),s.assign(r);var u=n.mul(-e.learningRate).add(o);o.assign(u)}))}})),this.incrementIterations()},e.prototype.dispose=function(){null!=this.accumulatedUpdates&&(Be(this.accumulatedGrads.map((function(t){return t.variable}))),Be(this.accumulatedUpdates.map((function(t){return t.variable}))))},e.prototype.getWeights=function(){return u(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return t=this.accumulatedGrads.concat(this.accumulatedUpdates),[4,this.saveIterations()];case 1:return[2,[e.sent()].concat(t.map((function(t){return{name:t.originalName,tensor:t.variable}})))]}}))}))},e.prototype.setWeights=function(t){return u(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return[4,this.extractIterations(t)];case 1:return t=n.sent(),e=t.length/2,this.accumulatedGrads=t.slice(0,e).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}})),this.accumulatedUpdates=t.slice(e,2*e).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}})),[2]}}))}))},e.prototype.getConfig=function(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}},e.fromConfig=function(t,e){return new t(e.learningRate,e.rho,e.epsilon)},e.className="Adadelta",e}(Df);Sf(Nf);var Ff=function(t){function e(e,n){void 0===n&&(n=.1);var r=t.call(this)||this;return r.learningRate=e,r.initialAccumulatorValue=n,r.accumulatedGrads=[],r}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t)).forEach((function(n,r){var o=Ot.registeredVariables[n];null==e.accumulatedGrads[r]&&(e.accumulatedGrads[r]={originalName:n+"/accumulator",variable:Pe((function(){return pn(o.shape,e.initialAccumulatorValue).variable(!1)}))});var a=Array.isArray(t)?t[r].tensor:t[n];if(null!=a){var i=e.accumulatedGrads[r].variable;Pe((function(){var t=i.add(a.square());i.assign(t);var n=a.div(t.add(Ot.backend.epsilon()).sqrt()).mul(-e.learningRate).add(o);o.assign(n)}))}})),this.incrementIterations()},e.prototype.dispose=function(){null!=this.accumulatedGrads&&Be(this.accumulatedGrads.map((function(t){return t.variable})))},e.prototype.getWeights=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.saveIterations()];case 1:return[2,[t.sent()].concat(this.accumulatedGrads.map((function(t){return{name:t.originalName,tensor:t.variable}})))]}}))}))},e.prototype.setWeights=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.extractIterations(t)];case 1:return t=e.sent(),this.accumulatedGrads=t.map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}})),[2]}}))}))},e.prototype.getConfig=function(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}},e.fromConfig=function(t,e){return new t(e.learningRate,e.initialAccumulatorValue)},e.className="Adagrad",e}(Df);Sf(Ff);var Mf=function(t){function e(e,n,r,o){void 0===o&&(o=null);var a=t.call(this)||this;return a.learningRate=e,a.beta1=n,a.beta2=r,a.epsilon=o,a.accumulatedFirstMoment=[],a.accumulatedSecondMoment=[],Pe((function(){a.accBeta1=an(n).variable(),a.accBeta2=an(r).variable()})),null==o&&(a.epsilon=Ot.backend.epsilon()),a}return s(e,t),e.prototype.applyGradients=function(t){var e=this,n=Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t);Pe((function(){var r=ou(1,e.accBeta1),o=ou(1,e.accBeta2);n.forEach((function(n,a){var i=Ot.registeredVariables[n];null==e.accumulatedFirstMoment[a]&&(e.accumulatedFirstMoment[a]={originalName:n+"/m",variable:Pe((function(){return mn(i).variable(!1)}))}),null==e.accumulatedSecondMoment[a]&&(e.accumulatedSecondMoment[a]={originalName:n+"/v",variable:Pe((function(){return mn(i).variable(!1)}))});var s=Array.isArray(t)?t[a].tensor:t[n];if(null!=s){var u=e.accumulatedFirstMoment[a].variable,c=e.accumulatedSecondMoment[a].variable,l=u.mul(e.beta1).add(s.mul(1-e.beta1)),f=c.mul(e.beta2).add(s.square().mul(1-e.beta2)),h=l.div(r),p=f.div(o);u.assign(l),c.assign(f);var d=h.div(p.sqrt().add(e.epsilon)).mul(-e.learningRate).add(i);i.assign(d)}})),e.accBeta1.assign(e.accBeta1.mul(e.beta1)),e.accBeta2.assign(e.accBeta2.mul(e.beta2))})),this.incrementIterations()},e.prototype.dispose=function(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&Be(this.accumulatedFirstMoment.map((function(t){return t.variable}))),null!=this.accumulatedSecondMoment&&Be(this.accumulatedSecondMoment.map((function(t){return t.variable})))},e.prototype.getWeights=function(){return u(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return t=this.accumulatedFirstMoment.concat(this.accumulatedSecondMoment),[4,this.saveIterations()];case 1:return[2,[e.sent()].concat(t.map((function(t){return{name:t.originalName,tensor:t.variable}})))]}}))}))},e.prototype.setWeights=function(t){return u(this,void 0,void 0,(function(){var e,n=this;return c(this,(function(r){switch(r.label){case 0:return[4,this.extractIterations(t)];case 1:return t=r.sent(),Pe((function(){n.accBeta1.assign(tu(n.beta1,n.iterations_+1)),n.accBeta2.assign(tu(n.beta2,n.iterations_+1))})),e=t.length/2,this.accumulatedFirstMoment=t.slice(0,e).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}})),this.accumulatedSecondMoment=t.slice(e,2*e).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}})),[2]}}))}))},e.prototype.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}},e.fromConfig=function(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon)},e.className="Adam",e}(Df);Sf(Mf);var Pf=function(t){function e(e,n,r,o,a){void 0===o&&(o=null),void 0===a&&(a=0);var i=t.call(this)||this;return i.learningRate=e,i.beta1=n,i.beta2=r,i.epsilon=o,i.decay=a,i.accumulatedFirstMoment=[],i.accumulatedWeightedInfNorm=[],Pe((function(){i.iteration=an(0).variable(),i.accBeta1=an(n).variable()})),null==o&&(i.epsilon=Ot.backend.epsilon()),i}return s(e,t),e.prototype.applyGradients=function(t){var e=this,n=Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t);Pe((function(){var r=ou(1,e.accBeta1),o=zs(-e.learningRate,e.iteration.mul(e.decay).add(1));n.forEach((function(n,a){var i=Ot.registeredVariables[n];null==e.accumulatedFirstMoment[a]&&(e.accumulatedFirstMoment[a]={originalName:n+"/m",variable:mn(i).variable(!1)}),null==e.accumulatedWeightedInfNorm[a]&&(e.accumulatedWeightedInfNorm[a]={originalName:n+"/v",variable:mn(i).variable(!1)});var s=Array.isArray(t)?t[a].tensor:t[n];if(null!=s){var u=e.accumulatedFirstMoment[a].variable,c=e.accumulatedWeightedInfNorm[a].variable,l=u.mul(e.beta1).add(s.mul(1-e.beta1)),f=c.mul(e.beta2),h=s.abs(),p=f.maximum(h);u.assign(l),c.assign(p);var d=o.div(r).mul(l.div(p.add(e.epsilon))).add(i);i.assign(d)}})),e.iteration.assign(e.iteration.add(1)),e.accBeta1.assign(e.accBeta1.mul(e.beta1))})),this.incrementIterations()},e.prototype.dispose=function(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&Be(this.accumulatedFirstMoment.map((function(t){return t.variable}))),null!=this.accumulatedWeightedInfNorm&&Be(this.accumulatedWeightedInfNorm.map((function(t){return t.variable})))},e.prototype.getWeights=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){throw new Error("getWeights() is not implemented for Adamax yet.")}))}))},e.prototype.setWeights=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(t){throw new Error("setWeights() is not implemented for Adamax yet.")}))}))},e.prototype.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}},e.fromConfig=function(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon,e.decay)},e.className="Adamax",e}(Df);Sf(Pf);var Bf=function(t){function e(e){var n=t.call(this)||this;return n.learningRate=e,n.setLearningRate(e),n}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t)).forEach((function(n,r){var o=Array.isArray(t)?t[r].tensor:t[n];if(null!=o){var a=Ot.registeredVariables[n];Pe((function(){var t=e.c.mul(o).add(a);a.assign(t)}))}})),this.incrementIterations()},e.prototype.setLearningRate=function(t){this.learningRate=t,null!=this.c&&this.c.dispose(),this.c=function(t){return Ot.keep(t)}(an(-t))},e.prototype.dispose=function(){this.c.dispose()},e.prototype.getWeights=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.saveIterations()];case 1:return[2,[t.sent()]]}}))}))},e.prototype.setWeights=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.extractIterations(t)];case 1:if(0!==(t=e.sent()).length)throw new Error("SGD optimizer does not have settable weights.");return[2]}}))}))},e.prototype.getConfig=function(){return{learningRate:this.learningRate}},e.fromConfig=function(t,e){return new t(e.learningRate)},e.className="SGD",e}(Df);Sf(Bf);var Lf=function(t){function e(e,n,r){void 0===r&&(r=!1);var o=t.call(this,e)||this;return o.learningRate=e,o.momentum=n,o.useNesterov=r,o.accumulations=[],o.m=an(o.momentum),o}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t)).forEach((function(n,r){var o=Ot.registeredVariables[n];null==e.accumulations[r]&&(e.accumulations[r]={originalName:n+"/momentum",variable:Pe((function(){return mn(o).variable(!1)}))});var a=e.accumulations[r].variable,i=Array.isArray(t)?t[r].tensor:t[n];null!=i&&Pe((function(){var t,n=e.m.mul(a).add(i);t=e.useNesterov?e.c.mul(i.add(n.mul(e.m))).add(o):e.c.mul(n).add(o),a.assign(n),o.assign(t)}))})),this.incrementIterations()},e.prototype.dispose=function(){this.m.dispose(),null!=this.accumulations&&Be(this.accumulations.map((function(t){return t.variable})))},e.prototype.setMomentum=function(t){this.momentum=t},e.prototype.getWeights=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.saveIterations()];case 1:return[2,[t.sent()].concat(this.accumulations.map((function(t){return{name:t.originalName,tensor:t.variable}})))]}}))}))},e.prototype.setWeights=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.extractIterations(t)];case 1:return t=e.sent(),this.accumulations=t.map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}})),[2]}}))}))},e.prototype.getConfig=function(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}},e.fromConfig=function(t,e){return new t(e.learningRate,e.momentum,e.useNesterov)},e.className="Momentum",e}(Bf);Sf(Lf);var Wf=function(t){function e(e,n,r,o,a){void 0===n&&(n=.9),void 0===r&&(r=0),void 0===o&&(o=null),void 0===a&&(a=!1);var i=t.call(this)||this;return i.learningRate=e,i.decay=n,i.momentum=r,i.epsilon=o,i.accumulatedMeanSquares=[],i.accumulatedMoments=[],i.accumulatedMeanGrads=[],i.centered=a,null==o&&(i.epsilon=Ot.backend.epsilon()),i}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t)).forEach((function(n,r){var o=Ot.registeredVariables[n];null==e.accumulatedMeanSquares[r]&&(e.accumulatedMeanSquares[r]={originalName:n+"/rms",variable:Pe((function(){return mn(o).variable(!1)}))}),null==e.accumulatedMoments[r]&&(e.accumulatedMoments[r]={originalName:n+"/momentum",variable:Pe((function(){return mn(o).variable(!1)}))}),null==e.accumulatedMeanGrads[r]&&e.centered&&(e.accumulatedMeanGrads[r]={originalName:n+"/mg",variable:Pe((function(){return mn(o).variable(!1)}))});var a=Array.isArray(t)?t[r].tensor:t[n];if(null!=a){var i=e.accumulatedMeanSquares[r].variable,s=e.accumulatedMoments[r].variable;Pe((function(){var t=i.mul(e.decay).add(a.square().mul(1-e.decay));if(e.centered){var n=e.accumulatedMeanGrads[r].variable,u=n.mul(e.decay).add(a.mul(1-e.decay)),c=s.mul(e.momentum).add(a.mul(e.learningRate).div(t.sub(u.square().add(e.epsilon)).sqrt()));i.assign(t),n.assign(u),s.assign(c);var l=o.sub(c);o.assign(l)}else{var f=i.mul(e.decay).add(a.square().mul(1-e.decay));c=s.mul(e.momentum).add(a.mul(e.learningRate).div(f.add(e.epsilon).sqrt())),i.assign(f),s.assign(c),l=o.sub(c),o.assign(l)}}))}})),this.incrementIterations()},e.prototype.dispose=function(){null!=this.accumulatedMeanSquares&&Be(this.accumulatedMeanSquares.map((function(t){return t.variable}))),null!=this.accumulatedMeanGrads&&this.centered&&Be(this.accumulatedMeanGrads.map((function(t){return t.variable}))),null!=this.accumulatedMoments&&Be(this.accumulatedMoments.map((function(t){return t.variable})))},e.prototype.getWeights=function(){return u(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return t=this.accumulatedMeanSquares.concat(this.accumulatedMoments),this.centered&&t.push.apply(t,this.accumulatedMeanGrads),[4,this.saveIterations()];case 1:return[2,[e.sent()].concat(t.map((function(t){return{name:t.originalName,tensor:t.variable}})))]}}))}))},e.prototype.setWeights=function(t){return u(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return[4,this.extractIterations(t)];case 1:return t=n.sent(),e=this.centered?t.length/3:t.length/2,this.accumulatedMeanSquares=t.slice(0,e).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}})),this.accumulatedMoments=t.slice(e,2*e).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}})),this.centered&&(this.accumulatedMeanGrads=t.slice(2*e,3*e).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}}))),[2]}}))}))},e.prototype.getConfig=function(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}},e.fromConfig=function(t,e){return new t(e.learningRate,e.decay,e.momentum,e.epsilon,e.centered)},e.className="RMSProp",e}(Df);Sf(Wf);var Uf=function(){function t(){}return t.sgd=function(t){return new Bf(t)},t.momentum=function(t,e,n){return void 0===n&&(n=!1),new Lf(t,e,n)},t.rmsprop=function(t,e,n,r,o){return void 0===e&&(e=.9),void 0===n&&(n=0),void 0===r&&(r=null),void 0===o&&(o=!1),new Wf(t,e,n,r,o)},t.adam=function(t,e,n,r){return void 0===t&&(t=.001),void 0===e&&(e=.9),void 0===n&&(n=.999),void 0===r&&(r=null),new Mf(t,e,n,r)},t.adadelta=function(t,e,n){return void 0===t&&(t=.001),void 0===e&&(e=.95),void 0===n&&(n=null),new Nf(t,e,n)},t.adamax=function(t,e,n,r,o){return void 0===t&&(t=.002),void 0===e&&(e=.9),void 0===n&&(n=.999),void 0===r&&(r=null),void 0===o&&(o=0),new Pf(t,e,n,r,o)},t.adagrad=function(t,e){return void 0===e&&(e=.1),new Ff(t,e)},t}();Uf.sgd,Uf.momentum,Uf.adadelta,Uf.adagrad,Uf.rmsprop,Uf.adamax,Uf.adam,"undefined"!=typeof requestAnimationFrame&&requestAnimationFrame;ht=xl}).call(this,n(5),n(10),n(63).Buffer,n(67).setImmediate)},function(t,e,n){"use strict";n.d(e,"c",(function(){return o})),n.d(e,"a",(function(){return a})),n.d(e,"b",(function(){return i})),n.d(e,"d",(function(){return s})),n.d(e,"e",(function(){return u}));var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function o(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var a=function(){return(a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function i(t,e,n,r){return new(n||(n=Promise))((function(o,a){function i(t){try{u(r.next(t))}catch(e){a(e)}}function s(t){try{u(r.throw(t))}catch(e){a(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,s)}u((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(s){a=[6,s],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function u(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var a=arguments[e],i=0,s=a.length;i<s;i++,o++)r[o]=a[i];return r}},function(t,e){t.exports=require("react")},function(t,e,n){t.exports=n(61)()},function(t,e,n){var r=n(56),o=n(57),a=n(58),i=n(60);t.exports=function(t,e){return r(t)||o(t,e)||a(t,e)||i()},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(r){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){t.exports={container:"tUn9t5uXBW0G4uOuaTOqA",baseCounter:"_3JRt0WWENWRFRoNQBy35fI",activeCounter:"_1fIU1q1Zn5Q8C9xn0Ir-dW",inactiveCounter:"_2mwc0c5WhPOqV9wJk9VkGV",baseIcon:"_2_g_DOxWE8kqzFMzKyK37t",activeIcon:"_3mr2-PKNrqmyEJlyzqUVvx",inactiveIcon:"_1RzxXrRIq2Q9MbP1nZJdM9"}},function(t,e,n){t.exports={container:"_1BAMDen_YLcifIe4T1Qv-_",overlay:"_1e9w5ipw5j_XUcEv_CJUlO",outline:"_2W6OS2MmM9HFQCXWdJ8ASr",portraitCamera:"_2R1kfrIDlFyYzv1nDgZcTN",landscapeCamera:"TwXhRfznW400Ln2BpPUbd"}},function(t,e,n){var r;!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var t=[],e=0;e<arguments.length;e++){var r=arguments[e];if(r){var a=typeof r;if("string"===a||"number"===a)t.push(r);else if(Array.isArray(r)&&r.length){var i=o.apply(null,r);i&&t.push(i)}else if("object"===a)for(var s in r)n.call(r,s)&&r[s]&&t.push(s)}}return t.join(" ")}t.exports?(o.default=o,t.exports=o):void 0===(r=function(){return o}.apply(e,[]))||(t.exports=r)}()},function(t,e,n){"use strict";function r(t){var e="";if(!t)try{t=n(!function(){var t=new Error("Cannot find module 'fs'");throw t.code="MODULE_NOT_FOUND",t}())}catch(r){e=r.toString()}return{readFile:t?function(e){return new Promise((function(n,r){t.readFile(e,(function(t,e){return t?r(t):n(e)}))}))}:function(){throw new Error("readFile - failed to require fs in nodejs environment with error: "+e)}}}n.d(e,"a",(function(){return r}))},function(t,e){var n,r,o=t.exports={};function a(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(t){if(n===setTimeout)return setTimeout(t,0);if((n===a||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:a}catch(t){n=a}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(t){r=i}}();var u,c=[],l=!1,f=-1;function h(){l&&u&&(l=!1,u.length?c=u.concat(c):f=-1,c.length&&p())}function p(){if(!l){var t=s(h);l=!0;for(var e=c.length;e;){for(u=c,c=[];++f<e;)u&&u[f].run();f=-1,e=c.length}u=null,l=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function v(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new d(t,e)),1!==c.length||l||s(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=v,o.addListener=v,o.once=v,o.off=v,o.removeListener=v,o.removeAllListeners=v,o.emit=v,o.prependListener=v,o.prependOnceListener=v,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e,n){t.exports={container:"_3UWaUYYyQc5VbvW6HKIRHv",landscape:"_2degJvmXASrj_NvC6CXWqN"}},function(t,e,n){t.exports={button:"_1Tg9slZrrhpko8KnDP7C6X",icon:"_1Fm1wq10kVJMKVxtWwkZex"}},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return a}));var r=n(1),o=n(9);function a(){var e=t.Canvas||t.HTMLCanvasElement,n=t.Image||t.HTMLImageElement,a=t.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment")},i=Object(o.a)();return Object(r.a)({Canvas:e||function(){},CanvasRenderingContext2D:t.CanvasRenderingContext2D||function(){},Image:n||function(){},ImageData:t.ImageData||function(){},Video:t.HTMLVideoElement||function(){},createCanvasElement:function(){if(e)return new e;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},createImageElement:function(){if(n)return new n;throw new Error("createImageElement - missing Image implementation for nodejs environment")},fetch:a},i)}}).call(this,n(5))},function(t,e,n){"use strict";(function(r,o){function a(){return"object"==typeof r&&void 0!==t&&void 0!==o&&!!o.version}n.d(e,"a",(function(){return a}))}).call(this,n(5),n(10))},function(t,e,n){t.exports={cameraContainer:"_3Ums-OZ0qWebWj0SZbqYjT",moduleContainer:"IOOd58zY5WSnpJo3-6iVV"}},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},t.exports.default=t.exports,t.exports.__esModule=!0,n(e)}t.exports=n,t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){var r=n(75);t.exports=function(t,e){if(null==t)return{};var n,o,a=r(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)n=i[o],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(a[n]=t[n])}return a},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){t.exports={container:"_309CoDF8kNC59Cacci2i3u"}},function(t,e,n){t.exports={canvas:"vNKPZsVtPwMoITxtjuu9V"}},function(t,e,n){var r;r=function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="./src/react-webcam.tsx")}({"./src/react-webcam.tsx":function(t,e,n){"use strict";n.r(e);var r,o=n("react"),a=(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};function u(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)}"undefined"!=typeof window&&(void 0===navigator.mediaDevices&&(navigator.mediaDevices={}),void 0===navigator.mediaDevices.getUserMedia&&(navigator.mediaDevices.getUserMedia=function(t){var e=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return e?new Promise((function(n,r){e.call(navigator,t,n,r)})):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}));var c=function(t){function e(e){var n=t.call(this,e)||this;return n.canvas=null,n.ctx=null,n.state={hasUserMedia:!1},n}return a(e,t),e.prototype.componentDidMount=function(){var t=this.state,n=this.props;u()?(e.mountedInstances.push(this),t.hasUserMedia||e.userMediaRequested||this.requestUserMedia()):n.onUserMediaError("getUserMedia not supported")},e.prototype.componentDidUpdate=function(t){var e=this.props;if(u()){var n=JSON.stringify(t.audioConstraints)!==JSON.stringify(e.audioConstraints),r=JSON.stringify(t.videoConstraints)!==JSON.stringify(e.videoConstraints),o=t.minScreenshotWidth!==e.minScreenshotWidth,a=t.minScreenshotHeight!==e.minScreenshotHeight;(r||o||a)&&(this.canvas=null,this.ctx=null),(n||r)&&this.requestUserMedia()}else e.onUserMediaError("getUserMedia not supported")},e.prototype.componentWillUnmount=function(){var t=this.state,n=e.mountedInstances.indexOf(this);e.mountedInstances.splice(n,1),e.userMediaRequested=!1,0===e.mountedInstances.length&&t.hasUserMedia&&(this.stream&&(this.stream.getVideoTracks&&this.stream.getAudioTracks?(this.stream.getVideoTracks().map((function(t){return t.stop()})),this.stream.getAudioTracks().map((function(t){return t.stop()}))):this.stream.stop()),t.src&&window.URL.revokeObjectURL(t.src))},e.prototype.getScreenshot=function(){var t=this.state,e=this.props;if(!t.hasUserMedia)return null;var n=this.getCanvas();return n&&n.toDataURL(e.screenshotFormat,e.screenshotQuality)},e.prototype.getCanvas=function(){var t=this.state,e=this.props;if(!this.video)return null;if(!t.hasUserMedia||!this.video.videoHeight)return null;if(!this.ctx){var n=this.video.videoWidth,r=this.video.videoHeight;if(!this.props.forceScreenshotSourceSize){var o=n/r;r=(n=e.minScreenshotWidth||this.video.clientWidth)/o,e.minScreenshotHeight&&r<e.minScreenshotHeight&&(n=(r=e.minScreenshotHeight)*o)}this.canvas=document.createElement("canvas"),this.canvas.width=n,this.canvas.height=r,this.ctx=this.canvas.getContext("2d")}var a=this.ctx,i=this.canvas;return a&&i&&(e.mirrored&&(a.translate(i.width,0),a.scale(-1,1)),a.imageSmoothingEnabled=e.imageSmoothing,a.drawImage(this.video,0,0,i.width,i.height),e.mirrored&&(a.scale(-1,1),a.translate(-i.width,0))),i},e.prototype.requestUserMedia=function(){var t=this.props,n=function(n,r){var o={video:void 0===r||r};t.audio&&(o.audio=void 0===n||n),navigator.mediaDevices.getUserMedia(o).then((function(t){e.mountedInstances.forEach((function(e){return e.handleUserMedia(null,t)}))})).catch((function(t){e.mountedInstances.forEach((function(e){return e.handleUserMedia(t)}))}))};if("mediaDevices"in navigator)n(t.audioConstraints,t.videoConstraints);else{var r=function(t){return{optional:[{sourceId:t}]}},o=function(t){var e=t.deviceId;return"string"==typeof e?e:Array.isArray(e)&&e.length>0?e[0]:"object"==typeof e&&e.ideal?e.ideal:null};MediaStreamTrack.getSources((function(e){var a=null,i=null;e.forEach((function(t){"audio"===t.kind?a=t.id:"video"===t.kind&&(i=t.id)}));var s=o(t.audioConstraints);s&&(a=s);var u=o(t.videoConstraints);u&&(i=u),n(r(a),r(i))}))}e.userMediaRequested=!0},e.prototype.handleUserMedia=function(t,e){var n=this.props;if(t||!e)return this.setState({hasUserMedia:!1}),void n.onUserMediaError(t);this.stream=e;try{this.video&&(this.video.srcObject=e),this.setState({hasUserMedia:!0})}catch(r){this.setState({hasUserMedia:!0,src:window.URL.createObjectURL(e)})}n.onUserMedia()},e.prototype.render=function(){var t=this,e=this.state,n=this.props,r=n.audio,a=(n.forceScreenshotSourceSize,n.onUserMedia,n.onUserMediaError,n.screenshotFormat,n.screenshotQuality,n.minScreenshotWidth,n.minScreenshotHeight,n.audioConstraints,n.videoConstraints,n.imageSmoothing,n.mirrored),u=n.style,c=void 0===u?{}:u,l=s(n,["audio","forceScreenshotSourceSize","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored","style"]),f=a?i(i({},c),{transform:(c.transform||"")+" scaleX(-1)"}):c;return o.createElement("video",i({autoPlay:!0,src:e.src,muted:r,playsInline:!0,ref:function(e){t.video=e},style:f},l))},e.defaultProps={audio:!0,forceScreenshotSourceSize:!1,imageSmoothing:!0,mirrored:!1,onUserMedia:function(){},onUserMediaError:function(){},screenshotFormat:"image/webp",screenshotQuality:.92},e.mountedInstances=[],e.userMediaRequested=!1,e}(o.Component);e.default=c},react:function(e,n){e.exports=t}}).default},t.exports=r(n(2))},function(t,e,n){t.exports={video:"_3GqInLQ5XsRTU_HmqqchW9"}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Preparing camera...","face-scan-loading-feedback-message":"Preparing face scan...","hold-still-feedback-message":"Please hold still","image-too-bright-feedback-message":"Move away from direct light","image-too-dark-feedback-message":"Move to a brighter area","move-back-feedback-message":"Move back","move-center-feedback-message":"Place your face in the frame","move-closer-feedback-message":"Move closer","one-face-only-feedback-message":"Only one face allowed"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Příprava fotoaparátu…","face-scan-loading-feedback-message":"Příprava skenování obličeje…","hold-still-feedback-message":"Stůjte klidně","image-too-bright-feedback-message":"Posuňte se dál z přímého světla","image-too-dark-feedback-message":"Posuňte se na světlejší místo","move-back-feedback-message":"Posuňte se dál","move-center-feedback-message":"Umístěte svůj obličej do rámečku","move-closer-feedback-message":"Posuňte se blíž","one-face-only-feedback-message":"Je povolen pouze jeden obličej"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Forbereder kamera...","face-scan-loading-feedback-message":"Forbereder ansigtsscanning...","hold-still-feedback-message":"Stå stille","image-too-bright-feedback-message":"Flyt væk fra direkte lys","image-too-dark-feedback-message":"Flyt til et lysere område","move-back-feedback-message":"Flyt dig tilbage","move-center-feedback-message":"Hold dit ansigt i rammen","move-closer-feedback-message":"Flyt dig tættere på","one-face-only-feedback-message":"Kun ét ansigt er tilladt"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Kamera lädt...","face-scan-loading-feedback-message":"Gesichtsscan wird vorbereitet","hold-still-feedback-message":"Bitte still halten","image-too-bright-feedback-message":"Vermeiden Sie direkte Lichteinstrahlung","image-too-dark-feedback-message":"Wählen Sie einen helleren Ort","move-back-feedback-message":"Gehen Sie zurück","move-center-feedback-message":"Plazieren Sie Ihr Gesicht in die Mitte","move-closer-feedback-message":"Kommen Sie näher","one-face-only-feedback-message":"Nur ein Gesicht ist erlaubt"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"La cámara se está preparando...","face-scan-loading-feedback-message":"Preparando escaneado facial...","hold-still-feedback-message":"Aguanta un momento","image-too-bright-feedback-message":"Aléjate de la luz directa","image-too-dark-feedback-message":"Muévete a un área más iluminada","move-back-feedback-message":"Retírate","move-center-feedback-message":"Colócate en el centro","move-closer-feedback-message":"Acércate","one-face-only-feedback-message":"Enfócate solo a ti"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"La cámara se está preparando...","face-scan-loading-feedback-message":"Preparando escaneado facial...","hold-still-feedback-message":"Quédate quieto un momento","image-too-bright-feedback-message":"Aléjate de la luz directa","image-too-dark-feedback-message":"Muévete a un área más iluminada","move-back-feedback-message":"Aléjate","move-center-feedback-message":"Colócate en el centro","move-closer-feedback-message":"Acércate","one-face-only-feedback-message":"Enfócate solo a ti"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Valmistellaan kameraa...","face-scan-loading-feedback-message":"Valmistellaan kasvojen skannausta...","hold-still-feedback-message":"Pysy paikallasi","image-too-bright-feedback-message":"Siirry pois suorasta valosta","image-too-dark-feedback-message":"Siirry kirkkaampaan valoon","move-back-feedback-message":"Siirry taaksepäin","move-center-feedback-message":"Aseta kasvot keskelle kehystä","move-closer-feedback-message":"Siirry lähemmäksi","one-face-only-feedback-message":"Vain yhdet kasvot on sallittu"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Préparation de l'appareil...","face-scan-loading-feedback-message":"Préparation du scan...","hold-still-feedback-message":"Veuillez ne pas bouger","image-too-bright-feedback-message":"Éloignez-vous de toute source de lumière directe","image-too-dark-feedback-message":"Déplacez-vous à un endroit plus lumineux","move-back-feedback-message":"Reculez","move-center-feedback-message":"Placez votre visage dans le cadre","move-closer-feedback-message":"Approchez-vous","one-face-only-feedback-message":"Un seul visage permis"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"कैमरे को तैयार किया जा रहा है...","face-scan-loading-feedback-message":"चेहरा स्कैन करने की तैयारी हो रही है…","hold-still-feedback-message":"कृपया हिले डुले नहीं","image-too-bright-feedback-message":"सीधी रोशनी से दूर हटें","image-too-dark-feedback-message":"ज़्यादा रोशनी वाली जगह पर जाएं","move-back-feedback-message":"पीछे जाएं","move-center-feedback-message":"अपने चेहरे को फ़्रेम में लाएं","move-closer-feedback-message":"थोड़ा करीब आएँ","one-face-only-feedback-message":"सिर्फ़ एक चेहरे की अनुमति है"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Caricamento della camera...","face-scan-loading-feedback-message":"Caricamento dello scan facciale...","hold-still-feedback-message":"Rimani fermo","image-too-bright-feedback-message":"Spostati dalla luce diretta","image-too-dark-feedback-message":"Spostati in una zona più illuminata","move-back-feedback-message":"Allontanati","move-center-feedback-message":"Posiziona la tua faccia nel riquadro","move-closer-feedback-message":"Avvicinati","one-face-only-feedback-message":"Solo una faccia è permessa"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"カメラ準備中...","face-scan-loading-feedback-message":"フェイススキャン準備中...","hold-still-feedback-message":"動かないでください","image-too-bright-feedback-message":"直射光を避けてください","image-too-dark-feedback-message":"もっと明るい場所に移動してください","move-back-feedback-message":"離れてください","move-center-feedback-message":"顔を枠内に収めてください","move-closer-feedback-message":"近づいてください","one-face-only-feedback-message":"認識できる顔は1つだけです"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Bezig met camera voorbereiden...","face-scan-loading-feedback-message":"Bezig met gezichtsscan voorbereiden...","hold-still-feedback-message":"Sta stil","image-too-bright-feedback-message":"Niet in direct licht plaatsen","image-too-dark-feedback-message":"Op een lichtere plaats zetten","move-back-feedback-message":"Ga achteruit","move-center-feedback-message":"Plaats je gezicht in het kader","move-closer-feedback-message":"Kom dichter bij","one-face-only-feedback-message":"Slechts één gezicht toegestaan"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Klargjør kameraet ...","face-scan-loading-feedback-message":"Klargjør ansiktsskanning ...","hold-still-feedback-message":"Hold deg i ro","image-too-bright-feedback-message":"Gå vekk fra direkte lys","image-too-dark-feedback-message":"Gå til et lysere område","move-back-feedback-message":"Gå bakover","move-center-feedback-message":"Hold ansiktet ditt i rammen","move-closer-feedback-message":"Beveg deg forover","one-face-only-feedback-message":"Kun ett ansikt tillat"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Przygotowywanie aparatu...","face-scan-loading-feedback-message":"Przygotowywanie skanu twarzy...","hold-still-feedback-message":"Nie ruszaj się","image-too-bright-feedback-message":"Przejdź do lepiej oświetlonego miejsca","image-too-dark-feedback-message":"Odsuń się, aby światło nie padało na Ciebie bezpośrednio","move-back-feedback-message":"Cofnij się","move-center-feedback-message":"Umieść twarz w ramce","move-closer-feedback-message":"Przybliż się","one-face-only-feedback-message":"Dozwolona jest tylko jedna twarz"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Preparando câmera...","face-scan-loading-feedback-message":"Preparando scan do rosto...","hold-still-feedback-message":"Segure firme","image-too-bright-feedback-message":"Afaste-se da iluminação direta.","image-too-dark-feedback-message":"Vá para uma área mais iluminada","move-back-feedback-message":"Afaste-se","move-center-feedback-message":"Coloque seu rosto no quadro","move-closer-feedback-message":"Aproxime-se","one-face-only-feedback-message":"Somente um rosto permitido"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Se pregătește camera...","face-scan-loading-feedback-message":"Se pregătește scanarea feței...","hold-still-feedback-message":"Vă rugăm nu vă mișcați","image-too-bright-feedback-message":"Îndepărtați-vă de lumina directă","image-too-dark-feedback-message":"Duceți-vă într-o zonă mai luminoasă","move-back-feedback-message":"Mergeți mai în spate","move-center-feedback-message":"Poziționați fața în cadru","move-closer-feedback-message":"Veniți mai aproape","one-face-only-feedback-message":"Este permisă doar o singură față"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Подготовка камеры...","face-scan-loading-feedback-message":"Подготовка к сканированию лица...","hold-still-feedback-message":"Не двигайтесь","image-too-bright-feedback-message":"Отодвиньтесь от прямого света","image-too-dark-feedback-message":"Перейдите в более светлое место","move-back-feedback-message":"Отодвиньтесь назад","move-center-feedback-message":"Поместите лицо в рамку","move-closer-feedback-message":"Придвиньтесь ближе","one-face-only-feedback-message":"Допускается только одно лицо"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Förbereder kameran …","face-scan-loading-feedback-message":"Förbereder ansiktsskanning ...","hold-still-feedback-message":"Vänligen håll still","image-too-bright-feedback-message":"Avlägsna dig från direkt ljus","image-too-dark-feedback-message":"Flytta till ett ljusare område","move-back-feedback-message":"Backa","move-center-feedback-message":"Placera ditt ansikte i ramen","move-closer-feedback-message":"Flytta dig närmare","one-face-only-feedback-message":"Endast ett ansikte tillåtet"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"กำลังเตรียมกล้อง...","face-scan-loading-feedback-message":"กำลังเตรียมการสแกนใบหน้า...","hold-still-feedback-message":"โปรดหยุดนิ่ง","image-too-bright-feedback-message":"ขยับออกห่างจากแสงโดยตรง","image-too-dark-feedback-message":"ขยับไปยังพื้นที่ที่สว่างกว่า","move-back-feedback-message":"ถอยหลัง","move-center-feedback-message":"ขยับให้ใบหน้าของคุณอยู่ในเฟรม","move-closer-feedback-message":"ขยับเข้ามาใกล้ขึ้น","one-face-only-feedback-message":"อนุญาตให้มีเพียงใบหน้าเดียวเท่านั้น"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Kamera hazırlanıyor...","face-scan-loading-feedback-message":"Yüz tarama hazırlanıyor...","hold-still-feedback-message":"Lütfen kıpırdamadan bekleyin","image-too-bright-feedback-message":"Direkt ışıktan uzaklaşın","image-too-dark-feedback-message":"Daha aydınlık bir alana geçin","move-back-feedback-message":"Uzaklaşın","move-center-feedback-message":"Yüzünüzü çerçeveye yerleştirin","move-closer-feedback-message":"Yakınlaşın","one-face-only-feedback-message":"Yalnızca bir yüze izin verilir"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Đang chuẩn bị máy ảnh...","face-scan-loading-feedback-message":"Đang chuẩn bị quét khuôn mặt...","hold-still-feedback-message":"Vui lòng giữ yên","image-too-bright-feedback-message":"Di chuyển khỏi chỗ ánh sáng chiếu trực tiếp","image-too-dark-feedback-message":"Di chuyển đến chỗ sáng hơn","move-back-feedback-message":"Lùi lại","move-center-feedback-message":"Giữ khuôn mặt của bạn ở trong khung hình","move-closer-feedback-message":"Di chuyển lại gần hơn","one-face-only-feedback-message":"Chỉ cho phép một khuôn mặt"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Kaamera ettevalmistamine...","face-scan-loading-feedback-message":"Näoskanni ettevalmistamine...","hold-still-feedback-message":"Ärge liigutage","image-too-bright-feedback-message":"Liikuge otsesest valgusest eemale","image-too-dark-feedback-message":"Liikuge paremini valgustatud kohta","move-back-feedback-message":"Liikuge kaugemale","move-center-feedback-message":"Paigutage oma nägu kaadrisse","move-closer-feedback-message":"Liikuge lähemale","one-face-only-feedback-message":"Ainult üks nägu on lubatud"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Підготовка камери...","face-scan-loading-feedback-message":"Підготовка до сканування обличчя...","hold-still-feedback-message":"Не рухайтеся","image-too-bright-feedback-message":"Відійдіть від прямого світла","image-too-dark-feedback-message":"Підійдіть у світліше місце","move-back-feedback-message":"Відійдіть назад","move-center-feedback-message":"Помістіть своє обличчя в рамку","move-closer-feedback-message":"Підійдіть ближче","one-face-only-feedback-message":"Дозволяється лише одне обличчя"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Ruošiamas fotoaparatas...","face-scan-loading-feedback-message":"Ruošiamasi nuskaityti veidą...","hold-still-feedback-message":"Nejudėkite","image-too-bright-feedback-message":"Paeikite toliau nuo tiesioginių saulės spindulių","image-too-dark-feedback-message":"Pereikite į šviesesnę vietą","move-back-feedback-message":"Paeikite atgal","move-center-feedback-message":"Laikykite veidą rėmelyje","move-closer-feedback-message":"Prieikite arčiau","one-face-only-feedback-message":"Gali būti tik vienas veidas"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Menyediakan kamera...","face-scan-loading-feedback-message":"Menyediakan imbasan muka...","hold-still-feedback-message":"Sila jangan bergerak","image-too-bright-feedback-message":"Jauhkan diri daripada cahaya terus","image-too-dark-feedback-message":"Bergerak ke kawasan yang lebih terang","move-back-feedback-message":"Berundur","move-center-feedback-message":"Letakkan muka anda dalam bingkai","move-closer-feedback-message":"Bergerak lebih dekat","one-face-only-feedback-message":"Hanya satu muka dibenarkan"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Mempersiapkan kamera...","face-scan-loading-feedback-message":"Mempersiapkan pemindaian wajah...","hold-still-feedback-message":"Harap diam","image-too-bright-feedback-message":"Menjauh dari cahaya langsung","image-too-dark-feedback-message":"Pindah ke area yang lebih terang","move-back-feedback-message":"Mundur","move-center-feedback-message":"Tempatkan wajah dalam bingkai","move-closer-feedback-message":"Lebih dekat","one-face-only-feedback-message":"Hanya boleh satu wajah"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"카메라 준비 중...","face-scan-loading-feedback-message":"얼굴 스캔 준비 중...","hold-still-feedback-message":"움직이지 마세요","image-too-bright-feedback-message":"직접광에서 멀리 떨어지세요","image-too-dark-feedback-message":"더 밝은 곳으로 이동하세요","move-back-feedback-message":"뒤로 물러서세요","move-center-feedback-message":"얼굴을 프레임에 맞추세요","move-closer-feedback-message":"더 가까이 오세요","one-face-only-feedback-message":"한 사람의 얼굴만 허용됩니다"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"...جارٍ تحضير الكاميرا","face-scan-loading-feedback-message":"...جارٍ التحضير لمسح الوجه","hold-still-feedback-message":"الرجاء البقاء ساكنًا","image-too-bright-feedback-message":"ابتعِد عن الضوء المباشر","image-too-dark-feedback-message":"انتقل إلى منطقة أكثر إضاءة","move-back-feedback-message":"ارجع للوراء","move-center-feedback-message":"ضع وجهك في الإطار","move-closer-feedback-message":"اقترب أكثر","one-face-only-feedback-message":"يُسمح بوجه واحد فقط"}}},function(t,e){t.exports={messages:{"camera-loading-feedback-message":"Sagatavo kameru...","face-scan-loading-feedback-message":"Gatavojas sejas skenēšanai...","hold-still-feedback-message":"Nekustieties","image-too-bright-feedback-message":"Pavirziet tur, kur nav tiešas saules gaismas","image-too-dark-feedback-message":"Pavirzieties uz gaišāku zonu","move-back-feedback-message":"Atvirzieties","move-center-feedback-message":"Ietilpiniet seju rāmī","move-closer-feedback-message":"Pavirzieties tuvāk","one-face-only-feedback-message":"Atļauta tikai viena seja"}}},function(t,e,n){var r=n(72);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){var r=n(73).default,o=n(74);t.exports=function(t,e){if(e&&("object"===r(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return o(t)},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t){if(Array.isArray(t))return t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,a=[],i=!0,s=!1;try{for(n=n.call(t);!(i=(r=n.next()).done)&&(a.push(r.value),!e||a.length!==e);i=!0);}catch(u){s=!0,o=u}finally{try{i||null==n.return||n.return()}finally{if(s)throw o}}return a}},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){var r=n(59);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){"use strict";var r=n(62);function o(){}function a(){}a.resetWarningCache=o,t.exports=function(){function t(t,e,n,o,a,i){if(i!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function e(){return t}t.isRequired=t;var n={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:a,resetWarningCache:o};return n.PropTypes=n,n}},function(t,e,n){"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(t,e,n){"use strict";(function(t){var r=n(64),o=n(65),a=n(66);function i(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(t,e){if(i()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,n){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,n);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return c(this,t,e,n)}function c(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,n,r){if(e.byteLength,n<0||e.byteLength<n)throw new RangeError("'offset' is out of bounds");if(e.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=h(t,e);return t}(t,e,n,r):"string"==typeof e?function(t,e,n){"string"==typeof n&&""!==n||(n="utf8");if(!u.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|d(e,n),o=(t=s(t,r)).write(e,n);o!==r&&(t=t.slice(0,o));return t}(t,e,n):function(t,e){if(u.isBuffer(e)){var n=0|p(e.length);return 0===(t=s(t,n)).length||e.copy(t,0,0,n),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(r=e.length)!=r?s(t,0):h(t,e);if("Buffer"===e.type&&a(e.data))return h(t,e.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e){if(l(e),t=s(t,e<0?0:0|p(e)),!u.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function h(t,e){var n=e.length<0?0:0|p(e.length);t=s(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function p(t){if(t>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function d(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return j(t).length;default:if(r)return U(t).length;e=(""+e).toLowerCase(),r=!0}}function v(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,n);case"utf8":case"utf-8":return R(this,e,n);case"ascii":return I(this,e,n);case"latin1":case"binary":return S(this,e,n);case"base64":return k(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function m(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function g(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=u.from(e,r)),u.isBuffer(e))return 0===e.length?-1:y(t,e,n,r,o);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):y(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,n,r,o){var a,i=1,s=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;i=2,s/=2,u/=2,n/=2}function c(t,e){return 1===i?t[e]:t.readUInt16BE(e*i)}if(o){var l=-1;for(a=n;a<s;a++)if(c(t,a)===c(e,-1===l?0:a-l)){if(-1===l&&(l=a),a-l+1===u)return l*i}else-1!==l&&(a-=a-l),l=-1}else for(n+u>s&&(n=s-u),a=n;a>=0;a--){for(var f=!0,h=0;h<u;h++)if(c(t,a+h)!==c(e,h)){f=!1;break}if(f)return a}return-1}function b(t,e,n,r){n=Number(n)||0;var o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;var a=e.length;if(a%2!=0)throw new TypeError("Invalid hex string");r>a/2&&(r=a/2);for(var i=0;i<r;++i){var s=parseInt(e.substr(2*i,2),16);if(isNaN(s))return i;t[n+i]=s}return i}function x(t,e,n,r){return z(U(e,t.length-n),t,n,r)}function w(t,e,n,r){return z(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function E(t,e,n,r){return w(t,e,n,r)}function C(t,e,n,r){return z(j(e),t,n,r)}function _(t,e,n,r){return z(function(t,e){for(var n,r,o,a=[],i=0;i<t.length&&!((e-=2)<0);++i)n=t.charCodeAt(i),r=n>>8,o=n%256,a.push(o),a.push(r);return a}(e,t.length-n),t,n,r)}function k(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function R(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o<n;){var a,i,s,u,c=t[o],l=null,f=c>239?4:c>223?3:c>191?2:1;if(o+f<=n)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(a=t[o+1]))&&(u=(31&c)<<6|63&a)>127&&(l=u);break;case 3:a=t[o+1],i=t[o+2],128==(192&a)&&128==(192&i)&&(u=(15&c)<<12|(63&a)<<6|63&i)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:a=t[o+1],i=t[o+2],s=t[o+3],128==(192&a)&&128==(192&i)&&128==(192&s)&&(u=(15&c)<<18|(63&a)<<12|(63&i)<<6|63&s)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),o+=f}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=4096));return n}(r)}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}(),e.kMaxLength=i(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,n){return c(null,t,e,n)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,n){return function(t,e,n,r){return l(e),e<=0?s(t,e):void 0!==n?"string"==typeof r?s(t,e).fill(n,r):s(t,e).fill(n):s(t,e)}(null,t,e,n)},u.allocUnsafe=function(t){return f(null,t)},u.allocUnsafeSlow=function(t){return f(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,o=0,a=Math.min(n,r);o<a;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!a(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=u.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var i=t[n];if(!u.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},u.byteLength=d,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)m(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?R(this,0,t):v.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,n,r,o){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var a=(o>>>=0)-(r>>>=0),i=(n>>>=0)-(e>>>=0),s=Math.min(a,i),c=this.slice(r,o),l=t.slice(e,n),f=0;f<s;++f)if(c[f]!==l[f]){a=c[f],i=l[f];break}return a<i?-1:i<a?1:0},u.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},u.prototype.indexOf=function(t,e,n){return g(this,t,e,n,!0)},u.prototype.lastIndexOf=function(t,e,n){return g(this,t,e,n,!1)},u.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var a=!1;;)switch(r){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return x(this,t,e,n);case"ascii":return w(this,t,e,n);case"latin1":case"binary":return E(this,t,e,n);case"base64":return C(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,n);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),a=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function S(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function A(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var o="",a=e;a<n;++a)o+=W(t[a]);return o}function O(t,e,n){for(var r=t.slice(e,n),o="",a=0;a<r.length;a+=2)o+=String.fromCharCode(r[a]+256*r[a+1]);return o}function T(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,n,r,o,a){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<a)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function N(t,e,n,r){e<0&&(e=65535+e+1);for(var o=0,a=Math.min(t.length-n,2);o<a;++o)t[n+o]=(e&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function F(t,e,n,r){e<0&&(e=4294967295+e+1);for(var o=0,a=Math.min(t.length-n,4);o<a;++o)t[n+o]=e>>>8*(r?o:3-o)&255}function M(t,e,n,r,o,a){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function P(t,e,n,r,a){return a||M(t,0,n,4),o.write(t,e,n,r,23,4),n+4}function B(t,e,n,r,a){return a||M(t,0,n,8),o.write(t,e,n,r,52,8),n+8}u.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=u.prototype;else{var o=e-t;n=new u(o,void 0);for(var a=0;a<o;++a)n[a]=this[a+t]}return n},u.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||T(t,e,this.length);for(var r=this[t],o=1,a=0;++a<e&&(o*=256);)r+=this[t+a]*o;return r},u.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||T(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},u.prototype.readUInt8=function(t,e){return e||T(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||T(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||T(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||T(t,e,this.length);for(var r=this[t],o=1,a=0;++a<e&&(o*=256);)r+=this[t+a]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*e)),r},u.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||T(t,e,this.length);for(var r=e,o=1,a=this[t+--r];r>0&&(o*=256);)a+=this[t+--r]*o;return a>=(o*=128)&&(a-=Math.pow(2,8*e)),a},u.prototype.readInt8=function(t,e){return e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||T(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(t,e){e||T(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(t,e){return e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||T(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||T(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||T(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||T(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||D(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,a=0;for(this[e]=255&t;++a<n&&(o*=256);)this[e+a]=t/o&255;return e+n},u.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||D(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,a=1;for(this[e+o]=255&t;--o>=0&&(a*=256);)this[e+o]=t/a&255;return e+n},u.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):F(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);D(this,t,e,n,o-1,-o)}var a=0,i=1,s=0;for(this[e]=255&t;++a<n&&(i*=256);)t<0&&0===s&&0!==this[e+a-1]&&(s=1),this[e+a]=(t/i>>0)-s&255;return e+n},u.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);D(this,t,e,n,o-1,-o)}var a=n-1,i=1,s=0;for(this[e+a]=255&t;--a>=0&&(i*=256);)t<0&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/i>>0)-s&255;return e+n},u.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):F(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,n){return P(this,t,e,!0,n)},u.prototype.writeFloatBE=function(t,e,n){return P(this,t,e,!1,n)},u.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n)},u.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n)},u.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var o,a=r-n;if(this===t&&n<e&&e<r)for(o=a-1;o>=0;--o)t[o+e]=this[o+n];else if(a<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<a;++o)t[o+e]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+a),e);return a},u.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var a;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(a=e;a<n;++a)this[a]=t;else{var i=u.isBuffer(t)?t:U(new u(t,r).toString()),s=i.length;for(a=0;a<n-e;++a)this[a+e]=i[a%s]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function W(t){return t<16?"0"+t.toString(16):t.toString(16)}function U(t,e){var n;e=e||1/0;for(var r=t.length,o=null,a=[],i=0;i<r;++i){if((n=t.charCodeAt(i))>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(i+1===r){(e-=3)>-1&&a.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&a.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&a.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;a.push(n)}else if(n<2048){if((e-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function j(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}}).call(this,n(5))},function(t,e,n){"use strict";e.byteLength=function(t){var e=c(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,r=c(t),i=r[0],s=r[1],u=new a(function(t,e,n){return 3*(e+n)/4-n}(0,i,s)),l=0,f=s>0?i-4:i;for(n=0;n<f;n+=4)e=o[t.charCodeAt(n)]<<18|o[t.charCodeAt(n+1)]<<12|o[t.charCodeAt(n+2)]<<6|o[t.charCodeAt(n+3)],u[l++]=e>>16&255,u[l++]=e>>8&255,u[l++]=255&e;2===s&&(e=o[t.charCodeAt(n)]<<2|o[t.charCodeAt(n+1)]>>4,u[l++]=255&e);1===s&&(e=o[t.charCodeAt(n)]<<10|o[t.charCodeAt(n+1)]<<4|o[t.charCodeAt(n+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e);return u},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,a=[],i=0,s=n-o;i<s;i+=16383)a.push(l(t,i,i+16383>s?s:i+16383));1===o?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return a.join("")};for(var r=[],o=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=i.length;s<u;++s)r[s]=i[s],o[i.charCodeAt(s)]=s;function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function l(t,e,n){for(var o,a,i=[],s=e;s<n;s+=3)o=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),i.push(r[(a=o)>>18&63]+r[a>>12&63]+r[a>>6&63]+r[63&a]);return i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,n,r,o){var a,i,s=8*o-r-1,u=(1<<s)-1,c=u>>1,l=-7,f=n?o-1:0,h=n?-1:1,p=t[e+f];for(f+=h,a=p&(1<<-l)-1,p>>=-l,l+=s;l>0;a=256*a+t[e+f],f+=h,l-=8);for(i=a&(1<<-l)-1,a>>=-l,l+=r;l>0;i=256*i+t[e+f],f+=h,l-=8);if(0===a)a=1-c;else{if(a===u)return i?NaN:1/0*(p?-1:1);i+=Math.pow(2,r),a-=c}return(p?-1:1)*i*Math.pow(2,a-r)},e.write=function(t,e,n,r,o,a){var i,s,u,c=8*a-o-1,l=(1<<c)-1,f=l>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:a-1,d=r?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,i=l):(i=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-i))<1&&(i--,u*=2),(e+=i+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(i++,u/=2),i+f>=l?(s=0,i=l):i+f>=1?(s=(e*u-1)*Math.pow(2,o),i+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,o),i=0));o>=8;t[n+p]=255&s,p+=d,s/=256,o-=8);for(i=i<<o|s,c+=o;c>0;t[n+p]=255&i,p+=d,i/=256,c-=8);t[n+p-d]|=128*v}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,o=Function.prototype.apply;function a(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new a(o.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new a(o.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},a.prototype.unref=a.prototype.ref=function(){},a.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(68),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(5))},function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var r,o,a,i,s,u=1,c={},l=!1,f=t.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(t);h=h&&h.setTimeout?h:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick((function(){d(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?t.MessageChannel?((a=new MessageChannel).port1.onmessage=function(t){d(t.data)},r=function(t){a.port2.postMessage(t)}):f&&"onreadystatechange"in f.createElement("script")?(o=f.documentElement,r=function(t){var e=f.createElement("script");e.onreadystatechange=function(){d(t),e.onreadystatechange=null,o.removeChild(e),e=null},o.appendChild(e)}):r=function(t){setTimeout(d,0,t)}:(i="setImmediate$"+Math.random()+"$",s=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(i)&&d(+e.data.slice(i.length))},t.addEventListener?t.addEventListener("message",s,!1):t.attachEvent("onmessage",s),r=function(e){t.postMessage(i+e,"*")}),h.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n<e.length;n++)e[n]=arguments[n+1];var o={callback:t,args:e};return c[u]=o,r(u),u++},h.clearImmediate=p}function p(t){delete c[t]}function d(t){if(l)setTimeout(d,0,t);else{var e=c[t];if(e){l=!0;try{!function(t){var e=t.callback,n=t.args;switch(n.length){case 0:e();break;case 1:e(n[0]);break;case 2:e(n[0],n[1]);break;case 3:e(n[0],n[1],n[2]);break;default:e.apply(void 0,n)}}(e)}finally{p(t),l=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(this,n(5),n(10))},function(t,e){},function(t,e){},function(t,e){},function(t,e){function n(e,r){return t.exports=n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},t.exports.default=t.exports,t.exports.__esModule=!0,n(e,r)}t.exports=n,t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function n(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(t.exports=n=function(t){return typeof t},t.exports.default=t.exports,t.exports.__esModule=!0):(t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.default=t.exports,t.exports.__esModule=!0),n(e)}t.exports=n,t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t,e){if(null==t)return{};var n,r,o={},a=Object.keys(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)>=0||(o[n]=t[n]);return o},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){"use strict";n.r(e),n.d(e,"ERROR_CODE",(function(){return o})),n.d(e,"LANGUAGE_CODE",(function(){return d})),n.d(e,"CAPTURE_METHOD",(function(){return v})),n.d(e,"IMAGE_TYPE",(function(){return m})),n.d(e,"QUALITY_TYPE",(function(){return g})),n.d(e,"default",(function(){return hi}));var r={};n.r(r),n.d(r,"drawContour",(function(){return It})),n.d(r,"drawDetections",(function(){return xe})),n.d(r,"drawFaceExpressions",(function(){return an})),n.d(r,"DrawBoxOptions",(function(){return ye})),n.d(r,"DrawBox",(function(){return be})),n.d(r,"DrawFaceLandmarksOptions",(function(){return cn})),n.d(r,"DrawFaceLandmarks",(function(){return ln})),n.d(r,"drawFaceLandmarks",(function(){return fn})),n.d(r,"AnchorPosition",(function(){return he})),n.d(r,"DrawTextFieldOptions",(function(){return me})),n.d(r,"DrawTextField",(function(){return ge}));const o={NO_CAMERA_PERMISSION:"NO_CAMERA_PERMISSION",NO_CAMERA:"NO_CAMERA",UNSUPPORTED_BROWSER:"UNSUPPORTED_BROWSER",OVERCONSTRAINED:"OVERCONSTRAINED",GENERIC_CAMERA_ERROR:"GENERIC_CAMERA_ERROR",FACE_DETECTION_INIT_ERROR:"FACE_DETECTION_INIT_ERROR",INTERNAL_ERROR:"INTERNAL_ERROR"},a="MOVE_CLOSER",i="MOVE_BACK",s="MOVE_CENTER",u="ONE_FACE_ONLY",c="HOLD_STILL",l="CAMERA_LOADING",f="FACE_SCAN_LOADING",h="IMAGE_TOO_DARK",p="IMAGE_TOO_BRIGHT",d={AR:"ar",CS:"cs",DA:"da",DE:"de",EN:"en",ES:"es",ES_419:"es-419",ET:"et",FI:"fi",FR:"fr",HI:"hi",ID:"id",IT:"it",JA:"ja",KO:"ko",LT:"lt",LV:"lv",MS:"ms",NB:"nb",NL:"nl",PL:"pl",PT:"pt",RO:"ro",RU:"ru",SV:"sv",TH:"th",TR:"tr",UK:"uk",VI:"vi"},v={MANUAL:"manual",AUTO:"auto"},m={ORIGINAL:"original",CROPPED:"cropped"},g={HIGH:"high",MEDIUM:"medium",LOW:"low"},y={[g.HIGH]:1,[g.MEDIUM]:.96,[g.LOW]:.9};var b=n(2),x=n.n(b);class w extends b.Component{componentDidCatch(){const{onError:t}=this.props;t(o.INTERNAL_ERROR)}render(){const{children:t}=this.props;return t}}var E=w,C=n(4),_=n.n(C),k=n(20),R=n.n(k),I=x.a.createContext(null);function S(){return x.a.useContext(I)}var A=function(t){var e=t.i18n,n=t.defaultComponent,r=t.forceRenderOnLocaleChange,o=void 0===r||r,a=t.children,i=function(){return{i18n:e,defaultComponent:n}},s=function(){return o&&e.locale||"default"},u=x.a.useState(i()),c=_()(u,2),l=c[0],f=c[1],h=x.a.useState(s()),p=_()(h,2),d=p[0],v=p[1];return x.a.useEffect((function(){var t=e.on("change",(function(){f(i()),v(s())}));return"default"===d&&v(s()),function(){return t()}}),[]),o&&"default"===d?null:x.a.createElement(I.Provider,{value:l,key:d},a)};function O(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return T(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?T(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,s=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return i=t.done,t},e:function(t){s=!0,a=t},f:function(){try{i||null==n.return||n.return()}finally{if(s)throw a}}}}function T(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var D=/<(\d+)>(.*?)<\/\1>|<(\d+)\/>/,N=/(?:\r\n|\r|\n)/g,F={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0};function M(t){if(!t.length)return[];var e=t.slice(0,4),n=_()(e,4),r=n[0],o=n[1],a=n[2],i=n[3];return[[parseInt(r||a),o||"",i]].concat(M(t.slice(4,t.length)))}var P=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return function(){return"".concat(e,"_").concat(t++)}};function B(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function L(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?B(Object(n),!0).forEach((function(e){R()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function W(t){var e=S(),n=e.i18n,r=e.defaultComponent,o=t.render,a=t.component,i=t.id,s=t.message,u=t.formats,c=L({},t.values),l=L({},t.components);c&&Object.keys(c).forEach((function(t){var e=c[t];if(x.a.isValidElement(e)){var n=Object.keys(l).length;l[n]=e,c[t]="<".concat(n,"/>")}}));var f=n&&"function"==typeof n._?n._(i,c,{message:s,formats:u}):i,h=f?function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=P(0,"$lingui$"),o=e.replace(N,"").split(D);if(1===o.length)return e;var a=[],i=o.shift();i&&a.push(i);var s,u=O(M(o));try{for(u.s();!(s=u.n()).done;){var c=_()(s.value,3),l=c[0],f=c[1],h=c[2],p=n[l];(!p||F[p.type]&&f)&&(p=x.a.createElement(x.a.Fragment)),a.push(x.a.cloneElement(p,{key:r()},f?t(f,n):p.props.children)),h&&a.push(h)}}catch(d){u.e(d)}finally{u.f()}return a}(f,l):null;if(null===o||null===a)return h;var p=r||x.a.Fragment;if(o&&a);else if(o&&"function"!=typeof o);else if(a&&"function"!=typeof a)return x.a.createElement(p,null,h);if("function"==typeof o)return o({id:i,translation:h,message:s});var d=a||p;return x.a.createElement(d,null,h)}W.defaultProps={values:{},components:{}};var U,j=n(3),z=n.n(j),V=n(8),G=n.n(V),H=n(7),q=n.n(H);function K(){return(K=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var X,$=function(t){return b.createElement("svg",K({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1280 720"},t),U||(U=b.createElement("path",{fill:"#FFF",fillOpacity:.7,fillRule:"evenodd",d:"M1280 0v720H0V0h1280zM658.215 95.79a286.506 286.506 0 00-31.573-.605c-3.545.197-8.59.56-14.622 1.286-6.207.747-16.005 2.002-28.095 5.248a155.94 155.94 0 00-16.938 5.584c-18.993 7.515-37.088 18.327-50.068 33.828-19.713 23.543-29.338 53.4-33.045 83.01-3.922 31.334 1.288 62.583 2.466 93.896.036.933-.066 1.933-1.189 2.205-.489.12-1.01.044-1.49-.105-2.367-.735-3.576-2.94-5.427-4.353-4.138-3.16-10.825-3.19-14.466.709-5.106 5.47-4.03 13.544-2.5 20.126a1882.27 1882.27 0 015.703 25.242l.698 3.203c3.236 14.859 5.256 30.448 14.16 43.384 1.275 1.854 2.705 3.69 4.675 4.858 4.438 2.63 8.543 3.032 11.32 7.741 2.541 4.307 3.22 9.748 4.45 14.478 3.743 14.39 10.884 27.878 17.09 41.39 7.208 15.702 15.101 31.167 24.77 45.629 13.507 20.203 30.719 38.55 52.234 50.83 13.213 7.54 29.09 13.962 44.455 13.237l.01-.002.011.002c15.13.714 30.754-5.501 43.844-12.89l.611-.347c21.515-12.28 38.727-30.627 52.235-50.83 9.668-14.462 17.561-29.927 24.77-45.629 6.205-13.512 13.346-27 17.087-41.39 1.23-4.73 1.911-10.171 4.451-14.478 2.779-4.709 6.883-5.112 11.32-7.74 1.972-1.17 3.401-3.005 4.676-4.86 8.904-12.935 10.925-28.524 14.16-43.383l.698-3.203a1877.285 1877.285 0 015.703-25.242c1.528-6.582 2.606-14.657-2.5-20.126-3.64-3.9-10.327-3.869-14.466-.71-1.851 1.414-3.06 3.619-5.426 4.354-.48.15-1.002.224-1.491.105-1.123-.272-1.225-1.272-1.189-2.205 1.179-31.313 6.388-62.562 2.466-93.896-3.707-29.61-13.332-59.467-33.045-83.01-12.98-15.501-31.075-26.313-50.067-33.828-11.67-4.617-24.272-7.12-27.795-7.833-11.799-2.391-21.042-3.11-28.671-3.68zM642.24 586.523l-.708.05-.699.036-.698-.037c-.236-.015-.472-.03-.708-.049h2.813z"})))};function Y(){return(Y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var J,Q,Z=function(t){return b.createElement("svg",Y({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 715 715"},t),X||(X=b.createElement("path",{fill:"#D9DEE5",fillOpacity:.7,fillRule:"evenodd",d:"M715 0v715H0V0h715zM368.33 210.97a168.754 168.754 0 00-18.77-.363c-2.107.119-5.107.337-8.692.772-3.69.448-9.515 1.201-16.702 3.149a92.101 92.101 0 00-10.07 3.35c-11.29 4.51-22.047 10.996-29.763 20.297-11.719 14.126-17.44 32.04-19.644 49.806-2.331 18.8.765 37.55 1.466 56.337.021.56-.04 1.16-.707 1.324-.29.071-.6.026-.886-.063-1.407-.441-2.125-1.764-3.226-2.612-2.46-1.896-6.435-1.914-8.6.425-3.035 3.282-2.395 8.127-1.486 12.076 1.16 5.043 2.298 10.08 3.39 15.145.14.64.277 1.281.416 1.922 1.923 8.915 3.124 18.269 8.417 26.03.758 1.113 1.608 2.214 2.78 2.915 2.638 1.578 5.078 1.82 6.728 4.645 1.511 2.584 1.915 5.849 2.647 8.687 2.224 8.634 6.47 16.726 10.158 24.834 4.286 9.42 8.978 18.7 14.725 27.377 8.03 12.122 18.262 23.13 31.052 30.498 7.773 4.477 17.096 8.296 26.14 7.954l.293-.014.294.014c8.856.335 17.98-3.32 25.653-7.675l.487-.28c12.79-7.367 23.022-18.375 31.052-30.497 5.747-8.677 10.44-17.956 14.725-27.377 3.689-8.108 7.934-16.2 10.158-24.834.732-2.838 1.136-6.103 2.646-8.687 1.652-2.826 4.092-3.067 6.73-4.645 1.171-.701 2.021-1.802 2.78-2.915 5.292-7.761 6.493-17.115 8.417-26.03l.415-1.922c1.092-5.065 2.23-10.102 3.39-15.145.909-3.95 1.55-8.794-1.486-12.076-2.164-2.34-6.14-2.32-8.6-.425-1.1.848-1.819 2.17-3.226 2.612-.285.09-.595.134-.886.063-.667-.163-.728-.764-.706-1.324.7-18.787 3.797-37.536 1.465-56.337-2.203-17.766-7.925-35.68-19.644-49.806-7.716-9.3-18.473-15.788-29.763-20.297-6.937-2.77-14.43-4.271-16.524-4.7-7.014-1.434-12.509-1.866-17.044-2.208z"})))};function tt(){return(tt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var et,nt,rt=function(t){return b.createElement("svg",tt({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 386 524"},t),J||(J=b.createElement("defs",null,b.createElement("linearGradient",{id:"face-outline_svg__a",x1:"50.72%",x2:"49.208%",y1:"26.23%",y2:"117.124%"},b.createElement("stop",{offset:"0%",stopColor:"#B6BFCC"}),b.createElement("stop",{offset:"100%",stopColor:"#FFF"})))),Q||(Q=b.createElement("path",{fill:"none",stroke:"url(#face-outline_svg__a)",strokeWidth:5.006,d:"M638.585 600c-.686 0-1.592-.013-2.81-.052a69.953 69.953 0 01-4.575-.296 72.809 72.809 0 01-4.533-.597 79.015 79.015 0 01-4.472-.87 85.112 85.112 0 01-4.362-1.102 91.261 91.261 0 01-4.273-1.312 101.02 101.02 0 01-4.155-1.484 114.88 114.88 0 01-4.056-1.64 125.655 125.655 0 01-7.787-3.652 147.069 147.069 0 01-7.304-3.993c-20.9-12.179-39.54-30.642-55.409-54.88-8.67-13.241-16.471-27.9-25.299-47.536-1.196-2.66-2.43-5.319-3.664-7.985-5.222-11.272-10.624-22.928-13.847-35.587-.338-1.325-.641-2.7-.943-4.093-.625-2.866-1.27-5.83-2.225-7.484-.379-.25-1.374-.71-2.115-1.054-1.373-.635-3.08-1.427-4.939-2.55-3.91-2.368-6.378-5.567-8.277-8.385-8.738-12.96-11.7-27.823-14.313-40.938-.457-2.292-.912-4.578-1.397-6.848l-.685-3.217a1892.951 1892.951 0 00-5.588-25.25c-1.25-5.49-4.567-20.075 5.26-30.824 3.985-4.36 9.824-6.86 16.017-6.86.744 0 1.487.036 2.222.105-.273-3.957-.572-7.901-.865-11.79-1.665-22.04-3.386-44.83-.563-67.858 4.469-36.439 16.293-66.575 35.149-89.569 12.744-15.54 30.924-28.155 54.037-37.494a163.732 163.732 0 0117.99-6.058c13.257-3.633 24.137-4.97 29.366-5.612 5.05-.62 10.155-1.079 15.178-1.363a292.987 292.987 0 0110.846-.205c7.276 0 14.62.278 21.829.828 7.234.551 17.14 1.306 29.746 3.915l.227.047c4.19.865 16.946 3.5 29.19 8.448 23.114 9.339 41.293 21.953 54.037 37.494 18.855 22.995 30.681 53.13 35.149 89.569 2.824 23.028 1.102 45.818-.563 67.859-.293 3.888-.591 7.832-.864 11.79a23.46 23.46 0 012.222-.105c6.193 0 12.032 2.5 16.018 6.86 9.825 10.747 6.507 25.332 5.259 30.822a1923.38 1923.38 0 00-5.588 25.246l-.685 3.22c-.484 2.27-.94 4.555-1.397 6.844-2.613 13.116-5.575 27.983-14.313 40.944-1.899 2.817-4.367 6.017-8.279 8.384-1.858 1.124-3.565 1.916-4.937 2.551-.738.344-1.727.8-2.11 1.05-.976 1.733-1.614 4.658-2.23 7.49a121.69 121.69 0 01-.943 4.09c-3.223 12.657-8.622 24.311-13.844 35.58-1.236 2.67-2.47 5.33-3.667 7.993-8.826 19.633-16.63 34.293-25.3 47.536-15.87 24.238-34.509 42.701-55.4 54.874a149.984 149.984 0 01-7.28 3.982 129.842 129.842 0 01-7.794 3.659 108.88 108.88 0 01-8.229 3.133 93.884 93.884 0 01-4.282 1.313 79.774 79.774 0 01-8.824 1.97 72.51 72.51 0 01-4.558.602 66.17 66.17 0 01-6.885.323l-1.73-.005c-.38.014-.884.027-1.584.027z",transform:"translate(-447 -79)"})))};function ot(){return(ot=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var at=function(t){return b.createElement("svg",ot({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 386 524"},t),et||(et=b.createElement("defs",null,b.createElement("linearGradient",{id:"face-outline-success_svg__a",x1:"50.72%",x2:"49.208%",y1:"26.23%",y2:"117.124%"},b.createElement("stop",{offset:"0%",stopColor:"#2FC58D"}),b.createElement("stop",{offset:"100%",stopColor:"#FFF"})))),nt||(nt=b.createElement("path",{fill:"none",stroke:"url(#face-outline-success_svg__a)",strokeWidth:5.006,d:"M638.585 600c-.686 0-1.592-.013-2.81-.052a69.953 69.953 0 01-4.575-.296 72.809 72.809 0 01-4.533-.597 79.015 79.015 0 01-4.472-.87 85.112 85.112 0 01-4.362-1.102 91.261 91.261 0 01-4.273-1.312 101.02 101.02 0 01-4.155-1.484 114.88 114.88 0 01-4.056-1.64 125.655 125.655 0 01-7.787-3.652 147.069 147.069 0 01-7.304-3.993c-20.9-12.179-39.54-30.642-55.409-54.88-8.67-13.241-16.471-27.9-25.299-47.536-1.196-2.66-2.43-5.319-3.664-7.985-5.222-11.272-10.624-22.928-13.847-35.587-.338-1.325-.641-2.7-.943-4.093-.625-2.866-1.27-5.83-2.225-7.484-.379-.25-1.374-.71-2.115-1.054-1.373-.635-3.08-1.427-4.939-2.55-3.91-2.368-6.378-5.567-8.277-8.385-8.738-12.96-11.7-27.823-14.313-40.938-.457-2.292-.912-4.578-1.397-6.848l-.685-3.217a1892.951 1892.951 0 00-5.588-25.25c-1.25-5.49-4.567-20.075 5.26-30.824 3.985-4.36 9.824-6.86 16.017-6.86.744 0 1.487.036 2.222.105-.273-3.957-.572-7.901-.865-11.79-1.665-22.04-3.386-44.83-.563-67.858 4.469-36.439 16.293-66.575 35.149-89.569 12.744-15.54 30.924-28.155 54.037-37.494a163.732 163.732 0 0117.99-6.058c13.257-3.633 24.137-4.97 29.366-5.612 5.05-.62 10.155-1.079 15.178-1.363a292.987 292.987 0 0110.846-.205c7.276 0 14.62.278 21.829.828 7.234.551 17.14 1.306 29.746 3.915l.227.047c4.19.865 16.946 3.5 29.19 8.448 23.114 9.339 41.293 21.953 54.037 37.494 18.855 22.995 30.681 53.13 35.149 89.569 2.824 23.028 1.102 45.818-.563 67.859-.293 3.888-.591 7.832-.864 11.79a23.46 23.46 0 012.222-.105c6.193 0 12.032 2.5 16.018 6.86 9.825 10.747 6.507 25.332 5.259 30.822a1923.38 1923.38 0 00-5.588 25.246l-.685 3.22c-.484 2.27-.94 4.555-1.397 6.844-2.613 13.116-5.575 27.983-14.313 40.944-1.899 2.817-4.367 6.017-8.279 8.384-1.858 1.124-3.565 1.916-4.937 2.551-.738.344-1.727.8-2.11 1.05-.976 1.733-1.614 4.658-2.23 7.49a121.69 121.69 0 01-.943 4.09c-3.223 12.657-8.622 24.311-13.844 35.58-1.236 2.67-2.47 5.33-3.667 7.993-8.826 19.633-16.63 34.293-25.3 47.536-15.87 24.238-34.509 42.701-55.4 54.874a149.984 149.984 0 01-7.28 3.982 129.842 129.842 0 01-7.794 3.659 108.88 108.88 0 01-8.229 3.133 93.884 93.884 0 01-4.282 1.313 79.774 79.774 0 01-8.824 1.97 72.51 72.51 0 01-4.558.602 66.17 66.17 0 01-6.885.323l-1.73-.005c-.38.014-.884.027-1.584.027z",transform:"translate(-447 -79)"})))};const it=t=>{let{isPortraitCamera:e,isSuccess:n}=t;const r=e?Z:$,o=n?at:rt,a=q.a[e?"portraitCamera":"landscapeCamera"];return x.a.createElement("div",{className:q.a.container},x.a.createElement(r,{className:q.a.overlay}),x.a.createElement(o,{className:G()(q.a.outline,a)}))};it.defaultProps={isSuccess:!1,isPortraitCamera:!1},it.propTypes={isSuccess:z.a.bool,isPortraitCamera:z.a.bool};var st=it,ut=n(11),ct=n.n(ut);const lt=t=>{let{message:e,isPortraitCamera:n}=t;return x.a.createElement("div",{className:G()(ct.a.container,{[ct.a.landscape]:!n})},e)};lt.defaultProps={message:"",isPortraitCamera:!1},lt.propTypes={message:z.a.element,isPortraitCamera:z.a.bool};var ft,ht,pt=lt,dt=n(12),vt=n.n(dt);function mt(){return(mt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var gt=function(t){return b.createElement("svg",mt({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28"},t),ft||(ft=b.createElement("defs",null,b.createElement("path",{id:"ico-chevron-right_svg__a",d:"M12.28 22.625l-1.56-1.25L16.62 14l-5.9-7.375 1.56-1.25L19.18 14z"}))),ht||(ht=b.createElement("use",{fill:"#F0F",xlinkHref:"#ico-chevron-right_svg__a",fillRule:"evenodd"})))};function yt(){return(yt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}const bt=t=>{let{children:e,...n}=t;return x.a.createElement("button",yt({className:vt.a.button,type:"button"},n),e,x.a.createElement(gt,{className:vt.a.icon}))};bt.propTypes={onClick:z.a.func.isRequired,disabled:z.a.bool,children:z.a.node};var xt=bt,wt=n(21),Et=n.n(wt);const Ct=t=>x.a.createElement("div",{className:Et.a.container},x.a.createElement(xt,t,"Take picture")),_t=t=>{let{CustomButton:e,...n}=t;const r=e||Ct;return x.a.createElement(r,n)};_t.propTypes={CustomButton:z.a.func,onClick:z.a.func.isRequired,disabled:z.a.bool};var kt=_t,Rt=n(0);function It(t,e,n){if(void 0===n&&(n=!1),t.beginPath(),e.slice(1).forEach((function(n,r){var o=n.x,a=n.y,i=e[r];t.moveTo(i.x,i.y),t.lineTo(o,a)})),n){var r=e[e.length-1],o=e[0];if(!r||!o)return;t.moveTo(r.x,r.y),t.lineTo(o.x,o.y)}t.stroke()}var St=n(1),At=function(){function t(t,e){if(!Lt(t)||!Lt(e))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:t,height:e}));this._width=t,this._height=e}return Object.defineProperty(t.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),t.prototype.reverse=function(){return new t(1/this.width,1/this.height)},t}();function Ot(t,e){return t instanceof Rt.a&&t.shape.length===e}function Tt(t){return Ot(t,3)}function Dt(t){return Ot(t,4)}function Nt(t){return t%2==0}function Ft(t,e){void 0===e&&(e=2);var n=Math.pow(10,e);return Math.floor(t*n)/n}function Mt(t){return t&&t.width&&t.height}function Pt(t){return t.reduce((function(t,e){return t.add(e)}),new Ut(0,0)).div(new Ut(t.length,t.length))}function Bt(t,e,n){return Array(t).fill(0).map((function(t,r){return e+r*n}))}function Lt(t){return!!t&&t!==1/0&&t!==-1/0&&!isNaN(t)||0===t}function Wt(t){return Lt(t)&&0<=t&&t<=1}var Ut=function(){function t(t,e){this._x=t,this._y=e}return Object.defineProperty(t.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.sub=function(e){return new t(this.x-e.x,this.y-e.y)},t.prototype.mul=function(e){return new t(this.x*e.x,this.y*e.y)},t.prototype.div=function(e){return new t(this.x/e.x,this.y/e.y)},t.prototype.abs=function(){return new t(Math.abs(this.x),Math.abs(this.y))},t.prototype.magnitude=function(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))},t.prototype.floor=function(){return new t(Math.floor(this.x),Math.floor(this.y))},t}(),jt=function(){function t(e,n){void 0===n&&(n=!0);var r=e||{},o=[r.left,r.top,r.right,r.bottom].every(Lt),a=[r.x,r.y,r.width,r.height].every(Lt);if(!a&&!o)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify(r));var i=a?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top],s=i[0],u=i[1],c=i[2],l=i[3];t.assertIsValidBox({x:s,y:u,width:c,height:l},"Box.constructor",n),this._x=s,this._y=u,this._width=c,this._height=l}return t.isRect=function(t){return!!t&&[t.x,t.y,t.width,t.height].every(Lt)},t.assertIsValidBox=function(e,n,r){if(void 0===r&&(r=!1),!t.isRect(e))throw new Error(n+" - invalid box: "+JSON.stringify(e)+", expected object with properties x, y, width, height");if(!r&&(e.width<0||e.height<0))throw new Error(n+" - width ("+e.width+") and height ("+e.height+") must be positive numbers")},Object.defineProperty(t.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){return this.x},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x+this.width},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"topLeft",{get:function(){return new Ut(this.left,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"topRight",{get:function(){return new Ut(this.right,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottomLeft",{get:function(){return new Ut(this.left,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottomRight",{get:function(){return new Ut(this.right,this.bottom)},enumerable:!0,configurable:!0}),t.prototype.round=function(){var e=[this.x,this.y,this.width,this.height].map((function(t){return Math.round(t)}));return new t({x:e[0],y:e[1],width:e[2],height:e[3]})},t.prototype.floor=function(){var e=[this.x,this.y,this.width,this.height].map((function(t){return Math.floor(t)}));return new t({x:e[0],y:e[1],width:e[2],height:e[3]})},t.prototype.toSquare=function(){var e=this.x,n=this.y,r=this.width,o=this.height,a=Math.abs(r-o);return r<o&&(e-=a/2,r+=a),o<r&&(n-=a/2,o+=a),new t({x:e,y:n,width:r,height:o})},t.prototype.rescale=function(e){var n=Mt(e)?e.width:e,r=Mt(e)?e.height:e;return new t({x:this.x*n,y:this.y*r,width:this.width*n,height:this.height*r})},t.prototype.pad=function(e,n){var r=[this.x-e/2,this.y-n/2,this.width+e,this.height+n];return new t({x:r[0],y:r[1],width:r[2],height:r[3]})},t.prototype.clipAtImageBorders=function(e,n){var r=this.x,o=this.y,a=this.right,i=this.bottom,s=Math.max(r,0),u=Math.max(o,0),c=a-s,l=i-u;return new t({x:s,y:u,width:Math.min(c,e-s),height:Math.min(l,n-u)}).floor()},t.prototype.shift=function(e,n){var r=this.width,o=this.height;return new t({x:this.x+e,y:this.y+n,width:r,height:o})},t.prototype.padAtBorders=function(t,e){var n=this.width+1,r=this.height+1,o=n,a=r,i=this.left,s=this.top,u=this.right,c=this.bottom;return u>e&&(o=-u+e+n,u=e),c>t&&(a=-c+t+r,c=t),i<1&&(a=2-i,i=1),s<1&&(a=2-s,s=1),{dy:1,edy:a,dx:1,edx:o,y:s,ey:c,x:i,ex:u,w:n,h:r}},t.prototype.calibrate=function(e){return new t({left:this.left+e.left*this.width,top:this.top+e.top*this.height,right:this.right+e.right*this.width,bottom:this.bottom+e.bottom*this.height}).toSquare().round()},t}(),zt=function(t){function e(e,n,r,o,a){return void 0===a&&(a=!1),t.call(this,{left:e,top:n,right:r,bottom:o},a)||this}return Object(St.c)(e,t),e}(jt),Vt=function(){function t(t,e,n,r,o){this._imageDims=new At(o.width,o.height),this._score=t,this._classScore=e,this._className=n,this._box=new jt(r).rescale(this._imageDims)}return Object.defineProperty(t.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"className",{get:function(){return this._className},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"box",{get:function(){return this._box},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageDims",{get:function(){return this._imageDims},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageWidth",{get:function(){return this.imageDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageHeight",{get:function(){return this.imageDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"relativeBox",{get:function(){return new jt(this._box).rescale(this.imageDims.reverse())},enumerable:!0,configurable:!0}),t.prototype.forSize=function(e,n){return new t(this.score,this.classScore,this.className,this.relativeBox,{width:e,height:n})},t}(),Gt=function(t){function e(e,n,r){return t.call(this,e,e,"",n,r)||this}return Object(St.c)(e,t),e.prototype.forSize=function(n,r){var o=t.prototype.forSize.call(this,n,r);return new e(o.score,o.relativeBox,o.imageDims)},e}(Vt);function Ht(t,e,n){void 0===n&&(n=!0);var r=Math.max(0,Math.min(t.right,e.right)-Math.max(t.left,e.left))*Math.max(0,Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top));return n?r/(t.area+e.area-r):r/Math.min(t.area,e.area)}function qt(t,e,n,r){void 0===r&&(r=!0);for(var o=e.map((function(t,e){return{score:t,boxIndex:e}})).sort((function(t,e){return t.score-e.score})).map((function(t){return t.boxIndex})),a=[],i=function(){var e=o.pop();a.push(e);for(var i=o,s=[],u=0;u<i.length;u++){var c=i[u],l=t[e],f=t[c];s.push(Ht(l,f,r))}o=o.filter((function(t,e){return s[e]<=n}))};o.length>0;)i();return a}function Kt(t,e){return Rt.L((function(){var n=e[0],r=e[1],o=e[2],a=Rt.n(Object(St.e)(t.shape.slice(0,3),[1]),n),i=Rt.n(Object(St.e)(t.shape.slice(0,3),[1]),r),s=Rt.n(Object(St.e)(t.shape.slice(0,3),[1]),o),u=Rt.h([a,i,s],3);return Rt.F(t,u)}))}function Xt(t){return 1/(1+Math.exp(-t))}var $t=function(t){function e(e,n,r,o,a){return void 0===a&&(a=!1),t.call(this,{x:e,y:n,width:r,height:o},a)||this}return Object(St.c)(e,t),e}(jt),Yt=function(){function t(t,e,n){void 0===n&&(n=new Ut(0,0));var r=e.width,o=e.height;this._imgDims=new At(r,o),this._shift=n,this._positions=t.map((function(t){return t.mul(new Ut(r,o)).add(n)}))}return Object.defineProperty(t.prototype,"shift",{get:function(){return new Ut(this._shift.x,this._shift.y)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageWidth",{get:function(){return this._imgDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageHeight",{get:function(){return this._imgDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"positions",{get:function(){return this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"relativePositions",{get:function(){var t=this;return this._positions.map((function(e){return e.sub(t._shift).div(new Ut(t.imageWidth,t.imageHeight))}))},enumerable:!0,configurable:!0}),t.prototype.forSize=function(t,e){return new this.constructor(this.relativePositions,{width:t,height:e})},t.prototype.shiftBy=function(t,e){return new this.constructor(this.relativePositions,this._imgDims,new Ut(t,e))},t.prototype.shiftByPoint=function(t){return this.shiftBy(t.x,t.y)},t.prototype.align=function(t,e){if(void 0===e&&(e={}),t){var n=t instanceof Gt?t.box.floor():new jt(t);return this.shiftBy(n.x,n.y).align(null,e)}var r=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},e),o=r.useDlibAlignment,a=r.minBoxPadding;return o?this.alignDlib():this.alignMinBbox(a)},t.prototype.alignDlib=function(){var t=this.getRefPointsForAlignment(),e=t[0],n=t[1],r=t[2],o=function(t){return r.sub(t).magnitude()},a=(o(e)+o(n))/2,i=Math.floor(a/.45),s=Pt(t),u=Math.floor(Math.max(0,s.x-.5*i)),c=Math.floor(Math.max(0,s.y-.43*i));return new $t(u,c,Math.min(i,this.imageWidth+u),Math.min(i,this.imageHeight+c))},t.prototype.alignMinBbox=function(t){var e,n,r,o,a,i,s,u=(e=this.positions,n=e.map((function(t){return t.x})),r=e.map((function(t){return t.y})),o=n.reduce((function(t,e){return e<t?e:t}),1/0),a=r.reduce((function(t,e){return e<t?e:t}),1/0),i=n.reduce((function(t,e){return t<e?e:t}),0),s=r.reduce((function(t,e){return t<e?e:t}),0),new zt(o,a,i,s));return u.pad(u.width*t,u.height*t)},t.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class")},t}(),Jt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.getRefPointsForAlignment=function(){var t=this.positions;return[t[0],t[1],Pt([t[3],t[4]])]},e}(Yt),Qt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.getJawOutline=function(){return this.positions.slice(0,17)},e.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22)},e.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27)},e.prototype.getNose=function(){return this.positions.slice(27,36)},e.prototype.getLeftEye=function(){return this.positions.slice(36,42)},e.prototype.getRightEye=function(){return this.positions.slice(42,48)},e.prototype.getMouth=function(){return this.positions.slice(48,68)},e.prototype.getRefPointsForAlignment=function(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(Pt)},e}(Yt),Zt=function(){function t(t,e){this._label=t,this._distance=e}return Object.defineProperty(t.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"distance",{get:function(){return this._distance},enumerable:!0,configurable:!0}),t.prototype.toString=function(t){return void 0===t&&(t=!0),this.label+(t?" ("+Ft(this.distance)+")":"")},t}(),te=function(t){function e(e,n){var r=t.call(this,e)||this;return r._label=n,r}return Object(St.c)(e,t),e.assertIsValidLabeledBox=function(t,e){if(jt.assertIsValidBox(t,e),!Lt(t.label))throw new Error(e+" - expected property label ("+t.label+") to be a number")},Object.defineProperty(e.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),e}(jt),ee=function(){function t(t,e){if("string"!=typeof t)throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(e)||e.some((function(t){return!(t instanceof Float32Array)})))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=t,this._descriptors=e}return Object.defineProperty(t.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"descriptors",{get:function(){return this._descriptors},enumerable:!0,configurable:!0}),t.prototype.toJSON=function(){return{label:this.label,descriptors:this.descriptors.map((function(t){return Array.from(t)}))}},t.fromJSON=function(e){var n=e.descriptors.map((function(t){return new Float32Array(t)}));return new t(e.label,n)},t}();!function(t){function e(e,n,r,o){var a=t.call(this,e,n)||this;return a._score=r,a._classScore=o,a}Object(St.c)(e,t),e.assertIsValidPredictedBox=function(t,e){if(te.assertIsValidLabeledBox(t,e),!Wt(t.score)||!Wt(t.classScore))throw new Error(e+" - expected properties score ("+t.score+") and ("+t.classScore+") to be a number between [0, 1]")},Object.defineProperty(e.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0})}(te);function ne(t){return t.detection instanceof Gt}function re(t,e){var n={detection:e};return Object.assign({},t,n)}function oe(){var t=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment")};return{Canvas:HTMLCanvasElement,CanvasRenderingContext2D:CanvasRenderingContext2D,Image:HTMLImageElement,ImageData:ImageData,Video:HTMLVideoElement,createCanvasElement:function(){return document.createElement("canvas")},createImageElement:function(){return document.createElement("img")},fetch:t,readFile:function(){throw new Error("readFile - filesystem not available for browser environment")}}}var ae=n(9),ie=n(13);function se(){return"object"==typeof window&&"undefined"!=typeof document&&"undefined"!=typeof HTMLImageElement&&"undefined"!=typeof HTMLCanvasElement&&"undefined"!=typeof HTMLVideoElement&&"undefined"!=typeof ImageData&&"undefined"!=typeof CanvasRenderingContext2D}var ue,ce=n(14);function le(t){ue=t}function fe(){se()&&le(oe()),Object(ce.a)()&&le(Object(ie.a)())}var he,pe={getEnv:function(){if(!ue)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return ue},setEnv:le,initialize:fe,createBrowserEnv:oe,createFileSystem:ae.a,createNodejsEnv:ie.a,monkeyPatch:function(t){if(ue||fe(),!ue)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var e=t.Canvas,n=void 0===e?ue.Canvas:e,r=t.Image,o=void 0===r?ue.Image:r;ue.Canvas=n,ue.Image=o,ue.createCanvasElement=t.createCanvasElement||function(){return new n},ue.createImageElement=t.createImageElement||function(){return new o},ue.ImageData=t.ImageData||ue.ImageData,ue.Video=t.Video||ue.Video,ue.fetch=t.fetch||ue.fetch,ue.readFile=t.readFile||ue.readFile},isBrowser:se,isNodejs:ce.a};function de(t){return pe.isNodejs()||"string"!=typeof t?t:document.getElementById(t)}function ve(t){var e=pe.getEnv(),n=e.Canvas;if(t instanceof e.CanvasRenderingContext2D)return t;var r=de(t);if(!(r instanceof n))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var o=r.getContext("2d");if(!o)throw new Error("resolveContext2d - canvas 2d context is null");return o}fe(),function(t){t.TOP_LEFT="TOP_LEFT",t.TOP_RIGHT="TOP_RIGHT",t.BOTTOM_LEFT="BOTTOM_LEFT",t.BOTTOM_RIGHT="BOTTOM_RIGHT"}(he||(he={}));var me=function(t){void 0===t&&(t={});var e=t.anchorPosition,n=t.backgroundColor,r=t.fontColor,o=t.fontSize,a=t.fontStyle,i=t.padding;this.anchorPosition=e||he.TOP_LEFT,this.backgroundColor=n||"rgba(0, 0, 0, 0.5)",this.fontColor=r||"rgba(255, 255, 255, 1)",this.fontSize=o||14,this.fontStyle=a||"Georgia",this.padding=i||4},ge=function(){function t(e,n,r){void 0===r&&(r={}),this.text="string"==typeof e?[e]:e instanceof t?e.text:e,this.anchor=n,this.options=new me(r)}return t.prototype.measureWidth=function(t){var e=this.options.padding;return this.text.map((function(e){return t.measureText(e).width})).reduce((function(t,e){return t<e?e:t}),0)+2*e},t.prototype.measureHeight=function(){var t=this.options,e=t.fontSize,n=t.padding;return this.text.length*e+2*n},t.prototype.getUpperLeft=function(t,e){var n=this.options.anchorPosition,r=n===he.BOTTOM_RIGHT||n===he.TOP_RIGHT,o=n===he.BOTTOM_LEFT||n===he.BOTTOM_RIGHT,a=this.measureWidth(t),i=this.measureHeight(),s=r?this.anchor.x-a:this.anchor.x,u=o?this.anchor.y-i:this.anchor.y;if(e){var c=e.width,l=e.height;return{x:Math.max(Math.min(s,c-a),0),y:Math.max(Math.min(u,l-i),0)}}return{x:s,y:u}},t.prototype.draw=function(t){var e=de(t),n=ve(e),r=this.options,o=r.backgroundColor,a=r.fontColor,i=r.fontSize,s=r.fontStyle,u=r.padding;n.font=i+"px "+s;var c=this.measureWidth(n),l=this.measureHeight();n.fillStyle=o;var f=this.getUpperLeft(n,e);n.fillRect(f.x,f.y,c,l),n.fillStyle=a,this.text.forEach((function(t,e){var r=u+f.x,o=u+f.y+(e+1)*i;n.fillText(t,r,o)}))},t}(),ye=function(t){void 0===t&&(t={});var e=t.boxColor,n=t.lineWidth,r=t.label,o=t.drawLabelOptions;this.boxColor=e||"rgba(0, 0, 255, 1)",this.lineWidth=n||2,this.label=r;var a={anchorPosition:he.BOTTOM_LEFT,backgroundColor:this.boxColor};this.drawLabelOptions=new me(Object.assign({},a,o))},be=function(){function t(t,e){void 0===e&&(e={}),this.box=new jt(t),this.options=new ye(e)}return t.prototype.draw=function(t){var e=ve(t),n=this.options,r=n.boxColor,o=n.lineWidth,a=this.box,i=a.x,s=a.y,u=a.width,c=a.height;e.strokeStyle=r,e.lineWidth=o,e.strokeRect(i,s,u,c);var l=this.options.label;l&&new ge([l],{x:i-o/2,y:s},this.options.drawLabelOptions).draw(t)},t}();function xe(t,e){(Array.isArray(e)?e:[e]).forEach((function(e){var n=e instanceof Gt?e.score:ne(e)?e.detection.score:void 0,r=e instanceof Gt?e.box:ne(e)?e.detection.box:new jt(e),o=n?""+Ft(n):void 0;new be(r,{label:o}).draw(t)}))}function we(t){var e=pe.getEnv(),n=e.Image,r=e.Video;return t instanceof n&&t.complete||t instanceof r&&t.readyState>=3}function Ee(t){var e=pe.getEnv(),n=e.Image,r=e.Video;return t instanceof n?new At(t.naturalWidth,t.naturalHeight):t instanceof r?new At(t.videoWidth,t.videoHeight):new At(t.width,t.height)}function Ce(t){var e=t.width,n=t.height,r=(0,pe.getEnv().createCanvasElement)();return r.width=e,r.height=n,r}function _e(t,e){var n=pe.getEnv().ImageData;if(!(t instanceof n||we(t)))throw new Error("createCanvasFromMedia - media has not finished loading yet");var r=e||Ee(t),o=r.width,a=r.height,i=Ce({width:o,height:a});return t instanceof n?ve(i).putImageData(t,0,0):ve(i).drawImage(t,0,0,o,a),i}function ke(t,e){return Object(St.b)(this,void 0,void 0,(function(){var n,r,o,a,i,s;return Object(St.d)(this,(function(u){switch(u.label){case 0:return n=e||pe.getEnv().createCanvasElement(),r=t.shape.slice(Dt(t)?1:0),o=r[0],a=r[1],i=r[2],s=Rt.L((function(){return t.as3D(o,a,i).toInt()})),[4,Rt.f.toPixels(s,n)];case 1:return u.sent(),s.dispose(),[2,n]}}))}))}function Re(t){var e=pe.getEnv(),n=e.Image,r=e.Canvas,o=e.Video;return t instanceof n||t instanceof r||t instanceof o}var Ie=function(){function t(t,e){var n=this;if(void 0===e&&(e=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(t))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+t);this._treatAsBatchInput=e,this._batchSize=t.length,t.forEach((function(t,e){if(Tt(t))return n._imageTensors[e]=t,void(n._inputDimensions[e]=t.shape);if(Dt(t)){var r=t.shape[0];if(1!==r)throw new Error("NetInput - tf.Tensor4D with batchSize "+r+" passed, but not supported in input array");return n._imageTensors[e]=t,void(n._inputDimensions[e]=t.shape.slice(1))}var o=t instanceof pe.getEnv().Canvas?t:_e(t);n._canvases[e]=o,n._inputDimensions[e]=[o.height,o.width,3]}))}return Object.defineProperty(t.prototype,"imageTensors",{get:function(){return this._imageTensors},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"canvases",{get:function(){return this._canvases},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isBatchInput",{get:function(){return this.batchSize>1||this._treatAsBatchInput},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"batchSize",{get:function(){return this._batchSize},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"inputDimensions",{get:function(){return this._inputDimensions},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"reshapedInputDimensions",{get:function(){var t=this;return Bt(this.batchSize,0,1).map((function(e,n){return t.getReshapedInputDimensions(n)}))},enumerable:!0,configurable:!0}),t.prototype.getInput=function(t){return this.canvases[t]||this.imageTensors[t]},t.prototype.getInputDimensions=function(t){return this._inputDimensions[t]},t.prototype.getInputHeight=function(t){return this._inputDimensions[t][0]},t.prototype.getInputWidth=function(t){return this._inputDimensions[t][1]},t.prototype.getReshapedInputDimensions=function(t){if("number"!=typeof this.inputSize)throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");return function(t,e){var n=t.width,r=t.height,o=e/Math.max(r,n);return new At(Math.round(n*o),Math.round(r*o))}({width:this.getInputWidth(t),height:this.getInputHeight(t)},this.inputSize)},t.prototype.toBatchTensor=function(t,e){var n=this;return void 0===e&&(e=!0),this._inputSize=t,Rt.L((function(){var r=Bt(n.batchSize,0,1).map((function(r){var o=n.getInput(r);if(o instanceof Rt.a){var a=Dt(o)?o:o.expandDims();return(a=function(t,e){return void 0===e&&(e=!1),Rt.L((function(){var n=t.shape.slice(1),r=n[0],o=n[1];if(r===o)return t;var a=Math.abs(r-o),i=Math.round(a*(e?.5:1)),s=r>o?2:1,u=function(e){var n=t.shape.slice();return n[s]=e,Rt.n(n,0)},c=u(i),l=a-c.shape[s],f=[e&&l?u(l):null,t,c].filter((function(t){return!!t})).map((function(t){return t.toFloat()}));return Rt.h(f,s)}))}(a,e)).shape[1]===t&&a.shape[2]===t||(a=Rt.o.resizeBilinear(a,[t,t])),a.as3D(t,t,3)}if(o instanceof pe.getEnv().Canvas)return Rt.f.fromPixels(function(t,e,n){void 0===n&&(n=!1);var r=pe.getEnv(),o=r.Image,a=r.Canvas;if(!(t instanceof o||t instanceof a))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");var i=Ee(t),s=e/Math.max(i.height,i.width),u=s*i.width,c=s*i.height,l=Ce({width:e,height:e}),f=t instanceof a?t:_e(t),h=Math.abs(u-c)/2,p=n&&u<c?h:0,d=n&&c<u?h:0;return ve(l).drawImage(f,p,d,u,c),l}(o,t,e));throw new Error("toBatchTensor - at batchIdx "+r+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+o)}));return Rt.E(r.map((function(t){return t.toFloat()}))).as4D(n.batchSize,t,t,3)}))},t}();function Se(t){return Object(St.b)(this,void 0,void 0,(function(){var e,n,r;return Object(St.d)(this,(function(o){switch(o.label){case 0:if(t instanceof Ie)return[2,t];if(!(e=Array.isArray(t)?t:[t]).length)throw new Error("toNetInput - empty array passed as input");return n=function(e){return Array.isArray(t)?" at input index "+e+":":""},(r=e.map(de)).forEach((function(t,r){if(!Re(t)&&!Tt(t)&&!Dt(t)){if("string"==typeof e[r])throw new Error("toNetInput -"+n(r)+" string passed, but could not resolve HTMLElement for element id "+e[r]);throw new Error("toNetInput -"+n(r)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id")}if(Dt(t)){var o=t.shape[0];if(1!==o)throw new Error("toNetInput -"+n(r)+" tf.Tensor4D with batchSize "+o+" passed, but not supported in input array")}})),[4,Promise.all(r.map((function(t){return Re(t)&&(e=t,new Promise((function(t,n){if(e instanceof pe.getEnv().Canvas||we(e))return t();function r(e){e.currentTarget&&(e.currentTarget.removeEventListener("load",r),e.currentTarget.removeEventListener("error",o),t(e))}function o(t){t.currentTarget&&(t.currentTarget.removeEventListener("load",r),t.currentTarget.removeEventListener("error",o),n(t))}e.addEventListener("load",r),e.addEventListener("error",o)})));var e})))];case 1:return o.sent(),[2,new Ie(r,Array.isArray(t))]}}))}))}function Ae(t,e){return Object(St.b)(this,void 0,void 0,(function(){var n,r,o,a,i,s;return Object(St.d)(this,(function(u){switch(u.label){case 0:return n=pe.getEnv().Canvas,r=t,t instanceof n?[3,5]:[4,Se(t)];case 1:if((o=u.sent()).batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return(a=o.getInput(0))instanceof n?(i=a,[3,4]):[3,2];case 2:return[4,ke(a)];case 3:i=u.sent(),u.label=4;case 4:r=i,u.label=5;case 5:return s=ve(r),[2,e.map((function(t){return t instanceof Gt?t.forSize(r.width,r.height).box.floor():t})).map((function(t){return t.clipAtImageBorders(r.width,r.height)})).map((function(t){var e=t.x,n=t.y,r=t.width,o=t.height,a=Ce({width:r,height:o});return ve(a).putImageData(s.getImageData(e,n,r,o),0,0),a}))]}}))}))}function Oe(t,e){return Object(St.b)(this,void 0,void 0,(function(){return Object(St.d)(this,(function(n){if(!Tt(t)&&!Dt(t))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(Dt(t)&&t.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return[2,Rt.L((function(){var n=t.shape.slice(Dt(t)?1:0),r=n[0],o=n[1],a=n[2];return e.map((function(t){return t instanceof Gt?t.forSize(o,r).box:t})).map((function(t){return t.clipAtImageBorders(o,r)})).map((function(e){var n=e.x,i=e.y,s=e.width,u=e.height;return Rt.C(t.as3D(r,o,a),[i,n,0],[u,s,a])}))}))]}))}))}function Te(t,e){return Object(St.b)(this,void 0,void 0,(function(){var n;return Object(St.d)(this,(function(r){switch(r.label){case 0:return[4,(0,pe.getEnv().fetch)(t,e)];case 1:if(!((n=r.sent()).status<400))throw new Error("failed to fetch: ("+n.status+") "+n.statusText+", from url: "+n.url);return[2,n]}}))}))}function De(t){return Object(St.b)(this,void 0,void 0,(function(){return Object(St.d)(this,(function(e){switch(e.label){case 0:return[4,Te(t)];case 1:return[2,e.sent().json()]}}))}))}function Ne(t,e){var n=e+"-weights_manifest.json";if(!t)return{modelBaseUri:"",manifestUri:n};if("/"===t)return{modelBaseUri:"/",manifestUri:"/"+n};var r=t.startsWith("http://")?"http://":t.startsWith("https://")?"https://":"",o=(t=t.replace(r,"")).split("/").filter((function(t){return t})),a=t.endsWith(".json")?o[o.length-1]:n,i=r+(t.endsWith(".json")?o.slice(0,o.length-1):o).join("/");return{modelBaseUri:i=t.startsWith("/")?"/"+i:i,manifestUri:"/"===i?"/"+a:i+"/"+a}}function Fe(t,e){return Object(St.b)(this,void 0,void 0,(function(){var n,r,o,a;return Object(St.d)(this,(function(i){switch(i.label){case 0:return n=Ne(t,e),r=n.manifestUri,o=n.modelBaseUri,[4,De(r)];case 1:return a=i.sent(),[2,Rt.p.loadWeights(a,o)]}}))}))}var Me=function(){function t(t){this._name=t,this._params=void 0,this._paramMappings=[]}return Object.defineProperty(t.prototype,"params",{get:function(){return this._params},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"paramMappings",{get:function(){return this._paramMappings},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isLoaded",{get:function(){return!!this.params},enumerable:!0,configurable:!0}),t.prototype.getParamFromPath=function(t){var e=this.traversePropertyPath(t);return e.obj[e.objProp]},t.prototype.reassignParamFromPath=function(t,e){var n=this.traversePropertyPath(t),r=n.obj,o=n.objProp;r[o].dispose(),r[o]=e},t.prototype.getParamList=function(){var t=this;return this._paramMappings.map((function(e){var n=e.paramPath;return{path:n,tensor:t.getParamFromPath(n)}}))},t.prototype.getTrainableParams=function(){return this.getParamList().filter((function(t){return t.tensor instanceof Rt.b}))},t.prototype.getFrozenParams=function(){return this.getParamList().filter((function(t){return!(t.tensor instanceof Rt.b)}))},t.prototype.variable=function(){var t=this;this.getFrozenParams().forEach((function(e){var n=e.path,r=e.tensor;t.reassignParamFromPath(n,r.variable())}))},t.prototype.freeze=function(){var t=this;this.getTrainableParams().forEach((function(e){var n=e.path,r=e.tensor,o=Rt.G(r.dataSync());r.dispose(),t.reassignParamFromPath(n,o)}))},t.prototype.dispose=function(t){void 0===t&&(t=!0),this.getParamList().forEach((function(e){if(t&&e.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+e.path);e.tensor.dispose()})),this._params=void 0},t.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map((function(t){var e=t.tensor;return Array.from(e.dataSync())})).reduce((function(t,e){return t.concat(e)})))},t.prototype.load=function(t){return Object(St.b)(this,void 0,void 0,(function(){return Object(St.d)(this,(function(e){switch(e.label){case 0:return t instanceof Float32Array?(this.extractWeights(t),[2]):[4,this.loadFromUri(t)];case 1:return e.sent(),[2]}}))}))},t.prototype.loadFromUri=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e;return Object(St.d)(this,(function(n){switch(n.label){case 0:if(t&&"string"!=typeof t)throw new Error(this._name+".loadFromUri - expected model uri");return[4,Fe(t,this.getDefaultModelName())];case 1:return e=n.sent(),this.loadFromWeightMap(e),[2]}}))}))},t.prototype.loadFromDisk=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e,n,r,o,a,i,s,u,c,l;return Object(St.d)(this,(function(f){switch(f.label){case 0:if(t&&"string"!=typeof t)throw new Error(this._name+".loadFromDisk - expected model file path");return e=pe.getEnv().readFile,n=Ne(t,this.getDefaultModelName()),r=n.manifestUri,o=n.modelBaseUri,a=function(t){return Promise.all(t.map((function(t){return e(t).then((function(t){return t.buffer}))})))},i=Rt.p.weightsLoaderFactory(a),c=(u=JSON).parse,[4,e(r)];case 1:return s=c.apply(u,[f.sent().toString()]),[4,i(s,o)];case 2:return l=f.sent(),this.loadFromWeightMap(l),[2]}}))}))},t.prototype.loadFromWeightMap=function(t){var e=this.extractParamsFromWeigthMap(t),n=e.paramMappings,r=e.params;this._paramMappings=n,this._params=r},t.prototype.extractWeights=function(t){var e=this.extractParams(t),n=e.paramMappings,r=e.params;this._paramMappings=n,this._params=r},t.prototype.traversePropertyPath=function(t){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var e=t.split("/").reduce((function(e,n){if(!e.nextObj.hasOwnProperty(n))throw new Error("traversePropertyPath - object does not have property "+n+", for path "+t);return{obj:e.nextObj,objProp:n,nextObj:e.nextObj[n]}}),{nextObj:this.params}),n=e.obj,r=e.objProp;if(!(n&&r&&n[r]instanceof Rt.a))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+t);return{obj:n,objProp:r}},t}();function Pe(t,e,n){return Rt.L((function(){var r=Rt.z(t,e.depthwise_filter,e.pointwise_filter,n,"same");return r=Rt.c(r,e.bias)}))}function Be(t,e,n){return void 0===n&&(n=!1),Rt.L((function(){var r=Rt.w(n?Rt.c(Rt.i(t,e.conv0.filters,[2,2],"same"),e.conv0.bias):Pe(t,e.conv0,[2,2])),o=Pe(r,e.conv1,[1,1]),a=Pe(Rt.w(Rt.c(r,o)),e.conv2,[1,1]);return Rt.w(Rt.c(r,Rt.c(o,a)))}))}function Le(t,e,n,r){return void 0===n&&(n=!1),void 0===r&&(r=!0),Rt.L((function(){var o=Rt.w(n?Rt.c(Rt.i(t,e.conv0.filters,r?[2,2]:[1,1],"same"),e.conv0.bias):Pe(t,e.conv0,r?[2,2]:[1,1])),a=Pe(o,e.conv1,[1,1]),i=Pe(Rt.w(Rt.c(o,a)),e.conv2,[1,1]),s=Pe(Rt.w(Rt.c(o,Rt.c(a,i))),e.conv3,[1,1]);return Rt.w(Rt.c(o,Rt.c(a,Rt.c(i,s))))}))}function We(t,e,n,r){return void 0===n&&(n="same"),void 0===r&&(r=!1),Rt.L((function(){var o=Rt.c(Rt.i(t,e.filters,[1,1],n),e.bias);return r?Rt.w(o):o}))}function Ue(t,e){Object.keys(t).forEach((function(n){e.some((function(t){return t.originalPath===n}))||t[n].dispose()}))}function je(t,e){return function(n,r,o,a){var i=Rt.K(t(n*r*o*o),[o,o,n,r]),s=Rt.H(t(r));return e.push({paramPath:a+"/filters"},{paramPath:a+"/bias"}),{filters:i,bias:s}}}function ze(t,e){return function(n,r,o){var a=Rt.I(t(n*r),[n,r]),i=Rt.H(t(r));return e.push({paramPath:o+"/weights"},{paramPath:o+"/bias"}),{weights:a,bias:i}}}var Ve=function(t,e,n){this.depthwise_filter=t,this.pointwise_filter=e,this.bias=n};function Ge(t,e){return function(n,r,o){var a=Rt.K(t(9*n),[3,3,n,1]),i=Rt.K(t(n*r),[1,1,n,r]),s=Rt.H(t(r));return e.push({paramPath:o+"/depthwise_filter"},{paramPath:o+"/pointwise_filter"},{paramPath:o+"/bias"}),new Ve(a,i,s)}}function He(t){return function(e){var n=t(e+"/depthwise_filter",4),r=t(e+"/pointwise_filter",4),o=t(e+"/bias",1);return new Ve(n,r,o)}}function qe(t,e){return function(n,r,o){var a=t[n];if(!Ot(a,r))throw new Error("expected weightMap["+n+"] to be a Tensor"+r+"D, instead have "+a);return e.push({originalPath:n,paramPath:o||n}),a}}function Ke(t){var e=t;return{extractWeights:function(t){var n=e.slice(0,t);return e=e.slice(t),n},getRemainingWeights:function(){return e}}}function Xe(t,e){var n=je(t,e),r=Ge(t,e);function o(t,e,o,a){return void 0===a&&(a=!1),{conv0:a?n(t,e,3,o+"/conv0"):r(t,e,o+"/conv0"),conv1:r(e,e,o+"/conv1"),conv2:r(e,e,o+"/conv2")}}return{extractDenseBlock3Params:o,extractDenseBlock4Params:function(t,e,n,a){void 0===a&&(a=!1);var i=o(t,e,n,a);return{conv0:i.conv0,conv1:i.conv1,conv2:i.conv2,conv3:r(e,e,n+"/conv3")}}}}function $e(t){return function(e){return{filters:t(e+"/filters",4),bias:t(e+"/bias",1)}}}function Ye(t,e){var n=qe(t,e),r=$e(n),o=He(n);return{extractDenseBlock3Params:function(t,e){return void 0===e&&(e=!1),{conv0:e?r(t+"/conv0"):o(t+"/conv0"),conv1:o(t+"/conv1"),conv2:o(t+"/conv2")}},extractDenseBlock4Params:function(t,e){return void 0===e&&(e=!1),{conv0:e?r(t+"/conv0"):o(t+"/conv0"),conv1:o(t+"/conv1"),conv2:o(t+"/conv2"),conv3:o(t+"/conv3")}}}}var Je=function(t){function e(){return t.call(this,"FaceFeatureExtractor")||this}return Object(St.c)(e,t),e.prototype.forwardInput=function(t){var e=this.params;if(!e)throw new Error("FaceFeatureExtractor - load model before inference");return Rt.L((function(){var n=Le(Kt(t.toBatchTensor(112,!0),[122.782,117.001,104.298]).div(Rt.y(255)),e.dense0,!0);return n=Le(n,e.dense1),n=Le(n,e.dense2),n=Le(n,e.dense3),n=Rt.d(n,[7,7],[2,2],"valid")}))},e.prototype.forward=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e;return Object(St.d)(this,(function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Se(t)];case 1:return[2,e.apply(this,[n.sent()])]}}))}))},e.prototype.getDefaultModelName=function(){return"face_feature_extractor_model"},e.prototype.extractParamsFromWeigthMap=function(t){return function(t){var e=[],n=Ye(t,e).extractDenseBlock4Params,r={dense0:n("dense0",!0),dense1:n("dense1"),dense2:n("dense2"),dense3:n("dense3")};return Ue(t,e),{params:r,paramMappings:e}}(t)},e.prototype.extractParams=function(t){return function(t){var e=[],n=Ke(t),r=n.extractWeights,o=n.getRemainingWeights,a=Xe(r,e).extractDenseBlock4Params,i=a(3,32,"dense0",!0),s=a(32,64,"dense1"),u=a(64,128,"dense2"),c=a(128,256,"dense3");if(0!==o().length)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:e,params:{dense0:i,dense1:s,dense2:u,dense3:c}}}(t)},e}(Me);function Qe(t,e){return Rt.L((function(){return Rt.c(Rt.q(t,e.weights),e.bias)}))}function Ze(t){var e={},n={};return Object.keys(t).forEach((function(r){(r.startsWith("fc")?n:e)[r]=t[r]})),{featureExtractorMap:e,classifierMap:n}}var tn=function(t){function e(e,n){var r=t.call(this,e)||this;return r._faceFeatureExtractor=n,r}return Object(St.c)(e,t),Object.defineProperty(e.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),e.prototype.runNet=function(t){var e=this,n=this.params;if(!n)throw new Error(this._name+" - load model before inference");return Rt.L((function(){var r=t instanceof Ie?e.faceFeatureExtractor.forwardInput(t):t;return Qe(r.as2D(r.shape[0],-1),n.fc)}))},e.prototype.dispose=function(e){void 0===e&&(e=!0),this.faceFeatureExtractor.dispose(e),t.prototype.dispose.call(this,e)},e.prototype.loadClassifierParams=function(t){var e=this.extractClassifierParams(t),n=e.params,r=e.paramMappings;this._params=n,this._paramMappings=r},e.prototype.extractClassifierParams=function(t){return function(t,e,n){var r=[],o=Ke(t),a=o.extractWeights,i=o.getRemainingWeights,s=ze(a,r)(e,n,"fc");if(0!==i().length)throw new Error("weights remaing after extract: "+i().length);return{paramMappings:r,params:{fc:s}}}(t,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},e.prototype.extractParamsFromWeigthMap=function(t){var e=Ze(t),n=e.featureExtractorMap,r=e.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(n),function(t){var e,n=[],r=qe(t,n),o={fc:(e="fc",{weights:r(e+"/weights",2),bias:r(e+"/bias",1)})};return Ue(t,n),{params:o,paramMappings:n}}(r)},e.prototype.extractParams=function(t){var e=this.getClassifierChannelsIn(),n=this.getClassifierChannelsOut(),r=n*e+n,o=t.slice(0,t.length-r),a=t.slice(t.length-r);return this.faceFeatureExtractor.extractWeights(o),this.extractClassifierParams(a)},e}(Me),en=["neutral","happy","sad","angry","fearful","disgusted","surprised"],nn=function(){function t(t){var e=this;if(7!==t.length)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+t.length);en.forEach((function(n,r){e[n]=t[r]}))}return t.prototype.asSortedArray=function(){var t=this;return en.map((function(e){return{expression:e,probability:t[e]}})).sort((function(t,e){return e.probability-t.probability}))},t}(),rn=function(t){function e(e){return void 0===e&&(e=new Je),t.call(this,"FaceExpressionNet",e)||this}return Object(St.c)(e,t),e.prototype.forwardInput=function(t){var e=this;return Rt.L((function(){return Rt.D(e.runNet(t))}))},e.prototype.forward=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e;return Object(St.d)(this,(function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Se(t)];case 1:return[2,e.apply(this,[n.sent()])]}}))}))},e.prototype.predictExpressions=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e,n,r,o,a=this;return Object(St.d)(this,(function(i){switch(i.label){case 0:return[4,Se(t)];case 1:return e=i.sent(),[4,this.forwardInput(e)];case 2:return n=i.sent(),[4,Promise.all(Rt.O(n).map((function(t){return Object(St.b)(a,void 0,void 0,(function(){var e;return Object(St.d)(this,(function(n){switch(n.label){case 0:return[4,t.data()];case 1:return e=n.sent(),t.dispose(),[2,e]}}))}))})))];case 3:return r=i.sent(),n.dispose(),o=r.map((function(t){return new nn(t)})),[2,e.isBatchInput?o:o[0]]}}))}))},e.prototype.getDefaultModelName=function(){return"face_expression_model"},e.prototype.getClassifierChannelsIn=function(){return 256},e.prototype.getClassifierChannelsOut=function(){return 7},e}(tn);function on(t,e){var n={expressions:e};return Object.assign({},t,n)}function an(t,e,n,r){void 0===n&&(n=.1),(Array.isArray(e)?e:[e]).forEach((function(e){var o=e instanceof nn?e:e.expressions instanceof nn?e.expressions:void 0;if(!o)throw new Error("drawFaceExpressions - expected faceExpressions to be FaceExpressions | WithFaceExpressions<{}> or array thereof");var a=o.asSortedArray().filter((function(t){return t.probability>n})),i=ne(e)?e.detection.box.bottomLeft:r||new Ut(0,0);new ge(a.map((function(t){return t.expression+" ("+Ft(t.probability)+")"})),i).draw(t)}))}function sn(t){return ne(t)&&t.landmarks instanceof Yt&&t.unshiftedLandmarks instanceof Yt&&t.alignedRect instanceof Gt}function un(t,e){var n=t.detection.box,r=e.shiftBy(n.x,n.y),o=r.align(),a=t.detection.imageDims,i={landmarks:r,unshiftedLandmarks:e,alignedRect:new Gt(t.detection.score,o.rescale(a.reverse()),a)};return Object.assign({},t,i)}var cn=function(t){void 0===t&&(t={});var e=t.drawLines,n=void 0===e||e,r=t.drawPoints,o=void 0===r||r,a=t.lineWidth,i=t.lineColor,s=t.pointSize,u=t.pointColor;this.drawLines=n,this.drawPoints=o,this.lineWidth=a||1,this.pointSize=s||2,this.lineColor=i||"rgba(0, 255, 255, 1)",this.pointColor=u||"rgba(255, 0, 255, 1)"},ln=function(){function t(t,e){void 0===e&&(e={}),this.faceLandmarks=t,this.options=new cn(e)}return t.prototype.draw=function(t){var e=ve(t),n=this.options,r=n.drawLines,o=n.drawPoints,a=n.lineWidth,i=n.lineColor,s=n.pointSize,u=n.pointColor;if(r&&this.faceLandmarks instanceof Qt&&(e.strokeStyle=i,e.lineWidth=a,It(e,this.faceLandmarks.getJawOutline()),It(e,this.faceLandmarks.getLeftEyeBrow()),It(e,this.faceLandmarks.getRightEyeBrow()),It(e,this.faceLandmarks.getNose()),It(e,this.faceLandmarks.getLeftEye(),!0),It(e,this.faceLandmarks.getRightEye(),!0),It(e,this.faceLandmarks.getMouth(),!0)),o){e.strokeStyle=u,e.fillStyle=u;this.faceLandmarks.positions.forEach((function(t){e.beginPath(),e.arc(t.x,t.y,s,0,2*Math.PI),e.fill()}))}},t}();function fn(t,e){(Array.isArray(e)?e:[e]).forEach((function(e){var n=e instanceof Yt?e:sn(e)?e.landmarks:void 0;if(!n)throw new Error("drawFaceLandmarks - expected faceExpressions to be FaceLandmarks | WithFaceLandmarks<WithFaceDetection<{}>> or array thereof");new ln(n).draw(t)}))}function hn(t,e){var n=[],r=Ke(t),o=r.extractWeights,a=r.getRemainingWeights,i=function(t,e){var n=je(t,e),r=Ge(t,e);return{extractConvParams:n,extractSeparableConvParams:r,extractReductionBlockParams:function(t,e,o){return{separable_conv0:r(t,e,o+"/separable_conv0"),separable_conv1:r(e,e,o+"/separable_conv1"),expansion_conv:n(t,e,1,o+"/expansion_conv")}},extractMainBlockParams:function(t,e){return{separable_conv0:r(t,t,e+"/separable_conv0"),separable_conv1:r(t,t,e+"/separable_conv1"),separable_conv2:r(t,t,e+"/separable_conv2")}}}}(o,n),s=i.extractConvParams,u=i.extractSeparableConvParams,c=i.extractReductionBlockParams,l=i.extractMainBlockParams,f={conv_in:s(3,32,3,"entry_flow/conv_in"),reduction_block_0:c(32,64,"entry_flow/reduction_block_0"),reduction_block_1:c(64,128,"entry_flow/reduction_block_1")},h={};Bt(e,0,1).forEach((function(t){h["main_block_"+t]=l(128,"middle_flow/main_block_"+t)}));var p={reduction_block:c(128,256,"exit_flow/reduction_block"),separable_conv:u(256,512,"exit_flow/separable_conv")};if(0!==a().length)throw new Error("weights remaing after extract: "+a().length);return{paramMappings:n,params:{entry_flow:f,middle_flow:h,exit_flow:p}}}function pn(t,e){var n=[],r=function(t,e){var n=qe(t,e),r=$e(n),o=He(n);return{extractConvParams:r,extractSeparableConvParams:o,extractReductionBlockParams:function(t){return{separable_conv0:o(t+"/separable_conv0"),separable_conv1:o(t+"/separable_conv1"),expansion_conv:r(t+"/expansion_conv")}},extractMainBlockParams:function(t){return{separable_conv0:o(t+"/separable_conv0"),separable_conv1:o(t+"/separable_conv1"),separable_conv2:o(t+"/separable_conv2")}}}}(t,n),o=r.extractConvParams,a=r.extractSeparableConvParams,i=r.extractReductionBlockParams,s=r.extractMainBlockParams,u={conv_in:o("entry_flow/conv_in"),reduction_block_0:i("entry_flow/reduction_block_0"),reduction_block_1:i("entry_flow/reduction_block_1")},c={};Bt(e,0,1).forEach((function(t){c["main_block_"+t]=s("middle_flow/main_block_"+t)}));var l={reduction_block:i("exit_flow/reduction_block"),separable_conv:a("exit_flow/separable_conv")};return Ue(t,n),{params:{entry_flow:u,middle_flow:c,exit_flow:l},paramMappings:n}}function dn(t,e,n){return Rt.c(Rt.i(t,e.filters,n,"same"),e.bias)}function vn(t,e,n){void 0===n&&(n=!0);var r=n?Rt.w(t):t;return r=Pe(r,e.separable_conv0,[1,1]),r=Pe(Rt.w(r),e.separable_conv1,[1,1]),r=Rt.s(r,[3,3],[2,2],"same"),r=Rt.c(r,dn(t,e.expansion_conv,[2,2]))}var mn,gn=function(t){function e(e){var n=t.call(this,"TinyXception")||this;return n._numMainBlocks=e,n}return Object(St.c)(e,t),e.prototype.forwardInput=function(t){var e=this,n=this.params;if(!n)throw new Error("TinyXception - load model before inference");return Rt.L((function(){var r=Kt(t.toBatchTensor(112,!0),[122.782,117.001,104.298]).div(Rt.y(256)),o=Rt.w(dn(r,n.entry_flow.conv_in,[2,2]));return o=vn(o,n.entry_flow.reduction_block_0,!1),o=vn(o,n.entry_flow.reduction_block_1),Bt(e._numMainBlocks,0,1).forEach((function(t){o=function(t,e){var n=Pe(Rt.w(t),e.separable_conv0,[1,1]);return n=Pe(Rt.w(n),e.separable_conv1,[1,1]),n=Pe(Rt.w(n),e.separable_conv2,[1,1]),n=Rt.c(n,t)}(o,n.middle_flow["main_block_"+t])})),o=vn(o,n.exit_flow.reduction_block),o=Rt.w(Pe(o,n.exit_flow.separable_conv,[1,1]))}))},e.prototype.forward=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e;return Object(St.d)(this,(function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Se(t)];case 1:return[2,e.apply(this,[n.sent()])]}}))}))},e.prototype.getDefaultModelName=function(){return"tiny_xception_model"},e.prototype.extractParamsFromWeigthMap=function(t){return pn(t,this._numMainBlocks)},e.prototype.extractParams=function(t){return hn(t,this._numMainBlocks)},e}(Me);!function(t){t.FEMALE="female",t.MALE="male"}(mn||(mn={}));var yn=function(t){function e(e){void 0===e&&(e=new gn(2));var n=t.call(this,"AgeGenderNet")||this;return n._faceFeatureExtractor=e,n}return Object(St.c)(e,t),Object.defineProperty(e.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),e.prototype.runNet=function(t){var e=this,n=this.params;if(!n)throw new Error(this._name+" - load model before inference");return Rt.L((function(){var r=t instanceof Ie?e.faceFeatureExtractor.forwardInput(t):t,o=Rt.d(r,[7,7],[2,2],"valid").as2D(r.shape[0],-1);return{age:Qe(o,n.fc.age).as1D(),gender:Qe(o,n.fc.gender)}}))},e.prototype.forwardInput=function(t){var e=this;return Rt.L((function(){var n=e.runNet(t),r=n.age,o=n.gender;return{age:r,gender:Rt.D(o)}}))},e.prototype.forward=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e;return Object(St.d)(this,(function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Se(t)];case 1:return[2,e.apply(this,[n.sent()])]}}))}))},e.prototype.predictAgeAndGender=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e,n,r,o,a,i,s=this;return Object(St.d)(this,(function(u){switch(u.label){case 0:return[4,Se(t)];case 1:return e=u.sent(),[4,this.forwardInput(e)];case 2:return n=u.sent(),r=Rt.O(n.age),o=Rt.O(n.gender),a=r.map((function(t,e){return{ageTensor:t,genderTensor:o[e]}})),[4,Promise.all(a.map((function(t){var e=t.ageTensor,n=t.genderTensor;return Object(St.b)(s,void 0,void 0,(function(){var t,r,o,a,i;return Object(St.d)(this,(function(s){switch(s.label){case 0:return[4,e.data()];case 1:return t=s.sent()[0],[4,n.data()];case 2:return r=s.sent()[0],a=(o=r>.5)?mn.MALE:mn.FEMALE,i=o?r:1-r,e.dispose(),n.dispose(),[2,{age:t,gender:a,genderProbability:i}]}}))}))})))];case 3:return i=u.sent(),n.age.dispose(),n.gender.dispose(),[2,e.isBatchInput?i:i[0]]}}))}))},e.prototype.getDefaultModelName=function(){return"age_gender_model"},e.prototype.dispose=function(e){void 0===e&&(e=!0),this.faceFeatureExtractor.dispose(e),t.prototype.dispose.call(this,e)},e.prototype.loadClassifierParams=function(t){var e=this.extractClassifierParams(t),n=e.params,r=e.paramMappings;this._params=n,this._paramMappings=r},e.prototype.extractClassifierParams=function(t){return function(t){var e=[],n=Ke(t),r=n.extractWeights,o=n.getRemainingWeights,a=ze(r,e),i=a(512,1,"fc/age"),s=a(512,2,"fc/gender");if(0!==o().length)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:e,params:{fc:{age:i,gender:s}}}}(t)},e.prototype.extractParamsFromWeigthMap=function(t){var e=Ze(t),n=e.featureExtractorMap,r=e.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(n),function(t){var e=[],n=qe(t,e);function r(t){return{weights:n(t+"/weights",2),bias:n(t+"/bias",1)}}var o={fc:{age:r("fc/age"),gender:r("fc/gender")}};return Ue(t,e),{params:o,paramMappings:e}}(r)},e.prototype.extractParams=function(t){var e=t.slice(0,t.length-1539),n=t.slice(t.length-1539);return this.faceFeatureExtractor.extractWeights(e),this.extractClassifierParams(n)},e}(Me),bn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.postProcess=function(t,e,n){var r=n.map((function(t){var n=t.width,r=t.height,o=e/Math.max(r,n);return{width:n*o,height:r*o}})),o=r.length;return Rt.L((function(){var n=function(t,e){return Rt.E([Rt.n([68],t),Rt.n([68],e)],1).as2D(1,136).as1D()},a=function(t,e){var n=r[t],o=n.width,a=n.height;return e(o,a)?Math.abs(o-a)/2:0};return t.mul(Rt.n([o,136],e)).sub(Rt.E(Array.from(Array(o),(function(t,e){return n(function(t){return a(t,(function(t,e){return t<e}))}(e),function(t){return a(t,(function(t,e){return e<t}))}(e))})))).div(Rt.E(Array.from(Array(o),(function(t,e){return n(r[e].width,r[e].height)}))))}))},e.prototype.forwardInput=function(t){var e=this;return Rt.L((function(){var n=e.runNet(t);return e.postProcess(n,t.inputSize,t.inputDimensions.map((function(t){return{height:t[0],width:t[1]}})))}))},e.prototype.forward=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e;return Object(St.d)(this,(function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Se(t)];case 1:return[2,e.apply(this,[n.sent()])]}}))}))},e.prototype.detectLandmarks=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e,n,r,o=this;return Object(St.d)(this,(function(a){switch(a.label){case 0:return[4,Se(t)];case 1:return e=a.sent(),n=Rt.L((function(){return Rt.O(o.forwardInput(e))})),[4,Promise.all(n.map((function(t,n){return Object(St.b)(o,void 0,void 0,(function(){var r,o,a,i,s;return Object(St.d)(this,(function(u){switch(u.label){case 0:return a=(o=Array).from,[4,t.data()];case 1:return r=a.apply(o,[u.sent()]),i=r.filter((function(t,e){return Nt(e)})),s=r.filter((function(t,e){return!Nt(e)})),[2,new Qt(Array(68).fill(0).map((function(t,e){return new Ut(i[e],s[e])})),{height:e.getInputHeight(n),width:e.getInputWidth(n)})]}}))}))})))];case 2:return r=a.sent(),n.forEach((function(t){return t.dispose()})),[2,e.isBatchInput?r:r[0]]}}))}))},e.prototype.getClassifierChannelsOut=function(){return 136},e}(tn),xn=function(t){function e(e){return void 0===e&&(e=new Je),t.call(this,"FaceLandmark68Net",e)||this}return Object(St.c)(e,t),e.prototype.getDefaultModelName=function(){return"face_landmark_68_model"},e.prototype.getClassifierChannelsIn=function(){return 256},e}(bn);var wn=function(t){function e(){return t.call(this,"TinyFaceFeatureExtractor")||this}return Object(St.c)(e,t),e.prototype.forwardInput=function(t){var e=this.params;if(!e)throw new Error("TinyFaceFeatureExtractor - load model before inference");return Rt.L((function(){var n=Be(Kt(t.toBatchTensor(112,!0),[122.782,117.001,104.298]).div(Rt.y(255)),e.dense0,!0);return n=Be(n,e.dense1),n=Be(n,e.dense2),n=Rt.d(n,[14,14],[2,2],"valid")}))},e.prototype.forward=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e;return Object(St.d)(this,(function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Se(t)];case 1:return[2,e.apply(this,[n.sent()])]}}))}))},e.prototype.getDefaultModelName=function(){return"face_feature_extractor_tiny_model"},e.prototype.extractParamsFromWeigthMap=function(t){return function(t){var e=[],n=Ye(t,e).extractDenseBlock3Params,r={dense0:n("dense0",!0),dense1:n("dense1"),dense2:n("dense2")};return Ue(t,e),{params:r,paramMappings:e}}(t)},e.prototype.extractParams=function(t){return function(t){var e=[],n=Ke(t),r=n.extractWeights,o=n.getRemainingWeights,a=Xe(r,e).extractDenseBlock3Params,i=a(3,32,"dense0",!0),s=a(32,64,"dense1"),u=a(64,128,"dense2");if(0!==o().length)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:e,params:{dense0:i,dense1:s,dense2:u}}}(t)},e}(Me),En=function(t){function e(e){return void 0===e&&(e=new wn),t.call(this,"FaceLandmark68TinyNet",e)||this}return Object(St.c)(e,t),e.prototype.getDefaultModelName=function(){return"face_landmark_68_tiny_model"},e.prototype.getClassifierChannelsIn=function(){return 128},e}(bn);!function(t){function e(){return null!==t&&t.apply(this,arguments)||this}Object(St.c)(e,t)}(xn);function Cn(t,e,n,r,o){void 0===o&&(o="same");var a=e.conv,i=a.filters,s=a.bias,u=Rt.i(t,i,n,o);return u=function(t,e){return Rt.c(Rt.t(t,e.weights),e.biases)}(u=Rt.c(u,s),e.scale),r?Rt.w(u):u}function _n(t,e){return Cn(t,e,[1,1],!1)}function kn(t,e){return Cn(t,e,[2,2],!0,"valid")}function Rn(t,e){function n(n,r,o,a){var i=function(e,n,r){var o=t(e),a=o.length/(n*r*r);if(a%1!=0)throw new Error("depth has to be an integer: "+a+", weights.length: "+o.length+", numFilters: "+n+", filterSize: "+r);return Rt.L((function(){return Rt.N(Rt.K(o,[n,a,r,r]),[2,3,1,0])}))}(n,r,o),s=Rt.H(t(r));return e.push({paramPath:a+"/filters"},{paramPath:a+"/bias"}),{filters:i,bias:s}}function r(r,o,a,i){return{conv:n(r,o,a,i+"/conv"),scale:function(n,r){var o=Rt.H(t(n)),a=Rt.H(t(n));return e.push({paramPath:r+"/weights"},{paramPath:r+"/biases"}),{weights:o,biases:a}}(o,i+"/scale")}}return{extractConvLayerParams:r,extractResidualLayerParams:function(t,e,n,o,a){return void 0===a&&(a=!1),{conv1:r((a?.5:1)*t,e,n,o+"/conv1"),conv2:r(t,e,n,o+"/conv2")}}}}function In(t,e){var n=qe(t,e);function r(t){return{conv:{filters:n(t+"/conv/filters",4),bias:n(t+"/conv/bias",1)},scale:function(t){return{weights:n(t+"/scale/weights",1),biases:n(t+"/scale/biases",1)}}(t)}}return{extractConvLayerParams:r,extractResidualLayerParams:function(t){return{conv1:r(t+"/conv1"),conv2:r(t+"/conv2")}}}}function Sn(t){var e=[],n=In(t,e),r=n.extractConvLayerParams,o=n.extractResidualLayerParams,a=r("conv32_down"),i=o("conv32_1"),s=o("conv32_2"),u=o("conv32_3"),c=o("conv64_down"),l=o("conv64_1"),f=o("conv64_2"),h=o("conv64_3"),p=o("conv128_down"),d=o("conv128_1"),v=o("conv128_2"),m=o("conv256_down"),g=o("conv256_1"),y=o("conv256_2"),b=o("conv256_down_out"),x=t.fc;if(e.push({originalPath:"fc",paramPath:"fc"}),!Ot(x,2))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+x);var w={conv32_down:a,conv32_1:i,conv32_2:s,conv32_3:u,conv64_down:c,conv64_1:l,conv64_2:f,conv64_3:h,conv128_down:p,conv128_1:d,conv128_2:v,conv256_down:m,conv256_1:g,conv256_2:y,conv256_down_out:b,fc:x};return Ue(t,e),{params:w,paramMappings:e}}function An(t,e){var n=function(t,e){return Cn(t,e,[1,1],!0)}(t,e.conv1);return n=_n(n,e.conv2),n=Rt.c(n,t),n=Rt.w(n)}function On(t,e){var n=kn(t,e.conv1);n=_n(n,e.conv2);var r=Rt.d(t,2,2,"valid"),o=Rt.P(r.shape),a=r.shape[3]!==n.shape[3];if(r.shape[1]!==n.shape[1]||r.shape[2]!==n.shape[2]){var i=Object(St.e)(n.shape);i[1]=1;var s=Rt.P(i);n=Rt.h([n,s],1);var u=Object(St.e)(n.shape);u[2]=1;var c=Rt.P(u);n=Rt.h([n,c],2)}return r=a?Rt.h([r,o],3):r,n=Rt.c(r,n),n=Rt.w(n)}var Tn=function(t){function e(){return t.call(this,"FaceRecognitionNet")||this}return Object(St.c)(e,t),e.prototype.forwardInput=function(t){var e=this.params;if(!e)throw new Error("FaceRecognitionNet - load model before inference");return Rt.L((function(){var n=kn(Kt(t.toBatchTensor(150,!0).toFloat(),[122.782,117.001,104.298]).div(Rt.y(256)),e.conv32_down);n=An(n=Rt.s(n,3,2,"valid"),e.conv32_1),n=An(n,e.conv32_2),n=An(n,e.conv32_3),n=An(n=On(n,e.conv64_down),e.conv64_1),n=An(n,e.conv64_2),n=An(n,e.conv64_3),n=An(n=On(n,e.conv128_down),e.conv128_1),n=An(n,e.conv128_2),n=An(n=On(n,e.conv256_down),e.conv256_1);var r=(n=On(n=An(n,e.conv256_2),e.conv256_down_out)).mean([1,2]);return Rt.q(r,e.fc)}))},e.prototype.forward=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e;return Object(St.d)(this,(function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Se(t)];case 1:return[2,e.apply(this,[n.sent()])]}}))}))},e.prototype.computeFaceDescriptor=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e,n,r,o=this;return Object(St.d)(this,(function(a){switch(a.label){case 0:return[4,Se(t)];case 1:return e=a.sent(),n=Rt.L((function(){return Rt.O(o.forwardInput(e))})),[4,Promise.all(n.map((function(t){return t.data()})))];case 2:return r=a.sent(),n.forEach((function(t){return t.dispose()})),[2,e.isBatchInput?r:r[0]]}}))}))},e.prototype.getDefaultModelName=function(){return"face_recognition_model"},e.prototype.extractParamsFromWeigthMap=function(t){return Sn(t)},e.prototype.extractParams=function(t){return function(t){var e=Ke(t),n=e.extractWeights,r=e.getRemainingWeights,o=[],a=Rn(n,o),i=a.extractConvLayerParams,s=a.extractResidualLayerParams,u=i(4704,32,7,"conv32_down"),c=s(9216,32,3,"conv32_1"),l=s(9216,32,3,"conv32_2"),f=s(9216,32,3,"conv32_3"),h=s(36864,64,3,"conv64_down",!0),p=s(36864,64,3,"conv64_1"),d=s(36864,64,3,"conv64_2"),v=s(36864,64,3,"conv64_3"),m=s(147456,128,3,"conv128_down",!0),g=s(147456,128,3,"conv128_1"),y=s(147456,128,3,"conv128_2"),b=s(589824,256,3,"conv256_down",!0),x=s(589824,256,3,"conv256_1"),w=s(589824,256,3,"conv256_2"),E=s(589824,256,3,"conv256_down_out"),C=Rt.L((function(){return Rt.N(Rt.I(n(32768),[128,256]),[1,0])}));if(o.push({paramPath:"fc"}),0!==r().length)throw new Error("weights remaing after extract: "+r().length);return{params:{conv32_down:u,conv32_1:c,conv32_2:l,conv32_3:f,conv64_down:h,conv64_1:p,conv64_2:d,conv64_3:v,conv128_down:m,conv128_1:g,conv128_2:y,conv256_down:b,conv256_1:x,conv256_2:w,conv256_down_out:E,fc:C},paramMappings:o}}(t)},e}(Me);function Dn(t,e){var n={descriptor:e};return Object.assign({},t,n)}function Nn(t,e){var n={age:e};return Object.assign({},t,n)}function Fn(t,e,n){var r={gender:e,genderProbability:n};return Object.assign({},t,r)}var Mn=function(){function t(t){var e=void 0===t?{}:t,n=e.minFaceSize,r=e.scaleFactor,o=e.maxNumScales,a=e.scoreThresholds,i=e.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=n||20,this._scaleFactor=r||.709,this._maxNumScales=o||10,this._scoreThresholds=a||[.6,.7,.7],this._scaleSteps=i,"number"!=typeof this._minFaceSize||this._minFaceSize<0)throw new Error(this._name+" - expected minFaceSize to be a number > 0");if("number"!=typeof this._scaleFactor||this._scaleFactor<=0||this._scaleFactor>=1)throw new Error(this._name+" - expected scaleFactor to be a number between 0 and 1");if("number"!=typeof this._maxNumScales||this._maxNumScales<0)throw new Error(this._name+" - expected maxNumScales to be a number > 0");if(!Array.isArray(this._scoreThresholds)||3!==this._scoreThresholds.length||this._scoreThresholds.some((function(t){return"number"!=typeof t})))throw new Error(this._name+" - expected scoreThresholds to be an array of numbers of length 3");if(this._scaleSteps&&(!Array.isArray(this._scaleSteps)||this._scaleSteps.some((function(t){return"number"!=typeof t}))))throw new Error(this._name+" - expected scaleSteps to be an array of numbers")}return Object.defineProperty(t.prototype,"minFaceSize",{get:function(){return this._minFaceSize},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scaleFactor",{get:function(){return this._scaleFactor},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxNumScales",{get:function(){return this._maxNumScales},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scoreThresholds",{get:function(){return this._scoreThresholds},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scaleSteps",{get:function(){return this._scaleSteps},enumerable:!0,configurable:!0}),t}();function Pn(t,e){function n(n,r,o,a,i){var s=Rt.K(t(n*r*o*o),[o,o,n,r]),u=Rt.H(t(r));return e.push({paramPath:a+"/filters"},{paramPath:a+"/"+(i?"batch_norm_offset":"bias")}),{filters:s,bias:u}}function r(t,e,r,o){var a=n(t,e,r,o,!0);return{filters:a.filters,batch_norm_offset:a.bias}}function o(n,o,a){return{depthwise_conv:function(n,r){var o=Rt.K(t(9*n),[3,3,n,1]),a=Rt.H(t(n)),i=Rt.H(t(n)),s=Rt.H(t(n)),u=Rt.H(t(n));return e.push({paramPath:r+"/filters"},{paramPath:r+"/batch_norm_scale"},{paramPath:r+"/batch_norm_offset"},{paramPath:r+"/batch_norm_mean"},{paramPath:r+"/batch_norm_variance"}),{filters:o,batch_norm_scale:a,batch_norm_offset:i,batch_norm_mean:s,batch_norm_variance:u}}(n,a+"/depthwise_conv"),pointwise_conv:r(n,o,1,a+"/pointwise_conv")}}return{extractMobilenetV1Params:function(){return{conv_0:r(3,32,3,"mobilenetv1/conv_0"),conv_1:o(32,64,"mobilenetv1/conv_1"),conv_2:o(64,128,"mobilenetv1/conv_2"),conv_3:o(128,128,"mobilenetv1/conv_3"),conv_4:o(128,256,"mobilenetv1/conv_4"),conv_5:o(256,256,"mobilenetv1/conv_5"),conv_6:o(256,512,"mobilenetv1/conv_6"),conv_7:o(512,512,"mobilenetv1/conv_7"),conv_8:o(512,512,"mobilenetv1/conv_8"),conv_9:o(512,512,"mobilenetv1/conv_9"),conv_10:o(512,512,"mobilenetv1/conv_10"),conv_11:o(512,512,"mobilenetv1/conv_11"),conv_12:o(512,1024,"mobilenetv1/conv_12"),conv_13:o(1024,1024,"mobilenetv1/conv_13")}},extractPredictionLayerParams:function(){return{conv_0:r(1024,256,1,"prediction_layer/conv_0"),conv_1:r(256,512,3,"prediction_layer/conv_1"),conv_2:r(512,128,1,"prediction_layer/conv_2"),conv_3:r(128,256,3,"prediction_layer/conv_3"),conv_4:r(256,128,1,"prediction_layer/conv_4"),conv_5:r(128,256,3,"prediction_layer/conv_5"),conv_6:r(256,64,1,"prediction_layer/conv_6"),conv_7:r(64,128,3,"prediction_layer/conv_7"),box_predictor_0:{box_encoding_predictor:n(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),class_predictor:n(512,9,1,"prediction_layer/box_predictor_0/class_predictor")},box_predictor_1:{box_encoding_predictor:n(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),class_predictor:n(1024,18,1,"prediction_layer/box_predictor_1/class_predictor")},box_predictor_2:{box_encoding_predictor:n(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),class_predictor:n(512,18,1,"prediction_layer/box_predictor_2/class_predictor")},box_predictor_3:{box_encoding_predictor:n(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),class_predictor:n(256,18,1,"prediction_layer/box_predictor_3/class_predictor")},box_predictor_4:{box_encoding_predictor:n(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),class_predictor:n(256,18,1,"prediction_layer/box_predictor_4/class_predictor")},box_predictor_5:{box_encoding_predictor:n(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),class_predictor:n(128,18,1,"prediction_layer/box_predictor_5/class_predictor")}}}}}function Bn(t){var e=[],n=function(t,e){var n=qe(t,e);function r(t,e,r){return{filters:n(t+"/Conv2d_"+e+"_pointwise/weights",4,r+"/filters"),batch_norm_offset:n(t+"/Conv2d_"+e+"_pointwise/convolution_bn_offset",1,r+"/batch_norm_offset")}}function o(t){var e="mobilenetv1/conv_"+t,o="MobilenetV1/Conv2d_"+t+"_depthwise",a=e+"/depthwise_conv",i=e+"/pointwise_conv";return{depthwise_conv:{filters:n(o+"/depthwise_weights",4,a+"/filters"),batch_norm_scale:n(o+"/BatchNorm/gamma",1,a+"/batch_norm_scale"),batch_norm_offset:n(o+"/BatchNorm/beta",1,a+"/batch_norm_offset"),batch_norm_mean:n(o+"/BatchNorm/moving_mean",1,a+"/batch_norm_mean"),batch_norm_variance:n(o+"/BatchNorm/moving_variance",1,a+"/batch_norm_variance")},pointwise_conv:r("MobilenetV1",t,i)}}function a(t,e){return{filters:n(t+"/weights",4,e+"/filters"),bias:n(t+"/biases",1,e+"/bias")}}function i(t){return{box_encoding_predictor:a("Prediction/BoxPredictor_"+t+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+t+"/box_encoding_predictor"),class_predictor:a("Prediction/BoxPredictor_"+t+"/ClassPredictor","prediction_layer/box_predictor_"+t+"/class_predictor")}}return{extractMobilenetV1Params:function(){return{conv_0:r("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:o(1),conv_2:o(2),conv_3:o(3),conv_4:o(4),conv_5:o(5),conv_6:o(6),conv_7:o(7),conv_8:o(8),conv_9:o(9),conv_10:o(10),conv_11:o(11),conv_12:o(12),conv_13:o(13)}},extractPredictionLayerParams:function(){return{conv_0:r("Prediction",0,"prediction_layer/conv_0"),conv_1:r("Prediction",1,"prediction_layer/conv_1"),conv_2:r("Prediction",2,"prediction_layer/conv_2"),conv_3:r("Prediction",3,"prediction_layer/conv_3"),conv_4:r("Prediction",4,"prediction_layer/conv_4"),conv_5:r("Prediction",5,"prediction_layer/conv_5"),conv_6:r("Prediction",6,"prediction_layer/conv_6"),conv_7:r("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:i(0),box_predictor_1:i(1),box_predictor_2:i(2),box_predictor_3:i(3),box_predictor_4:i(4),box_predictor_5:i(5)}}}}(t,e),r=n.extractMobilenetV1Params,o=n.extractPredictionLayerParams,a=t["Output/extra_dim"];if(e.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!Tt(a))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+a);var i={mobilenetv1:r(),prediction_layer:o(),output_layer:{extra_dim:a}};return Ue(t,e),{params:i,paramMappings:e}}function Ln(t,e,n){return Rt.L((function(){var r=Rt.i(t,e.filters,n,"same");return r=Rt.c(r,e.batch_norm_offset),Rt.g(r,0,6)}))}function Wn(t,e){return Rt.L((function(){var n=null,r=Ln(t,e.conv_0,[2,2]);if([e.conv_1,e.conv_2,e.conv_3,e.conv_4,e.conv_5,e.conv_6,e.conv_7,e.conv_8,e.conv_9,e.conv_10,e.conv_11,e.conv_12,e.conv_13].forEach((function(t,e){var o=e+1,a=function(t){return[2,4,6,12].some((function(e){return e===t}))?[2,2]:[1,1]}(o);r=Ln(r=function(t,e,n){return Rt.L((function(){var r=Rt.j(t,e.filters,n,"same");return r=Rt.e(r,e.batch_norm_mean,e.batch_norm_variance,e.batch_norm_offset,e.batch_norm_scale,.0010000000474974513),Rt.g(r,0,6)}))}(r,t.depthwise_conv,a),t.pointwise_conv,[1,1]),11===o&&(n=r)})),null===n)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:r,conv11:n}}))}function Un(t,e,n){var r=t.arraySync(),o=Math.min(r[e][0],r[e][2]),a=Math.min(r[e][1],r[e][3]),i=Math.max(r[e][0],r[e][2]),s=Math.max(r[e][1],r[e][3]),u=Math.min(r[n][0],r[n][2]),c=Math.min(r[n][1],r[n][3]),l=Math.max(r[n][0],r[n][2]),f=Math.max(r[n][1],r[n][3]),h=(i-o)*(s-a),p=(l-u)*(f-c);if(h<=0||p<=0)return 0;var d=Math.max(o,u),v=Math.max(a,c),m=Math.min(i,l),g=Math.min(s,f),y=Math.max(m-d,0)*Math.max(g-v,0);return y/(h+p-y)}function jn(t,e){var n=function(t){var e=Rt.O(Rt.N(t,[1,0])),n=[Rt.F(e[2],e[0]),Rt.F(e[3],e[1])];return{sizes:n,centers:[Rt.c(e[0],Rt.k(n[0],Rt.y(2))),Rt.c(e[1],Rt.k(n[1],Rt.y(2)))]}}(t),r=n.sizes,o=n.centers,a=Rt.O(Rt.N(e,[1,0])),i=Rt.k(Rt.t(Rt.l(Rt.k(a[2],Rt.y(5))),r[0]),Rt.y(2)),s=Rt.c(Rt.t(Rt.k(a[0],Rt.y(10)),r[0]),o[0]),u=Rt.k(Rt.t(Rt.l(Rt.k(a[3],Rt.y(5))),r[1]),Rt.y(2)),c=Rt.c(Rt.t(Rt.k(a[1],Rt.y(10)),r[1]),o[1]);return Rt.N(Rt.E([Rt.F(s,i),Rt.F(c,u),Rt.c(s,i),Rt.c(c,u)]),[1,0])}function zn(t,e){return Rt.L((function(){var n=t.shape[0];return{boxPredictionEncoding:Rt.x(We(t,e.box_encoding_predictor),[n,-1,1,4]),classPrediction:Rt.x(We(t,e.class_predictor),[n,-1,3])}}))}var Vn=function(){function t(t){var e=void 0===t?{}:t,n=e.minConfidence,r=e.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=n||.5,this._maxResults=r||100,"number"!=typeof this._minConfidence||this._minConfidence<=0||this._minConfidence>=1)throw new Error(this._name+" - expected minConfidence to be a number between 0 and 1");if("number"!=typeof this._maxResults)throw new Error(this._name+" - expected maxResults to be a number")}return Object.defineProperty(t.prototype,"minConfidence",{get:function(){return this._minConfidence},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxResults",{get:function(){return this._maxResults},enumerable:!0,configurable:!0}),t}(),Gn=function(t){function e(){return t.call(this,"SsdMobilenetv1")||this}return Object(St.c)(e,t),e.prototype.forwardInput=function(t){var e=this.params;if(!e)throw new Error("SsdMobilenetv1 - load model before inference");return Rt.L((function(){var n=t.toBatchTensor(512,!1).toFloat(),r=Wn(Rt.F(Rt.t(n,Rt.y(.007843137718737125)),Rt.y(1)),e.mobilenetv1),o=function(t,e,n){return Rt.L((function(){var r=Ln(t,n.conv_0,[1,1]),o=Ln(r,n.conv_1,[2,2]),a=Ln(o,n.conv_2,[1,1]),i=Ln(a,n.conv_3,[2,2]),s=Ln(i,n.conv_4,[1,1]),u=Ln(s,n.conv_5,[2,2]),c=Ln(u,n.conv_6,[1,1]),l=Ln(c,n.conv_7,[2,2]),f=zn(e,n.box_predictor_0),h=zn(t,n.box_predictor_1),p=zn(o,n.box_predictor_2),d=zn(i,n.box_predictor_3),v=zn(u,n.box_predictor_4),m=zn(l,n.box_predictor_5);return{boxPredictions:Rt.h([f.boxPredictionEncoding,h.boxPredictionEncoding,p.boxPredictionEncoding,d.boxPredictionEncoding,v.boxPredictionEncoding,m.boxPredictionEncoding],1),classPredictions:Rt.h([f.classPrediction,h.classPrediction,p.classPrediction,d.classPrediction,v.classPrediction,m.classPrediction],1)}}))}(r.out,r.conv11,e.prediction_layer);return function(t,e,n){return Rt.L((function(){var r=t.shape[0],o=jn(Rt.x(Rt.M(n.extra_dim,[r,1,1]),[-1,4]),Rt.x(t,[-1,4]));o=Rt.x(o,[r,o.shape[0]/r,4]);var a=Rt.A(Rt.B(e,[0,0,1],[-1,-1,-1])),i=Rt.B(a,[0,0,0],[-1,-1,1]);return i=Rt.x(i,[r,i.shape[1]]),{boxes:Rt.O(o),scores:Rt.O(i)}}))}(o.boxPredictions,o.classPredictions,e.output_layer)}))},e.prototype.forward=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e;return Object(St.d)(this,(function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Se(t)];case 1:return[2,e.apply(this,[n.sent()])]}}))}))},e.prototype.locateFaces=function(t,e){return void 0===e&&(e={}),Object(St.b)(this,void 0,void 0,(function(){var n,r,o,a,i,s,u,c,l,f,h,p,d,v,m,g,y,b,x,w;return Object(St.d)(this,(function(E){switch(E.label){case 0:return n=new Vn(e),r=n.maxResults,o=n.minConfidence,[4,Se(t)];case 1:for(a=E.sent(),i=this.forwardInput(a),s=i.boxes,u=i.scores,c=s[0],l=u[0],f=1;f<s.length;f++)s[f].dispose(),u[f].dispose();return d=(p=Array).from,[4,l.data()];case 2:return h=d.apply(p,[E.sent()]),.5,v=function(t,e,n,r,o){var a=t.shape[0],i=Math.min(n,a),s=e.map((function(t,e){return{score:t,boxIndex:e}})).filter((function(t){return t.score>o})).sort((function(t,e){return e.score-t.score})),u=[];return s.forEach((function(e){if(!(u.length>=i)){for(var n=e.score,a=u.length-1;a>=0;--a){var s=Un(t,e.boxIndex,u[a]);if(0!==s&&(e.score*=s<=r?1:0,e.score<=o))break}n===e.score&&u.push(e.boxIndex)}})),u}(c,h,r,.5,o),m=a.getReshapedInputDimensions(0),g=a.inputSize,y=g/m.width,b=g/m.height,x=c.arraySync(),w=v.map((function(t){var e=[Math.max(0,x[t][0]),Math.min(1,x[t][2])].map((function(t){return t*b})),n=e[0],r=e[1],o=[Math.max(0,x[t][1]),Math.min(1,x[t][3])].map((function(t){return t*y})),i=o[0],s=o[1];return new Gt(h[t],new $t(i,n,s-i,r-n),{height:a.getInputHeight(0),width:a.getInputWidth(0)})})),c.dispose(),l.dispose(),[2,w]}}))}))},e.prototype.getDefaultModelName=function(){return"ssd_mobilenetv1_model"},e.prototype.extractParamsFromWeigthMap=function(t){return Bn(t)},e.prototype.extractParams=function(t){return function(t){var e=[],n=Ke(t),r=n.extractWeights,o=n.getRemainingWeights,a=Pn(r,e),i=a.extractMobilenetV1Params,s=a.extractPredictionLayerParams,u=i(),c=s(),l={extra_dim:Rt.J(r(20472),[1,5118,4])};if(e.push({paramPath:"output_layer/extra_dim"}),0!==o().length)throw new Error("weights remaing after extract: "+o().length);return{params:{mobilenetv1:u,prediction_layer:c,output_layer:l},paramMappings:e}}(t)},e}(Me);!function(t){function e(){return null!==t&&t.apply(this,arguments)||this}Object(St.c)(e,t)}(Gn);var Hn,qn=[new Ut(.738768,.874946),new Ut(2.42204,2.65704),new Ut(4.30971,7.04493),new Ut(10.246,4.59428),new Ut(12.6868,11.8741)],Kn=[new Ut(1.603231,2.094468),new Ut(6.041143,7.080126),new Ut(2.882459,3.518061),new Ut(4.266906,5.178857),new Ut(9.041765,10.66308)],Xn=[117.001,114.697,97.404],$n=function(t){return"number"==typeof t};function Yn(t){return Rt.L((function(){var e=Rt.t(t,Rt.y(.10000000149011612));return Rt.c(Rt.w(Rt.F(t,e)),e)}))}function Jn(t,e){return Rt.L((function(){var n=Rt.v(t,[[0,0],[1,1],[1,1],[0,0]]);return n=Rt.i(n,e.conv.filters,[1,1],"valid"),n=Rt.F(n,e.bn.sub),n=Rt.t(n,e.bn.truediv),Yn(n=Rt.c(n,e.conv.bias))}))}function Qn(t,e){return Rt.L((function(){var n=Rt.v(t,[[0,0],[1,1],[1,1],[0,0]]);return n=Rt.z(n,e.depthwise_filter,e.pointwise_filter,[1,1],"valid"),Yn(n=Rt.c(n,e.bias))}))}function Zn(t,e){var n=je(t,e);var r=Ge(t,e);return{extractConvParams:n,extractConvWithBatchNormParams:function(r,o,a){return{conv:n(r,o,3,a+"/conv"),bn:function(n,r){var o=Rt.H(t(n)),a=Rt.H(t(n));return e.push({paramPath:r+"/sub"},{paramPath:r+"/truediv"}),{sub:o,truediv:a}}(o,a+"/bn")}},extractSeparableConvParams:r}}function tr(t,e){var n=qe(t,e);function r(t){return{filters:n(t+"/filters",4),bias:n(t+"/bias",1)}}return{extractConvParams:r,extractConvWithBatchNormParams:function(t){return{conv:r(t+"/conv"),bn:function(t){return{sub:n(t+"/sub",1),truediv:n(t+"/truediv",1)}}(t+"/bn")}},extractSeparableConvParams:He(n)}}!function(t){t[t.XS=224]="XS",t[t.SM=320]="SM",t[t.MD=416]="MD",t[t.LG=608]="LG"}(Hn||(Hn={}));var er=function(){function t(t){var e=void 0===t?{}:t,n=e.inputSize,r=e.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=n||416,this._scoreThreshold=r||.5,"number"!=typeof this._inputSize||this._inputSize%32!=0)throw new Error(this._name+" - expected inputSize to be a number divisible by 32");if("number"!=typeof this._scoreThreshold||this._scoreThreshold<=0||this._scoreThreshold>=1)throw new Error(this._name+" - expected scoreThreshold to be a number between 0 and 1")}return Object.defineProperty(t.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scoreThreshold",{get:function(){return this._scoreThreshold},enumerable:!0,configurable:!0}),t}(),nr=function(t){function e(e){var n=t.call(this,"TinyYolov2")||this;return function(t){if(!t)throw new Error("invalid config: "+t);if("boolean"!=typeof t.withSeparableConvs)throw new Error("config.withSeparableConvs has to be a boolean, have: "+t.withSeparableConvs);if(!$n(t.iouThreshold)||t.iouThreshold<0||t.iouThreshold>1)throw new Error("config.iouThreshold has to be a number between [0, 1], have: "+t.iouThreshold);if(!Array.isArray(t.classes)||!t.classes.length||!t.classes.every((function(t){return"string"==typeof t})))throw new Error("config.classes has to be an array class names: string[], have: "+JSON.stringify(t.classes));if(!Array.isArray(t.anchors)||!t.anchors.length||!t.anchors.map((function(t){return t||{}})).every((function(t){return $n(t.x)&&$n(t.y)})))throw new Error("config.anchors has to be an array of { x: number, y: number }, have: "+JSON.stringify(t.anchors));if(t.meanRgb&&(!Array.isArray(t.meanRgb)||3!==t.meanRgb.length||!t.meanRgb.every($n)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(t.meanRgb))}(e),n._config=e,n}return Object(St.c)(e,t),Object.defineProperty(e.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"withClassScores",{get:function(){return this.config.withClassScores||this.config.classes.length>1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"boxEncodingSize",{get:function(){return 5+(this.withClassScores?this.config.classes.length:0)},enumerable:!0,configurable:!0}),e.prototype.runTinyYolov2=function(t,e){var n=Jn(t,e.conv0);return n=Jn(n=Rt.s(n,[2,2],[2,2],"same"),e.conv1),n=Jn(n=Rt.s(n,[2,2],[2,2],"same"),e.conv2),n=Jn(n=Rt.s(n,[2,2],[2,2],"same"),e.conv3),n=Jn(n=Rt.s(n,[2,2],[2,2],"same"),e.conv4),n=Jn(n=Rt.s(n,[2,2],[2,2],"same"),e.conv5),n=Jn(n=Rt.s(n,[2,2],[1,1],"same"),e.conv6),We(n=Jn(n,e.conv7),e.conv8,"valid",!1)},e.prototype.runMobilenet=function(t,e){var n=this.config.isFirstLayerConv2d?Yn(We(t,e.conv0,"valid",!1)):Qn(t,e.conv0);return n=Qn(n=Rt.s(n,[2,2],[2,2],"same"),e.conv1),n=Qn(n=Rt.s(n,[2,2],[2,2],"same"),e.conv2),n=Qn(n=Rt.s(n,[2,2],[2,2],"same"),e.conv3),n=Qn(n=Rt.s(n,[2,2],[2,2],"same"),e.conv4),n=Qn(n=Rt.s(n,[2,2],[2,2],"same"),e.conv5),n=Rt.s(n,[2,2],[1,1],"same"),n=e.conv6?Qn(n,e.conv6):n,We(n=e.conv7?Qn(n,e.conv7):n,e.conv8,"valid",!1)},e.prototype.forwardInput=function(t,e){var n=this,r=this.params;if(!r)throw new Error("TinyYolov2 - load model before inference");return Rt.L((function(){var o=t.toBatchTensor(e,!1).toFloat();return o=(o=n.config.meanRgb?Kt(o,n.config.meanRgb):o).div(Rt.y(256)),n.config.withSeparableConvs?n.runMobilenet(o,r):n.runTinyYolov2(o,r)}))},e.prototype.forward=function(t,e){return Object(St.b)(this,void 0,void 0,(function(){var n;return Object(St.d)(this,(function(r){switch(r.label){case 0:return n=this.forwardInput,[4,Se(t)];case 1:return[4,n.apply(this,[r.sent(),e])];case 2:return[2,r.sent()]}}))}))},e.prototype.detect=function(t,e){return void 0===e&&(e={}),Object(St.b)(this,void 0,void 0,(function(){var n,r,o,a,i,s,u,c,l,f,h,p,d,v=this;return Object(St.d)(this,(function(m){switch(m.label){case 0:return n=new er(e),r=n.inputSize,o=n.scoreThreshold,[4,Se(t)];case 1:return a=m.sent(),[4,this.forwardInput(a,r)];case 2:return i=m.sent(),s=Rt.L((function(){return Rt.O(i)[0].expandDims()})),u={width:a.getInputWidth(0),height:a.getInputHeight(0)},[4,this.extractBoxes(s,a.getReshapedInputDimensions(0),o)];case 3:return c=m.sent(),i.dispose(),s.dispose(),l=c.map((function(t){return t.box})),f=c.map((function(t){return t.score})),h=c.map((function(t){return t.classScore})),p=c.map((function(t){return v.config.classes[t.label]})),d=qt(l.map((function(t){return t.rescale(r)})),f,this.config.iouThreshold,!0),[2,d.map((function(t){return new Vt(f[t],h[t],p[t],l[t],u)}))]}}))}))},e.prototype.getDefaultModelName=function(){return""},e.prototype.extractParamsFromWeigthMap=function(t){return function(t,e){var n,r=[],o=tr(t,r),a=o.extractConvParams,i=o.extractConvWithBatchNormParams,s=o.extractSeparableConvParams;if(e.withSeparableConvs){var u=e.filterSizes&&e.filterSizes.length||9;n={conv0:e.isFirstLayerConv2d?a("conv0"):s("conv0"),conv1:s("conv1"),conv2:s("conv2"),conv3:s("conv3"),conv4:s("conv4"),conv5:s("conv5"),conv6:u>7?s("conv6"):void 0,conv7:u>8?s("conv7"):void 0,conv8:a("conv8")}}else n={conv0:i("conv0"),conv1:i("conv1"),conv2:i("conv2"),conv3:i("conv3"),conv4:i("conv4"),conv5:i("conv5"),conv6:i("conv6"),conv7:i("conv7"),conv8:a("conv8")};return Ue(t,r),{params:n,paramMappings:r}}(t,this.config)},e.prototype.extractParams=function(t){var n=this.config.filterSizes||e.DEFAULT_FILTER_SIZES,r=n?n.length:void 0;if(7!==r&&8!==r&&9!==r)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+r+" filterSizes in config");return function(t,e,n,r){var o,a=Ke(t),i=a.extractWeights,s=a.getRemainingWeights,u=[],c=Zn(i,u),l=c.extractConvParams,f=c.extractConvWithBatchNormParams,h=c.extractSeparableConvParams;if(e.withSeparableConvs){var p=r[0],d=r[1],v=r[2],m=r[3],g=r[4],y=r[5],b=r[6],x=r[7],w=r[8];o={conv0:e.isFirstLayerConv2d?l(p,d,3,"conv0"):h(p,d,"conv0"),conv1:h(d,v,"conv1"),conv2:h(v,m,"conv2"),conv3:h(m,g,"conv3"),conv4:h(g,y,"conv4"),conv5:h(y,b,"conv5"),conv6:x?h(b,x,"conv6"):void 0,conv7:w?h(x,w,"conv7"):void 0,conv8:l(w||x||b,5*n,1,"conv8")}}else{p=r[0],d=r[1],v=r[2],m=r[3],g=r[4],y=r[5],b=r[6],x=r[7],w=r[8];o={conv0:f(p,d,"conv0"),conv1:f(d,v,"conv1"),conv2:f(v,m,"conv2"),conv3:f(m,g,"conv3"),conv4:f(g,y,"conv4"),conv5:f(y,b,"conv5"),conv6:f(b,x,"conv6"),conv7:f(x,w,"conv7"),conv8:l(w,5*n,1,"conv8")}}if(0!==s().length)throw new Error("weights remaing after extract: "+s().length);return{params:o,paramMappings:u}}(t,this.config,this.boxEncodingSize,n)},e.prototype.extractBoxes=function(t,e,n){return Object(St.b)(this,void 0,void 0,(function(){var r,o,a,i,s,u,c,l,f,h,p,d,v,m,g,y,b,x,w,E,C,_,k,R,I,S,A,O,T,D=this;return Object(St.d)(this,(function(N){switch(N.label){case 0:return r=e.width,o=e.height,a=Math.max(r,o),i=a/r,s=a/o,u=t.shape[1],c=this.config.anchors.length,l=Rt.L((function(){var e=t.reshape([u,u,c,D.boxEncodingSize]);return[e.slice([0,0,0,0],[u,u,c,4]),e.slice([0,0,0,4],[u,u,c,1]),D.withClassScores?Rt.D(e.slice([0,0,0,5],[u,u,c,D.config.classes.length]),3):Rt.y(0)]})),f=l[0],h=l[1],p=l[2],d=[],[4,h.array()];case 1:return v=N.sent(),[4,f.array()];case 2:m=N.sent(),g=0,N.label=3;case 3:if(!(g<u))return[3,12];y=0,N.label=4;case 4:if(!(y<u))return[3,11];b=0,N.label=5;case 5:return b<c?(x=Xt(v[g][y][b][0]),!n||x>n?(w=(y+Xt(m[g][y][b][0]))/u*i,E=(g+Xt(m[g][y][b][1]))/u*s,C=Math.exp(m[g][y][b][2])*this.config.anchors[b].x/u*i,_=Math.exp(m[g][y][b][3])*this.config.anchors[b].y/u*s,k=w-C/2,R=E-_/2,I={row:g,col:y,anchor:b},this.withClassScores?[4,this.extractPredictedClass(p,I)]:[3,7]):[3,9]):[3,10];case 6:return T=N.sent(),[3,8];case 7:T={classScore:1,label:0},N.label=8;case 8:A=(S=T).classScore,O=S.label,d.push(Object(St.a)({box:new zt(k,R,k+C,R+_),score:x,classScore:x*A,label:O},I)),N.label=9;case 9:return b++,[3,5];case 10:return y++,[3,4];case 11:return g++,[3,3];case 12:return f.dispose(),h.dispose(),p.dispose(),[2,d]}}))}))},e.prototype.extractPredictedClass=function(t,e){return Object(St.b)(this,void 0,void 0,(function(){var n,r,o,a;return Object(St.d)(this,(function(i){switch(i.label){case 0:return n=e.row,r=e.col,o=e.anchor,[4,t.array()];case 1:return a=i.sent(),[2,Array(this.config.classes.length).fill(0).map((function(t,e){return a[n][r][o][e]})).map((function(t,e){return{classScore:t,label:e}})).reduce((function(t,e){return t.classScore>e.classScore?t:e}))]}}))}))},e.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],e}(Me),rr=function(t){function e(e){void 0===e&&(e=!0);var n=Object.assign({},{withSeparableConvs:e,iouThreshold:.4,classes:["face"]},e?{anchors:Kn,meanRgb:Xn}:{anchors:qn,withClassScores:!0});return t.call(this,n)||this}return Object(St.c)(e,t),Object.defineProperty(e.prototype,"withSeparableConvs",{get:function(){return this.config.withSeparableConvs},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),e.prototype.locateFaces=function(t,e){return Object(St.b)(this,void 0,void 0,(function(){return Object(St.d)(this,(function(n){switch(n.label){case 0:return[4,this.detect(t,e)];case 1:return[2,n.sent().map((function(t){return new Gt(t.score,t.relativeBox,{width:t.imageWidth,height:t.imageHeight})}))]}}))}))},e.prototype.getDefaultModelName=function(){return this.withSeparableConvs?"tiny_yolov2_separable_conv_model":"tiny_yolov2_model"},e.prototype.extractParamsFromWeigthMap=function(e){return t.prototype.extractParamsFromWeigthMap.call(this,e)},e}(nr);var or=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._name="TinyFaceDetectorOptions",e}return Object(St.c)(e,t),e}(er),ar=function(){function t(){}return t.prototype.then=function(t){return Object(St.b)(this,void 0,void 0,(function(){var e;return Object(St.d)(this,(function(n){switch(n.label){case 0:return e=t,[4,this.run()];case 1:return[2,e.apply(void 0,[n.sent()])]}}))}))},t.prototype.run=function(){return Object(St.b)(this,void 0,void 0,(function(){return Object(St.d)(this,(function(t){throw new Error("ComposableTask - run is not implemented")}))}))},t}();function ir(t,e,n,r,o){return void 0===o&&(o=function(t){return t.alignedRect}),Object(St.b)(this,void 0,void 0,(function(){var a,i,s,u,c;return Object(St.d)(this,(function(l){switch(l.label){case 0:return a=t.map((function(t){return sn(t)?o(t):t.detection})),(s=r)?[3,5]:e instanceof Rt.a?[4,Oe(e,a)]:[3,2];case 1:return u=l.sent(),[3,4];case 2:return[4,Ae(e,a)];case 3:u=l.sent(),l.label=4;case 4:s=u,l.label=5;case 5:return[4,n(i=s)];case 6:return c=l.sent(),i.forEach((function(t){return t instanceof Rt.a&&t.dispose()})),[2,c]}}))}))}function sr(t,e,n,r,o){return Object(St.b)(this,void 0,void 0,(function(){var a=this;return Object(St.d)(this,(function(i){return[2,ir([t],e,(function(t){return Object(St.b)(a,void 0,void 0,(function(){return Object(St.d)(this,(function(e){return[2,n(t[0])]}))}))}),r,o)]}))}))}function ur(t){var e=Ke(t),n=e.extractWeights,r=e.getRemainingWeights,o=[],a=function(t,e){var n=je(t,e),r=ze(t,e);function o(n,r){var o=Rt.H(t(n));return e.push({paramPath:r}),o}function a(t,e,r){return void 0===r&&(r=!1),{conv1:n(t[0],t[1],3,e+"/conv1"),prelu1_alpha:o(t[1],e+"/prelu1_alpha"),conv2:n(t[1],t[2],3,e+"/conv2"),prelu2_alpha:o(t[2],e+"/prelu2_alpha"),conv3:n(t[2],t[3],r?2:3,e+"/conv3"),prelu3_alpha:o(t[3],e+"/prelu3_alpha")}}return{extractPNetParams:function(){var t=a([3,10,16,32],"pnet"),e=n(32,2,1,"pnet/conv4_1"),r=n(32,4,1,"pnet/conv4_2");return Object(St.a)(Object(St.a)({},t),{conv4_1:e,conv4_2:r})},extractRNetParams:function(){var t=a([3,28,48,64],"rnet",!0),e=r(576,128,"rnet/fc1"),n=o(128,"rnet/prelu4_alpha"),i=r(128,2,"rnet/fc2_1"),s=r(128,4,"rnet/fc2_2");return Object(St.a)(Object(St.a)({},t),{fc1:e,prelu4_alpha:n,fc2_1:i,fc2_2:s})},extractONetParams:function(){var t=a([3,32,64,64],"onet"),e=n(64,128,2,"onet/conv4"),i=o(128,"onet/prelu4_alpha"),s=r(1152,256,"onet/fc1"),u=o(256,"onet/prelu5_alpha"),c=r(256,2,"onet/fc2_1"),l=r(256,4,"onet/fc2_2"),f=r(256,10,"onet/fc2_3");return Object(St.a)(Object(St.a)({},t),{conv4:e,prelu4_alpha:i,fc1:s,prelu5_alpha:u,fc2_1:c,fc2_2:l,fc2_3:f})}}}(n,o),i=a.extractPNetParams,s=a.extractRNetParams,u=a.extractONetParams,c=i(),l=s(),f=u();if(0!==r().length)throw new Error("weights remaing after extract: "+r().length);return{params:{pnet:c,rnet:l,onet:f},paramMappings:o}}function cr(t){var e=[],n=function(t,e){var n=qe(t,e);function r(t){return{filters:n(t+"/weights",4,t+"/filters"),bias:n(t+"/bias",1)}}function o(t){return{weights:n(t+"/weights",2),bias:n(t+"/bias",1)}}function a(t){return n(t,1)}function i(t){return{conv1:r(t+"/conv1"),prelu1_alpha:a(t+"/prelu1_alpha"),conv2:r(t+"/conv2"),prelu2_alpha:a(t+"/prelu2_alpha"),conv3:r(t+"/conv3"),prelu3_alpha:a(t+"/prelu3_alpha")}}return{extractPNetParams:function(){var t=i("pnet"),e=r("pnet/conv4_1"),n=r("pnet/conv4_2");return Object(St.a)(Object(St.a)({},t),{conv4_1:e,conv4_2:n})},extractRNetParams:function(){var t=i("rnet"),e=o("rnet/fc1"),n=a("rnet/prelu4_alpha"),r=o("rnet/fc2_1"),s=o("rnet/fc2_2");return Object(St.a)(Object(St.a)({},t),{fc1:e,prelu4_alpha:n,fc2_1:r,fc2_2:s})},extractONetParams:function(){var t=i("onet"),e=r("onet/conv4"),n=a("onet/prelu4_alpha"),s=o("onet/fc1"),u=a("onet/prelu5_alpha"),c=o("onet/fc2_1"),l=o("onet/fc2_2"),f=o("onet/fc2_3");return Object(St.a)(Object(St.a)({},t),{conv4:e,prelu4_alpha:n,fc1:s,prelu5_alpha:u,fc2_1:c,fc2_2:l,fc2_3:f})}}}(t,e),r=n.extractPNetParams,o=n.extractRNetParams,a=n.extractONetParams,i=r(),s=o(),u=a();return Ue(t,e),{params:{pnet:i,rnet:s,onet:u},paramMappings:e}}function lr(t,e){var n=e[0],r=e[1];return{height:Math.floor(n*t),width:Math.floor(r*t)}}var fr=function(t){function e(e,n,r,o){return t.call(this,{left:e,top:n,right:r,bottom:o},!0)||this}return Object(St.c)(e,t),e}(jt);function hr(t){return Rt.L((function(){return Rt.t(Rt.F(t,Rt.y(127.5)),Rt.y(.0078125))}))}function pr(t,e){return Rt.L((function(){return Rt.c(Rt.w(t),Rt.t(e,Rt.u(Rt.w(Rt.u(t)))))}))}function dr(t,e,n){return void 0===n&&(n=!1),Rt.L((function(){var r=We(t,e.conv1,"valid");return r=pr(r,e.prelu1_alpha),r=pr(r=We(r=Rt.s(r,n?[2,2]:[3,3],[2,2],"same"),e.conv2,"valid"),e.prelu2_alpha),r=pr(r=We(r=n?r:Rt.s(r,[3,3],[2,2],"valid"),e.conv3,"valid"),e.prelu3_alpha)}))}function vr(t,e,n,r,o){o.stage1=[];var a=e.map((function(e){return Rt.L((function(){var n={scale:e},o=function(t,e){return Rt.L((function(){var n=lr(e,t.shape.slice(1)),r=n.height,o=n.width,a=hr(Rt.o.resizeBilinear(t,[r,o]));return Rt.N(a,[0,2,1,3])}))}(t,e),a=Date.now(),i=function(t,e){return Rt.L((function(){var n=dr(t,e,!0),r=We(n,e.conv4_1,"valid"),o=Rt.m(Rt.r(r,3),3);return{prob:Rt.D(Rt.F(r,o),3),regions:We(n,e.conv4_2,"valid")}}))}(o,r),s=i.prob,u=i.regions;return n.pnet=Date.now()-a,{scoresTensor:Rt.O(Rt.O(s,3)[1])[0],regionsTensor:Rt.O(u)[0],scale:e,statsForScale:n}}))})).map((function(t){var e=t.scoresTensor,r=t.regionsTensor,a=t.scale,i=t.statsForScale,s=function(t,e,n,r){for(var o=[],a=t.arraySync(),i=0;i<t.shape[0];i++)for(var s=0;s<t.shape[1];s++)a[i][s]>=r&&o.push(new Ut(s,i));return o.map((function(t){var r=new zt(Math.round((2*t.y+1)/n),Math.round((2*t.x+1)/n),Math.round((2*t.y+12)/n),Math.round((2*t.x+12)/n)),o=a[t.y][t.x],i=e.arraySync();return{cell:r,score:o,region:new fr(i[t.y][t.x][0],i[t.y][t.x][1],i[t.y][t.x][2],i[t.y][t.x][3])}}))}(e,r,a,n);if(e.dispose(),r.dispose(),!s.length)return o.stage1.push(i),[];var u=Date.now(),c=qt(s.map((function(t){return t.cell})),s.map((function(t){return t.score})),.5);return i.nms=Date.now()-u,i.numBoxes=c.length,o.stage1.push(i),c.map((function(t){return s[t]}))})).reduce((function(t,e){return t.concat(e)}),[]),i=[],s=[];if(a.length>0){var u=Date.now(),c=qt(a.map((function(t){return t.cell})),a.map((function(t){return t.score})),.7);o.stage1_nms=Date.now()-u,s=c.map((function(t){return a[t].score})),i=c.map((function(t){return a[t]})).map((function(t){var e=t.cell,n=t.region;return new zt(e.left+n.left*e.width,e.top+n.top*e.height,e.right+n.right*e.width,e.bottom+n.bottom*e.height).toSquare().round()}))}return{boxes:i,scores:s}}function mr(t,e,n){var r=n.width,o=n.height;return Object(St.b)(this,void 0,void 0,(function(){var n,a,i,s=this;return Object(St.d)(this,(function(u){switch(u.label){case 0:return n=ve(t),[4,Promise.all(e.map((function(e){return Object(St.b)(s,void 0,void 0,(function(){var r,o,a,i,s,u,c,l;return Object(St.d)(this,(function(f){return r=e.padAtBorders(t.height,t.width),o=r.y,a=r.ey,i=r.x,s=r.ex,u=i-1,c=o-1,l=n.getImageData(u,c,s-u,a-c),[2,pe.isNodejs()?_e(l):createImageBitmap(l)]}))}))})))];case 1:return a=u.sent(),i=[],a.forEach((function(t){var e=ve(Ce({width:r,height:o}));e.drawImage(t,0,0,r,o);for(var n=e.getImageData(0,0,r,o).data,a=[],s=0;s<n.length;s+=4)a.push(n[s+2]),a.push(n[s+1]),a.push(n[s]);i.push(a)})),[2,i.map((function(t){return Rt.L((function(){return hr(Rt.N(Rt.K(t,[1,r,o,3]),[0,2,1,3]).toFloat())}))}))]}}))}))}function gr(t,e,n,r,o){return Object(St.b)(this,void 0,void 0,(function(){var a,i,s,u,c,l,f,h,p,d,v,m,g,y;return Object(St.d)(this,(function(b){switch(b.label){case 0:return a=Date.now(),[4,mr(t,e,{width:24,height:24})];case 1:return i=b.sent(),o.stage2_extractImagePatches=Date.now()-a,a=Date.now(),s=i.map((function(t){var e=function(t,e){return Rt.L((function(){var n=dr(t,e),r=pr(Qe(Rt.x(n,[n.shape[0],e.fc1.weights.shape[0]]),e.fc1),e.prelu4_alpha),o=Qe(r,e.fc2_1),a=Rt.m(Rt.r(o,1),1),i=Rt.D(Rt.F(o,a),1),s=Qe(r,e.fc2_2);return{scores:Rt.O(i,1)[1],regions:s}}))}(t,r);return t.dispose(),e})),o.stage2_rnet=Date.now()-a,u=s.length>1?Rt.h(s.map((function(t){return t.scores}))):s[0].scores,f=(l=Array).from,[4,u.data()];case 2:return c=f.apply(l,[b.sent()]),u.dispose(),h=c.map((function(t,e){return{score:t,idx:e}})).filter((function(t){return t.score>n})).map((function(t){return t.idx})),p=h.map((function(t){return e[t]})),d=h.map((function(t){return c[t]})),v=[],m=[],p.length>0&&(a=Date.now(),g=qt(p,d,.7),o.stage2_nms=Date.now()-a,y=g.map((function(t){var e=s[h[t]].regions.arraySync();return new fr(e[0][0],e[0][1],e[0][2],e[0][3])})),m=g.map((function(t){return d[t]})),v=g.map((function(t,e){return p[t].calibrate(y[e])}))),s.forEach((function(t){t.regions.dispose(),t.scores.dispose()})),[2,{boxes:v,scores:m}]}}))}))}function yr(t,e,n,r,o){return Object(St.b)(this,void 0,void 0,(function(){var a,i,s,u,c,l,f,h,p,d,v,m,g,y,b;return Object(St.d)(this,(function(x){switch(x.label){case 0:return a=Date.now(),[4,mr(t,e,{width:48,height:48})];case 1:return i=x.sent(),o.stage3_extractImagePatches=Date.now()-a,a=Date.now(),s=i.map((function(t){var e=function(t,e){return Rt.L((function(){var n=dr(t,e);n=pr(n=We(n=Rt.s(n,[2,2],[2,2],"same"),e.conv4,"valid"),e.prelu4_alpha);var r=pr(Qe(Rt.x(n,[n.shape[0],e.fc1.weights.shape[0]]),e.fc1),e.prelu5_alpha),o=Qe(r,e.fc2_1),a=Rt.m(Rt.r(o,1),1),i=Rt.D(Rt.F(o,a),1),s=Qe(r,e.fc2_2),u=Qe(r,e.fc2_3);return{scores:Rt.O(i,1)[1],regions:s,points:u}}))}(t,r);return t.dispose(),e})),o.stage3_onet=Date.now()-a,u=s.length>1?Rt.h(s.map((function(t){return t.scores}))):s[0].scores,f=(l=Array).from,[4,u.data()];case 2:return c=f.apply(l,[x.sent()]),u.dispose(),h=c.map((function(t,e){return{score:t,idx:e}})).filter((function(t){return t.score>n})).map((function(t){return t.idx})),p=h.map((function(t){var e=s[t].regions.arraySync();return new fr(e[0][0],e[0][1],e[0][2],e[0][3])})),d=h.map((function(t,n){return e[t].calibrate(p[n])})),v=h.map((function(t){return c[t]})),m=[],g=[],y=[],d.length>0&&(a=Date.now(),b=qt(d,v,.7,!1),o.stage3_nms=Date.now()-a,m=b.map((function(t){return d[t]})),g=b.map((function(t){return v[t]})),y=b.map((function(t,e){return Array(5).fill(0).map((function(n,r){var o=s[t].points.arraySync();return new Ut(o[0][r]*(m[e].width+1)+m[e].left,o[0][r+5]*(m[e].height+1)+m[e].top)}))}))),s.forEach((function(t){t.regions.dispose(),t.scores.dispose(),t.points.dispose()})),[2,{boxes:m,scores:g,points:y}]}}))}))}var br=function(t){function e(){return t.call(this,"Mtcnn")||this}return Object(St.c)(e,t),e.prototype.load=function(e){return Object(St.b)(this,void 0,void 0,(function(){return Object(St.d)(this,(function(n){return[2,t.prototype.load.call(this,e)]}))}))},e.prototype.loadFromDisk=function(e){return Object(St.b)(this,void 0,void 0,(function(){return Object(St.d)(this,(function(n){return[2,t.prototype.loadFromDisk.call(this,e)]}))}))},e.prototype.forwardInput=function(t,e){return void 0===e&&(e={}),Object(St.b)(this,void 0,void 0,(function(){var n,r,o,a,i,s,u,c,l,f,h,p,d,v,m,g,y,b,x,w,E;return Object(St.d)(this,(function(C){switch(C.label){case 0:if(!(n=this.params))throw new Error("Mtcnn - load model before inference");if(!(r=t.canvases[0]))throw new Error("Mtcnn - inputCanvas is not defined, note that passing tensors into Mtcnn.forwardInput is not supported yet.");return o={},a=Date.now(),i=Rt.L((function(){return t=Rt.m(Rt.f.fromPixels(r)).toFloat(),Rt.L((function(){return Rt.E(Rt.O(t,3).reverse(),3)}));var t})),s=function(t){return i.dispose(),o.total=Date.now()-a,t},u=i.shape.slice(1),c=u[0],l=u[1],f=new Mn(e),h=f.minFaceSize,p=f.scaleFactor,d=f.maxNumScales,v=f.scoreThresholds,m=f.scaleSteps,g=(m||function(t,e,n){for(var r=n[0],o=n[1],a=12/t,i=[],s=Math.min(r,o)*a,u=0;s>=12;)i.push(a*Math.pow(e,u)),s*=e,u+=1;return i}(h,p,[c,l])).filter((function(t){var e=lr(t,[c,l]);return Math.min(e.width,e.height)>12})).slice(0,d),o.scales=g,o.pyramid=g.map((function(t){return lr(t,[c,l])})),y=Date.now(),[4,vr(i,g,v[0],n.pnet,o)];case 1:return b=C.sent(),o.total_stage1=Date.now()-y,b.boxes.length?(o.stage2_numInputBoxes=b.boxes.length,y=Date.now(),[4,gr(r,b.boxes,v[1],n.rnet,o)]):[2,s({results:[],stats:o})];case 2:return x=C.sent(),o.total_stage2=Date.now()-y,x.boxes.length?(o.stage3_numInputBoxes=x.boxes.length,y=Date.now(),[4,yr(r,x.boxes,v[2],n.onet,o)]):[2,s({results:[],stats:o})];case 3:return w=C.sent(),o.total_stage3=Date.now()-y,E=w.boxes.map((function(t,e){return un(re({},new Gt(w.scores[e],new $t(t.left/l,t.top/c,t.width/l,t.height/c),{height:c,width:l})),new Jt(w.points[e].map((function(e){return e.sub(new Ut(t.left,t.top)).div(new Ut(t.width,t.height))})),{width:t.width,height:t.height}))})),[2,s({results:E,stats:o})]}}))}))},e.prototype.forward=function(t,e){return void 0===e&&(e={}),Object(St.b)(this,void 0,void 0,(function(){var n;return Object(St.d)(this,(function(r){switch(r.label){case 0:return n=this.forwardInput,[4,Se(t)];case 1:return[4,n.apply(this,[r.sent(),e])];case 2:return[2,r.sent().results]}}))}))},e.prototype.forwardWithStats=function(t,e){return void 0===e&&(e={}),Object(St.b)(this,void 0,void 0,(function(){var n;return Object(St.d)(this,(function(r){switch(r.label){case 0:return n=this.forwardInput,[4,Se(t)];case 1:return[2,n.apply(this,[r.sent(),e])]}}))}))},e.prototype.getDefaultModelName=function(){return"mtcnn_model"},e.prototype.extractParamsFromWeigthMap=function(t){return cr(t)},e.prototype.extractParams=function(t){return ur(t)},e}(Me),xr=[new Ut(1.603231,2.094468),new Ut(6.041143,7.080126),new Ut(2.882459,3.518061),new Ut(4.266906,5.178857),new Ut(9.041765,10.66308)],wr=[117.001,114.697,97.404],Er=function(t){function e(){var e={withSeparableConvs:!0,iouThreshold:.4,classes:["face"],anchors:xr,meanRgb:wr,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return t.call(this,e)||this}return Object(St.c)(e,t),Object.defineProperty(e.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),e.prototype.locateFaces=function(t,e){return Object(St.b)(this,void 0,void 0,(function(){return Object(St.d)(this,(function(n){switch(n.label){case 0:return[4,this.detect(t,e)];case 1:return[2,n.sent().map((function(t){return new Gt(t.score,t.relativeBox,{width:t.imageWidth,height:t.imageHeight})}))]}}))}))},e.prototype.getDefaultModelName=function(){return"tiny_face_detector_model"},e.prototype.extractParamsFromWeigthMap=function(e){return t.prototype.extractParamsFromWeigthMap.call(this,e)},e}(nr),Cr={ssdMobilenetv1:new Gn,tinyFaceDetector:new Er,tinyYolov2:new rr,mtcnn:new br,faceLandmark68Net:new xn,faceLandmark68TinyNet:new En,faceRecognitionNet:new Tn,faceExpressionNet:new rn,ageGenderNet:new yn},_r=function(t){function e(e,n,r){var o=t.call(this)||this;return o.parentTask=e,o.input=n,o.extractedFaces=r,o}return Object(St.c)(e,t),e}(ar),kr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.run=function(){return Object(St.b)(this,void 0,void 0,(function(){var t,e,n=this;return Object(St.d)(this,(function(r){switch(r.label){case 0:return[4,this.parentTask];case 1:return[4,ir(t=r.sent(),this.input,(function(t){return Object(St.b)(n,void 0,void 0,(function(){return Object(St.d)(this,(function(e){switch(e.label){case 0:return[4,Promise.all(t.map((function(t){return Cr.faceExpressionNet.predictExpressions(t)})))];case 1:return[2,e.sent()]}}))}))}),this.extractedFaces)];case 2:return e=r.sent(),[2,t.map((function(t,n){return on(t,e[n])}))]}}))}))},e.prototype.withAgeAndGender=function(){return new Or(this,this.input)},e}(_r),Rr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.run=function(){return Object(St.b)(this,void 0,void 0,(function(){var t,e;return Object(St.d)(this,(function(n){switch(n.label){case 0:return[4,this.parentTask];case 1:return(t=n.sent())?[4,sr(t,this.input,(function(t){return Cr.faceExpressionNet.predictExpressions(t)}),this.extractedFaces)]:[2];case 2:return e=n.sent(),[2,on(t,e)]}}))}))},e.prototype.withAgeAndGender=function(){return new Tr(this,this.input)},e}(_r),Ir=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.withAgeAndGender=function(){return new Dr(this,this.input)},e.prototype.withFaceDescriptors=function(){return new Mr(this,this.input)},e}(kr),Sr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.withAgeAndGender=function(){return new Nr(this,this.input)},e.prototype.withFaceDescriptor=function(){return new Pr(this,this.input)},e}(Rr),Ar=function(t){function e(e,n,r){var o=t.call(this)||this;return o.parentTask=e,o.input=n,o.extractedFaces=r,o}return Object(St.c)(e,t),e}(ar),Or=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.run=function(){return Object(St.b)(this,void 0,void 0,(function(){var t,e,n=this;return Object(St.d)(this,(function(r){switch(r.label){case 0:return[4,this.parentTask];case 1:return[4,ir(t=r.sent(),this.input,(function(t){return Object(St.b)(n,void 0,void 0,(function(){return Object(St.d)(this,(function(e){switch(e.label){case 0:return[4,Promise.all(t.map((function(t){return Cr.ageGenderNet.predictAgeAndGender(t)})))];case 1:return[2,e.sent()]}}))}))}),this.extractedFaces)];case 2:return e=r.sent(),[2,t.map((function(t,n){var r=e[n],o=r.age;return Nn(Fn(t,r.gender,r.genderProbability),o)}))]}}))}))},e.prototype.withFaceExpressions=function(){return new kr(this,this.input)},e}(Ar),Tr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.run=function(){return Object(St.b)(this,void 0,void 0,(function(){var t,e,n,r,o;return Object(St.d)(this,(function(a){switch(a.label){case 0:return[4,this.parentTask];case 1:return(t=a.sent())?[4,sr(t,this.input,(function(t){return Cr.ageGenderNet.predictAgeAndGender(t)}),this.extractedFaces)]:[2];case 2:return e=a.sent(),n=e.age,r=e.gender,o=e.genderProbability,[2,Nn(Fn(t,r,o),n)]}}))}))},e.prototype.withFaceExpressions=function(){return new Rr(this,this.input)},e}(Ar),Dr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.withFaceExpressions=function(){return new Ir(this,this.input)},e.prototype.withFaceDescriptors=function(){return new Mr(this,this.input)},e}(Or),Nr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.withFaceExpressions=function(){return new Sr(this,this.input)},e.prototype.withFaceDescriptor=function(){return new Pr(this,this.input)},e}(Tr),Fr=function(t){function e(e,n){var r=t.call(this)||this;return r.parentTask=e,r.input=n,r}return Object(St.c)(e,t),e}(ar),Mr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.run=function(){return Object(St.b)(this,void 0,void 0,(function(){var t;return Object(St.d)(this,(function(e){switch(e.label){case 0:return[4,this.parentTask];case 1:return[4,ir(t=e.sent(),this.input,(function(t){return Promise.all(t.map((function(t){return Cr.faceRecognitionNet.computeFaceDescriptor(t)})))}),null,(function(t){return t.landmarks.align(null,{useDlibAlignment:!0})}))];case 2:return[2,e.sent().map((function(e,n){return Dn(t[n],e)}))]}}))}))},e.prototype.withFaceExpressions=function(){return new Ir(this,this.input)},e.prototype.withAgeAndGender=function(){return new Dr(this,this.input)},e}(Fr),Pr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.run=function(){return Object(St.b)(this,void 0,void 0,(function(){var t,e;return Object(St.d)(this,(function(n){switch(n.label){case 0:return[4,this.parentTask];case 1:return(t=n.sent())?[4,sr(t,this.input,(function(t){return Cr.faceRecognitionNet.computeFaceDescriptor(t)}),null,(function(t){return t.landmarks.align(null,{useDlibAlignment:!0})}))]:[2];case 2:return e=n.sent(),[2,Dn(t,e)]}}))}))},e.prototype.withFaceExpressions=function(){return new Sr(this,this.input)},e.prototype.withAgeAndGender=function(){return new Nr(this,this.input)},e}(Fr),Br=function(t){function e(e,n,r){var o=t.call(this)||this;return o.parentTask=e,o.input=n,o.useTinyLandmarkNet=r,o}return Object(St.c)(e,t),Object.defineProperty(e.prototype,"landmarkNet",{get:function(){return this.useTinyLandmarkNet?Cr.faceLandmark68TinyNet:Cr.faceLandmark68Net},enumerable:!0,configurable:!0}),e}(ar),Lr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.run=function(){return Object(St.b)(this,void 0,void 0,(function(){var t,e,n,r,o,a=this;return Object(St.d)(this,(function(i){switch(i.label){case 0:return[4,this.parentTask];case 1:return t=i.sent(),e=t.map((function(t){return t.detection})),this.input instanceof Rt.a?[4,Oe(this.input,e)]:[3,3];case 2:return r=i.sent(),[3,5];case 3:return[4,Ae(this.input,e)];case 4:r=i.sent(),i.label=5;case 5:return n=r,[4,Promise.all(n.map((function(t){return a.landmarkNet.detectLandmarks(t)})))];case 6:return o=i.sent(),n.forEach((function(t){return t instanceof Rt.a&&t.dispose()})),[2,t.map((function(t,e){return un(t,o[e])}))]}}))}))},e.prototype.withFaceExpressions=function(){return new Ir(this,this.input)},e.prototype.withAgeAndGender=function(){return new Dr(this,this.input)},e.prototype.withFaceDescriptors=function(){return new Mr(this,this.input)},e}(Br),Wr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.run=function(){return Object(St.b)(this,void 0,void 0,(function(){var t,e,n,r,o;return Object(St.d)(this,(function(a){switch(a.label){case 0:return[4,this.parentTask];case 1:return(t=a.sent())?(e=t.detection,this.input instanceof Rt.a?[4,Oe(this.input,[e])]:[3,3]):[2];case 2:return r=a.sent(),[3,5];case 3:return[4,Ae(this.input,[e])];case 4:r=a.sent(),a.label=5;case 5:return n=r,[4,this.landmarkNet.detectLandmarks(n[0])];case 6:return o=a.sent(),n.forEach((function(t){return t instanceof Rt.a&&t.dispose()})),[2,un(t,o)]}}))}))},e.prototype.withFaceExpressions=function(){return new Sr(this,this.input)},e.prototype.withAgeAndGender=function(){return new Nr(this,this.input)},e.prototype.withFaceDescriptor=function(){return new Pr(this,this.input)},e}(Br),Ur=function(t){function e(e,n){void 0===n&&(n=new Vn);var r=t.call(this)||this;return r.input=e,r.options=n,r}return Object(St.c)(e,t),e}(ar),jr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(St.c)(e,t),e.prototype.run=function(){return Object(St.b)(this,void 0,void 0,(function(){var t,e,n,r;return Object(St.d)(this,(function(o){switch(o.label){case 0:return e=(t=this).input,(n=t.options)instanceof Mn?[4,Cr.mtcnn.forward(e,n)]:[3,2];case 1:return[2,o.sent().map((function(t){return t.detection}))];case 2:if(!(r=n instanceof or?function(t){return Cr.tinyFaceDetector.locateFaces(t,n)}:n instanceof Vn?function(t){return Cr.ssdMobilenetv1.locateFaces(t,n)}:n instanceof er?function(t){return Cr.tinyYolov2.locateFaces(t,n)}:null))throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return[2,r(e)]}}))}))},e.prototype.runAndExtendWithFaceDetections=function(){var t=this;return new Promise((function(e){return Object(St.b)(t,void 0,void 0,(function(){var t;return Object(St.d)(this,(function(n){switch(n.label){case 0:return[4,this.run()];case 1:return t=n.sent(),[2,e(t.map((function(t){return re({},t)})))]}}))}))}))},e.prototype.withFaceLandmarks=function(t){return void 0===t&&(t=!1),new Lr(this.runAndExtendWithFaceDetections(),this.input,t)},e.prototype.withFaceExpressions=function(){return new kr(this.runAndExtendWithFaceDetections(),this.input)},e.prototype.withAgeAndGender=function(){return new Or(this.runAndExtendWithFaceDetections(),this.input)},e}(Ur);!function(t){function e(){return null!==t&&t.apply(this,arguments)||this}Object(St.c)(e,t),e.prototype.run=function(){return Object(St.b)(this,void 0,void 0,(function(){var t,e;return Object(St.d)(this,(function(n){switch(n.label){case 0:return[4,new jr(this.input,this.options)];case 1:return t=n.sent(),e=t[0],t.forEach((function(t){t.score>e.score&&(e=t)})),[2,e]}}))}))},e.prototype.runAndExtendWithFaceDetection=function(){var t=this;return new Promise((function(e){return Object(St.b)(t,void 0,void 0,(function(){var t;return Object(St.d)(this,(function(n){switch(n.label){case 0:return[4,this.run()];case 1:return t=n.sent(),[2,e(t?re({},t):void 0)]}}))}))}))},e.prototype.withFaceLandmarks=function(t){return void 0===t&&(t=!1),new Wr(this.runAndExtendWithFaceDetection(),this.input,t)},e.prototype.withFaceExpressions=function(){return new Rr(this.runAndExtendWithFaceDetection(),this.input)},e.prototype.withAgeAndGender=function(){return new Tr(this.runAndExtendWithFaceDetection(),this.input)}}(Ur);function zr(t,e){return void 0===e&&(e=new Vn),new jr(t,e)}!function(){function t(t,e){void 0===e&&(e=.6),this._distanceThreshold=e;var n=Array.isArray(t)?t:[t];if(!n.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");var r=1,o=function(){return"person "+r++};this._labeledDescriptors=n.map((function(t){if(t instanceof ee)return t;if(t instanceof Float32Array)return new ee(o(),[t]);if(t.descriptor&&t.descriptor instanceof Float32Array)return new ee(o(),[t.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>")}))}Object.defineProperty(t.prototype,"labeledDescriptors",{get:function(){return this._labeledDescriptors},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"distanceThreshold",{get:function(){return this._distanceThreshold},enumerable:!0,configurable:!0}),t.prototype.computeMeanDistance=function(t,e){return e.map((function(e){return function(t,e){if(t.length!==e.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var n=Array.from(t),r=Array.from(e);return Math.sqrt(n.map((function(t,e){return t-r[e]})).reduce((function(t,e){return t+Math.pow(e,2)}),0))}(e,t)})).reduce((function(t,e){return t+e}),0)/(e.length||1)},t.prototype.matchDescriptor=function(t){var e=this;return this.labeledDescriptors.map((function(n){var r=n.descriptors,o=n.label;return new Zt(o,e.computeMeanDistance(t,r))})).reduce((function(t,e){return t.distance<e.distance?t:e}))},t.prototype.findBestMatch=function(t){var e=this.matchDescriptor(t);return e.distance<this.distanceThreshold?e:new Zt("unknown",e.distance)},t.prototype.toJSON=function(){return{distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map((function(t){return t.toJSON()}))}},t.fromJSON=function(e){return new t(e.labeledDescriptors.map((function(t){return ee.fromJSON(t)})),e.distanceThreshold)}}();const Vr=t=>{const e=.25*t.height,n=t.y-e>=0?t.y-e:0,r=.3*t.width,o=t.width-r,a=t.y-e>=0?t.height+e:t.height+t.y;return{x:t.x+r/2,y:n,width:o,height:a}},Gr=(t,e)=>{const n=document.createElement("canvas");n.width=t.videoWidth,n.height=t.videoHeight;const r=n.getContext("2d");r.drawImage(t,0,0);const o=Vr(e);return r.getImageData(o.x,o.y,o.width,o.height)},Hr=(t,e)=>{let{count:n,mean:r,m2:o}=t;n++;const a=e-r;r+=a/n;return o+=a*(e-r),{count:n,mean:r,m2:o}},qr=t=>{const{data:e}=t;let n={count:0,mean:0,m2:0};for(let r=0;r<e.length;r+=4)n=Hr(n,e[r]),n=Hr(n,e[r+1]),n=Hr(n,e[r+2]);return{mean:n.mean,variance:n.m2/n.count}},Kr=(t,e)=>{const{x:n,y:r,width:o,height:a}=t;return{x:e.width-o-n,y:r,width:o,height:a}},Xr=(t,e)=>{const{width:n,height:o}=t;(function t(e,n){var r=new At(n.width,n.height),o=r.width,a=r.height;if(o<=0||a<=0)throw new Error("resizeResults - invalid dimensions: "+JSON.stringify({width:o,height:a}));if(Array.isArray(e))return e.map((function(e){return t(e,{width:o,height:a})}));if(sn(e)){var i=e.detection.forSize(o,a),s=e.unshiftedLandmarks.forSize(i.box.width,i.box.height);return un(re(e,i),s)}return ne(e)?re(e,e.detection.forSize(o,a)):e instanceof Yt||e instanceof Gt?e.forSize(o,a):e})(e,{width:n,height:o}).forEach(e=>{const a=Vr(e.box),i=Kr(e.box,{width:n,height:o}),s=Kr(a,{width:n,height:o}),u=new r.DrawBox(i),c=new r.DrawBox(s,{boxColor:"yellow"});u.draw(t),c.draw(t)})};var $r=n(22),Yr=n.n($r);const Jr=Object(b.createRef)(),Qr=t=>{let{facesProperties:e,videoElement:n,debugMessages:r}=t;const{clientWidth:o,clientHeight:a}=n;return Object(b.useEffect)(()=>{const t=Jr&&Jr.current;t&&(t.width=o,t.height=a,Xr(t,e),((t,e)=>{const n=t.getContext("2d");n.font="15px Arial",n.fillStyle="purple",e.forEach((t,e)=>{const r=20*(e+1)+30;n.fillText(t,10,r)})})(t,r))}),x.a.createElement("canvas",{className:Yr.a.canvas,ref:Jr})};Qr.defaultProps={videoElement:{}},Qr.propType={facesProperties:z.a.any.isRequired,debugMessages:z.a.array.isRequired,videoElement:z.a.instanceOf(Element).isRequired};var Zr,to,eo=Qr,no=n(6),ro=n.n(no);function oo(){return(oo=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var ao=function(t){return b.createElement("svg",oo({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28"},t),Zr||(Zr=b.createElement("defs",null,b.createElement("path",{id:"ico-camera_svg__a",d:"M3.5 8a.5.5 0 00-.5.5V21c0 .552.449 1 1 1h20a1 1 0 001-1V8.5a.5.5 0 00-.5-.5h-8.524l-.126-.855C15.713 6.207 14.918 5.5 14 5.5s-1.713.707-1.85 1.645L12.024 8H3.5zM24 24H4c-1.655 0-3-1.346-3-3V8.5C1 7.122 2.122 6 3.5 6h6.896C10.97 4.529 12.393 3.5 14 3.5s3.03 1.029 3.604 2.5H24.5C25.878 6 27 7.122 27 8.5V21c0 1.654-1.346 3-3 3zM6.5 10h-2a.5.5 0 000 1h2a.5.5 0 000-1zm7.5 1.5c-1.93 0-3.5 1.57-3.5 3.5s1.57 3.5 3.5 3.5 3.5-1.57 3.5-3.5-1.57-3.5-3.5-3.5zm0 9A5.506 5.506 0 018.5 15c0-3.033 2.467-5.5 5.5-5.5 3.032 0 5.5 2.467 5.5 5.5 0 3.032-2.468 5.5-5.5 5.5z"}))),to||(to=b.createElement("use",{fill:"#F0F",xlinkHref:"#ico-camera_svg__a",fillRule:"evenodd"})))};const io={ALWAYS:"always",AUTO:"auto",NEVER:"never"},so=[3,2,1],uo=t=>{let{action:e,countdownMode:n}=t;const r=Object(b.useRef)(),[o,a]=Object(b.useState)(so.length),i=()=>{clearInterval(r.current)},s=()=>{0===o?(i(),e()):a(t=>t-1)},u=()=>{r.current=setInterval(s,1e3)},c=()=>{switch(n){case io.AUTO:window.innerWidth>=628?u():e();break;case io.ALWAYS:u();break;case io.NEVER:default:e()}};Object(b.useEffect)(()=>(c(),i),[n,o]);const l=t=>o===t?ro.a.activeCounter:ro.a.inactiveCounter;return n===io.NEVER?null:x.a.createElement("div",{className:ro.a.container},so.map(t=>x.a.createElement("span",{key:t,className:l(t)},t)),x.a.createElement("span",{className:l(0)},x.a.createElement(ao,{className:0===o?ro.a.activeIcon:ro.a.inactiveIcon})))};uo.defaultProps={countdownMode:"never"},uo.propTypes={action:z.a.func.isRequired,countdownMode:z.a.oneOf(Object.values(io))};var co=uo,lo=n(23),fo=n.n(lo),ho=n(24),po=n.n(ho);function vo(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}const mo={PNG:"png",JPEG:"jpeg"};class go extends b.Component{constructor(t){super(t),vo(this,"webcamRef",x.a.createRef()),vo(this,"handleVideoPlaying",()=>{const{onVideoPlaying:t}=this.props;t();const{videoWidth:e,videoHeight:n}=this.webcamRef.current.video;this.setState({videoWidth:e,videoHeight:n})}),vo(this,"handleUserMedia",()=>{this.webcamRef.current.video.addEventListener("playing",this.handleVideoPlaying)}),vo(this,"handleUserMediaError",t=>{const{onError:e}=this.props,{name:n="",message:r=""}=t;[n,r].some(t=>t.toLowerCase().includes("constrain"))?e(o.OVERCONSTRAINED):e("NotAllowedError"!==n?o.GENERIC_CAMERA_ERROR:o.NO_CAMERA_PERMISSION)}),vo(this,"takePhoto",()=>this.webcamRef.current.getScreenshot()),this.state={videoHeight:null,videoWidth:null}}componentWillUnmount(){this.webcamRef.current.video.srcObject=null,this.webcamRef.current.video.removeEventListener("playing",this.handleVideoPlaying)}render(){const{videoWidth:t,videoHeight:e}=this.state,{widthMinConstraint:n,widthIdealConstraint:r,format:o,quality:a}=this.props;return x.a.createElement(fo.a,{ref:this.webcamRef,width:"100%",className:po.a.video,videoConstraints:{facingMode:"user",width:{min:n,ideal:r}},audio:!1,onUserMediaError:this.handleUserMediaError,onUserMedia:this.handleUserMedia,screenshotFormat:"image/"+o,screenshotQuality:a,minScreenshotWidth:t,minScreenshotHeight:e})}}go.defaultProps={widthMinConstraint:1024,widthIdealConstraint:1280,onError:()=>{}},go.propTypes={onVideoPlaying:z.a.func.isRequired,widthMinConstraint:z.a.number,widthIdealConstraint:z.a.number,format:z.a.oneOf(Object.values(mo)),onError:z.a.func,quality:z.a.oneOf(Object.values(y))};var yo=go;navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia;const bo=async()=>navigator.mediaDevices?await new Promise(t=>{navigator.mediaDevices.enumerateDevices().then(e=>{const n=e.filter(t=>"videoinput"===t.kind);t(!!n.length)}).catch(e=>{t(!1)})})?void 0:o.NO_CAMERA:o.UNSUPPORTED_BROWSER,xo={DETECTIONS_COUNT:0},wo="INIT_MODEL_DURATION",Eo="INIT_DETECTION_DURATION",Co="AVERAGE_DETECTION_DURATION",_o="DETECTIONS_COUNT",ko="FACES_COUNT",Ro="FACE_SCORE",Io="BOX_SIZE",So="RELATIVE_BOX",Ao="CENTERING",Oo="IS_STABLE_INDEX",To="BRIGHTNESS_DETECTION_DURATION",Do="BRIGHTNESS_VALUE",No=[ko,Ro,Io,So,Ao,Oo,To,Do],Fo=t=>xo[t],Mo=t=>{let{key:e,value:n}=t;xo[e]=n},Po=async t=>{const e=performance.now();return{result:await t(),duration:performance.now()-e}},Bo=t=>{const e=(t=>{let{previousAverage:e=0,count:n=0,newValue:r}=t;return(e*n+r)/(n+1)})({previousAverage:Fo(Co),count:Fo(_o),newValue:t});Mo({key:Co,value:e}),xo[_o]++},Lo=new or({inputSize:320,scoreThreshold:.6}),Wo=async t=>{try{const{duration:e}=await Po(async()=>Cr.tinyFaceDetector.loadFromUri(t));return(t=>{Mo({key:wo,value:t})})(e),null}catch(e){return e}},Uo=async()=>{try{const{duration:t}=await Po(async()=>zr(document.createElement("canvas"),Lo));return(t=>{Mo({key:Eo,value:t})})(t),null}catch(t){return t}},jo={PORTRAIT:.65,LANDSCAPE:.6},zo=t=>Math.round(100*t)/100,Vo=(t,e)=>t?h:e?p:"";var Go=[t=>{let e="",n=!0;t.length||(e=s,n=!1);return{instructionCode:e,debugMessages:[{key:ko,value:t.length}],canContinueOtherChecks:n}},t=>{let e="";return t.length>1&&(e=u),{instructionCode:e,debugMessages:[]}},function(t){let{videoElement:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="",r=!0;const o=[];if(e){const a=performance.now(),i=Gr(e,t[0].box),s=qr(i),u=performance.now();o.push({key:To,value:u-a}),o.push({key:Do,value:s.mean});const c=s.mean<=50,l=s.mean>=200;n=Vo(c,l),r=""===n}return{instructionCode:n,debugMessages:o,canContinueOtherChecks:r}},t=>{const[{score:e}]=t;return{instructionCode:"",debugMessages:[{key:Ro,value:""+zo(e)}]}},t=>{let e="";const[{imageWidth:n,imageHeight:r,box:o}]=t,a=o.x+o.width/2,i=o.y+o.height/2+-.15*o.height,u=n/2,c=r/2,l=.1*Math.min(n,r);(Math.abs(u-a)>l||Math.abs(c-i)>l)&&(e=s);const f=zo(a/n),h=zo(i/r);return{instructionCode:e,debugMessages:[{key:Ao,value:`x = ${f}; y = ${h}`}]}},t=>{let e="";const[{box:n}]=t;(n.width<200||n.height<200)&&(e=a);return{instructionCode:e,debugMessages:[{key:Io,value:`${zo(n.height)} x ${zo(n.width)}`}]}},function(t){let{isPortraitCamera:e=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="";const[{relativeBox:r}]=t,o=e?"width":"height",s=e?"PORTRAIT":"LANDSCAPE",u=jo[s],c=u+.08,l=u-.08;r[o]>c&&(n=i),r[o]<l&&(n=a);const f=zo(r[o]),h=[{key:So,value:`[${o}]: ${f}`}];return{instructionCode:n,debugMessages:h}}];const Ho=(t,e)=>{const n=Math.max(...t),r=Math.min(...t);return Number((n-r).toFixed(2))>e},qo=t=>[Ho(t.map(t=>t.x),.02),Ho(t.map(t=>t.y),.02),Ho(t.map(t=>t.size),.02)].some(Boolean);let Ko=[];const Xo=(t,e,n)=>{const r=t[0],o=qo(Ko),a=Ko.length===e;(!n||o||a)&&(Ko=[]),r&&(Ko=[...Ko,r])},$o=(t,e,n)=>!!n||!(t||!e),Yo=(t,e)=>{let n="";return t||e||(n=c),n},Jo=t=>t?null:{key:Oo,value:Ko.length},Qo=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{captureMethod:n,numberOfChecks:r,isCurrentFaceValid:o}=e;Xo(t,r,o);const a=qo(Ko),i=Ko.length===r,s=n===v.MANUAL;return{isStable:$o(a,i,s),faceStableMessageCode:Yo(a,i),debugMessage:Jo(s)}},Zo=(t,e)=>{No.forEach(t=>{delete xo[t]});const{isSingleFaceValid:n,singleFaceMessageCode:r}=function(){const t=[];for(let n=0;n<Go.length;n++){const e=Go[n],{instructionCode:r,debugMessages:o,canContinueOtherChecks:a=!0}=e(...arguments);if(r&&t.push(r),o.forEach(t=>{Mo(t)}),!a)break}const e=!t.length;return{isSingleFaceValid:e,singleFaceMessageCode:t.length?t[0]:""}}(t,e),{isStable:o,faceStableMessageCode:a}=function(){const t=Qo(...arguments),{debugMessage:e}=t;return e&&Mo(e),t}(t,{...e,isCurrentFaceValid:n});return{isSingleFaceValid:n,isValid:n&&o,messageCode:r||a}},ta=t=>Object.entries(t).map(t=>{let[e,n]=t;return`${(t=>t.replace(/_/g," ").toLowerCase())(e)}: ${(t=>"number"==typeof t?Math.ceil(t):t)(n)}`});var ea=n(15),na=n.n(ea);const ra={[a]:x.a.createElement(W,{id:"move-closer-feedback-message"}),[i]:x.a.createElement(W,{id:"move-back-feedback-message"}),[s]:x.a.createElement(W,{id:"move-center-feedback-message"}),[u]:x.a.createElement(W,{id:"one-face-only-feedback-message"}),[c]:x.a.createElement(W,{id:"hold-still-feedback-message"}),[l]:x.a.createElement(W,{id:"camera-loading-feedback-message"}),[f]:x.a.createElement(W,{id:"face-scan-loading-feedback-message"}),[p]:x.a.createElement(W,{id:"image-too-bright-feedback-message"}),[h]:x.a.createElement(W,{id:"image-too-dark-feedback-message"})},oa=t=>{let{faceCaptureAssetsRootUrl:e,onSuccess:n,onError:r,showOverlay:a,widthIdealConstraint:i,widthMinConstraint:u,format:c,CustomButton:l,countdownMode:h,captureMethod:p,isDebug:d,imageType:g,qualityType:w}=t;const[E,C]=Object(b.useState)([]),[_,k]=Object(b.useState)([]),[R,I]=Object(b.useState)(!1),[S,A]=Object(b.useState)(!1),[O,T]=Object(b.useState)(!1),[D,N]=Object(b.useState)(ra.CAMERA_LOADING),[F,M]=Object(b.useState)(!1),[P,B]=Object(b.useState)(!1),L=Object(b.useRef)(null),W=Object(b.useRef)(),U=Object(b.useRef)(),j=Object(b.useRef)(S);j.current=S;const z=!P,V=P?v.MANUAL:p,G=V===v.MANUAL&&!R,H=L.current&&L.current.webcamRef.current.video,q=d&&H,K=H&&H.videoHeight>H.videoWidth,X=y[w],$=t=>{N(ra[t])},Y=async()=>{const t=await(async t=>{const{result:e,duration:n}=await Po(async()=>zr(t,Lo));return Bo(n),e})(H),{isSingleFaceValid:e,isValid:n,messageCode:r}=Zo(t,{isPortraitCamera:K,captureMethod:V,numberOfChecks:4,videoElement:H}),o=ta(xo);return k(o),C(t),M(e),{isValid:n,messageCode:r,bbox:Array.isArray(t)&&t.length>0?t[0].box:{}}},J=t=>{const e=L.current.takePhoto();g===m.ORIGINAL?K?($(""),n({image:e})):(async(t,e)=>{const n=document.createElement("canvas"),r=n.getContext("2d"),{relativeEdgeCropping:o,format:a,qualityValue:i}=e;return new Promise(e=>{const s=new Image;s.onload=function(){const t=Math.ceil(o*s.width);n.width=s.width-2*t,n.height=s.height,r.drawImage(s,t,0,n.width,n.height,0,0,n.width,n.height),e({croppedImg:n.toDataURL("image/"+a,i)})},s.src=t})})(e,{relativeEdgeCropping:.12,format:c,qualityValue:X}).then(t=>{let{croppedImg:e}=t;$(""),n({image:e})}).catch(r):(async(t,e)=>{const n=document.createElement("canvas"),r=n.getContext("2d"),{bbox:o,relativeMarginCropping:a,format:i,qualityValue:s,isPortraitCamera:u}=e;return new Promise(e=>{const c=new Image;c.onload=function(){const{topLeftXCoord:t,topLeftYCoord:l,width:f,height:h}=((t,e,n)=>{const r=2*t,o=e.x-t*e.width<0?0:e.x-t*e.width,a=e.y-r*e.height<0?0:e.y-r*e.height;let i=0!==o?e.width+e.width*(2*t):e.width+e.x+e.width*t,s=0!==a?e.height+e.height*(t+r):e.height+e.y+e.height*t;return s=s+a>n.imageHeight?n.imageHeight-a:s,i=i+o>n.imageWidth?n.imageWidth-o:i,{topLeftXCoord:o,topLeftYCoord:a,width:i,height:s}})(a,o||((t,e)=>{const n=e?.45:.7,r=e?.25:.1;return{x:.5*t.width-n*t.height/2,y:r*t.height,height:n*t.height,width:n*t.height}})(c,u),{imageHeight:c.height,imageWidth:c.width});n.width=f,n.height=h,r.drawImage(c,t,l,f,h,0,0,f,h),e({croppedImg:n.toDataURL("image/"+i,s)})},c.src=t})})(e,{bbox:t,relativeMarginCropping:.3,format:c,qualityValue:X,isPortraitCamera:K}).then(t=>{let{croppedImg:e}=t;$(""),n({image:e})}).catch(r)},Q=async()=>{const t=z&&await Wo(e);setTimeout(()=>{j.current||B(!0)},5e3);const n=z&&!t&&await Uo();t||n?r(o.FACE_DETECTION_INIT_ERROR):(A(!0),$(s))};return Object(b.useEffect)(()=>{(async()=>{const t=await bo();t&&r(t)})(),Q()},[]),Object(b.useEffect)(()=>{if(O&&S&&V===v.AUTO){const t=async()=>{const{isValid:e,messageCode:n,bbox:r}=await Y();e?J(r):($(n),W.current=setTimeout(t,200))};U.current=setTimeout(t,1e3)}return()=>(clearTimeout(U.current),void clearTimeout(W.current))},[O,S,V]),x.a.createElement("div",{className:na.a.moduleContainer,"data-qa":"face-capture"},x.a.createElement("div",{className:na.a.cameraContainer},x.a.createElement(yo,{ref:L,widthIdealConstraint:i,widthMinConstraint:u,format:c,quality:X,onVideoPlaying:()=>{T(!0),$(S?s:f)},onError:r}),a&&x.a.createElement(st,{isPortraitCamera:K,isSuccess:F}),D&&x.a.createElement(pt,{isPortraitCamera:K,message:D}),q&&x.a.createElement(eo,{facesProperties:E,debugMessages:_,videoElement:H})),R&&x.a.createElement(co,{action:async()=>{let t;if(I(!1),z){const{isValid:e,messageCode:n,bbox:r}=await Y();if(t=r,!e)return void $(n)}J(t)},countdownMode:h}),G&&x.a.createElement(kt,{CustomButton:l,onClick:()=>I(!0),disabled:!O||!S}))};oa.defaultProps={faceCaptureAssetsRootUrl:"assets/face-capture/",isDebug:!1,captureMethod:v.MANUAL,onError:()=>{},showOverlay:!0,format:mo.JPEG,countdownMode:io.NEVER,imageType:m.ORIGINAL,qualityType:g.HIGH},oa.propTypes={faceCaptureAssetsRootUrl:z.a.string,captureMethod:z.a.oneOf(Object.values(v)),onSuccess:z.a.func.isRequired,onError:z.a.func,showOverlay:z.a.bool,widthIdealConstraint:z.a.number,widthMinConstraint:z.a.number,format:z.a.oneOf(Object.values(mo)),CustomButton:z.a.func,countdownMode:z.a.oneOf(Object.values(io)),isDebug:z.a.bool,imageType:z.a.oneOf(Object.values(m)),qualityType:z.a.oneOf(Object.values(g))};var aa=oa,ia=n(16),sa=n.n(ia),ua=n(17),ca=n.n(ua),la=n(54),fa=n.n(la),ha=n(55),pa=n.n(ha),da=n(18),va=n.n(da),ma=n(19),ga=n.n(ma),ya=function(t){return"string"==typeof t},ba=function(t){return"function"==typeof t},xa=new Map,wa=new Map;function Ea(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(r){if(ya(r)&&(r=new Date(r)),n){var o=_a(t,e),a=wa.get(o);if(a)return a.format(r);var i=new Intl.DateTimeFormat(t,e);return wa.set(o,i),i.format(r)}return new Intl.DateTimeFormat(t,e).format(r)}}function Ca(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(r){if(n){var o=_a(t,e),a=xa.get(o);if(a)return a.format(r);var i=new Intl.NumberFormat(t,e);return xa.set(o,i),i.format(r)}return new Intl.NumberFormat(t,e).format(r)}}function _a(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Array.isArray(t)?t.sort().join("-"):t;return"".concat(n,"-").concat(JSON.stringify(e))}Object.freeze({__proto__:null,date:Ea,number:Ca});var ka=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;function Ra(t){var e=t.locale,n=t.locales,r=t.values,o=t.formats,a=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{plurals:void 0},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};e=e||t;var o=n.plurals,a=function(t){return ya(t)?r[t]||{style:t}:t},i=function(t,n){return function(r){var o=ba(n)?n(r):n,a=Array.isArray(o)?o:[o],i=Ca(e)(t);return a.map((function(t){return ya(t)?t.replace("#",i):t}))}};return{plural:function(t,e){var n=e.offset,r=void 0===n?0:n,a=ga()(e,["offset"]),s=a[t]||a[null==o?void 0:o(t-r)]||a.other;return i(t-r,s)},selectordinal:function(t,e){var n=e.offset,r=void 0===n?0:n,a=ga()(e,["offset"]),s=a[t]||a[null==o?void 0:o(t-r,!0)]||a.other;return i(t-r,s)},select:function(t,e){return e[t]||e.other},number:function(t,n){return Ca(e,a(n))(t)},date:function(t,n){return Ea(e,a(n))(t)},undefined:function(t){return t}}}(e,n,t.localeData,o);return function t(e,n,o){var i=r[e],s=a[n](i,o),u=ba(s)?s(t):s;return Array.isArray(u)?u.join(""):u}}function Ia(t,e,n,r){return function(o){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=Ra({locale:e,locales:n,localeData:r,formats:a,values:o}),s=function t(e){return Array.isArray(e)?e.reduce((function(e,n){if(ya(n))return e+n;var r=_()(n,3),o=r[0],a=r[1],s=r[2],u={};null==s||ya(s)?u=s:Object.keys(s).forEach((function(e){u[e]=t(s[e])}));var c=i(o,a,u);return null==c?e:e+c}),""):e},u=s(t);return ya(u)&&ka.test(u)?JSON.parse('"'.concat(u.trim(),'"')):ya(u)?u.trim():u}}var Sa=function(t){fa()(o,t);var e,n,r=(e=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var t,r=va()(e);if(n){var o=va()(this).constructor;t=Reflect.construct(r,arguments,o)}else t=r.apply(this,arguments);return pa()(this,t)});function o(t){var e;return sa()(this,o),(e=r.call(this))._messages={},e._localeData={},null!=t.missing&&(e._missing=t.missing),null!=t.messages&&e.load(t.messages),null!=t.localeData&&e.loadLocaleData(t.localeData),null==t.locale&&null==t.locales||e.activate(t.locale,t.locales),e}return ca()(o,[{key:"_loadLocaleData",value:function(t,e){null==this._localeData[t]?this._localeData[t]=e:Object.assign(this._localeData[t],e)}},{key:"loadLocaleData",value:function(t,e){var n=this;null!=e?this._loadLocaleData(t,e):Object.keys(t).forEach((function(e){return n._loadLocaleData(e,t[e])})),this.emit("change")}},{key:"_load",value:function(t,e){null==this._messages[t]?this._messages[t]=e:Object.assign(this._messages[t],e)}},{key:"load",value:function(t,e){var n=this;null!=e?this._load(t,e):Object.keys(t).forEach((function(e){return n._load(e,t[e])})),this.emit("change")}},{key:"activate",value:function(t,e){this._locale=t,this._locales=e,this.emit("change")}},{key:"_",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.message,o=n.formats,a=n.context;ya(t)||(e=t.values||e,r=t.message,a=t.context,t=t.id);var i,s=!a&&!this.messages[t],u=a&&!this.messages[a][t],c=u||s,l=this._missing;return l&&c?ba(l)?l(this.locale,t,a):l:(c&&this.emit("missing",{id:t,context:a,locale:this._locale}),i=a&&!u?this.messages[a][t]||r||t:this.messages[t]||r||t,ya(i)&&ka.test(i)?JSON.parse('"'.concat(i,'"')):ya(i)?i:Ia(i,this.locale,this.locales,this.localeData)(e,o))}},{key:"date",value:function(t,e){return Ea(this.locales||this.locale,e)(t)}},{key:"number",value:function(t,e){return Ca(this.locales||this.locale,e)(t)}},{key:"locale",get:function(){return this._locale}},{key:"locales",get:function(){return this._locales}},{key:"messages",get:function(){var t;return null!==(t=this._messages[this._locale])&&void 0!==t?t:{}}},{key:"localeData",get:function(){var t;return null!==(t=this._localeData[this._locale])&&void 0!==t?t:{}}}]),o}(function(){function t(){sa()(this,t),this._events={}}return ca()(t,[{key:"on",value:function(t,e){var n=this;return this._hasEvent(t)||(this._events[t]=[]),this._events[t].push(e),function(){return n.removeListener(t,e)}}},{key:"removeListener",value:function(t,e){if(this._hasEvent(t)){var n=this._events[t].indexOf(e);~n&&this._events[t].splice(n,1)}}},{key:"emit",value:function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];this._hasEvent(t)&&this._events[t].map((function(t){return t.apply(e,r)}))}},{key:"_hasEvent",value:function(t){return Array.isArray(this._events[t])}}]),t}());function Aa(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Sa(t)}const Oa=Aa();var Ta=n(25),Da=n(26),Na=n(27),Fa=n(28),Ma=n(29),Pa=n(30),Ba=n(31),La=n(32),Wa=n(33),Ua=n(34),ja=n(35),za=n(36),Va=n(37),Ga=n(38),Ha=n(39),qa=n(40),Ka=n(41),Xa=n(42),$a=n(43),Ya=n(44),Ja=n(45),Qa=n(46),Za=n(47),ti=n(48),ei=n(49),ni=n(50),ri=n(51),oi=n(52),ai=n(53),ii={[d.AR]:oi.messages,[d.CS]:Da.messages,[d.DA]:Na.messages,[d.DE]:Fa.messages,[d.EN]:Ta.messages,[d.ES]:Ma.messages,[d.ES_419]:Pa.messages,[d.ET]:Qa.messages,[d.FI]:Ba.messages,[d.FR]:La.messages,[d.HI]:Wa.messages,[d.ID]:ni.messages,[d.IT]:Ua.messages,[d.JA]:ja.messages,[d.KO]:ri.messages,[d.LT]:ti.messages,[d.LV]:ai.messages,[d.MS]:ei.messages,[d.NB]:Va.messages,[d.NL]:za.messages,[d.PL]:Ga.messages,[d.PT]:Ha.messages,[d.RO]:qa.messages,[d.RU]:Ka.messages,[d.SV]:Xa.messages,[d.TH]:$a.messages,[d.TR]:Ya.messages,[d.UK]:Za.messages,[d.VI]:Ja.messages};const si=d.EN;function ui(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const[e,n=""]=t.split("-");return{language:e,region:n}}function ci(t){const{language:e,region:n}=ui(t);return[e.toLowerCase(),n.toUpperCase()].filter(Boolean).join("-")}const li=t=>{let{language:e,children:n}=t;const r=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const e=ci(t);if(e&&Object.keys(ii).includes(e))return e;const{language:n}=ui(e);if(n&&Object.keys(ii).includes(n))return n;const r=Object.keys(ii).find(t=>ui(t).language===n);return r||si}(e);return Oa.load(r,(t=>ii[t])(r)),Oa.activate(r),x.a.createElement(A,{i18n:Oa},n)};li.defaultProps={language:si},li.propTypes={language:z.a.oneOf(Object.values(d)),children:z.a.node.isRequired};var fi=li;var hi=t=>{const{language:e}=t;return x.a.createElement(E,{onError:t.onError},x.a.createElement(fi,{language:e},x.a.createElement(aa,t)))}}]);
|
|
2
|
+
(()=>{var e={4420:(e,t,n)=>{e.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t){e.exports=n(9497)},function(e,t){e.exports=n(5697)},function(e,t){e.exports=n(4184)},function(e,t,n){"use strict";n.r(t),n.d(t,"lazyIcon",(function(){return p.a}));var r=n(0),o=n.n(r),a=n(1),i=n.n(a),s=n(2),u=n.n(s);function c(){return c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(this,arguments)}function l(e){var t=c({},e);return o.a.createElement("span",c({"data-qa":"yoti-icon-placeholder"},t))}function f(e){var t=e.component,n=e.size,a=e.color,i=e.className,s=e.onClick,f=t,h=function(e){return{className:u()(e,i),style:{fontSize:n,color:a},onClick:s}};return o.a.createElement(r.Suspense,{fallback:o.a.createElement(l,h("yoti-icon-placeholder"))},o.a.createElement(f,c({"data-qa":"icon"},h("yoti-icon"))))}n(8),f.defaultProps={size:null,color:null,className:"",onClick:function(){}},f.propTypes={component:i.a.oneOfType([i.a.func,i.a.object]).isRequired,size:i.a.string,color:i.a.string,className:i.a.string,onClick:i.a.func};var h=f,p=n(7);t.default=h},,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(0),o=(n(8),function(e,t){return Object(r.lazy)((function(){return e.then((function(e){return{default:e[t]}}))}))})},function(e,t,n){}])},2797:(e,t,n)=>{e.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=12)}([function(e,t){e.exports=n(9497)},,,,,,,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"activitySelected",(function(){return u})),n.d(t,"activity",(function(){return p})),n.d(t,"add",(function(){return y})),n.d(t,"ageEstimation",(function(){return _})),n.d(t,"applicationsSelected",(function(){return S})),n.d(t,"applications",(function(){return D})),n.d(t,"archive",(function(){return j})),n.d(t,"arrowDown",(function(){return H})),n.d(t,"arrowLeft",(function(){return K})),n.d(t,"arrowRight",(function(){return Q})),n.d(t,"arrowUp",(function(){return oe})),n.d(t,"attachment",(function(){return ce})),n.d(t,"calendar",(function(){return he.a})),n.d(t,"camera",(function(){return ve})),n.d(t,"checkbox",(function(){return we})),n.d(t,"chevronDown",(function(){return _e.a})),n.d(t,"chevronLeft",(function(){return Oe.a})),n.d(t,"chevronRight",(function(){return ke.a})),n.d(t,"chevronUp",(function(){return Se})),n.d(t,"clear",(function(){return Pe.a})),n.d(t,"clock",(function(){return Me})),n.d(t,"cloudDownload",(function(){return Le})),n.d(t,"copy",(function(){return Ue})),n.d(t,"darker",(function(){return Xe.a})),n.d(t,"bin",(function(){return Ze})),n.d(t,"discoverSelected",(function(){return tt})),n.d(t,"discover",(function(){return it})),n.d(t,"dislike",(function(){return ft})),n.d(t,"dismiss",(function(){return mt})),n.d(t,"docAardhaar",(function(){return xt})),n.d(t,"docDrivingLicense",(function(){return Ct})),n.d(t,"docGeneric",(function(){return Pt})),n.d(t,"docNationalId",(function(){return Ft})),n.d(t,"docPassCard",(function(){return Wt})),n.d(t,"docPassport",(function(){return qt})),n.d(t,"documentImage",(function(){return Yt})),n.d(t,"document",(function(){return nn})),n.d(t,"prohibited",(function(){return un})),n.d(t,"download",(function(){return pn})),n.d(t,"edit",(function(){return yn})),n.d(t,"email",(function(){return _n})),n.d(t,"externalLink",(function(){return Cn.a})),n.d(t,"face",(function(){return Rn})),n.d(t,"faceVerified",(function(){return Dn})),n.d(t,"favourite",(function(){return Bn})),n.d(t,"favourited",(function(){return Wn})),n.d(t,"feedback",(function(){return qn})),n.d(t,"filter",(function(){return Yn})),n.d(t,"flag",(function(){return nr})),n.d(t,"gender",(function(){return sr})),n.d(t,"goBack",(function(){return hr})),n.d(t,"help",(function(){return gr})),n.d(t,"hide",(function(){return wr.a})),n.d(t,"house",(function(){return _r})),n.d(t,"information",(function(){return Cr.a})),n.d(t,"lighter",(function(){return Ir.a})),n.d(t,"like",(function(){return Ar})),n.d(t,"listHorizontal",(function(){return Nr})),n.d(t,"listVertical",(function(){return zr})),n.d(t,"loadingSpinner",(function(){return Hr.a})),n.d(t,"lockLocked",(function(){return qr})),n.d(t,"lockUnlocked",(function(){return Yr})),n.d(t,"logOut",(function(){return no})),n.d(t,"mapPin",(function(){return so})),n.d(t,"megaphone",(function(){return ho})),n.d(t,"menu",(function(){return yo})),n.d(t,"microphone",(function(){return _o})),n.d(t,"moreSelected",(function(){return So})),n.d(t,"more",(function(){return Do})),n.d(t,"myData",(function(){return jo})),n.d(t,"name",(function(){return Ho})),n.d(t,"nfcChip",(function(){return Ko})),n.d(t,"officeBuilding",(function(){return Qo})),n.d(t,"pagesSelected",(function(){return oa})),n.d(t,"pages",(function(){return ca})),n.d(t,"paymentCard",(function(){return da})),n.d(t,"phone",(function(){return ba})),n.d(t,"pin",(function(){return Oa})),n.d(t,"preview",(function(){return Sa})),n.d(t,"profileSelected",(function(){return Da})),n.d(t,"profile",(function(){return ja})),n.d(t,"receive",(function(){return Ha})),n.d(t,"retry",(function(){return Ka})),n.d(t,"rotateAnticlockwise",(function(){return Ya.a})),n.d(t,"rotateClockwise",(function(){return Ja.a})),n.d(t,"ruid",(function(){return ti})),n.d(t,"scanQr",(function(){return ii})),n.d(t,"search",(function(){return fi})),n.d(t,"send",(function(){return mi})),n.d(t,"settings",(function(){return xi})),n.d(t,"show",(function(){return Oi.a})),n.d(t,"signature",(function(){return Ii})),n.d(t,"slightlySmilingFace",(function(){return Ti})),n.d(t,"sort",(function(){return Bi})),n.d(t,"textInput",(function(){return Vi})),n.d(t,"tick",(function(){return Gi.a})),n.d(t,"upload",(function(){return Ki})),n.d(t,"verified",(function(){return Qi})),n.d(t,"video",(function(){return os})),n.d(t,"yotiIcon",(function(){return cs})),n.d(t,"zoomIn",(function(){return ls.a})),n.d(t,"zoomOut",(function(){return fs.a}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-activity-selected_svg__a",d:"M8.206 9.984A6.186 6.186 0 0114.141 5.5a.5.5 0 010 1 5.183 5.183 0 00-4.973 3.755.5.5 0 11-.962-.271zM14.141 25c-1.103 0-2-.897-2-2h4c0 1.103-.897 2-2 2zM3.396 21.896c.845-8.109 1.31-12.363 1.383-12.645A9.661 9.661 0 0114.141 2a9.662 9.662 0 019.362 7.251c.072.282.538 4.537 1.382 12.646L25 23h-6.86c0 2.206-1.794 4-4 4-2.205 0-4-1.794-4-4H3.282l.115-1.104z"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-activity-selected_svg__a",fillRule:"evenodd"})))}var c,l,f=["title","titleId"];function h(){return h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},h.apply(this,arguments)}function p(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,f);return a.createElement("svg",h({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,c||(c=a.createElement("defs",null,a.createElement("path",{id:"ico-activity_svg__a",d:"M8.066 9.984A6.183 6.183 0 0114 5.5a.5.5 0 110 1 5.184 5.184 0 00-4.973 3.755.498.498 0 11-.961-.271zM22.64 21H5.36c.48-4.596 1.128-10.685 1.223-11.281A7.66 7.66 0 0114 4c3.49 0 6.535 2.35 7.417 5.719.095.596.742 6.685 1.223 11.281zM14 25c-1.103 0-2-.897-2-2h4c0 1.103-.897 2-2 2zM3.255 21.896C4.1 13.787 4.566 9.534 4.638 9.252A9.662 9.662 0 0114 2a9.661 9.661 0 019.362 7.251c.073.282.538 4.537 1.383 12.646L24.858 23H18c0 2.206-1.794 4-4 4s-4-1.794-4-4H3.14l.115-1.104z"}))),l||(l=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-activity_svg__a",fillRule:"evenodd"})))}var d,v,m=["title","titleId"];function g(){return g=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},g.apply(this,arguments)}function y(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,m);return a.createElement("svg",g({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,d||(d=a.createElement("defs",null,a.createElement("path",{id:"ico-add_svg__a",d:"M15 5v8h8v2h-8v8h-2v-8H5v-2h8V5h2z"}))),v||(v=a.createElement("use",{fill:"currentColor",fillRule:"nonzero",xlinkHref:"#ico-add_svg__a"})))}var b,w,x=["title","titleId"];function E(){return E=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},E.apply(this,arguments)}function _(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,x);return a.createElement("svg",E({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,b||(b=a.createElement("defs",null,a.createElement("path",{id:"ico-age-estimation_svg__a",d:"M10.674 7.734a9.43 9.43 0 017.278 0 9.303 9.303 0 012.972 1.999 9.311 9.311 0 012.003 10.233 9.3 9.3 0 01-2.003 2.966c-.708.706-1.42 1.25-2.173 1.658l3.532.801-.442 1.95-3.685-.835a1.95 1.95 0 01-1.504-1.898c0-.728.402-1.389 1.049-1.725.626-.325 1.201-.759 1.81-1.367a7.279 7.279 0 001.574-2.33 7.25 7.25 0 00.578-2.854 7.306 7.306 0 00-2.152-5.184 7.34 7.34 0 00-2.337-1.572 7.429 7.429 0 00-5.722 0 7.347 7.347 0 00-2.336 1.572 7.313 7.313 0 000 10.369c.609.607 1.184 1.041 1.81 1.366a1.947 1.947 0 01-.438 3.619l-3.702.84-.442-1.951 3.532-.801c-.754-.409-1.465-.952-2.172-1.658A9.282 9.282 0 015.7 19.966a9.253 9.253 0 01-.736-3.634 9.295 9.295 0 012.739-6.599 9.33 9.33 0 012.971-2zm1.593 11.845l.09.016c.92.248 2.994.248 3.913 0a.5.5 0 11.261.965c-.548.148-1.357.233-2.218.233-.86 0-1.669-.085-2.217-.233a.5.5 0 11.26-.965zm1.984-5.623a.5.5 0 01.558.434l.38 3.036a.503.503 0 01-.121.393.504.504 0 01-.375.169h-.76a.5.5 0 010-1h.193l-.309-2.474a.5.5 0 01.434-.558zm-2.974.116a.76.76 0 110 1.52.76.76 0 010-1.52zm6.072 0a.76.76 0 11-.759.759.76.76 0 01.76-.759zM14.313 1c4.007 0 7.774 1.56 10.606 4.394l.708.707-2.828 2.828-1.415-1.414 1.388-1.387a12.87 12.87 0 00-7.458-3.084V5h-2V3.044a12.876 12.876 0 00-7.459 3.084l1.387 1.387-1.414 1.414L3 6.1l.707-.706A14.899 14.899 0 0114.314 1z"}))),w||(w=a.createElement("use",{fill:"currentColor",fillRule:"nonzero",xlinkHref:"#ico-age-estimation_svg__a"})))}var O,k,C=["title","titleId"];function I(){return I=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},I.apply(this,arguments)}function S(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,C);return a.createElement("svg",I({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,O||(O=a.createElement("defs",null,a.createElement("path",{id:"ico-applications-selected_svg__a",d:"M19 15h-4v4h-1.595A5.51 5.51 0 009 14.595V13h4V9.003h2V13h4v2zM8 23.5a3.5 3.5 0 110-7 3.5 3.5 0 010 7zM17 11h6V5h-6v6zm8 2V3H15v4.003h-2V3H3v10h4v1.595C4.444 15.069 2.5 17.31 2.5 20c0 3.032 2.468 5.5 5.5 5.5 2.691 0 4.932-1.944 5.405-4.5H15v4h10V15h-4v-2h4z"}))),k||(k=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-applications-selected_svg__a",fillRule:"evenodd"})))}var R,A,P=["title","titleId"];function T(){return T=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},T.apply(this,arguments)}function D(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,P);return a.createElement("svg",T({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,R||(R=a.createElement("defs",null,a.createElement("path",{id:"ico-applications_svg__a",d:"M19 15h-4v4h-1.595A5.51 5.51 0 009 14.595V13h4V9.003h2V13h4v2zm-2 8h6v-6h-6v6zm-9 .5a3.5 3.5 0 110-7 3.5 3.5 0 010 7zM5 11h6V5H5v6zm12 0h6V5h-6v6zm8 2V3H15v4.003h-2V3H3v10h4v1.595C4.444 15.069 2.5 17.31 2.5 20c0 3.032 2.468 5.5 5.5 5.5 2.691 0 4.932-1.944 5.405-4.5H15v4h10V15h-4v-2h4z"}))),A||(A=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-applications_svg__a",fillRule:"evenodd"})))}var M,N,F=["title","titleId"];function B(){return B=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},B.apply(this,arguments)}function j(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,F);return a.createElement("svg",B({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,M||(M=a.createElement("defs",null,a.createElement("path",{id:"ico-archive_svg__a",d:"M4 6.997h20v-2H4v2zm18 2.005H6v13c0 .552.449 1 1 1h14a1 1 0 001-1v-13zm4 0h-2v13c0 1.655-1.346 3-3 3H7c-1.654 0-3-1.345-3-3v-13H2V2.997h24v6.005zm-15 2.505a.5.5 0 01.5-.5h5a.5.5 0 010 1h-5a.5.5 0 01-.5-.5z"}))),N||(N=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-archive_svg__a",fillRule:"evenodd"})))}var L,z,W=["title","titleId"];function V(){return V=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},V.apply(this,arguments)}function H(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,W);return a.createElement("svg",V({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,L||(L=a.createElement("defs",null,a.createElement("path",{id:"ico-arrow-down_svg__a",d:"M9.76 5.516l-6.9 8.624 6.9 8.625 1.561-1.25-5.1-6.375H25.14v-2H6.221l5.1-6.376z"}))),z||(z=a.createElement("use",{fill:"currentColor",transform:"matrix(0 -1 -1 0 28.14 28.14)",xlinkHref:"#ico-arrow-down_svg__a",fillRule:"evenodd"})))}var U,G,q=["title","titleId"];function X(){return X=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(this,arguments)}function K(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,q);return a.createElement("svg",X({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,U||(U=a.createElement("defs",null,a.createElement("path",{id:"ico-arrow-left_svg__a",d:"M9.62 5.375L2.72 14l6.9 8.625 1.561-1.25L6.082 15H25v-2H6.081l5.1-6.376z"}))),G||(G=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-arrow-left_svg__a",fillRule:"evenodd"})))}var $,Z,Y=["title","titleId"];function J(){return J=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J.apply(this,arguments)}function Q(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Y);return a.createElement("svg",J({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,$||($=a.createElement("defs",null,a.createElement("path",{id:"ico-arrow-right_svg__a",d:"M9.9 5.375L3 14l6.9 8.625 1.561-1.25L6.362 15H25.28v-2H6.361l5.1-6.376z"}))),Z||(Z=a.createElement("use",{fill:"currentColor",transform:"matrix(-1 0 0 1 28.28 0)",xlinkHref:"#ico-arrow-right_svg__a",fillRule:"evenodd"})))}var ee,te,ne=["title","titleId"];function re(){return re=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},re.apply(this,arguments)}function oe(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,ne);return a.createElement("svg",re({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,ee||(ee=a.createElement("defs",null,a.createElement("path",{id:"ico-arrow-up_svg__a",d:"M9.76 5.266l-6.9 8.624 6.9 8.625 1.561-1.25-5.1-6.375H25.14v-2H6.221l5.1-6.376z"}))),te||(te=a.createElement("use",{fill:"currentColor",transform:"rotate(90 14 13.89)",xlinkHref:"#ico-arrow-up_svg__a",fillRule:"evenodd"})))}var ae,ie,se=["title","titleId"];function ue(){return ue=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ue.apply(this,arguments)}function ce(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,se);return a.createElement("svg",ue({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,ae||(ae=a.createElement("defs",null,a.createElement("path",{id:"ico-attachment_svg__a",d:"M9.51 25.484c-1.74 0-3.404-.611-4.647-1.854-1.343-1.343-1.997-3.202-1.84-5.234.152-1.974 1.056-3.882 2.547-5.373l8.485-8.485c2.419-2.419 5.763-2.723 7.778-.707 2.016 2.015 1.712 5.36-.707 7.778l-7.424 7.425c-1.37 1.37-3.276 1.553-4.493.452l-.002.003-.097-.097-.004-.005.002-.002c-.548-.604-.812-1.404-.745-2.27a3.706 3.706 0 011.096-2.324l4.321-4.49 1.44 1.388-4.333 4.503c-.313.312-.501.7-.53 1.077-.013.175-.001.496.215.752.465.39 1.22.093 1.716-.402l7.424-7.424c1.612-1.613 1.917-3.74.707-4.95s-3.337-.905-4.95.707l-8.485 8.485c-1.153 1.154-1.852 2.614-1.967 4.113-.11 1.44.337 2.742 1.26 3.665 1.95 1.95 5.44 1.633 7.778-.707l9.214-9.874 1.463 1.364-9.238 9.9c-1.712 1.712-3.903 2.586-5.984 2.586"}))),ie||(ie=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-attachment_svg__a",fillRule:"evenodd"})))}var le,fe,he=n(43),pe=["title","titleId"];function de(){return de=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},de.apply(this,arguments)}function ve(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,pe);return a.createElement("svg",de({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,le||(le=a.createElement("defs",null,a.createElement("path",{id:"ico-camera_svg__a",d:"M7 10.5a.5.5 0 01-.5.5h-2a.5.5 0 010-1h2a.5.5 0 01.5.5zm18 10.534a.967.967 0 01-.966.966H3.966A.967.967 0 013 21.034V8.466C3 8.209 3.209 8 3.466 8h5.915c.668 0 1.295-.26 1.766-.73l.976-.977A.993.993 0 0112.83 6h2.345c.265 0 .516.104.705.291l.978.974c.47.468 1.095.727 1.758.729 1.629.003 5.917.006 5.918.006.257 0 .466.209.466.466v12.568zM24.535 6s-4.286-.003-5.915-.006a.498.498 0 01-.35-.146l-.98-.974A2.973 2.973 0 0015.176 4H12.83c-.803 0-1.556.313-2.123.88l-.974.975A.498.498 0 019.381 6H3.466A2.468 2.468 0 001 8.466v12.568A2.969 2.969 0 003.966 24h20.067A2.969 2.969 0 0027 21.034V8.466A2.469 2.469 0 0024.535 6zM14 18.5a3.755 3.755 0 01-3.75-3.75c0-2.068 1.682-3.75 3.75-3.75s3.75 1.682 3.75 3.75A3.755 3.755 0 0114 18.5zM14 9c-3.17 0-5.75 2.58-5.75 5.75S10.83 20.5 14 20.5s5.75-2.58 5.75-5.75S17.17 9 14 9z"}))),fe||(fe=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-camera_svg__a",fillRule:"evenodd"})))}var me,ge,ye=["title","titleId"];function be(){return be=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},be.apply(this,arguments)}function we(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,ye);return a.createElement("svg",be({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,me||(me=a.createElement("defs",null,a.createElement("path",{id:"ico-checkbox_svg__a",d:"M19.207 11.707l-1.415-1.415-5.292 5.293-2.293-2.293-1.415 1.415 3.708 3.707 6.707-6.707zM8 7c-.551 0-1 .449-1 1v12c0 .551.449 1 1 1h12c.551 0 1-.449 1-1V8c0-.551-.449-1-1-1H8zm12 16H8c-1.654 0-3-1.346-3-3V8c0-1.654 1.346-3 3-3h12c1.654 0 3 1.346 3 3v12c0 1.654-1.346 3-3 3z"}))),ge||(ge=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-checkbox_svg__a",fillRule:"evenodd"})))}var xe,Ee,_e=n(29),Oe=n(67),ke=n(68),Ce=["title","titleId"];function Ie(){return Ie=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ie.apply(this,arguments)}function Se(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Ce);return a.createElement("svg",Ie({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,xe||(xe=a.createElement("defs",null,a.createElement("path",{id:"ico-chevron-up_svg__a",d:"M21.375 17.481L14 11.581l-7.375 5.9-1.25-1.562L14 9.019l8.625 6.9z"}))),Ee||(Ee=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-chevron-up_svg__a",fillRule:"evenodd"})))}var Re,Ae,Pe=n(15),Te=["title","titleId"];function De(){return De=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},De.apply(this,arguments)}function Me(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Te);return a.createElement("svg",De({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Re||(Re=a.createElement("defs",null,a.createElement("path",{id:"ico-clock_svg__a",d:"M13.917 24.25a10.048 10.048 0 01-9.944-8.402 10.154 10.154 0 01-.14-1.682c0-5.56 4.524-10.082 10.084-10.082S24 8.607 24 14.166c0 5.56-4.523 10.084-10.083 10.084m0-22c6.57 0 11.916 5.346 11.916 11.916 0 6.572-5.345 11.918-11.916 11.918a11.874 11.874 0 01-11.752-9.933A11.95 11.95 0 012 14.166C2 7.596 7.346 2.25 13.917 2.25zm0 3.917a.5.5 0 00-.5.5v7.5c0 .12.042.234.12.325l3 3.5a.502.502 0 00.705.055.5.5 0 00.054-.706l-2.88-3.36V6.668a.5.5 0 00-.5-.5z"}))),Ae||(Ae=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-clock_svg__a",fillRule:"evenodd"})))}var Ne,Fe,Be=["title","titleId"];function je(){return je=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},je.apply(this,arguments)}function Le(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Be);return a.createElement("svg",je({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Ne||(Ne=a.createElement("defs",null,a.createElement("path",{id:"ico-cloud-download_svg__a",d:"M15 22.92V13h-2v9.92l-2.75-2.2L9 22.28l5 4 5-4-1.25-1.56-2.75 2.2zm11-9.666A5.756 5.756 0 0120.248 19H20v-2h.248A3.753 3.753 0 0024 13.254a3.73 3.73 0 00-2.636-3.578l-.783-.243.085-.815a3.849 3.849 0 00-6.946-2.653l-.445.617-.713-.266a3.416 3.416 0 00-4.59 2.955l-.058.842-.84.084A3.397 3.397 0 004 13.59C4 15.47 5.532 17 7.415 17H8v2h-.585A5.42 5.42 0 012 13.59a5.39 5.39 0 014.09-5.248 5.43 5.43 0 016.47-4.108 5.87 5.87 0 014.28-1.86 5.852 5.852 0 015.844 5.672A5.715 5.715 0 0126 13.254z"}))),Fe||(Fe=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-cloud-download_svg__a",fillRule:"evenodd"})))}var ze,We,Ve=["title","titleId"];function He(){return He=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},He.apply(this,arguments)}function Ue(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Ve);return a.createElement("svg",He({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,ze||(ze=a.createElement("defs",null,a.createElement("path",{id:"ico-copy_svg__a",d:"M13 15h3v2h-3v3h-2v-3H8v-2h3v-3h2v3zm12-9v13h-2V6c0-.551-.448-1-1-1H9V3h13c1.654 0 3 1.346 3 3zm-6 16a1 1 0 01-1 1H6c-.551 0-1-.448-1-1V10c0-.552.449-1 1-1h12a1 1 0 011 1v12zM18 7H6c-1.654 0-3 1.346-3 3v12c0 1.654 1.346 3 3 3h12c1.654 0 3-1.346 3-3V10c0-1.654-1.346-3-3-3z"}))),We||(We=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-copy_svg__a",fillRule:"evenodd"})))}var Ge,qe,Xe=n(47),Ke=["title","titleId"];function $e(){return $e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},$e.apply(this,arguments)}function Ze(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Ke);return a.createElement("svg",$e({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Ge||(Ge=a.createElement("defs",null,a.createElement("path",{id:"ico-delete_svg__a",d:"M21 7H7v16c0 .552.449 1 1 1h12a1 1 0 001-1V7zm-9-2h4c0-1.103-.897-2-2-2s-2 .897-2 2zm13 2h-2v16c0 1.654-1.346 3-3 3H8c-1.654 0-3-1.346-3-3V7H3V5h7c0-2.205 1.794-4 4-4s4 1.795 4 4h7v2zm-8.5 13a.5.5 0 00.5-.5v-8a.5.5 0 00-1 0v8a.5.5 0 00.5.5zm-5.5-.5v-8a.5.5 0 011 0v8a.5.5 0 01-1 0z"}))),qe||(qe=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-delete_svg__a",fillRule:"evenodd"})))}var Ye,Je,Qe=["title","titleId"];function et(){return et=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},et.apply(this,arguments)}function tt(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Qe);return a.createElement("svg",et({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Ye||(Ye=a.createElement("defs",null,a.createElement("path",{id:"ico-discover-selected_svg__a",d:"M9.344 18.657l2.316-6.29 3.972 3.973-6.288 2.317zM19.327 8.03l-8.039 2.961a.506.506 0 00-.296.296l-2.961 8.039a.5.5 0 00.642.642l8.038-2.962a.5.5 0 00.297-.296l2.961-8.038a.5.5 0 00-.642-.642zM14 24C8.486 24 4 19.514 4 14S8.486 4 14 4s10 4.486 10 10-4.486 10-10 10zm0-22C7.383 2 2 7.383 2 14s5.383 12 12 12 12-5.383 12-12S20.617 2 14 2z"}))),Je||(Je=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-discover-selected_svg__a",fillRule:"evenodd"})))}var nt,rt,ot=["title","titleId"];function at(){return at=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},at.apply(this,arguments)}function it(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,ot);return a.createElement("svg",at({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,nt||(nt=a.createElement("defs",null,a.createElement("path",{id:"ico-discover_svg__a",d:"M16.34 15.633L14.707 14l3.537-3.537-1.904 5.17zm-6.996 3.024l2.316-6.29 3.972 3.973-6.288 2.317zm8.193-8.901L14 13.293l-1.632-1.632 5.17-1.905zm1.79-1.725l-8.039 2.961a.506.506 0 00-.296.296l-2.961 8.039a.5.5 0 00.642.642l8.038-2.962a.5.5 0 00.297-.296l2.961-8.038a.5.5 0 00-.642-.642zM14 24C8.486 24 4 19.514 4 14S8.486 4 14 4s10 4.486 10 10-4.486 10-10 10zm0-22C7.383 2 2 7.383 2 14s5.383 12 12 12 12-5.383 12-12S20.617 2 14 2z"}))),rt||(rt=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-discover_svg__a",fillRule:"evenodd"})))}var st,ut,ct=["title","titleId"];function lt(){return lt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},lt.apply(this,arguments)}function ft(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,ct);return a.createElement("svg",lt({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,st||(st=a.createElement("defs",null,a.createElement("path",{id:"ico-dislike_svg__a",d:"M24 20.5c0 1.93-1.57 3.5-3.5 3.5h-4.687a8.952 8.952 0 01-3.16-.573L11 22.807V14.6l.366-.195a10.936 10.936 0 004.704-4.871L17 7.63c.02-.04.037-.08.052-.123a.744.744 0 011.447.198l-.494 5.2A.997.997 0 0019 13.999h3.5c.827 0 1.5.673 1.5 1.5v5zM9 24H4V13h5v11zm13.5-12h-2.4l.395-4.162c.003-.032.005-.063.005-.095A2.746 2.746 0 0017.756 5a2.741 2.741 0 00-2.578 1.806l-.905 1.849A8.94 8.94 0 0111 12.304V12a1 1 0 00-1-1H3a1 1 0 00-1 1v13a1 1 0 001 1h7a1 1 0 001-1v-.057l.951.356a10.93 10.93 0 003.862.701H20.5c3.032 0 5.5-2.468 5.5-5.5v-5c0-1.93-1.57-3.5-3.5-3.5z"}))),ut||(ut=a.createElement("use",{fill:"currentColor",transform:"matrix(1 0 0 -1 0 31)",xlinkHref:"#ico-dislike_svg__a",fillRule:"evenodd"})))}var ht,pt,dt=["title","titleId"];function vt(){return vt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},vt.apply(this,arguments)}function mt(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,dt);return a.createElement("svg",vt({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,ht||(ht=a.createElement("defs",null,a.createElement("path",{id:"ico-dismiss_svg__a",d:"M18.242 8.343L14 12.585 9.758 8.343 8.343 9.758 12.585 14l-4.242 4.242 1.415 1.415L14 15.415l4.242 4.242 1.415-1.415L15.414 14l4.243-4.242z"}))),pt||(pt=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-dismiss_svg__a",fillRule:"evenodd"})))}var gt,yt,bt=["title","titleId"];function wt(){return wt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},wt.apply(this,arguments)}function xt(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,bt);return a.createElement("svg",wt({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,gt||(gt=a.createElement("defs",null,a.createElement("path",{id:"ico-doc-aardhaar_svg__a",d:"M6.5 13a.5.5 0 00-.5.5v4a.5.5 0 00.5.5h4a.5.5 0 00.5-.5v-4a.5.5 0 00-.5-.5h-4zm0 6c-.827 0-1.5-.673-1.5-1.5v-4c0-.827.673-1.5 1.5-1.5h4c.827 0 1.5.673 1.5 1.5v4c0 .827-.673 1.5-1.5 1.5h-4zm18-12a.5.5 0 01.5.5v13a.5.5 0 01-.5.5h-21a.5.5 0 01-.5-.5v-13a.5.5 0 01.5-.5zm-2 9a.5.5 0 00-.5.5V18h-1.5a.5.5 0 000 1h2a.5.5 0 00.5-.5v-2a.5.5 0 00-.5-.5zm-4 0h-2a.5.5 0 00-.5.5v2a.5.5 0 00.5.5h2a.5.5 0 00.5-.5v-2a.5.5 0 00-.5-.5zm-.5 1v1h-1v-1h1zm.5-5h-2a.5.5 0 00-.5.5v2a.5.5 0 00.5.5h2a.5.5 0 00.5-.5v-2a.5.5 0 00-.5-.5zm4 0h-2a.5.5 0 00-.5.5v2a.5.5 0 00.5.5h2a.5.5 0 00.5-.5v-2a.5.5 0 00-.5-.5zM18 13v1h-1v-1h1zm4 0v1h-1v-1h1zm.5-4h-17a.5.5 0 000 1h17a.5.5 0 000-1zm-19 14A2.503 2.503 0 011 20.5v-13C1 6.122 2.122 5 3.5 5h21C25.878 5 27 6.122 27 7.5v13c0 1.378-1.122 2.5-2.5 2.5h-21z"}))),yt||(yt=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-doc-aardhaar_svg__a",fillRule:"evenodd"})))}var Et,_t,Ot=["title","titleId"];function kt(){return kt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},kt.apply(this,arguments)}function Ct(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Ot);return a.createElement("svg",kt({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Et||(Et=a.createElement("defs",null,a.createElement("path",{id:"ico-doc-driving-license_svg__a",d:"M10.5 17.46v-3.153l2.813-1.425c.12.351.187.726.187 1.118a3.502 3.502 0 01-3 3.46zM6.5 14c0-.399.07-.78.194-1.137L9.5 14.305v3.155c-1.694-.244-3-1.7-3-3.46zm3.5-3.5c1.182 0 2.226.59 2.86 1.49l-2.858 1.448-2.85-1.464A3.494 3.494 0 0110 10.5zm0-1A4.505 4.505 0 005.5 14c0 2.481 2.019 4.5 4.5 4.5 2.482 0 4.5-2.019 4.5-4.5 0-2.482-2.018-4.5-4.5-4.5zm13 6a.5.5 0 01-.5.5h-5a.5.5 0 010-1h5a.5.5 0 01.5.5zm0-3a.5.5 0 01-.5.5h-5a.5.5 0 010-1h5a.5.5 0 01.5.5zm2 7.5a1 1 0 01-1 1H4c-.551 0-1-.448-1-1V8c0-.551.449-1 1-1h20c.552 0 1 .449 1 1v12zM24 5H4C2.346 5 1 6.346 1 8v12c0 1.654 1.346 3 3 3h20c1.654 0 3-1.346 3-3V8c0-1.654-1.346-3-3-3z"}))),_t||(_t=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-doc-driving-license_svg__a",fillRule:"evenodd"})))}var It,St,Rt=["title","titleId"];function At(){return At=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},At.apply(this,arguments)}function Pt(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Rt);return a.createElement("svg",At({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,It||(It=a.createElement("defs",null,a.createElement("path",{id:"ico-doc-generic_svg__a",d:"M9.596 13.034l.903-.18c.19.728.468 1.385.808 1.905a3 3 0 01-1.711-1.725zm.722-3.225c-.114.594-.126 1.3-.02 2.066l-.897.178a2.997 2.997 0 01.917-2.244zm4.875 1.092l-.894.178c-.194-.745-.474-1.392-.805-1.896.197.078.39.17.57.29.524.35.91.85 1.129 1.428zm-.302 2.733a3.036 3.036 0 01-.42.495c.114-.61.12-1.323.017-2.068l.905-.18a2.974 2.974 0 01-.502 1.753zm-1.383-1.378c.085.666.076 1.309-.038 1.814-.13.574-.344.81-.488.84-.148.029-.434-.109-.773-.59-.3-.422-.553-1.012-.729-1.66l2.028-.404zM11.81 9.025a.234.234 0 01.047-.005c.384 0 1.073.845 1.455 2.255l-2.031.404c-.196-1.51.156-2.58.53-2.654zm1.366 6.866a3.977 3.977 0 002.545-1.701 3.97 3.97 0 00.597-3.003 3.974 3.974 0 00-1.7-2.546 3.979 3.979 0 00-3.003-.597 4.005 4.005 0 00-3.143 4.704 4.007 4.007 0 004.704 3.143zm3.527 2.357a.5.5 0 01-.392.588l-4.904.975a.502.502 0 01-.589-.393.501.501 0 01.393-.588l4.904-.975a.5.5 0 01.588.393zm6.823-7.96l-1.869 4.673-1.404-7.06 2.716 1.086c.512.205.761.788.557 1.3zm-3.052 10.48a.999.999 0 01-.636.425l-11.77 2.34L4.754 6.86l11.77-2.34a1 1 0 011.176.785l2.926 14.712a.99.99 0 01-.15.75zM23.712 7.13L19.79 5.561l-.13-.646a3 3 0 00-3.527-2.357l-13.73 2.73 4.096 20.597 13.731-2.73a2.986 2.986 0 001.91-1.277 2.976 2.976 0 00.447-2.251l-.212-1.07 3.01-7.527a3.005 3.005 0 00-1.672-3.9z"}))),St||(St=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-doc-generic_svg__a",fillRule:"evenodd"})))}var Tt,Dt,Mt=["title","titleId"];function Nt(){return Nt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Nt.apply(this,arguments)}function Ft(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Mt);return a.createElement("svg",Nt({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Tt||(Tt=a.createElement("defs",null,a.createElement("path",{id:"ico-doc-national-id_svg__a",d:"M19 16.5a.5.5 0 00-.5-.5h-4a.5.5 0 000 1h4a.5.5 0 00.5-.5zm4-3a.5.5 0 00-.5-.5h-8a.5.5 0 000 1h8a.5.5 0 00.5-.5zm0-3a.5.5 0 00-.5-.5h-8a.5.5 0 000 1h8a.5.5 0 00.5-.5zM6.5 11a.5.5 0 00-.5.5v5a.5.5 0 00.5.5h4a.5.5 0 00.5-.5v-5a.5.5 0 00-.5-.5h-4zm4 7h-4c-.827 0-1.5-.673-1.5-1.5v-5c0-.827.673-1.5 1.5-1.5h4c.827 0 1.5.673 1.5 1.5v5c0 .827-.673 1.5-1.5 1.5zm-7-11a.5.5 0 00-.5.5v13a.5.5 0 00.5.5h21a.5.5 0 00.5-.5v-13a.5.5 0 00-.5-.5h-21zm21 16h-21A2.503 2.503 0 011 20.5v-13C1 6.122 2.122 5 3.5 5h21C25.878 5 27 6.122 27 7.5v13c0 1.378-1.122 2.5-2.5 2.5z"}))),Dt||(Dt=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-doc-national-id_svg__a",fillRule:"evenodd"})))}var Bt,jt,Lt=["title","titleId"];function zt(){return zt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},zt.apply(this,arguments)}function Wt(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Lt);return a.createElement("svg",zt({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Bt||(Bt=a.createElement("defs",null,a.createElement("path",{id:"ico-doc-pass-card_svg__a",d:"M23 10.5a.5.5 0 00-.5-.5h-6a.5.5 0 000 1h6a.5.5 0 00.5-.5zM19 16h3v-2h-3v2zm3 1h-3a1 1 0 01-1-1v-2a1 1 0 011-1h3a1 1 0 011 1v2a1 1 0 01-1 1zM6.5 11a.5.5 0 00-.5.5v5a.5.5 0 00.5.5h4a.5.5 0 00.5-.5v-5a.5.5 0 00-.5-.5h-4zm4 7h-4c-.827 0-1.5-.673-1.5-1.5v-5c0-.827.673-1.5 1.5-1.5h4c.827 0 1.5.673 1.5 1.5v5c0 .827-.673 1.5-1.5 1.5zm-7-11a.5.5 0 00-.5.5v13a.5.5 0 00.5.5h21a.5.5 0 00.5-.5v-13a.5.5 0 00-.5-.5h-21zm21 16h-21A2.503 2.503 0 011 20.5v-13C1 6.122 2.122 5 3.5 5h21C25.878 5 27 6.122 27 7.5v13c0 1.378-1.122 2.5-2.5 2.5z"}))),jt||(jt=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-doc-pass-card_svg__a",fillRule:"evenodd"})))}var Vt,Ht,Ut=["title","titleId"];function Gt(){return Gt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Gt.apply(this,arguments)}function qt(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Ut);return a.createElement("svg",Gt({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Vt||(Vt=a.createElement("defs",null,a.createElement("path",{id:"ico-doc-passport_svg__a",d:"M6 4v20h15a1 1 0 001-1V5c0-.551-.448-1-1-1H6zm15-2c1.654 0 3 1.346 3 3v18c0 1.654-1.346 3-3 3H4V2h17zm-3.5 18h-7a.5.5 0 100 1h7a.5.5 0 000-1zM14 6.507a5 5 0 10.001 10.001A5 5 0 0014 6.507zm1.49 5.435c-.093 2.029-.82 3.565-1.49 3.565s-1.397-1.536-1.49-3.565zm-3.981 0c.048 1.224.302 2.33.71 3.147a4.001 4.001 0 01-2.196-3.146zm6.467 0a4.004 4.004 0 01-2.195 3.148c.408-.818.661-1.924.71-3.147zM12.22 7.927c-.394.788-.644 1.846-.705 3.017H10.04a4.008 4.008 0 012.106-2.98zM14 7.508c.657 0 1.367 1.471 1.484 3.435h-2.966c.117-1.964.827-3.435 1.483-3.435zm1.782.417a4.008 4.008 0 012.18 3.019h-1.476c-.06-1.144-.298-2.178-.676-2.96z"}))),Ht||(Ht=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-doc-passport_svg__a",fillRule:"evenodd"})))}var Xt,Kt,$t=["title","titleId"];function Zt(){return Zt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Zt.apply(this,arguments)}function Yt(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,$t);return a.createElement("svg",Zt({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Xt||(Xt=a.createElement("defs",null,a.createElement("path",{id:"ico-document-image_svg__a",d:"M18 15.5a.5.5 0 00-.5-.5h-2a.5.5 0 000 1h2a.5.5 0 00.5-.5zm0-3a.5.5 0 00-.5-.5h-2a.5.5 0 000 1h2a.5.5 0 00.5-.5zM11 15h2v-2h-2v2zm2.5 1h-3a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5zM25 20h-2v3h-3v2h5v-5zm0-17h-5.5v2H23v3h2V3zM8 23H5v-3H3v5h5v-2zM5 5h3V3H3v5h2V5zm4 5a1 1 0 00-1 1v6a1 1 0 001 1h10a1 1 0 001-1v-6a1 1 0 00-1-1H9zm10 10H9c-1.654 0-3-1.346-3-3v-6c0-1.654 1.346-3 3-3h10c1.654 0 3 1.346 3 3v6c0 1.654-1.346 3-3 3z"}))),Kt||(Kt=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-document-image_svg__a",fillRule:"evenodd"})))}var Jt,Qt,en=["title","titleId"];function tn(){return tn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},tn.apply(this,arguments)}function nn(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,en);return a.createElement("svg",tn({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Jt||(Jt=a.createElement("defs",null,a.createElement("path",{id:"ico-document_svg__a",d:"M6 24h16V4H6v20zM24 2v24H4V2h20zm-8.5 17h-6a.5.5 0 000 1h6a.5.5 0 000-1zm3-3h-9a.5.5 0 000 1h9a.5.5 0 000-1zm0-3h-9a.5.5 0 000 1h9a.5.5 0 000-1zm0-3h-9a.5.5 0 000 1h9a.5.5 0 000-1zm0-3h-9a.5.5 0 000 1h9a.5.5 0 000-1z"}))),Qt||(Qt=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-document_svg__a",fillRule:"evenodd"})))}var rn,on,an=["title","titleId"];function sn(){return sn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},sn.apply(this,arguments)}function un(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,an);return a.createElement("svg",sn({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,rn||(rn=a.createElement("defs",null,a.createElement("path",{id:"ico-do-not_svg__a",d:"M14 3c2.677 0 5.131.957 7.039 2.546l.032-.031 1.414 1.414-.031.032A10.96 10.96 0 0125 14c0 6.075-4.925 11-11 11-2.677 0-5.131-.957-7.039-2.546l-.032.031-1.414-1.414.031-.032A10.96 10.96 0 013 14C3 7.925 7.925 3 14 3zm7.032 5.383l-12.65 12.65a9 9 0 0012.65-12.65zM14 5a9 9 0 00-7.032 14.617l12.65-12.65A8.982 8.982 0 0014 5z"}))),on||(on=a.createElement("use",{fill:"currentColor",fillRule:"nonzero",xlinkHref:"#ico-do-not_svg__a"})))}var cn,ln,fn=["title","titleId"];function hn(){return hn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},hn.apply(this,arguments)}function pn(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,fn);return a.createElement("svg",hn({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,cn||(cn=a.createElement("defs",null,a.createElement("path",{id:"ico-download_svg__a",d:"M19.625 14.78l-1.25-1.561-3.375 2.7V5h-2v10.92l-3.375-2.7-1.25 1.562L14 19.28l5.625-4.5zM24 21v2H4v-2h20z"}))),ln||(ln=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-download_svg__a",fillRule:"evenodd"})))}var dn,vn,mn=["title","titleId"];function gn(){return gn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gn.apply(this,arguments)}function yn(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,mn);return a.createElement("svg",gn({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,dn||(dn=a.createElement("defs",null,a.createElement("path",{id:"ico-edit_svg__a",d:"M21.34 9.89l-1.014 1.015-3.535-3.536 1.014-1.014c.39-.39.909-.605 1.46-.605.553 0 1.071.215 1.461.605l.614.614c.39.39.605.91.605 1.46a2.05 2.05 0 01-.605 1.462zM10.427 20.805L6.89 17.27l9.193-9.193 3.535 3.536-9.192 9.192zm-4.042-2.628l3.134 3.135-3.514.38.38-3.515zm16.37-12.621l-.614-.614a4.04 4.04 0 00-2.875-1.19 4.038 4.038 0 00-2.875 1.19L4.52 16.811l-.771 7.135 7.135-.771 11.87-11.87a4.04 4.04 0 001.19-2.875 4.038 4.038 0 00-1.19-2.875z"}))),vn||(vn=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-edit_svg__a",fillRule:"evenodd"})))}var bn,wn,xn=["title","titleId"];function En(){return En=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},En.apply(this,arguments)}function _n(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,xn);return a.createElement("svg",En({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,bn||(bn=a.createElement("defs",null,a.createElement("path",{id:"ico-email_svg__a",d:"M18.18 14.134L25 8.197V20.38l-6.82-6.246zm-7.59.671l1.438 1.251a2.965 2.965 0 003.935.007l1.446-1.258 6.748 6.18H3.843l6.748-6.18zm-.77-.67L3 20.38V8.197l6.82 5.937zm4.822.427a.956.956 0 01-1.292-.007L4.672 7h18.656l-8.686 7.562zM1 22.984h26V5H1v17.984z"}))),wn||(wn=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-email_svg__a",fillRule:"evenodd"})))}var On,kn,Cn=n(48),In=["title","titleId"];function Sn(){return Sn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Sn.apply(this,arguments)}function Rn(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,In);return a.createElement("svg",Sn({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,On||(On=a.createElement("defs",null,a.createElement("path",{id:"ico-face_svg__a",d:"M16.88 18.394a.5.5 0 10-.26-.965c-.619.167-1.598.267-2.62.267s-2.002-.1-2.62-.267a.5.5 0 10-.26.965c.708.192 1.758.302 2.88.302 1.121 0 2.171-.11 2.88-.302zm-2.005-3.563a.49.49 0 00.12-.393l-.5-4a.5.5 0 00-.991.124l.43 3.438H13.5a.5.5 0 000 1h1a.5.5 0 00.375-.17zM18 10a1 1 0 100 2 1 1 0 000-2zm-8 0a1 1 0 100 2 1 1 0 000-2zm13.988 17.172l-4.856-1.1a2.252 2.252 0 01-1.734-2.19c0-.841.464-1.604 1.211-1.992.855-.444 1.637-1.034 2.463-1.858A9.94 9.94 0 0024 12.978a9.933 9.933 0 00-2.928-7.055 9.972 9.972 0 00-3.18-2.139 10.103 10.103 0 00-7.785 0 9.97 9.97 0 00-3.18 2.14 9.915 9.915 0 00-2.142 3.171A9.91 9.91 0 004 12.978a9.94 9.94 0 002.928 7.054c.826.824 1.608 1.414 2.463 1.858a2.235 2.235 0 011.21 1.991c0 1.04-.706 1.939-1.717 2.186l-4.872 1.105-.442-1.95 4.855-1.101a.247.247 0 00.044-.456c-1.04-.54-1.98-1.245-2.953-2.217A11.926 11.926 0 012 12.978c0-1.617.317-3.186.943-4.664a11.95 11.95 0 012.572-3.807A11.983 11.983 0 019.33 1.941a12.103 12.103 0 019.341 0 11.968 11.968 0 013.814 2.566 11.937 11.937 0 013.516 8.471c0 1.617-.318 3.186-.943 4.663a11.95 11.95 0 01-2.572 3.807c-.975.972-1.913 1.677-2.954 2.217a.242.242 0 00-.133.216c0 .116.08.216.193.244l4.84 1.096-.443 1.95z"}))),kn||(kn=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-face_svg__a",fillRule:"evenodd"})))}var An,Pn=["title","titleId"];function Tn(){return Tn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Tn.apply(this,arguments)}function Dn(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Pn);return a.createElement("svg",Tn({xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,An||(An=a.createElement("path",{fill:"currentColor",d:"M18.67 1.937a11.946 11.946 0 013.814 2.566A11.94 11.94 0 0126 12.974c0 1.616-.317 3.185-.944 4.663a11.95 11.95 0 01-2.572 3.807c-.96.958-1.926 1.683-2.954 2.217a.243.243 0 00-.132.216c0 .116.08.216.193.244l4.839 1.096-.442 1.95-4.855-1.1a2.251 2.251 0 01-1.735-2.19c0-.84.465-1.604 1.212-1.991.855-.444 1.637-1.034 2.462-1.858A9.944 9.944 0 0024 12.974a9.944 9.944 0 00-2.928-7.055 9.965 9.965 0 00-3.179-2.14 10.105 10.105 0 00-7.786 0 9.96 9.96 0 00-3.178 2.14A9.914 9.914 0 004 12.974a9.927 9.927 0 002.928 7.054c.825.824 1.608 1.414 2.462 1.858a2.235 2.235 0 011.211 1.991c0 1.04-.706 1.939-1.717 2.186l-4.872 1.105-.442-1.95 4.855-1.101a.247.247 0 00.176-.24.242.242 0 00-.132-.216c-1.027-.534-1.993-1.259-2.953-2.217A11.94 11.94 0 012 12.974c0-1.617.317-3.186.944-4.664a11.95 11.95 0 012.572-3.807 11.936 11.936 0 013.813-2.566 12.103 12.103 0 019.341 0zm.123 6.851l1.414 1.415L12.5 17.91l-4.707-4.707 1.414-1.415 3.293 3.293 6.293-6.293z",fillRule:"evenodd"})))}var Mn,Nn=["title","titleId"];function Fn(){return Fn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Fn.apply(this,arguments)}function Bn(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Nn);return a.createElement("svg",Fn({xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Mn||(Mn=a.createElement("path",{fill:"currentColor",d:"M14 2.587l-3.708 7.514L2 11.306l6 5.848-1.416 8.259 7.416-3.9 7.417 3.9L20 17.154l6-5.848-8.292-1.205L14 2.587zm-4.18 14.88l.164-.957-.695-.678-3.322-3.237 4.59-.667.961-.14.43-.87L14 6.758l2.053 4.16.43.87.96.14 4.59.667-3.321 3.237-.695.678.163.956.785 4.572-4.106-2.159-.859-.45-.86.45-4.105 2.159.785-4.572z",fillRule:"evenodd"})))}var jn,Ln=["title","titleId"];function zn(){return zn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},zn.apply(this,arguments)}function Wn(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Ln);return a.createElement("svg",zn({xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,jn||(jn=a.createElement("path",{fill:"currentColor",d:"M14 2.587l-3.708 7.514L2 11.306l6 5.848-1.416 8.259L14 21.514l7.417 3.899L20 17.154l6-5.848-8.292-1.205z",fillRule:"evenodd"})))}var Vn,Hn,Un=["title","titleId"];function Gn(){return Gn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Gn.apply(this,arguments)}function qn(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Un);return a.createElement("svg",Gn({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Vn||(Vn=a.createElement("defs",null,a.createElement("path",{id:"ico-feedback_svg__a",d:"M16 16.5a.5.5 0 00-.5-.5h-6a.5.5 0 000 1h6a.5.5 0 00.5-.5zm3-3a.5.5 0 00-.5-.5h-9a.5.5 0 000 1h9a.5.5 0 00.5-.5zm0-3a.5.5 0 00-.5-.5h-9a.5.5 0 000 1h9a.5.5 0 00.5-.5zm-5.316-6.495c-5.186.155-9.435 4.237-9.673 9.291a9.551 9.551 0 001.207 5.122c.194.348.25.75.156 1.131l-.996 4.072 4.108-1.194a1.596 1.596 0 011.13.094 10.106 10.106 0 004.782.98c5.227-.199 9.443-4.35 9.598-9.45.08-2.672-.926-5.196-2.836-7.106-1.952-1.953-4.675-3.024-7.476-2.94zM3.197 26a1.14 1.14 0 01-1.114-1.412l1.307-5.344a11.56 11.56 0 01-1.377-6.042C2.3 7.11 7.4 2.192 13.624 2.005c3.35-.098 6.61 1.185 8.95 3.526 2.304 2.304 3.518 5.352 3.42 8.58-.186 6.148-5.246 11.15-11.52 11.389-1.92.073-3.848-.31-5.58-1.108l-5.379 1.563a1.16 1.16 0 01-.319.045z"}))),Hn||(Hn=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-feedback_svg__a",fillRule:"evenodd"})))}var Xn,Kn,$n=["title","titleId"];function Zn(){return Zn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Zn.apply(this,arguments)}function Yn(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,$n);return a.createElement("svg",Zn({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Xn||(Xn=a.createElement("defs",null,a.createElement("path",{id:"ico-filter_svg__a",d:"M5 4c-.551 0-1-.449-1-1 0-.551.449-1 1-1 .551 0 1 .449 1 1 0 .551-.449 1-1 1zm2.825-2A3.003 3.003 0 005 0a3.003 3.003 0 00-2.825 2H0v2h2.175A3.003 3.003 0 005 6a3.003 3.003 0 002.825-2H20V2H7.825zM8 16a1.001 1.001 0 010-2 1 1 0 010 2zm0-4a3.002 3.002 0 00-2.825 2H0v2h5.175A3.003 3.003 0 008 18a3.003 3.003 0 002.825-2H20v-2h-9.175A3.002 3.002 0 008 12zm7-2a1 1 0 110-2 1 1 0 010 2zm0-4a3.003 3.003 0 00-2.825 2H0v2h12.175A3.002 3.002 0 0015 12a3.002 3.002 0 002.825-2H20V8h-2.175A3.003 3.003 0 0015 6z"}))),Kn||(Kn=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-filter_svg__a",fillRule:"evenodd",transform:"translate(4 5)"})))}var Jn,Qn,er=["title","titleId"];function tr(){return tr=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},tr.apply(this,arguments)}function nr(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,er);return a.createElement("svg",tr({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Jn||(Jn=a.createElement("defs",null,a.createElement("path",{id:"ico-flag_svg__a",d:"M16 15h5V7h-5v8zm-9 0h8V7H7v8zM23 5H7V4a1 1 0 00-2 0v21h2v-8h16V5z"}))),Qn||(Qn=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-flag_svg__a",fillRule:"evenodd"})))}var rr,or,ar=["title","titleId"];function ir(){return ir=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ir.apply(this,arguments)}function sr(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,ar);return a.createElement("svg",ir({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,rr||(rr=a.createElement("defs",null,a.createElement("path",{id:"ico-gender_svg__a",d:"M13 18c-3.309 0-6-2.691-6-6s2.691-6 6-6c3.308 0 6 2.691 6 6s-2.692 6-6 6zm5-17v2h2.586l-2.688 2.688A7.96 7.96 0 0013 4c-4.411 0-8 3.588-8 8 0 4.072 3.06 7.436 7 7.93V22h-2v2h2v2h2v-2h2v-2h-2v-2.07c3.94-.494 7-3.858 7-7.93a7.948 7.948 0 00-1.688-4.897L22 4.413V7h2V1h-6z"}))),or||(or=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-gender_svg__a",fillRule:"evenodd"})))}var ur,cr,lr=["title","titleId"];function fr(){return fr=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},fr.apply(this,arguments)}function hr(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,lr);return a.createElement("svg",fr({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,ur||(ur=a.createElement("defs",null,a.createElement("path",{id:"ico-go-back_svg__a",d:"M18 10h-4.176l2-2.5-1.249-1-3.6 4.5 3.6 4.5 1.25-1-2-2.5H18c1.654 0 3 1.346 3 3s-1.346 3-3 3H6v2h12c2.757 0 5-2.243 5-5s-2.243-5-5-5"}))),cr||(cr=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-go-back_svg__a",fillRule:"evenodd"})))}var pr,dr,vr=["title","titleId"];function mr(){return mr=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mr.apply(this,arguments)}function gr(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,vr);return a.createElement("svg",mr({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,pr||(pr=a.createElement("defs",null,a.createElement("path",{id:"ico-help_svg__a",d:"M15.25 19.25a1.25 1.25 0 11-2.5 0 1.25 1.25 0 012.5 0m2.25-7.75c0 1.704-.92 2.508-1.591 3.097-.567.495-.909.795-.909 1.59v.625h-2v-.625c0-1.704.92-2.508 1.591-3.096.567-.495.909-.795.909-1.591 0-.352-.108-1.5-1.5-1.5s-1.5 1.148-1.5 1.5h-2C10.5 9.815 11.595 8 14 8c2.405 0 3.5 1.815 3.5 3.5M14 23c-4.962 0-9-4.038-9-9s4.038-9 9-9 9 4.038 9 9-4.038 9-9 9m0-20C7.925 3 3 7.925 3 14s4.925 11 11 11 11-4.925 11-11S20.075 3 14 3"}))),dr||(dr=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-help_svg__a",fillRule:"evenodd"})))}var yr,br,wr=n(44),xr=["title","titleId"];function Er(){return Er=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Er.apply(this,arguments)}function _r(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,xr);return a.createElement("svg",Er({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,yr||(yr=a.createElement("defs",null,a.createElement("path",{id:"ico-house_svg__a",d:"M14 .997L27 8.58v17.418H1V8.58L14 .997zm0 2.315L3 9.73v14.269h12v-8.461c0-1.49 1.221-2.697 2.727-2.697 1.507 0 2.728 1.208 2.728 2.697l-.001 8.46H25V9.73L14 3.312zm3.727 10.528c-.956 0-1.727.762-1.727 1.697v8.303h3.455v-8.303c0-.935-.771-1.697-1.728-1.697zM10 12.498a3.5 3.5 0 110 7 3.5 3.5 0 010-7zm0 1a2.5 2.5 0 10.002 5.002A2.5 2.5 0 0010 13.498z"}))),br||(br=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-house_svg__a",fillRule:"evenodd"})))}var Or,kr,Cr=n(46),Ir=n(49),Sr=["title","titleId"];function Rr(){return Rr=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Rr.apply(this,arguments)}function Ar(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Sr);return a.createElement("svg",Rr({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Or||(Or=a.createElement("defs",null,a.createElement("path",{id:"ico-like_svg__a",d:"M24 17.5c0 1.93-1.57 3.5-3.5 3.5h-4.687a8.952 8.952 0 01-3.16-.573L11 19.807V11.6l.366-.195a10.936 10.936 0 004.704-4.871L17 4.631c.02-.04.037-.081.052-.123a.74.74 0 01.704-.509c.398 0 .724.314.743.706l-.494 5.2A.997.997 0 0019 10.999h3.5c.827 0 1.5.673 1.5 1.5v5zM9 21H4V10h5v11zM22.5 9h-2.4l.395-4.162c.003-.032.005-.063.005-.095A2.746 2.746 0 0017.756 2a2.741 2.741 0 00-2.578 1.806l-.905 1.848A8.93 8.93 0 0111 9.304V9a1 1 0 00-1-1H3a1 1 0 00-1 1v13a1 1 0 001 1h7a1 1 0 001-1v-.057l.951.356a10.93 10.93 0 003.862.701H20.5c3.032 0 5.5-2.468 5.5-5.5v-5c0-1.93-1.57-3.5-3.5-3.5z"}))),kr||(kr=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-like_svg__a",fillRule:"evenodd"})))}var Pr,Tr,Dr=["title","titleId"];function Mr(){return Mr=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Mr.apply(this,arguments)}function Nr(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Dr);return a.createElement("svg",Mr({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Pr||(Pr=a.createElement("defs",null,a.createElement("path",{id:"ico-list-horizontal_svg__a",d:"M16.25 22a2.25 2.25 0 10-4.502.002A2.25 2.25 0 0016.25 22m0-8a2.25 2.25 0 10-4.502.002A2.25 2.25 0 0016.25 14M14 8.25a2.25 2.25 0 11.002-4.502A2.25 2.25 0 0114 8.25"}))),Tr||(Tr=a.createElement("use",{fill:"currentColor",transform:"rotate(90 14 14)",xlinkHref:"#ico-list-horizontal_svg__a",fillRule:"evenodd"})))}var Fr,Br,jr=["title","titleId"];function Lr(){return Lr=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lr.apply(this,arguments)}function zr(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,jr);return a.createElement("svg",Lr({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Fr||(Fr=a.createElement("defs",null,a.createElement("path",{id:"ico-list-vertical_svg__a",d:"M0 28h28V0H0z"}))),Br||(Br=a.createElement("g",{fill:"none",fillRule:"evenodd"},a.createElement("mask",{id:"ico-list-vertical_svg__b",fill:"#fff"},a.createElement("use",{xlinkHref:"#ico-list-vertical_svg__a"})),a.createElement("path",{fill:"currentColor",d:"M16.25 22a2.25 2.25 0 10-4.502.002A2.25 2.25 0 0016.25 22m0-8a2.25 2.25 0 10-4.502.002A2.25 2.25 0 0016.25 14M14 8.25a2.25 2.25 0 11.002-4.502A2.25 2.25 0 0114 8.25",mask:"url(#ico-list-vertical_svg__b)"}))))}var Wr,Vr,Hr=n(27),Ur=["title","titleId"];function Gr(){return Gr=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Gr.apply(this,arguments)}function qr(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Ur);return a.createElement("svg",Gr({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Wr||(Wr=a.createElement("defs",null,a.createElement("path",{id:"ico-lock-locked_svg__a",d:"M15 15.5a.998.998 0 01-.5.861V19a.5.5 0 01-1 0v-2.639a.999.999 0 01-.5-.861 1 1 0 012 0zm5 6.5H8v-9a1 1 0 011-1h10a1 1 0 011 1v9zM12 7c0-1.103.897-2 2-2s2 .897 2 2v3h-4V7zm7 3h-1V7c0-2.205-1.794-4-4-4s-4 1.795-4 4v3H9c-1.654 0-3 1.346-3 3v11h16V13c0-1.654-1.346-3-3-3z"}))),Vr||(Vr=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-lock-locked_svg__a",fillRule:"evenodd"})))}var Xr,Kr,$r=["title","titleId"];function Zr(){return Zr=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Zr.apply(this,arguments)}function Yr(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,$r);return a.createElement("svg",Zr({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Xr||(Xr=a.createElement("defs",null,a.createElement("path",{id:"ico-lock-unlocked_svg__a",d:"M13 15.5a1 1 0 012 0 .998.998 0 01-.5.861V19a.5.5 0 01-1 0v-2.639a.999.999 0 01-.5-.861zm6-3.5a1 1 0 011 1v9H8v-9a1 1 0 011-1h10zm1-10c-2.206 0-4 1.795-4 4v4H9c-1.654 0-3 1.346-3 3v11h16V13c0-1.654-1.346-3-3-3h-1V6c0-1.103.897-2 2-2s2 .897 2 2v2h2V6c0-2.205-1.794-4-4-4z"}))),Kr||(Kr=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-lock-unlocked_svg__a",fillRule:"evenodd"})))}var Jr,Qr,eo=["title","titleId"];function to(){return to=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},to.apply(this,arguments)}function no(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,eo);return a.createElement("svg",to({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Jr||(Jr=a.createElement("defs",null,a.createElement("path",{id:"ico-log-out_svg__a",d:"M19.36 3.36v2h-13v18h13v2h-15v-22h15zm1.78 5.375l4.5 5.625-4.5 5.625-1.561-1.25 2.7-3.375H10.36v-2h11.92l-2.7-3.375 1.561-1.25z"}))),Qr||(Qr=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-log-out_svg__a",fillRule:"evenodd"})))}var ro,oo,ao=["title","titleId"];function io(){return io=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},io.apply(this,arguments)}function so(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,ao);return a.createElement("svg",io({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,ro||(ro=a.createElement("defs",null,a.createElement("path",{id:"ico-map-pin_svg__a",d:"M19.657 17.657A8 8 0 008.343 6.343c-3.124 3.124-3.124 8.19-.013 11.301L14 23.111l5.657-5.454zM21.07 4.929c3.905 3.905 3.905 10.237-.013 14.155L14 25.889l-.694-.669-6.377-6.149c-3.905-3.905-3.905-10.237 0-14.142 3.905-3.906 10.237-3.906 14.142 0zM14 7a5 5 0 100 10 5 5 0 000-10zm0 1c2.21 0 4 1.79 4 4s-1.79 4-4 4-4-1.79-4-4 1.79-4 4-4z"}))),oo||(oo=a.createElement("use",{fill:"currentColor",fillRule:"nonzero",xlinkHref:"#ico-map-pin_svg__a"})))}var uo,co,lo=["title","titleId"];function fo(){return fo=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},fo.apply(this,arguments)}function ho(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,lo);return a.createElement("svg",fo({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,uo||(uo=a.createElement("defs",null,a.createElement("path",{id:"ico-megaphone_svg__a",d:"M10 14.552a.5.5 0 01-.5.5h-2a.5.5 0 010-1h2a.5.5 0 01.5.5zm0-2a.5.5 0 01-.5.5h-2a.5.5 0 010-1h2a.5.5 0 01.5.5zm14 2v-2a1.001 1.001 0 010 2zm-2 7.498l-6-4.88V9.934l6-4.88V22.05zm-11-4.998v5a1 1 0 01-2 0v-5H5v-7h10v7h-4zm13-6.5V4a1.499 1.499 0 00-2.33-1.249l-6.525 5.301H3v11h4v3c0 1.654 1.345 3 3 3s3-1.346 3-3v-3h2.145l6.447 5.244.078.058a1.498 1.498 0 002.33-1.25v-6.552c1.654 0 3-1.346 3-3s-1.346-3-3-3z"}))),co||(co=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-megaphone_svg__a",fillRule:"evenodd"})))}var po,vo,mo=["title","titleId"];function go(){return go=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},go.apply(this,arguments)}function yo(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,mo);return a.createElement("svg",go({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,po||(po=a.createElement("defs",null,a.createElement("path",{id:"ico-menu_svg__a",d:"M4 7v2h20V8H4h20V7H4zm0 6v2h20v-1H4h20v-1H4zm0 6v2h20v-1H4h20v-1H4z"}))),vo||(vo=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-menu_svg__a",fillRule:"evenodd"})))}var bo,wo,xo=["title","titleId"];function Eo(){return Eo=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Eo.apply(this,arguments)}function _o(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,xo);return a.createElement("svg",Eo({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,bo||(bo=a.createElement("defs",null,a.createElement("path",{id:"ico-microphone_svg__a",d:"M14 5.042a2.976 2.976 0 012.972 2.972v2.013h-5.944V8.014A2.976 2.976 0 0114 5.042m0 10.944a2.975 2.975 0 01-2.972-2.972v-1.987h5.944v1.987A2.975 2.975 0 0114 15.986m6.5-3.338a.5.5 0 01.5.5c0 3.494-2.626 6.381-6.008 6.806.006.042.013.084.013.128v2.925l2.991-.004a1.001 1.001 0 01.003 2l-7.995.01a1 1 0 11-.003-1.999l3.006-.004-.002-.013v-2.915c0-.043.008-.084.013-.126C9.633 19.536 7 16.646 7 13.148a.5.5 0 111 0 5.874 5.874 0 005.867 5.866h.266A5.873 5.873 0 0020 13.148a.5.5 0 01.5-.5zM14 2.986a5.034 5.034 0 015.028 5.028v5A5.034 5.034 0 0114 18.042a5.033 5.033 0 01-5.028-5.028v-5A5.034 5.034 0 0114 2.986z"}))),wo||(wo=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-microphone_svg__a",fillRule:"evenodd"})))}var Oo,ko,Co=["title","titleId"];function Io(){return Io=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Io.apply(this,arguments)}function So(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Co);return a.createElement("svg",Io({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Oo||(Oo=a.createElement("defs",null,a.createElement("path",{id:"ico-more-selected_svg__a",d:"M14 10c2.206 0 4 1.794 4 4s-1.794 4-4 4-4-1.794-4-4 1.794-4 4-4zm10 0c2.206 0 4 1.794 4 4s-1.794 4-4 4-4-1.794-4-4 1.794-4 4-4zM4 18c-2.205 0-4-1.794-4-4s1.794-4 4-4c2.205 0 4 1.794 4 4s-1.795 4-4 4"}))),ko||(ko=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-more-selected_svg__a",fillRule:"evenodd"})))}var Ro,Ao,Po=["title","titleId"];function To(){return To=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},To.apply(this,arguments)}function Do(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Po);return a.createElement("svg",To({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Ro||(Ro=a.createElement("defs",null,a.createElement("path",{id:"ico-more_svg__a",d:"M12 14c0 1.103.897 2 2 2s2-.897 2-2-.897-2-2-2-2 .897-2 2zm-2 0c0-2.206 1.794-4 4-4s4 1.794 4 4-1.794 4-4 4-4-1.794-4-4zm12 0c0 1.103.897 2 2 2s2-.897 2-2-.897-2-2-2-2 .897-2 2zm-2 0c0-2.206 1.794-4 4-4s4 1.794 4 4-1.794 4-4 4-4-1.794-4-4zM2 14c0 1.103.897 2 2 2s2-.897 2-2-.897-2-2-2-2 .897-2 2zm-2 0c0-2.206 1.794-4 4-4 2.205 0 4 1.794 4 4s-1.795 4-4 4-4-1.794-4-4z"}))),Ao||(Ao=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-more_svg__a",fillRule:"evenodd"})))}var Mo,No,Fo=["title","titleId"];function Bo(){return Bo=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Bo.apply(this,arguments)}function jo(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Fo);return a.createElement("svg",Bo({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Mo||(Mo=a.createElement("defs",null,a.createElement("path",{id:"ico-my-data_svg__a",d:"M5 18.637c0-1.654 1.229-3.029 2.798-3.13a2.973 2.973 0 012.253.804A2.97 2.97 0 0111 18.5v3H5v-2.863zm8-.137a5.02 5.02 0 00-1.581-3.649 4.947 4.947 0 00-3.75-1.34C5.051 13.68 3 15.932 3 18.637V23.5h10v-5zm-3-10c0 1.103-.897 2-2 2s-2-.897-2-2 .897-2 2-2 2 .897 2 2zm2 0c0-2.205-1.794-4-4-4-2.205 0-4 1.795-4 4 0 2.206 1.795 4 4 4 2.206 0 4-1.794 4-4zm3 13h10v-2H15v2zm0-4h10v-2H15v2zm0-8h10v-2H15v2zm0 4h10v-2H15v2z"}))),No||(No=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-my-data_svg__a",fillRule:"evenodd"})))}var Lo,zo,Wo=["title","titleId"];function Vo(){return Vo=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Vo.apply(this,arguments)}function Ho(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Wo);return a.createElement("svg",Vo({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Lo||(Lo=a.createElement("defs",null,a.createElement("path",{id:"ico-name_svg__a",d:"M25 22H3V8h9c0 1.103.897 2 2 2s2-.897 2-2h9v14zM13 6a1.001 1.001 0 012 0v2a1 1 0 01-2 0V6zm1-2c1.103 0 2 .897 2 2h11v18H1V6h11c0-1.103.897-2 2-2zm2.5 13h-10a.5.5 0 000 1h10a.5.5 0 000-1zm3-4h-13a.5.5 0 000 1h13a.5.5 0 000-1z"}))),zo||(zo=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-name_svg__a",fillRule:"evenodd"})))}var Uo,Go,qo=["title","titleId"];function Xo(){return Xo=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Xo.apply(this,arguments)}function Ko(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,qo);return a.createElement("svg",Xo({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Uo||(Uo=a.createElement("defs",null,a.createElement("path",{id:"ico-nfc-chip_svg__a",d:"M14 19a5.002 5.002 0 004.9-3.999L27 15v8H1v-8l8.1.001A5.002 5.002 0 0014 19zm0-8a3 3 0 110 6 3 3 0 010-6zm13-6v8h-8.1a5.002 5.002 0 00-9.8 0H1V5h26z"}))),Go||(Go=a.createElement("use",{fill:"currentColor",fillRule:"nonzero",xlinkHref:"#ico-nfc-chip_svg__a"})))}var $o,Zo,Yo=["title","titleId"];function Jo(){return Jo=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Jo.apply(this,arguments)}function Qo(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Yo);return a.createElement("svg",Jo({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,$o||($o=a.createElement("defs",null,a.createElement("path",{id:"ico-office-building_svg__a",d:"M22 24h2v-8h-2v8zm-2 0h-4v-3c0-1.103-.897-2-2-2s-2 .897-2 2v3H8V4h12v20zm-5 0h-2v-3a1 1 0 012 0v3zM4 24h2V9H4v15zM22 2v12h4v12H2V7h4V2h16zm-4.5 13h-7a.5.5 0 000 1h7a.5.5 0 000-1zm0-3h-7a.5.5 0 000 1h7a.5.5 0 000-1zm0-3h-7a.5.5 0 000 1h7a.5.5 0 000-1zm0-3h-7a.5.5 0 000 1h7a.5.5 0 000-1z"}))),Zo||(Zo=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-office-building_svg__a",fillRule:"evenodd"})))}var ea,ta,na=["title","titleId"];function ra(){return ra=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ra.apply(this,arguments)}function oa(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,na);return a.createElement("svg",ra({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,ea||(ea=a.createElement("defs",null,a.createElement("path",{id:"ico-pages-selected_svg__a",d:"M4 16h12c.552 0 1-.449 1-1V7.94H3V15c0 .551.449 1 1 1m12 2H4c-1.654 0-3-1.346-3-3V6c0-1.654 1.346-3 3-3h12c1.654 0 3 1.346 3 3v9c0 1.654-1.346 3-3 3m11 4c0 1.655-1.346 3-3 3H12c-1.654 0-3-1.345-3-3v-3h2v3a1 1 0 001 1h12a1 1 0 001-1v-7h-5v-5h4c1.654 0 3 1.347 3 3v9z"}))),ta||(ta=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-pages-selected_svg__a",fillRule:"evenodd"})))}var aa,ia,sa=["title","titleId"];function ua(){return ua=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ua.apply(this,arguments)}function ca(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,sa);return a.createElement("svg",ua({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,aa||(aa=a.createElement("defs",null,a.createElement("path",{id:"ico-pages_svg__a",d:"M4 16h12c.552 0 1-.449 1-1V7.94H3V15c0 .551.449 1 1 1M3 6v.94h14V6a1 1 0 00-1-1H4c-.551 0-1 .448-1 1m13 12H4c-1.654 0-3-1.346-3-3V6c0-1.654 1.346-3 3-3h12c1.654 0 3 1.346 3 3v9c0 1.654-1.346 3-3 3m11-5v9c0 1.655-1.346 3-3 3H12c-1.654 0-3-1.345-3-3v-3h2v3a1 1 0 001 1h12a1 1 0 001-1v-7h-5v-1h5v-1c0-.55-.448-1-1-1h-4v-2h4c1.654 0 3 1.347 3 3"}))),ia||(ia=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-pages_svg__a",fillRule:"evenodd"})))}var la,fa,ha=["title","titleId"];function pa(){return pa=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},pa.apply(this,arguments)}function da(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,ha);return a.createElement("svg",pa({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,la||(la=a.createElement("defs",null,a.createElement("path",{id:"ico-payment-card_svg__a",d:"M19.26 18.26c1.137-1.138 1.764-2.651 1.764-4.26s-.627-3.121-1.765-4.26a.524.524 0 10-.74.742A4.943 4.943 0 0119.977 14c0 1.33-.518 2.579-1.458 3.519a.522.522 0 00.37.894.519.519 0 00.37-.154zm-1.432-1.432a4.003 4.003 0 000-5.656.497.497 0 00-.706 0 .499.499 0 000 .707 3.005 3.005 0 010 4.243.497.497 0 000 .706.495.495 0 00.706 0zm-1.413-1.413c.779-.78.779-2.05 0-2.829a.499.499 0 00-.707 0 .499.499 0 000 .707c.389.39.389 1.025 0 1.415a.499.499 0 00.353.853.502.502 0 00.354-.146zM6.5 11a.5.5 0 00-.5.5v2a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-2a.5.5 0 00-.5-.5h-3zm3 4h-3c-.827 0-1.5-.673-1.5-1.5v-2c0-.827.673-1.5 1.5-1.5h3c.827 0 1.5.673 1.5 1.5v2c0 .827-.673 1.5-1.5 1.5zM4 7c-.551 0-1 .449-1 1v12c0 .552.449 1 1 1h20a1 1 0 001-1V8c0-.551-.448-1-1-1H4zm20 16H4c-1.654 0-3-1.346-3-3V8c0-1.654 1.346-3 3-3h20c1.654 0 3 1.346 3 3v12c0 1.654-1.346 3-3 3z"}))),fa||(fa=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-payment-card_svg__a",fillRule:"evenodd"})))}var va,ma,ga=["title","titleId"];function ya(){return ya=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ya.apply(this,arguments)}function ba(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,ga);return a.createElement("svg",ya({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,va||(va=a.createElement("defs",null,a.createElement("path",{id:"ico-phone_svg__a",d:"M19.175 23.494a4.288 4.288 0 003.24-1.26l.753-.752c.213-.214.33-.497.33-.799 0-.301-.117-.585-.33-.798l-2.08-2.08a1.123 1.123 0 00-1.156-.273l-2.02.673a3.11 3.11 0 01-3.201-.756l-4.161-4.16a3.113 3.113 0 01-.756-3.203l.673-2.02c.136-.407.032-.85-.273-1.155l-2.08-2.08a1.131 1.131 0 00-1.597 0l-.752.753a4.328 4.328 0 000 6.113l10.411 10.411c.85.85 1.915 1.342 2.999 1.386zm.188 2.004c-.09 0-.18-.002-.27-.006-1.587-.065-3.125-.764-4.33-1.97L4.35 13.112a6.328 6.328 0 010-8.941l.752-.753a3.132 3.132 0 014.425 0l2.08 2.08a3.11 3.11 0 01.756 3.202l-.673 2.02c-.136.408-.031.85.273 1.155l4.16 4.161c.306.305.749.41 1.156.273l2.02-.674a3.114 3.114 0 013.202.756l2.08 2.08c.591.592.917 1.378.917 2.213a3.11 3.11 0 01-.917 2.213l-.752.753a6.257 6.257 0 01-4.467 1.849z"}))),ma||(ma=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-phone_svg__a",fillRule:"evenodd"})))}var wa,xa,Ea=["title","titleId"];function _a(){return _a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_a.apply(this,arguments)}function Oa(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Ea);return a.createElement("svg",_a({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,wa||(wa=a.createElement("defs",null,a.createElement("path",{id:"ico-pin_svg__a",d:"M14 12.25a1.75 1.75 0 10.001 3.501A1.75 1.75 0 0014 12.25zm6 0a1.75 1.75 0 10.001 3.501A1.75 1.75 0 0020 12.25zm-12 0a1.75 1.75 0 10.001 3.501A1.75 1.75 0 008 12.25zM4 7c-.551 0-1 .449-1 1v12c0 .552.449 1 1 1h20a1 1 0 001-1V8c0-.551-.448-1-1-1H4zm20 16H4c-1.655 0-3-1.346-3-3V8c0-1.654 1.345-3 3-3h20c1.654 0 3 1.346 3 3v12c0 1.654-1.346 3-3 3z"}))),xa||(xa=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-pin_svg__a",fillRule:"evenodd"})))}var ka,Ca=["title","titleId"];function Ia(){return Ia=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ia.apply(this,arguments)}function Sa(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Ca);return a.createElement("svg",Ia({xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,ka||(ka=a.createElement("path",{fill:"currentColor",d:"M14 19.5c-5.417 0-7.816-4.78-7.994-5.5.178-.72 2.577-5.5 7.994-5.5s7.815 4.78 7.993 5.5c-.178.72-2.576 5.5-7.993 5.5m11 .5v5h-5v-2h3v-3h2zM5 20v3h3v2H3v-5h2zm9-13.5c6.667 0 10 6.068 10 7.5 0 1.432-3.333 7.5-10 7.5S4 15.432 4 14c0-1.432 3.333-7.5 10-7.5zm0 4c-1.93 0-3.5 1.57-3.5 3.5s1.57 3.5 3.5 3.5 3.5-1.57 3.5-3.5-1.57-3.5-3.5-3.5zm0 2c.827 0 1.5.673 1.5 1.5s-.673 1.5-1.5 1.5-1.5-.673-1.5-1.5.673-1.5 1.5-1.5zM8 3v2H5v3H3V3h5zm17 0v5h-2V5h-3V3h5z",fillRule:"evenodd"})))}var Ra,Aa,Pa=["title","titleId"];function Ta(){return Ta=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ta.apply(this,arguments)}function Da(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Pa);return a.createElement("svg",Ta({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Ra||(Ra=a.createElement("defs",null,a.createElement("path",{id:"ico-profile-selected_svg__a",d:"M17.5 11.5a.5.5 0 01.5-.5h3a.5.5 0 010 1h-3a.5.5 0 01-.5-.5m2.5 6a.5.5 0 01-.5.5H18a.5.5 0 010-1h1.5a.5.5 0 01.5.5m1.5-3a.5.5 0 01-.5.5h-3a.5.5 0 010-1h3a.5.5 0 01.5.5M11 7c-2.206 0-4 1.794-4 4s1.794 4 4 4 4-1.794 4-4-1.794-4-4-4m5 16.799V21c0-2.757-2.243-5-5-5a5.005 5.005 0 00-4.913 4.09A9.934 9.934 0 014 14C4 8.486 8.486 4 14 4s10 4.486 10 10c0 4.829-3.441 8.87-8 9.799M14 2C7.383 2 2 7.383 2 14s5.383 12 12 12 12-5.383 12-12S20.617 2 14 2"}))),Aa||(Aa=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-profile-selected_svg__a",fillRule:"evenodd"})))}var Ma,Na,Fa=["title","titleId"];function Ba(){return Ba=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ba.apply(this,arguments)}function ja(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Fa);return a.createElement("svg",Ba({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Ma||(Ma=a.createElement("defs",null,a.createElement("path",{id:"ico-profile_svg__a",d:"M17.5 11.5a.5.5 0 01.5-.5h3a.5.5 0 010 1h-3a.5.5 0 01-.5-.5m2.5 6a.5.5 0 01-.5.5H18a.5.5 0 010-1h1.5a.5.5 0 01.5.5m1.5-3a.5.5 0 01-.5.5h-3a.5.5 0 010-1h3a.5.5 0 01.5.5M11 13c-1.103 0-2-.897-2-2s.897-2 2-2 2 .897 2 2-.897 2-2 2m0-6c-2.206 0-4 1.794-4 4s1.794 4 4 4 4-1.794 4-4-1.794-4-4-4m5 16.799V21c0-2.757-2.243-5-5-5a5.005 5.005 0 00-4.913 4.09A9.934 9.934 0 014 14C4 8.486 8.486 4 14 4s10 4.486 10 10c0 4.829-3.441 8.87-8 9.799M8 21.98V21c0-1.654 1.346-3 3-3s3 1.346 3 3v3a9.94 9.94 0 01-6-2.019M14 2C7.383 2 2 7.383 2 14s5.383 12 12 12 12-5.383 12-12S20.617 2 14 2"}))),Na||(Na=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-profile_svg__a",fillRule:"evenodd"})))}var La,za,Wa=["title","titleId"];function Va(){return Va=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Va.apply(this,arguments)}function Ha(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Wa);return a.createElement("svg",Va({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,La||(La=a.createElement("defs",null,a.createElement("path",{id:"ico-receive_svg__a",d:"M10.436 21.535a.483.483 0 01-.568-.02.485.485 0 01-.181-.539l1.85-6.476h9.954l-11.055 7.035zm-.568-15.05a.519.519 0 01.3-.104c.08 0 .171.022.268.083L21.491 13.5h-9.954l-1.85-6.476a.483.483 0 01.181-.538zM8.672 4.884a2.481 2.481 0 012.837-.106L26.003 14l-14.494 9.223a2.49 2.49 0 01-2.837-.106 2.48 2.48 0 01-.908-2.69L9.6 14 7.764 7.573a2.48 2.48 0 01.908-2.69zM7.14 14.5a.5.5 0 010 1h-4a.5.5 0 010-1zm-1-2a.5.5 0 010 1h-4a.5.5 0 010-1z"}))),za||(za=a.createElement("use",{fill:"currentColor",transform:"matrix(-1 0 0 1 27.642 0)",xlinkHref:"#ico-receive_svg__a",fillRule:"evenodd"})))}var Ua,Ga,qa=["title","titleId"];function Xa(){return Xa=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Xa.apply(this,arguments)}function Ka(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,qa);return a.createElement("svg",Xa({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Ua||(Ua=a.createElement("defs",null,a.createElement("path",{id:"ico-retry_svg__a",d:"M9.581 7.858c2.977-3.099 7.675-3.572 11.174-1.36l-2.12.722.645 1.893 4.585-1.56.102-4.843-2-.042-.046 2.208C17.625 2.094 11.813 2.647 8.139 6.472a10.844 10.844 0 00-3.039 7.55c0 1.442.279 2.846.827 4.173l1.849-.765a8.85 8.85 0 01-.676-3.407c0-2.31.881-4.5 2.481-6.165m17.32 6.119c0 2.828-1.08 5.51-3.04 7.55a10.868 10.868 0 01-7.863 3.345c-2.06 0-4.122-.582-5.918-1.746l-.047 2.205-2-.042.103-4.842 4.584-1.56.645 1.893-2.12.721c3.5 2.212 8.198 1.74 11.174-1.359a8.86 8.86 0 002.481-6.165 8.876 8.876 0 00-.675-3.408l1.848-.764c.549 1.327.827 2.73.827 4.172"}))),Ga||(Ga=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-retry_svg__a",fillRule:"evenodd"})))}var $a,Za,Ya=n(50),Ja=n(51),Qa=["title","titleId"];function ei(){return ei=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ei.apply(this,arguments)}function ti(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Qa);return a.createElement("svg",ei({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,$a||($a=a.createElement("defs",null,a.createElement("path",{id:"ico-ruid_svg__a",d:"M10.998 23.528V21c0-1.654 1.346-3 3-3 1.655 0 3 1.346 3 3v2.524c-1.934.606-4.03.622-6 .004m14.874-11.259a11.92 11.92 0 00-4.702-7.89A11.994 11.994 0 007.99 3.61l1 1.732a9.997 9.997 0 0110.985.641 9.935 9.935 0 013.918 6.574 9.94 9.94 0 01-1.878 7.42 9.935 9.935 0 01-3.017 2.678V21c0-2.757-2.243-5-5-5s-5 2.243-5 5v1.653c-.333-.193-.66-.401-.977-.637-3.945-2.941-5.088-8.256-2.946-12.508l.988 2.046 1.801-.869L5.776 6.36l-4.778.482.2 1.99 2.076-.21C.714 13.724 2.096 20.094 6.826 23.62a11.939 11.939 0 007.157 2.375c3.663 0 7.283-1.667 9.635-4.823a11.922 11.922 0 002.254-8.903M13.998 9c1.103 0 2 .897 2 2s-.897 2-2 2-2-.897-2-2 .897-2 2-2m0 6c2.206 0 4-1.795 4-4 0-2.206-1.794-4-4-4-2.205 0-4 1.794-4 4 0 2.205 1.795 4 4 4"}))),Za||(Za=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-ruid_svg__a",fillRule:"evenodd"})))}var ni,ri,oi=["title","titleId"];function ai(){return ai=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ai.apply(this,arguments)}function ii(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,oi);return a.createElement("svg",ai({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,ni||(ni=a.createElement("defs",null,a.createElement("path",{id:"ico-scan-qr_svg__a",d:"M15 19h2v4h-2v2h-2v-4h2v-2zm0-4H9v-2h4v-2h2v4zM3 15h2v-2H3v2zm10-8h2V3h-2v4zm4 10h2v-4h-2v4zm6-4h2v4h-4v-2h2v-2zm-4-4h4V5h-4v4zm5-6h-6a1 1 0 00-1 1v6a1 1 0 001 1h6a1 1 0 001-1V4a1 1 0 00-1-1zM5 23h4v-4H5v4zm5-6H4a1 1 0 00-1 1v6a1 1 0 001 1h6a1 1 0 001-1v-6a1 1 0 00-1-1zm11 6h2v-2h-2v2zm3-4h-4a1 1 0 00-1 1v4a1 1 0 001 1h4a1 1 0 001-1v-4a1 1 0 00-1-1zM5 9h4V5H5v4zm-1 2h6a1 1 0 001-1V4a1 1 0 00-1-1H4a1 1 0 00-1 1v6a1 1 0 001 1z"}))),ri||(ri=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-scan-qr_svg__a",fillRule:"evenodd"})))}var si,ui,ci=["title","titleId"];function li(){return li=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},li.apply(this,arguments)}function fi(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,ci);return a.createElement("svg",li({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,si||(si=a.createElement("defs",null,a.createElement("path",{id:"ico-search_svg__a",d:"M16.481 7.5a.5.5 0 01-.5.5c-2.206 0-4 1.794-4 4a.5.5 0 01-1 0c0-2.757 2.243-5 5-5a.5.5 0 01.5.5m3.742 8.742A5.951 5.951 0 0115.982 18a5.956 5.956 0 01-4.242-1.758 6.005 6.005 0 010-8.485A5.957 5.957 0 0115.98 6c1.603 0 3.11.624 4.243 1.758a6.007 6.007 0 010 8.485m1.413-9.9A7.939 7.939 0 0015.982 4a7.944 7.944 0 00-5.656 2.343c-2.88 2.88-3.095 7.422-.659 10.558L4.96 21.607l1.415 1.414 4.705-4.706A7.936 7.936 0 0015.981 20a7.944 7.944 0 005.656-2.343c3.12-3.12 3.12-8.194 0-11.314"}))),ui||(ui=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-search_svg__a",fillRule:"evenodd"})))}var hi,pi,di=["title","titleId"];function vi(){return vi=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},vi.apply(this,arguments)}function mi(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,di);return a.createElement("svg",vi({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,hi||(hi=a.createElement("defs",null,a.createElement("path",{id:"ico-send_svg__a",d:"M10.796 21.535a.481.481 0 01-.567-.02.483.483 0 01-.182-.539l1.85-6.476h9.955l-11.056 7.035zm-.567-15.05a.51.51 0 01.3-.104c.08 0 .17.022.267.083L21.852 13.5h-9.955l-1.85-6.476a.48.48 0 01.181-.538zM9.032 4.884a2.483 2.483 0 012.838-.106L26.363 14 11.87 23.223a2.49 2.49 0 01-2.838-.106 2.48 2.48 0 01-.908-2.69L9.96 14 8.124 7.573a2.482 2.482 0 01.908-2.69zM7.5 14.5a.5.5 0 010 1h-4a.5.5 0 010-1zm-1-2a.5.5 0 010 1h-4a.5.5 0 010-1z"}))),pi||(pi=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-send_svg__a",fillRule:"evenodd"})))}var gi,yi,bi=["title","titleId"];function wi(){return wi=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},wi.apply(this,arguments)}function xi(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,bi);return a.createElement("svg",wi({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,gi||(gi=a.createElement("defs",null,a.createElement("path",{id:"ico-settings_svg__a",d:"M9.239 21.09l.53.3a8.378 8.378 0 001.947.8l.588.162.56 2.648h2.185l.56-2.648.589-.162c.7-.19 1.368-.468 1.988-.825l.53-.305 2.29 1.49 1.545-1.544-1.497-2.3.3-.529a8.424 8.424 0 00.791-1.927l.161-.588 2.694-.57v-2.184l-2.694-.57-.161-.588a8.514 8.514 0 00-.791-1.928l-.3-.528 1.497-2.3-1.545-1.545-2.29 1.491-.53-.306a8.47 8.47 0 00-1.988-.825l-.589-.16L15.049 3h-2.185l-.56 2.649-.588.16a8.442 8.442 0 00-1.948.801l-.529.3-2.245-1.46L5.45 6.993 6.904 9.23l-.306.531a8.431 8.431 0 00-.834 2.007l-.16.589-2.604.55v2.185l2.604.551.16.59a8.48 8.48 0 00.833 2.006l.307.531-1.455 2.236 1.546 1.544 2.244-1.46zm5.81 5.91h-2.185a2.01 2.01 0 01-1.957-1.586l-.312-1.475c-.436-.146-.86-.32-1.268-.52l-1.242.808a2.01 2.01 0 01-2.505-.262L4.035 22.42a2.01 2.01 0 01-.262-2.505l.797-1.224c-.216-.432-.401-.88-.556-1.34l-1.428-.302A2.01 2.01 0 011 15.092v-2.184c0-.94.667-1.762 1.587-1.957l1.427-.302c.155-.46.34-.908.556-1.34l-.797-1.224a2.01 2.01 0 01.262-2.505L5.58 4.035a2.009 2.009 0 012.505-.262l1.242.808c.409-.2.833-.374 1.268-.52l.313-1.474A2.008 2.008 0 0112.864 1h2.185c.94 0 1.762.667 1.957 1.587l.311 1.474a10.4 10.4 0 011.317.546l1.281-.834a2.009 2.009 0 012.505.262l1.545 1.545c.665.665.774 1.718.262 2.505l-.845 1.299c.195.401.366.817.511 1.245l1.521.322A2.009 2.009 0 0127 12.908v2.184c0 .94-.667 1.763-1.586 1.957l-1.521.322c-.145.428-.316.845-.511 1.245l.845 1.299a2.01 2.01 0 01-.262 2.505l-1.545 1.545a2.01 2.01 0 01-2.505.262l-1.281-.834c-.425.212-.864.394-1.317.546l-.311 1.475A2.01 2.01 0 0115.049 27zm-1.13-17.735c-2.757 0-5 2.243-5 5 0 2.758 2.243 5 5 5s5-2.242 5-5c0-2.757-2.243-5-5-5zm0 11c-3.309 0-6-2.691-6-6 0-3.308 2.692-6 6-6s6 2.692 6 6c0 3.309-2.692 6-6 6z"}))),yi||(yi=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-settings_svg__a",fillRule:"evenodd"})))}var Ei,_i,Oi=n(45),ki=["title","titleId"];function Ci(){return Ci=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ci.apply(this,arguments)}function Ii(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,ki);return a.createElement("svg",Ci({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Ei||(Ei=a.createElement("defs",null,a.createElement("path",{id:"ico-signature_svg__a",d:"M23.999 24.76a1 1 0 01-.998.955l-.047-.001c-1.869-.085-3.282-.921-4.529-1.658-.73-.433-1.422-.841-2.163-1.091-.94-.317-1.913.235-3.037.873-1.022.58-2.078 1.18-3.283 1.18-.412 0-.782-.184-1.016-.503-.484-.661-.207-1.535.176-2.743.206-.65.688-2.17.476-2.522-.04-.047-.066-.06-.066-.06-.632.012-2.4 2.42-3.609 4.962a1 1 0 11-1.806-.859c.642-1.351 2.914-5.783 5.178-6.08.695-.09 1.346.176 1.832.749.947 1.115.392 2.868-.098 4.414l-.134.425c.432-.174.89-.434 1.363-.702 1.347-.765 2.874-1.631 4.661-1.03.942.317 1.756.8 2.545 1.265 1.147.679 2.23 1.32 3.602 1.382a1 1 0 01.953 1.045zM7.726 4.87a1.99 1.99 0 011.414-.585c.535 0 1.037.208 1.414.586l4.243 4.242-2.828 2.829-4.243-4.243a1.986 1.986 0 01-.586-1.414c0-.534.208-1.036.586-1.414zm9.981 12.647l2.666-2.666 1.494 4.148-4.16-1.482zm-.788-.625l-4.243-4.243 2.828-2.829 4.243 4.243-2.828 2.829zm-.56 2.268l4.837 1.723c.229.081.463.121.693.121.517 0 1.016-.2 1.393-.577.546-.545.72-1.345.456-2.087l-1.723-4.837-9.693-9.693c.39-.39 1.025-.39 1.415 0l4.596 4.596a.495.495 0 00.707 0 .5.5 0 000-.707l-4.596-4.596a2.003 2.003 0 00-2.829 0c-.008.008-.011.02-.019.028a3.965 3.965 0 00-2.456-.846 3.971 3.971 0 00-2.828 1.172 4.003 4.003 0 000 5.656L16.359 19.16z"}))),_i||(_i=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-signature_svg__a",fillRule:"evenodd"})))}var Si,Ri,Ai=["title","titleId"];function Pi(){return Pi=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Pi.apply(this,arguments)}function Ti(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Ai);return a.createElement("svg",Pi({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Si||(Si=a.createElement("defs",null,a.createElement("path",{id:"ico-face_2_svg__a",d:"M14 2.66c6.263 0 11.34 5.077 11.34 11.34S20.263 25.34 14 25.34 2.66 20.263 2.66 14 7.737 2.66 14 2.66zm0 1.96a9.38 9.38 0 10.001 18.761A9.38 9.38 0 0014 4.62zm-3.147 12.568l.298.04c.125.014.274.03.447.047l.18.017c1.558.14 3.21.156 4.834-.03l.535-.071.073.972.073-.006c-1.834.275-3.778.275-5.603.111l-.496-.05-.487-.06.146-.97zm-.04-6.831a1.783 1.783 0 11-.001 3.567 1.783 1.783 0 01.002-3.567zm6.374 0a1.783 1.783 0 110 3.567 1.783 1.783 0 010-3.567zm-6.373.98a.804.804 0 100 1.608.804.804 0 000-1.608zm6.373 0a.804.804 0 100 1.608.804.804 0 000-1.608z"}))),Ri||(Ri=a.createElement("use",{fill:"currentColor",fillRule:"nonzero",xlinkHref:"#ico-face_2_svg__a"})))}var Di,Mi,Ni=["title","titleId"];function Fi(){return Fi=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Fi.apply(this,arguments)}function Bi(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Ni);return a.createElement("svg",Fi({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Di||(Di=a.createElement("defs",null,a.createElement("path",{id:"ico-sort_svg__a",d:"M8 4.72L2.375 9.218l1.25 1.562L7 8.081V23h2V8.08l3.375 2.701 1.25-1.562L8 4.719zM19 5v14.919l-3.375-2.7-1.25 1.562 5.625 4.5 5.625-4.5-1.25-1.562-3.375 2.7V5h-2z"}))),Mi||(Mi=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-sort_svg__a",fillRule:"evenodd"})))}var ji,Li,zi=["title","titleId"];function Wi(){return Wi=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Wi.apply(this,arguments)}function Vi(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,zi);return a.createElement("svg",Wi({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,ji||(ji=a.createElement("defs",null,a.createElement("path",{id:"ico-text-input_svg__a",d:"M25 8c0-.551-.448-1-1-1H4c-.551 0-1 .449-1 1v12c0 .552.449 1 1 1h20a1 1 0 001-1V8zm2 0v12c0 1.654-1.346 3-3 3H4c-1.654 0-3-1.346-3-3V8c0-1.654 1.346-3 3-3h20c1.654 0 3 1.346 3 3zM7 10v8h.5a.5.5 0 010 1h-2a.5.5 0 010-1H6v-8h-.5a.5.5 0 010-1h2a.5.5 0 010 1H7z"}))),Li||(Li=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-text-input_svg__a",fillRule:"evenodd"})))}var Hi,Ui,Gi=n(69),qi=["title","titleId"];function Xi(){return Xi=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Xi.apply(this,arguments)}function Ki(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,qi);return a.createElement("svg",Xi({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,Hi||(Hi=a.createElement("defs",null,a.createElement("path",{id:"ico-upload_svg__a",d:"M19.625 14.78l-1.25-1.561-3.375 2.7V5h-2v10.92l-3.375-2.7-1.25 1.562L14 19.28l5.625-4.5zM24 21v2H4v-2h20z"}))),Ui||(Ui=a.createElement("use",{fill:"currentColor",transform:"rotate(180 14 14)",xlinkHref:"#ico-upload_svg__a",fillRule:"evenodd"})))}var $i,Zi,Yi=["title","titleId"];function Ji(){return Ji=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ji.apply(this,arguments)}function Qi(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Yi);return a.createElement("svg",Ji({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,$i||($i=a.createElement("defs",null,a.createElement("path",{id:"ico-verified_svg__a",d:"M23 4v9.489c0 3.453-1.533 6.354-4.557 8.621a16.31 16.31 0 01-3.154 1.84c-.355.159-.704.299-1.035.418l-.254.088-.254-.088a16.332 16.332 0 01-4.189-2.258C6.533 19.843 5 16.942 5 13.489V4h18zm-8.564 22.415c.095-.028.262-.082.492-.165.378-.135.774-.294 1.174-.473a18.273 18.273 0 003.54-2.067C23.198 21.045 25 17.606 25 13.488V2H3v11.489c0 4.117 1.803 7.556 5.357 10.221a18.303 18.303 0 004.715 2.54c.23.083.398.137.492.165l.436.127.436-.128zm-1.686-8.501l-4.707-4.707 1.414-1.414 3.293 3.293 6.293-6.293 1.414 1.414-7.707 7.707z"}))),Zi||(Zi=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-verified_svg__a",fillRule:"evenodd"})))}var es,ts,ns=["title","titleId"];function rs(){return rs=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},rs.apply(this,arguments)}function os(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,ns);return a.createElement("svg",rs({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,es||(es=a.createElement("defs",null,a.createElement("path",{id:"ico-video_svg__a",d:"M24 18.382l-4-2v-4.764l4-2v8.764zM18 19.5c0 .27-.229.5-.5.5h-13c-.271 0-.5-.23-.5-.5v-11c0-.271.229-.5.5-.5h13c.271 0 .5.229.5.5v11zM17.5 6C18.878 6 20 7.121 20 8.5v.882l4.552-2.277A1.002 1.002 0 0126 8v12a1.001 1.001 0 01-1.448.894L20 18.618v.882c0 1.378-1.122 2.5-2.5 2.5h-13A2.503 2.503 0 012 19.5v-11C2 7.121 3.122 6 4.5 6zM7 9c-1.103 0-2 .897-2 2s.897 2 2 2 2-.897 2-2-.897-2-2-2zm0 1a1.001 1.001 0 010 2 1.001 1.001 0 010-2z"}))),ts||(ts=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-video_svg__a",fillRule:"evenodd"})))}var as,is,ss=["title","titleId"];function us(){return us=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},us.apply(this,arguments)}function cs(e){var t=e.title,n=e.titleId,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,ss);return a.createElement("svg",us({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},r),t?a.createElement("title",{id:n},t):null,as||(as=a.createElement("defs",null,a.createElement("path",{id:"ico-yoti-icon_svg__a",d:"M22.02 22.02h-7.03v-3.055a5.057 5.057 0 004.06-4.95 5.059 5.059 0 00-4.06-4.952V5.98h7.03v16.04zM5.98 5.98h7.03v3.083c-2.312.461-4.06 2.506-4.06 4.951s1.748 4.49 4.06 4.951v3.055H5.98V5.98zM14 17.084a3.072 3.072 0 01-3.069-3.07A3.073 3.073 0 0114 10.945a3.073 3.073 0 013.07 3.07A3.074 3.074 0 0114 17.084zM4 24h20V4H4v20z"}))),is||(is=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-yoti-icon_svg__a",fillRule:"evenodd"})))}var ls=n(52),fs=n(53)},,,function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-clear_svg__a",d:"M18.707 10.707L15.414 14l3.293 3.293-1.414 1.414L14 15.414l-3.293 3.293-1.414-1.414L12.586 14l-3.293-3.293 1.414-1.414L14 12.586l3.293-3.293 1.414 1.414zM14 22c-4.41 0-8-3.589-8-8s3.59-8 8-8c4.411 0 8 3.589 8 8s-3.589 8-8 8zm0-18C8.486 4 4 8.486 4 14s4.486 10 10 10 10-4.486 10-10S19.514 4 14 4z"}))),o||(o=a.createElement("g",{fill:"none",fillRule:"evenodd"},a.createElement("path",{fill:"none",d:"M0 28h28V0H0z"}),a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-clear_svg__a"}))))}},,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-loading-spinner_svg__a",d:"M14 4v2a8 8 0 108 8h2c0 5.523-4.477 10-10 10S4 19.523 4 14 8.477 4 14 4z"}))),o||(o=a.createElement("g",{fill:"none",fillRule:"evenodd"},a.createElement("path",{fill:"none",d:"M0 28h28V0H0z"}),a.createElement("use",{fill:"currentColor",fillRule:"nonzero",xlinkHref:"#ico-loading-spinner_svg__a"}))))}},,function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-chevron-down_svg__a",d:"M14 18.981l-8.625-6.9 1.25-1.562 7.375 5.9 7.375-5.9 1.25 1.562z"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-chevron-down_svg__a",fillRule:"evenodd"})))}},,,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-calendar_svg__a",d:"M13 20a1 1 0 112 0 1 1 0 01-2 0zm-3.5 0a1 1 0 112 0 1 1 0 01-2 0zM6 20a1 1 0 112 0 1 1 0 01-2 0zm14-4a1 1 0 112 0 1 1 0 01-2 0zm-3.5 0a1 1 0 112 0 1 1 0 01-2 0zM13 16a1 1 0 112 0 1 1 0 01-2 0zm-3.5 0a1 1 0 112 0 1 1 0 01-2 0zM6 16a1 1 0 112 0 1 1 0 01-2 0zm14-4a1 1 0 112 0 1 1 0 01-2 0zm-3.5 0a1 1 0 112 0 1 1 0 01-2 0zM13 12a1 1 0 112 0 1 1 0 01-2 0zm11 10a1 1 0 01-1 1H5c-.551 0-1-.448-1-1V9h20v13zM4 7c0-.551.449-1 1-1h18c.552 0 1 .449 1 1v1H4V7zm10-4.41L16.257 4h-4.514L14 2.59zM23 4h-4.857l-3.878-2.424a.501.501 0 00-.53 0L9.857 4H5C3.345 4 2 5.346 2 7v15c0 1.654 1.345 3 3 3h18c1.654 0 3-1.346 3-3V7c0-1.654-1.346-3-3-3z"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-calendar_svg__a",fillRule:"evenodd"})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-hide_svg__a",d:"M24.256 5.165l-1.42-1.421L3.743 22.836l1.42 1.42 19.093-19.09zM11 14c0-1.654 1.346-3 3-3 .053 0 .104.005.157.008l1.66-1.66A4.945 4.945 0 0014 9c-2.757 0-5 2.243-5 5 0 .642.126 1.254.347 1.818l1.66-1.66C11.006 14.104 11 14.052 11 14zm6 0c0 1.654-1.346 3-3 3-.053 0-.105-.005-.157-.008l-1.66 1.661A4.961 4.961 0 0014 19c2.757 0 5-2.243 5-5 0-.642-.126-1.253-.347-1.818l-1.66 1.661c.002.052.007.104.007.157zM3.004 14C3.208 12.867 6.77 7 14 7c1.335 0 2.544.201 3.63.535l1.57-1.57A14.192 14.192 0 0014 5C5.333 5 1 12.282 1 14c0 .977 1.402 3.75 4.202 5.963l1.42-1.421C4.309 16.792 3.12 14.64 3.005 14zM27 14c0 1.719-4.333 9-13 9-1.954 0-3.686-.372-5.2-.965l1.57-1.57C11.455 20.8 12.664 21 14 21c7.229 0 10.791-5.867 10.996-7-.116-.64-1.304-2.791-3.62-4.542l1.422-1.42C25.598 10.25 27 13.022 27 14z"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-hide_svg__a",fillRule:"evenodd"})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-show_svg__a",d:"M14 11c-1.655 0-3 1.346-3 3s1.345 3 3 3 3-1.346 3-3-1.345-3-3-3m0 8c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5M3.004 14c.204 1.133 3.767 7 10.996 7 7.229 0 10.791-5.867 10.996-7-.204-1.133-3.767-7-10.996-7-7.229 0-10.791 5.867-10.996 7M14 23c-8.667 0-13-7.281-13-9 0-1.719 4.333-9 13-9s13 7.281 13 9c0 1.719-4.333 9-13 9"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-show_svg__a",fillRule:"evenodd"})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-information_svg__a",d:"M15.25 10a1.25 1.25 0 11-2.5 0 1.25 1.25 0 012.5 0zM13 19.5h2v-7h-2v7zm1 3.5c-4.962 0-9-4.038-9-9s4.038-9 9-9 9 4.038 9 9-4.038 9-9 9zm0-20C7.925 3 3 7.925 3 14s4.925 11 11 11 11-4.925 11-11S20.075 3 14 3z"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-information_svg__a",fillRule:"evenodd"})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-darker_svg__a",d:"M20.364 9.05L18.95 7.636l2.828-2.828 1.414 1.414-2.828 2.828zm-12.728 9.9l1.414 1.414-2.828 2.828-1.414-1.414 2.828-2.828zm12.728 0l2.828 2.828-1.414 1.414-2.828-2.828 1.414-1.414zM7.636 9.05L4.808 6.222l1.414-1.414L9.05 7.636 7.636 9.05zM22 15h4v-2h-4v2zM2 15h4v-2H2v2zm11 11h2v-4h-2v4zm0-20h2V2h-2v4zm1 2c-3.308 0-6 2.692-6 6s2.692 6 6 6 6-2.692 6-6-2.692-6-6-6z"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-darker_svg__a",fillRule:"evenodd"})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-external-link_svg__a",d:"M13 5v2H7c-.551 0-1 .449-1 1v13c0 .552.449 1 1 1h13a1 1 0 001-1v-6h2v6c0 1.654-1.346 3-3 3H7c-1.654 0-3-1.346-3-3V8c0-1.654 1.346-3 3-3h6zm12-2v8h-2V6.414l-8.293 8.293-1.414-1.414L21.586 5H17V3h8z"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-external-link_svg__a",fillRule:"evenodd"})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-lighter_svg__a",d:"M20.364 9.05L18.95 7.636l2.828-2.828 1.414 1.414-2.828 2.828zm-12.728 9.9l1.414 1.414-2.828 2.828-1.414-1.414 2.828-2.828zm12.728 0l2.828 2.828-1.414 1.414-2.828-2.828 1.414-1.414zM7.636 9.05L4.808 6.222l1.414-1.414L9.05 7.636 7.636 9.05zM22 15h4v-2h-4v2zM2 15h4v-2H2v2zm11 11h2v-4h-2v4zm0-20h2V2h-2v4zm1 12c-2.206 0-4-1.794-4-4s1.794-4 4-4 4 1.794 4 4-1.794 4-4 4zm0-10c-3.308 0-6 2.692-6 6s2.692 6 6 6 6-2.692 6-6-2.692-6-6-6z"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-lighter_svg__a",fillRule:"evenodd"})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-rotate-anticlockwise_svg__a",d:"M14.682 4.303l1.24-1.752.103-.146-1.633-1.155-2.905 4.106 2.763 3.988.101.146 1.644-1.139-1.414-2.042C19.273 6.611 23 10.513 23 15.28c0 4.964-4.037 9-9 9s-9-4.036-9-9H3c0 6.066 4.934 11 11 11 6.065 0 11-4.934 11-11 0-5.835-4.57-10.622-10.318-10.976"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-rotate-anticlockwise_svg__a",fillRule:"evenodd"})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-rotate-clockwise_svg__a",d:"M14.682 4.303l1.24-1.752.103-.146-1.633-1.155-2.904 4.106 2.762 3.988.101.146 1.644-1.139-1.414-2.042C19.273 6.611 23 10.513 23 15.28c0 4.964-4.037 9-9 9s-9-4.036-9-9H3c0 6.066 4.934 11 11 11s11-4.934 11-11c0-5.835-4.569-10.622-10.318-10.976"}))),o||(o=a.createElement("use",{fill:"currentColor",transform:"matrix(-1 0 0 1 28 0)",xlinkHref:"#ico-rotate-clockwise_svg__a",fillRule:"evenodd"})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-zoom-in_svg__a",d:"M16.981 11h2v2h-2v2h-2v-2h-2v-2h2V9h2v2zm3.242 5.242A5.951 5.951 0 0115.982 18a5.956 5.956 0 01-4.242-1.758 6.005 6.005 0 010-8.485A5.957 5.957 0 0115.98 6c1.603 0 3.11.624 4.243 1.758a6.007 6.007 0 010 8.485zm1.415-9.899C20.127 4.832 18.117 4 15.98 4s-4.146.832-5.656 2.343c-2.88 2.88-3.095 7.422-.659 10.558L4.96 21.607l1.415 1.414 4.705-4.706A7.936 7.936 0 0015.981 20a7.944 7.944 0 005.656-2.343c3.12-3.12 3.12-8.194 0-11.314z"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-zoom-in_svg__a",fillRule:"evenodd"})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-zoom-out_svg__a",d:"M12.981 13h6v-2h-6v2zm7.243 3.242v.001A5.964 5.964 0 0115.98 18a5.958 5.958 0 01-4.243-1.758 6.005 6.005 0 010-8.485A5.974 5.974 0 0115.981 6c1.603 0 3.109.625 4.243 1.758a6.007 6.007 0 010 8.485zm1.413-9.899A7.949 7.949 0 0015.982 4a7.948 7.948 0 00-5.657 2.343c-2.879 2.88-3.094 7.422-.658 10.558L4.96 21.607l1.414 1.414 4.706-4.706A7.936 7.936 0 0015.981 20a7.945 7.945 0 005.656-2.343c3.12-3.12 3.12-8.194 0-11.314z"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-zoom-out_svg__a",fillRule:"evenodd"})))}},,,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-chevron-left_svg__a",d:"M15.719 22.625L8.819 14l6.9-8.625 1.562 1.25-5.9 7.375 5.9 7.375z"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-chevron-left_svg__a",fillRule:"evenodd"})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-chevron-right_svg__a",d:"M12.281 22.625l-1.562-1.25 5.9-7.375-5.9-7.375 1.562-1.25 6.9 8.625z"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-chevron-right_svg__a",fillRule:"evenodd"})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r,o,a=n(0),i=["title","titleId"];function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e){var t=e.title,n=e.titleId,u=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i);return a.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28","aria-labelledby":n},u),t?a.createElement("title",{id:n},t):null,r||(r=a.createElement("defs",null,a.createElement("path",{id:"ico-tick_svg__a",d:"M12 20.414l-6.707-6.707 1.414-1.414L12 17.586l9.293-9.293 1.414 1.414z"}))),o||(o=a.createElement("use",{fill:"currentColor",xlinkHref:"#ico-tick_svg__a",fillRule:"evenodd"})))}}])},9669:(e,t,n)=>{e.exports=n(1609)},5448:(e,t,n)=>{"use strict";var r=n(4867),o=n(6026),a=n(4372),i=n(5327),s=n(4097),u=n(4109),c=n(7985),l=n(5061),f=n(5655),h=n(5263);e.exports=function(e){return new Promise((function(t,n){var p,d=e.data,v=e.headers,m=e.responseType;function g(){e.cancelToken&&e.cancelToken.unsubscribe(p),e.signal&&e.signal.removeEventListener("abort",p)}r.isFormData(d)&&delete v["Content-Type"];var y=new XMLHttpRequest;if(e.auth){var b=e.auth.username||"",w=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";v.Authorization="Basic "+btoa(b+":"+w)}var x=s(e.baseURL,e.url);function E(){if(y){var r="getAllResponseHeaders"in y?u(y.getAllResponseHeaders()):null,a={data:m&&"text"!==m&&"json"!==m?y.response:y.responseText,status:y.status,statusText:y.statusText,headers:r,config:e,request:y};o((function(e){t(e),g()}),(function(e){n(e),g()}),a),y=null}}if(y.open(e.method.toUpperCase(),i(x,e.params,e.paramsSerializer),!0),y.timeout=e.timeout,"onloadend"in y?y.onloadend=E:y.onreadystatechange=function(){y&&4===y.readyState&&(0!==y.status||y.responseURL&&0===y.responseURL.indexOf("file:"))&&setTimeout(E)},y.onabort=function(){y&&(n(l("Request aborted",e,"ECONNABORTED",y)),y=null)},y.onerror=function(){n(l("Network Error",e,null,y)),y=null},y.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||f.transitional;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(l(t,e,r.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",y)),y=null},r.isStandardBrowserEnv()){var _=(e.withCredentials||c(x))&&e.xsrfCookieName?a.read(e.xsrfCookieName):void 0;_&&(v[e.xsrfHeaderName]=_)}"setRequestHeader"in y&&r.forEach(v,(function(e,t){void 0===d&&"content-type"===t.toLowerCase()?delete v[t]:y.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(y.withCredentials=!!e.withCredentials),m&&"json"!==m&&(y.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&y.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&y.upload&&y.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(p=function(e){y&&(n(!e||e&&e.type?new h("canceled"):e),y.abort(),y=null)},e.cancelToken&&e.cancelToken.subscribe(p),e.signal&&(e.signal.aborted?p():e.signal.addEventListener("abort",p))),d||(d=null),y.send(d)}))}},1609:(e,t,n)=>{"use strict";var r=n(4867),o=n(1849),a=n(321),i=n(7185);var s=function e(t){var n=new a(t),s=o(a.prototype.request,n);return r.extend(s,a.prototype,n),r.extend(s,n),s.create=function(n){return e(i(t,n))},s}(n(5655));s.Axios=a,s.Cancel=n(5263),s.CancelToken=n(4972),s.isCancel=n(6502),s.VERSION=n(7288).version,s.all=function(e){return Promise.all(e)},s.spread=n(8713),s.isAxiosError=n(6268),e.exports=s,e.exports.default=s},5263:e=>{"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},4972:(e,t,n)=>{"use strict";var r=n(5263);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t<r;t++)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e){n.reason||(n.reason=new r(e),t(n.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},o.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},6502:e=>{"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},321:(e,t,n)=>{"use strict";var r=n(4867),o=n(5327),a=n(782),i=n(3572),s=n(7185),u=n(4875),c=u.validators;function l(e){this.defaults=e,this.interceptors={request:new a,response:new a}}l.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=s(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&u.assertOptions(t,{silentJSONParsing:c.transitional(c.boolean),forcedJSONParsing:c.transitional(c.boolean),clarifyTimeoutError:c.transitional(c.boolean)},!1);var n=[],r=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(r=r&&t.synchronous,n.unshift(t.fulfilled,t.rejected))}));var o,a=[];if(this.interceptors.response.forEach((function(e){a.push(e.fulfilled,e.rejected)})),!r){var l=[i,void 0];for(Array.prototype.unshift.apply(l,n),l=l.concat(a),o=Promise.resolve(e);l.length;)o=o.then(l.shift(),l.shift());return o}for(var f=e;n.length;){var h=n.shift(),p=n.shift();try{f=h(f)}catch(d){p(d);break}}try{o=i(f)}catch(d){return Promise.reject(d)}for(;a.length;)o=o.then(a.shift(),a.shift());return o},l.prototype.getUri=function(e){return e=s(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},r.forEach(["delete","get","head","options"],(function(e){l.prototype[e]=function(t,n){return this.request(s(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(e){l.prototype[e]=function(t,n,r){return this.request(s(r||{},{method:e,url:t,data:n}))}})),e.exports=l},782:(e,t,n)=>{"use strict";var r=n(4867);function o(){this.handlers=[]}o.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){r.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},4097:(e,t,n)=>{"use strict";var r=n(1793),o=n(7303);e.exports=function(e,t){return e&&!r(t)?o(e,t):t}},5061:(e,t,n)=>{"use strict";var r=n(481);e.exports=function(e,t,n,o,a){var i=new Error(e);return r(i,t,n,o,a)}},3572:(e,t,n)=>{"use strict";var r=n(4867),o=n(8527),a=n(6502),i=n(5655),s=n(5263);function u(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new s("canceled")}e.exports=function(e){return u(e),e.headers=e.headers||{},e.data=o.call(e,e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||i.adapter)(e).then((function(t){return u(e),t.data=o.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return a(t)||(u(e),t&&t.response&&(t.response.data=o.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},481:e=>{"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}},7185:(e,t,n)=>{"use strict";var r=n(4867);e.exports=function(e,t){t=t||{};var n={};function o(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function a(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:o(void 0,e[n]):o(e[n],t[n])}function i(e){if(!r.isUndefined(t[e]))return o(void 0,t[e])}function s(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:o(void 0,e[n]):o(void 0,t[n])}function u(n){return n in t?o(e[n],t[n]):n in e?o(void 0,e[n]):void 0}var c={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:u};return r.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=c[e]||a,o=t(e);r.isUndefined(o)&&t!==u||(n[e]=o)})),n}},6026:(e,t,n)=>{"use strict";var r=n(5061);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},8527:(e,t,n)=>{"use strict";var r=n(4867),o=n(5655);e.exports=function(e,t,n){var a=this||o;return r.forEach(n,(function(n){e=n.call(a,e,t)})),e}},5655:(e,t,n)=>{"use strict";var r=n(4867),o=n(6016),a=n(481),i={"Content-Type":"application/x-www-form-urlencoded"};function s(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var u,c={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(u=n(5448)),u),transformRequest:[function(e,t){return o(t,"Accept"),o(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(s(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)||t&&"application/json"===t["Content-Type"]?(s(t,"application/json"),function(e,t,n){if(r.isString(e))try{return(t||JSON.parse)(e),r.trim(e)}catch(o){if("SyntaxError"!==o.name)throw o}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||c.transitional,n=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,i=!n&&"json"===this.responseType;if(i||o&&r.isString(e)&&e.length)try{return JSON.parse(e)}catch(s){if(i){if("SyntaxError"===s.name)throw a(s,this,"E_JSON_PARSE");throw s}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){c.headers[e]=r.merge(i)})),e.exports=c},7288:e=>{e.exports={version:"0.24.0"}},1849:e=>{"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},5327:(e,t,n)=>{"use strict";var r=n(4867);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var a;if(n)a=n(t);else if(r.isURLSearchParams(t))a=t.toString();else{var i=[];r.forEach(t,(function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,(function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),i.push(o(t)+"="+o(e))})))})),a=i.join("&")}if(a){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}},7303:e=>{"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},4372:(e,t,n)=>{"use strict";var r=n(4867);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,o,a,i){var s=[];s.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),r.isString(o)&&s.push("path="+o),r.isString(a)&&s.push("domain="+a),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},1793:e=>{"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},6268:e=>{"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},7985:(e,t,n)=>{"use strict";var r=n(4867);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=o(window.location.href),function(t){var n=r.isString(t)?o(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},6016:(e,t,n)=>{"use strict";var r=n(4867);e.exports=function(e,t){r.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))}},4109:(e,t,n)=>{"use strict";var r=n(4867),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,a,i={};return e?(r.forEach(e.split("\n"),(function(e){if(a=e.indexOf(":"),t=r.trim(e.substr(0,a)).toLowerCase(),n=r.trim(e.substr(a+1)),t){if(i[t]&&o.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([n]):i[t]?i[t]+", "+n:n}})),i):i}},8713:e=>{"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},4875:(e,t,n)=>{"use strict";var r=n(7288).version,o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var a={};o.transitional=function(e,t,n){function o(e,t){return"[Axios v"+r+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,i){if(!1===e)throw new Error(o(r," has been removed"+(t?" in "+t:"")));return t&&!a[r]&&(a[r]=!0,console.warn(o(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,i)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),o=r.length;o-- >0;){var a=r[o],i=t[a];if(i){var s=e[a],u=void 0===s||i(s,a,e);if(!0!==u)throw new TypeError("option "+a+" must be "+u)}else if(!0!==n)throw Error("Unknown option "+a)}},validators:o}},4867:(e,t,n)=>{"use strict";var r=n(1849),o=Object.prototype.toString;function a(e){return"[object Array]"===o.call(e)}function i(e){return void 0===e}function s(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===o.call(e)}function l(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),a(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:a,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:function(e){return null!==e&&!i(e)&&null!==e.constructor&&!i(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isPlainObject:u,isUndefined:i,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:c,isStream:function(e){return s(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:l,merge:function e(){var t={};function n(n,r){u(t[r])&&u(n)?t[r]=e(t[r],n):u(n)?t[r]=e({},n):a(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)l(arguments[r],n);return t},extend:function(e,t,n){return l(t,(function(t,o){e[o]=n&&"function"==typeof t?r(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},235:e=>{e.exports={messages:{"camera-loading-feedback-message":"...جارٍ تحضير الكاميرا","face-scan-loading-feedback-message":"...جارٍ التحضير لمسح الوجه","hold-still-feedback-message":"الرجاء البقاء ساكنًا","image-too-bright-feedback-message":"ابتعِد عن الضوء المباشر","image-too-dark-feedback-message":"انتقل إلى منطقة أكثر إضاءة","move-back-feedback-message":"ارجع للوراء","move-center-feedback-message":"ضع وجهك في الإطار","move-closer-feedback-message":"اقترب أكثر","one-face-only-feedback-message":"يُسمح بوجه واحد فقط"}}},992:e=>{e.exports={messages:{"camera-loading-feedback-message":"Příprava fotoaparátu…","face-scan-loading-feedback-message":"Příprava skenování obličeje…","hold-still-feedback-message":"Stůjte klidně","image-too-bright-feedback-message":"Posuňte se dál z přímého světla","image-too-dark-feedback-message":"Posuňte se na světlejší místo","move-back-feedback-message":"Posuňte se dál","move-center-feedback-message":"Umístěte svůj obličej do rámečku","move-closer-feedback-message":"Posuňte se blíž","one-face-only-feedback-message":"Je povolen pouze jeden obličej"}}},7555:e=>{e.exports={messages:{"camera-loading-feedback-message":"Forbereder kamera...","face-scan-loading-feedback-message":"Forbereder ansigtsscanning...","hold-still-feedback-message":"Stå stille","image-too-bright-feedback-message":"Flyt væk fra direkte lys","image-too-dark-feedback-message":"Flyt til et lysere område","move-back-feedback-message":"Flyt dig tilbage","move-center-feedback-message":"Hold dit ansigt i rammen","move-closer-feedback-message":"Flyt dig tættere på","one-face-only-feedback-message":"Kun ét ansigt er tilladt"}}},4973:e=>{e.exports={messages:{"camera-loading-feedback-message":"Kamera lädt...","face-scan-loading-feedback-message":"Gesichtsscan wird vorbereitet","hold-still-feedback-message":"Bitte still halten","image-too-bright-feedback-message":"Vermeiden Sie direkte Lichteinstrahlung","image-too-dark-feedback-message":"Wählen Sie einen helleren Ort","move-back-feedback-message":"Gehen Sie zurück","move-center-feedback-message":"Plazieren Sie Ihr Gesicht in die Mitte","move-closer-feedback-message":"Kommen Sie näher","one-face-only-feedback-message":"Nur ein Gesicht ist erlaubt"}}},8964:e=>{e.exports={messages:{"camera-loading-feedback-message":"Preparing camera...","face-scan-loading-feedback-message":"Preparing face scan...","hold-still-feedback-message":"Please hold still","image-too-bright-feedback-message":"Move away from direct light","image-too-dark-feedback-message":"Move to a brighter area","move-back-feedback-message":"Move back","move-center-feedback-message":"Place your face in the frame","move-closer-feedback-message":"Move closer","one-face-only-feedback-message":"Only one face allowed"}}},9827:e=>{e.exports={messages:{"camera-loading-feedback-message":"La cámara se está preparando...","face-scan-loading-feedback-message":"Preparando escaneado facial...","hold-still-feedback-message":"Quédate quieto un momento","image-too-bright-feedback-message":"Aléjate de la luz directa","image-too-dark-feedback-message":"Muévete a un área más iluminada","move-back-feedback-message":"Aléjate","move-center-feedback-message":"Colócate en el centro","move-closer-feedback-message":"Acércate","one-face-only-feedback-message":"Enfócate solo a ti"}}},4413:e=>{e.exports={messages:{"camera-loading-feedback-message":"La cámara se está preparando...","face-scan-loading-feedback-message":"Preparando escaneado facial...","hold-still-feedback-message":"Aguanta un momento","image-too-bright-feedback-message":"Aléjate de la luz directa","image-too-dark-feedback-message":"Muévete a un área más iluminada","move-back-feedback-message":"Retírate","move-center-feedback-message":"Colócate en el centro","move-closer-feedback-message":"Acércate","one-face-only-feedback-message":"Enfócate solo a ti"}}},606:e=>{e.exports={messages:{"camera-loading-feedback-message":"Kaamera ettevalmistamine...","face-scan-loading-feedback-message":"Näoskanni ettevalmistamine...","hold-still-feedback-message":"Ärge liigutage","image-too-bright-feedback-message":"Liikuge otsesest valgusest eemale","image-too-dark-feedback-message":"Liikuge paremini valgustatud kohta","move-back-feedback-message":"Liikuge kaugemale","move-center-feedback-message":"Paigutage oma nägu kaadrisse","move-closer-feedback-message":"Liikuge lähemale","one-face-only-feedback-message":"Ainult üks nägu on lubatud"}}},3090:e=>{e.exports={messages:{"camera-loading-feedback-message":"Valmistellaan kameraa...","face-scan-loading-feedback-message":"Valmistellaan kasvojen skannausta...","hold-still-feedback-message":"Pysy paikallasi","image-too-bright-feedback-message":"Siirry pois suorasta valosta","image-too-dark-feedback-message":"Siirry kirkkaampaan valoon","move-back-feedback-message":"Siirry taaksepäin","move-center-feedback-message":"Aseta kasvot keskelle kehystä","move-closer-feedback-message":"Siirry lähemmäksi","one-face-only-feedback-message":"Vain yhdet kasvot on sallittu"}}},2443:e=>{e.exports={messages:{"camera-loading-feedback-message":"Préparation de l'appareil...","face-scan-loading-feedback-message":"Préparation du scan...","hold-still-feedback-message":"Veuillez ne pas bouger","image-too-bright-feedback-message":"Éloignez-vous de toute source de lumière directe","image-too-dark-feedback-message":"Déplacez-vous à un endroit plus lumineux","move-back-feedback-message":"Reculez","move-center-feedback-message":"Placez votre visage dans le cadre","move-closer-feedback-message":"Approchez-vous","one-face-only-feedback-message":"Un seul visage permis"}}},1471:e=>{e.exports={messages:{"camera-loading-feedback-message":"कैमरे को तैयार किया जा रहा है...","face-scan-loading-feedback-message":"चेहरा स्कैन करने की तैयारी हो रही है…","hold-still-feedback-message":"कृपया हिले डुले नहीं","image-too-bright-feedback-message":"सीधी रोशनी से दूर हटें","image-too-dark-feedback-message":"ज़्यादा रोशनी वाली जगह पर जाएं","move-back-feedback-message":"पीछे जाएं","move-center-feedback-message":"अपने चेहरे को फ़्रेम में लाएं","move-closer-feedback-message":"थोड़ा करीब आएँ","one-face-only-feedback-message":"सिर्फ़ एक चेहरे की अनुमति है"}}},8048:e=>{e.exports={messages:{"camera-loading-feedback-message":"Mempersiapkan kamera...","face-scan-loading-feedback-message":"Mempersiapkan pemindaian wajah...","hold-still-feedback-message":"Harap diam","image-too-bright-feedback-message":"Menjauh dari cahaya langsung","image-too-dark-feedback-message":"Pindah ke area yang lebih terang","move-back-feedback-message":"Mundur","move-center-feedback-message":"Tempatkan wajah dalam bingkai","move-closer-feedback-message":"Lebih dekat","one-face-only-feedback-message":"Hanya boleh satu wajah"}}},5626:e=>{e.exports={messages:{"camera-loading-feedback-message":"Caricamento della camera...","face-scan-loading-feedback-message":"Caricamento dello scan facciale...","hold-still-feedback-message":"Rimani fermo","image-too-bright-feedback-message":"Spostati dalla luce diretta","image-too-dark-feedback-message":"Spostati in una zona più illuminata","move-back-feedback-message":"Allontanati","move-center-feedback-message":"Posiziona la tua faccia nel riquadro","move-closer-feedback-message":"Avvicinati","one-face-only-feedback-message":"Solo una faccia è permessa"}}},8828:e=>{e.exports={messages:{"camera-loading-feedback-message":"カメラ準備中...","face-scan-loading-feedback-message":"フェイススキャン準備中...","hold-still-feedback-message":"動かないでください","image-too-bright-feedback-message":"直射光を避けてください","image-too-dark-feedback-message":"もっと明るい場所に移動してください","move-back-feedback-message":"離れてください","move-center-feedback-message":"顔を枠内に収めてください","move-closer-feedback-message":"近づいてください","one-face-only-feedback-message":"認識できる顔は1つだけです"}}},8916:e=>{e.exports={messages:{"camera-loading-feedback-message":"카메라 준비 중...","face-scan-loading-feedback-message":"얼굴 스캔 준비 중...","hold-still-feedback-message":"움직이지 마세요","image-too-bright-feedback-message":"직접광에서 멀리 떨어지세요","image-too-dark-feedback-message":"더 밝은 곳으로 이동하세요","move-back-feedback-message":"뒤로 물러서세요","move-center-feedback-message":"얼굴을 프레임에 맞추세요","move-closer-feedback-message":"더 가까이 오세요","one-face-only-feedback-message":"한 사람의 얼굴만 허용됩니다"}}},8868:e=>{e.exports={messages:{"camera-loading-feedback-message":"Ruošiamas fotoaparatas...","face-scan-loading-feedback-message":"Ruošiamasi nuskaityti veidą...","hold-still-feedback-message":"Nejudėkite","image-too-bright-feedback-message":"Paeikite toliau nuo tiesioginių saulės spindulių","image-too-dark-feedback-message":"Pereikite į šviesesnę vietą","move-back-feedback-message":"Paeikite atgal","move-center-feedback-message":"Laikykite veidą rėmelyje","move-closer-feedback-message":"Prieikite arčiau","one-face-only-feedback-message":"Gali būti tik vienas veidas"}}},8706:e=>{e.exports={messages:{"camera-loading-feedback-message":"Sagatavo kameru...","face-scan-loading-feedback-message":"Gatavojas sejas skenēšanai...","hold-still-feedback-message":"Nekustieties","image-too-bright-feedback-message":"Pavirziet tur, kur nav tiešas saules gaismas","image-too-dark-feedback-message":"Pavirzieties uz gaišāku zonu","move-back-feedback-message":"Atvirzieties","move-center-feedback-message":"Ietilpiniet seju rāmī","move-closer-feedback-message":"Pavirzieties tuvāk","one-face-only-feedback-message":"Atļauta tikai viena seja"}}},9194:e=>{e.exports={messages:{"camera-loading-feedback-message":"Menyediakan kamera...","face-scan-loading-feedback-message":"Menyediakan imbasan muka...","hold-still-feedback-message":"Sila jangan bergerak","image-too-bright-feedback-message":"Jauhkan diri daripada cahaya terus","image-too-dark-feedback-message":"Bergerak ke kawasan yang lebih terang","move-back-feedback-message":"Berundur","move-center-feedback-message":"Letakkan muka anda dalam bingkai","move-closer-feedback-message":"Bergerak lebih dekat","one-face-only-feedback-message":"Hanya satu muka dibenarkan"}}},2643:e=>{e.exports={messages:{"camera-loading-feedback-message":"Klargjør kameraet ...","face-scan-loading-feedback-message":"Klargjør ansiktsskanning ...","hold-still-feedback-message":"Hold deg i ro","image-too-bright-feedback-message":"Gå vekk fra direkte lys","image-too-dark-feedback-message":"Gå til et lysere område","move-back-feedback-message":"Gå bakover","move-center-feedback-message":"Hold ansiktet ditt i rammen","move-closer-feedback-message":"Beveg deg forover","one-face-only-feedback-message":"Kun ett ansikt tillat"}}},2262:e=>{e.exports={messages:{"camera-loading-feedback-message":"Bezig met camera voorbereiden...","face-scan-loading-feedback-message":"Bezig met gezichtsscan voorbereiden...","hold-still-feedback-message":"Sta stil","image-too-bright-feedback-message":"Niet in direct licht plaatsen","image-too-dark-feedback-message":"Op een lichtere plaats zetten","move-back-feedback-message":"Ga achteruit","move-center-feedback-message":"Plaats je gezicht in het kader","move-closer-feedback-message":"Kom dichter bij","one-face-only-feedback-message":"Slechts één gezicht toegestaan"}}},7162:e=>{e.exports={messages:{"camera-loading-feedback-message":"Przygotowywanie aparatu...","face-scan-loading-feedback-message":"Przygotowywanie skanu twarzy...","hold-still-feedback-message":"Nie ruszaj się","image-too-bright-feedback-message":"Przejdź do lepiej oświetlonego miejsca","image-too-dark-feedback-message":"Odsuń się, aby światło nie padało na Ciebie bezpośrednio","move-back-feedback-message":"Cofnij się","move-center-feedback-message":"Umieść twarz w ramce","move-closer-feedback-message":"Przybliż się","one-face-only-feedback-message":"Dozwolona jest tylko jedna twarz"}}},8826:e=>{e.exports={messages:{"camera-loading-feedback-message":"Preparando câmera...","face-scan-loading-feedback-message":"Preparando scan do rosto...","hold-still-feedback-message":"Segure firme","image-too-bright-feedback-message":"Afaste-se da iluminação direta.","image-too-dark-feedback-message":"Vá para uma área mais iluminada","move-back-feedback-message":"Afaste-se","move-center-feedback-message":"Coloque seu rosto no quadro","move-closer-feedback-message":"Aproxime-se","one-face-only-feedback-message":"Somente um rosto permitido"}}},4157:e=>{e.exports={messages:{"camera-loading-feedback-message":"Se pregătește camera...","face-scan-loading-feedback-message":"Se pregătește scanarea feței...","hold-still-feedback-message":"Vă rugăm nu vă mișcați","image-too-bright-feedback-message":"Îndepărtați-vă de lumina directă","image-too-dark-feedback-message":"Duceți-vă într-o zonă mai luminoasă","move-back-feedback-message":"Mergeți mai în spate","move-center-feedback-message":"Poziționați fața în cadru","move-closer-feedback-message":"Veniți mai aproape","one-face-only-feedback-message":"Este permisă doar o singură față"}}},5632:e=>{e.exports={messages:{"camera-loading-feedback-message":"Подготовка камеры...","face-scan-loading-feedback-message":"Подготовка к сканированию лица...","hold-still-feedback-message":"Не двигайтесь","image-too-bright-feedback-message":"Отодвиньтесь от прямого света","image-too-dark-feedback-message":"Перейдите в более светлое место","move-back-feedback-message":"Отодвиньтесь назад","move-center-feedback-message":"Поместите лицо в рамку","move-closer-feedback-message":"Придвиньтесь ближе","one-face-only-feedback-message":"Допускается только одно лицо"}}},8646:e=>{e.exports={messages:{"camera-loading-feedback-message":"Förbereder kameran …","face-scan-loading-feedback-message":"Förbereder ansiktsskanning ...","hold-still-feedback-message":"Vänligen håll still","image-too-bright-feedback-message":"Avlägsna dig från direkt ljus","image-too-dark-feedback-message":"Flytta till ett ljusare område","move-back-feedback-message":"Backa","move-center-feedback-message":"Placera ditt ansikte i ramen","move-closer-feedback-message":"Flytta dig närmare","one-face-only-feedback-message":"Endast ett ansikte tillåtet"}}},9843:e=>{e.exports={messages:{"camera-loading-feedback-message":"กำลังเตรียมกล้อง...","face-scan-loading-feedback-message":"กำลังเตรียมการสแกนใบหน้า...","hold-still-feedback-message":"โปรดหยุดนิ่ง","image-too-bright-feedback-message":"ขยับออกห่างจากแสงโดยตรง","image-too-dark-feedback-message":"ขยับไปยังพื้นที่ที่สว่างกว่า","move-back-feedback-message":"ถอยหลัง","move-center-feedback-message":"ขยับให้ใบหน้าของคุณอยู่ในเฟรม","move-closer-feedback-message":"ขยับเข้ามาใกล้ขึ้น","one-face-only-feedback-message":"อนุญาตให้มีเพียงใบหน้าเดียวเท่านั้น"}}},4829:e=>{e.exports={messages:{"camera-loading-feedback-message":"Kamera hazırlanıyor...","face-scan-loading-feedback-message":"Yüz tarama hazırlanıyor...","hold-still-feedback-message":"Lütfen kıpırdamadan bekleyin","image-too-bright-feedback-message":"Direkt ışıktan uzaklaşın","image-too-dark-feedback-message":"Daha aydınlık bir alana geçin","move-back-feedback-message":"Uzaklaşın","move-center-feedback-message":"Yüzünüzü çerçeveye yerleştirin","move-closer-feedback-message":"Yakınlaşın","one-face-only-feedback-message":"Yalnızca bir yüze izin verilir"}}},99:e=>{e.exports={messages:{"camera-loading-feedback-message":"Підготовка камери...","face-scan-loading-feedback-message":"Підготовка до сканування обличчя...","hold-still-feedback-message":"Не рухайтеся","image-too-bright-feedback-message":"Відійдіть від прямого світла","image-too-dark-feedback-message":"Підійдіть у світліше місце","move-back-feedback-message":"Відійдіть назад","move-center-feedback-message":"Помістіть своє обличчя в рамку","move-closer-feedback-message":"Підійдіть ближче","one-face-only-feedback-message":"Дозволяється лише одне обличчя"}}},8698:e=>{e.exports={messages:{"camera-loading-feedback-message":"Đang chuẩn bị máy ảnh...","face-scan-loading-feedback-message":"Đang chuẩn bị quét khuôn mặt...","hold-still-feedback-message":"Vui lòng giữ yên","image-too-bright-feedback-message":"Di chuyển khỏi chỗ ánh sáng chiếu trực tiếp","image-too-dark-feedback-message":"Di chuyển đến chỗ sáng hơn","move-back-feedback-message":"Lùi lại","move-center-feedback-message":"Giữ khuôn mặt của bạn ở trong khung hình","move-closer-feedback-message":"Di chuyển lại gần hơn","one-face-only-feedback-message":"Chỉ cho phép một khuôn mặt"}}},4184:(e,t)=>{var n;!function(){"use strict";var r={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var a=typeof n;if("string"===a||"number"===a)e.push(n);else if(Array.isArray(n)&&n.length){var i=o.apply(null,n);i&&e.push(i)}else if("object"===a)for(var s in n)r.call(n,s)&&n[s]&&e.push(s)}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(n=function(){return o}.apply(t,[]))||(e.exports=n)}()},2703:(e,t,n)=>{"use strict";var r=n(414);function o(){}function a(){}a.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,a,i){if(i!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:o};return n.PropTypes=n,n}},5697:(e,t,n)=>{e.exports=n(2703)()},414:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},9497:e=>{"use strict";e.exports=require("react")},4902:()=>{},522:()=>{},753:()=>{},8730:()=>{}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";n.r(r),n.d(r,{CAPTURE_METHOD:()=>d,COUNTDOWN_MODES:()=>y,ERROR_CODE:()=>e,FORMAT_TYPE:()=>p,IMAGE_TYPE:()=>v,LANGUAGE_CODE:()=>h,QUALITY_TYPE:()=>m,default:()=>kC});const e={NO_CAMERA_PERMISSION:"NO_CAMERA_PERMISSION",NO_CAMERA:"NO_CAMERA",UNSUPPORTED_BROWSER:"UNSUPPORTED_BROWSER",OVERCONSTRAINED:"OVERCONSTRAINED",GENERIC_CAMERA_ERROR:"GENERIC_CAMERA_ERROR",FACE_DETECTION_INIT_ERROR:"FACE_DETECTION_INIT_ERROR",CAPTURE_LOAD_ERROR:"CAPTURE_LOAD_ERROR",INTERNAL_ERROR:"INTERNAL_ERROR"},t="MOVE_CLOSER",o="MOVE_BACK",a="MOVE_CENTER",i="ONE_FACE_ONLY",s="HOLD_STILL",u="CAMERA_LOADING",c="FACE_SCAN_LOADING",l="IMAGE_TOO_DARK",f="IMAGE_TOO_BRIGHT",h={AR:"ar",CS:"cs",DA:"da",DE:"de",EN:"en",ES:"es",ES_419:"es-419",ET:"et",FI:"fi",FR:"fr",HI:"hi",ID:"id",IT:"it",JA:"ja",KO:"ko",LT:"lt",LV:"lv",MS:"ms",NB:"nb",NL:"nl",PL:"pl",PT:"pt",RO:"ro",RU:"ru",SV:"sv",TH:"th",TR:"tr",UK:"uk",VI:"vi"},p={PNG:"png",JPEG:"jpeg"},d={MANUAL:"manual",AUTO:"auto"},v={ORIGINAL:"original",CROPPED:"cropped"},m={HIGH:"high",MEDIUM:"medium",LOW:"low"},g={[m.HIGH]:1,[m.MEDIUM]:.96,[m.LOW]:.9},y={ALWAYS:"always",AUTO:"auto",NEVER:"never"},b={ASSERTIVE:"assertive",POLITE:"polite"};var w=n(9497),x=n.n(w),E=n(5697),_=n.n(E);class O extends w.Component{componentDidCatch(){const{onError:t}=this.props;t(e.INTERNAL_ERROR)}render(){const{children:e}=this.props;return e}}const k=O;function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function I(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,s=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(u){s=!0,o=u}finally{try{i||null==n.return||n.return()}finally{if(s)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return C(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}O.defaultProps={onError:()=>{}},O.propTypes={onError:_().func,children:_().node.isRequired};var R=x().createContext(null);function A(){return x().useContext(R)}var P=function(e){var t=e.i18n,n=e.defaultComponent,r=e.forceRenderOnLocaleChange,o=void 0===r||r,a=e.children,i=function(){return{i18n:t,defaultComponent:n}},s=function(){return o&&t.locale||"default"},u=I(x().useState(i()),2),c=u[0],l=u[1],f=I(x().useState(s()),2),h=f[0],p=f[1];return x().useEffect((function(){var e=t.on("change",(function(){l(i()),p(s())}));return"default"===h&&p(s()),function(){return e()}}),[]),o&&"default"===h?null:x().createElement(R.Provider,{value:c,key:h},a)};function T(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return D(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?D(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return i=e.done,e},e:function(e){s=!0,a=e},f:function(){try{i||null==n.return||n.return()}finally{if(s)throw a}}}}function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var M=/<(\d+)>(.*?)<\/\1>|<(\d+)\/>/,N=/(?:\r\n|\r|\n)/g,F={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0};function B(e){if(!e.length)return[];var t=I(e.slice(0,4),4),n=t[0],r=t[1],o=t[2],a=t[3];return[[parseInt(n||o),r||"",a]].concat(B(e.slice(4,e.length)))}var j=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return function(){return"".concat(t,"_").concat(e++)}};function L(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function z(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?L(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):L(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function W(e){var t=A(),n=t.i18n,r=t.defaultComponent,o=e.render,a=e.component,i=e.id,s=e.message,u=e.formats,c=z({},e.values),l=z({},e.components);c&&Object.keys(c).forEach((function(e){var t=c[e];if(x().isValidElement(t)){var n=Object.keys(l).length;l[n]=t,c[e]="<".concat(n,"/>")}}));var f=n&&"function"==typeof n._?n._(i,c,{message:s,formats:u}):i,h=f?function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=j(0,"$lingui$"),o=t.replace(N,"").split(M);if(1===o.length)return t;var a=[],i=o.shift();i&&a.push(i);var s,u=T(B(o));try{for(u.s();!(s=u.n()).done;){var c=I(s.value,3),l=c[0],f=c[1],h=c[2],p=n[l];(!p||F[p.type]&&f)&&(p?console.error("".concat(p.type," is a void element tag therefore it must have no children")):console.error("Can use element at index '".concat(l,"' as it is not declared in the original translation")),p=x().createElement(x().Fragment)),a.push(x().cloneElement(p,{key:r()},f?e(f,n):p.props.children)),h&&a.push(h)}}catch(X){u.e(X)}finally{u.f()}return a}(f,l):null;if(null===o||null===a)return h;var p=r||x().Fragment;if(o&&a)console.error("You can't use both `component` and `render` prop at the same time. `component` is ignored.");else if(o&&"function"!=typeof o)console.error("Invalid value supplied to prop `render`. It must be a function, provided ".concat(o));else if(a&&"function"!=typeof a)return console.error("Invalid value supplied to prop `component`. It must be a React component, provided ".concat(a)),x().createElement(p,null,h);if("function"==typeof o)return o({id:i,translation:h,message:s});var d=a||p;return x().createElement(d,null,h)}W.defaultProps={values:{},components:{}};const V="_2_U2DYHedfGUyvS1oS5",H="mteIzegCA0cNMXt96BYN",U="Va8swWS5S29Uvou7UNnc";navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia;const G=async()=>navigator.mediaDevices?await new Promise((e=>{navigator.mediaDevices.enumerateDevices().then((t=>{const n=t.filter((e=>"videoinput"===e.kind));e(!!n.length)})).catch((t=>{console.error(t),e(!1)}))}))?void 0:e.NO_CAMERA:e.UNSUPPORTED_BROWSER;var q=function(e,t){return(q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function X(e,t){function n(){this.constructor=e}q(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function K(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){e.done?o(e.value):new n((function(t){t(e.value)})).then(i,s)}u((r=r.apply(e,t||[])).next())}))}function $(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}var Z=function(){function e(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.populateURLFlags()}return e.prototype.setPlatform=function(e,t){null!=this.platform&&console.warn("Platform "+this.platformName+" has already been set. Overwriting the platform with "+t+"."),this.platformName=e,this.platform=t},e.prototype.registerFlag=function(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){var r=this.urlFlags[e];console.warn("Setting feature override from URL "+e+": "+r+"."),this.set(e,r)}},e.prototype.get=function(e){return e in this.flags||(this.flags[e]=this.evaluateFlag(e)),this.flags[e]},e.prototype.getNumber=function(e){return this.get(e)},e.prototype.getBool=function(e){return this.get(e)},e.prototype.getFlags=function(){return this.flags},Object.defineProperty(e.prototype,"features",{get:function(){return this.flags},enumerable:!0,configurable:!0}),e.prototype.set=function(e,t){if(null==this.flagRegistry[e])throw new Error("Cannot set flag "+e+" as it has not been registered.");this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)},e.prototype.evaluateFlag=function(e){if(null==this.flagRegistry[e])throw new Error("Cannot evaluate flag '"+e+"': no evaluation function found.");return this.flagRegistry[e].evaluationFn()},e.prototype.setFlags=function(e){this.flags=Object.assign({},e)},e.prototype.reset=function(){this.flags={},this.urlFlags={},this.populateURLFlags()},e.prototype.populateURLFlags=function(){var e=this;if(void 0!==this.global&&void 0!==this.global.location&&void 0!==this.global.location.search){var t,n,r=(t=this.global.location.search,n={},t.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return function(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}(n,t[0],t[1]),t.join("=")})),n);"tfjsflags"in r&&r.tfjsflags.split(",").forEach((function(t){var n=t.split(":"),r=n[0],o=n[1];e.urlFlags[r]=function(e,t){if("true"===(t=t.toLowerCase())||"false"===t)return"true"===t;if(""+ +t===t)return+t;throw new Error("Could not parse value flag value "+t+" for flag "+e+".")}(r,o)}))}},e}();function Y(){return J}var J=null,Q=new Map;function ee(e,t){var n=re(e,t);return Q.get(n)}function te(e){for(var t=Q.entries(),n=[];;){var r=t.next(),o=r.done,a=r.value;if(o)break;var i=a[0],s=a[1];i.split("_")[0]===e&&n.push(s)}return n}function ne(e){var t=e.kernelName,n=e.backendName,r=re(t,n);if(Q.has(r))throw new Error("The kernel '"+t+"' for backend '"+n+"' is already registered");Q.set(r,e)}function re(e,t){return t+"_"+e}function oe(e){for(var t=e.length,n=0,r=0;t>0;)r=Math.random()*t|0,n=e[--t],e[t]=e[r],e[r]=n}function ae(e,t,n){return Math.max(e,Math.min(t,n))}function ie(e){return e%2==0?e:e+1}function se(e){for(var t=0,n=0;n<e.length;n++)t+=e[n];return t}function ue(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function ce(e,t,n){void 0===n&&(n=""),ue(pe(e,t),(function(){return n+" Shapes "+e+" and "+t+" must match"}))}function le(e){ue(null!=e,(function(){return"The input to the tensor constructor must be a non-null value."}))}function fe(e,t,n){if(void 0===t&&(t=[]),void 0===n&&(n=!1),null==t&&(t=[]),Array.isArray(e)||Ie(e)&&!n)for(var r=0;r<e.length;++r)fe(e[r],t,n);else t.push(e);return t}function he(e){if(0===e.length)return 1;for(var t=e[0],n=1;n<e.length;n++)t*=e[n];return t}function pe(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function de(e){return e%1==0}function ve(e){if(null!=Math.tanh)return Math.tanh(e);if(e===1/0)return 1;if(e===-1/0)return-1;var t=Math.exp(2*e);return(t-1)/(t+1)}function me(e){var t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function ge(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function ye(e,t,n){return void 0===t&&(t=function(e){return 0}),new Promise((function(r,o){var a=0,i=function(){if(e())r();else{var s=t(++a);null!=n&&a>=n?o():setTimeout(i,s)}};i()}))}function be(e,t){for(var n=1,r=-1,o=0;o<e.length;++o)if(e[o]>=0)n*=e[o];else if(-1===e[o]){if(-1!==r)throw Error("Shapes can only have 1 implicit size. Found -1 at dim "+r+" and dim "+o);r=o}else if(e[o]<0)throw Error("Shapes can not be < 0. Found "+e[o]+" at dim "+o);if(-1===r){if(t>0&&t!==n)throw Error("Size("+t+") must match the product of shape "+e);return e}if(0===n)throw Error("Cannot infer the missing size in ["+e+"] when there are 0 elements");if(t%n!=0)throw Error("The implicit shape can't be a fractional number. Got "+t+" / "+n);var a=e.slice();return a[r]=t/n,a}function we(e,t){var n=t.length;return ue((e=null==e?t.map((function(e,t){return t})):[].concat(e)).every((function(e){return e>=-n&&e<n})),(function(){return"All values in axis param must be in range [-"+n+", "+n+") but got axis "+e})),ue(e.every((function(e){return de(e)})),(function(){return"All values in axis param must be integers but got axis "+e})),e.map((function(e){return e<0?n+e:e}))}function xe(e,t){for(var n=[],r=[],o=null!=t&&Array.isArray(t)&&0===t.length,a=null==t||o?null:we(t,e).sort(),i=0,s=0;s<e.length;++s){if(null!=a){if(a[i]===s&&1!==e[s])throw new Error("Can't squeeze axis "+s+" since its dim '"+e[s]+"' is not 1");(null==a[i]||a[i]>s)&&1===e[s]&&(n.push(e[s]),r.push(s)),a[i]<=s&&i++}1!==e[s]&&(n.push(e[s]),r.push(s))}return{newShape:n,keptDims:r}}function Ee(e,t){var n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else{if("bool"!==e)throw new Error("Unknown data type "+e);n=new Uint8Array(t)}return n}function _e(e,t){var n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error("Unknown data type "+e);n=new Array(t)}return n}function Oe(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(isNaN(r)||!isFinite(r))throw Error("A tensor of type "+t+" being uploaded contains "+r+".")}}function ke(e){return"bool"===e||"complex64"===e||"float32"===e||"int32"===e||"string"===e}function Ce(e,t){return!("complex64"===t||"float32"===t&&"complex64"!==e||"int32"===t&&"float32"!==e&&"complex64"!==e||"bool"===t&&"bool"===e)}function Ie(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array}function Se(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw new Error("Unknown dtype "+e)}function Re(e){if(null==e)return 0;var t=0;return e.forEach((function(e){return t+=e.length})),t}function Ae(e){return"string"==typeof e||e instanceof String}function Pe(e){return"boolean"==typeof e}function Te(e){return"number"==typeof e}function De(e){return Array.isArray(e)?De(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array?"int32":Te(e)?"float32":Ae(e)?"string":Pe(e)?"bool":"float32"}function Me(e){return!!(e&&e.constructor&&e.call&&e.apply)}function Ne(e,t){for(var n=t;n<e;++n)if(e%n==0)return n;return e}function Fe(e){var t=e.length;if(t<2)return[];var n=new Array(t-1);n[t-2]=e[t-1];for(var r=t-3;r>=0;--r)n[r]=n[r+1]*e[r+1];return n}function Be(e,t,n){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=fe(e)),n&&Oe(e,t),function(e,t){return e instanceof Float32Array&&"float32"===t||e instanceof Int32Array&&"int32"===t||e instanceof Uint8Array&&"bool"===t}(e,t))return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){for(var r=new Uint8Array(e.length),o=0;o<r.length;++o)0!==Math.round(e[o])&&(r[o]=1);return r}throw new Error("Unknown data type "+t)}function je(e,t){if(0===e.length)return t[0];var n=e.reduce((function(e,t){return e*t}));if(0===n)return[];if(n!==t.length)throw new Error("["+e+"] does not match the input size.");return function e(t,n,r){var o=new Array;if(1===n.length)for(var a=n[0],i=0;i<a;i++)o[i]=r[t+i];else{a=n[0];var s=n.slice(1),u=s.reduce((function(e,t){return e*t}));for(i=0;i<a;i++)o[i]=e(t+i*u,s,r)}return o}(0,e,t)}function Le(e,t){for(var n=ze(e,t),r=0;r<n.length;r++)n[r]=1;return n}function ze(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw new Error("Unknown data type "+t)}function We(){return Y().platform.now()}function Ve(e){e.forEach((function(t){ue(Number.isInteger(t)&&t>=0,(function(){return"Tensor must have a shape comprised of positive integers but got shape ["+e+"]."}))}))}function He(e,t){return void 0===t&&(t="utf-8"),t=t||"utf-8",Y().platform.encode(e,t)}function Ue(e,t){return void 0===t&&(t="utf-8"),t=t||"utf-8",Y().platform.decode(e,t)}Object.freeze({shuffle:oe,clamp:ae,nearestLargerEven:ie,sum:se,randUniform:function(e,t){var n=Math.random();return t*n+(1-n)*e},distSquared:function(e,t){for(var n=0,r=0;r<e.length;r++){var o=Number(e[r])-Number(t[r]);n+=o*o}return n},assert:ue,assertShapesMatch:ce,assertNonNull:le,flatten:fe,sizeFromShape:he,isScalarShape:function(e){return 0===e.length},arraysEqual:pe,isInt:de,tanh:ve,sizeToSquarishShape:me,createShuffledIndices:function(e){for(var t=new Uint32Array(e),n=0;n<e;++n)t[n]=n;return oe(t),t},rightPad:ge,repeatedTry:ye,inferFromImplicitShape:be,parseAxisParam:we,squeezeShape:xe,getTypedArrayFromDType:Ee,getArrayFromDType:_e,checkConversionForErrors:Oe,isValidDtype:ke,hasEncodingLoss:Ce,isTypedArray:Ie,bytesPerElement:Se,bytesFromStringArray:Re,isString:Ae,isBoolean:Pe,isNumber:Te,inferDtype:De,isFunction:Me,nearestDivisor:Ne,computeStrides:Fe,toTypedArray:Be,toNestedArray:je,makeOnesTypedArray:Le,makeZerosTypedArray:ze,now:We,assertNonNegativeIntegerDimensions:Ve,fetch:function(e,t){return Y().platform.fetch(e,t)},encodeString:He,decodeString:Ue});var Ge=function(){function e(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new qe)}return e.prototype.profileKernel=function(e,t,n){var r,o=this,a=this.backendTimer.time((function(){r=n()}));return r.forEach((function(n){n.data().then((function(r){!function(e,t,n){if("float32"!==t)return!1;for(var r=0;r<e.length;r++){var o=e[r];if(isNaN(o)||!isFinite(o))return console.warn("Found "+o+" in the result of '"+n+"'"),!0}}(r,n.dtype,e),a.then((function(a){var i="";null!=a.getExtraProfileInfo&&(i=a.getExtraProfileInfo()),o.logger.logKernelProfile(e,n,r,a.kernelMs,t,i)}))}))})),r},e}(),qe=function(){function e(){}return e.prototype.logKernelProfile=function(e,t,n,r,o,a){ge(r+"ms",9),ge(e,25),t.rank,t.size,ge(t.shape.toString(),14);for(var i in o){var s=o[i].shape,u=s.length;i+": "+u+"D "+(u>0?s:"")+" "}},e}();function Xe(e,t,n){return ge(Array.isArray(e)?parseFloat(e[0].toFixed(7))+" + "+parseFloat(e[1].toFixed(7))+"j":Ae(e)?"'"+e+"'":"bool"===n?Ke(e):parseFloat(e.toFixed(7)).toString(),t)}function Ke(e){return 0===e?"false":"true"}function $e(e){for(var t=[],n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}var Ze=function(){function e(e,t,n){var r=this;if(this.dtype=t,this.shape=e.slice(),this.size=he(e),null!=n){var o=n.length;ue(o===this.size,(function(){return"Length of values '"+o+"' does not match the size inferred by the shape '"+r.size+"'."}))}if("complex64"===t)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||_e(t,this.size),this.strides=Fe(e)}return e.prototype.set=function(e){for(var t=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];0===n.length&&(n=[0]),ue(n.length===this.rank,(function(){return"The number of provided coordinates ("+n.length+") must match the rank ("+t.rank+")"}));var o=this.locToIndex(n);this.values[o]=e},e.prototype.get=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];0===e.length&&(e=[0]);for(var n=0,r=0,o=e;r<o.length;r++){var a=o[r];if(a<0||a>=this.shape[n]){var i="Requested out of range element at "+e+". Buffer shape="+this.shape;throw new Error(i)}n++}for(var s=e[e.length-1],u=0;u<e.length-1;++u)s+=this.strides[u]*e[u];return this.values[s]},e.prototype.locToIndex=function(e){if(0===this.rank)return 0;if(1===this.rank)return e[0];for(var t=e[e.length-1],n=0;n<e.length-1;++n)t+=this.strides[n]*e[n];return t},e.prototype.indexToLoc=function(e){if(0===this.rank)return[];if(1===this.rank)return[e];for(var t=new Array(this.shape.length),n=0;n<t.length-1;++n)t[n]=Math.floor(e/this.strides[n]),e-=t[n]*this.strides[n];return t[t.length-1]=e,t},Object.defineProperty(e.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),e.prototype.toTensor=function(){return Ye().makeTensor(this.values,this.shape,this.dtype)},e}(),Ye=null,Je=null,Qe=null,et=function(){function e(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=he(e),this.strides=Fe(e),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}return e.prototype.flatten=function(){return this.throwIfDisposed(),this.as1D()},e.prototype.asScalar=function(){return this.throwIfDisposed(),ue(1===this.size,(function(){return"The array must have only 1 element."})),this.reshape([])},e.prototype.as1D=function(){return this.throwIfDisposed(),this.reshape([this.size])},e.prototype.as2D=function(e,t){return this.throwIfDisposed(),this.reshape([e,t])},e.prototype.as3D=function(e,t,n){return this.throwIfDisposed(),this.reshape([e,t,n])},e.prototype.as4D=function(e,t,n,r){return this.throwIfDisposed(),this.reshape([e,t,n,r])},e.prototype.as5D=function(e,t,n,r,o){return this.throwIfDisposed(),this.reshape([e,t,n,r,o])},e.prototype.asType=function(e){return this.throwIfDisposed(),Je.cast(this,e)},Object.defineProperty(e.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),e.prototype.buffer=function(){return K(this,void 0,void 0,(function(){var e;return $(this,(function(t){switch(t.label){case 0:return[4,this.data()];case 1:return e=t.sent(),[2,Je.buffer(this.shape,this.dtype,e)]}}))}))},e.prototype.bufferSync=function(){return Je.buffer(this.shape,this.dtype,this.dataSync())},e.prototype.array=function(){return K(this,void 0,void 0,(function(){var e;return $(this,(function(t){switch(t.label){case 0:return[4,this.data()];case 1:return e=t.sent(),[2,je(this.shape,e)]}}))}))},e.prototype.arraySync=function(){return je(this.shape,this.dataSync())},e.prototype.data=function(){return K(this,void 0,void 0,(function(){var e,t;return $(this,(function(n){switch(n.label){case 0:return this.throwIfDisposed(),e=Ye().read(this.dataId),"string"!==this.dtype?[3,2]:[4,e];case 1:t=n.sent();try{return[2,t.map((function(e){return Ue(e)}))]}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}n.label=2;case 2:return[2,e]}}))}))},e.prototype.dataSync=function(){this.throwIfDisposed();var e=Ye().readSync(this.dataId);if("string"===this.dtype)try{return e.map((function(e){return Ue(e)}))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e},e.prototype.bytes=function(){return K(this,void 0,void 0,(function(){var e;return $(this,(function(t){switch(t.label){case 0:return this.throwIfDisposed(),[4,Ye().read(this.dataId)];case 1:return e=t.sent(),"string"===this.dtype?[2,e]:[2,new Uint8Array(e.buffer)]}}))}))},e.prototype.dispose=function(){this.isDisposed||(Ye().disposeTensor(this),this.isDisposedInternal=!0)},Object.defineProperty(e.prototype,"isDisposed",{get:function(){return this.isDisposedInternal},enumerable:!0,configurable:!0}),e.prototype.throwIfDisposed=function(){if(this.isDisposed)throw new Error("Tensor is disposed.")},e.prototype.toFloat=function(){return this.asType("float32")},e.prototype.toInt=function(){return this.asType("int32")},e.prototype.toBool=function(){return this.asType("bool")},e.prototype.print=function(e){return void 0===e&&(e=!1),Je.print(this,e)},e.prototype.reshape=function(e){return this.throwIfDisposed(),Je.reshape(this,e)},e.prototype.reshapeAs=function(e){return this.throwIfDisposed(),this.reshape(e.shape)},e.prototype.expandDims=function(e){return void 0===e&&(e=0),Je.expandDims(this,e)},e.prototype.cumsum=function(e,t,n){return void 0===e&&(e=0),void 0===t&&(t=!1),void 0===n&&(n=!1),Je.cumsum(this,e,t,n)},e.prototype.squeeze=function(e){return this.throwIfDisposed(),Je.squeeze(this,e)},e.prototype.clone=function(){return this.throwIfDisposed(),Je.clone(this)},e.prototype.oneHot=function(e,t,n){return this.throwIfDisposed(),Je.oneHot(this,e,t,n)},e.prototype.toString=function(e){return void 0===e&&(e=!1),function(e,t,n,r){var o=Fe(t),a=function(e,t,n,r){var o=he(t),a=r[r.length-1],i=new Array(a).fill(0),s=t.length,u="complex64"===n?$e(e):e;if(s>1)for(var c=0;c<o/a;c++)for(var l=c*a,f=0;f<a;f++)i[f]=Math.max(i[f],Xe(u[l+f],0,n).length);return i}(e,t,n,o),i=t.length,s=function e(t,n,r,o,a,i){void 0===i&&(i=!0);var s="complex64"===r?2:1,u=n[0],c=n.length;if(0===c)return"complex64"===r?[Xe($e(t)[0],0,r)]:"bool"===r?[Ke(t[0])]:[t[0].toString()];if(1===c){if(u>20){var l=3*s,f=Array.from(t.slice(0,l)),h=Array.from(t.slice((u-3)*s,u*s));return"complex64"===r&&(f=$e(f),h=$e(h)),["["+f.map((function(e,t){return Xe(e,a[t],r)})).join(", ")+", ..., "+h.map((function(e,t){return Xe(e,a[u-3+t],r)})).join(", ")+"]"]}return["["+("complex64"===r?$e(t):Array.from(t)).map((function(e,t){return Xe(e,a[t],r)})).join(", ")+"]"]}var p=n.slice(1),d=o.slice(1),v=o[0]*s,m=[];if(u>20){for(var g=0;g<3;g++){var y=(b=g*v)+v;m.push.apply(m,e(t.slice(b,y),p,r,d,a,!1))}for(m.push("..."),g=u-3;g<u;g++)y=(b=g*v)+v,m.push.apply(m,e(t.slice(b,y),p,r,d,a,g===u-1))}else for(g=0;g<u;g++){var b;y=(b=g*v)+v,m.push.apply(m,e(t.slice(b,y),p,r,d,a,g===u-1))}var w=2===c?",":"";for(m[0]="["+m[0]+w,g=1;g<m.length-1;g++)m[g]=" "+m[g]+w;var x=",\n";for(g=2;g<c;g++)x+="\n";return m[m.length-1]=" "+m[m.length-1]+"]"+(i?"":x),m}(e,t,n,o,a),u=["Tensor"];return r&&(u.push(" dtype: "+n),u.push(" rank: "+i),u.push(" shape: ["+t+"]"),u.push(" values:")),u.push(s.map((function(e){return" "+e})).join("\n")),u.join("\n")}(this.dataSync(),this.shape,this.dtype,e)},e.prototype.tile=function(e){return this.throwIfDisposed(),Je.tile(this,e)},e.prototype.gather=function(e,t){return void 0===t&&(t=0),this.throwIfDisposed(),Je.gather(this,e,t)},e.prototype.matMul=function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=!1),this.throwIfDisposed(),Je.matMul(this,e,t,n)},e.prototype.dot=function(e){return this.throwIfDisposed(),Je.dot(this,e)},e.prototype.norm=function(e,t,n){return void 0===e&&(e="euclidean"),void 0===t&&(t=null),void 0===n&&(n=!1),this.throwIfDisposed(),Je.norm(this,e,t,n)},e.prototype.slice=function(e,t){return this.throwIfDisposed(),Je.slice(this,e,t)},e.prototype.reverse=function(e){return this.throwIfDisposed(),Je.reverse(this,e)},e.prototype.concat=function(t,n){return void 0===n&&(n=0),this.throwIfDisposed(),t instanceof e&&(t=[t]),Je.concat([this].concat(t),n)},e.prototype.split=function(e,t){return void 0===t&&(t=0),this.throwIfDisposed(),Je.split(this,e,t)},e.prototype.stack=function(e,t){return void 0===t&&(t=0),Je.stack([this,e],t)},e.prototype.unstack=function(e){return void 0===e&&(e=0),Je.unstack(this,e)},e.prototype.pad=function(e,t){return void 0===t&&(t=0),Je.pad(this,e,t)},e.prototype.batchNormalization=function(e,t,n,r,o){return void 0===n&&(n=.001),Qe("tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon"),this.batchNorm(e,t,o,r,n)},e.prototype.batchNorm=function(e,t,n,r,o){return void 0===o&&(o=.001),this.throwIfDisposed(),Je.batchNorm(this,e,t,n,r,o)},e.prototype.all=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=!1),this.throwIfDisposed(),Je.all(this,e,t)},e.prototype.any=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=!1),this.throwIfDisposed(),Je.any(this,e,t)},e.prototype.logSumExp=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=!1),this.throwIfDisposed(),Je.logSumExp(this,e,t)},e.prototype.sum=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=!1),this.throwIfDisposed(),Je.sum(this,e,t)},e.prototype.prod=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=!1),this.throwIfDisposed(),Je.prod(this,e,t)},e.prototype.mean=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=!1),this.throwIfDisposed(),Je.mean(this,e,t)},e.prototype.min=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=!1),this.throwIfDisposed(),Je.min(this,e,t)},e.prototype.max=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=!1),this.throwIfDisposed(),Je.max(this,e,t)},e.prototype.argMin=function(e){return void 0===e&&(e=null),this.throwIfDisposed(),Je.argMin(this,e)},e.prototype.argMax=function(e){return void 0===e&&(e=null),this.throwIfDisposed(),Je.argMax(this,e)},e.prototype.cast=function(e){return this.throwIfDisposed(),Je.cast(this,e)},e.prototype.add=function(e){return this.throwIfDisposed(),Je.add(this,e)},e.prototype.addStrict=function(e){return this.throwIfDisposed(),Je.addStrict(this,e)},e.prototype.atan2=function(e){return this.throwIfDisposed(),Je.atan2(this,e)},e.prototype.sub=function(e){return this.throwIfDisposed(),Je.sub(this,e)},e.prototype.subStrict=function(e){return this.throwIfDisposed(),Je.subStrict(this,e)},e.prototype.pow=function(e){return this.throwIfDisposed(),Je.pow(this,e)},e.prototype.powStrict=function(e){return this.throwIfDisposed(),Je.powStrict(this,e)},e.prototype.mul=function(e){return this.throwIfDisposed(),Je.mul(this,e)},e.prototype.mulStrict=function(e){return this.throwIfDisposed(),Je.mulStrict(this,e)},e.prototype.div=function(e){return this.throwIfDisposed(),Je.div(this,e)},e.prototype.divNoNan=function(e){return this.throwIfDisposed(),Je.divNoNan(this,e)},e.prototype.floorDiv=function(e){return this.throwIfDisposed(),Je.floorDiv(this,e)},e.prototype.divStrict=function(e){return this.throwIfDisposed(),Je.divStrict(this,e)},e.prototype.minimum=function(e){return this.throwIfDisposed(),Je.minimum(this,e)},e.prototype.minimumStrict=function(e){return this.throwIfDisposed(),Je.minimumStrict(this,e)},e.prototype.maximum=function(e){return this.throwIfDisposed(),Je.maximum(this,e)},e.prototype.maximumStrict=function(e){return this.throwIfDisposed(),Je.maximumStrict(this,e)},e.prototype.mod=function(e){return this.throwIfDisposed(),Je.mod(this,e)},e.prototype.modStrict=function(e){return this.throwIfDisposed(),Je.modStrict(this,e)},e.prototype.squaredDifference=function(e){return this.throwIfDisposed(),Je.squaredDifference(this,e)},e.prototype.squaredDifferenceStrict=function(e){return this.throwIfDisposed(),Je.squaredDifferenceStrict(this,e)},e.prototype.transpose=function(e){return this.throwIfDisposed(),Je.transpose(this,e)},e.prototype.notEqual=function(e){return this.throwIfDisposed(),Je.notEqual(this,e)},e.prototype.notEqualStrict=function(e){return this.throwIfDisposed(),Je.notEqualStrict(this,e)},e.prototype.less=function(e){return this.throwIfDisposed(),Je.less(this,e)},e.prototype.lessStrict=function(e){return this.throwIfDisposed(),Je.lessStrict(this,e)},e.prototype.equal=function(e){return this.throwIfDisposed(),Je.equal(this,e)},e.prototype.equalStrict=function(e){return this.throwIfDisposed(),Je.equalStrict(this,e)},e.prototype.lessEqual=function(e){return this.throwIfDisposed(),Je.lessEqual(this,e)},e.prototype.lessEqualStrict=function(e){return this.throwIfDisposed(),Je.lessEqualStrict(this,e)},e.prototype.greater=function(e){return this.throwIfDisposed(),Je.greater(this,e)},e.prototype.greaterStrict=function(e){return this.throwIfDisposed(),Je.greaterStrict(this,e)},e.prototype.greaterEqual=function(e){return this.throwIfDisposed(),Je.greaterEqual(this,e)},e.prototype.greaterEqualStrict=function(e){return this.throwIfDisposed(),Je.greaterEqualStrict(this,e)},e.prototype.logicalAnd=function(e){return this.throwIfDisposed(),Je.logicalAnd(this,e)},e.prototype.logicalOr=function(e){return this.throwIfDisposed(),Je.logicalOr(this,e)},e.prototype.logicalNot=function(){return this.throwIfDisposed(),Je.logicalNot(this)},e.prototype.logicalXor=function(e){return this.throwIfDisposed(),Je.logicalXor(this,e)},e.prototype.where=function(e,t){return this.throwIfDisposed(),Je.where(e,this,t)},e.prototype.neg=function(){return this.throwIfDisposed(),Je.neg(this)},e.prototype.ceil=function(){return this.throwIfDisposed(),Je.ceil(this)},e.prototype.floor=function(){return this.throwIfDisposed(),Je.floor(this)},e.prototype.sign=function(){return this.throwIfDisposed(),Je.sign(this)},e.prototype.isNaN=function(){return this.throwIfDisposed(),Je.isNaN(this)},e.prototype.isInf=function(){return this.throwIfDisposed(),Je.isInf(this)},e.prototype.isFinite=function(){return this.throwIfDisposed(),Je.isFinite(this)},e.prototype.exp=function(){return this.throwIfDisposed(),Je.exp(this)},e.prototype.expm1=function(){return this.throwIfDisposed(),Je.expm1(this)},e.prototype.log=function(){return this.throwIfDisposed(),Je.log(this)},e.prototype.log1p=function(){return this.throwIfDisposed(),Je.log1p(this)},e.prototype.sqrt=function(){return this.throwIfDisposed(),Je.sqrt(this)},e.prototype.rsqrt=function(){return this.throwIfDisposed(),Je.rsqrt(this)},e.prototype.square=function(){return this.throwIfDisposed(),Je.square(this)},e.prototype.reciprocal=function(){return this.throwIfDisposed(),Je.reciprocal(this)},e.prototype.abs=function(){return this.throwIfDisposed(),Je.abs(this)},e.prototype.clipByValue=function(e,t){return this.throwIfDisposed(),Je.clipByValue(this,e,t)},e.prototype.relu=function(){return this.throwIfDisposed(),Je.relu(this)},e.prototype.relu6=function(){return this.throwIfDisposed(),Je.relu6(this)},e.prototype.elu=function(){return this.throwIfDisposed(),Je.elu(this)},e.prototype.selu=function(){return this.throwIfDisposed(),Je.selu(this)},e.prototype.leakyRelu=function(e){return void 0===e&&(e=.2),this.throwIfDisposed(),Je.leakyRelu(this,e)},e.prototype.prelu=function(e){return this.throwIfDisposed(),Je.prelu(this,e)},e.prototype.sigmoid=function(){return this.throwIfDisposed(),Je.sigmoid(this)},e.prototype.logSigmoid=function(){return this.throwIfDisposed(),Je.logSigmoid(this)},e.prototype.softplus=function(){return this.throwIfDisposed(),Je.softplus(this)},e.prototype.zerosLike=function(){return this.throwIfDisposed(),Je.zerosLike(this)},e.prototype.onesLike=function(){return this.throwIfDisposed(),Je.onesLike(this)},e.prototype.sin=function(){return this.throwIfDisposed(),Je.sin(this)},e.prototype.cos=function(){return this.throwIfDisposed(),Je.cos(this)},e.prototype.tan=function(){return this.throwIfDisposed(),Je.tan(this)},e.prototype.asin=function(){return this.throwIfDisposed(),Je.asin(this)},e.prototype.acos=function(){return this.throwIfDisposed(),Je.acos(this)},e.prototype.atan=function(){return this.throwIfDisposed(),Je.atan(this)},e.prototype.sinh=function(){return this.throwIfDisposed(),Je.sinh(this)},e.prototype.cosh=function(){return this.throwIfDisposed(),Je.cosh(this)},e.prototype.tanh=function(){return this.throwIfDisposed(),Je.tanh(this)},e.prototype.asinh=function(){return this.throwIfDisposed(),Je.asinh(this)},e.prototype.acosh=function(){return this.throwIfDisposed(),Je.acosh(this)},e.prototype.atanh=function(){return this.throwIfDisposed(),Je.atanh(this)},e.prototype.erf=function(){return this.throwIfDisposed(),Je.erf(this)},e.prototype.round=function(){return this.throwIfDisposed(),Je.round(this)},e.prototype.step=function(e){return void 0===e&&(e=0),this.throwIfDisposed(),Je.step(this,e)},e.prototype.softmax=function(e){return void 0===e&&(e=-1),this.throwIfDisposed(),Je.softmax(this,e)},e.prototype.logSoftmax=function(e){return void 0===e&&(e=-1),this.throwIfDisposed(),Je.logSoftmax(this,e)},e.prototype.resizeBilinear=function(e,t){return void 0===t&&(t=!1),this.throwIfDisposed(),Je.image.resizeBilinear(this,e,t)},e.prototype.resizeNearestNeighbor=function(e,t){return void 0===t&&(t=!1),this.throwIfDisposed(),Je.image.resizeNearestNeighbor(this,e,t)},e.prototype.conv1d=function(e,t,n,r,o,a){return void 0===r&&(r="NWC"),void 0===o&&(o=1),this.throwIfDisposed(),Je.conv1d(this,e,t,n,r,o,a)},e.prototype.conv2d=function(e,t,n,r,o,a){return void 0===r&&(r="NHWC"),void 0===o&&(o=[1,1]),this.throwIfDisposed(),Je.conv2d(this,e,t,n,r,o,a)},e.prototype.conv2dTranspose=function(e,t,n,r,o){return this.throwIfDisposed(),Je.conv2dTranspose(this,e,t,n,r,o)},e.prototype.depthwiseConv2D=function(e,t,n,r,o,a){return void 0===r&&(r="NHWC"),void 0===o&&(o=[1,1]),this.throwIfDisposed(),Je.depthwiseConv2d(this,e,t,n,r,o,a)},e.prototype.separableConv2d=function(e,t,n,r,o,a){return void 0===o&&(o=[1,1]),void 0===a&&(a="NHWC"),this.throwIfDisposed(),Je.separableConv2d(this,e,t,n,r,o,a)},e.prototype.avgPool=function(e,t,n,r){return this.throwIfDisposed(),Je.avgPool(this,e,t,n,r)},e.prototype.maxPool=function(e,t,n,r){return this.throwIfDisposed(),Je.maxPool(this,e,t,n,r)},e.prototype.localResponseNormalization=function(e,t,n,r){return void 0===e&&(e=5),void 0===t&&(t=1),void 0===n&&(n=1),void 0===r&&(r=.5),Je.localResponseNormalization(this,e,t,n,r)},e.prototype.pool=function(e,t,n,r,o){return this.throwIfDisposed(),Je.pool(this,e,t,n,r,o)},e.prototype.variable=function(e,t,n){return void 0===e&&(e=!0),this.throwIfDisposed(),Ye().makeVariable(this,e,t,n)},e.prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),Je.unsortedSegmentSum(this,e,t)},e.prototype.batchToSpaceND=function(e,t){return this.throwIfDisposed(),Je.batchToSpaceND(this,e,t)},e.prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),Je.spaceToBatchND(this,e,t)},e.prototype.topk=function(e,t){return void 0===e&&(e=1),void 0===t&&(t=!0),this.throwIfDisposed(),Je.topk(this,e,t)},e.prototype.stridedSlice=function(e,t,n,r,o,a,i,s){return void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===i&&(i=0),void 0===s&&(s=0),this.throwIfDisposed(),Je.stridedSlice(this,e,t,n,r,o,a,i,s)},e.prototype.depthToSpace=function(e,t){return this.throwIfDisposed(),Je.depthToSpace(this,e,t)},e.prototype.fft=function(){return this.throwIfDisposed(),Je.spectral.fft(this)},e.prototype.ifft=function(){return this.throwIfDisposed(),Je.spectral.ifft(this)},e.prototype.rfft=function(){return this.throwIfDisposed(),Je.spectral.rfft(this)},e.prototype.irfft=function(){return this.throwIfDisposed(),Je.spectral.irfft(this)},e}();Object.defineProperty(et,Symbol.hasInstance,{value:function(e){return!!e&&null!=e.dataId&&null!=e.shape&&null!=e.dtype}});var tt,nt,rt,ot,at,it=function(e){function t(t,n,r,o){var a=e.call(this,t.shape,t.dtype,t.dataId,o)||this;return a.trainable=n,a.name=r,a}return X(t,e),t.prototype.assign=function(e){if(e.dtype!==this.dtype)throw new Error("dtype of the new value ("+e.dtype+") and previous value ("+this.dtype+") must match");if(!pe(e.shape,this.shape))throw new Error("shape of the new value ("+e.shape+") and previous value ("+this.shape+") must match");Ye().disposeTensor(this),this.dataId=e.dataId,Ye().incRef(this,null)},t.prototype.dispose=function(){Ye().disposeVariable(this),this.isDisposedInternal=!0},t}(et);Object.defineProperty(it,Symbol.hasInstance,{value:function(e){return e instanceof et&&null!=e.assign&&e.assign instanceof Function}}),function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"}(tt||(tt={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(nt||(nt={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(rt||(rt={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(ot||(ot={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(at||(at={}));var st={float32:ot,int32:nt,bool:rt,complex64:at};function ut(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error("Can not upcast "+e+" with "+t)}return st[e][t]}function ct(e){return ut(e,"int32")}function lt(e,t){if(e.dtype===t.dtype)return[e,t];var n=ut(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function ft(e,t){ue(e.dtype===t.dtype,(function(){return"The dtypes of the first("+e.dtype+") and second("+t.dtype+") input must match"}))}function ht(e){var t=[];return function e(t,n,r){if(null!=t)if(t instanceof et)n.push(t);else if(o=t,Array.isArray(o)||"object"==typeof o){var o,a=t;for(var i in a){var s=a[i];r.has(s)||(r.add(s),e(s,n,r))}}}(e,t,new Set),t}Object.freeze({makeTypesMatch:lt,assertTypesMatch:ft,isTensorInList:function(e,t){for(var n=0;n<t.length;n++)if(t[n].id===e.id)return!0;return!1},getTensorsInContainer:ht});var pt,dt=function(){function e(){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}}return e.prototype.dispose=function(){for(var e in this.registeredVariables)this.registeredVariables[e].dispose()},e}(),vt=function(){function e(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new dt}return e.prototype.ready=function(){return K(this,void 0,void 0,(function(){var e,t,n;return $(this,(function(r){switch(r.label){case 0:if(null!=this.pendingBackendInit)return[2,this.pendingBackendInit.then((function(){}))];if(null!=this.backendInstance)return[2];e=this.getSortedBackends(),t=0,r.label=1;case 1:return t<e.length?(n=e[t],[4,this.initializeBackend(n).success]):[3,5];case 2:return r.sent()?[4,this.setBackend(n)]:[3,4];case 3:return r.sent(),[2];case 4:return t++,[3,1];case 5:throw new Error("Could not initialize any backends, all backend initializations failed.")}}))}))},Object.defineProperty(e.prototype,"backend",{get:function(){if(null!=this.pendingBackendInit)throw new Error("Backend '"+this.backendName+"' has not yet been initialized. Make sure to await tf.ready() before calling other methods");if(null==this.backendInstance){var e=this.initializeBackendsAndReturnBest(),t=e.name;if(e.asyncInit)throw new Error("The highest priority backend '"+t+"' has not yet been initialized. Make sure to await tf.ready() before calling other methods");this.setBackend(t)}return this.backendInstance},enumerable:!0,configurable:!0}),e.prototype.backendNames=function(){return Object.keys(this.registryFactory)},e.prototype.findBackend=function(e){if(!(e in this.registry)){if(!(e in this.registryFactory))return null;if(this.initializeBackend(e).asyncInit)return null}return this.registry[e]},e.prototype.findBackendFactory=function(e){return e in this.registryFactory?this.registryFactory[e].factory:null},e.prototype.registerBackend=function(e,t,n){return void 0===n&&(n=1),e in this.registryFactory?(console.warn(e+" backend was already registered. Reusing existing backend factory."),!1):(this.registryFactory[e]={factory:t,priority:n},!0)},e.prototype.setBackend=function(e){return K(this,void 0,void 0,(function(){var t,n,r;return $(this,(function(o){switch(o.label){case 0:if(null==this.registryFactory[e])throw new Error("Backend name '"+e+"' not found in registry");return this.backendName=e,null!=this.registry[e]?[3,4]:(this.backendInstance=null,t=this.initializeBackend(e),n=t.success,t.asyncInit?[4,n]:[3,2]);case 1:return r=o.sent(),[3,3];case 2:r=n,o.label=3;case 3:if(!r)return[2,!1];o.label=4;case 4:return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new Ge(this.backendInstance),[2,!0]}}))}))},e.prototype.setupRegisteredKernels=function(){var e=this;te(this.backendName).forEach((function(t){null!=t.setupFunc&&t.setupFunc(e.backendInstance)}))},e.prototype.disposeRegisteredKernels=function(e){var t=this;te(e).forEach((function(n){null!=n.disposeFunc&&n.disposeFunc(t.registry[e])}))},e.prototype.initializeBackend=function(e){var t=this,n=this.registryFactory[e];if(null==n)throw new Error("Cannot initialize backend "+e+", no registration found.");try{var r=n.factory();if(Promise.resolve(r)===r){var o=++this.pendingBackendInitId,a=r.then((function(n){return!(o<t.pendingBackendInitId||(t.registry[e]=n,t.pendingBackendInit=null,0))})).catch((function(n){return!(o<t.pendingBackendInitId||(t.pendingBackendInit=null,console.warn("Initialization of backend "+e+" failed"),console.warn(n.stack||n.message),1))}));return this.pendingBackendInit=a,{success:a,asyncInit:!0}}return this.registry[e]=r,{success:!0,asyncInit:!1}}catch(t){return console.warn("Initialization of backend "+e+" failed"),console.warn(t.stack||t.message),{success:!1,asyncInit:!1}}},e.prototype.removeBackend=function(e){if(!(e in this.registryFactory))throw new Error(e+" backend not found in registry");this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)},e.prototype.getSortedBackends=function(){var e=this;if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort((function(t,n){return e.registryFactory[n].priority-e.registryFactory[t].priority}))},e.prototype.initializeBackendsAndReturnBest=function(){for(var e=this.getSortedBackends(),t=0;t<e.length;t++){var n=e[t],r=this.initializeBackend(n),o=r.success,a=r.asyncInit;if(a||o)return{name:n,asyncInit:a}}throw new Error("Could not initialize any backends, all backend initializations failed.")},e.prototype.moveData=function(e,t){var n=this.state.tensorInfo.get(t),r=n.backend,o=this.readSync(t);r.disposeData(t),n.backend=e,e.move(t,o,n.shape,n.dtype),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++},e.prototype.tidy=function(e,t){var n,r=this,o=null;if(null==t){if("function"!=typeof e)throw new Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");o=e}return this.scopedRun((function(){return r.startScope(o)}),(function(){return r.endScope(n)}),(function(){return(n=t())instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n}))},e.prototype.scopedRun=function(e,t,n){e();try{var r=n();return t(),r}catch(e){throw t(),e}},e.prototype.nextTensorId=function(){return e.nextTensorId++},e.prototype.nextVariableId=function(){return e.nextVariableId++},e.prototype.clone=function(e){var t=this.makeTensorFromDataId(e.dataId,e.shape,e.dtype),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],(function(e){return{x:function(){return e.toFloat()}}}),[]),t},e.prototype.runKernel=function(e,t,n,r,o){return this.runKernelFunc(null,t,null,e,n,r,o)},e.prototype.shouldCheckForMemLeaks=function(){return this.ENV.getBool("IS_TEST")},e.prototype.checkKernelForMemLeak=function(e,t,n){var r=this.backend.numDataIds(),o=0;n.forEach((function(e){o+="complex64"===e.dtype?3:1}));var a=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=r-t-o-a;if(i>0)throw new Error("Backend '"+this.backendName+"' has an internal memory leak ("+i+" data ids) after running '"+e+"'")},e.prototype.runKernelFunc=function(e,t,n,r,o,a,i){var s,u=this;void 0===a&&(a=[]),void 0===i&&(i=[]);var c,l=[],f=this.isTapeOn(),h=null!=this.state.activeScope?this.state.activeScope.name:"",p=function(e){f&&(l=e.map((function(e){return u.keep(u.clone(e))})))},d=this.state.numBytes,v=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);var m,g=ee(r,this.backendName);return c=null!=g?function(){var e=u.backend.numDataIds();m=g.kernelFunc({inputs:t,attrs:o,backend:u.backend});var n=Array.isArray(m)?m:[m];u.shouldCheckForMemLeaks()&&u.checkKernelForMemLeak(h,e,n);var r=n.map((function(e){var t=e.dataId,n=e.shape,r=e.dtype;return u.makeTensorFromDataId(t,n,r)})),s=r.filter((function(e,t){return i[t]}));return p(a.slice().concat(s)),r}:function(){var t=u.backend.numDataIds();m=u.tidy((function(){return e(u.backend,p)}));var n=Array.isArray(m)?m:[m];return u.shouldCheckForMemLeaks()&&u.checkKernelForMemLeak(h,t,n),n},this.scopedRun((function(){return u.state.kernelDepth++}),(function(){return u.state.kernelDepth--}),(function(){s=u.ENV.getBool("DEBUG")?u.profiler.profileKernel(h,t,(function(){return c()})):c()})),f&&this.addTapeNode(h,t,s,n,l),this.state.profiling&&this.state.activeProfile.kernels.push({name:h,bytesAdded:this.state.numBytes-d,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-v,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(t).map((function(e){return t[e].shape})),outputShapes:s.map((function(e){return e.shape}))}),Array.isArray(m)?s:s[0]},e.prototype.makeTensor=function(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;var o=e;"string"===n&&Ae(e[0])&&(o=e.map((function(e){return He(e)})));var a=r.write(o,t,n),i=new et(t,n,a,this.nextTensorId());if(this.incRef(i,r),"string"===n){var s=this.state.tensorInfo.get(a),u=Re(o);this.state.numBytes+=u-s.bytes,s.bytes=u}return i},e.prototype.makeTensorFromDataId=function(e,t,n,r){var o=new et(t,n=n||"float32",e,this.nextTensorId());return this.incRef(o,r),o},e.prototype.makeVariable=function(e,t,n,r){void 0===t&&(t=!0),n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.asType(r));var o=new it(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[o.name])throw new Error("Variable with name "+o.name+" was already registered");return this.state.registeredVariables[o.name]=o,this.incRef(o,this.backend),o},e.prototype.incRef=function(e,t){var n=this.state.tensorInfo.has(e.dataId)?this.state.tensorInfo.get(e.dataId).refCount:0;if(this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++,0===n){this.state.numDataBuffers++;var r=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(r=e.size*Se(e.dtype)),this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:r,refCount:0}),this.state.numBytes+=r}this.state.tensorInfo.get(e.dataId).refCount++,e instanceof it||this.track(e)},e.prototype.disposeTensor=function(e){if(this.state.tensorInfo.has(e.dataId)){this.state.numTensors--,"string"===e.dtype&&this.state.numStringTensors--;var t=this.state.tensorInfo.get(e.dataId);t.refCount<=1?("complex64"!==e.dtype&&(this.state.numBytes-=t.bytes),this.state.numDataBuffers--,t.backend.disposeData(e.dataId),this.state.tensorInfo.delete(e.dataId)):this.state.tensorInfo.get(e.dataId).refCount--}},e.prototype.disposeVariables=function(){for(var e in this.state.registeredVariables){var t=this.state.registeredVariables[e];this.disposeVariable(t)}},e.prototype.disposeVariable=function(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]},e.prototype.memory=function(){var 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,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e},e.prototype.profile=function(e){return K(this,void 0,void 0,(function(){var t,n;return $(this,(function(r){return this.state.profiling=!0,t=this.state.numBytes,n=this.state.numTensors,this.state.activeProfile.kernels=[],this.state.activeProfile.result=e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max.apply(Math,this.state.activeProfile.kernels.map((function(e){return e.totalBytesSnapshot}))),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n,[2,this.state.activeProfile]}))}))},e.prototype.isTapeOn=function(){return this.state.gradientDepth>0&&0===this.state.kernelDepth},e.prototype.addTapeNode=function(e,t,n,r,o){var a=this,i={id:this.state.nextTapeNodeId++,name:e,inputs:t,outputs:n,saved:o};null!=r&&(i.gradient=function(e){return e=e.map((function(e,t){if(null==e){var r=n[t],o=ze(r.size,r.dtype);return a.makeTensor(o,r.shape,r.dtype)}return e})),r(e.length>1?e:e[0],o)}),this.state.activeTape.push(i)},e.prototype.keep=function(e){return e.kept=!0,e},e.prototype.startTape=function(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++},e.prototype.endTape=function(){this.state.gradientDepth--},e.prototype.startScope=function(e){var t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t},e.prototype.endScope=function(e){for(var t=this,n=ht(e),r=new Set(n.map((function(e){return e.id}))),o=0;o<this.state.activeScope.track.length;o++){var a=this.state.activeScope.track[o];a.kept||r.has(a.id)||a.dispose()}var i=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],n.forEach((function(e){e.kept||e.scopeId!==i.id||t.track(e)}))},e.prototype.gradients=function(e,t,n,r){var o=this;if(void 0===r&&(r=!1),ue(t.length>0,(function(){return"gradients() received an empty list of xs."})),null!=n&&"float32"!==n.dtype)throw new Error("dy must have 'float32' dtype, but has '"+n.dtype+"'");var a=this.scopedRun((function(){return o.startTape()}),(function(){return o.endTape()}),(function(){return o.tidy("forward",e)}));ue(a instanceof et,(function(){return"The result y returned by f() must be a tensor."}));var i=function(e,t,n){for(var r={},o={},a=0;a<t.length;a++)r[t[a].id]=!0;for(a=0;a<e.length;a++){var i=(d=e[a]).inputs;for(var s in i){for(var u=i[s],c=!1,l=0;l<t.length;l++)if(r[u.id]){d.outputs.forEach((function(e){return r[e.id]=!0})),c=!0,o[d.id]=!0;break}if(c)break}}var f={};f[n.id]=!0;var h={};for(a=e.length-1;a>=0;a--)for(i=(d=e[a]).inputs,l=0;l<d.outputs.length;l++)if(f[d.outputs[l].id]){for(var s in i)f[i[s].id]=!0,h[d.id]=!0;break}var p=[];for(a=0;a<e.length;a++){var d;if(o[(d=e[a]).id]&&h[d.id]){var v={};for(var s in d.inputs){var m=d.inputs[s];r[m.id]&&(v[s]=m)}var g=Object.assign({},d);g.inputs=v,g.outputs=d.outputs,p.push(g)}}return p}(this.state.activeTape,t,a);if(!r&&0===i.length&&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",(function(){var e,r,s={};s[a.id]=null==n?(r=Le(he(e=a.shape),"float32"),mt.makeTensor(r,e,"float32")):n,function(e,t,n){for(var r=function(r){var o=t[r],a=[];if(o.outputs.forEach((function(t){var n=e[t.id];null!=n?a.push(n):a.push(null)})),null==o.gradient)throw new Error("Cannot compute gradient: gradient function not found for "+o.name+".");var i=o.gradient(a),s=function(t){if(!(t in i))throw new Error("Cannot backprop through input "+t+". Available gradients found: "+Object.keys(i)+".");var r=n((function(){return i[t]()}));if("float32"!==r.dtype)throw new Error("Error in gradient for op "+o.name+". The gradient of input "+t+" must have 'float32' dtype, but has '"+r.dtype+"'");var a=o.inputs[t];if(!pe(r.shape,a.shape))throw new Error("Error in gradient for op "+o.name+". The gradient of input '"+t+"' has shape '"+r.shape+"', which does not match the shape of the input '"+a.shape+"'");if(null==e[a.id])e[a.id]=r;else{var s=e[a.id];e[a.id]=s.add(r),s.dispose()}};for(var u in o.inputs)s(u)},o=t.length-1;o>=0;o--)r(o)}(s,i,(function(e){return o.tidy(e)}));var u=t.map((function(e){return s[e.id]}));return 0===o.state.gradientDepth&&(o.state.activeTape.forEach((function(e){for(var t=0,n=e.saved;t<n.length;t++)n[t].dispose()})),o.state.activeTape=null),{value:a,grads:u}}))},e.prototype.customGrad=function(e){var t=this;return ue(Me(e),(function(){return"The f passed in customGrad(f) must be a function."})),function(){for(var n,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];ue(r.every((function(e){return e instanceof et})),(function(){return"The args passed in customGrad(f)(x1, x2,...) must all be tensors"}));var a={};return r.forEach((function(e,t){a[t]=e})),t.runKernelFunc((function(t,o){return ue((n=e.apply(void 0,r.concat([o]))).value instanceof et,(function(){return"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"})),ue(Me(n.gradFunc),(function(){return"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."})),n.value}),a,(function(e,t){var o=n.gradFunc(e,t),a=Array.isArray(o)?o:[o];ue(a.length===r.length,(function(){return"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(...)."})),ue(a.every((function(e){return e instanceof et})),(function(){return"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."}));var i={};return a.forEach((function(e,t){i[t]=function(){return e}})),i}))}},e.prototype.readSync=function(e){return this.state.tensorInfo.get(e).backend.readSync(e)},e.prototype.read=function(e){return this.state.tensorInfo.get(e).backend.read(e)},e.prototype.time=function(e){return K(this,void 0,void 0,(function(){var t,n;return $(this,(function(r){switch(r.label){case 0:return t=We(),[4,this.backend.time(e)];case 1:return(n=r.sent()).wallMs=We()-t,[2,n]}}))}))},e.prototype.track=function(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e},Object.defineProperty(e.prototype,"registeredVariables",{get:function(){return this.state.registeredVariables},enumerable:!0,configurable:!0}),e.prototype.reset=function(){for(var e in this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new dt,this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null},e.nextTensorId=0,e.nextVariableId=0,e}(),mt=function(){var e=function(){if(null==pt){var e=void 0;if("undefined"!=typeof window)e=window;else if(void 0!==n.g)e=n.g;else if("undefined"!=typeof process)e=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}pt=e}return pt}();if(null==e._tfengine){var t=new Z(e);e._tfengine=new vt(t)}return function(e){J=e}(e._tfengine.ENV),Ye=function(){return e._tfengine},e._tfengine}();function gt(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}var yt=Y();yt.registerFlag("DEBUG",(function(){return!1}),(function(e){e&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")})),yt.registerFlag("IS_BROWSER",(function(){return gt()})),yt.registerFlag("IS_NODE",(function(){return"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node})),yt.registerFlag("IS_CHROME",(function(){return"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)})),yt.registerFlag("PROD",(function(){return!1})),yt.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(function(){return yt.getBool("DEBUG")})),yt.registerFlag("DEPRECATION_WARNINGS_ENABLED",(function(){return!0})),yt.registerFlag("IS_TEST",(function(){return!1}));var bt,wt,xt,Et={},_t={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function Ot(e,t){Et[e]=t}function kt(e){e in Et||(Et[e]=function(e){if(1!==e&&2!==e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");var t=function(e){if("undefined"!=typeof OffscreenCanvas&&2===e)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}(e);return t.addEventListener("webglcontextlost",(function(t){t.preventDefault(),delete Et[e]}),!1),1===e?t.getContext("webgl",_t)||t.getContext("experimental-webgl",_t):t.getContext("webgl2",_t)}(e));var t=Et[e];return t.isContextLost()?(delete Et[e],kt(e)):(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),Et[e])}function Ct(e,t){return[t,e]}function It(e){var t=he(e);return me(Math.ceil(t/4))}function St(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function Rt(e,t){var n,r,o,a,i,s,u,c,l,f=e;return 2===Y().getNumber("WEBGL_VERSION")?(n=f.R32F,r=f.R16F,o=f.RGBA16F,a=f.RGBA32F,i=f.RED,s=4,u=1,c=f.HALF_FLOAT,l=f.FLOAT):(n=e.RGBA,r=e.RGBA,o=e.RGBA,a=f.RGBA,i=e.RGBA,s=4,u=4,c=null!=t?t.HALF_FLOAT_OES:null,l=e.FLOAT),{internalFormatFloat:n,internalFormatHalfFloat:r,internalFormatPackedHalfFloat:o,internalFormatPackedFloat:a,textureFormatFloat:i,downloadTextureFormat:e.RGBA,downloadUnpackNumChannels:s,defaultNumChannels:u,textureTypeHalfFloat:c,textureTypeFloat:l}}function At(e,t,n){var r=n();return t&&function(e){var t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+Tt(e,t))}(e),r}!function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"}(bt||(bt={})),function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"}(wt||(wt={})),function(e){e[e.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",e[e.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",e[e.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",e[e.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",e[e.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(xt||(xt={}));function Pt(e){return!!(Y().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||5.96e-8<Math.abs(e)&&Math.abs(e)<65504)}function Tt(e,t){switch(t){case e.NO_ERROR:return"NO_ERROR";case e.INVALID_ENUM:return"INVALID_ENUM";case e.INVALID_VALUE:return"INVALID_VALUE";case e.INVALID_OPERATION:return"INVALID_OPERATION";case e.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case e.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case e.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"Unknown error code "+t}}function Dt(e,t,n){return nn(e,t,(function(){return e.getExtension(n)}),'Extension "'+n+'" not supported on this browser.')}function Mt(e,t,n){var r=nn(e,t,(function(){return e.createShader(e.VERTEX_SHADER)}),"Unable to create vertex WebGLShader.");if(At(e,t,(function(){return e.shaderSource(r,n)})),At(e,t,(function(){return e.compileShader(r)})),!1===e.getShaderParameter(r,e.COMPILE_STATUS))throw e.getShaderInfoLog(r),new Error("Failed to compile vertex shader.");return r}function Nt(e,t,n){var r=nn(e,t,(function(){return e.createShader(e.FRAGMENT_SHADER)}),"Unable to create fragment WebGLShader.");if(At(e,t,(function(){return e.shaderSource(r,n)})),At(e,t,(function(){return e.compileShader(r)})),!1===e.getShaderParameter(r,e.COMPILE_STATUS))throw function(e,t){var n=jt.exec(t);if(null!=n){for(var r=+n[1],o=e.split("\n"),a=o.length.toString().length+2,i=o.map((function(e,t){return ge((t+1).toString(),a)+e})),s=0,u=0;u<i.length;u++)s=Math.max(i[u].length,s);var c=i.slice(0,r-1),l=i.slice(r-1,r),f=i.slice(r);c.join("\n"),t.split("\n")[0],ge(l[0],s),f.join("\n")}}(n,e.getShaderInfoLog(r)),new Error("Failed to compile fragment shader.");return r}var Ft,Bt,jt=/ERROR: [0-9]+:([0-9]+):/g;function Lt(e,t){return nn(e,t,(function(){return e.createProgram()}),"Unable to create WebGLProgram.")}function zt(e,t,n){if(At(e,t,(function(){return e.linkProgram(n)})),!1===e.getProgramParameter(n,e.LINK_STATUS))throw e.getProgramInfoLog(n),new Error("Failed to link vertex and fragment shaders.")}function Wt(e,t,n){if(At(e,t,(function(){return e.validateProgram(n)})),!1===e.getProgramParameter(n,e.VALIDATE_STATUS))throw e.getProgramInfoLog(n),new Error("Shader program validation failed.")}function Vt(e,t,n){var r=nn(e,t,(function(){return e.createBuffer()}),"Unable to create WebGLBuffer");return At(e,t,(function(){return e.bindBuffer(e.ARRAY_BUFFER,r)})),At(e,t,(function(){return e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW)})),r}function Ht(e,t,n){var r=nn(e,t,(function(){return e.createBuffer()}),"Unable to create WebGLBuffer");return At(e,t,(function(){return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r)})),At(e,t,(function(){return e.bufferData(e.ELEMENT_ARRAY_BUFFER,n,e.STATIC_DRAW)})),r}function Ut(e,t){return nn(e,t,(function(){return e.createTexture()}),"Unable to create WebGLTexture.")}function Gt(e,t){var n=Y().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0){var r="["+e+"x"+t+"]";throw new Error("Requested texture size "+r+" is invalid.")}if(e>n||t>n)throw r="["+e+"x"+t+"]",new Error("Requested texture size "+r+" greater than WebGL maximum on this browser / GPU ["+n+"x"+n+"].")}function qt(e,t){return nn(e,t,(function(){return e.createFramebuffer()}),"Unable to create WebGLFramebuffer.")}function Xt(e,t,n,r,o,a,i,s){var u=e.getAttribLocation(n,r);return-1!==u&&(At(e,t,(function(){return e.bindBuffer(e.ARRAY_BUFFER,o)})),At(e,t,(function(){return e.vertexAttribPointer(u,a,e.FLOAT,!1,i,s)})),At(e,t,(function(){return e.enableVertexAttribArray(u)})),!0)}function Kt(e,t,n,r){rn(e,r),At(e,t,(function(){return e.activeTexture(e.TEXTURE0+r)})),At(e,t,(function(){return e.bindTexture(e.TEXTURE_2D,n)}))}function $t(e,t,n,r){return nn(e,t,(function(){return e.getUniformLocation(n,r)}),'uniform "'+r+'" not present in program.')}function Zt(e,t,n){return e.getUniformLocation(t,n)}function Yt(e,t,n,r,o,a){At(e,t,(function(){return Kt(e,t,r,a)})),At(e,t,(function(){return e.uniform1i(o,a)}))}function Jt(e,t,n,r){At(e,t,(function(){return e.bindFramebuffer(e.FRAMEBUFFER,r)})),At(e,t,(function(){return e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0)}))}function Qt(e,t,n){At(e,t,(function(){return e.bindFramebuffer(e.FRAMEBUFFER,n)})),At(e,t,(function(){return e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)}))}function en(e){var t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+tn(e,t))}function tn(e,t){switch(t){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case e.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return"unknown error "+t}}function nn(e,t,n,r){var o=At(e,t,(function(){return n()}));if(null==o)throw new Error(r);return o}function rn(e,t){var n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+e.TEXTURE0;if(r<e.TEXTURE0||r>n)throw new Error("textureUnit must be in [gl.TEXTURE0, gl.TEXTURE"+n+"].")}function on(e,t){return void 0===t&&(t=2),he(e.slice(0,e.length-t))}function an(e){if(0===e.length)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]}function sn(e){var t=[1,1,1];return 0===e.length||1===e.length&&1===e[0]||(t=[on(e)].concat(an(e))),t}function un(e,t){var n;void 0===t&&(t=!1);var r=Y().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t&&(r*=2,1===(e=e.map((function(t,n){return n>=e.length-2?ie(e[n]):e[n]}))).length&&(e=[2,e[0]])),2!==e.length){var o=xe(e);e=o.newShape}var a=he(e);if(e.length<=1&&a<=r)return[1,a];if(2===e.length&&e[0]<=r&&e[1]<=r)return e;if(3===e.length&&e[0]*e[1]<=r&&e[2]<=r)return[e[0]*e[1],e[2]];if(3===e.length&&e[0]<=r&&e[1]*e[2]<=r)return[e[0],e[1]*e[2]];if(4===e.length&&e[0]*e[1]*e[2]<=r&&e[3]<=r)return[e[0]*e[1]*e[2],e[3]];if(4===e.length&&e[0]<=r&&e[1]*e[2]*e[3]<=r)return[e[0],e[1]*e[2]*e[3]];if(t){var i=on(e),s=2,u=2;return e.length&&(s=(n=an(e))[0],u=n[1]),me(a=i*(s/2)*(u/2)).map((function(e){return 2*e}))}return me(a)}function cn(e){return e%2==0}function ln(e,t){if(pe(e=e.slice(-2),t=t.slice(-2)))return!0;if(!e.length||!t.length)return!0;if(0===e[0]||0===e[1]||0===t[0]||0===t[1])return!0;if(e.length!==t.length){var n=e.slice(-1)[0],r=t.slice(-1)[0];if(n===r)return!0;if(cn(n)&&cn(r)&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&cn(e[0])&&cn(t[0])}function fn(e){if(null==Ft){var t=kt(e);Ft=t.getParameter(t.MAX_TEXTURE_SIZE)}return Ft}function hn(e){if(null==Bt){var t=kt(e);Bt=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,Bt)}function pn(e){if(0===e)return 0;var t=kt(e);return dn(t,"EXT_disjoint_timer_query_webgl2")&&2===e?2:dn(t,"EXT_disjoint_timer_query")?1:0}function dn(e,t){return null!=e.getExtension(t)}function vn(e){try{if(null!=kt(e))return!0}catch(e){return!1}return!1}function mn(e){if(0===e)return!1;var t=kt(e);if(1===e){if(!dn(t,"OES_texture_float"))return!1}else if(!dn(t,"EXT_color_buffer_float"))return!1;return yn(t)}function gn(e){if(0===e)return!1;var t=kt(e);if(1!==e){if(dn(t,"EXT_color_buffer_float"))return yn(t);if(dn(t,"EXT_color_buffer_half_float")){var n=t.getExtension("EXT_color_buffer_half_float");return function(e,t){var n=Rt(e,t),r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texImage2D(e.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);var o=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,o),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);var a=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(o),a}(t,n)}return!1}return!!dn(t,"OES_texture_float")&&!!dn(t,"WEBGL_color_buffer_float")&&yn(t)}function yn(e){var t=Rt(e),n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,1,1,0,t.textureFormatFloat,t.textureTypeFloat,null);var r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);var o=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(r),o}function bn(e){return 2===e&&null!=kt(e).fenceSync}var wn=Object.freeze({callAndCheck:At,canBeRepresented:Pt,getWebGLErrorMessage:Tt,getExtensionOrThrow:Dt,createVertexShader:Mt,createFragmentShader:Nt,createProgram:Lt,linkProgram:zt,validateProgram:Wt,createStaticVertexBuffer:Vt,createStaticIndexBuffer:Ht,getNumChannels:function(){return 2===Y().getNumber("WEBGL_VERSION")?1:4},createTexture:Ut,validateTextureSize:Gt,createFramebuffer:qt,bindVertexBufferToProgramAttribute:Xt,bindTextureUnit:Kt,unbindTextureUnit:function(e,t,n){rn(e,n),At(e,t,(function(){return e.activeTexture(e.TEXTURE0+n)})),At(e,t,(function(){return e.bindTexture(e.TEXTURE_2D,null)}))},getProgramUniformLocationOrThrow:$t,getProgramUniformLocation:Zt,bindTextureToProgramUniformSampler:Yt,bindCanvasToFramebuffer:function(e,t){At(e,t,(function(){return e.bindFramebuffer(e.FRAMEBUFFER,null)})),At(e,t,(function(){return e.viewport(0,0,e.canvas.width,e.canvas.height)})),At(e,t,(function(){return e.scissor(0,0,e.canvas.width,e.canvas.height)}))},bindColorTextureToFramebuffer:Jt,unbindColorTextureFromFramebuffer:Qt,validateFramebuffer:en,getFramebufferErrorMessage:tn,getBatchDim:on,getRowsCols:an,getShapeAs3D:sn,getTextureShapeFromLogicalShape:un,isReshapeFree:ln,getWebGLMaxTextureSize:fn,resetMaxTextureSize:function(){Ft=null},resetMaxTexturesInShader:function(){Bt=null},getMaxTexturesInShader:hn,getWebGLDisjointQueryTimerVersion:pn,hasExtension:dn,isWebGLVersionEnabled:vn,isCapableOfRenderingToFloatTexture:mn,isDownloadFloatTextureEnabled:gn,isWebGLFenceEnabled:bn}),xn=Y();function En(e){Y().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function _n(e,t){return mt.tidy(e,t)}function On(e){ht(e).forEach((function(e){return e.dispose()}))}function kn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];Y().getBool("IS_TEST")||console.warn.apply(console,e)}function Cn(e,t){var n=e;if(Ie(e))return"string"===t?[]:[e.length];if(!Array.isArray(e))return[];for(var r=[];Array.isArray(n)||Ie(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&Y().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&function e(t,n,r){if(r=r||[],Array.isArray(t)||Ie(t)){ue(n.length>0,(function(){return"Element arr["+r.join("][")+"] should be a primitive, but is an array of "+t.length+" elements"})),ue(t.length===n[0],(function(){return"Element arr["+r.join("][")+"] should have "+n[0]+" elements, but has "+t.length+" elements"}));for(var o=n.slice(1),a=0;a<t.length;++a)e(t[a],o,r.concat(a))}else ue(0===n.length,(function(){return"Element arr["+r.join("][")+"] is a primitive, but should be an array/TypedArray of "+n[0]+" elements"}))}(e,r,[]),r}function In(e,t,n,r){if(null!=e&&("numeric"!==e&&e!==t||"numeric"===e&&"string"===t))throw new Error("Argument '"+n+"' passed to '"+r+"' must be "+e+" tensor, but got "+t+" tensor")}function Sn(e,t,n,r){if(void 0===r&&(r="numeric"),e instanceof et)return In(r,e.dtype,t,n),e;var o=De(e);if("string"!==o&&["bool","int32","float32"].indexOf(r)>=0&&(o=r),In(r,o,t,n),null==e||!Ie(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){var a=null==e?"null":e.constructor.name;throw new Error("Argument '"+t+"' passed to '"+n+"' must be a Tensor or TensorLike, but got '"+a+"'")}var i=Cn(e,o);Ie(e)||Array.isArray(e)||(e=[e]);var s="string"!==o?Be(e,o,Y().getBool("DEBUG")):fe(e,[],!0);return mt.makeTensor(s,i,o)}function Rn(e,t,n,r){if(void 0===r&&(r="numeric"),!Array.isArray(e))throw new Error("Argument "+t+" passed to "+n+" must be a `Tensor[]` or `TensorLike[]`");return e.map((function(e,r){return Sn(e,t+"["+r+"]",n)}),r)}function An(e,t){for(var n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function Pn(e,t,n){for(var r=e.length+t.length,o=[],a=0,i=0,s=0;s<r;s++)-1===n.indexOf(s)?o.push(e[a++]):o.push(t[i++]);return o}function Tn(e,t){for(var n=[],r=e.length,o=0;o<r;o++)-1===t.indexOf(o)&&n.push(e[o]);return[n,t.map((function(t){return e[t]}))]}function Dn(e,t){return Pn(e,t.map((function(e){return 1})),t)}function Mn(e,t,n){ue(An(t,n),(function(){return e+" supports only inner-most axes for now. Got axes "+t+" and rank-"+n+" input."}))}function Nn(e,t){if(An(e,t))return null;for(var n=[],r=0;r<t;++r)-1===e.indexOf(r)&&n.push(r);return e.forEach((function(e){return n.push(e)})),n}function Fn(e){return e.map((function(e,t){return[t,e]})).sort((function(e,t){return e[1]-t[1]})).map((function(e){return e[0]}))}function Bn(e,t){for(var n=[],r=t-e;r<t;++r)n.push(r);return n}function jn(e,t){var n=e[0].length;e.forEach((function(e,t){ue(e.length===n,(function(){return"Error in concat"+n+"D: rank of tensors["+t+"] must be the same as the rank of the rest ("+n+")"}))})),ue(t>=0&&t<n,(function(){return"Error in concat"+n+"D: axis must be between 0 and "+(n-1)+"."}));var r=e[0];e.forEach((function(e,o){for(var a=0;a<n;a++)ue(a===t||e[a]===r[a],(function(){return"Error in concat"+n+"D: Shape of tensors["+o+"] ("+e+") does not match the shape of the rest ("+r+") along the non-concatenated axis "+o+"."}))}))}function Ln(e,t){for(var n=e[0].slice(),r=1;r<e.length;r++)n[t]+=e[r][t];return n}function zn(e){var t=Object.keys(e);if(1!==t.length)throw new Error("Please provide an object with a single key (operation name) mapping to a function. Got an object with "+t.length+" keys.");var n=t[0],r=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1));var o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];mt.startScope(n);try{var o=r.apply(void 0,e);return o instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),mt.endScope(o),o}catch(e){throw mt.endScope(null),e}};return Object.defineProperty(o,"name",{value:n,configurable:!0}),o}xn.registerFlag("HAS_WEBGL",(function(){return xn.getNumber("WEBGL_VERSION")>0})),xn.registerFlag("WEBGL_VERSION",(function(){return vn(2)?2:vn(1)?1:0})),xn.registerFlag("WEBGL_BUFFER_SUPPORTED",(function(){return 2===xn.get("WEBGL_VERSION")})),xn.registerFlag("WEBGL_CPU_FORWARD",(function(){return!0})),xn.registerFlag("WEBGL_FORCE_F16_TEXTURES",(function(){return!1})),xn.registerFlag("WEBGL_PACK",(function(){return xn.getBool("HAS_WEBGL")})),xn.registerFlag("WEBGL_PACK_NORMALIZATION",(function(){return xn.getBool("WEBGL_PACK")})),xn.registerFlag("WEBGL_PACK_CLIP",(function(){return xn.getBool("WEBGL_PACK")})),xn.registerFlag("WEBGL_PACK_DEPTHWISECONV",(function(){return!1})),xn.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(function(){return xn.getBool("WEBGL_PACK")})),xn.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(function(){return xn.getBool("WEBGL_PACK")})),xn.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(function(){return xn.getBool("WEBGL_PACK")})),xn.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(function(){return xn.getBool("WEBGL_PACK")})),xn.registerFlag("WEBGL_PACK_REDUCE",(function(){return xn.getBool("WEBGL_PACK")})),xn.registerFlag("WEBGL_LAZILY_UNPACK",(function(){return xn.getBool("WEBGL_PACK")})),xn.registerFlag("WEBGL_CONV_IM2COL",(function(){return xn.getBool("WEBGL_PACK")})),xn.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(function(){return fn(xn.getNumber("WEBGL_VERSION"))})),xn.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(function(){return hn(xn.getNumber("WEBGL_VERSION"))})),xn.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(function(){var e=xn.getNumber("WEBGL_VERSION");return 0===e?0:pn(e)})),xn.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(function(){return xn.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&(e=navigator.userAgent||navigator.vendor||window.opera,!(/(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))));var e})),xn.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(function(){return mn(xn.getNumber("WEBGL_VERSION"))})),xn.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(function(){return!xn.getBool("WEBGL_FORCE_F16_TEXTURES")&&xn.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")})),xn.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(function(){return gn(xn.getNumber("WEBGL_VERSION"))})),xn.registerFlag("WEBGL_FENCE_API_ENABLED",(function(){return bn(xn.getNumber("WEBGL_VERSION"))})),xn.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(function(){return xn.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0})),Qe=En;var Wn=zn({complex_:function(e,t){var n=Sn(e,"real","complex"),r=Sn(t,"imag","complex");return ce(n.shape,r.shape,"real and imag shapes, "+n.shape+" and "+r.shape+", must match in call to tf.complex()."),mt.runKernelFunc((function(e){return e.complex(n,r)}),{$real:n,$imag:r})}}),Vn=zn({real_:function(e){var t=Sn(e,"input","real");return mt.runKernelFunc((function(e){return e.real(t)}),{$input:t})}}),Hn=zn({imag_:function(e){var t=Sn(e,"input","imag");return mt.runKernelFunc((function(e){return e.imag(t)}),{$input:t})}});function Un(e,t,n){return Gn(e,t,Cn(e,n),n)}function Gn(e,t,n,r){if(null==r&&(r=De(e)),"complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!Ie(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)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(null!=t){Ve(t);var o=he(t),a=he(n);ue(o===a,(function(){return"Based on the provided shape, ["+t+"], the tensor should have "+o+" values but has "+a}));for(var i=0;i<n.length;++i){var s=n[i],u=i!==n.length-1||s!==he(t.slice(i));ue(n[i]===t[i]||!u,(function(){return"Error creating a new Tensor. Inferred shape ("+n+") does not match the provided shape ("+t+"). "}))}}return Ie(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?Be(e,r,Y().getBool("DEBUG")):fe(e,[],!0),mt.makeTensor(e,t,r)}function qn(e,t){if((Ie(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&Ie(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return Gn(e,[],[],t)}function Xn(e,t){le(e);var n=Cn(e,t);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return Gn(e,null,n,t)}function Kn(e,t,n){if(le(e),null!=t&&2!==t.length)throw new Error("tensor2d() requires shape to have two numbers");var r=Cn(e,n);if(2!==r.length&&1!==r.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return Gn(e,t,r,n)}function $n(e,t,n){if(le(e),null!=t&&3!==t.length)throw new Error("tensor3d() requires shape to have three numbers");var r=Cn(e,n);if(3!==r.length&&1!==r.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Gn(e,t,r,n)}function Zn(e,t,n){if(le(e),null!=t&&4!==t.length)throw new Error("tensor4d() requires shape to have four numbers");var r=Cn(e,n);if(4!==r.length&&1!==r.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return Gn(e,t,r,n)}function Yn(e,t){if(void 0===t&&(t="float32"),"complex64"===t){var n=Yn(e,"float32"),r=Jn(e,"float32");return Wn(n,r)}var o=Le(he(e),t);return mt.makeTensor(o,e,t)}function Jn(e,t){if(void 0===t&&(t="float32"),"complex64"===t){var n=Jn(e,"float32"),r=Jn(e,"float32");return Wn(n,r)}var o=ze(he(e),t);return mt.makeTensor(o,e,t)}function Qn(e,t,n){return mt.runKernelFunc((function(r){return r.fill(e,t,n)}),{})}function er(e,t,n,r){if(void 0===n&&(n=1),void 0===r&&(r="float32"),0===n)throw new Error("Cannot have a step of zero");if(e===t||e<t&&n<0||t<e&&n>1)return Jn([0],r);var o=ze(Math.abs(Math.ceil((t-e)/n)),r);t<e&&1===n&&(n=-1),o[0]=e;for(var a=1;a<o.length;a++)o[a]=o[a-1]+n;return Xn(o,r)}var tr=zn({onesLike_:function(e){var t=Sn(e,"x","onesLike");if("complex64"===t.dtype){var n=tr(Vn(t)),r=nr(Hn(t));return Wn(n,r)}return mt.runKernelFunc((function(e){return e.onesLike(t)}),{$x:t},(function(e,t){return{$x:function(){return nr(e)}}}))}}),nr=zn({zerosLike_:function(e){var t=Sn(e,"x","zerosLike");return mt.runKernelFunc((function(e){return e.zerosLike(t)}),{$x:t},(function(e,t){return{$x:function(){return nr(e)}}}))}}),rr=zn({concat_:function(e,t){void 0===t&&(t=0),ue(e.length>=1,(function(){return"Pass at least one tensor to concat"}));var n=Rn(e,"tensors","concat");"complex64"===n[0].dtype&&n.forEach((function(e){if("complex64"!==e.dtype)throw new Error("Cannot concatenate complex64 tensors with a tensor\n with dtype "+e.dtype+". ")})),t=we(t,n[0].shape)[0];var r=Ln(n.map((function(e){return e.shape})),t);if(0===he(r))return Un([],r);if(1===(n=n.filter((function(e){return e.size>0}))).length)return n[0];var o=n.map((function(e){return e.shape}));jn(o,t);var a=n,i={axis:t};return mt.runKernelFunc((function(e){return e.concat(n,t)}),a,(function(e){var n=o.map((function(e){return e[t]}));return ur(e,n,t).map((function(e){return function(){return e}}))}),"Concat",i)}}),or=zn({concat1d_:function(e){return rr(e,0)}}),ar=zn({concat2d_:function(e,t){return rr(e,t)}}),ir=zn({concat3d_:function(e,t){return rr(e,t)}}),sr=zn({concat4d_:function(e,t){return rr(e,t)}}),ur=zn({split_:function(e,t,n){void 0===n&&(n=0);var r,o=Sn(e,"x","split");return n=we(n,o.shape)[0],"number"==typeof t?(ue(o.shape[n]%t==0,(function(){return"Number of splits must evenly divide the axis."})),r=new Array(t).fill(o.shape[n]/t)):(ue(o.shape[n]===t.reduce((function(e,t){return e+t})),(function(){return"The sum of sizes must match the size of the axis dimension."})),r=t),mt.runKernelFunc((function(e){return e.split(o,r,n)}),{$x:o},(function(e){return{$x:function(){return rr(e,n)}}}))}});function cr(e,t){return e(t={exports:{}},t.exports),t.exports}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self&&self;var lr=cr((function(e){!function(e,t,n){function r(e){var t,n=this,r=(t=4022871197,function(e){e=e.toString();for(var n=0;n<e.length;n++){var r=.02519603282416938*(t+=e.charCodeAt(n));r-=t=r>>>0,t=(r*=t)>>>0,t+=4294967296*(r-=t)}return 2.3283064365386963e-10*(t>>>0)});n.next=function(){var e=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=e-(n.c=0|e)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(e),n.s0<0&&(n.s0+=1),n.s1-=r(e),n.s1<0&&(n.s1+=1),n.s2-=r(e),n.s2<0&&(n.s2+=1),r=null}function o(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function a(e,t){var n=new r(e),a=t&&t.state,i=n.next;return i.int32=function(){return 4294967296*n.next()|0},i.double=function(){return i()+11102230246251565e-32*(2097152*i()|0)},i.quick=i,a&&("object"==typeof a&&o(a,n),i.state=function(){return o(n,{})}),i}t&&t.exports?t.exports=a:this.alea=a}(0,e)})),fr=cr((function(e){!function(e,t,n){function r(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),t.next()}function o(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function a(e,t){var n=new r(e),a=t&&t.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=n.next,i.quick=i,a&&("object"==typeof a&&o(a,n),i.state=function(){return o(n,{})}),i}t&&t.exports?t.exports=a:this.xor128=a}(0,e)})),hr=cr((function(e){!function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),r==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function o(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function a(e,t){var n=new r(e),a=t&&t.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=n.next,i.quick=i,a&&("object"==typeof a&&o(a,n),i.state=function(){return o(n,{})}),i}t&&t.exports?t.exports=a:this.xorwow=a}(0,e)})),pr=cr((function(e){!function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.x,o=t.i;return e=r[o],n=(e^=e>>>7)^e<<24,n^=(e=r[o+1&7])^e>>>10,n^=(e=r[o+3&7])^e>>>3,n^=(e=r[o+4&7])^e<<7,e=r[o+7&7],n^=(e^=e<<13)^e<<9,r[o]=n,t.i=o+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n<t.length;++n)r[7&n]=r[7&n]<<15^t.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n?r[7]=-1:r[n],e.x=r,e.i=0,n=256;n>0;--n)e.next()}(t,e)}function o(e,t){return t.x=e.x.slice(),t.i=e.i,t}function a(e,t){null==e&&(e=+new Date);var n=new r(e),a=t&&t.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=n.next,i.quick=i,a&&(a.x&&o(a,n),i.state=function(){return o(n,{})}),i}t&&t.exports?t.exports=a:this.xorshift7=a}(0,e)})),dr=cr((function(e){!function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.w,o=t.X,a=t.i;return t.w=r=r+1640531527|0,n=o[a+34&127],e=o[a=a+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=o[a]=n^e,t.i=a,n+(r^r>>>16)|0},function(e,t){var n,r,o,a,i,s=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),o=0,a=-32;a<u;++a)t&&(r^=t.charCodeAt((a+32)%t.length)),0===a&&(i=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,a>=0&&(i=i+1640531527|0,o=0==(n=s[127&a]^=r+i)?o+1:0);for(o>=128&&(s[127&(t&&t.length||0)]=-1),o=127,a=512;a>0;--a)r=s[o+34&127],n=s[o=o+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[o]=r^n;e.w=i,e.X=s,e.i=o}(t,e)}function o(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function a(e,t){null==e&&(e=+new Date);var n=new r(e),a=t&&t.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=n.next,i.quick=i,a&&(a.X&&o(a,n),i.state=function(){return o(n,{})}),i}t&&t.exports?t.exports=a:this.xor4096=a}(0,e)})),vr=cr((function(e){!function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,o=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^o,o=o-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^o,t.a=o-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var r=0;r<n.length+20;r++)t.b^=0|n.charCodeAt(r),t.next()}function o(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function a(e,t){var n=new r(e),a=t&&t.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=n.next,i.quick=i,a&&("object"==typeof a&&o(a,n),i.state=function(){return o(n,{})}),i}t&&t.exports?t.exports=a:this.tychei=a}(0,e)})),mr=cr((function(e){!function(t,r){var o,a=this,i=256,s="random",u=r.pow(i,6),c=r.pow(2,52),l=2*c,f=255;function h(e,n,f){var h=[],g=v(function e(t,n){var r,o=[],a=typeof t;if(n&&"object"==a)for(r in t)try{o.push(e(t[r],n-1))}catch(e){}return o.length?o:"string"==a?t:t+"\0"}((n=1==n?{entropy:!0}:n||{}).entropy?[e,m(t)]:null==e?function(){try{var e;return o&&(e=o.randomBytes)?e=e(i):(e=new Uint8Array(i),(a.crypto||a.msCrypto).getRandomValues(e)),m(e)}catch(e){var n=a.navigator,r=n&&n.plugins;return[+new Date,a,r,a.screen,m(t)]}}():e,3),h),y=new p(h),b=function(){for(var e=y.g(6),t=u,n=0;e<c;)e=(e+n)*i,t*=i,n=y.g(1);for(;e>=l;)e/=2,t/=2,n>>>=1;return(e+n)/t};return b.int32=function(){return 0|y.g(4)},b.quick=function(){return y.g(4)/4294967296},b.double=b,v(m(y.S),t),(n.pass||f||function(e,t,n,o){return o&&(o.S&&d(o,y),e.state=function(){return d(y,{})}),n?(r[s]=e,t):e})(b,g,"global"in n?n.global:this==r,n.state)}function p(e){var t,n=e.length,r=this,o=0,a=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);o<i;)s[o]=o++;for(o=0;o<i;o++)s[o]=s[a=f&a+e[o%n]+(t=s[o])],s[a]=t;(r.g=function(e){for(var t,n=0,o=r.i,a=r.j,s=r.S;e--;)t=s[o=f&o+1],n=n*i+s[f&(s[o]=s[a=f&a+t])+(s[a]=t)];return r.i=o,r.j=a,n})(i)}function d(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function v(e,t){for(var n,r=e+"",o=0;o<r.length;)t[f&o]=f&(n^=19*t[f&o])+r.charCodeAt(o++);return m(t)}function m(e){return String.fromCharCode.apply(0,e)}if(r["seed"+s]=h,v(r.random(),t),e.exports){e.exports=h;try{o=n(4902)}catch(e){}}}([],Math)}));mr.alea=lr,mr.xor128=fr,mr.xorwow=hr,mr.xorshift7=pr,mr.xor4096=dr,mr.tychei=vr;var gr=mr.alea,yr=function(){function e(e,t,n,r,o){this.mean=e,this.stdDev=t,this.dtype=n,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);var a=o||Math.random();this.random=gr(a.toString())}return e.prototype.nextValue=function(){if(!isNaN(this.nextVal)){var e=this.nextVal;return this.nextVal=NaN,e}for(var t,n,r=!1;!r;){var o=void 0,a=void 0,i=void 0;do{i=(o=2*this.random()-1)*o+(a=2*this.random()-1)*a}while(i>=1||0===i);var s=Math.sqrt(-2*Math.log(i)/i);t=this.mean+this.stdDev*o*s,n=this.mean+this.stdDev*a*s,this.truncated&&!this.isValidTruncated(t)||(r=!0)}return this.truncated&&!this.isValidTruncated(n)||(this.nextVal=this.convertValue(n)),this.convertValue(t)},e.prototype.convertValue=function(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)},e.prototype.isValidTruncated=function(e){return e<=this.upper&&e>=this.lower},e}(),br=function(){function e(e,t,n,r){this.alpha=e,this.beta=1/t,this.dtype=n;var o=r||Math.random();this.randu=gr(o.toString()),this.randn=new yr(0,1,n,!1,this.randu()),this.d=e<1?e+2/3:e-1/3,this.c=1/Math.sqrt(9*this.d)}return e.prototype.nextValue=function(){for(var e,t,n,r,o,a;;){do{r=this.randn.nextValue(),a=1+this.c*r}while(a<=0);if(a*=a*a,t=1-.331*(e=r*r)*e,n=.5*e+this.d*(1-a+Math.log(a)),(o=this.randu())<t||Math.log(o)<n)break}return a=1/this.beta*this.d*a,this.alpha<1&&(a*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(a)},e.prototype.convertValue=function(e){return"float32"===this.dtype?e:Math.round(e)},e}(),wr=function(){function e(e,t,n,r){var o=this;if(void 0===e&&(e=0),void 0===t&&(t=1),this.canReturnFloat=function(){return null==o.dtype||"float32"===o.dtype},this.min=e,this.range=t-e,this.dtype=n,null==r&&(r=Math.random()),"number"==typeof r&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error("The difference between "+e+" - "+t+" <= 1 and dtype is not float");this.random=gr(r)}return e.prototype.convertValue=function(e){return this.canReturnFloat()?e:Math.round(e)},e.prototype.nextValue=function(){return this.convertValue(this.min+this.range*this.random())},e}();function xr(e,t,n){return void 0===t&&(t="float32"),t=t||"float32",Ve(e),new Ze(e,t,n)}var Er=zn({batchToSpaceND_:function(e,t,n){var r=Sn(e,"x","batchToSpaceND"),o=t.reduce((function(e,t){return e*t}));return ue(r.rank>=1+t.length,(function(){return"input rank is "+r.rank+" but should be > than blockShape.length "+t.length})),ue(n.length===t.length,(function(){return"crops.length is "+n.length+" but should be equal to blockShape.length "+t.length})),ue(r.shape[0]%o==0,(function(){return"input tensor batch is "+r.shape[0]+" but is not divisible by the product of the elements of blockShape "+t.join(" * ")+" === "+o})),mt.runKernelFunc((function(e){return e.batchToSpaceND(r,t,n)}),{$x:r},(function(e){return{$x:function(){return e.spaceToBatchND(t,n)}}}))}}),_r=zn({broadcastTo_:function(e,t){var n=Sn(e,"broadcastTo","x"),r=n.shape;if(t.some((function(e){return!(e>0)||e%1!=0})))throw new Error("broadcastTo(): Invalid broadcast shape ["+t+"].");if(t.length<n.rank)throw new Error("broadcastTo(): shape.length="+t.length+" < input.rank="+n.rank+".");if(t.length>n.rank){for(var o=n.shape.slice();o.length<t.length;)o.unshift(1);n=n.reshape(o)}for(var a=Array.from(t),i=t.length-1;i>=0;i--)if(n.shape[i]===t[i])a[i]=1;else if(1!==n.shape[i])throw new Error("broadcastTo(): ["+r+"] cannot be broadcast to ["+t+"].");var s=a.map((function(e,t){return e>1?t:-1})).filter((function(e){return e>=0}));return 0===s.length?n.clone():mt.runKernelFunc((function(e){return e.tile(n,a)}),{input:n},(function(e){return{input:function(){return e.sum(s,!0)}}}))}}),Or=zn({cast_:function(e,t){var n=Sn(e,"x","cast");if(!ke(t))throw new Error("Failed to cast to unknown dtype "+t);if("string"===t&&"string"!==n.dtype||"string"!==t&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");var r={dtype:t};return mt.runKernelFunc((function(e){return e.cast(n,t)}),{x:n},(function(e){return{x:function(){return e.clone()}}}),"Cast",r)}}),kr=zn({clone_:function(e){var t=Sn(e,"x","clone",null);return mt.runKernelFunc((function(){return mt.makeTensorFromDataId(t.dataId,t.shape,t.dtype)}),{$x:t},(function(e){return{$x:function(){return e.toFloat()}}}))}}),Cr=zn({cumsum_:function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=!1),void 0===r&&(r=!1);var o=Sn(e,"x","cumsum"),a=Nn([t|=0],o.rank),i=o;null!=a&&(i=o.transpose(a));var s=Bn(1,o.rank)[0],u=mt.runKernelFunc((function(e){return e.cumsum(i,s,n,r)}),{permutedX:i},(function(e){return{permutedX:function(){return e.cumsum(t,n,!r)}}}));return null!=a&&(u=u.transpose(a)),u}}),Ir=zn({depthToSpace_:function(e,t,n){void 0===n&&(n="NHWC");var r=Sn(e,"x","depthToSpace"),o="NHWC"===n?r.shape[1]:r.shape[2],a="NHWC"===n?r.shape[2]:r.shape[3],i="NHWC"===n?r.shape[3]:r.shape[1];return ue(o*t>=0,(function(){return"Negative dimension size caused by overflow when multiplying\n "+o+" and "+t+" for depthToSpace with input shape\n "+r.shape})),ue(a*t>=0,(function(){return"Negative dimension size caused by overflow when multiplying\n "+a+" and "+t+" for depthToSpace with input shape\n "+r.shape})),ue(i%(t*t)==0,(function(){return"Dimension size must be evenly divisible by "+t*t+" but is "+i+" for depthToSpace with input shape "+r.shape})),mt.runKernelFunc((function(e){return e.depthToSpace(r,t,n)}),{$x:r})}}),Sr=zn({expandDims_:function(e,t){void 0===t&&(t=0);var n=Sn(e,"x","expandDims",null);ue(t<=n.rank,(function(){return"Axis must be <= rank of the tensor"}));var r=n.shape.slice();return t<0&&(ue(-(n.rank+1)<=t,(function(){return"Axis must be in the interval ["+-(n.rank+1)+", "+n.rank+"]"})),t=n.rank+t+1),r.splice(t,0,1),Wr(n,r)}}),Rr=zn({eye_:function(e,t,n,r){void 0===r&&(r="float32"),null==t&&(t=e);for(var o=xr([e,t],r),a=e<=t?e:t,i=0;i<a;++i)o.set(1,i,i);var s=o.toTensor().as2D(e,t);if(null==n)return s;if(1===n.length)return Gr(Sr(s,0),[n[0],1,1]);if(2===n.length)return Gr(Sr(Sr(s,0),0),[n[0],n[1],1,1]);if(3===n.length)return Gr(Sr(Sr(Sr(s,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error("eye() currently supports only 1D and 2D batchShapes, but received "+n.length+"D.")}}),Ar=zn({multinomial_:function(e,t,n,r){void 0===r&&(r=!1);var o=Sn(e,"logits","multinomial"),a=o.size,i=o.rank;if(a<2)throw new Error("Error in multinomial: you need at least 2 outcomes, but got "+a+".");if(i>2)throw new Error("Rank of probabilities must be 1 or 2, but is "+i);n=n||Math.random();var s=1===i?o.as2D(1,-1):o,u=mt.runKernelFunc((function(e){return e.multinomial(s,r,t,n)}),{logits2D:s});return 1===i?u.as1D():u}}),Pr=zn({oneHot_:function(e,t,n,r){if(void 0===n&&(n=1),void 0===r&&(r=0),t<2)throw new Error("Error in oneHot: depth must be >=2, but it is "+t);var o=Sn(e,"indices","oneHot","int32"),a=o.shape.concat([t]);return o=o.flatten(),mt.runKernelFunc((function(e){return e.oneHot(o,t,n,r)}),{$indices:o},(function(e){return{$indices:function(){return Jn(o.shape,"float32")}}})).reshape(a)}}),Tr=zn({pad_:function(e,t,n){void 0===n&&(n=0);var r=Sn(e,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");var o={paddings:t,constantValue:n};return mt.runKernelFunc((function(e){return e.pad(r,t,n)}),{x:r},(function(e){var n=t.map((function(e){return e[0]}));return{x:function(){return e.slice(n,r.shape)}}}),"PadV2",o)}}),Dr=zn({pad1d_:function(e,t,n){return void 0===n&&(n=0),ue(2===t.length,(function(){return"Invalid number of paddings. Must be length of 2."})),Tr(e,[t],n)}}),Mr=zn({pad2d_:function(e,t,n){return void 0===n&&(n=0),ue(2===t.length&&2===t[0].length&&2===t[1].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),Tr(e,t,n)}}),Nr=zn({pad3d_:function(e,t,n){return void 0===n&&(n=0),ue(3===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),Tr(e,t,n)}}),Fr=zn({pad4d_:function(e,t,n){return void 0===n&&(n=0),ue(4===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length&&2===t[3].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),Tr(e,t,n)}}),Br=zn({rand_:function(e,t,n){var r=he(e),o=null;if(null==n||"float32"===n)o=new Float32Array(r);else if("int32"===n)o=new Int32Array(r);else{if("bool"!==n)throw new Error("Unknown data type "+n);o=new Uint8Array(r)}for(var a=0;a<r;a++)o[a]=t();return mt.makeTensor(o,e,n)}}),jr=zn({randomNormal_:function(e,t,n,r,o){if(void 0===t&&(t=0),void 0===n&&(n=1),null!=r&&"bool"===r)throw new Error("Unsupported data type "+r);for(var a=new yr(t,n,r,!1,o),i=xr(e,r),s=0;s<i.values.length;s++)i.values[s]=a.nextValue();return i.toTensor()}}),Lr=zn({randomGamma_:function(e,t,n,r,o){if(void 0===n&&(n=1),void 0===r&&(r="float32"),null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error("Unsupported data type "+r);for(var a=new br(t,n,r,o),i=xr(e,r),s=0;s<i.values.length;s++)i.values[s]=a.nextValue();return i.toTensor()}}),zr=zn({randomUniform_:function(e,t,n,r,o){void 0===t&&(t=0),void 0===n&&(n=1),void 0===r&&(r="float32");for(var a=xr(e,r),i=new wr(t,n,null,o),s=0;s<a.values.length;s++)a.values[s]=i.nextValue();return a.toTensor()}}),Wr=zn({reshape_:function(e,t){var n=Sn(e,"x","reshape",null);t=be(t,n.size),ue(n.size===he(t),(function(){return"new shape and old shape must have the same number of elements."}));var r={shape:t};return mt.runKernelFunc((function(e){return e.reshape(n,t)}),{x:n},(function(e){return{x:function(){return e.reshape(n.shape)}}}),"Reshape",r)}}),Vr=zn({spaceToBatchND_:function(e,t,n){var r=Sn(e,"x","spaceToBatchND");return ue(r.rank>=1+t.length,(function(){return"input rank "+r.rank+" should be > than [blockShape] "+t.length})),ue(n.length===t.length,(function(){return"paddings.shape[0] "+n.length+" must be equal to [blockShape] "+t.length})),ue(r.shape.reduce((function(e,r,o){return o>0&&o<=t.length?e&&(r+n[o-1][0]+n[o-1][1])%t[o-1]==0:e}),!0),(function(){return"input spatial dimensions "+r.shape.slice(1)+" with paddings "+n.toString()+" must be divisible by blockShapes "+t.toString()})),mt.runKernelFunc((function(e){return e.spaceToBatchND(r,t,n)}),{$x:r},(function(e){return{$x:function(){return e.batchToSpaceND(t,n)}}}))}}),Hr=zn({squeeze_:function(e,t){var n=Sn(e,"x","squeeze");return Wr(n,xe(n.shape,t).newShape)}}),Ur=zn({stack_:function(e,t){void 0===t&&(t=0);var n=Rn(e,"tensors","stack");if(ue(n.length>=1,(function(){return"Pass at least one tensor to tf.stack"})),1===n.length)return n[0].expandDims(t);var r=n[0].rank,o=n[0].shape,a=n[0].dtype;ue(t<=r,(function(){return"Axis must be <= rank of the tensor"})),n.forEach((function(e){ce(o,e.shape,"All tensors passed to stack must have matching shapes")})),n.forEach((function(e){ue(a===e.dtype,(function(){return"All tensors passed to stack must have matching dtypes"}))}));var i=n.map((function(e){return e.expandDims(t)}));return rr(i,t)}}),Gr=zn({tile_:function(e,t){var n=Sn(e,"x","tile",null);return ue(n.rank===t.length,(function(){return"Error in transpose: rank of input "+n.rank+" must match length of reps "+t+"."})),mt.runKernelFunc((function(e,r){var o=e.tile(n,t);return r([n]),o}),{$x:n},(function(e,n){var r=n[0];return{$x:function(){var n=nr(r);if(1===r.rank)for(var o=0;o<t[0];++o)n=n.add(e.slice([o*r.shape[0]],[r.shape[0]]));else if(2===r.rank)for(o=0;o<t[0];++o)for(var a=0;a<t[1];++a)n=n.add(e.slice([o*r.shape[0],a*r.shape[1]],[r.shape[0],r.shape[1]]));else if(3===r.rank)for(o=0;o<t[0];++o)for(a=0;a<t[1];++a)for(var i=0;i<t[2];++i)n=n.add(e.slice([o*r.shape[0],a*r.shape[1],i*r.shape[2]],[r.shape[0],r.shape[1],r.shape[2]]));else{if(4!==r.rank)throw new Error("Gradient for tile operation is not implemented for rank-"+r.rank+" tensors yet.");for(o=0;o<t[0];++o)for(a=0;a<t[1];++a)for(i=0;i<t[2];++i)for(var s=0;s<t[3];++s)n=n.add(e.slice([o*r.shape[0],a*r.shape[1],i*r.shape[2],s*r.shape[3]],[r.shape[0],r.shape[1],r.shape[2],r.shape[3]]))}return n}}}))}}),qr=zn({truncatedNormal_:function(e,t,n,r,o){if(void 0===t&&(t=0),void 0===n&&(n=1),null!=r&&"bool"===r)throw new Error("Unsupported data type "+r);for(var a=new yr(t,n,r,!0,o),i=xr(e,r),s=0;s<i.values.length;s++)i.values[s]=a.nextValue();return i.toTensor()}}),Xr=zn({unstack_:function(e,t){void 0===t&&(t=0),t=t||0;var n=Sn(e,"x","unstack");return ue(t>=-n.shape.length&&t<n.shape.length,(function(){return"Axis = "+t+" is not in [-"+n.shape.length+", "+n.shape.length+")"})),t<0&&(t+=n.shape.length),mt.runKernelFunc((function(e){return e.unstack(n,t)}),{$x:n},(function(e){return{$x:function(){return Ur(e,t)}}}))}});function Kr(e,t,n,r){void 0===r&&(r=!0);var o=[];if(r)(o=o.concat(t.slice(0))).push(e[0]/n),o=o.concat(e.slice(1));else{o=o.concat(e[0]);for(var a=t.length,i=0;i<a;++i)o=o.concat([e[i+1]/t[i],t[i]]);o=o.concat(e.slice(a+1))}return o}function $r(e,t,n){void 0===n&&(n=!0);var r=[];if(n){r.push(t);for(var o=t+1;o<e;++o)o<=2*t?(r.push(o),r.push(o-(t+1))):r.push(o)}else{var a=[],i=[];for(o=1;o<e;++o)o>=2*t+1||o%2==1?i.push(o):a.push(o);r.push.apply(r,a),r.push(0),r.push.apply(r,i)}return r}function Zr(e,t,n,r){void 0===r&&(r=!0);var o=[];r?o.push(e[0]/n):o.push(e[0]*n);for(var a=1;a<e.length;++a)a<=t.length?r?o.push(t[a-1]*e[a]):o.push(e[a]/t[a-1]):o.push(e[a]);return o}function Yr(e,t){for(var n=[0],r=0;r<t;++r)n.push(e[r][0]);return n}function Jr(e,t,n){for(var r=e.slice(0,1),o=0;o<n;++o)r.push(e[o+1]-t[o][0]-t[o][1]);return r}function Qr(e,t){if(e.rank<1)throw new Error("tf.gatherND() expects the input to be rank 1 or higher, but the rank was "+e.rank+".");if(t.rank<1)throw new Error("tf.gatherND() expects the indices to be rank 1 or higher, but the rank was "+t.rank+".");if("int32"!==t.dtype)throw new Error("tf.gatherND() expects the indices to be int32 type, but the dtype was "+t.dtype+".");if(t.shape[t.rank-1]>e.rank)throw new Error("index innermost dimension length must be <= tensor rank; saw: "+t.shape[t.rank-1]+" vs. "+e.rank);if(0===e.size)throw new Error("Requested more than 0 entries, but input is empty. Input shape: "+e.shape+".");for(var n=t.shape,r=n[n.length-1],o=1,a=0;a<n.length-1;++a)o*=n[a];var i=e.shape,s=n.slice();s.pop();var u=1;for(a=r;a<e.rank;++a)u*=i[a],s.push(i[a]);var c=Fe(e.shape).map((function(e){return e/u})).concat([1]).slice(0,r);return[s,o,u,c]}function eo(e){return e<=30?e:Ne(e,Math.floor(Math.sqrt(e)))}function to(e,t,n){for(var r=t.rank>1?t.shape[t.rank-1]:1,o=n.length,a=1,i=r;i<o;++i)a*=n[i];var s=r<1?1:r;return{sliceRank:r,numUpdates:t.size/s,sliceSize:a,strides:Fe(n.slice(0,r)).concat([1]),outputSize:he(n)}}function no(e,t,n){ue(e.rank===t.length,(function(){return"Error in slice"+e.rank+"D: Length of begin "+t+" must match the rank of the array ("+e.rank+")."})),ue(e.rank===n.length,(function(){return"Error in slice"+e.rank+"D: Length of size "+n+" must match the rank of the array ("+e.rank+")."}));for(var r=function(r){ue(t[r]+n[r]<=e.shape[r],(function(){return"Error in slice"+e.rank+"D: begin["+r+"] + size["+r+"] ("+(t[r]+n[r])+") would overflow input.shape["+r+"] ("+e.shape[r]+")"}))},o=0;o<e.rank;++o)r(o)}function ro(e){for(var t=[],n=0;e>0;)1&e&&t.push(n),e/=2,n++;return t}function oo(e,t,n){for(var r=[],o=0;o<e.length;o++)r[o]=Math.ceil((t[o]-e[o])/n[o]);return r}function ao(e,t,n,r,o){var a=t[o],i=n[o]||1;(e&1<<o||null==a)&&(a=i>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);var s=r[o];return a<0&&(a+=s),ae(0,a,s-1)}function io(e,t,n,r,o){var a=t[o],i=n[o]||1;(e&1<<o||null==a)&&(a=i>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);var s=r[o];return a<0&&(a+=s),i>0?ae(0,a,s):ae(-1,a,s-1)}function so(e,t,n){for(var r=n.length,o=0;o<n.length;o++)if(n[o]>1){r=o;break}for(o=r+1;o<n.length;o++)if(t[o]>0||n[o]!==e[o])return!1;return!0}function uo(e,t){for(var n=e.length>0?e[e.length-1]:1,r=0;r<e.length-1;r++)n+=e[r]*t[r];return n}Object.freeze({assertParamsValid:no,maskToAxes:ro,computeOutShape:oo,startForAxis:ao,stopForAxis:io,isSliceContinous:so,computeFlatOffset:uo});function co(e){return mt.customGrad(e)}var lo=zn({softmax_:function(e,t){void 0===t&&(t=-1);var n=Sn(e,"logits","softmax");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error("Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and dim was "+t);return co((function(e,n){var r=e.logSumExp([t],!0),o=e.toFloat().sub(r).exp();return n([o]),{value:o,gradFunc:function(e,n){var r=n[0],o=e.mul(r);return o.sub(o.sum([t],!0).mul(r))}}}))(n)}}),fo=zn({logSoftmax_:function(e,t){void 0===t&&(t=-1);var n=Sn(e,"logits","logSoftmax");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error("Log Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and axis was "+t);return co((function(e,n){var r=e.max(t,!0),o=e.sub(r),a=o.toFloat().sub(o.exp().sum(t,!0).log());return n([a]),{value:a,gradFunc:function(e,n){var r=n[0].exp();return e.sub(e.sum(t,!0).mul(r))}}}))(n)}}),ho=function(){function e(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}return e.prototype.get=function(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)},e.prototype.set=function(e,t){this.dataIdsCount++,this.data.set(e,t)},e.prototype.has=function(e){return this.data.has(e)},e.prototype.delete=function(e){return this.dataIdsCount--,this.data.delete(e)},e.prototype.numDataIds=function(){return this.dataIdsCount},e}(),po=function(){function e(){}return e.prototype.time=function(e){return vo("time")},e.prototype.read=function(e){return vo("read")},e.prototype.readSync=function(e){return vo("readSync")},e.prototype.numDataIds=function(){return vo("numDataIds")},e.prototype.disposeData=function(e){return vo("disposeData")},e.prototype.write=function(e,t,n){return vo("write")},e.prototype.move=function(e,t,n,r){return vo("move")},e.prototype.memory=function(){return vo("memory")},e.prototype.floatPrecision=function(){return vo("floatPrecision")},e.prototype.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4},e.prototype.batchMatMul=function(e,t,n,r){return vo("batchMatMul")},e.prototype.fusedBatchMatMul=function(e){return e.a,e.b,e.transposeA,e.transposeB,e.bias,e.activation,e.preluActivationWeights,vo("fusedBatchMatMul")},e.prototype.slice=function(e,t,n){return vo("slice")},e.prototype.stridedSlice=function(e,t,n,r){return vo("stridedSlice")},e.prototype.unstack=function(e,t){return vo("unstack")},e.prototype.reverse=function(e,t){return vo("reverse")},e.prototype.concat=function(e,t){return vo("concat")},e.prototype.neg=function(e){return vo("neg")},e.prototype.add=function(e,t){return vo("add")},e.prototype.addN=function(e){return vo("addN")},e.prototype.subtract=function(e,t){return vo("subtract")},e.prototype.multiply=function(e,t){return vo("multiply")},e.prototype.realDivide=function(e,t){return vo("realDivide")},e.prototype.floorDiv=function(e,t){return vo("floorDiv")},e.prototype.sum=function(e,t){return vo("sum")},e.prototype.prod=function(e,t){return vo("prod")},e.prototype.unsortedSegmentSum=function(e,t,n){return vo("unsortedSegmentSum")},e.prototype.argMin=function(e,t){return vo("argMin")},e.prototype.argMax=function(e,t){return vo("argMax")},e.prototype.equal=function(e,t){return vo("equal")},e.prototype.notEqual=function(e,t){return vo("notEqual")},e.prototype.less=function(e,t){return vo("less")},e.prototype.lessEqual=function(e,t){return vo("lessEqual")},e.prototype.greater=function(e,t){return vo("greater")},e.prototype.greaterEqual=function(e,t){return vo("greaterEqual")},e.prototype.logicalNot=function(e){return vo("logicalNot")},e.prototype.logicalAnd=function(e,t){return vo("logicalAnd")},e.prototype.logicalOr=function(e,t){return vo("logicalOr")},e.prototype.where=function(e){return vo("where")},e.prototype.select=function(e,t,n){return vo("select")},e.prototype.topk=function(e,t,n){return vo("topk")},e.prototype.min=function(e,t){return vo("min")},e.prototype.minimum=function(e,t){return vo("minimum")},e.prototype.mod=function(e,t){return vo("mod")},e.prototype.max=function(e,t){return vo("max")},e.prototype.maximum=function(e,t){return vo("maximum")},e.prototype.all=function(e,t){return vo("all")},e.prototype.any=function(e,t){return vo("any")},e.prototype.squaredDifference=function(e,t){return vo("squaredDifference")},e.prototype.ceil=function(e){return vo("ceil")},e.prototype.floor=function(e){return vo("floor")},e.prototype.round=function(e){return vo("round")},e.prototype.sign=function(e){return vo("sign")},e.prototype.isNaN=function(e){return vo("isNaN")},e.prototype.isInf=function(e){return vo("isInf")},e.prototype.isFinite=function(e){return vo("isFinite")},e.prototype.pow=function(e,t){return vo("pow")},e.prototype.exp=function(e){return vo("exp")},e.prototype.expm1=function(e){return vo("expm1")},e.prototype.log=function(e){return vo("log")},e.prototype.log1p=function(e){return vo("log1p")},e.prototype.sqrt=function(e){return vo("sqrt")},e.prototype.rsqrt=function(e){return vo("rsqrt")},e.prototype.square=function(e){return vo("square")},e.prototype.reciprocal=function(e){return vo("reciprocal")},e.prototype.relu=function(e){return vo("relu")},e.prototype.relu6=function(e){return vo("relu6")},e.prototype.prelu=function(e,t){return vo("prelu")},e.prototype.elu=function(e){return vo("elu")},e.prototype.eluDer=function(e,t){return vo("eluDer")},e.prototype.selu=function(e){return vo("selu")},e.prototype.int=function(e){return vo("int")},e.prototype.clip=function(e,t,n){return vo("clip")},e.prototype.abs=function(e){return vo("abs")},e.prototype.complexAbs=function(e){return vo("complexAbs")},e.prototype.sigmoid=function(e){return vo("sigmoid")},e.prototype.softplus=function(e){return vo("softplus")},e.prototype.sin=function(e){return vo("sin")},e.prototype.cos=function(e){return vo("cos")},e.prototype.tan=function(e){return vo("tan")},e.prototype.asin=function(e){return vo("asin")},e.prototype.acos=function(e){return vo("acos")},e.prototype.atan=function(e){return vo("atan")},e.prototype.atan2=function(e,t){return vo("atan2")},e.prototype.sinh=function(e){return vo("sinh")},e.prototype.cosh=function(e){return vo("cosh")},e.prototype.tanh=function(e){return vo("tanh")},e.prototype.asinh=function(e){return vo("asinh")},e.prototype.acosh=function(e){return vo("acosh")},e.prototype.atanh=function(e){return vo("atanh")},e.prototype.erf=function(e){return vo("erf")},e.prototype.step=function(e,t){return vo("step")},e.prototype.fusedConv2d=function(e){return e.input,e.filter,e.convInfo,e.bias,e.activation,e.preluActivationWeights,vo("fusedConv2d")},e.prototype.conv2d=function(e,t,n){return vo("conv2d")},e.prototype.conv2dDerInput=function(e,t,n){return vo("conv2dDerInput")},e.prototype.conv2dDerFilter=function(e,t,n){return vo("conv2dDerFilter")},e.prototype.fusedDepthwiseConv2D=function(e){return e.input,e.filter,e.convInfo,e.bias,e.activation,e.preluActivationWeights,vo("fusedDepthwiseConv2D")},e.prototype.depthwiseConv2D=function(e,t,n){return vo("depthwiseConv2D")},e.prototype.depthwiseConv2DDerInput=function(e,t,n){return vo("depthwiseConv2DDerInput")},e.prototype.depthwiseConv2DDerFilter=function(e,t,n){return vo("depthwiseConv2DDerFilter")},e.prototype.conv3d=function(e,t,n){return vo("conv3d")},e.prototype.conv3dDerInput=function(e,t,n){return vo("conv3dDerInput")},e.prototype.conv3dDerFilter=function(e,t,n){return vo("conv3dDerFilter")},e.prototype.maxPool=function(e,t){return vo("maxPool")},e.prototype.maxPoolBackprop=function(e,t,n,r){return vo("maxPoolBackprop")},e.prototype.avgPool=function(e,t){return vo("avgPool")},e.prototype.avgPoolBackprop=function(e,t,n){return vo("avgPoolBackprop")},e.prototype.avgPool3d=function(e,t){return vo("avgPool3d")},e.prototype.avgPool3dBackprop=function(e,t,n){return vo("avgPool3dBackprop")},e.prototype.maxPool3d=function(e,t){return vo("maxPool3d")},e.prototype.maxPool3dBackprop=function(e,t,n,r){return vo("maxPool3dBackprop")},e.prototype.reshape=function(e,t){return vo("reshape")},e.prototype.cast=function(e,t){return vo("cast")},e.prototype.tile=function(e,t){return vo("tile")},e.prototype.pad=function(e,t,n){return vo("pad")},e.prototype.transpose=function(e,t){return vo("transpose")},e.prototype.gather=function(e,t,n){return vo("gather")},e.prototype.gatherND=function(e,t){return vo("gatherND")},e.prototype.scatterND=function(e,t,n){return vo("scatterND")},e.prototype.batchToSpaceND=function(e,t,n){return vo("batchToSpaceND")},e.prototype.spaceToBatchND=function(e,t,n){return vo("spaceToBatchND")},e.prototype.resizeBilinear=function(e,t,n,r){return vo("resizeBilinear")},e.prototype.resizeBilinearBackprop=function(e,t,n){return vo("resizeBilinearBackprop")},e.prototype.resizeNearestNeighbor=function(e,t,n,r){return vo("resizeNearestNeighbor")},e.prototype.resizeNearestNeighborBackprop=function(e,t,n){return vo("resizeNearestNeighborBackprop")},e.prototype.batchNormalization=function(e,t,n,r,o,a){return vo("batchNormalization")},e.prototype.localResponseNormalization4D=function(e,t,n,r,o){return vo("localResponseNormalization4D")},e.prototype.LRNGrad=function(e,t,n,r,o,a,i){return vo("LRNGrad")},e.prototype.multinomial=function(e,t,n,r){return vo("multinomial")},e.prototype.oneHot=function(e,t,n,r){return vo("oneHot")},e.prototype.cumsum=function(e,t,n,r){return vo("cumsum")},e.prototype.nonMaxSuppression=function(e,t,n,r,o){return vo("nonMaxSuppression")},e.prototype.fft=function(e){return vo("fft")},e.prototype.ifft=function(e){return vo("ifft")},e.prototype.complex=function(e,t){return vo("complex")},e.prototype.real=function(e){return vo("real")},e.prototype.imag=function(e){return vo("imag")},e.prototype.cropAndResize=function(e,t,n,r,o,a){return vo("cropAndResize")},e.prototype.depthToSpace=function(e,t,n){return vo("depthToSpace")},e.prototype.split=function(e,t,n){return vo("split")},e.prototype.sparseToDense=function(e,t,n,r){return vo("sparseToDense")},e.prototype.diag=function(e){return vo("diag")},e.prototype.fill=function(e,t,n){return vo("fill")},e.prototype.onesLike=function(e){return vo("onesLike")},e.prototype.zerosLike=function(e){return vo("zerosLike")},e.prototype.linspace=function(e,t,n){return vo("linspace")},e.prototype.dispose=function(){return vo("dispose")},e}();function vo(e){throw new Error("'"+e+"' not yet implemented or not found in the registry. Did you forget to import the kernel?")}function mo(e,t){for(var n=e.length,r=[],o=0;o<n;o++){var a=n-1-o,i=e[a]||1;(t[t.length-1-o]||1)>1&&1===i&&r.unshift(a)}return r}function go(e,t){for(var n=[],r=0;r<t.length;r++){var o=e[e.length-r-1],a=t.length-r-1,i=t[a];(null==o||1===o&&i>1)&&n.unshift(a)}return n}function yo(e,t){for(var n=[],r=Math.max(e.length,t.length),o=0;o<r;o++){var a=e[e.length-o-1];null==a&&(a=1);var i=t[t.length-o-1];if(null==i&&(i=1),1===a)n.unshift(i);else if(1===i)n.unshift(a);else{if(a!==i)throw Error("Operands could not be broadcast together with shapes "+e+" and "+t+".");n.unshift(a)}}return n}function bo(e,t,n,r,o,a,i){void 0===i&&(i="channelsLast");var s,u=Oo(t),c=u[0],l=u[1];if("channelsLast"===i)s=[c,l,e[3],e[3]];else{if("channelsFirst"!==i)throw new Error("Unknown dataFormat "+i);s=[c,l,e[1],e[1]]}return xo(e,s,n,r,o,a,!1,i)}function wo(e,t,n,r,o,a,i){void 0===i&&(i="NDHWC");var s,u,c=ko(t),l=c[0],f=c[1],h=c[2];if("NDHWC"===i)u="channelsLast",s=[l,f,h,e[4],e[4]];else{if("NCDHW"!==i)throw new Error("Unknown dataFormat "+i);u="channelsFirst",s=[l,f,h,e[1],e[1]]}return Eo(e,s,n,r,o,!1,u,a)}function xo(e,t,n,r,o,a,i,s){void 0===i&&(i=!1),void 0===s&&(s="channelsLast");var u=[-1,-1,-1,-1],c=u[0],l=u[1],f=u[2],h=u[3];if("channelsLast"===s)c=e[0],l=e[1],f=e[2],h=e[3];else{if("channelsFirst"!==s)throw new Error("Unknown dataFormat "+s);c=e[0],h=e[1],l=e[2],f=e[3]}var p,d=t[0],v=t[1],m=t[3],g=Oo(n),y=g[0],b=g[1],w=Oo(r),x=w[0],E=w[1],_=Co(d,x),O=Co(v,E),k=function(e,t,n,r,o,a,i,s){var u,c,l;if("number"==typeof e){u={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};var f=function(e,t,n,r,o){null==r&&(r=_o(e,t,n));var a=e[1],i=Io((e[0]-t+2*r)/n+1,o);ue(de(i),(function(){return"The output # of rows ("+i+") must be an integer. Change the stride and/or zero pad parameters"}));var s=Io((a-t+2*r)/n+1,o);return ue(de(s),(function(){return"The output # of columns ("+s+") must be an integer. Change the stride and/or zero pad parameters"})),[i,s]}([t,n],a,r,e,s);c=f[0],l=f[1]}else if("same"===e){c=Math.ceil(t/r),l=Math.ceil(n/o);var h=Math.max(0,(c-1)*r+a-t),p=Math.max(0,(l-1)*o+i-n),d=Math.floor(h/2),v=h-d,m=Math.floor(p/2);u={top:d,bottom:v,left:m,right:p-m,type:"SAME"}}else{if("valid"!==e)throw Error("Unknown padding parameter: "+e);u={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((t-a+1)/r),l=Math.ceil((n-i+1)/o)}return{padInfo:u,outHeight:c,outWidth:l}}(o,l,f,y,b,_,O,a),C=k.padInfo,I=k.outHeight,S=k.outWidth,R=i?m*h:m;return"channelsFirst"===s?p=[c,R,I,S]:"channelsLast"===s&&(p=[c,I,S,R]),{batchSize:c,dataFormat:s,inHeight:l,inWidth:f,inChannels:h,outHeight:I,outWidth:S,outChannels:R,padInfo:C,strideHeight:y,strideWidth:b,filterHeight:d,filterWidth:v,effectiveFilterHeight:_,effectiveFilterWidth:O,dilationHeight:x,dilationWidth:E,inShape:e,outShape:p,filterShape:t}}function Eo(e,t,n,r,o,a,i,s){void 0===a&&(a=!1),void 0===i&&(i="channelsLast");var u=[-1,-1,-1,-1,-1],c=u[0],l=u[1],f=u[2],h=u[3],p=u[4];if("channelsLast"===i)c=e[0],l=e[1],f=e[2],h=e[3],p=e[4];else{if("channelsFirst"!==i)throw new Error("Unknown dataFormat "+i);c=e[0],p=e[1],l=e[2],f=e[3],h=e[4]}var d,v=t[0],m=t[1],g=t[2],y=t[4],b=ko(n),w=b[0],x=b[1],E=b[2],_=ko(r),O=_[0],k=_[1],C=_[2],I=Co(v,O),S=Co(m,k),R=Co(g,C),A=function(e,t,n,r,o,a,i,s,u,c,l){var f,h,p,d;if("number"==typeof e){f={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};var v=function(e,t,n,r,o,a){null==o&&(o=_o(e,t,r));var i=e[1],s=e[2],u=Io((e[0]-t+2*o)/r+1,a);ue(de(u),(function(){return"The output # of depths ("+u+") must be an integer. Change the stride and/or zero pad parameters"}));var c=Io((i-t+2*o)/r+1,a);ue(de(c),(function(){return"The output # of rows ("+c+") must be an integer. Change the stride and/or zero pad parameters"}));var l=Io((s-t+2*o)/r+1,a);return ue(de(l),(function(){return"The output # of columns ("+l+") must be an integer. Change the stride and/or zero pad parameters"})),[u,c,l,1]}([t,n,r,1],s,0,o,e,l);h=v[0],p=v[1],d=v[2]}else if("same"===e){var m=((h=Math.ceil(t/o))-1)*o+s-t,g=((p=Math.ceil(n/a))-1)*a+u-n,y=((d=Math.ceil(r/i))-1)*i+c-r,b=Math.floor(m/2),w=m-b,x=Math.floor(g/2),E=g-x,_=Math.floor(y/2);f={top:x,bottom:E,left:_,right:y-_,front:b,back:w,type:"SAME"}}else{if("valid"!==e)throw Error("Unknown padding parameter: "+e);f={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},h=Math.ceil((t-s+1)/o),p=Math.ceil((n-u+1)/a),d=Math.ceil((r-c+1)/i)}return{padInfo:f,outDepth:h,outHeight:p,outWidth:d}}(o,l,f,h,w,x,E,I,S,R,s),P=A.padInfo,T=A.outDepth,D=A.outHeight,M=A.outWidth,N=a?y*p:y;return"channelsFirst"===i?d=[c,N,T,D,M]:"channelsLast"===i&&(d=[c,T,D,M,N]),{batchSize:c,dataFormat:i,inDepth:l,inHeight:f,inWidth:h,inChannels:p,outDepth:T,outHeight:D,outWidth:M,outChannels:N,padInfo:P,strideDepth:w,strideHeight:x,strideWidth:E,filterDepth:v,filterHeight:m,filterWidth:g,effectiveFilterDepth:I,effectiveFilterHeight:S,effectiveFilterWidth:R,dilationDepth:O,dilationHeight:k,dilationWidth:C,inShape:e,outShape:d,filterShape:t}}function _o(e,t,n,r){void 0===r&&(r=1);var o=Co(t,r);return Math.floor((e[0]*(n-1)-n+o)/2)}function Oo(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function ko(e){return"number"==typeof e?[e,e,e]:e}function Co(e,t){return t<=1?e:e+(e-1)*(t-1)}function Io(e,t){if(!t)return e;switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw new Error("Unknown roundingMode "+t)}}function So(e){var t=Oo(e),n=t[0],r=t[1],o=t[2];return 1===n&&1===r&&1===o}function Ro(e,t){return So(e)||So(t)}function Ao(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error("Unknown dataFormat "+e)}function Po(e,t,n){if("complex64"===t){if("complex64"===e.dtype)return e.clone();var r=Jn(e.shape),o=e.toFloat(),a=n.complex(o,r);return r.dispose(),o.dispose(),a}if(!Ce(e.dtype,t))return mt.makeTensorFromDataId(e.dataId,e.shape,t);if("complex64"===e.dtype){var i=n.real(e);return a=i.cast(t),i.dispose(),a}if("int32"===t)return n.int(e);if("bool"===t){var s=qn(0,e.dtype);return a=n.notEqual(e,s),s.dispose(),a}throw new Error("Error in Cast: failed to cast "+e.dtype+" to "+t)}function To(e,t){return mt.makeTensorFromDataId(e.dataId,t,e.dtype)}function Do(e,t,n){var r=(t-e)/(n-1),o=ze(n,"float32");o[0]=e;for(var a=1;a<o.length;a++)o[a]=o[a-1]+r;return Xn(o,"float32")}Object.freeze({castTensor:Po,reshapeTensor:To,linspaceImpl:Do,upcastType:ut,axesAreInnerMostDims:An,combineLocations:Pn,computeOutAndReduceShapes:Tn,expandShapeToKeepDim:Dn,assertAxesAreInnerMostDims:Mn,getAxesPermutation:Nn,getUndoAxesPermutation:Fn,getInnerMostAxes:Bn,getBroadcastDims:mo,getReductionAxes:go,assertAndGetBroadcastShape:yo,assertParamsConsistent:jn,computeOutShape:Ln,computePool2DInfo:bo,computePool3DInfo:wo,computeConv2DInfo:xo,computeConv3DInfo:Eo,computeDefaultPad:_o,tupleValuesAreOne:So,eitherStridesOrDilationsAreOne:Ro,convertConv2DDataFormat:Ao});function Mo(e,t){if(e.length!==t.length)throw new Error("Cannot merge real and imag arrays of different lengths. real:"+e.length+", imag: "+t.length+".");for(var n=new Float32Array(2*e.length),r=0;r<n.length;r+=2)n[r]=e[r/2],n[r+1]=t[r/2];return n}function No(e,t){return{real:e[2*t],imag:e[2*t+1]}}function Fo(e,t,n,r){e[2*r]=t,e[2*r+1]=n}function Bo(e,t,n){var r=(n?2:-2)*Math.PI*(e/t);return{real:Math.cos(r),imag:Math.sin(r)}}function jo(e,t,n,r,o){for(var a=Array.from(t).map((function(e,t){return{score:e,boxIndex:t}})).filter((function(e){return e.score>o})).sort((function(e,t){return t.score-e.score})),i=[],s=0;s<a.length;s++){var u=a[s],c=u.score,l=u.boxIndex;if(c<o)break;for(var f=!1,h=i.length-1;h>=0;--h)if(Lo(e,l,i[h])>=r){f=!0;break}if(!f&&(i.push(l),i.length>=n))break}return Xn(i,"int32")}function Lo(e,t,n){var r=e.subarray(4*t,4*t+4),o=e.subarray(4*n,4*n+4),a=Math.min(r[0],r[2]),i=Math.min(r[1],r[3]),s=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),c=Math.min(o[0],o[2]),l=Math.min(o[1],o[3]),f=Math.max(o[0],o[2]),h=Math.max(o[1],o[3]),p=(s-a)*(u-i),d=(f-c)*(h-l);if(p<=0||d<=0)return 0;var v=Math.max(a,c),m=Math.max(i,l),g=Math.min(s,f),y=Math.min(u,h),b=Math.max(g-v,0)*Math.max(y-m,0);return b/(p+d-b)}function zo(e,t,n){var r=new Array(e.rank).fill(0),o=e.shape.slice();return t.map((function(t){o[n]=t;var a=e.slice(r,o);return r[n]+=t,a}))}function Wo(e,t){for(var n=new Array(e.rank),r=0;r<n.length;r++)n[r]=e.shape[r]*t[r];var o=xr(n,e.dtype);for(r=0;r<o.values.length;++r){for(var a=o.indexToLoc(r),i=new Array(e.rank),s=0;s<i.length;s++)i[s]=a[s]%e.shape[s];var u=e.locToIndex(i);o.values[r]=e.values[u]}return o.toTensor()}function Vo(e,t,n,r,o){for(var a=t[t.length-1],i=[e.length/a,a],s=i[0],u=i[1],c=Ee(n,s*r),l=Ee("int32",s*r),f=0;f<s;f++){for(var h=f*u,p=e.subarray(h,h+u),d=[],v=0;v<p.length;v++)d.push({value:p[v],index:v});d.sort((function(e,t){return t.value-e.value}));var m=f*r,g=c.subarray(m,m+r),y=l.subarray(m,m+r);for(v=0;v<r;v++)g[v]=d[v].value,y[v]=d[v].index}var b=t.slice();return b[b.length-1]=r,[Un(c,b,n),Un(l,b,"int32")]}function Ho(e,t){for(var n=[],r=0;r<t.length;r++)t[r]&&n.push(r);var o=xr(e,"int32"),a=xr([n.length,e.length],"int32");for(r=0;r<n.length;r++){var i=o.indexToLoc(n[r]),s=r*e.length;a.values.set(i,s)}return a.toTensor()}var Uo=function(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((function(e,t){return"T"+t}));var n=[];this.variableNames.forEach((function(e){n.push("float v"+e+" = get"+e+"AtOutCoords();")}));var r=this.variableNames.map((function(e){return"v"+e})).join(" + ");this.userCode="\n void main() {\n "+n.join("\n ")+"\n\n float result = "+r+";\n setOutput(result);\n }\n "},Go=function(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((function(e,t){return"T"+t}));var n=[];this.variableNames.forEach((function(e){n.push("vec4 v"+e+" = get"+e+"AtOutCoords();")}));var r=this.variableNames.map((function(e){return"v"+e})).join(" + ");this.userCode="\n void main() {\n "+n.join("\n ")+"\n\n vec4 result = "+r+";\n setOutput(result);\n }\n "},qo=function(e,t,n){this.variableNames=["A"];var r=e.windowSize,o=e.batchSize,a=e.inSize,i=Math.ceil(a/r);n||this.variableNames.push("bestIndicesA"),this.outputShape=[o,i];var s="max"===t?">":"<",u=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * "+r+";\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < "+r+"; i++) {\n int inIdx = "+u+";\n float candidate = getA(batch, inIdx);\n if (candidate "+s+" bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n "};function Xo(e,t){return["x","y","z","w","u","v"].slice(0,t).map((function(t){return e+"."+t}))}function Ko(e,t){return 1===t?[e]:Xo(e,t)}function $o(){var e,t,n,r,o,a,i,s,u,c;return 2===Y().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",n="out",r="in",o="texture",a="outputColor",i="out vec4 outputColor;",s="\n bool isnan_custom(float val) {\n return (val > 0.0 || val < 0.0) ? false : val != 0.0;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n ",u="",c="\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "):(e="",t="attribute",n="varying",r="varying",o="texture2D",a="gl_FragColor",i="",s="\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ",u="\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ",c="\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "),{version:e,attribute:t,varyingVs:n,varyingFs:r,texture2D:o,output:a,defineOutput:i,defineSpecialNaN:s,defineSpecialInf:u,defineRound:c}}function Zo(e,t,n){void 0===n&&(n="index");var r=Fe(t);return r.map((function(t,o){return"int "+e[o]+" = "+n+" / "+t+"; "+(o===r.length-1?"int "+e[o+1]+" = "+n+" - "+e[o]+" * "+t:"index -= "+e[o]+" * "+t)+";"})).join("")}function Yo(e){var t=Fe(e).map((function(e){return e.toString()}));return"\n int getFlatIndex(ivec3 coords) {\n return coords.x * "+t[0]+" + coords.y * "+t[1]+" + coords.z;\n }\n"}var Jo="\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n";function Qo(e,t,n,r){var o=[];e.forEach((function(e){var t=he(e.shapeInfo.logicalShape);e.shapeInfo.isUniform?o.push("uniform float "+e.name+(t>1?"["+t+"]":"")+";"):(o.push("uniform sampler2D "+e.name+";"),o.push("uniform int offset"+e.name+";"))}));var a,i,s=o.join("\n"),u=e.map((function(e){return function(e,t,n){void 0===n&&(n=!1);var r="";r+=n?ta(e):ea(e);var o=e.shapeInfo.logicalShape,a=t.logicalShape;return o.length<=a.length&&(r+=n?function(e,t){var n,r=e.name,o=r.charAt(0).toUpperCase()+r.slice(1),a="get"+o+"AtOutCoords",i=e.shapeInfo.logicalShape.length,s=t.logicalShape.length,u=mo(e.shapeInfo.logicalShape,t.logicalShape),c=ua(s),l=s-i,f=["x","y","z","w","u","v"];n=0===i?"":s<2&&u.length>=1?"coords = 0;":u.map((function(e){return"coords."+f[e+l]+" = 0;"})).join("\n");var h;h=s<2&&i>0?"coords":e.shapeInfo.logicalShape.map((function(e,t){return"coords."+f[t+l]})).join(", ");var p="return outputValue;",d=1===he(e.shapeInfo.logicalShape),v=1===he(t.logicalShape);if(1!==i||d||v){if(d&&!v)p=1===s?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(u.length){var m=i-2,g=i-1;u.indexOf(m)>-1&&u.indexOf(g)>-1?p="return vec4(outputValue.x);":u.indexOf(m)>-1?p="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":u.indexOf(g)>-1&&(p="return vec4(outputValue.xx, outputValue.zz);")}}else p="\n return vec4(outputValue.xy, outputValue.xy);\n ";return"\n vec4 "+a+"() {\n "+c+" coords = getOutputCoords();\n "+n+"\n vec4 outputValue = get"+o+"("+h+");\n "+p+"\n }\n "}(e,t):function(e,t){var n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),o="get"+r+"AtOutCoords",a=t.texShape,i=e.shapeInfo.texShape,s=e.shapeInfo.logicalShape.length,u=t.logicalShape.length;if(!e.shapeInfo.isUniform&&s===u&&null==e.shapeInfo.flatOffset&&pe(i,a))return"\n float "+o+"() {\n return sampleTexture("+n+", resultUV);\n }\n ";var c,l=ua(u),f=mo(e.shapeInfo.logicalShape,t.logicalShape),h=u-s,p=["x","y","z","w","u","v"];c=0===s?"":u<2&&f.length>=1?"coords = 0;":f.map((function(e){return"coords."+p[e+h]+" = 0;"})).join("\n");var d;return d=u<2&&s>0?"coords":e.shapeInfo.logicalShape.map((function(e,t){return"coords."+p[t+h]})).join(", "),"\n float "+o+"() {\n "+l+" coords = getOutputCoords();\n "+c+"\n return get"+r+"("+d+");\n }\n "}(e,t)),r}(e,t,r)})).join("\n"),c=t.texShape,l=$o(),f=function(e){return"\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return "+e.texture2D+"(textureSampler, uv).r;\n }\n "}(l),h=function(e){return e.version+"\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n "+e.varyingFs+" vec2 resultUV;\n "+e.defineOutput+"\n const vec2 halfCR = vec2(0.5, 0.5);\n\n struct ivec5\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n };\n\n struct ivec6\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n int v;\n };\n\n uniform float NAN;\n "+e.defineSpecialNaN+"\n "+e.defineSpecialInf+"\n "+e.defineRound+"\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n int idiv(int a, int b, float sign) {\n int res = a / b;\n int mod = imod(a, b);\n if (sign < 0. && mod != 0) {\n res -= 1;\n }\n return res;\n }\n\n //Based on the work of Dave Hoskins\n //https://www.shadertoy.com/view/4djSRW\n #define HASHSCALE1 443.8975\n float random(float seed){\n vec2 p = resultUV * seed;\n vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n }\n\n "+na+"\n "+ra+"\n "+oa+"\n "}(l);return t.isPacked?(a=function(e,t){switch(e.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(e,t){var n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return 1===n[0]?"\n int getOutputCoords() {\n return 2 * int(resultUV.x * "+n[1]+".0);\n }\n ":1===n[1]?"\n int getOutputCoords() {\n return 2 * int(resultUV.y * "+n[0]+".0);\n }\n ":"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+n[0]+", "+n[1]+"));\n return 2 * (resTexRC.x * "+n[1]+" + resTexRC.y);\n }\n "}(0,t);case 2:return function(e,t){var n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(pe(e,t))return"\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2("+n[0]+", "+n[1]+"));\n }\n ";var r=Math.ceil(e[1]/2);return"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+n[0]+", "+n[1]+"));\n\n int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n int r = 2 * (index / "+r+");\n int c = imod(index, "+r+") * 2;\n\n return ivec2(r, c);\n }\n "}(e,t);case 3:return n=e,r=t,o=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],i=(a=Math.ceil(n[2]/2))*Math.ceil(n[1]/2),"\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+o[0]+", "+o[1]+"));\n int index = resTexRC.x * "+o[1]+" + resTexRC.y;\n\n int b = index / "+i+";\n index -= b * "+i+";\n\n int r = 2 * (index / "+a+");\n int c = imod(index, "+a+") * 2;\n\n return ivec3(b, r, c);\n }\n ";default:return function(e,t){for(var n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(e[e.length-1]/2),o=r*Math.ceil(e[e.length-2]/2),a=o,i="",s="b, r, c",u=2;u<e.length-1;u++)i="\n int b"+u+" = index / "+(a*=e[e.length-u-1])+";\n index -= b"+u+" * "+a+";\n "+i,s="b"+u+", "+s;return"\n ivec"+e.length+" getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+n[0]+", "+n[1]+"));\n int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n\n "+i+"\n\n int b = index / "+o+";\n index -= b * "+o+";\n\n int r = 2 * (index / "+r+");\n int c = imod(index, "+r+") * 2;\n\n return ivec"+e.length+"("+s+");\n }\n "}(e,t)}var n,r,o,a,i}(t.logicalShape,c),i=function(e){return"\n void setOutput(vec4 val) {\n "+e.output+" = val;\n }\n "}(l)):(a=function(e,t){switch(e.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(e,t){return 1===t[0]?"\n int getOutputCoords() {\n return int(resultUV.x * "+t[1]+".0);\n }\n ":1===t[1]?"\n int getOutputCoords() {\n return int(resultUV.y * "+t[0]+".0);\n }\n ":"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n return resTexRC.x * "+t[1]+" + resTexRC.y;\n }\n "}(0,t);case 2:return function(e,t){return pe(e,t)?"\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2("+t[0]+", "+t[1]+"));\n }\n ":1===e[1]?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n return ivec2(index, 0);\n }\n ":1===e[0]?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n return ivec2(0, index);\n }\n ":"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n int r = index / "+e[1]+";\n int c = index - r * "+e[1]+";\n return ivec2(r, c);\n }\n "}(e,t);case 3:return n=t,r=Zo(["r","c","d"],e),"\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+n[0]+", "+n[1]+"));\n int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n "+r+"\n return ivec3(r, c, d);\n }\n ";case 4:return function(e,t){var n=Zo(["r","c","d","d2"],e);return"\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n "+n+"\n return ivec4(r, c, d, d2);\n }\n "}(e,t);case 5:return function(e,t){var n=Zo(["r","c","d","d2","d3"],e);return"\n ivec5 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2("+t[0]+",\n "+t[1]+"));\n\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n\n "+n+"\n\n ivec5 outShape = ivec5(r, c, d, d2, d3);\n return outShape;\n }\n "}(e,t);case 6:return function(e,t){var n=Zo(["r","c","d","d2","d3","d4"],e);return"\n ivec6 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n\n "+n+"\n\n ivec6 result = ivec6(r, c, d, d2, d3, d4);\n return result;\n }\n "}(e,t);default:throw new Error(e.length+"-D output sampling is not yet supported")}var n,r}(t.logicalShape,c),i=function(e){return"\n void setOutput(float val) {\n "+e.output+" = vec4(val, 0, 0, 0);\n }\n "}(l)),r&&(h+=aa),[h,f,i,s,a,u,n].join("\n")}function ea(e){var t=e.shapeInfo.logicalShape;switch(t.length){case 0:return function(e){var t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1);if(e.shapeInfo.isUniform)return"float "+n+"() {return "+t+";}";var r=e.shapeInfo.texShape,o=r[0],a=r[1];if(1===o&&1===a)return"\n float "+n+"() {\n return sampleTexture("+t+", halfCR);\n }\n ";var i=e.shapeInfo.texShape;return"\n float "+n+"() {\n vec2 uv = uvFromFlat("+i[0]+", "+i[1]+", "+ia(t)+");\n return sampleTexture("+t+", uv);\n }\n "}(e);case 1:return function(e){var t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1);if(e.shapeInfo.isUniform)return"\n float "+n+"(int index) {\n "+sa(e)+"\n }\n ";var r=e.shapeInfo.texShape,o=r[0],a=r[1];if(1===a&&1===o)return"\n float "+n+"(int index) {\n return sampleTexture("+t+", halfCR);\n }\n ";var i=ia(t);return 1===a?"\n float "+n+"(int index) {\n vec2 uv = vec2(0.5, (float(index + "+i+") + 0.5) / "+o+".0);\n return sampleTexture("+t+", uv);\n }\n ":1===o?"\n float "+n+"(int index) {\n vec2 uv = vec2((float(index + "+i+") + 0.5) / "+a+".0, 0.5);\n return sampleTexture("+t+", uv);\n }\n ":"\n float "+n+"(int index) {\n vec2 uv = uvFromFlat("+o+", "+a+", index + "+i+");\n return sampleTexture("+t+", uv);\n }\n "}(e);case 2:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),o=e.shapeInfo.texShape;if(null!=o&&pe(t,o)){var a=o[0];return"\n float "+r+"(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2("+o[1]+".0, "+a+".0);\n return sampleTexture("+n+", uv);\n }\n "}var i=xe(t),s=i.newShape,u=i.keptDims,c=s;if(c.length<t.length)return"\n "+ea(ca(e,c))+"\n float "+r+"(int row, int col) {\n return "+r+"("+la(["row","col"],u)+");\n }\n ";if(e.shapeInfo.isUniform)return"\n float "+r+"(int row, int col) {\n int index = round(dot(vec2(row, col), vec2("+t[1]+", 1)));\n "+sa(e)+"\n }\n ";var l=o[0],f=o[1],h=ia(n);return 1===f?"\n float "+r+"(int row, int col) {\n float index = dot(vec3(row, col, "+h+"), vec3("+t[1]+", 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / "+l+".0);\n return sampleTexture("+n+", uv);\n }\n ":1===l?"\n float "+r+"(int row, int col) {\n float index = dot(vec3(row, col, "+h+"), vec3("+t[1]+", 1, 1));\n vec2 uv = vec2((index + 0.5) / "+f+".0, 0.5);\n return sampleTexture("+n+", uv);\n }\n ":"\n float "+r+"(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+t[1]+" + col + "+h+";\n vec2 uv = uvFromFlat("+l+", "+f+", index);\n return sampleTexture("+n+", uv);\n }\n"}(e);case 3:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),o=t[1]*t[2],a=t[2],i=xe(t),s=i.newShape,u=i.keptDims,c=s;if(c.length<t.length)return"\n "+ea(ca(e,c))+"\n float "+r+"(int row, int col, int depth) {\n return "+r+"("+la(["row","col","depth"],u)+");\n }\n ";if(e.shapeInfo.isUniform)return"\n float "+r+"(int row, int col, int depth) {\n int index = round(dot(vec3(row, col, depth),\n vec3("+o+", "+a+", 1)));\n "+sa(e)+"\n }\n ";var l=e.shapeInfo.texShape,f=l[0],h=l[1],p=e.shapeInfo.flatOffset;return h===o&&null==p?"\n float "+r+"(int row, int col, int depth) {\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2("+a+", 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+h+".0, "+f+".0);\n return sampleTexture("+n+", uv);\n }\n ":h===a&&null==p?"\n float "+r+"(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2("+t[1]+", 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+h+".0, "+f+".0);\n return sampleTexture("+n+", uv);\n }\n ":"\n float "+r+"(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+o+" + col * "+a+" + depth + "+ia(n)+";\n vec2 uv = uvFromFlat("+f+", "+h+", index);\n return sampleTexture("+n+", uv);\n }\n "}(e);case 4:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),o=t[3],a=t[2]*o,i=t[1]*a,s=xe(t),u=s.newShape,c=s.keptDims;if(u.length<t.length)return"\n "+ea(ca(e,u))+"\n float "+r+"(int row, int col, int depth, int depth2) {\n return "+r+"("+la(["row","col","depth","depth2"],c)+");\n }\n ";if(e.shapeInfo.isUniform)return"\n float "+r+"(int row, int col, int depth, int depth2) {\n int index = round(dot(vec4(row, col, depth, depth2),\n vec4("+i+", "+a+", "+o+", 1)));\n "+sa(e)+"\n }\n ";var l=e.shapeInfo.flatOffset,f=e.shapeInfo.texShape,h=f[0],p=f[1];return p===i&&null==l?"\n float "+r+"(int row, int col, int depth, int depth2) {\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3("+a+", "+o+", 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+p+".0, "+h+".0);\n return sampleTexture("+n+", uv);\n }\n ":p===o&&null==l?"\n float "+r+"(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3("+t[1]*t[2]+", "+t[2]+", 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+p+".0, "+h+".0);\n return sampleTexture("+n+", uv);\n }\n ":"\n float "+r+"(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+i+" + col * "+a+" +\n depth * "+o+" + depth2;\n vec2 uv = uvFromFlat("+h+", "+p+", index + "+ia(n)+");\n return sampleTexture("+n+", uv);\n }\n "}(e);case 5:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),o=t[4],a=t[3]*o,i=t[2]*a,s=t[1]*i,u=xe(t),c=u.newShape,l=u.keptDims;if(c.length<t.length)return"\n "+ea(ca(e,c))+"\n float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n return "+r+"("+la(["row","col","depth","depth2","depth3"],l)+");\n }\n ";if(e.shapeInfo.isUniform)return"\n float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n float index = dot(\n vec4(row, col, depth, depth2),\n vec4("+s+", "+i+", "+a+", "+o+")) +\n depth3;\n "+sa(e)+"\n }\n ";var f=e.shapeInfo.flatOffset,h=e.shapeInfo.texShape,p=h[0],d=h[1];return d===s&&null==f?"\n float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4("+i+", "+a+", "+o+", 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+d+".0, "+p+".0);\n return sampleTexture("+n+", uv);\n }\n ":d===o&&null==f?"\n float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n float texR = dot(\n vec4(row, col, depth, depth2),\n vec4("+t[1]*t[2]*t[3]+",\n "+t[2]*t[3]+", "+t[3]+", 1));\n int texC = depth3;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+d+".0, "+p+".0);\n return sampleTexture("+n+", uv);\n }\n ":"\n float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+s+" + col * "+i+" + depth * "+a+" +\n depth2 * "+o+" + depth3 + "+ia(n)+";\n vec2 uv = uvFromFlat("+p+", "+d+", index);\n return sampleTexture("+n+", uv);\n }\n "}(e);case 6:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),o=xe(t),a=o.newShape,i=o.keptDims;if(a.length<t.length)return"\n "+ea(ca(e,a))+"\n float "+r+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n return "+r+"("+la(["row","col","depth","depth2","depth3","depth4"],i)+");\n }\n ";var s=t[5],u=t[4]*s,c=t[3]*u,l=t[2]*c,f=t[1]*l;if(e.shapeInfo.isUniform)return"\n float "+r+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int index = round(dot(\n vec4(row, col, depth, depth2),\n vec4("+f+", "+l+", "+c+", "+u+")) +\n dot(\n vec2(depth3, depth4),\n vec2("+s+", 1)));\n "+sa(e)+"\n }\n ";var h=e.shapeInfo.flatOffset,p=e.shapeInfo.texShape,d=p[0],v=p[1];return v===f&&null==h?"\n float "+r+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4("+l+", "+c+", "+u+", "+s+")) +\n float(depth4);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+v+".0, "+d+".0);\n return sampleTexture("+n+", uv);\n }\n ":v===s&&null==h?"\n float "+r+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n float texR = dot(vec4(row, col, depth, depth2),\n vec4("+t[1]*t[2]*t[3]*t[4]+",\n "+t[2]*t[3]*t[4]+",\n "+t[3]*t[4]+",\n "+t[4]+")) + float(depth3);\n int texC = depth4;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+v+".0, "+d+".0);\n return sampleTexture("+n+", uv);\n }\n ":"\n float "+r+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+f+" + col * "+l+" + depth * "+c+" +\n depth2 * "+u+" + depth3 * "+s+" + depth4 + "+ia(n)+";\n vec2 uv = uvFromFlat("+d+", "+v+", index);\n return sampleTexture("+n+", uv);\n }\n "}(e);default:throw new Error(t.length+"-D input sampling is not yet supported")}}function ta(e){var t;switch(e.shapeInfo.logicalShape.length){case 0:return"\n vec4 "+("get"+(t=e.name).charAt(0).toUpperCase()+t.slice(1))+"() {\n return "+$o().texture2D+"("+t+", halfCR);\n }\n ";case 1:return function(e){var t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),r=e.shapeInfo.texShape,o=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],a=$o();return"\n vec4 "+n+"(int index) {\n vec2 uv = packedUVfrom1D(\n "+o[0]+", "+o[1]+", index);\n return "+a.texture2D+"("+t+", uv);\n }\n "}(e);case 2:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),o=e.shapeInfo.texShape,a=o[0],i=o[1],s=$o();if(null!=o&&pe(t,o))return"\n vec4 "+r+"(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2("+i+".0, "+a+".0);\n\n return "+s.texture2D+"("+n+", uv);\n }\n ";var u=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];return"\n vec4 "+r+"(int row, int col) {\n vec2 uv = packedUVfrom2D("+Math.ceil(t[1]/2)+", "+u[0]+", "+u[1]+", row, col);\n return "+s.texture2D+"("+n+", uv);\n }\n "}(e);case 3:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),o=e.shapeInfo.texShape,a=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];if(1===t[0])return"\n "+ta(ca(e,t.slice(1)))+"\n vec4 "+r+"(int b, int row, int col) {\n return "+r+"("+la(["b","row","col"],[1,2])+");\n }\n ";var i=a[0],s=a[1],u=Math.ceil(t[2]/2);return"\n vec4 "+r+"(int b, int row, int col) {\n vec2 uv = packedUVfrom3D(\n "+i+", "+s+", "+u*Math.ceil(t[1]/2)+", "+u+", b, row, col);\n return "+$o().texture2D+"("+n+", uv);\n }\n "}(e);default:return function(e){for(var t=e.shapeInfo.logicalShape,n=t.length,r=e.name,o="get"+r.charAt(0).toUpperCase()+r.slice(1),a=e.shapeInfo.texShape,i=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)],s=i[0],u=i[1],c=Math.ceil(t[n-1]/2),l=c*Math.ceil(t[n-2]/2),f="int b, int row, int col",h="b * "+l+" + (row / 2) * "+c+" + (col / 2)",p=2;p<n-1;p++)f="int b"+p+", "+f,h="b"+p+" * "+(l*=t[n-p-1])+" + "+h;return"\n vec4 "+o+"("+f+") {\n int index = "+h+";\n int texR = index / "+u+";\n int texC = index - texR * "+u+";\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+u+", "+s+");\n return "+$o().texture2D+"("+r+", uv);\n }\n "}(e)}}var na="\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n int texelIndex = index / 2;\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",ra="\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n int texNumC, int row, int col) {\n int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",oa="\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n int texelsInBatch, int texelsInLogicalRow, int b,\n int row, int col) {\n int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",aa="\n float getChannel(vec4 frag, vec2 innerDims) {\n vec2 modCoord = mod(innerDims, 2.);\n return modCoord.x == 0. ?\n (modCoord.y == 0. ? frag.r : frag.g) :\n (modCoord.y == 0. ? frag.b : frag.a);\n }\n float getChannel(vec4 frag, int dim) {\n float modCoord = mod(float(dim), 2.);\n return modCoord == 0. ? frag.r : frag.g;\n }\n";function ia(e){return"offset"+e}function sa(e){var t=e.name,n=he(e.shapeInfo.logicalShape);return n<2?"return "+t+";":"\n for (int i = 0; i < "+n+"; i++) {\n if (i == index) {\n return "+t+"[i];\n }\n }\n "}function ua(e){if(e<=1)return"int";if(2===e)return"ivec2";if(3===e)return"ivec3";if(4===e)return"ivec4";if(5===e)return"ivec5";if(6===e)return"ivec6";throw Error("GPU for rank "+e+" is not yet supported")}function ca(e,t){var n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function la(e,t){return t.map((function(t){return e[t]})).join(", ")}var fa=function(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,ue(e.length>2,(function(){return"Packed arg"+(n.charAt(0).toUpperCase()+n.slice(1))+" supports only inputs with rank above 2."}));var o=e[e.length-1],a=Math.ceil(o/t);this.outputShape=e.slice(0,-1),a>1&&this.outputShape.push(a),r||this.variableNames.push("bestIndicesA");var i,s,u=this.outputShape,c=u.length,l=ua(c),f=Ko("coords",c);if(1===a){var h=ua(s=c+1);i="\n "+h+" sourceLocR = "+h+"("+f.join()+", 0);\n ++"+f[c-1]+";\n "+h+" sourceLocG = "+h+"("+f.join()+", 0);\n ++"+f[c-2]+";\n "+h+" sourceLocA = "+h+"("+f.join()+", 0);\n --"+f[c-1]+";\n "+h+" sourceLocB = "+h+"("+f.join()+", 0);\n --"+f[c-2]+";"}else s=c,i="\n "+l+" sourceLocR = coords;\n ++"+f[c-1]+";\n "+l+" sourceLocG = coords;\n ++"+f[c-2]+";\n "+l+" sourceLocA = coords;\n --"+f[c-1]+";\n "+l+" sourceLocB = coords;\n --"+f[c-2]+";";var p=["x","y","z","w","u","v"].slice(0,s),d="."+p[s-1],v=p.map((function(e){return"int "+e})),m=Ko("sourceLocR",s-1).concat("inIdx.r"),g=Ko("sourceLocG",s-1).concat("inIdx.g"),y=Ko("sourceLocB",s-1).concat("inIdx.b"),b=Ko("sourceLocA",s-1).concat("inIdx.a"),w="max"===n?"greaterThan":"lessThan",x=r?"":"\n inIdx = round(vec4(getBestIndicesAChannel("+m.join()+"),\n getBestIndicesAChannel("+g.join()+"),\n getBestIndicesAChannel("+y.join()+"),\n getBestIndicesAChannel("+b.join()+")));",E="vec4(\n getAChannel("+m.join()+"),\n hasNextCol ? getAChannel("+g.join()+") : 0.,\n hasNextRow ? getAChannel("+y.join()+") : 0.,\n hasNextRow && hasNextCol ? getAChannel("+b.join()+") : 0.)",_=r?"":"\n float getBestIndicesAChannel("+v.join()+") {\n return getChannel(getBestIndicesA("+p.join()+"),\n vec2("+p.slice(-2).join()+"));\n }";this.userCode="\n float getAChannel("+v.join()+") {\n return getChannel(getA("+p.join()+"),\n vec2("+p.slice(-2).join()+"));\n }\n "+_+"\n void main() {\n "+l+" coords = getOutputCoords();\n bool hasNextCol = "+f[c-1]+" < "+(u[c-1]-1)+";\n bool hasNextRow = "+f[c-2]+" < "+(u[c-2]-1)+";\n "+i+"\n ivec4 srcIdx = ivec4(sourceLocR"+d+", sourceLocG"+d+",\n sourceLocB"+d+", sourceLocA"+d+") * "+t+";\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = "+E+";\n\n for (int i = 0; i < "+t+"; i++) {\n inIdx = srcIdx;\n "+x+"\n vec4 candidate = "+E+";\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4("+w+"(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n bestValue = vec4(replace.x ? candidate.x : bestValue.x,\n replace.y ? candidate.y : bestValue.y,\n replace.z ? candidate.z : bestValue.z,\n replace.w ? candidate.w : bestValue.w);\n bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n srcIdx++;\n }\n setOutput(bestIndex);\n }\n "},ha=function(e){this.variableNames=["dy"],this.outputShape=e.inShape;var t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,o=e.strideWidth,a=e.dilationHeight,i=e.dilationWidth,s=e.effectiveFilterHeight,u=e.effectiveFilterWidth,c=s-1-e.padInfo.top,l=u-1-e.padInfo.left,f=1/(t*n);this.userCode="\n const ivec2 pads = ivec2("+c+", "+l+");\n const float avgMultiplier = float("+f+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+s+";\n wR += "+a+") {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+u+";\n wC+= "+i+") {\n float dyC = float(dyCCorner + wC) / "+o+".0;\n\n if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n setOutput(dotProd);\n }\n "},pa=function(e){this.variableNames=["dy"],this.outputShape=e.inShape;var t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,o=e.strideDepth,a=e.strideHeight,i=e.strideWidth,s=e.dilationDepth,u=e.dilationHeight,c=e.dilationWidth,l=e.effectiveFilterDepth,f=e.effectiveFilterHeight,h=e.effectiveFilterWidth,p=l-1-e.padInfo.front,d=f-1-e.padInfo.top,v=h-1-e.padInfo.left,m=1/(t*n*r);this.userCode="\n const ivec3 pads = ivec3("+p+", "+d+", "+v+");\n const float avgMultiplier = float("+m+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < "+l+";\n wD += "+s+") {\n float dyD = float(dyDCorner + wD) / "+o+".0;\n\n if (dyD < 0.0 || dyD >= "+e.outDepth+".0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < "+f+";\n wR += "+u+") {\n float dyR = float(dyRCorner + wR) / "+a+".0;\n\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+h+";\n wC += "+c+") {\n float dyC = float(dyCCorner + wC) / "+i+".0;\n\n if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n }\n setOutput(dotProd);\n }\n "},da=function(e,t,n,r,o,a){this.outputShape=[],this.variableNames=["x","mean","variance"],yo(e,t),yo(e,n);var i="0.0";null!=r&&(yo(e,r),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");var s="1.0";null!=o&&(yo(e,o),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=e,this.userCode="\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = "+i+";\n float scale = "+s+";\n float inv = scale * inversesqrt(variance + float("+a+"));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n "},va=function(e,t,n,r,o,a){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],yo(e,t),yo(e,n);var i="vec4(0.0)";null!=r&&(yo(e,r),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");var s="vec4(1.0)";null!=o&&(yo(e,o),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=e,this.userCode="\n void main() {\n vec4 offset = "+i+";\n vec4 scale = "+s+";\n\n vec4 x = getXAtOutCoords();\n vec4 mean = getMeanAtOutCoords();\n vec4 variance = getVarianceAtOutCoords();\n\n vec4 inv = scale * inversesqrt(variance + vec4("+a+"));\n\n setOutput((x - mean) * inv + offset);\n }\n "},ma=function(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=yo(t,n),this.userCode="\n float binaryOpComplex(\n float areal, float aimag, float breal, float bimag) {\n "+e+"\n }\n\n void main() {\n float areal = getARealAtOutCoords();\n float aimag = getAImagAtOutCoords();\n float breal = getBRealAtOutCoords();\n float bimag = getBImagAtOutCoords();\n setOutput(binaryOpComplex(areal, aimag, breal, bimag));\n }\n "},ga="return a + b;",ya="return a - b;",ba="return a * b;",wa="return (a < 0.) ? b * a : a;",xa=function(e,t,n){this.variableNames=["A","B"],this.outputShape=yo(t,n),this.userCode="\n float binaryOperation(float a, float b) {\n "+e+"\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n "},Ea="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",_a=function(e,t,n,r){void 0===r&&(r=!1),this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=yo(t,n);var o=this.outputShape.length,a="";if(r)if(0===o||1===he(this.outputShape))a="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else if(a="\n "+ua(o)+" coords = getOutputCoords();\n ",1===o)a+="\n result.y = (coords + 1) >= "+this.outputShape[0]+" ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ";else{var i=Ko("coords",o);a+="\n bool nextRowOutOfBounds =\n ("+i[o-2]+" + 1) >= "+this.outputShape[o-2]+";\n bool nextColOutOfBounds =\n ("+i[o-1]+" + 1) >= "+this.outputShape[o-1]+";\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n "}this.userCode="\n vec4 binaryOperation(vec4 a, vec4 b) {\n "+e+"\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n "+a+"\n\n setOutput(result);\n }\n "},Oa=function(){function e(e){this.variableNames=["A"],this.outputShape=e,this.userCode="\n uniform float minVal;\n uniform float maxVal;\n\n void main() {\n float value = getAAtOutCoords();\n if (isnan(value)) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, minVal, maxVal));\n }\n "}return e.prototype.getCustomSetupFunc=function(e,t){var n=this;return function(r,o){null==n.minLoc&&(n.minLoc=r.getUniformLocationNoThrow(o,"minVal"),n.maxLoc=r.getUniformLocationNoThrow(o,"maxVal")),r.gl.uniform1f(n.minLoc,e),r.gl.uniform1f(n.maxLoc,t)}},e}(),ka=function(){function e(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.userCode="\n uniform float minVal;\n uniform float maxVal;\n\n void main() {\n vec4 value = getAAtOutCoords();\n\n if (any(isnan(value))) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n }\n "}return e.prototype.getCustomSetupFunc=function(e,t){var n=this;return function(r,o){null==n.minLoc&&(n.minLoc=r.getUniformLocationNoThrow(o,"minVal"),n.maxLoc=r.getUniformLocationNoThrow(o,"maxVal")),r.gl.uniform1f(n.minLoc,e),r.gl.uniform1f(n.maxLoc,t)}},e}(),Ca=function(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode="\n void main() {\n float re = abs(getRealAtOutCoords());\n float im = abs(getImagAtOutCoords());\n float mx = max(re, im);\n\n // sadly the length function in glsl is not underflow-safe\n // (at least not on Intel GPUs). So the safe solution is\n // to ensure underflow-safety in all cases.\n setOutput(\n mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n );\n }\n "},Ia=function(e){this.outputShape=[],this.outputShape=Ln(e,1),this.variableNames=e.map((function(e,t){return"T"+t}));var t=new Array(e.length-1);t[0]=e[0][1];for(var n=1;n<t.length;n++)t[n]=t[n-1]+e[n][1];var r=["if (yC < "+t[0]+") setOutput(getT0(yR, yC));"];for(n=1;n<t.length;n++){var o=t[n-1];r.push("else if (yC < "+t[n]+") setOutput(getT"+n+"(yR, yC-"+o+"));")}var a=t.length,i=t[t.length-1];r.push("else setOutput(getT"+a+"(yR, yC-"+i+"));"),this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int yR = coords.x;\n int yC = coords.y;\n\n "+r.join("\n ")+"\n }\n "},Sa=function(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=Ln(e,t);var n=this.outputShape,r=n.length,o=ua(r),a=Ko("coords",r),i=["x","y","z","w","u","v"].slice(0,r);this.variableNames=e.map((function(e,t){return"T"+t}));var s=new Array(e.length-1);s[0]=e[0][t];for(var u=1;u<s.length;u++)s[u]=s[u-1]+e[u][t];var c=i[t],l=i.slice(-2),f=i.join(),h="if ("+c+" < "+s[0]+") {\n return getChannel(\n getT0("+f+"), vec2("+l.join()+"));\n }";for(u=1;u<s.length;u++){var p=s[u-1];h+="\n if ("+c+" < "+s[u]+" && "+c+" >= "+s[u-1]+") {\n return getChannel(\n getT"+u+"("+Ra(i,c,p)+"),\n vec2("+Ra(l,c,p)+"));\n }"}var d=s.length,v=s[s.length-1];h+="\n return getChannel(\n getT"+d+"("+Ra(i,c,v)+"),\n vec2("+Ra(l,c,v)+"));",this.userCode="\n float getValue("+i.map((function(e){return"int "+e}))+") {\n "+h+"\n }\n\n void main() {\n "+o+" coords = getOutputCoords();\n vec4 result = vec4(getValue("+a+"), 0., 0., 0.);\n\n "+a[r-1]+" = "+a[r-1]+" + 1;\n if ("+a[r-1]+" < "+n[r-1]+") {\n result.g = getValue("+a+");\n }\n\n "+a[r-2]+" = "+a[r-2]+" + 1;\n if ("+a[r-2]+" < "+n[r-2]+") {\n result.a = getValue("+a+");\n }\n\n "+a[r-1]+" = "+a[r-1]+" - 1;\n if ("+a[r-2]+" < "+n[r-2]+" &&\n "+a[r-1]+" < "+n[r-1]+") {\n result.b = getValue("+a+");\n }\n setOutput(result);\n }\n "};function Ra(e,t,n){var r=e.indexOf(t);return e.map((function(e,t){return t===r?e+" - "+n:e})).join()}var Aa=function(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;var t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,o=e.padInfo.left,a="channelsLast"===e.dataFormat;this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int d2 = coords.w;\n\n // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int b = 0; b < "+e.batchSize+"; b++) {\n for (int yR = 0; yR < "+e.outHeight+"; yR++) {\n int xR = wR + yR * "+t+" - "+r+";\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int yC = 0; yC < "+e.outWidth+"; yC++) {\n int xC = wC + yC * "+n+" - "+o+";\n\n if (xC < 0 || xC >= "+e.inWidth+") {\n continue;\n }\n\n if ("+a+") {\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n } else {\n float dyValue = getDy(b, d2, yR, yC);\n float xValue = getX(b, d1, xR, xC);\n dotProd += (xValue * dyValue);\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n "},Pa=function(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;var t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,o=e.strideWidth,a="channelsLast"===e.dataFormat,i=t-1-e.padInfo.top,s=n-1-e.padInfo.left,u=a?1:2,c=a?2:3,l=a?3:1;this.userCode="\n const ivec2 pads = ivec2("+i+", "+s+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords["+l+"];\n\n ivec2 dyCorner = ivec2(coords["+u+"], coords["+c+"]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+t+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = "+t+" - 1 - wR;\n\n for (int wC = 0; wC < "+n+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+o+".0;\n\n if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = "+n+" - 1 - wC;\n\n for (int d2 = 0; d2 < "+e.outChannels+"; d2++) {\n\n if ("+a+") {\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n } else {\n float xValue = getDy(batch, d2, idyR, idyC);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n "},Ta=function(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;var t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,o=e.padInfo.front,a=e.padInfo.top,i=e.padInfo.left;this.userCode="\n void main() {\n ivec5 coords = getOutputCoords();\n int wF = coords.x;\n int wR = coords.y;\n int wC = coords.z;\n int d1 = coords.w;\n int d2 = coords.u;\n\n float dotProd = 0.0;\n\n for (int b = 0; b < "+e.batchSize+"; b++) {\n for (int yF = 0; yF < "+e.outDepth+"; yF++) {\n int xF = wF + yF * "+t+" - "+o+";\n\n if (xF < 0 || xF >= "+e.inDepth+") {\n continue;\n }\n\n for (int yR = 0; yR < "+e.outHeight+"; yR++) {\n int xR = wR + yR * "+n+" - "+a+";\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int yC = 0; yC < "+e.outWidth+"; yC++) {\n int xC = wC + yC * "+r+" - "+i+";\n\n if (xC < 0 || xC >= "+e.inWidth+") {\n continue;\n }\n\n float dyValue = getDy(b, yF, yR, yC, d2);\n float xValue = getX(b, xF, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n "},Da=function(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;var t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,o=e.strideDepth,a=e.strideHeight,i=e.strideWidth,s=t-1-e.padInfo.front,u=n-1-e.padInfo.top,c=r-1-e.padInfo.left;this.userCode="\n const ivec3 pads = ivec3("+s+", "+u+", "+c+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.u;\n\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyFCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n float dotProd = 0.0;\n for (int wF = 0; wF < "+t+"; wF++) {\n float dyF = float(dyFCorner + wF) / "+o+".0;\n\n if (dyF < 0.0 || dyF >= "+e.outDepth+".0 || fract(dyF) > 0.0) {\n continue;\n }\n int idyF = int(dyF);\n\n int wFPerm = "+t+" - 1 - wF;\n\n for (int wR = 0; wR < "+n+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+a+".0;\n\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = "+n+" - 1 - wR;\n\n for (int wC = 0; wC < "+r+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+i+".0;\n\n if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = "+r+" - 1 - wC;\n\n for (int d2 = 0; d2 < "+e.outChannels+"; d2++) {\n float xValue = getDy(batch, idyF, idyR, idyC, d2);\n float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n }\n }\n }\n setOutput(dotProd);\n }\n "},Ma=function(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;var t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,o=e.padInfo.left,a=e.outChannels/e.inChannels;this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int dm = coords.w;\n int d2 = d1 * "+a+" + dm;\n\n float dotProd = 0.0;\n\n // TO DO: Vec4 over the batch size\n for (int b = 0; b < "+e.batchSize+"; b++) {\n for (int yR = 0; yR < "+e.outHeight+"; yR++) {\n int xR = wR + yR * "+t+" - "+r+";\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int yC = 0; yC < "+e.outWidth+"; yC++) {\n int xC = wC + yC * "+n+" - "+o+";\n\n if (xC < 0 || xC >= "+e.inWidth+") {\n continue;\n }\n\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n setOutput(dotProd);\n }\n "},Na=function(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;var t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,o=e.strideWidth,a=t-1-e.padInfo.top,i=n-1-e.padInfo.left,s=e.outChannels/e.inChannels;this.userCode="\n const ivec2 pads = ivec2("+a+", "+i+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n ivec2 dyCorner = coords.yz - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n float dotProd = 0.0;\n\n for (int wR = 0; wR < "+t+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = "+t+" - 1 - wR;\n\n for (int wC = 0; wC < "+n+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+o+".0;\n\n if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = "+n+" - 1 - wC;\n\n // TO DO: Vec4 over the channelMul\n for (int dm = 0; dm < "+s+"; dm++) {\n int d2 = d1 * "+s+" + dm;\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, dm);\n dotProd += xValue * wValue;\n }\n }\n }\n setOutput(dotProd);\n }\n "},Fa=function(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.outputShape=e.outShape;var o=e.padInfo.top,a=e.padInfo.left,i=e.strideHeight,s=e.strideWidth,u=e.dilationHeight,c=e.dilationWidth,l=e.filterHeight,f=e.filterWidth,h=4*Math.floor(e.inChannels/4),p=e.inChannels%4,d="channelsLast"===e.dataFormat,v=d?1:2,m=d?2:3,g=d?3:1,y="",b="";n&&(y=r?"float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n "+n+"\n }":"\n float activation(float x) {\n "+n+"\n }\n ",b="result = activation(result);");var w=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n "+y+"\n\n const ivec2 strides = ivec2("+i+", "+s+");\n const ivec2 pads = ivec2("+o+", "+a+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords["+g+"];\n\n ivec2 xRCCorner =\n ivec2(coords["+v+"], coords["+m+"]) * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+l+"; wR++) {\n int xR = xRCorner + wR * "+u+";\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+f+"; wC++) {\n int xC = xCCorner + wC * "+c+";\n\n if (xC < 0 || xC >= "+e.inWidth+") {\n continue;\n }\n\n for (int d1 = 0; d1 < "+h+"; d1 += 4) {\n vec4 wValues = vec4(\n getW(wR, wC, d1, d2),\n getW(wR, wC, d1 + 1, d2),\n getW(wR, wC, d1 + 2, d2),\n getW(wR, wC, d1 + 3, d2)\n );\n\n if ("+d+") {\n vec4 xValues = vec4(\n getX(batch, xR, xC, d1),\n getX(batch, xR, xC, d1 + 1),\n getX(batch, xR, xC, d1 + 2),\n getX(batch, xR, xC, d1 + 3)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec4 xValues = vec4(\n getX(batch, d1, xR, xC),\n getX(batch, d1 + 1, xR, xC),\n getX(batch, d1 + 2, xR, xC),\n getX(batch, d1 + 3, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n\n if ("+(1===p)+") {\n\n if ("+d+") {\n dotProd +=\n getX(batch, xR, xC, "+h+") *\n getW(wR, wC, "+h+", d2);\n } else {\n dotProd +=\n getX(batch, "+h+", xR, xC) *\n getW(wR, wC, "+h+", d2);\n }\n\n } else if ("+(2===p)+") {\n vec2 wValues = vec2(\n getW(wR, wC, "+h+", d2),\n getW(wR, wC, "+h+" + 1, d2)\n );\n\n if ("+d+") {\n vec2 xValues = vec2(\n getX(batch, xR, xC, "+h+"),\n getX(batch, xR, xC, "+h+" + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, "+h+", xR, xC),\n getX(batch, "+h+" + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if ("+(3===p)+") {\n vec3 wValues = vec3(\n getW(wR, wC, "+h+", d2),\n getW(wR, wC, "+h+" + 1, d2),\n getW(wR, wC, "+h+" + 2, d2)\n );\n\n if ("+d+") {\n vec3 xValues = vec3(\n getX(batch, xR, xC, "+h+"),\n getX(batch, xR, xC, "+h+" + 1),\n getX(batch, xR, xC, "+h+" + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, "+h+", xR, xC),\n getX(batch, "+h+" + 1, xR, xC),\n getX(batch, "+h+" + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n "+w+"\n "+b+"\n setOutput(result);\n }\n "},Ba=function(e){this.variableNames=["x","W"],this.outputShape=e.outShape;var t=e.padInfo.front,n=e.padInfo.top,r=e.padInfo.left,o=e.strideDepth,a=e.strideHeight,i=e.strideWidth,s=e.dilationDepth,u=e.dilationHeight,c=e.dilationWidth,l=e.filterDepth,f=e.filterHeight,h=e.filterWidth,p=4*Math.floor(e.inChannels/4),d=e.inChannels%4;this.userCode="\n const ivec3 strides = ivec3("+o+", "+a+", "+i+");\n const ivec3 pads = ivec3("+t+", "+n+", "+r+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d2 = coords.u;\n\n ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xFCorner = xFRCCorner.x;\n int xRCorner = xFRCCorner.y;\n int xCCorner = xFRCCorner.z;\n\n // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n // y(yF, yR, yC, d2). ? = to be determined. : = across all\n // values in that axis.\n float dotProd = 0.0;\n for (int wF = 0; wF < "+l+"; wF++) {\n int xF = xFCorner + wF * "+s+";\n\n if (xF < 0 || xF >= "+e.inDepth+") {\n continue;\n }\n\n for (int wR = 0; wR < "+f+"; wR++) {\n int xR = xRCorner + wR * "+u+";\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+h+"; wC++) {\n int xC = xCCorner + wC * "+c+";\n\n if (xC < 0 || xC >= "+e.inWidth+") {\n continue;\n }\n\n for (int d1 = 0; d1 < "+p+"; d1 += 4) {\n vec4 xValues = vec4(\n getX(batch, xF, xR, xC, d1),\n getX(batch, xF, xR, xC, d1 + 1),\n getX(batch, xF, xR, xC, d1 + 2),\n getX(batch, xF, xR, xC, d1 + 3)\n );\n vec4 wValues = vec4(\n getW(wF, wR, wC, d1, d2),\n getW(wF, wR, wC, d1 + 1, d2),\n getW(wF, wR, wC, d1 + 2, d2),\n getW(wF, wR, wC, d1 + 3, d2)\n );\n\n dotProd += dot(xValues, wValues);\n }\n\n if ("+(1===d)+") {\n dotProd +=\n getX(batch, xF, xR, xC, "+p+") *\n getW(wF, wR, wC, "+p+", d2);\n } else if ("+(2===d)+") {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, "+p+"),\n getX(batch, xF, xR, xC, "+p+" + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, "+p+", d2),\n getW(wF, wR, wC, "+p+" + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if ("+(3===d)+") {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, "+p+"),\n getX(batch, xF, xR, xC, "+p+" + 1),\n getX(batch, xF, xR, xC, "+p+" + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, "+p+", d2),\n getW(wF, wR, wC, "+p+" + 1, d2),\n getW(wF, wR, wC, "+p+" + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n "},ja=function(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.outputShape=e.outShape;var o=e.inHeight,a=e.inWidth,i=e.padInfo.top,s=e.padInfo.left,u=e.strideHeight,c=e.strideWidth,l=e.dilationHeight,f=e.dilationWidth,h=e.filterHeight,p=e.filterWidth,d=e.outChannels/e.inChannels,v="",m="";n&&(v=r?"float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n "+n+"\n }":"\n float activation(float x) {\n "+n+"\n }\n ",m="result = activation(result);");var g=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n "+v+"\n\n const ivec2 strides = ivec2("+u+", "+c+");\n const ivec2 pads = ivec2("+i+", "+s+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / "+d+";\n int q = d2 - d1 * "+d+";\n\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n for (int wR = 0; wR < "+h+"; wR++) {\n int xR = xRCorner + wR * "+l+";\n\n if (xR < 0 || xR >= "+o+") {\n continue;\n }\n\n for (int wC = 0; wC < "+p+"; wC++) {\n int xC = xCCorner + wC * "+f+";\n\n if (xC < 0 || xC >= "+a+") {\n continue;\n }\n\n float xVal = getX(batch, xR, xC, d1);\n float wVal = getW(wR, wC, d1, q);\n dotProd += xVal * wVal;\n }\n }\n\n float result = dotProd;\n "+g+"\n "+m+"\n setOutput(result);\n }\n "},La=function(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.outShape;for(var o=e.inHeight,a=e.inWidth,i=e.padInfo.top,s=e.padInfo.left,u=e.strideHeight,c=e.strideWidth,l=e.dilationHeight,f=e.dilationWidth,h=e.filterHeight,p=e.filterWidth,d=p,v="int xR; int xC; int xCOffset;",m=0;m<h;m++)for(var g=0;g<p;g++)v+="\n vec4 xTexelR"+m+"C"+2*g+" = vec4(0.);\n vec4 wR"+m+"C"+g+" = vec4(0.);\n vec4 xR"+m+"C"+g+" = vec4(0.);";for(m=0;m<h;m++)for(var y=0;y<d;y++){if(v+="\n xR = xRCorner + "+m*l+";\n xC = xCCorner + "+(g=2*y)*f+";\n ",1===c){if(g<p&&(v+=s%2==1?"\n xCOffset = xC + 1;\n if(xR >= 0 && xR < "+o+" && xCOffset >= 0 && xCOffset < "+a+") {\n xTexelR"+m+"C"+g+" = getX(batch, xR, xCOffset, d1);\n } else {\n xTexelR"+m+"C"+g+" = vec4(0.);\n }\n\n xCOffset = xC + 1 - 2;\n if(xR >= 0 && xR < "+o+" && xCOffset >= 0 && xCOffset < "+a+") {\n vec4 previous = getX(batch, xR, xCOffset, d1);\n xR"+m+"C"+g+" = vec4(previous.zw, xTexelR"+m+"C"+g+".xy);\n } else {\n xR"+m+"C"+g+" = vec4(0, 0, xTexelR"+m+"C"+g+".xy);\n }\n ":"\n if(xR >= 0 && xR < "+o+" && xC >= 0 && xC < "+a+") {\n xTexelR"+m+"C"+g+" = getX(batch, xR, xC, d1);\n } else {\n xTexelR"+m+"C"+g+" = vec4(0.);\n }\n\n xR"+m+"C"+g+" = xTexelR"+m+"C"+g+";\n ",g+1<p)){var b=s%2==0?ie(f):f;f%2==0&&s%2==1||f%2!=0&&s%2!=1?(v+="\n xCOffset = xC + "+s%2+" + "+b+";\n\n if(xR >= 0 && xR < "+o+" &&\n xCOffset >= 0 && xCOffset < "+a+") {\n xTexelR"+m+"C"+(g+2)+" = getX(batch, xR, xCOffset, d1);\n }\n ",f>1&&(v+="\n xCOffset -= 2;\n if(xR >= 0 && xR < "+o+" &&\n xCOffset >= 0 && xCOffset < "+a+") {\n xTexelR"+m+"C"+g+" = getX(batch, xR, xCOffset, d1);\n } else {\n xTexelR"+m+"C"+g+" = vec4(0.);\n }\n "),v+="\n xR"+m+"C"+(g+1)+" = vec4(\n xTexelR"+m+"C"+g+".zw, xTexelR"+m+"C"+(g+2)+".xy);\n "):v+="\n xCOffset = xC + "+b+";\n\n if(xR >= 0 && xR < "+o+" &&\n xCOffset >= 0 && xCOffset < "+a+") {\n xTexelR"+m+"C"+(g+2)+" = getX(batch, xR, xCOffset, d1);\n }\n\n xR"+m+"C"+(g+1)+" = xTexelR"+m+"C"+(g+2)+";\n "}}else g<p&&(v+="\n if(xR >= 0 && xR < "+o+") {\n ",s%2==1?(v+="\n xCOffset = xC + 1 - "+c+";\n if(xCOffset >= 0 && xCOffset < "+a+") {\n xTexelR"+m+"C"+g+" = getX(batch, xR, xCOffset, d1);\n } else {\n xTexelR"+m+"C"+g+" = vec4(0.);\n }\n\n if(xC + 1 >= 0 && xC + 1 < "+a+") {\n xTexelR"+m+"C"+(g+2)+" = getX(batch, xR, xC + 1, d1);\n } else {\n xTexelR"+m+"C"+(g+2)+" = vec4(0.);\n }\n\n xR"+m+"C"+g+" = vec4(\n xTexelR"+m+"C"+g+".zw, xTexelR"+m+"C"+(g+2)+".zw);\n ",g+1<p&&(v+="\n vec4 final = vec4(0.);\n xCOffset = xC + 1 + "+c+";\n if(xCOffset >= 0 && xCOffset < "+a+") {\n final = getX(batch, xR, xCOffset, d1);\n }\n xR"+m+"C"+(g+1)+" = vec4(xTexelR"+m+"C"+(g+2)+".xy, final.xy);\n ")):(v+="\n if(xC >= 0 && xC < "+a+") {\n xTexelR"+m+"C"+g+" = getX(batch, xR, xC, d1);\n } else {\n xTexelR"+m+"C"+g+" = vec4(0.);\n }\n\n xCOffset = xC + "+c+";\n if(xCOffset >= 0 && xCOffset < "+a+") {\n xTexelR"+m+"C"+(g+2)+" = getX(batch, xR, xCOffset, d1);\n } else {\n xTexelR"+m+"C"+(g+2)+" = vec4(0.);\n }\n\n xR"+m+"C"+g+" = vec4(\n xTexelR"+m+"C"+g+".xy, xTexelR"+m+"C"+(g+2)+".xy);\n ",g+1<p&&(v+="\n xR"+m+"C"+(g+1)+" = vec4(\n xTexelR"+m+"C"+g+".zw, xTexelR"+m+"C"+(g+2)+".zw);\n ")),v+="}");g<p&&(v+="\n vec4 wTexelR"+m+"C"+g+" = getW("+m+", "+g+", d1, q);\n wR"+m+"C"+g+" = vec4(wTexelR"+m+"C"+g+".xz, wTexelR"+m+"C"+g+".xz);\n ",g+1<p&&(v+="\n vec4 wTexelR"+m+"C"+(g+1)+" = getW("+m+", "+(g+1)+", d1, q);\n wR"+m+"C"+(g+1)+" =\n vec4(wTexelR"+m+"C"+(g+1)+".xz, wTexelR"+m+"C"+(g+1)+".xz);"))}for(m=0;m<h;m++)for(g=0;g<p;g++)v+="dotProd += xR"+m+"C"+g+" * wR"+m+"C"+g+";";var w="",x="";n&&(w=r?"vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n "+n+"\n }":"vec4 activation(vec4 x) {\n "+n+"\n }",x="result = activation(result);");var E=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n "+w+"\n\n const ivec2 strides = ivec2("+u+", "+c+");\n const ivec2 pads = ivec2("+i+", "+s+");\n\n void main() {\n\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2;\n int q = 0;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n vec4 dotProd = vec4(0.);\n\n "+v+"\n\n vec4 result = dotProd;\n "+E+"\n "+x+"\n setOutput(result);\n }\n "},za=function(e,t,n,r,o){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];var a=e[0],i=e[1],s=e[2],u=e[3],c=t[0],l=n[0],f=n[1];this.outputShape=[c,l,f,u];var h="bilinear"===r?1:0,p=[i-1+".0",s-1+".0"],d=p[0],v=p[1],m=l>1?[""+(i-1)/(l-1),"(y2-y1) * height_ratio","y1*"+d+" + float(y)*(height_scale)"]:["0.0","0.0","0.5 * (y1+y2) * "+d],g=m[0],y=m[1],b=m[2],w=f>1?[""+(s-1)/(f-1),"(x2-x1) * width_ratio","x1*"+v+" + float(x)*(width_scale)"]:["0.0","0.0","0.5 * (x1+x2) * "+v],x=w[0],E=w[1],_=w[2];this.userCode="\n const float height_ratio = float("+g+");\n const float width_ratio = float("+x+");\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int y = coords[1];\n int x = coords[2];\n int d = coords[3];\n\n // get box vals\n float y1 = getBoxes(b,0);\n float x1 = getBoxes(b,1);\n float y2 = getBoxes(b,2);\n float x2 = getBoxes(b,3);\n\n // get image in batch index\n int bInd = round(getBoxInd(b));\n if(bInd < 0 || bInd >= "+a+") {\n return;\n }\n\n float height_scale = "+y+";\n float width_scale = "+E+";\n\n float in_y = "+b+";\n if( in_y < 0.0 || in_y > "+d+" ) {\n setOutput(float("+o+"));\n return;\n }\n float in_x = "+_+";\n if( in_x < 0.0 || in_x > "+v+" ) {\n setOutput(float("+o+"));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if("+h+" == 1) {\n // Compute the four integer indices.\n ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n float top = topLeft + (topRight - topLeft) * fracCR.x;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n float newValue = top + (bottom - top) * fracCR.y;\n setOutput(newValue);\n } else {\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestCR = ivec2(floor(\n sourceFracIndexCR + vec2(0.5,0.5)));\n float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n setOutput(newValue);\n }\n }\n "},Wa=function(e,t,n){this.variableNames=["x"],this.outputShape=e;var r=e.length,o=e[e.length-1],a=n?"<":">";this.userCode="\n int getIndex(int i) {\n "+(n?"return "+o+" -i - 1;":"return i;")+"\n }\n\n void main() {\n "+ua(r)+" coords = getOutputCoords();\n int end = "+Va(r,"coords")+";\n float val = 0.0;\n for (int i = "+o+" - 1; i >= 0; i -= 1) {\n int idx = getIndex(i);\n if (idx "+a+" end) {\n continue;\n }\n if (idx == end && "+t+") {\n continue;\n }\n "+Va(r,"coords")+" = idx;\n val += getX("+function(e,t){if(1===e)return""+t;if(2===e)return t+".x, "+t+".y";if(3===e)return t+".x, "+t+".y, "+t+".z";if(4===e)return t+".x, "+t+".y, "+t+".z, "+t+".w";throw Error("Cumulative sum for rank "+e+" is not yet supported")}(r,"coords")+");\n }\n setOutput(val);\n }\n "};function Va(e,t){if(1===e)return""+t;if(2===e)return t+".y";if(3===e)return t+".z";if(4===e)return t+".w";throw Error("Cumulative sum for rank "+e+" is not yet supported")}var Ha=function(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=bt.DENSE;var t=It(e),n=$o();this.outputShape=e,this.userCode="\n ivec3 outCoordsFromFlatIndex(int index) {\n "+Zo(["r","c","d"],e)+"\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = 4 * (resTexRC.x * "+t[1]+" + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getA(rc.x, rc.y, rc.z);\n }\n\n "+n.output+" = result;\n }\n "},Ua=function(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=bt.DENSE;var t=It(e),n=$o();this.outputShape=e,this.userCode="\n ivec3 outCoordsFromFlatIndex(int index) {\n "+Zo(["r","c","d"],e)+"\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = 4 * (resTexRC.x * "+t[1]+" + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n }\n\n "+n.output+" = result;\n }\n "},Ga=function(){function e(e,t,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=n,this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int h = "+this.getHeightCoordString()+";\n int w = "+this.getWidthCoordString()+";\n int d = "+this.getDepthCoordString()+";\n\n int in_h = h / "+t+";\n int offset_h = imod(h, "+t+");\n int in_w = w / "+t+";\n int offset_w = imod(w, "+t+");\n int offset_d = (offset_h * "+t+" + offset_w) *\n "+this.getOutputDepthSize()+";\n int in_d = d + offset_d;\n\n float result = "+this.getInputSamplingString()+";\n setOutput(result);\n }\n "}return e.prototype.getHeightCoordString=function(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"},e.prototype.getWidthCoordString=function(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"},e.prototype.getDepthCoordString=function(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"},e.prototype.getOutputDepthSize=function(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]},e.prototype.getInputSamplingString=function(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"},e}(),qa=function(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n setOutput(val);\n }\n "},Xa=function(e){this.variableNames=["A"],this.outTexUsage=wt.DOWNLOAD;var t=$o();this.outputShape=e,this.userCode="\n "+Jo+"\n\n void main() {\n float x = getAAtOutCoords();\n "+t.output+" = encode_float(x);\n }\n "},Ka=function(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=wt.DOWNLOAD;var t=$o();this.outputShape=e,this.userCode="\n "+Jo+"\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n "+t.output+" = encode_float(x);\n }\n "},$a=function(e,t,n){void 0===n&&(n=!1),this.variableNames=["A"];var r=$o(),o=t[0],a=t[1];this.outputShape=e;var i="result";n&&(i="floor(result * 255. + 0.5)"),this.userCode="\n "+Yo(e)+"\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n int flatIndex = getFlatIndex(coords);\n int offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n \n int r = flatIndex / "+a+";\n int c = imod(flatIndex, "+a+");\n vec2 uv = (vec2(c, r) + halfCR) / vec2("+a+".0, "+o+".0);\n vec4 values = "+r.texture2D+"(A, uv);\n\n float result;\n\n if(offset == 0) {\n result = values[0];\n } else if(offset == 1) {\n result = values[1];\n } else if(offset == 2) {\n result = values[2];\n } else {\n result = values[3];\n }\n\n "+r.output+" = vec4("+i+", 0., 0., 0.);\n }\n "},Za=function(e,t,n){void 0===n&&(n=!1),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var r=$o(),o=t[0],a=t[1];this.outputShape=e;var i="",s="result";n&&(s="floor(result * 255. + 0.5)");for(var u=0;u<=1;u++)for(var c=0;c<=1;c++){var l=2*u+c;i+="\n localCoords = coords;\n if(localCoords[2] + "+c+" < "+e[2]+") {\n localCoords[2] += "+c+";\n if(localCoords[1] + "+u+" < "+e[1]+") {\n localCoords[1] += "+u+";\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n r = flatIndex / "+a+";\n c = imod(flatIndex, "+a+");\n uv = (vec2(c, r) + halfCR) / vec2("+a+".0, "+o+".0);\n values = "+r.texture2D+"(A, uv);\n\n if(offset == 0) {\n result["+l+"] = values[0];\n } else if(offset == 1) {\n result["+l+"] = values[1];\n } else if(offset == 2) {\n result["+l+"] = values[2];\n } else {\n result["+l+"] = values[3];\n }\n }\n }\n "}this.userCode="\n "+Yo(e)+"\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n vec4 result = vec4(0.);\n int flatIndex, r, c, offset;\n ivec3 localCoords;\n vec2 uv;\n vec4 values;\n\n "+i+"\n\n "+r.output+" = "+s+";\n }\n "},Ya=function(e,t,n){this.variableNames=["real","imag"];var r=t[1];this.outputShape=t;var o=n?"2.0 * "+Math.PI:"-2.0 * "+Math.PI,a=n?r+".0":"1.0";this.userCode="\n const float exponentMultiplier = "+o+";\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n "+e+"\n }\n\n float mulMatDFT(int batch, int index) {\n float indexRatio = float(index) / float("+r+");\n float exponentMultiplierTimesIndexRatio =\n exponentMultiplier * indexRatio;\n\n float result = 0.0;\n\n for (int i = 0; i < "+r+"; i++) {\n // x = (-2|2 * PI / N) * index * i;\n float x = exponentMultiplierTimesIndexRatio * float(i);\n float expR = cos(x);\n float expI = sin(x);\n float real = getReal(batch, i);\n float imag = getImag(batch, i);\n\n result +=\n unaryOpComplex(real, expR, imag, expI) / "+a+";\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n "},Ja=function(){function e(e,t){this.outputShape=[],this.variableNames=["x"],this.outputShape=e,this.userCode="\n uniform float value;\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "}return e.prototype.getCustomSetupFunc=function(e){var t=this;return function(n,r){null==t.valueLoc&&(t.valueLoc=n.getUniformLocationNoThrow(r,"value")),n.gl.uniform1f(t.valueLoc,e)}},e}(),Qa=function(e,t,n){this.variableNames=["A","indices"];var r=e.slice();r[n]=t,this.outputShape=r,this.rank=r.length;var o=ua(this.rank),a=function(e,t){var n=e.length;if(n>4)throw Error("Gather for rank "+n+" is not yet supported");if(1===n)return"int(getIndices(resRC))";for(var r=["resRC.x","resRC.y","resRC.z","resRC.w"],o=[],a=0;a<e.length;a++)a===t?o.push("int(getIndices("+r[a]+"))"):o.push(""+r[a]);return o.join()}(e,n);this.userCode="\n void main() {\n "+o+" resRC = getOutputCoords();\n setOutput(getA("+a+"));\n }\n "},ei=function(e,t,n){this.sliceDim=e,this.strides=t,this.variableNames=["x","indices"],this.outputShape=n;var r=ua(t.length),o=ua(n.length),a=this.sliceDim>1?"strides[j]":"strides";this.userCode="\n "+r+" strides = "+r+"("+this.strides+");\n void main() {\n "+o+" coords = getOutputCoords();\n int flattenIndex = 0;\n for (int j = 0; j < "+this.sliceDim+"; j++) {\n int index = round(getIndices(coords[0], j));\n flattenIndex += index * "+a+";\n }\n setOutput(getX(flattenIndex, coords[1]));\n }\n "};function ti(e,t){var n=$o();return Mt(e,t,n.version+"\n precision highp float;\n "+n.attribute+" vec3 clipSpacePos;\n "+n.attribute+" vec2 uv;\n "+n.varyingVs+" vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }")}function ni(e,t){return Vt(e,t,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}function ri(e,t){return Ht(e,t,new Uint16Array([0,1,2,2,1,3]))}function oi(e,t,n,r,o,a,i){Gt(n,r);var s=Ut(e,t),u=e.TEXTURE_2D;return At(e,t,(function(){return e.bindTexture(u,s)})),At(e,t,(function(){return e.texParameteri(u,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE)})),At(e,t,(function(){return e.texParameteri(u,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)})),At(e,t,(function(){return e.texParameteri(u,e.TEXTURE_MIN_FILTER,e.NEAREST)})),At(e,t,(function(){return e.texParameteri(u,e.TEXTURE_MAG_FILTER,e.NEAREST)})),At(e,t,(function(){return e.texImage2D(u,0,o,n,r,0,a,i,null)})),At(e,t,(function(){return e.bindTexture(e.TEXTURE_2D,null)})),s}function ai(e,t,n,r,o){var a=Ct(n,r);return oi(e,t,a[0],a[1],o.internalFormatFloat,o.textureFormatFloat,e.FLOAT)}function ii(e,t,n,r,o){var a=Ct(n,r);return oi(e,t,a[0],a[1],o.internalFormatHalfFloat,o.textureFormatFloat,o.textureTypeHalfFloat)}function si(e,t,n,r,o){var a=Ct(n,r);return oi(e,t,a[0],a[1],e.RGBA,e.RGBA,e.UNSIGNED_BYTE)}function ui(e,t,n,r,o){var a=St(n,r);return oi(e,t,a[0],a[1],o.internalFormatPackedFloat,e.RGBA,e.FLOAT)}function ci(e,t,n,r,o){var a=St(n,r);return oi(e,t,a[0],a[1],o.internalFormatPackedHalfFloat,e.RGBA,o.textureTypeHalfFloat)}function li(e,t,n,r){return At(e,t,(function(){return e.bindBuffer(e.ARRAY_BUFFER,r)})),Xt(e,t,n,"clipSpacePos",r,3,20,0)&&Xt(e,t,n,"uv",r,2,20,12)}function fi(e,t,n,r,o,a,i){var s,u,c;At(e,t,(function(){return e.bindTexture(e.TEXTURE_2D,n)})),a instanceof Uint8Array?(s=new Uint8Array(r*o*4),u=e.UNSIGNED_BYTE,c=e.RGBA):(s=new Float32Array(r*o*4),u=e.FLOAT,c=i.internalFormatPackedFloat),s.set(a),At(e,t,(function(){return e.texImage2D(e.TEXTURE_2D,0,c,r,o,0,e.RGBA,u,s)})),At(e,t,(function(){return e.bindTexture(e.TEXTURE_2D,null)}))}function hi(e,t,n,r){At(e,t,(function(){return e.bindTexture(e.TEXTURE_2D,n)})),r.data instanceof Uint8Array?At(e,t,(function(){return e.texImage2D(e.TEXTURE_2D,0,e.RGBA,r.width,r.height,0,e.RGBA,e.UNSIGNED_BYTE,r.data)})):At(e,t,(function(){return e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,r)})),At(e,t,(function(){return e.bindTexture(e.TEXTURE_2D,null)}))}function pi(e,t,n,r,o){var a=e.createBuffer();At(e,t,(function(){return e.bindBuffer(e.PIXEL_PACK_BUFFER,a)}));var i=16*n*r;return At(e,t,(function(){return e.bufferData(e.PIXEL_PACK_BUFFER,i,e.STREAM_READ)})),At(e,t,(function(){return e.readPixels(0,0,r,n,e.RGBA,e.FLOAT,0)})),At(e,t,(function(){return e.bindBuffer(e.PIXEL_PACK_BUFFER,null)})),a}function di(e,t,n){var r=e,o=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,o),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),o}function vi(e,t,n,r,o){var a=Ct(n,r),i=a[0],s=a[1],u=new Uint8Array(n*r*4);return At(e,t,(function(){return e.readPixels(0,0,i,s,o.downloadTextureFormat,e.UNSIGNED_BYTE,u)})),new Float32Array(u.buffer)}function mi(e,t,n,r,o,a,i,s){var u=e,c=new Float32Array(function(e,t){var n=St(e,t);return n[0]*n[1]*4}(a,i));return u.bindBuffer(u.PIXEL_PACK_BUFFER,t),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,c),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),c}function gi(e,t,n,r){var o=new Float32Array(n*r*4);return At(e,t,(function(){return e.readPixels(0,0,r,n,e.RGBA,e.FLOAT,o)})),o}var yi=Object.freeze({createVertexShader:ti,createVertexBuffer:ni,createIndexBuffer:ri,createFloat32MatrixTexture:ai,createFloat16MatrixTexture:ii,createUnsignedBytesMatrixTexture:si,createPackedMatrixTexture:ui,createFloat16PackedMatrixTexture:ci,bindVertexProgramAttributeStreams:li,uploadDenseMatrixToTexture:fi,uploadPixelDataToTexture:hi,createBufferFromOutputTexture:pi,downloadFloat32MatrixFromBuffer:di,downloadByteEncodedFloatMatrixFromOutputTexture:vi,downloadPackedMatrixFromBuffer:mi,downloadMatrixFromPackedOutputTexture:gi}),bi=function(){function e(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];var t=Y().getNumber("WEBGL_VERSION");null!=e?(this.gl=e,Ot(t,e)):this.gl=kt(t);var n="WEBGL_color_buffer_float";if(1===Y().getNumber("WEBGL_VERSION")){if(this.textureFloatExtension=Dt(this.gl,this.debug,"OES_texture_float"),dn(this.gl,"OES_texture_half_float"))this.textureHalfFloatExtension=Dt(this.gl,this.debug,"OES_texture_half_float");else if(Y().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(n),dn(this.gl,"EXT_color_buffer_half_float"))this.colorBufferHalfFloatExtension=Dt(this.gl,this.debug,"EXT_color_buffer_half_float");else if(Y().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(n="EXT_color_buffer_float",dn(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!dn(this.gl,"EXT_color_buffer_half_float"))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension("EXT_color_buffer_half_float")}this.vertexBuffer=ni(this.gl,this.debug),this.indexBuffer=ri(this.gl,this.debug),this.framebuffer=qt(this.gl,this.debug),this.textureConfig=Rt(this.gl,this.textureHalfFloatExtension)}return Object.defineProperty(e.prototype,"debug",{get:function(){return Y().getBool("DEBUG")},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){var e=this;if(!this.disposed){null!=this.program&&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."),null!=this.outputTexture&&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.");var t=this.gl;At(t,this.debug,(function(){return t.finish()})),At(t,this.debug,(function(){return t.bindFramebuffer(t.FRAMEBUFFER,null)})),At(t,this.debug,(function(){return t.deleteFramebuffer(e.framebuffer)})),At(t,this.debug,(function(){return t.bindBuffer(t.ARRAY_BUFFER,null)})),At(t,this.debug,(function(){return t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)})),At(t,this.debug,(function(){return t.deleteBuffer(e.indexBuffer)})),this.disposed=!0}},e.prototype.createFloat32MatrixTexture=function(e,t){return this.throwIfDisposed(),ai(this.gl,this.debug,e,t,this.textureConfig)},e.prototype.createFloat16MatrixTexture=function(e,t){return this.throwIfDisposed(),ii(this.gl,this.debug,e,t,this.textureConfig)},e.prototype.createUnsignedBytesMatrixTexture=function(e,t){return this.throwIfDisposed(),si(this.gl,this.debug,e,t,this.textureConfig)},e.prototype.uploadPixelDataToTexture=function(e,t){this.throwIfDisposed(),hi(this.gl,this.debug,e,t)},e.prototype.uploadDenseMatrixToTexture=function(e,t,n,r){this.throwIfDisposed(),fi(this.gl,this.debug,e,t,n,r,this.textureConfig)},e.prototype.createFloat16PackedMatrixTexture=function(e,t){return this.throwIfDisposed(),ci(this.gl,this.debug,e,t,this.textureConfig)},e.prototype.createPackedMatrixTexture=function(e,t){return this.throwIfDisposed(),ui(this.gl,this.debug,e,t,this.textureConfig)},e.prototype.deleteMatrixTexture=function(e){var t=this;this.throwIfDisposed(),this.outputTexture===e&&(Qt(this.gl,this.debug,this.framebuffer),this.outputTexture=null),At(this.gl,this.debug,(function(){return t.gl.deleteTexture(e)}))},e.prototype.downloadByteEncodedFloatMatrixFromOutputTexture=function(e,t,n){var r=this;return this.downloadMatrixDriver(e,(function(){return vi(r.gl,r.debug,t,n,r.textureConfig)}))},e.prototype.downloadPackedMatrixFromBuffer=function(e,t,n,r,o,a){return mi(this.gl,e,0,0,0,o,a,this.textureConfig)},e.prototype.downloadFloat32MatrixFromBuffer=function(e,t){return di(this.gl,e,t)},e.prototype.createBufferFromTexture=function(e,t,n){this.bindTextureToFrameBuffer(e);var r=pi(this.gl,this.debug,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r},e.prototype.createAndWaitForFence=function(){var e=this.createFence(this.gl);return this.pollFence(e)},e.prototype.createFence=function(e){var t,n,r=this;if(Y().getBool("WEBGL_FENCE_API_ENABLED")){var o=e,a=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=function(){var e=o.clientWaitSync(a,0,0);return e===o.ALREADY_SIGNALED||e===o.CONDITION_SATISFIED},t=a}else Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=function(){return r.isQueryAvailable(t,Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}):n=function(){return!0};return{query:t,isFencePassed:n}},e.prototype.downloadMatrixFromPackedTexture=function(e,t,n){var r=this;return this.downloadMatrixDriver(e,(function(){return gi(r.gl,r.debug,t,n)}))},e.prototype.createProgram=function(e){this.throwIfDisposed();var t=this.gl,n=Nt(t,this.debug,e),r=ti(t,this.debug),o=Lt(t,this.debug);return At(t,this.debug,(function(){return t.attachShader(o,r)})),At(t,this.debug,(function(){return t.attachShader(o,n)})),zt(t,this.debug,o),this.debug&&Wt(t,this.debug,o),this.vertexAttrsAreBound||(this.setProgram(o),this.vertexAttrsAreBound=li(t,this.debug,this.program,this.vertexBuffer)),o},e.prototype.deleteProgram=function(e){var t=this;this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&At(this.gl,this.debug,(function(){return t.gl.deleteProgram(e)}))},e.prototype.setProgram=function(e){var t=this;this.throwIfDisposed(),this.program=e,null!=this.program&&this.debug&&Wt(this.gl,this.debug,this.program),At(this.gl,this.debug,(function(){return t.gl.useProgram(e)}))},e.prototype.getUniformLocation=function(e,t,n){return void 0===n&&(n=!0),this.throwIfDisposed(),n?$t(this.gl,this.debug,e,t):Zt(this.gl,e,t)},e.prototype.getAttributeLocation=function(e,t){var n=this;return this.throwIfDisposed(),At(this.gl,this.debug,(function(){return n.gl.getAttribLocation(e,t)}))},e.prototype.getUniformLocationNoThrow=function(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)},e.prototype.setInputMatrixTexture=function(e,t,n){this.throwIfDisposed(),this.throwIfNoProgram(),Yt(this.gl,this.debug,this.program,e,t,n)},e.prototype.setOutputMatrixTexture=function(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)},e.prototype.setOutputPackedMatrixTexture=function(e,t,n){this.throwIfDisposed();var r=St(t,n),o=r[0],a=r[1];this.setOutputMatrixTextureDriver(e,o,a)},e.prototype.setOutputMatrixWriteRegion=function(e,t,n,r){this.setOutputMatrixWriteRegionDriver(n,e,r,t)},e.prototype.setOutputPackedMatrixWriteRegion=function(e,t,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")},e.prototype.debugValidate=function(){null!=this.program&&Wt(this.gl,this.debug,this.program),en(this.gl)},e.prototype.executeProgram=function(){this.throwIfDisposed(),this.throwIfNoProgram();var e=this.gl;this.debug&&this.debugValidate(),At(e,this.debug,(function(){return e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}))},e.prototype.blockUntilAllProgramsCompleted=function(){var e=this;this.throwIfDisposed(),At(this.gl,this.debug,(function(){return e.gl.finish()}))},e.prototype.getQueryTimerExtension=function(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=Dt(this.gl,this.debug,2===Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension},e.prototype.getQueryTimerExtensionWebGL2=function(){return this.getQueryTimerExtension()},e.prototype.getQueryTimerExtensionWebGL1=function(){return this.getQueryTimerExtension()},e.prototype.beginQuery=function(){if(2===Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var e=this.gl,t=this.getQueryTimerExtensionWebGL2(),n=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,n),n}var r=this.getQueryTimerExtensionWebGL1(),o=r.createQueryEXT();return r.beginQueryEXT(r.TIME_ELAPSED_EXT,o),o},e.prototype.endQuery=function(){if(2!==Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}else{var t=this.gl,n=this.getQueryTimerExtensionWebGL2();t.endQuery(n.TIME_ELAPSED_EXT)}},e.prototype.waitForQueryAndGetTime=function(e){return K(this,void 0,void 0,(function(){var t=this;return $(this,(function(n){switch(n.label){case 0:return[4,ye((function(){return t.disposed||t.isQueryAvailable(e,Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}))];case 1:return n.sent(),[2,this.getQueryTime(e,Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))]}}))}))},e.prototype.getQueryTime=function(e,t){if(0===t)return null;if(2===t){var n=this.gl;return n.getQueryParameter(e,n.QUERY_RESULT)/1e6}var r=this.getQueryTimerExtensionWebGL1();return r.getQueryObjectEXT(e,r.QUERY_RESULT_EXT)/1e6},e.prototype.isQueryAvailable=function(e,t){if(0===t)return!0;if(2===t){var n=this.gl,r=this.getQueryTimerExtensionWebGL2(),o=n.getQueryParameter(e,n.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),o&&!this.disjoint}return o=(r=this.getQueryTimerExtensionWebGL1()).getQueryObjectEXT(e,r.QUERY_RESULT_AVAILABLE_EXT),null==this.disjoint&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),o&&!this.disjoint},e.prototype.pollFence=function(e){var t=this;return new Promise((function(n){t.addItemToPoll((function(){return e.isFencePassed()}),(function(){return n()}))}))},e.prototype.pollItems=function(){for(var e=function(e){for(var t=0;t<e.length;++t){if(!e[t]())break}return t-1}(this.itemsToPoll.map((function(e){return e.isDoneFn}))),t=0;t<=e;++t)(0,this.itemsToPoll[t].resolveFn)();this.itemsToPoll=this.itemsToPoll.slice(e+1)},e.prototype.addItemToPoll=function(e,t){var n=this;this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1||ye((function(){return n.pollItems(),0===n.itemsToPoll.length}))},e.prototype.bindTextureToFrameBuffer=function(e){this.throwIfDisposed(),Jt(this.gl,this.debug,e,this.framebuffer),this.debug&&en(this.gl)},e.prototype.unbindTextureToFrameBuffer=function(){null!=this.outputTexture?(Jt(this.gl,this.debug,this.outputTexture,this.framebuffer),this.debug&&en(this.gl)):Qt(this.gl,this.debug,this.framebuffer)},e.prototype.downloadMatrixDriver=function(e,t){this.bindTextureToFrameBuffer(e);var n=t();return this.unbindTextureToFrameBuffer(),n},e.prototype.setOutputMatrixTextureDriver=function(e,t,n){this.throwIfDisposed();var r=this.gl;Jt(r,this.debug,e,this.framebuffer),this.debug&&en(r),this.outputTexture=e,At(r,this.debug,(function(){return r.viewport(0,0,t,n)})),At(r,this.debug,(function(){return r.scissor(0,0,t,n)}))},e.prototype.setOutputMatrixWriteRegionDriver=function(e,t,n,r){var o=this;this.throwIfDisposed(),At(this.gl,this.debug,(function(){return o.gl.scissor(e,t,n,r)}))},e.prototype.throwIfDisposed=function(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")},e.prototype.throwIfNoProgram=function(){if(null==this.program)throw new Error("No GPU program is currently set.")},e}();function wi(e,t){if(e.length!==t.length)throw Error("Binary was compiled with "+e.length+" inputs, but was executed with "+t.length+" inputs");e.forEach((function(e,n){var r=e.logicalShape,o=t[n],a=o.shape;if(!pe(r,a))throw Error("Binary was compiled with different shapes than the current args. Shapes "+r+" and "+a+" must match");if(!e.isUniform||!o.isUniform){var i=e.texShape,s=o.isUniform?null:o.texData.texShape;if(!pe(i,s))throw Error("Binary was compiled with different texture shapes than the current args. Shape "+i+" and "+s+" must match")}}))}var xi=function(e,t,n){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;for(var r=n.filterWidth,o=n.inChannels,a=n.strideWidth,i=n.strideHeight,s=n.padInfo,u=n.outWidth,c=n.dilationWidth,l=n.dilationHeight,f=n.dataFormat,h=s.left,p=s.top,d=o*r,v=$o(),m="channelsLast"===f,g=m?0:1,y=m?1:2,b="",w=0;w<=1;w++)for(var x=0;x<=1;x++)b+="\n blockIndex = rc.y + "+x+";\n pos = rc.x + "+w+";\n\n if(blockIndex < "+e[1]+" && pos < "+e[0]+") {\n offsetY = int(blockIndex / ("+u+")) * "+i+" - "+p+";\n d0 = offsetY + "+l+" * (pos / "+d+");\n\n if(d0 < "+t[g]+" && d0 >= 0) {\n\n offsetX = int(mod(float(blockIndex), "+u+".) * "+a+". - "+h+".);\n d1 = offsetX + "+c+" * (int(mod(float(pos), "+d+".) / "+o+".));\n\n if(d1 < "+t[y]+" && d1 >= 0) {\n\n ch = int(mod(float(pos), "+o+".));\n\n if ("+m+") {\n innerDims = vec2(d1, ch);\n result["+(2*w+x)+"] = getChannel(\n getA(d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result["+(2*w+x)+"] = getChannel(\n getA(ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n ";this.userCode="\n void main() {\n ivec2 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n "+b+"\n\n "+v.output+" = result;\n }\n "},Ei=function(e,t,n,r,o){this.variableNames=["x"],this.outputShape=[];var a,i=t,s=e[3]-1;this.outputShape=e;var u="float("+n+") + float("+r+") * sum";a=.5===o?"inversesqrt("+u+")":1===o?"1.0/("+u+")":"exp(log("+u+") * float(-"+o+"));",this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n int d = coords[3];\n float x = getX(b, r, c, d);\n float sum = 0.0;\n for (int j = -"+i+"; j <= "+i+"; j++) {\n int idx = d + j;\n if (idx >= 0 && idx <= "+s+") {\n float z = getX(b, r, c, idx);\n sum += z * z;\n }\n }\n float val = x * "+a+";\n setOutput(val);\n }\n "},_i=function(e,t,n,r,o){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=n,this.alpha=r,this.beta=o,this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n\n float result = 0.0;\n for (int d = 0; d < "+this.depth+"; ++d) {\n int depthBegin = int(max(0.0, float(d - "+t+")));\n int depthEnd = int(min(float("+this.depth+"),\n float(d + "+t+" + 1)));\n\n const int MIN_DEPTH_BEGIN = 0;\n const int MAX_DEPTH_END = "+this.depth+";\n\n float norm = 0.0;\n for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd) {\n norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n }\n else {\n break;\n }\n }\n\n norm = float("+r+") * norm + float("+n+");\n\n for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd){\n float dyi = -2.0 * float("+r+")\n * float("+o+")\n * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * "+o+");\n }\n if (k == coords[3]) {\n dyi *= getDy(b, r, c, d);\n result += dyi;\n }\n }\n else {\n break;\n }\n }\n }\n setOutput(result);\n }\n "},Oi=function(e,t,n,r,o){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;var a,i=t,s=e[3]-1;this.outputShape=e;var u="float("+n+") + float("+r+") * sum";a=.5===o?"inversesqrt("+u+")":1===o?"1.0/("+u+")":"exp(log("+u+") * float(-"+o+"));",this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords.x;\n int r = coords.y;\n int c = coords.z;\n int d = coords.w;\n\n bool hasNextCol = d < "+this.outputShape[3]+";\n bool hasNextRow = c < "+this.outputShape[2]+";\n\n vec4 sum = vec4(0.);\n vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n vec4 xAtOutputCoords = vec4(\n getChannel(xFragAtOutputCoords, vec2(c, d)),\n hasNextCol ?\n getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n hasNextRow ?\n getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n (hasNextRow && hasNextCol) ?\n getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n );\n\n int firstChannel = d - "+i+";\n vec2 cache = vec2(0.);\n if(firstChannel >= 0){\n vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n if(hasNextRow){\n cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n }\n }\n\n ivec2 depth = ivec2(d, d + 1);\n for (int j = - "+i+"; j <= "+i+"; j++) {\n ivec2 idx = depth + j;\n bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n bvec2 belowUpperBound = lessThanEqual(idx, ivec2("+s+"));\n\n bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n if(depthInRange || depthPlusOneInRange){\n vec4 z = vec4(0.);\n vec4 xFragAtCurrentDepth;\n z.xz = cache.xy;\n if(depthPlusOneInRange && hasNextCol){\n xFragAtCurrentDepth = idx.y != d ?\n getX(b, r, c, idx.y) : xFragAtOutputCoords;\n z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n if(hasNextRow){\n z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n }\n }\n cache.xy = z.yw;\n sum += z * z;\n }\n }\n vec4 result = xAtOutputCoords * "+a+";\n setOutput(result);\n }\n "},ki=function(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;var t=e.strideHeight,n=e.strideWidth,r=e.dilationHeight,o=e.effectiveFilterHeight,a=e.effectiveFilterWidth,i=o-1-e.padInfo.top,s=a-1-e.padInfo.left,u=o*a-1;this.userCode="\n const ivec2 pads = ivec2("+i+", "+s+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+o+";\n wR += "+r+") {\n float dyR = float(dyRCorner + wR) / "+t+".0;\n\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+a+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+n+".0;\n\n if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n int maxPosValue = "+u+" - int(getMaxPos(b, idyR, idyC, d));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue = wR * "+a+" + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n "},Ci=function(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;var t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,o=e.dilationDepth,a=e.dilationHeight,i=e.dilationWidth,s=e.effectiveFilterDepth,u=e.effectiveFilterHeight,c=e.effectiveFilterWidth,l=s-1-e.padInfo.front,f=u-1-e.padInfo.top,h=c-1-e.padInfo.left,p=s*u*c-1;this.userCode="\n const ivec3 pads = ivec3("+l+", "+f+", "+h+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < "+s+";\n wD += "+o+") {\n float dyD = float(dyDCorner + wD) / "+t+".0;\n\n if (dyD < 0.0 || dyD >= "+e.outDepth+".0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < "+u+";\n wR += "+a+") {\n float dyR = float(dyRCorner + wR) / "+n+".0;\n\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+c+";\n wC += "+i+") {\n float dyC = float(dyCCorner + wC) / "+r+".0;\n\n if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n int maxPosValue = "+p+" -\n int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue =\n wD * "+u+" * "+c+" +\n wR * "+c+" + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n }\n setOutput(dotProd);\n }\n "},Ii=function(e,t,n,r,o,a,i){void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===a&&(a=null),void 0===i&&(i=!1),this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;var s=n?e[1]:e[2],u=Math.ceil(s/2),c=n?"i * 2, rc.y":"rc.y, i * 2",l=r?"rc.z, i * 2":"i * 2, rc.z",f=n?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],h=r?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],p="",d="";a&&(p=i?"vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n "+a+"\n }":"vec4 activation(vec4 x) {\n "+a+"\n }",d="result = activation(result);");var v=o?"result += getBiasAtOutCoords();":"";o&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),this.userCode="\n "+p+"\n\n const float sharedDimension = "+u+".0;\n\n vec4 dot2x2ARowBCol(ivec3 rc) {\n vec4 result = vec4(0);\n for (int i = 0; i < "+u+"; i++) {\n vec4 a = getMatrixA(rc.x, "+c+");\n vec4 b = getMatrixB(rc.x, "+l+");\n\n // These swizzled products need to be separately added.\n // See: https://github.com/tensorflow/tfjs/issues/1735\n result += ("+f[0]+" * "+h[0]+");\n result += ("+f[1]+" * "+h[1]+");\n }\n return result;\n }\n\n void main() {\n ivec3 rc = getOutputCoords();\n vec4 result = dot2x2ARowBCol(rc);\n\n "+v+"\n\n "+d+"\n\n setOutput(result);\n }\n "},Si=function(){function e(e,t,n){this.variableNames=["probs"],this.outputShape=[e,n],this.userCode="\n uniform float seed;\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n\n float r = random(seed);\n float cdf = 0.0;\n\n for (int i = 0; i < "+(t-1)+"; i++) {\n cdf += getProbs(batch, i);\n\n if (r < cdf) {\n setOutput(float(i));\n return;\n }\n }\n\n // If no other event happened, last event happened.\n setOutput(float("+(t-1)+"));\n }\n "}return e.prototype.getCustomSetupFunc=function(e){var t=this;return function(n,r){null==t.seedLoc&&(t.seedLoc=n.getUniformLocation(r,"seed")),n.gl.uniform1f(t.seedLoc,e)}},e}(),Ri=function(e,t,n,r){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int index = round(getIndices(coords.x));\n setOutput(mix(float("+r+"), float("+n+"),\n float(index == coords.y)));\n }\n "},Ai=function(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e;var t=e.length;if(0===t)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{var n=Ko("rc",t),r=ua(t),o=function(e,t,n){if(1===e)return"rc > "+t[0];for(var r="",o=e-2;o<e;o++)r+=n[o]+" >= "+t[o],o<e-1&&(r+="||");return r}(t,e,n),a=function(e,t,n,r){if(1===e)return"";var o=r.slice(-2);return"\n int r = "+o[0]+";\n int c = "+o[1]+";\n int rp1 = r + 1;\n int cp1 = c + 1;\n\n bool cEdge = cp1 >= "+t+";\n bool rEdge = rp1 >= "+n+";\n "}(t,e[e.length-1],e[e.length-2],n),i=function(e,t){var n=e.length,r=function(e,t){for(var n=[],r=0;r<=1;r++)for(var o=0;o<=1;o++){for(var a=(0===r?"r":"rp1")+", "+(0===o?"c":"cp1"),i=2;i<e;i++)a=t[t.length-1-i]+","+a;n.push(a)}return n}(n,t);return 1===n?"getA(rc),\n rc + 1 >= "+e[0]+" ? 0. : getA(rc + 1),\n 0, 0":"getA("+r[0]+"),\n cEdge ? 0. : getA("+r[1]+"),\n rEdge ? 0. : getA("+r[2]+"),\n rEdge || cEdge ? 0. : getA("+r[3]+")"}(e,n);this.userCode="\n void main() {\n "+r+" rc = getOutputCoords();\n\n if("+o+") {\n setOutput(vec4(0));\n } else {\n "+a+"\n\n setOutput(vec4("+i+"));\n }\n }\n "}},Pi=function(e,t,n){this.variableNames=["x"],this.outputShape=t.map((function(t,n){return t[0]+e[n]+t[1]}));var r=e.length,o=ua(r),a=t.map((function(e){return e[0]})).join(","),i=t.map((function(t,n){return t[0]+e[n]})).join(","),s=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?"\n "+o+" start = "+o+"("+a+");\n "+o+" end = "+o+"("+i+");\n\n void main() {\n "+o+" outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(float("+n+"));\n } else {\n "+o+" coords = outC - start;\n setOutput(getX("+s+"));\n }\n }\n ":"\n int start = "+a+";\n int end = "+i+";\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(float("+n+"));\n } else {\n setOutput(getX(outC - start));\n }\n }\n "},Ti=function(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((function(t,n){return t[0]+e[n]+t[1]}));for(var r=e.length,o=ua(r),a=t.map((function(e){return e[0]})).join(","),i=t.map((function(t,n){return t[0]+e[n]})).join(","),s=Ko("rc",r),u=Ko("source",r),c=s[r-1]+" < "+this.outputShape[r-1],l=1===r?"source":"vec2("+u.slice(-2).join()+")",f=[o+" rc = outputLoc;",s[r-1]+" += 1;\n if("+c+") {\n ",1===r?"":"}\n rc = outputLoc;\n "+s[r-2]+" += 1;\n if("+s[r-2]+" < "+this.outputShape[r-2]+") {",1===r?"":" "+s[r-1]+" += 1;\n if("+c+") {"],h=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",p="",d=0,v=1===r?2:4;d<v;d++)p+="\n "+f[d]+"\n if ("+h+") {\n result["+d+"] = float("+n+");\n } else {\n "+o+" source = rc - start;\n result["+d+"] = getChannel(getX("+u.join()+"), "+l+");\n }\n ";p+=1===r?"} ":"}}",this.userCode="\n const "+o+" start = "+o+"("+a+");\n const "+o+" end = "+o+"("+i+");\n\n void main() {\n "+o+" outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n "+p+"\n setOutput(result);\n }\n "},Di=function(e,t,n){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");var r=e.filterWidth,o=e.strideHeight,a=e.strideWidth,i=e.dilationHeight,s=e.dilationWidth,u=e.effectiveFilterHeight,c=e.effectiveFilterWidth,l=e.padInfo.top,f=e.padInfo.left;this.outputShape=e.outShape;var h="avg"===t,p="0.0";if(h||(p="-1.0 / 1e-20"),n)this.userCode="\n const ivec2 strides = ivec2("+o+", "+a+");\n const ivec2 pads = ivec2("+l+", "+f+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n float avgValue = 0.0;\n\n for (int wR = 0; wR < "+u+";\n wR += "+i+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+c+";\n wC += "+s+") {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= "+e.inWidth+") {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value >= currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = wR * "+c+" + wC;\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n ";else{var d=t+"("+t+"("+t+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===t&&(d="avgValue / count");var v=4*Math.floor(r/4),m=r%4,g="\n if ("+h+") {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n ";this.userCode="\n const ivec2 strides = ivec2("+o+", "+a+");\n const ivec2 pads = ivec2("+l+", "+f+");\n const float initializationValue = "+p+";\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xR, int xC, int d) {\n if (xC < 0 || xC >= "+e.inWidth+") {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4("+p+");\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < "+u+";\n wR += "+i+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+v+"; wC += 4) {\n int xC = xCCorner + wC * "+s+";\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + "+s+", d),\n getValue(batch, xR, xC + 2 * "+s+", d),\n getValue(batch, xR, xC + 3 * "+s+", d)\n );\n\n "+g+"\n }\n\n int xC = xCCorner + "+v+";\n if ("+(1===m)+") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n "+g+"\n } else if ("+(2===m)+") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + "+s+", d),\n initializationValue,\n initializationValue\n );\n\n "+g+"\n } else if ("+(3===m)+") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + "+s+", d),\n getValue(batch, xR, xC + 2 * "+s+", d),\n initializationValue\n );\n\n "+g+"\n }\n }\n setOutput("+d+");\n }\n "}},Mi=function(e,t,n){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");var r=e.filterWidth,o=e.strideDepth,a=e.strideHeight,i=e.strideWidth,s=e.dilationDepth,u=e.dilationHeight,c=e.dilationWidth,l=e.effectiveFilterDepth,f=e.effectiveFilterHeight,h=e.effectiveFilterWidth,p=e.padInfo.front,d=e.padInfo.top,v=e.padInfo.left;this.outputShape=e.outShape;var m="avg"===t,g="0.0";if(m||(g="-1.0 / 1e-20"),n)this.userCode="\n const ivec3 strides =\n ivec3("+o+", "+a+", "+i+");\n const ivec3 pads = ivec3("+p+", "+d+", "+v+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n\n for (int wD = 0; wD < "+l+";\n wD += "+s+") {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= "+e.inDepth+") {\n continue;\n }\n\n for (int wR = 0; wR < "+f+";\n wR += "+u+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+h+";\n wC += "+c+") {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= "+e.inWidth+") {\n continue;\n }\n\n float value = getX(batch, xD, xR, xC, ch);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value >= currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition =\n wD * "+f+" * "+h+" +\n wR * "+h+" + wC;;\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n ";else{var y=t+"("+t+"("+t+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===t&&(y="avgValue / count");var b=4*Math.floor(r/4),w=r%4,x="\n if ("+m+") {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n ";this.userCode="\n const ivec3 strides =\n ivec3("+o+", "+a+", "+i+");\n const ivec3 pads = ivec3("+p+", "+d+", "+v+");\n const float initializationValue = "+g+";\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xD, int xR, int xC, int ch) {\n if (xC < 0 || xC >= "+e.inWidth+") {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xD, xR, xC, ch);\n }\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n // ? = to be determined\n vec4 minMaxValue = vec4("+g+");\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < "+l+";\n wD += "+s+") {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= "+e.inDepth+") {\n continue;\n }\n\n for (int wR = 0; wR < "+f+";\n wR += "+u+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+b+"; wC += 4) {\n int xC = xCCorner + wC * "+c+";\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + "+c+", ch),\n getValue(batch, xD, xR, xC + 2 * "+c+", ch),\n getValue(batch, xD, xR, xC + 3 * "+c+", ch)\n );\n\n "+x+"\n }\n\n int xC = xCCorner + "+b+";\n if ("+(1===w)+") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n "+x+"\n } else if ("+(2===w)+") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + "+c+", ch),\n initializationValue,\n initializationValue\n );\n\n "+x+"\n } else if ("+(3===w)+") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + "+c+", ch),\n getValue(batch, xD, xR, xC + 2 * "+c+", ch),\n initializationValue\n );\n\n "+x+"\n }\n }\n setOutput("+y+");\n }\n }\n "}},Ni=function(e,t){this.variableNames=["x"];var n=e.windowSize,r=e.batchSize,o=e.inSize,a=Math.ceil(o/n);this.outputShape=[r,a];var i="0.0",s="";"prod"===t?i="1.0":"min"===t?(i="1.0 / 1e-20",s="min"):"max"===t&&(i="-1.0 / 1e-20",s="max");var u=t+"("+t+"("+t+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"sum"===t?u="sumValue":"prod"===t?u="prodValue":"all"===t?u="allValue":"any"===t&&(u="anyValue");var c=4*Math.floor(n/4),l=n%4,f="\n if ("+("sum"===t)+") {\n sumValue += dot(values, ones);\n } else if ("+("prod"===t)+") {\n vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n prodValue *= tmp[0] * tmp[1];\n } else {\n minMaxValue = "+s+"(values, minMaxValue);\n }\n ",h="vec4";"all"===t?(i="1.0",f="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",h="bvec4"):"any"===t&&(i="0.0",f="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",h="bvec4");var p="";o%n>0&&(p="\n if (inIdx < 0 || inIdx >= "+o+") {\n return initializationValue;\n }\n "),this.userCode="\n const float initializationValue = "+i+";\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n "+p+"\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * "+n+";\n\n vec4 minMaxValue = vec4("+i+");\n float prodValue = 1.0;\n float sumValue = 0.0;\n float allValue = 1.0;\n float anyValue = 0.0;\n\n for (int i = 0; i < "+c+"; i += 4) {\n int inIdx = inOffset + i;\n "+h+" values = "+h+"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n "+f+"\n }\n\n int inIdx = inOffset + "+c+";\n if ("+(1===l)+") {\n "+h+" values = "+h+"(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n "+f+"\n } else if ("+(2===l)+") {\n "+h+" values = "+h+"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n "+f+"\n } else if ("+(3===l)+") {\n "+h+" values = "+h+"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n "+f+"\n }\n setOutput("+u+");\n }\n "},Fi=function(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;for(var n="",r=0;r<4;r++){var o="thisRC = rc;";r%2==1&&(o+="thisRC.z += 1;"),r>1&&(o+="thisRC.y += 1;"),n+="\n "+o+"\n "+(r>0?"if(thisRC.y < rows && thisRC.z < cols){":"")+"\n int flatIndex = getFlatIndex(thisRC);\n\n ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n result["+r+"] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n "+(r>0?"}":"")+"\n "}this.userCode="\n \n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n "+Zo(["r","c","d"],t)+"\n return ivec3(r, c, d);\n }\n \n "+Yo(e)+"\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = "+e[1]+";\n int cols = "+e[2]+";\n\n "+n+"\n\n setOutput(result);\n }\n "},Bi=function(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t.shape;var r=t.shape,o=r[1],a=r[2],i=e.shape,s=i[1],u=i[2],c=[n&&s>1?o-1:o,n&&u>1?a-1:a],l=[n&&s>1?s-1:s,n&&u>1?u-1:u],f=c[0]/l[0],h=c[1]/l[1],p=1/f,d=1/h,v=2*Math.ceil(p)+2,m=2*Math.ceil(d)+2;this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float("+f+");\n const float widthScale = float("+h+");\n\n const float invHeightScale = float("+p+");\n const float invWidthScale = float("+d+");\n\n const int winHeight = int("+v+");\n const int winWidth = int("+m+");\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(startRLerp - float(winHeight / 2));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(startCLerp - float(winWidth / 2));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= "+s+") {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= "+u+") {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), "+(o-1)+".0));\n float dxRLerp = dxR - float(topDxRIndex);\n float inverseDxRLerp = 1.0 - dxRLerp;\n\n float dxC = float(dyC) * widthScale;\n int leftDxCIndex = int(floor(dxC));\n int rightDxCIndex = int(min(ceil(dxC), "+(a-1)+".0));\n float dxCLerp = dxC - float(leftDxCIndex);\n float inverseDxCLerp = 1.0 - dxCLerp;\n\n if (r == topDxRIndex && c == leftDxCIndex) {\n // topLeft\n accumulator +=\n getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n }\n\n if (r == topDxRIndex && c == rightDxCIndex) {\n // topRight\n accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n }\n\n if (r == bottomDxRIndex && c == leftDxCIndex) {\n // bottomLeft\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n }\n\n if (r == bottomDxRIndex && c == rightDxCIndex) {\n // bottomRight\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n "},ji=function(e,t,n,r){this.variableNames=["A"],this.outputShape=[];var o=e[0],a=e[1],i=e[2],s=e[3];this.outputShape=[o,t,n,s];var u=[r&&t>1?a-1:a,r&&n>1?i-1:i],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];this.userCode="\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n "+u[0]/c[0]+",\n "+u[1]/c[1]+");\n const vec2 inputShapeRC = vec2("+a+".0, "+i+".0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC;\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(sourceFracIndexRC);\n ivec2 sourceCeilRC = ivec2(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n float top = topLeft + (topRight - topLeft) * fracRC.y;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n float newValue = top + (bottom - top) * fracRC.x;\n\n setOutput(newValue);\n }\n "},Li=function(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];var o=e[0],a=e[1],i=e[2],s=e[3];this.outputShape=[o,t,n,s];var u=[r&&t>1?a-1:a,r&&n>1?i-1:i],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];this.userCode="\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n "+u[0]/c[0]+",\n "+u[1]/c[1]+",\n "+u[1]/c[1]+");\n const vec3 inputShapeRC = vec3("+a+".0, "+i+".0,\n "+i+".0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = vec3(yRC) * effectiveInputOverOutputRatioRC;\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(sourceFracIndexRC);\n ivec3 sourceCeilRC = ivec3(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < "+(s-1)+";\n bool hasNextRow = coords.z < "+(n-1)+";\n\n // In parallel, construct four corners for all four components in\n // packed 2x2 cell.\n vec4 topLeft = vec4(\n getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 bottomLeft = vec4(\n getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 topRight = vec4(\n getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec4 bottomRight = vec4(\n getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n vec4 newValue = mix(top, bottom, fracRC.x);\n\n setOutput(newValue);\n }\n "},zi=function(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t.shape;var r=t.shape,o=r[1],a=r[2],i=e.shape,s=i[1],u=i[2],c=[n&&s>1?o-1:o,n&&u>1?a-1:a],l=[n&&s>1?s-1:s,n&&u>1?u-1:u],f=c[0]/l[0],h=c[1]/l[1],p=1/f,d=1/h,v=2*Math.ceil(p)+2,m=2*Math.ceil(d)+2;this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float("+f+");\n const float widthScale = float("+h+");\n\n const float invHeightScale = float("+p+");\n const float invWidthScale = float("+d+");\n\n const int winHeight = int("+v+");\n const int winWidth = int("+m+");\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= "+s+") {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= "+u+") {\n continue;\n }\n\n float sourceFracRow =\n float("+c[0]+") *\n (float(dyR) / float("+l[0]+"));\n\n float sourceFracCol =\n float("+c[1]+") *\n (float(dyC) / float("+l[1]+"));\n\n int sourceNearestRow = int(min(\n float(int("+o+") - 1),\n "+n+" ? float(round(sourceFracRow)) :\n float(floor(sourceFracRow))));\n\n int sourceNearestCol = int(min(\n float(int("+a+") - 1),\n "+n+" ? float(round(sourceFracCol)) :\n float(floor(sourceFracCol))));\n\n if (r == sourceNearestRow && c == sourceNearestCol) {\n accumulator += getDy(b, dyR, dyC, d);\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n "},Wi=function(e,t,n,r){this.variableNames=["A"],this.outputShape=[];var o=e[0],a=e[1],i=e[2],s=e[3];this.outputShape=[o,t,n,s];var u=[r&&t>1?a-1:a,r&&n>1?i-1:i],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],l=r?"0.5":"0.0";this.userCode="\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n "+u[0]/c[0]+",\n "+u[1]/c[1]+");\n const vec2 inputShapeRC = vec2("+a+".0, "+i+".0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC;\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + "+l+")));\n\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n "},Vi=function(e,t){this.variableNames=["x"];var n=e.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");if(this.outputShape=e,1!==n){var r=e.map((function(n,r){return function(n){return-1!==t.indexOf(n)&&1!==e[n]?e[n]+" - coords["+n+"] - 1":"coords["+n+"]"}(r)})).join(","),o=ua(n);this.userCode="\n void main() {\n "+o+" coords = getOutputCoords();\n setOutput(getX("+r+"));\n }\n "}else this.userCode="\n void main() {\n int coord = getOutputCoords();\n setOutput(getX("+e[0]+" - coord - 1));\n }\n "},Hi=function(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;var n=e.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");this.outputShape=e;var r=Ko("rc",n),o=r[n-1]+" + 1 < "+this.outputShape[n-1],a=r[n-2]+" + 1 < "+this.outputShape[n-2],i=ua(n);function s(n){var r=e.map((function(r,o){return function(n,r){return-1!==t.indexOf(n)&&1!==e[n]?e[n]+" - "+r[n]+" - 1":""+r[n]}(o,n)}));return"getChannel(getX("+r.join(",")+"), vec2("+r.slice(-2).join(",")+"))"}this.userCode=1===n?"\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX("+e[0]+" - rc - 1),\n "+e[0]+" - rc - 1);\n if("+o+"){\n result.g = getChannel(getX("+e[0]+" - (rc + 1) - 1),\n "+e[0]+" - (rc + 1) - 1);\n }\n setOutput(result);\n }\n ":"\n void main() {\n "+i+" rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = "+function(e){return s(e)}(r.slice())+";\n if("+o+"){\n result.g = "+function(e){return e[n-1]="("+e[n-1]+" + 1)",s(e)}(r.slice())+";\n }\n if("+a+") {\n result.b = "+function(e){return e[n-2]="("+e[n-2]+" + 1)",s(e)}(r.slice())+";\n if("+o+") {\n result.a = "+function(e){return e[n-1]="("+e[n-1]+" + 1)",e[n-2]="("+e[n-2]+" + 1)",s(e)}(r.slice())+";\n }\n }\n setOutput(result);\n }\n "},Ui=function(e,t,n,r,o,a,i){void 0===i&&(i=!0),this.variableNames=["updates","indices","defaultValue"],this.outputShape=a;var s=ua(o.length),u=ua(a.length),c="";1===n?c="i":2===n&&(c="i, j");var l="getIndices("+c+")",f="";1===r?f="i":2===r&&(f="i, coords[1]");var h="getUpdates("+f+")",p=t>1?"strides[j]":"strides";this.userCode="\n "+s+" strides = "+s+"("+o+");\n\n void main() {\n "+u+" coords = getOutputCoords();\n float sum = 0.0;\n bool found = false;\n for (int i = 0; i < "+e+"; i++) {\n int flattenedIndex = 0;\n for (int j = 0; j < "+t+"; j++) {\n int index = round("+l+");\n flattenedIndex += index * "+p+";\n }\n if (flattenedIndex == coords[0]) {\n sum += "+h+";\n found = true;\n }\n }\n setOutput(mix(getDefaultValue(), sum, float(found)));\n }\n "},Gi=function(e,t){this.variableNames=["x","segmentIds"];var n=e.windowSize,r=e.batchSize,o=e.inSize,a=e.numSegments,i=a*Math.ceil(o/n);this.outputShape=[r,i];var s=4*Math.floor(n/4),u=n%4,c="\n sumValue += dot(values, segFilter);\n ",l="";o%n>0&&(l="\n if (inIdx < 0 || inIdx >= "+o+") {\n return initializationValue;\n }\n ");var f="";o%n>0&&(f="\n if (inIdx < 0 || inIdx >= "+o+") {\n return -1.0;\n }\n "),this.userCode="\n const float initializationValue = 0.0;\n\n float getValue(int batch, int inIdx) {\n "+l+"\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n "+f+"\n return getSegmentIds(inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = int(floor(float(outIdx) / float(\n "+a+")) * float("+n+"));\n int currentSeg = int(mod(float(outIdx), float("+a+")));\n\n float sumValue = 0.0;\n\n for (int i = 0; i < "+s+"; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n );\n\n "+c+"\n }\n\n int inIdx = inOffset + "+s+";\n if ("+(1===u)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n 0,\n 0,\n 0\n );\n\n "+c+"\n } else if ("+(2===u)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n 0,\n 0\n );\n\n "+c+"\n } else if ("+(3===u)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n 0\n );\n\n "+c+"\n }\n setOutput(sumValue);\n }\n "},qi=function(e,t,n){var r,o;if(this.variableNames=["c","a","b"],this.outputShape=t,n>4)throw Error("Where for rank "+n+" is not yet supported");if(1===n)o="resRC",r="resRC";else{for(var a=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[],s=[],u=0;u<t.length;u++)s.push(""+a[u]),u<e&&i.push(""+a[u]);r=i.join(),o=s.join()}var c=ua(n);this.userCode="\n void main() {\n "+c+" resRC = getOutputCoords();\n float cVal = getC("+r+");\n if (cVal >= 1.0) {\n setOutput(getA("+o+"));\n } else {\n setOutput(getB("+o+"));\n }\n }\n "},Xi=function(){function e(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;var t,n=ua(this.rank),r="uniform int start["+this.rank+"];",o=function(e){if(1===e)return"sourceLoc";if(e<=6)return Ki.slice(0,e).map((function(e){return"sourceLoc."+e})).join(",");throw Error("Slicing for rank "+e+" is not yet supported")}(this.rank);t="\n "+n+" sourceLoc;\n "+n+" coords = getOutputCoords();\n "+e.map((function(e,t){return"sourceLoc."+Ki[t]+" = start["+t+"] + coords."+Ki[t]+";"})).join("\n")+"\n ",this.userCode="\n "+r+"\n void main() {\n "+t+"\n setOutput(getSource("+o+"));\n }\n "}return e.prototype.getCustomSetupFunc=function(e){var t=this;if(e.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the length of start ("+e.length+")");return function(n,r){null==t.startLoc&&(t.startLoc=n.getUniformLocationNoThrow(r,"start"),null==t.startLoc)||n.gl.uniform1iv(t.startLoc,e)}},e}(),Ki=["x","y","z","w","u","v"],$i=function(){function e(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length;var t=ua(this.rank),n=Ko("coords",this.rank),r=Ko("sourceLoc",this.rank),o=1===this.rank?"sourceLoc":"vec2("+r.slice(-2).join()+")",a="getChannel(getSource("+r.join()+"), "+o+")",i="\n result.x = "+a+";\n if (++"+n[this.rank-1]+" < "+e[this.rank-1]+") {\n ++"+r[this.rank-1]+";\n result.y = "+a+";\n --"+r[this.rank-1]+";\n }\n ",s=1===this.rank?"":"\n --"+n[this.rank-1]+";\n if (++"+n[this.rank-2]+" < "+e[this.rank-2]+") {\n ++"+r[this.rank-2]+";\n result.z = "+a+";\n if (++"+n[this.rank-1]+" < "+e[this.rank-1]+") {\n ++"+r[this.rank-1]+";\n result.w = "+a+";\n }\n }\n ",u=this.rank<=4?"sourceLoc = coords +\n "+t+"("+e.map((function(e,t){return"start["+t+"]"})).join()+");":e.map((function(e,t){return r[t]+" = "+n[t]+" + start["+t+"];"})).join("\n");this.userCode="\n uniform int start["+this.rank+"];\n void main() {\n "+t+" coords = getOutputCoords();\n "+t+" sourceLoc;\n "+u+"\n vec4 result = vec4(0.);\n "+i+"\n "+s+"\n setOutput(result);\n }\n "}return e.prototype.getCustomSetupFunc=function(e){var t=this;if(e.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the length of start ("+e.length+")");return function(n,r){null==t.startLoc&&(t.startLoc=n.getUniformLocationNoThrow(r,"start"),null==t.startLoc)||n.gl.uniform1iv(t.startLoc,e)}},e}(),Zi=function(e,t,n){this.variableNames=["x"],this.outputShape=n;var r=n.length,o=ua(n.length),a=ua(n.length),i="";if(1===r)i="coords * strides + begin";else{var s=0;i=n.map((function(e,t){return s++,1===n.length?"coords * strides["+t+"] + begin["+t+"]":"coords["+(s-1)+"] * strides["+t+"] + begin["+t+"]"})).join(",")}this.userCode="\n "+o+" begin = "+o+"("+e+");\n "+o+" strides = "+o+"("+t+");\n\n void main() {\n "+a+" coords = getOutputCoords();\n setOutput(getX("+i+"));\n }\n "},Yi=function(){function e(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}return e.prototype.acquireTexture=function(e,t,n){var r,o=Ji(t,n),a=Qi(e,o,n);if(a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]),this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this.log();var i=this.freeTextures[a].shift();return this.usedTextures[a].push(i),i}return this.numUsedTextures++,this.log(),o===xt.PACKED_2X2_FLOAT32?r=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):o===xt.PACKED_2X2_FLOAT16?r=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):o===xt.UNPACKED_FLOAT32?r=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):o===xt.UNPACKED_FLOAT16?r=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):o===xt.PACKED_4X1_UNSIGNED_BYTE&&(r=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[a].push(r),r},e.prototype.releaseTexture=function(e,t,n,r){if(null!=this.freeTextures){var o=Qi(t,Ji(n,r),r);o in this.freeTextures||(this.freeTextures[o]=[]),this.freeTextures[o].push(e),this.numFreeTextures++,this.numUsedTextures--;var a=this.usedTextures[o],i=a.indexOf(e);if(i<0)throw new Error("Cannot release a texture that was never provided by this texture manager");a.splice(i,1),this.log()}},e.prototype.log=function(){if(this.logEnabled){this.numFreeTextures,this.numUsedTextures;this.numFreeTextures,this.numUsedTextures}},e.prototype.getNumUsedTextures=function(){return this.numUsedTextures},e.prototype.getNumFreeTextures=function(){return this.numFreeTextures},e.prototype.dispose=function(){var e=this;if(null!=this.freeTextures){for(var t in this.freeTextures)this.freeTextures[t].forEach((function(t){e.gpgpu.deleteMatrixTexture(t)}));for(var t in this.usedTextures)this.usedTextures[t].forEach((function(t){e.gpgpu.deleteMatrixTexture(t)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0}},e}();function Ji(e,t){if(e===wt.UPLOAD)return xt.PACKED_2X2_FLOAT32;if(e===wt.RENDER||null==e)return function(e){return Y().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?xt.PACKED_2X2_FLOAT32:xt.UNPACKED_FLOAT32:e?xt.PACKED_2X2_FLOAT16:xt.UNPACKED_FLOAT16}(t);if(e===wt.DOWNLOAD||e===wt.PIXELS)return xt.PACKED_4X1_UNSIGNED_BYTE;throw new Error("Unknown logical texture type "+e)}function Qi(e,t,n){return e[0]+"_"+e[1]+"_"+t+"_"+n}var es=function(e,t){this.variableNames=["A"];for(var n=new Array(e.length),r=0;r<n.length;r++)n[r]=e[r]*t[r];this.outputShape=n,this.rank=n.length;var o=ua(this.rank),a=function(e){var t=e.length;if(t>5)throw Error("Tile for rank "+t+" is not yet supported");if(1===t)return"imod(resRC, "+e[0]+")";for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[],o=0;o<e.length;o++)r.push("imod("+n[o]+", "+e[o]+")");return r.join()}(e);this.userCode="\n void main() {\n "+o+" resRC = getOutputCoords();\n setOutput(getA("+a+"));\n }\n "},ts=function(e,t){this.variableNames=["A"];for(var n=new Array(e.length),r=0;r<n.length;r++)n[r]=e[t[r]];this.outputShape=n,this.rank=n.length;var o=ua(this.rank),a=function(e){var t=e.length;if(t>6)throw Error("Transpose for rank "+t+" is not yet supported");for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(t),o=0;o<e.length;o++)r[e[o]]=n[o];return r.join()}(t);this.userCode="\n void main() {\n "+o+" resRC = getOutputCoords();\n setOutput(getA("+a+"));\n }\n "},ns=function(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;for(var n=new Array(e.length),r=0;r<n.length;r++)n[r]=e[t[r]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error("Packed transpose for rank "+this.rank+" is not yet supported.");var o=ua(this.rank),a=Xo("rc",this.rank),i=new Array(this.rank);for(r=0;r<t.length;r++)i[t[r]]=a[r];var s="vec2("+i.slice(-2).join()+")",u="++"+a[this.rank-1]+" < "+n[this.rank-1],c="getChannel(getA("+i.join()+"), "+s+")";this.userCode="\n void main() {\n "+o+" rc = getOutputCoords();\n vec4 result = vec4(0.);\n result[0] = "+c+";\n if("+u+") {\n result[1] = "+c+";\n }\n --"+a[this.rank-1]+";\n if(++"+a[this.rank-2]+" < "+n[this.rank-2]+") {\n result[2] = "+c+";\n if("+u+") {\n result[3] = "+c+";\n }\n }\n setOutput(result);\n }\n "},rs=1.7580993408473768,os=1.0507009873554805,as=function(e,t){this.variableNames=["A"],this.outputShape=e,this.userCode="\n float unaryOperation(float x) {\n "+t+"\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n "},is="if (isnan(x)) return x;",ss="return abs(x);",us=is+"\n return (x < 0.0) ? 0.0 : x;\n",cs=is+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",ls="return (x >= 0.0) ? x : (exp(x) - 1.0);",fs="return -x;",hs="return ceil(x);",ps="return floor(x);",ds="return exp(x);",vs="return exp(x) - 1.0;",ms="return x;",gs="\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",ys="\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",bs="\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n",ws=function(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.userCode="\n vec4 unaryOperation(vec4 x) {\n "+t+"\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n "},xs=function(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e;var t=e.length,n=Ko("rc",t),r=ua(t),o=function(e,t){if(1===e)return"rc";for(var n="",r=0;r<e;r++)n+=t[r],r<e-1&&(n+=",");return n}(t,n),a=n.slice(-2),i=t<=1?"rc":"vec2("+a.join(",")+")";this.userCode="\n void main() {\n "+r+" rc = getOutputCoords();\n vec4 packedInput = getA("+o+");\n\n setOutput(getChannel(packedInput, "+i+"));\n }\n "},Es={};function _s(e,t){if(void 0===t&&(t=!1),"linear"===e)return"return x;";if("relu"===e)return t?gs:us;if("elu"===e)return t?bs:ls;if("relu6"===e)return t?ys:cs;if("prelu"===e)return t?Ea:wa;throw new Error("Activation "+e+" has not been implemented for the WebGL backend.")}var Os=function(e){function t(t){var n,r=e.call(this)||this;if(r.pendingRead=new WeakMap,r.pendingDisposal=new WeakSet,r.dataRefCount=new WeakMap,r.numBytesInGPU=0,r.uploadWaitMs=0,r.downloadWaitMs=0,r.warnedAboutMemory=!1,r.pendingDeletes=0,r.disposed=!1,!Y().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(null==t){var o=kt(Y().getNumber("WEBGL_VERSION"));r.binaryCache=((n=Y().getNumber("WEBGL_VERSION"))in Es||(Es[n]={}),Es[n]),r.gpgpu=new bi(o),r.canvas=o.canvas,r.gpgpuCreatedLocally=!0}else r.gpgpu=t,r.binaryCache={},r.gpgpuCreatedLocally=!1,r.canvas=t.gl.canvas;return r.textureManager=new Yi(r.gpgpu),r.numMBBeforeWarning=null==Y().global.screen?1024:Y().global.screen.height*Y().global.screen.width*window.devicePixelRatio*600/1024/1024,r.texData=new ho(r,mt),r}return X(t,e),t.prototype.numDataIds=function(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes},t.prototype.write=function(e,t,n){if(Y().getBool("DEBUG")&&this.checkNumericalProblems(e),"complex64"===n&&null!=e)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");var r={};return this.texData.set(r,{shape:t,dtype:n,values:e,usage:wt.UPLOAD}),r},t.prototype.move=function(e,t,n,r){if(Y().getBool("DEBUG")&&this.checkNumericalProblems(t),"complex64"===r)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:n,dtype:r,values:t,usage:wt.UPLOAD})},t.prototype.readSync=function(e){var t=this.texData.get(e),n=t.values,r=t.dtype,o=t.complexTensors,a=t.slice,i=t.shape,s=t.isPacked;if(null!=a){var u;u=s?new ws(i,ms):new as(i,ms);var c=this.runWebGLProgram(u,[{dataId:e,shape:i,dtype:r}],r),l=this.readSync(c.dataId);return this.disposeData(c.dataId),l}if(null!=n)return this.convertAndCacheOnCPU(e);if("string"===r)return n;var f,h,p=null!=this.activeTimers;return p&&(f=We()),h="complex64"===r?Mo(o.real.dataSync(),o.imag.dataSync()):this.getValuesFromTexture(e),p&&(this.downloadWaitMs+=We()-f),this.convertAndCacheOnCPU(e,h)},t.prototype.read=function(e){return K(this,void 0,void 0,(function(){var t,n,r,o,a,i,s,u,c,l,f,h,p,d,v,m,g,y,b,w,x,E;return $(this,(function(_){switch(_.label){case 0:if(this.pendingRead.has(e))return t=this.pendingRead.get(e),[2,new Promise((function(e){return t.push(e)}))];if(n=this.texData.get(e),r=n.values,o=n.shape,a=n.slice,i=n.dtype,s=n.complexTensors,u=n.isPacked,null!=a)return void 0,c=u?new ws(o,ms):new as(o,ms),l=this.runWebGLProgram(c,[{dataId:e,shape:o,dtype:i}],i),f=this.read(l.dataId),this.disposeData(l.dataId),[2,f];if(null!=r)return[2,this.convertAndCacheOnCPU(e)];if(!Y().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===Y().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");return h=null,"complex64"!==i&&Y().get("WEBGL_BUFFER_SUPPORTED")&&(p=this.decode(e),d=this.texData.get(p.dataId),h=(E=this.gpgpu).createBufferFromTexture.apply(E,[d.texture].concat(It(o)))),this.pendingRead.set(e,[]),"complex64"===i?[3,2]:[4,this.gpgpu.createAndWaitForFence()];case 1:_.sent(),_.label=2;case 2:return"complex64"!==i?[3,4]:[4,Promise.all([s.real.data(),s.imag.data()])];case 3:return m=_.sent(),g=m[0],y=m[1],v=Mo(g,y),[3,5];case 4:null==h?v=this.getValuesFromTexture(e):(b=he(o),v=this.gpgpu.downloadFloat32MatrixFromBuffer(h,b)),_.label=5;case 5:return null!=p&&this.disposeData(p.dataId),w=this.convertAndCacheOnCPU(e,v),x=this.pendingRead.get(e),this.pendingRead.delete(e),x.forEach((function(e){return e(w)})),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e),this.pendingDeletes--),[2,w]}}))}))},t.prototype.checkNumericalProblems=function(e){if(null!=e)for(var t=0;t<e.length;t++){var n=e[t];if(!Pt(n)){if(Y().getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))throw Error("The value "+n+" cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'");throw Error("The value "+n+" cannot be represented on this device.")}}},t.prototype.getValuesFromTexture=function(e){var t,n=this.texData.get(e),r=n.shape,o=n.dtype,a=n.isPacked,i=he(r);if(Y().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){var s=this.decode(e),u=this.texData.get(s.dataId),c=(t=this.gpgpu).downloadMatrixFromPackedTexture.apply(t,[u.texture].concat(It(r))).subarray(0,i);return this.disposeData(s.dataId),c}var l=Y().getBool("WEBGL_PACK")&&!0===a,f=l?sn(r):r,h=l?new Ka(f):new Xa(f),p=this.runWebGLProgram(h,[{shape:f,dtype:o,dataId:e}],"float32"),d=this.texData.get(p.dataId),v=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(d.texture,d.texShape[0],d.texShape[1]).subarray(0,i);return this.disposeData(p.dataId),v},t.prototype.time=function(e){return K(this,void 0,void 0,(function(){var t,n,r,o,a,i,s;return $(this,(function(u){switch(u.label){case 0:return t=this.activeTimers,n=[],r=!1,null==this.programTimersStack?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,e(),o=fe(this.activeTimers.map((function(e){return e.query}))).filter((function(e){return null!=e})),a=fe(this.activeTimers.map((function(e){return e.name}))).filter((function(e){return null!=e})),this.activeTimers=t,r&&(this.programTimersStack=null),[4,Promise.all(o)];case 1:return i=u.sent(),s={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:se(i),getExtraProfileInfo:function(){return i.map((function(e,t){return{name:a[t],ms:e}})).map((function(e){return e.name+": "+e.ms})).join(", ")},wallMs:null},this.uploadWaitMs=0,this.downloadWaitMs=0,[2,s]}}))}))},t.prototype.memory=function(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU}},t.prototype.startTimer=function(){return Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?this.gpgpu.beginQuery():{startMs:We(),endMs:null}},t.prototype.endTimer=function(e){return Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(this.gpgpu.endQuery(),e):(e.endMs=We(),e)},t.prototype.getQueryTime=function(e){return K(this,void 0,void 0,(function(){var t;return $(this,(function(n){return Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?[2,this.gpgpu.waitForQueryAndGetTime(e)]:[2,(t=e).endMs-t.startMs]}))}))},t.prototype.disposeData=function(e){if(!this.pendingDisposal.has(e)){if(this.pendingRead.has(e))return this.pendingDisposal.add(e),void this.pendingDeletes++;if(this.texData.has(e)){this.releaseGPUData(e);var t=this.texData.get(e).complexTensors;null!=t&&(t.real.dispose(),t.imag.dispose()),this.texData.delete(e)}}},t.prototype.releaseGPUData=function(e){var t=this.texData.get(e),n=t.texture,r=t.dtype,o=t.texShape,a=t.usage,i=t.isPacked,s=t.slice,u=s&&s.origDataId||e,c=this.dataRefCount.get(u);c>1?this.dataRefCount.set(u,c-1):(this.dataRefCount.delete(u),null!=n&&(this.numBytesInGPU-=this.computeBytes(o,r),this.textureManager.releaseTexture(n,o,a,i)));var l=this.texData.get(e);l.texture=null,l.texShape=null,l.isPacked=!1,l.slice=null},t.prototype.getTexture=function(e){return this.uploadToGPU(e),this.texData.get(e).texture},t.prototype.getDataInfo=function(e){return this.texData.get(e)},t.prototype.getCPUBackend=function(){return Y().getBool("WEBGL_CPU_FORWARD")?(null==this.cpuBackend&&(this.cpuBackend=mt.findBackend("cpu")),this.cpuBackend):null},t.prototype.shouldExecuteOnCPU=function(e,t){var n=this;return void 0===t&&(t=128),null!=this.getCPUBackend()&&e.every((function(e){return null==n.texData.get(e.dataId).texture&&e.size<t}))},t.prototype.getGPGPUContext=function(){return this.gpgpu},t.prototype.complex=function(e,t){var n=this.makeOutput(e.shape,"complex64");return this.texData.get(n.dataId).complexTensors={real:mt.keep(e.clone()),imag:mt.keep(t.clone())},n},t.prototype.real=function(e){return this.texData.get(e.dataId).complexTensors.real.clone()},t.prototype.imag=function(e){return this.texData.get(e.dataId).complexTensors.imag.clone()},t.prototype.slice=function(e,t,n){if(this.shouldExecuteOnCPU([e]))return this.cpuBackend.slice(e,t,n);if(0===he(n))return Un([],n,e.dtype);var r=this.texData.get(e.dataId).isPacked,o=so(e.shape,t,n);if(r||!o){var a=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new $i(n):new Xi(n),i=a.getCustomSetupFunc(t);return this.compileAndRun(a,[e],null,i)}return this.uploadToGPU(e.dataId),this.shallowSlice(e,t,n)},t.prototype.shallowSlice=function(e,t,n){var r=this.texData.get(e.dataId),o=this.makeOutput(n,e.dtype),a=this.texData.get(o.dataId);Object.assign(a,r),a.shape=n,a.dtype=e.dtype;var i=uo(t,e.strides);r.slice&&(i+=r.slice.flatOffset),a.slice={flatOffset:i,origDataId:r.slice&&r.slice.origDataId||e.dataId};var s=this.dataRefCount.get(a.slice.origDataId)||1;return this.dataRefCount.set(a.slice.origDataId,s+1),o},t.prototype.stridedSlice=function(e,t,n,r){if(this.shouldExecuteOnCPU([e]))return this.cpuBackend.stridedSlice(e,t,n,r);var o=oo(t,n,r);if(o.some((function(e){return 0===e})))return Un([],o);var a=new Zi(t,r,o);return this.compileAndRun(a,[e])},t.prototype.reverse=function(e,t){var n=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Hi(e.shape,t):new Vi(e.shape,t);return this.compileAndRun(n,[e])},t.prototype.concat=function(e,t){if("complex64"===e[0].dtype){var n=e.map((function(e){return Vn(e)})),r=e.map((function(e){return Hn(e)}));return Wn(this.concat(n,t),this.concat(r,t))}if(this.shouldExecuteOnCPU(e))return this.cpuBackend.concat(e,t);if(1===e.length)return e[0];if(e.length>Y().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){var o=Math.floor(e.length/2),a=this.concat(e.slice(0,o),t),i=this.concat(e.slice(o),t);return this.concat([a,i],t)}if(Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&e[0].rank>1){var s=new Sa(e.map((function(e){return e.shape})),t);return this.compileAndRun(s,e)}var u=Ln(e.map((function(e){return e.shape})),t),c=e.map((function(e){return e.as2D(-1,he(e.shape.slice(t)))})),l=new Ia(c.map((function(e){return e.shape})));return this.compileAndRun(l,c).reshape(u)},t.prototype.neg=function(e){if(this.shouldExecuteOnCPU([e]))return this.cpuBackend.neg(e);if(Y().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,fs,e.dtype);var t=new as(e.shape,fs);return this.compileAndRun(t,[e])},t.prototype.batchMatMul=function(e,t,n,r){var o=n?e.shape[2]:e.shape[1],a=r?t.shape[1]:t.shape[2],i=n?e.shape[1]:e.shape[2],s=e.shape[0];if((1===o||1===a)&&i>1e3){n&&(e=e.transpose([0,2,1])),r&&(t=t.transpose([0,2,1]));var u=1===a?e:e.as3D(s,i,1),c=1===a?2:1,l=1===a?t.as3D(s,1,i):t;return this.multiply(u,l).sum(c,!0)}var f=ut(e.dtype,t.dtype),h=new Ii(e.shape,[s,o,a],n,r);return this.compileAndRun(h,[e,t],f)},t.prototype.fusedBatchMatMul=function(e){var t=e.a,n=e.b,r=e.transposeA,o=e.transposeB,a=e.bias,i=e.activation,s=e.preluActivationWeights,u=r?t.shape[2]:t.shape[1],c=o?n.shape[1]:n.shape[2],l=t.shape[0],f=ut(t.dtype,n.dtype),h=null!=a,p=null!=s,d=i?_s(i,!0):null,v=new Ii(t.shape,[l,u,c],r,o,h,d,p),m=[t,n];return a&&m.push(a),s&&m.push(s),this.compileAndRun(v,m,f)},t.prototype.multiply=function(e,t){if("complex64"===e.dtype){var n=this.texData.get(e.dataId),r=this.texData.get(t.dataId),o=new ma("return areal * breal - aimag * bimag;",e.shape,t.shape),a=new ma("return areal * bimag + aimag * breal;",e.shape,t.shape),i=[this.makeComplexComponentTensorInfo(e,n.complexTensors.real),this.makeComplexComponentTensorInfo(e,n.complexTensors.imag),this.makeComplexComponentTensorInfo(t,r.complexTensors.real),this.makeComplexComponentTensorInfo(t,r.complexTensors.imag)],s=this.compileAndRun(o,i),u=this.compileAndRun(a,i),c=this.complex(s,u);return s.dispose(),u.dispose(),c}if(this.shouldExecuteOnCPU([e,t]))return this.cpuBackend.multiply(e,t);if(Y().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(e,t,ba,e.dtype);var l=new xa(ba,e.shape,t.shape);return this.compileAndRun(l,[e,t],e.dtype)},t.prototype.batchNormalization=function(e,t,n,r,o,a){var i=[e,t,n],s=null;null!=a&&(s=a.shape,i.push(a));var u=null;if(null!=o&&(u=o.shape,i.push(o)),Y().getBool("WEBGL_PACK_NORMALIZATION")){var c=new va(e.shape,t.shape,n.shape,s,u,r);return this.compileAndRun(c,i)}var l=new da(e.shape,t.shape,n.shape,s,u,r);return this.compileAndRun(l,i)},t.prototype.localResponseNormalization4D=function(e,t,n,r,o){var a=Y().getBool("WEBGL_PACK_NORMALIZATION")?new Oi(e.shape,t,n,r,o):new Ei(e.shape,t,n,r,o);return this.compileAndRun(a,[e])},t.prototype.LRNGrad=function(e,t,n,r,o,a,i){var s=new _i(t.shape,r,o,a,i);return this.compileAndRun(s,[t,n,e])},t.prototype.tile=function(e,t){if("string"===e.dtype){var n=this.readSync(e.dataId).map((function(e){return Ue(e)}));return Wo(xr(e.shape,e.dtype,n),t)}var r=new es(e.shape,t);return this.compileAndRun(r,[e])},t.prototype.pad=function(e,t,n){var r=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Ti(e.shape,t,n):new Pi(e.shape,t,n);return this.compileAndRun(r,[e])},t.prototype.transpose=function(e,t){if(this.shouldExecuteOnCPU([e]))return this.cpuBackend.transpose(e,t);var n=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new ns(e.shape,t):new ts(e.shape,t);return this.compileAndRun(n,[e])},t.prototype.gather=function(e,t,n){if(this.shouldExecuteOnCPU([e,t]))return this.cpuBackend.gather(e,t,n);var r=new Qa(e.shape,t.size,n);return this.compileAndRun(r,[e,t])},t.prototype.batchToSpaceND=function(e,t,n){ue(e.rank<=4,(function(){return"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"}));var r=t.reduce((function(e,t){return e*t})),o=Kr(e.shape,t,r),a=$r(o.length,t.length),i=Zr(e.shape,t,r),s=Yr(n,t.length),u=Jr(i,n,t.length);return e.reshape(o).transpose(a).reshape(i).slice(s,u)},t.prototype.spaceToBatchND=function(e,t,n){ue(e.rank<=4,(function(){return"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"}));var r=t.reduce((function(e,t){return e*t})),o=[[0,0]];o.push.apply(o,n);for(var a=1+t.length;a<e.shape.length;++a)o.push([0,0]);var i=e.pad(o),s=Kr(i.shape,t,r,!1),u=$r(s.length,t.length,!1),c=Zr(i.shape,t,r,!1);return i.reshape(s).transpose(u).reshape(c)},t.prototype.reduce=function(e,t,n){var r=e.shape[0],o=e.shape[1],a=eo(o),i=new Ni({windowSize:a,inSize:o,batchSize:r},t),s=this.compileAndRun(i,[e],n);return 1===s.shape[1]?s:this.reduce(s,t,n)},t.prototype.argReduce=function(e,t,n){void 0===n&&(n=null);var r=e.shape[0],o=e.shape[1];null!=n&&(r=n.shape[0],o=n.shape[1]);var a=eo(o),i=new qo({windowSize:a,inSize:o,batchSize:r},t,null==n),s=[e];null!=n&&s.push(n);var u=this.compileAndRun(i,s,"int32");return 1===u.shape[1]?u:this.argReduce(e,t,u)},t.prototype.argReducePacked=function(e,t,n){void 0===n&&(n=null);var r=null!=n?n.shape:e.shape,o=eo(r[r.length-1]),a=new fa(r,o,t,null==n),i=null==n?[e]:[e,n],s=this.compileAndRun(a,i,"int32");return s.rank===e.rank?this.argReducePacked(e,t,s):s},t.prototype.sum=function(e,t){Mn("sum",t,e.rank);var n=Tn(e.shape,t),r=n[0],o=he(n[1]),a=e.as2D(-1,o),i=ct(e.dtype);return this.reduce(a,"sum",i).reshape(r)},t.prototype.prod=function(e,t){if(this.shouldExecuteOnCPU([e]))return this.cpuBackend.prod(e,t);var n=Tn(e.shape,t),r=n[0],o=he(n[1]),a=e.as2D(-1,o),i=ct(e.dtype);return this.reduce(a,"prod",i).reshape(r)},t.prototype.unsortedSegmentSum=function(e,t,n){var r=0,o=Nn([r],e.rank),a=e;null!=o&&(a=e.transpose(o),r=Bn(1,e.rank)[0]);var i=function(e,t,n){for(var r=[],o=e.length,a=0;a<o;a++)a!==t?r.push(e[a]):r.push(n);return r}(a.shape,r,n),s=he([a.shape[r]]),u=a.as2D(-1,s),c=ct(e.dtype),l=this.segOpCompute(u,"unsortedSegmentSum",t,c,n).reshape(i);return null!=o&&(l=l.transpose(Fn(o))),l},t.prototype.segOpCompute=function(e,t,n,r,o){var a=e.shape[0],i=e.shape[1],s=function(e,t){var n,r=!1;for(e<=30?(n=e,r=!0):n=Ne(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=Ne(e,n+1);return n}(i,o),u=new Gi({windowSize:s,inSize:i,batchSize:a,numSegments:o},t),c=this.compileAndRun(u,[e,n],r);return c.shape[1]===o?c:(n=er(0,o).tile([i/s]),this.segOpCompute(c,t,n,r,o))},t.prototype.argMinMaxReduce=function(e,t,n){var r=[t];if(Mn("arg"+n.charAt(0).toUpperCase()+n.slice(1),r,e.rank),!Y().getBool("WEBGL_PACK_REDUCE")||e.rank<=2){var o=Tn(e.shape,r),a=o[0],i=he(o[1]),s=e.as2D(-1,i);return this.argReduce(s,n).reshape(a)}return this.argReducePacked(e,n)},t.prototype.argMin=function(e,t){return this.argMinMaxReduce(e,t,"min")},t.prototype.argMax=function(e,t){return this.argMinMaxReduce(e,t,"max")},t.prototype.cumsum=function(e,t,n,r){if(t!==e.rank-1)throw new Error("WebGL cumsum shader expects an inner-most axis="+(e.rank-1)+" but got axis="+t);var o=new Wa(e.shape,n,r);return this.compileAndRun(o,[e])},t.prototype.equal=function(e,t){if(Y().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(e,t,"\n return vec4(equal(a, b));\n","bool");var n=new xa("return float(a == b);",e.shape,t.shape);return this.compileAndRun(n,[e,t],"bool")},t.prototype.notEqual=function(e,t){if(Y().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(e,t,"\n return vec4(notEqual(a, b));\n","bool");var n=new xa("return float(a != b);",e.shape,t.shape);return this.compileAndRun(n,[e,t],"bool")},t.prototype.less=function(e,t){if(this.shouldExecuteOnCPU([e,t]))return this.cpuBackend.less(e,t);if(Y().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(e,t,"\n return vec4(lessThan(a, b));\n","bool");var n=new xa("return float(a < b);",e.shape,t.shape);return this.compileAndRun(n,[e,t],"bool")},t.prototype.lessEqual=function(e,t){if(Y().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(e,t,"\n return vec4(lessThanEqual(a, b));\n","bool");var n=new xa("return float(a <= b);",e.shape,t.shape);return this.compileAndRun(n,[e,t],"bool")},t.prototype.greater=function(e,t){if(this.shouldExecuteOnCPU([e,t]))return this.cpuBackend.greater(e,t);if(Y().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(e,t,"\n return vec4(greaterThan(a, b));\n","bool");var n=new xa("return float(a > b);",e.shape,t.shape);return this.compileAndRun(n,[e,t],"bool")},t.prototype.greaterEqual=function(e,t){if(Y().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(e,t,"\n return vec4(greaterThanEqual(a, b));\n","bool");var n=new xa("return float(a >= b);",e.shape,t.shape);return this.compileAndRun(n,[e,t],"bool")},t.prototype.logicalNot=function(e){var t=new as(e.shape,"return float(!(x >= 1.0));");return this.compileAndRun(t,[e])},t.prototype.logicalAnd=function(e,t){if(Y().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(e,t,"\n return vec4(\n vec4(greaterThanEqual(a, vec4(1.0))) *\n vec4(greaterThanEqual(b, vec4(1.0))));\n","bool");var n=new xa("return float(a >= 1.0 && b >= 1.0);",e.shape,t.shape);return this.compileAndRun(n,[e,t],"bool")},t.prototype.logicalOr=function(e,t){if(Y().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(e,t,"\n return min(\n vec4(greaterThanEqual(a, vec4(1.0))) +\n vec4(greaterThanEqual(b, vec4(1.0))),\n vec4(1.0));\n","bool");var n=new xa("return float(a >= 1.0 || b >= 1.0);",e.shape,t.shape);return this.compileAndRun(n,[e,t],"bool")},t.prototype.select=function(e,t,n){var r=new qi(e.rank,t.shape,t.rank);return this.compileAndRun(r,[e,t,n],ut(t.dtype,n.dtype))},t.prototype.where=function(e){kn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");var t=e.dataSync();return Ho(e.shape,t)},t.prototype.topk=function(e,t,n){return Vo(e.dataSync(),e.shape,e.dtype,t)},t.prototype.min=function(e,t){Mn("min",t,e.rank);var n=Tn(e.shape,t),r=n[0],o=he(n[1]),a=e.as2D(-1,o);return this.reduce(a,"min",a.dtype).reshape(r)},t.prototype.minimum=function(e,t){if(this.shouldExecuteOnCPU([e,t]))return this.cpuBackend.minimum(e,t);var n=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new _a("\n vec4 result = vec4(min(a, b));\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",e.shape,t.shape):new xa("\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return min(a, b);\n",e.shape,t.shape);return this.compileAndRun(n,[e,t])},t.prototype.mod=function(e,t){var n=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new _a("\n vec4 result = mod(a, b);\n vec4 isNaN = vec4(equal(b, vec4(0.0)));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",e.shape,t.shape):new xa("if (b == 0.0) return NAN;\n return mod(a, b);",e.shape,t.shape);return this.compileAndRun(n,[e,t])},t.prototype.max=function(e,t){if(this.shouldExecuteOnCPU([e]))return this.cpuBackend.max(e,t);Mn("max",t,e.rank);var n=Tn(e.shape,t),r=n[0],o=he(n[1]),a=e.as2D(-1,o);return this.reduce(a,"max",a.dtype).reshape(r)},t.prototype.maximum=function(e,t){if(this.shouldExecuteOnCPU([e,t]))return this.cpuBackend.maximum(e,t);var n=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new _a("\n vec4 result = vec4(max(a, b));\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",e.shape,t.shape):new xa("\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return max(a, b);\n",e.shape,t.shape);return this.compileAndRun(n,[e,t])},t.prototype.all=function(e,t){Mn("all",t,e.rank);var n=Tn(e.shape,t),r=n[0],o=he(n[1]),a=e.as2D(-1,o);return this.reduce(a,"all",a.dtype).reshape(r)},t.prototype.any=function(e,t){Mn("any",t,e.rank);var n=Tn(e.shape,t),r=n[0],o=he(n[1]),a=e.as2D(-1,o);return this.reduce(a,"any",a.dtype).reshape(r)},t.prototype.squaredDifference=function(e,t){var n=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new _a("return (a - b) * (a - b);",e.shape,t.shape):new xa("return (a - b) * (a - b);",e.shape,t.shape);return this.compileAndRun(n,[e,t])},t.prototype.realDivide=function(e,t){if(Y().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(e,t,"\n // vec4 one = vec4(equal(a, b));\n // return one + (vec4(1.0) - one) * a / b;\n vec4 result = a / b;\n if(a.x == b.x) {\n result.x = 1.;\n }\n if(a.y == b.y) {\n result.y = 1.;\n }\n if(a.z == b.z) {\n result.z = 1.;\n }\n if(a.w == b.w) {\n result.w = 1.;\n }\n\n return result;\n","float32",!0);var n=new xa("\nif (a == b) {\n return 1.0;\n};\nreturn a / b;",e.shape,t.shape);return this.compileAndRun(n,[e,t],"float32")},t.prototype.floorDiv=function(e,t){if(Y().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(e,t,"\n ivec4 ia = round(a);\n ivec4 ib = round(b);\n bvec4 cond = notEqual(ib, ivec4(0));\n ivec4 result = ivec4(0);\n vec4 s = sign(a) * sign(b);\n\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n if (cond[0]) {\n result[0] = idiv(ia[0], ib[0], s[0]);\n }\n if (cond[1]) {\n result[1] = idiv(ia[1], ib[1], s[1]);\n }\n if (cond[2]) {\n result[2] = idiv(ia[2], ib[2], s[2]);\n }\n if (cond[3]) {\n result[3] = idiv(ia[3], ib[3], s[3]);\n }\n return vec4(result);\n","int32");var n=new xa("\n float s = sign(a) * sign(b);\n int ia = round(a);\n int ib = round(b);\n if (ib != 0) {\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n return float(idiv(ia, ib, s));\n } else {\n return NAN;\n }\n",e.shape,t.shape);return this.compileAndRun(n,[e,t],"int32")},t.prototype.add=function(e,t){if("complex64"===e.dtype&&"complex64"===t.dtype)return this.complexSeparableBinaryOp(e,t,ga);if(this.shouldExecuteOnCPU([e,t]))return this.cpuBackend.add(e,t);var n=ut(e.dtype,t.dtype);if(Y().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(e,t,ga,n);var r=new xa(ga,e.shape,t.shape);return this.compileAndRun(r,[e,t],n)},t.prototype.packedUnaryOp=function(e,t,n){var r=new ws(e.shape,t);return this.compileAndRun(r,[e],n)},t.prototype.packedBinaryOp=function(e,t,n,r,o){void 0===o&&(o=!1);var a=new _a(n,e.shape,t.shape,o);return this.compileAndRun(a,[e,t],r)},t.prototype.complexSeparableBinaryOp=function(e,t,n){var r=this,o=this.texData.get(e.dataId),a=this.texData.get(t.dataId),i=[[o.complexTensors.real,a.complexTensors.real],[o.complexTensors.imag,a.complexTensors.imag]].map((function(o){var a=o[0],i=o[1],s=r.makeComplexComponentTensorInfo(e,a),u=r.makeComplexComponentTensorInfo(t,i),c=new xa(n,e.shape,t.shape);return r.compileAndRun(c,[s,u],ut(a.dtype,i.dtype))})),s=i[0],u=i[1],c=this.complex(s,u);return s.dispose(),u.dispose(),c},t.prototype.makeComplexComponentTensorInfo=function(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}},t.prototype.addN=function(e){if(1===e.length)return e[0];if(e.length>Y().get("WEBGL_MAX_TEXTURES_IN_SHADER")){var t=Math.floor(e.length/2),n=this.addN(e.slice(0,t)),r=this.addN(e.slice(t));return this.addN([n,r])}var o=e.map((function(e){return e.dtype})).reduce((function(e,t){return ut(e,t)})),a=e.map((function(e){return e.shape})),i=Y().getBool("WEBGL_PACK")?new Go(e[0].shape,a):new Uo(e[0].shape,a);return this.compileAndRun(i,e,o)},t.prototype.subtract=function(e,t){if("complex64"===e.dtype&&"complex64"===t.dtype)return this.complexSeparableBinaryOp(e,t,ya);if(this.shouldExecuteOnCPU([e,t]))return this.cpuBackend.subtract(e,t);var n=ut(e.dtype,t.dtype);if(Y().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(e,t,ya,e.dtype);var r=new xa(ya,e.shape,t.shape);return this.compileAndRun(r,[e,t],n)},t.prototype.pow=function(e,t){var n=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new _a("\n // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n vec4 result = multiplier * pow(abs(a), b);\n\n // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n bvec4 isExpZero = equal(b, vec4(0.0));\n result.r = isExpZero.r ? 1.0 : result.r;\n result.g = isExpZero.g ? 1.0 : result.g;\n result.b = isExpZero.b ? 1.0 : result.b;\n result.a = isExpZero.a ? 1.0 : result.a;\n\n vec4 isNaN = vec4(lessThan(a, vec4(0.0))) * vec4(lessThan(floor(b), b));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",e.shape,t.shape):new xa("\nif(a < 0.0 && floor(b) < b){\n return NAN;\n}\nif (b == 0.0) {\n return 1.0;\n}\nreturn (round(mod(b, 2.0)) != 1) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",e.shape,t.shape),r=ut(e.dtype,t.dtype);return this.compileAndRun(n,[e,t],r)},t.prototype.ceil=function(e){if(this.shouldExecuteOnCPU([e]))return this.cpuBackend.ceil(e);if(Y().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,hs,e.dtype);var t=new as(e.shape,hs);return this.compileAndRun(t,[e])},t.prototype.floor=function(e){if(this.shouldExecuteOnCPU([e]))return this.cpuBackend.floor(e);if(Y().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,ps,e.dtype);var t=new as(e.shape,ps);return this.compileAndRun(t,[e])},t.prototype.sign=function(e){var t=new as(e.shape,"\n if (isnan(x)) { return 0.0; }\n return sign(x);\n");return this.compileAndRun(t,[e])},t.prototype.isNaN=function(e){var t=new as(e.shape,"return float(isnan(x));");return this.compileAndRun(t,[e],"bool")},t.prototype.isInf=function(e){var t=new as(e.shape,"return float(isinf(x));");return this.compileAndRun(t,[e],"bool")},t.prototype.isFinite=function(e){var t=new as(e.shape,"return float(!isnan(x) && !isinf(x));");return this.compileAndRun(t,[e],"bool")},t.prototype.round=function(e){var t=new as(e.shape,"\n // OpenGL ES does not support round function.\n // The algorithm is based on banker's rounding.\n float base = floor(x);\n if ((x - base) < 0.5) {\n return floor(x);\n } else if ((x - base) > 0.5) {\n return ceil(x);\n } else {\n if (mod(base, 2.0) == 0.0) {\n return base;\n } else {\n return base + 1.0;\n }\n }\n");return this.compileAndRun(t,[e])},t.prototype.exp=function(e){if(this.shouldExecuteOnCPU([e]))return this.cpuBackend.exp(e);if(Y().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,ds,e.dtype);var t=new as(e.shape,ds);return this.compileAndRun(t,[e])},t.prototype.expm1=function(e){if(this.shouldExecuteOnCPU([e]))return this.cpuBackend.expm1(e);if(Y().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,vs,e.dtype);var t=new as(e.shape,vs);return this.compileAndRun(t,[e])},t.prototype.log=function(e){if(this.shouldExecuteOnCPU([e]))return this.cpuBackend.log(e);if(Y().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,"\n vec4 result = log(x);\n vec4 isNaN = vec4(lessThan(x, vec4(0.0)));\n result.r = isNaN.r == 1.0 ? NAN : result.r;\n result.g = isNaN.g == 1.0 ? NAN : result.g;\n result.b = isNaN.b == 1.0 ? NAN : result.b;\n result.a = isNaN.a == 1.0 ? NAN : result.a;\n\n return result;\n",e.dtype);var t=new as(e.shape,"if (x < 0.0) return NAN;\n return log(x);");return this.compileAndRun(t,[e])},t.prototype.log1p=function(e){var t=new as(e.shape,"return log(1.0 + x);");return this.compileAndRun(t,[e])},t.prototype.sqrt=function(e){var t=new as(e.shape,"return sqrt(x);");return this.compileAndRun(t,[e])},t.prototype.rsqrt=function(e){if(this.shouldExecuteOnCPU([e]))return this.cpuBackend.rsqrt(e);var t=new as(e.shape,"return inversesqrt(x);");return this.compileAndRun(t,[e])},t.prototype.reciprocal=function(e){var t=new as(e.shape,"return 1.0 / x;");return this.compileAndRun(t,[e])},t.prototype.relu=function(e){var t;return t=Y().getBool("WEBGL_PACK")?new ws(e.shape,gs):new as(e.shape,us),this.compileAndRun(t,[e])},t.prototype.relu6=function(e){var t;return t=Y().getBool("WEBGL_PACK")?new ws(e.shape,ys):new as(e.shape,cs),this.compileAndRun(t,[e])},t.prototype.prelu=function(e,t){var n=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new _a(Ea,e.shape,t.shape):new xa(wa,e.shape,t.shape);return this.compileAndRun(n,[e,t])},t.prototype.elu=function(e){if(Y().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,bs,e.dtype);var t=new as(e.shape,ls);return this.compileAndRun(t,[e])},t.prototype.eluDer=function(e,t){var n=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new _a("\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",e.shape,t.shape):new xa("return (b >= 1.0) ? a : a * (b + 1.0);",e.shape,t.shape);return this.compileAndRun(n,[e,t])},t.prototype.selu=function(e){var t=new as(e.shape,"\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = 1.7580993408473768;\n float scale = 1.0507009873554805;\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n");return this.compileAndRun(t,[e])},t.prototype.int=function(e){var t=new as(e.shape,"return float(int(x));");return this.compileAndRun(t,[e],"int32")},t.prototype.clip=function(e,t,n){var r,o=(r=Y().getBool("WEBGL_PACK_CLIP")?new ka(e.shape):new Oa(e.shape)).getCustomSetupFunc(t,n);return this.compileAndRun(r,[e],null,o)},t.prototype.abs=function(e){if(this.shouldExecuteOnCPU([e]))return this.cpuBackend.abs(e);if(Y().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,ss,e.dtype);var t=new as(e.shape,ss);return this.compileAndRun(t,[e])},t.prototype.complexAbs=function(e){var t=this.texData.get(e.dataId),n=new Ca(e.shape),r=[this.makeComplexComponentTensorInfo(e,t.complexTensors.real),this.makeComplexComponentTensorInfo(e,t.complexTensors.imag)];return this.compileAndRun(n,r)},t.prototype.sigmoid=function(e){var t=new as(e.shape,"return 1.0 / (1.0 + exp(-1.0 * x));");return this.compileAndRun(t,[e])},t.prototype.softplus=function(e){var t=new as(e.shape,"\n float epsilon = 1.1920928955078125e-7;\n float threshold = log(epsilon) + 2.0;\n\n bool too_large = x > -threshold;\n bool too_small = x < threshold;\n\n float result;\n float exp_x = exp(x);\n\n if (too_large){\n result = x;\n }\n else if (too_small){\n result = exp_x;\n }\n else{\n result = log(exp_x + 1.0);\n }\n return result;\n");return this.compileAndRun(t,[e])},t.prototype.sin=function(e){var t=new as(e.shape,"if (isnan(x)) return x;\n return sin(x);\n");return this.compileAndRun(t,[e])},t.prototype.cos=function(e){var t=new as(e.shape,"if (isnan(x)) return x;\n return cos(x);\n");return this.compileAndRun(t,[e])},t.prototype.tan=function(e){var t=new as(e.shape,"return tan(x);");return this.compileAndRun(t,[e])},t.prototype.asin=function(e){var t=new as(e.shape,"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n");return this.compileAndRun(t,[e])},t.prototype.acos=function(e){var t=new as(e.shape,"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n");return this.compileAndRun(t,[e])},t.prototype.atan=function(e){var t=new as(e.shape,"if (isnan(x)) return x;\n return atan(x);\n");return this.compileAndRun(t,[e])},t.prototype.atan2=function(e,t){var n=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new _a("\n vec4 result = atan(a, b);\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",e.shape,t.shape):new xa("\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return atan(a, b);\n",e.shape,t.shape);return this.compileAndRun(n,[e,t])},t.prototype.sinh=function(e){var t=new as(e.shape,"\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n");return this.compileAndRun(t,[e])},t.prototype.cosh=function(e){var t=new as(e.shape,"\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n");return this.compileAndRun(t,[e])},t.prototype.tanh=function(e){var t=new as(e.shape,"\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n");return this.compileAndRun(t,[e])},t.prototype.asinh=function(e){var t=new as(e.shape,"if (isnan(x)) return x;return log(x + sqrt(x * x + 1.0));");return this.compileAndRun(t,[e])},t.prototype.acosh=function(e){var t=new as(e.shape,"if (isnan(x)) return x;\n if (x < 1.0) return NAN;\n return log(x + sqrt(x * x - 1.0));");return this.compileAndRun(t,[e])},t.prototype.atanh=function(e){var t=new as(e.shape,"if (isnan(x)) return x;\n if ((x < -1.0) || (x > 1.0)) return NAN;\n return (log(1.0 + x) - log(1.0 - x)) / 2.0;");return this.compileAndRun(t,[e])},t.prototype.erf=function(e){var t=new as(e.shape,'\n // Error function is calculated approximately with elementary function.\n // See "Handbook of Mathematical Functions with Formulas,\n // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n float p = 0.3275911;\n float a1 = 0.254829592;\n float a2 = -0.284496736;\n float a3 = 1.421413741;\n float a4 = -1.453152027;\n float a5 = 1.061405429;\n\n float sign = sign(x);\n x = abs(x);\n float t = 1.0 / (1.0 + p * x);\n return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n');return this.compileAndRun(t,[e])},t.prototype.step=function(e,t){var n=new as(e.shape,function(e){return void 0===e&&(e=0),is+"\n return x > 0.0 ? 1.0 : float("+e+");\n "}(t));return this.compileAndRun(n,[e])},t.prototype.conv2dByMatMul=function(e,t,n,r,o,a){var i=e.shape,s=this.texData.get(e.dataId),u=n.inChannels,c=i[0]*i[1]*i[2],l=n.outChannels,f="channelsLast"===n.dataFormat,h=(1===c||1===l)&&u>1e3,p=i[2]%2!=0&&!!s.isPacked;if(h||!Y().getBool("WEBGL_LAZILY_UNPACK")||!Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")||!p){var d=f?i[0]*i[1]*i[2]:i[0]*i[2]*i[3],v=this.reshape(e,[1,d,n.inChannels]),m=this.reshape(t,[1,n.inChannels,n.outChannels]);return this.reshape(this.fusedBatchMatMul({a:v,b:m,transposeA:!1,transposeB:!1,bias:r,activation:o,preluActivationWeights:a}),n.outShape)}var g=f?i[0]*i[1]*(i[2]+1):i[0]*i[2]*(i[3]+1),y={dataId:e.dataId,shape:[1,g,n.inChannels],dtype:e.dtype},b=s.shape;s.shape=s.shape.slice(),s.shape[s.shape.length-2]++,ue(ln(s.shape,y.shape),(function(){return"packed reshape "+s.shape+" to "+y.shape+" isn't free"}));var w=this.reshape(t,[1,n.inChannels,n.outChannels]),x=this.fusedBatchMatMul({a:y,b:w,transposeA:!1,transposeB:!1,bias:r,activation:o,preluActivationWeights:a}),E=this.texData.get(x.dataId);return ue(E.isPacked,(function(){return"batchMatMul result is expected to be packed"})),s.shape=b,E.shape=n.outShape,mt.makeTensorFromDataId(x.dataId,n.outShape,x.dtype)},t.prototype.conv2dWithIm2Row=function(e,t,n,r,o,a){var i=n.filterWidth,s=n.filterHeight,u=n.inChannels,c=n.outWidth,l=n.outHeight,f="channelsLast"===n.dataFormat,h=i*s*u,p=l*c,d=[h,p],v=e.squeeze([0]),m=t.reshape([1,h,-1]),g=new xi(d,v.shape,n),y=this.compileAndRun(g,[v]).reshape([1,d[0],d[1]]),b=null!=r,w=null!=a,x=o?_s(o,!0):null,E=new Ii(y.shape,[1,p,n.outChannels],!0,!1,b,x,w),_=[y,m];r&&_.push(r),w&&_.push(a);var O=this.compileAndRun(E,_);return f?O.reshape([1,l,c,n.outChannels]):O.reshape([1,n.outChannels,l,c])},t.prototype.fusedConv2d=function(e){var t=e.input,n=e.filter,r=e.convInfo,o=e.bias,a=e.activation,i=e.preluActivationWeights;if(1===r.filterHeight&&1===r.filterWidth&&1===r.dilationHeight&&1===r.dilationWidth&&1===r.strideHeight&&1===r.strideWidth&&("SAME"===r.padInfo.type||"VALID"===r.padInfo.type))return this.conv2dByMatMul(t,n,r,o,a,i);if(Y().getBool("WEBGL_CONV_IM2COL")&&1===t.shape[0])return this.conv2dWithIm2Row(t,n,r,o,a,i);var s=null!=o,u=null!=i,c=a?_s(a,!1):null,l=new Fa(r,s,c,u),f=[t,n];return o&&f.push(o),i&&f.push(i),this.compileAndRun(l,f)},t.prototype.conv2d=function(e,t,n){if(1===n.filterHeight&&1===n.filterWidth&&1===n.dilationHeight&&1===n.dilationWidth&&1===n.strideHeight&&1===n.strideWidth&&("SAME"===n.padInfo.type||"VALID"===n.padInfo.type))return this.conv2dByMatMul(e,t,n);if(Y().getBool("WEBGL_CONV_IM2COL")&&1===e.shape[0])return this.conv2dWithIm2Row(e,t,n);var r=new Fa(n);return this.compileAndRun(r,[e,t])},t.prototype.conv2dDerInput=function(e,t,n){var r=new Pa(n);return this.compileAndRun(r,[e,t])},t.prototype.conv2dDerFilter=function(e,t,n){var r=new Aa(n);return this.compileAndRun(r,[e,t])},t.prototype.fusedDepthwiseConv2D=function(e){var t,n=e.input,r=e.filter,o=e.convInfo,a=e.bias,i=e.activation,s=e.preluActivationWeights,u=Y().getBool("WEBGL_PACK_DEPTHWISECONV")&&o.strideWidth<=2&&o.outChannels/o.inChannels==1,c=i?_s(i,u):null,l=[n,r],f=null!=a,h=null!=s;return f&&l.push(a),h&&l.push(s),u?(t=new La(o,f,c,h),this.compileAndRun(t,l)):(t=new ja(o,f,c,h),this.compileAndRun(t,l))},t.prototype.depthwiseConv2D=function(e,t,n){var r;return Y().getBool("WEBGL_PACK_DEPTHWISECONV")&&n.strideWidth<=2&&n.outChannels/n.inChannels==1?(r=new La(n),this.compileAndRun(r,[e,t])):(r=new ja(n),this.compileAndRun(r,[e,t]))},t.prototype.depthwiseConv2DDerInput=function(e,t,n){var r=new Na(n);return this.compileAndRun(r,[e,t])},t.prototype.depthwiseConv2DDerFilter=function(e,t,n){var r=new Ma(n);return this.compileAndRun(r,[e,t])},t.prototype.conv3d=function(e,t,n){var r=new Ba(n);return this.compileAndRun(r,[e,t])},t.prototype.conv3dDerInput=function(e,t,n){var r=new Da(n);return this.compileAndRun(r,[e,t])},t.prototype.conv3dDerFilter=function(e,t,n){var r=new Ta(n);return this.compileAndRun(r,[e,t])},t.prototype.maxPool=function(e,t){var n=new Di(t,"max",!1);return this.compileAndRun(n,[e])},t.prototype.avgPool=function(e,t){var n=new Di(t,"avg",!1);return this.compileAndRun(n,[e],"float32")},t.prototype.maxPoolBackprop=function(e,t,n,r){var o=new Di(r,"max",!0),a=this.compileAndRun(o,[t]),i=new ki(r),s=this.compileAndRun(i,[e,a],t.dtype);return a.dispose(),s},t.prototype.avgPoolBackprop=function(e,t,n){var r=new ha(n);return this.compileAndRun(r,[e],t.dtype)},t.prototype.cast=function(e,t){return Po(e,t,this)},t.prototype.unstack=function(e,t){for(var n=e.shape[t],r=new Array(e.rank-1),o=0,a=0;a<e.rank;a++)a!==t&&(r[o++]=e.shape[a]);var i=new Array(e.rank).fill(0),s=e.shape.slice();s[t]=1;var u=new Array(n);for(a=0;a<u.length;a++)i[t]=a,u[a]=this.slice(e,i,s).reshape(r);return u},t.prototype.avgPool3d=function(e,t){var n=new Mi(t,"avg",!1);return this.compileAndRun(n,[e],"float32")},t.prototype.avgPool3dBackprop=function(e,t,n){var r=new pa(n);return this.compileAndRun(r,[e],t.dtype)},t.prototype.maxPool3d=function(e,t){var n=new Mi(t,"max",!1);return this.compileAndRun(n,[e],"float32")},t.prototype.maxPool3dBackprop=function(e,t,n,r){var o=new Mi(r,"max",!0),a=this.compileAndRun(o,[t]),i=new Ci(r),s=this.compileAndRun(i,[e,a],t.dtype);return a.dispose(),s},t.prototype.reshape=function(e,t){var n=this.texData.get(e.dataId);if(n.isPacked&&!ln(e.shape,t)&&(null===n.texture||!ln(n.shape,t))){var r=this.packedReshape(e,t);return mt.makeTensorFromDataId(r.dataId,r.shape,r.dtype)}return To(e,t)},t.prototype.resizeBilinear=function(e,t,n,r){var o=Y().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Li(e.shape,t,n,r):new ji(e.shape,t,n,r);return this.compileAndRun(o,[e],"float32")},t.prototype.resizeBilinearBackprop=function(e,t,n){var r=new Bi(e,t,n);return this.compileAndRun(r,[e])},t.prototype.resizeNearestNeighbor=function(e,t,n,r){var o=new Wi(e.shape,t,n,r);return this.compileAndRun(o,[e])},t.prototype.resizeNearestNeighborBackprop=function(e,t,n){var r=new zi(e,t,n);return this.compileAndRun(r,[e])},t.prototype.multinomial=function(e,t,n,r){var o=t?e:lo(e),a=o.shape[0],i=o.shape[1],s=new Si(a,i,n),u=s.getCustomSetupFunc(r);return this.compileAndRun(s,[o],"int32",u)},t.prototype.oneHot=function(e,t,n,r){var o=new Ri(e.size,t,n,r);return this.compileAndRun(o,[e])},t.prototype.diag=function(e){var t=new qa(e.size);return this.compileAndRun(t,[e])},t.prototype.nonMaxSuppression=function(e,t,n,r,o){return kn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"),jo(e.dataSync(),t.dataSync(),n,r,o)},t.prototype.cropAndResize=function(e,t,n,r,o,a){var i=new za(e.shape,t.shape,r,o,a);return this.compileAndRun(i,[e,t,n],"float32")},t.prototype.depthToSpace=function(e,t,n){ue(t>1,(function(){return"blockSize should be > 1 for depthToSpace, but was: "+t}));var r=e.shape[0],o="NHWC"===n?e.shape[1]:e.shape[2],a="NHWC"===n?e.shape[2]:e.shape[3],i="NHWC"===n?e.shape[3]:e.shape[1],s=o*t,u=a*t,c=i/(t*t),l=new Ga("NHWC"===n?[r,s,u,c]:[r,c,s,u],t,n);return this.compileAndRun(l,[e])},t.prototype.split=function(e,t,n){return zo(e,t,n)},t.prototype.scatterND=function(e,t,n){var r=to(0,e,n),o=r.sliceRank,a=r.numUpdates,i=r.sliceSize,s=r.strides,u=r.outputSize,c=[u/i,i],l=e.reshape([a,o]),f=t.reshape([a,i]);if(0===u)return To(Un([]),n);var h=qn(0),p=new Ui(a,o,l.rank,f.rank,s,c);return this.compileAndRun(p,[f,l,h]).reshape(n)},t.prototype.sparseToDense=function(e,t,n,r){var o=to(0,e,n),a=o.sliceRank,i=o.numUpdates,s=o.strides,u=o.outputSize,c=new Ui(i,a,e.rank,t.rank,s,[u,1],!1);return this.compileAndRun(c,[t,e,r]).reshape(n)},t.prototype.fft=function(e){return this.fftImpl(e,!1)},t.prototype.ifft=function(e){return this.fftImpl(e,!0)},t.prototype.fftImpl=function(e,t){var n=this.texData.get(e.dataId),r=new Ya("return real * expR - imag * expI;",e.shape,t),o=new Ya("return real * expI + imag * expR;",e.shape,t),a=[this.makeComplexComponentTensorInfo(e,n.complexTensors.real),this.makeComplexComponentTensorInfo(e,n.complexTensors.imag)],i=this.compileAndRun(r,a),s=this.compileAndRun(o,a),u=this.complex(i,s).as2D(e.shape[0],e.shape[1]);return i.dispose(),s.dispose(),u},t.prototype.gatherND=function(e,t){var n=t.shape,r=n[n.length-1],o=Qr(e,t),a=o[0],i=o[1],s=o[2],u=o[3],c=t.reshape([i,r]),l=e.reshape([e.size/s,s]),f=new ei(r,u,[i,s]);return this.compileAndRun(f,[l,c]).reshape(a)},t.prototype.fill=function(e,t,n){if("string"===(n=n||De(t))){var r=_e(n,he(e));return r.fill(t),mt.makeTensor(r,e,n,this)}var o=new Ja(e,t),a=o.getCustomSetupFunc(t);return this.compileAndRun(o,[],n,a)},t.prototype.onesLike=function(e){if("string"===e.dtype)throw new Error("onesLike is not supported under string dtype");return this.fill(e.shape,1,e.dtype)},t.prototype.zerosLike=function(e){return this.fill(e.shape,"string"===e.dtype?"":0,e.dtype)},t.prototype.linspace=function(e,t,n){return Do(e,t,n)},t.prototype.makeTensorInfo=function(e,t){var n=this.write(null,e,t);return this.texData.get(n).usage=null,{dataId:n,shape:e,dtype:t}},t.prototype.makeOutput=function(e,t){var n=this.makeTensorInfo(e,t).dataId;return mt.makeTensorFromDataId(n,e,t,this)},t.prototype.unpackTensor=function(e){var t=new xs(e.shape);return this.runWebGLProgram(t,[e],e.dtype)},t.prototype.packTensor=function(e){var t=new Ai(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)},t.prototype.packedReshape=function(e,t){var n=[on(e.shape)].concat(an(e.shape)),r={dtype:e.dtype,shape:n,dataId:e.dataId},o=[on(t)].concat(an(t)),a=new Fi(o,n),i=this.runWebGLProgram(a,[r],e.dtype,null,!0);return{dataId:i.dataId,shape:t,dtype:i.dtype}},t.prototype.decode=function(e){var t,n=this.texData.get(e),r=n.isPacked,o=n.shape,a=n.dtype,i=sn(o);return t=r?new Ua(i):new Ha(i),{dtype:a,shape:o,dataId:this.runWebGLProgram(t,[{shape:i,dtype:a,dataId:e}],a,null,!0).dataId}},t.prototype.runWebGLProgram=function(e,t,n,r,o){var a=this;void 0===o&&(o=!1);var i=this.makeTensorInfo(e.outputShape,n),s=this.texData.get(i.dataId);if(e.packedOutput&&(s.isPacked=!0),e.outPackingScheme===bt.DENSE){var u=It(e.outputShape);s.texShape=u.map((function(e){return 2*e}))}if(null!=e.outTexUsage&&(s.usage=e.outTexUsage),0===he(i.shape))return s.values=Ee(i.dtype,0),i;var c=[],l=t.map((function(t){if("complex64"===t.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");var n=a.texData.get(t.dataId);if(null==n.texture){if(!e.packedInputs&&he(t.shape)<=Y().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:t.shape,texData:null,isUniform:!0,uniformValues:n.values};e.packedInputs&&(n.isPacked=!0,n.shape=t.shape)}else if(!!n.isPacked!=!!e.packedInputs)t=n.isPacked?a.unpackTensor(t):a.packTensor(t),c.push(t),n=a.texData.get(t.dataId);else if(n.isPacked&&!ln(n.shape,t.shape)){var r=t,o=t.shape;t.shape=n.shape,t=a.packedReshape(t,o),c.push(t),n=a.texData.get(t.dataId),r.shape=o}return a.uploadToGPU(t.dataId),{shape:t.shape,texData:n,isUniform:!1}}));this.uploadToGPU(i.dataId);var f,h={shape:i.shape,texData:s,isUniform:!1},p=function(e,t,n){var r="";t.concat(n).forEach((function(e){var t=null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0,n=e.isUniform?"uniform":e.texData.texShape;r+=e.shape+"_"+n+"_"+t}));var o=e.userCode;return e.constructor.name+"_"+r+"_"+o}(e,l,h),d=this.getAndSaveBinary(p,(function(){return function(e,t,n,r){var o=t.userCode,a=n.map((function(e,n){var r={logicalShape:e.shape,texShape:e.isUniform?null:e.texData.texShape,isUniform:e.isUniform,isPacked:!e.isUniform&&e.texData.isPacked,flatOffset:null};return null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0&&(r.flatOffset=e.texData.slice.flatOffset),{name:t.variableNames[n],shapeInfo:r}})),i=a.map((function(e){return e.shapeInfo})),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},u=Qo(a,s,o,t.packedInputs),c=e.createProgram(u),l=null,f=e.getUniformLocation(c,"NAN",!1);1===Y().getNumber("WEBGL_VERSION")&&(l=e.getUniformLocation(c,"INFINITY",!1));for(var h={},p=0;p<t.variableNames.length;p++){var d=t.variableNames[p];h[d]=e.getUniformLocation(c,d,!1),h["offset"+d]=e.getUniformLocation(c,"offset"+d,!1)}return{program:t,source:u,webGLProgram:c,uniformLocations:h,inShapeInfos:i,outShapeInfo:s,infLoc:l,nanLoc:f}}(a.gpgpu,e,l,h)})),v=null!=this.activeTimers;if(v&&(f=this.startTimer()),function(e,t,n,r,o){wi(t.inShapeInfos,n),wi([t.outShapeInfo],[r]);var a=r.texData.texture,i=r.texData.texShape;r.texData.isPacked?e.setOutputPackedMatrixTexture(a,i[0],i[1]):e.setOutputMatrixTexture(a,i[0],i[1]),e.setProgram(t.webGLProgram),1===Y().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach((function(n,r){var o=t.program.variableNames[r],a=t.uniformLocations[o],i=t.uniformLocations["offset"+o];if(null!=a)if(n.isUniform)if(he(n.shape)<2)e.gl.uniform1f(a,n.uniformValues[0]);else{var s=n.uniformValues;s instanceof Float32Array||(s=new Float32Array(s)),e.gl.uniform1fv(a,s)}else null!=n.texData.slice&&null!=i&&e.gl.uniform1i(i,n.texData.slice.flatOffset),e.setInputMatrixTexture(n.texData.texture,a,r)})),null!=o&&o(e,t.webGLProgram),e.executeProgram()}(this.gpgpu,d,l,h,r),c.forEach((function(e){return a.disposeData(e.dataId)})),v&&(f=this.endTimer(f),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(f)})),!Y().getBool("WEBGL_LAZILY_UNPACK")&&s.isPacked&&!1===o){var m=this.unpackTensor(i);return this.disposeData(i.dataId),m}return i},t.prototype.compileAndRun=function(e,t,n,r,o){void 0===o&&(o=!1),n=n||t[0].dtype;var a=this.runWebGLProgram(e,t,n,r,o);return mt.makeTensorFromDataId(a.dataId,a.shape,a.dtype)},t.prototype.getAndSaveBinary=function(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]},t.prototype.getTextureManager=function(){return this.textureManager},t.prototype.dispose=function(){this.disposed||(this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)},t.prototype.floatPrecision=function(){var e=this;return null==this.floatPrecisionValue&&(this.floatPrecisionValue=_n((function(){if(!Y().get("WEBGL_RENDER_FLOAT32_ENABLED")){var t=Y().getBool("DEBUG");Y().set("DEBUG",!1);var n=e.abs(qn(1e-8)).dataSync()[0];if(Y().set("DEBUG",t),n>0)return 32}return 16}))),this.floatPrecisionValue},t.prototype.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4},t.prototype.uploadToGPU=function(e){var t,n=this.texData.get(e),r=n.shape,o=n.dtype,a=n.values,i=n.texture,s=n.usage,u=n.isPacked;if(null==i){var c,l=null!=this.activeTimers;l&&(c=We());var f=n.texShape;if(null==f&&(f=un(r,u),n.texShape=f),null!=a){var h=sn(r),p=void 0,d=f[1],v=f[0],m=a instanceof Uint8Array;u?(d=(t=St(f[0],f[1]))[0],v=t[1],p=new Za(h,[v,d],m)):p=new $a(h,[v,d],m);var g=this.makeTensorInfo([v,d],o);this.texData.get(g.dataId).usage=m?wt.PIXELS:wt.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(g.dataId),d,v,a);var y=this.runWebGLProgram(p,[g],o,null,!0),b=this.texData.get(y.dataId);n.texture=b.texture,n.texShape=b.texShape,n.isPacked=b.isPacked,n.usage=b.usage,this.disposeData(g.dataId),this.texData.delete(y.dataId),n.values=null,l&&(this.uploadWaitMs+=We()-c)}else{var w=this.acquireTexture(f,s,o,u);n.texture=w}}},t.prototype.convertAndCacheOnCPU=function(e,t){var n=this.texData.get(e),r=n.dtype;return this.releaseGPUData(e),null!=t&&(n.values=function(e,t){if("float32"===t||"complex64"===t)return e;if("int32"===t||"bool"===t){for(var n="int32"===t?new Int32Array(e.length):new Uint8Array(e.length),r=0;r<n.length;++r)n[r]=Math.round(e[r]);return n}throw new Error("Unknown dtype "+t)}(t,r)),n.values},t.prototype.acquireTexture=function(e,t,n,r){if(this.numBytesInGPU+=this.computeBytes(e,n),!this.warnedAboutMemory&&this.numBytesInGPU>1024*this.numMBBeforeWarning*1024){var o=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn("High memory usage in GPU: "+o+" MB, most likely due to a memory leak")}return this.textureManager.acquireTexture(e,t,r)},t.prototype.computeBytes=function(e,t){return e[0]*e[1]*Se(t)},t}(po);gt()&&mt.registerBackend("webgl",(function(){return new Os}),2);var ks=zn({square_:function(e){var t=Sn(e,"x","square"),n=[t];return mt.runKernelFunc((function(e,n){return n([t]),e.square(t)}),{x:t},(function(e,t){var n=t[0];return{x:function(){return e.mul(n.toFloat().mul(2))}}}),"Square",{},n,[])}}),Cs=zn({abs_:function(e){var t=Sn(e,"x","abs");return"complex64"===t.dtype?mt.runKernelFunc((function(e){return e.complexAbs(t)}),{$x:t}):mt.runKernelFunc((function(e,n){var r=e.abs(t);return n([t]),r}),{x:t},(function(e,t){var n=t[0];return{x:function(){return e.mul(n.toFloat().step(-1))}}}),"Abs")}}),Is=zn({acos_:function(e){var t=Sn(e,"x","acos");return mt.runKernelFunc((function(e,n){var r=e.acos(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.divStrict(qn(1).sub(n.toFloat().square()).sqrt()).neg()}}}))}}),Ss=zn({acosh_:function(e){var t=Sn(e,"x","acosh");return mt.runKernelFunc((function(e,n){var r=e.acosh(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.divStrict(n.toFloat().square().sub(1).sqrt())}}}))}}),Rs=zn({asin_:function(e){var t=Sn(e,"x","asin");return mt.runKernelFunc((function(e,n){var r=e.asin(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.divStrict(qn(1).sub(n.toFloat().square()).sqrt())}}}))}}),As=zn({asinh_:function(e){var t=Sn(e,"x","asinh");return mt.runKernelFunc((function(e,n){var r=e.asinh(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.divStrict(qn(1).add(n.toFloat().square()).sqrt())}}}))}}),Ps=zn({atan_:function(e){var t=Sn(e,"x","atan");return mt.runKernelFunc((function(e,n){var r=e.atan(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.div(n.toFloat().square().add(1))}}}))}}),Ts=zn({atanh_:function(e){var t=Sn(e,"x","atanh");return mt.runKernelFunc((function(e,n){var r=e.atanh(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.div(qn(1).sub(n.toFloat().square()))}}}))}}),Ds=zn({ceil_:function(e){var t=Sn(e,"x","ceil");return mt.runKernelFunc((function(e){return e.ceil(t)}),{$x:t},(function(e){return{$x:function(){return nr(e)}}}))}}),Ms=zn({clipByValue_:function(e,t,n){var r=Sn(e,"x","clipByValue");ue(t<=n,(function(){return"Error in clip: min ("+t+") must be less than or equal to max ("+n+")."}));var o=[r],a={min:t,max:n};return mt.runKernelFunc((function(e,o){var a=e.clip(r,t,n);return o([r]),a}),{x:r},(function(e,r){var o=r[0];return{x:function(){return e.where(o.greaterEqual(t).logicalAnd(o.lessEqual(n)),nr(e))}}}),"ClipByValue",a,o)}}),Ns=zn({cos_:function(e){var t=Sn(e,"x","cos");return mt.runKernelFunc((function(e,n){var r=e.cos(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return n.toFloat().sin().neg().mul(e)}}}))}}),Fs=zn({cosh_:function(e){var t=Sn(e,"x","cosh");return mt.runKernelFunc((function(e,n){var r=e.cosh(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return n.toFloat().sinh().mulStrict(e)}}}))}}),Bs=zn({erf_:function(e){var t=Sn(e,"x","erf");return ue("int32"===t.dtype||"float32"===t.dtype,(function(){return"Input dtype must be `int32` or `float32`."})),"int32"===t.dtype&&(t=t.toFloat()),mt.runKernelFunc((function(e,n){var r=e.erf(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.mul(n.square().neg().exp().mul(2/Math.sqrt(Math.PI)))}}}))}}),js=zn({exp_:function(e){var t=Sn(e,"x","exp");return mt.runKernelFunc((function(e,n){var r=e.exp(t);return n([r]),r}),{$x:t},(function(e,t){return{$x:function(){return e.mulStrict(t[0])}}}))}}),Ls=zn({expm1_:function(e){var t=Sn(e,"x","expm1");return mt.runKernelFunc((function(e,n){var r=e.expm1(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.mul(n.exp())}}}))}}),zs=zn({floor_:function(e){var t=Sn(e,"x","floor");return mt.runKernelFunc((function(e){return e.floor(t)}),{$x:t},(function(e){return{$x:function(){return nr(e)}}}))}}),Ws=zn({log_:function(e){var t=Sn(e,"x","log");return mt.runKernelFunc((function(e,n){var r=e.log(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.div(n.toFloat())}}}))}}),Vs=zn({log1p_:function(e){var t=Sn(e,"x","log1p");return mt.runKernelFunc((function(e,n){var r=e.log1p(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.div(n.add(1))}}}))}}),Hs=zn({logSigmoid_:function(e){var t=Sn(e,"x","logSigmoid");return mt.runKernelFunc((function(e,n){var r=e.softplus(t.neg()).neg();return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.mul(n.neg().sigmoid())}}}))}}),Us=zn({neg_:function(e){var t=Sn(e,"x","neg");return mt.runKernelFunc((function(e){return e.neg(t)}),{$x:t},(function(e){return{$x:function(){return e.neg()}}}))}}),Gs=zn({reciprocal_:function(e){var t=Sn(e,"x","reciprocal");return mt.runKernelFunc((function(e,n){var r=e.reciprocal(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.div(n.square().neg())}}}))}}),qs=zn({round_:function(e){var t=Sn(e,"x","round");return mt.runKernelFunc((function(e){return e.round(t)}),{$x:t},(function(e){return{$x:function(){return nr(e)}}}))}}),Xs=zn({rsqrt_:function(e){var t=Sn(e,"x","rsqrt");return mt.runKernelFunc((function(e,n){var r=e.rsqrt(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.div(n.pow(1.5).mul(2)).neg()}}}))}}),Ks=zn({sigmoid_:function(e){var t=Sn(e,"x","sigmoid");return mt.runKernelFunc((function(e,n){var r=e.sigmoid(t);return n([r]),r}),{x:t},(function(e,t){var n=t[0];return{x:function(){return e.mul(n.mul(qn(1).sub(n)))}}}),"Sigmoid")}}),$s=zn({sign_:function(e){var t=Sn(e,"x","sign");return mt.runKernelFunc((function(e){return e.sign(t)}),{$x:t},(function(e){return{$x:function(){return nr(e)}}}))}}),Zs=zn({isNaN_:function(e){var t=Sn(e,"x","isNaN");return mt.runKernelFunc((function(e){return e.isNaN(t)}),{$x:t},(function(e){return{$x:function(){return nr(e)}}}))}}),Ys=zn({isInf_:function(e){var t=Sn(e,"x","isInf");return mt.runKernelFunc((function(e){return e.isInf(t)}),{$x:t},(function(e){return{$x:function(){return nr(e)}}}))}}),Js=zn({isFinite_:function(e){var t=Sn(e,"x","isFinite");return mt.runKernelFunc((function(e){return e.isFinite(t)}),{$x:t},(function(e){return{$x:function(){return nr(e)}}}))}}),Qs=zn({sin_:function(e){var t=Sn(e,"x","sin");return mt.runKernelFunc((function(e,n){var r=e.sin(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return n.toFloat().cos().mul(e)}}}))}}),eu=zn({sinh_:function(e){var t=Sn(e,"x","sinh");return mt.runKernelFunc((function(e,n){var r=e.sinh(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return n.toFloat().cosh().mulStrict(e)}}}))}}),tu=zn({softplus_:function(e){var t=Sn(e,"x","softplus");return mt.runKernelFunc((function(e,n){var r=e.softplus(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.mul(n.sigmoid())}}}))}}),nu=zn({sqrt_:function(e){var t=Sn(e,"x","sqrt");return mt.runKernelFunc((function(e,n){var r=e.sqrt(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.div(n.toFloat().sqrt().mul(2))}}}))}}),ru=zn({step_:function(e,t){void 0===t&&(t=0);var n=Sn(e,"x","step");return mt.runKernelFunc((function(e){return e.step(n,t)}),{$x:n},(function(e){return{$x:function(){return nr(e)}}}))}}),ou=zn({tan_:function(e){var t=Sn(e,"x","tan");return mt.runKernelFunc((function(e,n){var r=e.tan(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return e.div(n.cos().square())}}}))}}),au=zn({tanh_:function(e){var t=Sn(e,"x","tanh");return mt.runKernelFunc((function(e,n){var r=e.tanh(t);return n([r]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return qn(1).sub(n.square()).mulStrict(e)}}}))}});function iu(e,t,n,r,o,a){var i,s,u=Sn(e,"x","batchNorm"),c=Sn(t,"mean","batchNorm"),l=Sn(n,"variance","batchNorm");return null!=o&&(i=Sn(o,"scale","batchNorm")),null!=r&&(s=Sn(r,"offset","batchNorm")),ue(2===u.rank,(function(){return"Error in batchNorm3D: x must be rank 3 but got rank "+u.rank+"."})),ue(2===c.rank||1===c.rank,(function(){return"Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank "+c.rank+"."})),ue(2===l.rank||1===l.rank,(function(){return"Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank "+l.rank+"."})),null!=i&&ue(2===i.rank||1===i.rank,(function(){return"Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank "+i.rank+"."})),null!=s&&ue(2===s.rank||1===s.rank,(function(){return"Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank "+s.rank+"."})),cu(u,c,l,s,i,a)}function su(e,t,n,r,o,a){var i,s,u=Sn(e,"x","batchNorm"),c=Sn(t,"mean","batchNorm"),l=Sn(n,"variance","batchNorm");return null!=o&&(i=Sn(o,"scale","batchNorm")),null!=r&&(s=Sn(r,"offset","batchNorm")),ue(3===u.rank,(function(){return"Error in batchNorm3D: x must be rank 3 but got rank "+u.rank+"."})),ue(3===c.rank||1===c.rank,(function(){return"Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank "+c.rank+"."})),ue(3===l.rank||1===l.rank,(function(){return"Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank "+l.rank+"."})),null!=i&&ue(3===i.rank||1===i.rank,(function(){return"Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank "+i.rank+"."})),null!=s&&ue(3===s.rank||1===s.rank,(function(){return"Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank "+s.rank+"."})),cu(u,c,l,s,i,a)}function uu(e,t,n,r,o,a){var i,s,u=Sn(e,"x","batchNorm"),c=Sn(t,"mean","batchNorm"),l=Sn(n,"variance","batchNorm");return null!=o&&(i=Sn(o,"scale","batchNorm")),null!=r&&(s=Sn(r,"offset","batchNorm")),ue(4===u.rank,(function(){return"Error in batchNorm4D: x must be rank 4 but got rank "+u.rank+"."})),ue(4===c.rank||1===c.rank,(function(){return"Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank "+c.rank+"."})),ue(4===l.rank||1===l.rank,(function(){return"Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank "+l.rank+"."})),null!=i&&ue(4===i.rank||1===i.rank,(function(){return"Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank "+i.rank+"."})),null!=s&&ue(4===s.rank||1===s.rank,(function(){return"Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank "+s.rank+"."})),cu(u,c,l,s,i,a)}function cu(e,t,n,r,o,a){null==a&&(a=.001);var i,s,u,c=Sn(e,"x","batchNorm"),l=Sn(t,"mean","batchNorm"),f=Sn(n,"variance","batchNorm");null!=o&&(i=Sn(o,"scale","batchNorm")),null!=r&&(s=Sn(r,"offset","batchNorm")),ue(l.rank===f.rank,(function(){return"Batch normalization gradient requires mean and variance to have equal ranks."})),ue(null==s||l.rank===s.rank,(function(){return"Batch normalization gradient requires mean and offset to have equal ranks."})),ue(null==i||l.rank===i.rank,(function(){return"Batch normalization gradient requires mean and scale to have equal ranks."})),u=0===c.rank||1===c.rank?c.as4D(1,1,1,c.size):2===c.rank?c.as4D(1,1,c.shape[0],c.shape[1]):3===c.rank?c.as4D(1,c.shape[0],c.shape[1],c.shape[2]):c;var h=[c,l,f,i];return mt.runKernelFunc((function(e,t){var n=e.batchNormalization(u,lu(l),lu(f),a,lu(i),lu(s));return t([c,l,f,i]),n}),{x:c,mean:l,variance:f,scale:i,offset:s},(function(e,t){var n=t,r=n[0],o=n[1],i=n[2],s=n[3],c=null==s?qn(1):s,l=go(o.shape,u.shape),f=[];if(1===o.rank){for(var h=0;h<u.shape.length-1;++h)f.push(u.shape[h]);f.push(1)}var p=r.sub(o),d=e.mul(c),v=Xs(i.add(qn(a))),m=v.mul(v).mul(v).mul(qn(-.5));return{x:function(){return 1===o.rank?e.mul(Gr(v.as4D(1,1,1,o.shape[0]),f)).mul(c).reshape(r.shape):e.mul(v).mul(c).reshape(r.shape)},mean:function(){var e=v.mul(qn(-1)).mul(d);return 1===o.rank&&(e=e.sum(l)),e.reshape(o.shape)},variance:function(){var e=m.mul(p).mul(d);return 1===o.rank&&(e=e.sum(l)),e.reshape(o.shape)},scale:function(){var t=p.mul(v),n=e.mul(t);return 1===o.rank&&(n=n.sum(l)),n.reshape(o.shape)},offset:function(){var t=e;return 1===o.rank&&(t=t.sum(l)),t.reshape(o.shape)}}}),"BatchNormalization",{varianceEpsilon:a},h).reshape(c.shape)}function lu(e){return null==e?null:0===e.rank?e.as1D():1===e.rank?e:2===e.rank?e.as4D(1,1,e.shape[0],e.shape[1]):3===e.rank?e.as4D(1,e.shape[0],e.shape[1],e.shape[2]):e}function fu(){En("tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon")}var hu=zn({batchNormalization2d_:function(e,t,n,r,o,a){return void 0===r&&(r=.001),fu(),iu(e,t,n,a,o,r)}}),pu=zn({batchNormalization3d_:function(e,t,n,r,o,a){return void 0===r&&(r=.001),fu(),su(e,t,n,a,o,r)}}),du=zn({batchNormalization4d_:function(e,t,n,r,o,a){return void 0===r&&(r=.001),fu(),uu(e,t,n,a,o,r)}}),vu=zn({batchNormalization_:function(e,t,n,r,o,a){return void 0===r&&(r=.001),fu(),cu(e,t,n,a,o,r)}}),mu=zn({batchNorm_:cu}),gu=zn({batchNorm2d_:iu}),yu=zn({batchNorm3d_:su}),bu=zn({batchNorm4d_:uu}),wu=zn({logicalAnd_:function(e,t){var n=Sn(e,"a","logicalAnd","bool"),r=Sn(t,"b","logicalAnd","bool");return yo(n.shape,r.shape),mt.runKernelFunc((function(e){return e.logicalAnd(n,r)}),{$a:n,$b:r})}}),xu=zn({logicalNot_:function(e){var t=Sn(e,"x","logicalNot","bool");return mt.runKernelFunc((function(e){return e.logicalNot(t)}),{$x:t})}}),Eu=zn({logicalOr_:function(e,t){var n=Sn(e,"a","logicalOr","bool"),r=Sn(t,"b","logicalOr","bool");return yo(n.shape,r.shape),mt.runKernelFunc((function(e){return e.logicalOr(n,r)}),{$a:n,$b:r})}}),_u=zn({logicalXor_:function(e,t){var n=Sn(e,"a","logicalXor","bool"),r=Sn(t,"b","logicalXor","bool");return yo(n.shape,r.shape),Eu(e,t).logicalAnd(wu(e,t).logicalNot())}}),Ou=zn({where_:function(e,t,n){var r=Sn(t,"a","where"),o=Sn(n,"b","where"),a=Sn(e,"condition","where","bool");return ce(r.shape,o.shape,"Error in where: "),1===a.rank?ue(a.shape[0]===r.shape[0],(function(){return"The first dimension of `a` must match the size of `condition`."})):ce(a.shape,o.shape,"Error in where: "),mt.runKernelFunc((function(e,t){var n=e.select(a,r,o);return t([a]),n}),{$condition:a,$a:r,$b:o},(function(e,t){var n=t[0];return{$condition:function(){return nr(n).toFloat()},$a:function(){return e.mul(n.cast(e.dtype))},$b:function(){return e.mul(n.logicalNot().cast(e.dtype))}}}))}}),ku=function(e){return K(this,void 0,void 0,(function(){var t,n,r;return $(this,(function(o){switch(o.label){case 0:return[4,(t=Sn(e,"condition","whereAsync","bool")).data()];case 1:return n=o.sent(),r=Ho(t.shape,n),e!==t&&t.dispose(),[2,r]}}))}))},Cu=zn({add_:function(e,t){var n,r=Sn(e,"a","add"),o=Sn(t,"b","add");n=lt(r,o),r=n[0],o=n[1];var a=yo(r.shape,o.shape);return mt.runKernelFunc((function(e){return e.add(r,o)}),{a:r,b:o},(function(e){return{a:function(){var t=e,n=go(r.shape,a);return n.length>0&&(t=t.sum(n)),t.reshape(r.shape)},b:function(){var t=e,n=go(o.shape,a);return n.length>0&&(t=t.sum(n)),t.reshape(o.shape)}}}),"Add")}}),Iu=zn({addN_:function(e){ue(Array.isArray(e),(function(){return"The argument passed to tf.addN() must be a list of tensors"})),ue(e.length>=1,(function(){return"Must pass at least one tensor to tf.addN(), but got "+e.length}));var t=e.map((function(e,t){return Sn(e,"tensors"+t,"addN")})),n=t[0];t.forEach((function(e){if(e.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),t.forEach((function(e){if(!pe(e.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));var r=t;return mt.runKernelFunc((function(e){return e.addN(t)}),r,(function(e){var n={};return t.forEach((function(t,r){n[r]=function(){return e.clone()}})),n}),"AddN")}}),Su=zn({addStrict_:function(e,t){var n=Sn(e,"a","addStrict"),r=Sn(t,"b","addStrict");return ce(n.shape,r.shape,"Error in addStrict: "),n.add(r)}}),Ru=zn({atan2_:function(e,t){var n,r=Sn(e,"a","atan2"),o=Sn(t,"b","atan2");n=lt(r,o),r=n[0],o=n[1];var a=yo(r.shape,o.shape);return mt.runKernelFunc((function(e,t){var n=e.atan2(r,o);return t([r,o]),n}),{$a:r,$b:o},(function(e,t){var n=t[0],r=t[1];return{$a:function(){var t=Cu(n.square(),r.square()),o=e.mul(r.div(t)),i=go(n.shape,a);return i.length>0&&(o=o.sum(i)),o.reshape(n.shape)},$b:function(){var t=Cu(n.square(),r.square()),o=Us(e.mul(n.div(t))),i=go(r.shape,a);return i.length>0&&(o=o.sum(i)),o.reshape(r.shape)}}}))}}),Au=zn({div_:function(e,t){var n,r=Sn(e,"a","div"),o=Sn(t,"b","div");if(n=lt(r,o),r=n[0],o=n[1],"int32"===r.dtype&&"int32"===o.dtype)return Du(r,o);var a=yo(r.shape,o.shape);return mt.runKernelFunc((function(e,t){var n=e.realDivide(r,o);return t([r,o]),n}),{a:r,b:o},(function(e,t){var n=t[0],r=t[1];return{a:function(){var t=e.div(r.toFloat()),o=go(n.shape,a);return o.length>0?t.sum(o).reshape(n.shape):t},b:function(){var t=e.mul(n.toFloat()),o=go(r.shape,a);o.length>0&&(t=t.sum(o).reshape(r.shape));var i=r.square();return t.div(i.toFloat()).neg()}}}),"Div")}}),Pu=zn({divNoNan_:function(e,t){var n,r=Sn(e,"a","div"),o=Sn(t,"b","div");r=(n=lt(r,o))[0],o=n[1];var a=Au(r,o),i=nr(a),s=o.equal(i);return Ou(s,i,a)}}),Tu=zn({divStrict_:function(e,t){var n=Sn(e,"a","div"),r=Sn(t,"b","div");return ce(n.shape,r.shape,"Error in divideStrict: "),n.div(r)}}),Du=zn({floorDiv_:function(e,t){var n,r=Sn(e,"a","floorDiv"),o=Sn(t,"b","floorDiv");n=lt(r,o),r=n[0],o=n[1];var a=yo(r.shape,o.shape);return mt.runKernelFunc((function(e,t){var n=e.floorDiv(r,o);return t([r,o]),n}),{a:r,b:o},(function(e,t){var n=t[0],r=t[1];return{a:function(){var t=e.div(r.toFloat()),o=go(n.shape,a);return o.length>0?t.sum(o).reshape(n.shape):t},b:function(){var t=e.mul(n.toFloat()),o=go(r.shape,a);o.length>0&&(t=t.sum(o).reshape(r.shape));var i=r.square();return t.div(i.toFloat()).neg()}}}),"FloorDiv")}}),Mu=zn({maximum_:function(e,t){var n,r=Sn(e,"a","maximum"),o=Sn(t,"b","maximum");return n=lt(r,o),r=n[0],o=n[1],"bool"===r.dtype&&(r=r.toInt(),o=o.toInt()),yo(r.shape,o.shape),mt.runKernelFunc((function(e,t){var n=e.maximum(r,o);return t([r,o]),n}),{$a:r,$b:o},(function(e,t){var n=t[0],r=t[1];return{$a:function(){return e.mul(n.greaterEqual(r).toFloat())},$b:function(){return e.mul(n.less(r).toFloat())}}}))}}),Nu=zn({maximumStrict_:function(e,t){var n=Sn(e,"a","maximumStrict"),r=Sn(t,"b","maximumStrict");return ce(n.shape,r.shape,"Error in maximumStrict: "),n.maximum(r)}}),Fu=zn({minimum_:function(e,t){var n,r=Sn(e,"a","minimum"),o=Sn(t,"b","minimum");return n=lt(r,o),r=n[0],o=n[1],"bool"===r.dtype&&(r=r.toInt(),o=o.toInt()),yo(r.shape,o.shape),mt.runKernelFunc((function(e,t){var n=e.minimum(r,o);return t([r,o]),n}),{$a:r,$b:o},(function(e,t){var n=t[0],r=t[1];return{$a:function(){return e.mul(n.lessEqual(r).toFloat())},$b:function(){return e.mul(n.greater(r).toFloat())}}}))}}),Bu=zn({minimumStrict_:function(e,t){var n=Sn(e,"a","minimumStrict"),r=Sn(t,"b","minimumStrict");return ce(n.shape,r.shape,"Error in minimumStrict: "),n.minimum(r)}}),ju=zn({mod_:function(e,t){var n,r=Sn(e,"a","mod"),o=Sn(t,"b","mod");n=lt(r,o),r=n[0],o=n[1];var a=yo(r.shape,o.shape);return mt.runKernelFunc((function(e,t){var n=e.mod(r,o);return t([r,o]),n}),{$a:r,$b:o},(function(e,t){var n=t[0],r=t[1];return{$a:function(){var t=go(n.shape,a);return t.length>0?e.sum(t).reshape(n.shape):e},$b:function(){var t=e.mul(n.div(r).floor().neg()),o=go(r.shape,a);return o.length>0?t.sum(o).reshape(r.shape):t}}}))}}),Lu=zn({modStrict_:function(e,t){var n=Sn(e,"a","modStrict"),r=Sn(t,"b","modStrict");return ce(n.shape,r.shape,"Error in modStrict: "),n.mod(r)}}),zu=zn({mul_:function(e,t){var n,r=Sn(e,"a","mul"),o=Sn(t,"b","mul");n=lt(r,o),r=n[0],o=n[1];var a=yo(r.shape,o.shape);return mt.runKernelFunc((function(e,t){var n=e.multiply(r,o);return t([r,o]),n}),{a:r,b:o},(function(e,t){var n=t[0],r=t[1];return{a:function(){var t=e.mul(r.toFloat()),o=go(n.shape,a);return o.length>0?t.sum(o).reshape(n.shape):t},b:function(){var t=e.mul(n.toFloat()),o=go(r.shape,a);return o.length>0?t.sum(o).reshape(r.shape):t}}}),"Mul")}}),Wu=zn({mulStrict_:function(e,t){var n=Sn(e,"a","mul"),r=Sn(t,"b","mul");return ce(n.shape,r.shape,"Error in multiplyStrict: "),n.mul(r)}}),Vu=zn({pow_:function(e,t){var n=Sn(e,"base","pow"),r=Sn(t,"exp","pow"),o=yo(n.shape,r.shape);return e=n.cast(ut(n.dtype,r.dtype)),t=r.cast(ut(n.dtype,r.dtype)),mt.runKernelFunc((function(e,t){var o=e.pow(n,r);return t([n,r,o]),o}),{$base:n,$exp:r},(function(e,t){var n=t[0],r=t[1],a=t[2];return{$base:function(){var t=r.toFloat(),a=e.mul(t.mul(n.pow(t.sub(qn(1))))),i=go(n.shape,o);return i.length>0&&(a=a.sum(i)),a.reshape(n.shape)},$exp:function(){var t=n.greater(0),i=n.log().where(t,nr(n)),s=e.mul(a.mul(i)),u=go(r.shape,o);return u.length>0&&(s=s.sum(u)),s.reshape(r.shape)}}}))}}),Hu=zn({powStrict_:function(e,t){return ce(e.shape,t.shape,"Error in powStrict: "),e.pow(t)}}),Uu=zn({squaredDifference_:function(e,t){var n,r=Sn(e,"a","squaredDifference"),o=Sn(t,"b","squaredDifference");return n=lt(r,o),r=n[0],o=n[1],yo(r.shape,o.shape),mt.runKernelFunc((function(e,t){var n=e.squaredDifference(r,o);return t([r,o]),n}),{$a:r,$b:o},(function(e,t){var n=t[0],r=t[1],o=qn(2);return{$a:function(){return e.mul(n.sub(r).mul(o))},$b:function(){return e.mul(r.sub(n).mul(o))}}}))}}),Gu=zn({squaredDifferenceStrict_:function(e,t){var n=Sn(e,"a","squaredDifferenceStrict"),r=Sn(t,"b","squaredDifferenceStrict");return ce(n.shape,r.shape,"Error in squaredDifferenceStrict: "),n.squaredDifference(r)}}),qu=zn({sub_:function(e,t){var n,r=Sn(e,"a","sub"),o=Sn(t,"b","sub");n=lt(r,o),r=n[0],o=n[1];var a=yo(r.shape,o.shape);return mt.runKernelFunc((function(e){return e.subtract(r,o)}),{a:r,b:o},(function(e){return{a:function(){var t=e,n=go(r.shape,a);return n.length>0&&(t=t.sum(n)),t.reshape(r.shape)},b:function(){var t=e,n=go(o.shape,a);return n.length>0&&(t=t.sum(n)),t.neg().reshape(o.shape)}}}),"Sub")}}),Xu=zn({subStrict_:function(e,t){var n=Sn(e,"a","subStrict"),r=Sn(t,"b","subStrict");return ce(n.shape,r.shape,"Error in subStrict: "),n.sub(r)}}),Ku=zn({equal_:function(e,t){var n,r=Sn(e,"a","equal"),o=Sn(t,"b","equal");return n=lt(r,o),r=n[0],o=n[1],yo(r.shape,o.shape),mt.runKernelFunc((function(e){return e.equal(r,o)}),{$a:r,$b:o})}}),$u=zn({equalStrict_:function(e,t){var n=Sn(e,"a","equalStrict"),r=Sn(t,"b","equalStrict");return ce(n.shape,r.shape,"Error in equalStrict: "),n.equal(r)}}),Zu=zn({greater_:function(e,t){var n,r=Sn(e,"a","greater"),o=Sn(t,"b","greater");return n=lt(r,o),r=n[0],o=n[1],yo(r.shape,o.shape),mt.runKernelFunc((function(e){return e.greater(r,o)}),{$a:r,$b:o})}}),Yu=zn({greaterEqual_:function(e,t){var n,r=Sn(e,"a","greaterEqual"),o=Sn(t,"b","greaterEqual");return n=lt(r,o),r=n[0],o=n[1],yo(r.shape,o.shape),mt.runKernelFunc((function(e,t){var n=e.greaterEqual(r,o);return t([r,o]),n}),{$a:r,$b:o},(function(e,t){var n=t[0],r=t[1];return{$a:function(){return nr(n)},$b:function(){return nr(r)}}}))}}),Ju=zn({greaterEqualStrict_:function(e,t){var n=Sn(e,"a","greaterEqualStrict"),r=Sn(t,"b","greaterEqualStrict");return ce(n.shape,r.shape,"Error in greaterEqualStrict: "),n.greaterEqual(r)}}),Qu=zn({greaterStrict_:function(e,t){var n=Sn(e,"a","greaterStrict"),r=Sn(t,"b","greaterStrict");return ce(n.shape,r.shape,"Error in greaterStrict: "),n.greater(r)}}),ec=zn({less_:function(e,t){var n,r=Sn(e,"a","less"),o=Sn(t,"b","less");return n=lt(r,o),r=n[0],o=n[1],yo(r.shape,o.shape),mt.runKernelFunc((function(e){return e.less(r,o)}),{$a:r,$b:o})}}),tc=zn({lessEqual_:function(e,t){var n,r=Sn(e,"a","lessEqual"),o=Sn(t,"b","lessEqual");return n=lt(r,o),r=n[0],o=n[1],yo(r.shape,o.shape),mt.runKernelFunc((function(e){return e.lessEqual(r,o)}),{$a:r,$b:o})}}),nc=zn({lessEqualStrict_:function(e,t){var n=Sn(e,"a","lessEqualStrict"),r=Sn(t,"b","lessEqualStrict");return ce(n.shape,r.shape,"Error in lessEqualStrict: "),n.lessEqual(r)}}),rc=zn({lessStrict_:function(e,t){var n=Sn(e,"a","lessStrict"),r=Sn(t,"b","lessStrict");return ce(n.shape,r.shape,"Error in lessStrict: "),n.less(r)}}),oc=zn({notEqual_:function(e,t){var n,r=Sn(e,"a","notEqual"),o=Sn(t,"b","notEqual");return n=lt(r,o),r=n[0],o=n[1],yo(r.shape,o.shape),mt.runKernelFunc((function(e){return e.notEqual(r,o)}),{$a:r,$b:o})}}),ac=zn({notEqualStrict_:function(e,t){var n=Sn(e,"a","notEqualStrict"),r=Sn(t,"b","notEqualStrict");return ce(n.shape,r.shape,"Error in notEqualStrict: "),n.notEqual(r)}});function ic(e,t){for(var n=[],r=e;r<t;++r)n.push(r);return n}function sc(e){for(var t=[],n=0;n<e.length;++n)for(var r=0;r<e[n].length;++r)t.push(e[n][r]);return t}var uc=zn({gather_:function(e,t,n){void 0===n&&(n=0);var r=Sn(e,"x","gather"),o=Sn(t,"indices","gather","int32");n=we(n,r.shape)[0];var a=function(e,t,n){for(var r=e.shape[n],o=[],a=1,i=1,s=0;s<n;s++)o.push(e.shape[s]),a*=e.shape[s];for(s=0;s<t.rank;s++)o.push(t.shape[s]);for(s=n+1;s<e.rank;s++)o.push(e.shape[s]),i*=e.shape[s];return{batchSize:a,sliceSize:i,dimSize:r,outputShape:o}}(r,o,n);return mt.runKernelFunc((function(e,t){var a=e.gather(r,o.flatten(),n);return t([o]),a}),{$x:r},(function(e,t){var o=t[0];return{$x:function(){var t=r.shape,a=o.size,i=t.slice(0,n),s=i.length,u=t.slice(n,t.length).slice(1),c=u.length,l=ic(0,s),f=ic(s+1,s+1+c),h=sc([i,[a],u]),p=e.reshape(h),d=o.reshape([a]),v=sc([[s],l,f]),m=p.transpose(v),g=cc(m,d,r.shape[n]),y=Fn(v);return g.transpose(y)}}})).reshape(a.outputShape)}}),cc=zn({unsortedSegmentSum_:function(e,t,n){var r=Sn(e,"x","unsortedSegmentSum"),o=Sn(t,"segmentIds","unsortedSegmentSum","int32");return ue(de(n),(function(){return"numSegments must be of dtype int"})),mt.runKernelFunc((function(e,t){var a=e.unsortedSegmentSum(r,o,n);return t([o]),a}),{$x:r},(function(e,t){var n=t[0];return{$x:function(){return function(e,t){for(var n=Mu(t,nr(t)),r=uc(e,n),o=Yu(t,qn(0,"int32")),a=r.rank-o.rank,i=0;i<a;++i)o=Sr(o,i+1);o=wu(o,Yn(r.shape,"bool"));var s=nr(r);return Ou(o,r,s)}(e,n)}}}))}});function lc(e,t,n,r,o,a,i){void 0===a&&(a="NHWC"),ue(e.length===t.rank,(function(){return"Length of inShape ("+e.length+") and rank of dy ("+t.rank+") must match"}));var s=e,u=t,c=!1;3===t.rank&&(c=!0,u=t.as4D(1,t.shape[0],t.shape[1],t.shape[2]),s=[1,e[0],e[1],e[2]]),ue(4===s.length,(function(){return"Error in conv2dDerInput: inShape must be length 4, but got length "+s.length+"."})),ue(4===u.rank,(function(){return"Error in conv2dDerInput: dy must be rank 4, but got rank "+u.rank})),ue(4===n.rank,(function(){return"Error in conv2dDerInput: filter must be rank 4, but got rank "+n.rank}));var l="NHWC"===a?s[3]:s[1],f="NHWC"===a?u.shape[3]:u.shape[1];ue(l===n.shape[2],(function(){return"Error in conv2dDerInput: depth of input ("+l+") must match input depth for filter "+n.shape[2]+"."})),ue(f===n.shape[3],(function(){return"Error in conv2dDerInput: depth of output ("+f+") must match output depth for filter "+n.shape[3]+"."})),null!=i&&ue(de(o),(function(){return"Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+o+"."}));var h=Ao(a),p=xo(s,n.shape,r,1,o,i,!1,h),d=mt.runKernelFunc((function(e,t){var r=e.conv2dDerInput(u,n,p);return t([n,u]),r}),{dy4D:u,filter:n},(function(e,t){var n=t[0],s=t[1];return{dy4D:function(){return dc(e,n,r,o,a,1,i)},filter:function(){return mc(e,s,n.shape,r,o,a,i)}}}));return c?d.as3D(d.shape[1],d.shape[2],d.shape[3]):d}function fc(e){var t=function(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}(e),n=t[0],r=t[1],o=t[2];return 1===n&&1===r&&1===o}function hc(e,t,n,r,o){ue(e.length===t.rank,(function(){return"Length of inShape ("+e.length+") and rank of dy ("+t.rank+") must match"}));var a=e,i=t,s=!1;4===t.rank&&(s=!0,i=t.as5D(1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]),a=[1,e[0],e[1],e[2],e[3]]);var u=a[4],c=i.shape[4];ue(5===a.length,(function(){return"Error in conv3dDerInput: inShape must be length 5, but got length "+a.length+"."})),ue(5===i.rank,(function(){return"Error in conv3dDerInput: dy must be rank 5, but got rank "+i.rank})),ue(5===n.rank,(function(){return"Error in conv3dDerInput: filter must be rank 5, but got rank "+n.rank})),ue(u===n.shape[3],(function(){return"Error in conv3dDerInput: depth of input ("+u+") must match input depth for filter "+n.shape[3]+"."})),ue(c===n.shape[4],(function(){return"Error in conv3dDerInput: depth of output ("+c+") must match output depth for filter "+n.shape[4]+"."}));var l=Eo(a,n.shape,r,1,o),f=mt.runKernelFunc((function(e){return e.conv3dDerInput(i,n,l)}),{dy5D:i});return s?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f}var pc=zn({conv1d_:function(e,t,n,r,o,a,i){void 0===o&&(o="NWC"),void 0===a&&(a=1);var s=Sn(e,"x","conv1d"),u=Sn(t,"filter","conv1d"),c=s,l=!1;2===s.rank&&(l=!0,c=s.as3D(1,s.shape[0],s.shape[1])),ue(3===c.rank,(function(){return"Error in conv1d: input must be rank 3, but got rank "+c.rank+"."})),ue(3===u.rank,(function(){return"Error in conv1d: filter must be rank 3, but got rank "+u.rank+"."})),null!=i&&ue(de(r),(function(){return"Error in conv1d: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+r+"."})),ue(c.shape[2]===u.shape[1],(function(){return"Error in conv1d: depth of input ("+c.shape[2]+") must match input depth for filter "+u.shape[1]+"."})),ue(Ro(n,a),(function(){return"Error in conv1D: Either stride or dilation must be 1. Got stride "+n+" and dilation '"+a+"'"})),ue("NWC"===o,(function(){return"Error in conv1d: got dataFormat of "+o+" but only NWC is currently supported."}));var f=u.as4D(1,u.shape[0],u.shape[1],u.shape[2]),h=c.as4D(c.shape[0],1,c.shape[1],c.shape[2]),p=dc(h,f,[1,n],r,"NHWC",[1,a],i);return l?p.as2D(p.shape[2],p.shape[3]):p.as3D(p.shape[0],p.shape[2],p.shape[3])}}),dc=zn({conv2d_:function(e,t,n,r,o,a,i){void 0===o&&(o="NHWC"),void 0===a&&(a=[1,1]);var s=Sn(e,"x","conv2d"),u=Sn(t,"filter","conv2d"),c=s,l=!1;3===s.rank&&(l=!0,c=s.as4D(1,s.shape[0],s.shape[1],s.shape[2])),ue(4===c.rank,(function(){return"Error in conv2d: input must be rank 4, but got rank "+c.rank+"."})),ue(4===u.rank,(function(){return"Error in conv2d: filter must be rank 4, but got rank "+u.rank+"."})),null!=i&&ue(de(r),(function(){return"Error in conv2d: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+r+"."}));var f="NHWC"===o?c.shape[3]:c.shape[1];ue(f===u.shape[2],(function(){return"Error in conv2d: depth of input ("+f+") must match input depth for filter "+u.shape[2]+"."})),ue(Ro(n,a),(function(){return"Error in conv2D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+a+"'"}));var h=Ao(o),p=xo(c.shape,u.shape,n,a,r,i,!1,h),d=[u,c],v=mt.runKernelFunc((function(e,t){var n=e.conv2d(c,u,p);return t([u,c]),n}),{x:c,filter:u},(function(e,t){var i=t,s=i[0],u=i[1];return ue(So(a),(function(){return"Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+a+"'"})),{x:function(){return gc(u.shape,e,s,n,r,o)},filter:function(){return mc(u,e,s.shape,n,r,o)}}}),"Conv2D",p,d);return l?v.as3D(v.shape[1],v.shape[2],v.shape[3]):v}}),vc=zn({conv3d_:function(e,t,n,r,o,a){void 0===o&&(o="NDHWC"),void 0===a&&(a=[1,1,1]);var i=Sn(e,"x","conv3d"),s=Sn(t,"filter","conv3d"),u=i,c=!1;4===i.rank&&(c=!0,u=i.as5D(1,i.shape[0],i.shape[1],i.shape[2],i.shape[3])),ue(5===u.rank,(function(){return"Error in conv3d: input must be rank 5, but got rank "+u.rank+"."})),ue(5===s.rank,(function(){return"Error in conv3d: filter must be rank 5, but got rank "+s.rank+"."})),ue(u.shape[4]===s.shape[3],(function(){return"Error in conv3d: depth of input ("+u.shape[4]+") must match input depth for filter "+s.shape[3]+"."})),ue(function(e,t){return fc(e)||fc(t)}(n,a),(function(){return"Error in conv3D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+a+"'"})),ue("NDHWC"===o,(function(){return"Error in conv3d: got dataFormat of "+o+" but only NDHWC is currently supported."}));var l=Eo(u.shape,s.shape,n,a,r),f=mt.runKernelFunc((function(e,t){var n=e.conv3d(u,s,l);return t([u,s]),n}),{x:u,$filter:s},(function(e,t){ue(fc(a),(function(){return"Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+a+"'"}));var o=t[0],i=t[1];return{x:function(){return hc(o.shape,e,i,n,r)},$filter:function(){return function(e,t,n,r,o){var a=e;4===e.rank&&(a=e.as5D(1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]));var i=t;4===i.rank&&(i=t.as5D(1,t.shape[0],t.shape[1],t.shape[2],t.shape[3])),ue(5===a.rank,(function(){return"Error in conv3dDerFilter: input must be rank 5, but got shape "+a.shape+"."})),ue(5===i.rank,(function(){return"Error in conv3dDerFilter: dy must be rank 5, but got shape "+i.shape+"."})),ue(5===n.length,(function(){return"Error in conv3dDerFilter: filterShape must be length 5, but got "+n+"."})),ue(a.shape[4]===n[3],(function(){return"Error in conv3dDerFilter: depth of input "+a.shape[4]+") must match input depth in filter ("+n[3]+"."})),ue(i.shape[4]===n[4],(function(){return"Error in conv3dDerFilter: depth of dy ("+i.shape[4]+") must match output depth for filter ("+n[4]+")."}));var s=Eo(a.shape,n,r,1,o);return mt.runKernelFunc((function(e){return e.conv3dDerFilter(a,i,s)}),{x5D:a,dy5D:i})}(o,e,i.shape,n,r)}}}));return c?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f}}),mc=zn({conv2dDerFilter_:function(e,t,n,r,o,a,i){void 0===a&&(a="NHWC");var s=e;3===e.rank&&(s=e.as4D(1,e.shape[0],e.shape[1],e.shape[2]));var u=t;3===u.rank&&(u=t.as4D(1,t.shape[0],t.shape[1],t.shape[2])),ue(4===s.rank,(function(){return"Error in conv2dDerFilter: input must be rank 4, but got shape "+s.shape+"."})),ue(4===u.rank,(function(){return"Error in conv2dDerFilter: dy must be rank 4, but got shape "+u.shape+"."})),ue(4===n.length,(function(){return"Error in conv2dDerFilter: filterShape must be length 4, but got "+n+"."}));var c="NHWC"===a?s.shape[3]:s.shape[1],l="NHWC"===a?u.shape[3]:u.shape[1];ue(c===n[2],(function(){return"Error in conv2dDerFilter: depth of input "+c+") must match input depth in filter ("+n[2]+"."})),ue(l===n[3],(function(){return"Error in conv2dDerFilter: depth of dy ("+l+") must match output depth for filter ("+n[3]+")."})),null!=i&&ue(de(o),(function(){return"Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+o+"."}));var f=Ao(a),h=xo(s.shape,n,r,1,o,i,!1,f);return mt.runKernelFunc((function(e){return e.conv2dDerFilter(s,u,h)}),{x4D:s,dy4D:u})}}),gc=zn({conv2dDerInput_:lc}),yc=zn({depthwiseConv2d_:function(e,t,n,r,o,a,i){void 0===o&&(o="NHWC"),void 0===a&&(a=[1,1]);var s=Sn(e,"x","depthwiseConv2d"),u=Sn(t,"filter","depthwiseConv2d"),c=s,l=!1;3===s.rank&&(l=!0,c=s.as4D(1,s.shape[0],s.shape[1],s.shape[2])),ue(4===c.rank,(function(){return"Error in depthwiseConv2d: input must be rank 4, but got rank "+c.rank+"."})),ue(4===u.rank,(function(){return"Error in depthwiseConv2d: filter must be rank 4, but got rank "+u.rank+"."})),ue(c.shape[3]===u.shape[2],(function(){return"Error in depthwiseConv2d: number of input channels ("+c.shape[3]+") must match the inChannels dimension in filter "+u.shape[2]+"."})),null==a&&(a=[1,1]),ue(Ro(n,a),(function(){return"Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+a+"'"})),null!=i&&ue(de(r),(function(){return"Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+r+"."}));var f=xo(c.shape,u.shape,n,a,r,i,!0),h=[c,u],p=mt.runKernelFunc((function(e,t){var n=e.depthwiseConv2D(c,u,f);return t([c,u]),n}),{x:c,filter:u},(function(e,t){ue(So(a),(function(){return"Error in gradient of depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '"+a+"'"}));var n=t[0],r=t[1];return{x:function(){return bc(n.shape,e,r,f)},filter:function(){return wc(n,e,r.shape,f)}}}),"DepthwiseConv2dNative",f,h);return l?p.as3D(p.shape[1],p.shape[2],p.shape[3]):p}}),bc=zn({depthwiseConv2dDerInput_:function(e,t,n,r){var o=t,a=!1;3===t.rank&&(a=!0,o=t.as4D(1,t.shape[0],t.shape[1],t.shape[2]));var i=mt.runKernelFunc((function(e){return e.depthwiseConv2DDerInput(o,n,r)}),{dy4D:o});return a?i.as3D(i.shape[1],i.shape[2],i.shape[3]):i}}),wc=zn({depthwiseConv2dDerFilter_:function(e,t,n,r){var o=e;3===e.rank&&(o=e.as4D(1,e.shape[0],e.shape[1],e.shape[2]));var a=t;return 3===a.rank&&(a=t.as4D(1,t.shape[0],t.shape[1],t.shape[2])),mt.runKernelFunc((function(e){return e.depthwiseConv2DDerFilter(o,a,r)}),{x4D:o,dy4D:a})}}),xc=zn({separableConv2d_:function(e,t,n,r,o,a,i){void 0===a&&(a=[1,1]),void 0===i&&(i="NHWC");var s=Sn(e,"x","separableConv2d"),u=Sn(t,"depthwiseFilter","separableConv2d"),c=Sn(n,"pointwiseFilter","separableConv2d"),l=s,f=!1;if(3===s.rank&&(f=!0,l=s.as4D(1,s.shape[0],s.shape[1],s.shape[2])),"NCHW"===i)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");ue(4===l.rank,(function(){return"Error in separableConv2d: input must be rank 4, but got rank "+l.rank+"."})),ue(4===u.rank,(function(){return"Error in separableConv2d: depthwise filter must be rank 4, but got rank "+u.rank+"."})),ue(4===c.rank,(function(){return"Error in separableConv2d: pointwise filter must be rank 4, but got rank "+u.rank+"."})),ue(1===c.shape[0],(function(){return"Error in separableConv2d: the first dimension of pointwise filter must be 1, but got "+c.shape[0]+"."})),ue(1===c.shape[1],(function(){return"Error in separableConv2d: the second dimension of pointwise filter must be 1, but got "+c.shape[1]+"."}));var h=u.shape[2],p=u.shape[3];ue(c.shape[2]===h*p,(function(){return"Error in separableConv2d: the third dimension of pointwise filter must be "+h*p+", but got "+c.shape[2]+"."}));var d=yc(l,u,r,o,i,a),v=dc(d,c,1,"valid",i);return f?v.as3D(v.shape[1],v.shape[2],v.shape[3]):v}}),Ec=zn({conv2dTranspose_:function(e,t,n,r,o,a){return lc(n,Sn(e,"x","conv2dTranspose"),Sn(t,"filter","conv2dTranspose"),r,o,"NHWC",a)}}),_c=zn({conv3dTranspose_:function(e,t,n,r,o){return hc(n,Sn(e,"x","conv3dTranspose"),Sn(t,"filter","conv3dTranspose"),r,o)}}),Oc=zn({matMul_:function(e,t,n,r){var o;void 0===n&&(n=!1),void 0===r&&(r=!1);var a=Sn(e,"a","matMul"),i=Sn(t,"b","matMul");o=lt(a,i),a=o[0],i=o[1];var s=n?a.shape[a.rank-2]:a.shape[a.rank-1],u=r?i.shape[i.rank-1]:i.shape[i.rank-2],c=n?a.shape[a.rank-1]:a.shape[a.rank-2],l=r?i.shape[i.rank-2]:i.shape[i.rank-1],f=a.shape.slice(0,-2),h=i.shape.slice(0,-2),p=he(f),d=he(h);ue(a.rank>=2&&i.rank>=2&&a.rank===i.rank,(function(){return"Error in matMul: inputs must have the same rank of at least 2, got ranks "+a.rank+" and "+i.rank+"."})),ue(pe(f,h),(function(){return"Error in matMul: outer dimensions ("+f+") and ("+h+") of Tensors with shapes "+a.shape+" and "+i.shape+" must match."})),ue(s===u,(function(){return"Error in matMul: inner shapes ("+s+") and ("+u+") of Tensors with shapes "+a.shape+" and "+i.shape+" and transposeA="+n+" and transposeB="+r+" must match."}));var v=a.shape.slice(0,-2).concat([c,l]),m=n?a.as3D(p,s,c):a.as3D(p,c,s),g=r?i.as3D(d,l,u):i.as3D(d,u,l),y={transposeA:n,transposeB:r};return mt.runKernelFunc((function(e,t){var o=e.batchMatMul(m,g,n,r);return t([m,g]),o}),{a:m,b:g},(function(e,t){var o=t,a=o[0],i=o[1];return n||r?!n&&r?{a:function(){return e.matMul(i,!1,!1)},b:function(){return e.matMul(a,!0,!1)}}:n&&!r?{a:function(){return i.matMul(e,!1,!0)},b:function(){return a.matMul(e,!1,!1)}}:{a:function(){return i.matMul(e,!0,!0)},b:function(){return e.matMul(a,!0,!0)}}:{a:function(){return e.matMul(i,!1,!0)},b:function(){return a.matMul(e,!0,!1)}}}),"BatchMatMul",y).reshape(v)}}),kc=zn({dot_:function(e,t){var n=Sn(e,"t1","dot"),r=Sn(t,"t2","dot");ue(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),(function(){return"Error in dot: inputs must all be rank 1 or 2, but got ranks "+n.rank+" and "+r.rank+"."}));var o=1===n.rank?n.size:n.shape[1],a=1===r.rank?r.size:r.shape[0];return ue(o===a,(function(){return"Error in dot: inner dimensions of inputs must match, but got "+o+" and "+a+"."})),1===n.rank&&1===r.rank?n.as2D(1,-1).matMul(r.as2D(-1,1)).asScalar():1===n.rank&&2===r.rank?n.as2D(1,-1).matMul(r.as2D(r.shape[0],r.shape[1])).as1D():2===n.rank&&1===r.rank?n.matMul(r.as2D(-1,1)).as1D():n.matMul(r.as2D(r.shape[0],r.shape[1]))}}),Cc=zn({outerProduct_:function(e,t){var n=Sn(e,"v1","outerProduct"),r=Sn(t,"v2","outerProduct");return ue(1===n.rank&&1===r.rank,(function(){return"Error in outerProduct: inputs must be rank 1, but got ranks "+n.rank+" and "+r.rank+"."})),n.as2D(-1,1).matMul(r.as2D(1,-1))}}),Ic=zn({reverse_:function(e,t){var n=Sn(e,"x","reverse");if(0===n.rank)return n.clone();var r=we(t,n.shape);return mt.runKernelFunc((function(e){return e.reverse(n,r)}),{$x:n},(function(e){return{$x:function(){return e.reverse(r)}}})).reshapeAs(n)}}),Sc=zn({reverse1d_:function(e){var t=Sn(e,"x","reverse");return ue(1===t.rank,(function(){return"Error in reverse1D: x must be rank 1 but got rank "+t.rank+"."})),Ic(t,0)}}),Rc=zn({reverse2d_:function(e,t){var n=Sn(e,"x","reverse");return ue(2===n.rank,(function(){return"Error in reverse2D: x must be rank 2 but got rank "+n.rank+"."})),Ic(n,t)}}),Ac=zn({reverse3d_:function(e,t){var n=Sn(e,"x","reverse");return ue(3===n.rank,(function(){return"Error in reverse3D: x must be rank 3 but got rank "+n.rank+"."})),Ic(n,t)}}),Pc=zn({reverse4d_:function(e,t){var n=Sn(e,"x","reverse");return ue(4===n.rank,(function(){return"Error in reverse4D: x must be rank 4 but got rank "+n.rank+"."})),Ic(n,t)}});function Tc(e,t,n,r,o,a){var i=Sn(e,"x","maxPool"),s=i,u=!1;3===i.rank&&(u=!0,s=i.as4D(1,i.shape[0],i.shape[1],i.shape[2])),null==r&&(r=[1,1]),ue(4===s.rank,(function(){return"Error in maxPool: input must be rank 4 but got rank "+s.rank+"."})),ue(Ro(n,r),(function(){return"Error in maxPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+r+"'"})),null!=a&&ue(de(o),(function(){return"Error in maxPool: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+o+"."}));var c=bo(s.shape,t,n,r,o,a);if(1===c.filterWidth&&1===c.filterHeight&&pe(c.inShape,c.outShape))return i.clone();var l=[s],f=mt.runKernelFunc((function(e,t){var n=e.maxPool(s,c);return t([s,n]),n}),{x:s},(function(e,a){var i=a[0],s=a[1];return{x:function(){return function(e,t,n,r,o,a,i,s){var u=Sn(e,"dy","maxPoolBackprop"),c=Sn(t,"input","maxPoolBackprop"),l=Sn(n,"output","maxPoolBackprop");ue(c.rank===u.rank,(function(){return"Rank of input ("+c.rank+") does not match rank of dy ("+u.rank+")"})),null==a&&(a=[1,1]),ue(Ro(o,a),(function(){return"Error in maxPoolBackProp: Either strides or dilations must be 1. Got strides "+o+" and dilations '"+a+"'"})),ue(4===u.rank,(function(){return"Error in maxPoolBackprop: dy must be rank 4 but got rank "+u.rank+"."})),ue(4===c.rank,(function(){return"Error in maxPoolBackprop: input must be rank 4 but got rank "+c.rank+"."}));var f=bo(c.shape,r,o,a,i,s);return mt.runKernelFunc((function(e){return e.maxPoolBackprop(u,c,l,f)}),{$dy:u,$input:c})}(e,i,s,t,n,r,o)}}}),"MaxPool",c,l);return u?f.as3D(f.shape[1],f.shape[2],f.shape[3]):f}function Dc(e,t,n,r,o,a){var i=Sn(e,"x","avgPool","float32");null==r&&(r=[1,1]),ue(Ro(n,r),(function(){return"Error in avgPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+r+"'"}));var s=i,u=!1;3===i.rank&&(u=!0,s=i.as4D(1,i.shape[0],i.shape[1],i.shape[2])),ue(4===s.rank,(function(){return"Error in avgPool: x must be rank 4 but got rank "+s.rank+"."})),null!=a&&ue(de(o),(function(){return"Error in avgPool: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+o+"."}));var c=bo(s.shape,t,n,r,o,a);if(1===c.filterWidth&&1===c.filterHeight&&pe(c.inShape,c.outShape))return i.clone();var l=mt.runKernelFunc((function(e){return e.avgPool(s,c)}),{x:s},(function(e){return{x:function(){return function(e,t,n,r,o,a){var i=Sn(e,"dy","avgPoolBackprop"),s=Sn(t,"input","avgPoolBackprop");ue(s.rank===i.rank,(function(){return"Rank of input ("+s.rank+") does not match rank of dy ("+i.rank+")"})),null==o&&(o=[1,1]),ue(Ro(r,o),(function(){return"Error in avgPoolBackprop: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+o+"'"}));var u=s,c=i,l=!1;3===s.rank&&(l=!0,u=s.as4D(1,s.shape[0],s.shape[1],s.shape[2]),c=i.as4D(1,i.shape[0],i.shape[1],i.shape[2])),ue(4===c.rank,(function(){return"Error in avgPoolBackprop: dy must be rank 4 but got rank "+c.rank+"."})),ue(4===u.rank,(function(){return"Error in avgPoolBackprop: input must be rank 4 but got rank "+u.rank+"."}));var f=bo(u.shape,n,r,o,a),h=mt.runKernelFunc((function(e){return e.avgPoolBackprop(c,u,f)}),{dy4D:c,input4D:u});return l?h.as3D(h.shape[1],h.shape[2],h.shape[3]):h}(e,s,t,n,r,o)}}}),"AvgPool",c);return l=l.cast(i.dtype),u?l.as3D(l.shape[1],l.shape[2],l.shape[3]):l}var Mc=zn({maxPool_:function(e,t,n,r,o){return Tc(e,t,n,1,r,o)}}),Nc=zn({avgPool_:function(e,t,n,r,o){return Dc(e,t,n,1,r,o)}}),Fc=zn({pool_:function(e,t,n,r,o,a){null==o&&(o=[1,1]),null==a&&(a=1),0===r&&(r="valid");var i=Sn(e,"x","maxPool"),s=i,u=!1;3===i.rank&&(u=!0,s=i.as4D(1,i.shape[0],i.shape[1],i.shape[2])),ue(Ro(a,o),(function(){return"Error in pool: Either strides or dilations must be 1. Got strides "+a+" and dilations '"+o+"'"}));var c,l=bo(s.shape,t,a,o,r),f=[l.dilationHeight,l.dilationWidth];c="same"===r?function(e,t){var n=e.map((function(e,n){return e+(e-1)*(t[n]-1)})).map((function(e){return e-1})),r=n.map((function(e){return Math.floor(e/2)})),o=n.map((function(e,t){return e-r[t]}));return n.map((function(e,t){return[r[t],o[t]]}))}([l.filterHeight,l.filterWidth],f):[[0,0],[0,0]];var h=1===f[0]&&1===f[1],p=function(e,t,n){var r=n.map((function(e){return e[0]})),o=n.map((function(e){return e[1]})),a=e.concat(r,o),i=t.map((function(e,t){return(e-a[t]%e)%e})),s=o.map((function(e,t){return e+i[t]}));return[t.map((function(e,t){return[r[t],s[t]]})),t.map((function(e,t){return[0,i[t]]}))]}([l.inHeight,l.inWidth],f,c),d=p[0],v=p[1],m=h?r:"valid",g=h?s:Vr(s,f,d),y=("avg"===n?function(){return Dc(g,t,a,1,m)}:function(){return Tc(g,t,a,1,m)})(),b=h?y:Er(y,f,v);return u?b.as3D(b.shape[1],b.shape[2],b.shape[3]):b}}),Bc=zn({maxPool3d_:function(e,t,n,r,o,a,i){void 0===a&&(a="NDHWC");var s=Sn(e,"x","maxPool3d"),u=s,c=!1;4===s.rank&&(c=!0,u=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3])),null==i&&(i=[1,1,1]),ue(5===u.rank,(function(){return"Error in maxPool3d: x must be rank 5 but got rank "+u.rank+"."})),ue("NDHWC"===a,(function(){return"Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of "+a})),ue(Ro(n,i),(function(){return"Error in maxPool3d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+i+"'"})),null!=o&&ue(de(r),(function(){return"Error in maxPool3d: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+r+"."}));var l=wo(u.shape,t,n,i,r,o,a),f=mt.runKernelFunc((function(e,t){var n=e.maxPool3d(u,l);return t([u,n]),n}),{x:u},(function(e,a){var s=a[0],u=a[1];return{x:function(){return function(e,t,n,r,o,a,i,s){var u=Sn(e,"dy","maxPool3dBackprop"),c=Sn(t,"input","maxPool3dBackprop"),l=Sn(n,"output","maxPool3dBackprop"),f=u,h=c,p=l,d=!1;4===c.rank&&(d=!0,f=u.as5D(1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]),h=c.as5D(1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]),p=l.as5D(1,l.shape[0],l.shape[1],l.shape[2],l.shape[3])),ue(5===f.rank,(function(){return"Error in maxPool3dBackprop: dy must be rank 5 but got rank "+f.rank+"."})),ue(5===h.rank,(function(){return"Error in maxPool3dBackprop: input must be rank 5 but got rank "+h.rank+"."})),ue(5===p.rank,(function(){return"Error in maxPool3dBackprop: output must be rank 5 but got rank "+p.rank+"."})),null==a&&(a=[1,1,1]),ue(Ro(o,a),(function(){return"Error in maxPool3dBackprop: Either strides or dilations must be 1. Got strides "+o+" and dilations '"+a+"'"})),null!=s&&ue(de(i),(function(){return"Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode "+s+" but got pad "+i+"."}));var v=wo(h.shape,r,o,a,i,s),m=mt.runKernelFunc((function(e){return e.maxPool3dBackprop(f,h,p,v)}),{dy5D:f,input5D:h});return d?m.as4D(m.shape[1],m.shape[2],m.shape[3],m.shape[4]):m}(e,s,u,t,n,i,r,o)}}}));return c?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f}}),jc=zn({avgPool3d_:function(e,t,n,r,o,a,i){void 0===a&&(a="NDHWC");var s=Sn(e,"x","avgPool3d","float32"),u=s,c=!1;4===s.rank&&(c=!0,u=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3])),null==i&&(i=[1,1,1]),ue(5===u.rank,(function(){return"Error in avgPool3d: x must be rank 5 but got rank "+u.rank+"."})),ue("NDHWC"===a,(function(){return"Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of "+a})),ue(Ro(n,i),(function(){return"Error in avgPool3d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+i+"'"})),null!=o&&ue(de(r),(function(){return"Error in avgPool3d: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+r+"."}));var l=wo(u.shape,t,n,i,r,o,a),f=mt.runKernelFunc((function(e){return e.avgPool3d(u,l)}),{x:u},(function(e){return{x:function(){return function(e,t,n,r,o,a,i){var s=Sn(e,"dy","avgPool3dBackprop"),u=Sn(t,"input","avgPool3dBackprop"),c=s,l=u,f=!1;4===u.rank&&(f=!0,c=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]),l=u.as5D(1,u.shape[0],u.shape[1],u.shape[2],u.shape[3])),ue(5===c.rank,(function(){return"Error in avgPool3dBackprop: dy must be rank 5 but got rank "+c.rank+"."})),ue(5===l.rank,(function(){return"Error in avgPool3dBackprop: input must be rank 5 but got rank "+l.rank+"."})),null==o&&(o=[1,1,1]),ue(Ro(r,o),(function(){return"Error in avgPool3dBackprop: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+o+"'"})),null!=i&&ue(de(a),(function(){return"Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+a+"."}));var h=wo(l.shape,n,r,o,a,i),p=mt.runKernelFunc((function(e){return e.avgPool3dBackprop(c,l,h)}),{dy5D:c,input5D:l});return f?p.as4D(p.shape[1],p.shape[2],p.shape[3],p.shape[4]):p}(e,u,t,n,i,r,o)}}}));return f=f.cast(u.dtype),c?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f}}),Lc=zn({slice_:function(e,t,n){var r,o,a=Sn(e,"x","slice");if(0===a.rank)throw new Error("Slicing scalar is not possible");(r="number"==typeof t?[t].concat(new Array(a.rank-1).fill(0)):t.length<a.rank?t.concat(new Array(a.rank-t.length).fill(0)):t.slice()).forEach((function(e){ue(-1!==e,(function(){return"slice() does not support negative begin indexing."}))})),o=(o=null==n?new Array(a.rank).fill(-1):"number"==typeof n?[n].concat(new Array(a.rank-1).fill(-1)):n.length<a.rank?n.concat(new Array(a.rank-n.length).fill(-1)):n).map((function(e,t){return e>=0?e:(ue(-1===e,(function(){return"Negative size values should be exactly -1 but got "+e+" for the slice() size at index "+t+"."})),a.shape[t]-r[t])})),no(a,r,o);var i=a.shape,s={begin:r,size:o};return mt.runKernelFunc((function(e){return e.slice(a,r,o)}),{x:a},(function(e){for(var t=[],n=0;n<e.rank;n++)t.push([r[n],i[n]-r[n]-o[n]]);return{x:function(){return e.pad(t)}}}),"Slice",s)}}),zc=zn({slice1d_:function(e,t,n){var r=Sn(e,"x","slice1d");return ue(1===r.rank,(function(){return"slice1d expects a rank-1 tensor, but got a rank-"+r.rank+" tensor"})),Lc(r,[t],[n])}}),Wc=zn({slice2d_:function(e,t,n){var r=Sn(e,"x","slice2d");return ue(2===r.rank,(function(){return"slice2d expects a rank-2 tensor, but got a rank-"+r.rank+" tensor"})),Lc(r,t,n)}}),Vc=zn({slice3d_:function(e,t,n){var r=Sn(e,"x","slice3d");return ue(3===r.rank,(function(){return"slice3d expects a rank-3 tensor, but got a rank-"+r.rank+" tensor"})),Lc(r,t,n)}}),Hc=zn({slice4d_:function(e,t,n){var r=Sn(e,"x","slice4d");return ue(4===r.rank,(function(){return"slice4d expects a rank-4 tensor, but got a rank-"+r.rank+" tensor"})),Lc(r,t,n)}});function Uc(e,t,n,r,o){return t.rank<n.rank&&(t=t.reshape(Dn(t.shape,r))),e.rank<n.rank&&(e=e.reshape(Dn(e.shape,r))),{x:function(){var r=e.mul(n.equal(t).cast(e.dtype));return null==o?r:r.transpose(o)}}}var Gc=zn({all_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=Sn(e,"x","all","bool"),o=we(t,r.shape),a=o,i=Nn(a,r.rank);null!=i&&(r=r.transpose(i),a=Bn(a.length,r.rank));var s=mt.runKernelFunc((function(e){return e.all(r,a)}),{$x:r});if(n){var u=Dn(s.shape,o);return s.reshape(u)}return s}}),qc=zn({any_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=Sn(e,"x","any","bool"),o=we(t,r.shape),a=o,i=Nn(a,r.rank);null!=i&&(r=r.transpose(i),a=Bn(a.length,r.rank));var s=mt.runKernelFunc((function(e){return e.any(r,a)}),{$x:r});if(n){var u=Dn(s.shape,o);return s.reshape(u)}return s}}),Xc=zn({argMax_:function(e,t){void 0===t&&(t=0);var n=Sn(e,"x","argMax");null==t&&(t=0);var r=we(t,n.shape),o=Nn(r,n.rank);null!=o&&(n=n.transpose(o),r=Bn(r.length,n.rank));var a={axis:r[0]},i=[n];return mt.runKernelFunc((function(e,t){var o=e.argMax(n,r[0]);return t([n]),o}),{x:n},(function(e,t){var n=t[0];return{x:function(){return nr(n)}}}),"ArgMax",a,i)}}),Kc=zn({argMin_:function(e,t){void 0===t&&(t=0);var n=Sn(e,"x","argMin");null==t&&(t=0);var r=we(t,n.shape),o=Nn(r,n.rank);return null!=o&&(n=n.transpose(o),r=Bn(r.length,n.rank)),mt.runKernelFunc((function(e,t){var o=e.argMin(n,r[0]);return t([n]),o}),{$x:n},(function(e,t){var n=t[0];return{$x:function(){return nr(n)}}}))}}),$c=zn({logSumExp_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=Sn(e,"x","logSumExp"),o=we(t,r.shape),a=r.max(o,!0),i=r.sub(a).exp().sum(o).log(),s=a.reshape(i.shape).add(i);if(n){var u=Dn(s.shape,o);return s.reshape(u)}return s}}),Zc=zn({max_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=Sn(e,"x","max"),o=r,a=we(t,r.shape),i=a,s=Nn(i,r.rank);null!=s&&(r=r.transpose(s),i=Bn(i.length,r.rank));var u=[r],c=mt.runKernelFunc((function(e,t){var n=e.max(r,i);return t([o,n]),n}),{x:r},(function(e,t){return Uc(e,t[1],t[0],a,s)}),"Max",{axes:i},u,[!0]);if(n){var l=Dn(c.shape,a);c=c.reshape(l)}return c}}),Yc=zn({mean_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=Sn(e,"x","mean"),o=we(t,r.shape),a=he(Tn(r.shape,o)[1]);return co((function(e){var r=qn(a);return{value:(r.dtype===e.dtype?e:e.cast(r.dtype)).div(r).sum(t,n),gradFunc:function(t){var n=e.shape.slice();return o.forEach((function(e){n[e]=1})),t.reshape(n).mul(Yn(e.shape,"float32")).div(a)}}}))(r)}}),Jc=zn({min_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=Sn(e,"x","min"),o=r,a=we(t,r.shape),i=a,s=Nn(i,r.rank);null!=s&&(r=r.transpose(s),i=Bn(i.length,r.rank));var u=[r],c=mt.runKernelFunc((function(e,t){var n=e.min(r,i);return t([o,n]),n}),{x:r},(function(e,t){return Uc(e,t[1],t[0],a,s)}),"Min",{axes:i},u,[!0]);if(n){var l=Dn(c.shape,a);c=c.reshape(l)}return c}}),Qc=zn({moments_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=we(t,(e=Sn(e,"x","moments")).shape),o=e.mean(r,n),a=o.shape;n||(a=Dn(o.shape,r));var i=e.toFloat().sub(o.reshape(a)).square();return{mean:o,variance:i.mean(r,n)}}}),el=zn({sum_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=Sn(e,"x","sum");"bool"===r.dtype&&(r=r.toInt());var o=we(t,r.shape);return co((function(e){var t=Nn(o,e.rank),r=o,a=e;null!=t&&(a=e.transpose(t),r=Bn(r.length,e.rank));var i=mt.runKernelFunc((function(e){return e.sum(a,r)}),{permutedX:a});if(n){var s=Dn(i.shape,o);i=i.reshape(s)}return{value:i,gradFunc:function(t){var n=e.shape.slice();return o.forEach((function(e){n[e]=1})),t.reshape(n).mul(Yn(e.shape,"float32"))}}}))(r)}}),tl=zn({prod_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=Sn(e,"x","prod");"bool"===r.dtype&&(r=r.toInt());var o=we(t,r.shape),a=Nn(o,r.rank),i=o,s=r;null!=a&&(s=r.transpose(a),i=Bn(i.length,r.rank));var u=mt.runKernelFunc((function(e){return e.prod(s,i)}),{permutedX:s});if(n){var c=Dn(u.shape,o);u=u.reshape(c)}return u}}),nl=zn({elu_:function(e){var t=Sn(e,"x","elu");return mt.runKernelFunc((function(e,n){var r=e.elu(t);return n([r]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){return mt.runKernelFunc((function(t){return t.eluDer(e,n)}),{dy:e,y:n})}}}))}}),rl=zn({leakyRelu_:function(e,t){void 0===t&&(t=.2);var n=Sn(e,"x","leakyRelu");return Mu(qn(t).mul(n),n)}}),ol=zn({prelu_:function(e,t){var n=Sn(e,"x","prelu"),r=Sn(t,"alpha","prelu");return mt.runKernelFunc((function(e,t){var o=e.prelu(n,r);return t([n,r]),o}),{x:n,alpha:r},(function(e,t){var n=t[0],r=t[1],o=n.greater(0);return{x:function(){return Ou(o,e,e.mul(r))},alpha:function(){var t=Ou(o,nr(e),e.mul(n)),a=go(r.shape,e.shape);return a.length>0&&(t=t.sum(a)),t.reshape(r.shape)}}}),"Prelu")}}),al=zn({relu_:function(e){var t=Sn(e,"x","relu");return"bool"===t.dtype?t.toInt():mt.runKernelFunc((function(e,n){var r=e.relu(t);return n([t]),r}),{x:t},(function(e,t){var n=t[0];return{x:function(){return e.mulStrict(n.step().toFloat())}}}),"Relu")}}),il=zn({relu6_:function(e){var t=Sn(e,"x","relu6");return"bool"===t.dtype?t.toInt():mt.runKernelFunc((function(e,n){var r=e.relu6(t);return n([t]),r}),{x:t},(function(e,t){var n=t[0],r=n.lessEqual(6).mul(n.step());return{x:function(){return e.mulStrict(r.toFloat())}}}),"Relu6")}}),sl=zn({selu_:function(e){var t=Sn(e,"x","selu");return mt.runKernelFunc((function(e,n){var r=e.selu(t);return n([t]),r}),{$x:t},(function(e,t){var n=t[0];return{$x:function(){var t=n.greater(qn(0)),r=qn(rs),o=qn(os),a=e.mul(o),i=e.mul(r).mul(n.toFloat().exp());return Ou(t,a,i)}}}))}}),ul=zn({transpose_:function(e,t){var n=Sn(e,"x","transpose");if(null==t&&(t=n.shape.map((function(e,t){return t})).reverse()),ue(n.rank===t.length,(function(){return"Error in transpose: rank of input "+n.rank+" must match length of perm "+t+"."})),t.forEach((function(e){ue(e>=0&&e<n.rank,(function(){return"All entries in 'perm' must be between 0 and "+(n.rank-1)+" but got "+t}))})),n.rank<=1)return n.clone();var r={perm:t};return mt.runKernelFunc((function(e){return e.transpose(n,t)}),{x:n},(function(e){var n=Fn(t);return{x:function(){return e.transpose(n)}}}),"Transpose",r)}}),cl=zn({localResponseNormalization_:function(e,t,n,r,o){void 0===t&&(t=5),void 0===n&&(n=1),void 0===r&&(r=1),void 0===o&&(o=.5);var a=Sn(e,"x","localResponseNormalization");ue(4===a.rank||3===a.rank,(function(){return"Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank "+a.rank+"."})),ue(de(t),(function(){return"Error in localResponseNormalization: depthRadius must be an integer but got depthRadius "+t+"."}));var i=a,s=!1;3===a.rank&&(s=!0,i=a.as4D(1,a.shape[0],a.shape[1],a.shape[2]));var u=mt.runKernelFunc((function(e,a){var s=e.localResponseNormalization4D(i,t,n,r,o);return a([i,s]),s}),{x4D:i},(function(e,a){var i=a[0],s=a[1];return{x4D:function(){return mt.runKernelFunc((function(a){return a.LRNGrad(e,i,s,t,n,r,o)}),{})}}}));return s?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u}}),ll=zn({norm_:function(e,t,n,r){void 0===t&&(t="euclidean"),void 0===n&&(n=null),void 0===r&&(r=!1);var o=function e(t,n,r){if(void 0===r&&(r=null),0===t.rank)return t.abs();if(1!==t.rank&&null===r)return e(t.reshape([-1]),n,r);if(1===t.rank||"number"==typeof r||Array.isArray(r)&&1===r.length){if(1===n)return t.abs().sum(r);if(n===1/0)return t.abs().max(r);if(n===-1/0)return t.abs().min(r);if("euclidean"===n||2===n)return t.abs().pow(qn(2,"int32")).sum(r).sqrt();throw new Error("Error in norm: invalid ord value: "+n)}if(Array.isArray(r)&&2===r.length){if(1===n)return t.abs().sum(r[0]).max(r[1]-1);if(n===1/0)return t.abs().sum(r[1]).max(r[0]);if(n===-1/0)return t.abs().sum(r[1]).min(r[0]);if("fro"===n||"euclidean"===n)return t.square().sum(r).sqrt();throw new Error("Error in norm: invalid ord value: "+n)}throw new Error("Error in norm: invalid axis: "+r)}(e=Sn(e,"x","norm"),t,n),a=o.shape;if(r){var i=we(n,e.shape);a=Dn(o.shape,i)}return o.reshape(a)}}),fl=zn({basicLSTMCell_:function(e,t,n,r,o,a){var i=Sn(e,"forgetBias","basicLSTMCell"),s=Sn(t,"lstmKernel","basicLSTMCell"),u=Sn(n,"lstmBias","basicLSTMCell"),c=Sn(r,"data","basicLSTMCell"),l=Sn(o,"c","basicLSTMCell"),f=Sn(a,"h","basicLSTMCell"),h=c.concat(f,1).matMul(s).add(u),p=h.shape[0],d=h.shape[1]/4,v=[p,d],m=h.slice([0,0],v),g=h.slice([0,d],v),y=h.slice([0,2*d],v),b=h.slice([0,3*d],v),w=m.sigmoid().mulStrict(g.tanh()).addStrict(l.mulStrict(i.add(y).sigmoid())),x=w.tanh().mulStrict(b.sigmoid());return[w,x]}}),hl=zn({multiRNNCell_:function(e,t,n,r){for(var o=Sn(t,"data","multiRNNCell"),a=Rn(n,"c","multiRNNCell"),i=Rn(r,"h","multiRNNCell"),s=o,u=[],c=0;c<e.length;c++){var l=e[c](s,a[c],i[c]);u.push(l[0]),u.push(l[1]),s=l[1]}var f=[],h=[];for(c=0;c<u.length;c+=2)f.push(u[c]),h.push(u[c+1]);return[f,h]}}),pl=zn({movingAverage_:function(e,t,n,r,o){void 0===o&&(o=!0);var a=Sn(e,"v","movingAverage"),i=Sn(t,"x","movingAverage"),s=Sn(n,"decay","movingAverage");ft(a,i),ue(pe(a.shape,i.shape),(function(){return"Shape mismatch in v and x"}));var u=qn(1),c=u.sub(s),l=i.sub(a).mul(c);if(o){ue(null!=r,(function(){return"When using zeroDebias: true, step is required."}));var f=Sn(r,"step","movingAverage");l=l.div(u.sub(Vu(s,f)))}return a.add(l)}}),dl=zn({stridedSlice_:function(e,t,n,r,o,a,i,s,u){if(void 0===o&&(o=0),void 0===a&&(a=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===u&&(u=0),null==r&&(r=new Array(t.length)),0!==i)throw new Error("ellipsis mask is not yet supported");var c=Sn(e,"x","stridedSlice"),l=ro(s),f=c.shape.slice();l.forEach((function(e){t[e]=0,n[e]=1,f.splice(e,0,1)})),c=c.reshape(f);for(var h=0;h<c.rank;h++)t[h]=ao(o,t,r,c.shape,h),n[h]=io(a,n,r,c.shape,h),r[h]=r[h]||1;var p=ro(u);p.forEach((function(e){n[e]=t[e]+1,r[e]=1}));var d=oo(t,n,r),v=d.filter((function(e,t){return-1===p.indexOf(t)}));return r.every((function(e){return 1===e}))?Lc(c,t,d).reshape(v):mt.runKernelFunc((function(e){return e.stridedSlice(c,t,n,r)}),{$x:c}).reshape(v)}}),vl=zn({topk_:function(e,t,n){void 0===t&&(t=1),void 0===n&&(n=!0);var r=Sn(e,"x","topk");if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");var o=r.shape[r.shape.length-1];if(t>o)throw new Error("'k' passed to topk() must be <= the last dimension ("+o+") but got "+t);var a=mt.runKernelFunc((function(e){return e.topk(r,t,n)}),{$x:r});return{values:a[0],indices:a[1]}}}),ml=zn({scatterND_:function(e,t,n){var r=Sn(e,"indices","scatterND","int32"),o=Sn(t,"updates","scatterND");return function(e,t,n){if(t.rank<1)throw new Error("tf.scatterND() expects the indices to be rank 1 or higher, but the rank was "+t.rank+".");if(e.rank<1)throw new Error("tf.scatterND() expects the updates to be rank 1 or higher, but the rank was "+e.rank+".");if("int32"!==t.dtype)throw new Error("The dtype of 'indices' should be int32, but got dtype: "+t.dtype);if(n.length<1)throw new Error("Output rank must be greater or equal to 1, but got shape: "+n);if(0===n.length){if(0===t.size)throw new Error("Indices specified for empty output. indices shape: "+t.shape);if(0===e.size)throw new Error("Updates specified for empty output. updates shape: "+e.shape)}!function(e,t,n){var r=t.rank>1?t.shape[t.rank-1]:1,o=t.rank>1?t.rank-1:1,a="Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: "+n.shape+", indices.shape: "+t.shape+", shape: "+e+", sliceDim: "+r+", and batchDim: "+o+".";if(n.rank<o)throw new Error(a+" update.rank < "+o+". ");if(e.length<r+(n.rank-o))throw new Error(a+" Output shape length < "+(r+(n.rank-o)));if(n.rank!==o+e.length-r)throw new Error(a+" update.rank != "+(o+e.length-r));for(var i=0;i<o;++i)if(n.shape[i]!==t.shape[i])throw new Error(a+" updates.shape["+i+"] ("+n.shape[i]+") != indices.shape["+i+"] ("+t.shape[i]+").");for(i=0;i<n.rank-o;++i)if(n.shape[i+o]!==e[i+r])throw new Error(a+" updates.shape["+(i+o)+"] ("+n.shape[i+o]+") != shape["+(i+o)+"] ("+e[i+o]+")")}(n,t,e)}(o,r,n),mt.runKernelFunc((function(e){return e.scatterND(r,o,n)}),{$indices:r,$updates:o})}}),gl=zn({fft_:function(e){ue("complex64"===e.dtype,(function(){return"The dtype for tf.spectral.fft() must be complex64 but got "+e.dtype+"."}));var t=e.shape[e.shape.length-1],n=e.size/t,r=e.as2D(n,t);return mt.runKernelFunc((function(e){return e.fft(r)}),{input:e}).reshape(e.shape)}}),yl=zn({ifft_:function(e){ue("complex64"===e.dtype,(function(){return"The dtype for tf.spectral.ifft() must be complex64 but got "+e.dtype+"."}));var t=e.shape[e.shape.length-1],n=e.size/t,r=e.as2D(n,t);return mt.runKernelFunc((function(e){return e.ifft(r)}),{input:e}).reshape(e.shape)}}),bl=zn({rfft_:function(e,t){ue("float32"===e.dtype,(function(){return"The dtype for rfft() must be real value but got "+e.dtype}));var n,r=e.shape[e.shape.length-1],o=e.size/r;if(null!=t&&t<r){var a=e.shape.map((function(e){return 0})),i=e.shape.map((function(e){return e}));i[e.shape.length-1]=t,n=e.slice(a,i),r=t}else if(null!=t&&t>r){var s=e.shape.map((function(e){return e}));s[e.shape.length-1]=t-r,n=e.concat(Jn(s),e.shape.length-1),r=t}else n=e;var u=n.zerosLike(),c=Wn(n,u).as2D(o,r),l=gl(c),f=Math.floor(r/2)+1,h=Vn(l),p=Hn(l),d=h.split([f,r-f],h.shape.length-1),v=p.split([f,r-f],p.shape.length-1),m=n.shape.slice();return m[n.shape.length-1]=f,Wn(d[0],v[0]).reshape(m)}}),wl=zn({irfft_:function(e){var t=e.shape[e.shape.length-1],n=e.size/t;if(t<=2){var r=e.as2D(n,t),o=yl(r);return Vn(o)}var a=[n,2*(t-1)],i=Vn(e).as2D(n,t),s=Hn(e).as2D(n,t),u=i.slice([0,1],[n,t-2]).reverse(1),c=s.slice([0,1],[n,t-2]).reverse(1).mul(qn(-1)),l=i.concat(u,1),f=s.concat(c,1);return r=Wn(l,f).as2D(a[0],a[1]),o=yl(r),Vn(o)}}),xl=Object.freeze({fft:gl,ifft:yl,rfft:bl,irfft:wl}),El=zn({sparseToDense_:function(e,t,n,r){void 0===r&&(r=0);var o=Sn(e,"sparseIndices","sparseToDense","int32"),a=Sn(t,"sparseValues","sparseToDense"),i=Sn(r,"defaultValue","sparseToDense",a.dtype);return function(e,t,n,r){if("int32"!==e.dtype)throw new Error("tf.sparseToDense() expects the indices to be int32 type, but the dtype was "+e.dtype+".");if(e.rank>2)throw new Error("sparseIndices should be a scalar, vector, or matrix, but got shape "+e.shape+".");var o=e.rank>0?e.shape[0]:1,a=e.rank>1?e.shape[1]:1;if(n.length!==a)throw new Error("outputShape has incorrect number of elements:, "+n.length+", should be: "+a+".");var i=t.size;if(0!==t.rank&&(1!==t.rank||i!==o))throw new Error("sparseValues has incorrect shape "+t.shape+", should be [] or ["+o+"]");if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(o,a,n,i),mt.runKernelFunc((function(e){return e.sparseToDense(o,a,n,i)}),{$sparseIndices:o,$sparseValues:a,$defaultValue:i})}}),_l=zn({gatherND_:function(e,t){var n=Sn(t,"indices","gatherND","int32"),r=Sn(e,"x","gatherND");return mt.runKernelFunc((function(e){return e.gatherND(r,n)}),{$x:r,$indices:n})}}),Ol=zn({diag_:function(e){var t=Sn(e,"x","diag").flatten(),n=e.shape.concat(e.shape);return mt.runKernelFunc((function(e){return e.diag(t)}),{$x:t}).reshape(n)}}),kl=zn({dropout_:function(e,t,n,r){var o=Sn(e,"x","dropout");if(ue("float32"===o.dtype,(function(){return"x has to be a floating point tensor since it's going to be scaled, but got a "+o.dtype+" tensor instead."})),ue(t>=0&&t<1,(function(){return"rate must be a float in the range [0, 1), but got "+t+"."})),0===t)return e instanceof et?o.clone():o;var a=function(e,t){if(null==t)return e.shape.slice();if(pe(e.shape,t))return t;if(e.shape.length===t.length){for(var n=[],r=0;r<e.shape.length;r++)null==t[r]&&null!=e.shape[r]?n.push(e.shape[r]):n.push(t[r]);return n}return t}(o,n),i=1-t,s=zr(a,0,1,"float32",r).add(i).floor().div(i);return o.mul(s)}});function Cl(e,t,n){for(var r=1-e%2,o=new Float32Array(e),a=0;a<e;++a){var i=2*Math.PI*a/(e+r-1);o[a]=t-n*Math.cos(i)}return Xn(o,"float32")}var Il,Sl=zn({hannWindow_:function(e){return Cl(e,.5,.5)}}),Rl=zn({hammingWindow_:function(e){return Cl(e,.54,.46)}}),Al=zn({frame_:function(e,t,n,r,o){void 0===r&&(r=!1),void 0===o&&(o=0);for(var a=0,i=[];a+t<=e.size;)i.push(Lc(e,a,t)),a+=n;if(r)for(;a<e.size;){var s=a+t-e.size,u=rr([Lc(e,a,t-s),Qn([s],o)]);i.push(u),a+=n}return 0===i.length?Kn([],[0,t]):rr(i).as2D(i.length,t)}}),Pl=zn({stft_:function(e,t,n,r,o){var a;void 0===o&&(o=Sl),null==r&&(a=t,r=Math.floor(Math.pow(2,Math.ceil(Math.log(a)/Math.log(2)))));for(var i=Al(e,t,n),s=zu(i,o(t)),u=[],c=0;c<i.shape[0];c++)u.push(bl(s.slice([c,0],[1,t]),r));return rr(u)}}),Tl=Object.freeze({hannWindow:Sl,hammingWindow:Rl,frame:Al,stft:Pl});!function(e){e[e.NONE=0]="NONE",e[e.MEAN=1]="MEAN",e[e.SUM=2]="SUM",e[e.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(Il||(Il={}));var Dl=zn({absoluteDifference_:function(e,t,n,r){void 0===r&&(r=Il.SUM_BY_NONZERO_WEIGHTS);var o=Sn(e,"labels","absoluteDifference"),a=Sn(t,"predictions","absoluteDifference"),i=null;null!=n&&(i=Sn(n,"weights","absoluteDifference")),ce(o.shape,a.shape,"Error in absoluteDifference: ");var s=o.sub(a).abs();return Ml(s,i,r)}}),Ml=zn({computeWeightedLoss_:function(e,t,n){void 0===n&&(n=Il.SUM_BY_NONZERO_WEIGHTS);var r=Sn(e,"losses","computeWeightedLoss"),o=null;null!=t&&(o=Sn(t,"weights","computeWeightedLoss"));var a=null==o?r:r.mul(o);if(n===Il.NONE)return a;if(n===Il.SUM)return a.sum();if(n===Il.MEAN){if(null==o)return a.mean();var i=r.size/o.size,s=a.sum().div(o.sum());return i>1?s.div(qn(i)):s}if(n===Il.SUM_BY_NONZERO_WEIGHTS){if(null==o)return a.sum().div(qn(r.size));var u=o.mul(Yn(r.shape)).notEqual(qn(0)).sum().toFloat();return a.sum().div(u)}throw Error("Unknown reduction: "+n)}}),Nl=zn({cosineDistance_:function(e,t,n,r,o){void 0===o&&(o=Il.SUM_BY_NONZERO_WEIGHTS);var a=Sn(e,"labels","cosineDistance"),i=Sn(t,"predictions","cosineDistance"),s=null;null!=r&&(s=Sn(r,"weights","cosineDistance")),ce(a.shape,i.shape,"Error in cosineDistance: ");var u=qn(1).sub(a.mul(i).sum(n,!0));return Ml(u,s,o)}}),Fl=zn({hingeLoss_:function(e,t,n,r){void 0===r&&(r=Il.SUM_BY_NONZERO_WEIGHTS);var o=Sn(e,"labels","hingeLoss"),a=Sn(t,"predictions","hingeLoss"),i=null;null!=n&&(i=Sn(n,"weights","hingeLoss")),ce(o.shape,a.shape,"Error in hingeLoss: ");var s=qn(1);o=qn(2).mul(o).sub(s);var u=s.sub(o.mul(a)).relu();return Ml(u,i,r)}}),Bl=zn({huberLoss_:function(e,t,n,r,o){void 0===r&&(r=1),void 0===o&&(o=Il.SUM_BY_NONZERO_WEIGHTS);var a=Sn(e,"labels","huberLoss"),i=Sn(t,"predictions","huberLoss"),s=null;null!=n&&(s=Sn(n,"weights","huberLoss")),ce(a.shape,i.shape,"Error in huberLoss: ");var u=qn(r),c=i.sub(a).abs(),l=Fu(c,u),f=c.sub(l),h=qn(.5).mul(l.square()).add(u.mul(f));return Ml(h,s,o)}}),jl=zn({logLoss_:function(e,t,n,r,o){void 0===r&&(r=1e-7),void 0===o&&(o=Il.SUM_BY_NONZERO_WEIGHTS);var a=Sn(e,"labels","logLoss"),i=Sn(t,"predictions","logLoss"),s=null;null!=n&&(s=Sn(n,"weights","logLoss")),ce(a.shape,i.shape,"Error in logLoss: ");var u=qn(1),c=qn(r),l=a.mul(i.add(c).log()).neg().sub(u.sub(a).mul(u.sub(i).add(c).log()));return Ml(l,s,o)}}),Ll=zn({meanSquaredError_:function(e,t,n,r){void 0===r&&(r=Il.SUM_BY_NONZERO_WEIGHTS);var o=Sn(e,"labels","meanSquaredError"),a=Sn(t,"predictions","meanSquaredError"),i=null;null!=n&&(i=Sn(n,"weights","meanSquaredError")),ce(o.shape,a.shape,"Error in meanSquaredError: ");var s=o.squaredDifference(a);return Ml(s,i,r)}}),zl=zn({sigmoidCrossEntropy_:function(e,t,n,r,o){void 0===r&&(r=0),void 0===o&&(o=Il.SUM_BY_NONZERO_WEIGHTS);var a=Sn(e,"multiClassLabels","sigmoidCrossEntropy"),i=Sn(t,"logits","sigmoidCrossEntropy"),s=null;if(null!=n&&(s=Sn(n,"weights","sigmoidCrossEntropy")),ce(a.shape,i.shape,"Error in sigmoidCrossEntropy: "),r>0){var u=qn(r),c=qn(1),l=qn(.5);a=a.mul(c.sub(u)).add(l.mul(u))}var f=function(e,t){var n=Sn(e,"labels","sigmoidCrossEntropyWithLogits"),r=Sn(t,"logits","sigmoidCrossEntropyWithLogits");ce(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");var o=r.relu(),a=r.mul(n),i=r.abs().neg().exp().log1p();return o.sub(a).add(i)}(a,i);return Ml(f,s,o)}}),Wl=zn({softmaxCrossEntropy_:function(e,t,n,r,o){void 0===r&&(r=0),void 0===o&&(o=Il.SUM_BY_NONZERO_WEIGHTS);var a=Sn(e,"onehotLabels","softmaxCrossEntropy"),i=Sn(t,"logits","softmaxCrossEntropy"),s=null;if(null!=n&&(s=Sn(n,"weights","softmaxCrossEntropy")),ce(a.shape,i.shape,"Error in softmaxCrossEntropy: "),r>0){var u=qn(r),c=qn(1),l=qn(a.shape[1]);a=a.mul(c.sub(u)).add(u.div(l))}var f=function(e,t,n){if(void 0===n&&(n=-1),-1===n&&(n=t.rank-1),n!==t.rank-1)throw Error("Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank "+t.rank+" and dim was "+n);return co((function(e,t,r){var o=t.logSumExp([n],!0),a=t.toFloat().sub(o);return r([e,a]),{value:a.mul(e).neg().sum([n]),gradFunc:function(e,t){var r=t[0],o=t[1],a=Dn(e.shape,[n]);return[e.reshape(a).mul(r.toFloat().sub(o.exp())),e.reshape(a).mul(o.exp().sub(r.toFloat()))]}}}))(e,t)}(a,i);return Ml(f,s,o)}}),Vl=Object.freeze({get Reduction(){return Il},absoluteDifference:Dl,computeWeightedLoss:Ml,cosineDistance:Nl,hingeLoss:Fl,huberLoss:Bl,logLoss:jl,meanSquaredError:Ll,sigmoidCrossEntropy:zl,softmaxCrossEntropy:Wl});function Hl(e,t){return void 0===t&&(t=!1),mt.tidy((function(){if(2!==e.shape.length)throw new Error("qr2d() requires a 2D Tensor, but got a "+e.shape.length+"D Tensor.");for(var n=e.shape[0],r=e.shape[1],o=Rr(n),a=e.clone(),i=Kn([[1]],[1,1]),s=i.clone(),u=n>=r?r:n,c=function(e){var t,u=a,c=s,l=o;t=mt.tidy((function(){var t=a.slice([e,e],[n-e,1]),u=t.norm(),c=a.slice([e,e],[1,1]),l=Kn([[-1]]).where(c.greater(0),Kn([[1]])),f=c.sub(l.mul(u)),h=t.div(f);s=1===h.shape[0]?i.clone():i.concat(h.slice([1,0],[h.shape[0]-1,h.shape[1]]),0);var p=l.matMul(f).div(u).neg(),d=a.slice([e,0],[n-e,r]),v=p.mul(s);if(0===e)a=d.sub(v.matMul(s.transpose().matMul(d)));else{var m=d.sub(v.matMul(s.transpose().matMul(d)));a=a.slice([0,0],[e,r]).concat(m,0)}var g=o.slice([0,e],[n,o.shape[1]-e]);if(0===e)o=g.sub(g.matMul(s).matMul(v.transpose()));else{var y=g.sub(g.matMul(s).matMul(v.transpose()));o=o.slice([0,0],[n,e]).concat(y,1)}return[s,a,o]})),s=t[0],a=t[1],o=t[2],On([u,c,l])},l=0;l<u;++l)c(l);return!t&&n>r&&(o=o.slice([0,0],[n,r]),a=a.slice([0,0],[r,r])),[o,a]}))}var Ul=zn({bandPart_:function(e,t,n){if(t%1!=0)throw new Error("bandPart(): numLower must be an integer, got "+t+".");if(n%1!=0)throw new Error("bandPart(): numUpper must be an integer, got "+n+".");var r=Sn(e,"a","bandPart");if(r.rank<2)throw new Error("bandPart(): Rank must be at least 2, got "+r.rank+".");var o=r.shape,a=r.shape.slice(-2),i=a[0],s=a[1];if(!(t<=i))throw new Error("bandPart(): numLower ("+t+") must not be greater than the number of rows ("+i+").");if(!(n<=s))throw new Error("bandPart(): numUpper ("+n+") must not be greater than the number of columns ("+s+").");t<0&&(t=i),n<0&&(n=s);var u=er(0,i,1,"int32").reshape([-1,1]),c=er(0,s,1,"int32"),l=qu(u,c),f=wu(l.lessEqual(qn(+t,"int32")),l.greaterEqual(qn(-n,"int32"))),h=Jn([i,s],r.dtype);return Ur(Xr(r.reshape([-1,i,s])).map((function(e){return Ou(f,e,h)}))).reshape(o)}}),Gl=zn({gramSchmidt_:function(e){var t;if(Array.isArray(e)){t=!1,ue(null!=e&&e.length>0,(function(){return"Gram-Schmidt process: input must not be null, undefined, or empty"}));for(var n=e[0].shape[0],r=function(t){ue(e[t].shape[0]===n,(function(){return"Gram-Schmidt: Non-unique lengths found in the input vectors: ("+e[t].shape[0]+" vs. "+n+")"}))},o=1;o<e.length;++o)r(o)}else t=!0,e=ur(e,e.shape[0],0).map((function(e){return Hr(e,[0])}));ue(e.length<=e[0].shape[0],(function(){return"Gram-Schmidt: Number of vectors ("+e.length+") exceeds number of dimensions ("+e[0].shape[0]+")."}));var a=[],i=e,s=function(e){a.push(mt.tidy((function(){var t=i[e];if(e>0)for(var n=0;n<e;++n){var r=el(a[n].mulStrict(t)).mul(a[n]);t=t.sub(r)}return t.div(ll(t,"euclidean"))})))};for(o=0;o<e.length;++o)s(o);return t?Ur(a,0):a}}),ql=zn({qr_:function(e,t){if(void 0===t&&(t=!1),e.rank<2)throw new Error("qr() requires input tensor to have a rank >= 2, but got rank "+e.rank);if(2===e.rank)return Hl(e,t);var n=e.shape.slice(0,e.shape.length-2).reduce((function(e,t){return e*t})),r=Xr(e.reshape([n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),o=[],a=[];return r.forEach((function(e){var n=Hl(e,t),r=n[0],i=n[1];o.push(r),a.push(i)})),[Ur(o,0).reshape(e.shape),Ur(a,0).reshape(e.shape)]}}),Xl=Object.freeze({bandPart:Ul,gramSchmidt:Gl,qr:ql});function Kl(e,t,n,r,o){null==r&&(r=.5),null==o&&(o=Number.NEGATIVE_INFINITY);var a=e.shape[0];return n=Math.min(n,a),ue(0<=r&&r<=1,(function(){return"iouThreshold must be in [0, 1], but was '"+r+"'"})),ue(2===e.rank,(function(){return"boxes must be a 2D tensor, but was of rank '"+e.rank+"'"})),ue(4===e.shape[1],(function(){return"boxes must have 4 columns, but 2nd dimension was "+e.shape[1]})),ue(1===t.rank,(function(){return"scores must be a 1D tensor"})),ue(t.shape[0]===a,(function(){return"scores has incompatible shape with boxes. Expected "+a+", but was "+t.shape[0]})),{maxOutputSize:n,iouThreshold:r,scoreThreshold:o}}var $l=zn({resizeBilinear_:function(e,t,n){void 0===n&&(n=!1);var r=Sn(e,"images","resizeBilinear");ue(3===r.rank||4===r.rank,(function(){return"Error in resizeBilinear: x must be rank 3 or 4, but got rank "+r.rank+"."})),ue(2===t.length,(function(){return"Error in resizeBilinear: new shape must 2D, but got shape "+t+"."}));var o=r,a=!1;3===r.rank&&(a=!0,o=r.as4D(1,r.shape[0],r.shape[1],r.shape[2]));var i=t[0],s=t[1],u=mt.runKernelFunc((function(e,t){return t([o]),e.resizeBilinear(o,i,s,n)}),{x:o},(function(e,t){return{x:function(){return mt.runKernelFunc((function(r){return r.resizeBilinearBackprop(e,t[0],n)}),{})}}}),"ResizeBilinear",{alignCorners:n,newHeight:i,newWidth:s});return a?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u}}),Zl=zn({resizeNearestNeighbor_:function(e,t,n){void 0===n&&(n=!1);var r=Sn(e,"images","resizeNearestNeighbor");ue(3===r.rank||4===r.rank,(function(){return"Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank "+r.rank+"."})),ue(2===t.length,(function(){return"Error in resizeNearestNeighbor: new shape must 2D, but got shape "+t+"."})),ue("float32"===r.dtype||"int32"===r.dtype,(function(){return"`images` must have `int32` or `float32` as dtype"}));var o=r,a=!1;3===r.rank&&(a=!0,o=r.as4D(1,r.shape[0],r.shape[1],r.shape[2]));var i=t[0],s=t[1],u=mt.runKernelFunc((function(e,t){return t([o]),e.resizeNearestNeighbor(o,i,s,n)}),{batchImages:o},(function(e,t){return{batchImages:function(){return mt.runKernelFunc((function(r){return r.resizeNearestNeighborBackprop(e,t[0],n)}),{})}}}));return a?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u}}),Yl=zn({nonMaxSuppression_:function(e,t,n,r,o){void 0===r&&(r=.5),void 0===o&&(o=Number.NEGATIVE_INFINITY);var a=Sn(e,"boxes","nonMaxSuppression"),i=Sn(t,"scores","nonMaxSuppression"),s=Kl(a,i,n,r,o);n=s.maxOutputSize,r=s.iouThreshold,o=s.scoreThreshold;var u={maxOutputSize:n,iouThreshold:r,scoreThreshold:o};return mt.runKernelFunc((function(e){return e.nonMaxSuppression(a,i,n,r,o)}),{boxes:a,scores:i},null,"NonMaxSuppressionV3",u)}}),Jl=zn({cropAndResize_:function(e,t,n,r,o,a){var i=Sn(e,"image","cropAndResize"),s=Sn(t,"boxes","cropAndResize","float32"),u=Sn(n,"boxInd","cropAndResize","int32");o=o||"bilinear",a=a||0;var c=s.shape[0];return ue(4===i.rank,(function(){return"Error in cropAndResize: image must be rank 4,but got rank "+i.rank+"."})),ue(2===s.rank&&4===s.shape[1],(function(){return"Error in cropAndResize: boxes must be have size ["+c+",4] but had shape "+s.shape+"."})),ue(1===u.rank&&u.shape[0]===c,(function(){return"Error in cropAndResize: boxInd must be have size ["+c+"] but had shape "+s.shape+"."})),ue(2===r.length,(function(){return"Error in cropAndResize: cropSize must be of length 2, but got length "+r.length+"."})),ue(r[0]>=1&&r[1]>=1,(function(){return"cropSize must be atleast [1,1], but was "+r})),ue("bilinear"===o||"nearest"===o,(function(){return"method must be bilinear or nearest, but was "+o})),mt.runKernelFunc((function(e,t){return e.cropAndResize(i,s,u,r,o,a)}),{images:i,boxes:s,boxInd:u},null,"CropAndResize",{method:o,extrapolationValue:a,cropSize:r})}}),Ql=Object.freeze({resizeBilinear:$l,resizeNearestNeighbor:Zl,nonMaxSuppression:Yl,nonMaxSuppressionAsync:function(e,t,n,r,o){return void 0===r&&(r=.5),void 0===o&&(o=Number.NEGATIVE_INFINITY),K(this,void 0,void 0,(function(){var a,i,s,u,c,l,f;return $(this,(function(h){switch(h.label){case 0:return a=Sn(e,"boxes","nonMaxSuppressionAsync"),i=Sn(t,"scores","nonMaxSuppressionAsync"),s=Kl(a,i,n,r,o),n=s.maxOutputSize,r=s.iouThreshold,o=s.scoreThreshold,[4,Promise.all([a.data(),i.data()])];case 1:return u=h.sent(),c=u[0],l=u[1],f=jo(c,l,n,r,o),a!==e&&a.dispose(),i!==t&&i.dispose(),[2,f]}}))}))},cropAndResize:Jl}),ef=function(e,t){return!(e>0)||"linear"===t},tf=function(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return e.mul(t.step());throw new Error("Gradient for activation "+n+" has not been implemented yet.")},nf=function(e,t){var n=t,r=go(e.shape,t.shape);return r.length>0&&(n=n.sum(r)),n.reshape(e.shape)},rf=function(e,t,n){if("linear"===t)return e;if("relu"===t)return al(e);if("elu"===t)return nl(e);if("relu6"===t)return il(e);if("prelu"===t)return ol(e,n);throw new Error("Unknown fused activation "+t+".")},of=zn({fusedMatMul_:function(e){var t,n=e.a,r=e.b,o=e.transposeA,a=void 0!==o&&o,i=e.transposeB,s=void 0!==i&&i,u=e.bias,c=e.activation,l=void 0===c?"linear":c,f=e.preluActivationWeights;if(!1===ef(mt.state.gradientDepth,l)){var h=Oc(n,r,a,s);return null!=u&&(h=Cu(h,u)),rf(h,l,f)}var p=Sn(n,"a","fused matMul"),d=Sn(r,"b","fused matMul");t=lt(p,d),p=t[0],d=t[1];var v=a?p.shape[p.rank-2]:p.shape[p.rank-1],m=s?d.shape[d.rank-1]:d.shape[d.rank-2],g=a?p.shape[p.rank-1]:p.shape[p.rank-2],y=s?d.shape[d.rank-2]:d.shape[d.rank-1],b=p.shape.slice(0,-2),w=d.shape.slice(0,-2),x=he(b),E=he(w);ue(p.rank>=2&&d.rank>=2&&p.rank===d.rank,(function(){return"Error in fused matMul: inputs must have the same rank of at least 2, got ranks "+p.rank+" and "+d.rank+"."})),ue(pe(b,w),(function(){return"Error in fused matMul: outer dimensions ("+b+") and ("+w+") of Tensors with shapes "+p.shape+" and "+d.shape+" must match."})),ue(v===m,(function(){return"Error in fused matMul: inner shapes ("+v+") and ("+m+") of Tensors with shapes "+p.shape+" and "+d.shape+" and transposeA="+a+" and transposeB="+s+" must match."}));var _,O,k=p.shape.slice(0,-2).concat([g,y]),C=a?p.as3D(x,v,g):p.as3D(x,g,v),I=s?d.as3D(E,y,m):d.as3D(E,m,y);null!=u&&yo(k,(_=lt(_=Sn(u,"bias","fused matMul"),p)[0]).shape),null!=f&&(O=Sn(f,"prelu weights","fused matMul"));var S={$a:C,$b:I};return null!=u&&(S.$bias=_),null!=f&&(S.$preluActivationWeights=O),mt.runKernelFunc((function(e,t){var n=e.fusedBatchMatMul({a:C,b:I,transposeA:a,transposeB:s,bias:_,activation:l,preluActivationWeights:O});return t([C,I,n]),n}),S,(function(e,t){var n=t[0],r=t[1],o=t[2],i=tf(e,o,l),c={};return null!=u&&(c={$bias:function(){return nf(_,i)}}),a||s?!a&&s?Object.assign({$a:function(){return i.matMul(r,!1,!1)},$b:function(){return i.matMul(n,!0,!1)}},c):a&&!s?Object.assign({$a:function(){return r.matMul(i,!1,!0)},$b:function(){return n.matMul(i,!1,!1)}},c):Object.assign({$a:function(){return r.matMul(i,!0,!0)},$b:function(){return i.matMul(n,!0,!0)}},c):Object.assign({$a:function(){return i.matMul(r,!1,!0)},$b:function(){return n.matMul(i,!0,!1)}},c)})).reshape(k)}}),af=zn({fusedConv2d_:function(e){var t=e.x,n=e.filter,r=e.strides,o=e.pad,a=e.dataFormat,i=void 0===a?"NHWC":a,s=e.dilations,u=void 0===s?[1,1]:s,c=e.dimRoundingMode,l=e.bias,f=e.activation,h=void 0===f?"linear":f,p=e.preluActivationWeights;if(h=h||"linear",!1===ef(mt.state.gradientDepth,h)){var d=dc(t,n,r,o,i,u,c);return null!=l&&(d=Cu(d,l)),rf(d,h,p)}var v=Sn(t,"x","conv2d"),m=Sn(n,"filter","conv2d"),g=v,y=!1;3===v.rank&&(y=!0,g=v.as4D(1,v.shape[0],v.shape[1],v.shape[2])),ue(4===g.rank,(function(){return"Error in fused conv2d: input must be rank 4, but got rank "+g.rank+"."})),ue(4===m.rank,(function(){return"Error in fused conv2d: filter must be rank 4, but got rank "+m.rank+"."})),null!=c&&ue(de(o),(function(){return"Error in fused conv2d: pad must be an integer when using, dimRoundingMode "+c+" but got pad "+o+"."})),ue(g.shape[3]===m.shape[2],(function(){return"Error in conv2d: depth of input ("+g.shape[3]+") must match input depth for filter "+m.shape[2]+"."})),ue(Ro(r,u),(function(){return"Error in conv2D: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'"})),ue("NHWC"===i,(function(){return"Error in conv2d: got dataFormat of "+i+" but only NHWC is currently supported."}));var b,w,x=xo(g.shape,m.shape,r,u,o,c);null!=l&&(b=lt(b=Sn(l,"bias","fused conv2d"),v)[0],yo(x.outShape,b.shape)),null!=p&&(w=Sn(p,"prelu weights","fused conv2d"));var E={x:g,filter:m};null!=l&&(E.bias=b),null!=p&&(E.preluActivationWeights=w);var _=[m,g],O=mt.runKernelFunc((function(e,t){var n=e.fusedConv2d({input:g,filter:m,convInfo:x,bias:b,activation:h,preluActivationWeights:w});return t([m,g,n]),n}),E,(function(e,t){var n=t,a=n[0],i=n[1],s=n[2],c=tf(e,s,h);ue(So(u),(function(){return"Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+u+"'"}));var f={};return null!=l&&(f={bias:function(){return nf(b,c)}}),Object.assign({x:function(){return gc(i.shape,c,a,r,o)},filter:function(){return mc(i,c,a.shape,r,o)}},f)}),"FusedConv2D",{convInfo:x,activation:h},_,[!0]);return y?O.as3D(O.shape[1],O.shape[2],O.shape[3]):O}}),sf=zn({fusedDepthwiseConv2d_:function(e){var t=e.x,n=e.filter,r=e.strides,o=e.pad,a=e.dataFormat,i=void 0===a?"NHWC":a,s=e.dilations,u=void 0===s?[1,1]:s,c=e.dimRoundingMode,l=e.bias,f=e.activation,h=void 0===f?"linear":f,p=e.preluActivationWeights;if(!1===ef(mt.state.gradientDepth,h)){var d=yc(t,n,r,o,i,u,c);return null!=l&&(d=Cu(d,l)),rf(d,h,p)}var v=Sn(t,"x","depthwiseConv2d"),m=Sn(n,"filter","depthwiseConv2d"),g=v,y=!1;3===v.rank&&(y=!0,g=v.as4D(1,v.shape[0],v.shape[1],v.shape[2])),ue(4===g.rank,(function(){return"Error in fused depthwiseConv2d: input must be rank 4, but got rank "+g.rank+"."})),ue(4===m.rank,(function(){return"Error in fused depthwiseConv2d: filter must be rank 4, but got rank "+m.rank+"."})),ue(g.shape[3]===m.shape[2],(function(){return"Error in fused depthwiseConv2d: number of input channels ("+g.shape[3]+") must match the inChannels dimension in filter "+m.shape[2]+"."})),null==u&&(u=[1,1]),ue(Ro(r,u),(function(){return"Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'"})),null!=c&&ue(de(o),(function(){return"Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode "+c+" but got pad "+o+"."}));var b,w,x=xo(g.shape,m.shape,r,u,o,c,!0);null!=l&&(b=lt(b=Sn(l,"bias","fused conv2d"),v)[0],yo(x.outShape,b.shape)),null!=p&&(w=Sn(p,"prelu weights","fused depthwiseConv2d"));var E={x:g,filter:m};null!=l&&(E.bias=b),null!=p&&(E.preluActivationWeights=w);var _=[m,g],O=mt.runKernelFunc((function(e,t){var n=e.fusedDepthwiseConv2D({input:g,filter:m,convInfo:x,bias:b,activation:h,preluActivationWeights:w});return t([m,g,n]),n}),E,(function(e,t){ue(So(u),(function(){return"Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '"+u+"'"}));var n=t[0],r=t[1],o=t[2],a=tf(e,o,h),i={};return null!=l&&(i={bias:function(){return nf(b,a)}}),Object.assign({x:function(){return bc(r.shape,a,n,x)},filter:function(){return wc(r,a,n.shape,x)}},i)}),"FusedDepthwiseConv2D",{convInfo:x,activation:h},_,[!0]);return y?O.as3D(O.shape[1],O.shape[2],O.shape[3]):O}}),uf=Object.freeze({matMul:of,conv2d:af,depthwiseConv2d:sf}),cf=Object.freeze({image:Ql,linalg:Xl,losses:Vl,spectral:xl,fused:uf,signal:Tl,square:ks,conv1d:pc,conv2d:dc,conv3d:vc,depthwiseConv2d:yc,separableConv2d:xc,conv2dTranspose:Ec,conv3dTranspose:_c,op:zn,batchNormalization2d:hu,batchNormalization3d:pu,batchNormalization4d:du,batchNormalization:vu,batchNorm:mu,batchNorm2d:gu,batchNorm3d:yu,batchNorm4d:bu,booleanMaskAsync:function(e,t,n){return K(this,void 0,void 0,(function(){var r,o,a,i,s,u,c,l,f,h,p,d,v;return $(this,(function(m){switch(m.label){case 0:for(r=Sn(e,"tensor","boolMask"),o=Sn(t,"mask","boolMask","bool"),a=null==n?0:n,i=o.rank,s=r.shape,ue(i>0,(function(){return"mask cannot be scalar"})),ce(s.slice(a,a+i),o.shape,"mask's shape must match the first K dimensions of tensor's shape,"),u=1,c=a;c<a+i;c++)u*=s[c];return l=s.slice(0,a).concat([u],s.slice(a+i)),f=r.reshape(l),h=o.reshape([-1]),[4,ku(h)];case 1:return p=m.sent(),d=p.squeeze([1]),v=uc(f,d,a),e!==r&&r.dispose(),t!==o&&o.dispose(),d.dispose(),f.dispose(),h.dispose(),p.dispose(),[2,v]}}))}))},complex:Wn,real:Vn,imag:Hn,concat:rr,concat1d:or,concat2d:ar,concat3d:ir,concat4d:sr,split:ur,matMul:Oc,dot:kc,outerProduct:Cc,reverse:Ic,reverse1d:Sc,reverse2d:Rc,reverse3d:Ac,reverse4d:Pc,maxPool:Mc,avgPool:Nc,pool:Fc,maxPool3d:Bc,avgPool3d:jc,slice:Lc,slice1d:zc,slice2d:Wc,slice3d:Vc,slice4d:Hc,abs:Cs,acos:Is,acosh:Ss,asin:Rs,asinh:As,atan:Ps,atanh:Ts,ceil:Ds,clipByValue:Ms,cos:Ns,cosh:Fs,erf:Bs,exp:js,expm1:Ls,floor:zs,log:Ws,log1p:Vs,logSigmoid:Hs,neg:Us,reciprocal:Gs,round:qs,rsqrt:Xs,sigmoid:Ks,sign:$s,isNaN:Zs,isInf:Ys,isFinite:Js,sin:Qs,sinh:eu,softplus:tu,sqrt:nu,step:ru,tan:ou,tanh:au,all:Gc,any:qc,argMax:Xc,argMin:Kc,logSumExp:$c,max:Zc,mean:Yc,min:Jc,moments:Qc,sum:el,prod:tl,equal:Ku,equalStrict:$u,greater:Zu,greaterEqual:Yu,greaterEqualStrict:Ju,greaterStrict:Qu,less:ec,lessEqual:tc,lessEqualStrict:nc,lessStrict:rc,notEqual:oc,notEqualStrict:ac,add:Cu,addN:Iu,addStrict:Su,atan2:Ru,div:Au,divNoNan:Pu,divStrict:Tu,floorDiv:Du,maximum:Mu,maximumStrict:Nu,minimum:Fu,minimumStrict:Bu,mod:ju,modStrict:Lu,mul:zu,mulStrict:Wu,pow:Vu,powStrict:Hu,squaredDifference:Uu,squaredDifferenceStrict:Gu,sub:qu,subStrict:Xu,elu:nl,leakyRelu:rl,prelu:ol,relu:al,relu6:il,selu:sl,logicalAnd:wu,logicalNot:xu,logicalOr:Eu,logicalXor:_u,where:Ou,whereAsync:ku,buffer:xr,print:function(e,t){void 0===t&&(t=!1),e.toString(t)},batchToSpaceND:Er,broadcastTo:_r,cast:Or,clone:kr,cumsum:Cr,depthToSpace:Ir,expandDims:Sr,eye:Rr,multinomial:Ar,oneHot:Pr,pad:Tr,pad1d:Dr,pad2d:Mr,pad3d:Nr,pad4d:Fr,rand:Br,randomNormal:jr,randomGamma:Lr,randomUniform:zr,reshape:Wr,spaceToBatchND:Vr,squeeze:Hr,stack:Ur,tile:Gr,truncatedNormal:qr,unstack:Xr,setdiff1dAsync:function(e,t){return K(this,void 0,void 0,(function(){var n,r,o,a,i,s,u,c,l,f;return $(this,(function(h){switch(h.label){case 0:return n=Sn(e,"x","setdiff1d"),r=Sn(t,"y","setdiff1d"),ue(n.dtype===r.dtype,(function(){return"x and y should have the same dtype, but got x ("+n.dtype+") and y ("+r.dtype+")."})),ue(1===n.rank,(function(){return"x should be 1D tensor, but got x ("+n.shape+")."})),ue(1===r.rank,(function(){return"y should be 1D tensor, but got y ("+r.shape+")."})),[4,n.data()];case 1:return o=h.sent(),[4,r.data()];case 2:for(a=h.sent(),i=new Set(a),s=0,l=0;l<o.length;l++)i.has(o[l])||s++;for(u=new Ze([s],n.dtype),c=new Ze([s],"int32"),l=0,f=0;l<o.length;l++)i.has(o[l])||(u.values[f]=o[l],c.values[f]=l,f++);return[2,[u.toTensor(),c.toTensor()]]}}))}))},fill:Qn,linspace:function(e,t,n){if(n<=0)throw new Error("The number of values should be positive.");return mt.runKernelFunc((function(r){return r.linspace(e,t,n)}),{})},ones:Yn,range:er,scalar:qn,tensor:Un,tensor1d:Xn,tensor2d:Kn,tensor3d:$n,tensor4d:Zn,tensor5d:function(e,t,n){if(le(e),null!=t&&5!==t.length)throw new Error("tensor5d() requires shape to have five numbers");var r=Cn(e,n);if(5!==r.length&&1!==r.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return Gn(e,t,r,n)},tensor6d:function(e,t,n){if(le(e),null!=t&&6!==t.length)throw new Error("tensor6d() requires shape to have six numbers");var r=Cn(e,n);if(6!==r.length&&1!==r.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return Gn(e,t=t||r,r,n)},variable:function(e,t,n,r){return void 0===t&&(t=!0),mt.makeVariable(e,t,n,r)},zeros:Jn,onesLike:tr,zerosLike:nr,transpose:ul,softmax:lo,logSoftmax:fo,localResponseNormalization:cl,norm:ll,gather:uc,unsortedSegmentSum:cc,basicLSTMCell:fl,multiRNNCell:hl,movingAverage:pl,stridedSlice:dl,topk:vl,scatterND:ml,fft:gl,ifft:yl,rfft:bl,irfft:wl,sparseToDense:El,gatherND:_l,diag:Ol,dropout:kl,hannWindow:Sl,hammingWindow:Rl,frame:Al,stft:Pl,inTopKAsync:function(e,t,n){return void 0===n&&(n=1),K(this,void 0,void 0,(function(){var r,o,a,i,s,u,c,l,f,h,p,d,v,m;return $(this,(function(g){switch(g.label){case 0:return r=Sn(e,"predictions","inTopK"),o=Sn(t,"targets","inTopK"),ue(r.rank>1,(function(){return"inTopK() expects the predictions to be of rank 2 or higher, but got "+r.rank})),ue(r.rank-1===o.rank,(function(){return"predictions rank should be 1 larger than targets rank, but got predictions rank "+r.rank+" and targets rank "+o.rank})),ce(r.shape.slice(0,r.shape.length-1),o.shape,"predictions's shape should be align with the targets' shape, except the last dimension."),a=r.shape[r.shape.length-1],ue(n>0&&n<=a,(function(){return"'k' passed to inTopK() must be > 0 && <= the predictions last dimension ("+a+"), but got "+n})),[4,r.data()];case 1:return i=g.sent(),[4,o.data()];case 2:for(s=g.sent(),u=[i.length/a,a],l=u[1],f=Ee("bool",c=u[0]),h=0;h<c;h++){for(p=h*l,d=i.subarray(p,p+l),v=[],m=0;m<d.length;m++)v.push({value:d[m],index:m});for(v.sort((function(e,t){return t.value-e.value})),f[h]=0,m=0;m<n;m++)if(v[m].index===s[h]){f[h]=1;break}}return e!==r&&r.dispose(),t!==o&&o.dispose(),[2,Un(f,o.shape,"bool")]}}))}))}});function lf(e,t){Array.isArray(e)||(e=[e]),e.forEach((function(e){null!=e&&ue("complex64"!==e.dtype,(function(){return t+" does not support complex64 tensors."}))}))}function ff(e,t,n,r){if("linear"===n)return e.linear(t);if("relu"===n)return e.relu(t);if("elu"===n)return e.elu(t);if("relu6"===n)return e.relu6(t);if("prelu"===n)return e.prelu(t,r);throw new Error("Activation "+n+" has not been implemented for the CPU backend.")}var hf=function(e){function t(){var t=e.call(this)||this;return t.blockSize=48,t.firstUse=!0,t.data=new ho(t,mt),t}return X(t,e),t.prototype.write=function(e,t,n){this.firstUse&&(this.firstUse=!1,Y().get("IS_NODE")&&kn("\n============================\nHi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.\n============================\n"));var r={};return this.data.set(r,{values:e,dtype:n}),r},t.prototype.move=function(e,t,n,r){this.data.set(e,{values:t,dtype:r})},t.prototype.numDataIds=function(){return this.data.numDataIds()},t.prototype.read=function(e){return K(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.readSync(e)]}))}))},t.prototype.readSync=function(e){var t=this.data.get(e),n=t.dtype,r=t.complexTensors;return"complex64"===n?Mo(this.readSync(r.real.dataId),this.readSync(r.imag.dataId)):this.data.get(e).values},t.prototype.bufferSync=function(e){var t=this.readSync(e.dataId),n=t;if("string"===e.dtype)try{n=t.map((function(e){return Ue(e)}))}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return xr(e.shape,e.dtype,n)},t.prototype.makeOutput=function(e,t,n){var r=this.write(e,t,n);return mt.makeTensorFromDataId(r,t,n,this)},t.prototype.disposeData=function(e){if(this.data.has(e)){var t=this.data.get(e).complexTensors;null!=t&&(t.real.dispose(),t.imag.dispose()),this.data.delete(e)}},t.prototype.time=function(e){return K(this,void 0,void 0,(function(){var t;return $(this,(function(n){return t=We(),e(),[2,{kernelMs:We()-t}]}))}))},t.prototype.memory=function(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}},t.prototype.complex=function(e,t){var n=this.makeOutput(null,e.shape,"complex64");return this.data.get(n.dataId).complexTensors={real:mt.keep(e.clone()),imag:mt.keep(t.clone())},n},t.prototype.real=function(e){return this.data.get(e.dataId).complexTensors.real.clone()},t.prototype.imag=function(e){return this.data.get(e.dataId).complexTensors.imag.clone()},t.prototype.slice=function(e,t,n){if(lf(e,"slice"),so(e.shape,t,n)){var r=uo(t,e.strides),o=he(n);return Un(this.readSync(e.dataId).subarray(r,r+o),n,e.dtype)}for(var a=xr(n,e.dtype),i=this.bufferSync(e),s=0;s<a.size;++s){var u=a.indexToLoc(s).map((function(e,n){return e+t[n]}));a.values[s]=i.get.apply(i,u)}return a.toTensor()},t.prototype.stridedSlice=function(e,t,n,r){lf(e,"stridedSlice");var o=oo(t,n,r);if(o.some((function(e){return 0===e})))return Un([],o);for(var a=xr(o,e.dtype),i=this.bufferSync(e),s=0;s<a.size;s++){for(var u=a.indexToLoc(s),c=new Array(u.length),l=0;l<c.length;l++)c[l]=u[l]*r[l]+t[l];a.set.apply(a,[i.get.apply(i,c)].concat(u))}return a.toTensor()},t.prototype.diag=function(e){for(var t=this.readSync(e.dataId),n=xr([e.size,e.size],e.dtype),r=n.values,o=0;o<t.length;o++)r[o*e.size+o]=t[o];return n.toTensor()},t.prototype.unstack=function(e,t){for(var n=e.shape[t],r=new Array(e.rank-1),o=0,a=0;a<e.rank;a++)a!==t&&(r[o++]=e.shape[a]);var i=new Array(e.rank).fill(0),s=e.shape.slice();s[t]=1;var u=new Array(n);for(a=0;a<u.length;a++)i[t]=a,u[a]=this.slice(e,i,s).reshape(r);return u},t.prototype.reverse=function(e,t){lf(e,"reverse");for(var n=xr(e.shape,e.dtype),r=this.bufferSync(e),o=function(o){var a=n.indexToLoc(o),i=a.slice();t.forEach((function(t){return i[t]=e.shape[t]-1-i[t]})),n.set.apply(n,[r.get.apply(r,i)].concat(a))},a=0;a<n.size;a++)o(a);return n.toTensor()},t.prototype.concat=function(e,t){var n=this;if("complex64"===e[0].dtype){var r=e.map((function(e){return Vn(e)})),o=e.map((function(e){return Hn(e)}));return Wn(this.concat(r,t),this.concat(o,t))}var a=e.map((function(e){var n=he(e.shape.slice(t));return e.as2D(-1,n)})),i=Ln(a.map((function(e){return e.shape})),1),s=xr(i,e[0].dtype).values;if(1===a[0].shape[0]){var u=0;a.forEach((function(e){s.set(n.readSync(e.dataId),u),u+=e.size}))}else{var c=0;a.forEach((function(e){for(var t=n.readSync(e.dataId),r=0,o=0;o<e.shape[0];++o)for(var a=o*i[1]+c,u=0;u<e.shape[1];++u)s[a+u]=t[r++];c+=e.shape[1]}))}var l=Ln(e.map((function(e){return e.shape})),t);return Un(s,l,e[0].dtype)},t.prototype.neg=function(e){return lf(e,"neg"),this.multiply(qn(-1),e)},t.prototype.add=function(e,t){return"complex64"===e.dtype||"complex64"===t.dtype?this.broadcastedBinaryComplexOp(e.cast("complex64"),t.cast("complex64"),(function(e,t,n,r){return{real:e+n,imag:t+r}})):this.broadcastedBinaryOp(e,t,ut(e.dtype,t.dtype),(function(e,t){return e+t}))},t.prototype.addN=function(e){var t=this;lf(e,"addN");for(var n=e.map((function(e){return t.readSync(e.dataId)})),r=xr(e[0].shape,e[0].dtype),o=r.values,a=0;a<e.length;a++)for(var i=n[a],s=0;s<o.length;s++)o[s]+=i[s];return r.toTensor()},t.prototype.subtract=function(e,t){return"complex64"===e.dtype||"complex64"===t.dtype?this.broadcastedBinaryComplexOp(e.cast("complex64"),t.cast("complex64"),(function(e,t,n,r){return{real:e-n,imag:t-r}})):this.broadcastedBinaryOp(e,t,ut(e.dtype,t.dtype),(function(e,t){return e-t}))},t.prototype.pow=function(e,t){return lf([e,t],"pow"),this.broadcastedBinaryOp(e,t,e.dtype,(function(e,t){return Math.pow(e,t)}))},t.prototype.batchMatMul=function(e,t,n,r){lf([e,t],"matMul");for(var o=n?e.shape[1]:e.shape[2],a=n?e.shape[2]:e.shape[1],i=r?t.shape[1]:t.shape[2],s=e.shape[0],u=this.readSync(e.dataId),c=this.readSync(t.dataId),l=n?[e.strides[0],1,e.strides[1]]:[e.strides[0],e.strides[1],1],f=l[0],h=l[1],p=l[2],d=r?[1,t.strides[1],t.strides[0]]:[t.strides[1],1,t.strides[0]],v=d[0],m=d[1],g=d[2],y=a*i,b=xr([s,a,i],e.dtype),w=b.values,x=this.blockSize,E=0;E<s;E++)for(var _=0;_<a;_+=x)for(var O=0;O<i;O+=x)for(var k=0;k<o;k+=x)for(var C=Math.min(_+x,a),I=Math.min(O+x,i),S=Math.min(k+x,o),R=_;R<C;R++)for(var A=O;A<I;A++){for(var P=0,T=k;T<S;T++)P+=u[E*f+R*h+T*p]*c[T*v+A*m+E*g];w[E*y+(R*i+A)]+=P}return b.toTensor()},t.prototype.fusedBatchMatMul=function(e){var t=e.a,n=e.b,r=e.transposeA,o=e.transposeB,a=e.bias,i=e.activation,s=e.preluActivationWeights,u=this.batchMatMul(t,n,r,o);return a&&(u=this.add(u,a)),i&&(u=ff(this,u,i,s)),u},t.prototype.multiply=function(e,t){return"complex64"===e.dtype||"complex64"===t.dtype?this.broadcastedBinaryComplexOp(e.cast("complex64"),t.cast("complex64"),(function(e,t,n,r){return{real:e*n-t*r,imag:e*r+t*n}})):this.broadcastedBinaryOp(e,t,ut(e.dtype,t.dtype),(function(e,t){return e*t}))},t.prototype.realDivide=function(e,t){return lf([e,t],"realDivide"),this.broadcastedBinaryOp(e,t,"float32",(function(e,t){return e/t}))},t.prototype.floorDiv=function(e,t){return lf([e,t],"floorDiv"),this.broadcastedBinaryOp(e,t,"int32",(function(e,t){return Math.floor(e/t)}))},t.prototype.sum=function(e,t){lf(e,"sum"),Mn("sum",t,e.rank);for(var n=Tn(e.shape,t),r=n[0],o=n[1],a=Jn(r,ut(e.dtype,"int32")),i=he(o),s=this.readSync(a.dataId),u=this.readSync(e.dataId),c=0;c<s.length;++c){for(var l=c*i,f=0,h=0;h<i;++h)f+=u[l+h];s[c]=f}return a},t.prototype.prod=function(e,t){lf(e,"sum");for(var n=Tn(e.shape,t),r=n[0],o=n[1],a=Jn(r,ut(e.dtype,"int32")),i=he(o),s=this.readSync(a.dataId),u=this.readSync(e.dataId),c=0;c<s.length;++c){for(var l=c*i,f=1,h=0;h<i;++h)f*=u[l+h];s[c]=f}return a},t.prototype.unsortedSegmentSum=function(e,t,n){lf(e,"unsortedSegmentSum");for(var r=[],o=e.rank-t.rank,a=0;a<o;++a)t=t.expandDims(a+1);for(a=0;a<n;++a){var i=qn(a,"int32"),s=Ku(i,t).asType("float32").mul(e).sum(0);r.push(s)}return Ur(r)},t.prototype.argMin=function(e,t){lf(e,"argMin");var n=[t];Mn("argMin",n,e.rank);for(var r=Tn(e.shape,n),o=r[0],a=r[1],i=Jn(o,"int32"),s=he(a),u=this.readSync(i.dataId),c=this.readSync(e.dataId),l=0;l<u.length;++l){for(var f=l*s,h=c[f],p=0,d=0;d<s;++d){var v=c[f+d];v<h&&(h=v,p=d)}u[l]=p}return i},t.prototype.argMax=function(e,t){lf(e,"argMax");var n=[t];Mn("argMax",n,e.rank);for(var r=Tn(e.shape,n),o=r[0],a=r[1],i=Jn(o,"int32"),s=he(a),u=this.readSync(i.dataId),c=this.readSync(e.dataId),l=0;l<u.length;++l){for(var f=l*s,h=c[f],p=0,d=0;d<s;++d){var v=c[f+d];v>h&&(h=v,p=d)}u[l]=p}return i},t.prototype.cumsum=function(e,t,n,r){if(lf(e,"cumsum"),t!==e.rank-1)throw new Error("backend.cumsum in CPU expects an inner-most axis="+(e.rank-1)+" but got axis="+t);for(var o=ut(e.dtype,"int32"),a=Jn(e.shape,o),i=this.readSync(a.dataId),s=this.readSync(e.dataId),u=e.shape[e.rank-1],c=r?function(e,t){return e+u-t-1}:function(e,t){return e+t},l=0;l<s.length;l+=u)for(var f=0;f<u;f++){var h=c(l,f);if(0===f)i[h]=n?0:s[h];else{var p=c(l,f-1);i[h]=n?s[p]+i[p]:s[h]+i[p]}}return a},t.prototype.equal=function(e,t){return lf([e,t],"equal"),this.broadcastedBinaryOp(e,t,"bool",(function(e,t){return e===t?1:0}))},t.prototype.notEqual=function(e,t){return lf([e,t],"notEqual"),this.broadcastedBinaryOp(e,t,"bool",(function(e,t){return e!==t?1:0}))},t.prototype.less=function(e,t){return lf([e,t],"less"),this.broadcastedBinaryOp(e,t,"bool",(function(e,t){return e<t?1:0}))},t.prototype.lessEqual=function(e,t){return lf([e,t],"lessEqual"),this.broadcastedBinaryOp(e,t,"bool",(function(e,t){return e<=t?1:0}))},t.prototype.greater=function(e,t){return lf([e,t],"greater"),this.broadcastedBinaryOp(e,t,"bool",(function(e,t){return e>t?1:0}))},t.prototype.greaterEqual=function(e,t){return lf([e,t],"greaterEqual"),this.broadcastedBinaryOp(e,t,"bool",(function(e,t){return e>=t?1:0}))},t.prototype.logicalNot=function(e){lf(e,"logicalNot");for(var t=this.readSync(e.dataId),n=new Uint8Array(t.length),r=0;r<t.length;++r)n[r]=t[r]?0:1;return this.makeOutput(n,e.shape,"bool")},t.prototype.logicalAnd=function(e,t){return lf([e,t],"logicalAnd"),this.broadcastedBinaryOp(e,t,"bool",(function(e,t){return e&&t}))},t.prototype.logicalOr=function(e,t){return lf([e,t],"logicalOr"),this.broadcastedBinaryOp(e,t,"bool",(function(e,t){return e||t}))},t.prototype.select=function(e,t,n){lf([e,t,n],"select");for(var r=this.readSync(e.dataId),o=this.readSync(t.dataId),a=this.readSync(n.dataId),i=Jn(t.shape,ut(t.dtype,n.dtype)),s=this.readSync(i.dataId),u=0,c=0===e.rank||e.rank>1||1===t.rank?1:he(t.shape.slice(1)),l=0;l<r.length;l++)for(var f=0;f<c;f++)1===r[l]?s[u++]=o[l]:s[u++]=a[l];return i},t.prototype.where=function(e){lf([e],"where");var t=this.readSync(e.dataId);return Ho(e.shape,t)},t.prototype.topk=function(e,t,n){return lf(e,"topk"),Vo(this.readSync(e.dataId),e.shape,e.dtype,t)},t.prototype.min=function(e,t){lf(e,"min"),Mn("min",t,e.rank);for(var n=Tn(e.shape,t),r=n[0],o=n[1],a=Jn(r,e.dtype),i=he(o),s=this.readSync(a.dataId),u=this.readSync(e.dataId),c=0;c<s.length;++c){for(var l=c*i,f=u[l],h=0;h<i;++h){var p=u[l+h];p<f&&(f=p)}s[c]=f}return a},t.prototype.minimum=function(e,t){return lf([e,t],"minimum"),this.broadcastedBinaryOp(e,t,e.dtype,(function(e,t){return Math.min(e,t)}))},t.prototype.mod=function(e,t){return lf([e,t],"mod"),this.broadcastedBinaryOp(e,t,e.dtype,(function(e,t){var n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t}))},t.prototype.max=function(e,t){lf(e,"max"),Mn("max",t,e.rank);for(var n=Tn(e.shape,t),r=n[0],o=n[1],a=Jn(r,e.dtype),i=he(o),s=this.readSync(a.dataId),u=this.readSync(e.dataId),c=0;c<s.length;++c){for(var l=c*i,f=u[l],h=0;h<i;++h){var p=u[l+h];p>f&&(f=p)}s[c]=f}return a},t.prototype.maximum=function(e,t){return lf([e,t],"maximum"),this.broadcastedBinaryOp(e,t,e.dtype,(function(e,t){return Math.max(e,t)}))},t.prototype.all=function(e,t){lf(e,"all"),Mn("all",t,e.rank);for(var n=Tn(e.shape,t),r=n[0],o=n[1],a=Jn(r,e.dtype),i=he(o),s=this.readSync(a.dataId),u=this.readSync(e.dataId),c=0;c<s.length;++c){for(var l=c*i,f=u[l],h=0;h<i;++h){var p=u[l+h];f=f&&p}s[c]=f}return a},t.prototype.any=function(e,t){lf(e,"any"),Mn("any",t,e.rank);for(var n=Tn(e.shape,t),r=n[0],o=n[1],a=Jn(r,e.dtype),i=he(o),s=this.readSync(a.dataId),u=this.readSync(e.dataId),c=0;c<s.length;++c){for(var l=c*i,f=u[l],h=0;h<i;++h){var p=u[l+h];f=f||p}s[c]=f}return a},t.prototype.squaredDifference=function(e,t){return lf([e,t],"squaredDifference"),this.broadcastedBinaryOp(e,t,e.dtype,(function(e,t){var n=e-t;return n*n}))},t.prototype.ceil=function(e){lf(e,"ceil");for(var t=this.readSync(e.dataId),n=new Float32Array(t.length),r=0;r<t.length;++r)n[r]=Math.ceil(t[r]);return this.makeOutput(n,e.shape,"float32")},t.prototype.floor=function(e){lf(e,"floor");for(var t=this.readSync(e.dataId),n=new Float32Array(t.length),r=0;r<t.length;++r)n[r]=Math.floor(t[r]);return this.makeOutput(n,e.shape,"float32")},t.prototype.sign=function(e){lf(e,"x");for(var t=this.readSync(e.dataId),n=new Float32Array(t.length),r=0;r<t.length;++r)t[r]<0?n[r]=-1:t[r]>0?n[r]=1:n[r]=0;return this.makeOutput(n,e.shape,"float32")},t.prototype.isNaN=function(e){lf(e,"x");for(var t=this.readSync(e.dataId),n=new Uint8Array(t.length),r=0;r<t.length;++r)Number.isNaN(t[r])&&(n[r]=1);return this.makeOutput(n,e.shape,"bool")},t.prototype.isInf=function(e){lf(e,"x");for(var t=this.readSync(e.dataId),n=new Uint8Array(t.length),r=0;r<t.length;++r)Math.abs(t[r])===1/0&&(n[r]=1);return this.makeOutput(n,e.shape,"bool")},t.prototype.isFinite=function(e){lf(e,"x");for(var t=this.readSync(e.dataId),n=new Uint8Array(t.length),r=0;r<t.length;++r)Number.isFinite(t[r])&&(n[r]=1);return this.makeOutput(n,e.shape,"bool")},t.prototype.round=function(e){lf(e,"round");for(var t=this.readSync(e.dataId),n=new Float32Array(t.length),r=0;r<t.length;++r){var o=Math.floor(t[r]);t[r]-o<.5?n[r]=Math.floor(t[r]):t[r]-o>.5?n[r]=Math.ceil(t[r]):n[r]=o%2==0?o:o+1}return this.makeOutput(n,e.shape,"float32")},t.prototype.exp=function(e){lf(e,"exp");for(var t=this.readSync(e.dataId),n=new Float32Array(t.length),r=0;r<t.length;++r)n[r]=Math.exp(t[r]);return this.makeOutput(n,e.shape,"float32")},t.prototype.expm1=function(e){lf(e,"expm1");for(var t=this.readSync(e.dataId),n=new Float32Array(t.length),r=0;r<t.length;++r)n[r]=Math.expm1(t[r]);return this.makeOutput(n,e.shape,"float32")},t.prototype.log=function(e){lf(e,"log");for(var t=this.readSync(e.dataId),n=new Float32Array(t.length),r=0;r<t.length;++r){var o=t[r];n[r]=Math.log(o)}return this.makeOutput(n,e.shape,"float32")},t.prototype.log1p=function(e){lf(e,"log1p");for(var t=this.readSync(e.dataId),n=new Float32Array(t.length),r=0;r<t.length;++r){var o=t[r];n[r]=Math.log1p(o)}return this.makeOutput(n,e.shape,"float32")},t.prototype.sqrt=function(e){lf(e,"sqrt");for(var t=this.readSync(e.dataId),n=new Float32Array(t.length),r=0;r<t.length;++r){var o=t[r];n[r]=Math.sqrt(o)}return this.makeOutput(n,e.shape,"float32")},t.prototype.rsqrt=function(e){lf(e,"rsqrt");for(var t=this.readSync(e.dataId),n=new Float32Array(t.length),r=0;r<t.length;++r){var o=t[r];n[r]=1/Math.sqrt(o)}return this.makeOutput(n,e.shape,"float32")},t.prototype.reciprocal=function(e){lf(e,"reciprocal");for(var t=this.readSync(e.dataId),n=new Float32Array(t.length),r=0;r<t.length;++r)n[r]=1/t[r];return this.makeOutput(n,e.shape,"float32")},t.prototype.linear=function(e){return e},t.prototype.relu=function(e){lf(e,"relu");for(var t=Jn(e.shape,e.dtype),n=this.readSync(t.dataId),r=this.readSync(e.dataId),o=0;o<r.length;++o)n[o]=Math.max(0,r[o]);return t},t.prototype.relu6=function(e){lf(e,"relu");for(var t=Jn(e.shape,e.dtype),n=this.readSync(t.dataId),r=this.readSync(e.dataId),o=0;o<r.length;++o)n[o]=Math.min(Math.max(0,r[o]),6);return t},t.prototype.prelu=function(e,t){return lf([e,t],"prelu"),this.broadcastedBinaryOp(e,t,e.dtype,(function(e,t){return e<0?t*e:e}))},t.prototype.elu=function(e){lf(e,"elu");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r){var o=n[r];t[r]=o>=0?o:Math.exp(o)-1}return this.makeOutput(t,e.shape,"float32")},t.prototype.eluDer=function(e,t){lf([e,t],"eluDer");for(var n=new Float32Array(t.size),r=this.readSync(t.dataId),o=this.readSync(e.dataId),a=0;a<r.length;++a){var i=r[a];n[a]=i>=1?o[a]:o[a]*(i+1)}return this.makeOutput(n,t.shape,"float32")},t.prototype.selu=function(e){lf(e,"selu");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r){var o=n[r];t[r]=o>=0?1.0507009873554805*o:1.7580993408473768*(Math.exp(o)-1)}return this.makeOutput(t,e.shape,"float32")},t.prototype.clip=function(e,t,n){lf(e,"clip");for(var r=new Float32Array(e.size),o=this.readSync(e.dataId),a=0;a<o.length;++a){var i=o[a];r[a]=i>n?n:i<t?t:i}return this.makeOutput(r,e.shape,"float32")},t.prototype.abs=function(e){for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=Math.abs(n[r]);return this.makeOutput(t,e.shape,"float32")},t.prototype.complexAbs=function(e){for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<e.size;++r){var o=n[2*r],a=n[2*r+1];t[r]=Math.hypot(o,a)}return this.makeOutput(t,e.shape,"float32")},t.prototype.int=function(e){lf(e,"int");for(var t=new Int32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=n[r];return this.makeOutput(t,e.shape,"int32")},t.prototype.sigmoid=function(e){lf(e,"sigmoid");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=1/(1+Math.exp(-n[r]));return this.makeOutput(t,e.shape,"float32")},t.prototype.softplus=function(e){lf(e,"softplus");for(var t=Math.log(1.1920928955078125e-7)+2,n=new Float32Array(e.size),r=this.readSync(e.dataId),o=0;o<r.length;++o){var a,i=r[o]>-t,s=r[o]<t,u=Math.exp(r[o]);a=s?u:i?r[o]:Math.log(1+u),n[o]=a}return this.makeOutput(n,e.shape,"float32")},t.prototype.sin=function(e){lf(e,"sin");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=Math.sin(n[r]);return this.makeOutput(t,e.shape,"float32")},t.prototype.cos=function(e){lf(e,"cos");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=Math.cos(n[r]);return this.makeOutput(t,e.shape,"float32")},t.prototype.tan=function(e){lf(e,"tan");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=Math.tan(n[r]);return this.makeOutput(t,e.shape,"float32")},t.prototype.asin=function(e){lf(e,"asin");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=Math.asin(n[r]);return this.makeOutput(t,e.shape,"float32")},t.prototype.acos=function(e){lf(e,"acos");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=Math.acos(n[r]);return this.makeOutput(t,e.shape,"float32")},t.prototype.atan=function(e){lf(e,"atan");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=Math.atan(n[r]);return this.makeOutput(t,e.shape,"float32")},t.prototype.atan2=function(e,t){return lf([e,t],"atan2"),this.broadcastedBinaryOp(e,t,e.dtype,(function(e,t){return Math.atan2(e,t)}))},t.prototype.sinh=function(e){lf(e,"sinh");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=Math.sinh(n[r]);return this.makeOutput(t,e.shape,"float32")},t.prototype.cosh=function(e){lf(e,"cosh");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=Math.cosh(n[r]);return this.makeOutput(t,e.shape,"float32")},t.prototype.tanh=function(e){lf(e,"tanh");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=ve(n[r]);return this.makeOutput(t,e.shape,"float32")},t.prototype.asinh=function(e){lf(e,"asinh");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=Math.asinh(n[r]);return this.makeOutput(t,e.shape,"float32")},t.prototype.acosh=function(e){lf(e,"acosh");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=Math.acosh(n[r]);return this.makeOutput(t,e.shape,"float32")},t.prototype.atanh=function(e){lf(e,"atanh");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r)t[r]=Math.atanh(n[r]);return this.makeOutput(t,e.shape,"float32")},t.prototype.erf=function(e){lf(e,"erf");for(var t=new Float32Array(e.size),n=this.readSync(e.dataId),r=0;r<n.length;++r){var o=Math.sign(n[r]),a=Math.abs(n[r]),i=1/(1+.3275911*a);t[r]=o*(1-((((1.061405429*i-1.453152027)*i+1.421413741)*i-.284496736)*i+.254829592)*i*Math.exp(-a*a))}return this.makeOutput(t,e.shape,"float32")},t.prototype.step=function(e,t){void 0===t&&(t=0),lf(e,"step");for(var n=new Float32Array(e.size),r=this.readSync(e.dataId),o=0;o<r.length;++o){var a=r[o];isNaN(a)?n[o]=NaN:n[o]=a>0?1:t}return this.makeOutput(n,e.shape,"float32")},t.prototype.fusedConv2d=function(e){var t=e.input,n=e.filter,r=e.convInfo,o=e.bias,a=e.activation,i=e.preluActivationWeights,s=this.conv2d(t,n,r);return o&&(s=this.add(s,o)),a&&(s=ff(this,s,a,i)),s},t.prototype.conv2d=function(e,t,n){lf([e,t],"conv2d");for(var r=n.filterHeight,o=n.filterWidth,a=n.dilationHeight,i=n.dilationWidth,s=n.padInfo.left,u=n.padInfo.top,c="channelsLast"===n.dataFormat,l=xr(n.outShape,e.dtype),f=e.strides[0],h=c?e.strides[1]:e.strides[2],p=c?e.strides[2]:1,d=c?1:e.strides[1],v=l.strides[0],m=c?l.strides[1]:l.strides[2],g=c?l.strides[2]:1,y=c?1:l.strides[1],b=this.readSync(e.dataId),w=this.readSync(t.dataId),x=l.values,E=0;E<n.batchSize;++E)for(var _=E*f,O=E*v,k=0;k<n.outHeight;++k)for(var C=O+k*m,I=k*n.strideHeight-u,S=0;S<r;S++){var R=I+S*a;if(!(R<0||R>=n.inHeight))for(var A=S*t.strides[0],P=_+R*h,T=0;T<n.outWidth;++T)for(var D=C+T*g,M=T*n.strideWidth-s,N=0;N<o;N++){var F=M+N*i;if(!(F<0||F>=n.inWidth))for(var B=P+F*p,j=A+N*t.strides[1],L=0;L<n.inChannels;++L){for(var z=b[B+L*d],W=0;W<n.outChannels;++W)x[D+W*y]+=z*w[j+W];j+=n.outChannels}}}return l.toTensor()},t.prototype.conv3d=function(e,t,n){for(var r=n.filterDepth,o=n.filterHeight,a=n.filterWidth,i=n.dilationDepth,s=n.dilationHeight,u=n.dilationWidth,c=n.padInfo.front,l=n.padInfo.left,f=n.padInfo.top,h=xr(n.outShape,e.dtype),p=this.readSync(e.dataId),d=this.readSync(t.dataId),v=h.values,m=0;m<n.batchSize;++m)for(var g=m*e.strides[0],y=m*h.strides[0],b=0;b<n.outDepth;++b)for(var w=y+b*h.strides[1],x=b*n.strideDepth-c,E=0;E<r;E++){var _=x+E*i;if(!(_<0||_>=n.inDepth))for(var O=E*t.strides[0],k=g+_*e.strides[1],C=0;C<n.outHeight;++C)for(var I=w+C*h.strides[2],S=C*n.strideHeight-f,R=0;R<o;R++){var A=S+R*s;if(!(A<0||A>=n.inHeight))for(var P=O+R*t.strides[1],T=k+A*e.strides[2],D=0;D<n.outWidth;++D)for(var M=I+D*n.outChannels,N=D*n.strideWidth-l,F=0;F<a;F++){var B=N+F*u;if(!(B<0||B>=n.inWidth))for(var j=P+F*t.strides[2],L=T+B*n.inChannels,z=j,W=0;W<n.inChannels;++W){for(var V=p[L+W],H=0;H<n.outChannels;++H)v[M+H]+=V*d[z+H];z+=n.outChannels}}}}return h.toTensor()},t.prototype.conv2dDerInput=function(e,t,n){lf([e,t],"conv2dDerInput");for(var r=xr(n.inShape,"float32"),o=r.values,a=this.readSync(e.dataId),i=this.readSync(t.dataId),s=t.strides,u=s[0],c=s[1],l=s[2],f=n.batchSize,h=n.filterHeight,p=n.filterWidth,d=n.inChannels,v=n.inHeight,m=n.inWidth,g=n.outChannels,y=n.outHeight,b=n.outWidth,w=n.strideHeight,x=n.strideWidth,E=n.dataFormat,_=h-1-n.padInfo.top,O=p-1-n.padInfo.left,k="channelsLast"===E,C=r.strides[0],I=k?r.strides[1]:r.strides[2],S=k?r.strides[2]:1,R=k?1:r.strides[1],A=e.strides[0],P=k?e.strides[1]:e.strides[2],T=k?e.strides[2]:1,D=k?1:e.strides[1],M=0;M<f;++M)for(var N=0;N<d;++N)for(var F=0;F<v;++F)for(var B=F-_,j=Math.max(0,Math.ceil(B/w)),L=Math.min(y,(h+B)/w),z=0;z<m;++z){for(var W=z-O,V=Math.max(0,Math.ceil(W/x)),H=Math.min(b,(p+W)/x),U=0,G=j;G<L;++G)for(var q=G*w-B,X=V;X<H;++X)for(var K=A*M+P*G+T*X,$=u*(h-1-q)+c*(p-1-(X*x-W))+l*N,Z=0;Z<g;++Z)U+=a[K+D*Z]*i[$+Z];o[C*M+I*F+S*z+R*N]=U}return r.toTensor()},t.prototype.conv3dDerInput=function(e,t,n){for(var r=xr(n.inShape,"float32"),o=r.values,a=r.strides,i=a[0],s=a[1],u=a[2],c=a[3],l=this.readSync(e.dataId),f=e.strides,h=f[0],p=f[1],d=f[2],v=f[3],m=this.readSync(t.dataId),g=t.strides,y=g[0],b=g[1],w=g[2],x=g[3],E=n.batchSize,_=n.filterDepth,O=n.filterHeight,k=n.filterWidth,C=n.inChannels,I=n.inDepth,S=n.inHeight,R=n.inWidth,A=n.outChannels,P=n.outDepth,T=n.outHeight,D=n.outWidth,M=n.strideDepth,N=n.strideHeight,F=n.strideWidth,B=_-1-n.padInfo.front,j=O-1-n.padInfo.top,L=k-1-n.padInfo.left,z=0;z<E;++z)for(var W=0;W<C;++W)for(var V=0;V<I;++V)for(var H=V-B,U=Math.max(0,Math.ceil(H/M)),G=Math.min(P,(_+H)/M),q=0;q<S;++q)for(var X=q-j,K=Math.max(0,Math.ceil(X/N)),$=Math.min(T,(O+X)/N),Z=0;Z<R;++Z){for(var Y=Z-L,J=Math.max(0,Math.ceil(Y/F)),Q=Math.min(D,(k+Y)/F),ee=0,te=U;te<G;++te)for(var ne=te*M-H,re=K;re<$;++re)for(var oe=re*N-X,ae=J;ae<Q;++ae)for(var ie=h*z+p*te+d*re+v*ae,se=y*(_-1-ne)+b*(O-1-oe)+w*(k-1-(ae*F-Y))+x*W,ue=0;ue<A;++ue)ee+=l[ie+ue]*m[se+ue];o[i*z+s*V+u*q+c*Z+W]=ee}return r.toTensor()},t.prototype.conv2dDerFilter=function(e,t,n){lf([e,t],"conv2dDerFilter");for(var r=n.strideHeight,o=n.strideWidth,a=n.filterHeight,i=n.filterWidth,s="channelsLast"===n.dataFormat,u=xr(n.filterShape,"float32"),c=n.padInfo.left,l=n.padInfo.top,f=this.bufferSync(e),h=this.bufferSync(t),p=0;p<a;++p)for(var d=Math.max(0,Math.ceil((l-p)/r)),v=Math.min(n.outHeight,(n.inHeight+l-p)/r),m=0;m<i;++m)for(var g=Math.max(0,Math.ceil((c-m)/o)),y=Math.min(n.outWidth,(n.inWidth+c-m)/o),b=0;b<n.inChannels;++b)for(var w=0;w<n.outChannels;++w){for(var x=0,E=0;E<n.batchSize;++E)for(var _=d;_<v;++_)for(var O=p+_*r-l,k=g;k<y;++k){var C=m+k*o-c;x+=s?f.get(E,O,C,b)*h.get(E,_,k,w):f.get(E,b,O,C)*h.get(E,w,_,k)}u.set(x,p,m,b,w)}return u.toTensor()},t.prototype.conv3dDerFilter=function(e,t,n){for(var r=n.strideDepth,o=n.strideHeight,a=n.strideWidth,i=n.filterDepth,s=n.filterHeight,u=n.filterWidth,c=xr(n.filterShape,"float32"),l=c.values,f=c.strides,h=f[0],p=f[1],d=f[2],v=f[3],m=this.readSync(t.dataId),g=t.strides,y=g[0],b=g[1],w=g[2],x=g[3],E=this.readSync(e.dataId),_=e.strides,O=_[0],k=_[1],C=_[2],I=_[3],S=n.padInfo.front,R=n.padInfo.left,A=n.padInfo.top,P=0;P<i;++P)for(var T=Math.max(0,Math.ceil((S-P)/r)),D=Math.min(n.outDepth,(n.inDepth+S-P)/r),M=P*h,N=0;N<s;++N)for(var F=Math.max(0,Math.ceil((A-N)/o)),B=Math.min(n.outHeight,(n.inHeight+A-N)/o),j=N*p+M,L=0;L<u;++L)for(var z=Math.max(0,Math.ceil((R-L)/a)),W=Math.min(n.outWidth,(n.inWidth+R-L)/a),V=L*d+j,H=0;H<n.inChannels;++H)for(var U=H*v+V,G=0;G<n.outChannels;++G){for(var q=0,X=0;X<n.batchSize;++X)for(var K=X*O,$=X*y,Z=T;Z<D;++Z)for(var Y=(P+Z*r-S)*k+K,J=Z*b+$,Q=F;Q<B;++Q)for(var ee=(N+Q*o-A)*C+Y,te=Q*w+J,ne=z;ne<W;++ne){var re=ne*x+te;q+=E[(L+ne*a-R)*I+ee+H]*m[re+G]}l[U+G]=q}return c.toTensor()},t.prototype.fusedDepthwiseConv2D=function(e){var t=e.input,n=e.filter,r=e.convInfo,o=e.bias,a=e.activation,i=e.preluActivationWeights,s=this.depthwiseConv2D(t,n,r);return o&&(s=this.add(s,o)),a&&(s=ff(this,s,a,i)),s},t.prototype.depthwiseConv2D=function(e,t,n){lf([e,t],"depthwiseConv2D");for(var r=n.filterHeight,o=n.filterWidth,a=n.dilationHeight,i=n.dilationWidth,s=n.padInfo.left,u=n.padInfo.top,c=n.outChannels/n.inChannels,l=xr(n.outShape,e.dtype),f=this.readSync(e.dataId),h=this.readSync(t.dataId),p=l.values,d=0;d<n.batchSize;++d)for(var v=d*e.strides[0],m=d*l.strides[0],g=0;g<n.outHeight;++g)for(var y=m+g*l.strides[1],b=g*n.strideHeight-s,w=0;w<r;++w){var x=b+w*a;if(!(x<0||x>=n.inHeight))for(var E=w*t.strides[0],_=v+x*e.strides[1],O=0;O<n.outWidth;++O)for(var k=y+O*l.strides[2],C=O*n.strideWidth-u,I=0;I<o;++I){var S=C+I*i;if(!(S<0||S>=n.inWidth))for(var R=E+I*t.strides[1],A=_+S*n.inChannels,P=k,T=R,D=0;D<n.inChannels;++D){for(var M=f[A+D],N=0;N<c;++N)p[P+N]+=M*h[T+N];P+=c,T+=c}}}return l.toTensor()},t.prototype.depthwiseConv2DDerInput=function(e,t,n){lf([e,t],"depthwiseConv2DDerInput");for(var r=xr(n.inShape,"float32"),o=r.values,a=r.strides,i=a[0],s=a[1],u=a[2],c=this.readSync(e.dataId),l=e.strides,f=l[0],h=l[1],p=l[2],d=this.readSync(t.dataId),v=t.strides,m=v[0],g=v[1],y=v[2],b=n.batchSize,w=n.filterHeight,x=n.filterWidth,E=n.inChannels,_=n.inHeight,O=n.inWidth,k=n.outChannels,C=n.outHeight,I=n.outWidth,S=n.strideHeight,R=n.strideWidth,A=w-1-n.padInfo.top,P=x-1-n.padInfo.left,T=k/E,D=0;D<b;++D)for(var M=0;M<E;++M)for(var N=0;N<_;++N)for(var F=N-A,B=Math.max(0,Math.ceil(F/S)),j=Math.min(C,(w+F)/S),L=0;L<O;++L){for(var z=L-P,W=Math.max(0,Math.ceil(z/R)),V=Math.min(I,(x+z)/R),H=0,U=B;U<j;++U)for(var G=U*S-F,q=W;q<V;++q)for(var X=f*D+h*U+p*q,K=m*(w-1-G)+g*(x-1-(q*R-z))+y*M,$=0;$<T;++$)H+=c[X+(M*T+$)]*d[K+$];o[i*D+s*N+u*L+M]=H}return r.toTensor()},t.prototype.depthwiseConv2DDerFilter=function(e,t,n){lf([e,t],"depthwiseConv2DDerFilter");for(var r=n.strideHeight,o=n.strideWidth,a=n.filterHeight,i=n.filterWidth,s=xr(n.filterShape,"float32"),u=n.padInfo.left,c=n.padInfo.top,l=n.outChannels/n.inChannels,f=this.bufferSync(e),h=this.bufferSync(t),p=0;p<a;++p)for(var d=Math.max(0,Math.ceil((c-p)/r)),v=Math.min(n.outHeight,(n.inHeight+c-p)/r),m=0;m<i;++m)for(var g=Math.max(0,Math.ceil((u-m)/o)),y=Math.min(n.outWidth,(n.inWidth+u-m)/o),b=0;b<n.outChannels;++b){for(var w=Math.trunc(b/l),x=b%l,E=0,_=0;_<n.batchSize;++_)for(var O=d;O<v;++O)for(var k=p+O*r-c,C=g;C<y;++C){var I=m+C*o-u;E+=f.get(_,k,I,w)*h.get(_,O,C,b)}s.set(E,p,m,w,x)}return s.toTensor()},t.prototype.tile=function(e,t){return lf(e,"tile"),Wo(this.bufferSync(e),t)},t.prototype.pad=function(e,t,n){lf(e,"pad");var r=t.map((function(t,n){return t[0]+e.shape[n]+t[1]})),o=t.map((function(e){return e[0]})),a=this.bufferSync(e),i=xr(r,e.dtype);0!==n&&i.values.fill(n);for(var s=0;s<e.size;s++){var u=a.indexToLoc(s),c=u.map((function(e,t){return e+o[t]}));i.set.apply(i,[a.get.apply(a,u)].concat(c))}return i.toTensor()},t.prototype.transpose=function(e,t){lf(e,"transpose");for(var n=new Array(e.rank),r=0;r<n.length;r++)n[r]=e.shape[t[r]];var o=this.readSync(e.dataId),a=xr(n,e.dtype),i=this.bufferSync(e);for(r=0;r<e.size;++r){for(var s=i.indexToLoc(r),u=new Array(s.length),c=0;c<u.length;c++)u[c]=s[t[c]];var l=a.locToIndex(u);a.values[l]=o[r]}return a.toTensor()},t.prototype.gather=function(e,t,n){lf([e,t],"gather");var r=e.shape.slice(),o=this.readSync(t.dataId);r[n]=o.length;for(var a=xr(r,e.dtype),i=this.bufferSync(e),s=0;s<a.size;++s){var u=a.indexToLoc(s),c=u.slice();c[n]=o[u[n]];var l=i.locToIndex(c);a.values[s]=i.values[l]}return a.toTensor()},t.prototype.batchToSpaceND=function(e,t,n){lf([e],"batchToSpaceND");var r=t.reduce((function(e,t){return e*t})),o=Kr(e.shape,t,r),a=$r(o.length,t.length),i=Zr(e.shape,t,r),s=Yr(n,t.length),u=Jr(i,n,t.length);return e.reshape(o).transpose(a).reshape(i).slice(s,u)},t.prototype.spaceToBatchND=function(e,t,n){lf([e],"spaceToBatchND");var r=t.reduce((function(e,t){return e*t})),o=[[0,0]];o.push.apply(o,n);for(var a=1+t.length;a<e.shape.length;++a)o.push([0,0]);var i=e.pad(o),s=Kr(i.shape,t,r,!1),u=$r(s.length,t.length,!1),c=Zr(i.shape,t,r,!1);return i.reshape(s).transpose(u).reshape(c)},t.prototype.pool=function(e,t,n){lf(e,"pool");for(var r=t.strideHeight,o=t.strideWidth,a=t.dilationHeight,i=t.dilationWidth,s=t.effectiveFilterHeight,u=t.effectiveFilterWidth,c=t.padInfo.top,l=t.padInfo.left,f="max"===n?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,h=this.readSync(e.dataId),p=xr(t.outShape,e.dtype),d=p.values,v=t.outShape[1]*t.outShape[2]*t.outShape[3],m=t.outShape[2]*t.outShape[3],g=t.outShape[3],y=0;y<t.batchSize;++y)for(var b=y*v,w=y*e.strides[0],x=0;x<t.inChannels;++x)for(var E=0;E<t.outHeight;++E)for(var _=E*r-c,O=Math.max(0,_),k=Math.min(t.inHeight,s+_),C=b+E*m,I=0;I<t.outWidth;++I){for(var S=I*o-l,R=Math.max(0,S),A=Math.min(t.inWidth,u+S),P=f,T=0,D=0,M=O;M<k;M+=a){for(var N=w+M*e.strides[1],F=R;F<A;F+=i){var B=h[N+F*e.strides[2]+x];"max"===n&&B>P?P=B:"avg"===n&&(T+=B,D++)}if(isNaN(P))break}d[C+I*g+x]="avg"===n?T/D:P}return p.toTensor()},t.prototype.maxPool=function(e,t){return this.pool(e,t,"max")},t.prototype.maxPoolPositions=function(e,t){for(var n=xr(t.outShape,"int32"),r=t.strideHeight,o=t.strideWidth,a=t.dilationHeight,i=t.dilationWidth,s=t.effectiveFilterHeight,u=t.effectiveFilterWidth,c=t.padInfo.top,l=t.padInfo.left,f=this.bufferSync(e),h=0;h<t.batchSize;++h)for(var p=0;p<t.inChannels;++p)for(var d=0;d<t.outHeight;++d){for(var v=d*r-c,m=v;m<0;)m+=a;for(var g=Math.min(t.inHeight,s+v),y=0;y<t.outWidth;++y){for(var b=y*o-l,w=b;w<0;)w+=i;for(var x=Math.min(t.inWidth,u+b),E=Number.NEGATIVE_INFINITY,_=-1,O=m;O<g;O+=a)for(var k=O-v,C=w;C<x;C+=i){var I=C-b,S=f.get(h,O,C,p);S>E&&(E=S,_=k*u+I)}n.set(_,h,d,y,p)}}return n.toTensor()},t.prototype.maxPoolBackprop=function(e,t,n,r){lf([t,n],"maxPoolBackprop");for(var o=this.maxPoolPositions(t,r),a=r.strideHeight,i=r.strideWidth,s=r.dilationHeight,u=r.dilationWidth,c=r.effectiveFilterHeight,l=r.effectiveFilterWidth,f=l-1-r.padInfo.left,h=c-1-r.padInfo.top,p=xr(t.shape,"float32"),d=this.bufferSync(o),v=this.bufferSync(e),m=0;m<r.batchSize;++m)for(var g=0;g<r.inChannels;++g)for(var y=0;y<r.inHeight;++y)for(var b=0;b<r.inWidth;++b){for(var w=y-h,x=b-f,E=0,_=0;_<c;_+=s){var O=(w+_)/a;if(!(O<0||O>=r.outHeight||Math.floor(O)!==O))for(var k=0;k<l;k+=u){var C=(x+k)/i;if(!(C<0||C>=r.outWidth||Math.floor(C)!==C)){var I=c*l-1-d.get(m,O,C,g)===_*l+k?1:0;0!==I&&(E+=v.get(m,O,C,g)*I)}}}p.set(E,m,y,b,g)}return p.toTensor()},t.prototype.avgPoolBackprop=function(e,t,n){lf([e,t],"avgPoolBackprop");for(var r=n.strideHeight,o=n.strideWidth,a=n.filterHeight,i=n.filterWidth,s=n.dilationHeight,u=n.dilationWidth,c=n.effectiveFilterHeight,l=n.effectiveFilterWidth,f=l-1-n.padInfo.left,h=c-1-n.padInfo.top,p=xr(t.shape,"float32"),d=1/(a*i),v=this.bufferSync(e),m=0;m<n.batchSize;++m)for(var g=0;g<n.inChannels;++g)for(var y=0;y<n.inHeight;++y)for(var b=0;b<n.inWidth;++b){for(var w=y-h,x=b-f,E=0,_=0;_<c;_+=s){var O=(w+_)/r;if(!(O<0||O>=n.outHeight||Math.floor(O)!==O))for(var k=0;k<l;k+=u){var C=(x+k)/o;C<0||C>=n.outWidth||Math.floor(C)!==C||(E+=v.get(m,O,C,g))}}p.set(E*d,m,y,b,g)}return p.toTensor()},t.prototype.pool3d=function(e,t,n){lf(e,"pool3d");for(var r=t.strideDepth,o=t.strideHeight,a=t.strideWidth,i=t.dilationDepth,s=t.dilationHeight,u=t.dilationWidth,c=t.effectiveFilterDepth,l=t.effectiveFilterHeight,f=t.effectiveFilterWidth,h=t.padInfo.front,p=t.padInfo.top,d=t.padInfo.left,v="max"===n?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=this.readSync(e.dataId),g=xr(t.outShape,e.dtype),y=g.values,b=t.outShape[1]*t.outShape[2]*t.outShape[3]*t.outShape[4],w=t.outShape[2]*t.outShape[3]*t.outShape[4],x=t.outShape[3]*t.outShape[4],E=t.outShape[4],_=0;_<t.batchSize;++_)for(var O=_*b,k=_*e.strides[0],C=0;C<t.inChannels;++C)for(var I=0;I<t.outDepth;++I){for(var S=I*r-h,R=S;R<0;)R+=i;for(var A=Math.min(t.inDepth,c+S),P=O+I*w,T=0;T<t.outHeight;++T){for(var D=T*o-p,M=D;M<0;)M+=s;for(var N=Math.min(t.inHeight,l+D),F=P+T*x,B=0;B<t.outWidth;++B){for(var j=B*a-d,L=j;L<0;)L+=u;for(var z=Math.min(t.inWidth,f+j),W=F+B*E,V=v,H=0,U=0,G=R;G<A;G+=i){for(var q=k+G*e.strides[1],X=M;X<N;X+=s){for(var K=q+X*e.strides[2],$=L;$<z;$+=u){var Z=m[K+$*e.strides[3]+C];if("max"===n&&Z>V?V=Z:"avg"===n&&(H+=Z,U++),isNaN(V))break}if(isNaN(V))break}if(isNaN(V))break}y[W+C]="avg"===n?H/U:V}}}return g.toTensor()},t.prototype.avgPool3d=function(e,t){return lf(e,"avgPool3d"),this.pool3d(e,t,"avg").toFloat()},t.prototype.avgPool3dBackprop=function(e,t,n){lf([e,t],"avgPool3dBackprop");for(var r=n.strideDepth,o=n.strideHeight,a=n.strideWidth,i=n.filterDepth,s=n.filterHeight,u=n.filterWidth,c=n.dilationDepth,l=n.dilationHeight,f=n.dilationWidth,h=n.effectiveFilterDepth,p=n.effectiveFilterHeight,d=n.effectiveFilterWidth,v=h-1-n.padInfo.front,m=d-1-n.padInfo.left,g=p-1-n.padInfo.top,y=xr(t.shape,"float32"),b=1/(i*s*u),w=this.bufferSync(e),x=0;x<n.batchSize;++x)for(var E=0;E<n.inChannels;++E)for(var _=0;_<n.inDepth;++_)for(var O=0;O<n.inHeight;++O)for(var k=0;k<n.inWidth;++k){for(var C=_-v,I=O-g,S=k-m,R=0,A=0;A<h;A+=c){var P=(C+A)/r;if(!(P<0||P>=n.outDepth||Math.floor(P)!==P))for(var T=0;T<p;T+=l){var D=(I+T)/o;if(!(D<0||D>=n.outHeight||Math.floor(D)!==D))for(var M=0;M<d;M+=f){var N=(S+M)/a;N<0||N>=n.outWidth||Math.floor(N)!==N||(R+=w.get(x,P,D,N,E))}}}y.set(R*b,x,_,O,k,E)}return y.toTensor()},t.prototype.maxPool3d=function(e,t){return lf(e,"maxPool3d"),this.pool3d(e,t,"max").toFloat()},t.prototype.maxPool3dPositions=function(e,t){for(var n=xr(t.outShape,"int32"),r=t.strideDepth,o=t.strideHeight,a=t.strideWidth,i=t.dilationDepth,s=t.dilationHeight,u=t.dilationWidth,c=t.effectiveFilterDepth,l=t.effectiveFilterHeight,f=t.effectiveFilterWidth,h=t.padInfo.front,p=t.padInfo.top,d=t.padInfo.left,v=this.bufferSync(e),m=0;m<t.batchSize;++m)for(var g=0;g<t.inChannels;++g)for(var y=0;y<t.outDepth;++y){for(var b=y*r-h,w=b;w<0;)w+=i;for(var x=Math.min(t.inDepth,c+b),E=0;E<t.outHeight;++E){for(var _=E*o-p,O=_;O<0;)O+=s;for(var k=Math.min(t.inHeight,l+_),C=0;C<t.outWidth;++C){for(var I=C*a-d,S=I;S<0;)S+=u;for(var R=Math.min(t.inWidth,f+I),A=Number.NEGATIVE_INFINITY,P=-1,T=w;T<x;T+=i)for(var D=T-b,M=O;M<k;M+=s)for(var N=M-_,F=S;F<R;F+=u){var B=F-I,j=v.get(m,T,M,F,g);j>=A&&(A=j,P=D*l*f+N*l+B)}n.set(P,m,y,E,C,g)}}}return n.toTensor()},t.prototype.maxPool3dBackprop=function(e,t,n,r){lf([t,n],"maxPool3dBackprop");for(var o=this.maxPool3dPositions(t,r),a=r.strideDepth,i=r.strideHeight,s=r.strideWidth,u=r.dilationDepth,c=r.dilationHeight,l=r.dilationWidth,f=r.effectiveFilterDepth,h=r.effectiveFilterHeight,p=r.effectiveFilterWidth,d=f-1-r.padInfo.front,v=p-1-r.padInfo.left,m=h-1-r.padInfo.top,g=xr(t.shape,"float32"),y=this.bufferSync(o),b=this.bufferSync(e),w=0;w<r.batchSize;++w)for(var x=0;x<r.inChannels;++x)for(var E=0;E<r.inDepth;++E)for(var _=0;_<r.inHeight;++_)for(var O=0;O<r.inWidth;++O){for(var k=E-d,C=_-m,I=O-v,S=0,R=0;R<f;R+=u){var A=(k+R)/a;if(!(A<0||A>=r.outDepth||Math.floor(A)!==A))for(var P=0;P<h;P+=c){var T=(C+P)/i;if(!(T<0||T>=r.outHeight||Math.floor(T)!==T))for(var D=0;D<p;D+=l){var M=(I+D)/s;if(!(M<0||M>=r.outWidth||Math.floor(M)!==M)){var N=f*h*p-1-y.get(w,A,T,M,x)===R*h*p+P*p+D?1:0;0!==N&&(S+=b.get(w,A,T,M,x)*N)}}}}g.set(S,w,E,_,O,x)}return g.toTensor()},t.prototype.cast=function(e,t){return Po(e,t,this)},t.prototype.reshape=function(e,t){return To(e,t)},t.prototype.avgPool=function(e,t){return lf(e,"avgPool"),this.pool(e,t,"avg").toFloat()},t.prototype.resizeBilinear=function(e,t,n,r){lf(e,"resizeBilinear");for(var o=e.shape,a=o[0],i=o[1],s=o[2],u=o[3],c=this.readSync(e.dataId),l=new Float32Array(he([a,t,n,u])),f=[r&&t>1?i-1:i,r&&n>1?s-1:s],h=[r&&t>1?t-1:t,r&&n>1?n-1:n],p=0,d=f[0]/h[0],v=f[1]/h[1],m=0;m<a;m++)for(var g=0;g<t;g++)for(var y=d*g,b=Math.floor(y),w=y-b,x=Math.min(i-1,Math.ceil(y)),E=m*e.strides[0]+b*e.strides[1],_=m*e.strides[0]+x*e.strides[1],O=0;O<n;O++)for(var k=v*O,C=Math.floor(k),I=k-C,S=Math.min(s-1,Math.ceil(k)),R=E+C*e.strides[2],A=_+C*e.strides[2],P=E+S*e.strides[2],T=_+S*e.strides[2],D=0;D<u;D++){var M=c[R+D],N=c[A+D],F=M+(c[P+D]-M)*I,B=F+(N+(c[T+D]-N)*I-F)*w;l[p++]=B}return Un(l,[a,t,n,u])},t.prototype.resizeBilinearBackprop=function(e,t,n){lf([e,t],"resizeBilinearBackprop");for(var r=t.shape,o=r[0],a=r[1],i=r[2],s=r[3],u=e.shape,c=u[1],l=u[2],f=new Float32Array(o*a*i*s),h=[n&&c>1?a-1:a,n&&l>1?i-1:i],p=[n&&c>1?c-1:c,n&&l>1?l-1:l],d=h[0]/p[0],v=h[1]/p[1],m=this.readSync(e.dataId),g=0,y=0;y<o;y++)for(var b=y*t.strides[0],w=0;w<c;w++)for(var x=w*d,E=Math.floor(x),_=Math.min(Math.ceil(x),a-1),O=b+E*t.strides[1],k=b+_*t.strides[1],C=x-E,I=1-C,S=0;S<l;S++)for(var R=S*v,A=Math.floor(R),P=Math.min(Math.ceil(R),i-1),T=R-A,D=1-T,M=O+A*t.strides[2],N=O+P*t.strides[2],F=k+A*t.strides[2],B=k+P*t.strides[2],j=I*D,L=I*T,z=C*D,W=C*T,V=0;V<s;V++){var H=m[g++];f[M+V]+=H*j,f[N+V]+=H*L,f[F+V]+=H*z,f[B+V]+=H*W}return Zn(f,[o,i,a,s],t.dtype)},t.prototype.resizeNearestNeighbor=function(e,t,n,r){lf(e,"resizeNearestNeighbor");for(var o=e.shape,a=o[0],i=o[1],s=o[2],u=o[3],c=this.readSync(e.dataId),l=new Float32Array(a*t*n*u),f=[r&&t>1?i-1:i,r&&n>1?s-1:s],h=[r&&t>1?t-1:t,r&&n>1?n-1:n],p=f[0]/h[0],d=f[1]/h[1],v=0,m=0;m<a;m++)for(var g=m*e.strides[0],y=0;y<t;y++)for(var b=p*y,w=g+Math.min(i-1,r?Math.round(b):Math.floor(b))*e.strides[1],x=0;x<n;x++)for(var E=d*x,_=w+Math.min(s-1,r?Math.round(E):Math.floor(E))*e.strides[2],O=0;O<u;O++){var k=c[_+O];l[v++]=k}return Un(l,[a,t,n,u],e.dtype)},t.prototype.resizeNearestNeighborBackprop=function(e,t,n){lf([e,t],"resizeNearestNeighborBackprop");for(var r=t.shape,o=r[0],a=r[1],i=r[2],s=r[3],u=e.shape,c=u[1],l=u[2],f=new Float32Array(o*a*i*s),h=this.readSync(e.dataId),p=[n&&c>1?a-1:a,n&&l>1?i-1:i],d=[n&&c>1?c-1:c,n&&l>1?l-1:l],v=p[0]/d[0],m=p[1]/d[1],g=1/v,y=1/m,b=2*Math.ceil(g)+2,w=2*Math.ceil(y)+2,x=0;x<o;x++)for(var E=x*t.strides[0],_=0;_<a;_++)for(var O=E+_*t.strides[1],k=Math.floor(_*g),C=Math.floor(k-b/2),I=0;I<i;I++)for(var S=O+I*t.strides[2],R=Math.floor(I*y),A=Math.floor(R-w/2),P=0;P<s;P++){for(var T=0,D=0;D<b;D++){var M=D+C;if(!(M<0||M>=c)){var N=E+M*e.strides[1],F=M*v;if(_===Math.min(a-1,n?Math.round(F):Math.floor(F)))for(var B=0;B<w;B++){var j=B+A;if(!(j<0||j>=l)){var L=N+j*e.strides[2],z=j*m;I===Math.min(i-1,n?Math.round(z):Math.floor(z))&&(T+=h[L+P])}}}}f[S+P]=T}return Zn(f,t.shape,t.dtype)},t.prototype.batchNormalization=function(e,t,n,r,o,a){lf([e,t,n,o,a],"batchNorm");for(var i=this.readSync(e.dataId),s=this.readSync(t.dataId),u=this.readSync(n.dataId),c=o?this.readSync(o.dataId):new Float32Array([1]),l=a?this.readSync(a.dataId):new Float32Array([0]),f=new Float32Array(i.length),h=l.length,p=c.length,d=u.length,v=s.length,m=0,g=0,y=0,b=0,w=0;w<i.length;++w)f[w]=l[m++]+(i[w]-s[g++])*c[y++]/Math.sqrt(u[b++]+r),m>=h&&(m=0),g>=v&&(g=0),y>=p&&(y=0),b>=d&&(b=0);return Zn(f,e.shape)},t.prototype.localResponseNormalization4D=function(e,t,n,r,o){lf(e,"localResponseNormalization4D");var a=e.shape[3],i=a-1,s=this.readSync(e.dataId),u=e.size,c=new Float32Array(u);function l(e){for(var n=e%a,r=e-n+Math.max(0,n-t),o=e-n+Math.min(n+t,i),u=0;r<=o;r++){var c=s[r];u+=c*c}return u}for(var f=0;f<u;f++){var h=l(f),p=s[f]*Math.pow(n+r*h,-o);c[f]=p}return Zn(c,e.shape)},t.prototype.LRNGrad=function(e,t,n,r,o,a,i){lf(e,"LRNGrad");for(var s=e.shape[3],u=this.readSync(e.dataId),c=this.readSync(t.dataId),l=this.readSync(n.dataId),f=new Float32Array(e.size),h=e.size,p=0;p<h;p++){for(var d=p%s,v=p-d+Math.max(0,d-r),m=p-d+Math.min(s,d+r+1),g=0,y=v;y<m;y++)g+=Math.pow(c[y],2);for(g=a*g+o,y=v;y<m;y++){var b=-2*a*i*c[y]*l[p]/g;p===y&&(b+=Math.pow(g,-i)),b*=u[p],f[y]+=b}}return Zn(f,e.shape)},t.prototype.multinomial=function(e,t,n,r){lf(e,"multinomial");for(var o=t?e:lo(e),a=o.shape[0],i=o.shape[1],s=Jn([a,n],"int32"),u=this.readSync(s.dataId),c=this.readSync(o.dataId),l=0;l<a;++l){var f=l*i,h=new Float32Array(i-1);h[0]=c[f];for(var p=1;p<h.length;++p)h[p]=h[p-1]+c[f+p];for(var d=gr(r.toString()),v=l*n,m=0;m<n;++m){var g=d();u[v+m]=h.length;for(var y=0;y<h.length;y++)if(g<h[y]){u[v+m]=y;break}}}return s},t.prototype.oneHot=function(e,t,n,r){lf(e,"oneHot");var o=new Float32Array(e.size*t);o.fill(r);for(var a=this.readSync(e.dataId),i=0;i<e.size;++i)a[i]>=0&&a[i]<t&&(o[i*t+a[i]]=n);return Kn(o,[e.size,t],"int32")},t.prototype.nonMaxSuppression=function(e,t,n,r,o){return lf(e,"nonMaxSuppression"),jo(this.readSync(e.dataId),this.readSync(t.dataId),n,r,o)},t.prototype.fft=function(e){return this.fftBatch(e,!1)},t.prototype.ifft=function(e){return this.fftBatch(e,!0)},t.prototype.fftBatch=function(e,t){for(var n=e.shape[0],r=e.shape[1],o=xr(e.shape,"float32"),a=xr(e.shape,"float32"),i=Vn(e).as2D(n,r),s=Hn(e).as2D(n,r),u=0;u<n;u++)for(var c=i.slice([u,0],[1,r]),l=s.slice([u,0],[1,r]),f=Wn(c,l),h=this.readSync(this.fftImpl(f,t).dataId),p=0;p<r;p++){var d=No(h,p);o.values[u*r+p]=d.real,a.values[u*r+p]=d.imag}return Wn(o.toTensor(),a.toTensor()).as2D(n,r)},t.prototype.fftImpl=function(e,t){var n=e.as1D(),r=n.size;if(this.isExponentOf2(r)){var o=this.fftRadix2(n,r,t).as2D(e.shape[0],e.shape[1]);return t&&(o=Wn(Vn(o).div(qn(r)),Hn(o).div(qn(r)))),o}var a=this.readSync(e.dataId),i=function(e){for(var t=new Float32Array(e.length/2),n=new Float32Array(e.length/2),r=0;r<e.length;r+=2)t[r/2]=e[r],n[r/2]=e[r+1];return{real:t,imag:n}}(this.fourierTransformByMatmul(a,r,t));return Wn(i.real,i.imag).as2D(e.shape[0],e.shape[1])},t.prototype.isExponentOf2=function(e){return 0==(e&e-1)},t.prototype.fftRadix2=function(e,t,n){if(1===t)return e;var r=this.readSync(e.dataId),o=t/2,a=function(e){for(var t=Math.ceil(e.length/4),n=new Float32Array(t),r=new Float32Array(t),o=0;o<e.length;o+=4)n[Math.floor(o/4)]=e[o],r[Math.floor(o/4)]=e[o+1];return{real:n,imag:r}}(r),i=Wn(a.real,a.imag).as1D(),s=function(e){for(var t=Math.floor(e.length/4),n=new Float32Array(t),r=new Float32Array(t),o=2;o<e.length;o+=4)n[Math.floor(o/4)]=e[o],r[Math.floor(o/4)]=e[o+1];return{real:n,imag:r}}(r),u=Wn(s.real,s.imag).as1D();i=this.fftRadix2(i,o,n),u=this.fftRadix2(u,o,n);var c=function(e,t){for(var n=new Float32Array(e/2),r=new Float32Array(e/2),o=0;o<Math.ceil(e/2);o++){var a=(t?2:-2)*Math.PI*(o/e);n[o]=Math.cos(a),r[o]=Math.sin(a)}return{real:n,imag:r}}(t,n),l=Wn(c.real,c.imag).mul(u),f=i.add(l),h=i.sub(l),p=Vn(f).concat(Vn(h)),d=Hn(f).concat(Hn(h));return Wn(p,d).as1D()},t.prototype.fourierTransformByMatmul=function(e,t,n){for(var r=new Float32Array(2*t),o=0;o<t;o++){for(var a=0,i=0,s=0;s<t;s++){var u=Bo(o*s,t,n),c=No(e,s);a+=c.real*u.real-c.imag*u.imag,i+=c.real*u.imag+c.imag*u.real}n&&(a/=t,i/=t),Fo(r,a,i,o)}return r},t.prototype.depthToSpace=function(e,t,n){ue("NHWC"===n,(function(){return"Only NHWC dataFormat supported on CPU for depthToSpace. Got "+n})),ue(t>1,(function(){return"blockSize should be > 1 for depthToSpace, but was: "+t}));for(var r=e.shape[0],o=e.shape[1],a=e.shape[2],i=e.shape[3],s=o*t,u=a*t,c=i/(t*t),l=this.readSync(e.dataId),f=new Float32Array(r*s*u*c),h=0,p=0;p<r;++p)for(var d=0;d<s;++d)for(var v=Math.floor(d/t),m=d%t,g=0;g<u;++g)for(var y=Math.floor(g/t),b=(m*t+g%t)*c,w=0;w<c;++w){var x=w+b+i*(y+a*(v+o*p));f[h++]=l[x]}return Zn(f,[r,s,u,c])},t.prototype.broadcastedBinaryOp=function(e,t,n,r){var o=yo(e.shape,t.shape),a=xr(o,n),i=this.readSync(e.dataId),s=this.readSync(t.dataId),u=mo(e.shape,o),c=mo(t.shape,o),l=a.values;if(u.length+c.length===0)for(var f=0;f<l.length;++f)l[f]=r(i[f%i.length],s[f%s.length]);else{var h=this.bufferSync(e),p=this.bufferSync(t),d=function(n){var o=a.indexToLoc(n),f=o.slice(-e.rank);u.forEach((function(e){return f[e]=0}));var d=h.locToIndex(f),v=o.slice(-t.rank);c.forEach((function(e){return v[e]=0}));var m=p.locToIndex(v);l[n]=r(i[d],s[m])};for(f=0;f<l.length;++f)d(f)}return a.toTensor()},t.prototype.broadcastedBinaryComplexOp=function(e,t,n){var r=yo(e.shape,t.shape),o=xr(r,"float32"),a=xr(r,"float32"),i=this.readSync(e.dataId),s=this.readSync(t.dataId),u=mo(e.shape,r),c=mo(t.shape,r),l=o.values,f=a.values;if(u.length+c.length===0)for(var h=0;h<l.length;h++){var p=h%i.length,d=h%s.length,v=n(i[2*p],i[2*p+1],s[2*d],s[2*d+1]);l[h]=v.real,f[h]=v.imag}else{var m=this.bufferSync(this.data.get(e.dataId).complexTensors.real),g=this.bufferSync(this.data.get(t.dataId).complexTensors.real),y=function(r){var a=o.indexToLoc(r),h=a.slice(-e.rank);u.forEach((function(e){return h[e]=0}));var p=m.locToIndex(h),d=a.slice(-t.rank);c.forEach((function(e){return d[e]=0}));var v=g.locToIndex(d),y=n(i[2*p],i[2*p+1],s[2*v],s[2*v+1]);l[r]=y.real,f[r]=y.imag};for(h=0;h<l.length;h++)y(h)}return this.complex(o.toTensor(),a.toTensor())},t.prototype.split=function(e,t,n){return zo(e,t,n)},t.prototype.dispose=function(){},t.prototype.floatPrecision=function(){return 32},t.prototype.epsilon=function(){return 1e-7},t.prototype.cropAndResize=function(e,t,n,r,o,a){for(var i=e.shape,s=i[0],u=i[1],c=i[2],l=i[3],f=t.shape[0],h=r[0],p=r[1],d=xr([f,h,p,l],"float32"),v=this.readSync(t.dataId),m=this.readSync(n.dataId),g=this.readSync(e.dataId),y=e.strides,b=d.strides,w=0;w<f;w++){var x=4*w,E=v[x],_=v[x+1],O=v[x+2],k=v[x+3],C=m[w];if(!(C>=s))for(var I=h>1?(O-E)*(u-1)/(h-1):0,S=p>1?(k-_)*(c-1)/(p-1):0,R=0;R<h;R++){var A=h>1?E*(u-1)+R*I:.5*(E+O)*(u-1);if(A<0||A>u-1)for(var P=0;P<p;P++)for(var T=0;T<l;T++){var D=T+P*b[2]+R*b[1]+w*b[0];d.values[D]=a}else if("bilinear"===o){var M=Math.floor(A),N=Math.ceil(A),F=A-M;for(P=0;P<p;P++)if((G=p>1?_*(c-1)+P*S:.5*(_+k)*(c-1))<0||G>c-1)for(T=0;T<l;T++)D=T+P*b[2]+R*b[1]+w*b[0],d.values[D]=a;else{var B=Math.floor(G),j=Math.ceil(G),L=G-B;for(T=0;T<l;T++){var z=g[D=T+B*y[2]+M*y[1]+C*y[0]],W=g[D=T+j*y[2]+M*y[1]+C*y[0]],V=g[D=T+B*y[2]+N*y[1]+C*y[0]],H=z+(W-z)*L,U=V+(g[D=T+j*y[2]+N*y[1]+C*y[0]]-V)*L;D=T+P*b[2]+R*b[1]+w*b[0],d.values[D]=H+(U-H)*F}}}else for(P=0;P<p;++P){var G;if((G=p>1?_*(c-1)+P*S:.5*(_+k)*(c-1))<0||G>c-1)for(T=0;T<l;T++)D=T+P*b[2]+R*b[1]+w*b[0],d.values[D]=a;else{var q=Math.round(G),X=Math.round(A);for(T=0;T<l;T++){var K=T+q*y[2]+X*y[1]+C*y[0],$=T+P*b[2]+R*b[1]+w*b[0];d.values[$]=g[K]}}}}}return d.toTensor()},t.prototype.sparseToDense=function(e,t,n,r){var o=to(0,e,n),a=o.sliceRank,i=o.numUpdates,s=o.sliceSize,u=o.strides,c=o.outputSize;return this.scatter(e,t,n,c,s,i,a,u,r,!1)},t.prototype.gatherND=function(e,t){var n=t.shape,r=n[n.length-1],o=Qr(e,t),a=o[0],i=o[1],s=o[2],u=o[3];if(0===i)return Un([],a,e.dtype);for(var c=new Ze([i,s],e.dtype),l=this.readSync(t.dataId),f=this.readSync(e.dataId),h=0;h<i;h++){for(var p=[],d=0,v=0;v<r;v++){var m=l[h*r+v];d+=m*u[v],p.push(m)}if(d<0||d>=e.size/s)throw new Error("Invalid indices: "+p+" does not index into "+e.shape);for(var g=0;g<s;g++)c.values[h*s+g]=f[d*s+g]}return c.toTensor().reshape(a)},t.prototype.scatterND=function(e,t,n){var r=to(0,e,n),o=r.sliceRank,a=r.numUpdates,i=r.sliceSize,s=r.strides,u=r.outputSize,c=qn(0);return this.scatter(e,t,n,u,i,a,o,s,c,!0)},t.prototype.fill=function(e,t,n){var r=_e(n=n||De(t),he(e));return r.fill(t),mt.makeTensor(r,e,n,this)},t.prototype.onesLike=function(e){if("string"===e.dtype)throw new Error("onesLike is not supported for string tensors");return this.fill(e.shape,1,e.dtype)},t.prototype.zerosLike=function(e){var t=_e(e.dtype,he(e.shape));return this.makeOutput(t,e.shape,e.dtype)},t.prototype.linspace=function(e,t,n){return Do(e,t,n)},t.prototype.scatter=function(e,t,n,r,o,a,i,s,u,c){var l=[r/o,o],f=this.readSync(e.dataId),h=this.readSync(t.dataId);if(0===r)return Un([],n,t.dtype);var p=new Ze(l,t.dtype);p.values.fill(this.readSync(u.dataId)[0]);for(var d=0;d<a;d++){for(var v=[],m=0,g=0;g<i;g++){var y=f[d*i+g];v.push(y),m+=y*s[g]}if(m<0||m>=r/o)throw new Error("Invalid indices: "+v+" does not index into "+n);for(var b=0;b<o;b++)c?p.values[m*o+b]+=h[d*o+b]:p.values[m*o+b]=0===t.rank?h[0]:h[d*o+b]}return p.toTensor().reshape(n)},t}(po);mt.registerBackend("cpu",(function(){return new hf}),1),ne({kernelName:"Square",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x,o=n;lf(r,"square");for(var a=o.data.get(r.dataId).values,i=new Float32Array(a.length),s=0;s<a.length;++s){var u=a[s];i[s]=u*u}return{dataId:o.write(i,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}}),ne({kernelName:"Square",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x,o=n,a=new as(r.shape,"return x * x;");return o.runWebGLProgram(a,[r],r.dtype)}});var pf,df=function(e){this.variableNames=["A"];var t=$o(),n=e[0],r=e[1];this.outputShape=e,this.userCode="\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+r+".0, "+n+".0);\n\n vec4 values = "+t.texture2D+"(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n setOutput(floor(value * 255.0 + 0.5));\n }\n "},vf=function(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var t=$o(),n=e[0],r=e[1];this.outputShape=e,this.userCode="\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n\n vec4 result = vec4(0.);\n\n for(int row=0; row<=1; row++) {\n for(int col=0; col<=1; col++) {\n texC = coords[1] + row;\n depth = coords[2] + col;\n\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+r+".0, "+n+".0);\n vec4 values = "+t.texture2D+"(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n result[row * 2 + col] = floor(value * 255.0 + 0.5);\n }\n }\n\n "+t.output+" = result;\n }\n "};ne({kernelName:"FromPixels",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,o=t.pixels,a=r.numChannels,i="undefined"!=typeof HTMLVideoElement&&o instanceof HTMLVideoElement,s="undefined"!=typeof HTMLImageElement&&o instanceof HTMLImageElement,u=i?[o.videoWidth,o.videoHeight]:[o.width,o.height],c=u[0],l=u[1],f=[l,c],h=[l,c,a];(s||i)&&(null==pf&&(pf=document.createElement("canvas").getContext("2d")),pf.canvas.width=c,pf.canvas.height=l,pf.drawImage(o,0,0,c,l),o=pf.canvas);var p=n.makeTensorInfo(f,"int32");n.texData.get(p.dataId).usage=wt.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(p.dataId),o);var d=Y().getBool("WEBGL_PACK")?new vf(h):new df(h),v=n.runWebGLProgram(d,[p],"int32");return n.disposeData(p.dataId),v}});var mf=function(){function e(){}return e.prototype.fetch=function(e,t){return fetch(e,t)},e.prototype.now=function(){return performance.now()},e.prototype.encode=function(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error("Browser's encoder only supports utf-8, but got "+t);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)},e.prototype.decode=function(e,t){return new TextDecoder(t).decode(e)},e}();Y().get("IS_BROWSER")&&Y().setPlatform("browser",new mf);var gf,yf=function(){function e(){this.util=n(753),this.textEncoder=new this.util.TextEncoder}return e.prototype.fetch=function(e,t){return null!=Y().global.fetch?Y().global.fetch(e,t):(null==gf&&(gf=n(522)),gf(e,t))},e.prototype.now=function(){var e=process.hrtime();return 1e3*e[0]+e[1]/1e6},e.prototype.encode=function(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error("Node built-in encoder only supports utf-8, but got "+t);return this.textEncoder.encode(e)},e.prototype.decode=function(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)},e}();Y().get("IS_NODE")&&Y().setPlatform("node",new yf);var bf={float32:4,int32:4,uint16:2,uint8:1,bool:1};function wf(e,t){for(var n={},r=0,o=function(t){var o=t.name,a=t.dtype,i=t.shape,s=he(i),u=void 0;if("quantization"in t){var c=t.quantization;if("uint8"!==c.dtype&&"uint16"!==c.dtype)throw new Error("Weight "+t.name+" has unknown quantization dtype "+c.dtype+". Supported quantization dtypes are: 'uint8' and 'uint16'.");var l=bf[c.dtype],f=e.slice(r,r+s*l),h="uint8"===c.dtype?new Uint8Array(f):new Uint16Array(f);if("float32"===a)u=Float32Array.from(h,(function(e){return e*c.scale+c.min}));else{if("int32"!==a)throw new Error("Unsupported dtype in weight '"+o+"': "+a);u=Int32Array.from(h,(function(e){return Math.round(e*c.scale+c.min)}))}r+=s*l}else if("string"===a){var p=he(t.shape);u=[];for(var d=0;d<p;d++){var v=new Uint32Array(e.slice(r,r+4))[0];r+=4;var m=new Uint8Array(e.slice(r,r+v));u.push(m),r+=v}}else{var g=bf[a];if(f=e.slice(r,r+s*g),"float32"===a)u=new Float32Array(f);else if("int32"===a)u=new Int32Array(f);else{if("bool"!==a)throw new Error("Unsupported dtype in weight '"+o+"': "+a);u=new Uint8Array(f)}r+=s*g}n[o]=Un(u,i,a)},a=0,i=t;a<i.length;a++)o(i[a]);return n}function xf(e){if(null===e)throw new Error("Invalid input value: "+JSON.stringify(e));var t=0,n=[];e.forEach((function(e){if(t+=e.byteLength,n.push(e.byteLength===e.buffer.byteLength?e:new e.constructor(e)),!(e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array))throw new Error("Unsupported TypedArray subtype: "+e.constructor.name)}));var r=new Uint8Array(t),o=0;return n.forEach((function(e){r.set(new Uint8Array(e.buffer),o),o+=e.byteLength})),r.buffer}var Ef="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function _f(e){return Ef?Buffer.byteLength(e):new Blob([e]).size}function Of(e){var t=0;e.forEach((function(e){t+=e.byteLength}));var n=new Uint8Array(t),r=0;return e.forEach((function(e){n.set(new Uint8Array(e),r),r+=e.byteLength})),n.buffer}function kf(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);var t=e.split("/");return t[t.length-1]}function Cf(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:_f(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:_f(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:e.weightData.byteLength}}var If=function(){function e(){this.saveRouters=[],this.loadRouters=[]}return e.getInstance=function(){return null==e.instance&&(e.instance=new e),e.instance},e.registerSaveRouter=function(t){e.getInstance().saveRouters.push(t)},e.registerLoadRouter=function(t){e.getInstance().loadRouters.push(t)},e.getSaveHandlers=function(t){return e.getHandlers(t,"save")},e.getLoadHandlers=function(t,n){return e.getHandlers(t,"load",n)},e.getHandlers=function(t,n,r){var o=[];return("load"===n?e.getInstance().loadRouters:e.getInstance().saveRouters).forEach((function(e){var n=e(t,r);null!==n&&o.push(n)})),o},e}(),Sf="://",Rf=function(){function e(){this.managers={}}return e.getInstance=function(){return null==e.instance&&(e.instance=new e),e.instance},e.registerManager=function(t,n){ue(null!=t,(function(){return"scheme must not be undefined or null."})),t.endsWith(Sf)&&(t=t.slice(0,t.indexOf(Sf))),ue(t.length>0,(function(){return"scheme must not be an empty string."}));var r=e.getInstance();ue(null==r.managers[t],(function(){return"A model store manager is already registered for scheme '"+t+"'."})),r.managers[t]=n},e.getManager=function(e){var t=this.getInstance().managers[e];if(null==t)throw new Error("Cannot find model manager for scheme '"+e+"'");return t},e.getSchemes=function(){return Object.keys(this.getInstance().managers)},e}();function Af(e){if(-1===e.indexOf(Sf))throw new Error("The url string provided does not contain a scheme. Supported schemes are: "+Rf.getSchemes().join(","));return{scheme:e.split(Sf)[0],path:e.split(Sf)[1]}}function Pf(e,t,n){return void 0===n&&(n=!1),K(this,void 0,void 0,(function(){var r,o,a,i,s,u,c,l,f;return $(this,(function(h){switch(h.label){case 0:return ue(e!==t,(function(){return"Old path and new path are the same: '"+e+"'"})),ue((r=If.getLoadHandlers(e)).length>0,(function(){return"Copying failed because no load handler is found for source URL "+e+"."})),ue(r.length<2,(function(){return"Copying failed because more than one ("+r.length+") load handlers for source URL "+e+"."})),o=r[0],ue((a=If.getSaveHandlers(t)).length>0,(function(){return"Copying failed because no save handler is found for destination URL "+t+"."})),ue(a.length<2,(function(){return"Copying failed because more than one ("+r.length+") save handlers for destination URL "+t+"."})),i=a[0],s=Af(e).scheme,u=Af(e).path,c=s===Af(e).scheme,[4,o.load()];case 1:return l=h.sent(),n&&c?[4,Rf.getManager(s).removeModel(u)]:[3,3];case 2:h.sent(),h.label=3;case 3:return[4,i.save(l)];case 4:return f=h.sent(),!n||c?[3,6]:[4,Rf.getManager(s).removeModel(u)];case 5:h.sent(),h.label=6;case 6:return[2,f.modelArtifactsInfo]}}))}))}var Tf="models_store",Df="model_info_store";function Mf(){if(!Y().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");var e=window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function Nf(e){var t=e.result;t.createObjectStore(Tf,{keyPath:"modelPath"}),t.createObjectStore(Df,{keyPath:"modelPath"})}var Ff=function(){function e(e){if(this.indexedDB=Mf(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}return e.prototype.save=function(e){return K(this,void 0,void 0,(function(){return $(this,(function(t){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return[2,this.databaseAction(this.modelPath,e)]}))}))},e.prototype.load=function(){return K(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.databaseAction(this.modelPath)]}))}))},e.prototype.databaseAction=function(e,t){var n=this;return new Promise((function(e,r){var o=n.indexedDB.open("tensorflowjs",1);o.onupgradeneeded=function(){return Nf(o)},o.onsuccess=function(){var a=o.result;if(null==t){var i=a.transaction(Tf,"readonly"),s=i.objectStore(Tf).get(n.modelPath);s.onsuccess=function(){if(null==s.result)return a.close(),r(new Error("Cannot find model with path '"+n.modelPath+"' in IndexedDB."));e(s.result.modelArtifacts)},s.onerror=function(e){return a.close(),r(s.error)},i.oncomplete=function(){return a.close()}}else{var u,c=Cf(t),l=a.transaction(Df,"readwrite"),f=l.objectStore(Df),h=f.put({modelPath:n.modelPath,modelArtifactsInfo:c});h.onsuccess=function(){var o=(u=a.transaction(Tf,"readwrite")).objectStore(Tf).put({modelPath:n.modelPath,modelArtifacts:t,modelArtifactsInfo:c});o.onsuccess=function(){return e({modelArtifactsInfo:c})},o.onerror=function(e){var t=(f=l.objectStore(Df)).delete(n.modelPath);t.onsuccess=function(){return a.close(),r(o.error)},t.onerror=function(e){return a.close(),r(o.error)}}},h.onerror=function(e){return a.close(),r(h.error)},l.oncomplete=function(){null==u?a.close():u.oncomplete=function(){return a.close()}}}},o.onerror=function(e){return r(o.error)}}))},e.URL_SCHEME="indexeddb://",e}(),Bf=function(e){return Y().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ff.URL_SCHEME)?(t=e.slice(Ff.URL_SCHEME.length),new Ff(t)):null;var t};If.registerSaveRouter(Bf),If.registerLoadRouter(Bf);var jf=function(){function e(){this.indexedDB=Mf()}return e.prototype.listModels=function(){return K(this,void 0,void 0,(function(){var e=this;return $(this,(function(t){return[2,new Promise((function(t,n){var r=e.indexedDB.open("tensorflowjs",1);r.onupgradeneeded=function(){return Nf(r)},r.onsuccess=function(){var e=r.result,o=e.transaction(Df,"readonly"),a=o.objectStore(Df).getAll();a.onsuccess=function(){for(var e={},n=0,r=a.result;n<r.length;n++){var o=r[n];e[o.modelPath]=o.modelArtifactsInfo}t(e)},a.onerror=function(t){return e.close(),n(a.error)},o.oncomplete=function(){return e.close()}},r.onerror=function(e){return n(r.error)}}))]}))}))},e.prototype.removeModel=function(e){return K(this,void 0,void 0,(function(){var t=this;return $(this,(function(n){var r;return e=(r=e).startsWith(Ff.URL_SCHEME)?r.slice(Ff.URL_SCHEME.length):r,[2,new Promise((function(n,r){var o=t.indexedDB.open("tensorflowjs",1);o.onupgradeneeded=function(){return Nf(o)},o.onsuccess=function(){var t,a=o.result,i=a.transaction(Df,"readwrite"),s=i.objectStore(Df),u=s.get(e);u.onsuccess=function(){if(null==u.result)return a.close(),r(new Error("Cannot find model with path '"+e+"' in IndexedDB."));var o=s.delete(e),i=function(){var o=(t=a.transaction(Tf,"readwrite")).objectStore(Tf).delete(e);o.onsuccess=function(){return n(u.result.modelArtifactsInfo)},o.onerror=function(e){return r(u.error)}};o.onsuccess=i,o.onerror=function(e){return i(),a.close(),r(u.error)}},u.onerror=function(e){return a.close(),r(u.error)},i.oncomplete=function(){null==t?a.close():t.oncomplete=function(){return a.close()}}},o.onerror=function(e){return r(o.error)}}))]}))}))},e}();if(Y().getBool("IS_BROWSER"))try{Rf.registerManager(Ff.URL_SCHEME,new jf)}catch(q){}var Lf="/",zf="tensorflowjs_models",Wf="info",Vf="model_topology",Hf="weight_specs",Uf="weight_data",Gf="model_metadata";function qf(e){return{info:[zf,e,Wf].join(Lf),topology:[zf,e,Vf].join(Lf),weightSpecs:[zf,e,Hf].join(Lf),weightData:[zf,e,Uf].join(Lf),modelMetadata:[zf,e,Gf].join(Lf)}}function Xf(e){var t=e.split(Lf);if(t.length<3)throw new Error("Invalid key format: "+e);return t.slice(1,t.length-1).join(Lf)}var Kf=function(){function e(e){if(!Y().getBool("IS_BROWSER")||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=qf(this.modelPath)}return e.prototype.save=function(e){return K(this,void 0,void 0,(function(){var t,n,r;return $(this,(function(o){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),r=Cf(e);try{return this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,(a=e.weightData,Ef?Buffer.from(a).toString("base64"):btoa(String.fromCharCode.apply(null,new Uint8Array(a))))),this.LS.setItem(this.keys.modelMetadata,JSON.stringify({format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,userDefinedMetadata:e.userDefinedMetadata})),[2,{modelArtifactsInfo:r}]}catch(e){throw this.LS.removeItem(this.keys.info),this.LS.removeItem(this.keys.topology),this.LS.removeItem(this.keys.weightSpecs),this.LS.removeItem(this.keys.weightData),this.LS.removeItem(this.keys.modelMetadata),new Error("Failed to save model '"+this.modelPath+"' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes="+r.modelTopologyBytes+", weightSpecsBytes="+r.weightSpecsBytes+", weightDataBytes="+r.weightDataBytes+".")}var a;return[2]}))}))},e.prototype.load=function(){return K(this,void 0,void 0,(function(){var e,t,n,r,o,a,i;return $(this,(function(s){if(null==(e=JSON.parse(this.LS.getItem(this.keys.info))))throw new Error("In local storage, there is no model with name '"+this.modelPath+"'");if("JSON"!==e.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");if(t={},null==(n=JSON.parse(this.LS.getItem(this.keys.topology))))throw new Error("In local storage, the topology of model '"+this.modelPath+"' is missing.");if(t.modelTopology=n,null==(r=JSON.parse(this.LS.getItem(this.keys.weightSpecs))))throw new Error("In local storage, the weight specs of model '"+this.modelPath+"' are missing.");if(t.weightSpecs=r,null!=(o=this.LS.getItem(this.keys.modelMetadata))&&(a=JSON.parse(o),t.format=a.format,t.generatedBy=a.generatedBy,t.convertedBy=a.convertedBy,t.userDefinedMetadata=a.userDefinedMetadata),null==(i=this.LS.getItem(this.keys.weightData)))throw new Error("In local storage, the binary weight values of model '"+this.modelPath+"' are missing.");return t.weightData=function(e){if(Ef){var t=Buffer.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}for(var n=atob(e),r=new Uint8Array(n.length),o=0;o<n.length;++o)r.set([n.charCodeAt(o)],o);return r.buffer}(i),[2,t]}))}))},e.URL_SCHEME="localstorage://",e}(),$f=function(e){return Y().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Kf.URL_SCHEME)?(t=e.slice(Kf.URL_SCHEME.length),new Kf(t)):null;var t};If.registerSaveRouter($f),If.registerLoadRouter($f);var Zf=function(){function e(){ue(Y().getBool("IS_BROWSER"),(function(){return"Current environment is not a web browser"})),ue(void 0!==window.localStorage,(function(){return"Current browser does not appear to support localStorage"})),this.LS=window.localStorage}return e.prototype.listModels=function(){return K(this,void 0,void 0,(function(){var e,t,n,r,o,a;return $(this,(function(i){for(e={},t=zf+Lf,n=Lf+Wf,r=0;r<this.LS.length;++r)(o=this.LS.key(r)).startsWith(t)&&o.endsWith(n)&&(a=Xf(o),e[a]=JSON.parse(this.LS.getItem(o)));return[2,e]}))}))},e.prototype.removeModel=function(e){return K(this,void 0,void 0,(function(){var t,n;return $(this,(function(r){var o;if(e=(o=e).startsWith(Kf.URL_SCHEME)?o.slice(Kf.URL_SCHEME.length):o,t=qf(e),null==this.LS.getItem(t.info))throw new Error("Cannot find model at path '"+e+"'");return n=JSON.parse(this.LS.getItem(t.info)),this.LS.removeItem(t.info),this.LS.removeItem(t.topology),this.LS.removeItem(t.weightSpecs),this.LS.removeItem(t.weightData),[2,n]}))}))},e}();if(Y().getBool("IS_BROWSER"))try{Rf.registerManager(Kf.URL_SCHEME,new Zf)}catch(q){}function Yf(e){return new Promise((function(e){return setTimeout(e)})).then(e)}var Jf=function(){function e(t){if(!Y().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");t.startsWith(e.URL_SCHEME)&&(t=t.slice(e.URL_SCHEME.length)),null!=t&&0!==t.length||(t="model"),this.modelTopologyFileName=t+".json",this.weightDataFileName=t+".weights.bin"}return e.prototype.save=function(e){return K(this,void 0,void 0,(function(){var t,n,r,o,a,i;return $(this,(function(s){switch(s.label){case 0:if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");if(t=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"})),!(e.modelTopology instanceof ArrayBuffer))return[3,1];throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");case 1:return n=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:n},o=window.URL.createObjectURL(new Blob([JSON.stringify(r)],{type:"application/json"})),(a=null==this.jsonAnchor?document.createElement("a"):this.jsonAnchor).download=this.modelTopologyFileName,a.href=o,[4,Yf((function(){return a.dispatchEvent(new MouseEvent("click"))}))];case 2:return s.sent(),null==e.weightData?[3,4]:((i=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor).download=this.weightDataFileName,i.href=t,[4,Yf((function(){return i.dispatchEvent(new MouseEvent("click"))}))]);case 3:s.sent(),s.label=4;case 4:return[2,{modelArtifactsInfo:Cf(e)}]}}))}))},e.URL_SCHEME="downloads://",e}(),Qf=function(){function e(e){if(null==e||e.length<1)throw new Error("When calling browserFiles, at least 1 file is required, but received "+e);this.files=e}return e.prototype.load=function(){return K(this,void 0,void 0,(function(){var e,t,n=this;return $(this,(function(r){return e=this.files[0],t=this.files.slice(1),[2,new Promise((function(r,o){var a=new FileReader;a.onload=function(a){var i=JSON.parse(a.target.result),s=i.modelTopology;if(null!=s){0===t.length&&r({modelTopology:s});var u=i.weightsManifest;if(null!=u){var c;try{c=n.checkManifestAndWeightFiles(u,t)}catch(e){return void o(e)}var l=[],f=[],h=[];u.forEach((function(e){e.paths.forEach((function(e){f.push(e),h.push(null)})),l.push.apply(l,e.weights)})),u.forEach((function(e){e.paths.forEach((function(e){var t=new FileReader;t.onload=function(t){var n=t.target.result,o=f.indexOf(e);h[o]=n,-1===h.indexOf(null)&&r({modelTopology:s,weightSpecs:l,weightData:Of(h),format:i.format,generatedBy:i.generatedBy,convertedBy:i.convertedBy,userDefinedMetadata:i.userDefinedMetadata})},t.onerror=function(t){return o("Failed to weights data from file of path '"+e+"'.")},t.readAsArrayBuffer(c[e])}))}))}else o(new Error("weightManifest field is missing from file "+e.name))}else o(new Error("modelTopology field is missing from file "+e.name))},a.onerror=function(t){return o("Failed to read model topology and weights manifest JSON from file '"+e.name+"'. BrowserFiles supports loading Keras-style tf.Model artifacts only.")},a.readAsText(e)}))]}))}))},e.prototype.checkManifestAndWeightFiles=function(e,t){for(var n=[],r=t.map((function(e){return kf(e.name)})),o={},a=0,i=e;a<i.length;a++)i[a].paths.forEach((function(e){var a=kf(e);if(-1!==n.indexOf(a))throw new Error("Duplicate file basename found in weights manifest: '"+a+"'");if(n.push(a),-1===r.indexOf(a))throw new Error("Weight file with basename '"+a+"' is not provided.");o[e]=t[r.indexOf(a)]}));if(n.length!==t.length)throw new Error("Mismatch in the number of files in weights manifest ("+n.length+") and the number of weight files provided ("+t.length+").");return o},e}();function eh(e,t,n,r){!function(e){ue(null!=e&&Array.isArray(e)&&e.length>0,(function(){return"promises must be a none empty array"}))}(e),function(e,t){ue(e>=0&&e<=1,(function(){return"Progress fraction must be in range [0, 1], but got startFraction "+e})),ue(t>=0&&t<=1,(function(){return"Progress fraction must be in range [0, 1], but got endFraction "+t})),ue(t>=e,(function(){return"startFraction must be no more than endFraction, but got startFraction "+e+" and endFraction "+t}))}(n=null==n?0:n,r=null==r?1:r);var o=0;return Promise.all(e.map((function(a){return a.then((function(a){var i=n+ ++o/e.length*(r-n);return t(i),a})),a})))}function th(e,t){return K(this,void 0,void 0,(function(){var n,r,o,a,i,s,u,c,l;return $(this,(function(f){switch(f.label){case 0:return null==t&&(t={}),n=null==t.fetchFunc?Y().platform.fetch:t.fetchFunc,r=e.map((function(e){return n(e,t.requestInit,{isBinary:!0})})),o=0,a=.5,null!=t.onProgress?[3,2]:[4,Promise.all(r)];case 1:return i=f.sent(),[3,4];case 2:return[4,eh(r,t.onProgress,o,a)];case 3:i=f.sent(),f.label=4;case 4:return s=i.map((function(e){return e.arrayBuffer()})),u=.5,c=1,null!=t.onProgress?[3,6]:[4,Promise.all(s)];case 5:return l=f.sent(),[3,8];case 6:return[4,eh(s,t.onProgress,u,c)];case 7:l=f.sent(),f.label=8;case 8:return[2,l]}}))}))}function nh(e){var t=this;return function(n,r,o){return void 0===r&&(r=""),K(t,void 0,void 0,(function(){var t,a,i,s,u,c,l,f,h,p;return $(this,(function(d){switch(d.label){case 0:if(t=n.map((function(){return!1})),a={},i=null!=o?o.map((function(){return!1})):[],s=[],n.forEach((function(e,n){var r=0;e.weights.forEach((function(e){var u="quantization"in e?e.quantization.dtype:e.dtype,c=bf[u]*he(e.shape),l=function(){t[n]=!0,null==a[n]&&(a[n]=[]),a[n].push({manifestEntry:e,groupOffset:r,sizeBytes:c})};null!=o?o.forEach((function(t,n){t===e.name&&(l(),i[n]=!0)})):l(),s.push(e.name),r+=c}))})),!i.every((function(e){return e})))throw u=o.filter((function(e,t){return!i[t]})),new Error("Could not find weights in manifest with names: "+u.join(", ")+". \nManifest JSON has weights with names: "+s.join(", ")+".");return c=t.reduce((function(e,t,n){return t&&e.push(n),e}),[]),l=[],c.forEach((function(e){n[e].paths.forEach((function(e){var t=r+(r.endsWith("/")?"":"/")+e;l.push(t)}))})),[4,e(l)];case 1:return f=d.sent(),h={},p=0,c.forEach((function(e){for(var t=n[e].paths.length,r=0,o=0;o<t;o++)r+=f[p+o].byteLength;for(var i=new ArrayBuffer(r),s=new Uint8Array(i),u=0,c=0;c<t;c++){var l=new Uint8Array(f[p+c]);s.set(l,u),u+=l.byteLength}a[e].forEach((function(e){var t=wf(i.slice(e.groupOffset,e.groupOffset+e.sizeBytes),[e.manifestEntry]);for(var n in t)h[n]=t[n]})),p+=t})),[2,h]}}))}))}}If.registerSaveRouter((function(e){return Y().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Jf.URL_SCHEME)?(void 0===(t=e.slice(Jf.URL_SCHEME.length))&&(t="model"),new Jf(t)):null;var t}));var rh=function(){function e(e,t){if(this.DEFAULT_METHOD="POST",null==t&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,null!=t.fetchFunc?(ue("function"==typeof t.fetchFunc,(function(){return"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=Y().platform.fetch,ue(null!=e&&e.length>0,(function(){return"URL path for http must not be null, undefined or empty."})),Array.isArray(e)&&ue(2===e.length,(function(){return"URL paths for http must have a length of 2, (actual length is "+e.length+")."})),this.path=e,null!=t.requestInit&&null!=t.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{}}return e.prototype.save=function(e){return K(this,void 0,void 0,(function(){var t,n,r,o;return $(this,(function(a){switch(a.label){case 0:if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");return(t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit)).body=new FormData,n=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,userDefinedMetadata:e.userDefinedMetadata,weightsManifest:n},t.body.append("model.json",new Blob([JSON.stringify(r)],{type:"application/json"}),"model.json"),null!=e.weightData&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:"application/octet-stream"}),"model.weights.bin"),[4,this.fetch(this.path,t)];case 1:if((o=a.sent()).ok)return[2,{modelArtifactsInfo:Cf(e),responses:[o]}];throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+o.status+".")}}))}))},e.prototype.load=function(){return K(this,void 0,void 0,(function(){var e,t,n,r,o,a,i,s,u,c,l,f;return $(this,(function(h){switch(h.label){case 0:return[4,this.fetch(this.path,this.requestInit)];case 1:if(!(e=h.sent()).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.");h.label=2;case 2:return h.trys.push([2,4,,5]),[4,e.json()];case 3:return t=h.sent(),[3,5];case 4:throw h.sent(),n="Failed to parse model JSON of response from "+this.path+".",this.path.endsWith(".pb")?n+=" 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.":n+=" Please make sure the server is serving valid JSON for this request.",new Error(n);case 5:if(r=t.modelTopology,o=t.weightsManifest,a=t.generatedBy,i=t.convertedBy,s=t.format,u=t.userDefinedMetadata,null==r&&null==o)throw new Error("The JSON from HTTP path "+this.path+" contains neither model topology or manifest for weights.");return null==o?[3,7]:[4,this.loadWeights(o)];case 6:f=h.sent(),c=f[0],l=f[1],h.label=7;case 7:return[2,{modelTopology:r,weightSpecs:c,weightData:l,userDefinedMetadata:u,generatedBy:a,convertedBy:i,format:s}]}}))}))},e.prototype.loadWeights=function(e){return K(this,void 0,void 0,(function(){var t,n,r,o,a,i,s,u,c,l,f;return $(this,(function(h){switch(h.label){case 0:for(t=Array.isArray(this.path)?this.path[1]:this.path,n=function(e){var t=e.lastIndexOf("/"),n=e.lastIndexOf("?");return[e.substring(0,t)+"/",n>t?e.substring(n):""]}(t),r=n[0],o=n[1],a=this.weightPathPrefix||r,i=[],s=0,u=e;s<u.length;s++)c=u[s],i.push.apply(i,c.weights);return l=[],e.forEach((function(e){e.paths.forEach((function(e){l.push(a+e+o)}))})),[4,th(l,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress})];case 1:return f=h.sent(),[2,[i,Of(f)]]}}))}))},e.URL_SCHEME_REGEX=/^https?:\/\//,e}();function oh(e){return null!=e.match(rh.URL_SCHEME_REGEX)}var ah=function(e,t){return"undefined"==typeof fetch?null:(Array.isArray(e)?e.every((function(e){return oh(e)})):oh(e))?ih(e,{onProgress:t}):null};function ih(e,t){return new rh(e,t)}If.registerSaveRouter(ah),If.registerLoadRouter(ah);var sh,uh=function(){function e(e){this.modelArtifacts=e}return e.prototype.load=function(){return K(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.modelArtifacts]}))}))},e}(),ch=function(){function e(e){this.saveHandler=e}return e.prototype.save=function(e){return K(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.saveHandler(e)]}))}))},e}(),lh=Object.freeze({browserFiles:function(e){return new Qf(e)},browserHTTPRequest:function(e,t){return ih(e,t)},concatenateArrayBuffers:Of,decodeWeights:wf,encodeWeights:function(e,t){return K(this,void 0,void 0,(function(){var n,r,o,a,i,s=this;return $(this,(function(u){switch(u.label){case 0:for(n=[],r=[],o=Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e),a=function(a){var i=o[a],u=Array.isArray(e)?e[a].tensor:e[i];if("float32"!==u.dtype&&"int32"!==u.dtype&&"bool"!==u.dtype&&"string"!==u.dtype)throw new Error("Unsupported dtype in weight '"+i+"': "+u.dtype);var c={name:i,shape:u.shape,dtype:u.dtype};if("string"===u.dtype){var l=new Promise((function(e){return K(s,void 0,void 0,(function(){var t,n,r,o,a,i,s;return $(this,(function(c){switch(c.label){case 0:return[4,u.bytes()];case 1:for(t=c.sent(),n=t.reduce((function(e,t){return e+t.length}),0)+4*t.length,r=new Uint8Array(n),o=0,a=0;a<t.length;a++)i=t[a],s=new Uint8Array(new Uint32Array([i.length]).buffer),r.set(s,o),o+=4,r.set(i,o),o+=i.length;return e(r),[2]}}))}))}));r.push(l)}else r.push(u.data());null!=t&&(c.group=t),n.push(c)},i=0;i<o.length;++i)a(i);return[4,Promise.all(r)];case 1:return[2,{data:xf(u.sent()),specs:n}]}}))}))},fromMemory:function(e,t,n,r){return 1===arguments.length?null!=e.modelTopology||null!=e.weightSpecs?new uh(e):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new uh({modelTopology:e})):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new uh({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r}))},getLoadHandlers:function(e,t){return If.getLoadHandlers(e,t)},getModelArtifactsInfoForJSON:Cf,getSaveHandlers:function(e){return If.getSaveHandlers(e)},http:ih,isHTTPScheme:oh,loadWeights:function(e,t,n,r){return void 0===t&&(t=""),K(this,void 0,void 0,(function(){return $(this,(function(o){return[2,nh((function(e){return th(e,{requestInit:r})}))(e,t,n)]}))}))},registerLoadRouter:function(e){return If.registerLoadRouter(e)},registerSaveRouter:function(e){return If.registerSaveRouter(e)},weightsLoaderFactory:nh,withSaveHandler:function(e){return new ch(e)},copyModel:function(e,t){return K(this,void 0,void 0,(function(){return $(this,(function(n){return[2,Pf(e,t,!1)]}))}))},listModels:function(){return K(this,void 0,void 0,(function(){var e,t,n,r,o,a,i;return $(this,(function(s){switch(s.label){case 0:e=Rf.getSchemes(),t={},n=0,r=e,s.label=1;case 1:return n<r.length?(o=r[n],[4,Rf.getManager(o).listModels()]):[3,4];case 2:for(i in a=s.sent())t[o+Sf+i]=a[i];s.label=3;case 3:return n++,[3,1];case 4:return[2,t]}}))}))},moveModel:function(e,t){return K(this,void 0,void 0,(function(){return $(this,(function(n){return[2,Pf(e,t,!0)]}))}))},removeModel:function(e){return K(this,void 0,void 0,(function(){var t;return $(this,(function(n){return t=Af(e),[2,Rf.getManager(t.scheme).removeModel(t.path)]}))}))}}),fh=zn({confusionMatrix_:function(e,t,n){var r=Sn(e,"labels","confusionMatrix"),o=Sn(t,"predictions","confusionMatrix");ue(null==n||n>0&&Number.isInteger(n),(function(){return"If provided, numClasses must be a positive integer, but got "+n})),ue(1===r.rank,(function(){return"Expected the rank of labels to be 1, but got "+r.rank})),ue(1===o.rank,(function(){return"Expected the rank of predictions to be 1, but got "+o.rank})),ue(r.shape[0]===o.shape[0],(function(){return"Mismatch in the number of examples: "+r.shape[0]+" vs. "+o.shape[0]+". Labels and predictions should have the same number of elements."})),ue(n>0&&Number.isInteger(n),(function(){return"numClasses is required to be a positive integer, but got "+n}));var a=Pr(r.asType("int32"),n),i=Pr(o.asType("int32"),n);return a.transpose().matMul(i).asType("int32")}}),hh=(Object.freeze({confusionMatrix:fh}),zn({fromPixels_:function(e,t){if(void 0===t&&(t=3),t>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==e)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");var n=!1,r=!1,o=!1,a=!1,i=!1;if(e.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&e instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)o=!0;else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)a=!0;else{if(null==e.getContext)throw new Error("pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was "+e.constructor.name);i=!0}if(o&&o&&e.readyState<2)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element.");if(null!=ee("FromPixels",mt.backendName))return mt.runKernel("FromPixels",{pixels:e},{numChannels:t});var s,u,c=o?[e.videoWidth,e.videoHeight]:[e.width,e.height],l=c[0],f=c[1];if(i?s=e.getContext("2d").getImageData(0,0,l,f).data:r||n?s=e.data:(a||o)&&(null==sh&&(sh=document.createElement("canvas").getContext("2d")),sh.canvas.width=l,sh.canvas.height=f,sh.drawImage(e,0,0,l,f),s=sh.getImageData(0,0,l,f).data),4===t)u=new Int32Array(s);else{var h=l*f;u=new Int32Array(h*t);for(var p=0;p<h;p++)for(var d=0;d<t;++d)u[p*t+d]=s[4*p+d]}return $n(u,[f,l,t],"int32")}})),ph=Object.freeze({toPixels:function(e,t){return K(this,void 0,void 0,(function(){var n,r,o,a,i,s,u,c,l,f,h,p,d,v,m,g,y,b,w,x,E,_,O;return $(this,(function(k){switch(k.label){case 0:if(n=Sn(e,"img","toPixels"),e instanceof et||(n=n.toInt()),2!==n.rank&&3!==n.rank)throw new Error("toPixels only supports rank 2 or 3 tensors, got rank "+n.rank+".");if(r=n.shape.slice(0,2),o=r[0],a=r[1],(i=2===n.rank?1:n.shape[2])>4||2===i)throw new Error("toPixels only supports depth of size 1, 3 or 4 but got "+i);return[4,n.data()];case 1:return s=k.sent(),u=n.min(),c=n.max(),[4,Promise.all([u.data(),c.data()])];case 2:if(l=k.sent(),f=l[0],h=l[1],p=f[0],d=h[0],u.dispose(),c.dispose(),"float32"===n.dtype){if(p<0||d>1)throw new Error("Tensor values for a float32 Tensor must be in the range [0 - 1] but got range ["+p+" - "+d+"].")}else{if("int32"!==n.dtype)throw new Error("Unsupported type for toPixels: "+n.dtype+". Please use float32 or int32 tensors.");if(p<0||d>255)throw new Error("Tensor values for a int32 Tensor must be in the range [0 - 255] but got range ["+p+" - "+d+"].")}for(v="float32"===n.dtype?255:1,m=new Uint8ClampedArray(a*o*4),g=0;g<o*a;++g)y=void 0,b=void 0,w=void 0,x=void 0,1===i?(y=s[g]*v,b=s[g]*v,w=s[g]*v,x=255):3===i?(y=s[3*g]*v,b=s[3*g+1]*v,w=s[3*g+2]*v,x=255):4===i&&(y=s[4*g]*v,b=s[4*g+1]*v,w=s[4*g+2]*v,x=s[4*g+3]*v),m[0+(E=4*g)]=Math.round(y),m[E+1]=Math.round(b),m[E+2]=Math.round(w),m[E+3]=Math.round(x);return null!=t&&(t.width=a,t.height=o,_=t.getContext("2d"),O=new ImageData(m,a,o),_.putImageData(O,0,0)),n!==e&&n.dispose(),[2,m]}}))}))},fromPixels:hh}),dh=function(){function e(){}return e.prototype.getClassName=function(){return this.constructor.className},e.fromConfig=function(e,t){return new e(t)},e}(),vh=function(){function e(){this.classNameMap={}}return e.getMap=function(){return null==e.instance&&(e.instance=new e),e.instance},e.register=function(t){e.getMap().classNameMap[t.className]=[t,t.fromConfig]},e}();function mh(e){ue(null!=e.className,(function(){return"Class being registered does not have the static className property defined."})),ue("string"==typeof e.className,(function(){return"className is required to be a string, but got type "+typeof e.className})),ue(e.className.length>0,(function(){return"Class being registered has an empty-string as its className, which is disallowed."})),vh.register(e)}Object.freeze({Serializable:dh,SerializationMap:vh,registerClass:mh});function gh(){return 32===mt.backend.floatPrecision()?.001:.1}function yh(e,t,n){var r=!0;if((Ie(e)||Ie(t))&&(r=!1),Ie(e)&&Ie(t)&&(r=!0),r){var o=e.constructor.name,a=t.constructor.name;if(o!==a)throw new Error("Arrays are of different type. Actual: "+o+". Expected: "+a)}if(Array.isArray(e)&&Array.isArray(t)){var i=Cn(e),s=Cn(t);if(!pe(i,s))throw new Error("Arrays have different shapes. Actual: ["+i+"]. Expected: ["+s+"]")}var u=Ie(e)?e:fe(e),c=Ie(t)?t:fe(t);if(u.length!==c.length)throw new Error("Arrays have different lengths actual: "+u.length+" vs expected: "+c.length+".\nActual: "+u+".\nExpected: "+c+".");for(var l=0;l<c.length;++l){var f=u[l],h=c[l];if(!n(f,h))throw new Error("Arrays differ: actual["+l+"] = "+f+", expected["+l+"] = "+h+".\nActual: "+u+".\nExpected: "+c+".")}}function bh(e,t,n){return!isFinite(e)&&!isFinite(t)||!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}Object.freeze({TEST_EPSILON_FLOAT16:.1,expectArraysClose:function(e,t,n){return null==n&&(n=gh()),yh(e,t,(function(e,t){return bh(e,t,n)}))},testEpsilon:gh,expectPromiseToFail:function(e,t){e().then((function(){return t.fail()}),(function(){return t()}))},expectArraysEqual:function(e,t){var n="string"==typeof t||"number"==typeof t||"boolean"==typeof t?[t]:t;return Ae(e)||Ae(e[0])||Ae(t)||Ae(t[0])?yh(e,n,(function(e,t){return e==t})):yh(e,t,(function(e,t){return bh(e,t,0)}))},expectNumbersClose:function(e,t,n){if(null==n&&(n=gh()),!bh(e,t,n))throw new Error("Numbers differ: actual === "+e+", expected === "+t)},expectValuesInRange:function(e,t,n){for(var r=0;r<e.length;r++)if(e[r]<t||e[r]>n)throw new Error("Value out of range:"+e[r]+" low: "+t+", high: "+n)},expectArrayBuffersEqual:function(e,t){expect(new Float32Array(e)).toEqual(new Float32Array(t))}}),Object.freeze({gpgpu_util:yi,webgl_util:wn,forceHalfFloat:function(){Y().set("WEBGL_FORCE_F16_TEXTURES",!0)},MathBackendWebGL:Os,setWebGLContext:Ot,GPGPUContext:bi});var wh=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return X(t,e),t.prototype.minimize=function(e,t,n){void 0===t&&(t=!1);var r=this.computeGradients(e,n),o=r.value,a=r.grads;if(null!=n){var i=n.map((function(e){return{name:e.name,tensor:a[e.name]}}));this.applyGradients(i)}else this.applyGradients(a);return On(a),t?o:(o.dispose(),null)},Object.defineProperty(t.prototype,"iterations",{get:function(){return null==this.iterations_&&(this.iterations_=0),this.iterations_},enumerable:!0,configurable:!0}),t.prototype.incrementIterations=function(){this.iterations_=this.iterations+1},t.prototype.computeGradients=function(e,t){return function(e,t){ue(Me(e),(function(){return"The f passed in variableGrads(f) must be a function"})),ue(null==t||Array.isArray(t)&&t.every((function(e){return e instanceof it})),(function(){return"The varList passed in variableGrads(f, varList) must be an array of variables"}));var n=null!=t;if(!n)for(var r in t=[],mt.registeredVariables)t.push(mt.registeredVariables[r]);var o=n?t.filter((function(e){return!e.trainable})):null,a=t.length;ue((t=t.filter((function(e){return e.trainable}))).length>0,(function(){return"variableGrads() expects at least one of the input variables to be trainable, but none of the "+a+" variables is trainable."}));var i=mt.gradients(e,t,null,!0),s=i.value,u=i.grads;ue(u.some((function(e){return null!=e})),(function(){return"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()."})),ue(0===s.rank,(function(){return"The f passed in variableGrads(f) must return a scalar, but it returned a rank-"+s.rank+" tensor"}));var c={};return t.forEach((function(e,t){null!=u[t]&&(c[e.name]=u[t])})),null!=o&&o.forEach((function(e){return c[e.name]=null})),{value:s,grads:c}}(e,t)},t.prototype.dispose=function(){null!=this.iterations_&&On(this.iterations_)},t.prototype.saveIterations=function(){return K(this,void 0,void 0,(function(){return $(this,(function(e){return null==this.iterations_&&(this.iterations_=0),[2,{name:"iter",tensor:qn(this.iterations_,"int32")}]}))}))},t.prototype.getWeights=function(){return K(this,void 0,void 0,(function(){return $(this,(function(e){throw new Error("getWeights() is not implemented for this optimizer yet.")}))}))},t.prototype.setWeights=function(e){return K(this,void 0,void 0,(function(){return $(this,(function(e){throw new Error("setWeights() is not implemented for this optimizer class "+this.getClassName())}))}))},t.prototype.extractIterations=function(e){return K(this,void 0,void 0,(function(){var t;return $(this,(function(n){switch(n.label){case 0:return t=this,[4,e[0].tensor.data()];case 1:return t.iterations_=n.sent()[0],[2,e.slice(1)]}}))}))},t}(dh);Object.defineProperty(wh,Symbol.hasInstance,{value:function(e){return null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients}});var xh=function(e){function t(t,n,r){void 0===r&&(r=null);var o=e.call(this)||this;return o.learningRate=t,o.rho=n,o.epsilon=r,o.accumulatedGrads=[],o.accumulatedUpdates=[],null==r&&(o.epsilon=mt.backend.epsilon()),o}return X(t,e),t.prototype.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var o=mt.registeredVariables[n];null==t.accumulatedGrads[r]&&(t.accumulatedGrads[r]={originalName:n+"/accum_grad",variable:_n((function(){return nr(o).variable(!1)}))}),null==t.accumulatedUpdates[r]&&(t.accumulatedUpdates[r]={originalName:n+"/accum_var",variable:_n((function(){return nr(o).variable(!1)}))});var a=Array.isArray(e)?e[r].tensor:e[n];if(null!=a){var i=t.accumulatedGrads[r].variable,s=t.accumulatedUpdates[r].variable;_n((function(){var e=i.mul(t.rho).add(a.square().mul(1-t.rho)),n=s.add(t.epsilon).sqrt().div(i.add(t.epsilon).sqrt()).mul(a),r=s.mul(t.rho).add(n.square().mul(1-t.rho));i.assign(e),s.assign(r);var u=n.mul(-t.learningRate).add(o);o.assign(u)}))}})),this.incrementIterations()},t.prototype.dispose=function(){null!=this.accumulatedUpdates&&(On(this.accumulatedGrads.map((function(e){return e.variable}))),On(this.accumulatedUpdates.map((function(e){return e.variable}))))},t.prototype.getWeights=function(){return K(this,void 0,void 0,(function(){var e;return $(this,(function(t){switch(t.label){case 0:return e=this.accumulatedGrads.concat(this.accumulatedUpdates),[4,this.saveIterations()];case 1:return[2,[t.sent()].concat(e.map((function(e){return{name:e.originalName,tensor:e.variable}})))]}}))}))},t.prototype.setWeights=function(e){return K(this,void 0,void 0,(function(){var t;return $(this,(function(n){switch(n.label){case 0:return[4,this.extractIterations(e)];case 1:return e=n.sent(),t=e.length/2,this.accumulatedGrads=e.slice(0,t).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}})),this.accumulatedUpdates=e.slice(t,2*t).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}})),[2]}}))}))},t.prototype.getConfig=function(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}},t.fromConfig=function(e,t){return new e(t.learningRate,t.rho,t.epsilon)},t.className="Adadelta",t}(wh);mh(xh);var Eh=function(e){function t(t,n){void 0===n&&(n=.1);var r=e.call(this)||this;return r.learningRate=t,r.initialAccumulatorValue=n,r.accumulatedGrads=[],r}return X(t,e),t.prototype.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var o=mt.registeredVariables[n];null==t.accumulatedGrads[r]&&(t.accumulatedGrads[r]={originalName:n+"/accumulator",variable:_n((function(){return Qn(o.shape,t.initialAccumulatorValue).variable(!1)}))});var a=Array.isArray(e)?e[r].tensor:e[n];if(null!=a){var i=t.accumulatedGrads[r].variable;_n((function(){var e=i.add(a.square());i.assign(e);var n=a.div(e.add(mt.backend.epsilon()).sqrt()).mul(-t.learningRate).add(o);o.assign(n)}))}})),this.incrementIterations()},t.prototype.dispose=function(){null!=this.accumulatedGrads&&On(this.accumulatedGrads.map((function(e){return e.variable})))},t.prototype.getWeights=function(){return K(this,void 0,void 0,(function(){return $(this,(function(e){switch(e.label){case 0:return[4,this.saveIterations()];case 1:return[2,[e.sent()].concat(this.accumulatedGrads.map((function(e){return{name:e.originalName,tensor:e.variable}})))]}}))}))},t.prototype.setWeights=function(e){return K(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.extractIterations(e)];case 1:return e=t.sent(),this.accumulatedGrads=e.map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}})),[2]}}))}))},t.prototype.getConfig=function(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}},t.fromConfig=function(e,t){return new e(t.learningRate,t.initialAccumulatorValue)},t.className="Adagrad",t}(wh);mh(Eh);var _h=function(e){function t(t,n,r,o){void 0===o&&(o=null);var a=e.call(this)||this;return a.learningRate=t,a.beta1=n,a.beta2=r,a.epsilon=o,a.accumulatedFirstMoment=[],a.accumulatedSecondMoment=[],_n((function(){a.accBeta1=qn(n).variable(),a.accBeta2=qn(r).variable()})),null==o&&(a.epsilon=mt.backend.epsilon()),a}return X(t,e),t.prototype.applyGradients=function(e){var t=this,n=Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e);_n((function(){var r=qu(1,t.accBeta1),o=qu(1,t.accBeta2);n.forEach((function(n,a){var i=mt.registeredVariables[n];null==t.accumulatedFirstMoment[a]&&(t.accumulatedFirstMoment[a]={originalName:n+"/m",variable:_n((function(){return nr(i).variable(!1)}))}),null==t.accumulatedSecondMoment[a]&&(t.accumulatedSecondMoment[a]={originalName:n+"/v",variable:_n((function(){return nr(i).variable(!1)}))});var s=Array.isArray(e)?e[a].tensor:e[n];if(null!=s){var u=t.accumulatedFirstMoment[a].variable,c=t.accumulatedSecondMoment[a].variable,l=u.mul(t.beta1).add(s.mul(1-t.beta1)),f=c.mul(t.beta2).add(s.square().mul(1-t.beta2)),h=l.div(r),p=f.div(o);u.assign(l),c.assign(f);var d=h.div(p.sqrt().add(t.epsilon)).mul(-t.learningRate).add(i);i.assign(d)}})),t.accBeta1.assign(t.accBeta1.mul(t.beta1)),t.accBeta2.assign(t.accBeta2.mul(t.beta2))})),this.incrementIterations()},t.prototype.dispose=function(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&On(this.accumulatedFirstMoment.map((function(e){return e.variable}))),null!=this.accumulatedSecondMoment&&On(this.accumulatedSecondMoment.map((function(e){return e.variable})))},t.prototype.getWeights=function(){return K(this,void 0,void 0,(function(){var e;return $(this,(function(t){switch(t.label){case 0:return e=this.accumulatedFirstMoment.concat(this.accumulatedSecondMoment),[4,this.saveIterations()];case 1:return[2,[t.sent()].concat(e.map((function(e){return{name:e.originalName,tensor:e.variable}})))]}}))}))},t.prototype.setWeights=function(e){return K(this,void 0,void 0,(function(){var t,n=this;return $(this,(function(r){switch(r.label){case 0:return[4,this.extractIterations(e)];case 1:return e=r.sent(),_n((function(){n.accBeta1.assign(Vu(n.beta1,n.iterations_+1)),n.accBeta2.assign(Vu(n.beta2,n.iterations_+1))})),t=e.length/2,this.accumulatedFirstMoment=e.slice(0,t).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}})),this.accumulatedSecondMoment=e.slice(t,2*t).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}})),[2]}}))}))},t.prototype.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}},t.fromConfig=function(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)},t.className="Adam",t}(wh);mh(_h);var Oh=function(e){function t(t,n,r,o,a){void 0===o&&(o=null),void 0===a&&(a=0);var i=e.call(this)||this;return i.learningRate=t,i.beta1=n,i.beta2=r,i.epsilon=o,i.decay=a,i.accumulatedFirstMoment=[],i.accumulatedWeightedInfNorm=[],_n((function(){i.iteration=qn(0).variable(),i.accBeta1=qn(n).variable()})),null==o&&(i.epsilon=mt.backend.epsilon()),i}return X(t,e),t.prototype.applyGradients=function(e){var t=this,n=Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e);_n((function(){var r=qu(1,t.accBeta1),o=Au(-t.learningRate,t.iteration.mul(t.decay).add(1));n.forEach((function(n,a){var i=mt.registeredVariables[n];null==t.accumulatedFirstMoment[a]&&(t.accumulatedFirstMoment[a]={originalName:n+"/m",variable:nr(i).variable(!1)}),null==t.accumulatedWeightedInfNorm[a]&&(t.accumulatedWeightedInfNorm[a]={originalName:n+"/v",variable:nr(i).variable(!1)});var s=Array.isArray(e)?e[a].tensor:e[n];if(null!=s){var u=t.accumulatedFirstMoment[a].variable,c=t.accumulatedWeightedInfNorm[a].variable,l=u.mul(t.beta1).add(s.mul(1-t.beta1)),f=c.mul(t.beta2),h=s.abs(),p=f.maximum(h);u.assign(l),c.assign(p);var d=o.div(r).mul(l.div(p.add(t.epsilon))).add(i);i.assign(d)}})),t.iteration.assign(t.iteration.add(1)),t.accBeta1.assign(t.accBeta1.mul(t.beta1))})),this.incrementIterations()},t.prototype.dispose=function(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&On(this.accumulatedFirstMoment.map((function(e){return e.variable}))),null!=this.accumulatedWeightedInfNorm&&On(this.accumulatedWeightedInfNorm.map((function(e){return e.variable})))},t.prototype.getWeights=function(){return K(this,void 0,void 0,(function(){return $(this,(function(e){throw new Error("getWeights() is not implemented for Adamax yet.")}))}))},t.prototype.setWeights=function(e){return K(this,void 0,void 0,(function(){return $(this,(function(e){throw new Error("setWeights() is not implemented for Adamax yet.")}))}))},t.prototype.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}},t.fromConfig=function(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)},t.className="Adamax",t}(wh);mh(Oh);var kh=function(e){function t(t){var n=e.call(this)||this;return n.learningRate=t,n.setLearningRate(t),n}return X(t,e),t.prototype.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var o=Array.isArray(e)?e[r].tensor:e[n];if(null!=o){var a=mt.registeredVariables[n];_n((function(){var e=t.c.mul(o).add(a);a.assign(e)}))}})),this.incrementIterations()},t.prototype.setLearningRate=function(e){this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=function(e){return mt.keep(e)}(qn(-e))},t.prototype.dispose=function(){this.c.dispose()},t.prototype.getWeights=function(){return K(this,void 0,void 0,(function(){return $(this,(function(e){switch(e.label){case 0:return[4,this.saveIterations()];case 1:return[2,[e.sent()]]}}))}))},t.prototype.setWeights=function(e){return K(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.extractIterations(e)];case 1:if(0!==(e=t.sent()).length)throw new Error("SGD optimizer does not have settable weights.");return[2]}}))}))},t.prototype.getConfig=function(){return{learningRate:this.learningRate}},t.fromConfig=function(e,t){return new e(t.learningRate)},t.className="SGD",t}(wh);mh(kh);var Ch=function(e){function t(t,n,r){void 0===r&&(r=!1);var o=e.call(this,t)||this;return o.learningRate=t,o.momentum=n,o.useNesterov=r,o.accumulations=[],o.m=qn(o.momentum),o}return X(t,e),t.prototype.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var o=mt.registeredVariables[n];null==t.accumulations[r]&&(t.accumulations[r]={originalName:n+"/momentum",variable:_n((function(){return nr(o).variable(!1)}))});var a=t.accumulations[r].variable,i=Array.isArray(e)?e[r].tensor:e[n];null!=i&&_n((function(){var e,n=t.m.mul(a).add(i);e=t.useNesterov?t.c.mul(i.add(n.mul(t.m))).add(o):t.c.mul(n).add(o),a.assign(n),o.assign(e)}))})),this.incrementIterations()},t.prototype.dispose=function(){this.m.dispose(),null!=this.accumulations&&On(this.accumulations.map((function(e){return e.variable})))},t.prototype.setMomentum=function(e){this.momentum=e},t.prototype.getWeights=function(){return K(this,void 0,void 0,(function(){return $(this,(function(e){switch(e.label){case 0:return[4,this.saveIterations()];case 1:return[2,[e.sent()].concat(this.accumulations.map((function(e){return{name:e.originalName,tensor:e.variable}})))]}}))}))},t.prototype.setWeights=function(e){return K(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.extractIterations(e)];case 1:return e=t.sent(),this.accumulations=e.map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}})),[2]}}))}))},t.prototype.getConfig=function(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}},t.fromConfig=function(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)},t.className="Momentum",t}(kh);mh(Ch);var Ih=function(e){function t(t,n,r,o,a){void 0===n&&(n=.9),void 0===r&&(r=0),void 0===o&&(o=null),void 0===a&&(a=!1);var i=e.call(this)||this;return i.learningRate=t,i.decay=n,i.momentum=r,i.epsilon=o,i.accumulatedMeanSquares=[],i.accumulatedMoments=[],i.accumulatedMeanGrads=[],i.centered=a,null==o&&(i.epsilon=mt.backend.epsilon()),i}return X(t,e),t.prototype.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var o=mt.registeredVariables[n];null==t.accumulatedMeanSquares[r]&&(t.accumulatedMeanSquares[r]={originalName:n+"/rms",variable:_n((function(){return nr(o).variable(!1)}))}),null==t.accumulatedMoments[r]&&(t.accumulatedMoments[r]={originalName:n+"/momentum",variable:_n((function(){return nr(o).variable(!1)}))}),null==t.accumulatedMeanGrads[r]&&t.centered&&(t.accumulatedMeanGrads[r]={originalName:n+"/mg",variable:_n((function(){return nr(o).variable(!1)}))});var a=Array.isArray(e)?e[r].tensor:e[n];if(null!=a){var i=t.accumulatedMeanSquares[r].variable,s=t.accumulatedMoments[r].variable;_n((function(){var e=i.mul(t.decay).add(a.square().mul(1-t.decay));if(t.centered){var n=t.accumulatedMeanGrads[r].variable,u=n.mul(t.decay).add(a.mul(1-t.decay)),c=s.mul(t.momentum).add(a.mul(t.learningRate).div(e.sub(u.square().add(t.epsilon)).sqrt()));i.assign(e),n.assign(u),s.assign(c);var l=o.sub(c);o.assign(l)}else{var f=i.mul(t.decay).add(a.square().mul(1-t.decay));c=s.mul(t.momentum).add(a.mul(t.learningRate).div(f.add(t.epsilon).sqrt())),i.assign(f),s.assign(c),l=o.sub(c),o.assign(l)}}))}})),this.incrementIterations()},t.prototype.dispose=function(){null!=this.accumulatedMeanSquares&&On(this.accumulatedMeanSquares.map((function(e){return e.variable}))),null!=this.accumulatedMeanGrads&&this.centered&&On(this.accumulatedMeanGrads.map((function(e){return e.variable}))),null!=this.accumulatedMoments&&On(this.accumulatedMoments.map((function(e){return e.variable})))},t.prototype.getWeights=function(){return K(this,void 0,void 0,(function(){var e;return $(this,(function(t){switch(t.label){case 0:return e=this.accumulatedMeanSquares.concat(this.accumulatedMoments),this.centered&&e.push.apply(e,this.accumulatedMeanGrads),[4,this.saveIterations()];case 1:return[2,[t.sent()].concat(e.map((function(e){return{name:e.originalName,tensor:e.variable}})))]}}))}))},t.prototype.setWeights=function(e){return K(this,void 0,void 0,(function(){var t;return $(this,(function(n){switch(n.label){case 0:return[4,this.extractIterations(e)];case 1:return e=n.sent(),t=this.centered?e.length/3:e.length/2,this.accumulatedMeanSquares=e.slice(0,t).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}})),this.accumulatedMoments=e.slice(t,2*t).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}})),this.centered&&(this.accumulatedMeanGrads=e.slice(2*t,3*t).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}}))),[2]}}))}))},t.prototype.getConfig=function(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}},t.fromConfig=function(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)},t.className="RMSProp",t}(wh);mh(Ih);var Sh=function(){function e(){}return e.sgd=function(e){return new kh(e)},e.momentum=function(e,t,n){return void 0===n&&(n=!1),new Ch(e,t,n)},e.rmsprop=function(e,t,n,r,o){return void 0===t&&(t=.9),void 0===n&&(n=0),void 0===r&&(r=null),void 0===o&&(o=!1),new Ih(e,t,n,r,o)},e.adam=function(e,t,n,r){return void 0===e&&(e=.001),void 0===t&&(t=.9),void 0===n&&(n=.999),void 0===r&&(r=null),new _h(e,t,n,r)},e.adadelta=function(e,t,n){return void 0===e&&(e=.001),void 0===t&&(t=.95),void 0===n&&(n=null),new xh(e,t,n)},e.adamax=function(e,t,n,r,o){return void 0===e&&(e=.002),void 0===t&&(t=.9),void 0===n&&(n=.999),void 0===r&&(r=null),void 0===o&&(o=0),new Oh(e,t,n,r,o)},e.adagrad=function(e,t){return void 0===t&&(t=.1),new Eh(e,t)},e}();Sh.sgd,Sh.momentum,Sh.adadelta,Sh.adagrad,Sh.rmsprop,Sh.adamax,Sh.adam,"undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate&&setImmediate;Je=cf;var Rh=function(e,t){return Rh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},Rh(e,t)};function Ah(e,t){function n(){this.constructor=e}Rh(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var Ph=function(){return Ph=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ph.apply(this,arguments)};function Th(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(X){a(X)}}function s(e){try{u(r.throw(e))}catch(X){a(X)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))}function Dh(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(X){a=[6,X],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function Mh(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var a=arguments[t],i=0,s=a.length;i<s;i++,o++)r[o]=a[i];return r}var Nh=function(){function e(e,t){if(!Hh(e)||!Hh(t))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:e,height:t}));this._width=e,this._height=t}return Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),e.prototype.reverse=function(){return new e(1/this.width,1/this.height)},e}();function Fh(e,t){return e instanceof et&&e.shape.length===t}function Bh(e){return Fh(e,3)}function jh(e){return Fh(e,4)}function Lh(e){return e%2==0}function zh(e){return e&&e.width&&e.height}function Wh(e){return e.reduce((function(e,t){return e.add(t)}),new Gh(0,0)).div(new Gh(e.length,e.length))}function Vh(e,t,n){return Array(e).fill(0).map((function(e,r){return t+r*n}))}function Hh(e){return!!e&&e!==1/0&&e!==-1/0&&!isNaN(e)||0===e}function Uh(e){return Hh(e)&&0<=e&&e<=1}var Gh=function(){function e(e,t){this._x=e,this._y=t}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y)},e.prototype.sub=function(t){return new e(this.x-t.x,this.y-t.y)},e.prototype.mul=function(t){return new e(this.x*t.x,this.y*t.y)},e.prototype.div=function(t){return new e(this.x/t.x,this.y/t.y)},e.prototype.abs=function(){return new e(Math.abs(this.x),Math.abs(this.y))},e.prototype.magnitude=function(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y))},e}(),qh=function(){function e(t,n){void 0===n&&(n=!0);var r=t||{},o=[r.left,r.top,r.right,r.bottom].every(Hh),a=[r.x,r.y,r.width,r.height].every(Hh);if(!a&&!o)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify(r));var i=a?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top],s=i[0],u=i[1],c=i[2],l=i[3];e.assertIsValidBox({x:s,y:u,width:c,height:l},"Box.constructor",n),this._x=s,this._y=u,this._width=c,this._height=l}return e.isRect=function(e){return!!e&&[e.x,e.y,e.width,e.height].every(Hh)},e.assertIsValidBox=function(t,n,r){if(void 0===r&&(r=!1),!e.isRect(t))throw new Error(n+" - invalid box: "+JSON.stringify(t)+", expected object with properties x, y, width, height");if(!r&&(t.width<0||t.height<0))throw new Error(n+" - width ("+t.width+") and height ("+t.height+") must be positive numbers")},Object.defineProperty(e.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"left",{get:function(){return this.x},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"top",{get:function(){return this.y},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"right",{get:function(){return this.x+this.width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"area",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topLeft",{get:function(){return new Gh(this.left,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topRight",{get:function(){return new Gh(this.right,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomLeft",{get:function(){return new Gh(this.left,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomRight",{get:function(){return new Gh(this.right,this.bottom)},enumerable:!0,configurable:!0}),e.prototype.round=function(){var t=[this.x,this.y,this.width,this.height].map((function(e){return Math.round(e)}));return new e({x:t[0],y:t[1],width:t[2],height:t[3]})},e.prototype.floor=function(){var t=[this.x,this.y,this.width,this.height].map((function(e){return Math.floor(e)}));return new e({x:t[0],y:t[1],width:t[2],height:t[3]})},e.prototype.toSquare=function(){var t=this,n=t.x,r=t.y,o=t.width,a=t.height,i=Math.abs(o-a);return o<a&&(n-=i/2,o+=i),a<o&&(r-=i/2,a+=i),new e({x:n,y:r,width:o,height:a})},e.prototype.rescale=function(t){var n=zh(t)?t.width:t,r=zh(t)?t.height:t;return new e({x:this.x*n,y:this.y*r,width:this.width*n,height:this.height*r})},e.prototype.pad=function(t,n){var r=[this.x-t/2,this.y-n/2,this.width+t,this.height+n];return new e({x:r[0],y:r[1],width:r[2],height:r[3]})},e.prototype.clipAtImageBorders=function(t,n){var r=this,o=r.x,a=r.y,i=r.right,s=r.bottom,u=Math.max(o,0),c=Math.max(a,0),l=i-u,f=s-c;return new e({x:u,y:c,width:Math.min(l,t-u),height:Math.min(f,n-c)}).floor()},e.prototype.shift=function(t,n){var r=this.width,o=this.height;return new e({x:this.x+t,y:this.y+n,width:r,height:o})},e.prototype.padAtBorders=function(e,t){var n=this.width+1,r=this.height+1,o=n,a=r,i=this.left,s=this.top,u=this.right,c=this.bottom;return u>t&&(o=-u+t+n,u=t),c>e&&(a=-c+e+r,c=e),i<1&&(a=2-i,i=1),s<1&&(a=2-s,s=1),{dy:1,edy:a,dx:1,edx:o,y:s,ey:c,x:i,ex:u,w:n,h:r}},e.prototype.calibrate=function(t){return new e({left:this.left+t.left*this.width,top:this.top+t.top*this.height,right:this.right+t.right*this.width,bottom:this.bottom+t.bottom*this.height}).toSquare().round()},e}(),Xh=function(e){function t(t,n,r,o,a){return void 0===a&&(a=!1),e.call(this,{left:t,top:n,right:r,bottom:o},a)||this}return Ah(t,e),t}(qh),Kh=function(){function e(e,t,n,r,o){this._imageDims=new Nh(o.width,o.height),this._score=e,this._classScore=t,this._className=n,this._box=new qh(r).rescale(this._imageDims)}return Object.defineProperty(e.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"className",{get:function(){return this._className},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"box",{get:function(){return this._box},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageDims",{get:function(){return this._imageDims},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageWidth",{get:function(){return this.imageDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageHeight",{get:function(){return this.imageDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"relativeBox",{get:function(){return new qh(this._box).rescale(this.imageDims.reverse())},enumerable:!0,configurable:!0}),e.prototype.forSize=function(t,n){return new e(this.score,this.classScore,this.className,this.relativeBox,{width:t,height:n})},e}(),$h=function(e){function t(t,n,r){return e.call(this,t,t,"",n,r)||this}return Ah(t,e),t.prototype.forSize=function(n,r){var o=e.prototype.forSize.call(this,n,r);return new t(o.score,o.relativeBox,o.imageDims)},t}(Kh);function Zh(e,t,n){void 0===n&&(n=!0);var r=Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top));return n?r/(e.area+t.area-r):r/Math.min(e.area,t.area)}function Yh(e,t,n,r){void 0===r&&(r=!0);for(var o=t.map((function(e,t){return{score:e,boxIndex:t}})).sort((function(e,t){return e.score-t.score})).map((function(e){return e.boxIndex})),a=[],i=function(){var t=o.pop();a.push(t);for(var i=o,s=[],u=0;u<i.length;u++){var c=i[u],l=e[t],f=e[c];s.push(Zh(l,f,r))}o=o.filter((function(e,t){return s[t]<=n}))};o.length>0;)i();return a}function Jh(e,t){return _n((function(){var n=t[0],r=t[1],o=t[2],a=Qn(Mh(e.shape.slice(0,3),[1]),n),i=Qn(Mh(e.shape.slice(0,3),[1]),r),s=Qn(Mh(e.shape.slice(0,3),[1]),o),u=rr([a,i,s],3);return qu(e,u)}))}function Qh(e){return 1/(1+Math.exp(-e))}var ep,tp=function(e){function t(t,n,r,o,a){return void 0===a&&(a=!1),e.call(this,{x:t,y:n,width:r,height:o},a)||this}return Ah(t,e),t}(qh),np=function(){function e(e,t,n){void 0===n&&(n=new Gh(0,0));var r=t.width,o=t.height;this._imgDims=new Nh(r,o),this._shift=n,this._positions=e.map((function(e){return e.mul(new Gh(r,o)).add(n)}))}return Object.defineProperty(e.prototype,"shift",{get:function(){return new Gh(this._shift.x,this._shift.y)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageWidth",{get:function(){return this._imgDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageHeight",{get:function(){return this._imgDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"positions",{get:function(){return this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"relativePositions",{get:function(){var e=this;return this._positions.map((function(t){return t.sub(e._shift).div(new Gh(e.imageWidth,e.imageHeight))}))},enumerable:!0,configurable:!0}),e.prototype.forSize=function(e,t){return new this.constructor(this.relativePositions,{width:e,height:t})},e.prototype.shiftBy=function(e,t){return new this.constructor(this.relativePositions,this._imgDims,new Gh(e,t))},e.prototype.shiftByPoint=function(e){return this.shiftBy(e.x,e.y)},e.prototype.align=function(e,t){if(void 0===t&&(t={}),e){var n=e instanceof $h?e.box.floor():new qh(e);return this.shiftBy(n.x,n.y).align(null,t)}var r=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},t),o=r.useDlibAlignment,a=r.minBoxPadding;return o?this.alignDlib():this.alignMinBbox(a)},e.prototype.alignDlib=function(){var e=this.getRefPointsForAlignment(),t=e[0],n=e[1],r=e[2],o=function(e){return r.sub(e).magnitude()},a=(o(t)+o(n))/2,i=Math.floor(a/.45),s=Wh(e),u=Math.floor(Math.max(0,s.x-.5*i)),c=Math.floor(Math.max(0,s.y-.43*i));return new tp(u,c,Math.min(i,this.imageWidth+u),Math.min(i,this.imageHeight+c))},e.prototype.alignMinBbox=function(e){var t=function(e){var t=e.map((function(e){return e.x})),n=e.map((function(e){return e.y})),r=t.reduce((function(e,t){return t<e?t:e}),1/0),o=n.reduce((function(e,t){return t<e?t:e}),1/0),a=t.reduce((function(e,t){return e<t?t:e}),0),i=n.reduce((function(e,t){return e<t?t:e}),0);return new Xh(r,o,a,i)}(this.positions);return t.pad(t.width*e,t.height*e)},e.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class")},e}(),rp=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.getRefPointsForAlignment=function(){var e=this.positions;return[e[0],e[1],Wh([e[3],e[4]])]},t}(np),op=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.getJawOutline=function(){return this.positions.slice(0,17)},t.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22)},t.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27)},t.prototype.getNose=function(){return this.positions.slice(27,36)},t.prototype.getLeftEye=function(){return this.positions.slice(36,42)},t.prototype.getRightEye=function(){return this.positions.slice(42,48)},t.prototype.getMouth=function(){return this.positions.slice(48,68)},t.prototype.getRefPointsForAlignment=function(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(Wh)},t}(np),ap=function(){function e(e,t){this._label=e,this._distance=t}return Object.defineProperty(e.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"distance",{get:function(){return this._distance},enumerable:!0,configurable:!0}),e.prototype.toString=function(e){return void 0===e&&(e=!0),this.label+(e?" ("+function(e,t){void 0===t&&(t=2);var n=Math.pow(10,t);return Math.floor(e*n)/n}(this.distance)+")":"")},e}(),ip=function(e){function t(t,n){var r=e.call(this,t)||this;return r._label=n,r}return Ah(t,e),t.assertIsValidLabeledBox=function(e,t){if(qh.assertIsValidBox(e,t),!Hh(e.label))throw new Error(t+" - expected property label ("+e.label+") to be a number")},Object.defineProperty(t.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),t}(qh),sp=function(){function e(e,t){if("string"!=typeof e)throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(t)||t.some((function(e){return!(e instanceof Float32Array)})))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=e,this._descriptors=t}return Object.defineProperty(e.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"descriptors",{get:function(){return this._descriptors},enumerable:!0,configurable:!0}),e.prototype.toJSON=function(){return{label:this.label,descriptors:this.descriptors.map((function(e){return Array.from(e)}))}},e.fromJSON=function(t){var n=t.descriptors.map((function(e){return new Float32Array(e)}));return new e(t.label,n)},e}();!function(e){function t(t,n,r,o){var a=e.call(this,t,n)||this;return a._score=r,a._classScore=o,a}Ah(t,e),t.assertIsValidPredictedBox=function(e,t){if(ip.assertIsValidLabeledBox(e,t),!Uh(e.score)||!Uh(e.classScore))throw new Error(t+" - expected properties score ("+e.score+") and ("+e.classScore+") to be a number between [0, 1]")},Object.defineProperty(t.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0})}(ip);function up(e){return e.detection instanceof $h}function cp(e,t){var n={detection:t};return Object.assign({},e,n)}function lp(){var e=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment")};return{Canvas:HTMLCanvasElement,CanvasRenderingContext2D,Image:HTMLImageElement,ImageData,Video:HTMLVideoElement,createCanvasElement:function(){return document.createElement("canvas")},createImageElement:function(){return document.createElement("img")},fetch:e,readFile:function(){throw new Error("readFile - filesystem not available for browser environment")}}}function fp(e){var t="";if(!e)try{e=n(8730)}catch(r){t=r.toString()}return{readFile:e?function(t){return new Promise((function(n,r){e.readFile(t,(function(e,t){return e?r(e):n(t)}))}))}:function(){throw new Error("readFile - failed to require fs in nodejs environment with error: "+t)}}}function hp(){var e=n.g.Canvas||n.g.HTMLCanvasElement,t=n.g.Image||n.g.HTMLImageElement,r=n.g.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment")},o=fp();return Ph({Canvas:e||function(){},CanvasRenderingContext2D:n.g.CanvasRenderingContext2D||function(){},Image:t||function(){},ImageData:n.g.ImageData||function(){},Video:n.g.HTMLVideoElement||function(){},createCanvasElement:function(){if(e)return new e;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},createImageElement:function(){if(t)return new t;throw new Error("createImageElement - missing Image implementation for nodejs environment")},fetch:r},o)}function pp(){return"object"==typeof window&&"undefined"!=typeof document&&"undefined"!=typeof HTMLImageElement&&"undefined"!=typeof HTMLCanvasElement&&"undefined"!=typeof HTMLVideoElement&&"undefined"!=typeof ImageData&&"undefined"!=typeof CanvasRenderingContext2D}function dp(){return"object"==typeof n.g&&"undefined"!=typeof process&&!!process.version}function vp(e){ep=e}function mp(){pp()&&vp(lp()),dp()&&vp(hp())}var gp,yp={getEnv:function(){if(!ep)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return ep},setEnv:vp,initialize:mp,createBrowserEnv:lp,createFileSystem:fp,createNodejsEnv:hp,monkeyPatch:function(e){if(ep||mp(),!ep)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var t=e.Canvas,n=void 0===t?ep.Canvas:t,r=e.Image,o=void 0===r?ep.Image:r;ep.Canvas=n,ep.Image=o,ep.createCanvasElement=e.createCanvasElement||function(){return new n},ep.createImageElement=e.createImageElement||function(){return new o},ep.ImageData=e.ImageData||ep.ImageData,ep.Video=e.Video||ep.Video,ep.fetch=e.fetch||ep.fetch,ep.readFile=e.readFile||ep.readFile},isBrowser:pp,isNodejs:dp};function bp(e){return yp.isNodejs()||"string"!=typeof e?e:document.getElementById(e)}function wp(e){var t=yp.getEnv(),n=t.Canvas;if(e instanceof t.CanvasRenderingContext2D)return e;var r=bp(e);if(!(r instanceof n))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var o=r.getContext("2d");if(!o)throw new Error("resolveContext2d - canvas 2d context is null");return o}mp(),function(e){e.TOP_LEFT="TOP_LEFT",e.TOP_RIGHT="TOP_RIGHT",e.BOTTOM_LEFT="BOTTOM_LEFT",e.BOTTOM_RIGHT="BOTTOM_RIGHT"}(gp||(gp={}));var xp=function(e){void 0===e&&(e={});var t=e.anchorPosition,n=e.backgroundColor,r=e.fontColor,o=e.fontSize,a=e.fontStyle,i=e.padding;this.anchorPosition=t||gp.TOP_LEFT,this.backgroundColor=n||"rgba(0, 0, 0, 0.5)",this.fontColor=r||"rgba(255, 255, 255, 1)",this.fontSize=o||14,this.fontStyle=a||"Georgia",this.padding=i||4},Ep=function(){function e(t,n,r){void 0===r&&(r={}),this.text="string"==typeof t?[t]:t instanceof e?t.text:t,this.anchor=n,this.options=new xp(r)}return e.prototype.measureWidth=function(e){var t=this.options.padding;return this.text.map((function(t){return e.measureText(t).width})).reduce((function(e,t){return e<t?t:e}),0)+2*t},e.prototype.measureHeight=function(){var e=this.options,t=e.fontSize,n=e.padding;return this.text.length*t+2*n},e.prototype.getUpperLeft=function(e,t){var n=this.options.anchorPosition,r=n===gp.BOTTOM_RIGHT||n===gp.TOP_RIGHT,o=n===gp.BOTTOM_LEFT||n===gp.BOTTOM_RIGHT,a=this.measureWidth(e),i=this.measureHeight(),s=r?this.anchor.x-a:this.anchor.x,u=o?this.anchor.y-i:this.anchor.y;if(t){var c=t.width,l=t.height;return{x:Math.max(Math.min(s,c-a),0),y:Math.max(Math.min(u,l-i),0)}}return{x:s,y:u}},e.prototype.draw=function(e){var t=bp(e),n=wp(t),r=this.options,o=r.backgroundColor,a=r.fontColor,i=r.fontSize,s=r.fontStyle,u=r.padding;n.font=i+"px "+s;var c=this.measureWidth(n),l=this.measureHeight();n.fillStyle=o;var f=this.getUpperLeft(n,t);n.fillRect(f.x,f.y,c,l),n.fillStyle=a,this.text.forEach((function(e,t){var r=u+f.x,o=u+f.y+(t+1)*i;n.fillText(e,r,o)}))},e}(),_p=function(e){void 0===e&&(e={});var t=e.boxColor,n=e.lineWidth,r=e.label,o=e.drawLabelOptions;this.boxColor=t||"rgba(0, 0, 255, 1)",this.lineWidth=n||2,this.label=r;var a={anchorPosition:gp.BOTTOM_LEFT,backgroundColor:this.boxColor};this.drawLabelOptions=new xp(Object.assign({},a,o))},Op=function(){function e(e,t){void 0===t&&(t={}),this.box=new qh(e),this.options=new _p(t)}return e.prototype.draw=function(e){var t=wp(e),n=this.options,r=n.boxColor,o=n.lineWidth,a=this.box,i=a.x,s=a.y,u=a.width,c=a.height;t.strokeStyle=r,t.lineWidth=o,t.strokeRect(i,s,u,c);var l=this.options.label;l&&new Ep([l],{x:i-o/2,y:s},this.options.drawLabelOptions).draw(e)},e}();function kp(e){var t=yp.getEnv(),n=t.Image,r=t.Video;return e instanceof n&&e.complete||e instanceof r&&e.readyState>=3}function Cp(e){var t=yp.getEnv(),n=t.Image,r=t.Video;return e instanceof n?new Nh(e.naturalWidth,e.naturalHeight):e instanceof r?new Nh(e.videoWidth,e.videoHeight):new Nh(e.width,e.height)}function Ip(e){var t=e.width,n=e.height,r=(0,yp.getEnv().createCanvasElement)();return r.width=t,r.height=n,r}function Sp(e,t){var n=yp.getEnv().ImageData;if(!(e instanceof n||kp(e)))throw new Error("createCanvasFromMedia - media has not finished loading yet");var r=t||Cp(e),o=r.width,a=r.height,i=Ip({width:o,height:a});return e instanceof n?wp(i).putImageData(e,0,0):wp(i).drawImage(e,0,0,o,a),i}function Rp(e,t){return Th(this,void 0,void 0,(function(){var n,r,o,a,i,s;return Dh(this,(function(u){switch(u.label){case 0:return n=t||yp.getEnv().createCanvasElement(),r=e.shape.slice(jh(e)?1:0),o=r[0],a=r[1],i=r[2],s=_n((function(){return e.as3D(o,a,i).toInt()})),[4,ph.toPixels(s,n)];case 1:return u.sent(),s.dispose(),[2,n]}}))}))}function Ap(e){var t=yp.getEnv(),n=t.Image,r=t.Canvas,o=t.Video;return e instanceof n||e instanceof r||e instanceof o}var Pp=function(){function e(e,t){var n=this;if(void 0===t&&(t=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(e))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+e);this._treatAsBatchInput=t,this._batchSize=e.length,e.forEach((function(e,t){if(Bh(e))return n._imageTensors[t]=e,void(n._inputDimensions[t]=e.shape);if(jh(e)){var r=e.shape[0];if(1!==r)throw new Error("NetInput - tf.Tensor4D with batchSize "+r+" passed, but not supported in input array");return n._imageTensors[t]=e,void(n._inputDimensions[t]=e.shape.slice(1))}var o=e instanceof yp.getEnv().Canvas?e:Sp(e);n._canvases[t]=o,n._inputDimensions[t]=[o.height,o.width,3]}))}return Object.defineProperty(e.prototype,"imageTensors",{get:function(){return this._imageTensors},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canvases",{get:function(){return this._canvases},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBatchInput",{get:function(){return this.batchSize>1||this._treatAsBatchInput},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"batchSize",{get:function(){return this._batchSize},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputDimensions",{get:function(){return this._inputDimensions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reshapedInputDimensions",{get:function(){var e=this;return Vh(this.batchSize,0,1).map((function(t,n){return e.getReshapedInputDimensions(n)}))},enumerable:!0,configurable:!0}),e.prototype.getInput=function(e){return this.canvases[e]||this.imageTensors[e]},e.prototype.getInputDimensions=function(e){return this._inputDimensions[e]},e.prototype.getInputHeight=function(e){return this._inputDimensions[e][0]},e.prototype.getInputWidth=function(e){return this._inputDimensions[e][1]},e.prototype.getReshapedInputDimensions=function(e){if("number"!=typeof this.inputSize)throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");return function(e,t){var n=e.width,r=e.height,o=t/Math.max(r,n);return new Nh(Math.round(n*o),Math.round(r*o))}({width:this.getInputWidth(e),height:this.getInputHeight(e)},this.inputSize)},e.prototype.toBatchTensor=function(e,t){var n=this;return void 0===t&&(t=!0),this._inputSize=e,_n((function(){var r=Vh(n.batchSize,0,1).map((function(r){var o=n.getInput(r);if(o instanceof et){var a=jh(o)?o:o.expandDims();return a=function(e,t){return void 0===t&&(t=!1),_n((function(){var n=e.shape.slice(1),r=n[0],o=n[1];if(r===o)return e;var a=Math.abs(r-o),i=Math.round(a*(t?.5:1)),s=r>o?2:1,u=function(t){var n=e.shape.slice();return n[s]=t,Qn(n,0)},c=u(i),l=a-c.shape[s],f=[t&&l?u(l):null,e,c].filter((function(e){return!!e})).map((function(e){return e.toFloat()}));return rr(f,s)}))}(a,t),a.shape[1]===e&&a.shape[2]===e||(a=Ql.resizeBilinear(a,[e,e])),a.as3D(e,e,3)}if(o instanceof yp.getEnv().Canvas)return ph.fromPixels(function(e,t,n){void 0===n&&(n=!1);var r=yp.getEnv(),o=r.Image,a=r.Canvas;if(!(e instanceof o||e instanceof a))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");var i=Cp(e),s=t/Math.max(i.height,i.width),u=s*i.width,c=s*i.height,l=Ip({width:t,height:t}),f=e instanceof a?e:Sp(e),h=Math.abs(u-c)/2,p=n&&u<c?h:0,d=n&&c<u?h:0;return wp(l).drawImage(f,p,d,u,c),l}(o,e,t));throw new Error("toBatchTensor - at batchIdx "+r+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+o)})),o=Ur(r.map((function(e){return e.toFloat()}))).as4D(n.batchSize,e,e,3);return o}))},e}();function Tp(e){return Th(this,void 0,void 0,(function(){var t,n,r;return Dh(this,(function(o){switch(o.label){case 0:if(e instanceof Pp)return[2,e];if(!(t=Array.isArray(e)?e:[e]).length)throw new Error("toNetInput - empty array passed as input");return n=function(t){return Array.isArray(e)?" at input index "+t+":":""},(r=t.map(bp)).forEach((function(e,r){if(!Ap(e)&&!Bh(e)&&!jh(e)){if("string"==typeof t[r])throw new Error("toNetInput -"+n(r)+" string passed, but could not resolve HTMLElement for element id "+t[r]);throw new Error("toNetInput -"+n(r)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id")}if(jh(e)){var o=e.shape[0];if(1!==o)throw new Error("toNetInput -"+n(r)+" tf.Tensor4D with batchSize "+o+" passed, but not supported in input array")}})),[4,Promise.all(r.map((function(e){return Ap(e)&&(t=e,new Promise((function(e,n){if(t instanceof yp.getEnv().Canvas||kp(t))return e();function r(t){t.currentTarget&&(t.currentTarget.removeEventListener("load",r),t.currentTarget.removeEventListener("error",o),e(t))}function o(e){e.currentTarget&&(e.currentTarget.removeEventListener("load",r),e.currentTarget.removeEventListener("error",o),n(e))}t.addEventListener("load",r),t.addEventListener("error",o)})));var t})))];case 1:return o.sent(),[2,new Pp(r,Array.isArray(e))]}}))}))}function Dp(e,t){return Th(this,void 0,void 0,(function(){var n,r,o,a,i,s;return Dh(this,(function(u){switch(u.label){case 0:return n=yp.getEnv().Canvas,r=e,e instanceof n?[3,5]:[4,Tp(e)];case 1:if((o=u.sent()).batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return(a=o.getInput(0))instanceof n?(i=a,[3,4]):[3,2];case 2:return[4,Rp(a)];case 3:i=u.sent(),u.label=4;case 4:r=i,u.label=5;case 5:return s=wp(r),[2,t.map((function(e){return e instanceof $h?e.forSize(r.width,r.height).box.floor():e})).map((function(e){return e.clipAtImageBorders(r.width,r.height)})).map((function(e){var t=e.x,n=e.y,r=e.width,o=e.height,a=Ip({width:r,height:o});return wp(a).putImageData(s.getImageData(t,n,r,o),0,0),a}))]}}))}))}function Mp(e,t){return Th(this,void 0,void 0,(function(){return Dh(this,(function(n){if(!Bh(e)&&!jh(e))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(jh(e)&&e.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return[2,_n((function(){var n=e.shape.slice(jh(e)?1:0),r=n[0],o=n[1],a=n[2],i=t.map((function(e){return e instanceof $h?e.forSize(o,r).box:e})).map((function(e){return e.clipAtImageBorders(o,r)})).map((function(t){var n=t.x,i=t.y,s=t.width,u=t.height;return Vc(e.as3D(r,o,a),[i,n,0],[u,s,a])}));return i}))]}))}))}function Np(e,t){return Th(this,void 0,void 0,(function(){var n;return Dh(this,(function(r){switch(r.label){case 0:return[4,(0,yp.getEnv().fetch)(e,t)];case 1:if(!((n=r.sent()).status<400))throw new Error("failed to fetch: ("+n.status+") "+n.statusText+", from url: "+n.url);return[2,n]}}))}))}function Fp(e){return Th(this,void 0,void 0,(function(){return Dh(this,(function(t){switch(t.label){case 0:return[4,Np(e)];case 1:return[2,t.sent().json()]}}))}))}function Bp(e,t){var n=t+"-weights_manifest.json";if(!e)return{modelBaseUri:"",manifestUri:n};if("/"===e)return{modelBaseUri:"/",manifestUri:"/"+n};var r=e.startsWith("http://")?"http://":e.startsWith("https://")?"https://":"",o=(e=e.replace(r,"")).split("/").filter((function(e){return e})),a=e.endsWith(".json")?o[o.length-1]:n,i=r+(e.endsWith(".json")?o.slice(0,o.length-1):o).join("/");return{modelBaseUri:i=e.startsWith("/")?"/"+i:i,manifestUri:"/"===i?"/"+a:i+"/"+a}}function jp(e,t){return Th(this,void 0,void 0,(function(){var n,r,o,a;return Dh(this,(function(i){switch(i.label){case 0:return n=Bp(e,t),r=n.manifestUri,o=n.modelBaseUri,[4,Fp(r)];case 1:return a=i.sent(),[2,lh.loadWeights(a,o)]}}))}))}var Lp=function(){function e(e){this._name=e,this._params=void 0,this._paramMappings=[]}return Object.defineProperty(e.prototype,"params",{get:function(){return this._params},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"paramMappings",{get:function(){return this._paramMappings},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLoaded",{get:function(){return!!this.params},enumerable:!0,configurable:!0}),e.prototype.getParamFromPath=function(e){var t=this.traversePropertyPath(e);return t.obj[t.objProp]},e.prototype.reassignParamFromPath=function(e,t){var n=this.traversePropertyPath(e),r=n.obj,o=n.objProp;r[o].dispose(),r[o]=t},e.prototype.getParamList=function(){var e=this;return this._paramMappings.map((function(t){var n=t.paramPath;return{path:n,tensor:e.getParamFromPath(n)}}))},e.prototype.getTrainableParams=function(){return this.getParamList().filter((function(e){return e.tensor instanceof it}))},e.prototype.getFrozenParams=function(){return this.getParamList().filter((function(e){return!(e.tensor instanceof it)}))},e.prototype.variable=function(){var e=this;this.getFrozenParams().forEach((function(t){var n=t.path,r=t.tensor;e.reassignParamFromPath(n,r.variable())}))},e.prototype.freeze=function(){var e=this;this.getTrainableParams().forEach((function(t){var n=t.path,r=t.tensor,o=Un(r.dataSync());r.dispose(),e.reassignParamFromPath(n,o)}))},e.prototype.dispose=function(e){void 0===e&&(e=!0),this.getParamList().forEach((function(t){if(e&&t.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+t.path);t.tensor.dispose()})),this._params=void 0},e.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map((function(e){var t=e.tensor;return Array.from(t.dataSync())})).reduce((function(e,t){return e.concat(t)})))},e.prototype.load=function(e){return Th(this,void 0,void 0,(function(){return Dh(this,(function(t){switch(t.label){case 0:return e instanceof Float32Array?(this.extractWeights(e),[2]):[4,this.loadFromUri(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.loadFromUri=function(e){return Th(this,void 0,void 0,(function(){var t;return Dh(this,(function(n){switch(n.label){case 0:if(e&&"string"!=typeof e)throw new Error(this._name+".loadFromUri - expected model uri");return[4,jp(e,this.getDefaultModelName())];case 1:return t=n.sent(),this.loadFromWeightMap(t),[2]}}))}))},e.prototype.loadFromDisk=function(e){return Th(this,void 0,void 0,(function(){var t,n,r,o,a,i,s,u,c,l;return Dh(this,(function(f){switch(f.label){case 0:if(e&&"string"!=typeof e)throw new Error(this._name+".loadFromDisk - expected model file path");return t=yp.getEnv().readFile,n=Bp(e,this.getDefaultModelName()),r=n.manifestUri,o=n.modelBaseUri,a=function(e){return Promise.all(e.map((function(e){return t(e).then((function(e){return e.buffer}))})))},i=lh.weightsLoaderFactory(a),c=(u=JSON).parse,[4,t(r)];case 1:return s=c.apply(u,[f.sent().toString()]),[4,i(s,o)];case 2:return l=f.sent(),this.loadFromWeightMap(l),[2]}}))}))},e.prototype.loadFromWeightMap=function(e){var t=this.extractParamsFromWeigthMap(e),n=t.paramMappings,r=t.params;this._paramMappings=n,this._params=r},e.prototype.extractWeights=function(e){var t=this.extractParams(e),n=t.paramMappings,r=t.params;this._paramMappings=n,this._params=r},e.prototype.traversePropertyPath=function(e){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var t=e.split("/").reduce((function(t,n){if(!t.nextObj.hasOwnProperty(n))throw new Error("traversePropertyPath - object does not have property "+n+", for path "+e);return{obj:t.nextObj,objProp:n,nextObj:t.nextObj[n]}}),{nextObj:this.params}),n=t.obj,r=t.objProp;if(!(n&&r&&n[r]instanceof et))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+e);return{obj:n,objProp:r}},e}();function zp(e,t,n){return _n((function(){var r=xc(e,t.depthwise_filter,t.pointwise_filter,n,"same");return r=Cu(r,t.bias)}))}function Wp(e,t,n){return void 0===n&&(n=!1),_n((function(){var r=al(n?Cu(dc(e,t.conv0.filters,[2,2],"same"),t.conv0.bias):zp(e,t.conv0,[2,2])),o=zp(r,t.conv1,[1,1]),a=zp(al(Cu(r,o)),t.conv2,[1,1]);return al(Cu(r,Cu(o,a)))}))}function Vp(e,t,n,r){return void 0===n&&(n=!1),void 0===r&&(r=!0),_n((function(){var o=al(n?Cu(dc(e,t.conv0.filters,r?[2,2]:[1,1],"same"),t.conv0.bias):zp(e,t.conv0,r?[2,2]:[1,1])),a=zp(o,t.conv1,[1,1]),i=zp(al(Cu(o,a)),t.conv2,[1,1]),s=zp(al(Cu(o,Cu(a,i))),t.conv3,[1,1]);return al(Cu(o,Cu(a,Cu(i,s))))}))}function Hp(e,t,n,r){return void 0===n&&(n="same"),void 0===r&&(r=!1),_n((function(){var o=Cu(dc(e,t.filters,[1,1],n),t.bias);return r?al(o):o}))}function Up(e,t){Object.keys(e).forEach((function(n){t.some((function(e){return e.originalPath===n}))||e[n].dispose()}))}function Gp(e,t){return function(n,r,o,a){var i=Zn(e(n*r*o*o),[o,o,n,r]),s=Xn(e(r));return t.push({paramPath:a+"/filters"},{paramPath:a+"/bias"}),{filters:i,bias:s}}}function qp(e,t){return function(n,r,o){var a=Kn(e(n*r),[n,r]),i=Xn(e(r));return t.push({paramPath:o+"/weights"},{paramPath:o+"/bias"}),{weights:a,bias:i}}}var Xp=function(e,t,n){this.depthwise_filter=e,this.pointwise_filter=t,this.bias=n};function Kp(e,t){return function(n,r,o){var a=Zn(e(9*n),[3,3,n,1]),i=Zn(e(n*r),[1,1,n,r]),s=Xn(e(r));return t.push({paramPath:o+"/depthwise_filter"},{paramPath:o+"/pointwise_filter"},{paramPath:o+"/bias"}),new Xp(a,i,s)}}function $p(e){return function(t){var n=e(t+"/depthwise_filter",4),r=e(t+"/pointwise_filter",4),o=e(t+"/bias",1);return new Xp(n,r,o)}}function Zp(e,t){return function(n,r,o){var a=e[n];if(!Fh(a,r))throw new Error("expected weightMap["+n+"] to be a Tensor"+r+"D, instead have "+a);return t.push({originalPath:n,paramPath:o||n}),a}}function Yp(e){var t=e;return{extractWeights:function(e){var n=t.slice(0,e);return t=t.slice(e),n},getRemainingWeights:function(){return t}}}function Jp(e,t){var n=Gp(e,t),r=Kp(e,t);function o(e,t,o,a){return void 0===a&&(a=!1),{conv0:a?n(e,t,3,o+"/conv0"):r(e,t,o+"/conv0"),conv1:r(t,t,o+"/conv1"),conv2:r(t,t,o+"/conv2")}}return{extractDenseBlock3Params:o,extractDenseBlock4Params:function(e,t,n,a){void 0===a&&(a=!1);var i=o(e,t,n,a);return{conv0:i.conv0,conv1:i.conv1,conv2:i.conv2,conv3:r(t,t,n+"/conv3")}}}}function Qp(e){return function(t){return{filters:e(t+"/filters",4),bias:e(t+"/bias",1)}}}function ed(e,t){var n=Zp(e,t),r=Qp(n),o=$p(n);return{extractDenseBlock3Params:function(e,t){return void 0===t&&(t=!1),{conv0:t?r(e+"/conv0"):o(e+"/conv0"),conv1:o(e+"/conv1"),conv2:o(e+"/conv2")}},extractDenseBlock4Params:function(e,t){return void 0===t&&(t=!1),{conv0:t?r(e+"/conv0"):o(e+"/conv0"),conv1:o(e+"/conv1"),conv2:o(e+"/conv2"),conv3:o(e+"/conv3")}}}}var td=function(e){function t(){return e.call(this,"FaceFeatureExtractor")||this}return Ah(t,e),t.prototype.forwardInput=function(e){var t=this.params;if(!t)throw new Error("FaceFeatureExtractor - load model before inference");return _n((function(){var n=Vp(Jh(e.toBatchTensor(112,!0),[122.782,117.001,104.298]).div(qn(255)),t.dense0,!0);return n=Vp(n,t.dense1),n=Vp(n,t.dense2),n=Vp(n,t.dense3),n=Nc(n,[7,7],[2,2],"valid")}))},t.prototype.forward=function(e){return Th(this,void 0,void 0,(function(){var t;return Dh(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,Tp(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.getDefaultModelName=function(){return"face_feature_extractor_model"},t.prototype.extractParamsFromWeigthMap=function(e){return function(e){var t=[],n=ed(e,t).extractDenseBlock4Params,r={dense0:n("dense0",!0),dense1:n("dense1"),dense2:n("dense2"),dense3:n("dense3")};return Up(e,t),{params:r,paramMappings:t}}(e)},t.prototype.extractParams=function(e){return function(e){var t=[],n=Yp(e),r=n.extractWeights,o=n.getRemainingWeights,a=Jp(r,t).extractDenseBlock4Params,i=a(3,32,"dense0",!0),s=a(32,64,"dense1"),u=a(64,128,"dense2"),c=a(128,256,"dense3");if(0!==o().length)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{dense0:i,dense1:s,dense2:u,dense3:c}}}(e)},t}(Lp);function nd(e,t){return _n((function(){return Cu(Oc(e,t.weights),t.bias)}))}function rd(e){var t={},n={};return Object.keys(e).forEach((function(r){(r.startsWith("fc")?n:t)[r]=e[r]})),{featureExtractorMap:t,classifierMap:n}}var od=function(e){function t(t,n){var r=e.call(this,t)||this;return r._faceFeatureExtractor=n,r}return Ah(t,e),Object.defineProperty(t.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),t.prototype.runNet=function(e){var t=this,n=this.params;if(!n)throw new Error(this._name+" - load model before inference");return _n((function(){var r=e instanceof Pp?t.faceFeatureExtractor.forwardInput(e):e;return nd(r.as2D(r.shape[0],-1),n.fc)}))},t.prototype.dispose=function(t){void 0===t&&(t=!0),this.faceFeatureExtractor.dispose(t),e.prototype.dispose.call(this,t)},t.prototype.loadClassifierParams=function(e){var t=this.extractClassifierParams(e),n=t.params,r=t.paramMappings;this._params=n,this._paramMappings=r},t.prototype.extractClassifierParams=function(e){return function(e,t,n){var r=[],o=Yp(e),a=o.extractWeights,i=o.getRemainingWeights,s=qp(a,r)(t,n,"fc");if(0!==i().length)throw new Error("weights remaing after extract: "+i().length);return{paramMappings:r,params:{fc:s}}}(e,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},t.prototype.extractParamsFromWeigthMap=function(e){var t=rd(e),n=t.featureExtractorMap,r=t.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(n),function(e){var t,n=[],r=Zp(e,n),o={fc:(t="fc",{weights:r(t+"/weights",2),bias:r(t+"/bias",1)})};return Up(e,n),{params:o,paramMappings:n}}(r)},t.prototype.extractParams=function(e){var t=this.getClassifierChannelsIn(),n=this.getClassifierChannelsOut(),r=n*t+n,o=e.slice(0,e.length-r),a=e.slice(e.length-r);return this.faceFeatureExtractor.extractWeights(o),this.extractClassifierParams(a)},t}(Lp),ad=["neutral","happy","sad","angry","fearful","disgusted","surprised"],id=function(){function e(e){var t=this;if(7!==e.length)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+e.length);ad.forEach((function(n,r){t[n]=e[r]}))}return e.prototype.asSortedArray=function(){var e=this;return ad.map((function(t){return{expression:t,probability:e[t]}})).sort((function(e,t){return t.probability-e.probability}))},e}(),sd=function(e){function t(t){return void 0===t&&(t=new td),e.call(this,"FaceExpressionNet",t)||this}return Ah(t,e),t.prototype.forwardInput=function(e){var t=this;return _n((function(){return lo(t.runNet(e))}))},t.prototype.forward=function(e){return Th(this,void 0,void 0,(function(){var t;return Dh(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,Tp(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.predictExpressions=function(e){return Th(this,void 0,void 0,(function(){var t,n,r,o,a=this;return Dh(this,(function(i){switch(i.label){case 0:return[4,Tp(e)];case 1:return t=i.sent(),[4,this.forwardInput(t)];case 2:return n=i.sent(),[4,Promise.all(Xr(n).map((function(e){return Th(a,void 0,void 0,(function(){var t;return Dh(this,(function(n){switch(n.label){case 0:return[4,e.data()];case 1:return t=n.sent(),e.dispose(),[2,t]}}))}))})))];case 3:return r=i.sent(),n.dispose(),o=r.map((function(e){return new id(e)})),[2,t.isBatchInput?o:o[0]]}}))}))},t.prototype.getDefaultModelName=function(){return"face_expression_model"},t.prototype.getClassifierChannelsIn=function(){return 256},t.prototype.getClassifierChannelsOut=function(){return 7},t}(od);function ud(e,t){var n={expressions:t};return Object.assign({},e,n)}function cd(e){return up(e)&&e.landmarks instanceof np&&e.unshiftedLandmarks instanceof np&&e.alignedRect instanceof $h}function ld(e,t){var n=e.detection.box,r=t.shiftBy(n.x,n.y),o=r.align(),a=e.detection.imageDims,i={landmarks:r,unshiftedLandmarks:t,alignedRect:new $h(e.detection.score,o.rescale(a.reverse()),a)};return Object.assign({},e,i)}function fd(e,t,n){if(void 0===n&&(n=!1),e.beginPath(),t.slice(1).forEach((function(n,r){var o=n.x,a=n.y,i=t[r];e.moveTo(i.x,i.y),e.lineTo(o,a)})),n){var r=t[t.length-1],o=t[0];if(!r||!o)return;e.moveTo(r.x,r.y),e.lineTo(o.x,o.y)}e.stroke()}var hd=function(e){void 0===e&&(e={});var t=e.drawLines,n=void 0===t||t,r=e.drawPoints,o=void 0===r||r,a=e.lineWidth,i=e.lineColor,s=e.pointSize,u=e.pointColor;this.drawLines=n,this.drawPoints=o,this.lineWidth=a||1,this.pointSize=s||2,this.lineColor=i||"rgba(0, 255, 255, 1)",this.pointColor=u||"rgba(255, 0, 255, 1)"};!function(){function e(e,t){void 0===t&&(t={}),this.faceLandmarks=e,this.options=new hd(t)}e.prototype.draw=function(e){var t=wp(e),n=this.options,r=n.drawLines,o=n.drawPoints,a=n.lineWidth,i=n.lineColor,s=n.pointSize,u=n.pointColor;if(r&&this.faceLandmarks instanceof op&&(t.strokeStyle=i,t.lineWidth=a,fd(t,this.faceLandmarks.getJawOutline()),fd(t,this.faceLandmarks.getLeftEyeBrow()),fd(t,this.faceLandmarks.getRightEyeBrow()),fd(t,this.faceLandmarks.getNose()),fd(t,this.faceLandmarks.getLeftEye(),!0),fd(t,this.faceLandmarks.getRightEye(),!0),fd(t,this.faceLandmarks.getMouth(),!0)),o){t.strokeStyle=u,t.fillStyle=u;this.faceLandmarks.positions.forEach((function(e){t.beginPath(),t.arc(e.x,e.y,s,0,2*Math.PI),t.fill()}))}}}();function pd(e,t){var n=[],r=Yp(e),o=r.extractWeights,a=r.getRemainingWeights,i=function(e,t){var n=Gp(e,t),r=Kp(e,t);return{extractConvParams:n,extractSeparableConvParams:r,extractReductionBlockParams:function(e,t,o){return{separable_conv0:r(e,t,o+"/separable_conv0"),separable_conv1:r(t,t,o+"/separable_conv1"),expansion_conv:n(e,t,1,o+"/expansion_conv")}},extractMainBlockParams:function(e,t){return{separable_conv0:r(e,e,t+"/separable_conv0"),separable_conv1:r(e,e,t+"/separable_conv1"),separable_conv2:r(e,e,t+"/separable_conv2")}}}}(o,n),s=i.extractConvParams,u=i.extractSeparableConvParams,c=i.extractReductionBlockParams,l=i.extractMainBlockParams,f={conv_in:s(3,32,3,"entry_flow/conv_in"),reduction_block_0:c(32,64,"entry_flow/reduction_block_0"),reduction_block_1:c(64,128,"entry_flow/reduction_block_1")},h={};Vh(t,0,1).forEach((function(e){h["main_block_"+e]=l(128,"middle_flow/main_block_"+e)}));var p={reduction_block:c(128,256,"exit_flow/reduction_block"),separable_conv:u(256,512,"exit_flow/separable_conv")};if(0!==a().length)throw new Error("weights remaing after extract: "+a().length);return{paramMappings:n,params:{entry_flow:f,middle_flow:h,exit_flow:p}}}function dd(e,t){var n=[],r=function(e,t){var n=Zp(e,t),r=Qp(n),o=$p(n);return{extractConvParams:r,extractSeparableConvParams:o,extractReductionBlockParams:function(e){return{separable_conv0:o(e+"/separable_conv0"),separable_conv1:o(e+"/separable_conv1"),expansion_conv:r(e+"/expansion_conv")}},extractMainBlockParams:function(e){return{separable_conv0:o(e+"/separable_conv0"),separable_conv1:o(e+"/separable_conv1"),separable_conv2:o(e+"/separable_conv2")}}}}(e,n),o=r.extractConvParams,a=r.extractSeparableConvParams,i=r.extractReductionBlockParams,s=r.extractMainBlockParams,u={conv_in:o("entry_flow/conv_in"),reduction_block_0:i("entry_flow/reduction_block_0"),reduction_block_1:i("entry_flow/reduction_block_1")},c={};Vh(t,0,1).forEach((function(e){c["main_block_"+e]=s("middle_flow/main_block_"+e)}));var l={reduction_block:i("exit_flow/reduction_block"),separable_conv:a("exit_flow/separable_conv")};return Up(e,n),{params:{entry_flow:u,middle_flow:c,exit_flow:l},paramMappings:n}}function vd(e,t,n){return Cu(dc(e,t.filters,n,"same"),t.bias)}function md(e,t,n){void 0===n&&(n=!0);var r=n?al(e):e;return r=zp(r,t.separable_conv0,[1,1]),r=zp(al(r),t.separable_conv1,[1,1]),r=Mc(r,[3,3],[2,2],"same"),r=Cu(r,vd(e,t.expansion_conv,[2,2]))}var gd,yd=function(e){function t(t){var n=e.call(this,"TinyXception")||this;return n._numMainBlocks=t,n}return Ah(t,e),t.prototype.forwardInput=function(e){var t=this,n=this.params;if(!n)throw new Error("TinyXception - load model before inference");return _n((function(){var r=Jh(e.toBatchTensor(112,!0),[122.782,117.001,104.298]).div(qn(256)),o=al(vd(r,n.entry_flow.conv_in,[2,2]));return o=md(o,n.entry_flow.reduction_block_0,!1),o=md(o,n.entry_flow.reduction_block_1),Vh(t._numMainBlocks,0,1).forEach((function(e){o=function(e,t){var n=zp(al(e),t.separable_conv0,[1,1]);return n=zp(al(n),t.separable_conv1,[1,1]),n=zp(al(n),t.separable_conv2,[1,1]),Cu(n,e)}(o,n.middle_flow["main_block_"+e])})),o=md(o,n.exit_flow.reduction_block),o=al(zp(o,n.exit_flow.separable_conv,[1,1]))}))},t.prototype.forward=function(e){return Th(this,void 0,void 0,(function(){var t;return Dh(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,Tp(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.getDefaultModelName=function(){return"tiny_xception_model"},t.prototype.extractParamsFromWeigthMap=function(e){return dd(e,this._numMainBlocks)},t.prototype.extractParams=function(e){return pd(e,this._numMainBlocks)},t}(Lp);!function(e){e.FEMALE="female",e.MALE="male"}(gd||(gd={}));var bd=function(e){function t(t){void 0===t&&(t=new yd(2));var n=e.call(this,"AgeGenderNet")||this;return n._faceFeatureExtractor=t,n}return Ah(t,e),Object.defineProperty(t.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),t.prototype.runNet=function(e){var t=this,n=this.params;if(!n)throw new Error(this._name+" - load model before inference");return _n((function(){var r=e instanceof Pp?t.faceFeatureExtractor.forwardInput(e):e,o=Nc(r,[7,7],[2,2],"valid").as2D(r.shape[0],-1);return{age:nd(o,n.fc.age).as1D(),gender:nd(o,n.fc.gender)}}))},t.prototype.forwardInput=function(e){var t=this;return _n((function(){var n=t.runNet(e),r=n.age,o=n.gender;return{age:r,gender:lo(o)}}))},t.prototype.forward=function(e){return Th(this,void 0,void 0,(function(){var t;return Dh(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,Tp(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.predictAgeAndGender=function(e){return Th(this,void 0,void 0,(function(){var t,n,r,o,a,i,s=this;return Dh(this,(function(u){switch(u.label){case 0:return[4,Tp(e)];case 1:return t=u.sent(),[4,this.forwardInput(t)];case 2:return n=u.sent(),r=Xr(n.age),o=Xr(n.gender),a=r.map((function(e,t){return{ageTensor:e,genderTensor:o[t]}})),[4,Promise.all(a.map((function(e){var t=e.ageTensor,n=e.genderTensor;return Th(s,void 0,void 0,(function(){var e,r,o,a,i;return Dh(this,(function(s){switch(s.label){case 0:return[4,t.data()];case 1:return e=s.sent()[0],[4,n.data()];case 2:return r=s.sent()[0],a=(o=r>.5)?gd.MALE:gd.FEMALE,i=o?r:1-r,t.dispose(),n.dispose(),[2,{age:e,gender:a,genderProbability:i}]}}))}))})))];case 3:return i=u.sent(),n.age.dispose(),n.gender.dispose(),[2,t.isBatchInput?i:i[0]]}}))}))},t.prototype.getDefaultModelName=function(){return"age_gender_model"},t.prototype.dispose=function(t){void 0===t&&(t=!0),this.faceFeatureExtractor.dispose(t),e.prototype.dispose.call(this,t)},t.prototype.loadClassifierParams=function(e){var t=this.extractClassifierParams(e),n=t.params,r=t.paramMappings;this._params=n,this._paramMappings=r},t.prototype.extractClassifierParams=function(e){return function(e){var t=[],n=Yp(e),r=n.extractWeights,o=n.getRemainingWeights,a=qp(r,t),i=a(512,1,"fc/age"),s=a(512,2,"fc/gender");if(0!==o().length)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{fc:{age:i,gender:s}}}}(e)},t.prototype.extractParamsFromWeigthMap=function(e){var t=rd(e),n=t.featureExtractorMap,r=t.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(n),function(e){var t=[],n=Zp(e,t);function r(e){return{weights:n(e+"/weights",2),bias:n(e+"/bias",1)}}var o={fc:{age:r("fc/age"),gender:r("fc/gender")}};return Up(e,t),{params:o,paramMappings:t}}(r)},t.prototype.extractParams=function(e){var t=e.slice(0,e.length-1539),n=e.slice(e.length-1539);return this.faceFeatureExtractor.extractWeights(t),this.extractClassifierParams(n)},t}(Lp),wd=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.postProcess=function(e,t,n){var r=n.map((function(e){var n=e.width,r=e.height,o=t/Math.max(r,n);return{width:n*o,height:r*o}})),o=r.length;return _n((function(){var n=function(e,t){return Ur([Qn([68],e),Qn([68],t)],1).as2D(1,136).as1D()},a=function(e,t){var n=r[e],o=n.width,a=n.height;return t(o,a)?Math.abs(o-a)/2:0},i=e.mul(Qn([o,136],t)).sub(Ur(Array.from(Array(o),(function(e,t){return n(function(e){return a(e,(function(e,t){return e<t}))}(t),function(e){return a(e,(function(e,t){return t<e}))}(t))})))).div(Ur(Array.from(Array(o),(function(e,t){return n(r[t].width,r[t].height)}))));return i}))},t.prototype.forwardInput=function(e){var t=this;return _n((function(){var n=t.runNet(e);return t.postProcess(n,e.inputSize,e.inputDimensions.map((function(e){return{height:e[0],width:e[1]}})))}))},t.prototype.forward=function(e){return Th(this,void 0,void 0,(function(){var t;return Dh(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,Tp(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.detectLandmarks=function(e){return Th(this,void 0,void 0,(function(){var t,n,r,o=this;return Dh(this,(function(a){switch(a.label){case 0:return[4,Tp(e)];case 1:return t=a.sent(),n=_n((function(){return Xr(o.forwardInput(t))})),[4,Promise.all(n.map((function(e,n){return Th(o,void 0,void 0,(function(){var r,o,a,i,s;return Dh(this,(function(u){switch(u.label){case 0:return a=(o=Array).from,[4,e.data()];case 1:return r=a.apply(o,[u.sent()]),i=r.filter((function(e,t){return Lh(t)})),s=r.filter((function(e,t){return!Lh(t)})),[2,new op(Array(68).fill(0).map((function(e,t){return new Gh(i[t],s[t])})),{height:t.getInputHeight(n),width:t.getInputWidth(n)})]}}))}))})))];case 2:return r=a.sent(),n.forEach((function(e){return e.dispose()})),[2,t.isBatchInput?r:r[0]]}}))}))},t.prototype.getClassifierChannelsOut=function(){return 136},t}(od),xd=function(e){function t(t){return void 0===t&&(t=new td),e.call(this,"FaceLandmark68Net",t)||this}return Ah(t,e),t.prototype.getDefaultModelName=function(){return"face_landmark_68_model"},t.prototype.getClassifierChannelsIn=function(){return 256},t}(wd);var Ed=function(e){function t(){return e.call(this,"TinyFaceFeatureExtractor")||this}return Ah(t,e),t.prototype.forwardInput=function(e){var t=this.params;if(!t)throw new Error("TinyFaceFeatureExtractor - load model before inference");return _n((function(){var n=Wp(Jh(e.toBatchTensor(112,!0),[122.782,117.001,104.298]).div(qn(255)),t.dense0,!0);return n=Wp(n,t.dense1),n=Wp(n,t.dense2),n=Nc(n,[14,14],[2,2],"valid")}))},t.prototype.forward=function(e){return Th(this,void 0,void 0,(function(){var t;return Dh(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,Tp(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.getDefaultModelName=function(){return"face_feature_extractor_tiny_model"},t.prototype.extractParamsFromWeigthMap=function(e){return function(e){var t=[],n=ed(e,t).extractDenseBlock3Params,r={dense0:n("dense0",!0),dense1:n("dense1"),dense2:n("dense2")};return Up(e,t),{params:r,paramMappings:t}}(e)},t.prototype.extractParams=function(e){return function(e){var t=[],n=Yp(e),r=n.extractWeights,o=n.getRemainingWeights,a=Jp(r,t).extractDenseBlock3Params,i=a(3,32,"dense0",!0),s=a(32,64,"dense1"),u=a(64,128,"dense2");if(0!==o().length)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{dense0:i,dense1:s,dense2:u}}}(e)},t}(Lp),_d=function(e){function t(t){return void 0===t&&(t=new Ed),e.call(this,"FaceLandmark68TinyNet",t)||this}return Ah(t,e),t.prototype.getDefaultModelName=function(){return"face_landmark_68_tiny_model"},t.prototype.getClassifierChannelsIn=function(){return 128},t}(wd);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}Ah(t,e)}(xd);function Od(e,t,n,r,o){void 0===o&&(o="same");var a=t.conv,i=a.filters,s=a.bias,u=dc(e,i,n,o);return u=function(e,t){return Cu(zu(e,t.weights),t.biases)}(u=Cu(u,s),t.scale),r?al(u):u}function kd(e,t){return Od(e,t,[1,1],!1)}function Cd(e,t){return Od(e,t,[2,2],!0,"valid")}function Id(e,t){function n(n,r,o,a){var i=function(t,n,r){var o=e(t),a=o.length/(n*r*r);if(a%1!=0)throw new Error("depth has to be an integer: "+a+", weights.length: "+o.length+", numFilters: "+n+", filterSize: "+r);return _n((function(){return ul(Zn(o,[n,a,r,r]),[2,3,1,0])}))}(n,r,o),s=Xn(e(r));return t.push({paramPath:a+"/filters"},{paramPath:a+"/bias"}),{filters:i,bias:s}}function r(r,o,a,i){var s=n(r,o,a,i+"/conv"),u=function(n,r){var o=Xn(e(n)),a=Xn(e(n));return t.push({paramPath:r+"/weights"},{paramPath:r+"/biases"}),{weights:o,biases:a}}(o,i+"/scale");return{conv:s,scale:u}}return{extractConvLayerParams:r,extractResidualLayerParams:function(e,t,n,o,a){return void 0===a&&(a=!1),{conv1:r((a?.5:1)*e,t,n,o+"/conv1"),conv2:r(e,t,n,o+"/conv2")}}}}function Sd(e,t){var n=Zp(e,t);function r(e){var t=n(e+"/conv/filters",4),r=n(e+"/conv/bias",1),o=function(e){return{weights:n(e+"/scale/weights",1),biases:n(e+"/scale/biases",1)}}(e);return{conv:{filters:t,bias:r},scale:o}}return{extractConvLayerParams:r,extractResidualLayerParams:function(e){return{conv1:r(e+"/conv1"),conv2:r(e+"/conv2")}}}}function Rd(e){var t=[],n=Sd(e,t),r=n.extractConvLayerParams,o=n.extractResidualLayerParams,a=r("conv32_down"),i=o("conv32_1"),s=o("conv32_2"),u=o("conv32_3"),c=o("conv64_down"),l=o("conv64_1"),f=o("conv64_2"),h=o("conv64_3"),p=o("conv128_down"),d=o("conv128_1"),v=o("conv128_2"),m=o("conv256_down"),g=o("conv256_1"),y=o("conv256_2"),b=o("conv256_down_out"),w=e.fc;if(t.push({originalPath:"fc",paramPath:"fc"}),!Fh(w,2))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+w);var x={conv32_down:a,conv32_1:i,conv32_2:s,conv32_3:u,conv64_down:c,conv64_1:l,conv64_2:f,conv64_3:h,conv128_down:p,conv128_1:d,conv128_2:v,conv256_down:m,conv256_1:g,conv256_2:y,conv256_down_out:b,fc:w};return Up(e,t),{params:x,paramMappings:t}}function Ad(e,t){var n=function(e,t){return Od(e,t,[1,1],!0)}(e,t.conv1);return n=kd(n,t.conv2),n=Cu(n,e),n=al(n)}function Pd(e,t){var n=Cd(e,t.conv1);n=kd(n,t.conv2);var r=Nc(e,2,2,"valid"),o=Jn(r.shape),a=r.shape[3]!==n.shape[3];if(r.shape[1]!==n.shape[1]||r.shape[2]!==n.shape[2]){var i=Mh(n.shape);i[1]=1;var s=Jn(i),u=Mh((n=rr([n,s],1)).shape);u[2]=1;var c=Jn(u);n=rr([n,c],2)}return r=a?rr([r,o],3):r,n=Cu(r,n),n=al(n)}var Td=function(e){function t(){return e.call(this,"FaceRecognitionNet")||this}return Ah(t,e),t.prototype.forwardInput=function(e){var t=this.params;if(!t)throw new Error("FaceRecognitionNet - load model before inference");return _n((function(){var n=Cd(Jh(e.toBatchTensor(150,!0).toFloat(),[122.782,117.001,104.298]).div(qn(256)),t.conv32_down);n=Ad(n=Mc(n,3,2,"valid"),t.conv32_1),n=Ad(n,t.conv32_2),n=Ad(n,t.conv32_3),n=Ad(n=Pd(n,t.conv64_down),t.conv64_1),n=Ad(n,t.conv64_2),n=Ad(n,t.conv64_3),n=Ad(n=Pd(n,t.conv128_down),t.conv128_1),n=Ad(n,t.conv128_2),n=Ad(n=Pd(n,t.conv256_down),t.conv256_1);var r=(n=Pd(n=Ad(n,t.conv256_2),t.conv256_down_out)).mean([1,2]);return Oc(r,t.fc)}))},t.prototype.forward=function(e){return Th(this,void 0,void 0,(function(){var t;return Dh(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,Tp(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.computeFaceDescriptor=function(e){return Th(this,void 0,void 0,(function(){var t,n,r,o=this;return Dh(this,(function(a){switch(a.label){case 0:return[4,Tp(e)];case 1:return t=a.sent(),n=_n((function(){return Xr(o.forwardInput(t))})),[4,Promise.all(n.map((function(e){return e.data()})))];case 2:return r=a.sent(),n.forEach((function(e){return e.dispose()})),[2,t.isBatchInput?r:r[0]]}}))}))},t.prototype.getDefaultModelName=function(){return"face_recognition_model"},t.prototype.extractParamsFromWeigthMap=function(e){return Rd(e)},t.prototype.extractParams=function(e){return function(e){var t=Yp(e),n=t.extractWeights,r=t.getRemainingWeights,o=[],a=Id(n,o),i=a.extractConvLayerParams,s=a.extractResidualLayerParams,u=i(4704,32,7,"conv32_down"),c=s(9216,32,3,"conv32_1"),l=s(9216,32,3,"conv32_2"),f=s(9216,32,3,"conv32_3"),h=s(36864,64,3,"conv64_down",!0),p=s(36864,64,3,"conv64_1"),d=s(36864,64,3,"conv64_2"),v=s(36864,64,3,"conv64_3"),m=s(147456,128,3,"conv128_down",!0),g=s(147456,128,3,"conv128_1"),y=s(147456,128,3,"conv128_2"),b=s(589824,256,3,"conv256_down",!0),w=s(589824,256,3,"conv256_1"),x=s(589824,256,3,"conv256_2"),E=s(589824,256,3,"conv256_down_out"),_=_n((function(){return ul(Kn(n(32768),[128,256]),[1,0])}));if(o.push({paramPath:"fc"}),0!==r().length)throw new Error("weights remaing after extract: "+r().length);return{params:{conv32_down:u,conv32_1:c,conv32_2:l,conv32_3:f,conv64_down:h,conv64_1:p,conv64_2:d,conv64_3:v,conv128_down:m,conv128_1:g,conv128_2:y,conv256_down:b,conv256_1:w,conv256_2:x,conv256_down_out:E,fc:_},paramMappings:o}}(e)},t}(Lp);function Dd(e,t,n){var r={gender:t,genderProbability:n};return Object.assign({},e,r)}var Md=function(){function e(e){var t=void 0===e?{}:e,n=t.minFaceSize,r=t.scaleFactor,o=t.maxNumScales,a=t.scoreThresholds,i=t.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=n||20,this._scaleFactor=r||.709,this._maxNumScales=o||10,this._scoreThresholds=a||[.6,.7,.7],this._scaleSteps=i,"number"!=typeof this._minFaceSize||this._minFaceSize<0)throw new Error(this._name+" - expected minFaceSize to be a number > 0");if("number"!=typeof this._scaleFactor||this._scaleFactor<=0||this._scaleFactor>=1)throw new Error(this._name+" - expected scaleFactor to be a number between 0 and 1");if("number"!=typeof this._maxNumScales||this._maxNumScales<0)throw new Error(this._name+" - expected maxNumScales to be a number > 0");if(!Array.isArray(this._scoreThresholds)||3!==this._scoreThresholds.length||this._scoreThresholds.some((function(e){return"number"!=typeof e})))throw new Error(this._name+" - expected scoreThresholds to be an array of numbers of length 3");if(this._scaleSteps&&(!Array.isArray(this._scaleSteps)||this._scaleSteps.some((function(e){return"number"!=typeof e}))))throw new Error(this._name+" - expected scaleSteps to be an array of numbers")}return Object.defineProperty(e.prototype,"minFaceSize",{get:function(){return this._minFaceSize},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scaleFactor",{get:function(){return this._scaleFactor},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxNumScales",{get:function(){return this._maxNumScales},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scoreThresholds",{get:function(){return this._scoreThresholds},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scaleSteps",{get:function(){return this._scaleSteps},enumerable:!0,configurable:!0}),e}();function Nd(e,t){function n(n,r,o,a,i){var s=Zn(e(n*r*o*o),[o,o,n,r]),u=Xn(e(r));return t.push({paramPath:a+"/filters"},{paramPath:a+"/"+(i?"batch_norm_offset":"bias")}),{filters:s,bias:u}}function r(e,t,r,o){var a=n(e,t,r,o,!0);return{filters:a.filters,batch_norm_offset:a.bias}}function o(n,o,a){var i=function(n,r){var o=Zn(e(9*n),[3,3,n,1]),a=Xn(e(n)),i=Xn(e(n)),s=Xn(e(n)),u=Xn(e(n));return t.push({paramPath:r+"/filters"},{paramPath:r+"/batch_norm_scale"},{paramPath:r+"/batch_norm_offset"},{paramPath:r+"/batch_norm_mean"},{paramPath:r+"/batch_norm_variance"}),{filters:o,batch_norm_scale:a,batch_norm_offset:i,batch_norm_mean:s,batch_norm_variance:u}}(n,a+"/depthwise_conv");return{depthwise_conv:i,pointwise_conv:r(n,o,1,a+"/pointwise_conv")}}return{extractMobilenetV1Params:function(){return{conv_0:r(3,32,3,"mobilenetv1/conv_0"),conv_1:o(32,64,"mobilenetv1/conv_1"),conv_2:o(64,128,"mobilenetv1/conv_2"),conv_3:o(128,128,"mobilenetv1/conv_3"),conv_4:o(128,256,"mobilenetv1/conv_4"),conv_5:o(256,256,"mobilenetv1/conv_5"),conv_6:o(256,512,"mobilenetv1/conv_6"),conv_7:o(512,512,"mobilenetv1/conv_7"),conv_8:o(512,512,"mobilenetv1/conv_8"),conv_9:o(512,512,"mobilenetv1/conv_9"),conv_10:o(512,512,"mobilenetv1/conv_10"),conv_11:o(512,512,"mobilenetv1/conv_11"),conv_12:o(512,1024,"mobilenetv1/conv_12"),conv_13:o(1024,1024,"mobilenetv1/conv_13")}},extractPredictionLayerParams:function(){return{conv_0:r(1024,256,1,"prediction_layer/conv_0"),conv_1:r(256,512,3,"prediction_layer/conv_1"),conv_2:r(512,128,1,"prediction_layer/conv_2"),conv_3:r(128,256,3,"prediction_layer/conv_3"),conv_4:r(256,128,1,"prediction_layer/conv_4"),conv_5:r(128,256,3,"prediction_layer/conv_5"),conv_6:r(256,64,1,"prediction_layer/conv_6"),conv_7:r(64,128,3,"prediction_layer/conv_7"),box_predictor_0:{box_encoding_predictor:n(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),class_predictor:n(512,9,1,"prediction_layer/box_predictor_0/class_predictor")},box_predictor_1:{box_encoding_predictor:n(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),class_predictor:n(1024,18,1,"prediction_layer/box_predictor_1/class_predictor")},box_predictor_2:{box_encoding_predictor:n(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),class_predictor:n(512,18,1,"prediction_layer/box_predictor_2/class_predictor")},box_predictor_3:{box_encoding_predictor:n(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),class_predictor:n(256,18,1,"prediction_layer/box_predictor_3/class_predictor")},box_predictor_4:{box_encoding_predictor:n(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),class_predictor:n(256,18,1,"prediction_layer/box_predictor_4/class_predictor")},box_predictor_5:{box_encoding_predictor:n(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),class_predictor:n(128,18,1,"prediction_layer/box_predictor_5/class_predictor")}}}}}function Fd(e){var t=[],n=function(e,t){var n=Zp(e,t);function r(e,t,r){return{filters:n(e+"/Conv2d_"+t+"_pointwise/weights",4,r+"/filters"),batch_norm_offset:n(e+"/Conv2d_"+t+"_pointwise/convolution_bn_offset",1,r+"/batch_norm_offset")}}function o(e){var t="mobilenetv1/conv_"+e,o="MobilenetV1/Conv2d_"+e+"_depthwise",a=t+"/depthwise_conv",i=t+"/pointwise_conv";return{depthwise_conv:{filters:n(o+"/depthwise_weights",4,a+"/filters"),batch_norm_scale:n(o+"/BatchNorm/gamma",1,a+"/batch_norm_scale"),batch_norm_offset:n(o+"/BatchNorm/beta",1,a+"/batch_norm_offset"),batch_norm_mean:n(o+"/BatchNorm/moving_mean",1,a+"/batch_norm_mean"),batch_norm_variance:n(o+"/BatchNorm/moving_variance",1,a+"/batch_norm_variance")},pointwise_conv:r("MobilenetV1",e,i)}}function a(e,t){return{filters:n(e+"/weights",4,t+"/filters"),bias:n(e+"/biases",1,t+"/bias")}}function i(e){return{box_encoding_predictor:a("Prediction/BoxPredictor_"+e+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+e+"/box_encoding_predictor"),class_predictor:a("Prediction/BoxPredictor_"+e+"/ClassPredictor","prediction_layer/box_predictor_"+e+"/class_predictor")}}return{extractMobilenetV1Params:function(){return{conv_0:r("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:o(1),conv_2:o(2),conv_3:o(3),conv_4:o(4),conv_5:o(5),conv_6:o(6),conv_7:o(7),conv_8:o(8),conv_9:o(9),conv_10:o(10),conv_11:o(11),conv_12:o(12),conv_13:o(13)}},extractPredictionLayerParams:function(){return{conv_0:r("Prediction",0,"prediction_layer/conv_0"),conv_1:r("Prediction",1,"prediction_layer/conv_1"),conv_2:r("Prediction",2,"prediction_layer/conv_2"),conv_3:r("Prediction",3,"prediction_layer/conv_3"),conv_4:r("Prediction",4,"prediction_layer/conv_4"),conv_5:r("Prediction",5,"prediction_layer/conv_5"),conv_6:r("Prediction",6,"prediction_layer/conv_6"),conv_7:r("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:i(0),box_predictor_1:i(1),box_predictor_2:i(2),box_predictor_3:i(3),box_predictor_4:i(4),box_predictor_5:i(5)}}}}(e,t),r=n.extractMobilenetV1Params,o=n.extractPredictionLayerParams,a=e["Output/extra_dim"];if(t.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!Bh(a))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+a);var i={mobilenetv1:r(),prediction_layer:o(),output_layer:{extra_dim:a}};return Up(e,t),{params:i,paramMappings:t}}function Bd(e,t,n){return _n((function(){var r=dc(e,t.filters,n,"same");return r=Cu(r,t.batch_norm_offset),Ms(r,0,6)}))}function jd(e,t){return _n((function(){var n=null,r=Bd(e,t.conv_0,[2,2]);if([t.conv_1,t.conv_2,t.conv_3,t.conv_4,t.conv_5,t.conv_6,t.conv_7,t.conv_8,t.conv_9,t.conv_10,t.conv_11,t.conv_12,t.conv_13].forEach((function(e,t){var o=t+1,a=function(e){return[2,4,6,12].some((function(t){return t===e}))?[2,2]:[1,1]}(o);r=function(e,t,n){return _n((function(){var r=yc(e,t.filters,n,"same");return r=mu(r,t.batch_norm_mean,t.batch_norm_variance,t.batch_norm_offset,t.batch_norm_scale,.0010000000474974513),Ms(r,0,6)}))}(r,e.depthwise_conv,a),r=Bd(r,e.pointwise_conv,[1,1]),11===o&&(n=r)})),null===n)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:r,conv11:n}}))}function Ld(e,t,n){var r=e.arraySync(),o=Math.min(r[t][0],r[t][2]),a=Math.min(r[t][1],r[t][3]),i=Math.max(r[t][0],r[t][2]),s=Math.max(r[t][1],r[t][3]),u=Math.min(r[n][0],r[n][2]),c=Math.min(r[n][1],r[n][3]),l=Math.max(r[n][0],r[n][2]),f=Math.max(r[n][1],r[n][3]),h=(i-o)*(s-a),p=(l-u)*(f-c);if(h<=0||p<=0)return 0;var d=Math.max(o,u),v=Math.max(a,c),m=Math.min(i,l),g=Math.min(s,f),y=Math.max(m-d,0)*Math.max(g-v,0);return y/(h+p-y)}function zd(e,t){var n=function(e){var t=Xr(ul(e,[1,0])),n=[qu(t[2],t[0]),qu(t[3],t[1])];return{sizes:n,centers:[Cu(t[0],Au(n[0],qn(2))),Cu(t[1],Au(n[1],qn(2)))]}}(e),r=n.sizes,o=n.centers,a=Xr(ul(t,[1,0])),i=Au(zu(js(Au(a[2],qn(5))),r[0]),qn(2)),s=Cu(zu(Au(a[0],qn(10)),r[0]),o[0]),u=Au(zu(js(Au(a[3],qn(5))),r[1]),qn(2)),c=Cu(zu(Au(a[1],qn(10)),r[1]),o[1]);return ul(Ur([qu(s,i),qu(c,u),Cu(s,i),Cu(c,u)]),[1,0])}function Wd(e,t){return _n((function(){var n=e.shape[0];return{boxPredictionEncoding:Wr(Hp(e,t.box_encoding_predictor),[n,-1,1,4]),classPrediction:Wr(Hp(e,t.class_predictor),[n,-1,3])}}))}var Vd=function(){function e(e){var t=void 0===e?{}:e,n=t.minConfidence,r=t.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=n||.5,this._maxResults=r||100,"number"!=typeof this._minConfidence||this._minConfidence<=0||this._minConfidence>=1)throw new Error(this._name+" - expected minConfidence to be a number between 0 and 1");if("number"!=typeof this._maxResults)throw new Error(this._name+" - expected maxResults to be a number")}return Object.defineProperty(e.prototype,"minConfidence",{get:function(){return this._minConfidence},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxResults",{get:function(){return this._maxResults},enumerable:!0,configurable:!0}),e}(),Hd=function(e){function t(){return e.call(this,"SsdMobilenetv1")||this}return Ah(t,e),t.prototype.forwardInput=function(e){var t=this.params;if(!t)throw new Error("SsdMobilenetv1 - load model before inference");return _n((function(){var n=e.toBatchTensor(512,!1).toFloat(),r=jd(qu(zu(n,qn(.007843137718737125)),qn(1)),t.mobilenetv1),o=function(e,t,n){return _n((function(){var r=Bd(e,n.conv_0,[1,1]),o=Bd(r,n.conv_1,[2,2]),a=Bd(o,n.conv_2,[1,1]),i=Bd(a,n.conv_3,[2,2]),s=Bd(i,n.conv_4,[1,1]),u=Bd(s,n.conv_5,[2,2]),c=Bd(u,n.conv_6,[1,1]),l=Bd(c,n.conv_7,[2,2]),f=Wd(t,n.box_predictor_0),h=Wd(e,n.box_predictor_1),p=Wd(o,n.box_predictor_2),d=Wd(i,n.box_predictor_3),v=Wd(u,n.box_predictor_4),m=Wd(l,n.box_predictor_5);return{boxPredictions:rr([f.boxPredictionEncoding,h.boxPredictionEncoding,p.boxPredictionEncoding,d.boxPredictionEncoding,v.boxPredictionEncoding,m.boxPredictionEncoding],1),classPredictions:rr([f.classPrediction,h.classPrediction,p.classPrediction,d.classPrediction,v.classPrediction,m.classPrediction],1)}}))}(r.out,r.conv11,t.prediction_layer);return function(e,t,n){return _n((function(){var r=e.shape[0],o=zd(Wr(Gr(n.extra_dim,[r,1,1]),[-1,4]),Wr(e,[-1,4]));o=Wr(o,[r,o.shape[0]/r,4]);var a=Ks(Lc(t,[0,0,1],[-1,-1,-1])),i=Lc(a,[0,0,0],[-1,-1,1]);return i=Wr(i,[r,i.shape[1]]),{boxes:Xr(o),scores:Xr(i)}}))}(o.boxPredictions,o.classPredictions,t.output_layer)}))},t.prototype.forward=function(e){return Th(this,void 0,void 0,(function(){var t;return Dh(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,Tp(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.locateFaces=function(e,t){return void 0===t&&(t={}),Th(this,void 0,void 0,(function(){var n,r,o,a,i,s,u,c,l,f,h,p,d,v,m,g,y,b,w,x;return Dh(this,(function(E){switch(E.label){case 0:return n=new Vd(t),r=n.maxResults,o=n.minConfidence,[4,Tp(e)];case 1:for(a=E.sent(),i=this.forwardInput(a),s=i.boxes,u=i.scores,c=s[0],l=u[0],f=1;f<s.length;f++)s[f].dispose(),u[f].dispose();return d=(p=Array).from,[4,l.data()];case 2:return h=d.apply(p,[E.sent()]),.5,v=function(e,t,n,r,o){var a=e.shape[0],i=Math.min(n,a),s=t.map((function(e,t){return{score:e,boxIndex:t}})).filter((function(e){return e.score>o})).sort((function(e,t){return t.score-e.score})),u=function(e){return e<=r?1:0},c=[];return s.forEach((function(t){if(!(c.length>=i)){for(var n=t.score,r=c.length-1;r>=0;--r){var a=Ld(e,t.boxIndex,c[r]);if(0!==a&&(t.score*=u(a),t.score<=o))break}n===t.score&&c.push(t.boxIndex)}})),c}(c,h,r,.5,o),m=a.getReshapedInputDimensions(0),g=a.inputSize,y=g/m.width,b=g/m.height,w=c.arraySync(),x=v.map((function(e){var t=[Math.max(0,w[e][0]),Math.min(1,w[e][2])].map((function(e){return e*b})),n=t[0],r=t[1],o=[Math.max(0,w[e][1]),Math.min(1,w[e][3])].map((function(e){return e*y})),i=o[0],s=o[1];return new $h(h[e],new tp(i,n,s-i,r-n),{height:a.getInputHeight(0),width:a.getInputWidth(0)})})),c.dispose(),l.dispose(),[2,x]}}))}))},t.prototype.getDefaultModelName=function(){return"ssd_mobilenetv1_model"},t.prototype.extractParamsFromWeigthMap=function(e){return Fd(e)},t.prototype.extractParams=function(e){return function(e){var t=[],n=Yp(e),r=n.extractWeights,o=n.getRemainingWeights,a=Nd(r,t),i=a.extractMobilenetV1Params,s=a.extractPredictionLayerParams,u=i(),c=s(),l={extra_dim:$n(r(20472),[1,5118,4])};if(t.push({paramPath:"output_layer/extra_dim"}),0!==o().length)throw new Error("weights remaing after extract: "+o().length);return{params:{mobilenetv1:u,prediction_layer:c,output_layer:l},paramMappings:t}}(e)},t}(Lp);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}Ah(t,e)}(Hd);var Ud,Gd=[new Gh(.738768,.874946),new Gh(2.42204,2.65704),new Gh(4.30971,7.04493),new Gh(10.246,4.59428),new Gh(12.6868,11.8741)],qd=[new Gh(1.603231,2.094468),new Gh(6.041143,7.080126),new Gh(2.882459,3.518061),new Gh(4.266906,5.178857),new Gh(9.041765,10.66308)],Xd=[117.001,114.697,97.404],Kd=function(e){return"number"==typeof e};function $d(e){return _n((function(){var t=zu(e,qn(.10000000149011612));return Cu(al(qu(e,t)),t)}))}function Zd(e,t){return _n((function(){var n=Tr(e,[[0,0],[1,1],[1,1],[0,0]]);return n=dc(n,t.conv.filters,[1,1],"valid"),n=qu(n,t.bn.sub),n=zu(n,t.bn.truediv),$d(n=Cu(n,t.conv.bias))}))}function Yd(e,t){return _n((function(){var n=Tr(e,[[0,0],[1,1],[1,1],[0,0]]);return n=xc(n,t.depthwise_filter,t.pointwise_filter,[1,1],"valid"),$d(n=Cu(n,t.bias))}))}function Jd(e,t){var n=Gp(e,t);var r=Kp(e,t);return{extractConvParams:n,extractConvWithBatchNormParams:function(r,o,a){var i=n(r,o,3,a+"/conv"),s=function(n,r){var o=Xn(e(n)),a=Xn(e(n));return t.push({paramPath:r+"/sub"},{paramPath:r+"/truediv"}),{sub:o,truediv:a}}(o,a+"/bn");return{conv:i,bn:s}},extractSeparableConvParams:r}}function Qd(e,t){var n=Zp(e,t);function r(e){return{filters:n(e+"/filters",4),bias:n(e+"/bias",1)}}return{extractConvParams:r,extractConvWithBatchNormParams:function(e){var t=r(e+"/conv"),o=function(e){return{sub:n(e+"/sub",1),truediv:n(e+"/truediv",1)}}(e+"/bn");return{conv:t,bn:o}},extractSeparableConvParams:$p(n)}}!function(e){e[e.XS=224]="XS",e[e.SM=320]="SM",e[e.MD=416]="MD",e[e.LG=608]="LG"}(Ud||(Ud={}));var ev=function(){function e(e){var t=void 0===e?{}:e,n=t.inputSize,r=t.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=n||416,this._scoreThreshold=r||.5,"number"!=typeof this._inputSize||this._inputSize%32!=0)throw new Error(this._name+" - expected inputSize to be a number divisible by 32");if("number"!=typeof this._scoreThreshold||this._scoreThreshold<=0||this._scoreThreshold>=1)throw new Error(this._name+" - expected scoreThreshold to be a number between 0 and 1")}return Object.defineProperty(e.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scoreThreshold",{get:function(){return this._scoreThreshold},enumerable:!0,configurable:!0}),e}(),tv=function(e){function t(t){var n=e.call(this,"TinyYolov2")||this;return function(e){if(!e)throw new Error("invalid config: "+e);if("boolean"!=typeof e.withSeparableConvs)throw new Error("config.withSeparableConvs has to be a boolean, have: "+e.withSeparableConvs);if(!Kd(e.iouThreshold)||e.iouThreshold<0||e.iouThreshold>1)throw new Error("config.iouThreshold has to be a number between [0, 1], have: "+e.iouThreshold);if(!Array.isArray(e.classes)||!e.classes.length||!e.classes.every((function(e){return"string"==typeof e})))throw new Error("config.classes has to be an array class names: string[], have: "+JSON.stringify(e.classes));if(!Array.isArray(e.anchors)||!e.anchors.length||!e.anchors.map((function(e){return e||{}})).every((function(e){return Kd(e.x)&&Kd(e.y)})))throw new Error("config.anchors has to be an array of { x: number, y: number }, have: "+JSON.stringify(e.anchors));if(e.meanRgb&&(!Array.isArray(e.meanRgb)||3!==e.meanRgb.length||!e.meanRgb.every(Kd)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(e.meanRgb))}(t),n._config=t,n}return Ah(t,e),Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"withClassScores",{get:function(){return this.config.withClassScores||this.config.classes.length>1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"boxEncodingSize",{get:function(){return 5+(this.withClassScores?this.config.classes.length:0)},enumerable:!0,configurable:!0}),t.prototype.runTinyYolov2=function(e,t){var n=Zd(e,t.conv0);return n=Zd(n=Mc(n,[2,2],[2,2],"same"),t.conv1),n=Zd(n=Mc(n,[2,2],[2,2],"same"),t.conv2),n=Zd(n=Mc(n,[2,2],[2,2],"same"),t.conv3),n=Zd(n=Mc(n,[2,2],[2,2],"same"),t.conv4),n=Zd(n=Mc(n,[2,2],[2,2],"same"),t.conv5),n=Zd(n=Mc(n,[2,2],[1,1],"same"),t.conv6),Hp(n=Zd(n,t.conv7),t.conv8,"valid",!1)},t.prototype.runMobilenet=function(e,t){var n=this.config.isFirstLayerConv2d?$d(Hp(e,t.conv0,"valid",!1)):Yd(e,t.conv0);return n=Yd(n=Mc(n,[2,2],[2,2],"same"),t.conv1),n=Yd(n=Mc(n,[2,2],[2,2],"same"),t.conv2),n=Yd(n=Mc(n,[2,2],[2,2],"same"),t.conv3),n=Yd(n=Mc(n,[2,2],[2,2],"same"),t.conv4),n=Yd(n=Mc(n,[2,2],[2,2],"same"),t.conv5),n=Mc(n,[2,2],[1,1],"same"),n=t.conv6?Yd(n,t.conv6):n,Hp(n=t.conv7?Yd(n,t.conv7):n,t.conv8,"valid",!1)},t.prototype.forwardInput=function(e,t){var n=this,r=this.params;if(!r)throw new Error("TinyYolov2 - load model before inference");return _n((function(){var o=e.toBatchTensor(t,!1).toFloat();return o=(o=n.config.meanRgb?Jh(o,n.config.meanRgb):o).div(qn(256)),n.config.withSeparableConvs?n.runMobilenet(o,r):n.runTinyYolov2(o,r)}))},t.prototype.forward=function(e,t){return Th(this,void 0,void 0,(function(){var n;return Dh(this,(function(r){switch(r.label){case 0:return n=this.forwardInput,[4,Tp(e)];case 1:return[4,n.apply(this,[r.sent(),t])];case 2:return[2,r.sent()]}}))}))},t.prototype.detect=function(e,t){return void 0===t&&(t={}),Th(this,void 0,void 0,(function(){var n,r,o,a,i,s,u,c,l,f,h,p,d,v=this;return Dh(this,(function(m){switch(m.label){case 0:return n=new ev(t),r=n.inputSize,o=n.scoreThreshold,[4,Tp(e)];case 1:return a=m.sent(),[4,this.forwardInput(a,r)];case 2:return i=m.sent(),s=_n((function(){return Xr(i)[0].expandDims()})),u={width:a.getInputWidth(0),height:a.getInputHeight(0)},[4,this.extractBoxes(s,a.getReshapedInputDimensions(0),o)];case 3:return c=m.sent(),i.dispose(),s.dispose(),l=c.map((function(e){return e.box})),f=c.map((function(e){return e.score})),h=c.map((function(e){return e.classScore})),p=c.map((function(e){return v.config.classes[e.label]})),d=Yh(l.map((function(e){return e.rescale(r)})),f,this.config.iouThreshold,!0),[2,d.map((function(e){return new Kh(f[e],h[e],p[e],l[e],u)}))]}}))}))},t.prototype.getDefaultModelName=function(){return""},t.prototype.extractParamsFromWeigthMap=function(e){return function(e,t){var n,r=[],o=Qd(e,r),a=o.extractConvParams,i=o.extractConvWithBatchNormParams,s=o.extractSeparableConvParams;if(t.withSeparableConvs){var u=t.filterSizes&&t.filterSizes.length||9;n={conv0:t.isFirstLayerConv2d?a("conv0"):s("conv0"),conv1:s("conv1"),conv2:s("conv2"),conv3:s("conv3"),conv4:s("conv4"),conv5:s("conv5"),conv6:u>7?s("conv6"):void 0,conv7:u>8?s("conv7"):void 0,conv8:a("conv8")}}else n={conv0:i("conv0"),conv1:i("conv1"),conv2:i("conv2"),conv3:i("conv3"),conv4:i("conv4"),conv5:i("conv5"),conv6:i("conv6"),conv7:i("conv7"),conv8:a("conv8")};return Up(e,r),{params:n,paramMappings:r}}(e,this.config)},t.prototype.extractParams=function(e){var n=this.config.filterSizes||t.DEFAULT_FILTER_SIZES,r=n?n.length:void 0;if(7!==r&&8!==r&&9!==r)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+r+" filterSizes in config");return function(e,t,n,r){var o,a=Yp(e),i=a.extractWeights,s=a.getRemainingWeights,u=[],c=Jd(i,u),l=c.extractConvParams,f=c.extractConvWithBatchNormParams,h=c.extractSeparableConvParams;if(t.withSeparableConvs){var p=r[0],d=r[1],v=r[2],m=r[3],g=r[4],y=r[5],b=r[6],w=r[7],x=r[8];o={conv0:t.isFirstLayerConv2d?l(p,d,3,"conv0"):h(p,d,"conv0"),conv1:h(d,v,"conv1"),conv2:h(v,m,"conv2"),conv3:h(m,g,"conv3"),conv4:h(g,y,"conv4"),conv5:h(y,b,"conv5"),conv6:w?h(b,w,"conv6"):void 0,conv7:x?h(w,x,"conv7"):void 0,conv8:l(x||w||b,5*n,1,"conv8")}}else p=r[0],d=r[1],v=r[2],m=r[3],g=r[4],y=r[5],b=r[6],w=r[7],x=r[8],o={conv0:f(p,d,"conv0"),conv1:f(d,v,"conv1"),conv2:f(v,m,"conv2"),conv3:f(m,g,"conv3"),conv4:f(g,y,"conv4"),conv5:f(y,b,"conv5"),conv6:f(b,w,"conv6"),conv7:f(w,x,"conv7"),conv8:l(x,5*n,1,"conv8")};if(0!==s().length)throw new Error("weights remaing after extract: "+s().length);return{params:o,paramMappings:u}}(e,this.config,this.boxEncodingSize,n)},t.prototype.extractBoxes=function(e,t,n){return Th(this,void 0,void 0,(function(){var r,o,a,i,s,u,c,l,f,h,p,d,v,m,g,y,b,w,x,E,_,O,k,C,I,S,R,A,P,T=this;return Dh(this,(function(D){switch(D.label){case 0:return r=t.width,o=t.height,a=Math.max(r,o),i=a/r,s=a/o,u=e.shape[1],c=this.config.anchors.length,l=_n((function(){var t=e.reshape([u,u,c,T.boxEncodingSize]);return[t.slice([0,0,0,0],[u,u,c,4]),t.slice([0,0,0,4],[u,u,c,1]),T.withClassScores?lo(t.slice([0,0,0,5],[u,u,c,T.config.classes.length]),3):qn(0)]})),f=l[0],h=l[1],p=l[2],d=[],[4,h.array()];case 1:return v=D.sent(),[4,f.array()];case 2:m=D.sent(),g=0,D.label=3;case 3:if(!(g<u))return[3,12];y=0,D.label=4;case 4:if(!(y<u))return[3,11];b=0,D.label=5;case 5:return b<c?(w=Qh(v[g][y][b][0]),!n||w>n?(x=(y+Qh(m[g][y][b][0]))/u*i,E=(g+Qh(m[g][y][b][1]))/u*s,_=Math.exp(m[g][y][b][2])*this.config.anchors[b].x/u*i,O=Math.exp(m[g][y][b][3])*this.config.anchors[b].y/u*s,k=x-_/2,C=E-O/2,I={row:g,col:y,anchor:b},this.withClassScores?[4,this.extractPredictedClass(p,I)]:[3,7]):[3,9]):[3,10];case 6:return P=D.sent(),[3,8];case 7:P={classScore:1,label:0},D.label=8;case 8:R=(S=P).classScore,A=S.label,d.push(Ph({box:new Xh(k,C,k+_,C+O),score:w,classScore:w*R,label:A},I)),D.label=9;case 9:return b++,[3,5];case 10:return y++,[3,4];case 11:return g++,[3,3];case 12:return f.dispose(),h.dispose(),p.dispose(),[2,d]}}))}))},t.prototype.extractPredictedClass=function(e,t){return Th(this,void 0,void 0,(function(){var n,r,o,a;return Dh(this,(function(i){switch(i.label){case 0:return n=t.row,r=t.col,o=t.anchor,[4,e.array()];case 1:return a=i.sent(),[2,Array(this.config.classes.length).fill(0).map((function(e,t){return a[n][r][o][t]})).map((function(e,t){return{classScore:e,label:t}})).reduce((function(e,t){return e.classScore>t.classScore?e:t}))]}}))}))},t.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],t}(Lp),nv=function(e){function t(t){void 0===t&&(t=!0);var n=Object.assign({},{withSeparableConvs:t,iouThreshold:.4,classes:["face"]},t?{anchors:qd,meanRgb:Xd}:{anchors:Gd,withClassScores:!0});return e.call(this,n)||this}return Ah(t,e),Object.defineProperty(t.prototype,"withSeparableConvs",{get:function(){return this.config.withSeparableConvs},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),t.prototype.locateFaces=function(e,t){return Th(this,void 0,void 0,(function(){return Dh(this,(function(n){switch(n.label){case 0:return[4,this.detect(e,t)];case 1:return[2,n.sent().map((function(e){return new $h(e.score,e.relativeBox,{width:e.imageWidth,height:e.imageHeight})}))]}}))}))},t.prototype.getDefaultModelName=function(){return this.withSeparableConvs?"tiny_yolov2_separable_conv_model":"tiny_yolov2_model"},t.prototype.extractParamsFromWeigthMap=function(t){return e.prototype.extractParamsFromWeigthMap.call(this,t)},t}(tv);var rv=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._name="TinyFaceDetectorOptions",t}return Ah(t,e),t}(ev),ov=function(){function e(){}return e.prototype.then=function(e){return Th(this,void 0,void 0,(function(){var t;return Dh(this,(function(n){switch(n.label){case 0:return t=e,[4,this.run()];case 1:return[2,t.apply(void 0,[n.sent()])]}}))}))},e.prototype.run=function(){return Th(this,void 0,void 0,(function(){return Dh(this,(function(e){throw new Error("ComposableTask - run is not implemented")}))}))},e}();function av(e,t){var n={descriptor:t};return Object.assign({},e,n)}function iv(e,t,n,r,o){return void 0===o&&(o=function(e){return e.alignedRect}),Th(this,void 0,void 0,(function(){var a,i,s,u,c;return Dh(this,(function(l){switch(l.label){case 0:return a=e.map((function(e){return cd(e)?o(e):e.detection})),(s=r)?[3,5]:t instanceof et?[4,Mp(t,a)]:[3,2];case 1:return u=l.sent(),[3,4];case 2:return[4,Dp(t,a)];case 3:u=l.sent(),l.label=4;case 4:s=u,l.label=5;case 5:return[4,n(i=s)];case 6:return c=l.sent(),i.forEach((function(e){return e instanceof et&&e.dispose()})),[2,c]}}))}))}function sv(e,t,n,r,o){return Th(this,void 0,void 0,(function(){var a=this;return Dh(this,(function(i){return[2,iv([e],t,(function(e){return Th(a,void 0,void 0,(function(){return Dh(this,(function(t){return[2,n(e[0])]}))}))}),r,o)]}))}))}function uv(e){var t=Yp(e),n=t.extractWeights,r=t.getRemainingWeights,o=[],a=function(e,t){var n=Gp(e,t),r=qp(e,t);function o(n,r){var o=Xn(e(n));return t.push({paramPath:r}),o}function a(e,t,r){return void 0===r&&(r=!1),{conv1:n(e[0],e[1],3,t+"/conv1"),prelu1_alpha:o(e[1],t+"/prelu1_alpha"),conv2:n(e[1],e[2],3,t+"/conv2"),prelu2_alpha:o(e[2],t+"/prelu2_alpha"),conv3:n(e[2],e[3],r?2:3,t+"/conv3"),prelu3_alpha:o(e[3],t+"/prelu3_alpha")}}return{extractPNetParams:function(){var e=a([3,10,16,32],"pnet"),t=n(32,2,1,"pnet/conv4_1"),r=n(32,4,1,"pnet/conv4_2");return Ph(Ph({},e),{conv4_1:t,conv4_2:r})},extractRNetParams:function(){var e=a([3,28,48,64],"rnet",!0),t=r(576,128,"rnet/fc1"),n=o(128,"rnet/prelu4_alpha"),i=r(128,2,"rnet/fc2_1"),s=r(128,4,"rnet/fc2_2");return Ph(Ph({},e),{fc1:t,prelu4_alpha:n,fc2_1:i,fc2_2:s})},extractONetParams:function(){var e=a([3,32,64,64],"onet"),t=n(64,128,2,"onet/conv4"),i=o(128,"onet/prelu4_alpha"),s=r(1152,256,"onet/fc1"),u=o(256,"onet/prelu5_alpha"),c=r(256,2,"onet/fc2_1"),l=r(256,4,"onet/fc2_2"),f=r(256,10,"onet/fc2_3");return Ph(Ph({},e),{conv4:t,prelu4_alpha:i,fc1:s,prelu5_alpha:u,fc2_1:c,fc2_2:l,fc2_3:f})}}}(n,o),i=a.extractPNetParams,s=a.extractRNetParams,u=a.extractONetParams,c=i(),l=s(),f=u();if(0!==r().length)throw new Error("weights remaing after extract: "+r().length);return{params:{pnet:c,rnet:l,onet:f},paramMappings:o}}function cv(e){var t=[],n=function(e,t){var n=Zp(e,t);function r(e){return{filters:n(e+"/weights",4,e+"/filters"),bias:n(e+"/bias",1)}}function o(e){return{weights:n(e+"/weights",2),bias:n(e+"/bias",1)}}function a(e){return n(e,1)}function i(e){return{conv1:r(e+"/conv1"),prelu1_alpha:a(e+"/prelu1_alpha"),conv2:r(e+"/conv2"),prelu2_alpha:a(e+"/prelu2_alpha"),conv3:r(e+"/conv3"),prelu3_alpha:a(e+"/prelu3_alpha")}}return{extractPNetParams:function(){var e=i("pnet"),t=r("pnet/conv4_1"),n=r("pnet/conv4_2");return Ph(Ph({},e),{conv4_1:t,conv4_2:n})},extractRNetParams:function(){var e=i("rnet"),t=o("rnet/fc1"),n=a("rnet/prelu4_alpha"),r=o("rnet/fc2_1"),s=o("rnet/fc2_2");return Ph(Ph({},e),{fc1:t,prelu4_alpha:n,fc2_1:r,fc2_2:s})},extractONetParams:function(){var e=i("onet"),t=r("onet/conv4"),n=a("onet/prelu4_alpha"),s=o("onet/fc1"),u=a("onet/prelu5_alpha"),c=o("onet/fc2_1"),l=o("onet/fc2_2"),f=o("onet/fc2_3");return Ph(Ph({},e),{conv4:t,prelu4_alpha:n,fc1:s,prelu5_alpha:u,fc2_1:c,fc2_2:l,fc2_3:f})}}}(e,t),r=n.extractPNetParams,o=n.extractRNetParams,a=n.extractONetParams,i=r(),s=o(),u=a();return Up(e,t),{params:{pnet:i,rnet:s,onet:u},paramMappings:t}}function lv(e,t){var n=t[0],r=t[1];return{height:Math.floor(n*e),width:Math.floor(r*e)}}var fv=function(e){function t(t,n,r,o){return e.call(this,{left:t,top:n,right:r,bottom:o},!0)||this}return Ah(t,e),t}(qh);function hv(e){return _n((function(){return zu(qu(e,qn(127.5)),qn(.0078125))}))}function pv(e,t){return _n((function(){return Cu(al(e),zu(t,Us(al(Us(e)))))}))}function dv(e,t,n){return void 0===n&&(n=!1),_n((function(){var r=Hp(e,t.conv1,"valid");return r=pv(r,t.prelu1_alpha),r=pv(r=Hp(r=Mc(r,n?[2,2]:[3,3],[2,2],"same"),t.conv2,"valid"),t.prelu2_alpha),r=pv(r=Hp(r=n?r:Mc(r,[3,3],[2,2],"valid"),t.conv3,"valid"),t.prelu3_alpha)}))}function vv(e,t,n,r,o){o.stage1=[];var a=t.map((function(t){return _n((function(){var n={scale:t},o=function(e,t){return _n((function(){var n=lv(t,e.shape.slice(1)),r=n.height,o=n.width,a=hv(Ql.resizeBilinear(e,[r,o]));return ul(a,[0,2,1,3])}))}(e,t),a=Date.now(),i=function(e,t){return _n((function(){var n=dv(e,t,!0),r=Hp(n,t.conv4_1,"valid"),o=Sr(Zc(r,3),3);return{prob:lo(qu(r,o),3),regions:Hp(n,t.conv4_2,"valid")}}))}(o,r),s=i.prob,u=i.regions;return n.pnet=Date.now()-a,{scoresTensor:Xr(Xr(s,3)[1])[0],regionsTensor:Xr(u)[0],scale:t,statsForScale:n}}))})),i=a.map((function(e){var t=e.scoresTensor,r=e.regionsTensor,a=e.scale,i=e.statsForScale,s=function(e,t,n,r){for(var o=[],a=e.arraySync(),i=0;i<e.shape[0];i++)for(var s=0;s<e.shape[1];s++)a[i][s]>=r&&o.push(new Gh(s,i));return o.map((function(e){var r=new Xh(Math.round((2*e.y+1)/n),Math.round((2*e.x+1)/n),Math.round((2*e.y+12)/n),Math.round((2*e.x+12)/n)),o=a[e.y][e.x],i=t.arraySync();return{cell:r,score:o,region:new fv(i[e.y][e.x][0],i[e.y][e.x][1],i[e.y][e.x][2],i[e.y][e.x][3])}}))}(t,r,a,n);if(t.dispose(),r.dispose(),!s.length)return o.stage1.push(i),[];var u=Date.now(),c=Yh(s.map((function(e){return e.cell})),s.map((function(e){return e.score})),.5);return i.nms=Date.now()-u,i.numBoxes=c.length,o.stage1.push(i),c.map((function(e){return s[e]}))})),s=i.reduce((function(e,t){return e.concat(t)}),[]),u=[],c=[];if(s.length>0){var l=Date.now(),f=Yh(s.map((function(e){return e.cell})),s.map((function(e){return e.score})),.7);o.stage1_nms=Date.now()-l,c=f.map((function(e){return s[e].score})),u=f.map((function(e){return s[e]})).map((function(e){var t=e.cell,n=e.region;return new Xh(t.left+n.left*t.width,t.top+n.top*t.height,t.right+n.right*t.width,t.bottom+n.bottom*t.height).toSquare().round()}))}return{boxes:u,scores:c}}function mv(e,t,n){var r=n.width,o=n.height;return Th(this,void 0,void 0,(function(){var n,a,i,s=this;return Dh(this,(function(u){switch(u.label){case 0:return n=wp(e),[4,Promise.all(t.map((function(t){return Th(s,void 0,void 0,(function(){var r,o,a,i,s,u,c,l;return Dh(this,(function(f){return r=t.padAtBorders(e.height,e.width),o=r.y,a=r.ey,i=r.x,s=r.ex,u=i-1,c=o-1,l=n.getImageData(u,c,s-u,a-c),[2,yp.isNodejs()?Sp(l):createImageBitmap(l)]}))}))})))];case 1:return a=u.sent(),i=[],a.forEach((function(e){var t=wp(Ip({width:r,height:o}));t.drawImage(e,0,0,r,o);for(var n=t.getImageData(0,0,r,o).data,a=[],s=0;s<n.length;s+=4)a.push(n[s+2]),a.push(n[s+1]),a.push(n[s]);i.push(a)})),[2,i.map((function(e){return _n((function(){return hv(ul(Zn(e,[1,r,o,3]),[0,2,1,3]).toFloat())}))}))]}}))}))}function gv(e,t,n,r,o){return Th(this,void 0,void 0,(function(){var a,i,s,u,c,l,f,h,p,d,v,m,g,y;return Dh(this,(function(b){switch(b.label){case 0:return a=Date.now(),[4,mv(e,t,{width:24,height:24})];case 1:return i=b.sent(),o.stage2_extractImagePatches=Date.now()-a,a=Date.now(),s=i.map((function(e){var t=function(e,t){return _n((function(){var n=dv(e,t),r=pv(nd(Wr(n,[n.shape[0],t.fc1.weights.shape[0]]),t.fc1),t.prelu4_alpha),o=nd(r,t.fc2_1),a=Sr(Zc(o,1),1),i=lo(qu(o,a),1),s=nd(r,t.fc2_2);return{scores:Xr(i,1)[1],regions:s}}))}(e,r);return e.dispose(),t})),o.stage2_rnet=Date.now()-a,u=s.length>1?rr(s.map((function(e){return e.scores}))):s[0].scores,f=(l=Array).from,[4,u.data()];case 2:return c=f.apply(l,[b.sent()]),u.dispose(),h=c.map((function(e,t){return{score:e,idx:t}})).filter((function(e){return e.score>n})).map((function(e){return e.idx})),p=h.map((function(e){return t[e]})),d=h.map((function(e){return c[e]})),v=[],m=[],p.length>0&&(a=Date.now(),g=Yh(p,d,.7),o.stage2_nms=Date.now()-a,y=g.map((function(e){var t=s[h[e]].regions.arraySync();return new fv(t[0][0],t[0][1],t[0][2],t[0][3])})),m=g.map((function(e){return d[e]})),v=g.map((function(e,t){return p[e].calibrate(y[t])}))),s.forEach((function(e){e.regions.dispose(),e.scores.dispose()})),[2,{boxes:v,scores:m}]}}))}))}function yv(e,t,n,r,o){return Th(this,void 0,void 0,(function(){var a,i,s,u,c,l,f,h,p,d,v,m,g,y,b;return Dh(this,(function(w){switch(w.label){case 0:return a=Date.now(),[4,mv(e,t,{width:48,height:48})];case 1:return i=w.sent(),o.stage3_extractImagePatches=Date.now()-a,a=Date.now(),s=i.map((function(e){var t=function(e,t){return _n((function(){var n=dv(e,t);n=pv(n=Hp(n=Mc(n,[2,2],[2,2],"same"),t.conv4,"valid"),t.prelu4_alpha);var r=pv(nd(Wr(n,[n.shape[0],t.fc1.weights.shape[0]]),t.fc1),t.prelu5_alpha),o=nd(r,t.fc2_1),a=Sr(Zc(o,1),1),i=lo(qu(o,a),1),s=nd(r,t.fc2_2),u=nd(r,t.fc2_3);return{scores:Xr(i,1)[1],regions:s,points:u}}))}(e,r);return e.dispose(),t})),o.stage3_onet=Date.now()-a,u=s.length>1?rr(s.map((function(e){return e.scores}))):s[0].scores,f=(l=Array).from,[4,u.data()];case 2:return c=f.apply(l,[w.sent()]),u.dispose(),h=c.map((function(e,t){return{score:e,idx:t}})).filter((function(e){return e.score>n})).map((function(e){return e.idx})),p=h.map((function(e){var t=s[e].regions.arraySync();return new fv(t[0][0],t[0][1],t[0][2],t[0][3])})),d=h.map((function(e,n){return t[e].calibrate(p[n])})),v=h.map((function(e){return c[e]})),m=[],g=[],y=[],d.length>0&&(a=Date.now(),b=Yh(d,v,.7,!1),o.stage3_nms=Date.now()-a,m=b.map((function(e){return d[e]})),g=b.map((function(e){return v[e]})),y=b.map((function(e,t){return Array(5).fill(0).map((function(n,r){var o=s[e].points.arraySync();return new Gh(o[0][r]*(m[t].width+1)+m[t].left,o[0][r+5]*(m[t].height+1)+m[t].top)}))}))),s.forEach((function(e){e.regions.dispose(),e.scores.dispose(),e.points.dispose()})),[2,{boxes:m,scores:g,points:y}]}}))}))}var bv=function(e){function t(){return e.call(this,"Mtcnn")||this}return Ah(t,e),t.prototype.load=function(t){return Th(this,void 0,void 0,(function(){return Dh(this,(function(n){return console.warn("mtcnn is deprecated and will be removed soon"),[2,e.prototype.load.call(this,t)]}))}))},t.prototype.loadFromDisk=function(t){return Th(this,void 0,void 0,(function(){return Dh(this,(function(n){return console.warn("mtcnn is deprecated and will be removed soon"),[2,e.prototype.loadFromDisk.call(this,t)]}))}))},t.prototype.forwardInput=function(e,t){return void 0===t&&(t={}),Th(this,void 0,void 0,(function(){var n,r,o,a,i,s,u,c,l,f,h,p,d,v,m,g,y,b,w,x,E;return Dh(this,(function(_){switch(_.label){case 0:if(!(n=this.params))throw new Error("Mtcnn - load model before inference");if(!(r=e.canvases[0]))throw new Error("Mtcnn - inputCanvas is not defined, note that passing tensors into Mtcnn.forwardInput is not supported yet.");return o={},a=Date.now(),i=_n((function(){return e=Sr(ph.fromPixels(r)).toFloat(),_n((function(){return Ur(Xr(e,3).reverse(),3)}));var e})),s=function(e){return i.dispose(),o.total=Date.now()-a,e},u=i.shape.slice(1),c=u[0],l=u[1],f=new Md(t),h=f.minFaceSize,p=f.scaleFactor,d=f.maxNumScales,v=f.scoreThresholds,m=f.scaleSteps,g=(m||function(e,t,n){for(var r=n[0],o=n[1],a=12/e,i=[],s=Math.min(r,o)*a,u=0;s>=12;)i.push(a*Math.pow(t,u)),s*=t,u+=1;return i}(h,p,[c,l])).filter((function(e){var t=lv(e,[c,l]);return Math.min(t.width,t.height)>12})).slice(0,d),o.scales=g,o.pyramid=g.map((function(e){return lv(e,[c,l])})),y=Date.now(),[4,vv(i,g,v[0],n.pnet,o)];case 1:return b=_.sent(),o.total_stage1=Date.now()-y,b.boxes.length?(o.stage2_numInputBoxes=b.boxes.length,y=Date.now(),[4,gv(r,b.boxes,v[1],n.rnet,o)]):[2,s({results:[],stats:o})];case 2:return w=_.sent(),o.total_stage2=Date.now()-y,w.boxes.length?(o.stage3_numInputBoxes=w.boxes.length,y=Date.now(),[4,yv(r,w.boxes,v[2],n.onet,o)]):[2,s({results:[],stats:o})];case 3:return x=_.sent(),o.total_stage3=Date.now()-y,E=x.boxes.map((function(e,t){return ld(cp({},new $h(x.scores[t],new tp(e.left/l,e.top/c,e.width/l,e.height/c),{height:c,width:l})),new rp(x.points[t].map((function(t){return t.sub(new Gh(e.left,e.top)).div(new Gh(e.width,e.height))})),{width:e.width,height:e.height}))})),[2,s({results:E,stats:o})]}}))}))},t.prototype.forward=function(e,t){return void 0===t&&(t={}),Th(this,void 0,void 0,(function(){var n;return Dh(this,(function(r){switch(r.label){case 0:return n=this.forwardInput,[4,Tp(e)];case 1:return[4,n.apply(this,[r.sent(),t])];case 2:return[2,r.sent().results]}}))}))},t.prototype.forwardWithStats=function(e,t){return void 0===t&&(t={}),Th(this,void 0,void 0,(function(){var n;return Dh(this,(function(r){switch(r.label){case 0:return n=this.forwardInput,[4,Tp(e)];case 1:return[2,n.apply(this,[r.sent(),t])]}}))}))},t.prototype.getDefaultModelName=function(){return"mtcnn_model"},t.prototype.extractParamsFromWeigthMap=function(e){return cv(e)},t.prototype.extractParams=function(e){return uv(e)},t}(Lp),wv=[new Gh(1.603231,2.094468),new Gh(6.041143,7.080126),new Gh(2.882459,3.518061),new Gh(4.266906,5.178857),new Gh(9.041765,10.66308)],xv=[117.001,114.697,97.404],Ev=function(e){function t(){var t={withSeparableConvs:!0,iouThreshold:.4,classes:["face"],anchors:wv,meanRgb:xv,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return e.call(this,t)||this}return Ah(t,e),Object.defineProperty(t.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),t.prototype.locateFaces=function(e,t){return Th(this,void 0,void 0,(function(){return Dh(this,(function(n){switch(n.label){case 0:return[4,this.detect(e,t)];case 1:return[2,n.sent().map((function(e){return new $h(e.score,e.relativeBox,{width:e.imageWidth,height:e.imageHeight})}))]}}))}))},t.prototype.getDefaultModelName=function(){return"tiny_face_detector_model"},t.prototype.extractParamsFromWeigthMap=function(t){return e.prototype.extractParamsFromWeigthMap.call(this,t)},t}(tv),_v={ssdMobilenetv1:new Hd,tinyFaceDetector:new Ev,tinyYolov2:new nv,mtcnn:new bv,faceLandmark68Net:new xd,faceLandmark68TinyNet:new _d,faceRecognitionNet:new Td,faceExpressionNet:new sd,ageGenderNet:new bd};function Ov(e,t){var n={age:t};return Object.assign({},e,n)}var kv=function(e){function t(t,n,r){var o=e.call(this)||this;return o.parentTask=t,o.input=n,o.extractedFaces=r,o}return Ah(t,e),t}(ov),Cv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.run=function(){return Th(this,void 0,void 0,(function(){var e,t,n=this;return Dh(this,(function(r){switch(r.label){case 0:return[4,this.parentTask];case 1:return[4,iv(e=r.sent(),this.input,(function(e){return Th(n,void 0,void 0,(function(){return Dh(this,(function(t){switch(t.label){case 0:return[4,Promise.all(e.map((function(e){return _v.faceExpressionNet.predictExpressions(e)})))];case 1:return[2,t.sent()]}}))}))}),this.extractedFaces)];case 2:return t=r.sent(),[2,e.map((function(e,n){return ud(e,t[n])}))]}}))}))},t.prototype.withAgeAndGender=function(){return new Pv(this,this.input)},t}(kv),Iv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.run=function(){return Th(this,void 0,void 0,(function(){var e,t;return Dh(this,(function(n){switch(n.label){case 0:return[4,this.parentTask];case 1:return(e=n.sent())?[4,sv(e,this.input,(function(e){return _v.faceExpressionNet.predictExpressions(e)}),this.extractedFaces)]:[2];case 2:return t=n.sent(),[2,ud(e,t)]}}))}))},t.prototype.withAgeAndGender=function(){return new Tv(this,this.input)},t}(kv),Sv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.withAgeAndGender=function(){return new Dv(this,this.input)},t.prototype.withFaceDescriptors=function(){return new Fv(this,this.input)},t}(Cv),Rv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.withAgeAndGender=function(){return new Mv(this,this.input)},t.prototype.withFaceDescriptor=function(){return new Bv(this,this.input)},t}(Iv),Av=function(e){function t(t,n,r){var o=e.call(this)||this;return o.parentTask=t,o.input=n,o.extractedFaces=r,o}return Ah(t,e),t}(ov),Pv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.run=function(){return Th(this,void 0,void 0,(function(){var e,t,n=this;return Dh(this,(function(r){switch(r.label){case 0:return[4,this.parentTask];case 1:return[4,iv(e=r.sent(),this.input,(function(e){return Th(n,void 0,void 0,(function(){return Dh(this,(function(t){switch(t.label){case 0:return[4,Promise.all(e.map((function(e){return _v.ageGenderNet.predictAgeAndGender(e)})))];case 1:return[2,t.sent()]}}))}))}),this.extractedFaces)];case 2:return t=r.sent(),[2,e.map((function(e,n){var r=t[n],o=r.age;return Ov(Dd(e,r.gender,r.genderProbability),o)}))]}}))}))},t.prototype.withFaceExpressions=function(){return new Cv(this,this.input)},t}(Av),Tv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.run=function(){return Th(this,void 0,void 0,(function(){var e,t,n,r,o;return Dh(this,(function(a){switch(a.label){case 0:return[4,this.parentTask];case 1:return(e=a.sent())?[4,sv(e,this.input,(function(e){return _v.ageGenderNet.predictAgeAndGender(e)}),this.extractedFaces)]:[2];case 2:return t=a.sent(),n=t.age,r=t.gender,o=t.genderProbability,[2,Ov(Dd(e,r,o),n)]}}))}))},t.prototype.withFaceExpressions=function(){return new Iv(this,this.input)},t}(Av),Dv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.withFaceExpressions=function(){return new Sv(this,this.input)},t.prototype.withFaceDescriptors=function(){return new Fv(this,this.input)},t}(Pv),Mv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.withFaceExpressions=function(){return new Rv(this,this.input)},t.prototype.withFaceDescriptor=function(){return new Bv(this,this.input)},t}(Tv),Nv=function(e){function t(t,n){var r=e.call(this)||this;return r.parentTask=t,r.input=n,r}return Ah(t,e),t}(ov),Fv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.run=function(){return Th(this,void 0,void 0,(function(){var e;return Dh(this,(function(t){switch(t.label){case 0:return[4,this.parentTask];case 1:return[4,iv(e=t.sent(),this.input,(function(e){return Promise.all(e.map((function(e){return _v.faceRecognitionNet.computeFaceDescriptor(e)})))}),null,(function(e){return e.landmarks.align(null,{useDlibAlignment:!0})}))];case 2:return[2,t.sent().map((function(t,n){return av(e[n],t)}))]}}))}))},t.prototype.withFaceExpressions=function(){return new Sv(this,this.input)},t.prototype.withAgeAndGender=function(){return new Dv(this,this.input)},t}(Nv),Bv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.run=function(){return Th(this,void 0,void 0,(function(){var e,t;return Dh(this,(function(n){switch(n.label){case 0:return[4,this.parentTask];case 1:return(e=n.sent())?[4,sv(e,this.input,(function(e){return _v.faceRecognitionNet.computeFaceDescriptor(e)}),null,(function(e){return e.landmarks.align(null,{useDlibAlignment:!0})}))]:[2];case 2:return t=n.sent(),[2,av(e,t)]}}))}))},t.prototype.withFaceExpressions=function(){return new Rv(this,this.input)},t.prototype.withAgeAndGender=function(){return new Mv(this,this.input)},t}(Nv),jv=function(e){function t(t,n,r){var o=e.call(this)||this;return o.parentTask=t,o.input=n,o.useTinyLandmarkNet=r,o}return Ah(t,e),Object.defineProperty(t.prototype,"landmarkNet",{get:function(){return this.useTinyLandmarkNet?_v.faceLandmark68TinyNet:_v.faceLandmark68Net},enumerable:!0,configurable:!0}),t}(ov),Lv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.run=function(){return Th(this,void 0,void 0,(function(){var e,t,n,r,o,a=this;return Dh(this,(function(i){switch(i.label){case 0:return[4,this.parentTask];case 1:return e=i.sent(),t=e.map((function(e){return e.detection})),this.input instanceof et?[4,Mp(this.input,t)]:[3,3];case 2:return r=i.sent(),[3,5];case 3:return[4,Dp(this.input,t)];case 4:r=i.sent(),i.label=5;case 5:return n=r,[4,Promise.all(n.map((function(e){return a.landmarkNet.detectLandmarks(e)})))];case 6:return o=i.sent(),n.forEach((function(e){return e instanceof et&&e.dispose()})),[2,e.map((function(e,t){return ld(e,o[t])}))]}}))}))},t.prototype.withFaceExpressions=function(){return new Sv(this,this.input)},t.prototype.withAgeAndGender=function(){return new Dv(this,this.input)},t.prototype.withFaceDescriptors=function(){return new Fv(this,this.input)},t}(jv),zv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.run=function(){return Th(this,void 0,void 0,(function(){var e,t,n,r,o;return Dh(this,(function(a){switch(a.label){case 0:return[4,this.parentTask];case 1:return(e=a.sent())?(t=e.detection,this.input instanceof et?[4,Mp(this.input,[t])]:[3,3]):[2];case 2:return r=a.sent(),[3,5];case 3:return[4,Dp(this.input,[t])];case 4:r=a.sent(),a.label=5;case 5:return n=r,[4,this.landmarkNet.detectLandmarks(n[0])];case 6:return o=a.sent(),n.forEach((function(e){return e instanceof et&&e.dispose()})),[2,ld(e,o)]}}))}))},t.prototype.withFaceExpressions=function(){return new Rv(this,this.input)},t.prototype.withAgeAndGender=function(){return new Mv(this,this.input)},t.prototype.withFaceDescriptor=function(){return new Bv(this,this.input)},t}(jv),Wv=function(e){function t(t,n){void 0===n&&(n=new Vd);var r=e.call(this)||this;return r.input=t,r.options=n,r}return Ah(t,e),t}(ov),Vv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ah(t,e),t.prototype.run=function(){return Th(this,void 0,void 0,(function(){var e,t,n,r;return Dh(this,(function(o){switch(o.label){case 0:return t=(e=this).input,(n=e.options)instanceof Md?[4,_v.mtcnn.forward(t,n)]:[3,2];case 1:return[2,o.sent().map((function(e){return e.detection}))];case 2:if(r=n instanceof rv?function(e){return _v.tinyFaceDetector.locateFaces(e,n)}:n instanceof Vd?function(e){return _v.ssdMobilenetv1.locateFaces(e,n)}:n instanceof ev?function(e){return _v.tinyYolov2.locateFaces(e,n)}:null,!r)throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return[2,r(t)]}}))}))},t.prototype.runAndExtendWithFaceDetections=function(){var e=this;return new Promise((function(t){return Th(e,void 0,void 0,(function(){var e;return Dh(this,(function(n){switch(n.label){case 0:return[4,this.run()];case 1:return e=n.sent(),[2,t(e.map((function(e){return cp({},e)})))]}}))}))}))},t.prototype.withFaceLandmarks=function(e){return void 0===e&&(e=!1),new Lv(this.runAndExtendWithFaceDetections(),this.input,e)},t.prototype.withFaceExpressions=function(){return new Cv(this.runAndExtendWithFaceDetections(),this.input)},t.prototype.withAgeAndGender=function(){return new Pv(this.runAndExtendWithFaceDetections(),this.input)},t}(Wv);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}Ah(t,e),t.prototype.run=function(){return Th(this,void 0,void 0,(function(){var e,t;return Dh(this,(function(n){switch(n.label){case 0:return[4,new Vv(this.input,this.options)];case 1:return e=n.sent(),t=e[0],e.forEach((function(e){e.score>t.score&&(t=e)})),[2,t]}}))}))},t.prototype.runAndExtendWithFaceDetection=function(){var e=this;return new Promise((function(t){return Th(e,void 0,void 0,(function(){var e;return Dh(this,(function(n){switch(n.label){case 0:return[4,this.run()];case 1:return e=n.sent(),[2,t(e?cp({},e):void 0)]}}))}))}))},t.prototype.withFaceLandmarks=function(e){return void 0===e&&(e=!1),new zv(this.runAndExtendWithFaceDetection(),this.input,e)},t.prototype.withFaceExpressions=function(){return new Iv(this.runAndExtendWithFaceDetection(),this.input)},t.prototype.withAgeAndGender=function(){return new Tv(this.runAndExtendWithFaceDetection(),this.input)}}(Wv);function Hv(e,t){return void 0===t&&(t=new Vd),new Vv(e,t)}!function(){function e(e,t){void 0===t&&(t=.6),this._distanceThreshold=t;var n=Array.isArray(e)?e:[e];if(!n.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");var r=1,o=function(){return"person "+r++};this._labeledDescriptors=n.map((function(e){if(e instanceof sp)return e;if(e instanceof Float32Array)return new sp(o(),[e]);if(e.descriptor&&e.descriptor instanceof Float32Array)return new sp(o(),[e.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>")}))}Object.defineProperty(e.prototype,"labeledDescriptors",{get:function(){return this._labeledDescriptors},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"distanceThreshold",{get:function(){return this._distanceThreshold},enumerable:!0,configurable:!0}),e.prototype.computeMeanDistance=function(e,t){return t.map((function(t){return function(e,t){if(e.length!==t.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var n=Array.from(e),r=Array.from(t);return Math.sqrt(n.map((function(e,t){return e-r[t]})).reduce((function(e,t){return e+Math.pow(t,2)}),0))}(t,e)})).reduce((function(e,t){return e+t}),0)/(t.length||1)},e.prototype.matchDescriptor=function(e){var t=this;return this.labeledDescriptors.map((function(n){var r=n.descriptors,o=n.label;return new ap(o,t.computeMeanDistance(e,r))})).reduce((function(e,t){return e.distance<t.distance?e:t}))},e.prototype.findBestMatch=function(e){var t=this.matchDescriptor(e);return t.distance<this.distanceThreshold?t:new ap("unknown",t.distance)},e.prototype.toJSON=function(){return{distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map((function(e){return e.toJSON()}))}},e.fromJSON=function(t){return new e(t.labeledDescriptors.map((function(e){return sp.fromJSON(e)})),t.distanceThreshold)}}();function Uv(e,t){var n=new Nh(t.width,t.height),r=n.width,o=n.height;if(r<=0||o<=0)throw new Error("resizeResults - invalid dimensions: "+JSON.stringify({width:r,height:o}));if(Array.isArray(e))return e.map((function(e){return Uv(e,{width:r,height:o})}));if(cd(e)){var a=e.detection.forSize(r,o),i=e.unshiftedLandmarks.forSize(a.box.width,a.box.height);return ld(cp(e,a),i)}return up(e)?cp(e,e.detection.forSize(r,o)):e instanceof np||e instanceof $h?e.forSize(r,o):e}const Gv={DETECTIONS_COUNT:0},qv="INIT_MODEL_DURATION",Xv="INIT_DETECTION_DURATION",Kv="AVERAGE_DETECTION_DURATION",$v="DETECTIONS_COUNT",Zv="FACES_COUNT",Yv="FACE_SCORE",Jv="BOX_SIZE",Qv="RELATIVE_BOX",em="CENTERING",om="IS_STABLE_INDEX",am="BRIGHTNESS_DETECTION_DURATION",im="BRIGHTNESS_VALUE",um=[Zv,Yv,Jv,Qv,em,om,am,im],fm=e=>Gv[e],ym=()=>Gv,_m=e=>{let{key:t,value:n}=e;Gv[t]=n},$m=async e=>{const t=performance.now();return{result:await e(),duration:performance.now()-t}},Ym=e=>{const t=(e=>{let{previousAverage:t=0,count:n=0,newValue:r}=e;return(t*n+r)/(n+1)})({previousAverage:fm(Kv),count:fm($v),newValue:e});_m({key:Kv,value:t}),Gv[$v]++},eg=new rv({inputSize:320,scoreThreshold:.6}),tg=async e=>{try{const{duration:t}=await $m((async()=>_v.tinyFaceDetector.loadFromUri(e)));return(e=>{_m({key:qv,value:e})})(t),null}catch(t){return t}},ng=async()=>{try{const{duration:e}=await $m((async()=>Hv(document.createElement("canvas"),eg)));return(e=>{_m({key:Xv,value:e})})(e),null}catch(e){return e}},rg=e=>{const t=.25*e.height,n=e.y-t>=0?e.y-t:0,r=.3*e.width,o=e.width-r,a=e.y-t>=0?e.height+t:e.height+e.y;return{x:e.x+r/2,y:n,width:o,height:a}},og=(e,t)=>{const n=document.createElement("canvas");n.width=e.videoWidth,n.height=e.videoHeight;const r=n.getContext("2d");r.drawImage(e,0,0);const o=rg(t);return r.getImageData(o.x,o.y,o.width,o.height)},ag=(e,t)=>{let{count:n,mean:r,m2:o}=e;n++;const a=t-r;r+=a/n;return o+=a*(t-r),{count:n,mean:r,m2:o}},ig=e=>{const{data:t}=e;let n={count:0,mean:0,m2:0};for(let r=0;r<t.length;r+=4)n=ag(n,t[r]),n=ag(n,t[r+1]),n=ag(n,t[r+2]);return{mean:n.mean,variance:n.m2/n.count}},sg={PORTRAIT:.65,LANDSCAPE:.6},ug=.08,cg=e=>Math.round(100*e)/100,lg=(e,t)=>e?l:t?f:"",fg=[e=>{let t="",n=!0;e.length||(t=a,n=!1);return{instructionCode:t,debugMessages:[{key:Zv,value:e.length}],canContinueOtherChecks:n}},e=>{let t="",n=!0;return e.length>1&&(t=i,n=!1),{instructionCode:t,debugMessage:[],canContinueOtherChecks:n}},function(e){let{videoElement:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="",r=!0;const o=[];if(t){const a=performance.now(),i=og(t,e[0].box),s=ig(i),u=performance.now();o.push({key:am,value:u-a}),o.push({key:im,value:s.mean});const c=s.mean<=50,l=s.mean>=200;n=lg(c,l),r=""===n}return{instructionCode:n,debugMessages:o,canContinueOtherChecks:r}},e=>{const[{score:t}]=e;return{instructionCode:"",debugMessages:[{key:Yv,value:`${cg(t)}`}]}},e=>{let t="";const[{imageWidth:n,imageHeight:r,box:o}]=e,i=o.x+o.width/2,s=o.y+o.height/2+-.15*o.height,u=n/2,c=r/2,l=.1*Math.min(n,r);(Math.abs(u-i)>l||Math.abs(c-s)>l)&&(t=a);const f=cg(i/n),h=cg(s/r);return{instructionCode:t,debugMessages:[{key:em,value:`x = ${f}; y = ${h}`}]}},e=>{let n="";const[{box:r}]=e;(r.width<200||r.height<200)&&(n=t);return{instructionCode:n,debugMessages:[{key:Jv,value:`${cg(r.height)} x ${cg(r.width)}`}]}},function(e){let{isPortraitCamera:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="";const[{relativeBox:a}]=e,i=n?"width":"height",s=n?"PORTRAIT":"LANDSCAPE",u=sg[s],c=u+ug,l=u-ug;a[i]>c&&(r=o),a[i]<l&&(r=t);const f=cg(a[i]),h=[{key:Qv,value:`[${i}]: ${f}`}];return{instructionCode:r,debugMessages:h}}],hg=fg,pg=(e,t)=>{const n=Math.max(...e),r=Math.min(...e);return Number((n-r).toFixed(2))>t},dg=e=>[pg(e.map((e=>e.x)),.02),pg(e.map((e=>e.y)),.02),pg(e.map((e=>e.size)),.02)].some(Boolean);let vg=[];const mg=(e,t,n)=>{const r=e[0],o=dg(vg),a=vg.length===t;(!n||o||a)&&(vg=[]),r&&(vg=[...vg,r])},gg=(e,t,n)=>!!n||!(e||!t),yg=(e,t)=>{let n="";return e||t||(n=s),n},bg=e=>e?null:{key:om,value:vg.length},wg=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{captureMethod:n,numberOfChecks:r,isCurrentFaceValid:o}=t;mg(e,r,o);const a=dg(vg),i=vg.length===r,s=n===d.MANUAL;return{isStable:gg(a,i,s),faceStableMessageCode:yg(a,i),debugMessage:bg(s)}},xg=(e,t)=>{um.forEach((e=>{delete Gv[e]}));const{isSingleFaceValid:n,singleFaceMessageCode:r}=function(){const e=[];for(let t=0;t<hg.length;t++){const n=hg[t],{instructionCode:r,debugMessages:o,canContinueOtherChecks:a=!0}=n(...arguments);if(r&&e.push(r),o&&o.forEach((e=>{_m(e)})),!a)break}return{isSingleFaceValid:!e.length,singleFaceMessageCode:e.length?e[0]:""}}(e,t),{isStable:o,faceStableMessageCode:a}=function(){const e=wg(...arguments),{debugMessage:t}=e;return t&&_m(t),e}(e,{...t,isCurrentFaceValid:n});return{isValid:n&&o,messageCode:r||a}},Eg=e=>Object.entries(e).map((e=>{let[t,n]=e;const r=(e=>e.replace(/_/g," ").toLowerCase())(t),o=(e=>"number"==typeof e?Math.ceil(e):e)(n);return`${r}: ${o}`}));if(typeof window!==[]+[][[]])var _g=window;else if(typeof global!=""+[][[]])_g=global;else _g=void 0;function Og(e,t){return e*t}var kg,Cg,Ig,Sg,Rg,Ag,Pg,Tg,Dg,Mg,Ng,Fg,Bg,jg,Lg,zg,Wg,Vg,Hg,Ug,Gg,qg,Xg,Kg,$g,Zg,Yg,Jg,Qg,ey,ty,ny,ry,oy,ay,iy,sy,uy,cy,ly,fy,hy,py,dy,vy,my,gy,yy,by,wy,xy,Ey,_y,Oy,ky,Cy,Iy,Sy,Ry,Ay,Py,Ty,Dy,My,Ny,Fy,By,jy,Ly,zy,Wy,Vy,Hy,Uy,Gy,qy,Xy,Ky,$y,Zy,Yy,Jy,Qy,eb,tb,nb,rb,ob,ab,ib,sb,ub,cb,lb,hb,pb,db,vb,mb,yb,bb,xb,_b,Ob,kb,Ib,Sb,Rb,Tb,Db,Nb,Fb,Bb,jb,zb,Wb,Vb,Hb,qb,Xb,Kb,$b,Zb,Qb,ew,tw,nw,rw,ow,aw,iw,sw,uw,cw,lw,fw,hw,pw,dw,vw,mw,gw,yw,bw,ww,xw,Ew,_w,Ow,kw,Cw,Iw,Sw,Rw,Aw,Pw,Tw,Dw,Mw,Nw,Fw,Bw,jw,Lw,zw,Ww,Vw,Hw,Uw,Gw,qw,Xw,Kw,$w,Zw,Yw,Jw,Qw,ex,tx,nx,rx,ox,ax,ix,sx,ux,cx,lx,fx,hx,px,dx,vx,mx,gx,yx,bx,wx,xx,Ex,_x,Ox,kx,Cx,Ix,Sx,Rx,Ax,Px,Tx,Dx,Mx,Nx,Fx,Bx,jx,Lx,zx,Wx,Vx,Hx,Ux,Gx,qx,Xx,Kx,$x,Zx,Yx,Jx,Qx,eE,tE,nE,rE,oE,aE,iE,sE,uE,cE,lE,fE,hE,pE,dE,vE,mE,gE,yE,bE,wE,xE,EE,_E,OE;function kE(e,t){return"number"==typeof t?e==t+Ly:e==t}function CE(e,t){switch(e){case kg:for(var n=t[Ly],r=bb,o=bb;RE(o,n.length);++o){var a=n.charCodeAt(o);(RE(a,By)||ME(a,Ry))&&(r=WE(r,ub))}return r;case Dy:for(var i=WE([],[]),s=LE(t[ub],Bb),u=bb;RE(u,t[bb].length);u++){var c=[t[bb].charCodeAt(u),eb.mb.charCodeAt(s++)];i+=UE(Ag,[qE(FE($E(c[bb]),$E(c[ub])),FE(c[bb],c[ub]))])}return i;case Tg:var l,f,h=function(){GE(function(e,t){return TE.apply(this,[uy,arguments])}(this,h)),this[Fm.call(null,"^\r[6T",Dw)]=HE(Gy,[lm("SV\nC",aw),null,km(" :>9",hy),null,pm.apply(null,["NT4PG",Mw]),null,vm("< ",Nw),null])};return l=h,f=[HE(Gy,[Im("Q'H",Pw),"startCamera",Nm.apply(null,["\0BB3",Fw,[Ob,"&\rM \\"]]),function(){return TE.apply(this,[my,arguments])}]),HE(Gy,[wZ("\n&",$w),MZ("'\rU|KE",qg),dm("UF",Rw),function(){return TE.apply(this,[Tg,arguments])}]),HE(Gy,[wZ("\n&",$w),BZ("VQ*49C[1",ox),jZ.apply(null,["L#]A;",ax]),function(){return TE.apply(this,[Py,arguments])}]),HE(Gy,[NZ.apply(null,["V",Rg,[Fb,"EO-\0"]]),Am(Ox,vb,Hb),jZ("L#]A;",ax),function(){return TE.apply(this,[Qg,arguments])}]),HE(Gy,[Im.call(null,"Q'H",Pw),Cm(Mx,Nx,Ob),Nm.call(null,"\0BB3",Fw,"BE#/z"),function(e){return CE.apply(this,[by,arguments])}])],f&&TE(Ny,[l[Om("D,,B\rC2T",xw)],f]),_g[wb.apply(null,["\v00#",wE,xE])][Rm("VMK$A!\n.,",Aw," TI")](l,Om.apply(null,["D,,B\rC2T",xw]),HE(Gy,[Mb.call(null,"\0*D\r[ ]Q",Gg),GE(ub)])),h;case Lg:r=t[Ly],t[Hy],t[qy];var p=t[$y],d=t[Uy],v=t[Ky];NE(typeof v,_E[lb])&&(v=Qy);var m=WE([],[]);for(Jy=p;ME(r,bb);){if(IE(d[_E[cb]],_g[_E[bb]])&&KE(d,v[_E[ub]]))return kE(v,Qy)&&(m+=HE(py,[Jy])),m;if(NE(d[_E[cb]],_g[_E[bb]])){var g=OE[v[d[bb]][bb]];m+=y=CE(Lg,[r,GE(GE(bb)),GE(GE({})),Jy,d[ub],g]),d=d[bb],r-=CE(kg,[y])}else if(NE(v[d][_E[cb]],_g[_E[bb]])){var y;g=OE[v[d][bb]];m+=y=CE.call(void 0,Lg,[r,GE(bb),"%^{8M.Xz7",Jy,bb,g]),r-=CE(kg,[y])}else m+=HE(py,[Jy]),Jy+=v[d],--r;++d}return m;case Pg:var b=t[Ly],w=t[Hy],x=_g[R3("7N\fW'_@",oE)][h3("H'P@;24H_,E",Hx)](pm.apply(null,["NT4PG",Mw])),E=x[I3("%T@6YB6",wx)](H3("yU",aE,tw)),_=w[F3(":B",Hg)],O=w[l3("W7=:\f\n>&K|IM",iE)],k=w[cZ("R15L\r",Tw)],C=w[A3("-LS6H",Fx)],I=w[w3("LL>IV%CNB\v",Lx)];return new(_g[k3("u; ",zw)])((function(e){var t=new(_g[p3("zDK",sE,"\nG\b2Z")]);t[v3("]BJ",ex,Kb)]=function(){var n=function(e,t,n){return CE.apply(this,[$y,arguments])}(O,_||function(e,t){return CE.apply(this,[Oy,arguments])}(t,I),HE(Gy,[n3.apply(null,["NO!T-2!",fE,[Ob]]),t[Pm(dx,vx,db)],"imageWidth",t[kZ("3>!(",Ex,[Bb,"W%?\nq"])]])),r=n.topLeftXCoord,o=n.topLeftYCoord,a=n[HZ("5XP*",wx)],i=n[Pm(Vg,vx,db)];x[kZ("3>!(",Ex,Db)]=a,x[Pm(dx,Dg,db)]=i,E[Um(jg,bb,mb)](t,r,o,a,i,bb,bb,a,i),e(HE(Gy,[Yb('ASK"9&V',ow,";>%3"),x[fb("6^p?9x+v",pE)](Lb("NO!d",dE,[hb,"EO-\0"])[gb("!^Z=,",vE)](k),C)]))},t[Pb.apply(null,["]4",tE,'"10]'])]=b}));case Dg:var S=t[Ly];return eb=function(){return CE.apply(this,[Dy,arguments])},sb(S);case Oy:var R=t[Ly],A=t[Hy],P=A?jy[cb]:jy[ub],T=A?jy[hb]:jy[lb];return HE(Gy,[c3.call(null,"]",cE),DE(Og(jy[pb],R[kZ("3>!(",Ex,Mg)]),AE(Og(P,R[Pm(Vg,vx,db)]),cb)),W3("W",lE,"3!C<N"),Og(T,R[Pm(dx,vx,db)]),Pm(dx,vx,db),Og(P,R[Pm(dx,vx,db)]),HZ("5XP*",Iy),Og(P,R[Pm(dx,vx,db)])]);case $y:var D=t[Ly],M=t[Hy],N=t[qy],F=Og(cb,D),B=DE(M[N3("",ex)],Og(D,M[HZ("5XP*",wx)]))<bb?bb:M[N3.call(null,"",ex)]-Og(D,M[KZ.call(null,"@",px)]),j=RE(DE(M[x3.call(null,"-",uE)],Og(F,M[Pm(dx,vx,db)])),bb)?bb:DE(M[x3.call(null,"-",uE)],Og(F,M[Pm(dx,vx,db)])),L=IE(bb,B)?WE(M[HZ("5XP*",wx)],Og(M[HZ.call(null,"5XP*",wx)],Og(qy,D))):WE(M[kZ.call(null,"3>!(",Ex,[Hb,";>%3"])],M[c3("]",cE)])+M[kZ("3>!(",Ex,"\v\nV6G")]*D,z=IE(bb,j)?WE(M[Pm(dx,vx,db)],Og(M[Pm(Vg,vx,Wy)],WE(D,F))):WE(WE(M[Pm(dx,vx,db)],M[W3.call(null,"W",lE,[hb,"EO-\0"])]),Og(M[Pm(dx,vx,Wy)],D));return z=z+j>N[n3("NO!T-2!",fE,[kb,"#"])]?DE(N[V3("XY?=eS%Y@",hE)],j):z,HE(Gy,["topLeftXCoord",B,"topLeftYCoord",j,kZ.apply(null,["3>!(",Ug,[pb,"H'.nu"]]),L=ME(WE(L,B),N.imageWidth)?DE(N.imageWidth,B):L,Pm(dx,vx,db),z]);case Ty:var W=t[Ly],V=t[Hy],H=_g[SZ.apply(null,["AP\rSJ",lx])][h3.call(null,"H'P@;24H_,E",Hx)](pm.call(null,"NT4PG",Mw)),U=H[m3.apply(null,['DK23$_0"!',Fb,[fw]])](XZ.apply(null,["K",gx])),G=V[Z3.call(null,".]%\f3#%)B.CMI",cy,Hb)],q=V[U3("L\\+?",Ux," TI")],X=V[b3("-LS6Hb?-H",Gx)];return new(_g[T3("j0^Y7=",qx)])((function(e){var t=new(_g[B3("BZ",Ig)]);t[j3.apply(null,["^Z29I",Xx])]=function(){var n=_g[q3("&G",Kx,Kb)][O3.apply(null,["LS",$x])](Og(G,t[HZ.call(null,"5XP*",wx)]));H[HZ("5XP*",wx)]=DE(t[KZ.call(null,"@",px)],Og(cb,n)),H[Pm(dx,vx,db)]=t[Pm(dx,vx,db)],U[Um(nw,bb,mb)](t,n,bb,H[HZ("5XP*",wx)],H[Pm(dx,vx,db)],bb,bb,H[HZ("5XP*",wx)],H[Pm(dx,vx,db)]),e(HE(Gy,[s3.apply(null,["*B\tJ'U}3",Zx]),H[L3("\v/G\b#qb",Sg," TI")](Q3("H3f",Yx)[z3("@A(*E",Jx,[Hb,";>%3"])](q),X)]))},t[t3.call(null,"\0",Qx)]=W}));case by:var K=t[Ly],$=this,Z=K[U3("L\\+?",ry,Ob)],Y=K[A3.call(null,"-LS6H",Fx)],J=K[C3.call(null,"F\v",Bx)],Q=K[J3("_V#E](L\v]+_w,(]T%",jx)],ee=K[w3.call(null,"LL>IV%CNB\v",Lx)],te=K[M3('Z5QA6\0"_#',zx,"@\b4M")];return new(_g[G3("\n'/O",Wx,[lw])])((function(e,t){var n=$[Am(Ox,vb,Hb)](HE(Gy,[cZ("R15L\r",Tw),Z,E3("V\f\nL",Vx),Y]));te?function(e,t){return CE.apply(this,[Pg,arguments])}(n,HE(Gy,[C3("F\v",Bx),J,Ub("\\#*E-?!A\n.CMI",mE,lb),Q,cZ("R15L\r",Tw),Z,A3("-LS6H",Fx),Y,Ab("Z&L\\2*X0;;8%G",gE,"\f\0lX"),ee]))[Cb("@66",yE)]((function(t){var n=t[s3("*B\tJ'U}3",Zx)];e(HE(Gy,[K3("H",nE),n]))}))[Jb.call(null,";L\rY*",bE)]((function(e){t(e)})):ee?e(HE(Gy,[X3("S/V",ax),n])):function(e,t){return CE.apply(this,[Ty,arguments])}(n,HE(Gy,[S3("U\vQ\v3\f7\n-;\t\vLQ\t",eE),.12,cZ.call(null,"R15L\r",Tw),Z,nZ.call(null,"_3'X0",Ix,[hw]),Y]))[D3.call(null,"Z.%",tE,"\rX\f)")]((function(t){var n=t[r3("D\v\bU$4",cx)];e(HE(Gy,[K3("H",nE),n]))}))[d3("\f[",rE,"EO-\0")]((function(e){t(e)}))}))}}function IE(e,t){return e!==t}function SE(){return TE.apply(this,[Vy,arguments])}function RE(e,t){return e<t}function AE(e,t){return e/t}function PE(e){return-e}function TE(e,t){switch(e){case Ny:for(var n=t[Ly],r=t[Hy],o=bb;RE(o,r[Sm(",\tH\v",Cw,Kb)]);o++){var a=r[o];a[Dm("'_A3*LV'",kb)]=a[rm("4 -\tT",Iw,[Qb])]||GE(ub),a[Km.call(null,'@A("V1\n;7,\t',Sw,[Nb])]=GE(bb),dm.call(null,"UF",Rw)in a&&(a[Xm("(-=\rGS\v",gy)]=GE(bb)),_g[bm.call(null,")G5=",gw)][Rm("VMK$A!\n.,",Aw,[Bb])](n,a[Im.call(null,"Q'H",Pw)],a)}break;case zy:for(var i=t[Ly],s=t[Hy],u=Em.apply(null,["",sw]),c=bb;RE(c,i[Mm("IZ\0A",aw)]);c=WE(c,ub)){u+=s[i[hm("\bR7W",uw,pb)](c)]}return u;case My:var l={8:"4",E:"7",H:".",X:"9",e:"5",g:"1",l:"2"};return function(e){return TE(zy,[e,l])};case ty:return"wJ57F[p7Dgn!NfAZzkQ,/H^Ovt\\oz7o";case Vy:var f=t[Ly],h=t[Hy],p=TE(ty,[]),d=WE([],[]),v=DE(f.length,ub);if(KE(v,bb))do{var m=LE(WE(v,h),p.length),g=[f.charCodeAt(v),p.charCodeAt(m)];d+=UE(Ag,[FE(qE($E(g[bb]),g[ub]),qE($E(g[ub]),g[bb]))]),v--}while(KE(v,bb));return UE(Zg,[d]);case uy:var y=t[Ly],b=t[Hy];if(GE(y instanceof b))throw new(_g[Hm.call(null,"`'=h\vH-C",Tw)])(Lm(Vb,fw,Wb));break;case my:var w=this,x=ME(t[mm("_,V@6",Fy)],bb)&&IE(XE(bb),t[bb])?t[bb]:{},E=x[xm('UG"$',Bw,[Db,"\v\nV6G"])],_=x[cm.call(null,".D_-r[0,_S,EG",jw)],O=x[Wm.call(null,"P9",Lw)],k=IE(void 0,O)&&O,C=x[nm("O&X[6^\rH#XZ*",zw)];this[Vm("\nQ",Ww)][lm("SV\nC",yy)]=E;var I=HE(Gy,[YZ.call(null,"(<H",Vw),NE(XE(bb),_)||_]);return k&&(I[fZ("O&X[",Hw)]=NE(XE(bb),C)||C),_g[LZ("MFD$",Uw)][gZ("L93?:\n,",Gw)][PZ("T\fv]#T ;",qw,[Ob])](I)[UZ("KC",Xw)]((function(e){return w[Fm("^\r[6T",Dw)][AZ("+Y\v_#\\",Jg)]=e,w[CZ("@WK",Rw,"EO-\0")][xm.apply(null,['UG"$',Bw,[tw,'"10]']])][JZ(":! =51",Kw)]=e,e}));case Tg:var S=this[Vm.apply(null,["\nQ",Ww])][GZ("\v^",Zw,[yb,'"10]'])];S&&(S[EZ("]'Eb7=B-H#R_-",Yw)]&&S[hZ('\bVbR\tq5" ',Jw)]?(S[mZ.apply(null,["81\r-L[\vI'E",ex])]()[ZZ("",tx,Ob)]((function(e){S[bZ("\v_/^B;#*LQ",nx)](e),e[gm(Qw,Nb,hb)]()})),S[hZ('\bVbR\tq5" ',Jw)]()[ZZ.call(null,"",tx,"H'.nu")]((function(e){S[TZ.apply(null,["\v\vJ\0;2",rx])](e),e[gm(Qw,Nb,hb)]()}))):S[gm(Qw,Nb,hb)]());break;case Py:var R=ME(t[Sm.apply(null,[",\tH\v",Cw,"-P/d"])],bb)&&IE(XE(Ly),t[bb])?t[bb]:{},A=R[qZ("D\nw+CF1",dy)],P=IE(XE(bb),A)&&A,T=R[OZ("\tGMT\ba3' \x001,",ix)],D=R[sZ.call(null,";(4<20;\rLQ\t",sx)];if(GE(this[Vm("\nQ",Ww)][xm('UG"$',Bw," TI")]))return null;var M=this[CZ("@WK",zg,hw)][lm("SV\nC",aw)][QZ("TJC\b1L\t>",Rb)],N=this[Fm("^\r[6T",Dw)][YZ("(<H",Vw)][zZ.apply(null,["O#ZW",ux,[cw]])];this[CZ("@WK",Rw,[vb])][tZ(";;6\rU",cx,[_b])]=_g[SZ("AP\rSJ",lx)][DZ("7\vDK\vcI",fx)](rZ.apply(null,["E",hx])),this[CZ("@WK",Rw,[Bb])][tZ(";;6\rU",cx,Qb)][KZ("@",px)]=(kE(null,T)?XE(bb):T[KZ("@",wy)])||M,this[Fm.call(null,"^\r[6T",Dw)][pm("NT4PG",Mw)][Pm(dx,vx,db)]=(null==T?XE(bb):T[Pm(dx,Dg,db)])||N,this[CZ("@WK",Rw,mb)][vm("< ",Nw)]=this[Vm("\nQ",Ww)][tZ(";;6\rU",cx,[mb])][dZ("\"\n<:' ",mx)](XZ("K",gx));var F=this[Vm.call(null,"\nQ",Ey)],B=F[RZ(";Y",yx)],j=F[rZ.apply(null,["E",hx])];return P&&(B[IZ("7' +:",bx)](j[HZ("5XP*",wx)],bb),B[FZ("+NV'",xx)](PE(Hy),ub)),B[lZ.call(null,"\n\f\f`LZ.%V;7,\tB",Qg,[mb,"W%?\nq"])]=D,B[Um(nw,bb,mb)](this[CZ("@WK",Rw,tw)][xm('UG"$',Bw,"U\bFqw")],Ly,bb,(kE(null,T)?XE(bb):T[KZ.apply(null,["@",px])])||j[kZ.apply(null,["3>!(",Ex,kb])],(kE(null,T)?XE(bb):T[Pm(dx,vx,db)])||j[Pm(dx,vx,db)]),P&&(B[pZ.call(null,"U\0",Tw,oy)](PE(ub),ub),B[vZ("Y\v[,BX?=",_x)](PE(j[KZ("@",px)]),bb)),j;case Qg:var L=ME(t[mm("_,V@6",dw)],bb)&&IE(XE(bb),t[bb])?t[bb]:{},z=L[xZ.apply(null,["2::\nJQ",kx])],W=L[cZ("R15L\r",Tw)],V=NE(XE(bb),W)?WZ.apply(null,["!A!",Cx,"3!C<N"]):W,H=L[nZ("_3'X0",Ix,$y)],U=NE(XE(bb),H)?jy[bb]:H,G=L[VZ("S/PS;$5BN*XZ9",Sx)],q=NE(XE(bb),G)||G;if(GE(this[Vm("\nQ",Ww)][GZ("\v^",ny,[yb,'"10]'])]))return null;var X=this[Y3(")3=)>'",Rx)](HE(Gy,[f3.call(null,"<D_,B]1+",Ax),z,VZ("S/PS;$5BN*XZ9",Sx),q]));return X&&X[L3("\v/G\b#qb",Px,[tw])](g3("5L_m",Tx)[P3("0<> ",Dx)](V),U)}}function DE(e,t){return e-t}function ME(e,t){return e>t}function NE(e,t){return e===t}function FE(e,t){return e|t}function BE(e,t){return e<=t}function jE(e,t){switch(e){case Xy:for(var n=t[Ly],r=DE(n[_E[ub]],ub);KE(r,bb);--r)_g[n[r]]=function(){var e=n[r];return function(t,n,r){var o=HE.call(void 0,Wg,[r,"c?Nv6X",n,pw,t,dw]);return _g[e]=function(){return o},o}}();break;case Xg:return new tb;case zy:var o=t[Ly];sb();for(r=bb;RE(r,o.length);)_g[o[r]]=function(){var e=o[r];return function(){var t=eb.apply(void 0,arguments);return _g[e]=function(){return t},t}}(),++r;break;case Cy:var a=t[Ly],i=WE([],[]),s=LE(t[ub],Nb);for(r=bb;RE(r,a.length);r++){var u=[a.charCodeAt(r),nb.Zb.charCodeAt(s++)];i+=UE(Ag,[qE($E(qE(u[bb],u[ub])),FE(u[bb],u[ub]))])}return i;case Yg:var c=t[Ly];return nb=function(e){return jE.apply(this,[Cy,arguments])},Yy(c);case uy:for(var l=t,f=l[bb],h=ub;RE(h,l[mm("_,V@6",dw)]);h+=cb)f[l[h]]=l[WE(h,ub)]}}function LE(e,t){var n=[e,t,"PUOUYx",Ly];return"number"==typeof e?(n[Ly]+n[$y])%n[Hy]:n[Ly]%n[Hy]}function zE(e,t){switch(e){case sy:Yy=function(){return zE.apply(this,[$g,arguments])},eb=function(e,t){return zE.apply(this,[Ng,arguments])},ob=function(){return zE.apply(this,[Ay,arguments])},nb=function(e,t){return UE.apply(this,[_y,arguments])},sb=function(){return UE.apply(this,[Dg,arguments])},HE(vy,[]),HE.call(this,ay,[UE(iy,[])]),jE.call(this,zy,[UE(Ng,[])]),HE.call(this,Kg,[UE(ey,[])]),_E=["Array","length","constructor","number","apply","fromCharCode","String"],Qy=HE(Dy,[]),HE(Xy,[]),jE(Xy,[HE(Cy,[])]),jy=HE(Ny,[["HXl","HE","H8e","Hg","Hle","He"],GE(GE(bb))]),ab=HE(Gy,[Zm("7",mw),(e,t)=>{for(var n in t)ab.o(t,n)&&GE(ab.o(e,n))&&_g[bm(")G5=",gw)][Tm("7\t611)\tJO\vT\b",yw)](e,n,HE(Gy,[Bm("GMRD3",bw),GE(bb),jm.apply(null,["VQ*",sw]),t[n]]))},qm.call(null,"",ww),(e,t)=>_g[bm(")G5=",ky)][Om("D,,B\rC2T",xw)][sm.call(null,"QlP7J$=*",Ew)].call(e,t)]),ib={},ab[Qm("$",_w,"-P/d")](ib,HE(Gy,[zm("*",Ow),()=>tb,tm("#",kw),()=>Zy])),tb=function(){return CE.apply(this,[Tg,arguments])}(),Zy=function(){return jE.apply(this,[Xg,arguments])},ib[Gb.call(null,"J",EE)],rb=ib[Eb.call(null,"k",Rb)];break;case $y:for(var n="",r=DE((s=t[Ly]).length,ub);KE(r,bb);)n+=s[r],r--;return n;case Sy:var o=t[Ly];for(nb.Zb=UE(xy,[o]);RE(nb.Zb.length,xb);)nb.Zb+=nb.Zb;break;case $g:Yy=function(e){return zE.apply(this,[Sy,arguments])},nb("I\b9Wj-:XV@L",mb);break;case Ly:return',N.wk$r"aYGakSZ+Okjr}i$K%';case Ng:var a=t[Ly],i=t[Hy],s=zE(Ly,[]);for(n=WE([],[]),r=DE(a.length,ub);KE(r,bb);r--){var u=LE(WE(r,i),s.length),c=[a.charCodeAt(r),s.charCodeAt(u)];n+=UE(Ag,[qE(FE($E(c[bb]),$E(c[ub])),FE(c[bb],c[ub]))])}return CE(Dg,[n]);case Qg:n="";if(KE(r=DE((s=t[Ly]).length,ub),bb))do{n+=s[r],r--}while(KE(r,bb));return n;case Yg:o=t[Ly];for(SE.hb=UE(xy,[o]);RE(SE.hb.length,tw);)SE.hb+=SE.hb;break;case Ay:ob=function(e){return zE.apply(this,[Yg,arguments])},TE(Vy,["p9yc{",_b]);break;case oy:return"5?'!,KdIxzw~"}}function WE(e,t){return e+t}function VE(e,t){return e>>t}function HE(e,t){switch(e){case py:var n=t[Ly];return BE(n,Cg)?_g[_E[db]][_E[pb]](n):(n-=Fg,_g[_E[db]][_E[pb]][_E[hb]](null,[WE(VE(n,yb),By),WE(LE(n,fy),Bg)]));case vy:bb=+[],xb=(ub=1)+(vb=(pb=(cb=ub+ub)-ub+(hb=ub+(lb=ub+cb)))*cb+hb-(db=lb+pb-cb))*pb+cb,Ob=db*cb+(_b=cb*ub*hb+pb-db)-pb,kb=hb+lb+ub+(mb=cb*db-vb+pb),Ib=vb*lb+cb-hb,Sb=ub*db*pb+_b+mb,Rb=(yb=cb-ub+mb)-ub-pb+hb*vb,Tb=yb+pb+mb-lb*hb,Db=lb*db+mb-ub-_b,Nb=mb+lb+yb-pb+hb,Fb=_b+yb-hb+mb+lb,Bb=pb*mb-ub-cb*_b,jb=_b+lb*pb-ub-vb,zb=yb*mb-vb+cb,Vb=cb*(Wb=pb*ub*vb-_b)-hb-ub+db,Hb=mb+db-yb+cb*lb,qb=vb*db+Wb-mb+hb,Xb=lb+_b+mb*db+ub,Kb=lb-vb-ub+hb*db,$b=lb*_b*hb-cb+ub,Zb=yb+hb*lb*pb,Qb=db-mb+yb+hb*cb,ew=Wb+mb+vb-cb,tw=_b+mb+pb*lb,rw=mb+_b*ub*hb+(nw=vb*pb-lb+mb*_b),ow=vb+cb*nw-hb+db,aw=cb+yb*nw-vb-mb,iw=hb*_b*Wb+vb+lb,sw=nw-yb+db*mb*vb,uw=db*nw+ub+_b,cw=ub+lb*_b+yb-mb,lw=db*hb-mb+pb,fw=cb+db-lb+mb+yb,hw=vb*cb+lb*pb-hb,pw=vb*db+pb*lb,dw=_b+mb*db+hb*cb,vw=_b+cb*yb+Wb*ub,mw=Wb*mb+nw+yb*_b,gw=hb*Wb+pb*nw+mb,yw=Wb*_b-cb-yb+vb,bw=hb+Wb*_b+cb+mb,ww=_b*lb*Wb+pb-cb,xw=ub+hb+yb*_b*cb,Ew=_b*nw+hb-yb,_w=cb+Wb+_b*mb*yb,Ow=vb*nw+hb-Wb+cb,kw=pb*_b+hb*lb*mb,Cw=pb-Wb+mb*_b*vb,Iw=vb*_b*yb-lb,Sw=cb+mb*nw-hb-Wb,Rw=Wb+yb*vb*mb+hb,Aw=cb*Wb+mb*nw,Pw=Wb+db*mb*vb+yb,Tw=_b+lb+mb*vb*yb,Dw=vb+_b*Wb-db*lb,Mw=mb+yb*nw-Wb+ub,Nw=db-pb*ub+vb*nw,Fw=nw+hb-cb+lb*mb,Bw=db*nw+hb*vb*pb,jw=yb+cb*vb*lb,Lw=vb-_b+yb+mb*nw,zw=db+mb*hb*_b*lb,Ww=hb*vb+_b*ub,Vw=yb+pb*Wb-cb,Hw=yb*nw+db-cb*pb,Uw=_b*db+pb+nw*vb,Gw=Wb+yb+nw*pb+db,qw=pb*Wb*lb-cb-mb,Xw=yb+nw*_b-lb*vb,Kw=pb*db+nw*vb-hb,$w=db+Wb*ub*_b*cb,Zw=lb-mb+pb*nw+db,Yw=cb*nw-ub+yb*Wb,Jw=nw*yb-hb*ub*mb,Qw=nw+db+mb,ex=yb*Wb*cb-vb-ub,tx=Wb*_b*cb+nw*pb,nx=pb+hb*_b+mb*Wb,rx=cb*lb*Wb*pb+mb,ox=pb+mb*yb*hb-db,ax=mb*nw+yb-_b+hb,ix=yb*nw+db-cb*_b,sx=Wb-lb+nw*_b+hb,ux=mb*cb*hb*lb-Wb,cx=yb*Wb+pb*mb-_b,lx=nw*lb-vb+mb-db,fx=_b-hb-ub+vb*nw,hx=Wb+pb+nw*mb-vb,px=pb+Wb*hb*_b*ub,dx=cb+Wb+mb*_b+db,vx=yb+mb*cb-vb-hb,mx=ub+_b*pb+hb+Wb,gx=nw*vb-yb-ub,yx=pb*yb-ub+mb*nw,bx=db*_b+nw*mb+ub,wx=vb*db*yb+hb+ub,xx=Wb*lb*_b+hb+mb,Ex=pb*yb*mb+ub,_x=hb*vb+Wb*db*lb,Ox=mb+nw+yb-lb,kx=Wb*pb*db-mb-lb,Cx=_b-mb-cb+db*nw,Ix=db*hb+nw*vb,Sx=nw*db-lb-pb,Rx=nw*pb-yb-lb*mb,Ax=_b*hb-db+mb*nw,Px=hb+cb*ub+db*nw,Tx=nw*mb-cb+pb,Dx=db*nw-cb-yb-ub,Mx=yb*cb-vb+nw,Nx=cb*vb*pb-Wb+mb,Fx=vb*db*pb*cb-mb,Bx=mb*pb*db*ub*cb,jx=Wb+yb-_b+pb*nw,Lx=nw+mb+db*vb*cb,zx=Wb+mb+cb*vb*hb,Wx=hb*nw+_b+mb-pb,Vx=_b*lb+cb+yb+pb,Hx=db+hb*Wb-pb*lb,Ux=Wb*lb*db-vb-nw,Gx=yb*db*vb+lb*Wb,qx=lb-mb+nw*cb-_b,Xx=cb+_b*nw+hb*mb,Kx=ub+vb*mb-hb-_b,$x=hb*lb*mb+pb,Zx=Wb-yb+mb*nw-cb,Yx=yb*_b*hb+nw-mb,Jx=nw*mb+yb*_b,Qx=Wb*_b+pb+ub+db,eE=vb+_b*hb*lb*yb,tE=pb*cb*mb*_b-nw,nE=mb-yb+vb*db*hb,rE=db+ub+pb*hb*yb,oE=yb+vb*nw+db-lb,aE=cb*ub-_b+yb*nw,iE=Wb*cb+yb-hb,sE=nw*lb*cb-Wb+ub,uE=nw*yb-cb*mb,cE=db-ub+vb*yb*hb,lE=yb-db+hb*nw,fE=pb*_b*db*hb+lb,hE=cb*hb+lb+nw*_b,pE=ub-cb+mb*vb*db,dE=nw*mb+vb*db,vE=cb*db*Wb-yb*ub,mE=_b*mb*yb-vb*cb,gE=db*mb*lb+_b,yE=vb+hb*pb*Wb-yb,bE=vb-Wb+ub+nw*yb,wE=_b+mb*nw+db,xE=vb*lb*ub+mb-pb,EE=mb*yb*vb+pb+ub;break;case Dy:return[Ob,PE(kb),Ib,PE(Sb),Rb,PE(Tb),db,PE(cb),PE(Db),yb,PE(db),PE(Nb),Fb,PE(db),kb,[bb],PE(lb),hb,PE(cb),ub,Tb,ub,PE(pb),ub,Bb,jb,bb,ub,pb,PE(zb),Vb,PE(cb),Hb,bb,PE(qb),Xb,PE(Xb),Vb,mb,PE(Hb),Kb,bb,PE($b),Xb,Kb,PE($b),Xb,PE(Xb),Zb,Qb,PE(_b),PE(Hb),kb,PE(Hb),db,PE(ub),cb,PE(lb),PE(Tb),cb,Ob,bb,PE(ew),Bb,Qb,hb,[bb]];case Xy:OE=[[ub,PE(lb),PE(jb)]];break;case Wg:var r=t[Ly],o=t[Hy],a=t[qy],i=t[$y],s=t[Uy],u=t[Ky];return CE(Lg,[r,i,o,s,a,u]);case Cy:return["Lm","Um","Pm","Cm","gm","Am"];case Kg:var c=t[Ly];ob();for(var l=bb;RE(l,c.length);++l)_g[c[l]]=function(){var e=c[l];return function(){var t=SE.apply(void 0,arguments);return _g[e]=function(){return t},t}}();break;case Ny:for(var f=t[Ly],h=t[Hy],p=[],d=TE(My,[]),v=h?_g[wm(">Z?MZ",ow,"*Z!'k")]:_g[Jm.apply(null,[".*^|.^U*",rw])],m=bb;RE(m,f[Mm.call(null,"IZ\0A",aw)]);m=WE(m,ub))p[Gm.call(null,"WPO",iw)](v(d(f[m])));return p;case ay:c=t[Ly];if(Yy(),RE(l=bb,c.length))do{_g[c[l]]=function(){var e=c[l];return function(){var t=nb.apply(void 0,arguments);return _g[e]=function(){return t},t}}(),++l}while(RE(l,c.length));break;case Gy:for(var g={},y=t,b=bb;RE(b,y[Mm("IZ\0A",aw)]);b+=cb)g[y[b]]=y[WE(b,ub)];return g}}function UE(e,t){switch(e){case _y:for(var n=t[Ly],r=t[Hy],o=zE(oy,[]),a=WE([],[]),i=DE(n.length,ub);KE(i,bb);i--){var s=LE(WE(i,r),o.length),u=[n.charCodeAt(i),o.charCodeAt(s)];a+=UE(Ag,[qE($E(qE(u[bb],u[ub])),FE(u[bb],u[ub]))])}return jE(Yg,[a]);case xy:for(a="",i=DE((o=t[Ly]).length,ub);KE(i,bb);)a+=o[i],i--;return a;case ly:var c=t[Ly];for(eb.mb=UE(xy,[c]);RE(eb.mb.length,vw);)eb.mb+=eb.mb;break;case Dg:sb=function(e){return UE.apply(this,[ly,arguments])},eb("O))D)IIUBnSQg$K-}5 <DT=|X",Hb);break;case iy:return["H3","wm","p3","q3","wb","G3","tZ","d3","hm","z3","Km","Yb","Qm","Rm","rm","U3","m3","PZ","Lb","n3","lZ","M3","Ab","WZ","NZ","Sm","ZZ","v3","nZ","Z3","Ub","pZ","Pb","CZ","GZ","D3","L3","Nm","xm","zZ","kZ","W3"];case Ng:return["Em","XZ","B3","bm","k3","tm","Y3","Wm","C3","rZ","O3","P3","DZ","r3","vm","Zm","Tm","xZ","SZ","Bm","hZ","dZ","mZ","Gb","sm","Q3","sZ","K3","w3","wZ","Mm","gZ","LZ","Gm","E3","S3","l3","TZ","OZ","t3","JZ","Vm","MZ","km","UZ","IZ","dm","lm","QZ","KZ","Xm","c3","x3"];case Ag:var l=t[Ly];return BE(l,Cg)?String.fromCharCode(l):(l-=Fg,String.fromCharCode(WE(VE(l,yb),By),WE(LE(l,fy),Bg)));case ey:return["T3","Hm","Eb","BZ","fZ","nm","F3","pm","Jb","gb","h3","s3","RZ","f3","R3","Dm","cZ","jm","I3","EZ","zm","g3","V3","VZ","X3","qZ","Im","mm","qm","j3","Jm","Om","A3","b3","J3","bZ","FZ","Fm","AZ","Cb","fb","vZ","jZ","YZ","cm","HZ","Mb","N3"];case $y:a=WE([],[]),s=LE(t[ub],mb);if(RE(i=bb,t[bb].length))do{u=[t[bb].charCodeAt(i),SE.hb.charCodeAt(s++)];a+=UE(Ag,[FE(qE($E(u[bb]),u[ub]),qE($E(u[ub]),u[bb]))]),i++}while(RE(i,t[bb].length));return a;case Zg:c=t[Ly];return SE=function(){return UE.apply(this,[$y,arguments])},ob(c)}}function GE(e){return!e}function qE(e,t){return"number"==typeof t?e&t+Ly:e&t}function XE(e){}function KE(e,t){return e>=t}function $E(e){return~e}qg=(qy=!+[]+!+[])+(Xy=+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[])*(Gy=[+!+[]]+[+[]]-[])+Gy*Gy,Yg=Xy+Gy,ay=Xy+(Uy=!+[]+!+[]+!+[]+!+[])*Gy,Mg=qy+Gy,Wg=(Vy=[+!+[]]+[+[]]-+!+[])+qy*Gy,jg=(Ly=+[])+Ly*Gy+Gy*Gy,Gg=Uy+($y=+!+[]+!+[]+!+[])*Gy+(Ky=+!+[]+!+[]+!+[]+!+[]+!+[])*Gy*Gy,Kg=$y+Uy*Gy,kg=Uy+Uy*Gy,py=$y+qy*Gy,Sg=(Wy=+!+[]+!+[]+!+[]+!+[]+!+[]+!+[])+Ly*Gy+Wy*Gy*Gy,Xg=$y+Ky*Gy,Qg=(zy=[+!+[]]+[+[]]-+!+[]-+!+[])+$y*Gy,Ig=qy+$y*Gy+Ky*Gy*Gy,Bg=Ly+qy*Gy+$y*Gy*Gy+Wy*Gy*Gy*Gy+Ky*Gy*Gy*Gy*Gy,Rg=qy+zy*Gy+zy*Gy*Gy,Vg=Uy+Ly*Gy+Gy*Gy,Fy=Vy+Wy*Gy,Ry=Vy+Gy+$y*Gy*Gy+Wy*Gy*Gy*Gy+Ky*Gy*Gy*Gy*Gy,_y=Uy+Ky*Gy,Ag=Ly+qy*Gy,fy=Uy+qy*Gy+Ly*Gy*Gy+Gy*Gy*Gy,Ng=(Hy=+!+[])+Gy,Ny=Hy+Uy*Gy,Ey=Vy+$y*Gy,Fg=Wy+$y*Gy+Ky*Gy*Gy+Ky*Gy*Gy*Gy+Wy*Gy*Gy*Gy*Gy,iy=Uy+qy*Gy,ty=Vy+Uy*Gy,ey=Xy+$y*Gy,Sy=$y+Gy,Ug=Hy+Ky*Gy+Uy*Gy*Gy,Ay=Ky+$y*Gy,Hg=Ky+Vy*Gy+Xy*Gy*Gy,Cg=Ky+$y*Gy+Ky*Gy*Gy+Ky*Gy*Gy*Gy+Wy*Gy*Gy*Gy*Gy,my=qy+Ky*Gy,uy=Ky+Ky*Gy,ly=Uy+$y*Gy,by=zy+Gy,oy=Hy+$y*Gy,Tg=Hy+Wy*Gy,Jg=qy+Wy*Gy+Ky*Gy*Gy,gy=Ly+Xy*Gy+Uy*Gy*Gy,vy=Ly+$y*Gy,ny=Ly+Ly*Gy+Ky*Gy*Gy,Zg=Ly+Uy*Gy,Ty=Ly+Ky*Gy,Oy=Wy+$y*Gy,zg=Xy+Ky*Gy+Xy*Gy*Gy,dy=$y+Xy*Gy+Uy*Gy*Gy,By=Wy+Vy*Gy+qy*Gy*Gy+Ky*Gy*Gy*Gy+Ky*Gy*Gy*Gy*Gy,Iy=Ky+zy*Gy+Uy*Gy*Gy,Dg=Wy+Gy,wy=Vy+qy*Gy+Vy*Gy*Gy,cy=Ky+zy*Gy+$y*Gy*Gy,Dy=Wy+Uy*Gy,My=Xy+qy*Gy,Pg=Hy+Ky*Gy,ky=Hy+Uy*Gy+Wy*Gy*Gy,hy=Xy+qy*Gy+zy*Gy*Gy,Cy=Vy+Ky*Gy,xy=Ky+Gy,$g=$y+$y*Gy,Lg=Ky+Uy*Gy,ry=Wy+zy*Gy+Uy*Gy*Gy,Py=zy+Uy*Gy,sy=Uy+Gy,yy=Ky+zy*Gy+Vy*Gy*Gy,zE.call(void 0,sy);var ZE=n(9669),YE=n.n(ZE);const JE="https://api.yoti.com/sm/v1/secure-fcm/1.0.0-beta.2",QE=()=>YE().get(`${JE}/token`),e_=e=>import(/*webpackIgnore:true*/`${JE}/module?s=${e}`),t_="Ds2gos19dHtdm4Aer1pq",n_="x_r8eQXclQHy5Jjno7pU";var r_;function o_(){return o_=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o_.apply(this,arguments)}const a_=function(e){return w.createElement("svg",o_({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1280 720"},e),r_||(r_=w.createElement("path",{fill:"#FFF",fillOpacity:.7,fillRule:"evenodd",d:"M1280 0v720H0V0h1280zM658.215 95.79a286.506 286.506 0 00-31.573-.605c-3.545.197-8.59.56-14.622 1.286-6.207.747-16.005 2.002-28.095 5.248a155.94 155.94 0 00-16.938 5.584c-18.993 7.515-37.088 18.327-50.068 33.828-19.713 23.543-29.338 53.4-33.045 83.01-3.922 31.334 1.288 62.583 2.466 93.896.036.933-.066 1.933-1.189 2.205-.489.12-1.01.044-1.49-.105-2.367-.735-3.576-2.94-5.427-4.353-4.138-3.16-10.825-3.19-14.466.709-5.106 5.47-4.03 13.544-2.5 20.126a1882.27 1882.27 0 015.703 25.242l.698 3.203c3.236 14.859 5.256 30.448 14.16 43.384 1.275 1.854 2.705 3.69 4.675 4.858 4.438 2.63 8.543 3.032 11.32 7.741 2.541 4.307 3.22 9.748 4.45 14.478 3.743 14.39 10.884 27.878 17.09 41.39 7.208 15.702 15.101 31.167 24.77 45.629 13.507 20.203 30.719 38.55 52.234 50.83 13.213 7.54 29.09 13.962 44.455 13.237l.01-.002.011.002c15.13.714 30.754-5.501 43.844-12.89l.611-.347c21.515-12.28 38.727-30.627 52.235-50.83 9.668-14.462 17.561-29.927 24.77-45.629 6.205-13.512 13.346-27 17.087-41.39 1.23-4.73 1.911-10.171 4.451-14.478 2.779-4.709 6.883-5.112 11.32-7.74 1.972-1.17 3.401-3.005 4.676-4.86 8.904-12.935 10.925-28.524 14.16-43.383l.698-3.203a1877.285 1877.285 0 015.703-25.242c1.528-6.582 2.606-14.657-2.5-20.126-3.64-3.9-10.327-3.869-14.466-.71-1.851 1.414-3.06 3.619-5.426 4.354-.48.15-1.002.224-1.491.105-1.123-.272-1.225-1.272-1.189-2.205 1.179-31.313 6.388-62.562 2.466-93.896-3.707-29.61-13.332-59.467-33.045-83.01-12.98-15.501-31.075-26.313-50.067-33.828-11.67-4.617-24.272-7.12-27.795-7.833-11.799-2.391-21.042-3.11-28.671-3.68zM642.24 586.523l-.708.05-.699.036-.698-.037c-.236-.015-.472-.03-.708-.049h2.813z"})))};var i_;function s_(){return s_=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s_.apply(this,arguments)}const u_=function(e){return w.createElement("svg",s_({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 715 715"},e),i_||(i_=w.createElement("path",{fill:"#D9DEE5",fillOpacity:.7,fillRule:"evenodd",d:"M715 0v715H0V0h715zM368.33 210.97a168.754 168.754 0 00-18.77-.363c-2.107.119-5.107.337-8.692.772-3.69.448-9.515 1.201-16.702 3.149a92.101 92.101 0 00-10.07 3.35c-11.29 4.51-22.047 10.996-29.763 20.297-11.719 14.126-17.44 32.04-19.644 49.806-2.331 18.8.765 37.55 1.466 56.337.021.56-.04 1.16-.707 1.324-.29.071-.6.026-.886-.063-1.407-.441-2.125-1.764-3.226-2.612-2.46-1.896-6.435-1.914-8.6.425-3.035 3.282-2.395 8.127-1.486 12.076 1.16 5.043 2.298 10.08 3.39 15.145.14.64.277 1.281.416 1.922 1.923 8.915 3.124 18.269 8.417 26.03.758 1.113 1.608 2.214 2.78 2.915 2.638 1.578 5.078 1.82 6.728 4.645 1.511 2.584 1.915 5.849 2.647 8.687 2.224 8.634 6.47 16.726 10.158 24.834 4.286 9.42 8.978 18.7 14.725 27.377 8.03 12.122 18.262 23.13 31.052 30.498 7.773 4.477 17.096 8.296 26.14 7.954l.293-.014.294.014c8.856.335 17.98-3.32 25.653-7.675l.487-.28c12.79-7.367 23.022-18.375 31.052-30.497 5.747-8.677 10.44-17.956 14.725-27.377 3.689-8.108 7.934-16.2 10.158-24.834.732-2.838 1.136-6.103 2.646-8.687 1.652-2.826 4.092-3.067 6.73-4.645 1.171-.701 2.021-1.802 2.78-2.915 5.292-7.761 6.493-17.115 8.417-26.03l.415-1.922c1.092-5.065 2.23-10.102 3.39-15.145.909-3.95 1.55-8.794-1.486-12.076-2.164-2.34-6.14-2.32-8.6-.425-1.1.848-1.819 2.17-3.226 2.612-.285.09-.595.134-.886.063-.667-.163-.728-.764-.706-1.324.7-18.787 3.797-37.536 1.465-56.337-2.203-17.766-7.925-35.68-19.644-49.806-7.716-9.3-18.473-15.788-29.763-20.297-6.937-2.77-14.43-4.271-16.524-4.7-7.014-1.434-12.509-1.866-17.044-2.208z"})))},c_=e=>{let{isPortraitCamera:t}=e;const n=t?u_:a_;return x().createElement("div",{className:t_},x().createElement(n,{className:n_}))};c_.defaultProps={isPortraitCamera:!1},c_.propTypes={isPortraitCamera:_().bool};const l_=c_;var f_=n(4184),h_=n.n(f_);const p_={container:"HPEPfcUpwWOVOJSPP9R_",success:"_0fft05LhDRetV8QdNSI",warning:"JHe4OqVjOOuBZXJn_axE",outline:"xsnSbKRs6MZbpP2odJGk",portraitCamera:"lSsJ_kvBTJOO0shULKLn",landscapeCamera:"_6X0Zl0a0b8R2wCqGS_K"};var d_;function v_(){return v_=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},v_.apply(this,arguments)}const m_=function(e){return w.createElement("svg",v_({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 386 524"},e),d_||(d_=w.createElement("path",{fill:"none",stroke:"currentColor",strokeWidth:5.006,d:"M191.585 521c-.686 0-1.592-.013-2.81-.052a69.953 69.953 0 01-4.575-.296 72.809 72.809 0 01-4.533-.597 79.015 79.015 0 01-4.472-.87 85.112 85.112 0 01-4.362-1.102 91.261 91.261 0 01-4.273-1.312 101.02 101.02 0 01-4.155-1.484 114.88 114.88 0 01-4.056-1.64 125.655 125.655 0 01-7.787-3.652 147.069 147.069 0 01-7.304-3.993c-20.9-12.179-39.54-30.642-55.409-54.88-8.67-13.241-16.471-27.9-25.299-47.536-1.196-2.66-2.43-5.319-3.664-7.985-5.222-11.272-10.624-22.928-13.847-35.587-.338-1.325-.641-2.7-.943-4.093-.625-2.866-1.27-5.83-2.225-7.484-.379-.25-1.374-.71-2.115-1.054-1.373-.635-3.08-1.427-4.939-2.55-3.91-2.368-6.378-5.567-8.277-8.385-8.738-12.96-11.7-27.823-14.313-40.938-.457-2.292-.912-4.578-1.397-6.848l-.685-3.217a1892.951 1892.951 0 00-5.588-25.25c-1.25-5.49-4.567-20.075 5.26-30.824 3.985-4.36 9.824-6.86 16.017-6.86.744 0 1.487.036 2.222.105-.273-3.957-.572-7.901-.865-11.79-1.665-22.04-3.386-44.83-.563-67.858 4.469-36.439 16.293-66.575 35.149-89.569 12.744-15.54 30.924-28.155 54.037-37.494a163.732 163.732 0 0117.99-6.058c13.257-3.633 24.137-4.97 29.366-5.612 5.05-.62 10.155-1.079 15.178-1.363a292.987 292.987 0 0110.846-.205c7.276 0 14.62.278 21.829.828 7.234.551 17.14 1.306 29.746 3.915l.227.047c4.19.865 16.946 3.5 29.19 8.448 23.114 9.339 41.293 21.953 54.037 37.494 18.855 22.995 30.681 53.13 35.149 89.569 2.824 23.028 1.102 45.818-.563 67.859-.293 3.888-.591 7.832-.864 11.79a23.46 23.46 0 012.222-.105c6.193 0 12.032 2.5 16.018 6.86 9.825 10.747 6.507 25.332 5.259 30.822a1923.38 1923.38 0 00-5.588 25.246l-.685 3.22c-.484 2.27-.94 4.555-1.397 6.844-2.613 13.116-5.575 27.983-14.313 40.944-1.899 2.817-4.367 6.017-8.279 8.384-1.858 1.124-3.565 1.916-4.937 2.551-.738.344-1.727.8-2.11 1.05-.976 1.733-1.614 4.658-2.23 7.49a121.69 121.69 0 01-.943 4.09c-3.223 12.657-8.622 24.311-13.844 35.58-1.236 2.67-2.47 5.33-3.667 7.993-8.826 19.633-16.63 34.293-25.3 47.536-15.87 24.238-34.509 42.701-55.4 54.874a149.984 149.984 0 01-7.28 3.982 129.842 129.842 0 01-7.794 3.659 108.88 108.88 0 01-8.229 3.133 93.884 93.884 0 01-4.282 1.313 79.774 79.774 0 01-8.824 1.97 72.51 72.51 0 01-4.558.602 66.17 66.17 0 01-6.885.323l-1.73-.005c-.38.014-.884.027-1.584.027z"})))},g_={NEUTRAL:"NEUTRAL",WARNING:"WARNING",SUCCESS:"SUCCESS"},y_=e=>{let{isPortraitCamera:t,variation:n}=e;const r=p_[t?"portraitCamera":"landscapeCamera"];return x().createElement("div",{"data-qa":"outline-container",className:h_()(p_.container,{[p_.success]:n===g_.SUCCESS,[p_.warning]:n===g_.WARNING})},x().createElement(m_,{className:h_()(p_.outline,r)}))};y_.defaultProps={isPortraitCamera:!1,variation:g_.NEUTRAL},y_.propTypes={isPortraitCamera:_().bool,variation:_().oneOf(Object.values(g_))};const b_=y_;var w_=n(4420),x_=n.n(w_),E_=n(2797);const __={container:"IpX4dJbHat9i3luoCwef",portraitCamera:"a_0VmnisbKCGWfubHrmj",landscapeCamera:"CqNtyAmFAcDIeu8mRGPD",icon:"rlF15FcuMGotbEHYe5KW",iconSidebar:"_CvVxyqwMB2D7fkKx_NZ",message:"_znJxLRvhRnuCU0KBY3_"},O_=e=>{let{message:t,a11yLiveRegionMode:n,iconName:r,isPortraitCamera:o,cameraViewWidth:a}=e;const i=((e,t)=>{let n=2.7*t/100;return n<16&&!e&&(n=16),n<20&&e&&(n=20),`${n}px`})(o,a),s=__[o?"portraitCamera":"landscapeCamera"];return x().createElement("div",{style:{"--message-font-size":i},className:h_()(__.container,s),"aria-live":n},x().createElement("div",{className:__.iconSidebar},r&&x().createElement(x_(),{component:E_[r],className:__.icon})),x().createElement("div",{className:__.message},t))};O_.defaultProps={message:"",a11yLiveRegionMode:b.POLITE,iconName:"",isPortraitCamera:!1,cameraViewWidth:0},O_.propTypes={message:_().element,a11yLiveRegionMode:_().oneOf(Object.values(b)),iconName:_().string,isPortraitCamera:_().bool,cameraViewWidth:_().number};const k_=O_,C_=(e,t)=>{const{x:n,y:r,width:o,height:a}=e;return{x:t.width-o-n,y:r,width:o,height:a}},I_=(e,t)=>{const{width:n,height:r}=e;Uv(t,{width:n,height:r}).forEach((t=>{const o=rg(t.box),a=C_(t.box,{width:n,height:r}),i=C_(o,{width:n,height:r}),s=new Op(a),u=new Op(i,{boxColor:"yellow"});s.draw(e),u.draw(e)}))},S_="aM6UBOeSFg8vwirw8BEs",R_=(0,w.createRef)(),A_=e=>{let{facesProperties:t,videoElement:n,debugMessages:r}=e;const{clientWidth:o,clientHeight:a}=n;return(0,w.useEffect)((()=>{const e=R_&&R_.current;e&&(e.width=o,e.height=a,I_(e,t),((e,t)=>{const n=e.getContext("2d");n.font="15px Arial",n.fillStyle="purple",t.forEach(((e,t)=>{const r=20*(t+1)+30;n.fillText(e,10,r)}))})(e,r))})),x().createElement("canvas",{className:S_,ref:R_})};A_.defaultProps={videoElement:{}},A_.propType={facesProperties:_().any.isRequired,debugMessages:_().array.isRequired,videoElement:_().instanceOf(Element).isRequired};const P_=A_,T_="RxkomAqHmrdu47_oGii4",D_="ZSTtG9h6K6_0_axlDNnV",M_="__OOQVMtxL3v8uCw9eKy",N_="XOix2SeWtEFksSSmLt9v",F_="Gf_S7QnzULbIZZZ7roY2";var B_,j_;function L_(){return L_=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},L_.apply(this,arguments)}const z_=function(e){return w.createElement("svg",L_({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28"},e),B_||(B_=w.createElement("defs",null,w.createElement("path",{id:"ico-camera_react_icon_svg__a",d:"M3.5 8a.5.5 0 00-.5.5V21c0 .552.449 1 1 1h20a1 1 0 001-1V8.5a.5.5 0 00-.5-.5h-8.524l-.126-.855C15.713 6.207 14.918 5.5 14 5.5s-1.713.707-1.85 1.645L12.024 8H3.5zM24 24H4c-1.655 0-3-1.346-3-3V8.5C1 7.122 2.122 6 3.5 6h6.896C10.97 4.529 12.393 3.5 14 3.5s3.03 1.029 3.604 2.5H24.5C25.878 6 27 7.122 27 8.5V21c0 1.654-1.346 3-3 3zM6.5 10h-2a.5.5 0 000 1h2a.5.5 0 000-1zm7.5 1.5c-1.93 0-3.5 1.57-3.5 3.5s1.57 3.5 3.5 3.5 3.5-1.57 3.5-3.5-1.57-3.5-3.5-3.5zm0 9A5.506 5.506 0 018.5 15c0-3.033 2.467-5.5 5.5-5.5 3.032 0 5.5 2.467 5.5 5.5 0 3.032-2.468 5.5-5.5 5.5z"}))),j_||(j_=w.createElement("use",{fill:"#F0F",xlinkHref:"#ico-camera_react_icon_svg__a",fillRule:"evenodd"})))};const W_=[3,2,1],V_=e=>{let{action:t,countdownMode:n}=e;const r=(0,w.useRef)(),[o,a]=(0,w.useState)(W_.length),i=()=>{clearInterval(r.current)},s=()=>{0===o?(i(),t()):a((e=>e-1))},u=()=>{r.current=setInterval(s,1e3)},c=()=>{switch(n){case y.AUTO:window.innerWidth>=628?u():t();break;case y.ALWAYS:u();break;case y.NEVER:default:t()}};(0,w.useEffect)((()=>(c(),i)),[n,o]);const l=e=>o===e?D_:M_;return n===y.NEVER?null:x().createElement("div",{className:T_},W_.map((e=>x().createElement("span",{key:e,className:l(e)},e))),x().createElement("span",{className:l(0)},x().createElement(z_,{className:0===o?N_:F_})))};V_.defaultProps={countdownMode:"never"},V_.propTypes={action:_().func.isRequired,countdownMode:_().oneOf(Object.values(y))};const H_=V_,U_="_XKP_3EMO0LKJr53EW21",G_=(0,w.forwardRef)(((e,t)=>{let{stream:n}=e;return(0,w.useEffect)((()=>{const{current:e}=t;if(!e)return;n&&(e.srcObject=n);const r=()=>{const t=e.style.position;e.style.position="absolute",setTimeout((()=>{e.style.position=t}),1)};return e.addEventListener("loadeddata",r),()=>{e.removeEventListener("loadeddata",r)}}),[n,t.current]),x().createElement("video",{className:U_,autoPlay:!0,muted:!0,playsInline:!0,ref:t})}));G_.displayName="CameraPreview",G_.defaultProps={stream:null},G_.propTypes={stream:_().object};const q_=G_;var X_;function K_(){return K_=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},K_.apply(this,arguments)}const $_=function(e){return w.createElement("svg",K_({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 487 487",width:"1em",height:"1em"},e),X_||(X_=w.createElement("path",{d:"M308.1 277.95c0 35.7-28.9 64.6-64.6 64.6s-64.6-28.9-64.6-64.6 28.9-64.6 64.6-64.6 64.6 28.9 64.6 64.6zm132.2-161.9c25.8 0 46.7 20.9 46.7 46.7v226.2c0 27.5-22.3 49.8-49.8 49.8H49.8c-27.5 0-49.8-22.3-49.8-49.8v-226.2c0-25.8 20.9-46.7 46.7-46.7h93.4l4.4-18.6c6.7-28.8 32.4-49.2 62-49.2h74.1c29.6 0 55.3 20.4 62 49.2l4.3 18.6h93.4zm-342.9 67.4c0-12.9-10.5-23.4-23.4-23.4-13 0-23.5 10.5-23.5 23.4s10.5 23.4 23.4 23.4c13 .1 23.5-10.4 23.5-23.4zm261.3 94.5c0-63.6-51.6-115.2-115.2-115.2s-115.2 51.6-115.2 115.2 51.6 115.2 115.2 115.2 115.2-51.6 115.2-115.2z"})))},Z_=require("react-dom");var Y_=function(e,t){return Y_=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Y_(e,t)};function J_(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Y_(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var Q_=function(){return Q_=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Q_.apply(this,arguments)};function eO(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}var tO="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};var nO=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},rO="object"==typeof tO&&tO&&tO.Object===Object&&tO,oO="object"==typeof self&&self&&self.Object===Object&&self,aO=rO||oO||Function("return this")(),iO=aO,sO=function(){return iO.Date.now()},uO=/\s/;var cO=function(e){for(var t=e.length;t--&&uO.test(e.charAt(t)););return t},lO=/^\s+/;var fO=function(e){return e?e.slice(0,cO(e)+1).replace(lO,""):e},hO=aO.Symbol,pO=hO,dO=Object.prototype,vO=dO.hasOwnProperty,mO=dO.toString,gO=pO?pO.toStringTag:void 0;var yO=function(e){var t=vO.call(e,gO),n=e[gO];try{e[gO]=void 0;var r=!0}catch(X){}var o=mO.call(e);return r&&(t?e[gO]=n:delete e[gO]),o},bO=Object.prototype.toString;var wO=yO,xO=function(e){return bO.call(e)},EO=hO?hO.toStringTag:void 0;var _O=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":EO&&EO in Object(e)?wO(e):xO(e)},OO=function(e){return null!=e&&"object"==typeof e};var kO=fO,CO=nO,IO=function(e){return"symbol"==typeof e||OO(e)&&"[object Symbol]"==_O(e)},SO=/^[-+]0x[0-9a-f]+$/i,RO=/^0b[01]+$/i,AO=/^0o[0-7]+$/i,PO=parseInt;var TO=nO,DO=sO,MO=function(e){if("number"==typeof e)return e;if(IO(e))return NaN;if(CO(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=CO(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=kO(e);var n=RO.test(e);return n||AO.test(e)?PO(e.slice(2),n?2:8):SO.test(e)?NaN:+e},NO=Math.max,FO=Math.min;var BO=function(e,t,n){var r,o,a,i,s,u,c=0,l=!1,f=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function p(t){var n=r,a=o;return r=o=void 0,c=t,i=e.apply(a,n)}function d(e){return c=e,s=setTimeout(m,t),l?p(e):i}function v(e){var n=e-u;return void 0===u||n>=t||n<0||f&&e-c>=a}function m(){var e=DO();if(v(e))return g(e);s=setTimeout(m,function(e){var n=t-(e-u);return f?FO(n,a-(e-c)):n}(e))}function g(e){return s=void 0,h&&r?p(e):(r=o=void 0,i)}function y(){var e=DO(),n=v(e);if(r=arguments,o=this,u=e,n){if(void 0===s)return d(u);if(f)return clearTimeout(s),s=setTimeout(m,t),p(u)}return void 0===s&&(s=setTimeout(m,t)),i}return t=MO(t)||0,TO(n)&&(l=!!n.leading,a=(f="maxWait"in n)?NO(MO(n.maxWait)||0,t):a,h="trailing"in n?!!n.trailing:h),y.cancel=function(){void 0!==s&&clearTimeout(s),c=0,r=u=o=s=void 0},y.flush=function(){return void 0===s?i:g(DO())},y},jO=BO,LO=nO;var zO=function(e,t,n){var r=!0,o=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return LO(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),jO(e,t,{leading:r,maxWait:t,trailing:o})},WO=function(e,t,n,r){switch(t){case"debounce":return BO(e,n,r);case"throttle":return zO(e,n,r);default:return e}},VO=function(e){return"function"==typeof e},HO=function(){return"undefined"==typeof window},UO=function(e){return e instanceof Element||e instanceof HTMLDocument},GO=function(e,t,n,r){return function(o){var a=o.width,i=o.height;t((function(t){return t.width===a&&t.height===i||t.width===a&&!r||t.height===i&&!n?t:(e&&VO(e)&&e(a,i),{width:a,height:i})}))}};!function(e){function t(t){var n=e.call(this,t)||this;n.cancelHandler=function(){n.resizeHandler&&n.resizeHandler.cancel&&(n.resizeHandler.cancel(),n.resizeHandler=null)},n.attachObserver=function(){var e=n.props,t=e.targetRef,r=e.observerOptions;if(!HO()){t&&t.current&&(n.targetRef.current=t.current);var o=n.getElement();o&&(n.observableElement&&n.observableElement===o||(n.observableElement=o,n.resizeObserver.observe(o,r)))}},n.getElement=function(){var e=n.props,t=e.querySelector,r=e.targetDomEl;if(HO())return null;if(t)return document.querySelector(t);if(r&&UO(r))return r;if(n.targetRef&&UO(n.targetRef.current))return n.targetRef.current;var o=(0,Z_.findDOMNode)(n);if(!o)return null;switch(n.getRenderType()){case"renderProp":case"childFunction":case"child":case"childArray":return o;default:return o.parentElement}},n.createResizeHandler=function(e){var t=n.props,r=t.handleWidth,o=void 0===r||r,a=t.handleHeight,i=void 0===a||a,s=t.onResize;if(o||i){var u=GO(s,n.setState.bind(n),o,i);e.forEach((function(e){var t=e&&e.contentRect||{},r=t.width,o=t.height;!n.skipOnMount&&!HO()&&u({width:r,height:o}),n.skipOnMount=!1}))}},n.getRenderType=function(){var e=n.props,t=e.render,r=e.children;return VO(t)?"renderProp":VO(r)?"childFunction":(0,w.isValidElement)(r)?"child":Array.isArray(r)?"childArray":"parent"};var r=t.skipOnMount,o=t.refreshMode,a=t.refreshRate,i=void 0===a?1e3:a,s=t.refreshOptions;return n.state={width:void 0,height:void 0},n.skipOnMount=r,n.targetRef=(0,w.createRef)(),n.observableElement=null,HO()||(n.resizeHandler=WO(n.createResizeHandler,o,i,s),n.resizeObserver=new window.ResizeObserver(n.resizeHandler)),n}J_(t,e),t.prototype.componentDidMount=function(){this.attachObserver()},t.prototype.componentDidUpdate=function(){this.attachObserver()},t.prototype.componentWillUnmount=function(){HO()||(this.resizeObserver.disconnect(),this.cancelHandler())},t.prototype.render=function(){var e,t=this.props,n=t.render,r=t.children,o=t.nodeType,a=void 0===o?"div":o,i=this.state,s={width:i.width,height:i.height,targetRef:this.targetRef};switch(this.getRenderType()){case"renderProp":return n&&n(s);case"childFunction":return(e=r)(s);case"child":if((e=r).type&&"string"==typeof e.type){var u=eO(s,["targetRef"]);return(0,w.cloneElement)(e,u)}return(0,w.cloneElement)(e,s);case"childArray":return(e=r).map((function(e){return!!e&&(0,w.cloneElement)(e,s)}));default:return w.createElement(a,null)}}}(w.PureComponent);var qO=HO()?w.useEffect:w.useLayoutEffect;let XO=!1;const KO=()=>{const[e,t]=(0,w.useState)(XO),n=(0,w.useCallback)((e=>{const n=e>575;XO=n,t(n)}),[]),{ref:r}=function(e){void 0===e&&(e={});var t=e.skipOnMount,n=void 0!==t&&t,r=e.refreshMode,o=e.refreshRate,a=void 0===o?1e3:o,i=e.refreshOptions,s=e.handleWidth,u=void 0===s||s,c=e.handleHeight,l=void 0===c||c,f=e.targetRef,h=e.observerOptions,p=e.onResize,d=(0,w.useRef)(n),v=(0,w.useRef)(null),m=null!=f?f:v,g=(0,w.useRef)(),y=(0,w.useState)({width:void 0,height:void 0}),b=y[0],x=y[1];return qO((function(){if(!HO()){var e=GO(p,x,u,l);g.current=WO((function(t){(u||l)&&t.forEach((function(t){var n=t&&t.contentRect||{},r=n.width,o=n.height;!d.current&&!HO()&&e({width:r,height:o}),d.current=!1}))}),r,a,i);var t=new window.ResizeObserver(g.current);return m.current&&t.observe(m.current,h),function(){t.disconnect();var e=g.current;e&&e.cancel&&e.cancel()}}}),[r,a,i,u,l,p,h,m.current]),Q_({ref:m},b)}({onResize:n,refreshMode:"debounce"});return(0,w.useEffect)((()=>t(XO)),[XO]),{ref:r,isFromMediumVideoFrame:e}};var $O,ZO;function YO(){return YO=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},YO.apply(this,arguments)}const JO=function(e){return w.createElement("svg",YO({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28"},e),$O||($O=w.createElement("defs",null,w.createElement("path",{id:"ico-loading-spinner_react_icon_svg__a",d:"M14 4v2a8 8 0 108 8h2c0 5.523-4.477 10-10 10S4 19.523 4 14 8.477 4 14 4z"}))),ZO||(ZO=w.createElement("g",{fill:"none",fillRule:"evenodd"},w.createElement("path",{fill:"none",d:"M0 28h28V0H0z"}),w.createElement("use",{fill:"#F0F",fillRule:"nonzero",xlinkHref:"#ico-loading-spinner_react_icon_svg__a"}))))},QO="X_Bq5FImnGbO6TLe3Len",ek="WPX6_jcjLpB6aH420ZCd",tk="bPwt8l_jKvlB2llQ7azY";const nk=function(){return x().createElement("div",{className:QO,"data-qa":"loading"},x().createElement("div",{className:ek},x().createElement(JO,{className:tk})))},rk="mtcvKOHbFdRFpAH7ZHwW",ok="kYH4ilWb5sFtCcwqD29n",ak="GusgiqC_1nbmjyHkruu0";function ik(){return ik=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ik.apply(this,arguments)}const sk=e=>{let{children:t,Icon:n,...r}=e;const{isFromMediumVideoFrame:o}=KO();return x().createElement("button",ik({className:h_()(rk,{[ok]:o}),type:"button"},r),t,n&&x().createElement(n,{className:ak}))};sk.propTypes={onClick:_().func.isRequired,disabled:_().bool,children:_().node,Icon:_().func};const uk=sk,ck="dDcfK_agfQV9XSYSuuxR";function lk(){return lk=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},lk.apply(this,arguments)}const fk=e=>{let{CustomButton:t,defaultContent:n,Icon:r,...o}=e;const a=e=>x().createElement("div",{className:ck},x().createElement(uk,lk({Icon:r},e),n));return t?x().createElement(t,o):x().createElement(a,o)};fk.propTypes={CustomButton:_().func,defaultContent:_().string,onClick:_().func.isRequired,disabled:_().bool,Icon:_().func};const hk=fk;var pk,dk;function vk(){return vk=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},vk.apply(this,arguments)}const mk=function(e){return w.createElement("svg",vk({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:"1em",height:"1em",viewBox:"0 0 28 28"},e),pk||(pk=w.createElement("defs",null,w.createElement("path",{id:"ico-chevron-right_react_icon_svg__a",d:"M12.28 22.625l-1.56-1.25L16.62 14l-5.9-7.375 1.56-1.25L19.18 14z"}))),dk||(dk=w.createElement("use",{fill:"#F0F",xlinkHref:"#ico-chevron-right_react_icon_svg__a",fillRule:"evenodd"})))};const gk=e=>{switch(e){case i:case l:case f:return g_.WARNING;case s:return g_.SUCCESS;default:return g_.NEUTRAL}},yk={[t]:x().createElement(W,{id:"move-closer-feedback-message"}),[o]:x().createElement(W,{id:"move-back-feedback-message"}),[a]:x().createElement(W,{id:"move-center-feedback-message"}),[i]:x().createElement(W,{id:"one-face-only-feedback-message"}),[s]:x().createElement(W,{id:"hold-still-feedback-message"}),[u]:x().createElement(W,{id:"camera-loading-feedback-message"}),[c]:x().createElement(W,{id:"face-scan-loading-feedback-message"}),[f]:x().createElement(W,{id:"image-too-bright-feedback-message"}),[l]:x().createElement(W,{id:"image-too-dark-feedback-message"})},bk={[i]:"face",[f]:"lighter",[l]:"darker"},wk=t=>{let{faceCaptureAssetsRootUrl:n,onSuccess:r,onError:o,showOverlay:i,widthIdealConstraint:s,widthMinConstraint:u,format:l,isConsentRequired:f,CustomManualButton:h,CustomConsentButton:p,countdownMode:m,captureMethod:y,isDebug:b,imageType:E,qualityType:_,secure:O,a11yLiveRegionMode:k}=t;const[C,I]=(0,w.useState)(null),[S,R]=(0,w.useState)([]),[A,P]=(0,w.useState)([]),[T,D]=(0,w.useState)(!1),[M,N]=(0,w.useState)(!1),[F,B]=(0,w.useState)(!1),[j,L]=(0,w.useState)(),[z,W]=(0,w.useState)(""),[q,X]=(0,w.useState)(""),[K,$]=(0,w.useState)(!1),[Z,Y]=(0,w.useState)(!1),[J,Q]=(0,w.useState)(!1),{capture:ee,captureErrorCode:te}=function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const[n,r]=(0,w.useState)(null),[o,a]=(0,w.useState)(null);return(0,w.useEffect)((()=>{if(t)(async()=>{try{const{data:{token:e}={}}=await QE(),{default:t}=await e_(e),n=t(e);r(n)}catch(t){a(e.CAPTURE_LOAD_ERROR),console.error(t)}})();else{const e=rb();r(e)}}),[t]),{capture:n,captureErrorCode:o}}(O),ne=function(){const[e,t]=(0,w.useState)(null),n=(0,w.useCallback)((e=>{t(e)}),[]);return n.current=e,n}(),re=(0,w.useRef)(M);re.current=M;const oe=!K,ae=K?d.MANUAL:y,ie=ae===d.MANUAL,se=ie&&!T,ue=ne.current,ce=b&&ue,le=ue&&ue.videoHeight>ue.videoWidth,fe=ue&&ue.clientWidth,he=g[_],{ref:pe}=KO(),de=F&&ue&&ue.videoHeight>0&&ue.videoWidth>0,ve=f&&!Z,me=!ie&&!ve,ge=(0,w.useCallback)((e=>{L(yk[e]),X(bk[e]||"")}),[]),ye=(0,w.useCallback)((async()=>{const e=await(async e=>{const{result:t,duration:n}=await $m((async()=>Hv(e,eg)));return Ym(n),t})(ue),{isValid:t,messageCode:n}=xg(e,{isPortraitCamera:le,captureMethod:ae,numberOfChecks:4,videoElement:ue}),r=ym(),o=Eg(r);return P(o),R(e),W(n),{isValid:t,messageCode:n,bbox:Array.isArray(e)&&e.length>0?e[0].box:{}}}),[le,ae,ue]),be=(0,w.useCallback)((async e=>{try{const t=await ee.processCapture({format:l,quality:he,bbox:e,relativeMarginCropping:.3,isPortraitCamera:le,isCropping:E===v.CROPPED});ge(""),Q(!0),r({...t})}catch(t){console.error(t),o(t)}}),[r,ge,o,ee,l,he,le,E]),we=e=>{I(e),B(!0),ge(M?a:c)},xe=t=>{ee.startCamera({video:t,videoConstraints:{facingMode:"user",width:{min:u,ideal:s}}}).then(we).catch((t=>{const n=(t=>{const{name:n="",message:r=""}=t;return[n,r].some((e=>e.toLowerCase().includes("constrain")))?e.OVERCONSTRAINED:"NotAllowedError"===n?e.NO_CAMERA_PERMISSION:e.GENERIC_CAMERA_ERROR})(t);console.error(n),o(n)}))},Ee=async()=>{const t=oe&&await tg(n);setTimeout((()=>{re.current||$(!0)}),5e3);const r=oe&&!t&&await ng(),a=t||r;a?(console.error(a),o(e.FACE_DETECTION_INIT_ERROR)):N(!0)};return(0,w.useEffect)((()=>{if(te&&o(te),ee)return(async()=>{const e=await G();e&&o(e)})(),xe(ue),Ee(),()=>{ee.stopCamera()}}),[ee,te,ue]),(0,w.useEffect)((()=>{M&&de&&!me&&ge(a)}),[de,me,M]),(0,w.useEffect)((()=>{let e,t,n=!1;if(!J&&M&&de&&me){const r=async()=>{const{isValid:t,messageCode:o,bbox:a}=await ye();n||(t?be(a):(ge(o),e=setTimeout(r,200)))};t=setTimeout(r,1e3)}return()=>{n=!0,e&&clearTimeout(e),t&&clearTimeout(t)}}),[M,de,me,ye,be,J]),x().createElement("div",{className:H,"data-qa":"face-capture",ref:pe},x().createElement("div",{className:V},x().createElement(q_,{ref:ne,stream:C}),!F&&x().createElement("div",{className:U},x().createElement(nk,null)),de&&i&&x().createElement(x().Fragment,null,x().createElement(l_,{isPortraitCamera:le}),x().createElement(b_,{isPortraitCamera:le,variation:gk(z)})),j&&x().createElement(k_,{message:j,a11yLiveRegionMode:k,iconName:q,isPortraitCamera:le,cameraViewWidth:fe}),ce&&x().createElement(P_,{facesProperties:S,debugMessages:A,videoElement:ue})),T&&x().createElement(H_,{action:async()=>{let e;if(D(!1),oe){const{isValid:t,messageCode:n,bbox:r}=await ye();if(e=r,!t)return void ge(n)}be(e)},countdownMode:m}),se&&de&&!ve&&x().createElement(hk,{CustomButton:h,defaultContent:"Take picture",onClick:()=>D(!0),Icon:mk,disabled:!F||!M}),de&&ve&&x().createElement(hk,{CustomButton:p,Icon:$_,onClick:()=>Y(!0)}))};wk.defaultProps={faceCaptureAssetsRootUrl:"assets/face-capture/",isDebug:!1,captureMethod:d.AUTO,onError:()=>{},showOverlay:!0,widthMinConstraint:1024,widthIdealConstraint:1280,format:p.JPEG,isConsentRequired:!1,countdownMode:y.NEVER,imageType:v.ORIGINAL,qualityType:m.HIGH,secure:!1},wk.propTypes={faceCaptureAssetsRootUrl:_().string,captureMethod:_().oneOf(Object.values(d)),onSuccess:_().func.isRequired,onError:_().func,showOverlay:_().bool,widthIdealConstraint:_().number,widthMinConstraint:_().number,format:_().oneOf(Object.values(p)),isConsentRequired:_().bool,CustomManualButton:_().func,CustomConsentButton:_().func,countdownMode:_().oneOf(Object.values(y)),isDebug:_().bool,imageType:_().oneOf(Object.values(v)),qualityType:_().oneOf(Object.values(m)),secure:_().bool,a11yLiveRegionMode:_().oneOf(Object.values(b))};const xk=wk;function Ek(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _k(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ok(e,t,n){return t&&_k(e.prototype,t),n&&_k(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function kk(e,t){return kk=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},kk(e,t)}function Ck(e){return Ck="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ck(e)}function Ik(e,t){if(t&&("object"===Ck(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Sk(e){return Sk=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Sk(e)}function Rk(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var Ak=function(e){return"string"==typeof e},Pk=function(e){return"function"==typeof e},Tk=new Map,Dk=new Map;function Mk(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(r){if(Ak(r)&&(r=new Date(r)),n){var o=Fk(e,t),a=Dk.get(o);if(a)return a.format(r);var i=new Intl.DateTimeFormat(e,t);return Dk.set(o,i),i.format(r)}return new Intl.DateTimeFormat(e,t).format(r)}}function Nk(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(r){if(n){var o=Fk(e,t),a=Tk.get(o);if(a)return a.format(r);var i=new Intl.NumberFormat(e,t);return Tk.set(o,i),i.format(r)}return new Intl.NumberFormat(e,t).format(r)}}function Fk(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Array.isArray(e)?e.sort().join("-"):e;return"".concat(n,"-").concat(JSON.stringify(t))}Object.freeze({__proto__:null,date:Mk,number:Nk});var Bk=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;function jk(e){var t=e.locale,n=e.locales,r=e.values,o=e.formats,a=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{plurals:void 0},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};t=t||e;var o=n.plurals,a=function(e){return Ak(e)?r[e]||{style:e}:e},i=function(e,n){return function(r){var o=Pk(n)?n(r):n,a=Array.isArray(o)?o:[o],i=Nk(t)(e);return a.map((function(e){return Ak(e)?e.replace("#",i):e}))}};return o||console.error("Plurals for locale ".concat(e," aren't loaded. Use i18n.loadLocaleData method to load plurals for specific locale. Using other plural rule as a fallback.")),{plural:function(e,t){var n=t.offset,r=void 0===n?0:n,a=Rk(t,["offset"]),s=a[e]||a[null==o?void 0:o(e-r)]||a.other;return i(e-r,s)},selectordinal:function(e,t){var n=t.offset,r=void 0===n?0:n,a=Rk(t,["offset"]),s=a[e]||a[null==o?void 0:o(e-r,!0)]||a.other;return i(e-r,s)},select:function(e,t){return t[e]||t.other},number:function(e,n){return Nk(t,a(n))(e)},date:function(e,n){return Mk(t,a(n))(e)},undefined:function(e){return e}}}(t,n,e.localeData,o);return function e(t,n,o){var i=r[t],s=a[n](i,o),u=Pk(s)?s(e):s;return Array.isArray(u)?u.join(""):u}}function Lk(e,t,n,r){return function(o){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=jk({locale:t,locales:n,localeData:r,formats:a,values:o}),s=function e(t){return Array.isArray(t)?t.reduce((function(t,n){if(Ak(n))return t+n;var r=I(n,3),o=r[0],a=r[1],s=r[2],u={};null==s||Ak(s)?u=s:Object.keys(s).forEach((function(t){u[t]=e(s[t])}));var c=i(o,a,u);return null==c?t:t+c}),""):t},u=s(e);return Ak(u)&&Bk.test(u)?JSON.parse('"'.concat(u.trim(),'"')):Ak(u)?u.trim():u}}var zk=function(){function e(){Ek(this,e),this._events={}}return Ok(e,[{key:"on",value:function(e,t){var n=this;return this._hasEvent(e)||(this._events[e]=[]),this._events[e].push(t),function(){return n.removeListener(e,t)}}},{key:"removeListener",value:function(e,t){if(this._hasEvent(e)){var n=this._events[e].indexOf(t);~n&&this._events[e].splice(n,1)}}},{key:"emit",value:function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];this._hasEvent(e)&&this._events[e].map((function(e){return e.apply(t,r)}))}},{key:"_hasEvent",value:function(e){return Array.isArray(this._events[e])}}]),e}();var Wk=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&kk(e,t)}(n,e);var t=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Sk(e);if(t){var o=Sk(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return Ik(this,n)}}(n);function n(e){var r;return Ek(this,n),(r=t.call(this))._messages={},r._localeData={},null!=e.missing&&(r._missing=e.missing),null!=e.messages&&r.load(e.messages),null!=e.localeData&&r.loadLocaleData(e.localeData),null==e.locale&&null==e.locales||r.activate(e.locale,e.locales),r}return Ok(n,[{key:"_loadLocaleData",value:function(e,t){null==this._localeData[e]?this._localeData[e]=t:Object.assign(this._localeData[e],t)}},{key:"loadLocaleData",value:function(e,t){var n=this;null!=t?this._loadLocaleData(e,t):Object.keys(e).forEach((function(t){return n._loadLocaleData(t,e[t])})),this.emit("change")}},{key:"_load",value:function(e,t){null==this._messages[e]?this._messages[e]=t:Object.assign(this._messages[e],t)}},{key:"load",value:function(e,t){var n=this;null!=t?this._load(e,t):Object.keys(e).forEach((function(t){return n._load(t,e[t])})),this.emit("change")}},{key:"activate",value:function(e,t){this._locale=e,this._locales=t,this.emit("change")}},{key:"_",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.message,o=n.formats,a=n.context;Ak(e)||(t=e.values||t,r=e.message,a=e.context,e=e.id);var i,s=!a&&!this.messages[e],u=a&&!this.messages[a][e],c=u||s,l=this._missing;return l&&c?Pk(l)?l(this._locale,e,a):l:(c&&this.emit("missing",{id:e,context:a,locale:this._locale}),i=a&&!u?this.messages[a][e]||r||e:this.messages[e]||r||e,Ak(i)&&Bk.test(i)?JSON.parse('"'.concat(i,'"')):Ak(i)?i:Lk(i,this._locale,this._locales,this.localeData)(t,o))}},{key:"date",value:function(e,t){return Mk(this._locales||this._locale,t)(e)}},{key:"number",value:function(e,t){return Nk(this._locales||this._locale,t)(e)}},{key:"locale",get:function(){return this._locale}},{key:"locales",get:function(){return this._locales}},{key:"messages",get:function(){var e;return null!==(e=this._messages[this._locale])&&void 0!==e?e:{}}},{key:"localeData",get:function(){var e;return null!==(e=this._localeData[this._locale])&&void 0!==e?e:{}}}]),n}(zk);var Vk=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Wk(e)}();const Hk=Vk;var Uk=n(8964),Gk=n(992),qk=n(7555),Xk=n(4973),Kk=n(4413),$k=n(9827),Zk=n(3090),Yk=n(2443),Jk=n(1471),Qk=n(5626),eC=n(8828),tC=n(2262),nC=n(2643),rC=n(7162),oC=n(8826),aC=n(4157),iC=n(5632),sC=n(8646),uC=n(9843),cC=n(4829),lC=n(8698),fC=n(606),hC=n(99),pC=n(8868),dC=n(9194),vC=n(8048),mC=n(8916),gC=n(235),yC=n(8706);const bC={[h.AR]:gC.messages,[h.CS]:Gk.messages,[h.DA]:qk.messages,[h.DE]:Xk.messages,[h.EN]:Uk.messages,[h.ES]:Kk.messages,[h.ES_419]:$k.messages,[h.ET]:fC.messages,[h.FI]:Zk.messages,[h.FR]:Yk.messages,[h.HI]:Jk.messages,[h.ID]:vC.messages,[h.IT]:Qk.messages,[h.JA]:eC.messages,[h.KO]:mC.messages,[h.LT]:pC.messages,[h.LV]:yC.messages,[h.MS]:dC.messages,[h.NB]:nC.messages,[h.NL]:tC.messages,[h.PL]:rC.messages,[h.PT]:oC.messages,[h.RO]:aC.messages,[h.RU]:iC.messages,[h.SV]:sC.messages,[h.TH]:uC.messages,[h.TR]:cC.messages,[h.UK]:hC.messages,[h.VI]:lC.messages},wC=h.EN;function xC(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const[t,n=""]=e.split("-");return{language:t,region:n}}function EC(e){const{language:t,region:n}=xC(e);return[t.toLowerCase(),n.toUpperCase()].filter(Boolean).join("-")}const _C=e=>{let{language:t,children:n}=e;const r=function(){const e=EC(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"");if(e&&Object.keys(bC).includes(e))return e;const{language:t}=xC(e);if(t&&Object.keys(bC).includes(t))return t;return Object.keys(bC).find((e=>xC(e).language===t))||wC}(t);return Hk.load(r,(e=>bC[e])(r)),Hk.activate(r),x().createElement(P,{i18n:Hk},n)};_C.defaultProps={language:wC},_C.propTypes={language:_().oneOf(Object.values(h)),children:_().node.isRequired};const OC=_C,kC=e=>{const{language:t,onError:n}=e;return x().createElement(k,{onError:n},x().createElement(OC,{language:t},x().createElement(xk,e)))}})(),module.exports=r})();
|