From af20841c03570901745a39629812b8f056ac9daa Mon Sep 17 00:00:00 2001 From: Nick McIntyre Date: Wed, 3 Aug 2022 16:40:42 -0500 Subject: [PATCH] Add p5.tidy --- README.md | 34 ++- dist/numero.js | 2 +- dist/numero.js.LICENSE.txt | 17 -- examples/ada/sketch.js | 2 +- examples/mauna-loa/sketch.js | 18 +- examples/tables/sketch.js | 37 +++- package-lock.json | 360 +++++++++++++++++------------- package.json | 9 +- src/index.ts | 4 +- src/table/groupby.ts | 169 -------------- src/table/index.ts | 277 ++++++++++++++++++++++- src/table/stats.ts | 250 --------------------- src/table/time.ts | 299 ------------------------- src/table/utils.ts | 317 --------------------------- src/table/wrangle.ts | 155 ------------- src/tensor/memory.ts | 2 +- test/index.js | 2 +- test/unit/image/index.js | 4 +- test/unit/table/groupby.js | 196 ----------------- test/unit/table/index.js | 81 +++++++ test/unit/table/joins.js | 314 ++++++++++++++++++++++++++ test/unit/table/stats.js | 411 ----------------------------------- test/unit/table/time.js | 53 ----- test/unit/table/utils.js | 231 -------------------- test/unit/table/wrangle.js | 284 ------------------------ test/unit/tensor/memory.js | 4 +- test/unit/tensor/ufunc.js | 162 +++++++------- 27 files changed, 1018 insertions(+), 2676 deletions(-) delete mode 100644 src/table/groupby.ts delete mode 100644 src/table/stats.ts delete mode 100644 src/table/time.ts delete mode 100644 src/table/utils.ts delete mode 100644 src/table/wrangle.ts delete mode 100644 test/unit/table/groupby.js create mode 100644 test/unit/table/index.js create mode 100644 test/unit/table/joins.js delete mode 100644 test/unit/table/stats.js delete mode 100644 test/unit/table/time.js delete mode 100644 test/unit/table/utils.js delete mode 100644 test/unit/table/wrangle.js diff --git a/README.md b/README.md index 1ca8c66..30b1087 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,14 @@ This addon library for p5.js turns the "software sketchbook" into a beginner-friendly environment for technical computing. It provides the following features: -- A tensor object (similar to [NumPy](https://numpy.org/) arrays) -- A computer algebra system (similar to [SymPy](https://www.sympy.org/en/index.html) -- in progress) -- A grammar of graphics (similar to [ggplot2](https://ggplot2.tidyverse.org/) -- in progress) -- A supercharged p5.Table (similar to [pandas](https://pandas.pydata.org/) DataFrames) -- A machine learning API (similar to [scikit-learn](https://scikit-learn.org/stable/index.html) -- coming soon!) -- A drawing turtle (because they're awesome) +- A tensor object similar to [NumPy](https://numpy.org/) arrays +- A computer algebra system similar to [SymPy](https://www.sympy.org/en/index.html) (in progress) +- A grammar of graphics similar to [ggplot2](https://ggplot2.tidyverse.org/) (in progress) +- A grammar of data manipulation similar to [dplyr](https://dplyr.tidyverse.org/) +- A machine learning API similar to [scikit-learn](https://scikit-learn.org/stable/index.html) (coming soon!) +- A drawing turtle -The library is written in [TypeScript](http://www.typescriptlang.org/) and uses [Day.js](https://day.js.org/), [Math.js](https://mathjs.org/), and [TensorFlow.js](https://js.tensorflow.org/api/latest/) under the hood. It bundles [p5.dataframe](https://github.com/nickmcintyre/p5.dataframe), [TurtleGFX](https://github.com/CodeGuppyPrograms/TurtleGFX), and [wildflower](https://github.com/nickmcintyre/wildflower). +The library is written in [TypeScript](http://www.typescriptlang.org/) and uses [Day.js](https://day.js.org/), [Math.js](https://mathjs.org/), [TensorFlow.js](https://js.tensorflow.org/api/latest/), and [tidy.js](https://pbeshai.github.io/tidy/) under the hood. It bundles [p5.tidy](https://github.com/nickmcintyre/p5.tidy), [TurtleGFX](https://github.com/CodeGuppyPrograms/TurtleGFX), and [wildflower](https://github.com/nickmcintyre/wildflower). ## Usage @@ -51,24 +51,22 @@ function draw() { } ``` -### Tables +### Data Wrangling View the [Mauna Loa example](/examples/mauna-loa/). ```javascript -let co2; +let data; function preload() { - co2 = loadTable('co2.csv', 'csv', 'header', wrangle); + data = loadTable('co2.csv', 'csv', 'header'); } function setup() { - noCanvas(); - print('Atmospheric Carbon Dioxide at Mauna Loa'); - co2.head(); -} - -function wrangle(table) { - table.parseDates('date'); - table.inferTypes(); + noCanvas() + const results = tidy( + data, + filter((d) => d.mean > 400), + ); + tidy(results, debug('Observations greater than 400ppm CO2')); } ``` diff --git a/dist/numero.js b/dist/numero.js index 73c5c3d..c5e8b52 100644 --- a/dist/numero.js +++ b/dist/numero.js @@ -1,2 +1,2 @@ /*! For license information please see numero.js.LICENSE.txt */ -var num;(()=>{var e={2948:(e,t,n)=>{var r=n(2140),a=n(9980),i=n(1730),s=n(7405),o=n(4026),u=n(865),l=n(8721);l.alea=r,l.xor128=a,l.xorwow=i,l.xorshift7=s,l.xor4096=o,l.tychei=u,e.exports=l},2140:function(e,t,n){var r;!function(e,a,i){function s(e){var t,n=this,r=(t=4022871197,function(e){e=e.toString();for(var n=0;n>>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 u(e,t){var n=new s(e),r=t&&t.state,a=n.next;return a.int32=function(){return 4294967296*n.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.alea=u}(0,e=n.nmd(e),n.amdD)},865:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,a=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^a,t.a=a-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>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.tychei=u}(0,e=n.nmd(e),n.amdD)},9980:function(e,t,n){var r;!function(e,a,i){function s(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>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor128=u}(0,e=n.nmd(e),n.amdD)},4026:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.w,a=t.X,i=t.i;return t.w=r=r+1640531527|0,n=a[i+34&127],e=a[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=a[i]=n^e,t.i=i,n+(r^r>>>16)|0},function(e,t){var n,r,a,i,s,o=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),a=0,i=-32;i>>15,r^=r<<4,r^=r>>>13,i>=0&&(s=s+1640531527|0,a=0==(n=o[127&i]^=r+s)?a+1:0);for(a>=128&&(o[127&(t&&t.length||0)]=-1),a=127,i=512;i>0;--i)r=o[a+34&127],n=o[a=a+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,o[a]=r^n;e.w=s,e.X=o,e.i=a}(t,e)}function o(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.X&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor4096=u}(0,e=n.nmd(e),n.amdD)},7405:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.x,a=t.i;return e=r[a],n=(e^=e>>>7)^e<<24,n^=(e=r[a+1&7])^e>>>10,n^=(e=r[a+3&7])^e>>>3,n^=(e=r[a+4&7])^e<<7,e=r[a+7&7],n^=(e^=e<<13)^e<<9,r[a]=n,t.i=a+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n0;--n)e.next()}(t,e)}function o(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.x&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorshift7=u}(0,e=n.nmd(e),n.amdD)},1730:function(e,t,n){var r;!function(e,a,i){function s(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>>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 u(e,t){var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorwow=u}(0,e=n.nmd(e),n.amdD)},8721:(e,t,n)=>{var r;!function(a,i){var s,o=this,u=256,l=i.pow(u,6),c=i.pow(2,52),p=2*c,d=255;function h(e,t,n){var r=[],d=y(g((t=1==t?{entropy:!0}:t||{}).entropy?[e,b(a)]:null==e?function(){try{var e;return s&&(e=s.randomBytes)?e=e(u):(e=new Uint8Array(u),(o.crypto||o.msCrypto).getRandomValues(e)),b(e)}catch(e){var t=o.navigator,n=t&&t.plugins;return[+new Date,o,n,o.screen,b(a)]}}():e,3),r),h=new f(r),x=function(){for(var e=h.g(6),t=l,n=0;e=p;)e/=2,t/=2,n>>>=1;return(e+n)/t};return x.int32=function(){return 0|h.g(4)},x.quick=function(){return h.g(4)/4294967296},x.double=x,y(b(h.S),a),(t.pass||n||function(e,t,n,r){return r&&(r.S&&m(r,h),e.state=function(){return m(h,{})}),n?(i.random=e,t):e})(x,d,"global"in t?t.global:this==i,t.state)}function f(e){var t,n=e.length,r=this,a=0,i=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);a{var r=n(626),a=n(477),i=n(2868),s=n(8197),o=n(1954),u=n(2408),l=n(1662);l.alea=r,l.xor128=a,l.xorwow=i,l.xorshift7=s,l.xor4096=o,l.tychei=u,e.exports=l},626:function(e,t,n){var r;!function(e,a,i){function s(e){var t,n=this,r=(t=4022871197,function(e){e=e.toString();for(var n=0;n>>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 u(e,t){var n=new s(e),r=t&&t.state,a=n.next;return a.int32=function(){return 4294967296*n.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.alea=u}(0,e=n.nmd(e),n.amdD)},2408:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,a=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^a,t.a=a-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>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.tychei=u}(0,e=n.nmd(e),n.amdD)},477:function(e,t,n){var r;!function(e,a,i){function s(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>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor128=u}(0,e=n.nmd(e),n.amdD)},1954:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.w,a=t.X,i=t.i;return t.w=r=r+1640531527|0,n=a[i+34&127],e=a[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=a[i]=n^e,t.i=i,n+(r^r>>>16)|0},function(e,t){var n,r,a,i,s,o=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),a=0,i=-32;i>>15,r^=r<<4,r^=r>>>13,i>=0&&(s=s+1640531527|0,a=0==(n=o[127&i]^=r+s)?a+1:0);for(a>=128&&(o[127&(t&&t.length||0)]=-1),a=127,i=512;i>0;--i)r=o[a+34&127],n=o[a=a+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,o[a]=r^n;e.w=s,e.X=o,e.i=a}(t,e)}function o(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.X&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor4096=u}(0,e=n.nmd(e),n.amdD)},8197:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.x,a=t.i;return e=r[a],n=(e^=e>>>7)^e<<24,n^=(e=r[a+1&7])^e>>>10,n^=(e=r[a+3&7])^e>>>3,n^=(e=r[a+4&7])^e<<7,e=r[a+7&7],n^=(e^=e<<13)^e<<9,r[a]=n,t.i=a+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n0;--n)e.next()}(t,e)}function o(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.x&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorshift7=u}(0,e=n.nmd(e),n.amdD)},2868:function(e,t,n){var r;!function(e,a,i){function s(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>>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 u(e,t){var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorwow=u}(0,e=n.nmd(e),n.amdD)},1662:(e,t,n)=>{var r;!function(a,i){var s,o=this,u=256,l=i.pow(u,6),c=i.pow(2,52),p=2*c,d=255;function h(e,t,n){var r=[],d=y(g((t=1==t?{entropy:!0}:t||{}).entropy?[e,b(a)]:null==e?function(){try{var e;return s&&(e=s.randomBytes)?e=e(u):(e=new Uint8Array(u),(o.crypto||o.msCrypto).getRandomValues(e)),b(e)}catch(e){var t=o.navigator,n=t&&t.plugins;return[+new Date,o,n,o.screen,b(a)]}}():e,3),r),h=new f(r),x=function(){for(var e=h.g(6),t=l,n=0;e=p;)e/=2,t/=2,n>>>=1;return(e+n)/t};return x.int32=function(){return 0|h.g(4)},x.quick=function(){return h.g(4)/4294967296},x.double=x,y(b(h.S),a),(t.pass||n||function(e,t,n,r){return r&&(r.S&&m(r,h),e.state=function(){return m(h,{})}),n?(i.random=e,t):e})(x,d,"global"in t?t.global:this==i,t.state)}function f(e){var t,n=e.length,r=this,a=0,i=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);a0&&s();break;case"number":n.im=0,n.re=e;break;default:s()}return isNaN(n.re)||isNaN(n.im),n}(e,t);this.re=n.re,this.im=n.im}u.prototype={re:0,im:0,sign:function(){var e=this.abs();return new u(this.re/e,this.im/e)},add:function(e,t){var n=new u(e,t);return this.isInfinite()&&n.isInfinite()?u.NAN:this.isInfinite()||n.isInfinite()?u.INFINITY:new u(this.re+n.re,this.im+n.im)},sub:function(e,t){var n=new u(e,t);return this.isInfinite()&&n.isInfinite()?u.NAN:this.isInfinite()||n.isInfinite()?u.INFINITY:new u(this.re-n.re,this.im-n.im)},mul:function(e,t){var n=new u(e,t);return this.isInfinite()&&n.isZero()||this.isZero()&&n.isInfinite()?u.NAN:this.isInfinite()||n.isInfinite()?u.INFINITY:0===n.im&&0===this.im?new u(this.re*n.re,0):new u(this.re*n.re-this.im*n.im,this.re*n.im+this.im*n.re)},div:function(e,t){var n=new u(e,t);if(this.isZero()&&n.isZero()||this.isInfinite()&&n.isInfinite())return u.NAN;if(this.isInfinite()||n.isZero())return u.INFINITY;if(this.isZero()||n.isInfinite())return u.ZERO;e=this.re,t=this.im;var r,a,i=n.re,s=n.im;return 0===s?new u(e/i,t/i):Math.abs(i)0)return new u(Math.pow(e,n.re),0);if(0===e)switch((n.re%4+4)%4){case 0:return new u(Math.pow(t,n.re),0);case 1:return new u(0,Math.pow(t,n.re));case 2:return new u(-Math.pow(t,n.re),0);case 3:return new u(0,-Math.pow(t,n.re))}}if(0===e&&0===t&&n.re>0&&n.im>=0)return u.ZERO;var r=Math.atan2(t,e),a=o(e,t);return e=Math.exp(n.re*a-n.im*r),t=n.im*a+n.re*r,new u(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,n=this.re,r=this.im,a=this.abs();if(n>=0){if(0===r)return new u(Math.sqrt(n),0);e=.5*Math.sqrt(2*(a+n))}else e=Math.abs(r)/Math.sqrt(2*(a-n));return t=n<=0?.5*Math.sqrt(2*(a-n)):Math.abs(r)/Math.sqrt(2*(a+n)),new u(e,r<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new u(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(-t>e||e>t)return Math.cos(e)-1;var n=e*e;return n*(n*(n*(n*(n*(n*(n*(n/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new u(o(e,t),Math.atan2(t,e))},abs:function(){return e=this.re,t=this.im,n=Math.abs(e),r=Math.abs(t),n<3e3&&r<3e3?Math.sqrt(n*n+r*r):(n1&&0===t,r=1-e,a=1+e,i=r*r+t*t,s=0!==i?new u((a*r-t*t)/i,(t*r+a*t)/i):new u(-1!==e?e/0:0,0!==t?t/0:0),l=s.re;return s.re=o(s.re,s.im)/2,s.im=Math.atan2(s.im,l)/2,n&&(s.im=-s.im),s},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(0,Math.PI/2);var n=e*e+t*t;return 0!==n?new u(e/n,-t/n).atanh():new u(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var n=e*e+t*t;return 0!==n?new u(e/n,-t/n).asinh():new u(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return u.INFINITY;var n=e*e+t*t;return 0!==n?new u(e/n,-t/n).acosh():new u(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,t=this.im,n=e*e+t*t;return new u(e/n,-t/n)},conjugate:function(){return new u(this.re,-this.im)},neg:function(){return new u(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new u(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new u(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new u(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){var n=new u(e,t);return Math.abs(n.re-this.re)<=u.EPSILON&&Math.abs(n.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){var e=this.re,t=this.im,n="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)=t?e:""+Array(t+1-r.length).join(n)+e},y={s:g,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),a=n%60;return(t<=0?"+":"-")+g(r,2,"0")+":"+g(a,2,"0")},m:function e(t,n){if(t.date()1)return e(s[0])}else{var o=t.name;x[o]=t,a=o}return!r&&a&&(b=a),a||!r&&b},w=function(e,t){if(v(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new N(n)},M=y;M.l=_,M.i=v,M.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var N=function(){function m(e){this.$L=_(e.locale,null,!0),this.parse(e)}var g=m.prototype;return g.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(M.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(h);if(r){var a=r[2]-1||0,i=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],a,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)):new Date(r[1],a,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)}}return new Date(t)}(e),this.$x=e.x||{},this.init()},g.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},g.$utils=function(){return M},g.isValid=function(){return!(this.$d.toString()===d)},g.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},g.isAfter=function(e,t){return w(e)12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},7719:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-iq",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"كانون الثاني_شباط_آذار_نيسان_أيار_حزيران_تموز_آب_أيلول_تشرين الأول_ تشرين الثاني_كانون الأول".split("_"),weekStart:1,weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"كانون الثاني_شباط_آذار_نيسان_أيار_حزيران_تموز_آب_أيلول_تشرين الأول_ تشرين الثاني_كانون الأول".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},2376:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-kw",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekdaysShort:"احد_اثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},8540:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-ly",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekStart:6,weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},meridiem:function(e){return e>12?"م":"ص"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"D/‏M/‏YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},6817:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-ma",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekStart:6,weekdaysShort:"احد_إثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},1573:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-sa",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},9339:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-tn",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekStart:1,weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},3939:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),r={1:"١",2:"٢",3:"٣",4:"٤",5:"٥",6:"٦",7:"٧",8:"٨",9:"٩",0:"٠"},a={"١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","٠":"0"},i={name:"ar",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),months:n,monthsShort:n,weekStart:6,relativeTime:{future:"بعد %s",past:"منذ %s",s:"ثانية واحدة",m:"دقيقة واحدة",mm:"%d دقائق",h:"ساعة واحدة",hh:"%d ساعات",d:"يوم واحد",dd:"%d أيام",M:"شهر واحد",MM:"%d أشهر",y:"عام واحد",yy:"%d أعوام"},preparse:function(e){return e.replace(/[١٢٣٤٥٦٧٨٩٠]/g,(function(e){return a[e]})).replace(/،/g,",")},postformat:function(e){return e.replace(/\d/g,(function(e){return r[e]})).replace(/,/g,"،")},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"D/‏M/‏YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"}};return t.default.locale(i,null,!0),i}(n(7484))},8092:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"az",weekdays:"Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə".split("_"),weekdaysShort:"Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən".split("_"),weekdaysMin:"Bz_BE_ÇA_Çə_CA_Cü_Şə".split("_"),months:"yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr".split("_"),monthsShort:"yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., H:mm",LLLL:"dddd, D MMMM YYYY г., H:mm"},relativeTime:{future:"%s sonra",past:"%s əvvəl",s:"bir neçə saniyə",m:"bir dəqiqə",mm:"%d dəqiqə",h:"bir saat",hh:"%d saat",d:"bir gün",dd:"%d gün",M:"bir ay",MM:"%d ay",y:"bir il",yy:"%d il"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},504:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"be",weekdays:"нядзелю_панядзелак_аўторак_сераду_чацвер_пятніцу_суботу".split("_"),months:"студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня".split("_"),weekStart:1,weekdaysShort:"нд_пн_ат_ср_чц_пт_сб".split("_"),monthsShort:"студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж".split("_"),weekdaysMin:"нд_пн_ат_ср_чц_пт_сб".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., HH:mm",LLLL:"dddd, D MMMM YYYY г., HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},9091:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bg",weekdays:"неделя_понеделник_вторник_сряда_четвъртък_петък_събота".split("_"),weekdaysShort:"нед_пон_вто_сря_чет_пет_съб".split("_"),weekdaysMin:"нд_пн_вт_ср_чт_пт_сб".split("_"),months:"януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември".split("_"),monthsShort:"янр_фев_мар_апр_май_юни_юли_авг_сеп_окт_ное_дек".split("_"),weekStart:1,ordinal:function(e){var t=e%100;if(t>10&&t<20)return e+"-ти";var n=e%10;return 1===n?e+"-ви":2===n?e+"-ри":7===n||8===n?e+"-ми":e+"-ти"},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY H:mm",LLLL:"dddd, D MMMM YYYY H:mm"},relativeTime:{future:"след %s",past:"преди %s",s:"няколко секунди",m:"минута",mm:"%d минути",h:"час",hh:"%d часа",d:"ден",dd:"%d дена",M:"месец",MM:"%d месеца",y:"година",yy:"%d години"}};return t.default.locale(n,null,!0),n}(n(7484))},9149:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bi",weekdays:"Sande_Mande_Tusde_Wenesde_Tosde_Fraede_Sarade".split("_"),months:"Januari_Februari_Maj_Eprel_Mei_Jun_Julae_Okis_Septemba_Oktoba_Novemba_Disemba".split("_"),weekStart:1,weekdaysShort:"San_Man_Tus_Wen_Tos_Frae_Sar".split("_"),monthsShort:"Jan_Feb_Maj_Epr_Mai_Jun_Jul_Oki_Sep_Okt_Nov_Dis".split("_"),weekdaysMin:"San_Ma_Tu_We_To_Fr_Sar".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"lo %s",past:"%s bifo",s:"sam seken",m:"wan minit",mm:"%d minit",h:"wan haoa",hh:"%d haoa",d:"wan dei",dd:"%d dei",M:"wan manis",MM:"%d manis",y:"wan yia",yy:"%d yia"}};return t.default.locale(n,null,!0),n}(n(7484))},5287:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bm",weekdays:"Kari_Ntɛnɛn_Tarata_Araba_Alamisa_Juma_Sibiri".split("_"),months:"Zanwuyekalo_Fewuruyekalo_Marisikalo_Awirilikalo_Mɛkalo_Zuwɛnkalo_Zuluyekalo_Utikalo_Sɛtanburukalo_ɔkutɔburukalo_Nowanburukalo_Desanburukalo".split("_"),weekStart:1,weekdaysShort:"Kar_Ntɛ_Tar_Ara_Ala_Jum_Sib".split("_"),monthsShort:"Zan_Few_Mar_Awi_Mɛ_Zuw_Zul_Uti_Sɛt_ɔku_Now_Des".split("_"),weekdaysMin:"Ka_Nt_Ta_Ar_Al_Ju_Si".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"MMMM [tile] D [san] YYYY",LLL:"MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm",LLLL:"dddd MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm"},relativeTime:{future:"%s kɔnɔ",past:"a bɛ %s bɔ",s:"sanga dama dama",m:"miniti kelen",mm:"miniti %d",h:"lɛrɛ kelen",hh:"lɛrɛ %d",d:"tile kelen",dd:"tile %d",M:"kalo kelen",MM:"kalo %d",y:"san kelen",yy:"san %d"}};return t.default.locale(n,null,!0),n}(n(7484))},5254:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={1:"১",2:"২",3:"৩",4:"৪",5:"৫",6:"৬",7:"৭",8:"৮",9:"৯",0:"০"},r={"১":"1","২":"2","৩":"3","৪":"4","৫":"5","৬":"6","৭":"7","৮":"8","৯":"9","০":"0"},a={name:"bn",weekdays:"রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পতিবার_শুক্রবার_শনিবার".split("_"),months:"জানুয়ারি_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর".split("_"),weekdaysShort:"রবি_সোম_মঙ্গল_বুধ_বৃহস্পতি_শুক্র_শনি".split("_"),monthsShort:"জানু_ফেব্রু_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্ট_অক্টো_নভে_ডিসে".split("_"),weekdaysMin:"রবি_সোম_মঙ্গ_বুধ_বৃহঃ_শুক্র_শনি".split("_"),preparse:function(e){return e.replace(/[১২৩৪৫৬৭৮৯০]/g,(function(e){return r[e]}))},postformat:function(e){return e.replace(/\d/g,(function(e){return n[e]}))},ordinal:function(e){return e},formats:{LT:"A h:mm সময়",LTS:"A h:mm:ss সময়",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm সময়",LLLL:"dddd, D MMMM YYYY, A h:mm সময়"},relativeTime:{future:"%s পরে",past:"%s আগে",s:"কয়েক সেকেন্ড",m:"এক মিনিট",mm:"%d মিনিট",h:"এক ঘন্টা",hh:"%d ঘন্টা",d:"এক দিন",dd:"%d দিন",M:"এক মাস",MM:"%d মাস",y:"এক বছর",yy:"%d বছর"}};return t.default.locale(a,null,!0),a}(n(7484))},2502:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bo",weekdays:"གཟའ་ཉི་མ་_གཟའ་ཟླ་བ་_གཟའ་མིག་དམར་_གཟའ་ལྷག་པ་_གཟའ་ཕུར་བུ_གཟའ་པ་སངས་_གཟའ་སྤེན་པ་".split("_"),weekdaysShort:"ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་".split("_"),weekdaysMin:"ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་".split("_"),months:"ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ".split("_"),monthsShort:"ཟླ་དང་པོ_ཟླ་གཉིས་པ_ཟླ་གསུམ་པ_ཟླ་བཞི་པ_ཟླ་ལྔ་པ_ཟླ་དྲུག་པ_ཟླ་བདུན་པ_ཟླ་བརྒྱད་པ_ཟླ་དགུ་པ_ཟླ་བཅུ་པ_ཟླ་བཅུ་གཅིག་པ_ཟླ་བཅུ་གཉིས་པ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm",LLLL:"dddd, D MMMM YYYY, A h:mm"},relativeTime:{future:"%s ལ་",past:"%s སྔོན་ལ་",s:"ཏོག་ཙམ་",m:"སྐར་མ་གཅིག་",mm:"སྐར་མ་ %d",h:"ཆུ་ཚོད་གཅིག་",hh:"ཆུ་ཚོད་ %d",d:"ཉིན་གཅིག་",dd:"ཉིན་ %d",M:"ཟླ་བ་གཅིག་",MM:"ཟླ་བ་ %d",y:"ལོ་གཅིག་",yy:"ལོ་ %d"}};return t.default.locale(n,null,!0),n}(n(7484))},8864:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e>9?n(e%10):e}function r(e,t,n){return e+" "+function(e,t){return 2===t?function(e){return{m:"v",b:"v",d:"z"}[e.charAt(0)]+e.substring(1)}(e):e}({mm:"munutenn",MM:"miz",dd:"devezh"}[n],e)}var a={name:"br",weekdays:"Sul_Lun_Meurzh_Mercʼher_Yaou_Gwener_Sadorn".split("_"),months:"Genver_Cʼhwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu".split("_"),weekStart:1,weekdaysShort:"Sul_Lun_Meu_Mer_Yao_Gwe_Sad".split("_"),monthsShort:"Gen_Cʼhwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker".split("_"),weekdaysMin:"Su_Lu_Me_Mer_Ya_Gw_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"h[e]mm A",LTS:"h[e]mm:ss A",L:"DD/MM/YYYY",LL:"D [a viz] MMMM YYYY",LLL:"D [a viz] MMMM YYYY h[e]mm A",LLLL:"dddd, D [a viz] MMMM YYYY h[e]mm A"},relativeTime:{future:"a-benn %s",past:"%s ʼzo",s:"un nebeud segondennoù",m:"ur vunutenn",mm:r,h:"un eur",hh:"%d eur",d:"un devezh",dd:r,M:"ur miz",MM:r,y:"ur bloaz",yy:function(e){switch(n(e)){case 1:case 3:case 4:case 5:case 9:return e+" bloaz";default:return e+" vloaz"}}},meridiem:function(e){return e<12?"a.m.":"g.m."}};return t.default.locale(a,null,!0),a}(n(7484))},4502:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bs",weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),months:"januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar".split("_"),weekStart:1,weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),monthsShort:"jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},3646:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ca",weekdays:"Diumenge_Dilluns_Dimarts_Dimecres_Dijous_Divendres_Dissabte".split("_"),weekdaysShort:"Dg._Dl._Dt._Dc._Dj._Dv._Ds.".split("_"),weekdaysMin:"Dg_Dl_Dt_Dc_Dj_Dv_Ds".split("_"),months:"Gener_Febrer_Març_Abril_Maig_Juny_Juliol_Agost_Setembre_Octubre_Novembre_Desembre".split("_"),monthsShort:"Gen._Febr._Març_Abr._Maig_Juny_Jul._Ag._Set._Oct._Nov._Des.".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM [de] YYYY",LLL:"D MMMM [de] YYYY [a les] H:mm",LLLL:"dddd D MMMM [de] YYYY [a les] H:mm",ll:"D MMM YYYY",lll:"D MMM YYYY, H:mm",llll:"ddd D MMM YYYY, H:mm"},relativeTime:{future:"d'aquí %s",past:"fa %s",s:"uns segons",m:"un minut",mm:"%d minuts",h:"una hora",hh:"%d hores",d:"un dia",dd:"%d dies",M:"un mes",MM:"%d mesos",y:"un any",yy:"%d anys"},ordinal:function(e){return e+(1===e||3===e?"r":2===e?"n":4===e?"t":"è")}};return t.default.locale(n,null,!0),n}(n(7484))},8507:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e>1&&e<5&&1!=~~(e/10)}function r(e,t,r,a){var i=e+" ";switch(r){case"s":return t||a?"pár sekund":"pár sekundami";case"m":return t?"minuta":a?"minutu":"minutou";case"mm":return t||a?i+(n(e)?"minuty":"minut"):i+"minutami";case"h":return t?"hodina":a?"hodinu":"hodinou";case"hh":return t||a?i+(n(e)?"hodiny":"hodin"):i+"hodinami";case"d":return t||a?"den":"dnem";case"dd":return t||a?i+(n(e)?"dny":"dní"):i+"dny";case"M":return t||a?"měsíc":"měsícem";case"MM":return t||a?i+(n(e)?"měsíce":"měsíců"):i+"měsíci";case"y":return t||a?"rok":"rokem";case"yy":return t||a?i+(n(e)?"roky":"let"):i+"lety"}}var a={name:"cs",weekdays:"neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota".split("_"),weekdaysShort:"ne_po_út_st_čt_pá_so".split("_"),weekdaysMin:"ne_po_út_st_čt_pá_so".split("_"),months:"leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec".split("_"),monthsShort:"led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro".split("_"),weekStart:1,yearStart:4,ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd D. MMMM YYYY H:mm",l:"D. M. YYYY"},relativeTime:{future:"za %s",past:"před %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},6636:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"cv",weekdays:"вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун".split("_"),months:"кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав".split("_"),weekStart:1,weekdaysShort:"выр_тун_ытл_юн_кӗҫ_эрн_шӑм".split("_"),monthsShort:"кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш".split("_"),weekdaysMin:"вр_тн_ыт_юн_кҫ_эр_шм".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]",LLL:"YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm",LLLL:"dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8792:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"cy",weekdays:"Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn".split("_"),months:"Ionawr_Chwefror_Mawrth_Ebrill_Mai_Mehefin_Gorffennaf_Awst_Medi_Hydref_Tachwedd_Rhagfyr".split("_"),weekStart:1,weekdaysShort:"Sul_Llun_Maw_Mer_Iau_Gwe_Sad".split("_"),monthsShort:"Ion_Chwe_Maw_Ebr_Mai_Meh_Gor_Aws_Med_Hyd_Tach_Rhag".split("_"),weekdaysMin:"Su_Ll_Ma_Me_Ia_Gw_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"mewn %s",past:"%s yn ôl",s:"ychydig eiliadau",m:"munud",mm:"%d munud",h:"awr",hh:"%d awr",d:"diwrnod",dd:"%d diwrnod",M:"mis",MM:"%d mis",y:"blwyddyn",yy:"%d flynedd"}};return t.default.locale(n,null,!0),n}(n(7484))},7427:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"da",weekdays:"søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),weekdaysShort:"søn._man._tirs._ons._tors._fre._lør.".split("_"),weekdaysMin:"sø._ma._ti._on._to._fr._lø.".split("_"),months:"januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december".split("_"),monthsShort:"jan._feb._mar._apr._maj_juni_juli_aug._sept._okt._nov._dec.".split("_"),weekStart:1,ordinal:function(e){return e+"."},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd [d.] D. MMMM YYYY [kl.] HH:mm"},relativeTime:{future:"om %s",past:"%s siden",s:"få sekunder",m:"et minut",mm:"%d minutter",h:"en time",hh:"%d timer",d:"en dag",dd:"%d dage",M:"en måned",MM:"%d måneder",y:"et år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},3237:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"ein paar Sekunden",m:["eine Minute","einer Minute"],mm:"%d Minuten",h:["eine Stunde","einer Stunde"],hh:"%d Stunden",d:["ein Tag","einem Tag"],dd:["%d Tage","%d Tagen"],M:["ein Monat","einem Monat"],MM:["%d Monate","%d Monaten"],y:["ein Jahr","einem Jahr"],yy:["%d Jahre","%d Jahren"]};function r(e,t,r){var a=n[r];return Array.isArray(a)&&(a=a[t?0:1]),a.replace("%d",e)}var a={name:"de-at",weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),months:"Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jän._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.".split("_"),ordinal:function(e){return e+"."},weekStart:1,formats:{LTS:"HH:mm:ss",LT:"HH:mm",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd, D. MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"vor %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},6148:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"ein paar Sekunden",m:["eine Minute","einer Minute"],mm:"%d Minuten",h:["eine Stunde","einer Stunde"],hh:"%d Stunden",d:["ein Tag","einem Tag"],dd:["%d Tage","%d Tagen"],M:["ein Monat","einem Monat"],MM:["%d Monate","%d Monaten"],y:["ein Jahr","einem Jahr"],yy:["%d Jahre","%d Jahren"]};function r(e,t,r){var a=n[r];return Array.isArray(a)&&(a=a[t?0:1]),a.replace("%d",e)}var a={name:"de-ch",weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),months:"Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.".split("_"),ordinal:function(e){return e+"."},weekStart:1,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd, D. MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"vor %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},790:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"ein paar Sekunden",m:["eine Minute","einer Minute"],mm:"%d Minuten",h:["eine Stunde","einer Stunde"],hh:"%d Stunden",d:["ein Tag","einem Tag"],dd:["%d Tage","%d Tagen"],M:["ein Monat","einem Monat"],MM:["%d Monate","%d Monaten"],y:["ein Jahr","einem Jahr"],yy:["%d Jahre","%d Jahren"]};function r(e,t,r){var a=n[r];return Array.isArray(a)&&(a=a[t?0:1]),a.replace("%d",e)}var a={name:"de",weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),months:"Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sept._Okt._Nov._Dez.".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,formats:{LTS:"HH:mm:ss",LT:"HH:mm",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd, D. MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"vor %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},1794:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"dv",weekdays:"އާދިއްތަ_ހޯމަ_އަންގާރަ_ބުދަ_ބުރާސްފަތި_ހުކުރު_ހޮނިހިރު".split("_"),months:"ޖެނުއަރީ_ފެބްރުއަރީ_މާރިޗު_އޭޕްރީލު_މޭ_ޖޫން_ޖުލައި_އޯގަސްޓު_ސެޕްޓެމްބަރު_އޮކްޓޯބަރު_ނޮވެމްބަރު_ޑިސެމްބަރު".split("_"),weekStart:7,weekdaysShort:"އާދިއްތަ_ހޯމަ_އަންގާރަ_ބުދަ_ބުރާސްފަތި_ހުކުރު_ހޮނިހިރު".split("_"),monthsShort:"ޖެނުއަރީ_ފެބްރުއަރީ_މާރިޗު_އޭޕްރީލު_މޭ_ޖޫން_ޖުލައި_އޯގަސްޓު_ސެޕްޓެމްބަރު_އޮކްޓޯބަރު_ނޮވެމްބަރު_ޑިސެމްބަރު".split("_"),weekdaysMin:"އާދި_ހޯމަ_އަން_ބުދަ_ބުރާ_ހުކު_ހޮނި".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"D/M/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"ތެރޭގައި %s",past:"ކުރިން %s",s:"ސިކުންތުކޮޅެއް",m:"މިނިޓެއް",mm:"މިނިޓު %d",h:"ގަޑިއިރެއް",hh:"ގަޑިއިރު %d",d:"ދުވަހެއް",dd:"ދުވަސް %d",M:"މަހެއް",MM:"މަސް %d",y:"އަހަރެއް",yy:"އަހަރު %d"}};return t.default.locale(n,null,!0),n}(n(7484))},5423:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"el",weekdays:"Κυριακή_Δευτέρα_Τρίτη_Τετάρτη_Πέμπτη_Παρασκευή_Σάββατο".split("_"),weekdaysShort:"Κυρ_Δευ_Τρι_Τετ_Πεμ_Παρ_Σαβ".split("_"),weekdaysMin:"Κυ_Δε_Τρ_Τε_Πε_Πα_Σα".split("_"),months:"Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος".split("_"),monthsShort:"Ιαν_Φεβ_Μαρ_Απρ_Μαι_Ιουν_Ιουλ_Αυγ_Σεπτ_Οκτ_Νοε_Δεκ".split("_"),ordinal:function(e){return e},weekStart:1,relativeTime:{future:"σε %s",past:"πριν %s",s:"μερικά δευτερόλεπτα",m:"ένα λεπτό",mm:"%d λεπτά",h:"μία ώρα",hh:"%d ώρες",d:"μία μέρα",dd:"%d μέρες",M:"ένα μήνα",MM:"%d μήνες",y:"ένα χρόνο",yy:"%d χρόνια"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"}};return t.default.locale(n,null,!0),n}(n(7484))},5109:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-au",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},5105:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-ca",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"YYYY-MM-DD",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},9517:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-gb",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekStart:1,yearStart:4,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}};return t.default.locale(n,null,!0),n}(n(7484))},758:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-ie",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},5805:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-il",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},8529:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-in",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekStart:1,yearStart:4,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}};return t.default.locale(n,null,!0),n}(n(7484))},302:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-nz",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},5941:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-sg",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},6183:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-tt",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekStart:1,yearStart:4,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}};return t.default.locale(n,null,!0),n}(n(7484))},5054:function(e){e.exports=function(){"use strict";return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")}}()},4990:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"eo",weekdays:"dimanĉo_lundo_mardo_merkredo_ĵaŭdo_vendredo_sabato".split("_"),months:"januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro".split("_"),weekStart:1,weekdaysShort:"dim_lun_mard_merk_ĵaŭ_ven_sab".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec".split("_"),weekdaysMin:"di_lu_ma_me_ĵa_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D[-a de] MMMM, YYYY",LLL:"D[-a de] MMMM, YYYY HH:mm",LLLL:"dddd, [la] D[-a de] MMMM, YYYY HH:mm"},relativeTime:{future:"post %s",past:"antaŭ %s",s:"sekundoj",m:"minuto",mm:"%d minutoj",h:"horo",hh:"%d horoj",d:"tago",dd:"%d tagoj",M:"monato",MM:"%d monatoj",y:"jaro",yy:"%d jaroj"}};return t.default.locale(n,null,!0),n}(n(7484))},3864:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-do",weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekStart:1,relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY h:mm A",LLLL:"dddd, D [de] MMMM [de] YYYY h:mm A"}};return t.default.locale(n,null,!0),n}(n(7484))},7118:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-mx",weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},3521:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-pr",monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),weekStart:1,formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"MM/DD/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY h:mm A",LLLL:"dddd, D [de] MMMM [de] YYYY h:mm A"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},6165:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-us",weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"MM/DD/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY h:mm A",LLLL:"dddd, D [de] MMMM [de] YYYY h:mm A"}};return t.default.locale(n,null,!0),n}(n(7484))},7763:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es",monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},9670:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e,t,n,r){var a={s:["mõne sekundi","mõni sekund","paar sekundit"],m:["ühe minuti","üks minut"],mm:["%d minuti","%d minutit"],h:["ühe tunni","tund aega","üks tund"],hh:["%d tunni","%d tundi"],d:["ühe päeva","üks päev"],M:["kuu aja","kuu aega","üks kuu"],MM:["%d kuu","%d kuud"],y:["ühe aasta","aasta","üks aasta"],yy:["%d aasta","%d aastat"]};return t?(a[n][2]?a[n][2]:a[n][1]).replace("%d",e):(r?a[n][0]:a[n][1]).replace("%d",e)}var r={name:"et",weekdays:"pühapäev_esmaspäev_teisipäev_kolmapäev_neljapäev_reede_laupäev".split("_"),weekdaysShort:"P_E_T_K_N_R_L".split("_"),weekdaysMin:"P_E_T_K_N_R_L".split("_"),months:"jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember".split("_"),monthsShort:"jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"%s pärast",past:"%s tagasi",s:n,m:n,mm:n,h:n,hh:n,d:n,dd:"%d päeva",M:n,MM:n,y:n,yy:n},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"}};return t.default.locale(r,null,!0),r}(n(7484))},6629:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"eu",weekdays:"igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata".split("_"),months:"urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua".split("_"),weekStart:1,weekdaysShort:"ig._al._ar._az._og._ol._lr.".split("_"),monthsShort:"urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.".split("_"),weekdaysMin:"ig_al_ar_az_og_ol_lr".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY[ko] MMMM[ren] D[a]",LLL:"YYYY[ko] MMMM[ren] D[a] HH:mm",LLLL:"dddd, YYYY[ko] MMMM[ren] D[a] HH:mm",l:"YYYY-M-D",ll:"YYYY[ko] MMM D[a]",lll:"YYYY[ko] MMM D[a] HH:mm",llll:"ddd, YYYY[ko] MMM D[a] HH:mm"},relativeTime:{future:"%s barru",past:"duela %s",s:"segundo batzuk",m:"minutu bat",mm:"%d minutu",h:"ordu bat",hh:"%d ordu",d:"egun bat",dd:"%d egun",M:"hilabete bat",MM:"%d hilabete",y:"urte bat",yy:"%d urte"}};return t.default.locale(n,null,!0),n}(n(7484))},6953:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fa",weekdays:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysShort:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysMin:"ی_د_س_چ_پ_ج_ش".split("_"),weekStart:6,months:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),monthsShort:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"در %s",past:"%s پیش",s:"چند ثانیه",m:"یک دقیقه",mm:"%d دقیقه",h:"یک ساعت",hh:"%d ساعت",d:"یک روز",dd:"%d روز",M:"یک ماه",MM:"%d ماه",y:"یک سال",yy:"%d سال"}};return t.default.locale(n,null,!0),n}(n(7484))},7822:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e,t,n,r){var a={s:"muutama sekunti",m:"minuutti",mm:"%d minuuttia",h:"tunti",hh:"%d tuntia",d:"päivä",dd:"%d päivää",M:"kuukausi",MM:"%d kuukautta",y:"vuosi",yy:"%d vuotta",numbers:"nolla_yksi_kaksi_kolme_neljä_viisi_kuusi_seitsemän_kahdeksan_yhdeksän".split("_")},i={s:"muutaman sekunnin",m:"minuutin",mm:"%d minuutin",h:"tunnin",hh:"%d tunnin",d:"päivän",dd:"%d päivän",M:"kuukauden",MM:"%d kuukauden",y:"vuoden",yy:"%d vuoden",numbers:"nollan_yhden_kahden_kolmen_neljän_viiden_kuuden_seitsemän_kahdeksan_yhdeksän".split("_")},s=r&&!t?i:a,o=s[n];return e<10?o.replace("%d",s.numbers[e]):o.replace("%d",e)}var r={name:"fi",weekdays:"sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai".split("_"),weekdaysShort:"su_ma_ti_ke_to_pe_la".split("_"),weekdaysMin:"su_ma_ti_ke_to_pe_la".split("_"),months:"tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu".split("_"),monthsShort:"tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,relativeTime:{future:"%s päästä",past:"%s sitten",s:n,m:n,mm:n,h:n,hh:n,d:n,dd:n,M:n,MM:n,y:n,yy:n},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD.MM.YYYY",LL:"D. MMMM[ta] YYYY",LLL:"D. MMMM[ta] YYYY, [klo] HH.mm",LLLL:"dddd, D. MMMM[ta] YYYY, [klo] HH.mm",l:"D.M.YYYY",ll:"D. MMM YYYY",lll:"D. MMM YYYY, [klo] HH.mm",llll:"ddd, D. MMM YYYY, [klo] HH.mm"}};return t.default.locale(r,null,!0),r}(n(7484))},9197:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fo",weekdays:"sunnudagur_mánadagur_týsdagur_mikudagur_hósdagur_fríggjadagur_leygardagur".split("_"),months:"januar_februar_mars_apríl_mai_juni_juli_august_september_oktober_november_desember".split("_"),weekStart:1,weekdaysShort:"sun_mán_týs_mik_hós_frí_ley".split("_"),monthsShort:"jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des".split("_"),weekdaysMin:"su_má_tý_mi_hó_fr_le".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D. MMMM, YYYY HH:mm"},relativeTime:{future:"um %s",past:"%s síðani",s:"fá sekund",m:"ein minuttur",mm:"%d minuttir",h:"ein tími",hh:"%d tímar",d:"ein dagur",dd:"%d dagar",M:"ein mánaður",MM:"%d mánaðir",y:"eitt ár",yy:"%d ár"}};return t.default.locale(n,null,!0),n}(n(7484))},7989:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fr-ca",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"}};return t.default.locale(n,null,!0),n}(n(7484))},4254:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fr-ch",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),weekStart:1,weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"}};return t.default.locale(n,null,!0),n}(n(7484))},6023:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fr",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"},ordinal:function(e){return e+(1===e?"er":"e")}};return t.default.locale(n,null,!0),n}(n(7484))},3220:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fy",weekdays:"snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon".split("_"),months:"jannewaris_febrewaris_maart_april_maaie_juny_july_augustus_septimber_oktober_novimber_desimber".split("_"),monthsShort:"jan._feb._mrt._apr._mai_jun._jul._aug._sep._okt._nov._des.".split("_"),weekStart:1,weekdaysShort:"si._mo._ti._wo._to._fr._so.".split("_"),weekdaysMin:"Si_Mo_Ti_Wo_To_Fr_So".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"oer %s",past:"%s lyn",s:"in pear sekonden",m:"ien minút",mm:"%d minuten",h:"ien oere",hh:"%d oeren",d:"ien dei",dd:"%d dagen",M:"ien moanne",MM:"%d moannen",y:"ien jier",yy:"%d jierren"}};return t.default.locale(n,null,!0),n}(n(7484))},7467:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ga",weekdays:"Dé Domhnaigh_Dé Luain_Dé Máirt_Dé Céadaoin_Déardaoin_Dé hAoine_Dé Satharn".split("_"),months:"Eanáir_Feabhra_Márta_Aibreán_Bealtaine_Méitheamh_Iúil_Lúnasa_Meán Fómhair_Deaireadh Fómhair_Samhain_Nollaig".split("_"),weekStart:1,weekdaysShort:"Dom_Lua_Mái_Céa_Déa_hAo_Sat".split("_"),monthsShort:"Eaná_Feab_Márt_Aibr_Beal_Méit_Iúil_Lúna_Meán_Deai_Samh_Noll".split("_"),weekdaysMin:"Do_Lu_Má_Ce_Dé_hA_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"i %s",past:"%s ó shin",s:"cúpla soicind",m:"nóiméad",mm:"%d nóiméad",h:"uair an chloig",hh:"%d uair an chloig",d:"lá",dd:"%d lá",M:"mí",MM:"%d mí",y:"bliain",yy:"%d bliain"}};return t.default.locale(n,null,!0),n}(n(7484))},4855:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gd",weekdays:"Didòmhnaich_Diluain_Dimàirt_Diciadain_Diardaoin_Dihaoine_Disathairne".split("_"),months:"Am Faoilleach_An Gearran_Am Màrt_An Giblean_An Cèitean_An t-Ògmhios_An t-Iuchar_An Lùnastal_An t-Sultain_An Dàmhair_An t-Samhain_An Dùbhlachd".split("_"),weekStart:1,weekdaysShort:"Did_Dil_Dim_Dic_Dia_Dih_Dis".split("_"),monthsShort:"Faoi_Gear_Màrt_Gibl_Cèit_Ògmh_Iuch_Lùn_Sult_Dàmh_Samh_Dùbh".split("_"),weekdaysMin:"Dò_Lu_Mà_Ci_Ar_Ha_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"ann an %s",past:"bho chionn %s",s:"beagan diogan",m:"mionaid",mm:"%d mionaidean",h:"uair",hh:"%d uairean",d:"latha",dd:"%d latha",M:"mìos",MM:"%d mìosan",y:"bliadhna",yy:"%d bliadhna"}};return t.default.locale(n,null,!0),n}(n(7484))},229:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gl",weekdays:"domingo_luns_martes_mércores_xoves_venres_sábado".split("_"),months:"xaneiro_febreiro_marzo_abril_maio_xuño_xullo_agosto_setembro_outubro_novembro_decembro".split("_"),weekStart:1,weekdaysShort:"dom._lun._mar._mér._xov._ven._sáb.".split("_"),monthsShort:"xan._feb._mar._abr._mai._xuñ._xul._ago._set._out._nov._dec.".split("_"),weekdaysMin:"do_lu_ma_mé_xo_ve_sá".split("_"),ordinal:function(e){return e+"º"},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},relativeTime:{future:"en %s",past:"fai %s",s:"uns segundos",m:"un minuto",mm:"%d minutos",h:"unha hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un ano",yy:"%d anos"}};return t.default.locale(n,null,!0),n}(n(7484))},6312:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gom-latn",weekdays:"Aitar_Somar_Mongllar_Budvar_Brestar_Sukrar_Son'var".split("_"),months:"Janer_Febrer_Mars_Abril_Mai_Jun_Julai_Agost_Setembr_Otubr_Novembr_Dezembr".split("_"),weekStart:1,weekdaysShort:"Ait._Som._Mon._Bud._Bre._Suk._Son.".split("_"),monthsShort:"Jan._Feb._Mars_Abr._Mai_Jun_Jul._Ago._Set._Otu._Nov._Dez.".split("_"),weekdaysMin:"Ai_Sm_Mo_Bu_Br_Su_Sn".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm [vazta]",LTS:"A h:mm:ss [vazta]",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY A h:mm [vazta]",LLLL:"dddd, MMMM[achea] Do, YYYY, A h:mm [vazta]",llll:"ddd, D MMM YYYY, A h:mm [vazta]"}};return t.default.locale(n,null,!0),n}(n(7484))},7632:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gu",weekdays:"રવિવાર_સોમવાર_મંગળવાર_બુધ્વાર_ગુરુવાર_શુક્રવાર_શનિવાર".split("_"),months:"જાન્યુઆરી_ફેબ્રુઆરી_માર્ચ_એપ્રિલ_મે_જૂન_જુલાઈ_ઑગસ્ટ_સપ્ટેમ્બર_ઑક્ટ્બર_નવેમ્બર_ડિસેમ્બર".split("_"),weekdaysShort:"રવિ_સોમ_મંગળ_બુધ્_ગુરુ_શુક્ર_શનિ".split("_"),monthsShort:"જાન્યુ._ફેબ્રુ._માર્ચ_એપ્રિ._મે_જૂન_જુલા._ઑગ._સપ્ટે._ઑક્ટ્._નવે._ડિસે.".split("_"),weekdaysMin:"ર_સો_મં_બુ_ગુ_શુ_શ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm વાગ્યે",LTS:"A h:mm:ss વાગ્યે",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm વાગ્યે",LLLL:"dddd, D MMMM YYYY, A h:mm વાગ્યે"},relativeTime:{future:"%s મા",past:"%s પેહલા",s:"અમુક પળો",m:"એક મિનિટ",mm:"%d મિનિટ",h:"એક કલાક",hh:"%d કલાક",d:"એક દિવસ",dd:"%d દિવસ",M:"એક મહિનો",MM:"%d મહિનો",y:"એક વર્ષ",yy:"%d વર્ષ"}};return t.default.locale(n,null,!0),n}(n(7484))},5418:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"מספר שניות",ss:"%d שניות",m:"דקה",mm:"%d דקות",h:"שעה",hh:"%d שעות",hh2:"שעתיים",d:"יום",dd:"%d ימים",dd2:"יומיים",M:"חודש",MM:"%d חודשים",MM2:"חודשיים",y:"שנה",yy:"%d שנים",yy2:"שנתיים"};function r(e,t,r){return(n[r+(2===e?"2":"")]||n[r]).replace("%d",e)}var a={name:"he",weekdays:"ראשון_שני_שלישי_רביעי_חמישי_שישי_שבת".split("_"),weekdaysShort:"א׳_ב׳_ג׳_ד׳_ה׳_ו׳_ש׳".split("_"),weekdaysMin:"א׳_ב׳_ג׳_ד׳_ה׳_ו_ש׳".split("_"),months:"ינואר_פברואר_מרץ_אפריל_מאי_יוני_יולי_אוגוסט_ספטמבר_אוקטובר_נובמבר_דצמבר".split("_"),monthsShort:"ינו_פבר_מרץ_אפר_מאי_יונ_יול_אוג_ספט_אוק_נוב_דצמ".split("_"),relativeTime:{future:"בעוד %s",past:"לפני %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r},ordinal:function(e){return e},format:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [ב]MMMM YYYY",LLL:"D [ב]MMMM YYYY HH:mm",LLLL:"dddd, D [ב]MMMM YYYY HH:mm",l:"D/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY HH:mm",llll:"ddd, D MMM YYYY HH:mm"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [ב]MMMM YYYY",LLL:"D [ב]MMMM YYYY HH:mm",LLLL:"dddd, D [ב]MMMM YYYY HH:mm",l:"D/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY HH:mm",llll:"ddd, D MMM YYYY HH:mm"}};return t.default.locale(a,null,!0),a}(n(7484))},7573:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"hi",weekdays:"रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार".split("_"),months:"जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर".split("_"),weekdaysShort:"रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि".split("_"),monthsShort:"जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.".split("_"),weekdaysMin:"र_सो_मं_बु_गु_शु_श".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm बजे",LTS:"A h:mm:ss बजे",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm बजे",LLLL:"dddd, D MMMM YYYY, A h:mm बजे"},relativeTime:{future:"%s में",past:"%s पहले",s:"कुछ ही क्षण",m:"एक मिनट",mm:"%d मिनट",h:"एक घंटा",hh:"%d घंटे",d:"एक दिन",dd:"%d दिन",M:"एक महीने",MM:"%d महीने",y:"एक वर्ष",yy:"%d वर्ष"}};return t.default.locale(n,null,!0),n}(n(7484))},6257:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="siječnja_veljače_ožujka_travnja_svibnja_lipnja_srpnja_kolovoza_rujna_listopada_studenoga_prosinca".split("_"),r="siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac".split("_"),a=/D[oD]?(\[[^[\]]*\]|\s)+MMMM?/,i=function(e,t){return a.test(t)?n[e.month()]:r[e.month()]};i.s=r,i.f=n;var s={name:"hr",weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),months:i,monthsShort:"sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"},relativeTime:{future:"za %s",past:"prije %s",s:"sekunda",m:"minuta",mm:"%d minuta",h:"sat",hh:"%d sati",d:"dan",dd:"%d dana",M:"mjesec",MM:"%d mjeseci",y:"godina",yy:"%d godine"},ordinal:function(e){return e+"."}};return t.default.locale(s,null,!0),s}(n(7484))},8889:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ht",weekdays:"dimanch_lendi_madi_mèkredi_jedi_vandredi_samdi".split("_"),months:"janvye_fevriye_mas_avril_me_jen_jiyè_out_septanm_oktòb_novanm_desanm".split("_"),weekdaysShort:"dim._len._mad._mèk._jed._van._sam.".split("_"),monthsShort:"jan._fev._mas_avr._me_jen_jiyè._out_sept._okt._nov._des.".split("_"),weekdaysMin:"di_le_ma_mè_je_va_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"nan %s",past:"sa gen %s",s:"kèk segond",m:"yon minit",mm:"%d minit",h:"inèdtan",hh:"%d zè",d:"yon jou",dd:"%d jou",M:"yon mwa",MM:"%d mwa",y:"yon ane",yy:"%d ane"}};return t.default.locale(n,null,!0),n}(n(7484))},8562:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"hu",weekdays:"vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat".split("_"),weekdaysShort:"vas_hét_kedd_sze_csüt_pén_szo".split("_"),weekdaysMin:"v_h_k_sze_cs_p_szo".split("_"),months:"január_február_március_április_május_június_július_augusztus_szeptember_október_november_december".split("_"),monthsShort:"jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"%s múlva",past:"%s",s:function(e,t,n,r){return"néhány másodperc"+(r||t?"":"e")},m:function(e,t,n,r){return"egy perc"+(r||t?"":"e")},mm:function(e,t,n,r){return e+" perc"+(r||t?"":"e")},h:function(e,t,n,r){return"egy "+(r||t?"óra":"órája")},hh:function(e,t,n,r){return e+" "+(r||t?"óra":"órája")},d:function(e,t,n,r){return"egy "+(r||t?"nap":"napja")},dd:function(e,t,n,r){return e+" "+(r||t?"nap":"napja")},M:function(e,t,n,r){return"egy "+(r||t?"hónap":"hónapja")},MM:function(e,t,n,r){return e+" "+(r||t?"hónap":"hónapja")},y:function(e,t,n,r){return"egy "+(r||t?"év":"éve")},yy:function(e,t,n,r){return e+" "+(r||t?"év":"éve")}},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"YYYY.MM.DD.",LL:"YYYY. MMMM D.",LLL:"YYYY. MMMM D. H:mm",LLLL:"YYYY. MMMM D., dddd H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8242:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"hy-am",weekdays:"կիրակի_երկուշաբթի_երեքշաբթի_չորեքշաբթի_հինգշաբթի_ուրբաթ_շաբաթ".split("_"),months:"հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի".split("_"),weekStart:1,weekdaysShort:"կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ".split("_"),monthsShort:"հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ".split("_"),weekdaysMin:"կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY թ.",LLL:"D MMMM YYYY թ., HH:mm",LLLL:"dddd, D MMMM YYYY թ., HH:mm"},relativeTime:{future:"%s հետո",past:"%s առաջ",s:"մի քանի վայրկյան",m:"րոպե",mm:"%d րոպե",h:"ժամ",hh:"%d ժամ",d:"օր",dd:"%d օր",M:"ամիս",MM:"%d ամիս",y:"տարի",yy:"%d տարի"}};return t.default.locale(n,null,!0),n}(n(7484))},3783:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"id",weekdays:"Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu".split("_"),months:"Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember".split("_"),weekdaysShort:"Min_Sen_Sel_Rab_Kam_Jum_Sab".split("_"),monthsShort:"Jan_Feb_Mar_Apr_Mei_Jun_Jul_Agt_Sep_Okt_Nov_Des".split("_"),weekdaysMin:"Mg_Sn_Sl_Rb_Km_Jm_Sb".split("_"),weekStart:1,formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] HH.mm",LLLL:"dddd, D MMMM YYYY [pukul] HH.mm"},relativeTime:{future:"dalam %s",past:"%s yang lalu",s:"beberapa detik",m:"semenit",mm:"%d menit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},8980:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:["nokkrar sekúndur","nokkrar sekúndur","nokkrum sekúndum"],m:["mínúta","mínútu","mínútu"],mm:["mínútur","mínútur","mínútum"],h:["klukkustund","klukkustund","klukkustund"],hh:["klukkustundir","klukkustundir","klukkustundum"],d:["dagur","dag","degi"],dd:["dagar","daga","dögum"],M:["mánuður","mánuð","mánuði"],MM:["mánuðir","mánuði","mánuðum"],y:["ár","ár","ári"],yy:["ár","ár","árum"]};function r(e,t,r,a){var i=function(e,t,r,a){var i=a?0:r?1:2,s=2===e.length&&t%10==1?e[0]:e,o=n[s][i];return 1===e.length?o:"%d "+o}(r,e,a,t);return i.replace("%d",e)}var a={name:"is",weekdays:"sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur".split("_"),months:"janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember".split("_"),weekStart:1,weekdaysShort:"sun_mán_þri_mið_fim_fös_lau".split("_"),monthsShort:"jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des".split("_"),weekdaysMin:"Su_Má_Þr_Mi_Fi_Fö_La".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] H:mm",LLLL:"dddd, D. MMMM YYYY [kl.] H:mm"},relativeTime:{future:"eftir %s",past:"fyrir %s síðan",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},3706:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"it-ch",weekdays:"domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato".split("_"),months:"gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre".split("_"),weekStart:1,weekdaysShort:"dom_lun_mar_mer_gio_ven_sab".split("_"),monthsShort:"gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic".split("_"),weekdaysMin:"do_lu_ma_me_gi_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"tra %s",past:"%s fa",s:"alcuni secondi",m:"un minuto",mm:"%d minuti",h:"un'ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"}};return t.default.locale(n,null,!0),n}(n(7484))},5551:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"it",weekdays:"domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato".split("_"),weekdaysShort:"dom_lun_mar_mer_gio_ven_sab".split("_"),weekdaysMin:"do_lu_ma_me_gi_ve_sa".split("_"),months:"gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre".split("_"),weekStart:1,monthsShort:"gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic".split("_"),formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"tra %s",past:"%s fa",s:"qualche secondo",m:"un minuto",mm:"%d minuti",h:"un' ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},6831:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ja",weekdays:"日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日".split("_"),weekdaysShort:"日_月_火_水_木_金_土".split("_"),weekdaysMin:"日_月_火_水_木_金_土".split("_"),months:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e){return e+"日"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日 HH:mm",LLLL:"YYYY年M月D日 dddd HH:mm",l:"YYYY/MM/DD",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日(ddd) HH:mm"},meridiem:function(e){return e<12?"午前":"午後"},relativeTime:{future:"%s後",past:"%s前",s:"数秒",m:"1分",mm:"%d分",h:"1時間",hh:"%d時間",d:"1日",dd:"%d日",M:"1ヶ月",MM:"%dヶ月",y:"1年",yy:"%d年"}};return t.default.locale(n,null,!0),n}(n(7484))},2641:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"jv",weekdays:"Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu".split("_"),months:"Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember".split("_"),weekStart:1,weekdaysShort:"Min_Sen_Sel_Reb_Kem_Jem_Sep".split("_"),monthsShort:"Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des".split("_"),weekdaysMin:"Mg_Sn_Sl_Rb_Km_Jm_Sp".split("_"),ordinal:function(e){return e},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] HH.mm",LLLL:"dddd, D MMMM YYYY [pukul] HH.mm"},relativeTime:{future:"wonten ing %s",past:"%s ingkang kepengker",s:"sawetawis detik",m:"setunggal menit",mm:"%d menit",h:"setunggal jam",hh:"%d jam",d:"sedinten",dd:"%d dinten",M:"sewulan",MM:"%d wulan",y:"setaun",yy:"%d taun"}};return t.default.locale(n,null,!0),n}(n(7484))},6622:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ka",weekdays:"კვირა_ორშაბათი_სამშაბათი_ოთხშაბათი_ხუთშაბათი_პარასკევი_შაბათი".split("_"),weekdaysShort:"კვი_ორშ_სამ_ოთხ_ხუთ_პარ_შაბ".split("_"),weekdaysMin:"კვ_ორ_სა_ოთ_ხუ_პა_შა".split("_"),months:"იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი".split("_"),monthsShort:"იან_თებ_მარ_აპრ_მაი_ივნ_ივლ_აგვ_სექ_ოქტ_ნოე_დეკ".split("_"),weekStart:1,formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"%s შემდეგ",past:"%s წინ",s:"წამი",m:"წუთი",mm:"%d წუთი",h:"საათი",hh:"%d საათის",d:"დღეს",dd:"%d დღის განმავლობაში",M:"თვის",MM:"%d თვის",y:"წელი",yy:"%d წლის"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},2921:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"kk",weekdays:"жексенбі_дүйсенбі_сейсенбі_сәрсенбі_бейсенбі_жұма_сенбі".split("_"),weekdaysShort:"жек_дүй_сей_сәр_бей_жұм_сен".split("_"),weekdaysMin:"жк_дй_сй_ср_бй_жм_сн".split("_"),months:"қаңтар_ақпан_наурыз_сәуір_мамыр_маусым_шілде_тамыз_қыркүйек_қазан_қараша_желтоқсан".split("_"),monthsShort:"қаң_ақп_нау_сәу_мам_мау_шіл_там_қыр_қаз_қар_жел".split("_"),weekStart:1,relativeTime:{future:"%s ішінде",past:"%s бұрын",s:"бірнеше секунд",m:"бір минут",mm:"%d минут",h:"бір сағат",hh:"%d сағат",d:"бір күн",dd:"%d күн",M:"бір ай",MM:"%d ай",y:"бір жыл",yy:"%d жыл"},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},5567:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"km",weekdays:"អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍".split("_"),months:"មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_"),weekStart:1,weekdaysShort:"អា_ច_អ_ព_ព្រ_សុ_ស".split("_"),monthsShort:"មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_"),weekdaysMin:"អា_ច_អ_ព_ព្រ_សុ_ស".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%sទៀត",past:"%sមុន",s:"ប៉ុន្មានវិនាទី",m:"មួយនាទី",mm:"%d នាទី",h:"មួយម៉ោង",hh:"%d ម៉ោង",d:"មួយថ្ងៃ",dd:"%d ថ្ងៃ",M:"មួយខែ",MM:"%d ខែ",y:"មួយឆ្នាំ",yy:"%d ឆ្នាំ"}};return t.default.locale(n,null,!0),n}(n(7484))},1113:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"kn",weekdays:"ಭಾನುವಾರ_ಸೋಮವಾರ_ಮಂಗಳವಾರ_ಬುಧವಾರ_ಗುರುವಾರ_ಶುಕ್ರವಾರ_ಶನಿವಾರ".split("_"),months:"ಜನವರಿ_ಫೆಬ್ರವರಿ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂಬರ್_ಅಕ್ಟೋಬರ್_ನವೆಂಬರ್_ಡಿಸೆಂಬರ್".split("_"),weekdaysShort:"ಭಾನು_ಸೋಮ_ಮಂಗಳ_ಬುಧ_ಗುರು_ಶುಕ್ರ_ಶನಿ".split("_"),monthsShort:"ಜನ_ಫೆಬ್ರ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂ_ಅಕ್ಟೋ_ನವೆಂ_ಡಿಸೆಂ".split("_"),weekdaysMin:"ಭಾ_ಸೋ_ಮಂ_ಬು_ಗು_ಶು_ಶ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm",LLLL:"dddd, D MMMM YYYY, A h:mm"},relativeTime:{future:"%s ನಂತರ",past:"%s ಹಿಂದೆ",s:"ಕೆಲವು ಕ್ಷಣಗಳು",m:"ಒಂದು ನಿಮಿಷ",mm:"%d ನಿಮಿಷ",h:"ಒಂದು ಗಂಟೆ",hh:"%d ಗಂಟೆ",d:"ಒಂದು ದಿನ",dd:"%d ದಿನ",M:"ಒಂದು ತಿಂಗಳು",MM:"%d ತಿಂಗಳು",y:"ಒಂದು ವರ್ಷ",yy:"%d ವರ್ಷ"}};return t.default.locale(n,null,!0),n}(n(7484))},9132:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ko",weekdays:"일요일_월요일_화요일_수요일_목요일_금요일_토요일".split("_"),weekdaysShort:"일_월_화_수_목_금_토".split("_"),weekdaysMin:"일_월_화_수_목_금_토".split("_"),months:"1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월".split("_"),monthsShort:"1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"YYYY.MM.DD.",LL:"YYYY년 MMMM D일",LLL:"YYYY년 MMMM D일 A h:mm",LLLL:"YYYY년 MMMM D일 dddd A h:mm",l:"YYYY.MM.DD.",ll:"YYYY년 MMMM D일",lll:"YYYY년 MMMM D일 A h:mm",llll:"YYYY년 MMMM D일 dddd A h:mm"},meridiem:function(e){return e<12?"오전":"오후"},relativeTime:{future:"%s 후",past:"%s 전",s:"몇 초",m:"1분",mm:"%d분",h:"한 시간",hh:"%d시간",d:"하루",dd:"%d일",M:"한 달",MM:"%d달",y:"일 년",yy:"%d년"}};return t.default.locale(n,null,!0),n}(n(7484))},4888:function(e,t,n){!function(e,t){"use strict";var n=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(t),r={1:"١",2:"٢",3:"٣",4:"٤",5:"٥",6:"٦",7:"٧",8:"٨",9:"٩",0:"٠"},a={"١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","٠":"0"},i=["کانوونی دووەم","شوبات","ئادار","نیسان","ئایار","حوزەیران","تەممووز","ئاب","ئەیلوول","تشرینی یەکەم","تشرینی دووەم","کانوونی یەکەم"],s={name:"ku",months:i,monthsShort:i,weekdays:"یەکشەممە_دووشەممە_سێشەممە_چوارشەممە_پێنجشەممە_هەینی_شەممە".split("_"),weekdaysShort:"یەکشەم_دووشەم_سێشەم_چوارشەم_پێنجشەم_هەینی_شەممە".split("_"),weekStart:6,weekdaysMin:"ی_د_س_چ_پ_هـ_ش".split("_"),preparse:function(e){return e.replace(/[١٢٣٤٥٦٧٨٩٠]/g,(function(e){return a[e]})).replace(/،/g,",")},postformat:function(e){return e.replace(/\d/g,(function(e){return r[e]})).replace(/,/g,"،")},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},meridiem:function(e){return e<12?"پ.ن":"د.ن"},relativeTime:{future:"لە %s",past:"لەمەوپێش %s",s:"چەند چرکەیەک",m:"یەک خولەک",mm:"%d خولەک",h:"یەک کاتژمێر",hh:"%d کاتژمێر",d:"یەک ڕۆژ",dd:"%d ڕۆژ",M:"یەک مانگ",MM:"%d مانگ",y:"یەک ساڵ",yy:"%d ساڵ"}};n.default.locale(s,null,!0),e.default=s,e.englishToArabicNumbersMap=r,Object.defineProperty(e,"__esModule",{value:!0})}(t,n(7484))},466:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ky",weekdays:"Жекшемби_Дүйшөмбү_Шейшемби_Шаршемби_Бейшемби_Жума_Ишемби".split("_"),months:"январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь".split("_"),weekStart:1,weekdaysShort:"Жек_Дүй_Шей_Шар_Бей_Жум_Ише".split("_"),monthsShort:"янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек".split("_"),weekdaysMin:"Жк_Дй_Шй_Шр_Бй_Жм_Иш".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%s ичинде",past:"%s мурун",s:"бирнече секунд",m:"бир мүнөт",mm:"%d мүнөт",h:"бир саат",hh:"%d саат",d:"бир күн",dd:"%d күн",M:"бир ай",MM:"%d ай",y:"бир жыл",yy:"%d жыл"}};return t.default.locale(n,null,!0),n}(n(7484))},1796:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"lb",weekdays:"Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg".split("_"),months:"Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),weekStart:1,weekdaysShort:"So._Mé._Dë._Më._Do._Fr._Sa.".split("_"),monthsShort:"Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.".split("_"),weekdaysMin:"So_Mé_Dë_Më_Do_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm [Auer]",LTS:"H:mm:ss [Auer]",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm [Auer]",LLLL:"dddd, D. MMMM YYYY H:mm [Auer]"}};return t.default.locale(n,null,!0),n}(n(7484))},8894:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"lo",weekdays:"ອາທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ".split("_"),months:"ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ".split("_"),weekdaysShort:"ທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ".split("_"),monthsShort:"ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ".split("_"),weekdaysMin:"ທ_ຈ_ອຄ_ພ_ພຫ_ສກ_ສ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"ວັນdddd D MMMM YYYY HH:mm"},relativeTime:{future:"ອີກ %s",past:"%sຜ່ານມາ",s:"ບໍ່ເທົ່າໃດວິນາທີ",m:"1 ນາທີ",mm:"%d ນາທີ",h:"1 ຊົ່ວໂມງ",hh:"%d ຊົ່ວໂມງ",d:"1 ມື້",dd:"%d ມື້",M:"1 ເດືອນ",MM:"%d ເດືອນ",y:"1 ປີ",yy:"%d ປີ"}};return t.default.locale(n,null,!0),n}(n(7484))},8768:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="sausio_vasario_kovo_balandžio_gegužės_birželio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio".split("_"),r="sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis".split("_"),a=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?|MMMM?(\[[^\[\]]*\]|\s)+D[oD]?/,i=function(e,t){return a.test(t)?n[e.month()]:r[e.month()]};i.s=r,i.f=n;var s={name:"lt",weekdays:"sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis".split("_"),weekdaysShort:"sek_pir_ant_tre_ket_pen_šeš".split("_"),weekdaysMin:"s_p_a_t_k_pn_š".split("_"),months:i,monthsShort:"sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"už %s",past:"prieš %s",s:"kelias sekundes",m:"minutę",mm:"%d minutes",h:"valandą",hh:"%d valandas",d:"dieną",dd:"%d dienas",M:"mėnesį",MM:"%d mėnesius",y:"metus",yy:"%d metus"},format:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY [m.] MMMM D [d.]",LLL:"YYYY [m.] MMMM D [d.], HH:mm [val.]",LLLL:"YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]",l:"YYYY-MM-DD",ll:"YYYY [m.] MMMM D [d.]",lll:"YYYY [m.] MMMM D [d.], HH:mm [val.]",llll:"YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY [m.] MMMM D [d.]",LLL:"YYYY [m.] MMMM D [d.], HH:mm [val.]",LLLL:"YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]",l:"YYYY-MM-DD",ll:"YYYY [m.] MMMM D [d.]",lll:"YYYY [m.] MMMM D [d.], HH:mm [val.]",llll:"YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]"}};return t.default.locale(s,null,!0),s}(n(7484))},953:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"lv",weekdays:"svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena".split("_"),months:"janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris".split("_"),weekStart:1,weekdaysShort:"Sv_P_O_T_C_Pk_S".split("_"),monthsShort:"jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec".split("_"),weekdaysMin:"Sv_P_O_T_C_Pk_S".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY.",LL:"YYYY. [gada] D. MMMM",LLL:"YYYY. [gada] D. MMMM, HH:mm",LLLL:"YYYY. [gada] D. MMMM, dddd, HH:mm"},relativeTime:{future:"pēc %s",past:"pirms %s",s:"dažām sekundēm",m:"minūtes",mm:"%d minūtēm",h:"stundas",hh:"%d stundām",d:"dienas",dd:"%d dienām",M:"mēneša",MM:"%d mēnešiem",y:"gada",yy:"%d gadiem"}};return t.default.locale(n,null,!0),n}(n(7484))},8066:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"me",weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),months:"januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar".split("_"),weekStart:1,weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),monthsShort:"jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8602:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mi",weekdays:"Rātapu_Mane_Tūrei_Wenerei_Tāite_Paraire_Hātarei".split("_"),months:"Kohi-tāte_Hui-tanguru_Poutū-te-rangi_Paenga-whāwhā_Haratua_Pipiri_Hōngoingoi_Here-turi-kōkā_Mahuru_Whiringa-ā-nuku_Whiringa-ā-rangi_Hakihea".split("_"),weekStart:1,weekdaysShort:"Ta_Ma_Tū_We_Tāi_Pa_Hā".split("_"),monthsShort:"Kohi_Hui_Pou_Pae_Hara_Pipi_Hōngoi_Here_Mahu_Whi-nu_Whi-ra_Haki".split("_"),weekdaysMin:"Ta_Ma_Tū_We_Tāi_Pa_Hā".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [i] HH:mm",LLLL:"dddd, D MMMM YYYY [i] HH:mm"},relativeTime:{future:"i roto i %s",past:"%s i mua",s:"te hēkona ruarua",m:"he meneti",mm:"%d meneti",h:"te haora",hh:"%d haora",d:"he ra",dd:"%d ra",M:"he marama",MM:"%d marama",y:"he tau",yy:"%d tau"}};return t.default.locale(n,null,!0),n}(n(7484))},1560:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mk",weekdays:"недела_понеделник_вторник_среда_четврток_петок_сабота".split("_"),months:"јануари_февруари_март_април_мај_јуни_јули_август_септември_октомври_ноември_декември".split("_"),weekStart:1,weekdaysShort:"нед_пон_вто_сре_чет_пет_саб".split("_"),monthsShort:"јан_фев_мар_апр_мај_јун_јул_авг_сеп_окт_ное_дек".split("_"),weekdaysMin:"нe_пo_вт_ср_че_пе_сa".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY H:mm",LLLL:"dddd, D MMMM YYYY H:mm"},relativeTime:{future:"после %s",past:"пред %s",s:"неколку секунди",m:"минута",mm:"%d минути",h:"час",hh:"%d часа",d:"ден",dd:"%d дена",M:"месец",MM:"%d месеци",y:"година",yy:"%d години"}};return t.default.locale(n,null,!0),n}(n(7484))},4017:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ml",weekdays:"ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച".split("_"),months:"ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ".split("_"),weekdaysShort:"ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി".split("_"),monthsShort:"ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.".split("_"),weekdaysMin:"ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm -നു",LTS:"A h:mm:ss -നു",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm -നു",LLLL:"dddd, D MMMM YYYY, A h:mm -നു"},relativeTime:{future:"%s കഴിഞ്ഞ്",past:"%s മുൻപ്",s:"അൽപ നിമിഷങ്ങൾ",m:"ഒരു മിനിറ്റ്",mm:"%d മിനിറ്റ്",h:"ഒരു മണിക്കൂർ",hh:"%d മണിക്കൂർ",d:"ഒരു ദിവസം",dd:"%d ദിവസം",M:"ഒരു മാസം",MM:"%d മാസം",y:"ഒരു വർഷം",yy:"%d വർഷം"}};return t.default.locale(n,null,!0),n}(n(7484))},4717:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mn",weekdays:"Ням_Даваа_Мягмар_Лхагва_Пүрэв_Баасан_Бямба".split("_"),months:"Нэгдүгээр сар_Хоёрдугаар сар_Гуравдугаар сар_Дөрөвдүгээр сар_Тавдугаар сар_Зургадугаар сар_Долдугаар сар_Наймдугаар сар_Есдүгээр сар_Аравдугаар сар_Арван нэгдүгээр сар_Арван хоёрдугаар сар".split("_"),weekdaysShort:"Ням_Дав_Мяг_Лха_Пүр_Баа_Бям".split("_"),monthsShort:"1 сар_2 сар_3 сар_4 сар_5 сар_6 сар_7 сар_8 сар_9 сар_10 сар_11 сар_12 сар".split("_"),weekdaysMin:"Ня_Да_Мя_Лх_Пү_Ба_Бя".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY оны MMMMын D",LLL:"YYYY оны MMMMын D HH:mm",LLLL:"dddd, YYYY оны MMMMын D HH:mm"},relativeTime:{future:"%s",past:"%s",s:"саяхан",m:"м",mm:"%dм",h:"1ц",hh:"%dц",d:"1ө",dd:"%dө",M:"1с",MM:"%dс",y:"1ж",yy:"%dж"}};return t.default.locale(n,null,!0),n}(n(7484))},5473:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mr",weekdays:"रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार".split("_"),months:"जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर".split("_"),weekdaysShort:"रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि".split("_"),monthsShort:"जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.".split("_"),weekdaysMin:"र_सो_मं_बु_गु_शु_श".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm वाजता",LTS:"A h:mm:ss वाजता",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm वाजता",LLLL:"dddd, D MMMM YYYY, A h:mm वाजता"}};return t.default.locale(n,null,!0),n}(n(7484))},7387:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ms-my",weekdays:"Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu".split("_"),months:"Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember".split("_"),weekStart:1,weekdaysShort:"Ahd_Isn_Sel_Rab_Kha_Jum_Sab".split("_"),monthsShort:"Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis".split("_"),weekdaysMin:"Ah_Is_Sl_Rb_Km_Jm_Sb".split("_"),ordinal:function(e){return e},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] HH.mm",LLLL:"dddd, D MMMM YYYY [pukul] HH.mm"},relativeTime:{future:"dalam %s",past:"%s yang lepas",s:"beberapa saat",m:"seminit",mm:"%d minit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"}};return t.default.locale(n,null,!0),n}(n(7484))},5742:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ms",weekdays:"Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu".split("_"),weekdaysShort:"Ahd_Isn_Sel_Rab_Kha_Jum_Sab".split("_"),weekdaysMin:"Ah_Is_Sl_Rb_Km_Jm_Sb".split("_"),months:"Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember".split("_"),monthsShort:"Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis".split("_"),weekStart:1,formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH.mm",LLLL:"dddd, D MMMM YYYY HH.mm"},relativeTime:{future:"dalam %s",past:"%s yang lepas",s:"beberapa saat",m:"seminit",mm:"%d minit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},8477:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mt",weekdays:"Il-Ħadd_It-Tnejn_It-Tlieta_L-Erbgħa_Il-Ħamis_Il-Ġimgħa_Is-Sibt".split("_"),months:"Jannar_Frar_Marzu_April_Mejju_Ġunju_Lulju_Awwissu_Settembru_Ottubru_Novembru_Diċembru".split("_"),weekStart:1,weekdaysShort:"Ħad_Tne_Tli_Erb_Ħam_Ġim_Sib".split("_"),monthsShort:"Jan_Fra_Mar_Apr_Mej_Ġun_Lul_Aww_Set_Ott_Nov_Diċ".split("_"),weekdaysMin:"Ħa_Tn_Tl_Er_Ħa_Ġi_Si".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"f’ %s",past:"%s ilu",s:"ftit sekondi",m:"minuta",mm:"%d minuti",h:"siegħa",hh:"%d siegħat",d:"ġurnata",dd:"%d ġranet",M:"xahar",MM:"%d xhur",y:"sena",yy:"%d sni"}};return t.default.locale(n,null,!0),n}(n(7484))},2966:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"my",weekdays:"တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ".split("_"),months:"ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ".split("_"),weekStart:1,weekdaysShort:"နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ".split("_"),monthsShort:"ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ".split("_"),weekdaysMin:"နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"လာမည့် %s မှာ",past:"လွန်ခဲ့သော %s က",s:"စက္ကန်.အနည်းငယ်",m:"တစ်မိနစ်",mm:"%d မိနစ်",h:"တစ်နာရီ",hh:"%d နာရီ",d:"တစ်ရက်",dd:"%d ရက်",M:"တစ်လ",MM:"%d လ",y:"တစ်နှစ်",yy:"%d နှစ်"}};return t.default.locale(n,null,!0),n}(n(7484))},9682:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nb",weekdays:"søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),weekdaysShort:"sø._ma._ti._on._to._fr._lø.".split("_"),weekdaysMin:"sø_ma_ti_on_to_fr_lø".split("_"),months:"januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember".split("_"),monthsShort:"jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] HH:mm",LLLL:"dddd D. MMMM YYYY [kl.] HH:mm"},relativeTime:{future:"om %s",past:"%s siden",s:"noen sekunder",m:"ett minutt",mm:"%d minutter",h:"en time",hh:"%d timer",d:"en dag",dd:"%d dager",M:"en måned",MM:"%d måneder",y:"ett år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},4149:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ne",weekdays:"आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार".split("_"),weekdaysShort:"आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.".split("_"),weekdaysMin:"आ._सो._मं._बु._बि._शु._श.".split("_"),months:"जनवरी_फेब्रुवरी_मार्च_अप्रिल_मे_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर".split("_"),monthsShort:"जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.".split("_"),relativeTime:{future:"%s पछि",past:"%s अघि",s:"सेकेन्ड",m:"एक मिनेट",mm:"%d मिनेट",h:"घन्टा",hh:"%d घन्टा",d:"एक दिन",dd:"%d दिन",M:"एक महिना",MM:"%d महिना",y:"एक वर्ष",yy:"%d वर्ष"},ordinal:function(e){return(""+e).replace(/\d/g,(function(e){return"०१२३४५६७८९"[e]}))},formats:{LT:"Aको h:mm बजे",LTS:"Aको h:mm:ss बजे",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, Aको h:mm बजे",LLLL:"dddd, D MMMM YYYY, Aको h:mm बजे"}};return t.default.locale(n,null,!0),n}(n(7484))},7496:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nl-be",weekdays:"zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),months:"januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),monthsShort:"jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.".split("_"),weekStart:1,weekdaysShort:"zo._ma._di._wo._do._vr._za.".split("_"),weekdaysMin:"zo_ma_di_wo_do_vr_za".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"over %s",past:"%s geleden",s:"een paar seconden",m:"één minuut",mm:"%d minuten",h:"één uur",hh:"%d uur",d:"één dag",dd:"%d dagen",M:"één maand",MM:"%d maanden",y:"één jaar",yy:"%d jaar"}};return t.default.locale(n,null,!0),n}(n(7484))},9182:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nl",weekdays:"zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),weekdaysShort:"zo._ma._di._wo._do._vr._za.".split("_"),weekdaysMin:"zo_ma_di_wo_do_vr_za".split("_"),months:"januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec".split("_"),ordinal:function(e){return e+(1===e||8===e||e>=20?"ste":"de")},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"over %s",past:"%s geleden",s:"een paar seconden",m:"een minuut",mm:"%d minuten",h:"een uur",hh:"%d uur",d:"een dag",dd:"%d dagen",M:"een maand",MM:"%d maanden",y:"een jaar",yy:"%d jaar"}};return t.default.locale(n,null,!0),n}(n(7484))},2722:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nn",weekdays:"sundag_måndag_tysdag_onsdag_torsdag_fredag_laurdag".split("_"),weekdaysShort:"sun_mån_tys_ons_tor_fre_lau".split("_"),weekdaysMin:"su_må_ty_on_to_fr_la".split("_"),months:"januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember".split("_"),monthsShort:"jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"om %s",past:"for %s sidan",s:"nokre sekund",m:"eitt minutt",mm:"%d minutt",h:"ein time",hh:"%d timar",d:"ein dag",dd:"%d dagar",M:"ein månad",MM:"%d månadar",y:"eitt år",yy:"%d år"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] H:mm",LLLL:"dddd D. MMMM YYYY [kl.] HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},6159:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"oc-lnc",weekdays:"dimenge_diluns_dimars_dimècres_dijòus_divendres_dissabte".split("_"),weekdaysShort:"Dg_Dl_Dm_Dc_Dj_Dv_Ds".split("_"),weekdaysMin:"dg_dl_dm_dc_dj_dv_ds".split("_"),months:"genièr_febrièr_març_abrial_mai_junh_julhet_agost_setembre_octòbre_novembre_decembre".split("_"),monthsShort:"gen_feb_març_abr_mai_junh_julh_ago_set_oct_nov_dec".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM [de] YYYY",LLL:"D MMMM [de] YYYY [a] H:mm",LLLL:"dddd D MMMM [de] YYYY [a] H:mm"},relativeTime:{future:"d'aquí %s",past:"fa %s",s:"unas segondas",m:"una minuta",mm:"%d minutas",h:"una ora",hh:"%d oras",d:"un jorn",dd:"%d jorns",M:"un mes",MM:"%d meses",y:"un an",yy:"%d ans"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},5914:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"pa-in",weekdays:"ਐਤਵਾਰ_ਸੋਮਵਾਰ_ਮੰਗਲਵਾਰ_ਬੁਧਵਾਰ_ਵੀਰਵਾਰ_ਸ਼ੁੱਕਰਵਾਰ_ਸ਼ਨੀਚਰਵਾਰ".split("_"),months:"ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ".split("_"),weekdaysShort:"ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ".split("_"),monthsShort:"ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ".split("_"),weekdaysMin:"ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm ਵਜੇ",LTS:"A h:mm:ss ਵਜੇ",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm ਵਜੇ",LLLL:"dddd, D MMMM YYYY, A h:mm ਵਜੇ"},relativeTime:{future:"%s ਵਿੱਚ",past:"%s ਪਿਛਲੇ",s:"ਕੁਝ ਸਕਿੰਟ",m:"ਇਕ ਮਿੰਟ",mm:"%d ਮਿੰਟ",h:"ਇੱਕ ਘੰਟਾ",hh:"%d ਘੰਟੇ",d:"ਇੱਕ ਦਿਨ",dd:"%d ਦਿਨ",M:"ਇੱਕ ਮਹੀਨਾ",MM:"%d ਮਹੀਨੇ",y:"ਇੱਕ ਸਾਲ",yy:"%d ਸਾਲ"}};return t.default.locale(n,null,!0),n}(n(7484))},1987:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e%10<5&&e%10>1&&~~(e/10)%10!=1}function r(e,t,r){var a=e+" ";switch(r){case"m":return t?"minuta":"minutę";case"mm":return a+(n(e)?"minuty":"minut");case"h":return t?"godzina":"godzinę";case"hh":return a+(n(e)?"godziny":"godzin");case"MM":return a+(n(e)?"miesiące":"miesięcy");case"yy":return a+(n(e)?"lata":"lat")}}var a="stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia".split("_"),i="styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień".split("_"),s=/D MMMM/,o=function(e,t){return s.test(t)?a[e.month()]:i[e.month()]};o.s=i,o.f=a;var u={name:"pl",weekdays:"niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota".split("_"),weekdaysShort:"ndz_pon_wt_śr_czw_pt_sob".split("_"),weekdaysMin:"Nd_Pn_Wt_Śr_Cz_Pt_So".split("_"),months:o,monthsShort:"sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,relativeTime:{future:"za %s",past:"%s temu",s:"kilka sekund",m:r,mm:r,h:r,hh:r,d:"1 dzień",dd:"%d dni",M:"miesiąc",MM:r,y:"rok",yy:r},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(u,null,!0),u}(n(7484))},7548:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"pt-br",weekdays:"domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado".split("_"),weekdaysShort:"dom_seg_ter_qua_qui_sex_sáb".split("_"),weekdaysMin:"Do_2ª_3ª_4ª_5ª_6ª_Sá".split("_"),months:"janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro".split("_"),monthsShort:"jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez".split("_"),ordinal:function(e){return e+"º"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY [às] HH:mm",LLLL:"dddd, D [de] MMMM [de] YYYY [às] HH:mm"},relativeTime:{future:"em %s",past:"há %s",s:"poucos segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"}};return t.default.locale(n,null,!0),n}(n(7484))},5001:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"pt",weekdays:"domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado".split("_"),weekdaysShort:"dom_seg_ter_qua_qui_sex_sab".split("_"),weekdaysMin:"Do_2ª_3ª_4ª_5ª_6ª_Sa".split("_"),months:"janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro".split("_"),monthsShort:"jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez".split("_"),ordinal:function(e){return e+"º"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY [às] HH:mm",LLLL:"dddd, D [de] MMMM [de] YYYY [às] HH:mm"},relativeTime:{future:"em %s",past:"há %s",s:"alguns segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"}};return t.default.locale(n,null,!0),n}(n(7484))},123:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"rn",weekdays:"Ku wa Mungu_Ku wa Mbere_Ku wa Kabiri_Ku wa Gatatu_Ku wa Kane_Ku wa Gatanu_Ku wa Gatandatu".split("_"),weekdaysShort:"Kngu_Kmbr_Kbri_Ktat_Kkan_Ktan_Kdat".split("_"),weekdaysMin:"K7_K1_K2_K3_K4_K5_K6".split("_"),months:"Nzero_Ruhuhuma_Ntwarante_Ndamukiza_Rusama_Ruhenshi_Mukakaro_Myandagaro_Nyakanga_Gitugutu_Munyonyo_Kigarama".split("_"),monthsShort:"Nzer_Ruhuh_Ntwar_Ndam_Rus_Ruhen_Muk_Myand_Nyak_Git_Muny_Kig".split("_"),weekStart:1,ordinal:function(e){return e},relativeTime:{future:"mu %s",past:"%s",s:"amasegonda",m:"Umunota",mm:"%d iminota",h:"isaha",hh:"%d amasaha",d:"Umunsi",dd:"%d iminsi",M:"ukwezi",MM:"%d amezi",y:"umwaka",yy:"%d imyaka"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8146:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ro",weekdays:"Duminică_Luni_Marți_Miercuri_Joi_Vineri_Sâmbătă".split("_"),weekdaysShort:"Dum_Lun_Mar_Mie_Joi_Vin_Sâm".split("_"),weekdaysMin:"Du_Lu_Ma_Mi_Jo_Vi_Sâ".split("_"),months:"Ianuarie_Februarie_Martie_Aprilie_Mai_Iunie_Iulie_August_Septembrie_Octombrie_Noiembrie_Decembrie".split("_"),monthsShort:"Ian._Febr._Mart._Apr._Mai_Iun._Iul._Aug._Sept._Oct._Nov._Dec.".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY H:mm",LLLL:"dddd, D MMMM YYYY H:mm"},relativeTime:{future:"peste %s",past:"acum %s",s:"câteva secunde",m:"un minut",mm:"%d minute",h:"o oră",hh:"%d ore",d:"o zi",dd:"%d zile",M:"o lună",MM:"%d luni",y:"un an",yy:"%d ani"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},600:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря".split("_"),r="январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь".split("_"),a="янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.".split("_"),i="янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.".split("_"),s=/D[oD]?(\[[^[\]]*\]|\s)+MMMM?/;function o(e,t,n){var r,a;return"m"===n?t?"минута":"минуту":e+" "+(r=+e,a={mm:t?"минута_минуты_минут":"минуту_минуты_минут",hh:"час_часа_часов",dd:"день_дня_дней",MM:"месяц_месяца_месяцев",yy:"год_года_лет"}[n].split("_"),r%10==1&&r%100!=11?a[0]:r%10>=2&&r%10<=4&&(r%100<10||r%100>=20)?a[1]:a[2])}var u=function(e,t){return s.test(t)?n[e.month()]:r[e.month()]};u.s=r,u.f=n;var l=function(e,t){return s.test(t)?a[e.month()]:i[e.month()]};l.s=i,l.f=a;var c={name:"ru",weekdays:"воскресенье_понедельник_вторник_среда_четверг_пятница_суббота".split("_"),weekdaysShort:"вск_пнд_втр_срд_чтв_птн_сбт".split("_"),weekdaysMin:"вс_пн_вт_ср_чт_пт_сб".split("_"),months:u,monthsShort:l,weekStart:1,yearStart:4,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., H:mm",LLLL:"dddd, D MMMM YYYY г., H:mm"},relativeTime:{future:"через %s",past:"%s назад",s:"несколько секунд",m:o,mm:o,h:"час",hh:o,d:"день",dd:o,M:"месяц",MM:o,y:"год",yy:o},ordinal:function(e){return e},meridiem:function(e){return e<4?"ночи":e<12?"утра":e<17?"дня":"вечера"}};return t.default.locale(c,null,!0),c}(n(7484))},6509:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"rw",weekdays:"Ku Cyumweru_Kuwa Mbere_Kuwa Kabiri_Kuwa Gatatu_Kuwa Kane_Kuwa Gatanu_Kuwa Gatandatu".split("_"),months:"Mutarama_Gashyantare_Werurwe_Mata_Gicurasi_Kamena_Nyakanga_Kanama_Nzeri_Ukwakira_Ugushyingo_Ukuboza".split("_"),relativeTime:{future:"mu %s",past:"%s",s:"amasegonda",m:"Umunota",mm:"%d iminota",h:"isaha",hh:"%d amasaha",d:"Umunsi",dd:"%d iminsi",M:"ukwezi",MM:"%d amezi",y:"umwaka",yy:"%d imyaka"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},5437:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sd",weekdays:"آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر".split("_"),months:"جنوري_فيبروري_مارچ_اپريل_مئي_جون_جولاءِ_آگسٽ_سيپٽمبر_آڪٽوبر_نومبر_ڊسمبر".split("_"),weekStart:1,weekdaysShort:"آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر".split("_"),monthsShort:"جنوري_فيبروري_مارچ_اپريل_مئي_جون_جولاءِ_آگسٽ_سيپٽمبر_آڪٽوبر_نومبر_ڊسمبر".split("_"),weekdaysMin:"آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd، D MMMM YYYY HH:mm"},relativeTime:{future:"%s پوء",past:"%s اڳ",s:"چند سيڪنڊ",m:"هڪ منٽ",mm:"%d منٽ",h:"هڪ ڪلاڪ",hh:"%d ڪلاڪ",d:"هڪ ڏينهن",dd:"%d ڏينهن",M:"هڪ مهينو",MM:"%d مهينا",y:"هڪ سال",yy:"%d سال"}};return t.default.locale(n,null,!0),n}(n(7484))},772:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"se",weekdays:"sotnabeaivi_vuossárga_maŋŋebárga_gaskavahkku_duorastat_bearjadat_lávvardat".split("_"),months:"ođđajagemánnu_guovvamánnu_njukčamánnu_cuoŋománnu_miessemánnu_geassemánnu_suoidnemánnu_borgemánnu_čakčamánnu_golggotmánnu_skábmamánnu_juovlamánnu".split("_"),weekStart:1,weekdaysShort:"sotn_vuos_maŋ_gask_duor_bear_láv".split("_"),monthsShort:"ođđj_guov_njuk_cuo_mies_geas_suoi_borg_čakč_golg_skáb_juov".split("_"),weekdaysMin:"s_v_m_g_d_b_L".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"MMMM D. [b.] YYYY",LLL:"MMMM D. [b.] YYYY [ti.] HH:mm",LLLL:"dddd, MMMM D. [b.] YYYY [ti.] HH:mm"},relativeTime:{future:"%s geažes",past:"maŋit %s",s:"moadde sekunddat",m:"okta minuhta",mm:"%d minuhtat",h:"okta diimmu",hh:"%d diimmut",d:"okta beaivi",dd:"%d beaivvit",M:"okta mánnu",MM:"%d mánut",y:"okta jahki",yy:"%d jagit"}};return t.default.locale(n,null,!0),n}(n(7484))},7109:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"si",weekdays:"ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්‍රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා".split("_"),months:"දුරුතු_නවම්_මැදින්_බක්_වෙසක්_පොසොන්_ඇසළ_නිකිණි_බිනර_වප්_ඉල්_උඳුවප්".split("_"),weekdaysShort:"ඉරි_සඳු_අඟ_බදා_බ්‍රහ_සිකු_සෙන".split("_"),monthsShort:"දුරු_නව_මැදි_බක්_වෙස_පොසො_ඇස_නිකි_බින_වප්_ඉල්_උඳු".split("_"),weekdaysMin:"ඉ_ස_අ_බ_බ්‍ර_සි_සෙ".split("_"),ordinal:function(e){return e},formats:{LT:"a h:mm",LTS:"a h:mm:ss",L:"YYYY/MM/DD",LL:"YYYY MMMM D",LLL:"YYYY MMMM D, a h:mm",LLLL:"YYYY MMMM D [වැනි] dddd, a h:mm:ss"},relativeTime:{future:"%sකින්",past:"%sකට පෙර",s:"තත්පර කිහිපය",m:"විනාඩිය",mm:"විනාඩි %d",h:"පැය",hh:"පැය %d",d:"දිනය",dd:"දින %d",M:"මාසය",MM:"මාස %d",y:"වසර",yy:"වසර %d"}};return t.default.locale(n,null,!0),n}(n(7484))},5627:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e>1&&e<5&&1!=~~(e/10)}function r(e,t,r,a){var i=e+" ";switch(r){case"s":return t||a?"pár sekúnd":"pár sekundami";case"m":return t?"minúta":a?"minútu":"minútou";case"mm":return t||a?i+(n(e)?"minúty":"minút"):i+"minútami";case"h":return t?"hodina":a?"hodinu":"hodinou";case"hh":return t||a?i+(n(e)?"hodiny":"hodín"):i+"hodinami";case"d":return t||a?"deň":"dňom";case"dd":return t||a?i+(n(e)?"dni":"dní"):i+"dňami";case"M":return t||a?"mesiac":"mesiacom";case"MM":return t||a?i+(n(e)?"mesiace":"mesiacov"):i+"mesiacmi";case"y":return t||a?"rok":"rokom";case"yy":return t||a?i+(n(e)?"roky":"rokov"):i+"rokmi"}}var a={name:"sk",weekdays:"nedeľa_pondelok_utorok_streda_štvrtok_piatok_sobota".split("_"),weekdaysShort:"ne_po_ut_st_št_pi_so".split("_"),weekdaysMin:"ne_po_ut_st_št_pi_so".split("_"),months:"január_február_marec_apríl_máj_jún_júl_august_september_október_november_december".split("_"),monthsShort:"jan_feb_mar_apr_máj_jún_júl_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd D. MMMM YYYY H:mm",l:"D. M. YYYY"},relativeTime:{future:"za %s",past:"pred %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},2544:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sl",weekdays:"nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota".split("_"),months:"januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december".split("_"),weekStart:1,weekdaysShort:"ned._pon._tor._sre._čet._pet._sob.".split("_"),monthsShort:"jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_to_sr_če_pe_so".split("_"),ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"},relativeTime:{future:"čez %s",past:"pred %s",s:"nekaj sekund",m:"minuta",mm:"%d minut",h:"ura",hh:"%d ur",d:"dan",dd:"%d dni",M:"mesec",MM:"%d mesecev",y:"leto",yy:"%d let"}};return t.default.locale(n,null,!0),n}(n(7484))},8341:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sq",weekdays:"E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë".split("_"),months:"Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor".split("_"),weekStart:1,weekdaysShort:"Die_Hën_Mar_Mër_Enj_Pre_Sht".split("_"),monthsShort:"Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj".split("_"),weekdaysMin:"D_H_Ma_Më_E_P_Sh".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"në %s",past:"%s më parë",s:"disa sekonda",m:"një minutë",mm:"%d minuta",h:"një orë",hh:"%d orë",d:"një ditë",dd:"%d ditë",M:"një muaj",MM:"%d muaj",y:"një vit",yy:"%d vite"}};return t.default.locale(n,null,!0),n}(n(7484))},7101:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={words:{m:["један минут","једног минута"],mm:["%d минут","%d минута","%d минута"],h:["један сат","једног сата"],hh:["%d сат","%d сата","%d сати"],d:["један дан","једног дана"],dd:["%d дан","%d дана","%d дана"],M:["један месец","једног месеца"],MM:["%d месец","%d месеца","%d месеци"],y:["једну годину","једне године"],yy:["%d годину","%d године","%d година"]},correctGrammarCase:function(e,t){return e%10>=1&&e%10<=4&&(e%100<10||e%100>=20)?e%10==1?t[0]:t[1]:t[2]},relativeTimeFormatter:function(e,t,r,a){var i=n.words[r];if(1===r.length)return"y"===r&&t?"једна година":a||t?i[0]:i[1];var s=n.correctGrammarCase(e,i);return"yy"===r&&t&&"%d годину"===s?e+" година":s.replace("%d",e)}},r={name:"sr-cyrl",weekdays:"Недеља_Понедељак_Уторак_Среда_Четвртак_Петак_Субота".split("_"),weekdaysShort:"Нед._Пон._Уто._Сре._Чет._Пет._Суб.".split("_"),weekdaysMin:"не_по_ут_ср_че_пе_су".split("_"),months:"Јануар_Фебруар_Март_Април_Мај_Јун_Јул_Август_Септембар_Октобар_Новембар_Децембар".split("_"),monthsShort:"Јан._Феб._Мар._Апр._Мај_Јун_Јул_Авг._Сеп._Окт._Нов._Дец.".split("_"),weekStart:1,relativeTime:{future:"за %s",past:"пре %s",s:"неколико секунди",m:n.relativeTimeFormatter,mm:n.relativeTimeFormatter,h:n.relativeTimeFormatter,hh:n.relativeTimeFormatter,d:n.relativeTimeFormatter,dd:n.relativeTimeFormatter,M:n.relativeTimeFormatter,MM:n.relativeTimeFormatter,y:n.relativeTimeFormatter,yy:n.relativeTimeFormatter},ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D. M. YYYY.",LL:"D. MMMM YYYY.",LLL:"D. MMMM YYYY. H:mm",LLLL:"dddd, D. MMMM YYYY. H:mm"}};return t.default.locale(r,null,!0),r}(n(7484))},617:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={words:{m:["jedan minut","jednog minuta"],mm:["%d minut","%d minuta","%d minuta"],h:["jedan sat","jednog sata"],hh:["%d sat","%d sata","%d sati"],d:["jedan dan","jednog dana"],dd:["%d dan","%d dana","%d dana"],M:["jedan mesec","jednog meseca"],MM:["%d mesec","%d meseca","%d meseci"],y:["jednu godinu","jedne godine"],yy:["%d godinu","%d godine","%d godina"]},correctGrammarCase:function(e,t){return e%10>=1&&e%10<=4&&(e%100<10||e%100>=20)?e%10==1?t[0]:t[1]:t[2]},relativeTimeFormatter:function(e,t,r,a){var i=n.words[r];if(1===r.length)return"y"===r&&t?"jedna godina":a||t?i[0]:i[1];var s=n.correctGrammarCase(e,i);return"yy"===r&&t&&"%d godinu"===s?e+" godina":s.replace("%d",e)}},r={name:"sr",weekdays:"Nedelja_Ponedeljak_Utorak_Sreda_Četvrtak_Petak_Subota".split("_"),weekdaysShort:"Ned._Pon._Uto._Sre._Čet._Pet._Sub.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),months:"Januar_Februar_Mart_April_Maj_Jun_Jul_Avgust_Septembar_Oktobar_Novembar_Decembar".split("_"),monthsShort:"Jan._Feb._Mar._Apr._Maj_Jun_Jul_Avg._Sep._Okt._Nov._Dec.".split("_"),weekStart:1,relativeTime:{future:"za %s",past:"pre %s",s:"nekoliko sekundi",m:n.relativeTimeFormatter,mm:n.relativeTimeFormatter,h:n.relativeTimeFormatter,hh:n.relativeTimeFormatter,d:n.relativeTimeFormatter,dd:n.relativeTimeFormatter,M:n.relativeTimeFormatter,MM:n.relativeTimeFormatter,y:n.relativeTimeFormatter,yy:n.relativeTimeFormatter},ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D. M. YYYY.",LL:"D. MMMM YYYY.",LLL:"D. MMMM YYYY. H:mm",LLLL:"dddd, D. MMMM YYYY. H:mm"}};return t.default.locale(r,null,!0),r}(n(7484))},4127:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ss",weekdays:"Lisontfo_Umsombuluko_Lesibili_Lesitsatfu_Lesine_Lesihlanu_Umgcibelo".split("_"),months:"Bhimbidvwane_Indlovana_Indlov'lenkhulu_Mabasa_Inkhwekhweti_Inhlaba_Kholwane_Ingci_Inyoni_Imphala_Lweti_Ingongoni".split("_"),weekStart:1,weekdaysShort:"Lis_Umb_Lsb_Les_Lsi_Lsh_Umg".split("_"),monthsShort:"Bhi_Ina_Inu_Mab_Ink_Inh_Kho_Igc_Iny_Imp_Lwe_Igo".split("_"),weekdaysMin:"Li_Us_Lb_Lt_Ls_Lh_Ug".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"nga %s",past:"wenteka nga %s",s:"emizuzwana lomcane",m:"umzuzu",mm:"%d emizuzu",h:"lihora",hh:"%d emahora",d:"lilanga",dd:"%d emalanga",M:"inyanga",MM:"%d tinyanga",y:"umnyaka",yy:"%d iminyaka"}};return t.default.locale(n,null,!0),n}(n(7484))},6421:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sv-fi",weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),weekdaysMin:"sö_må_ti_on_to_fr_lö".split("_"),months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){var t=e%10;return"["+e+(1===t||2===t?"a":"e")+"]"},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY, [kl.] HH.mm",LLLL:"dddd, D. MMMM YYYY, [kl.] HH.mm",l:"D.M.YYYY",ll:"D. MMM YYYY",lll:"D. MMM YYYY, [kl.] HH.mm",llll:"ddd, D. MMM YYYY, [kl.] HH.mm"},relativeTime:{future:"om %s",past:"för %s sedan",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},1876:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sv",weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),weekdaysMin:"sö_må_ti_on_to_fr_lö".split("_"),months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){var t=e%10;return"["+e+(1===t||2===t?"a":"e")+"]"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [kl.] HH:mm",LLLL:"dddd D MMMM YYYY [kl.] HH:mm",lll:"D MMM YYYY HH:mm",llll:"ddd D MMM YYYY HH:mm"},relativeTime:{future:"om %s",past:"för %s sedan",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},9723:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sw",weekdays:"Jumapili_Jumatatu_Jumanne_Jumatano_Alhamisi_Ijumaa_Jumamosi".split("_"),weekdaysShort:"Jpl_Jtat_Jnne_Jtan_Alh_Ijm_Jmos".split("_"),weekdaysMin:"J2_J3_J4_J5_Al_Ij_J1".split("_"),months:"Januari_Februari_Machi_Aprili_Mei_Juni_Julai_Agosti_Septemba_Oktoba_Novemba_Desemba".split("_"),monthsShort:"Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ago_Sep_Okt_Nov_Des".split("_"),weekStart:1,ordinal:function(e){return e},relativeTime:{future:"%s baadaye",past:"tokea %s",s:"hivi punde",m:"dakika moja",mm:"dakika %d",h:"saa limoja",hh:"masaa %d",d:"siku moja",dd:"masiku %d",M:"mwezi mmoja",MM:"miezi %d",y:"mwaka mmoja",yy:"miaka %d"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},5596:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ta",weekdays:"ஞாயிற்றுக்கிழமை_திங்கட்கிழமை_செவ்வாய்கிழமை_புதன்கிழமை_வியாழக்கிழமை_வெள்ளிக்கிழமை_சனிக்கிழமை".split("_"),months:"ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்".split("_"),weekdaysShort:"ஞாயிறு_திங்கள்_செவ்வாய்_புதன்_வியாழன்_வெள்ளி_சனி".split("_"),monthsShort:"ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்".split("_"),weekdaysMin:"ஞா_தி_செ_பு_வி_வெ_ச".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, HH:mm",LLLL:"dddd, D MMMM YYYY, HH:mm"},relativeTime:{future:"%s இல்",past:"%s முன்",s:"ஒரு சில விநாடிகள்",m:"ஒரு நிமிடம்",mm:"%d நிமிடங்கள்",h:"ஒரு மணி நேரம்",hh:"%d மணி நேரம்",d:"ஒரு நாள்",dd:"%d நாட்கள்",M:"ஒரு மாதம்",MM:"%d மாதங்கள்",y:"ஒரு வருடம்",yy:"%d ஆண்டுகள்"}};return t.default.locale(n,null,!0),n}(n(7484))},5159:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"te",weekdays:"ఆదివారం_సోమవారం_మంగళవారం_బుధవారం_గురువారం_శుక్రవారం_శనివారం".split("_"),months:"జనవరి_ఫిబ్రవరి_మార్చి_ఏప్రిల్_మే_జూన్_జులై_ఆగస్టు_సెప్టెంబర్_అక్టోబర్_నవంబర్_డిసెంబర్".split("_"),weekdaysShort:"ఆది_సోమ_మంగళ_బుధ_గురు_శుక్ర_శని".split("_"),monthsShort:"జన._ఫిబ్ర._మార్చి_ఏప్రి._మే_జూన్_జులై_ఆగ._సెప్._అక్టో._నవ._డిసె.".split("_"),weekdaysMin:"ఆ_సో_మం_బు_గు_శు_శ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm",LLLL:"dddd, D MMMM YYYY, A h:mm"},relativeTime:{future:"%s లో",past:"%s క్రితం",s:"కొన్ని క్షణాలు",m:"ఒక నిమిషం",mm:"%d నిమిషాలు",h:"ఒక గంట",hh:"%d గంటలు",d:"ఒక రోజు",dd:"%d రోజులు",M:"ఒక నెల",MM:"%d నెలలు",y:"ఒక సంవత్సరం",yy:"%d సంవత్సరాలు"}};return t.default.locale(n,null,!0),n}(n(7484))},9157:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tet",weekdays:"Domingu_Segunda_Tersa_Kuarta_Kinta_Sesta_Sabadu".split("_"),months:"Janeiru_Fevereiru_Marsu_Abril_Maiu_Juñu_Jullu_Agustu_Setembru_Outubru_Novembru_Dezembru".split("_"),weekStart:1,weekdaysShort:"Dom_Seg_Ters_Kua_Kint_Sest_Sab".split("_"),monthsShort:"Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),weekdaysMin:"Do_Seg_Te_Ku_Ki_Ses_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"iha %s",past:"%s liuba",s:"minutu balun",m:"minutu ida",mm:"minutu %d",h:"oras ida",hh:"oras %d",d:"loron ida",dd:"loron %d",M:"fulan ida",MM:"fulan %d",y:"tinan ida",yy:"tinan %d"}};return t.default.locale(n,null,!0),n}(n(7484))},9928:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tg",weekdays:"якшанбе_душанбе_сешанбе_чоршанбе_панҷшанбе_ҷумъа_шанбе".split("_"),months:"январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр".split("_"),weekStart:1,weekdaysShort:"яшб_дшб_сшб_чшб_пшб_ҷум_шнб".split("_"),monthsShort:"янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек".split("_"),weekdaysMin:"яш_дш_сш_чш_пш_ҷм_шб".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"баъди %s",past:"%s пеш",s:"якчанд сония",m:"як дақиқа",mm:"%d дақиқа",h:"як соат",hh:"%d соат",d:"як рӯз",dd:"%d рӯз",M:"як моҳ",MM:"%d моҳ",y:"як сол",yy:"%d сол"}};return t.default.locale(n,null,!0),n}(n(7484))},2019:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"th",weekdays:"อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์".split("_"),weekdaysShort:"อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์".split("_"),weekdaysMin:"อา._จ._อ._พ._พฤ._ศ._ส.".split("_"),months:"มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม".split("_"),monthsShort:"ม.ค._ก.พ._มี.ค._เม.ย._พ.ค._มิ.ย._ก.ค._ส.ค._ก.ย._ต.ค._พ.ย._ธ.ค.".split("_"),formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY เวลา H:mm",LLLL:"วันddddที่ D MMMM YYYY เวลา H:mm"},relativeTime:{future:"อีก %s",past:"%sที่แล้ว",s:"ไม่กี่วินาที",m:"1 นาที",mm:"%d นาที",h:"1 ชั่วโมง",hh:"%d ชั่วโมง",d:"1 วัน",dd:"%d วัน",M:"1 เดือน",MM:"%d เดือน",y:"1 ปี",yy:"%d ปี"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},5817:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tk",weekdays:"Ýekşenbe_Duşenbe_Sişenbe_Çarşenbe_Penşenbe_Anna_Şenbe".split("_"),weekdaysShort:"Ýek_Duş_Siş_Çar_Pen_Ann_Şen".split("_"),weekdaysMin:"Ýk_Dş_Sş_Çr_Pn_An_Şn".split("_"),months:"Ýanwar_Fewral_Mart_Aprel_Maý_Iýun_Iýul_Awgust_Sentýabr_Oktýabr_Noýabr_Dekabr".split("_"),monthsShort:"Ýan_Few_Mar_Apr_Maý_Iýn_Iýl_Awg_Sen_Okt_Noý_Dek".split("_"),weekStart:1,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%s soň",past:"%s öň",s:"birnäçe sekunt",m:"bir minut",mm:"%d minut",h:"bir sagat",hh:"%d sagat",d:"bir gün",dd:"%d gün",M:"bir aý",MM:"%d aý",y:"bir ýyl",yy:"%d ýyl"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},6513:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tl-ph",weekdays:"Linggo_Lunes_Martes_Miyerkules_Huwebes_Biyernes_Sabado".split("_"),months:"Enero_Pebrero_Marso_Abril_Mayo_Hunyo_Hulyo_Agosto_Setyembre_Oktubre_Nobyembre_Disyembre".split("_"),weekStart:1,weekdaysShort:"Lin_Lun_Mar_Miy_Huw_Biy_Sab".split("_"),monthsShort:"Ene_Peb_Mar_Abr_May_Hun_Hul_Ago_Set_Okt_Nob_Dis".split("_"),weekdaysMin:"Li_Lu_Ma_Mi_Hu_Bi_Sab".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"MM/D/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY HH:mm",LLLL:"dddd, MMMM DD, YYYY HH:mm"},relativeTime:{future:"sa loob ng %s",past:"%s ang nakalipas",s:"ilang segundo",m:"isang minuto",mm:"%d minuto",h:"isang oras",hh:"%d oras",d:"isang araw",dd:"%d araw",M:"isang buwan",MM:"%d buwan",y:"isang taon",yy:"%d taon"}};return t.default.locale(n,null,!0),n}(n(7484))},7296:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tlh",weekdays:"lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj".split("_"),months:"tera’ jar wa’_tera’ jar cha’_tera’ jar wej_tera’ jar loS_tera’ jar vagh_tera’ jar jav_tera’ jar Soch_tera’ jar chorgh_tera’ jar Hut_tera’ jar wa’maH_tera’ jar wa’maH wa’_tera’ jar wa’maH cha’".split("_"),weekStart:1,weekdaysShort:"lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj".split("_"),monthsShort:"jar wa’_jar cha’_jar wej_jar loS_jar vagh_jar jav_jar Soch_jar chorgh_jar Hut_jar wa’maH_jar wa’maH wa’_jar wa’maH cha’".split("_"),weekdaysMin:"lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},3035:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tr",weekdays:"Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi".split("_"),weekdaysShort:"Paz_Pts_Sal_Çar_Per_Cum_Cts".split("_"),weekdaysMin:"Pz_Pt_Sa_Ça_Pe_Cu_Ct".split("_"),months:"Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık".split("_"),monthsShort:"Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara".split("_"),weekStart:1,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%s sonra",past:"%s önce",s:"birkaç saniye",m:"bir dakika",mm:"%d dakika",h:"bir saat",hh:"%d saat",d:"bir gün",dd:"%d gün",M:"bir ay",MM:"%d ay",y:"bir yıl",yy:"%d yıl"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},7797:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tzl",weekdays:"Súladi_Lúneçi_Maitzi_Márcuri_Xhúadi_Viénerçi_Sáturi".split("_"),months:"Januar_Fevraglh_Març_Avrïu_Mai_Gün_Julia_Guscht_Setemvar_Listopäts_Noemvar_Zecemvar".split("_"),weekStart:1,weekdaysShort:"Súl_Lún_Mai_Már_Xhú_Vié_Sát".split("_"),monthsShort:"Jan_Fev_Mar_Avr_Mai_Gün_Jul_Gus_Set_Lis_Noe_Zec".split("_"),weekdaysMin:"Sú_Lú_Ma_Má_Xh_Vi_Sá".split("_"),ordinal:function(e){return e},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD.MM.YYYY",LL:"D. MMMM [dallas] YYYY",LLL:"D. MMMM [dallas] YYYY HH.mm",LLLL:"dddd, [li] D. MMMM [dallas] YYYY HH.mm"}};return t.default.locale(n,null,!0),n}(n(7484))},261:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tzm-latn",weekdays:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),months:"innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir".split("_"),weekStart:6,weekdaysShort:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),monthsShort:"innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir".split("_"),weekdaysMin:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dadkh s yan %s",past:"yan %s",s:"imik",m:"minuḍ",mm:"%d minuḍ",h:"saɛa",hh:"%d tassaɛin",d:"ass",dd:"%d ossan",M:"ayowr",MM:"%d iyyirn",y:"asgas",yy:"%d isgasn"}};return t.default.locale(n,null,!0),n}(n(7484))},4722:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tzm",weekdays:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),months:"ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ".split("_"),weekStart:6,weekdaysShort:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),monthsShort:"ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ".split("_"),weekdaysMin:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ %s",past:"ⵢⴰⵏ %s",s:"ⵉⵎⵉⴽ",m:"ⵎⵉⵏⵓⴺ",mm:"%d ⵎⵉⵏⵓⴺ",h:"ⵙⴰⵄⴰ",hh:"%d ⵜⴰⵙⵙⴰⵄⵉⵏ",d:"ⴰⵙⵙ",dd:"%d oⵙⵙⴰⵏ",M:"ⴰⵢoⵓⵔ",MM:"%d ⵉⵢⵢⵉⵔⵏ",y:"ⴰⵙⴳⴰⵙ",yy:"%d ⵉⵙⴳⴰⵙⵏ"}};return t.default.locale(n,null,!0),n}(n(7484))},313:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ug-cn",weekdays:"يەكشەنبە_دۈشەنبە_سەيشەنبە_چارشەنبە_پەيشەنبە_جۈمە_شەنبە".split("_"),months:"يانۋار_فېۋرال_مارت_ئاپرېل_ماي_ئىيۇن_ئىيۇل_ئاۋغۇست_سېنتەبىر_ئۆكتەبىر_نويابىر_دېكابىر".split("_"),weekStart:1,weekdaysShort:"يە_دۈ_سە_چا_پە_جۈ_شە".split("_"),monthsShort:"يانۋار_فېۋرال_مارت_ئاپرېل_ماي_ئىيۇن_ئىيۇل_ئاۋغۇست_سېنتەبىر_ئۆكتەبىر_نويابىر_دېكابىر".split("_"),weekdaysMin:"يە_دۈ_سە_چا_پە_جۈ_شە".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY-يىلىM-ئاينىڭD-كۈنى",LLL:"YYYY-يىلىM-ئاينىڭD-كۈنى، HH:mm",LLLL:"dddd، YYYY-يىلىM-ئاينىڭD-كۈنى، HH:mm"},relativeTime:{future:"%s كېيىن",past:"%s بۇرۇن",s:"نەچچە سېكونت",m:"بىر مىنۇت",mm:"%d مىنۇت",h:"بىر سائەت",hh:"%d سائەت",d:"بىر كۈن",dd:"%d كۈن",M:"بىر ئاي",MM:"%d ئاي",y:"بىر يىل",yy:"%d يىل"}};return t.default.locale(n,null,!0),n}(n(7484))},4144:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня".split("_"),r="січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень".split("_"),a=/D[oD]?(\[[^[\]]*\]|\s)+MMMM?/;function i(e,t,n){var r,a;return"m"===n?t?"хвилина":"хвилину":"h"===n?t?"година":"годину":e+" "+(r=+e,a={ss:t?"секунда_секунди_секунд":"секунду_секунди_секунд",mm:t?"хвилина_хвилини_хвилин":"хвилину_хвилини_хвилин",hh:t?"година_години_годин":"годину_години_годин",dd:"день_дні_днів",MM:"місяць_місяці_місяців",yy:"рік_роки_років"}[n].split("_"),r%10==1&&r%100!=11?a[0]:r%10>=2&&r%10<=4&&(r%100<10||r%100>=20)?a[1]:a[2])}var s=function(e,t){return a.test(t)?n[e.month()]:r[e.month()]};s.s=r,s.f=n;var o={name:"uk",weekdays:"неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота".split("_"),weekdaysShort:"ндл_пнд_втр_срд_чтв_птн_сбт".split("_"),weekdaysMin:"нд_пн_вт_ср_чт_пт_сб".split("_"),months:s,monthsShort:"січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд".split("_"),weekStart:1,relativeTime:{future:"за %s",past:"%s тому",s:"декілька секунд",m:i,mm:i,h:i,hh:i,d:"день",dd:i,M:"місяць",MM:i,y:"рік",yy:i},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY р.",LLL:"D MMMM YYYY р., HH:mm",LLLL:"dddd, D MMMM YYYY р., HH:mm"}};return t.default.locale(o,null,!0),o}(n(7484))},2957:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ur",weekdays:"اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ".split("_"),months:"جنوری_فروری_مارچ_اپریل_مئی_جون_جولائی_اگست_ستمبر_اکتوبر_نومبر_دسمبر".split("_"),weekStart:1,weekdaysShort:"اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ".split("_"),monthsShort:"جنوری_فروری_مارچ_اپریل_مئی_جون_جولائی_اگست_ستمبر_اکتوبر_نومبر_دسمبر".split("_"),weekdaysMin:"اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd، D MMMM YYYY HH:mm"},relativeTime:{future:"%s بعد",past:"%s قبل",s:"چند سیکنڈ",m:"ایک منٹ",mm:"%d منٹ",h:"ایک گھنٹہ",hh:"%d گھنٹے",d:"ایک دن",dd:"%d دن",M:"ایک ماہ",MM:"%d ماہ",y:"ایک سال",yy:"%d سال"}};return t.default.locale(n,null,!0),n}(n(7484))},8727:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"uz-latn",weekdays:"Yakshanba_Dushanba_Seshanba_Chorshanba_Payshanba_Juma_Shanba".split("_"),months:"Yanvar_Fevral_Mart_Aprel_May_Iyun_Iyul_Avgust_Sentabr_Oktabr_Noyabr_Dekabr".split("_"),weekStart:1,weekdaysShort:"Yak_Dush_Sesh_Chor_Pay_Jum_Shan".split("_"),monthsShort:"Yan_Fev_Mar_Apr_May_Iyun_Iyul_Avg_Sen_Okt_Noy_Dek".split("_"),weekdaysMin:"Ya_Du_Se_Cho_Pa_Ju_Sha".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"D MMMM YYYY, dddd HH:mm"},relativeTime:{future:"Yaqin %s ichida",past:"Bir necha %s oldin",s:"soniya",m:"bir daqiqa",mm:"%d daqiqa",h:"bir soat",hh:"%d soat",d:"bir kun",dd:"%d kun",M:"bir oy",MM:"%d oy",y:"bir yil",yy:"%d yil"}};return t.default.locale(n,null,!0),n}(n(7484))},7486:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"uz",weekdays:"Якшанба_Душанба_Сешанба_Чоршанба_Пайшанба_Жума_Шанба".split("_"),months:"январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр".split("_"),weekStart:1,weekdaysShort:"Якш_Душ_Сеш_Чор_Пай_Жум_Шан".split("_"),monthsShort:"янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек".split("_"),weekdaysMin:"Як_Ду_Се_Чо_Па_Жу_Ша".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"D MMMM YYYY, dddd HH:mm"},relativeTime:{future:"Якин %s ичида",past:"Бир неча %s олдин",s:"фурсат",m:"бир дакика",mm:"%d дакика",h:"бир соат",hh:"%d соат",d:"бир кун",dd:"%d кун",M:"бир ой",MM:"%d ой",y:"бир йил",yy:"%d йил"}};return t.default.locale(n,null,!0),n}(n(7484))},7553:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"vi",weekdays:"chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy".split("_"),months:"tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12".split("_"),weekStart:1,weekdaysShort:"CN_T2_T3_T4_T5_T6_T7".split("_"),monthsShort:"Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12".split("_"),weekdaysMin:"CN_T2_T3_T4_T5_T6_T7".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM [năm] YYYY",LLL:"D MMMM [năm] YYYY HH:mm",LLLL:"dddd, D MMMM [năm] YYYY HH:mm",l:"DD/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY HH:mm",llll:"ddd, D MMM YYYY HH:mm"},relativeTime:{future:"%s tới",past:"%s trước",s:"vài giây",m:"một phút",mm:"%d phút",h:"một giờ",hh:"%d giờ",d:"một ngày",dd:"%d ngày",M:"một tháng",MM:"%d tháng",y:"một năm",yy:"%d năm"}};return t.default.locale(n,null,!0),n}(n(7484))},5321:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"x-pseudo",weekdays:"S~úñdá~ý_Mó~ñdáý~_Túé~sdáý~_Wéd~ñésd~áý_T~húrs~dáý_~Fríd~áý_S~átúr~dáý".split("_"),months:"J~áñúá~rý_F~ébrú~árý_~Márc~h_Áp~ríl_~Máý_~Júñé~_Júl~ý_Áú~gúst~_Sép~témb~ér_Ó~ctób~ér_Ñ~óvém~bér_~Décé~mbér".split("_"),weekStart:1,weekdaysShort:"S~úñ_~Móñ_~Túé_~Wéd_~Thú_~Frí_~Sát".split("_"),monthsShort:"J~áñ_~Féb_~Már_~Ápr_~Máý_~Júñ_~Júl_~Áúg_~Sép_~Óct_~Ñóv_~Déc".split("_"),weekdaysMin:"S~ú_Mó~_Tú_~Wé_T~h_Fr~_Sá".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"í~ñ %s",past:"%s á~gó",s:"á ~féw ~sécó~ñds",m:"á ~míñ~úté",mm:"%d m~íñú~tés",h:"á~ñ hó~úr",hh:"%d h~óúrs",d:"á ~dáý",dd:"%d d~áýs",M:"á ~móñ~th",MM:"%d m~óñt~hs",y:"á ~ýéár",yy:"%d ý~éárs"}};return t.default.locale(n,null,!0),n}(n(7484))},4724:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"yo",weekdays:"Àìkú_Ajé_Ìsẹ́gun_Ọjọ́rú_Ọjọ́bọ_Ẹtì_Àbámẹ́ta".split("_"),months:"Sẹ́rẹ́_Èrèlè_Ẹrẹ̀nà_Ìgbé_Èbibi_Òkùdu_Agẹmo_Ògún_Owewe_Ọ̀wàrà_Bélú_Ọ̀pẹ̀̀".split("_"),weekStart:1,weekdaysShort:"Àìk_Ajé_Ìsẹ́_Ọjr_Ọjb_Ẹtì_Àbá".split("_"),monthsShort:"Sẹ́r_Èrl_Ẹrn_Ìgb_Èbi_Òkù_Agẹ_Ògú_Owe_Ọ̀wà_Bél_Ọ̀pẹ̀̀".split("_"),weekdaysMin:"Àì_Aj_Ìs_Ọr_Ọb_Ẹt_Àb".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"ní %s",past:"%s kọjá",s:"ìsẹjú aayá die",m:"ìsẹjú kan",mm:"ìsẹjú %d",h:"wákati kan",hh:"wákati %d",d:"ọjọ́ kan",dd:"ọjọ́ %d",M:"osù kan",MM:"osù %d",y:"ọdún kan",yy:"ọdún %d"}};return t.default.locale(n,null,!0),n}(n(7484))},3852:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh-cn",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,t){var n=100*e+t;return n<600?"凌晨":n<900?"早上":n<1100?"上午":n<1300?"中午":n<1800?"下午":"晚上"}};return t.default.locale(n,null,!0),n}(n(7484))},2390:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh-hk",months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"週日_週一_週二_週三_週四_週五_週六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),ordinal:function(e,t){return"W"===t?e+"週":e+"日"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日 HH:mm",LLLL:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s內",past:"%s前",s:"幾秒",m:"一分鐘",mm:"%d 分鐘",h:"一小時",hh:"%d 小時",d:"一天",dd:"%d 天",M:"一個月",MM:"%d 個月",y:"一年",yy:"%d 年"}};return t.default.locale(n,null,!0),n}(n(7484))},3901:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh-tw",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"週日_週一_週二_週三_週四_週五_週六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"週":e+"日"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日 HH:mm",LLLL:"YYYY年M月D日dddd HH:mm",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s內",past:"%s前",s:"幾秒",m:"1 分鐘",mm:"%d 分鐘",h:"1 小時",hh:"%d 小時",d:"1 天",dd:"%d 天",M:"1 個月",MM:"%d 個月",y:"1 年",yy:"%d 年"}};return t.default.locale(n,null,!0),n}(n(7484))},2009:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s后",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,t){var n=100*e+t;return n<600?"凌晨":n<900?"早上":n<1100?"上午":n<1300?"中午":n<1800?"下午":"晚上"}};return t.default.locale(n,null,!0),n}(n(7484))},285:function(e){e.exports=function(){"use strict";var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,a=/\d*[^-_:/,()\s\d]+/,i={},s=function(e){return(e=+e)+(e>68?1900:2e3)},o=function(e){return function(t){this[e]=+t}},u=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e)}],l=function(e){var t=i[e];return t&&(t.indexOf?t:t.s.concat(t.f))},c=function(e,t){var n,r=i.meridiem;if(r){for(var a=1;a<=24;a+=1)if(e.indexOf(r(a,0,t))>-1){n=a>12;break}}else n=e===(t?"pm":"PM");return n},p={A:[a,function(e){this.afternoon=c(e,!1)}],a:[a,function(e){this.afternoon=c(e,!0)}],S:[/\d/,function(e){this.milliseconds=100*+e}],SS:[n,function(e){this.milliseconds=10*+e}],SSS:[/\d{3}/,function(e){this.milliseconds=+e}],s:[r,o("seconds")],ss:[r,o("seconds")],m:[r,o("minutes")],mm:[r,o("minutes")],H:[r,o("hours")],h:[r,o("hours")],HH:[r,o("hours")],hh:[r,o("hours")],D:[r,o("day")],DD:[n,o("day")],Do:[a,function(e){var t=i.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r)}],M:[r,o("month")],MM:[n,o("month")],MMM:[a,function(e){var t=l("months"),n=(l("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n}],MMMM:[a,function(e){var t=l("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t}],Y:[/[+-]?\d+/,o("year")],YY:[n,function(e){this.year=s(e)}],YYYY:[/\d{4}/,o("year")],Z:u,ZZ:u};function d(n){var r,a;r=n,a=i&&i.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var i=r&&r.toUpperCase();return n||a[r]||e[r]||a[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),o=s.length,u=0;u-1)return new Date(("X"===t?1e3:1)*e);var r=d(t)(e),a=r.year,i=r.month,s=r.day,o=r.hours,u=r.minutes,l=r.seconds,c=r.milliseconds,p=r.zone,h=new Date,f=s||(a||i?1:h.getDate()),m=a||h.getFullYear(),g=0;a&&!i||(g=i>0?i-1:h.getMonth());var y=o||0,b=u||0,x=l||0,v=c||0;return p?new Date(Date.UTC(m,g,f,y,b,x,v+60*p.offset*1e3)):n?new Date(Date.UTC(m,g,f,y,b,x,v)):new Date(m,g,f,y,b,x,v)}catch(e){return new Date("")}}(t,o,r),this.init(),p&&!0!==p&&(this.$L=this.locale(p).$L),c&&t!=this.format(o)&&(this.$d=new Date("")),i={}}else if(o instanceof Array)for(var h=o.length,f=1;f<=h;f+=1){s[1]=o[f-1];var m=n.apply(this,s);if(m.isValid()){this.$d=m.$d,this.$L=m.$L,this.init();break}f===h&&(this.$d=new Date(""))}else a.call(this,e)}}}()},2997:function(e){e.exports=function(){"use strict";return function(e,t,n){t.prototype.dayOfYear=function(e){var t=Math.round((n(this).startOf("day")-n(this).startOf("year"))/864e5)+1;return null==e?t:this.add(e-t,"day")}}}()},6036:function(e){e.exports=function(){"use strict";return function(e,t,n){var r=t.prototype,a=function(e){return e&&(e.indexOf?e:e.s)},i=function(e,t,n,r,i){var s=e.name?e:e.$locale(),o=a(s[t]),u=a(s[n]),l=o||u.map((function(e){return e.slice(0,r)}));if(!i)return l;var c=s.weekStart;return l.map((function(e,t){return l[(t+(c||0))%7]}))},s=function(){return n.Ls[n.locale()]},o=function(e,t){return e.formats[t]||function(e){return e.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}(e.formats[t.toUpperCase()])},u=function(){var e=this;return{months:function(t){return t?t.format("MMMM"):i(e,"months")},monthsShort:function(t){return t?t.format("MMM"):i(e,"monthsShort","months",3)},firstDayOfWeek:function(){return e.$locale().weekStart||0},weekdays:function(t){return t?t.format("dddd"):i(e,"weekdays")},weekdaysMin:function(t){return t?t.format("dd"):i(e,"weekdaysMin","weekdays",2)},weekdaysShort:function(t){return t?t.format("ddd"):i(e,"weekdaysShort","weekdays",3)},longDateFormat:function(t){return o(e.$locale(),t)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};r.localeData=function(){return u.bind(this)()},n.localeData=function(){var e=s();return{firstDayOfWeek:function(){return e.weekStart||0},weekdays:function(){return n.weekdays()},weekdaysShort:function(){return n.weekdaysShort()},weekdaysMin:function(){return n.weekdaysMin()},months:function(){return n.months()},monthsShort:function(){return n.monthsShort()},longDateFormat:function(t){return o(e,t)},meridiem:e.meridiem,ordinal:e.ordinal}},n.months=function(){return i(s(),"months")},n.monthsShort=function(){return i(s(),"monthsShort","months",3)},n.weekdays=function(e){return i(s(),"weekdays",null,null,e)},n.weekdaysShort=function(e){return i(s(),"weekdaysShort","weekdays",3,e)},n.weekdaysMin=function(e){return i(s(),"weekdaysMin","weekdays",2,e)}}}()},6176:function(e){e.exports=function(){"use strict";var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(t,n,r){var a=n.prototype,i=a.format;r.en.formats=e,a.format=function(t){void 0===t&&(t="YYYY-MM-DDTHH:mm:ssZ");var n=this.$locale().formats,r=function(t,n){return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,r,a){var i=a&&a.toUpperCase();return r||n[a]||e[a]||n[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))}(t,void 0===n?{}:n);return i.call(this,r)}}}()},3776:function(e,t,n){var r;!function(a){"use strict";var i,s,o,u=9e15,l=1e9,c="0123456789abcdef",p="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",d="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",h={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-u,maxE:u,crypto:!1},f=!0,m="[DecimalError] ",g=m+"Invalid argument: ",y=m+"Precision limit exceeded",b=m+"crypto unavailable",x="[object Decimal]",v=Math.floor,_=Math.pow,w=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,M=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,N=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,S=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,k=1e7,D=p.length-1,T=d.length-1,I={toStringTag:x};function E(e){var t,n,r,a=e.length-1,i="",s=e[0];if(a>0){for(i+=s,t=1;tn)throw Error(g+e)}function A(e,t,n,r){var a,i,s,o;for(i=e[0];i>=10;i/=10)--t;return--t<0?(t+=7,a=0):(a=Math.ceil((t+1)/7),t%=7),i=_(10,7-t),o=e[a]%i|0,null==r?t<3?(0==t?o=o/100|0:1==t&&(o=o/10|0),s=n<4&&99999==o||n>3&&49999==o||5e4==o||0==o):s=(n<4&&o+1==i||n>3&&o+1==i/2)&&(e[a+1]/i/100|0)==_(10,t-2)-1||(o==i/2||0==o)&&0==(e[a+1]/i/100|0):t<4?(0==t?o=o/1e3|0:1==t?o=o/100|0:2==t&&(o=o/10|0),s=(r||n<4)&&9999==o||!r&&n>3&&4999==o):s=((r||n<4)&&o+1==i||!r&&n>3&&o+1==i/2)&&(e[a+1]/i/1e3|0)==_(10,t-3)-1,s}function L(e,t,n){for(var r,a,i=[0],s=0,o=e.length;sn-1&&(void 0===i[r+1]&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}I.absoluteValue=I.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),O(e)},I.ceil=function(){return O(new this.constructor(this),this.e+1,2)},I.clampedTo=I.clamp=function(e,t){var n=this,r=n.constructor;if(e=new r(e),t=new r(t),!e.s||!t.s)return new r(NaN);if(e.gt(t))throw Error(g+t);return n.cmp(e)<0?e:n.cmp(t)>0?t:new r(n)},I.comparedTo=I.cmp=function(e){var t,n,r,a,i=this,s=i.d,o=(e=new i.constructor(e)).d,u=i.s,l=e.s;if(!s||!o)return u&&l?u!==l?u:s===o?0:!s^u<0?1:-1:NaN;if(!s[0]||!o[0])return s[0]?u:o[0]?-l:0;if(u!==l)return u;if(i.e!==e.e)return i.e>e.e^u<0?1:-1;for(t=0,n=(r=s.length)<(a=o.length)?r:a;to[t]^u<0?1:-1;return r===a?0:r>a^u<0?1:-1},I.cosine=I.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+7,r.rounding=1,n=function(e,t){var n,r,a;if(t.isZero())return t;(r=t.d.length)<32?a=(1/X(4,n=Math.ceil(r/3))).toString():(n=16,a="2.3283064365386962890625e-10"),e.precision+=n,t=J(e,1,t.times(a),new e(1));for(var i=n;i--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return e.precision-=n,t}(r,Z(r,n)),r.precision=e,r.rounding=t,O(2==o||3==o?n.neg():n,e,t,!0)):new r(1):new r(NaN)},I.cubeRoot=I.cbrt=function(){var e,t,n,r,a,i,s,o,u,l,c=this,p=c.constructor;if(!c.isFinite()||c.isZero())return new p(c);for(f=!1,(i=c.s*_(c.s*c,1/3))&&Math.abs(i)!=1/0?r=new p(i.toString()):(n=E(c.d),(i=((e=c.e)-n.length+1)%3)&&(n+=1==i||-2==i?"0":"00"),i=_(n,1/3),e=v((e+1)/3)-(e%3==(e<0?-1:2)),(r=new p(n=i==1/0?"5e"+e:(n=i.toExponential()).slice(0,n.indexOf("e")+1)+e)).s=c.s),s=(e=p.precision)+3;;)if(l=(u=(o=r).times(o).times(o)).plus(c),r=$(l.plus(c).times(o),l.plus(u),s+2,1),E(o.d).slice(0,s)===(n=E(r.d)).slice(0,s)){if("9999"!=(n=n.slice(s-3,s+1))&&(a||"4999"!=n)){+n&&(+n.slice(1)||"5"!=n.charAt(0))||(O(r,e+1,1),t=!r.times(r).times(r).eq(c));break}if(!a&&(O(o,e+1,0),o.times(o).times(o).eq(c))){r=o;break}s+=4,a=1}return f=!0,O(r,e,p.rounding,t)},I.decimalPlaces=I.dp=function(){var e,t=this.d,n=NaN;if(t){if(n=7*((e=t.length-1)-v(this.e/7)),e=t[e])for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},I.dividedBy=I.div=function(e){return $(this,new this.constructor(e))},I.dividedToIntegerBy=I.divToInt=function(e){var t=this.constructor;return O($(this,new t(e),0,1,1),t.precision,t.rounding)},I.equals=I.eq=function(e){return 0===this.cmp(e)},I.floor=function(){return O(new this.constructor(this),this.e+1,3)},I.greaterThan=I.gt=function(e){return this.cmp(e)>0},I.greaterThanOrEqualTo=I.gte=function(e){var t=this.cmp(e);return 1==t||0===t},I.hyperbolicCosine=I.cosh=function(){var e,t,n,r,a,i=this,s=i.constructor,o=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return o;n=s.precision,r=s.rounding,s.precision=n+Math.max(i.e,i.sd())+4,s.rounding=1,(a=i.d.length)<32?t=(1/X(4,e=Math.ceil(a/3))).toString():(e=16,t="2.3283064365386962890625e-10"),i=J(s,1,i.times(t),new s(1),!0);for(var u,l=e,c=new s(8);l--;)u=i.times(i),i=o.minus(u.times(c.minus(u.times(c))));return O(i,s.precision=n,s.rounding=r,!0)},I.hyperbolicSine=I.sinh=function(){var e,t,n,r,a=this,i=a.constructor;if(!a.isFinite()||a.isZero())return new i(a);if(t=i.precision,n=i.rounding,i.precision=t+Math.max(a.e,a.sd())+4,i.rounding=1,(r=a.d.length)<3)a=J(i,2,a,a,!0);else{e=(e=1.4*Math.sqrt(r))>16?16:0|e,a=J(i,2,a=a.times(1/X(5,e)),a,!0);for(var s,o=new i(5),u=new i(16),l=new i(20);e--;)s=a.times(a),a=a.times(o.plus(s.times(u.times(s).plus(l))))}return i.precision=t,i.rounding=n,O(a,t,n,!0)},I.hyperbolicTangent=I.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,$(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},I.inverseCosine=I.acos=function(){var e,t=this,n=t.constructor,r=t.abs().cmp(1),a=n.precision,i=n.rounding;return-1!==r?0===r?t.isNeg()?z(n,a,i):new n(0):new n(NaN):t.isZero()?z(n,a+4,i).times(.5):(n.precision=a+6,n.rounding=1,t=t.asin(),e=z(n,a+4,i).times(.5),n.precision=a,n.rounding=i,e.minus(t))},I.inverseHyperbolicCosine=I.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,f=!1,n=n.times(n).minus(1).sqrt().plus(n),f=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},I.inverseHyperbolicSine=I.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,f=!1,n=n.times(n).plus(1).sqrt().plus(n),f=!0,r.precision=e,r.rounding=t,n.ln())},I.inverseHyperbolicTangent=I.atanh=function(){var e,t,n,r,a=this,i=a.constructor;return a.isFinite()?a.e>=0?new i(a.abs().eq(1)?a.s/0:a.isZero()?a:NaN):(e=i.precision,t=i.rounding,r=a.sd(),Math.max(r,e)<2*-a.e-1?O(new i(a),e,t,!0):(i.precision=n=r-a.e,a=$(a.plus(1),new i(1).minus(a),n+e,1),i.precision=e+4,i.rounding=1,a=a.ln(),i.precision=e,i.rounding=t,a.times(.5))):new i(NaN)},I.inverseSine=I.asin=function(){var e,t,n,r,a=this,i=a.constructor;return a.isZero()?new i(a):(t=a.abs().cmp(1),n=i.precision,r=i.rounding,-1!==t?0===t?((e=z(i,n+4,r).times(.5)).s=a.s,e):new i(NaN):(i.precision=n+6,i.rounding=1,a=a.div(new i(1).minus(a.times(a)).sqrt().plus(1)).atan(),i.precision=n,i.rounding=r,a.times(2)))},I.inverseTangent=I.atan=function(){var e,t,n,r,a,i,s,o,u,l=this,c=l.constructor,p=c.precision,d=c.rounding;if(l.isFinite()){if(l.isZero())return new c(l);if(l.abs().eq(1)&&p+4<=T)return(s=z(c,p+4,d).times(.25)).s=l.s,s}else{if(!l.s)return new c(NaN);if(p+4<=T)return(s=z(c,p+4,d).times(.5)).s=l.s,s}for(c.precision=o=p+10,c.rounding=1,e=n=Math.min(28,o/7+2|0);e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(f=!1,t=Math.ceil(o/7),r=1,u=l.times(l),s=new c(l),a=l;-1!==e;)if(a=a.times(u),i=s.minus(a.div(r+=2)),a=a.times(u),void 0!==(s=i.plus(a.div(r+=2))).d[t])for(e=t;s.d[e]===i.d[e]&&e--;);return n&&(s=s.times(2<this.d.length-2},I.isNaN=function(){return!this.s},I.isNegative=I.isNeg=function(){return this.s<0},I.isPositive=I.isPos=function(){return this.s>0},I.isZero=function(){return!!this.d&&0===this.d[0]},I.lessThan=I.lt=function(e){return this.cmp(e)<0},I.lessThanOrEqualTo=I.lte=function(e){return this.cmp(e)<1},I.logarithm=I.log=function(e){var t,n,r,a,i,s,o,u,l=this,c=l.constructor,p=c.precision,d=c.rounding;if(null==e)e=new c(10),t=!0;else{if(n=(e=new c(e)).d,e.s<0||!n||!n[0]||e.eq(1))return new c(NaN);t=e.eq(10)}if(n=l.d,l.s<0||!n||!n[0]||l.eq(1))return new c(n&&!n[0]?-1/0:1!=l.s?NaN:n?0:1/0);if(t)if(n.length>1)i=!0;else{for(a=n[0];a%10==0;)a/=10;i=1!==a}if(f=!1,s=W(l,o=p+5),r=t?Y(c,o+10):W(e,o),A((u=$(s,r,o,1)).d,a=p,d))do{if(s=W(l,o+=10),r=t?Y(c,o+10):W(e,o),u=$(s,r,o,1),!i){+E(u.d).slice(a+1,a+15)+1==1e14&&(u=O(u,p+1,0));break}}while(A(u.d,a+=10,d));return f=!0,O(u,p,d)},I.minus=I.sub=function(e){var t,n,r,a,i,s,o,u,l,c,p,d,h=this,m=h.constructor;if(e=new m(e),!h.d||!e.d)return h.s&&e.s?h.d?e.s=-e.s:e=new m(e.d||h.s!==e.s?h:NaN):e=new m(NaN),e;if(h.s!=e.s)return e.s=-e.s,h.plus(e);if(l=h.d,d=e.d,o=m.precision,u=m.rounding,!l[0]||!d[0]){if(d[0])e.s=-e.s;else{if(!l[0])return new m(3===u?-0:0);e=new m(h)}return f?O(e,o,u):e}if(n=v(e.e/7),c=v(h.e/7),l=l.slice(),i=c-n){for((p=i<0)?(t=l,i=-i,s=d.length):(t=d,n=c,s=l.length),i>(r=Math.max(Math.ceil(o/7),s)+2)&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for((p=(r=l.length)<(s=d.length))&&(s=r),r=0;r0;--r)l[s++]=0;for(r=d.length;r>i;){if(l[--r](s=(i=Math.ceil(o/7))>s?i+1:s+1)&&(a=s,n.length=1),n.reverse();a--;)n.push(0);n.reverse()}for((s=l.length)-(a=c.length)<0&&(a=s,n=c,c=l,l=n),t=0;a;)t=(l[--a]=l[a]+c[a]+t)/k|0,l[a]%=k;for(t&&(l.unshift(t),++r),s=l.length;0==l[--s];)l.pop();return e.d=l,e.e=F(l,r),f?O(e,o,u):e},I.precision=I.sd=function(e){var t,n=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(g+e);return n.d?(t=B(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},I.round=function(){var e=this,t=e.constructor;return O(new t(e),e.e+1,t.rounding)},I.sine=I.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+7,r.rounding=1,n=function(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:J(e,2,t,t);n=(n=1.4*Math.sqrt(r))>16?16:0|n,t=J(e,2,t=t.times(1/X(5,n)),t);for(var a,i=new e(5),s=new e(16),o=new e(20);n--;)a=t.times(t),t=t.times(i.plus(a.times(s.times(a).minus(o))));return t}(r,Z(r,n)),r.precision=e,r.rounding=t,O(o>2?n.neg():n,e,t,!0)):new r(NaN)},I.squareRoot=I.sqrt=function(){var e,t,n,r,a,i,s=this,o=s.d,u=s.e,l=s.s,c=s.constructor;if(1!==l||!o||!o[0])return new c(!l||l<0&&(!o||o[0])?NaN:o?s:1/0);for(f=!1,0==(l=Math.sqrt(+s))||l==1/0?(((t=E(o)).length+u)%2==0&&(t+="0"),l=Math.sqrt(t),u=v((u+1)/2)-(u<0||u%2),r=new c(t=l==1/0?"5e"+u:(t=l.toExponential()).slice(0,t.indexOf("e")+1)+u)):r=new c(l.toString()),n=(u=c.precision)+3;;)if(r=(i=r).plus($(s,i,n+2,1)).times(.5),E(i.d).slice(0,n)===(t=E(r.d)).slice(0,n)){if("9999"!=(t=t.slice(n-3,n+1))&&(a||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(O(r,u+1,1),e=!r.times(r).eq(s));break}if(!a&&(O(i,u+1,0),i.times(i).eq(s))){r=i;break}n+=4,a=1}return f=!0,O(r,u,c.rounding,e)},I.tangent=I.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,(n=n.sin()).s=1,n=$(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,O(2==o||4==o?n.neg():n,e,t,!0)):new r(NaN)},I.times=I.mul=function(e){var t,n,r,a,i,s,o,u,l,c=this,p=c.constructor,d=c.d,h=(e=new p(e)).d;if(e.s*=c.s,!(d&&d[0]&&h&&h[0]))return new p(!e.s||d&&!d[0]&&!h||h&&!h[0]&&!d?NaN:d&&h?0*e.s:e.s/0);for(n=v(c.e/7)+v(e.e/7),(u=d.length)<(l=h.length)&&(i=d,d=h,h=i,s=u,u=l,l=s),i=[],r=s=u+l;r--;)i.push(0);for(r=l;--r>=0;){for(t=0,a=u+r;a>r;)o=i[a]+h[r]*d[a-r-1]+t,i[a--]=o%k|0,t=o/k|0;i[a]=(i[a]+t)%k|0}for(;!i[--s];)i.pop();return t?++n:i.shift(),e.d=i,e.e=F(i,n),f?O(e,p.precision,p.rounding):e},I.toBinary=function(e,t){return Q(this,2,e,t)},I.toDecimalPlaces=I.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),void 0===e?n:(C(e,0,l),void 0===t?t=r.rounding:C(t,0,8),O(n,e+n.e+1,t))},I.toExponential=function(e,t){var n,r=this,a=r.constructor;return void 0===e?n=R(r,!0):(C(e,0,l),void 0===t?t=a.rounding:C(t,0,8),n=R(r=O(new a(r),e+1,t),!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n},I.toFixed=function(e,t){var n,r,a=this,i=a.constructor;return void 0===e?n=R(a):(C(e,0,l),void 0===t?t=i.rounding:C(t,0,8),n=R(r=O(new i(a),e+a.e+1,t),!1,e+r.e+1)),a.isNeg()&&!a.isZero()?"-"+n:n},I.toFraction=function(e){var t,n,r,a,i,s,o,u,l,c,p,d,h=this,m=h.d,y=h.constructor;if(!m)return new y(h);if(l=n=new y(1),r=u=new y(0),s=(i=(t=new y(r)).e=B(m)-h.e-1)%7,t.d[0]=_(10,s<0?7+s:s),null==e)e=i>0?t:l;else{if(!(o=new y(e)).isInt()||o.lt(l))throw Error(g+o);e=o.gt(t)?i>0?t:l:o}for(f=!1,o=new y(E(m)),c=y.precision,y.precision=i=7*m.length*2;p=$(o,t,0,1,1),1!=(a=n.plus(p.times(r))).cmp(e);)n=r,r=a,a=l,l=u.plus(p.times(a)),u=a,a=t,t=o.minus(p.times(a)),o=a;return a=$(e.minus(n),r,0,1,1),u=u.plus(a.times(l)),n=n.plus(a.times(r)),u.s=l.s=h.s,d=$(l,r,i,1).minus(h).abs().cmp($(u,n,i,1).minus(h).abs())<1?[l,r]:[u,n],y.precision=c,f=!0,d},I.toHexadecimal=I.toHex=function(e,t){return Q(this,16,e,t)},I.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),null==e){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),void 0===t?t=r.rounding:C(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(f=!1,n=$(n,e,0,t,1).times(e),f=!0,O(n)):(e.s=n.s,n=e),n},I.toNumber=function(){return+this},I.toOctal=function(e,t){return Q(this,8,e,t)},I.toPower=I.pow=function(e){var t,n,r,a,i,s,o=this,u=o.constructor,l=+(e=new u(e));if(!(o.d&&e.d&&o.d[0]&&e.d[0]))return new u(_(+o,l));if((o=new u(o)).eq(1))return o;if(r=u.precision,i=u.rounding,e.eq(1))return O(o,r,i);if((t=v(e.e/7))>=e.d.length-1&&(n=l<0?-l:l)<=9007199254740991)return a=H(u,o,n,r),e.s<0?new u(1).div(a):O(a,r,i);if((s=o.s)<0){if(tu.maxE+1||t0?s/0:0):(f=!1,u.rounding=o.s=1,n=Math.min(12,(t+"").length),(a=q(e.times(W(o,r+n)),r)).d&&A((a=O(a,r+5,1)).d,r,i)&&(t=r+10,+E((a=O(q(e.times(W(o,t+n)),t),t+5,1)).d).slice(r+1,r+15)+1==1e14&&(a=O(a,r+1,0))),a.s=s,f=!0,u.rounding=i,O(a,r,i))},I.toPrecision=function(e,t){var n,r=this,a=r.constructor;return void 0===e?n=R(r,r.e<=a.toExpNeg||r.e>=a.toExpPos):(C(e,1,l),void 0===t?t=a.rounding:C(t,0,8),n=R(r=O(new a(r),e,t),e<=r.e||r.e<=a.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n},I.toSignificantDigits=I.toSD=function(e,t){var n=this.constructor;return void 0===e?(e=n.precision,t=n.rounding):(C(e,1,l),void 0===t?t=n.rounding:C(t,0,8)),O(new n(this),e,t)},I.toString=function(){var e=this,t=e.constructor,n=R(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n},I.truncated=I.trunc=function(){return O(new this.constructor(this),this.e+1,1)},I.valueOf=I.toJSON=function(){var e=this,t=e.constructor,n=R(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};var $=function(){function e(e,t,n){var r,a=0,i=e.length;for(e=e.slice();i--;)r=e[i]*t+a,e[i]=r%n|0,a=r/n|0;return a&&e.unshift(a),e}function t(e,t,n,r){var a,i;if(n!=r)i=n>r?1:-1;else for(a=i=0;at[a]?1:-1;break}return i}function n(e,t,n,r){for(var a=0;n--;)e[n]-=a,a=e[n]1;)e.shift()}return function(r,a,i,o,u,l){var c,p,d,h,f,m,g,y,b,x,_,w,M,N,S,D,T,I,E,C,A=r.constructor,L=r.s==a.s?1:-1,$=r.d,R=a.d;if(!($&&$[0]&&R&&R[0]))return new A(r.s&&a.s&&($?!R||$[0]!=R[0]:R)?$&&0==$[0]||!R?0*L:L/0:NaN);for(l?(f=1,p=r.e-a.e):(l=k,f=7,p=v(r.e/f)-v(a.e/f)),E=R.length,T=$.length,x=(b=new A(L)).d=[],d=0;R[d]==($[d]||0);d++);if(R[d]>($[d]||0)&&p--,null==i?(N=i=A.precision,o=A.rounding):N=u?i+(r.e-a.e)+1:i,N<0)x.push(1),m=!0;else{if(N=N/f+2|0,d=0,1==E){for(h=0,R=R[0],N++;(d1&&(R=e(R,h,l),$=e($,h,l),E=R.length,T=$.length),D=E,w=(_=$.slice(0,E)).length;w=l/2&&++I;do{h=0,(c=t(R,_,E,w))<0?(M=_[0],E!=w&&(M=M*l+(_[1]||0)),(h=M/I|0)>1?(h>=l&&(h=l-1),1==(c=t(g=e(R,h,l),_,y=g.length,w=_.length))&&(h--,n(g,E=10;h/=10)d++;b.e=d+p*f-1,O(b,u?i+b.e+1:i,o,m)}return b}}();function O(e,t,n,r){var a,i,s,o,u,l,c,p,d,h=e.constructor;e:if(null!=t){if(!(p=e.d))return e;for(a=1,o=p[0];o>=10;o/=10)a++;if((i=t-a)<0)i+=7,s=t,u=(c=p[d=0])/_(10,a-s-1)%10|0;else if((d=Math.ceil((i+1)/7))>=(o=p.length)){if(!r)break e;for(;o++<=d;)p.push(0);c=u=0,a=1,s=(i%=7)-7+1}else{for(c=o=p[d],a=1;o>=10;o/=10)a++;u=(s=(i%=7)-7+a)<0?0:c/_(10,a-s-1)%10|0}if(r=r||t<0||void 0!==p[d+1]||(s<0?c:c%_(10,a-s-1)),l=n<4?(u||r)&&(0==n||n==(e.s<0?3:2)):u>5||5==u&&(4==n||r||6==n&&(i>0?s>0?c/_(10,a-s):0:p[d-1])%10&1||n==(e.s<0?8:7)),t<1||!p[0])return p.length=0,l?(t-=e.e+1,p[0]=_(10,(7-t%7)%7),e.e=-t||0):p[0]=e.e=0,e;if(0==i?(p.length=d,o=1,d--):(p.length=d+1,o=_(10,7-i),p[d]=s>0?(c/_(10,a-s)%_(10,s)|0)*o:0),l)for(;;){if(0==d){for(i=1,s=p[0];s>=10;s/=10)i++;for(s=p[0]+=o,o=1;s>=10;s/=10)o++;i!=o&&(e.e++,p[0]==k&&(p[0]=1));break}if(p[d]+=o,p[d]!=k)break;p[d--]=0,o=1}for(i=p.length;0===p[--i];)p.pop()}return f&&(e.e>h.maxE?(e.d=null,e.e=NaN):e.e0?i=i.charAt(0)+"."+i.slice(1)+P(r):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):a<0?(i="0."+P(-a-1)+i,n&&(r=n-s)>0&&(i+=P(r))):a>=s?(i+=P(a+1-s),n&&(r=n-a-1)>0&&(i=i+"."+P(r))):((r=a+1)0&&(a+1===s&&(i+="."),i+=P(r))),i}function F(e,t){var n=e[0];for(t*=7;n>=10;n/=10)t++;return t}function Y(e,t,n){if(t>D)throw f=!0,n&&(e.precision=n),Error(y);return O(new e(p),t,1,!0)}function z(e,t,n){if(t>T)throw Error(y);return O(new e(d),t,n,!0)}function B(e){var t=e.length-1,n=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function P(e){for(var t="";e--;)t+="0";return t}function H(e,t,n,r){var a,i=new e(1),s=Math.ceil(r/7+4);for(f=!1;;){if(n%2&&ee((i=i.times(t)).d,s)&&(a=!0),0===(n=v(n/2))){n=i.d.length-1,a&&0===i.d[n]&&++i.d[n];break}ee((t=t.times(t)).d,s)}return f=!0,i}function j(e){return 1&e.d[e.d.length-1]}function U(e,t,n){for(var r,a=new e(t[0]),i=0;++i17)return new d(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(f=!1,u=m):u=t,o=new d(.03125);e.e>-2;)e=e.times(o),p+=5;for(u+=r=Math.log(_(2,p))/Math.LN10*2+5|0,n=i=s=new d(1),d.precision=u;;){if(i=O(i.times(e),u,1),n=n.times(++c),E((o=s.plus($(i,n,u,1))).d).slice(0,u)===E(s.d).slice(0,u)){for(a=p;a--;)s=O(s.times(s),u,1);if(null!=t)return d.precision=m,s;if(!(l<3&&A(s.d,u-r,h,l)))return O(s,d.precision=m,h,f=!0);d.precision=u+=10,n=i=o=new d(1),c=0,l++}s=o}}function W(e,t){var n,r,a,i,s,o,u,l,c,p,d,h=1,m=e,g=m.d,y=m.constructor,b=y.rounding,x=y.precision;if(m.s<0||!g||!g[0]||!m.e&&1==g[0]&&1==g.length)return new y(g&&!g[0]?-1/0:1!=m.s?NaN:g?0:m);if(null==t?(f=!1,c=x):c=t,y.precision=c+=10,r=(n=E(g)).charAt(0),!(Math.abs(i=m.e)<15e14))return l=Y(y,c+2,x).times(i+""),m=W(new y(r+"."+n.slice(1)),c-10).plus(l),y.precision=x,null==t?O(m,x,b,f=!0):m;for(;r<7&&1!=r||1==r&&n.charAt(1)>3;)r=(n=E((m=m.times(e)).d)).charAt(0),h++;for(i=m.e,r>1?(m=new y("0."+n),i++):m=new y(r+"."+n.slice(1)),p=m,u=s=m=$(m.minus(1),m.plus(1),c,1),d=O(m.times(m),c,1),a=3;;){if(s=O(s.times(d),c,1),E((l=u.plus($(s,new y(a),c,1))).d).slice(0,c)===E(u.d).slice(0,c)){if(u=u.times(2),0!==i&&(u=u.plus(Y(y,c+2,x).times(i+""))),u=$(u,new y(h),c,1),null!=t)return y.precision=x,u;if(!A(u.d,c-10,b,o))return O(u,y.precision=x,b,f=!0);y.precision=c+=10,l=s=m=$(p.minus(1),p.plus(1),c,1),d=O(m.times(m),c,1),a=o=1}u=l,a+=2}}function V(e){return String(e.s*e.s/0)}function G(e,t){var n,r,a;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;48===t.charCodeAt(r);r++);for(a=t.length;48===t.charCodeAt(a-1);--a);if(t=t.slice(r,a)){if(a-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%7,n<0&&(r+=7),re.constructor.maxE?(e.d=null,e.e=NaN):e.e-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),S.test(t))return G(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(M.test(t))n=16,t=t.toLowerCase();else if(w.test(t))n=2;else{if(!N.test(t))throw Error(g+t);n=8}for((s=t.search(/p/i))>0?(l=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),o=(s=t.indexOf("."))>=0,r=e.constructor,o&&(s=(u=(t=t.replace(".","")).length)-s,a=H(r,new r(n),s,2*s)),s=p=(c=L(t,n,k)).length-1;0===c[s];--s)c.pop();return s<0?new r(0*e.s):(e.e=F(c,p),e.d=c,f=!1,o&&(e=$(e,a,4*u)),l&&(e=e.times(Math.abs(l)<54?_(2,l):i.pow(2,l))),f=!0,e)}function J(e,t,n,r,a){var i,s,o,u,l=e.precision,c=Math.ceil(l/7);for(f=!1,u=n.times(n),o=new e(r);;){if(s=$(o.times(u),new e(t++*t++),l,1),o=a?r.plus(s):r.minus(s),r=$(s.times(u),new e(t++*t++),l,1),void 0!==(s=o.plus(r)).d[c]){for(i=c;s.d[i]===o.d[i]&&i--;);if(-1==i)break}i=o,o=r,r=s,s=i}return f=!0,s.d.length=c+1,s}function X(e,t){for(var n=e;--t;)n*=e;return n}function Z(e,t){var n,r=t.s<0,a=z(e,e.precision,1),i=a.times(.5);if((t=t.abs()).lte(i))return o=r?4:1,t;if((n=t.divToInt(a)).isZero())o=r?3:2;else{if((t=t.minus(n.times(a))).lte(i))return o=j(n)?r?2:3:r?4:1,t;o=j(n)?r?1:4:r?3:2}return t.minus(a).abs()}function Q(e,t,n,r){var a,i,o,u,p,d,h,f,m,g=e.constructor,y=void 0!==n;if(y?(C(n,1,l),void 0===r?r=g.rounding:C(r,0,8)):(n=g.precision,r=g.rounding),e.isFinite()){for(y?(a=2,16==t?n=4*n-3:8==t&&(n=3*n-2)):a=t,(o=(h=R(e)).indexOf("."))>=0&&(h=h.replace(".",""),(m=new g(1)).e=h.length-o,m.d=L(R(m),10,a),m.e=m.d.length),i=p=(f=L(h,10,a)).length;0==f[--p];)f.pop();if(f[0]){if(o<0?i--:((e=new g(e)).d=f,e.e=i,f=(e=$(e,m,n,r,0,a)).d,i=e.e,d=s),o=f[n],u=a/2,d=d||void 0!==f[n+1],d=r<4?(void 0!==o||d)&&(0===r||r===(e.s<0?3:2)):o>u||o===u&&(4===r||d||6===r&&1&f[n-1]||r===(e.s<0?8:7)),f.length=n,d)for(;++f[--n]>a-1;)f[n]=0,n||(++i,f.unshift(1));for(p=f.length;!f[p-1];--p);for(o=0,h="";o1)if(16==t||8==t){for(o=16==t?4:3,--p;p%o;p++)h+="0";for(p=(f=L(h,a,t)).length;!f[p-1];--p);for(o=1,h="1.";op)for(i-=p;i--;)h+="0";else it)return e.length=t,!0}function te(e){return new this(e).abs()}function ne(e){return new this(e).acos()}function re(e){return new this(e).acosh()}function ae(e,t){return new this(e).plus(t)}function ie(e){return new this(e).asin()}function se(e){return new this(e).asinh()}function oe(e){return new this(e).atan()}function ue(e){return new this(e).atanh()}function le(e,t){e=new this(e),t=new this(t);var n,r=this.precision,a=this.rounding,i=r+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(n=t.s<0?z(this,r,a):new this(0)).s=e.s:!e.d||t.isZero()?(n=z(this,i,1).times(.5)).s=e.s:t.s<0?(this.precision=i,this.rounding=1,n=this.atan($(e,t,i,1)),t=z(this,i,1),this.precision=r,this.rounding=a,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan($(e,t,i,1)):(n=z(this,i,1).times(t.s>0?.25:.75)).s=e.s:n=new this(NaN),n}function ce(e){return new this(e).cbrt()}function pe(e){return O(e=new this(e),e.e+1,2)}function de(e,t,n){return new this(e).clamp(t,n)}function he(e){if(!e||"object"!=typeof e)throw Error(m+"Object expected");var t,n,r,a=!0===e.defaults,i=["precision",1,l,"rounding",0,8,"toExpNeg",-u,0,"toExpPos",0,u,"maxE",0,u,"minE",-u,0,"modulo",0,9];for(t=0;t=i[t+1]&&r<=i[t+2]))throw Error(g+n+": "+r);this[n]=r}if(n="crypto",a&&(this[n]=h[n]),void 0!==(r=e[n])){if(!0!==r&&!1!==r&&0!==r&&1!==r)throw Error(g+n+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(b);this[n]=!0}else this[n]=!1}return this}function fe(e){return new this(e).cos()}function me(e){return new this(e).cosh()}function ge(e,t){return new this(e).div(t)}function ye(e){return new this(e).exp()}function be(e){return O(e=new this(e),e.e+1,3)}function xe(){var e,t,n=new this(0);for(f=!1,e=0;e=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:o[i++]=a%1e7;else{if(!crypto.randomBytes)throw Error(b);for(t=crypto.randomBytes(r*=4);i=214e7?crypto.randomBytes(4).copy(t,i):(o.push(a%1e7),i+=4);i=r/4}else for(;i=10;a/=10)r++;r<7&&(n-=7-r)}return s.e=n,s.d=o,s}function Ce(e){return O(e=new this(e),e.e+1,this.rounding)}function Ae(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function Le(e){return new this(e).sin()}function $e(e){return new this(e).sinh()}function Oe(e){return new this(e).sqrt()}function Re(e,t){return new this(e).sub(t)}function Fe(){var e=0,t=arguments,n=new this(t[e]);for(f=!1;n.s&&++ei.maxE?(a.e=NaN,a.d=null):e.e=10;n/=10)t++;return void(f?t>i.maxE?(a.e=NaN,a.d=null):t{"use strict";var t=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{},s=i.preserveFormatting,o=void 0!==s&&s,u=i.escapeMapFn,l=void 0===u?a:u,c=String(e),p="",d=l(t({},n),o?t({},r):{}),h=Object.keys(d),f=function(){var e=!1;h.forEach((function(t,n){e||c.length>=t.length&&c.slice(0,t.length)===t&&(p+=d[h[n]],c=c.slice(t.length,c.length),e=!0)})),e||(p+=c.slice(0,1),c=c.slice(1,c.length))};c;)f();return p}},5628:function(e,t){var n;!function(r){"use strict";var a={s:1,n:0,d:1};function i(e,t){if(isNaN(e=parseInt(e,10)))throw c.InvalidParameter;return e*t}function s(e,t){if(0===t)throw c.DivisionByZero;var n=Object.create(c.prototype);n.s=e<0?-1:1;var r=l(e=e<0?-e:e,t);return n.n=e/r,n.d=t/r,n}function o(e){for(var t={},n=e,r=2,a=4;a<=n;){for(;n%r==0;)n/=r,t[r]=(t[r]||0)+1;a+=1+2*r++}return n!==e?n>1&&(t[n]=(t[n]||0)+1):t[e]=(t[e]||0)+1,t}var u=function(e,t){var n,r=0,s=1,o=1,u=0,l=0,p=0,d=1,h=1,f=0,m=1,g=1,y=1,b=1e7;if(null==e);else if(void 0!==t){if(o=(r=e)*(s=t),r%1!=0||s%1!=0)throw c.NonIntegerParameter}else switch(typeof e){case"object":if("d"in e&&"n"in e)r=e.n,s=e.d,"s"in e&&(r*=e.s);else{if(!(0 in e))throw c.InvalidParameter;r=e[0],1 in e&&(s=e[1])}o=r*s;break;case"number":if(e<0&&(o=e,e=-e),e%1==0)r=e;else if(e>0){for(e>=1&&(e/=h=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));m<=b&&y<=b;){if(e===(n=(f+g)/(m+y))){m+y<=b?(r=f+g,s=m+y):y>m?(r=g,s=y):(r=f,s=m);break}e>n?(f+=g,m+=y):(g+=f,y+=m),m>b?(r=g,s=y):(r=f,s=m)}r*=h}else(isNaN(e)||isNaN(t))&&(s=r=NaN);break;case"string":if(null===(m=e.match(/\d+|./g)))throw c.InvalidParameter;if("-"===m[f]?(o=-1,f++):"+"===m[f]&&f++,m.length===f+1?l=i(m[f++],o):"."===m[f+1]||"."===m[f]?("."!==m[f]&&(u=i(m[f++],o)),(1+ ++f===m.length||"("===m[f+1]&&")"===m[f+3]||"'"===m[f+1]&&"'"===m[f+3])&&(l=i(m[f],o),d=Math.pow(10,m[f].length),f++),("("===m[f]&&")"===m[f+2]||"'"===m[f]&&"'"===m[f+2])&&(p=i(m[f+1],o),h=Math.pow(10,m[f+1].length)-1,f+=3)):"/"===m[f+1]||":"===m[f+1]?(l=i(m[f],o),d=i(m[f+2],1),f+=3):"/"===m[f+3]&&" "===m[f+1]&&(u=i(m[f],o),l=i(m[f+2],o),d=i(m[f+4],1),f+=5),m.length<=f){o=r=p+(s=d*h)*u+h*l;break}default:throw c.InvalidParameter}if(0===s)throw c.DivisionByZero;a.s=o<0?-1:1,a.n=Math.abs(r),a.d=Math.abs(s)};function l(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function c(e,t){if(u(e,t),!(this instanceof c))return s(a.s*a.n,a.d);e=l(a.d,a.n),this.s=a.s,this.n=a.n/e,this.d=a.d/e}c.DivisionByZero=new Error("Division by Zero"),c.InvalidParameter=new Error("Invalid argument"),c.NonIntegerParameter=new Error("Parameters must be integer"),c.prototype={s:1,n:0,d:1,abs:function(){return s(this.n,this.d)},neg:function(){return s(-this.s*this.n,this.d)},add:function(e,t){return u(e,t),s(this.s*this.n*a.d+a.s*this.d*a.n,this.d*a.d)},sub:function(e,t){return u(e,t),s(this.s*this.n*a.d-a.s*this.d*a.n,this.d*a.d)},mul:function(e,t){return u(e,t),s(this.s*a.s*this.n*a.n,this.d*a.d)},div:function(e,t){return u(e,t),s(this.s*a.s*this.n*a.d,this.d*a.n)},clone:function(){return s(this.s*this.n,this.d)},mod:function(e,t){if(isNaN(this.n)||isNaN(this.d))return new c(NaN);if(void 0===e)return s(this.s*this.n%this.d,1);if(u(e,t),0===a.n&&0===this.d)throw c.DivisionByZero;return s(this.s*(a.d*this.n)%(a.n*this.d),a.d*this.d)},gcd:function(e,t){return u(e,t),s(l(a.n,this.n)*l(a.d,this.d),a.d*this.d)},lcm:function(e,t){return u(e,t),0===a.n&&0===this.n?s(0,1):s(a.n*this.n,l(a.n,this.n)*l(a.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):s(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):s(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):s(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return s(this.s*this.d,this.n)},pow:function(e,t){if(u(e,t),1===a.d)return a.s<0?s(Math.pow(this.s*this.d,a.n),Math.pow(this.n,a.n)):s(Math.pow(this.s*this.n,a.n),Math.pow(this.d,a.n));if(this.s<0)return null;var n=o(this.n),r=o(this.d),i=1,l=1;for(var c in n)if("1"!==c){if("0"===c){i=0;break}if(n[c]*=a.n,n[c]%a.d!=0)return null;n[c]/=a.d,i*=Math.pow(c,n[c])}for(var c in r)if("1"!==c){if(r[c]*=a.n,r[c]%a.d!=0)return null;r[c]/=a.d,l*=Math.pow(c,r[c])}return a.s<0?s(l,i):s(i,l)},equals:function(e,t){return u(e,t),this.s*this.n*a.d==a.s*a.n*this.d},compare:function(e,t){u(e,t);var n=this.s*this.n*a.d-a.s*a.n*this.d;return(0=0;i--)a=a.inverse().add(n[i]);if(a.sub(t).abs().valueOf()0&&(n+=t,n+=" ",r%=a),n+=r,n+="/",n+=a),n},toLatex:function(e){var t,n="",r=this.n,a=this.d;return this.s<0&&(n+="-"),1===a?n+=r:(e&&(t=Math.floor(r/a))>0&&(n+=t,r%=a),n+="\\frac{",n+=r,n+="}{",n+=a,n+="}"),n},toContinued:function(){var e,t=this.n,n=this.d,r=[];if(isNaN(t)||isNaN(n))return r;do{r.push(Math.floor(t/n)),e=t%n,t=n,n=e}while(1!==t);return r},toString:function(e){var t=this.n,n=this.d;if(isNaN(t)||isNaN(n))return"NaN";e=e||15;var r=function(e,t){for(;t%2==0;t/=2);for(;t%5==0;t/=5);if(1===t)return 0;for(var n=10%t,r=1;1!==n;r++)if(n=10*n%t,r>2e3)return 0;return r}(0,n),a=function(e,t,n){for(var r=1,a=function(e,t,n){for(var r=1;t>0;e=e*e%n,t>>=1)1&t&&(r=r*e%n);return r}(10,n,t),i=0;i<300;i++){if(r===a)return i;r=10*r%t,a=10*a%t}return 0}(0,n,r),i=this.s<0?"-":"";if(i+=t/n|0,t%=n,(t*=10)&&(i+="."),r){for(var s=a;s--;)i+=t/n|0,t%=n,t*=10;for(i+="(",s=r;s--;)i+=t/n|0,t%=n,t*=10;i+=")"}else for(s=e;t&&s--;)i+=t/n|0,t%=n,t*=10;return i}},void 0===(n=function(){return c}.apply(t,[]))||(e.exports=n)}()},3228:e=>{e.exports=function e(t,n){"use strict";var r,a,i=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,s=/(^[ ]*|[ ]*$)/g,o=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,l=/^0/,c=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},p=c(t).replace(s,"")||"",d=c(n).replace(s,"")||"",h=p.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),f=d.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=parseInt(p.match(u),16)||1!==h.length&&p.match(o)&&Date.parse(p),g=parseInt(d.match(u),16)||m&&d.match(o)&&Date.parse(d)||null;if(g){if(mg)return 1}for(var y=0,b=Math.max(h.length,f.length);ya)return 1}return 0}},3720:e=>{e.exports=n;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function n(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function r(e){return!0===(e&&e.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=r;var a={},i={};function s(e,t){var n,r,s;return t?(s=0<=(e>>>=0)&&e<256)&&(r=i[e])?r:(n=u(e,(0|e)<0?-1:0,!0),s&&(i[e]=n),n):(s=-128<=(e|=0)&&e<128)&&(r=a[e])?r:(n=u(e,e<0?-1:0,!1),s&&(a[e]=n),n)}function o(e,t){if(isNaN(e))return t?y:g;if(t){if(e<0)return y;if(e>=h)return w}else{if(e<=-f)return M;if(e+1>=f)return _}return e<0?o(-e,t).neg():u(e%d|0,e/d|0,t)}function u(e,t,r){return new n(e,t,r)}n.fromInt=s,n.fromNumber=o,n.fromBits=u;var l=Math.pow;function c(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return g;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||360)throw Error("interior hyphen");if(0===r)return c(e.substring(1),t,n).neg();for(var a=o(l(n,8)),i=g,s=0;s>>0:this.low},N.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},N.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((i=u).isZero())return c+s;for(;c.length<6;)c="0"+c;s=""+c+s}},N.getHighBits=function(){return this.high},N.getHighBitsUnsigned=function(){return this.high>>>0},N.getLowBits=function(){return this.low},N.getLowBitsUnsigned=function(){return this.low>>>0},N.getNumBitsAbs=function(){if(this.isNegative())return this.eq(M)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<=0},N.isOdd=function(){return 1==(1&this.low)},N.isEven=function(){return 0==(1&this.low)},N.equals=function(e){return r(e)||(e=p(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},N.eq=N.equals,N.notEquals=function(e){return!this.eq(e)},N.neq=N.notEquals,N.ne=N.notEquals,N.lessThan=function(e){return this.comp(e)<0},N.lt=N.lessThan,N.lessThanOrEqual=function(e){return this.comp(e)<=0},N.lte=N.lessThanOrEqual,N.le=N.lessThanOrEqual,N.greaterThan=function(e){return this.comp(e)>0},N.gt=N.greaterThan,N.greaterThanOrEqual=function(e){return this.comp(e)>=0},N.gte=N.greaterThanOrEqual,N.ge=N.greaterThanOrEqual,N.compare=function(e){if(r(e)||(e=p(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},N.comp=N.compare,N.negate=function(){return!this.unsigned&&this.eq(M)?M:this.not().add(b)},N.neg=N.negate,N.add=function(e){r(e)||(e=p(e));var t=this.high>>>16,n=65535&this.high,a=this.low>>>16,i=65535&this.low,s=e.high>>>16,o=65535&e.high,l=e.low>>>16,c=0,d=0,h=0,f=0;return h+=(f+=i+(65535&e.low))>>>16,d+=(h+=a+l)>>>16,c+=(d+=n+o)>>>16,c+=t+s,u((h&=65535)<<16|(f&=65535),(c&=65535)<<16|(d&=65535),this.unsigned)},N.subtract=function(e){return r(e)||(e=p(e)),this.add(e.neg())},N.sub=N.subtract,N.multiply=function(e){if(this.isZero())return g;if(r(e)||(e=p(e)),t)return u(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return g;if(this.eq(M))return e.isOdd()?M:g;if(e.eq(M))return this.isOdd()?M:g;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(m)&&e.lt(m))return o(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,a=65535&this.high,i=this.low>>>16,s=65535&this.low,l=e.high>>>16,c=65535&e.high,d=e.low>>>16,h=65535&e.low,f=0,y=0,b=0,x=0;return b+=(x+=s*h)>>>16,y+=(b+=i*h)>>>16,b&=65535,y+=(b+=s*d)>>>16,f+=(y+=a*h)>>>16,y&=65535,f+=(y+=i*d)>>>16,y&=65535,f+=(y+=s*c)>>>16,f+=n*h+a*d+i*c+s*l,u((b&=65535)<<16|(x&=65535),(f&=65535)<<16|(y&=65535),this.unsigned)},N.mul=N.multiply,N.divide=function(e){if(r(e)||(e=p(e)),e.isZero())throw Error("division by zero");var n,a,i;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?u((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?y:g;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return y;if(e.gt(this.shru(1)))return x;i=y}else{if(this.eq(M))return e.eq(b)||e.eq(v)?M:e.eq(M)?b:(n=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?b:v:(a=this.sub(e.mul(n)),i=n.add(a.div(e)));if(e.eq(M))return this.unsigned?y:g;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=g}for(a=this;a.gte(e);){n=Math.max(1,Math.floor(a.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(n)/Math.LN2),c=s<=48?1:l(2,s-48),d=o(n),h=d.mul(e);h.isNegative()||h.gt(a);)h=(d=o(n-=c,this.unsigned)).mul(e);d.isZero()&&(d=b),i=i.add(d),a=a.sub(h)}return i},N.div=N.divide,N.modulo=function(e){return r(e)||(e=p(e)),t?u((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},N.mod=N.modulo,N.rem=N.modulo,N.not=function(){return u(~this.low,~this.high,this.unsigned)},N.and=function(e){return r(e)||(e=p(e)),u(this.low&e.low,this.high&e.high,this.unsigned)},N.or=function(e){return r(e)||(e=p(e)),u(this.low|e.low,this.high|e.high,this.unsigned)},N.xor=function(e){return r(e)||(e=p(e)),u(this.low^e.low,this.high^e.high,this.unsigned)},N.shiftLeft=function(e){return r(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?u(this.low<>>32-e,this.unsigned):u(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):u(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},N.shr=N.shiftRight,N.shiftRightUnsigned=function(e){if(r(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?u(this.low>>>e|t<<32-e,t>>>e,this.unsigned):u(32===e?t:t>>>e-32,0,this.unsigned)},N.shru=N.shiftRightUnsigned,N.shr_u=N.shiftRightUnsigned,N.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},N.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},N.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},N.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},N.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},n.fromBytes=function(e,t,r){return r?n.fromBytesLE(e,t):n.fromBytesBE(e,t)},n.fromBytesLE=function(e,t){return new n(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},n.fromBytesBE=function(e,t){return new n(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},4676:(e,t,n)=>{var r=n(7522),a=n(8520),i=n(1865),s=n(4775),o=n(6709),u=n(6515),l=n(1566);l.alea=r,l.xor128=a,l.xorwow=i,l.xorshift7=s,l.xor4096=o,l.tychei=u,e.exports=l},7522:function(e,t,n){var r;!function(e,a,i){function s(e){var t,n=this,r=(t=4022871197,function(e){e=String(e);for(var n=0;n>>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 u(e,t){var n=new s(e),r=t&&t.state,a=n.next;return a.int32=function(){return 4294967296*n.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.alea=u}(0,e=n.nmd(e),n.amdD)},6515:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,a=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^a,t.a=a-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>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.tychei=u}(0,e=n.nmd(e),n.amdD)},8520:function(e,t,n){var r;!function(e,a,i){function s(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>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor128=u}(0,e=n.nmd(e),n.amdD)},6709:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.w,a=t.X,i=t.i;return t.w=r=r+1640531527|0,n=a[i+34&127],e=a[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=a[i]=n^e,t.i=i,n+(r^r>>>16)|0},function(e,t){var n,r,a,i,s,o=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),a=0,i=-32;i>>15,r^=r<<4,r^=r>>>13,i>=0&&(s=s+1640531527|0,a=0==(n=o[127&i]^=r+s)?a+1:0);for(a>=128&&(o[127&(t&&t.length||0)]=-1),a=127,i=512;i>0;--i)r=o[a+34&127],n=o[a=a+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,o[a]=r^n;e.w=s,e.X=o,e.i=a}(t,e)}function o(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.X&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor4096=u}(0,e=n.nmd(e),n.amdD)},4775:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.x,a=t.i;return e=r[a],n=(e^=e>>>7)^e<<24,n^=(e=r[a+1&7])^e>>>10,n^=(e=r[a+3&7])^e>>>3,n^=(e=r[a+4&7])^e<<7,e=r[a+7&7],n^=(e^=e<<13)^e<<9,r[a]=n,t.i=a+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n0;--n)e.next()}(t,e)}function o(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.x&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorshift7=u}(0,e=n.nmd(e),n.amdD)},1865:function(e,t,n){var r;!function(e,a,i){function s(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>>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 u(e,t){var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorwow=u}(0,e=n.nmd(e),n.amdD)},1566:function(e,t,n){var r;!function(a,i,s){var o,u=256,l=s.pow(u,6),c=s.pow(2,52),p=2*c,d=255;function h(e,t,n){var r=[],d=y(g((t=1==t?{entropy:!0}:t||{}).entropy?[e,b(i)]:null==e?function(){try{var e;return o&&(e=o.randomBytes)?e=e(u):(e=new Uint8Array(u),(a.crypto||a.msCrypto).getRandomValues(e)),b(e)}catch(e){var t=a.navigator,n=t&&t.plugins;return[+new Date,a,n,a.screen,b(i)]}}():e,3),r),h=new f(r),x=function(){for(var e=h.g(6),t=l,n=0;e=p;)e/=2,t/=2,n>>>=1;return(e+n)/t};return x.int32=function(){return 0|h.g(4)},x.quick=function(){return h.g(4)/4294967296},x.double=x,y(b(h.S),i),(t.pass||n||function(e,t,n,r){return r&&(r.S&&m(r,h),e.state=function(){return m(h,{})}),n?(s.random=e,t):e})(x,d,"global"in t?t.global:this==s,t.state)}function f(e){var t,n=e.length,r=this,a=0,i=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);a{var r=n(4832),a=n(8652),i=n(801),s=n(2030),o=n(3618),u=n(9049),l=n(1971);l.alea=r,l.xor128=a,l.xorwow=i,l.xorshift7=s,l.xor4096=o,l.tychei=u,e.exports=l},4832:function(e,t,n){var r;!function(e,a,i){function s(e){var t,n=this,r=(t=4022871197,function(e){e=e.toString();for(var n=0;n>>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 u(e,t){var n=new s(e),r=t&&t.state,a=n.next;return a.int32=function(){return 4294967296*n.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.alea=u}(0,e=n.nmd(e),n.amdD)},9049:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,a=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^a,t.a=a-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>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.tychei=u}(0,e=n.nmd(e),n.amdD)},8652:function(e,t,n){var r;!function(e,a,i){function s(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>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor128=u}(0,e=n.nmd(e),n.amdD)},3618:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.w,a=t.X,i=t.i;return t.w=r=r+1640531527|0,n=a[i+34&127],e=a[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=a[i]=n^e,t.i=i,n+(r^r>>>16)|0},function(e,t){var n,r,a,i,s,o=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),a=0,i=-32;i>>15,r^=r<<4,r^=r>>>13,i>=0&&(s=s+1640531527|0,a=0==(n=o[127&i]^=r+s)?a+1:0);for(a>=128&&(o[127&(t&&t.length||0)]=-1),a=127,i=512;i>0;--i)r=o[a+34&127],n=o[a=a+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,o[a]=r^n;e.w=s,e.X=o,e.i=a}(t,e)}function o(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.X&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor4096=u}(0,e=n.nmd(e),n.amdD)},2030:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.x,a=t.i;return e=r[a],n=(e^=e>>>7)^e<<24,n^=(e=r[a+1&7])^e>>>10,n^=(e=r[a+3&7])^e>>>3,n^=(e=r[a+4&7])^e<<7,e=r[a+7&7],n^=(e^=e<<13)^e<<9,r[a]=n,t.i=a+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n0;--n)e.next()}(t,e)}function o(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.x&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorshift7=u}(0,e=n.nmd(e),n.amdD)},801:function(e,t,n){var r;!function(e,a,i){function s(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>>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 u(e,t){var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorwow=u}(0,e=n.nmd(e),n.amdD)},1971:(e,t,n)=>{var r;!function(a,i){var s,o=(0,eval)("this"),u=256,l=i.pow(u,6),c=i.pow(2,52),p=2*c,d=255;function h(e,t,n){var r=[],d=y(g((t=1==t?{entropy:!0}:t||{}).entropy?[e,b(a)]:null==e?function(){try{var e;return s&&(e=s.randomBytes)?e=e(u):(e=new Uint8Array(u),(o.crypto||o.msCrypto).getRandomValues(e)),b(e)}catch(e){var t=o.navigator,n=t&&t.plugins;return[+new Date,o,n,o.screen,b(a)]}}():e,3),r),h=new f(r),x=function(){for(var e=h.g(6),t=l,n=0;e=p;)e/=2,t/=2,n>>>=1;return(e+n)/t};return x.int32=function(){return 0|h.g(4)},x.quick=function(){return h.g(4)/4294967296},x.double=x,y(b(h.S),a),(t.pass||n||function(e,t,n,r){return r&&(r.S&&m(r,h),e.state=function(){return m(h,{})}),n?(i.random=e,t):e})(x,d,"global"in t?t.global:this==i,t.state)}function f(e){var t,n=e.length,r=this,a=0,i=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);a{function t(){}t.prototype={on:function(e,t,n){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function a(){r.off(e,a),t.apply(n,arguments)}return a._=t,this.on(e,a,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),r=0,a=n.length;r3?e.slice(3):"any":e).split("|").map(L).filter($).filter(A),a=function(e,t){var n={};return e.forEach((function(e){-1!==t.indexOf(e.from)||-1===t.indexOf(e.to)||n[e.from]||(n[e.from]=e)})),Object.keys(n).map((function(e){return n[e]}))}(t,r),i=r.map((function(e){var t=l(e);return{name:e,typeIndex:c(t),test:t.test,conversion:null,conversionIndex:-1}})),s=a.map((function(e){var n=l(e.from);return{name:e.from,typeIndex:c(n),test:n.test,conversion:e,conversionIndex:t.indexOf(e)}}));return{types:i.concat(s),restParam:n}}function f(e){var t=F(e);return!!t&&t.restParam}function m(e){return e.types.some((function(e){return null!=e.conversion}))}function g(t){if(t&&0!==t.types.length){if(1===t.types.length)return l(t.types[0].name).test;if(2===t.types.length){var n=l(t.types[0].name).test,r=l(t.types[1].name).test;return function(e){return n(e)||r(e)}}var a=t.types.map((function(e){return l(e.name).test}));return function(e){for(var t=0;t=i+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(n=g(e[0]),function(e){return n(e[0])&&1===e.length}):2===e.length?(n=g(e[0]),r=g(e[1]),function(e){return n(e[0])&&r(e[1])&&2===e.length}):(t=e.map(g),function(e){for(var n=0;n0){var l=p(t[i]);return(r=new TypeError("Unexpected type of argument in function "+s+" (expected: "+a.join(" or ")+", actual: "+l+", index: "+i+")")).data={category:"wrongType",fn:s,index:i,actual:l,expected:a},r}}else o=u}var c=o.map((function(e){return f(e.params)?1/0:e.params.length}));if(t.lengthd?((r=new TypeError("Too many arguments in function "+s+" (expected: "+d+", actual: "+t.length+")")).data={category:"tooManyArgs",fn:s,index:t.length,expectedLength:d},r):((r=new TypeError('Arguments of type "'+t.join(", ")+'" do not match any of the defined signatures of function '+s+".")).data={category:"mismatch",actual:t.map(p)},r)}function N(e){for(var t=999,n=0;n=a:o?a>=i:a===i}(t,e)}));if(t)throw new TypeError('Conflicting signatures "'+d(t.params)+'" and "'+d(e.params)+'".');a.push(e)}));var i=P(a,(function(e){return(e?I(e.params,!1):[]).map((function(t){return{params:t,fn:e.fn}}))})).filter(O);i.sort(D);var s=i[0]&&i[0].params.length<=2&&!f(i[0].params),o=i[1]&&i[1].params.length<=2&&!f(i[1].params),l=i[2]&&i[2].params.length<=2&&!f(i[2].params),c=i[3]&&i[3].params.length<=2&&!f(i[3].params),p=i[4]&&i[4].params.length<=2&&!f(i[4].params),b=i[5]&&i[5].params.length<=2&&!f(i[5].params),v=s&&o&&l&&c&&p&&b,_=i.map((function(e){return y(e.params)})),w=s?g(i[0].params[0]):t,M=o?g(i[1].params[0]):t,N=l?g(i[2].params[0]):t,S=c?g(i[3].params[0]):t,k=p?g(i[4].params[0]):t,E=b?g(i[5].params[0]):t,C=s?g(i[0].params[1]):t,A=o?g(i[1].params[1]):t,$=l?g(i[2].params[1]):t,F=c?g(i[3].params[1]):t,H=p?g(i[4].params[1]):t,j=b?g(i[5].params[1]):t,U=i.map((function(e){return function(e,t){var n=t;if(e.some(m)){var r=f(e),a=e.map(T);n=function(){for(var e=[],n=r?arguments.length-1:arguments.length,i=0;i{},5410:()=>{},8628:()=>{},5778:()=>{},1601:()=>{},7792:()=>{},4977:()=>{},2007:()=>{},5042:()=>{}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.amdD=function(){throw new Error("define cannot be used indirect")},n.amdO={},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})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var r={};(()=>{"use strict";n.r(r),n.d(r,{Tensor:()=>Uie,Turtle:()=>Oie,abs:()=>Xie,acos:()=>pse,add:()=>Wie,asin:()=>dse,atan:()=>hse,atan2:()=>fse,average:()=>Zse,ceil:()=>Zie,compile:()=>Fie,complex:()=>bse,concat:()=>Cse,constrain:()=>Qie,copy:()=>xse,cos:()=>mse,derivative:()=>Yie,dispose:()=>Use,div:()=>Kie,dot:()=>Jie,endScope:()=>Hse,evaluate:()=>zie,exp:()=>ese,eye:()=>vse,fft:()=>Yse,fill:()=>_se,flatten:()=>Tse,floor:()=>tse,fromImage:()=>Wse,getBackend:()=>qoe,keep:()=>jse,linspace:()=>wse,log:()=>nse,math:()=>V,max:()=>rse,mean:()=>Xse,memory:()=>zse,min:()=>ase,mod:()=>ise,mult:()=>Gie,ones:()=>Mse,pad:()=>Ise,parse:()=>Bie,percentile:()=>Kse,pow:()=>sse,ptp:()=>Gse,quantile:()=>Jse,random:()=>Nse,randomGaussian:()=>Sse,range:()=>kse,reshape:()=>Ese,reverse:()=>Ase,round:()=>ose,sd:()=>Qse,setBackend:()=>Uoe,simplify:()=>Pie,sin:()=>gse,slice:()=>Lse,sort:()=>Fse,split:()=>$se,sq:()=>use,sqrt:()=>lse,stack:()=>Ose,startScope:()=>Pse,sub:()=>Vie,sum:()=>cse,tan:()=>yse,tf:()=>q,tidy:()=>Bse,toDateTime:()=>joe,toImage:()=>Vse,unstack:()=>Rse,variance:()=>eoe,zeros:()=>Dse});var e={};n.r(e),n.d(e,{arraysEqual:()=>pe,assert:()=>ie,assertNonNegativeIntegerDimensions:()=>Pe,assertNonNull:()=>oe,assertShapesMatch:()=>se,bytesFromStringArray:()=>Te,bytesPerElement:()=>De,checkConversionForErrors:()=>Me,clamp:()=>Q,computeStrides:()=>Oe,createScalarValue:()=>Oa,createShuffledIndices:()=>me,decodeString:()=>Ba,distSquared:()=>ae,encodeString:()=>za,fetch:()=>Ya,fingerPrint64:()=>$a,flatten:()=>ue,getArrayFromDType:()=>we,getTypedArrayFromDType:()=>_e,hasEncodingLoss:()=>Se,hexToLong:()=>Ma,indexToLoc:()=>je,inferDtype:()=>Ae,inferFromImplicitShape:()=>be,isBoolean:()=>Ee,isFunction:()=>Le,isInt:()=>de,isNumber:()=>Ce,isPromise:()=>Ue,isScalarShape:()=>ce,isString:()=>Ie,isTypedArray:()=>ke,isValidDtype:()=>Ne,locToIndex:()=>He,makeOnesTypedArray:()=>Ye,makeZerosNestedTypedArray:()=>Be,makeZerosTypedArray:()=>ze,nearestDivisor:()=>$e,nearestLargerEven:()=>ee,now:()=>Fa,parseAxisParam:()=>xe,randUniform:()=>re,repeatedTry:()=>ye,rightPad:()=>ge,shuffle:()=>X,shuffleCombo:()=>Z,sizeFromShape:()=>le,sizeToSquarishShape:()=>fe,squeezeShape:()=>ve,sum:()=>ne,swap:()=>te,tanh:()=>he,toNestedArray:()=>Fe,toTypedArray:()=>Ra});var t={};n.r(t),n.d(t,{assertTypesMatch:()=>pi,getTensorsInContainer:()=>hi,isTensorInList:()=>di,makeTypesMatch:()=>ci});var a={};n.r(a),n.d(a,{isBrowser:()=>Ni,isMobile:()=>Mi,mockIsMobile:()=>wi});var i={};n.r(i),n.d(i,{browserFiles:()=>Fs,browserHTTPRequest:()=>Ws,concatenateArrayBuffers:()=>Hi,copyModel:()=>ks,decodeWeights:()=>Yi,encodeWeights:()=>Fi,fromMemory:()=>Js,fromMemorySync:()=>Xs,getLoadHandlers:()=>Zi,getModelArtifactsForJSON:()=>qi,getModelArtifactsInfoForJSON:()=>Wi,getSaveHandlers:()=>Xi,http:()=>qs,isHTTPScheme:()=>js,listModels:()=>Ns,loadWeights:()=>Bs,moveModel:()=>Ds,registerLoadRouter:()=>Ji,registerSaveRouter:()=>Ki,removeModel:()=>Ss,weightsLoaderFactory:()=>Ps,withSaveHandler:()=>Zs,withSaveHandlerSync:()=>Qs});var s={};n.r(s),n.d(s,{confusionMatrix:()=>To});var o={};n.r(o),n.d(o,{assertAndGetBroadcastShape:()=>Co,getBroadcastDims:()=>Io,getReductionAxes:()=>Eo});var u={};n.r(u),n.d(u,{fromPixels:()=>Fo,fromPixelsAsync:()=>Oo,toPixels:()=>Ro});var l={};n.r(l),n.d(l,{prepareAndValidate:()=>Yo});var c={};n.r(c),n.d(c,{calculateShapes:()=>Po,validateInput:()=>Bo,validateUpdateShape:()=>zo});var p={};n.r(p),n.d(p,{assertParamsValid:()=>Ho,computeFlatOffset:()=>tu,computeOutShape:()=>Uo,getNormalizedAxes:()=>Go,isSliceContinous:()=>eu,maskToAxes:()=>jo,parseSliceParams:()=>nu,sliceInfo:()=>ru,startForAxis:()=>Zo,startIndicesWithElidedDims:()=>Ko,stopForAxis:()=>Qo,stopIndicesWithElidedDims:()=>Jo,stridesForAxis:()=>Xo,stridesWithElidedDims:()=>qo});var d={};n.r(d),n.d(d,{Serializable:()=>iu,SerializationMap:()=>su,registerClass:()=>ou});var h={};n.r(h),n.d(h,{TEST_EPSILON_FLOAT16:()=>uu,encodeStrings:()=>bu,expectArrayBuffersEqual:()=>yu,expectArraysClose:()=>lu,expectArraysEqual:()=>hu,expectNumbersClose:()=>fu,expectPromiseToFail:()=>du,expectValuesInRange:()=>gu,testEpsilon:()=>cu});var f={};n.r(f),n.d(f,{conv2d:()=>Hd,depthwiseConv2d:()=>qd,matMul:()=>Wd});var m={};n.r(m),n.d(m,{collectGatherOpShapeInfo:()=>Uf,computeOutShape:()=>jf,segOpComputeOptimalWindowSize:()=>Hf});var g={};n.r(g),n.d(g,{ERF_A1:()=>lf,ERF_A2:()=>cf,ERF_A3:()=>pf,ERF_A4:()=>df,ERF_A5:()=>hf,ERF_P:()=>uf,PARALLELIZE_THRESHOLD:()=>Xh,SELU_SCALE:()=>of,SELU_SCALEALPHA:()=>sf,applyActivation:()=>Bd,assertAndGetBroadcastShape:()=>Co,assertAxesAreInnerMostDims:()=>gc,assertParamsConsistent:()=>Kh,assignToTypedArray:()=>xf,axesAreInnerMostDims:()=>dc,calculateShapes:()=>Po,checkEinsumDimSizes:()=>Sf,checkPadOnDimRoundingMode:()=>vl,combineLocations:()=>hc,complexWithEvenIndex:()=>gf,complexWithOddIndex:()=>yf,computeConv2DInfo:()=>cl,computeConv3DInfo:()=>pl,computeDefaultPad:()=>dl,computeDilation2DInfo:()=>ol,computeOptimalWindowSize:()=>Zh,computeOutAndReduceShapes:()=>fc,computeOutShape:()=>Jh,computePool2DInfo:()=>ul,computePool3DInfo:()=>ll,convertConv2DDataFormat:()=>xl,decodeEinsumEquation:()=>Mf,eitherStridesOrDilationsAreOne:()=>bl,expandShapeToKeepDim:()=>mc,exponent:()=>_f,exponents:()=>vf,fromStringArrayToUint8:()=>Wf,fromUint8ToStringArray:()=>qf,getAxesPermutation:()=>yc,getBroadcastDims:()=>Io,getComplexWithIndex:()=>bf,getEinsumComputePath:()=>kf,getEinsumPermutation:()=>Nf,getFusedBiasGradient:()=>zd,getFusedDyActivation:()=>Yd,getImageCenter:()=>Qh,getInnerMostAxes:()=>xc,getPermuted:()=>tf,getReductionAxes:()=>Eo,getReshaped:()=>ef,getReshapedPermuted:()=>nf,getSliceBeginCoords:()=>rf,getSliceSize:()=>af,getSparseFillEmptyRowsIndicesDenseShapeMismatch:()=>Ef,getSparseFillEmptyRowsNegativeIndexErrorMessage:()=>Cf,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:()=>Af,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:()=>Of,getSparseReshapeInputOutputMismatchErrorMessage:()=>Ff,getSparseReshapeInputOutputMultipleErrorMessage:()=>Rf,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:()=>Lf,getSparseReshapeNegativeOutputDimErrorMessage:()=>$f,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:()=>Pf,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:()=>Yf,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:()=>zf,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:()=>Bf,getUndoAxesPermutation:()=>bc,isIdentityPermutation:()=>Df,log:()=>la,mergeRealAndImagArrays:()=>ff,prepareAndValidate:()=>Yo,prepareSplitSize:()=>If,segment_util:()=>m,shouldFuse:()=>Pd,slice_util:()=>p,splitRealAndImagArrays:()=>mf,tupleValuesAreOne:()=>yl,upcastType:()=>ui,validateInput:()=>Bo,validateUpdateShape:()=>zo,warn:()=>ua});var y={};n.r(y),n.d(y,{nonMaxSuppressionV3Impl:()=>ih,nonMaxSuppressionV4Impl:()=>sh,nonMaxSuppressionV5Impl:()=>oh,whereImpl:()=>kd});var b={};n.r(b),n.d(b,{maxNorm:()=>Cb,minMaxNorm:()=>$b,nonNeg:()=>Lb,unitNorm:()=>Ab});var x={};n.r(x),n.d(x,{constant:()=>Fb,glorotNormal:()=>Ub,glorotUniform:()=>jb,heNormal:()=>qb,heUniform:()=>Wb,identity:()=>Pb,leCunNormal:()=>Vb,leCunUniform:()=>Gb,ones:()=>Rb,orthogonal:()=>Kb,randomNormal:()=>zb,randomUniform:()=>Yb,truncatedNormal:()=>Bb,varianceScaling:()=>Hb,zeros:()=>Ob});var v={};n.r(v),n.d(v,{Layer:()=>cb,RNN:()=>o_,RNNCell:()=>u_,activation:()=>Tw,add:()=>Fw,alphaDropout:()=>DM,average:()=>Yw,averagePooling1d:()=>Vw,averagePooling2d:()=>Jw,averagePooling3d:()=>Qw,avgPool1d:()=>Gw,avgPool2d:()=>Xw,avgPool3d:()=>eM,avgPooling1d:()=>Kw,avgPooling2d:()=>Zw,avgPooling3d:()=>tM,batchNormalization:()=>Uw,bidirectional:()=>xM,concatenate:()=>zw,conv1d:()=>xw,conv2d:()=>vw,conv2dTranspose:()=>_w,conv3d:()=>ww,conv3dTranspose:()=>Mw,convLstm2d:()=>mM,convLstm2dCell:()=>gM,cropping2D:()=>Sw,dense:()=>Iw,depthwiseConv2d:()=>Dw,dot:()=>jw,dropout:()=>Ew,elu:()=>hw,embedding:()=>Rw,flatten:()=>Aw,gaussianDropout:()=>kM,gaussianNoise:()=>SM,globalAveragePooling1d:()=>nM,globalAveragePooling2d:()=>rM,globalMaxPool1d:()=>_M,globalMaxPool2d:()=>wM,globalMaxPooling1d:()=>aM,globalMaxPooling2d:()=>iM,gru:()=>lM,gruCell:()=>cM,input:()=>uv,inputLayer:()=>dw,layerNormalization:()=>qw,leakyReLU:()=>mw,lstm:()=>pM,lstmCell:()=>dM,masking:()=>TM,maxPool1d:()=>MM,maxPool2d:()=>NM,maxPooling1d:()=>sM,maxPooling2d:()=>oM,maxPooling3d:()=>uM,maximum:()=>Bw,minimum:()=>Pw,multiply:()=>Hw,permute:()=>Ow,prelu:()=>gw,reLU:()=>fw,repeatVector:()=>Lw,reshape:()=>$w,rnn:()=>yM,separableConv2d:()=>Nw,simpleRNN:()=>hM,simpleRNNCell:()=>fM,softmax:()=>yw,spatialDropout1d:()=>Cw,stackedRNNCells:()=>bM,thresholdedReLU:()=>bw,timeDistributed:()=>vM,upSampling2d:()=>kw,zeroPadding2d:()=>Ww});var _={};n.r(_),n.d(_,{MAPE:()=>zM,MSE:()=>HM,binaryAccuracy:()=>IM,binaryCrossentropy:()=>EM,categoricalAccuracy:()=>AM,categoricalCrossentropy:()=>LM,cosineProximity:()=>RM,mape:()=>BM,meanAbsoluteError:()=>FM,meanAbsolutePercentageError:()=>YM,meanSquaredError:()=>PM,mse:()=>jM,precision:()=>$M,recall:()=>OM,sparseCategoricalAccuracy:()=>CM});var w={};n.r(w),n.d(w,{modelFromJSON:()=>rv});var M={};n.r(M),n.d(M,{l1:()=>qM,l1l2:()=>UM,l2:()=>WM});var N={};n.r(N),n.d(N,{json:()=>pN});var S={};n.r(S),n.d(S,{json:()=>dN});var k={};n.r(k),n.d(k,{json:()=>hN});var D={};n.r(D),n.d(D,{json:()=>fN});var T={};n.r(T),n.d(T,{json:()=>mN});var I={};n.r(I),n.d(I,{json:()=>gN});var E={};n.r(E),n.d(E,{json:()=>yN});var C={};n.r(C),n.d(C,{json:()=>bN});var A={};n.r(A),n.d(A,{json:()=>xN});var L={};n.r(L),n.d(L,{json:()=>vN});var $={};n.r($),n.d($,{json:()=>_N});var O={};n.r(O),n.d(O,{json:()=>wN});var R={};n.r(R),n.d(R,{json:()=>MN});var F={};n.r(F),n.d(F,{json:()=>NN});var Y={};n.r(Y),n.d(Y,{json:()=>SN});var z={};n.r(z),n.d(z,{json:()=>kN});var B={};n.r(B),n.d(B,{json:()=>DN});var P={};n.r(P),n.d(P,{json:()=>TN});var H={};n.r(H),n.d(H,{json:()=>IN});var j={};n.r(j),n.d(j,{CSVDataset:()=>ak,Dataset:()=>WS,FileDataSource:()=>gk,TextLineDataset:()=>XS,URLDataSource:()=>yk,array:()=>GS,csv:()=>bk,func:()=>xk,generator:()=>vk,microphone:()=>wk,version_data:()=>Mk,webcam:()=>_k,zip:()=>KS});var U={};n.r(U),n.d(U,{addImpl:()=>rD,bincountImpl:()=>KD,bincountReduceImpl:()=>JD,ceilImpl:()=>QD,concatImpl:()=>iT,equalImpl:()=>HT,expImpl:()=>QT,expm1Impl:()=>aI,floorImpl:()=>_I,gatherNdImpl:()=>II,gatherV2Impl:()=>CI,greaterEqualImpl:()=>RI,greaterImpl:()=>LI,lessEqualImpl:()=>KI,lessImpl:()=>WI,linSpaceImpl:()=>ZI,logImpl:()=>eE,maxImpl:()=>mE,maximumImpl:()=>bE,minimumImpl:()=>TE,multiplyImpl:()=>$T,negImpl:()=>zE,notEqualImpl:()=>VE,prodImpl:()=>sC,rangeImpl:()=>uC,rsqrtImpl:()=>vC,scatterImpl:()=>MC,sigmoidImpl:()=>Uk,simpleAbsImpl:()=>dD,sliceImpl:()=>qD,sparseFillEmptyRowsImpl:()=>jC,sparseReshapeImpl:()=>qC,sparseSegmentReductionImpl:()=>VC,sqrtImpl:()=>ZC,squaredDifferenceImpl:()=>nA,stridedSliceImpl:()=>oA,stringNGramsImpl:()=>cA,stringSplitImpl:()=>hA,stringToHashBucketFastImpl:()=>mA,subImpl:()=>cI,tileImpl:()=>vA,topKImpl:()=>NA,transposeImpl:()=>xD,uniqueImpl:()=>CA});var q={};n.r(q),n.d(q,{Abs:()=>Ze,Acos:()=>Qe,Acosh:()=>et,AdadeltaOptimizer:()=>Ru,AdagradOptimizer:()=>Yu,AdamOptimizer:()=>Pu,AdamaxOptimizer:()=>Uu,Add:()=>tt,AddN:()=>nt,All:()=>rt,Any:()=>at,ArgMax:()=>it,ArgMin:()=>st,Asin:()=>ot,Asinh:()=>ut,Atan:()=>lt,Atan2:()=>pt,Atanh:()=>ct,AvgPool:()=>dt,AvgPool3D:()=>ft,AvgPool3DGrad:()=>mt,AvgPoolGrad:()=>ht,BatchMatMul:()=>gt,BatchToSpaceND:()=>yt,Bincount:()=>bt,BroadcastArgs:()=>vt,BroadcastTo:()=>xt,Callback:()=>VM,CallbackList:()=>ex,Cast:()=>_t,Ceil:()=>wt,ClipByValue:()=>Mt,Complex:()=>Nt,ComplexAbs:()=>St,Concat:()=>kt,Conv2D:()=>Dt,Conv2DBackpropFilter:()=>Tt,Conv2DBackpropInput:()=>It,Conv3D:()=>Et,Conv3DBackpropFilterV2:()=>Ct,Conv3DBackpropInputV2:()=>At,Cos:()=>Lt,Cosh:()=>$t,CropAndResize:()=>Ft,Cumprod:()=>Ot,Cumsum:()=>Rt,CustomCallback:()=>rx,DataStorage:()=>G,DenseBincount:()=>Yt,DepthToSpace:()=>zt,DepthwiseConv2dNative:()=>Bt,DepthwiseConv2dNativeBackpropFilter:()=>Pt,DepthwiseConv2dNativeBackpropInput:()=>Ht,Diag:()=>jt,Dilation2D:()=>Ut,Dilation2DBackpropFilter:()=>Wt,Dilation2DBackpropInput:()=>qt,ENV:()=>Ke,EarlyStopping:()=>JM,Einsum:()=>Gt,Elu:()=>Kt,EluGrad:()=>Jt,Environment:()=>qe,Equal:()=>Zt,Erf:()=>Xt,Exp:()=>Qt,ExpandDims:()=>en,Expm1:()=>tn,FFT:()=>nn,Fill:()=>rn,FlipLeftRight:()=>an,Floor:()=>sn,FloorDiv:()=>on,FromPixels:()=>ra,FusedBatchNorm:()=>un,FusedConv2D:()=>sa,FusedDepthwiseConv2D:()=>oa,GatherNd:()=>cn,GatherV2:()=>ln,GraphModel:()=>dS,Greater:()=>pn,GreaterEqual:()=>dn,History:()=>nx,IFFT:()=>fn,Identity:()=>hn,Imag:()=>mn,InputSpec:()=>ib,IsFinite:()=>gn,IsInf:()=>yn,IsNan:()=>bn,KernelBackend:()=>K,LRN:()=>En,LRNGrad:()=>Cn,LayerVariable:()=>nb,LayersModel:()=>tv,LeakyRelu:()=>xn,Less:()=>vn,LessEqual:()=>_n,LinSpace:()=>wn,Log:()=>Mn,Log1p:()=>Nn,LogSoftmax:()=>Tn,LogicalAnd:()=>Sn,LogicalNot:()=>kn,LogicalOr:()=>Dn,LowerBound:()=>In,Max:()=>An,MaxPool:()=>$n,MaxPool3D:()=>Rn,MaxPool3DGrad:()=>Fn,MaxPoolGrad:()=>On,MaxPoolWithArgmax:()=>Yn,Maximum:()=>Ln,Mean:()=>zn,Min:()=>Bn,Minimum:()=>Pn,MirrorPad:()=>Hn,Mod:()=>jn,MomentumOptimizer:()=>Wu,Multinomial:()=>Un,Multiply:()=>qn,Neg:()=>Wn,NonMaxSuppressionV3:()=>Gn,NonMaxSuppressionV4:()=>Kn,NonMaxSuppressionV5:()=>Jn,NotEqual:()=>Vn,OP_SCOPE_SUFFIX:()=>Ci,OneHot:()=>Zn,OnesLike:()=>Xn,Optimizer:()=>Ou,OptimizerConstructors:()=>Gu,Pack:()=>Qn,PadV2:()=>er,Pool:()=>tr,Pow:()=>nr,Prelu:()=>rr,Prod:()=>ar,RMSPropOptimizer:()=>Vu,RNN:()=>o_,Range:()=>ir,Rank:()=>ni,Real:()=>sr,RealDiv:()=>Vt,Reciprocal:()=>or,Reduction:()=>wh,Relu:()=>ur,Relu6:()=>fr,Reshape:()=>lr,ResizeBilinear:()=>dr,ResizeBilinearGrad:()=>hr,ResizeNearestNeighbor:()=>cr,ResizeNearestNeighborGrad:()=>pr,Reverse:()=>mr,RotateWithOffset:()=>aa,Round:()=>gr,Rsqrt:()=>yr,SGDOptimizer:()=>qu,ScatterNd:()=>br,SearchSorted:()=>xr,Select:()=>vr,Selu:()=>_r,Sequential:()=>av,Sigmoid:()=>kr,Sign:()=>Sr,Sin:()=>Mr,Sinh:()=>Nr,Slice:()=>wr,Softmax:()=>Ar,Softplus:()=>Dr,SpaceToBatchND:()=>Er,SparseFillEmptyRows:()=>Lr,SparseReshape:()=>$r,SparseSegmentMean:()=>Or,SparseSegmentSum:()=>Rr,SparseToDense:()=>Fr,SplitV:()=>Cr,Sqrt:()=>Tr,Square:()=>zr,SquaredDifference:()=>Yr,Step:()=>na,StridedSlice:()=>Br,StringNGrams:()=>Pr,StringSplit:()=>Hr,StringToHashBucketFast:()=>jr,Sub:()=>Ur,Sum:()=>Ir,SymbolicTensor:()=>sb,Tan:()=>qr,Tanh:()=>Wr,Tensor:()=>Qa,TensorBuffer:()=>Ka,Tile:()=>Vr,TopK:()=>Gr,Transform:()=>Kr,Transpose:()=>Jr,Unique:()=>Xr,Unpack:()=>Zr,UnsortedSegmentSum:()=>Qr,UpperBound:()=>ea,Variable:()=>ti,ZerosLike:()=>ta,_FusedMatMul:()=>ia,abs:()=>Hu,acos:()=>Ku,acosh:()=>Ju,add:()=>vu,addN:()=>Xu,all:()=>Zu,any:()=>Qu,argMax:()=>el,argMin:()=>tl,asin:()=>nl,asinh:()=>rl,atan:()=>al,atan2:()=>il,atanh:()=>sl,avgPool:()=>wl,avgPool3d:()=>Ml,backend:()=>wo,backend_util:()=>g,basicLSTMCell:()=>Tl,batchNorm:()=>El,batchNorm2d:()=>Cl,batchNorm3d:()=>Al,batchNorm4d:()=>Ll,batchToSpaceND:()=>Il,bincount:()=>$l,booleanMaskAsync:()=>Td,broadcastArgs:()=>Ol,broadcastTo:()=>Rl,broadcast_util:()=>o,browser:()=>u,buffer:()=>Es,callbacks:()=>XM,cast:()=>Cs,ceil:()=>Fl,clipByValue:()=>Yl,clone:()=>As,complex:()=>Li,concat:()=>Nl,concat1d:()=>zl,concat2d:()=>Bl,concat3d:()=>Pl,concat4d:()=>Hl,constraints:()=>b,conv1d:()=>Ul,conv2d:()=>jl,conv2dTranspose:()=>Wl,conv3d:()=>Vl,conv3dTranspose:()=>Kl,copyRegisteredKernels:()=>xa,cos:()=>Jl,cosh:()=>Xl,cosineWindow:()=>Od,cumprod:()=>Zl,cumsum:()=>Ql,customGrad:()=>Au,data:()=>j,denseBincount:()=>ec,deprecationWarn:()=>io,depthToSpace:()=>tc,depthwiseConv2d:()=>nc,deregisterOp:()=>rN,device_util:()=>a,diag:()=>rc,dilation2d:()=>ac,disableDeprecationWarnings:()=>ao,dispose:()=>po,disposeVariables:()=>so,div:()=>wu,divNoNan:()=>oc,dot:()=>uc,dropout:()=>Ld,einsum:()=>lc,elu:()=>cc,enableDebugMode:()=>ro,enableProdMode:()=>no,enclosingPowerOfTwo:()=>$d,engine:()=>oo,env:()=>Ve,equal:()=>ic,erf:()=>pc,euclideanNorm:()=>Sc,exp:()=>kc,expandDims:()=>Dc,expm1:()=>Tc,eye:()=>Ec,fft:()=>rd,fill:()=>Fu,findBackend:()=>xo,findBackendFactory:()=>vo,floor:()=>Cc,floorDiv:()=>_u,fused:()=>f,gather:()=>Ac,gatherND:()=>Ad,gather_util:()=>l,getBackend:()=>yo,getGradient:()=>ha,getKernel:()=>da,getKernelsForBackend:()=>fa,grad:()=>Du,grads:()=>Tu,greater:()=>Lc,greaterEqual:()=>$c,ifft:()=>ad,imag:()=>No,image:()=>Ph,inTopKAsync:()=>Rd,initializers:()=>x,input:()=>uv,io:()=>i,irfft:()=>id,isFinite:()=>Oc,isInf:()=>Rc,isNaN:()=>Fc,keep:()=>ho,kernel_impls:()=>y,layers:()=>v,leakyRelu:()=>Yc,less:()=>zc,lessEqual:()=>Bc,linalg:()=>Hh,linspace:()=>Pc,loadGraphModel:()=>hS,loadGraphModelSync:()=>fS,loadLayersModel:()=>ov,localResponseNormalization:()=>Hc,log:()=>jc,log1p:()=>Uc,logSigmoid:()=>Wc,logSoftmax:()=>Vc,logSumExp:()=>Gc,logicalAnd:()=>Kc,logicalNot:()=>Jc,logicalOr:()=>Xc,logicalXor:()=>Zc,losses:()=>jh,lowerBound:()=>tp,matMul:()=>eo,math:()=>s,max:()=>vc,maxPool:()=>np,maxPool3d:()=>rp,maxPoolWithArgmax:()=>ap,maximum:()=>ju,mean:()=>ip,memory:()=>uo,meshgrid:()=>up,metrics:()=>_,min:()=>_c,minimum:()=>lp,mirrorPad:()=>cp,mod:()=>pp,model:()=>iv,models:()=>w,moments:()=>dp,movingAverage:()=>Id,mul:()=>Mu,multiRNNCell:()=>hp,multinomial:()=>fp,neg:()=>So,nextFrame:()=>Gh,norm:()=>Nc,notEqual:()=>mp,oneHot:()=>to,ones:()=>op,onesLike:()=>gp,op:()=>Ai,outerProduct:()=>yp,pad:()=>bp,pad1d:()=>xp,pad2d:()=>vp,pad3d:()=>_p,pad4d:()=>wp,pool:()=>Np,pow:()=>zu,prelu:()=>Sp,print:()=>Ls,prod:()=>kp,profile:()=>lo,rand:()=>Dp,randomGamma:()=>Ap,randomNormal:()=>Lp,randomUniform:()=>$p,range:()=>Op,ready:()=>go,real:()=>ko,reciprocal:()=>Rp,registerBackend:()=>_o,registerCallbackConstructor:()=>lv,registerGradient:()=>ga,registerKernel:()=>ma,registerOp:()=>tN,regularizers:()=>M,relu:()=>Fp,relu6:()=>Yp,removeBackend:()=>bo,reshape:()=>_l,reverse:()=>zp,reverse1d:()=>Bp,reverse2d:()=>Pp,reverse3d:()=>Hp,reverse4d:()=>jp,rfft:()=>od,round:()=>Up,rsqrt:()=>qp,scalar:()=>$u,scatterND:()=>Ed,scatter_util:()=>c,searchSorted:()=>ep,selu:()=>Wp,separableConv2d:()=>Vp,sequential:()=>sv,serialization:()=>d,setBackend:()=>mo,setPlatform:()=>Mo,setdiff1dAsync:()=>Gp,sigmoid:()=>Sl,sign:()=>Kp,signal:()=>Bh,sin:()=>Jp,sinh:()=>Xp,slice:()=>kl,slice1d:()=>Zp,slice2d:()=>Qp,slice3d:()=>ed,slice4d:()=>td,slice_util:()=>p,softmax:()=>nd,softplus:()=>qc,spaceToBatchND:()=>Mp,sparse:()=>Uh,sparseToDense:()=>Cd,spectral:()=>zh,split:()=>sd,sqrt:()=>Nu,square:()=>Su,squaredDifference:()=>ud,squeeze:()=>ld,stack:()=>cd,step:()=>pd,stridedSlice:()=>dd,string:()=>qh,sub:()=>Bu,sum:()=>wc,sumOutType:()=>li,tan:()=>hd,tanh:()=>Dl,tensor:()=>Oi,tensor1d:()=>fd,tensor2d:()=>md,tensor3d:()=>Ao,tensor4d:()=>gd,tensor5d:()=>yd,tensor6d:()=>bd,tensor_util:()=>t,test_util:()=>h,tidy:()=>co,tile:()=>Ic,time:()=>fo,topk:()=>xd,train:()=>Wh,transpose:()=>Do,truncatedNormal:()=>vd,unique:()=>_d,unregisterGradient:()=>ba,unregisterKernel:()=>ya,unsortedSegmentSum:()=>wd,unstack:()=>Md,upcastType:()=>ui,upperBound:()=>Nd,util:()=>e,valueAndGrad:()=>Iu,valueAndGrads:()=>Eu,variable:()=>Sd,variableGrads:()=>Cu,version:()=>AP,version_converter:()=>mS,version_core:()=>xu,version_layers:()=>Fx,where:()=>sc,whereAsync:()=>Dd,zeros:()=>sp,zerosLike:()=>ku});var W={};n.r(W),n.d(W,{createAbs:()=>vW,createAccessorNode:()=>N7,createAcos:()=>wW,createAcosh:()=>mK,createAcot:()=>PW,createAcoth:()=>VK,createAcsc:()=>jW,createAcsch:()=>yK,createAdd:()=>cZ,createAddScalar:()=>qW,createAnd:()=>VJ,createApply:()=>xK,createApplyTransform:()=>p8,createArg:()=>WW,createArrayNode:()=>h7,createAsec:()=>wK,createAsech:()=>GW,createAsin:()=>bQ,createAsinh:()=>KW,createAssignmentNode:()=>S7,createAtan:()=>JW,createAtan2:()=>hZ,createAtanh:()=>ZW,createAtomicMass:()=>gU,createAvogadro:()=>yU,createBellNumbers:()=>q0,createBigNumberClass:()=>zH,createBignumber:()=>QW,createBin:()=>MK,createBitAnd:()=>KJ,createBitNot:()=>yV,createBitOr:()=>mZ,createBitXor:()=>XJ,createBlockNode:()=>f7,createBohrMagneton:()=>Jj,createBohrRadius:()=>nU,createBoltzmann:()=>bU,createBoolean:()=>xV,createCatalan:()=>yZ,createCbrt:()=>QJ,createCeil:()=>wQ,createChain:()=>v7,createChainClass:()=>K6,createClassicalElectronRadius:()=>rU,createClone:()=>_V,createColumn:()=>r0,createColumnTransform:()=>N8,createCombinations:()=>SV,createCombinationsWithRep:()=>SK,createCompare:()=>tX,createCompareNatural:()=>vZ,createCompareText:()=>rX,createCompile:()=>Y7,createComplex:()=>DV,createComplexClass:()=>lj,createComposition:()=>NQ,createConcat:()=>iX,createConcatTransform:()=>g8,createConditionalNode:()=>m7,createConductanceQuantum:()=>Xj,createConj:()=>IV,createConstantNode:()=>g7,createCos:()=>DK,createCosh:()=>CV,createCot:()=>GK,createCoth:()=>LV,createCoulomb:()=>Gj,createCount:()=>uX,createCreateUnit:()=>w0,createCross:()=>kQ,createCsc:()=>$V,createCsch:()=>IK,createCtranspose:()=>cX,createCube:()=>RV,createCumSum:()=>wZ,createCumSumTransform:()=>w8,createDeepEqual:()=>NZ,createDenseMatrixClass:()=>Mq,createDerivative:()=>n8,createDet:()=>DQ,createDeuteronMass:()=>lU,createDiag:()=>dX,createDiff:()=>kZ,createDiffTransform:()=>f8,createDistance:()=>IQ,createDivide:()=>C0,createDivideScalar:()=>fX,createDot:()=>DZ,createDotDivide:()=>gX,createDotMultiply:()=>CQ,createDotPow:()=>N0,createE:()=>Tj,createEfimovFactor:()=>mU,createEigs:()=>W0,createElectricConstant:()=>Wj,createElectronMass:()=>aU,createElementaryCharge:()=>Kj,createEqual:()=>bX,createEqualScalar:()=>zV,createEqualText:()=>IZ,createErf:()=>BV,createEvaluate:()=>V7,createExp:()=>WV,createExpm:()=>k0,createExpm1:()=>GV,createFactorial:()=>L0,createFalse:()=>wj,createFaraday:()=>xU,createFermiCoupling:()=>iU,createFft:()=>xX,createFibonacciHeapClass:()=>AQ,createFilter:()=>KV,createFilterTransform:()=>s8,createFineStructure:()=>sU,createFirstRadiation:()=>vU,createFix:()=>RQ,createFlatten:()=>_X,createFloor:()=>LZ,createForEach:()=>ZV,createForEachTransform:()=>u8,createFormat:()=>tG,createFraction:()=>KK,createFractionClass:()=>BU,createFunctionAssignmentNode:()=>_7,createFunctionNode:()=>I7,createGamma:()=>T0,createGasConstant:()=>wU,createGcd:()=>MX,createGetMatrixDataType:()=>rG,createGravitationConstant:()=>Hj,createGravity:()=>CU,createHartreeEnergy:()=>oU,createHasNumericValue:()=>SX,createHelp:()=>Z7,createHelpClass:()=>z7,createHex:()=>aG,createHypot:()=>DX,createI:()=>Rj,createIdentity:()=>OZ,createIfft:()=>IX,createIm:()=>iG,createImmutableDenseMatrixClass:()=>FQ,createIndex:()=>i0,createIndexClass:()=>YQ,createIndexNode:()=>k7,createIndexTransform:()=>S8,createInfinity:()=>Nj,createIntersect:()=>zQ,createInv:()=>s0,createInverseConductanceQuantum:()=>Zj,createInvmod:()=>FZ,createIsInteger:()=>oG,createIsNaN:()=>CK,createIsNegative:()=>fG,createIsNumeric:()=>XK,createIsPositive:()=>gG,createIsPrime:()=>LK,createIsZero:()=>bG,createKldivergence:()=>h1,createKlitzing:()=>tU,createKron:()=>CX,createLN10:()=>Cj,createLN2:()=>Ej,createLOG10E:()=>Lj,createLOG2E:()=>Aj,createLarger:()=>zZ,createLargerEq:()=>LX,createLcm:()=>BQ,createLeafCount:()=>P7,createLeftShift:()=>RX,createLgamma:()=>kG,createLog:()=>BZ,createLog10:()=>TG,createLog1p:()=>HQ,createLog2:()=>EG,createLoschmidt:()=>_U,createLsolve:()=>zX,createLsolveAll:()=>HZ,createLup:()=>$0,createLusolve:()=>e1,createMad:()=>M1,createMagneticConstant:()=>qj,createMagneticFluxQuantum:()=>Qj,createMap:()=>CG,createMapTransform:()=>l8,createMatrix:()=>QK,createMatrixClass:()=>PU,createMatrixFromColumns:()=>PX,createMatrixFromFunction:()=>tJ,createMatrixFromRows:()=>UZ,createMax:()=>jQ,createMaxTransform:()=>y8,createMean:()=>G0,createMeanTransform:()=>k8,createMedian:()=>r1,createMin:()=>HX,createMinTransform:()=>b8,createMod:()=>lJ,createMode:()=>UX,createMolarMass:()=>IU,createMolarMassC12:()=>EU,createMolarPlanckConstant:()=>MU,createMolarVolume:()=>NU,createMultinomial:()=>R0,createMultiply:()=>WZ,createMultiplyScalar:()=>LG,createNaN:()=>Sj,createNeutronMass:()=>cU,createNode:()=>X6,createNorm:()=>g1,createNot:()=>zG,createNthRoot:()=>hJ,createNthRoots:()=>WX,createNuclearMagneton:()=>eU,createNull:()=>Mj,createNumber:()=>BG,createNumeric:()=>yJ,createObjectNode:()=>Z6,createOct:()=>PG,createOnes:()=>VX,createOperatorNode:()=>c7,createOr:()=>bJ,createParenthesisNode:()=>p7,createParse:()=>C7,createParser:()=>a8,createParserClass:()=>Q7,createPartitionSelect:()=>KX,createPermutations:()=>Y0,createPhi:()=>Ij,createPi:()=>kj,createPickRandom:()=>WG,createPinv:()=>u0,createPlanckCharge:()=>OU,createPlanckConstant:()=>jj,createPlanckLength:()=>AU,createPlanckMass:()=>LU,createPlanckTemperature:()=>RU,createPlanckTime:()=>$U,createPow:()=>l0,createPrint:()=>GG,createProd:()=>_J,createProtonMass:()=>uU,createQr:()=>VZ,createQuantileSeq:()=>UQ,createQuantumOfCirculation:()=>pU,createRandom:()=>ZG,createRandomInt:()=>OK,createRange:()=>KZ,createRangeClass:()=>HU,createRangeNode:()=>y7,createRangeTransform:()=>x8,createRationalize:()=>t8,createRe:()=>QG,createReducedPlanckConstant:()=>Uj,createRelationalNode:()=>d7,createReplacer:()=>Nq,createReshape:()=>MJ,createResize:()=>XX,createResolve:()=>A7,createResultSet:()=>jU,createReviver:()=>b7,createRightArithShift:()=>QX,createRightLogShift:()=>XZ,createRotate:()=>k1,createRotationMatrix:()=>x1,createRound:()=>nZ,createRow:()=>qQ,createRowTransform:()=>M8,createRydberg:()=>dU,createSQRT1_2:()=>$j,createSQRT2:()=>Oj,createSackurTetrode:()=>SU,createSec:()=>eK,createSech:()=>FK,createSecondRadiation:()=>kU,createSetCartesian:()=>VQ,createSetDifference:()=>p0,createSetDistinct:()=>KQ,createSetIntersect:()=>E0,createSetIsSubset:()=>XQ,createSetMultiplicity:()=>h0,createSetPowerset:()=>QQ,createSetSize:()=>QZ,createSetSymDifference:()=>J0,createSetUnion:()=>s1,createSign:()=>nK,createSimplify:()=>j7,createSimplifyCore:()=>R7,createSin:()=>rK,createSinh:()=>zK,createSize:()=>SJ,createSlu:()=>dQ,createSmaller:()=>TJ,createSmallerEq:()=>aZ,createSort:()=>t0,createSpaClass:()=>f0,createSparse:()=>PK,createSparseMatrixClass:()=>aK,createSpeedOfLight:()=>Pj,createSplitUnit:()=>sK,createSqrt:()=>HK,createSqrtm:()=>g0,createSquare:()=>uK,createSqueeze:()=>EJ,createStd:()=>_1,createStdTransform:()=>I8,createStefanBoltzmann:()=>DU,createStirlingS2:()=>P0,createString:()=>cK,createSubset:()=>AJ,createSubsetTransform:()=>m8,createSubtract:()=>zJ,createSum:()=>hQ,createSumTransform:()=>v8,createSymbolNode:()=>D7,createSymbolicEqual:()=>q7,createTan:()=>pK,createTanh:()=>jK,createTau:()=>Dj,createThomsonCrossSection:()=>hU,createTo:()=>PJ,createTrace:()=>fQ,createTranspose:()=>HJ,createTrue:()=>_j,createTypeOf:()=>hK,createTyped:()=>zq,createUnaryMinus:()=>qK,createUnaryPlus:()=>xW,createUnequal:()=>sZ,createUnitClass:()=>v0,createUnitFunction:()=>j0,createUppercaseE:()=>Yj,createUppercasePi:()=>Fj,createUsolve:()=>uZ,createUsolveAll:()=>gQ,createVacuumImpedance:()=>Vj,createVariance:()=>c1,createVarianceTransform:()=>T8,createVersion:()=>zj,createWeakMixingAngle:()=>fU,createWienDisplacement:()=>TU,createXgcd:()=>UJ,createXor:()=>lZ,createZeros:()=>WJ});var V={};n.r(V),n.d(V,{AccessorNode:()=>V8,AccessorNodeDependencies:()=>N9,ArgumentsError:()=>JX,ArrayNode:()=>z8,ArrayNodeDependencies:()=>B9,AssignmentNode:()=>G8,AssignmentNodeDependencies:()=>q9,BigNumber:()=>D1,BigNumberDependencies:()=>d9,BlockNode:()=>B8,BlockNodeDependencies:()=>Oee,Chain:()=>L8,ChainDependencies:()=>Hee,Complex:()=>T1,ComplexDependencies:()=>h9,ConditionalNode:()=>P8,ConditionalNodeDependencies:()=>ate,ConstantNode:()=>H8,ConstantNodeDependencies:()=>ite,DenseMatrix:()=>G1,DenseMatrixDependencies:()=>m9,DimensionError:()=>ZU,EDependencies:()=>Nie,FibonacciHeap:()=>i5,FibonacciHeapDependencies:()=>Tne,Fraction:()=>A1,FractionDependencies:()=>g9,FunctionAssignmentNode:()=>W8,FunctionAssignmentNodeDependencies:()=>ste,FunctionNode:()=>X8,FunctionNodeDependencies:()=>ute,Help:()=>n9,HelpDependencies:()=>Hne,ImmutableDenseMatrix:()=>o5,ImmutableDenseMatrixDependencies:()=>Vee,Index:()=>u5,IndexDependencies:()=>Gee,IndexError:()=>QU,IndexNode:()=>K8,IndexNodeDependencies:()=>lte,InfinityDependencies:()=>Kne,LN10:()=>O1,LN10Dependencies:()=>ure,LN2:()=>J1,LN2Dependencies:()=>lre,LOG10E:()=>R1,LOG10EDependencies:()=>cre,LOG2E:()=>Y2,LOG2EDependencies:()=>pre,Matrix:()=>F1,MatrixDependencies:()=>f9,NaNDependencies:()=>Vre,Node:()=>$8,NodeDependencies:()=>x9,ObjectNode:()=>O8,ObjectNodeDependencies:()=>cte,OperatorNode:()=>R8,OperatorNodeDependencies:()=>pte,PIDependencies:()=>Sie,ParenthesisNode:()=>F8,ParenthesisNodeDependencies:()=>dte,Parser:()=>u9,ParserDependencies:()=>rae,Range:()=>P1,RangeDependencies:()=>wae,RangeNode:()=>j8,RangeNodeDependencies:()=>hte,RelationalNode:()=>Y8,RelationalNodeDependencies:()=>fte,ResultSet:()=>H1,ResultSetDependencies:()=>$ee,SQRT1_2:()=>j1,SQRT1_2Dependencies:()=>Fae,SQRT2:()=>Q1,SQRT2Dependencies:()=>Yae,Spa:()=>T5,SpaDependencies:()=>wre,SparseMatrix:()=>e3,SparseMatrixDependencies:()=>_9,SymbolNode:()=>J8,SymbolNodeDependencies:()=>ote,Unit:()=>E5,UnitDependencies:()=>xee,_Infinity:()=>$1,_NaN:()=>Y1,_false:()=>E1,_null:()=>z1,_true:()=>W1,abs:()=>r2,absDependencies:()=>b9,acos:()=>a2,acosDependencies:()=>S9,acosh:()=>s3,acoshDependencies:()=>k9,acot:()=>i2,acotDependencies:()=>D9,acoth:()=>M3,acothDependencies:()=>T9,acsc:()=>s2,acscDependencies:()=>I9,acsch:()=>o3,acschDependencies:()=>E9,add:()=>k4,addDependencies:()=>A9,addScalar:()=>o2,addScalarDependencies:()=>C9,all:()=>Aie,and:()=>U3,andDependencies:()=>O9,apply:()=>u3,applyDependencies:()=>F9,applyTransformDependencies:()=>Y9,arg:()=>u2,argDependencies:()=>z9,asec:()=>l3,asecDependencies:()=>P9,asech:()=>l2,asechDependencies:()=>H9,asin:()=>Z4,asinDependencies:()=>j9,asinh:()=>c2,asinhDependencies:()=>U9,atan:()=>p2,atan2:()=>D4,atan2Dependencies:()=>V9,atanDependencies:()=>W9,atanh:()=>d2,atanhDependencies:()=>G9,atomicMass:()=>L5,atomicMassDependencies:()=>vee,avogadro:()=>p6,avogadroDependencies:()=>_ee,bellNumbers:()=>I6,bellNumbersDependencies:()=>Tee,bignumber:()=>h2,bignumberDependencies:()=>K9,bin:()=>c3,binDependencies:()=>Iee,bitAnd:()=>q3,bitAndDependencies:()=>Eee,bitNot:()=>f2,bitNotDependencies:()=>Cee,bitOr:()=>T4,bitOrDependencies:()=>Aee,bitXor:()=>W3,bitXorDependencies:()=>Lee,bohrMagneton:()=>$5,bohrMagnetonDependencies:()=>Ree,bohrRadius:()=>d6,bohrRadiusDependencies:()=>Fee,boltzmann:()=>O5,boltzmannDependencies:()=>Yee,boolean:()=>m2,booleanDependencies:()=>zee,catalan:()=>I4,catalanDependencies:()=>Bee,cbrt:()=>V3,cbrtDependencies:()=>Pee,ceil:()=>Q4,ceilDependencies:()=>nee,chain:()=>q8,chainDependencies:()=>jee,classicalElectronRadius:()=>R6,classicalElectronRadiusDependencies:()=>Uee,clone:()=>g2,cloneDependencies:()=>qee,column:()=>_5,columnDependencies:()=>Zee,columnTransformDependencies:()=>Qee,combinations:()=>y2,combinationsDependencies:()=>Mee,combinationsWithRep:()=>p3,combinationsWithRepDependencies:()=>ete,compare:()=>G3,compareDependencies:()=>tte,compareNatural:()=>E4,compareNaturalDependencies:()=>nte,compareText:()=>K3,compareTextDependencies:()=>rte,compile:()=>t9,compileDependencies:()=>gte,complex:()=>b2,complexDependencies:()=>yte,composition:()=>e5,compositionDependencies:()=>xte,concat:()=>J3,concatDependencies:()=>vte,concatTransformDependencies:()=>_te,conductanceQuantum:()=>R5,conductanceQuantumDependencies:()=>wte,config:()=>$H,conj:()=>x2,conjDependencies:()=>cee,cos:()=>d3,cosDependencies:()=>Mte,cosh:()=>v2,coshDependencies:()=>Nte,cot:()=>N3,cotDependencies:()=>Ste,coth:()=>_2,cothDependencies:()=>kte,coulomb:()=>h6,coulombDependencies:()=>Dte,count:()=>X3,countDependencies:()=>Ite,create:()=>$ie,createAbs:()=>vW,createAccessorNode:()=>N7,createAcos:()=>wW,createAcosh:()=>mK,createAcot:()=>PW,createAcoth:()=>VK,createAcsc:()=>jW,createAcsch:()=>yK,createAdd:()=>cZ,createAddScalar:()=>qW,createAnd:()=>VJ,createApply:()=>xK,createApplyTransform:()=>p8,createArg:()=>WW,createArrayNode:()=>h7,createAsec:()=>wK,createAsech:()=>GW,createAsin:()=>bQ,createAsinh:()=>KW,createAssignmentNode:()=>S7,createAtan:()=>JW,createAtan2:()=>hZ,createAtanh:()=>ZW,createAtomicMass:()=>gU,createAvogadro:()=>yU,createBellNumbers:()=>q0,createBigNumberClass:()=>zH,createBignumber:()=>QW,createBin:()=>MK,createBitAnd:()=>KJ,createBitNot:()=>yV,createBitOr:()=>mZ,createBitXor:()=>XJ,createBlockNode:()=>f7,createBohrMagneton:()=>Jj,createBohrRadius:()=>nU,createBoltzmann:()=>bU,createBoolean:()=>xV,createCatalan:()=>yZ,createCbrt:()=>QJ,createCeil:()=>wQ,createChain:()=>v7,createChainClass:()=>K6,createClassicalElectronRadius:()=>rU,createClone:()=>_V,createColumn:()=>r0,createColumnTransform:()=>N8,createCombinations:()=>SV,createCombinationsWithRep:()=>SK,createCompare:()=>tX,createCompareNatural:()=>vZ,createCompareText:()=>rX,createCompile:()=>Y7,createComplex:()=>DV,createComplexClass:()=>lj,createComposition:()=>NQ,createConcat:()=>iX,createConcatTransform:()=>g8,createConditionalNode:()=>m7,createConductanceQuantum:()=>Xj,createConj:()=>IV,createConstantNode:()=>g7,createCos:()=>DK,createCosh:()=>CV,createCot:()=>GK,createCoth:()=>LV,createCoulomb:()=>Gj,createCount:()=>uX,createCreateUnit:()=>w0,createCross:()=>kQ,createCsc:()=>$V,createCsch:()=>IK,createCtranspose:()=>cX,createCube:()=>RV,createCumSum:()=>wZ,createCumSumTransform:()=>w8,createDeepEqual:()=>NZ,createDenseMatrixClass:()=>Mq,createDerivative:()=>n8,createDet:()=>DQ,createDeuteronMass:()=>lU,createDiag:()=>dX,createDiff:()=>kZ,createDiffTransform:()=>f8,createDistance:()=>IQ,createDivide:()=>C0,createDivideScalar:()=>fX,createDot:()=>DZ,createDotDivide:()=>gX,createDotMultiply:()=>CQ,createDotPow:()=>N0,createE:()=>Tj,createEfimovFactor:()=>mU,createEigs:()=>W0,createElectricConstant:()=>Wj,createElectronMass:()=>aU,createElementaryCharge:()=>Kj,createEqual:()=>bX,createEqualScalar:()=>zV,createEqualText:()=>IZ,createErf:()=>BV,createEvaluate:()=>V7,createExp:()=>WV,createExpm:()=>k0,createExpm1:()=>GV,createFactorial:()=>L0,createFalse:()=>wj,createFaraday:()=>xU,createFermiCoupling:()=>iU,createFft:()=>xX,createFibonacciHeapClass:()=>AQ,createFilter:()=>KV,createFilterTransform:()=>s8,createFineStructure:()=>sU,createFirstRadiation:()=>vU,createFix:()=>RQ,createFlatten:()=>_X,createFloor:()=>LZ,createForEach:()=>ZV,createForEachTransform:()=>u8,createFormat:()=>tG,createFraction:()=>KK,createFractionClass:()=>BU,createFunctionAssignmentNode:()=>_7,createFunctionNode:()=>I7,createGamma:()=>T0,createGasConstant:()=>wU,createGcd:()=>MX,createGetMatrixDataType:()=>rG,createGravitationConstant:()=>Hj,createGravity:()=>CU,createHartreeEnergy:()=>oU,createHasNumericValue:()=>SX,createHelp:()=>Z7,createHelpClass:()=>z7,createHex:()=>aG,createHypot:()=>DX,createI:()=>Rj,createIdentity:()=>OZ,createIfft:()=>IX,createIm:()=>iG,createImmutableDenseMatrixClass:()=>FQ,createIndex:()=>i0,createIndexClass:()=>YQ,createIndexNode:()=>k7,createIndexTransform:()=>S8,createInfinity:()=>Nj,createIntersect:()=>zQ,createInv:()=>s0,createInverseConductanceQuantum:()=>Zj,createInvmod:()=>FZ,createIsInteger:()=>oG,createIsNaN:()=>CK,createIsNegative:()=>fG,createIsNumeric:()=>XK,createIsPositive:()=>gG,createIsPrime:()=>LK,createIsZero:()=>bG,createKldivergence:()=>h1,createKlitzing:()=>tU,createKron:()=>CX,createLN10:()=>Cj,createLN2:()=>Ej,createLOG10E:()=>Lj,createLOG2E:()=>Aj,createLarger:()=>zZ,createLargerEq:()=>LX,createLcm:()=>BQ,createLeafCount:()=>P7,createLeftShift:()=>RX,createLgamma:()=>kG,createLog:()=>BZ,createLog10:()=>TG,createLog1p:()=>HQ,createLog2:()=>EG,createLoschmidt:()=>_U,createLsolve:()=>zX,createLsolveAll:()=>HZ,createLup:()=>$0,createLusolve:()=>e1,createMad:()=>M1,createMagneticConstant:()=>qj,createMagneticFluxQuantum:()=>Qj,createMap:()=>CG,createMapTransform:()=>l8,createMatrix:()=>QK,createMatrixClass:()=>PU,createMatrixFromColumns:()=>PX,createMatrixFromFunction:()=>tJ,createMatrixFromRows:()=>UZ,createMax:()=>jQ,createMaxTransform:()=>y8,createMean:()=>G0,createMeanTransform:()=>k8,createMedian:()=>r1,createMin:()=>HX,createMinTransform:()=>b8,createMod:()=>lJ,createMode:()=>UX,createMolarMass:()=>IU,createMolarMassC12:()=>EU,createMolarPlanckConstant:()=>MU,createMolarVolume:()=>NU,createMultinomial:()=>R0,createMultiply:()=>WZ,createMultiplyScalar:()=>LG,createNaN:()=>Sj,createNeutronMass:()=>cU,createNode:()=>X6,createNorm:()=>g1,createNot:()=>zG,createNthRoot:()=>hJ,createNthRoots:()=>WX,createNuclearMagneton:()=>eU,createNull:()=>Mj,createNumber:()=>BG,createNumeric:()=>yJ,createObjectNode:()=>Z6,createOct:()=>PG,createOnes:()=>VX,createOperatorNode:()=>c7,createOr:()=>bJ,createParenthesisNode:()=>p7,createParse:()=>C7,createParser:()=>a8,createParserClass:()=>Q7,createPartitionSelect:()=>KX,createPermutations:()=>Y0,createPhi:()=>Ij,createPi:()=>kj,createPickRandom:()=>WG,createPinv:()=>u0,createPlanckCharge:()=>OU,createPlanckConstant:()=>jj,createPlanckLength:()=>AU,createPlanckMass:()=>LU,createPlanckTemperature:()=>RU,createPlanckTime:()=>$U,createPow:()=>l0,createPrint:()=>GG,createProd:()=>_J,createProtonMass:()=>uU,createQr:()=>VZ,createQuantileSeq:()=>UQ,createQuantumOfCirculation:()=>pU,createRandom:()=>ZG,createRandomInt:()=>OK,createRange:()=>KZ,createRangeClass:()=>HU,createRangeNode:()=>y7,createRangeTransform:()=>x8,createRationalize:()=>t8,createRe:()=>QG,createReducedPlanckConstant:()=>Uj,createRelationalNode:()=>d7,createReplacer:()=>Nq,createReshape:()=>MJ,createResize:()=>XX,createResolve:()=>A7,createResultSet:()=>jU,createReviver:()=>b7,createRightArithShift:()=>QX,createRightLogShift:()=>XZ,createRotate:()=>k1,createRotationMatrix:()=>x1,createRound:()=>nZ,createRow:()=>qQ,createRowTransform:()=>M8,createRydberg:()=>dU,createSQRT1_2:()=>$j,createSQRT2:()=>Oj,createSackurTetrode:()=>SU,createSec:()=>eK,createSech:()=>FK,createSecondRadiation:()=>kU,createSetCartesian:()=>VQ,createSetDifference:()=>p0,createSetDistinct:()=>KQ,createSetIntersect:()=>E0,createSetIsSubset:()=>XQ,createSetMultiplicity:()=>h0,createSetPowerset:()=>QQ,createSetSize:()=>QZ,createSetSymDifference:()=>J0,createSetUnion:()=>s1,createSign:()=>nK,createSimplify:()=>j7,createSimplifyCore:()=>R7,createSin:()=>rK,createSinh:()=>zK,createSize:()=>SJ,createSlu:()=>dQ,createSmaller:()=>TJ,createSmallerEq:()=>aZ,createSort:()=>t0,createSpaClass:()=>f0,createSparse:()=>PK,createSparseMatrixClass:()=>aK,createSpeedOfLight:()=>Pj,createSplitUnit:()=>sK,createSqrt:()=>HK,createSqrtm:()=>g0,createSquare:()=>uK,createSqueeze:()=>EJ,createStd:()=>_1,createStdTransform:()=>I8,createStefanBoltzmann:()=>DU,createStirlingS2:()=>P0,createString:()=>cK,createSubset:()=>AJ,createSubsetTransform:()=>m8,createSubtract:()=>zJ,createSum:()=>hQ,createSumTransform:()=>v8,createSymbolNode:()=>D7,createSymbolicEqual:()=>q7,createTan:()=>pK,createTanh:()=>jK,createTau:()=>Dj,createThomsonCrossSection:()=>hU,createTo:()=>PJ,createTrace:()=>fQ,createTranspose:()=>HJ,createTrue:()=>_j,createTypeOf:()=>hK,createTyped:()=>zq,createUnaryMinus:()=>qK,createUnaryPlus:()=>xW,createUnequal:()=>sZ,createUnit:()=>F5,createUnitClass:()=>v0,createUnitDependencies:()=>Ete,createUnitFunction:()=>j0,createUppercaseE:()=>Yj,createUppercasePi:()=>Fj,createUsolve:()=>uZ,createUsolveAll:()=>gQ,createVacuumImpedance:()=>Vj,createVariance:()=>c1,createVarianceTransform:()=>T8,createVersion:()=>zj,createWeakMixingAngle:()=>fU,createWienDisplacement:()=>TU,createXgcd:()=>UJ,createXor:()=>lZ,createZeros:()=>WJ,cross:()=>t5,crossDependencies:()=>Cte,csc:()=>w2,cscDependencies:()=>Ate,csch:()=>h3,cschDependencies:()=>Lte,ctranspose:()=>Z3,ctransposeDependencies:()=>Ote,cube:()=>M2,cubeDependencies:()=>Rte,cumsum:()=>C4,cumsumDependencies:()=>Yte,cumsumTransformDependencies:()=>zte,deepEqual:()=>A4,deepEqualDependencies:()=>Bte,derivative:()=>c9,derivativeDependencies:()=>qte,det:()=>n5,detDependencies:()=>gee,deuteronMass:()=>Y5,deuteronMassDependencies:()=>Wte,diag:()=>Q3,diagDependencies:()=>Vte,diff:()=>L4,diffDependencies:()=>Gte,diffTransformDependencies:()=>Kte,distance:()=>r5,distanceDependencies:()=>Xte,divide:()=>f6,divideDependencies:()=>Pte,divideScalar:()=>e4,divideScalarDependencies:()=>Q9,docs:()=>J7,dot:()=>$4,dotDependencies:()=>dee,dotDivide:()=>t4,dotDivideDependencies:()=>Zte,dotMultiply:()=>a5,dotMultiplyDependencies:()=>Qte,dotPow:()=>z5,dotPowDependencies:()=>ene,e:()=>I1,eDependencies:()=>tne,efimovFactor:()=>K1,efimovFactorDependencies:()=>nne,eigs:()=>E6,eigsDependencies:()=>dne,electricConstant:()=>B5,electricConstantDependencies:()=>hne,electronMass:()=>m6,electronMassDependencies:()=>fne,elementaryCharge:()=>P5,elementaryChargeDependencies:()=>mne,equal:()=>n4,equalDependencies:()=>eee,equalScalar:()=>N2,equalScalarDependencies:()=>v9,equalText:()=>O4,equalTextDependencies:()=>gne,erf:()=>S2,erfDependencies:()=>yne,evaluate:()=>s9,evaluateDependencies:()=>bne,exp:()=>k2,expDependencies:()=>xne,expm:()=>H5,expm1:()=>D2,expm1Dependencies:()=>_ne,expmDependencies:()=>vne,factorial:()=>g6,factorialDependencies:()=>See,factory:()=>RH,falseDependencies:()=>wne,faraday:()=>j5,faradayDependencies:()=>Mne,fermiCoupling:()=>C6,fermiCouplingDependencies:()=>Nne,fft:()=>r4,fftDependencies:()=>Dne,filter:()=>T2,filterDependencies:()=>Ine,filterTransformDependencies:()=>Ene,fineStructure:()=>C1,fineStructureDependencies:()=>Cne,firstRadiation:()=>U5,firstRadiationDependencies:()=>Ane,fix:()=>s5,fixDependencies:()=>aee,flatten:()=>a4,flattenDependencies:()=>rne,floor:()=>R4,floorDependencies:()=>ree,forEach:()=>I2,forEachDependencies:()=>Lne,forEachTransformDependencies:()=>$ne,format:()=>E2,formatDependencies:()=>iee,fraction:()=>S3,fractionDependencies:()=>J9,gamma:()=>q5,gammaDependencies:()=>Nee,gasConstant:()=>q6,gasConstantDependencies:()=>One,gcd:()=>i4,gcdDependencies:()=>Rne,getMatrixDataType:()=>C2,getMatrixDataTypeDependencies:()=>Fne,gravitationConstant:()=>W5,gravitationConstantDependencies:()=>Yne,gravity:()=>y6,gravityDependencies:()=>zne,hartreeEnergy:()=>V5,hartreeEnergyDependencies:()=>Bne,hasNumericValue:()=>s4,hasNumericValueDependencies:()=>Pne,help:()=>o9,helpDependencies:()=>jne,hex:()=>A2,hexDependencies:()=>Une,hypot:()=>o4,hypotDependencies:()=>qne,i:()=>L1,iDependencies:()=>Sne,identity:()=>F4,identityDependencies:()=>uee,ifft:()=>u4,ifftDependencies:()=>Wne,im:()=>L2,imDependencies:()=>ane,index:()=>w5,indexDependencies:()=>Vne,indexTransformDependencies:()=>Gne,intersect:()=>l5,intersectDependencies:()=>Jne,inv:()=>M5,invDependencies:()=>yee,inverseConductanceQuantum:()=>b6,inverseConductanceQuantumDependencies:()=>Xne,invmod:()=>Y4,invmodDependencies:()=>ere,isAccessorNode:()=>rH,isArray:()=>PP,isArrayNode:()=>aH,isAssignmentNode:()=>iH,isBigNumber:()=>RP,isBlockNode:()=>sH,isBoolean:()=>GP,isChain:()=>bH,isCollection:()=>jP,isComplex:()=>FP,isConditionalNode:()=>oH,isConstantNode:()=>uH,isDate:()=>ZP,isDenseMatrix:()=>UP,isFraction:()=>YP,isFunction:()=>XP,isFunctionAssignmentNode:()=>lH,isFunctionNode:()=>cH,isHelp:()=>JP,isIndex:()=>VP,isIndexNode:()=>pH,isInteger:()=>$2,isIntegerDependencies:()=>R9,isMatrix:()=>HP,isNaN:()=>f3,isNaNDependencies:()=>tre,isNegative:()=>O2,isNegativeDependencies:()=>wee,isNode:()=>dH,isNull:()=>tH,isNumber:()=>OP,isNumeric:()=>k3,isNumericDependencies:()=>see,isObject:()=>eH,isObjectNode:()=>hH,isOperatorNode:()=>fH,isParenthesisNode:()=>mH,isPositive:()=>R2,isPositiveDependencies:()=>bte,isPrime:()=>m3,isPrimeDependencies:()=>nre,isRange:()=>WP,isRangeNode:()=>gH,isRegExp:()=>QP,isResultSet:()=>KP,isSparseMatrix:()=>qP,isString:()=>BP,isSymbolNode:()=>yH,isUndefined:()=>nH,isUnit:()=>zP,isZero:()=>F2,isZeroDependencies:()=>lee,kldivergence:()=>P6,kldivergenceDependencies:()=>ire,klitzing:()=>G5,klitzingDependencies:()=>sre,kron:()=>l4,kronDependencies:()=>ore,larger:()=>z4,largerDependencies:()=>kee,largerEq:()=>c4,largerEqDependencies:()=>Kee,lcm:()=>c5,lcmDependencies:()=>dre,leafCount:()=>r9,leafCountDependencies:()=>hre,leftShift:()=>p4,leftShiftDependencies:()=>fre,lgamma:()=>z2,lgammaDependencies:()=>mre,log:()=>B4,log10:()=>B2,log10Dependencies:()=>gre,log1p:()=>d5,log1pDependencies:()=>yre,log2:()=>P2,log2Dependencies:()=>bre,logDependencies:()=>rre,loschmidt:()=>K5,loschmidtDependencies:()=>xre,lsolve:()=>d4,lsolveAll:()=>P4,lsolveAllDependencies:()=>_re,lsolveDependencies:()=>vre,lup:()=>x6,lupDependencies:()=>Mre,lusolve:()=>F6,lusolveDependencies:()=>Sre,mad:()=>V6,madDependencies:()=>Ire,magneticConstant:()=>J5,magneticConstantDependencies:()=>Ere,magneticFluxQuantum:()=>v6,magneticFluxQuantumDependencies:()=>Cre,map:()=>H2,mapDependencies:()=>kre,mapTransformDependencies:()=>Are,matrix:()=>D3,matrixDependencies:()=>w9,matrixFromColumns:()=>h4,matrixFromColumnsDependencies:()=>ine,matrixFromFunction:()=>T3,matrixFromFunctionDependencies:()=>Lre,matrixFromRows:()=>H4,matrixFromRowsDependencies:()=>$re,max:()=>h5,maxDependencies:()=>Ore,maxTransformDependencies:()=>Rre,mean:()=>A6,meanDependencies:()=>Fre,meanTransformDependencies:()=>Yre,median:()=>Y6,medianDependencies:()=>Tre,min:()=>f4,minDependencies:()=>zre,minTransformDependencies:()=>Bre,mod:()=>I3,modDependencies:()=>Zne,mode:()=>m4,modeDependencies:()=>Pre,molarMass:()=>X5,molarMassC12:()=>_6,molarMassC12Dependencies:()=>jre,molarMassDependencies:()=>Hre,molarPlanckConstant:()=>Z5,molarPlanckConstantDependencies:()=>Ure,molarVolume:()=>L6,molarVolumeDependencies:()=>qre,multinomial:()=>w6,multinomialDependencies:()=>Wre,multiply:()=>j4,multiplyDependencies:()=>hee,multiplyScalar:()=>j2,multiplyScalarDependencies:()=>oee,neutronMass:()=>Q5,neutronMassDependencies:()=>Gre,norm:()=>H6,normDependencies:()=>Kre,not:()=>U2,notDependencies:()=>L9,nthRoot:()=>E3,nthRootDependencies:()=>Jre,nthRoots:()=>g4,nthRootsDependencies:()=>Xre,nuclearMagneton:()=>e6,nuclearMagnetonDependencies:()=>Zre,nullDependencies:()=>Qre,number:()=>q2,numberDependencies:()=>X9,numeric:()=>C3,numericDependencies:()=>Z9,oct:()=>W2,octDependencies:()=>eae,ones:()=>y4,onesDependencies:()=>tae,or:()=>A3,orDependencies:()=>nae,parse:()=>Z8,parseDependencies:()=>mte,parser:()=>p9,parserDependencies:()=>aae,partitionSelect:()=>b4,partitionSelectDependencies:()=>Dre,permutations:()=>M6,permutationsDependencies:()=>iae,phi:()=>B1,phiDependencies:()=>sae,pi:()=>X1,piDependencies:()=>oae,pickRandom:()=>V2,pickRandomDependencies:()=>uae,pinv:()=>N5,pinvDependencies:()=>lae,planckCharge:()=>t6,planckChargeDependencies:()=>cae,planckConstant:()=>$6,planckConstantDependencies:()=>pae,planckLength:()=>n6,planckLengthDependencies:()=>dae,planckMass:()=>N6,planckMassDependencies:()=>hae,planckTemperature:()=>r6,planckTemperatureDependencies:()=>fae,planckTime:()=>j6,planckTimeDependencies:()=>mae,pow:()=>S5,powDependencies:()=>bee,print:()=>G2,printDependencies:()=>gae,prod:()=>L3,prodDependencies:()=>Tte,protonMass:()=>a6,protonMassDependencies:()=>yae,qr:()=>U4,qrDependencies:()=>one,quantileSeq:()=>f5,quantileSeqDependencies:()=>bae,quantumOfCirculation:()=>S6,quantumOfCirculationDependencies:()=>xae,random:()=>K2,randomDependencies:()=>vae,randomInt:()=>g3,randomIntDependencies:()=>_ae,range:()=>q4,rangeDependencies:()=>Xee,rangeTransformDependencies:()=>Mae,rationalize:()=>l9,rationalizeDependencies:()=>Nae,re:()=>J2,reDependencies:()=>une,reducedPlanckConstant:()=>i6,reducedPlanckConstantDependencies:()=>Sae,replacer:()=>Z1,replacerDependencies:()=>kae,reshape:()=>$3,reshapeDependencies:()=>Dae,resize:()=>x4,resizeDependencies:()=>Tae,resolve:()=>Q8,resolveDependencies:()=>Hte,reviver:()=>U8,reviverDependencies:()=>Iae,rightArithShift:()=>v4,rightArithShiftDependencies:()=>Eae,rightLogShift:()=>W4,rightLogShiftDependencies:()=>Cae,rotate:()=>G6,rotateDependencies:()=>Lae,rotationMatrix:()=>U6,rotationMatrixDependencies:()=>Aae,round:()=>_4,roundDependencies:()=>tee,row:()=>m5,rowDependencies:()=>$ae,rowTransformDependencies:()=>Oae,rydberg:()=>s6,rydbergDependencies:()=>Rae,sackurTetrode:()=>U1,sackurTetrodeDependencies:()=>zae,sec:()=>X2,secDependencies:()=>Bae,sech:()=>y3,sechDependencies:()=>Pae,secondRadiation:()=>k6,secondRadiationDependencies:()=>Hae,setCartesian:()=>g5,setCartesianDependencies:()=>jae,setDifference:()=>k5,setDifferenceDependencies:()=>Uae,setDistinct:()=>y5,setDistinctDependencies:()=>qae,setIntersect:()=>o6,setIntersectDependencies:()=>Wae,setIsSubset:()=>b5,setIsSubsetDependencies:()=>Vae,setMultiplicity:()=>D5,setMultiplicityDependencies:()=>Gae,setPowerset:()=>x5,setPowersetDependencies:()=>Kae,setSize:()=>V4,setSizeDependencies:()=>Jae,setSymDifference:()=>O6,setSymDifferenceDependencies:()=>Xae,setUnion:()=>z6,setUnionDependencies:()=>Zae,sign:()=>Z2,signDependencies:()=>sne,simplify:()=>a9,simplifyCore:()=>e9,simplifyCoreDependencies:()=>jte,simplifyDependencies:()=>Ute,sin:()=>Q2,sinDependencies:()=>lne,sinh:()=>b3,sinhDependencies:()=>Qae,size:()=>O3,sizeDependencies:()=>pee,slu:()=>G4,sluDependencies:()=>Nre,smaller:()=>R3,smallerDependencies:()=>Wee,smallerEq:()=>w4,smallerEqDependencies:()=>Jee,sort:()=>v5,sortDependencies:()=>eie,sparse:()=>x3,sparseDependencies:()=>tie,speedOfLight:()=>u6,speedOfLightDependencies:()=>nie,splitUnit:()=>t3,splitUnitDependencies:()=>rie,sqrt:()=>v3,sqrtDependencies:()=>Jte,sqrtm:()=>I5,sqrtmDependencies:()=>aie,square:()=>n3,squareDependencies:()=>iie,squeeze:()=>F3,squeezeDependencies:()=>sie,std:()=>W6,stdDependencies:()=>uie,stdTransformDependencies:()=>lie,stefanBoltzmann:()=>l6,stefanBoltzmannDependencies:()=>cie,stirlingS2:()=>D6,stirlingS2Dependencies:()=>Dee,string:()=>r3,stringDependencies:()=>pie,subset:()=>Y3,subsetDependencies:()=>M9,subsetTransformDependencies:()=>die,subtract:()=>z3,subtractDependencies:()=>mee,sum:()=>K4,sumDependencies:()=>are,sumTransformDependencies:()=>hie,symbolicEqual:()=>i9,symbolicEqualDependencies:()=>fie,tan:()=>a3,tanDependencies:()=>mie,tanh:()=>_3,tanhDependencies:()=>gie,tau:()=>q1,tauDependencies:()=>kne,thomsonCrossSection:()=>c6,thomsonCrossSectionDependencies:()=>yie,to:()=>B3,toDependencies:()=>bie,trace:()=>J4,traceDependencies:()=>xie,transpose:()=>P3,transposeDependencies:()=>$te,trueDependencies:()=>vie,typeOf:()=>i3,typeOfDependencies:()=>_ie,typed:()=>e2,typedDependencies:()=>y9,unaryMinus:()=>w3,unaryMinusDependencies:()=>fee,unaryPlus:()=>t2,unaryPlusDependencies:()=>Fte,unequal:()=>M4,unequalDependencies:()=>wie,unit:()=>T6,unitDependencies:()=>Mie,usolve:()=>N4,usolveAll:()=>X4,usolveAllDependencies:()=>pne,usolveDependencies:()=>cne,vacuumImpedance:()=>C5,vacuumImpedanceDependencies:()=>kie,variance:()=>B6,varianceDependencies:()=>oie,varianceTransformDependencies:()=>Die,version:()=>V1,versionDependencies:()=>Tie,weakMixingAngle:()=>n2,weakMixingAngleDependencies:()=>Iie,wienDisplacement:()=>A5,wienDisplacementDependencies:()=>Eie,xgcd:()=>H3,xgcdDependencies:()=>Qne,xor:()=>S4,xorDependencies:()=>Cie,zeros:()=>j3,zerosDependencies:()=>$9});class G{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class K{refCount(e){return J("refCount")}incRef(e){return J("incRef")}timerAvailable(){return!0}time(e){return J("time")}read(e){return J("read")}readSync(e){return J("readSync")}readToGPU(e,t){return J("readToGPU")}numDataIds(){return J("numDataIds")}disposeData(e,t){return J("disposeData")}write(e,t,n){return J("write")}move(e,t,n,r,a){return J("move")}memory(){return J("memory")}floatPrecision(){return J("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return J("dispose")}}function J(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}function X(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,te(e,t,n)}function Z(e,t){if(e.length!==t.length)throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`);let n=e.length,r=0;for(;n>0;)r=Math.random()*n|0,n--,te(e,n,r),te(t,n,r)}function Q(e,t,n){return Math.max(e,Math.min(t,n))}function ee(e){return e%2==0?e:e+1}function te(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function ne(e){let t=0;for(let n=0;nn+` Shapes ${e} and ${t} must match`))}function oe(e){ie(null!=e,(()=>"The input to the tensor constructor must be a non-null value."))}function ue(e,t=[],n=!1){if(null==t&&(t=[]),Array.isArray(e)||ke(e)&&!n)for(let r=0;r0),n){return new Promise(((r,a)=>{let i=0;const s=()=>{if(e())return void r();i++;const o=t(i);null!=n&&i>=n?a():setTimeout(s,o)};s()}))}function be(e,t){let n=1,r=-1;for(let t=0;t=0)n*=e[t];else if(-1===e[t]){if(-1!==r)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${t}`);r=t}else if(e[t]<0)throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`);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}`);const a=e.slice();return a[r]=t/n,a}function xe(e,t){const n=t.length;return e=null==e?t.map(((e,t)=>t)):[].concat(e),ie(e.every((e=>e>=-n&&e`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)),ie(e.every((e=>de(e))),(()=>`All values in axis param must be integers but got axis ${e}`)),e.map((e=>e<0?n+e:e))}function ve(e,t){const n=[],r=[],a=null!=t&&Array.isArray(t)&&0===t.length,i=null==t||a?null:xe(t,e).sort();let s=0;for(let t=0;tt)&&1===e[t]&&(n.push(e[t]),r.push(t)),i[s]<=t&&s++}1!==e[t]&&(n.push(e[t]),r.push(t))}return{newShape:n,keptDims:r}}function _e(e,t){let 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 we(e,t){let 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 Me(e,t){for(let n=0;nt+=e.length)),t}function Ie(e){return"string"==typeof e||e instanceof String}function Ee(e){return"boolean"==typeof e}function Ce(e){return"number"==typeof e}function Ae(e){return Array.isArray(e)?Ae(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":Ce(e)?"float32":Ie(e)?"string":Ee(e)?"bool":"float32"}function Le(e){return!!(e&&e.constructor&&e.call&&e.apply)}function $e(e,t){for(let n=t;n=0;--r)n[r]=n[r+1]*e[r+1];return n}function Re(e,t,n,r=!1){const a=new Array;if(1===t.length){const i=t[0]*(r?2:1);for(let t=0;te*t))*(r?2:1);for(let t=0;te*t))*(n?2:1);if(0===r)return[];if(r!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return Re(0,e,t,n)}function Ye(e,t){const n=ze(e,t);for(let e=0;ee*t),1);if(null==t||"float32"===t)return Fe(e,new Float32Array(n));if("int32"===t)return Fe(e,new Int32Array(n));if("bool"===t)return Fe(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function Pe(e){e.forEach((t=>{ie(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function He(e,t,n){if(0===t)return 0;if(1===t)return e[0];let r=e[e.length-1];for(let t=0;t{const[t,n]=e.split(":");this.urlFlags[t]=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}.`)}(t,n)}))}}function We(e){const t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((e,...n)=>(function(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}(t,n[0],n[1]),n.join("=")))),t}function Ve(){return Ke}let Ge,Ke=null;function Je(){if(null==Ge){let e;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}Ge=e}return Ge}function Xe(e,t){const n=function(){const e=Je();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(n.has(e))return n.get(e);{const r=t();return n.set(e,r),n.get(e)}}const Ze="Abs",Qe="Acos",et="Acosh",tt="Add",nt="AddN",rt="All",at="Any",it="ArgMax",st="ArgMin",ot="Asin",ut="Asinh",lt="Atan",ct="Atanh",pt="Atan2",dt="AvgPool",ht="AvgPoolGrad",ft="AvgPool3D",mt="AvgPool3DGrad",gt="BatchMatMul",yt="BatchToSpaceND",bt="Bincount",xt="BroadcastTo",vt="BroadcastArgs",_t="Cast",wt="Ceil",Mt="ClipByValue",Nt="Complex",St="ComplexAbs",kt="Concat",Dt="Conv2D",Tt="Conv2DBackpropFilter",It="Conv2DBackpropInput",Et="Conv3D",Ct="Conv3DBackpropFilterV2",At="Conv3DBackpropInputV2",Lt="Cos",$t="Cosh",Ot="Cumprod",Rt="Cumsum",Ft="CropAndResize",Yt="DenseBincount",zt="DepthToSpace",Bt="DepthwiseConv2dNative",Pt="DepthwiseConv2dNativeBackpropFilter",Ht="DepthwiseConv2dNativeBackpropInput",jt="Diag",Ut="Dilation2D",qt="Dilation2DBackpropInput",Wt="Dilation2DBackpropFilter",Vt="RealDiv",Gt="Einsum",Kt="Elu",Jt="EluGrad",Xt="Erf",Zt="Equal",Qt="Exp",en="ExpandDims",tn="Expm1",nn="FFT",rn="Fill",an="FlipLeftRight",sn="Floor",on="FloorDiv",un="FusedBatchNorm",ln="GatherV2",cn="GatherNd",pn="Greater",dn="GreaterEqual",hn="Identity",fn="IFFT",mn="Imag",gn="IsFinite",yn="IsInf",bn="IsNan",xn="LeakyRelu",vn="Less",_n="LessEqual",wn="LinSpace",Mn="Log",Nn="Log1p",Sn="LogicalAnd",kn="LogicalNot",Dn="LogicalOr",Tn="LogSoftmax",In="LowerBound",En="LRN",Cn="LRNGrad",An="Max",Ln="Maximum",$n="MaxPool",On="MaxPoolGrad",Rn="MaxPool3D",Fn="MaxPool3DGrad",Yn="MaxPoolWithArgmax",zn="Mean",Bn="Min",Pn="Minimum",Hn="MirrorPad",jn="Mod",Un="Multinomial",qn="Multiply",Wn="Neg",Vn="NotEqual",Gn="NonMaxSuppressionV3",Kn="NonMaxSuppressionV4",Jn="NonMaxSuppressionV5",Xn="OnesLike",Zn="OneHot",Qn="Pack",er="PadV2",tr="Pool",nr="Pow",rr="Prelu",ar="Prod",ir="Range",sr="Real",or="Reciprocal",ur="Relu",lr="Reshape",cr="ResizeNearestNeighbor",pr="ResizeNearestNeighborGrad",dr="ResizeBilinear",hr="ResizeBilinearGrad",fr="Relu6",mr="Reverse",gr="Round",yr="Rsqrt",br="ScatterNd",xr="SearchSorted",vr="Select",_r="Selu",wr="Slice",Mr="Sin",Nr="Sinh",Sr="Sign",kr="Sigmoid",Dr="Softplus",Tr="Sqrt",Ir="Sum",Er="SpaceToBatchND",Cr="SplitV",Ar="Softmax",Lr="SparseFillEmptyRows",$r="SparseReshape",Or="SparseSegmentMean",Rr="SparseSegmentSum",Fr="SparseToDense",Yr="SquaredDifference",zr="Square",Br="StridedSlice",Pr="StringNGrams",Hr="StringSplit",jr="StringToHashBucketFast",Ur="Sub",qr="Tan",Wr="Tanh",Vr="Tile",Gr="TopK",Kr="Transform",Jr="Transpose",Xr="Unique",Zr="Unpack",Qr="UnsortedSegmentSum",ea="UpperBound",ta="ZerosLike",na="Step",ra="FromPixels",aa="RotateWithOffset",ia="_FusedMatMul",sa="FusedConv2D",oa="FusedDepthwiseConv2D";function ua(...e){Ve().getBool("IS_TEST")||Ve().getBool("PROD")||console.warn(...e)}function la(...e){Ve().getBool("IS_TEST")||Ve().getBool("PROD")||console.log(...e)}const ca=Xe("kernelRegistry",(()=>new Map)),pa=Xe("gradRegistry",(()=>new Map));function da(e,t){const n=va(e,t);return ca.get(n)}function ha(e){return pa.get(e)}function fa(e){const t=ca.entries(),n=[];for(;;){const{done:r,value:a}=t.next();if(r)break;const[i,s]=a,[o]=i.split("_");o===e&&n.push(s)}return n}function ma(e){const{kernelName:t,backendName:n}=e,r=va(t,n);ca.has(r)&&ua(`The kernel '${t}' for backend '${n}' is already registered`),ca.set(r,e)}function ga(e){const{kernelName:t}=e;pa.has(t)&&Ve().getBool("DEBUG")&&ua(`Overriding the gradient for '${t}'`),pa.set(t,e)}function ya(e,t){const n=va(e,t);if(!ca.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);ca.delete(n)}function ba(e){if(!pa.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);pa.delete(e)}function xa(e,t){fa(e).forEach((e=>{ma(Object.assign({},e,{backendName:t}))}))}function va(e,t){return`${t}_${e}`}var _a=n(3720);const wa=n.n(_a)()||_a;function Ma(e){return wa.fromString(e,!0,16)}const Na=Ma("c3a5c85c97cb3127"),Sa=Ma("b492b66fbe98f273"),ka=Ma("9ae16a3b2f90404f");function Da(e){return e.xor(e.shru(47))}function Ta(e,t,n){const r=e.slice(t,t+n);return wa.fromBytes(Array.from(r),!0,!0)}function Ia(e,t){return Ta(e,t,8)}function Ea(e,t){return Ta(e,t,4)}function Ca(e,t){return 0===t?e:e.shru(t).or(e.shl(64-t))}function Aa(e,t,n=Ma("9ddfea08eb382d69")){let r=e.xor(t).mul(n);r=r.xor(r.shru(47));let a=t.xor(r).mul(n);return a=a.xor(a.shru(47)),a=a.mul(n),a}function La(e,t,n,r){return function(e,t,n,r,a,i){a=a.add(e),i=Ca(i.add(a).add(r),21);const s=a;return a=(a=a.add(t)).add(n),i=i.add(Ca(a,44)),[a.add(r),i.add(s)]}(Ia(e,t),Ia(e,t+8),Ia(e,t+16),Ia(e,t+24),n,r)}function $a(e,t=e.length){const n=wa.fromNumber(81,!0);if(t<=32)return t<=16?function(e,t=e.length){if(t>=8){const n=ka.add(2*t),r=Ia(e,0).add(ka),a=Ia(e,t-8);return Aa(Ca(a,37).mul(n).add(r),Ca(r,25).add(a).mul(n),n)}if(t>=4){const n=ka.add(2*t);return Aa(Ea(e,0).shl(3).add(t),Ea(e,t-4),n)}if(t>0){const n=e[0]+(e[t>>1]<<8),r=t+(e[t-1]<<2);return Da(ka.mul(n).xor(Na.mul(r))).mul(ka)}return ka}(e,t):function(e,t=e.length){const n=ka.add(2*t),r=Ia(e,0).mul(Sa),a=Ia(e,8),i=Ia(e,t-8).mul(n),s=Ia(e,t-16).mul(ka);return Aa(Ca(r.add(a),43).add(Ca(i,30)).add(s),r.add(Ca(a.add(ka),18)).add(i),n)}(e,t);if(t<=64)return function(e,t=e.length){const n=ka.add(2*t),r=Ia(e,0).mul(ka),a=Ia(e,8),i=Ia(e,t-8).mul(n),s=Ia(e,t-16).mul(ka),o=Ca(r.add(a),43).add(Ca(i,30)).add(s),u=Aa(o,r.add(Ca(a.add(ka),18)).add(i),n),l=Ia(e,16).mul(n),c=Ia(e,24),p=o.add(Ia(e,t-32)).mul(n),d=u.add(Ia(e,t-24)).mul(n);return Aa(Ca(l.add(c),43).add(Ca(p,30)).add(d),l.add(Ca(c.add(r),18)).add(p),n)}(e,t);let r=n,a=n.mul(Sa).add(113),i=Da(a.mul(ka).add(113)).mul(ka),s=[wa.UZERO,wa.UZERO],o=[wa.UZERO,wa.UZERO];r=r.mul(ka).add(Ia(e,0));let u=0;const l=64*(t-1>>6),c=l+(t-1&63)-63;do{r=Ca(r.add(a).add(s[0]).add(Ia(e,u+8)),37).mul(Sa),a=Ca(a.add(s[1]).add(Ia(e,u+48)),42).mul(Sa),r=r.xor(o[1]),a=a.add(s[0]).add(Ia(e,u+40)),i=Ca(i.add(o[0]),33).mul(Sa),s=La(e,u,s[1].mul(Sa),r.add(o[0])),o=La(e,u+32,i.add(o[1]),a.add(Ia(e,u+16))),[i,r]=[r,i],u+=64}while(u!==l);const p=Sa.add(i.and(255).shl(1));return u=c,o[0]=o[0].add(t-1&63),s[0]=s[0].add(o[0]),o[0]=o[0].add(s[0]),r=Ca(r.add(a).add(s[0]).add(Ia(e,u+8)),37).mul(p),a=Ca(a.add(s[1]).add(Ia(e,u+48)),42).mul(p),r=r.xor(o[1].mul(9)),a=a.add(s[0].mul(9).add(Ia(e,u+40))),i=Ca(i.add(o[0]),33).mul(p),s=La(e,u,s[1].mul(p),r.add(o[0])),o=La(e,u+32,i.add(o[1]),a.add(Ia(e,u+16))),[i,r]=[r,i],Aa(Aa(s[0],o[0],p).add(Da(a).mul(Na)).add(i),Aa(s[1],o[1],p).add(r),p)}function Oa(e,t){return"string"===t?za(e):Ra([e],t)}function Ra(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=ue(e)),Ve().getBool("DEBUG")&&Me(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){const t=new Uint8Array(e.length);for(let n=0;n{r=n()};let i;const s=Fa();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(a);else{a();for(const e of r)e.dataSync();i=Promise.resolve({kernelMs:Fa()-s})}if(Ve().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t{Ha(t,n.dtype,e)}))}return{kernelName:e,outputs:r,inputs:t,timeMs:i.then((e=>e.kernelMs)),extraInfo:i.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:r,inputs:a,extraInfo:i}=e;n.forEach((e=>{Promise.all([e.data(),r,i]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],a,n[2])}))}))}}function Ha(e,t,n){if("float32"!==t)return!1;for(let t=0;t0?r:""} `}}console.log(`%c${o}\t%c${s}\t%c${u}D ${c}\t%c${l}\t%c${p}\t%c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}function Ua(e,t,n,r){const a=Oe(t),i=function(e,t,n,r){const a=le(t),i=r[r.length-1],s=new Array(i).fill(0),o=t.length,u="complex64"===n?Ga(e):e;if(o>1)for(let e=0;e" "+e)).join("\n")),u.join("\n")}function qa(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(7))} + ${parseFloat(e[1].toFixed(7))}j`:Ie(e)?`'${e}'`:"bool"===n?Wa(e):parseFloat(e.toFixed(7)).toString(),ge(r,t)}function Wa(e){return 0===e?"false":"true"}function Va(e,t,n,r,a,i=!0){const s="complex64"===n?2:1,o=t[0],u=t.length;if(0===u)return"complex64"===n?[qa(Ga(e)[0],0,n)]:"bool"===n?[Wa(e[0])]:[e[0].toString()];if(1===u){if(o>20){const t=3*s;let r=Array.from(e.slice(0,t)),i=Array.from(e.slice((o-3)*s,o*s));return"complex64"===n&&(r=Ga(r),i=Ga(i)),["["+r.map(((e,t)=>qa(e,a[t],n))).join(", ")+", ..., "+i.map(((e,t)=>qa(e,a[o-3+t],n))).join(", ")+"]"]}return["["+("complex64"===n?Ga(e):Array.from(e)).map(((e,t)=>qa(e,a[t],n))).join(", ")+"]"]}const l=t.slice(1),c=r.slice(1),p=r[0]*s,d=[];if(o>20){for(let t=0;t<3;t++){const r=t*p,i=r+p;d.push(...Va(e.slice(r,i),l,n,c,a,!1))}d.push("...");for(let t=o-3;t`Length of values '${e}' does not match the size inferred by the shape '${this.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||we(t,this.size),this.strides=Oe(e)}set(e,...t){0===t.length&&(t=[0]),ie(t.length===this.rank,(()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`));const n=this.locToIndex(t);this.values[n]=e}get(...e){0===e.length&&(e=[0]);let t=0;for(const n of e){if(n<0||n>=this.shape[t]){const t=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(t)}t++}let n=e[e.length-1];for(let t=0;tBa(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}dataToGPU(e){return this.throwIfDisposed(),Ja().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=Ja().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>Ba(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}async bytes(){this.throwIfDisposed();const e=await Ja().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(Ja().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Xa.print(this,e)}clone(){return this.throwIfDisposed(),Xa.clone(this)}toString(e=!1){return Ua(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Xa.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),Ja().makeVariable(this,e,t,n)}}function ei(){return Xe("Tensor",(()=>Qa))}Object.defineProperty(Qa,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),ei();class ti extends Qa{constructor(e,t,n,r){super(e.shape,e.dtype,e.dataId,r),this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!pe(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Ja().disposeTensor(this),this.dataId=e.dataId,Ja().incRef(this,null)}dispose(){Ja().disposeVariable(this),this.isDisposedInternal=!0}}var ni,ri,ai,ii,si;Object.defineProperty(ti,Symbol.hasInstance,{value:e=>e instanceof Qa&&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"}(ni||(ni={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(ri||(ri={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(ai||(ai={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(ii||(ii={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(si||(si={}));const oi={float32:ii,int32:ri,bool:ai,complex64:si};function ui(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return oi[e][t]}function li(e){return ui(e,"int32")}function ci(e,t){if(e.dtype===t.dtype)return[e,t];const n=ui(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function pi(e,t){ie(e.dtype===t.dtype,(()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`))}function di(e,t){return t.some((t=>t.id===e.id))}function hi(e){const t=[];return fi(e,t,new Set),t}function fi(e,t,n){if(null==e)return;if(e instanceof Qa)return void t.push(e);if(r=e,!Array.isArray(r)&&"object"!=typeof r)return;var r;const a=e;for(const e in a){const r=a[e];n.has(r)||(n.add(r),fi(r,t,n))}}function mi(e){return null!=e.kernelName}class gi{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map((e=>e.name))))}}}dispose(){for(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class yi{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new gi}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const e=this.getSortedBackends();for(let t=0;t{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){fa(e).forEach((t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])}))}initializeBackend(e){const t=this.registryFactory[e];if(null==t)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const n=t.factory();if(!n||n instanceof K||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,r=n.then((n=>!(t(tthis.registryFactory[t].priority-this.registryFactory[e].priority))}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;tthis.startScope(r)),(()=>this.endScope(n)),(()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(e,t,n){e();try{const e=n();return t(),e}catch(e){throw t(),e}}nextTensorId(){return yi.nextTensorId++}nextVariableId(){return yi.nextVariableId++}clone(e){const t=xi.runKernel(hn,{x:e}),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],(e=>({x:()=>{const t={x:e};return xi.runKernel(_t,t,{dtype:"float32"})}})),[],{}),t}runKernel(e,t,n){if(null==this.backendName&&this.backend,null==da(e,this.backendName))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){const r=this.backend.numDataIds();let a=0;n.forEach((e=>{a+="complex64"===e.dtype?3:1}));const i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],s=r-t-a-i;if(s>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${s} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const r=this.isTapeOn(),a=this.state.numBytes,i=this.state.numTensors;let s,o;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;const u=mi(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(mi(e)){const{kernelName:t,inputs:a,attrs:i}=e;null==this.backendName&&this.backend;const u=da(t,this.backendName);ie(null!=u,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),s=()=>{const e=this.backend.numDataIds();o=u.kernelFunc({inputs:a,attrs:i,backend:this.backend});const s=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,s);const l=s.map((e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e)));if(r){const e=this.getTensorsForGradient(t,a,l);n=this.saveTensorsForBackwardMode(e)}return l}}else{const{forwardFunc:t}=e,a=e=>{r&&(n=e.map((e=>this.keep(this.clone(e)))))};s=()=>{const e=this.backend.numDataIds();o=this.tidy((()=>t(this.backend,a)));const n=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(u,e,n),n}}const{inputs:l,attrs:c}=e,p=mi(e)?null:e.backwardsFunc;let d;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(d=this.profiler.profileKernel(u,l,(()=>s())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(d),t=d.outputs):t=s()})),r&&this.addTapeNode(u,l,t,p,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:u,bytesAdded:this.state.numBytes-a,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(l).map((e=>null!=l[e]?l[e].shape:null)),outputShapes:t.map((e=>e.shape)),kernelTimeMs:d.timeMs,extraInfo:d.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){const t=e.map((e=>this.keep(this.clone(e))));return t}getTensorsForGradient(e,t,n){const r=ha(e);if(null!=r){const e=r.inputsToSave||[],a=r.outputsToSave||[];let i;r.saveAllInputs?(ie(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),i=Object.keys(t).map((e=>t[e]))):i=e.map((e=>t[e]));const s=n.filter(((e,t)=>a[t]));return i.concat(s)}return[]}makeTensor(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;let a=e;"string"===n&&Ie(e[0])&&(a=e.map((e=>za(e))));const i=r.write(a,t,n),s=new Qa(t,n,i,this.nextTensorId());if(this.trackTensor(s,r),"string"===n){const e=this.state.tensorInfo.get(i),t=Te(a);this.state.numBytes+=t-e.bytes,e.bytes=t}return s}makeTensorFromDataId(e,t,n,r){const a={dataId:e,shape:t,dtype:n=n||"float32"};return this.makeTensorFromTensorInfo(a,r)}makeTensorFromTensorInfo(e,t){const{dataId:n,shape:r,dtype:a}=e,i=new Qa(r,a,n,this.nextTensorId());return this.trackTensor(i,t),i}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));const a=new ti(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw new Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*De(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof ti||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){const t=e.size*De(e.dtype);this.state.numBytes-=t}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]}memory(){const e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;const t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map((e=>e.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const e of this.state.activeProfile.kernels)e.kernelTimeMs=await e.kernelTimeMs,e.extraInfo=await e.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(e,t,n,r,a,i){const s={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},o=ha(e);null!=o&&(r=o.gradFunc),null!=r&&(s.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=ze(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],a,i))),this.state.activeTape.push(s)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=hi(e),n=new Set(t.map((e=>e.id)));for(let e=0;e{e.kept||e.scopeId!==r.id||this.track(e)}))}gradients(e,t,n,r=!1){if(ie(t.length>0,(()=>"gradients() received an empty list of xs.")),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const a=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));ie(a instanceof Qa,(()=>"The result y returned by f() must be a tensor."));const i=function(e,t,n){const r={},a={};for(let e=0;er[e.id]=!0)),o=!0,a[i.id]=!0;break}if(o)break}}const i={};i[n.id]=!0;const s={};for(let t=e.length-1;t>=0;t--){const n=e[t],r=n.inputs;for(let e=0;e0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",(()=>{const e={};e[a.id]=null==n?function(e){const t=Ye(le(e),"float32");return xi.makeTensor(t,e,"float32")}(a.shape):n,function(e,t,n,r){for(let a=t.length-1;a>=0;a--){const i=t[a],s=[];if(i.outputs.forEach((t=>{const n=e[t.id];null!=n?s.push(n):s.push(null)})),null==i.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${i.kernelName}.`);const o=i.gradient(s);for(const t in i.inputs){if(!(t in o))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(o)}.`);const a=n((()=>o[t]()));if("float32"!==a.dtype)throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${a.dtype}'`);const s=i.inputs[t];if(!pe(a.shape,s.shape))throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input '${t}' has shape '${a.shape}', which does not match the shape of the input '${s.shape}'`);if(null==e[s.id])e[s.id]=a;else{const t=e[s.id];e[s.id]=r(t,a),t.dispose()}}}}(e,i,(e=>this.tidy(e)),vi);const r=t.map((t=>e[t.id]));return 0===this.state.gradientDepth&&(this.state.activeTape.forEach((e=>{for(const t of e.saved)t.dispose()})),this.state.activeTape=null),{value:a,grads:r}}))}customGrad(e){return ie(Le(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;ie(t.every((e=>e instanceof Qa)),(()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors"));const r={};return t.forEach(((e,t)=>{r[t]=e})),this.runKernelFunc({forwardFunc:(r,a)=>(n=e(...t,a),ie(n.value instanceof Qa,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),ie(Le(n.gradFunc),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")),n.value),backwardsFunc:(e,r)=>{const a=n.gradFunc(e,r),i=Array.isArray(a)?a:[a];ie(i.length===t.length,(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).")),ie(i.every((e=>e instanceof Qa)),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."));const s={};return i.forEach(((e,t)=>{s[t]=()=>e})),s},inputs:r})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){const t=Fa(),n=await this.backend.time(e);return n.wallMs=Fa()-t,n}track(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new gi;for(const e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function bi(){const e=Je();if(null==e._tfengine){const t=new qe(e);e._tfengine=new yi(t)}var t;return t=e._tfengine.ENV,Ke=t,Ja=()=>e._tfengine,e._tfengine}yi.nextTensorId=0,yi.nextVariableId=0;const xi=bi();function vi(e,t){const n={a:e,b:t};return xi.runKernel(tt,n)}let _i;function wi(e){_i=e}function Mi(e){if(void 0!==_i)return _i;if(e||"undefined"!=typeof navigator&&null!=navigator){if(e||(e=navigator),"ReactNative"===e.product)return!0;const t=e.userAgent||e.vendor||("undefined"!=typeof window?window.opera:"");if(!t){const t=e;return t.userAgentData&&t.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}function Ni(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}const Si=Ve();function ki(e,t){let n=e;if(ke(e))return"string"===t?[]:[e.length];if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||ke(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&Ve().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&Di(e,r,[]),r}function Di(e,t,n){if(n=n||[],!Array.isArray(e)&&!ke(e))return void ie(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));ie(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),ie(e.length===t[0],(()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`));const r=t.slice(1);for(let t=0;t=0&&(a=r),Ti(r,a,t,n),null==e||!ke(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){const r=null==e?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${r}'`)}const i=ki(e,a);ke(e)||Array.isArray(e)||(e=[e]);const s="string"!==a?Ra(e,a):ue(e,[],!0);return xi.makeTensor(s,i,a)}function Ei(e,t,n,r="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map(((e,a)=>Ii(e,`${t}[${a}]`,n,r)))}Si.registerFlag("DEBUG",(()=>!1),(e=>{e&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")})),Si.registerFlag("IS_BROWSER",(()=>Ni())),Si.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),Si.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),Si.registerFlag("PROD",(()=>!1)),Si.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>Si.getBool("DEBUG"))),Si.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),Si.registerFlag("IS_TEST",(()=>!1)),Si.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>!0)),Si.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),Si.registerFlag("ENGINE_COMPILE_ONLY",(()=>!1));const Ci="__op";function Ai(e){const 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.`);let n=t[0];const r=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=Ci;const a=(...e)=>{xi.startScope(n);try{const t=r(...e);return Ue(t)&&console.error("Cannot return a Promise inside of tidy."),xi.endScope(t),t}catch(e){throw xi.endScope(null),e}};return Object.defineProperty(a,"name",{value:n,configurable:!0}),a}const Li=Ai({complex_:function(e,t){const n=Ii(e,"real","complex"),r=Ii(t,"imag","complex");se(n.shape,r.shape,`real and imag shapes, ${n.shape} and ${r.shape}, must match in call to tf.complex().`);const a={real:n,imag:r};return xi.runKernel(Nt,a)}});function $i(e,t,n,r){if(null==r&&(r=Ae(e)),"complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!ke(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){Pe(t);const e=le(t),r=le(n);ie(e===r,(()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${r}`));for(let e=0;e`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return ke(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?Ra(e,r):ue(e,[],!0),xi.makeTensor(e,t,r)}function Oi(e,t,n){return $i(e,t,ki(e,n),n)}const Ri={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};async function Fi(e,t){const n=[],r=[],a=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);for(let i=0;i{const t=await o.bytes(),n=t.reduce(((e,t)=>e+t.length),0)+4*t.length,r=new Uint8Array(n);let a=0;for(let e=0;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}`)}));const r=new Uint8Array(t);let a=0;return n.forEach((e=>{r.set(new Uint8Array(e.buffer),a),a+=e.byteLength})),r.buffer}const Bi="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function Pi(e){return Bi?Buffer.byteLength(e):new Blob([e]).size}function Hi(e){if(1===e.length)return e[0];let t=0;e.forEach((e=>{t+=e.byteLength}));const n=new Uint8Array(t);let r=0;return e.forEach((e=>{n.set(new Uint8Array(e),r),r+=e.byteLength})),n.buffer}function ji(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);const t=e.split("/");return t[t.length-1]}function Ui(e,t){const n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),n}async function qi(e,t){const n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),null!=e.weightsManifest){const[r,a]=await t(e.weightsManifest);n.weightSpecs=r,n.weightData=a}return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),n}function Wi(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:Pi(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:Pi(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:e.weightData.byteLength}}function Vi(){const e=function(){const e=e=>{let t=e<<13,n=0;for(;0==(8388608&t);)n-=8388608,t<<=1;return t&=-8388609,n+=947912704,t|n},t=new Uint32Array(2048);t[0]=0;for(let n=1;n<1024;n++)t[n]=e(n);for(let e=1024;e<2048;e++)t[e]=939524096+(e-1024<<13);return t}(),t=function(){const e=new Uint32Array(64);e[0]=0,e[31]=1199570944,e[32]=2147483648,e[63]=3347054592;for(let t=1;t<31;t++)e[t]=t<<23;for(let t=33;t<63;t++)e[t]=2147483648+(t-32<<23);return e}(),n=function(){const e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}();return r=>{const a=new ArrayBuffer(4*r.length),i=new Uint32Array(a);for(let a=0;a>10]+(1023&s)]+t[s>>10];i[a]=o}return new Float32Array(a)}}class Gi{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==Gi.instance&&(Gi.instance=new Gi),Gi.instance}static registerSaveRouter(e){Gi.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Gi.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Gi.getHandlers(e,"save")}static getLoadHandlers(e,t){return Gi.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?Gi.getInstance().loadRouters:Gi.getInstance().saveRouters).forEach((t=>{const a=t(e,n);null!==a&&r.push(a)})),r}}const Ki=e=>Gi.registerSaveRouter(e),Ji=e=>Gi.registerLoadRouter(e),Xi=e=>Gi.getSaveHandlers(e),Zi=(e,t)=>Gi.getLoadHandlers(e,t),Qi="tensorflowjs",es="models_store",ts="model_info_store";function ns(){if(!Ve().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self: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 rs(e){const t=e.result;t.createObjectStore(es,{keyPath:"modelPath"}),t.createObjectStore(ts,{keyPath:"modelPath"})}class as{constructor(e){if(this.indexedDB=ns(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise(((e,n)=>{const r=this.indexedDB.open(Qi,1);r.onupgradeneeded=()=>rs(r),r.onsuccess=()=>{const a=r.result;if(null==t){const t=a.transaction(es,"readonly"),r=t.objectStore(es).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return a.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(a.close(),n(r.error)),t.oncomplete=()=>a.close()}else{const r=Wi(t),i=a.transaction(ts,"readwrite");let s=i.objectStore(ts);const o=s.put({modelPath:this.modelPath,modelArtifactsInfo:r});let u;o.onsuccess=()=>{u=a.transaction(es,"readwrite");const o=u.objectStore(es).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r});o.onsuccess=()=>e({modelArtifactsInfo:r}),o.onerror=e=>{s=i.objectStore(ts);const t=s.delete(this.modelPath);t.onsuccess=()=>(a.close(),n(o.error)),t.onerror=e=>(a.close(),n(o.error))}},o.onerror=e=>(a.close(),n(o.error)),i.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}}},r.onerror=e=>n(r.error)}))}}as.URL_SCHEME="indexeddb://";const is=e=>{return Ve().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(as.URL_SCHEME)?(t=e.slice(as.URL_SCHEME.length),new as(t)):null;var t};Gi.registerSaveRouter(is),Gi.registerLoadRouter(is);class ss{constructor(){this.indexedDB=ns()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(Qi,1);n.onupgradeneeded=()=>rs(n),n.onsuccess=()=>{const r=n.result,a=r.transaction(ts,"readonly"),i=a.objectStore(ts).getAll();i.onsuccess=()=>{const t={};for(const e of i.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},i.onerror=e=>(r.close(),t(i.error)),a.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(as.URL_SCHEME)?t.slice(as.URL_SCHEME.length):t,new Promise(((t,n)=>{const r=this.indexedDB.open(Qi,1);r.onupgradeneeded=()=>rs(r),r.onsuccess=()=>{const a=r.result,i=a.transaction(ts,"readwrite"),s=i.objectStore(ts),o=s.get(e);let u;o.onsuccess=()=>{if(null==o.result)return a.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=s.delete(e),i=()=>{u=a.transaction(es,"readwrite");const r=u.objectStore(es).delete(e);r.onsuccess=()=>t(o.result.modelArtifactsInfo),r.onerror=e=>n(o.error)};r.onsuccess=i,r.onerror=e=>(i(),a.close(),n(o.error))}},o.onerror=e=>(a.close(),n(o.error)),i.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}},r.onerror=e=>n(r.error)}))}}const os="/",us="tensorflowjs_models",ls="info",cs="model_topology",ps="weight_specs",ds="weight_data",hs="model_metadata";function fs(e){return{info:[us,e,ls].join(os),topology:[us,e,cs].join(os),weightSpecs:[us,e,ps].join(os),weightData:[us,e,ds].join(os),modelMetadata:[us,e,hs].join(os)}}function ms(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function gs(e){const t=e.split(os);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(os)}class ys{constructor(e){if(!Ve().getBool("IS_BROWSER")||"undefined"==typeof window||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=fs(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),r=Wi(e);try{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,function(e){if(Bi)return Buffer.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,r=t.length;e{return Ve().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(ys.URL_SCHEME)?(t=e.slice(ys.URL_SCHEME.length),new ys(t)):null;var t};Gi.registerSaveRouter(bs),Gi.registerLoadRouter(bs);class xs{constructor(){ie(Ve().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),ie("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=us+os,n=os+ls;for(let r=0;r"scheme must not be undefined or null.")),e.endsWith(vs)&&(e=e.slice(0,e.indexOf(vs))),ie(e.length>0,(()=>"scheme must not be an empty string."));const n=_s.getInstance();ie(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=this.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(this.getInstance().managers)}}function ws(e){if(-1===e.indexOf(vs))throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${_s.getSchemes().join(",")}`);return{scheme:e.split(vs)[0],path:e.split(vs)[1]}}async function Ms(e,t,n=!1){ie(e!==t,(()=>`Old path and new path are the same: '${e}'`));const r=Gi.getLoadHandlers(e);ie(r.length>0,(()=>`Copying failed because no load handler is found for source URL ${e}.`)),ie(r.length<2,(()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`));const a=r[0],i=Gi.getSaveHandlers(t);ie(i.length>0,(()=>`Copying failed because no save handler is found for destination URL ${t}.`)),ie(i.length<2,(()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`));const s=i[0],o=ws(e).scheme,u=ws(e).path,l=o===ws(e).scheme,c=await a.load();n&&l&&await _s.getManager(o).removeModel(u);const p=await s.save(c);return n&&!l&&await _s.getManager(o).removeModel(u),p.modelArtifactsInfo}async function Ns(){const e=_s.getSchemes(),t={};for(const n of e){const e=await _s.getManager(n).listModels();for(const r in e)t[n+vs+r]=e[r]}return t}async function Ss(e){const t=ws(e);return _s.getManager(t.scheme).removeModel(t.path)}async function ks(e,t){return Ms(e,t,!1)}async function Ds(e,t){return Ms(e,t,!0)}class Ts{fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(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)}decode(e,t){return new TextDecoder(t).decode(e)}}if(Ve().get("IS_BROWSER")){Ve().setPlatform("browser",new Ts);try{_s.registerManager(ys.URL_SCHEME,new xs)}catch(e){}try{_s.registerManager(as.URL_SCHEME,new ss)}catch(e){}}let Is;function Es(e,t="float32",n){return t=t||"float32",Pe(e),new Ka(e,t,n)}Ve().get("IS_NODE")&&!Ve().get("IS_BROWSER")&&Ve().setPlatform("node",new class{constructor(){this.util=n(8628),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=Ve().global.fetch?Ve().global.fetch(e,t):(null==Is&&(Is=n(5410)),Is(e,t))}now(){const e=process.hrtime();return 1e3*e[0]+e[1]/1e6}encode(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)}decode(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)}});const Cs=Ai({cast_:function(e,t){const n=Ii(e,"x","cast");if(!Ne(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");const r={x:n},a={dtype:t};return xi.runKernel(_t,r,a)}}),As=Ai({clone_:function(e){const t={x:Ii(e,"x","clone","string_or_numeric")};return xi.runKernel(hn,t)}});function Ls(e,t=!1){console.log(e.toString(t))}function $s(e){return new Promise((e=>setTimeout(e))).then(e)}bi(),Xa={buffer:Es,cast:Cs,clone:As,print:Ls};class Os{constructor(e){if(!Ve().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Os.URL_SCHEME)&&(e=e.slice(Os.URL_SCHEME.length)),null!=e&&0!==e.length||(e="model"),this.modelJsonFileName=e+".json",this.weightDataFileName=e+".weights.bin"}async save(e){if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");const t=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"}));if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{const n=Ui(e,[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}]),r=window.URL.createObjectURL(new Blob([JSON.stringify(n)],{type:"application/json"})),a=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor;if(a.download=this.modelJsonFileName,a.href=r,await $s((()=>a.dispatchEvent(new MouseEvent("click")))),null!=e.weightData){const e=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;e.download=this.weightDataFileName,e.href=t,await $s((()=>e.dispatchEvent(new MouseEvent("click"))))}return{modelArtifactsInfo:Wi(e)}}}}Os.URL_SCHEME="downloads://";class Rs{constructor(e){if(null==e||e.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise(((e,t)=>{const n=new FileReader;n.onload=n=>{const r=JSON.parse(n.target.result),a=r.modelTopology;if(null==a)return void t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));if(null==r.weightsManifest)return void t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));if(0===this.weightsFiles.length)return void e({modelTopology:a});const i=qi(r,(e=>this.loadWeights(e)));e(i)},n.onerror=e=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),n.readAsText(this.jsonFile)}))}loadWeights(e){const t=[],n=[];for(const r of e)t.push(...r.weights),n.push(...r.paths);const r=this.checkManifestAndWeightFiles(e),a=n.map((e=>this.loadWeightsFile(e,r[e])));return Promise.all(a).then((e=>[t,Hi(e)]))}loadWeightsFile(e,t){return new Promise(((n,r)=>{const a=new FileReader;a.onload=e=>{const t=e.target.result;n(t)},a.onerror=t=>r(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)}))}checkManifestAndWeightFiles(e){const t=[],n=this.weightsFiles.map((e=>ji(e.name))),r={};for(const a of e)a.paths.forEach((e=>{const a=ji(e);if(-1!==t.indexOf(a))throw new Error(`Duplicate file basename found in weights manifest: '${a}'`);if(t.push(a),-1===n.indexOf(a))throw new Error(`Weight file with basename '${a}' is not provided.`);r[e]=this.weightsFiles[n.indexOf(a)]}));if(t.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return r}}function Fs(e){return new Rs(e)}function Ys(e,t,n,r){!function(e){ie(null!=e&&Array.isArray(e)&&e.length>0,(()=>"promises must be a none empty array"))}(e),function(e,t){ie(e>=0&&e<=1,(()=>`Progress fraction must be in range [0, 1], but got startFraction ${e}`)),ie(t>=0&&t<=1,(()=>`Progress fraction must be in range [0, 1], but got endFraction ${t}`)),ie(t>=e,(()=>`startFraction must be no more than endFraction, but got startFraction ${e} and endFraction ${t}`))}(n=null==n?0:n,r=null==r?1:r);let a=0;return Promise.all(e.map((i=>(i.then((i=>{const s=n+ ++a/e.length*(r-n);return t(s),i})),i))))}async function zs(e,t){null==t&&(t={});const n=null==t.fetchFunc?Ve().platform.fetch:t.fetchFunc,r=e.map((e=>n(e,t.requestInit,{isBinary:!0}))),a=(null==t.onProgress?await Promise.all(r):await Ys(r,t.onProgress,0,.5)).map((e=>e.arrayBuffer()));return null==t.onProgress?await Promise.all(a):await Ys(a,t.onProgress,.5,1)}async function Bs(e,t="",n,r){return Ps((e=>zs(e,{requestInit:r})))(e,t,n)}function Ps(e){return async(t,n="",r)=>{const a=t.map((()=>!1)),i={},s=null!=r?r.map((()=>!1)):[],o=[];if(t.forEach(((e,t)=>{let n=0;e.weights.forEach((e=>{const u="quantization"in e?e.quantization.dtype:e.dtype,l=Ri[u]*le(e.shape),c=()=>{a[t]=!0,null==i[t]&&(i[t]=[]),i[t].push({manifestEntry:e,groupOffset:n,sizeBytes:l})};null!=r?r.forEach(((t,n)=>{t===e.name&&(c(),s[n]=!0)})):c(),o.push(e.name),n+=l}))})),!s.every((e=>e))){const e=r.filter(((e,t)=>!s[t]));throw new Error(`Could not find weights in manifest with names: ${e.join(", ")}. \nManifest JSON has weights with names: ${o.join(", ")}.`)}const u=a.reduce(((e,t,n)=>(t&&e.push(n),e)),[]),l=[];u.forEach((e=>{t[e].paths.forEach((e=>{const t=n+(n.endsWith("/")?"":"/")+e;l.push(t)}))}));const c=await e(l),p={};let d=0;return u.forEach((e=>{const n=t[e].paths.length;let r=0;for(let e=0;e{const t=Yi(a.slice(e.groupOffset,e.groupOffset+e.sizeBytes),[e.manifestEntry]);for(const e in t)p[e]=t[e]})),d+=n})),p}}Gi.registerSaveRouter((e=>Ve().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Os.URL_SCHEME)?function(e="model"){return new Os(e)}(e.slice(Os.URL_SCHEME.length)):null));class Hs{constructor(e,t){if(this.DEFAULT_METHOD="POST",null==t&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,null!=t.fetchFunc?(ie("function"==typeof t.fetchFunc,(()=>"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=Ve().platform.fetch,ie(null!=e&&e.length>0,(()=>"URL path for http must not be null, undefined or empty.")),Array.isArray(e)&&ie(2===e.length,(()=>`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||{}}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;const n=Ui(e,[{paths:["./model.weights.bin"],weights:e.weightSpecs}]);t.body.append("model.json",new Blob([JSON.stringify(n)],{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");const r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Wi(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async load(){const e=await this.fetch(this.path,this.requestInit);if(!e.ok)throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`);let t;try{t=await e.json()}catch(e){let t=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?t+=" 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.":t+=" Please make sure the server is serving valid JSON for this request.",new Error(t)}const n=t.modelTopology,r=t.weightsManifest;if(null==n&&null==r)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return qi(t,(e=>this.loadWeights(e)))}async loadWeights(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[n,r]=function(e){const t=e.lastIndexOf("/"),n=e.lastIndexOf("?");return[e.substring(0,t)+"/",n>t?e.substring(n):""]}(t),a=this.weightPathPrefix||n,i=[];for(const t of e)i.push(...t.weights);const s=[],o=[];for(const t of e)for(const e of t.paths)null!=this.weightUrlConverter?o.push(this.weightUrlConverter(e)):s.push(a+e+r);return this.weightUrlConverter&&s.push(...await Promise.all(o)),[i,Hi(await zs(s,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress}))]}}function js(e){return null!=e.match(Hs.URL_SCHEME_REGEX)}Hs.URL_SCHEME_REGEX=/^https?:\/\//;const Us=(e,t)=>{if("undefined"==typeof fetch&&(null==t||null==t.fetchFunc))return null;{let n=!0;if(n=Array.isArray(e)?e.every((e=>js(e))):js(e),n)return qs(e,t)}return null};function qs(e,t){return new Hs(e,t)}function Ws(e,t){return qs(e,t)}Gi.registerSaveRouter(Us),Gi.registerLoadRouter(Us);class Vs{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}}class Gs{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}}class Ks{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}}function Js(e,t,n,r){const a=arguments;return new Ks(Xs(...a))}function Xs(e,t,n,r){return 1===arguments.length?null!=e.modelTopology||null!=e.weightSpecs?new Vs(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 Vs({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 Vs({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r}))}function Zs(e){return new Gs(e)}function Qs(e){return new Gs(e)}const eo=Ai({matMul_:function(e,t,n=!1,r=!1){let a=Ii(e,"a","matMul"),i=Ii(t,"b","matMul");[a,i]=ci(a,i);const s={a,b:i},o={transposeA:n,transposeB:r};return xi.runKernel(gt,s,o)}}),to=Ai({oneHot_:function(e,t,n=1,r=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);const a={indices:Ii(e,"indices","oneHot","int32")},i={depth:t,onValue:n,offValue:r};return xi.runKernel(Zn,a,i)}});function no(){Ve().set("PROD",!0)}function ro(){Ve().set("DEBUG",!0)}function ao(){Ve().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function io(e){Ve().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function so(){xi.disposeVariables()}function oo(){return xi}function uo(){return xi.memory()}function lo(e){return xi.profile(e)}function co(e,t){return xi.tidy(e,t)}function po(e){hi(e).forEach((e=>e.dispose()))}function ho(e){return xi.keep(e)}function fo(e){return xi.time(e)}function mo(e){return xi.setBackend(e)}function go(){return xi.ready()}function yo(){return xi.backendName}function bo(e){xi.removeBackend(e)}function xo(e){return xi.findBackend(e)}function vo(e){return xi.findBackendFactory(e)}function _o(e,t,n=1){return xi.registerBackend(e,t,n)}function wo(){return xi.backend}function Mo(e,t){Ve().setPlatform(e,t)}Za=io;const No=Ai({imag_:function(e){const t={input:Ii(e,"input","imag")};return xi.runKernel(mn,t)}}),So=Ai({neg_:function(e){const t={x:Ii(e,"x","neg")};return xi.runKernel(Wn,t)}}),ko=Ai({real_:function(e){const t={input:Ii(e,"input","real")};return xi.runKernel(sr,t)}}),Do=Ai({transpose_:function(e,t,n){const r=Ii(e,"x","transpose");if(null==t&&(t=r.shape.map(((e,t)=>t)).reverse()),ie(r.rank===t.length,(()=>`Error in transpose: rank of input ${r.rank} must match length of perm ${t}.`)),t.forEach((e=>{ie(e>=0&&e"All entries in 'perm' must be between 0 and "+(r.rank-1)+` but got ${t}`))})),r.rank<=1)return r.clone();const a={x:r},i={perm:t};return"complex64"===r.dtype?co((()=>{let e=ko(r),t=No(r);return e=xi.runKernel(Jr,{x:e},i),t=xi.runKernel(Jr,{x:t},i),n&&(t=So(t)),Li(e,t)})):xi.runKernel(Jr,a,i)}}),To=Ai({confusionMatrix_:function(e,t,n){const r=Ii(e,"labels","confusionMatrix"),a=Ii(t,"predictions","confusionMatrix");ie(null==n||n>0&&Number.isInteger(n),(()=>`If provided, numClasses must be a positive integer, but got ${n}`)),ie(1===r.rank,(()=>`Expected the rank of labels to be 1, but got ${r.rank}`)),ie(1===a.rank,(()=>`Expected the rank of predictions to be 1, but got ${a.rank}`)),ie(r.shape[0]===a.shape[0],(()=>`Mismatch in the number of examples: ${r.shape[0]} vs. ${a.shape[0]}. Labels and predictions should have the same number of elements.`)),ie(n>0&&Number.isInteger(n),(()=>`numClasses is required to be a positive integer, but got ${n}`));const i=to(Cs(r,"int32"),n),s=to(Cs(a,"int32"),n),o=Do(i),u=eo(o,s);return Cs(u,"int32")}});function Io(e,t){const n=e.length,r=[];for(let a=0;a1&&1===s&&r.unshift(i)}return r}function Eo(e,t){const n=[];for(let r=0;r1)&&n.unshift(i)}return n}function Co(e,t){const n=[],r=Math.max(e.length,t.length);for(let a=0;a4)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");let n=!1,r=!1,a=!1,i=!1,s=!1,o=!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)a=!0;else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)i=!0;else if(null!=e.getContext)s=!0;else{if(!("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap))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}`);o=!0}if(a){const t=2;if(a&&e.readyState element.")}if(null!=da(ra,xi.backendName)){const n={pixels:e},r={numChannels:t};return xi.runKernel(ra,n,r)}const[u,l]=a?[e.videoWidth,e.videoHeight]:[e.width,e.height];let c,p;if(s)c=e.getContext("2d").getImageData(0,0,u,l).data;else if(r||n)c=e.data;else if(i||a||o){if(null==Lo)if("undefined"==typeof document){if("undefined"==typeof OffscreenCanvas||"undefined"==typeof OffscreenCanvasRenderingContext2D)throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");Lo=new OffscreenCanvas(1,1).getContext("2d")}else Lo=document.createElement("canvas").getContext("2d");Lo.canvas.width=u,Lo.canvas.height=l,Lo.drawImage(e,0,0,u,l),c=Lo.getImageData(0,0,u,l).data}if(4===t)p=new Int32Array(c);else{const e=u*l;p=new Int32Array(e*t);for(let n=0;n4||2===i)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${i}`);if("float32"!==n.dtype&&"int32"!==n.dtype)throw new Error(`Unsupported type for toPixels: ${n.dtype}. Please use float32 or int32 tensors.`);const s=await n.data(),o="float32"===n.dtype?255:1,u=new Uint8ClampedArray(a*r*4);for(let e=0;e1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${a}.`)}else if("int32"===n.dtype&&(a<0||a>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${a}.`);1===i?(t[0]=a*o,t[1]=a*o,t[2]=a*o):t[r]=a*o}const r=4*e;u[r+0]=Math.round(t[0]),u[r+1]=Math.round(t[1]),u[r+2]=Math.round(t[2]),u[r+3]=Math.round(t[3])}if(null!=t){t.width=a,t.height=r;const e=t.getContext("2d"),n=new ImageData(u,a,r);e.putImageData(n,0,0)}return n!==e&&n.dispose(),u}const Fo=Ai({fromPixels_:$o});function Yo(e,t){const n=e.shape.length,r=t.shape.length;if(n<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);if(r<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);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[r-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r-1]} vs. ${n}`);if(0===le(e.shape))throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);const a=t.shape,i=a[a.length-1];let s=1;for(let e=0;ee/l)),1].slice(0,i);return[u,s,l,c]}function zo(e,t,n){const r=t.rank>1?t.shape[t.rank-1]:1,a=t.rank>1?t.rank-1:1,i=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${r}, and batchDim: ${a}.`;if(n.rank1?t.shape[r-1]:1,i=n.length;let s=1;for(let e=a;e`Error in slice${r}D: Length of begin ${t} must match the rank of the array (${r}).`)),ie(r===n.length,(()=>`Error in slice${r}D: Length of size ${n} must match the rank of the array (${r}).`));for(let a=0;a`Error in slice${r}D: begin[${a}] + size[${a}] (${t[a]+n[a]}) would overflow input.shape[${a}] (${e.shape[a]})`))}function jo(e){const t=[];let n=0;for(;e>0;)1&e&&t.push(n),e/=2,n++;return t}function Uo(e,t,n){const r=[];for(let a=0;a0){const u=t[0],l=n+1;c=Ko(s,u,l,r,e),p=Jo(o,u,l,a,e),d=qo(i,u,l,e)}else for(let t=0;t-1)i[a]=0;else{const s=Wo(t,n,a);let o=r[s];e&1<-1)i[a]=Number.MAX_SAFE_INTEGER;else{const s=Wo(t,n,a);let o=r[s];e&1<0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=Q(0,s,u-1),s}function Qo(e,t,n,r,a,i){let s=t[a];const o=n[a]||1;(e&1<0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=o>0?Q(0,s,u):Q(-1,s,u-1),s}function eu(e,t,n){let r=n.length;for(let e=0;e1){r=e;break}for(let a=r+1;a0||n[a]!==e[a])return!1;return!0}function tu(e,t){let n=e.length>0?e[e.length-1]:1;for(let r=0;r{ie(-1!==e,(()=>"slice() does not support negative begin indexing."))})),i=null==n?new Array(a).fill(-1):"number"==typeof n?[n,...new Array(a-1).fill(-1)]:n.lengtht>=0?t:(ie(-1===t,(()=>`Negative size values should be exactly -1 but got ${t} for the slice() size at index ${n}.`)),e.shape[n]-r[n]))),[r,i]}function ru(e,t,n,r,a,i,s,o,u){let l;if(null==r?(l=new Array(t.length),l.fill(1)):l=r,null!=s&&0!=(s&s-1))throw new Error("Multiple ellipses in slice is not allowed.");let c=!1;const p={dims:l.length,numAddAxisAfterEllipsis:0,begin:t.slice(),end:n.slice(),strides:l.slice(),beginMask:a,endMask:i,ellipsisMask:s,newAxisMask:o,shrinkAxisMask:u};for(let e=0;e0?0:-1,d.strides[t]>0?r:r-1];if(n&&d.strides[t]<=0)throw Error("only stride 1 allowed on non-range indexing.");m=m&&1===d.strides[t];const s=!!(d.beginMask&1<=r)throw Error(`slice index ${d.begin[t]} of dimension ${t} out of bounds.`)}else d.begin[t]=au(d.begin[t],0,d.strides[t],r,a,i),d.end[t]=au(d.end[t],1,d.strides[t],r,a,i);const e=1===d.strides[t]&&0===d.begin[t]&&d.end[t]===r;h=h&&e,f=f&&(0===t&&1===d.strides[t]||e)}else h=h&&1===d.strides[t]&&s,f=f&&(0===t&&1===d.strides[t]||s);let o,u=!1;if(d.beginValid&&d.endValid?(o=d.end[t]-d.begin[t],u=!0):n?(o=1,u=!0):s&&r>=0&&(o=d.strides[t]<0?-r:r,u=!0),u){let e;e=0===o||o<0!=d.strides[t]<0?0:Math.trunc(o/d.strides[t])+(o%d.strides[t]!=0?1:0),g.push(e)}else g.push(-1)}for(let e=0;e=0?y.push(g[t]):-2===t&&y.push(1)}const b=y.filter(((e,t)=>-2!==d.finalShapeGatherIndices[t]));return{finalShapeSparse:b,finalShape:y,isIdentity:h,sliceDim0:f,isSimpleSlice:m,begin:d.begin,end:d.end,strides:d.strides}}function au(e,t,n,r,a,i){if(a[t])return n>0?i[t]:i[t+1&1];{const t=e<0?r+e:e;return ti[1]?i[1]:t}}class iu{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class su{constructor(){this.classNameMap={}}static getMap(){return null==su.instance&&(su.instance=new su),su.instance}static register(e){su.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function ou(e){ie(null!=e.className,(()=>"Class being registered does not have the static className property defined.")),ie("string"==typeof e.className,(()=>"className is required to be a string, but got type "+typeof e.className)),ie(e.className.length>0,(()=>"Class being registered has an empty-string as its className, which is disallowed.")),su.register(e)}const uu=.1;function lu(e,t,n){return null==n&&(n=cu()),pu(e,t,((e,t)=>mu(e,t,n)))}function cu(){return 32===xi.backend.floatPrecision()?.001:uu}function pu(e,t,n){let r=!0;if((ke(e)||ke(t))&&(r=!1),ke(e)&&ke(t)&&(r=!0),r){const n=e.constructor.name,r=t.constructor.name;if(n!==r)throw new Error(`Arrays are of different type. Actual: ${n}. Expected: ${r}`)}if(Array.isArray(e)&&Array.isArray(t)){const n=ki(e),r=ki(t);if(!pe(n,r))throw new Error(`Arrays have different shapes. Actual: [${n}]. Expected: [${r}]`)}const a=ke(e)?e:ue(e),i=ke(t)?t:ue(t);if(a.length!==i.length)throw new Error(`Arrays have different lengths actual: ${a.length} vs expected: ${i.length}.\nActual: ${a}.\nExpected: ${i}.`);for(let e=0;et.fail()),(()=>t()))}function hu(e,t){const n="string"==typeof t||"number"==typeof t||"boolean"==typeof t?[t]:t;return Ie(e)||Ie(e[0])||Ie(t)||Ie(t[0])?pu(e,n,((e,t)=>e==t)):pu(e,t,((e,t)=>mu(e,t,0)))}function fu(e,t,n){if(null==n&&(n=cu()),!mu(e,t,n))throw new Error(`Numbers differ: actual === ${e}, expected === ${t}`)}function mu(e,t,n){return!isFinite(e)&&!isFinite(t)||!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}function gu(e,t,n){for(let r=0;rn)throw new Error(`Value out of range:${e[r]} low: ${t}, high: ${n}`)}function yu(e,t){const n=new Float32Array(e),r=new Float32Array(t);if(n.length!==r.length)throw new Error(`Expected ArrayBuffer to be of length ${r.length}, but it was ${n.length}`);for(let e=0;e"The f passed in grad(f) must be a function")),(t,n)=>{const r=Ii(t,"x","tf.grad","string_or_numeric"),a=null!=n?Ii(n,"dy","tf.grad"):null;return xi.tidy((()=>{const{value:t,grads:n}=xi.gradients((()=>e(r)),[r],a);return null!=a&&se(t.shape,a.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),Lu(n),n[0]}))}}function Tu(e){return ie(Le(e),(()=>"The f passed in grads(f) must be a function")),(t,n)=>{ie(Array.isArray(t),(()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"));const r=Ei(t,"args","tf.grads","string_or_numeric"),a=null!=n?Ii(n,"dy","tf.grads"):null;return xi.tidy((()=>{const{value:t,grads:n}=xi.gradients((()=>e(...r)),r,a);return null!=a&&se(t.shape,a.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Lu(n),n}))}}function Iu(e){return ie(Le(e),(()=>"The f passed in valueAndGrad(f) must be a function")),(t,n)=>{ie(t instanceof Qa,(()=>"The x passed in valueAndGrad(f)(x) must be a tensor")),ie(null==n||n instanceof Qa,(()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor"));const{grads:r,value:a}=xi.gradients((()=>e(t)),[t],n);return Lu(r),{grad:r[0],value:a}}}function Eu(e){return ie(Le(e),(()=>"The f passed in valueAndGrads(f) must be a function")),(t,n)=>{ie(Array.isArray(t)&&t.every((e=>e instanceof Qa)),(()=>"The args passed in valueAndGrads(f)(args) must be array of tensors")),ie(null==n||n instanceof Qa,(()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor"));const r=xi.gradients((()=>e(...t)),t,n);return null!=n&&se(r.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Lu(r.grads),r}}function Cu(e,t){ie(Le(e),(()=>"The f passed in variableGrads(f) must be a function")),ie(null==t||Array.isArray(t)&&t.every((e=>e instanceof ti)),(()=>"The varList passed in variableGrads(f, varList) must be an array of variables"));const n=null!=t;if(!n){t=[];for(const e in xi.registeredVariables)t.push(xi.registeredVariables[e])}const r=n?t.filter((e=>!e.trainable)):null,a=t.length;t=t.filter((e=>e.trainable)),ie(t.length>0,(()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${a} variables is trainable.`));const{value:i,grads:s}=xi.gradients(e,t,null,!0);ie(s.some((e=>null!=e)),(()=>"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().")),ie(0===i.rank,(()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${i.rank} tensor`));const o={};return t.forEach(((e,t)=>{null!=s[t]&&(o[e.name]=s[t])})),null!=r&&r.forEach((e=>o[e.name]=null)),{value:i,grads:o}}function Au(e){return xi.customGrad(e)}function Lu(e){if(e.filter((e=>null==e)).length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that\n the f you passed encloses all operations that lead from x to y.")}function $u(e,t){if((ke(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&&ke(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return $i(e,[],[],t)}class Ou extends iu{minimize(e,t=!1,n){const{value:r,grads:a}=this.computeGradients(e,n);if(null!=n){const e=n.map((e=>({name:e.name,tensor:a[e.name]})));this.applyGradients(e)}else this.applyGradients(a);return po(a),t?r:(r.dispose(),null)}get iterations(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return Cu(e,t)}dispose(){null!=this.iterations_&&po(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:$u(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(e){throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`)}async extractIterations(e){return this.iterations_=(await e[0].tensor.data())[0],e.slice(1)}}Object.defineProperty(Ou,Symbol.hasInstance,{value:e=>null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients});class Ru extends Ou{constructor(e,t,n=null){super(),this.learningRate=e,this.rho=t,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],null==n&&(this.epsilon=xi.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=xi.registeredVariables[t];null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:`${t}/accum_grad`,variable:co((()=>ku(r).variable(!1)))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:`${t}/accum_var`,variable:co((()=>ku(r).variable(!1)))});const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const i=this.accumulatedGrads[n].variable,s=this.accumulatedUpdates[n].variable;co((()=>{const e=vu(Mu(i,this.rho),Mu(Su(a),1-this.rho)),t=Mu(wu(Nu(vu(s,this.epsilon)),Nu(vu(i,this.epsilon))),a),n=vu(Mu(s,this.rho),Mu(Su(t),1-this.rho));i.assign(e),s.assign(n);const o=vu(Mu(t,-this.learningRate),r);r.assign(o)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&(po(this.accumulatedGrads.map((e=>e.variable))),po(this.accumulatedUpdates.map((e=>e.variable))))}async getWeights(){const e=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){const t=(e=await this.extractIterations(e)).length/2;this.accumulatedGrads=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)}))),this.accumulatedUpdates=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}}function Fu(e,t,n){const r={shape:e,value:t,dtype:n};return xi.runKernel(rn,{},r)}Ru.className="Adadelta",ou(Ru);class Yu extends Ou{constructor(e,t=.1){super(),this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=xi.registeredVariables[t];if(null==this.accumulatedGrads[n]){const e=!1;this.accumulatedGrads[n]={originalName:`${t}/accumulator`,variable:co((()=>Fu(r.shape,this.initialAccumulatorValue).variable(e)))}}const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const i=this.accumulatedGrads[n].variable;co((()=>{const e=vu(i,Su(a));i.assign(e);const t=vu(Mu(wu(a,Nu(vu(e,xi.backend.epsilon()))),-this.learningRate),r);r.assign(t)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&po(this.accumulatedGrads.map((e=>e.variable)))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e),this.accumulatedGrads=e.map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}}Yu.className="Adagrad",ou(Yu);const zu=Ai({pow_:function(e,t){let n=Ii(e,"base","pow"),r=Ii(t,"exp","pow");[n,r]=ci(n,r);const a={a:n,b:r};return xi.runKernel(nr,a)}}),Bu=Ai({sub_:function(e,t){let n=Ii(e,"a","sub"),r=Ii(t,"b","sub");[n,r]=ci(n,r);const a={a:n,b:r};return xi.runKernel(Ur,a)}});class Pu extends Ou{constructor(e,t,n,r=null){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],co((()=>{this.accBeta1=$u(t).variable(),this.accBeta2=$u(n).variable()})),null==r&&(this.epsilon=xi.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);co((()=>{const n=Bu(1,this.accBeta1),r=Bu(1,this.accBeta2);t.forEach(((t,a)=>{const i=xi.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:co((()=>ku(i).variable(!1)))}),null==this.accumulatedSecondMoment[a]&&(this.accumulatedSecondMoment[a]={originalName:`${t}/v`,variable:co((()=>ku(i).variable(!1)))});const s=Array.isArray(e)?e[a].tensor:e[t];if(null==s)return;const o=this.accumulatedFirstMoment[a].variable,u=this.accumulatedSecondMoment[a].variable,l=vu(Mu(o,this.beta1),Mu(s,1-this.beta1)),c=vu(Mu(u,this.beta2),Mu(Su(s),1-this.beta2)),p=wu(l,n),d=wu(c,r);o.assign(l),u.assign(c);const h=vu(Mu(wu(p,vu(Nu(d),this.epsilon)),-this.learningRate),i);i.assign(h)})),this.accBeta1.assign(Mu(this.accBeta1,this.beta1)),this.accBeta2.assign(Mu(this.accBeta2,this.beta2))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&po(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedSecondMoment&&po(this.accumulatedSecondMoment.map((e=>e.variable)))}async getWeights(){const e=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e),co((()=>{this.accBeta1.assign(zu(this.beta1,this.iterations_+1)),this.accBeta2.assign(zu(this.beta2,this.iterations_+1))}));const t=e.length/2;this.accumulatedFirstMoment=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)}))),this.accumulatedSecondMoment=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)}}Pu.className="Adam",ou(Pu);const Hu=Ai({abs_:function(e){const t=Ii(e,"x","abs");if("complex64"===t.dtype){const e={x:t};return xi.runKernel(St,e)}{const e={x:t};return xi.runKernel(Ze,e)}}}),ju=Ai({maximum_:function(e,t){let n=Ii(e,"a","maximum"),r=Ii(t,"b","maximum");[n,r]=ci(n,r),"bool"===n.dtype&&(n=Cs(n,"int32"),r=Cs(r,"int32")),Co(n.shape,r.shape);const a={a:n,b:r};return xi.runKernel(Ln,a)}});class Uu extends Ou{constructor(e,t,n,r=null,a=0){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.decay=a,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],co((()=>{this.iteration=$u(0).variable(),this.accBeta1=$u(t).variable()})),null==r&&(this.epsilon=xi.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);co((()=>{const n=Bu(1,this.accBeta1),r=wu(-this.learningRate,vu(Mu(this.iteration,this.decay),1));t.forEach(((t,a)=>{const i=xi.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:ku(i).variable(!1)}),null==this.accumulatedWeightedInfNorm[a]&&(this.accumulatedWeightedInfNorm[a]={originalName:`${t}/v`,variable:ku(i).variable(!1)});const s=Array.isArray(e)?e[a].tensor:e[t];if(null==s)return;const o=this.accumulatedFirstMoment[a].variable,u=this.accumulatedWeightedInfNorm[a].variable,l=vu(Mu(o,this.beta1),Mu(s,1-this.beta1)),c=Mu(u,this.beta2),p=Hu(s),d=ju(c,p);o.assign(l),u.assign(d);const h=vu(Mu(wu(r,n),wu(l,vu(d,this.epsilon))),i);i.assign(h)})),this.iteration.assign(vu(this.iteration,1)),this.accBeta1.assign(Mu(this.accBeta1,this.beta1))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&po(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedWeightedInfNorm&&po(this.accumulatedWeightedInfNorm.map((e=>e.variable)))}async getWeights(){throw new Error("getWeights() is not implemented for Adamax yet.")}async setWeights(e){throw new Error("setWeights() is not implemented for Adamax yet.")}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)}}Uu.className="Adamax",ou(Uu);class qu extends Ou{constructor(e){super(),this.learningRate=e,this.setLearningRate(e)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=Array.isArray(e)?e[n].tensor:e[t];if(null==r)return;const a=xi.registeredVariables[t];co((()=>{const e=vu(Mu(this.c,r),a);a.assign(e)}))})),this.incrementIterations()}setLearningRate(e){this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=ho($u(-e))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(0!==(e=await this.extractIterations(e)).length)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}}qu.className="SGD",ou(qu);class Wu extends qu{constructor(e,t,n=!1){super(e),this.learningRate=e,this.momentum=t,this.useNesterov=n,this.accumulations=[],this.m=$u(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=xi.registeredVariables[t];if(null==this.accumulations[n]){const e=!1;this.accumulations[n]={originalName:`${t}/momentum`,variable:co((()=>ku(r).variable(e)))}}const a=this.accumulations[n].variable,i=Array.isArray(e)?e[n].tensor:e[t];null!=i&&co((()=>{let e;const t=vu(Mu(this.m,a),i);e=this.useNesterov?vu(Mu(this.c,vu(i,Mu(t,this.m))),r):vu(Mu(this.c,t),r),a.assign(t),r.assign(e)}))})),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&po(this.accumulations.map((e=>e.variable)))}setMomentum(e){this.momentum=e}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e),this.accumulations=e.map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}}Wu.className="Momentum",ou(Wu);class Vu extends Ou{constructor(e,t=.9,n=0,r=null,a=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=r,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=a,null==r&&(this.epsilon=xi.backend.epsilon()),null==e)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=xi.registeredVariables[t],a=!1;null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:`${t}/rms`,variable:co((()=>ku(r).variable(a)))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:`${t}/momentum`,variable:co((()=>ku(r).variable(a)))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${t}/mg`,variable:co((()=>ku(r).variable(a)))});const i=Array.isArray(e)?e[n].tensor:e[t];if(null==i)return;const s=this.accumulatedMeanSquares[n].variable,o=this.accumulatedMoments[n].variable;co((()=>{const e=vu(Mu(s,this.decay),Mu(Su(i),1-this.decay));if(this.centered){const t=this.accumulatedMeanGrads[n].variable,a=vu(Mu(t,this.decay),Mu(i,1-this.decay)),u=wu(Mu(i,this.learningRate),Nu(Bu(e,vu(Su(a),this.epsilon)))),l=vu(Mu(o,this.momentum),u);s.assign(e),t.assign(a),o.assign(l);const c=Bu(r,l);r.assign(c)}else{const e=vu(Mu(s,this.decay),Mu(Su(i),1-this.decay)),t=vu(Mu(o,this.momentum),wu(Mu(i,this.learningRate),Nu(vu(e,this.epsilon))));s.assign(e),o.assign(t);const n=Bu(r,t);r.assign(n)}}))})),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&po(this.accumulatedMeanSquares.map((e=>e.variable))),null!=this.accumulatedMeanGrads&&this.centered&&po(this.accumulatedMeanGrads.map((e=>e.variable))),null!=this.accumulatedMoments&&po(this.accumulatedMoments.map((e=>e.variable)))}async getWeights(){const e=[...this.accumulatedMeanSquares,...this.accumulatedMoments];return this.centered&&e.push(...this.accumulatedMeanGrads),[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e);const t=this.centered?e.length/3:e.length/2,n=!1;this.accumulatedMeanSquares=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))),this.accumulatedMoments=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))),this.centered&&(this.accumulatedMeanGrads=e.slice(2*t,3*t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))))}getConfig(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}static fromConfig(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)}}Vu.className="RMSProp",ou(Vu);class Gu{static sgd(e){return new qu(e)}static momentum(e,t,n=!1){return new Wu(e,t,n)}static rmsprop(e,t=.9,n=0,r=null,a=!1){return new Vu(e,t,n,r,a)}static adam(e=.001,t=.9,n=.999,r=null){return new Pu(e,t,n,r)}static adadelta(e=.001,t=.95,n=null){return new Ru(e,t,n)}static adamax(e=.002,t=.9,n=.999,r=null,a=0){return new Uu(e,t,n,r,a)}static adagrad(e,t=.1){return new Yu(e,t)}}const Ku=Ai({acos_:function(e){const t={x:Ii(e,"x","acos")};return xi.runKernel(Qe,t)}}),Ju=Ai({acosh_:function(e){const t={x:Ii(e,"x","acosh")};return xi.runKernel(et,t)}}),Xu=Ai({addN_:function(e){ie(Array.isArray(e),(()=>"The argument passed to tf.addN() must be a list of tensors")),ie(e.length>=1,(()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`));const t=e.map(((e,t)=>Ii(e,`tensors${t}`,"addN"))),n=t[0];t.forEach((e=>{if(e.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),t.forEach((e=>{if(!pe(e.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));const r=t;return xi.runKernel(nt,r)}}),Zu=Ai({all_:function(e,t=null,n=!1){const r={x:Ii(e,"x","all","bool")},a={axis:t,keepDims:n};return xi.runKernel(rt,r,a)}}),Qu=Ai({any_:function(e,t=null,n=!1){const r={x:Ii(e,"x","any","bool")},a={axis:t,keepDims:n};return xi.runKernel(at,r,a)}}),el=Ai({argMax_:function(e,t=0){const n={x:Ii(e,"x","argMax")},r={axis:t};return xi.runKernel(it,n,r)}}),tl=Ai({argMin_:function(e,t=0){const n={x:Ii(e,"x","argMin")},r={axis:t};return xi.runKernel(st,n,r)}}),nl=Ai({asin_:function(e){const t={x:Ii(e,"x","asin")};return xi.runKernel(ot,t)}}),rl=Ai({asinh_:function(e){const t={x:Ii(e,"x","asinh")};return xi.runKernel(ut,t)}}),al=Ai({atan_:function(e){const t={x:Ii(e,"x","atan")};return xi.runKernel(lt,t)}}),il=Ai({atan2_:function(e,t){let n=Ii(e,"a","atan2"),r=Ii(t,"b","atan2");[n,r]=ci(n,r);const a={a:n,b:r};return xi.runKernel(pt,a)}}),sl=Ai({atanh_:function(e){const t={x:Ii(e,"x","atanh")};return xi.runKernel(ct,t)}});function ol(e,t,n,r,a="NHWC",i){return cl(e,[...t,e[3]],n,i,r,null,null,xl(a))}function ul(e,t,n,r,a,i,s="channelsLast"){const[o,u]=hl(t);let l;if("channelsLast"===s)l=[o,u,e[3],e[3]];else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);l=[o,u,e[1],e[1]]}return cl(e,l,n,r,a,i,!1,s)}function ll(e,t,n,r,a,i,s="NDHWC"){const[o,u,l]=fl(t);let c,p;if("NDHWC"===s)p="channelsLast",c=[o,u,l,e[4],e[4]];else{if("NCDHW"!==s)throw new Error(`Unknown dataFormat ${s}`);p="channelsFirst",c=[o,u,l,e[1],e[1]]}return pl(e,c,n,r,a,!1,p,i)}function cl(e,t,n,r,a,i,s=!1,o="channelsLast"){let[u,l,c,p]=[-1,-1,-1,-1];if("channelsLast"===o)[u,l,c,p]=e;else{if("channelsFirst"!==o)throw new Error(`Unknown dataFormat ${o}`);[u,p,l,c]=e}const[d,h,,f]=t,[m,g]=hl(n),[y,b]=hl(r),x=ml(d,y),v=ml(h,b),{padInfo:_,outHeight:w,outWidth:M}=function(e,t,n,r,a,i,s,o,u){let l,c,p;if("number"==typeof e){l={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};const a=function(e,t,n,r,a){null==r&&(r=dl(e,t,n));const i=e[1];return[gl((e[0]-t+2*r)/n+1,a),gl((i-t+2*r)/n+1,a)]}([t,n],i,r,e,o);c=a[0],p=a[1]}else if("same"===e){c=Math.ceil(t/r),p=Math.ceil(n/a);const e=Math.max(0,(c-1)*r+i-t),o=Math.max(0,(p-1)*a+s-n),u=Math.floor(e/2),d=e-u,h=Math.floor(o/2);l={top:u,bottom:d,left:h,right:o-h,type:"SAME"}}else if("valid"===e)l={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((t-i+1)/r),p=Math.ceil((n-s+1)/a);else{if("object"!=typeof e)throw Error(`Unknown padding parameter: ${e}`);{const d="channelsLast"===u?e[1][0]:e[2][0],h="channelsLast"===u?e[1][1]:e[2][1],f="channelsLast"===u?e[2][0]:e[3][0],m="channelsLast"===u?e[2][1]:e[3][1];l={top:d,bottom:h,left:f,right:m,type:0===d&&0===h&&0===f&&0===m?"VALID":"EXPLICIT"},c=gl((t-i+d+h)/r+1,o),p=gl((n-s+f+m)/a+1,o)}}return{padInfo:l,outHeight:c,outWidth:p}}(a,l,c,m,g,x,v,i,o),N=s?f*p:f;let S;return"channelsFirst"===o?S=[u,N,w,M]:"channelsLast"===o&&(S=[u,w,M,N]),{batchSize:u,dataFormat:o,inHeight:l,inWidth:c,inChannels:p,outHeight:w,outWidth:M,outChannels:N,padInfo:_,strideHeight:m,strideWidth:g,filterHeight:d,filterWidth:h,effectiveFilterHeight:x,effectiveFilterWidth:v,dilationHeight:y,dilationWidth:b,inShape:e,outShape:S,filterShape:t}}function pl(e,t,n,r,a,i=!1,s="channelsLast",o){let[u,l,c,p,d]=[-1,-1,-1,-1,-1];if("channelsLast"===s)[u,l,c,p,d]=e;else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);[u,d,l,c,p]=e}const[h,f,m,,g]=t,[y,b,x]=fl(n),[v,_,w]=fl(r),M=ml(h,v),N=ml(f,_),S=ml(m,w),{padInfo:k,outDepth:D,outHeight:T,outWidth:I}=function(e,t,n,r,a,i,s,o,u,l,c){let p,d,h,f;if("number"==typeof e){p={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};const i=function(e,t,n,r,a,i){null==a&&(a=dl(e,t,r));const s=e[1],o=e[2];return[gl((e[0]-t+2*a)/r+1,i),gl((s-t+2*a)/r+1,i),gl((o-t+2*a)/r+1,i),1]}([t,n,r,1],o,0,a,e,c);d=i[0],h=i[1],f=i[2]}else if("same"===e){d=Math.ceil(t/a),h=Math.ceil(n/i),f=Math.ceil(r/s);const e=(d-1)*a+o-t,c=(h-1)*i+u-n,m=(f-1)*s+l-r,g=Math.floor(e/2),y=e-g,b=Math.floor(c/2),x=c-b,v=Math.floor(m/2);p={top:b,bottom:x,left:v,right:m-v,front:g,back:y,type:"SAME"}}else{if("valid"!==e)throw Error(`Unknown padding parameter: ${e}`);p={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},d=Math.ceil((t-o+1)/a),h=Math.ceil((n-u+1)/i),f=Math.ceil((r-l+1)/s)}return{padInfo:p,outDepth:d,outHeight:h,outWidth:f}}(a,l,c,p,y,b,x,M,N,S,o),E=i?g*d:g;let C;return"channelsFirst"===s?C=[u,E,D,T,I]:"channelsLast"===s&&(C=[u,D,T,I,E]),{batchSize:u,dataFormat:s,inDepth:l,inHeight:c,inWidth:p,inChannels:d,outDepth:D,outHeight:T,outWidth:I,outChannels:E,padInfo:k,strideDepth:y,strideHeight:b,strideWidth:x,filterDepth:h,filterHeight:f,filterWidth:m,effectiveFilterDepth:M,effectiveFilterHeight:N,effectiveFilterWidth:S,dilationDepth:v,dilationHeight:_,dilationWidth:w,inShape:e,outShape:C,filterShape:t}}function dl(e,t,n,r=1){const a=ml(t,r);return Math.floor((e[0]*(n-1)-n+a)/2)}function hl(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function fl(e){return"number"==typeof e?[e,e,e]:e}function ml(e,t){return t<=1?e:e+(e-1)*(t-1)}function gl(e,t){if(!t)return Math.trunc(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 yl(e){const[t,n,r]=hl(e);return 1===t&&1===n&&1===r}function bl(e,t){return yl(e)||yl(t)}function xl(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}function vl(e,t,n){if(null!=n){if("string"==typeof t)throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);if("number"==typeof t)ie(de(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`));else{if("object"!=typeof t)throw Error(`Error in ${e}: Unknown padding parameter: ${t}`);t.forEach((t=>{t.forEach((t=>{ie(de(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`))}))}))}}}const _l=Ai({reshape_:function(e,t){const n={x:Ii(e,"x","reshape","string_or_numeric")},r={shape:t};return xi.runKernel(lr,n,r)}}),wl=Ai({avgPool_:function(e,t,n,r,a){const i=Ii(e,"x","avgPool","float32");ie(bl(n,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`));let s=i,o=!1;3===i.rank&&(o=!0,s=_l(i,[1,i.shape[0],i.shape[1],i.shape[2]])),ie(4===s.rank,(()=>`Error in avgPool: x must be rank 4 but got rank ${s.rank}.`)),vl("avgPool",r,a);const u={x:s},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a};let c=xi.runKernel(dt,u,l);return c=Cs(c,i.dtype),o?_l(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),Ml=Ai({avgPool3d_:function(e,t,n,r,a,i="NDHWC"){const s=Ii(e,"x","avgPool3d","float32");let o=s,u=!1;4===s.rank&&(u=!0,o=_l(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),ie(5===o.rank,(()=>`Error in avgPool3d: x must be rank 5 but got rank ${o.rank}.`)),ie("NDHWC"===i,(()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${i}`)),vl("avgPool3d",r,a);const l={x:o},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i};let p=xi.runKernel(ft,l,c);return p=Cs(p,o.dtype),u?_l(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}}),Nl=Ai({concat_:function(e,t=0){ie(e.length>=1,(()=>"Pass at least one tensor to concat"));const n=Ei(e,"tensors","concat","string_or_numeric");if("complex64"===n[0].dtype&&n.forEach((e=>{if("complex64"!==e.dtype)throw new Error(`Cannot concatenate complex64 tensors with a tensor\n with dtype ${e.dtype}. `)})),1===n.length)return As(n[0]);const r=n,a={axis:t};return xi.runKernel(kt,r,a)}}),Sl=Ai({sigmoid_:function(e){const t={x:Ii(e,"x","sigmoid","float32")};return xi.runKernel(kr,t)}}),kl=Ai({slice_:function(e,t,n){const r=Ii(e,"x","slice","string_or_numeric");if(0===r.rank)throw new Error("Slicing scalar is not possible");const a={x:r},i={begin:t,size:n};return xi.runKernel(wr,a,i)}}),Dl=Ai({tanh_:function(e){const t={x:Ii(e,"x","tanh","float32")};return xi.runKernel(Wr,t)}}),Tl=Ai({basicLSTMCell_:function(e,t,n,r,a,i){const s=Ii(e,"forgetBias","basicLSTMCell"),o=Ii(t,"lstmKernel","basicLSTMCell"),u=Ii(n,"lstmBias","basicLSTMCell"),l=Ii(r,"data","basicLSTMCell"),c=Ii(a,"c","basicLSTMCell"),p=Ii(i,"h","basicLSTMCell"),d=Nl([l,p],1),h=eo(d,o),f=vu(h,u),m=f.shape[0],g=f.shape[1]/4,y=[m,g],b=kl(f,[0,0],y),x=kl(f,[0,g],y),v=kl(f,[0,2*g],y),_=kl(f,[0,3*g],y),w=vu(Mu(Sl(b),Dl(x)),Mu(c,Sl(vu(s,v))));return[w,Mu(Dl(w),Sl(_))]}}),Il=Ai({batchToSpaceND_:function(e,t,n){const r=Ii(e,"x","batchToSpaceND"),a=t.reduce(((e,t)=>e*t));ie(r.rank>=1+t.length,(()=>`input rank is ${r.rank} but should be > than blockShape.length ${t.length}`)),ie(n.length===t.length,(()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`)),ie(r.shape[0]%a==0,(()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${a}`));const i={x:r},s={blockShape:t,crops:n};return xi.runKernel(yt,i,s)}}),El=Ai({batchNorm_:function(e,t,n,r,a,i){null==i&&(i=.001);const s=Ii(e,"x","batchNorm"),o=Ii(t,"mean","batchNorm"),u=Ii(n,"variance","batchNorm");let l,c;null!=a&&(l=Ii(a,"scale","batchNorm")),null!=r&&(c=Ii(r,"offset","batchNorm")),ie(o.rank===u.rank,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),ie(null==c||o.rank===c.rank,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),ie(null==l||o.rank===l.rank,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));const p=function(e){let t;return t=0===e.rank||1===e.rank?_l(e,[1,1,1,e.size]):2===e.rank?_l(e,[1,1,e.shape[0],e.shape[1]]):3===e.rank?_l(e,[1,e.shape[0],e.shape[1],e.shape[2]]):e,t}(s),d={x:p,scale:l,offset:c,mean:o,variance:u},h={varianceEpsilon:i},f=xi.runKernel(un,d,h);return _l(f,s.shape)}}),Cl=Ai({batchNorm2d_:function(e,t,n,r,a,i){const s=Ii(e,"x","batchNorm"),o=Ii(t,"mean","batchNorm"),u=Ii(n,"variance","batchNorm");let l,c;return null!=a&&(l=Ii(a,"scale","batchNorm")),null!=r&&(c=Ii(r,"offset","batchNorm")),ie(2===s.rank,(()=>`Error in batchNorm2D: x must be rank 2 but got rank ${s.rank}.`)),ie(2===o.rank||1===o.rank,(()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${o.rank}.`)),ie(2===u.rank||1===u.rank,(()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${u.rank}.`)),null!=l&&ie(2===l.rank||1===l.rank,(()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`)),null!=c&&ie(2===c.rank||1===c.rank,(()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`)),El(s,o,u,c,l,i)}}),Al=Ai({batchNorm3d_:function(e,t,n,r,a,i){const s=Ii(e,"x","batchNorm"),o=Ii(t,"mean","batchNorm"),u=Ii(n,"variance","batchNorm");let l,c;return null!=a&&(l=Ii(a,"scale","batchNorm")),null!=r&&(c=Ii(r,"offset","batchNorm")),ie(3===s.rank,(()=>`Error in batchNorm3D: x must be rank 3 but got rank ${s.rank}.`)),ie(3===o.rank||1===o.rank,(()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${o.rank}.`)),ie(3===u.rank||1===u.rank,(()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${u.rank}.`)),null!=l&&ie(3===l.rank||1===l.rank,(()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`)),null!=c&&ie(3===c.rank||1===c.rank,(()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`)),El(s,o,u,c,l,i)}}),Ll=Ai({batchNorm4d_:function(e,t,n,r,a,i){const s=Ii(e,"x","batchNorm"),o=Ii(t,"mean","batchNorm"),u=Ii(n,"variance","batchNorm");let l,c;return null!=a&&(l=Ii(a,"scale","batchNorm")),null!=r&&(c=Ii(r,"offset","batchNorm")),ie(4===s.rank,(()=>`Error in batchNorm4D: x must be rank 4 but got rank ${s.rank}.`)),ie(4===o.rank||1===o.rank,(()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${o.rank}.`)),ie(4===u.rank||1===u.rank,(()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${u.rank}.`)),null!=l&&ie(4===l.rank||1===l.rank,(()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`)),null!=c&&ie(4===c.rank||1===c.rank,(()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`)),El(s,o,u,c,l,i)}}),$l=Ai({bincount_:function(e,t,n){const r=Ii(e,"x","bincount"),a=Ii(t,"weights","bincount");ie("int32"===r.dtype,(()=>`Error in bincount: input dtype must be int32, but got ${r.dtype}`)),ie(n>=0,(()=>`size must be non-negative, but got ${n}.`)),ie(a.size===r.size||0===a.size,(()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${a.shape}.`));const i={x:r,weights:a},s={size:n};return xi.runKernel(bt,i,s)}}),Ol=Ai({broadcastArgs_:function(e,t){const n=Ii(e,"s0","broadcastArgs","int32"),r=Ii(t,"s1","broadcastArgs","int32");if(1!==n.rank)throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${n.rank}`);if(1!==r.rank)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${r.rank}`);const a={s0:n,s1:r};return xi.runKernel(vt,a)}}),Rl=Ai({broadcastTo_:function(e,t){let n=Ii(e,"broadcastTo","x");const r=n.shape;if(t.some((e=>!(e>0)||e%1!=0)))throw new Error(`broadcastTo(): Invalid broadcast shape [${t}].`);if(t.lengthn.rank){const e=n.shape.slice();for(;e.length=0;e--)if(a[e]===t[e])i[e]=1;else if(1!==n.shape[e])throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${t}].`);const s=i.map(((e,t)=>e>1?t:-1)).filter((e=>e>=0));if(0===s.length)return As(n);const o={x:n},u={reps:i};return xi.runKernel(Vr,o,u)}}),Fl=Ai({ceil_:function(e){const t={x:Ii(e,"x","ceil","float32")};return xi.runKernel(wt,t)}}),Yl=Ai({clipByValue_:function(e,t,n){const r=Ii(e,"x","clipByValue");ie(t<=n,(()=>`Error in clip: min (${t}) must be less than or equal to max (${n}).`));const a={x:r},i={clipValueMin:t,clipValueMax:n};return xi.runKernel(Mt,a,i)}}),zl=Ai({concat1d_:function(e){return Nl(e,0)}}),Bl=Ai({concat2d_:function(e,t){return Nl(e,t)}}),Pl=Ai({concat3d_:function(e,t){return Nl(e,t)}}),Hl=Ai({concat4d_:function(e,t){return Nl(e,t)}}),jl=Ai({conv2d_:function(e,t,n,r,a="NHWC",i=[1,1],s){const o=Ii(e,"x","conv2d","float32"),u=Ii(t,"filter","conv2d","float32");let l=o,c=!1;3===o.rank&&(c=!0,l=_l(o,[1,o.shape[0],o.shape[1],o.shape[2]])),ie(4===l.rank,(()=>`Error in conv2d: input must be rank 4, but got rank ${l.rank}.`)),ie(4===u.rank,(()=>`Error in conv2d: filter must be rank 4, but got rank ${u.rank}.`)),vl("conv2d",r,s);const p="NHWC"===a?l.shape[3]:l.shape[1];ie(p===u.shape[2],(()=>`Error in conv2d: depth of input (${p}) must match input depth for filter ${u.shape[2]}.`)),ie(bl(n,i),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`));const d={x:l,filter:u},h={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s},f=xi.runKernel(Dt,d,h);return c?_l(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),Ul=Ai({conv1d_:function(e,t,n,r,a="NWC",i=1,s){const o=Ii(e,"x","conv1d"),u=Ii(t,"filter","conv1d");let l=o,c=!1;2===o.rank&&(c=!0,l=_l(o,[1,o.shape[0],o.shape[1]])),ie(3===l.rank,(()=>`Error in conv1d: input must be rank 3, but got rank ${l.rank}.`)),ie(3===u.rank,(()=>`Error in conv1d: filter must be rank 3, but got rank ${u.rank}.`)),vl("conv1d",r,s),ie(l.shape[2]===u.shape[1],(()=>`Error in conv1d: depth of input (${l.shape[2]}) must match input depth for filter ${u.shape[1]}.`)),ie(bl(n,i),(()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${i}'`)),ie("NWC"===a,(()=>`Error in conv1d: got dataFormat of ${a} but only NWC is currently supported.`));const p=_l(u,[1,u.shape[0],u.shape[1],u.shape[2]]),d=_l(l,[l.shape[0],1,l.shape[1],l.shape[2]]),h=jl(d,p,[1,n],r,"NHWC",[1,i],s);return _l(h,c?[h.shape[2],h.shape[3]]:[h.shape[0],h.shape[2],h.shape[3]])}}),ql=Ai({conv2DBackpropInput_:function(e,t,n,r,a,i="NHWC",s){ie(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let o=e,u=t,l=!1;3===t.rank&&(l=!0,u=_l(t,[1,t.shape[0],t.shape[1],t.shape[2]]),o=[1,e[0],e[1],e[2]]),ie(4===o.length,(()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${o.length}.`)),ie(4===u.rank,(()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${u.rank}`)),ie(4===n.rank,(()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`));const c="NHWC"===i?o[3]:o[1],p="NHWC"===i?u.shape[3]:u.shape[1];ie(c===n.shape[2],(()=>`Error in conv2dDerInput: depth of input (${c}) must match input depth for filter ${n.shape[2]}.`)),ie(p===n.shape[3],(()=>`Error in conv2dDerInput: depth of output (${p}) must match output depth for filter ${n.shape[3]}.`)),vl("conv2dDerInput",a,s);const d={dy:u,filter:n},h={strides:r,pad:a,dataFormat:i,dimRoundingMode:s,inputShape:o},f=xi.runKernel(It,d,h);return l?_l(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),Wl=Ai({conv2dTranspose_:function(e,t,n,r,a,i){const s=Ii(e,"x","conv2dTranspose"),o=Ii(t,"filter","conv2dTranspose");return ql(n,s,o,r,a,"NHWC",i)}}),Vl=Ai({conv3d_:function(e,t,n,r,a="NDHWC",i=[1,1,1]){const s=Ii(e,"x","conv3d"),o=Ii(t,"filter","conv3d");let u=s,l=!1;4===s.rank&&(l=!0,u=_l(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),ie(5===u.rank,(()=>`Error in conv3d: input must be rank 5, but got rank ${u.rank}.`)),ie(5===o.rank,(()=>`Error in conv3d: filter must be rank 5, but got rank ${o.rank}.`)),ie(u.shape[4]===o.shape[3],(()=>`Error in conv3d: depth of input (${u.shape[4]}) must match input depth for filter ${o.shape[3]}.`)),ie(bl(n,i),(()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`)),ie("NDHWC"===a,(()=>`Error in conv3d: got dataFormat of ${a} but only NDHWC is currently supported.`));const c={x:u,filter:o},p={strides:n,pad:r,dataFormat:a,dilations:i},d=xi.runKernel(Et,c,p);return l?_l(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),Gl=Ai({conv3DBackpropInput_:function(e,t,n,r,a){ie(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let i=e,s=t,o=!1;4===t.rank&&(o=!0,s=_l(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),i=[1,e[0],e[1],e[2],e[3]]);const u=i[4],l=s.shape[4];ie(5===i.length,(()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${i.length}.`)),ie(5===s.rank,(()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${s.rank}`)),ie(5===n.rank,(()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`)),ie(u===n.shape[3],(()=>`Error in conv3dDerInput: depth of input (${u}) must match input depth for filter ${n.shape[3]}.`)),ie(l===n.shape[4],(()=>`Error in conv3dDerInput: depth of output (${l}) must match output depth for filter ${n.shape[4]}.`));const c={dy:s,filter:n},p={pad:a,strides:r,inputShape:i},d=xi.runKernel(At,c,p);return o?_l(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),Kl=Ai({conv3dTranspose_:function(e,t,n,r,a){const i=Ii(e,"x","conv3dTranspose"),s=Ii(t,"filter","conv3dTranspose");return Gl(n,i,s,r,a)}}),Jl=Ai({cos_:function(e){const t={x:Ii(e,"x","cos","float32")};return xi.runKernel(Lt,t)}}),Xl=Ai({cosh_:function(e){const t={x:Ii(e,"x","cosh","float32")};return xi.runKernel($t,t)}}),Zl=Ai({cumprod_:function(e,t=0,n=!1,r=!1){const a={x:Ii(e,"x","cumprod")},i={axis:t,exclusive:n,reverse:r};return xi.runKernel(Ot,a,i)}}),Ql=Ai({cumsum_:function(e,t=0,n=!1,r=!1){const a={x:Ii(e,"x","cumsum")},i={axis:t,exclusive:n,reverse:r};return xi.runKernel(Rt,a,i)}}),ec=Ai({denseBincount_:function(e,t,n,r=!1){const a=Ii(e,"x","denseBincount"),i=Ii(t,"weights","denseBincount");ie("int32"===a.dtype,(()=>`Error in denseBincount: input dtype must be int32, but got ${a.dtype}`)),ie(a.rank<=2,(()=>`Error in denseBincount: input must be at most rank 2, but got rank ${a.rank}.`)),ie(n>=0,(()=>`size must be non-negative, but got ${n}.`)),ie(i.size===a.size||0===i.size,(()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${a.shape}, weights shape: ${i.shape}.`));const s={x:a,weights:i},o={size:n,binaryOutput:r};return xi.runKernel(Yt,s,o)}}),tc=Ai({depthToSpace_:function(e,t,n="NHWC"){const r=Ii(e,"x","depthToSpace","float32"),a="NHWC"===n?r.shape[1]:r.shape[2],i="NHWC"===n?r.shape[2]:r.shape[3],s="NHWC"===n?r.shape[3]:r.shape[1];ie(t>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${t}`)),ie(a*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${a} and ${t} for depthToSpace with input shape\n ${r.shape}`)),ie(i*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${i} and ${t} for depthToSpace with input shape\n ${r.shape}`)),ie(s%(t*t)==0,(()=>`Dimension size must be evenly divisible by ${t*t} but is ${s} for depthToSpace with input shape ${r.shape}`));const o={x:r},u={blockSize:t,dataFormat:n};return xi.runKernel(zt,o,u)}}),nc=Ai({depthwiseConv2d_:function(e,t,n,r,a="NHWC",i=[1,1],s){const o=Ii(e,"x","depthwiseConv2d","float32"),u=Ii(t,"filter","depthwiseConv2d","float32");let l=o,c=!1;3===o.rank&&(c=!0,l=_l(o,[1,o.shape[0],o.shape[1],o.shape[2]])),ie(4===l.rank,(()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${l.rank}.`)),ie(4===u.rank,(()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${u.rank}.`)),ie(l.shape[3]===u.shape[2],(()=>`Error in depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${u.shape[2]}.`)),vl("depthwiseConv2d",r,s);const p={x:l,filter:u},d={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s},h=xi.runKernel(Bt,p,d);return c?_l(h,[h.shape[1],h.shape[2],h.shape[3]]):h}}),rc=Ai({diag_:function(e){const t={x:Ii(e,"x","diag")};return xi.runKernel(jt,t)}}),ac=Ai({dilation2d_:function(e,t,n,r,a=[1,1],i="NHWC"){const s=Ii(e,"x","dilation2d"),o=Ii(t,"filter","dilation2d");ie(3===s.rank||4===s.rank,(()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${s.rank}.`)),ie(3===o.rank,(()=>`Error in dilation2d: filter must be rank 3, but got rank ${o.rank}.`)),ie("NHWC"===i,(()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${i}`));let u=s,l=!1;3===s.rank&&(u=_l(s,[1,s.shape[0],s.shape[1],s.shape[2]]),l=!0);const c={x:u,filter:o},p={strides:n,pad:r,dilations:a},d=xi.runKernel(Ut,c,p);return l?_l(d,[d.shape[1],d.shape[2],d.shape[3]]):d}}),ic=Ai({equal_:function(e,t){let n=Ii(e,"a","equal","string_or_numeric"),r=Ii(t,"b","equal","string_or_numeric");[n,r]=ci(n,r),Co(n.shape,r.shape);const a={a:n,b:r};return xi.runKernel(Zt,a)}}),sc=Ai({where_:function(e,t,n){const r=Ii(t,"a","where"),a=Ii(n,"b","where"),i=Ii(e,"condition","where","bool"),s=Co(Co(i.shape,r.shape),a.shape),o={condition:Rl(i,s),t:Rl(r,s),e:Rl(a,s)};return xi.runKernel(vr,o)}}),oc=Ai({divNoNan_:function(e,t){let n=Ii(e,"a","div"),r=Ii(t,"b","div");[n,r]=ci(n,r);const a=wu(n,r),i=ku(a),s=ic(r,i);return sc(s,i,a)}}),uc=Ai({dot_:function(e,t){const n=Ii(e,"t1","dot"),r=Ii(t,"t2","dot");ie(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),(()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${r.rank}.`));const a=1===n.rank?n.size:n.shape[1],i=1===r.rank?r.size:r.shape[0];if(ie(a===i,(()=>`Error in dot: inner dimensions of inputs must match, but got ${a} and ${i}.`)),1===n.rank&&1===r.rank){const e=_l(n,[1,-1]),t=_l(r,[-1,1]),a=eo(e,t);return _l(a,[])}if(1===n.rank&&2===r.rank){const e=_l(n,[1,-1]),t=_l(r,[r.shape[0],r.shape[1]]),a=eo(e,t);return _l(a,[a.size])}if(2===n.rank&&1===r.rank){const e=_l(r,[-1,1]),t=eo(n,e);return _l(t,[t.size])}{const e=_l(r,[r.shape[0],r.shape[1]]);return eo(n,e)}}}),lc=Ai({einsum_:function(e,...t){const n=t.map(((e,t)=>Ii(e,`tensors${t}`,"einsum"))),r={equation:e};return xi.runKernel(Gt,n,r)}}),cc=Ai({elu_:function(e){const t={x:Ii(e,"x","elu","float32")};return xi.runKernel(Kt,t)}}),pc=Ai({erf_:function(e){let t=Ii(e,"x","erf");ie("int32"===t.dtype||"float32"===t.dtype,(()=>"Input dtype must be `int32` or `float32`.")),"int32"===t.dtype&&(t=Cs(t,"float32"));const n={x:t};return xi.runKernel(Xt,n)}});function dc(e,t){for(let n=0;ne[t]))]}function mc(e,t){return hc(e,t.map((e=>1)),t)}function gc(e,t,n){ie(dc(t,n),(()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`))}function yc(e,t){if(dc(e,t))return null;const n=[];for(let r=0;rn.push(e))),n}function bc(e){return e.map(((e,t)=>[t,e])).sort(((e,t)=>e[1]-t[1])).map((e=>e[0]))}function xc(e,t){const n=[];for(let r=t-e;r"Axis must be <= rank of the tensor"));const r={input:n},a={dim:t};return xi.runKernel(en,r,a)}}),Tc=Ai({expm1_:function(e){const t={x:Ii(e,"x","expm1")};return xi.runKernel(tn,t)}}),Ic=Ai({tile_:function(e,t){const n=Ii(e,"x","tile","string_or_numeric");ie(n.rank===t.length,(()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`));const r={x:n},a={reps:t};return xi.runKernel(Vr,r,a)}}),Ec=Ai({eye_:function(e,t,n,r="float32"){null==t&&(t=e);const a=Es([e,t],r),i=e<=t?e:t;for(let e=0;e`Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ${i.rank}.`)),ie(de(t),(()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`));let s=i,o=!1;3===i.rank&&(o=!0,s=_l(i,[1,i.shape[0],i.shape[1],i.shape[2]]));const u={x:s},l={depthRadius:t,bias:n,alpha:r,beta:a},c=xi.runKernel(En,u,l);return o?_l(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),jc=Ai({log_:function(e){const t={x:Ii(e,"x","log","float32")};return xi.runKernel(Mn,t)}}),Uc=Ai({log1p_:function(e){const t={x:Ii(e,"x","log1p")};return xi.runKernel(Nn,t)}}),qc=Ai({softplus_:function(e){const t={x:Ii(e,"x","softplus")};return xi.runKernel(Dr,t)}}),Wc=Ai({logSigmoid_:function(e){const t=Ii(e,"x","logSigmoid"),n=Au((e=>({value:So(qc(So(e))),gradFunc:t=>Mu(t,Sl(So(e)))})));return n(t)}}),Vc=Ai({logSoftmax_:function(e,t=-1){const n=Ii(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}`);const r=Au(((e,n)=>{const r=vc(e,t,!0),a=Bu(e,r),i=Bu(Cs(a,"float32"),jc(wc(kc(a),t,!0)));return n([i]),{value:i,gradFunc:(e,n)=>{const[r]=n,a=kc(r);return Bu(e,Mu(wc(e,t,!0),a))}}}));return r(n)}}),Gc=Ai({logSumExp_:function(e,t=null,n=!1){const r=Ii(e,"x","logSumExp"),a=xe(t,r.shape),i=vc(r,a,!0),s=Bu(r,i),o=kc(s),u=wc(o,a),l=jc(u),c=vu(_l(i,l.shape),l);if(n){const e=mc(c.shape,a);return _l(c,e)}return c}}),Kc=Ai({logicalAnd_:function(e,t){const n=Ii(e,"a","logicalAnd","bool"),r=Ii(t,"b","logicalAnd","bool");Co(n.shape,r.shape);const a={a:n,b:r};return xi.runKernel(Sn,a)}}),Jc=Ai({logicalNot_:function(e){const t={x:Ii(e,"x","logicalNot","bool")};return xi.runKernel(kn,t)}}),Xc=Ai({logicalOr_:function(e,t){const n=Ii(e,"a","logicalOr","bool"),r=Ii(t,"b","logicalOr","bool");Co(n.shape,r.shape);const a={a:n,b:r};return xi.runKernel(Dn,a)}}),Zc=Ai({logicalXor_:function(e,t){const n=Ii(e,"a","logicalXor","bool"),r=Ii(t,"b","logicalXor","bool");return Co(n.shape,r.shape),Kc(Xc(e,t),Jc(Kc(e,t)))}}),Qc=2147483648,ep=Ai({searchSorted_:function(e,t,n="left"){const r=Ii(e,"sortedSequence","searchSorted"),a=Ii(t,"values","searchSorted"),i=r.shape[r.shape.length-1],s=a.shape[a.shape.length-1],o=_l(r,[-1,i]),u=_l(a,[-1,s]);if(o.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(o.shape[0]!==u.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if(le(u.shape)>=Qc)throw new Error("values tensor size must less than 2147483648");if(o.shape[1]>=Qc)throw new Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${o.shape[1]}`);const l={sortedSequence:o,values:u},c={side:n};return xi.runKernel(xr,l,c)}});function tp(e,t){return ep(e,t,"left")}const np=Ai({maxPool_:function(e,t,n,r,a){const i=Ii(e,"x","maxPool");let s=i,o=!1;3===i.rank&&(o=!0,s=_l(i,[1,i.shape[0],i.shape[1],i.shape[2]])),ie(4===s.rank,(()=>`Error in maxPool: input must be rank 4 but got rank ${s.rank}.`)),ie(bl(n,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)),vl("maxPool",r,a);const u={x:s},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a},c=xi.runKernel($n,u,l);return o?_l(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),rp=Ai({maxPool3d_:function(e,t=[1,1,1],n,r,a,i="NDHWC"){const s=Ii(e,"x","maxPool3d");let o=s,u=!1;4===s.rank&&(u=!0,o=_l(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),ie(5===o.rank,(()=>`Error in maxPool3d: x must be rank 5 but got rank ${o.rank}.`)),ie("NDHWC"===i,(()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${i}`)),vl("maxPool3d",r,a);const l={x:o},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i},p=xi.runKernel(Rn,l,c);return u?_l(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}}),ap=Ai({maxPoolWithArgmax_:function(e,t,n,r,a=!1){const i={x:Ii(e,"x","maxPoolWithArgmax")},s={filterSize:t,strides:n,pad:r,includeBatchInIndex:a},o=xi.runKernel(Yn,i,s);return{result:o[0],indexes:o[1]}}}),ip=Ai({mean_:function(e,t=null,n=!1){const r={x:Ii(e,"x","mean")},a={axis:t,keepDims:n};return xi.runKernel(zn,r,a)}});function sp(e,t="float32"){if("complex64"===t){const t=sp(e,"float32"),n=sp(e,"float32");return Li(t,n)}const n=ze(le(e),t);return xi.makeTensor(n,e,t)}function op(e,t="float32"){if("complex64"===t){const t=op(e,"float32"),n=sp(e,"float32");return Li(t,n)}const n=Ye(le(e),t);return xi.makeTensor(n,e,t)}function up(e,t,{indexing:n="xy"}={}){if("xy"!==n&&"ij"!==n)throw new TypeError(`${n} is not a valid third argument to meshgrid`);if(void 0===e)return[];let r=Ii(e,"x","meshgrid",e instanceof Qa?e.dtype:"float32");if(void 0===t)return[r];let a=Ii(t,"y","meshgrid",t instanceof Qa?t.dtype:"float32");const i=le(r.shape),s=le(a.shape);return"xy"===n?(r=_l(r,[1,-1]),a=_l(a,[-1,1]),[eo(op([s,1],r.dtype),r),eo(a,op([1,i],a.dtype))]):(r=_l(r,[-1,1]),a=_l(a,[1,-1]),[eo(r,op([1,s],r.dtype)),eo(op([i,1],a.dtype),a)])}const lp=Ai({minimum_:function(e,t){let n=Ii(e,"a","minimum"),r=Ii(t,"b","minimum");[n,r]=ci(n,r),"bool"===n.dtype&&(n=Cs(n,"int32"),r=Cs(r,"int32")),Co(n.shape,r.shape);const a={a:n,b:r};return xi.runKernel(Pn,a)}}),cp=Ai({mirrorPad_:function(e,t,n){ie("reflect"===n||"symmetric"===n,(()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`));const r=Ii(e,"x","mirrorPad");if(0===r.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");ie(t.length===r.rank,(()=>`Padding doesn't match input. Must be ${r.rank}. Got ${t.length}.`));const a="reflect"===n?1:0;for(let e=0;e"Invalid number of paddings. Must be length of 2 each.")),ie(t[e][0]>=0&&t[e][0]<=r.shape[e]-a&&t[e][1]>=0&&t[e][1]<=r.shape[e]-a,(()=>`Padding in dimension ${e} cannot be greater than or equal to ${r.shape[e]-a} or less than 0 for input of shape ${r.shape}`));const i={paddings:t,mode:n},s={x:r};return xi.runKernel(Hn,s,i)}}),pp=Ai({mod_:function(e,t){let n=Ii(e,"a","mod"),r=Ii(t,"b","mod");[n,r]=ci(n,r);const a={a:n,b:r};return xi.runKernel(jn,a)}}),dp=Ai({moments_:function(e,t=null,n=!1){const r=xe(t,(e=Ii(e,"x","moments")).shape),a=ip(e,r,n);let i=a.shape;n||(i=mc(a.shape,r));const s=Su(Bu(Cs(e,"float32"),_l(a,i)));return{mean:a,variance:ip(s,r,n)}}}),hp=Ai({multiRNNCell_:function(e,t,n,r){const a=Ii(t,"data","multiRNNCell"),i=Ei(n,"c","multiRNNCell"),s=Ei(r,"h","multiRNNCell");let o=a;const u=[];for(let t=0;t2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${s}`);n=n||Math.random();const o={logits:1===s?_l(a,[1,-1]):a},u={numSamples:t,seed:n,normalized:r},l=xi.runKernel(Un,o,u);return 1===s?_l(l,[l.size]):l}}),mp=Ai({notEqual_:function(e,t){let n=Ii(e,"a","notEqual","string_or_numeric"),r=Ii(t,"b","notEqual","string_or_numeric");[n,r]=ci(n,r),Co(n.shape,r.shape);const a={a:n,b:r};return xi.runKernel(Vn,a)}}),gp=Ai({onesLike_:function(e){const t={x:Ii(e,"x","onesLike")};return xi.runKernel(Xn,t)}}),yp=Ai({outerProduct_:function(e,t){const n=Ii(e,"v1","outerProduct"),r=Ii(t,"v2","outerProduct");ie(1===n.rank&&1===r.rank,(()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${r.rank}.`));const a=_l(n,[-1,1]),i=_l(r,[1,-1]);return eo(a,i)}}),bp=Ai({pad_:function(e,t,n=0){const r=Ii(e,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const a={paddings:t,constantValue:n},i={x:r};return xi.runKernel(er,i,a)}}),xp=Ai({pad1d_:function(e,t,n=0){return ie(2===t.length,(()=>"Invalid number of paddings. Must be length of 2.")),bp(e,[t],n)}}),vp=Ai({pad2d_:function(e,t,n=0){return ie(2===t.length&&2===t[0].length&&2===t[1].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),bp(e,t,n)}}),_p=Ai({pad3d_:function(e,t,n=0){return ie(3===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),bp(e,t,n)}}),wp=Ai({pad4d_:function(e,t,n=0){return ie(4===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length&&2===t[3].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),bp(e,t,n)}}),Mp=Ai({spaceToBatchND_:function(e,t,n){const r=Ii(e,"x","spaceToBatchND");ie(r.rank>=1+t.length,(()=>`input rank ${r.rank} should be > than [blockShape] ${t.length}`)),ie(n.length===t.length,(()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`)),ie(r.shape.reduce(((e,r,a)=>a>0&&a<=t.length?e&&(r+n[a-1][0]+n[a-1][1])%t[a-1]==0:e),!0),(()=>`input spatial dimensions ${r.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`));const a={x:r},i={blockShape:t,paddings:n};return xi.runKernel(Er,a,i)}}),Np=Ai({pool_:function(e,t,n,r,a,i,s){null==a&&(a=[1,1]),null==i&&(i=1),0===r&&(r="valid");const o=Ii(e,"x","maxPool");let u=o,l=!1;3===o.rank&&(l=!0,u=_l(o,[1,o.shape[0],o.shape[1],o.shape[2]])),ie(bl(i,a),(()=>`Error in pool: Either strides or dilations must be 1. Got strides ${i} and dilations '${a}'`));const c=ul(u.shape,t,i,a,r),p=[c.dilationHeight,c.dilationWidth];let d;d="same"===r?function(e,t){const n=e.map(((e,n)=>e+(e-1)*(t[n]-1))),r=n.map((e=>e-1)),a=r.map((e=>Math.floor(e/2))),i=r.map(((e,t)=>e-a[t]));return r.map(((e,t)=>[a[t],i[t]]))}([c.filterHeight,c.filterWidth],p):[[0,0],[0,0]];const h=1===p[0]&&1===p[1],[f,m]=function(e,t,n){const r=n.map((e=>e[0])),a=n.map((e=>e[1])),i=e.concat(r,a),s=t.map(((e,t)=>(e-i[t]%e)%e)),o=a.map(((e,t)=>e+s[t])),u=t.map(((e,t)=>[r[t],o[t]])),l=t.map(((e,t)=>[0,s[t]]));return[u,l]}([c.inHeight,c.inWidth],p,d),g=h?r:"valid",y=h?u:Mp(u,p,f),b=("avg"===n?()=>wl(y,t,i,g,s):()=>np(y,t,i,g,s))(),x=h?b:Il(b,p,m);return l?_l(x,[x.shape[1],x.shape[2],x.shape[3]]):x}}),Sp=Ai({prelu_:function(e,t){const n={x:Ii(e,"x","prelu"),alpha:Ii(t,"alpha","prelu")};return xi.runKernel(rr,n)}}),kp=Ai({prod_:function(e,t=null,n=!1){let r=Ii(e,"x","prod");"bool"===r.dtype&&(r=Cs(r,"int32"));const a={x:r},i={axis:t,keepDims:n};return xi.runKernel(ar,a,i)}}),Dp=Ai({rand_:function(e,t,n){const r=le(e);let a=null;if(null==n||"float32"===n)a=new Float32Array(r);else if("int32"===n)a=new Int32Array(r);else{if("bool"!==n)throw new Error(`Unknown data type ${n}`);a=new Uint8Array(r)}for(let e=0;e=1||0===i);const s=Math.sqrt(-2*Math.log(i)/i);e=this.mean+this.stdDev*r*s,t=this.mean+this.stdDev*a*s,this.truncated&&!this.isValidTruncated(e)||(n=!0)}return this.truncated&&!this.isValidTruncated(t)||(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class Ep{constructor(e,t,n,r){this.alpha=e,this.beta=1/t,this.dtype=n;const a=r||Math.random();this.randu=Tp.alea(a.toString()),this.randn=new Ip(0,1,n,!1,this.randu()),this.d=e<1?e+2/3:e-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let e,t,n,r,a,i;for(;;){do{r=this.randn.nextValue(),i=1+this.c*r}while(i<=0);if(i*=i*i,e=r*r,t=1-.331*e*e,n=.5*e+this.d*(1-i+Math.log(i)),a=this.randu(),anull==this.dtype||"float32"===this.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=Tp.alea(r)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}const Ap=Ai({randomGamma_:function(e,t,n=1,r="float32",a){if(null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error(`Unsupported data type ${r}`);const i=new Ep(t,n,r,a),s=Es(e,r);for(let e=0;e`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`)),zp(t,0)}}),Pp=Ai({reverse2d_:function(e,t){const n=Ii(e,"x","reverse");return ie(2===n.rank,(()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`)),zp(n,t)}}),Hp=Ai({reverse3d_:function(e,t){const n=Ii(e,"x","reverse");return ie(3===n.rank,(()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`)),zp(n,t)}}),jp=Ai({reverse4d_:function(e,t){const n=Ii(e,"x","reverse");return ie(4===n.rank,(()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`)),zp(n,t)}}),Up=Ai({round_:function(e){const t={x:Ii(e,"x","round")};return xi.runKernel(gr,t)}}),qp=Ai({rsqrt_:function(e){const t={x:Ii(e,"x","rsqrt","float32")};return xi.runKernel(yr,t)}}),Wp=Ai({selu_:function(e){const t={x:Ii(e,"x","selu")};return xi.runKernel(_r,t)}}),Vp=Ai({separableConv2d_:function(e,t,n,r,a,i=[1,1],s="NHWC"){const o=Ii(e,"x","separableConv2d"),u=Ii(t,"depthwiseFilter","separableConv2d"),l=Ii(n,"pointwiseFilter","separableConv2d");let c=o,p=!1;if(3===o.rank&&(p=!0,c=_l(o,[1,o.shape[0],o.shape[1],o.shape[2]])),"NCHW"===s)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");ie(4===c.rank,(()=>`Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`)),ie(4===u.rank,(()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${u.rank}.`)),ie(4===l.rank,(()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${u.rank}.`)),ie(1===l.shape[0],(()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${l.shape[0]}.`)),ie(1===l.shape[1],(()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${l.shape[1]}.`));const d=u.shape[2],h=u.shape[3];ie(l.shape[2]===d*h,(()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${d*h}, but got ${l.shape[2]}.`));const f=nc(c,u,r,a,s,i),m=jl(f,l,1,"valid",s);return p?_l(m,[m.shape[1],m.shape[2],m.shape[3]]):m}}),Gp=async function(e,t){const n=Ii(e,"x","setdiff1d"),r=Ii(t,"y","setdiff1d");ie(n.dtype===r.dtype,(()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${r.dtype}).`)),ie(1===n.rank,(()=>`x should be 1D tensor, but got x (${n.shape}).`)),ie(1===r.rank,(()=>`y should be 1D tensor, but got y (${r.shape}).`));const a=await n.data(),i=await r.data(),s=new Set(i);let o=0;for(let e=0;e`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`)),kl(r,[t],[n])}}),Qp=Ai({slice2d_:function(e,t,n){const r=Ii(e,"x","slice2d");return ie(2===r.rank,(()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`)),kl(r,t,n)}}),ed=Ai({slice3d_:function(e,t,n){const r=Ii(e,"x","slice3d");return ie(3===r.rank,(()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`)),kl(r,t,n)}}),td=Ai({slice4d_:function(e,t,n){const r=Ii(e,"x","slice4d");return ie(4===r.rank,(()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`)),kl(r,t,n)}}),nd=Ai({softmax_:function(e,t=-1){const n=Ii(e,"logits","softmax","float32");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}`);const r={logits:n},a={dim:t};return xi.runKernel(Ar,r,a)}}),rd=Ai({fft_:function(e){ie("complex64"===e.dtype,(()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`));const t={input:e};return xi.runKernel(nn,t)}}),ad=Ai({ifft_:function(e){ie("complex64"===e.dtype,(()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`));const t={input:e};return xi.runKernel(fn,t)}}),id=Ai({irfft_:function(e){const t=e.shape[e.shape.length-1],n=e.size/t;let r;if(t<=2){const a=_l(e,[n,t]);r=ad(a)}else{const a=[n,2*(t-1)],i=_l(ko(e),[n,t]),s=_l(No(e),[n,t]),o=zp(kl(i,[0,1],[n,t-2]),1),u=Mu(zp(kl(s,[0,1],[n,t-2]),1),$u(-1)),l=Nl([i,o],1),c=Nl([s,u],1),p=_l(Li(l,c),[a[0],a[1]]);r=ad(p)}if(r=ko(r),3===e.rank&&0!==e.shape[0]){const t=r,n=e.shape[0];r=_l(r,[n,r.shape[0]/n,r.shape[1]]),t.dispose()}return r}}),sd=Ai({split_:function(e,t,n=0){const r={x:Ii(e,"x","split")},a={numOrSizeSplits:t,axis:n};return xi.runKernel(Cr,r,a)}}),od=Ai({rfft_:function(e,t){ie("float32"===e.dtype,(()=>`The dtype for rfft() must be real value but got ${e.dtype}`));let n=e.shape[e.shape.length-1];const r=e.size/n;let a;if(null!=t&&t0)),i=e.shape.map((e=>e));i[e.shape.length-1]=t,a=kl(e,r,i),n=t}else if(null!=t&&t>n){const r=e.shape.map((e=>e));r[e.shape.length-1]=t-n,a=Nl([e,sp(r)],e.shape.length-1),n=t}else a=e;const i=ku(a),s=_l(Li(a,i),[r,n]),o=rd(s),u=Math.floor(n/2)+1,l=ko(o),c=No(o),p=sd(l,[u,n-u],l.shape.length-1),d=sd(c,[u,n-u],c.shape.length-1),h=a.shape.slice();return h[a.shape.length-1]=u,_l(Li(p[0],d[0]),h)}}),ud=Ai({squaredDifference_:function(e,t){let n=Ii(e,"a","squaredDifference"),r=Ii(t,"b","squaredDifference");[n,r]=ci(n,r),Co(n.shape,r.shape);const a={a:n,b:r};return xi.runKernel(Yr,a,{})}}),ld=Ai({squeeze_:function(e,t){const n=Ii(e,"x","squeeze");return _l(n,ve(n.shape,t).newShape)}}),cd=Ai({stack_:function(e,t=0){const n=Ei(e,"tensors","stack","string_or_numeric");ie(n.length>=1,(()=>"Pass at least one tensor to tf.stack")),n.length>0&&ie(t<=n[0].rank,(()=>"Axis must be <= rank of the tensor"));const r=n,a={axis:t};return xi.runKernel(Qn,r,a)}}),pd=Ai({step_:function(e,t=0){const n={x:Ii(e,"x","step")},r={alpha:t};return xi.runKernel(na,n,r)}}),dd=Ai({stridedSlice_:function(e,t,n,r,a=0,i=0,s=0,o=0,u=0){const l={x:Ii(e,"x","stridedSlice","string_or_numeric")},c={begin:t,end:n,strides:r,beginMask:a,endMask:i,ellipsisMask:s,newAxisMask:o,shrinkAxisMask:u};return xi.runKernel(Br,l,c)}}),hd=Ai({tan_:function(e){const t={x:Ii(e,"x","tan","float32")};return xi.runKernel(qr,t)}});function fd(e,t){oe(e);const n=ki(e,t);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return $i(e,null,n,t)}function md(e,t,n){if(oe(e),null!=t&&2!==t.length)throw new Error("tensor2d() requires shape to have two numbers");const r=ki(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 $i(e,t,r,n)}function gd(e,t,n){if(oe(e),null!=t&&4!==t.length)throw new Error("tensor4d() requires shape to have four numbers");const r=ki(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 $i(e,t,r,n)}function yd(e,t,n){if(oe(e),null!=t&&5!==t.length)throw new Error("tensor5d() requires shape to have five numbers");const r=ki(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 $i(e,t,r,n)}function bd(e,t,n){if(oe(e),null!=t&&6!==t.length)throw new Error("tensor6d() requires shape to have six numbers");const r=ki(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 $i(e,t=t||r,r,n)}const xd=Ai({topk_:function(e,t=1,n=!0){const r=Ii(e,"x","topk");if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");const a=r.shape[r.shape.length-1];if(t<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${t}`);if(t>a)throw new Error(`'k' passed to topk() must be <= the last dimension (${a}) but got ${t}`);const i={x:r},s={k:t,sorted:n},[o,u]=xi.runKernel(Gr,i,s);return{values:o,indices:u}}}),vd=Ai({truncatedNormal_:function(e,t=0,n=1,r,a){if(null!=r&&"bool"===r)throw new Error("Unsupported data type $ { dtype }");const i=new Ip(t,n,r,!0,a),s=Es(e,r);for(let e=0;e0,(()=>"The input tensor must be at least 1D"));const r={x:n},a={axis:t},[i,s]=xi.runKernel(Xr,r,a);return{values:i,indices:s}}}),wd=Ai({unsortedSegmentSum_:function(e,t,n){const r=Ii(e,"x","unsortedSegmentSum"),a=Ii(t,"segmentIds","unsortedSegmentSum","int32");ie(de(n),(()=>"numSegments must be of dtype int"));const i={x:r,segmentIds:a},s={numSegments:n};return xi.runKernel(Qr,i,s)}}),Md=Ai({unstack_:function(e,t=0){const n=Ii(e,"x","unstack","string_or_numeric");ie(t>=-n.shape.length&&t`Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`));const r={value:n},a={axis:t};return xi.runKernel(Zr,r,a)}});function Nd(e,t){return ep(e,t,"right")}function Sd(e,t=!0,n,r){return xi.makeVariable(e,t,n,r)}function kd(e,t){const n=[];for(let e=0;e0,(()=>"mask cannot be scalar")),se(o.slice(i,i+s),a.shape,"mask's shape must match the first K dimensions of tensor's shape,");let u=1;for(let e=i;e"Shape mismatch in v and x"));const u=$u(1),l=Bu(u,o);let c=Mu(Bu(s,i),l);if(a){ie(null!=r,(()=>"When using zeroDebias: true, step is required."));const e=Ii(r,"step","movingAverage");c=wu(c,Bu(u,zu(o,e)))}return vu(i,c)}}),Ed=Ai({scatterND_:function(e,t,n){const r=Ii(e,"indices","scatterND","int32"),a=Ii(t,"updates","scatterND");Bo(a,r,n);const i={indices:r,updates:a},s={shape:n};return xi.runKernel(br,i,s)}}),Cd=Ai({sparseToDense_:function(e,t,n,r=0){const a=Ii(e,"sparseIndices","sparseToDense","int32"),i=Ii(t,"sparseValues","sparseToDense","string_or_numeric"),s=Ii(r,"defaultValue","sparseToDense",i.dtype);!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}.`);const a=e.rank>0?e.shape[0]:1,i=e.rank>1?e.shape[1]:1;if(n.length!==i)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${i}.`);const s=t.size;if(0!==t.rank&&(1!==t.rank||s!==a))throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${a}]`);if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(a,i,n,s);const o={sparseIndices:a,sparseValues:i,defaultValue:s},u={outputShape:n};return xi.runKernel(Fr,o,u)}}),Ad=Ai({gatherND_:function(e,t){const n=Ii(t,"indices","gatherND","int32"),r={params:Ii(e,"x","gatherND","string_or_numeric"),indices:n};return xi.runKernel(cn,r)}}),Ld=Ai({dropout_:function(e,t,n,r){const a=Ii(e,"x","dropout");if(ie("float32"===a.dtype,(()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${a.dtype} tensor instead.`)),ie(t>=0&&t<1,(()=>`rate must be a float in the range [0, 1), but got ${t}.`)),0===t)return e instanceof Qa?a.clone():a;const i=function(e,t){if(null==t)return e.shape.slice();if(pe(e.shape,t))return t;if(e.shape.length===t.length){const n=[];for(let r=0;r1,(()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`)),ie(r.rank-1===a.rank,(()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${a.rank}`)),se(r.shape.slice(0,r.shape.length-1),a.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const i=r.shape[r.shape.length-1];ie(n>0&&n<=i,(()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${i}), but got ${n}`));const s=await r.data(),o=await a.data(),[u,l]=[s.length/i,i],c=_e("bool",u);for(let e=0;et.value-e.value)),c[e]=0;for(let t=0;t`Error in conv2dDerFilter: input must be rank 4, but got shape ${o.shape}.`)),ie(4===u.rank,(()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${u.shape}.`)),ie(4===n.length,(()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`));const l="NHWC"===i?o.shape[3]:o.shape[1],c="NHWC"===i?u.shape[3]:u.shape[1];ie(l===n[2],(()=>`Error in conv2dDerFilter: depth of input ${l}) must match input depth in filter (${n[2]}.`)),ie(c===n[3],(()=>`Error in conv2dDerFilter: depth of dy (${c}) must match output depth for filter (${n[3]}).`)),vl("conv2dDerFilter",a,s);const p={x:o,dy:u},d={strides:r,pad:a,dataFormat:i,dimRoundingMode:s,filterShape:n};return xi.runKernel(Tt,p,d)}});function Yd(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return Mu(e,pd(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function zd(e,t){let n=t;const r=Eo(e.shape,t.shape);return r.length>0&&(n=wc(n,r)),_l(n,e.shape)}function Bd(e,t,n,r){if("linear"===t)return e;if("relu"===t)return Fp(e);if("elu"===t)return cc(e);if("relu6"===t)return Yp(e);if("prelu"===t)return Sp(e,n);if("leakyrelu"===t)return Yc(e,r);if("sigmoid"===t)return Sl(e);throw new Error(`Unknown fused activation ${t}.`)}const Pd=(e,t)=>!(e>0)||"linear"===t,Hd=Ai({fusedConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:i=[1,1],dimRoundingMode:s,bias:o,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(u=u||"linear",!1===Pd(xi.state.gradientDepth,u)){ie("NHWC"===a,(()=>`Error in fused conv2d: got dataFormat of ${a} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`));let p=jl(e,t,n,r,a,i,s);return null!=o&&(p=vu(p,o)),Bd(p,u,l,c)}const p=Ii(e,"x","conv2d","float32"),d=Ii(t,"filter","conv2d","float32");let h=p,f=!1;3===p.rank&&(f=!0,h=_l(p,[1,p.shape[0],p.shape[1],p.shape[2]])),ie(4===h.rank,(()=>`Error in fused conv2d: input must be rank 4, but got rank ${h.rank}.`)),ie(4===d.rank,(()=>`Error in fused conv2d: filter must be rank 4, but got rank ${d.rank}.`)),vl("fused conv2d",r,s);const m="NHWC"===a?h.shape[3]:h.shape[1];ie(d.shape[2]===m,(()=>`Error in conv2d: depth of input (${m}) must match input depth for filter ${d.shape[2]}.`)),ie(bl(n,i),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`));const g=cl(h.shape,d.shape,n,i,r,s);let y,b;if(null!=o&&(y=Ii(o,"bias","fused conv2d"),[y]=ci(y,p),"NHWC"===a?Co(g.outShape,y.shape):(ie(y.shape.length<=1,(()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${y.shape.length}.`)),ie(0===y.shape.length||y.shape[0]===g.outChannels||1===y.shape[0],(()=>`Error in fused conv2d: bias shape (${y.shape}) is not compatible with the number of output channels (${g.outChannels})`)))),null!=l){const e=l.shape;if(ie(e.length<=1||3===e.length,(()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${e.length}.`)),1===e.length)ie(1===e[0]||e[0]===g.outChannels,(()=>`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the number of output channels (${g.outChannels}).`));else if(3===e.length)try{Co(e,g.outShape)}catch(t){const n=`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the output shape of the conv2d (${g.outShape}).`;throw Error(n)}b=Ii(l,"prelu weights","fused conv2d")}const x=(e,t)=>{ie("NHWC"===a,(()=>`Error in gradient of fused conv2D: got dataFormat of ${a} but only NHWC is currently supported.`));const[s,o,l,c]=t,p=Yd(e,l,u);ie(yl(i),(()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${i}'`));const d=[ql(o.shape,p,s,n,r),Fd(o,p,s.shape,n,r)];if(null!=c){const e=zd(c,p);d.push(e)}return d},v={x:h,filter:d,bias:y,preluActivationWeights:b},_={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s,activation:u,leakyreluAlpha:c};if(null==o){const e=Au(((e,t,n)=>{let r=xi.runKernel(sa,v,_);return n([t,e,r]),f&&(r=_l(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:x}}));return e(h,d)}{const e=Au(((e,t,n,r)=>{let a=xi.runKernel(sa,v,_);return r([t,e,a,n]),f&&(a=_l(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:x}}));return e(h,d,y)}}}),jd=Ai({depthwiseConv2dNativeBackpropFilter_:function(e,t,n,r,a,i=[1,1],s){let o=e;3===e.rank&&(o=_l(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let u=t;3===u.rank&&(u=_l(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const l={x:o,dy:u},c={strides:r,pad:a,dimRoundingMode:s,dilations:i,filterShape:n};return xi.runKernel(Pt,l,c)}}),Ud=Ai({depthwiseConv2dNativeBackpropInput_:function(e,t,n,r,a,i=[1,1],s){let o=t,u=!1;3===t.rank&&(u=!0,o=_l(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const l={dy:o,filter:n},c={strides:r,pad:a,dimRoundingMode:s,dilations:i,inputShape:e},p=xi.runKernel(Ht,l,c);return u?_l(p,[p.shape[1],p.shape[2],p.shape[3]]):p}}),qd=Ai({fusedDepthwiseConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:i=[1,1],dimRoundingMode:s,bias:o,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(!1===Pd(xi.state.gradientDepth,u)){let p=nc(e,t,n,r,a,i,s);return null!=o&&(p=vu(p,o)),Bd(p,u,l,c)}const p=Ii(e,"x","depthwiseConv2d","float32"),d=Ii(t,"filter","depthwiseConv2d","float32");let h=p,f=!1;3===p.rank&&(f=!0,h=_l(p,[1,p.shape[0],p.shape[1],p.shape[2]])),ie(4===h.rank,(()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${h.rank}.`)),ie(4===d.rank,(()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${d.rank}.`)),ie(h.shape[3]===d.shape[2],(()=>`Error in fused depthwiseConv2d: number of input channels (${h.shape[3]}) must match the inChannels dimension in filter ${d.shape[2]}.`)),null==i&&(i=[1,1]),ie(bl(n,i),(()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`)),vl("fused depthwiseConv2d",r,s);const m=cl(h.shape,d.shape,n,i,r,s,!0);let g,y;null!=o&&(g=Ii(o,"bias","fused conv2d"),[g]=ci(g,p),Co(m.outShape,g.shape)),null!=l&&(y=Ii(l,"prelu weights","fused depthwiseConv2d"));const b=(e,t)=>{ie(yl(i),(()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${i}'`));const[a,o,l,c]=t,p=Yd(e,l,u),d=Ud(o.shape,p,a,n,r,i,s),h=jd(o,p,a.shape,n,r,i,s);return null!=c?[d,h,zd(g,p)]:[d,h]},x={x:h,filter:d,bias:g,preluActivationWeights:y},v={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s,activation:u,leakyreluAlpha:c};if(null==o){const e=Au(((e,t,n)=>{let r=xi.runKernel(oa,x,v);return n([t,e,r]),f&&(r=_l(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:b}}));return e(h,d)}{const e=Au(((e,t,n,r)=>{let a=xi.runKernel(oa,x,v);return r([t,e,a,n]),f&&(a=_l(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:b}}));return e(h,d,g)}}}),Wd=Ai({fusedMatMul_:function({a:e,b:t,transposeA:n=!1,transposeB:r=!1,bias:a,activation:i="linear",preluActivationWeights:s,leakyreluAlpha:o}){if(!1===Pd(xi.state.gradientDepth,i)){let u=eo(e,t,n,r);return null!=a&&(u=vu(u,a)),Bd(u,i,s,o)}let u=Ii(e,"a","fused matMul"),l=Ii(t,"b","fused matMul");[u,l]=ci(u,l);const c=n?u.shape[u.rank-2]:u.shape[u.rank-1],p=r?l.shape[l.rank-1]:l.shape[l.rank-2],d=n?u.shape[u.rank-1]:u.shape[u.rank-2],h=r?l.shape[l.rank-2]:l.shape[l.rank-1],f=u.shape.slice(0,-2),m=l.shape.slice(0,-2),g=le(f),y=le(m);ie(c===p,(()=>`Error in fused matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${u.shape} and ${l.shape} and transposeA=${n} and transposeB=${r} must match.`));const b=Co(u.shape.slice(0,-2),l.shape.slice(0,-2)).concat([d,h]),x=_l(u,n?[g,c,d]:[g,d,c]),v=_l(l,r?[y,h,p]:[y,p,h]);let _,w;null!=a&&(_=Ii(a,"bias","fused matMul"),[_]=ci(_,u),Co(b,_.shape)),null!=s&&(w=Ii(s,"prelu weights","fused matMul"));const M=(e,t)=>{const[s,o,u,l]=t,c=Yd(_l(e,u.shape),u,i);let p,d;return n||r?!n&&r?(p=eo(c,o,!1,!1),d=eo(c,s,!0,!1)):n&&!r?(p=eo(o,c,!1,!0),d=eo(s,c,!1,!1)):(p=eo(o,c,!0,!0),d=eo(c,s,!0,!0)):(p=eo(c,o,!1,!0),d=eo(s,c,!0,!1)),null!=a?[p,d,zd(l,c)]:[p,d]},N={a:x,b:v,bias:_,preluActivationWeights:w},S={transposeA:n,transposeB:r,activation:i,leakyreluAlpha:o};if(null==a){const e=Au(((e,t,n)=>{const r=xi.runKernel(ia,N,S);return n([e,t,r]),{value:_l(r,b),gradFunc:M}}));return e(x,v)}{const e=Au(((e,t,n,r)=>{const a=xi.runKernel(ia,N,S);return r([e,t,a,n]),{value:_l(a,b),gradFunc:M}}));return e(x,v,_)}}}),Vd=Ai({hammingWindow_:function(e){return Od(e,.54,.46)}}),Gd=Ai({hannWindow_:function(e){return Od(e,.5,.5)}}),Kd=Ai({frame_:function(e,t,n,r=!1,a=0){let i=0;const s=[];for(;i+t<=e.size;)s.push(kl(e,i,t)),i+=n;if(r)for(;i`Error in cropAndResize: image must be rank 4,but got rank ${s.rank}.`)),ie(2===o.rank&&4===o.shape[1],(()=>`Error in cropAndResize: boxes must be have size [${l},4] but had shape ${o.shape}.`)),ie(1===u.rank&&u.shape[0]===l,(()=>`Error in cropAndResize: boxInd must be have size [${l}] but had shape ${o.shape}.`)),ie(2===r.length,(()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`)),ie(r[0]>=1&&r[1]>=1,(()=>`cropSize must be atleast [1,1], but was ${r}`)),ie("bilinear"===a||"nearest"===a,(()=>`method must be bilinear or nearest, but was ${a}`));const c={image:s,boxes:o,boxInd:u},p={method:a,extrapolationValue:i,cropSize:r};return xi.runKernel(Ft,c,p)}}),Zd=Ai({flipLeftRight_:function(e){const t=Ii(e,"image","flipLeftRight","float32");ie(4===t.rank,(()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`));const n={image:t};return xi.runKernel(an,n,{})}}),Qd=Ai({grayscaleToRGB_:function(e){const t=Ii(e,"image","grayscaleToRGB"),n=t.rank-1,r=t.shape[n];ie(t.rank>=2,(()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`)),ie(1===r,(()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`));const a=new Array(t.rank);return a.fill(1,0,n),a[n]=3,Ic(t,a)}}),eh=Ai({rotateWithOffset_:function(e,t,n=0,r=.5){const a=Ii(e,"image","rotateWithOffset","float32");ie(4===a.rank,(()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${a.rank}.`));const i={image:a},s={radians:t,fillValue:n,center:r};return xi.runKernel(aa,i,s)}});function th(e,t,n,r,a,i){null==r&&(r=.5),null==a&&(a=Number.NEGATIVE_INFINITY),null==i&&(i=0);const s=e.shape[0];return n=Math.min(n,s),ie(0<=r&&r<=1,(()=>`iouThreshold must be in [0, 1], but was '${r}'`)),ie(2===e.rank,(()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`)),ie(4===e.shape[1],(()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`)),ie(1===t.rank,(()=>"scores must be a 1D tensor")),ie(t.shape[0]===s,(()=>`scores has incompatible shape with boxes. Expected ${s}, but was ${t.shape[0]}`)),ie(0<=i&&i<=1,(()=>`softNmsSigma must be in [0, 1], but was '${i}'`)),{maxOutputSize:n,iouThreshold:r,scoreThreshold:a,softNmsSigma:i}}const nh=Ai({nonMaxSuppression_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const i=Ii(e,"boxes","nonMaxSuppression","float32"),s=Ii(t,"scores","nonMaxSuppression","float32"),o=th(i,s,n,r,a),u={maxOutputSize:n=o.maxOutputSize,iouThreshold:r=o.iouThreshold,scoreThreshold:a=o.scoreThreshold};return xi.runKernel(Gn,{boxes:i,scores:s},u)}});function rh(e,t,n){const r=function(e,t,n){return function(e,t,n){let r=0,a=e.length,i=0,s=!1;for(;r>>1);const o=n(t,e[i]);o>0?r=i+1:(a=i,s=!o)}return s?r:-r-1}(e,t,n||ah)}(e,t,n),a=r<0?-(r+1):r;e.splice(a,0,t)}function ah(e,t){return e>t?1:ea&&l.push({score:t[e],boxIndex:e,suppressBeginIndex:0});l.sort(ph);const c=i>0?-.5/i:0,p=[],d=[];for(;p.length0;){const t=l.pop(),{score:n,boxIndex:i,suppressBeginIndex:s}=t;if(n=s;--n){const s=lh(e,i,p[n]);if(s>=r){o=!0;break}if(t.score=t.score*ch(r,c,s),t.score<=a)break}t.suppressBeginIndex=p.length,o||(t.score===n?(p.push(i),d.push(t.score)):t.score>a&&rh(l,t,ph))}const h=p.length,f=n-h;o&&f>0&&(p.push(...new Array(f).fill(0)),d.push(...new Array(f).fill(0)));const m={selectedIndices:p};return s&&(m.selectedScores=d),u&&(m.validOutputs=h),m}function lh(e,t,n){const r=e.subarray(4*t,4*t+4),a=e.subarray(4*n,4*n+4),i=Math.min(r[0],r[2]),s=Math.min(r[1],r[3]),o=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),l=Math.min(a[0],a[2]),c=Math.min(a[1],a[3]),p=Math.max(a[0],a[2]),d=Math.max(a[1],a[3]),h=(o-i)*(u-s),f=(p-l)*(d-c);if(h<=0||f<=0)return 0;const m=Math.max(i,l),g=Math.max(s,c),y=Math.min(o,p),b=Math.min(u,d),x=Math.max(y-m,0)*Math.max(b-g,0);return x/(h+f-x)}function ch(e,t,n){const r=Math.exp(t*n*n);return n<=e?r:0}function ph(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}const dh=Ai({nonMaxSuppressionWithScore_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=0){const s=Ii(e,"boxes","nonMaxSuppression"),o=Ii(t,"scores","nonMaxSuppression"),u=th(s,o,n,r,a,i),l={boxes:s,scores:o},c={maxOutputSize:n=u.maxOutputSize,iouThreshold:r=u.iouThreshold,scoreThreshold:a=u.scoreThreshold,softNmsSigma:i=u.softNmsSigma},p=xi.runKernel(Jn,l,c);return{selectedIndices:p[0],selectedScores:p[1]}}}),hh=Ai({nonMaxSuppressionPadded_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=!1){const s=Ii(e,"boxes","nonMaxSuppression"),o=Ii(t,"scores","nonMaxSuppression"),u=th(s,o,n,r,a,null),l={boxes:s,scores:o},c={maxOutputSize:u.maxOutputSize,iouThreshold:u.iouThreshold,scoreThreshold:u.scoreThreshold,padToMaxOutputSize:i},p=xi.runKernel(Kn,l,c);return{selectedIndices:p[0],validOutputs:p[1]}}}),fh=Ai({resizeBilinear_:function(e,t,n=!1,r=!1){const a=Ii(e,"images","resizeBilinear");ie(3===a.rank||4===a.rank,(()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${a.rank}.`)),ie(2===t.length,(()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`)),ie(!1===r||!1===n,(()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false."));let i=a,s=!1;3===a.rank&&(s=!0,i=_l(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const[]=t,o={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=xi.runKernel(dr,o,u);return s?_l(l,[l.shape[1],l.shape[2],l.shape[3]]):l}}),mh=Ai({resizeNearestNeighbor_:function(e,t,n=!1,r=!1){const a=Ii(e,"images","resizeNearestNeighbor");ie(3===a.rank||4===a.rank,(()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${a.rank}.`)),ie(2===t.length,(()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`)),ie("float32"===a.dtype||"int32"===a.dtype,(()=>"`images` must have `int32` or `float32` as dtype")),ie(!1===r||!1===n,(()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."));let i=a,s=!1;3===a.rank&&(s=!0,i=_l(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const[]=t,o={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=xi.runKernel(cr,o,u);return s?_l(l,[l.shape[1],l.shape[2],l.shape[3]]):l}}),gh=Ai({threshold_:function(e,t="binary",n=!1,r=.5){const a=Ii(e,"image","threshold"),i=a.shape[0]*a.shape[1];let s,o,u,l,c=Mu(fd([r]),255);if(ie(3===a.rank,(()=>`Error in threshold: image must be rank 3,but got rank ${a.rank}.`)),ie(3===a.shape[2]||1===a.shape[2],(()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${a.shape[2]}.`)),ie("int32"===a.dtype||"float32"===a.dtype,(()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${a.dtype}.`)),ie("otsu"===t||"binary"===t,(()=>`Method must be binary or otsu, but was ${t}`)),3===a.shape[2]){[s,o,u]=sd(a,[1,1,1],-1);const e=Mu(s,.2989),t=Mu(o,.587),n=Mu(u,.114);l=vu(vu(e,t),n)}else l=e;"otsu"===t&&(c=function(e,t){let n,r,a,i,s,o,u=fd([-1]),l=fd([0]),c=fd([0]);for(let p=0;p`Error in transform: image must be rank 4,but got rank ${s.rank}.`)),ie(2===o.rank&&(o.shape[0]===s.shape[0]||1===o.shape[0])&&8===o.shape[1],(()=>"Error in transform: Input transform should be batch x 8 or 1 x 8")),ie(null==i||2===i.length,(()=>`Error in transform: outputShape must be [height, width] or null, but got ${i}.`));const u={image:s,transforms:o},l={interpolation:n,fillMode:r,fillValue:a,outputShape:i};return xi.runKernel(Kr,u,l)}}),bh=Ai({bandPart_:function(e,t,n){ie(t%1==0,(()=>`bandPart(): numLower must be an integer, got ${t}.`)),ie(n%1==0,(()=>`bandPart(): numUpper must be an integer, got ${n}.`));const r=Ii(e,"a","bandPart");ie(r.rank>=2,(()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`));const a=r.shape,[i,s]=r.shape.slice(-2);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);const o=_l(Op(0,i,1,"int32"),[-1,1]),u=Op(0,s,1,"int32"),l=Bu(o,u),c=Kc(Bc(l,$u(+t,"int32")),$c(l,$u(-n,"int32"))),p=sp([i,s],r.dtype);return _l(cd(Md(_l(r,[-1,i,s])).map((e=>sc(c,e,p)))),a)}}),xh=Ai({gramSchmidt_:function(e){let t;if(Array.isArray(e)){t=!1,ie(null!=e&&e.length>0,(()=>"Gram-Schmidt process: input must not be null, undefined, or empty"));const n=e[0].shape[0];for(let t=1;t`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${n})`))}else t=!0,e=sd(e,e.shape[0],0).map((e=>ld(e,[0])));ie(e.length<=e[0].shape[0],(()=>`Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`));const n=[],r=e;for(let t=0;t{let e=r[t];if(t>0)for(let r=0;r{ie(2===e.shape.length,(()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`));const n=e.shape[0],r=e.shape[1];let a=Ec(n),i=As(e);const s=md([[1]],[1,1]);let o=As(s);const u=n>=r?r:n;for(let e=0;e{const t=kl(i,[e,e],[n-e,1]),u=Nc(t),l=kl(i,[e,e],[1,1]),c=sc(Lc(l,0),md([[-1]]),md([[1]])),p=Bu(l,Mu(c,u)),d=wu(t,p);o=1===d.shape[0]?As(s):Nl([s,kl(d,[1,0],[d.shape[0]-1,d.shape[1]])],0);const h=So(wu(eo(c,p),u)),f=kl(i,[e,0],[n-e,r]),m=Mu(h,o),g=Do(o);if(0===e)i=Bu(f,eo(m,eo(g,f)));else{const t=Bu(f,eo(m,eo(g,f)));i=Nl([kl(i,[0,0],[e,r]),t],0)}const y=Do(m),b=kl(a,[0,e],[n,a.shape[1]-e]);if(0===e)a=Bu(b,eo(eo(b,o),y));else{const t=Bu(b,eo(eo(b,o),y));a=Nl([kl(a,[0,0],[n,e]),t],1)}return[o,i,a]})),po([t,u,l])}return!t&&n>r&&(a=kl(a,[0,0],[n,r]),i=kl(i,[0,0],[r,r])),[a,i]}))}const _h=Ai({qr_:function(e,t=!1){if(ie(e.rank>=2,(()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`)),2===e.rank)return vh(e,t);{const n=e.shape.slice(0,e.shape.length-2).reduce(((e,t)=>e*t)),r=Md(_l(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],i=[];return r.forEach((e=>{const[n,r]=vh(e,t);a.push(n),i.push(r)})),[_l(cd(a,0),e.shape),_l(cd(i,0),e.shape)]}}});var wh;!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"}(wh||(wh={}));const Mh=Ai({computeWeightedLoss_:function(e,t,n=wh.SUM_BY_NONZERO_WEIGHTS){const r=Ii(e,"losses","computeWeightedLoss");let a=null;null!=t&&(a=Ii(t,"weights","computeWeightedLoss"));const i=null==a?r:Mu(r,a);if(n===wh.NONE)return i;if(n===wh.SUM)return wc(i);if(n===wh.MEAN){if(null==a)return ip(i);{const e=r.size/a.size,t=wu(wc(i),wc(a));return e>1?wu(t,$u(e)):t}}if(n===wh.SUM_BY_NONZERO_WEIGHTS){if(null==a)return wu(wc(i),$u(r.size));{const e=Mu(a,op(r.shape)),t=Cs(wc(mp(e,$u(0))),"float32");return wu(wc(i),t)}}throw Error(`Unknown reduction: ${n}`)}}),Nh=Ai({absoluteDifference_:function(e,t,n,r=wh.SUM_BY_NONZERO_WEIGHTS){const a=Ii(e,"labels","absoluteDifference"),i=Ii(t,"predictions","absoluteDifference");let s=null;null!=n&&(s=Ii(n,"weights","absoluteDifference")),se(a.shape,i.shape,"Error in absoluteDifference: ");const o=Hu(Bu(a,i));return Mh(o,s,r)}}),Sh=Ai({cosineDistance_:function(e,t,n,r,a=wh.SUM_BY_NONZERO_WEIGHTS){const i=Ii(e,"labels","cosineDistance"),s=Ii(t,"predictions","cosineDistance");let o=null;null!=r&&(o=Ii(r,"weights","cosineDistance")),se(i.shape,s.shape,"Error in cosineDistance: ");const u=$u(1),l=Bu(u,wc(Mu(i,s),n,!0));return Mh(l,o,a)}}),kh=Ai({hingeLoss_:function(e,t,n,r=wh.SUM_BY_NONZERO_WEIGHTS){let a=Ii(e,"labels","hingeLoss");const i=Ii(t,"predictions","hingeLoss");let s=null;null!=n&&(s=Ii(n,"weights","hingeLoss")),se(a.shape,i.shape,"Error in hingeLoss: ");const o=$u(1);a=Bu(Mu($u(2),a),o);const u=Fp(Bu(o,Mu(a,i)));return Mh(u,s,r)}}),Dh=Ai({huberLoss_:function(e,t,n,r=1,a=wh.SUM_BY_NONZERO_WEIGHTS){const i=Ii(e,"labels","huberLoss"),s=Ii(t,"predictions","huberLoss");let o=null;null!=n&&(o=Ii(n,"weights","huberLoss")),se(i.shape,s.shape,"Error in huberLoss: ");const u=$u(r),l=Hu(Bu(s,i)),c=lp(l,u),p=Bu(l,c),d=vu(Mu($u(.5),Su(c)),Mu(u,p));return Mh(d,o,a)}}),Th=Ai({logLoss_:function(e,t,n,r=1e-7,a=wh.SUM_BY_NONZERO_WEIGHTS){const i=Ii(e,"labels","logLoss"),s=Ii(t,"predictions","logLoss");let o=null;null!=n&&(o=Ii(n,"weights","logLoss")),se(i.shape,s.shape,"Error in logLoss: ");const u=$u(1),l=$u(r),c=So(Mu(i,jc(vu(s,l)))),p=Mu(Bu(u,i),jc(vu(Bu(u,s),l))),d=Bu(c,p);return Mh(d,o,a)}}),Ih=Ai({meanSquaredError_:function(e,t,n,r=wh.SUM_BY_NONZERO_WEIGHTS){const a=Ii(e,"labels","meanSquaredError"),i=Ii(t,"predictions","meanSquaredError");let s=null;null!=n&&(s=Ii(n,"weights","meanSquaredError")),se(a.shape,i.shape,"Error in meanSquaredError: ");const o=ud(a,i);return Mh(o,s,r)}}),Eh=Ai({sigmoidCrossEntropy_:function(e,t,n,r=0,a=wh.SUM_BY_NONZERO_WEIGHTS){let i=Ii(e,"multiClassLabels","sigmoidCrossEntropy");const s=Ii(t,"logits","sigmoidCrossEntropy");let o=null;if(null!=n&&(o=Ii(n,"weights","sigmoidCrossEntropy")),se(i.shape,s.shape,"Error in sigmoidCrossEntropy: "),r>0){const e=$u(r),t=$u(1),n=$u(.5);i=vu(Mu(i,Bu(t,e)),Mu(n,e))}const u=function(e,t){const n=Ii(e,"labels","sigmoidCrossEntropyWithLogits"),r=Ii(t,"logits","sigmoidCrossEntropyWithLogits");se(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");const a=Fp(r),i=Mu(r,n),s=Uc(kc(So(Hu(r))));return vu(Bu(a,i),s)}(i,s);return Mh(u,o,a)}}),Ch=Ai({softmaxCrossEntropy_:function(e,t,n,r=0,a=wh.SUM_BY_NONZERO_WEIGHTS){let i=Ii(e,"onehotLabels","softmaxCrossEntropy");const s=Ii(t,"logits","softmaxCrossEntropy");let o=null;if(null!=n&&(o=Ii(n,"weights","softmaxCrossEntropy")),se(i.shape,s.shape,"Error in softmaxCrossEntropy: "),r>0){const e=$u(r),t=$u(1),n=$u(i.shape[1]);i=vu(Mu(i,Bu(t,e)),wu(e,n))}const u=function(e,t,n=-1){if(-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}`);const r=Au(((e,t,r)=>{const a=Gc(t,[n],!0),i=Bu(Cs(t,"float32"),a);r([e,i]);const s=So(Mu(i,e));return{value:wc(s,[n]),gradFunc:(e,t)=>{const[r,a]=t,i=mc(e.shape,[n]);return[Mu(_l(e,i),Bu(Cs(r,"float32"),kc(a))),Mu(_l(e,i),Bu(kc(a),Cs(r,"float32")))]}}}));return r(e,t)}(i,s);return Mh(u,o,a)}}),Ah=Ai({sparseFillEmptyRows_:function(e,t,n,r){const a=Ii(e,"indices","sparseFillEmptyRows","int32"),i=Ii(t,"values","sparseFillEmptyRows"),s=Ii(n,"denseShape","sparseFillEmptyRows","int32"),o=Ii(r,"defaultValue","sparseFillEmptyRows",i.dtype);if(2!==a.rank)throw new Error(`Indices should be Tensor2D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Values should be Tensor1D but received shape ${i.shape}`);if(1!==s.rank)throw new Error(`Dense shape should be Tensor1D but received shape ${s.shape}`);if(0!==o.rank)throw new Error(`Default value should be a scalar but received shape ${o.shape}`);const u={indices:a,values:i,denseShape:s,defaultValue:o},l=xi.runKernel(Lr,u);return{outputIndices:l[0],outputValues:l[1],emptyRowIndicator:l[2],reverseIndexMap:l[3]}}}),Lh=Ai({sparseReshape_:function(e,t,n){const r=Ii(e,"inputIndices","sparseReshape","int32"),a=Ii(t,"inputShape","sparseReshape","int32"),i=Ii(n,"newShape","sparseReshape","int32");if(2!==r.rank)throw new Error(`Input indices should be Tensor2D but received shape\n ${r.shape}`);if(1!==a.rank)throw new Error(`Input shape should be Tensor1D but received shape ${a.shape}`);if(1!==i.rank)throw new Error(`New shape should be Tensor1D but received shape ${i.shape}`);const s={inputIndices:r,inputShape:a,newShape:i},o=xi.runKernel($r,s);return{outputIndices:o[0],outputShape:o[1]}}}),$h=Ai({sparseSegmentMean_:function(e,t,n){const r=Ii(e,"data","sparseSegmentMean"),a=Ii(t,"indices","sparseSegmentMean","int32"),i=Ii(n,"segmentIds","sparseSegmentMean","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${i.shape}`);const s={data:r,indices:a,segmentIds:i};return xi.runKernel(Or,s)}}),Oh=Ai({sparseSegmentSum_:function(e,t,n){const r=Ii(e,"data","sparseSegmentSum"),a=Ii(t,"indices","sparseSegmentSum","int32"),i=Ii(n,"segmentIds","sparseSegmentSum","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${i.shape}`);const s={data:r,indices:a,segmentIds:i};return xi.runKernel(Rr,s)}}),Rh=Ai({stringNGrams_:function(e,t,n,r,a,i,s,o){const u=Ii(e,"data","stringNGrams","string");if("string"!==u.dtype)throw new Error("Data must be of datatype string");if(1!==u.shape.length)throw new Error(`Data must be a vector, saw: ${u.shape}`);const l=Ii(t,"dataSplits","stringNGrams");if("int32"!==l.dtype)throw new Error("Data splits must be of datatype int32");const c={separator:n,nGramWidths:r,leftPad:a,rightPad:i,padWidth:s,preserveShortSequences:o},p={data:u,dataSplits:l},d=xi.runKernel(Pr,p,c);return{nGrams:d[0],nGramsSplits:d[1]}}}),Fh=Ai({stringSplit_:function(e,t,n=!0){const r=Ii(e,"input","stringSplit","string"),a=Ii(t,"delimiter","stringSplit","string");if(1!==r.rank)throw new Error(`Input should be Tensor1D but received shape ${r.shape}`);if(0!==a.rank)throw new Error(`Delimiter should be a scalar but received shape ${a.shape}`);const i={skipEmpty:n},s={input:r,delimiter:a},o=xi.runKernel(Hr,s,i);return{indices:o[0],values:o[1],shape:o[2]}}}),Yh=Ai({stringToHashBucketFast_:function(e,t){const n=Ii(e,"input","stringToHashBucketFast","string"),r={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");const a={input:n};return xi.runKernel(jr,a,r)}}),zh={fft:rd,ifft:ad,rfft:od,irfft:id},Bh={hammingWindow:Vd,hannWindow:Gd,frame:Kd,stft:Jd},Ph={flipLeftRight:Zd,grayscaleToRGB:Qd,resizeNearestNeighbor:mh,resizeBilinear:fh,rotateWithOffset:eh,cropAndResize:Xd,nonMaxSuppression:nh,nonMaxSuppressionAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const i=Ii(e,"boxes","nonMaxSuppressionAsync"),s=Ii(t,"scores","nonMaxSuppressionAsync"),o=th(i,s,n,r,a);n=o.maxOutputSize,r=o.iouThreshold,a=o.scoreThreshold;const u=await Promise.all([i.data(),s.data()]),l=u[0],c=u[1],{selectedIndices:p}=ih(l,c,n,r,a);return i!==e&&i.dispose(),s!==t&&s.dispose(),fd(p,"int32")},nonMaxSuppressionWithScore:dh,nonMaxSuppressionWithScoreAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=0){const s=Ii(e,"boxes","nonMaxSuppressionAsync"),o=Ii(t,"scores","nonMaxSuppressionAsync"),u=th(s,o,n,r,a,i);n=u.maxOutputSize,r=u.iouThreshold,a=u.scoreThreshold,i=u.softNmsSigma;const l=await Promise.all([s.data(),o.data()]),c=l[0],p=l[1],{selectedIndices:d,selectedScores:h}=oh(c,p,n,r,a,i);return s!==e&&s.dispose(),o!==t&&o.dispose(),{selectedIndices:fd(d,"int32"),selectedScores:fd(h)}},nonMaxSuppressionPadded:hh,nonMaxSuppressionPaddedAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=!1){const s=Ii(e,"boxes","nonMaxSuppressionAsync"),o=Ii(t,"scores","nonMaxSuppressionAsync"),u=th(s,o,n,r,a,null),l=u.maxOutputSize,c=u.iouThreshold,p=u.scoreThreshold,[d,h]=await Promise.all([s.data(),o.data()]),{selectedIndices:f,validOutputs:m}=sh(d,h,l,c,p,i);return s!==e&&s.dispose(),o!==t&&o.dispose(),{selectedIndices:fd(f,"int32"),validOutputs:$u(m,"int32")}},threshold:gh,transform:yh},Hh={bandPart:bh,gramSchmidt:xh,qr:_h},jh={absoluteDifference:Nh,computeWeightedLoss:Mh,cosineDistance:Sh,hingeLoss:kh,huberLoss:Dh,logLoss:Th,meanSquaredError:Ih,sigmoidCrossEntropy:Eh,softmaxCrossEntropy:Ch},Uh={sparseFillEmptyRows:Ah,sparseReshape:Lh,sparseSegmentMean:$h,sparseSegmentSum:Oh},qh={stringNGrams:Rh,stringSplit:Fh,stringToHashBucketFast:Yh},Wh={sgd:Gu.sgd,momentum:Gu.momentum,adadelta:Gu.adadelta,adagrad:Gu.adagrad,rmsprop:Gu.rmsprop,adamax:Gu.adamax,adam:Gu.adam},Vh="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:e=>e();function Gh(){return new Promise((e=>Vh((()=>e()))))}function Kh(e,t){const n=e[0].length;e.forEach(((e,t)=>{ie(e.length===n,(()=>`Error in concat${n}D: rank of tensors[${t}] must be the same as the rank of the rest (${n})`))})),ie(t>=0&&t`Error in concat${n}D: axis must be between 0 and ${n-1}.`));const r=e[0];e.forEach(((e,a)=>{for(let i=0;i`Error in concat${n}D: Shape of tensors[${a}] (${e}) does not match the shape of the rest (${r}) along the non-concatenated axis ${a}.`))}))}function Jh(e,t){const n=e[0].slice();for(let r=1;r=2*t+1||r%2==1?a.push(r):n.push(r);r.push(...n),r.push(0),r.push(...a)}return r}function nf(e,t,n,r=!0){const a=[];r?a.push(e[0]/n):a.push(e[0]*n);for(let n=1;n/g;function Mf(e,t){const n=((e=e.replace(/\s/g,"")).length-e.replace(wf,"").length)/"->".length;if(n<1)throw new Error("Equations without an arrow are not supported.");if(n>1)throw new Error('Equation must contain exactly one arrow ("->").');const[r,a]=e.split("->");ie(-1===r.indexOf("..."),(()=>'The ellipsis notation ("...") is not supported yet.'));const i=r.split(","),s=i.length;if(t!==s)throw new Error(`Expected ${s} input tensors, received ${t}`);if(s>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const o=[];for(let e=0;e-1!==e.indexOf(t))))throw new Error(`Output subscripts contain the label ${t} not present in the input subscripts.`);-1===o.indexOf(t)&&o.push(t)}for(let e=0;e-1!==e)),{permutationIndices:n,expandDims:r}}function Sf(e,t,n){const r=new Array(e);for(let e=0;e`Expected dimension ${r[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(a)}, but got dimension ${a[n]}`))}}function kf(e,t){const n=e,r=[];let a=0;0===e.length&&n.push(-1),a=e.length+1;for(let e=0;ee===t))}function Tf(e,t){const n=[];for(let r=0;r"Number of splits must evenly divide the axis.")),r=new Array(t).fill(e.shape[n]/t);else{const a=t.reduce(((e,t)=>(-1===t&&(e+=1),e)),0);ie(a<=1,(()=>"There should be only one negative value in split array."));const i=t.indexOf(-1);if(-1!==i){const r=t.reduce(((e,t)=>t>0?e+t:e));t[i]=e.shape[n]-r}ie(e.shape[n]===t.reduce(((e,t)=>e+t)),(()=>"The sum of sizes must match the size of the axis dimension.")),r=t}return r}function Ef(e){return`Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = ${e}`}function Cf(e,t){return`indices(${e}, 0) is invalid: ${t} < 0`}function Af(e,t,n){return`indices(${e}, 0) is invalid: ${t} >= ${n}`}function Lf(e,t){return`only one output dimension may be -1, not both ${e} and ${t}`}function $f(e,t){return`size ${e} must be non-negative, not ${t}`}function Of(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function Rf(e,t){return`Input to reshape is a SparseTensor with ${le(e)}\n dense values, but the requested shape requires a multiple of ${le(t)}. inputShape=${e} outputShape= ${t}`}function Ff(e,t){return`Input to reshape is a tensor with ${le(e)} dense values, but the requested shape has ${le(t)}. inputShape=${e} outputShape=${t}`}function Yf(){return"segment ids must be >= 0"}function zf(){return"segment ids are not increasing"}function Bf(e,t){return`Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.`}function Pf(e,t,n){return`Bad: indices[${e}] == ${t} out of range [0, ${n})`}function Hf(e,t){let n,r=!1;for(e<=Xh?(n=e,r=!0):n=$e(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=$e(e,n+1);return n}function jf(e,t,n){const r=[],a=e.length;for(let i=0;ia))throw new Error(`Expect batchDims in the range of [-${a}, ${a}], but got ${r}`);if(r<0&&(r+=a),r>i)throw new Error(`batchDims (${r}) must be less than rank(x) (\n ${i}).`);if(nBa(e)))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function Wf(e){return e.map((e=>za(e)))}const Vf={kernelName:Ze,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,pd(Cs(n,"float32"),-1))}}},Gf={kernelName:Qe,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=Su(Cs(n,"float32")),r=Nu(Bu($u(1),t));return So(wu(e,r))}}}},Kf={kernelName:et,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=Nu(Bu(Su(Cs(n,"float32")),1));return wu(e,t)}}}},Jf={kernelName:tt,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Co(n.shape,r.shape);return{a:()=>{let t=e;const r=Eo(n.shape,a);return r.length>0&&(t=wc(t,r)),_l(t,n.shape)},b:()=>{let t=e;const n=Eo(r.shape,a);return n.length>0&&(t=wc(t,n)),_l(t,r.shape)}}}},Xf={kernelName:nt,saveAllInputs:!0,gradFunc:(e,t)=>{const n={};return t.forEach(((t,r)=>{n[r]=()=>e.clone()})),n}},Zf={kernelName:it,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>ku(n)}}},Qf={kernelName:st,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>ku(n)}}},em={kernelName:ot,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>wu(e,Nu(Bu($u(1),Su(Cs(n,"float32")))))}}},tm={kernelName:ut,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=Nu(vu($u(1),Su(Cs(n,"float32"))));return wu(e,t)}}}},nm={kernelName:pt,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Co(n.shape,r.shape);return{a:()=>{const t=vu(Su(n),Su(r));let i=Mu(e,wu(r,t));const s=Eo(n.shape,a);return s.length>0&&(i=wc(i,s)),_l(i,n.shape)},b:()=>{const t=vu(Su(n),Su(r));let i=So(Mu(e,wu(n,t)));const s=Eo(r.shape,a);return s.length>0&&(i=wc(i,s)),_l(i,r.shape)}}}},rm={kernelName:lt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>wu(e,vu(Su(Cs(n,"float32")),1))}}},am={kernelName:ct,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>wu(e,Bu($u(1),Su(Cs(n,"float32"))))}}},im=Ai({avgPool3dGrad_:function(e,t,n,r,a,i){const s=Ii(e,"dy","avgPool3dGrad"),o=Ii(t,"input","avgPool3dGrad");let u=s,l=o,c=!1;4===o.rank&&(c=!0,u=_l(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]]),l=_l(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),ie(5===u.rank,(()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`)),ie(5===l.rank,(()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${l.rank}.`)),vl("avgPool3dGrad",a,i);const p={dy:u,input:l},d={filterSize:n,strides:r,pad:a,dimRoundingMode:i},h=xi.runKernel(mt,p,d);return c?_l(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}}),sm={kernelName:ft,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{filterSize:a,strides:i,pad:s,dimRoundingMode:o}=n;return{x:()=>im(e,r,a,i,s,o)}}},om=Ai({avgPoolGrad_:function(e,t,n,r,a){const i=Ii(e,"dy","avgPoolGrad"),s=Ii(t,"input","avgPoolGrad");ie(s.rank===i.rank,(()=>`Rank of input (${s.rank}) does not match rank of dy (${i.rank})`));let o=s,u=i,l=!1;3===s.rank&&(l=!0,o=_l(s,[1,s.shape[0],s.shape[1],s.shape[2]]),u=_l(i,[1,i.shape[0],i.shape[1],i.shape[2]])),ie(4===u.rank,(()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${u.rank}.`)),ie(4===o.rank,(()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${o.rank}.`));const c={dy:u,input:o},p={filterSize:n,strides:r,pad:a},d=xi.runKernel(ht,c,p);return l?_l(d,[d.shape[1],d.shape[2],d.shape[3]]):d}}),um={kernelName:dt,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{filterSize:a,strides:i,pad:s}=n;return{x:()=>om(e,r,a,i,s)}}},lm={kernelName:gt,inputsToSave:["a","b"],gradFunc:(e,t,n)=>{const[r,a]=t,{transposeA:i,transposeB:s}=n;return i||s?!i&&s?{a:()=>eo(e,a,!1,!1),b:()=>eo(e,r,!0,!1)}:i&&!s?{a:()=>eo(a,e,!1,!0),b:()=>eo(r,e,!1,!1)}:{a:()=>eo(a,e,!0,!0),b:()=>eo(e,r,!0,!0)}:{a:()=>eo(e,a,!1,!0),b:()=>eo(r,e,!0,!1)}}},cm={kernelName:yt,gradFunc:(e,t,n)=>{const{blockShape:r,crops:a}=n;return{x:()=>Mp(e,r,a)}}},pm={kernelName:xt,gradFunc:(e,t,n)=>{const r=n,a=r.inputShape,i=r.shape,s=Array.from(i);for(let e=a.length-1;e>=0;e--)if(a[e]===i[e])s[e]=1;else if(1!==a[e])throw new Error(`broadcastTo(): [${a}] cannot be broadcast to [${i}].`);const o=[];for(let e=0;e1&&o.push(e);return{x:()=>wc(e,o,!0)}}},dm={kernelName:_t,gradFunc:e=>({x:()=>e.clone()})},hm={kernelName:wt,gradFunc:e=>({x:()=>ku(e)})},fm={kernelName:Mt,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{clipValueMin:a,clipValueMax:i}=n;return{x:()=>sc(Kc($c(r,a),Bc(r,i)),e,ku(e))}}},mm={kernelName:St,inputsToSave:["x"],gradFunc:Vf.gradFunc},gm={kernelName:kt,saveAllInputs:!0,gradFunc:(e,t,n)=>{const r=t.map((e=>e.shape)),{axis:a}=n,i=xe(a,t[0].shape)[0],s=r.map((e=>e[i]));return sd(e,s,i).map((e=>()=>e))}},ym={kernelName:Dt,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const[r,a]=t,{dilations:i,strides:s,pad:o,dataFormat:u}=n;return ie(yl(i),(()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${i}'`)),{x:()=>ql(r.shape,e,a,s,o,u),filter:()=>Fd(r,e,a.shape,s,o,u)}}},bm={kernelName:It,inputsToSave:["dy","filter"],gradFunc:(e,t,n)=>{const[r,a]=t,{strides:i,pad:s,dataFormat:o,dimRoundingMode:u}=n;return{dy:()=>jl(e,a,i,s,o,1,u),filter:()=>Fd(e,r,a.shape,i,s,o,u)}}},xm=Ai({conv3DBackpropFilter_:function(e,t,n,r,a){let i=e;4===e.rank&&(i=_l(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));let s=t;4===s.rank&&(s=_l(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),ie(5===i.rank,(()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${i.shape}.`)),ie(5===s.rank,(()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${s.shape}.`)),ie(5===n.length,(()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`)),ie(i.shape[4]===n[3],(()=>`Error in conv3dDerFilter: depth of input ${i.shape[4]}) must match input depth in filter (${n[3]}.`)),ie(s.shape[4]===n[4],(()=>`Error in conv3dDerFilter: depth of dy (${s.shape[4]}) must match output depth for filter (${n[4]}).`));const o={x:i,dy:s},u={strides:r,pad:a,filterShape:n};return xi.runKernel(Ct,o,u)}}),vm={kernelName:Et,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const{dilations:r,strides:a,pad:i}=n;ie(yl(r),(()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`));const[s,o]=t;return{x:()=>Gl(s.shape,e,o,a,i),filter:()=>xm(s,e,o.shape,a,i)}}},_m={kernelName:Lt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(So(Jp(Cs(n,"float32"))),e)}}},wm={kernelName:$t,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(Xp(Cs(n,"float32")),e)}}},Mm={kernelName:Rt,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{axis:a,exclusive:i,reverse:s}=n;return{x:()=>{const t=yc([a],r.rank);let n=Ql(e,a,i,!s);return null!=t&&(n=Do(n,t)),n}}}},Nm={kernelName:Bt,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const{dilations:r,strides:a,pad:i,dimRoundingMode:s}=n,o=null==r?[1,1]:r;ie(yl(o),(()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${o}'`));const[u,l]=t;return ie(4===u.rank,(()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${u.rank}.`)),ie(4===l.rank,(()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${l.rank}.`)),ie(u.shape[3]===l.shape[2],(()=>`Error in gradient of depthwiseConv2d: number of input channels (${u.shape[3]}) must match the inChannels dimension in filter ${l.shape[2]}.`)),ie(bl(a,o),(()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${o}'.`)),vl("depthwiseConv2d",i,s),{x:()=>Ud(u.shape,e,l,a,i,o,s),filter:()=>jd(u,e,l.shape,a,i,o,s)}}},Sm={kernelName:Ut,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const[r,a]=t,i={x:r,filter:a,dy:e},s={x:r,filter:a,dy:e};return{x:()=>xi.runKernel(qt,i,n),filter:()=>xi.runKernel(Wt,s,n)}}},km={kernelName:Kt,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t,r={dy:e,y:n};return{x:()=>xi.runKernel(Jt,r)}}},Dm={kernelName:Xt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t,r=Mu(kc(So(Su(n))),2/Math.sqrt(Math.PI));return{x:()=>Mu(e,r)}}},Tm={kernelName:Qt,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,n)}}},Im={kernelName:en,inputsToSave:["input"],gradFunc:(e,t)=>{const[n]=t;return{input:()=>_l(e,n.shape)}}},Em={kernelName:tn,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,kc(n))}}},Cm={kernelName:sn,gradFunc:e=>({x:()=>ku(e)})},Am={kernelName:on,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Co(n.shape,r.shape);return{a:()=>{const t=wu(e,Cs(r,"float32")),i=Eo(n.shape,a);return i.length>0?_l(wc(t,i),n.shape):t},b:()=>{let t=Mu(e,Cs(n,"float32"));const i=Eo(r.shape,a);i.length>0&&(t=_l(wc(t,i),r.shape));const s=Su(r);return So(wu(t,Cs(s,"float32")))}}}},Lm={kernelName:un,inputsToSave:["x","mean","variance","scale"],gradFunc:(e,t,n)=>{const{varianceEpsilon:r}=n,[a,i,s,o]=t,u=null==o?$u(1):o,l=Eo(i.shape,a.shape),c=[];if(1===i.rank){for(let e=0;e1===i.rank?_l(Mu(Mu(e,Ic(_l(h,[1,1,1,i.shape[0]]),c)),u),a.shape):_l(Mu(Mu(e,h),u),a.shape),mean:()=>{let e=Mu(Mu(h,$u(-1)),d);return 1===i.rank&&(e=wc(e,l)),_l(e,i.shape)},variance:()=>{let e=Mu(Mu(f,p),d);return 1===i.rank&&(e=wc(e,l)),_l(e,i.shape)},scale:()=>{const t=Mu(p,h);let n=Mu(e,t);return 1===i.rank&&(n=wc(n,l)),_l(n,i.shape)},offset:()=>{let t=e;return 1===i.rank&&(t=wc(t,l)),_l(t,i.shape)}}}},$m={kernelName:ln,inputsToSave:["x","indices"],gradFunc:(e,t,n)=>{const[r,a]=t,{axis:i}=n,s=xe(i,r.shape)[0];return{x:()=>{const t=r.shape,n=a.size,o=t.slice(0,s),u=o.length,l=t.slice(i,t.length).slice(1),c=l.length,p=Om(0,u),d=Om(u+1,u+1+c),h=Rm([o,[n],l]),f=_l(e,h),m=_l(a,[n]),g=Rm([[u],p,d]),y=Do(f,g);let b=wd(y,m,r.shape[s]);const x=bc(g);return b=Do(b,x),b},indices:()=>a}}};function Om(e,t){const n=[];for(let r=e;r{const[n,r]=t;return{a:()=>ku(n),b:()=>ku(r)}}},Ym={kernelName:hn,gradFunc:e=>({x:()=>Cs(e,"float32")})},zm={kernelName:gn,gradFunc:e=>({x:()=>ku(e)})},Bm={kernelName:yn,gradFunc:e=>({x:()=>ku(e)})},Pm={kernelName:bn,gradFunc:e=>({x:()=>ku(e)})},Hm={kernelName:xn,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{alpha:a}=n,i=Lc(r,0);return{x:()=>sc(i,e,Mu(e,a))}}},jm={kernelName:Nn,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>wu(e,vu(n,1))}}},Um={kernelName:Mn,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>wu(e,Cs(n,"float32"))}}},qm={kernelName:Tn,inputsToSave:[],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r]=t,{axis:a}=n;return{logits:()=>{const t=kc(r);return Bu(e,Mu(wc(e,a,!0),t))}}}},Wm=Ai({localResponseNormalizationBackprop_:function(e,t,n,r=5,a=1,i=1,s=.5){const o={x:e,y:t,dy:n},u={depthRadius:r,bias:a,alpha:i,beta:s};return xi.runKernel(Cn,o,u)}}),Vm={kernelName:En,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r,a]=t,{depthRadius:i,bias:s,alpha:o,beta:u}=n;return{x:()=>Wm(r,a,e,i,s,o,u)}}};function Gm(e,t,n,r){return t.rankMu(e,Cs(ic(n,t),e.dtype))}}const Km={kernelName:An,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const r=n,{reductionIndices:a}=r,i=t[0],s=Gm(e,t[1],i,xe(a,i.shape));return{x:()=>s.x()}}},Jm={kernelName:Ln,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t;return{a:()=>Mu(e,Cs($c(n,r),"float32")),b:()=>Mu(e,Cs(zc(n,r),"float32"))}}},Xm=Ai({maxPool3dGrad_:function(e,t,n,r,a,i,s){const o=Ii(e,"dy","maxPool3dGrad"),u=Ii(t,"input","maxPool3dGrad"),l=Ii(n,"output","maxPool3dGrad");let c=o,p=u,d=l,h=!1;4===u.rank&&(h=!0,c=_l(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),p=_l(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]]),d=_l(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]])),ie(5===c.rank,(()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${c.rank}.`)),ie(5===p.rank,(()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${p.rank}.`)),ie(5===d.rank,(()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${d.rank}.`)),vl("maxPool3dGrad",i,s);const f={dy:c,input:p,output:d},m={filterSize:r,strides:a,pad:i,dimRoundingMode:s},g=xi.runKernel(Fn,f,m);return h?_l(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}}),Zm={kernelName:Rn,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r,a]=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=n;return{x:()=>Xm(e,r,a,i,s,o,u)}}},Qm=Ai({maxPoolGrad_:function(e,t,n,r,a,i,s){const o=Ii(e,"dy","maxPoolGrad"),u=Ii(t,"input","maxPoolGrad"),l=Ii(n,"output","maxPoolGrad");ie(u.rank===o.rank,(()=>`Rank of input (${u.rank}) does not match rank of dy (${o.rank})`)),ie(4===o.rank,(()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${o.rank}.`)),ie(4===u.rank,(()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${u.rank}.`)),vl("maxPoolGrad",i,s);const c={dy:o,input:u,output:l},p={filterSize:r,strides:a,pad:i,dimRoundingMode:s};return xi.runKernel(On,c,p)}}),eg={kernelName:$n,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r,a]=t,{filterSize:i,strides:s,pad:o}=n;return{x:()=>Qm(e,r,a,i,s,o)}}},tg={kernelName:zn,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{axis:a}=n,i=xe(a,r.shape),s=le(fc(r.shape,i)[1]);return{x:()=>{const t=r.shape.slice();i.forEach((e=>{t[e]=1}));const n=_l(e,t);return wu(Mu(n,op(r.shape,"float32")),s)}}}},ng={kernelName:Bn,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const r=n,{axis:a}=r,[i,s]=t,o=Gm(e,s,i,xe(a,i.shape));return{x:()=>o.x()}}},rg={kernelName:Hn,inputsToSave:["x"],gradFunc:(e,t,n)=>{const r=t[0],{paddings:a}=n,i=a.map((e=>e[0]));return{x:()=>kl(e,i,r.shape)}}},ag={kernelName:Qn,saveAllInputs:!0,gradFunc:(e,t,n)=>{const{axis:r}=n;return Md(e,r).map((e=>()=>e))}},ig={kernelName:er,inputsToSave:["x"],gradFunc:(e,t,n)=>{const r=t[0],{paddings:a}=n,i=a.map((e=>e[0]));return{x:()=>kl(e,i,r.shape)}}},sg={kernelName:nr,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(e,t)=>{const[n,r,a]=t,i=n,s=r,o=Co(i.shape,s.shape);return{a:()=>{const t=Cs(s,"float32");let n=Mu(e,Mu(t,zu(i,Bu(t,$u(1)))));const r=Eo(i.shape,o);return r.length>0&&(n=wc(n,r)),_l(n,i.shape)},b:()=>{const t=Lc(i,0),n=sc(t,jc(i),ku(i));let r=Mu(e,Mu(a,n));const u=Eo(s.shape,o);return u.length>0&&(r=wc(r,u)),_l(r,s.shape)}}}};const og={kernelName:ar,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{axis:a}=n;let i=[];return i=null==a?r.shape.map(((e,t)=>t)):"number"==typeof a?[a]:a,{x:()=>function(e,t,n){const r=e.shape.length,a=r-n.length,i=yc(n,r);let s=e;null!=i&&(s=Do(e,i));const o=s.shape.slice(),u=o.splice(r-n.length,n.length).reduce(((e,t)=>e*t),1);o.push(u);let l=function(e,t,n){const r=e.shape.slice();r[n]=1;const a=_l(t,r),i=Zl(e,n,!0,!1),s=Zl(e,n,!0,!0),o=Mu(i,s);return Mu(a,o)}(s.reshape(o),t,a);if(l=l.reshape(s.shape),null!=i){const e=bc(i);l=Do(l,e)}return l}(r,e,i)}}},ug={kernelName:_r,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=Lc(n,$u(0)),r=$u(sf),a=$u(of),i=Mu(e,a),s=Mu(Mu(e,r),kc(Cs(n,"float32")));return sc(t,i,s)}}}},lg={kernelName:wr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{begin:a,size:i}=n,s=r.shape,[o,u]=nu(r,a,i),l=[];for(let t=0;tbp(e,l)}}},cg={kernelName:Er,gradFunc:(e,t,n)=>{const{blockShape:r,paddings:a}=n;return{x:()=>Il(e,r,a)}}},pg={kernelName:Cr,gradFunc:(e,t,n)=>{const{axis:r}=n;return{x:()=>Nl(e,r)}}},dg={kernelName:Ir,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,a=r.shape.slice(),{axis:i}=n;xe(i,r.shape).forEach((e=>{a[e]=1}));const s=_l(e,a),o=Mu(s,op(r.shape,"float32"));return{x:()=>o}}},hg={kernelName:Vr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{reps:a}=n;return{x:()=>{let t=ku(r);if(1===r.rank)for(let n=0;n{const r=n,{axis:a}=r;return{value:()=>cd(e,a)}}},mg={kernelName:Qr,inputsToSave:["segmentIds"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>function(e,t){const n=ju(t,ku(t)),r=Ac(e,n);let a=$c(t,$u(0,"int32"));const i=r.rank-a.rank;for(let e=0;e{const[n,r]=t,a=Co(n.shape,r.shape);return{a:()=>{const t=wu(e,Cs(r,"float32")),i=Eo(n.shape,a);return i.length>0?_l(wc(t,i),n.shape):t},b:()=>{let t=Mu(e,Cs(n,"float32"));const i=Eo(r.shape,a);i.length>0&&(t=_l(wc(t,i),r.shape));const s=Su(r);return So(wu(t,Cs(s,"float32")))}}}},km,Dm,Tm,Im,Em,Am,Cm,Lm,$m,Fm,Ym,zm,Bm,Pm,Hm,jm,Um,qm,Vm,Km,Km,Jm,Zm,eg,tg,ng,{kernelName:Pn,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t;return{a:()=>Mu(e,Cs(Bc(n,r),"float32")),b:()=>Mu(e,Cs(Lc(n,r),"float32"))}}},rg,{kernelName:jn,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Co(n.shape,r.shape);return{a:()=>{const t=Eo(n.shape,a);return t.length>0?_l(wc(e,t),n.shape):e},b:()=>{const t=Mu(e,So(Cc(wu(n,r)))),i=Eo(r.shape,a);return i.length>0?_l(wc(t,i),r.shape):t}}}},{kernelName:qn,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Co(n.shape,r.shape);return{a:()=>{const t=Mu(e,Cs(r,"float32")),i=Eo(n.shape,a);return i.length>0?_l(wc(t,i),n.shape):t},b:()=>{const t=Mu(e,Cs(n,"float32")),i=Eo(r.shape,a);return i.length>0?_l(wc(t,i),r.shape):t}}}},{kernelName:Wn,gradFunc:e=>({x:()=>So(e)})},{kernelName:Zn,inputsToSave:["indices"],gradFunc:(e,t)=>{const n=t[0];return{indices:()=>sp(n.shape,"float32")}}},{kernelName:Xn,gradFunc:e=>({x:()=>ku(e)})},ag,ig,ig,sg,{kernelName:rr,inputsToSave:["x","alpha"],gradFunc:(e,t)=>{const[n,r]=t,a=Lc(n,0);return{x:()=>sc(a,e,Mu(e,r)),alpha:()=>{let t=sc(a,ku(e),Mu(e,n));const i=Eo(r.shape,e.shape);return i.length>0&&(t=wc(t,i)),_l(t,r.shape)}}}},og,{kernelName:or,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>wu(e,So(Su(n)))}}},{kernelName:fr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t,r=Mu(Bc(n,6),pd(n));return{x:()=>Mu(e,Cs(r,"float32"))}}},{kernelName:ur,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,Cs(pd(n),"float32"))}}},{kernelName:lr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>_l(e,n.shape)}}},{kernelName:dr,inputsToSave:["images"],gradFunc:(e,t,n)=>{const[r]=t,a={dy:e,images:r};return{images:()=>xi.runKernel(hr,a,n)}}},{kernelName:cr,inputsToSave:["images"],gradFunc:(e,t,n)=>{const[r]=t,a={dy:e,images:r};return{images:()=>xi.runKernel(pr,a,n)}}},{kernelName:mr,gradFunc:(e,t,n)=>{const{dims:r}=n,a=xe(r,e.shape);return{x:()=>zp(e,a)}}},{kernelName:gr,gradFunc:e=>({x:()=>ku(e)})},{kernelName:yr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>So(wu(e,Mu(zu(n,1.5),2)))}}},{kernelName:vr,inputsToSave:["condition"],gradFunc:(e,t)=>{const[n]=t;return{condition:()=>Cs(ku(n),"float32"),t:()=>Mu(e,Cs(n,e.dtype)),e:()=>Mu(e,Cs(Jc(n),e.dtype))}}},ug,{kernelName:kr,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,Mu(n,Bu($u(1),n)))}}},{kernelName:Sr,gradFunc:e=>({x:()=>ku(e)})},{kernelName:Mr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(Jl(Cs(n,"float32")),e)}}},{kernelName:Nr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(Xl(Cs(n,"float32")),e)}}},lg,{kernelName:Ar,outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r]=t,{dim:a}=n,i=Mu(e,r);return{logits:()=>Bu(i,Mu(wc(i,[a],!0),r))}}},{kernelName:Dr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,Sl(n))}}},cg,cg,pg,pg,{kernelName:Tr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>wu(e,Mu(Nu(Cs(n,"float32")),2))}}},{kernelName:Yr,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=$u(2);return{a:()=>Mu(e,Mu(a,Bu(n,r))),b:()=>Mu(e,Mu(a,Bu(r,n)))}}},{kernelName:zr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,Mu(Cs(n,"float32"),2))}}},{kernelName:na,gradFunc:e=>({x:()=>ku(e)})},{kernelName:Ur,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Co(n.shape,r.shape);return{a:()=>{let t=e;const r=Eo(n.shape,a);return r.length>0&&(t=wc(t,r)),_l(t,n.shape)},b:()=>{let t=e;const n=Eo(r.shape,a);return n.length>0&&(t=wc(t,n)),_l(So(t),r.shape)}}}},dg,{kernelName:qr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>wu(e,Su(Jl(n)))}}},{kernelName:Wr,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(Bu($u(1),Su(n)),e)}}},hg,{kernelName:Jr,gradFunc:(e,t,n)=>{const r=n,{perm:a}=r,i=bc(a);return{x:()=>Do(e,i)}}},fg,mg,{kernelName:ta,gradFunc:e=>({x:()=>ku(e)})}];for(const e of gg)ga(e);ei().prototype.abs=function(){return this.throwIfDisposed(),Hu(this)},ei().prototype.acos=function(){return this.throwIfDisposed(),Ku(this)},ei().prototype.acosh=function(){return this.throwIfDisposed(),Ju(this)},ei().prototype.add=function(e){return this.throwIfDisposed(),vu(this,e)},ei().prototype.all=function(e,t){return this.throwIfDisposed(),Zu(this,e,t)},ei().prototype.any=function(e,t){return this.throwIfDisposed(),Qu(this,e,t)},ei().prototype.argMax=function(e){return this.throwIfDisposed(),el(this,e)},ei().prototype.argMin=function(e){return this.throwIfDisposed(),tl(this,e)},ei().prototype.asScalar=function(){return this.throwIfDisposed(),ie(1===this.size,(()=>"The array must have only 1 element.")),_l(this,[])},ei().prototype.asType=function(e){return this.throwIfDisposed(),Cs(this,e)},ei().prototype.as1D=function(){return this.throwIfDisposed(),_l(this,[this.size])},ei().prototype.as2D=function(e,t){return this.throwIfDisposed(),_l(this,[e,t])},ei().prototype.as3D=function(e,t,n){return this.throwIfDisposed(),_l(this,[e,t,n])},ei().prototype.as4D=function(e,t,n,r){return this.throwIfDisposed(),_l(this,[e,t,n,r])},ei().prototype.as5D=function(e,t,n,r,a){return this.throwIfDisposed(),_l(this,[e,t,n,r,a])},ei().prototype.asin=function(){return this.throwIfDisposed(),nl(this)},ei().prototype.asinh=function(){return this.throwIfDisposed(),rl(this)},ei().prototype.atan=function(){return this.throwIfDisposed(),al(this)},ei().prototype.atan2=function(e){return this.throwIfDisposed(),il(this,e)},ei().prototype.atanh=function(){return this.throwIfDisposed(),sl(this)},ei().prototype.avgPool=function(e,t,n,r){return this.throwIfDisposed(),wl(this,e,t,n,r)},ei().prototype.batchToSpaceND=function(e,t){return this.throwIfDisposed(),Il(this,e,t)},ei().prototype.batchNorm=function(e,t,n,r,a){return this.throwIfDisposed(),El(this,e,t,n,r,a)},ei().prototype.broadcastTo=function(e){return this.throwIfDisposed(),Rl(this,e)},ei().prototype.cast=function(e){return this.throwIfDisposed(),Cs(this,e)},ei().prototype.ceil=function(){return this.throwIfDisposed(),Fl(this)},ei().prototype.clipByValue=function(e,t){return this.throwIfDisposed(),Yl(this,e,t)},ei().prototype.concat=function(e,t){return this.throwIfDisposed(),e instanceof Qa&&(e=[e]),Nl([this,...e],t)},ei().prototype.conv1d=function(e,t,n,r,a,i){return this.throwIfDisposed(),Ul(this,e,t,n,r,a,i)},ei().prototype.conv2dTranspose=function(e,t,n,r,a){return this.throwIfDisposed(),Wl(this,e,t,n,r,a)},ei().prototype.conv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),jl(this,e,t,n,r,a,i)},ei().prototype.cos=function(){return this.throwIfDisposed(),Jl(this)},ei().prototype.cosh=function(){return this.throwIfDisposed(),Xl(this)},ei().prototype.cumprod=function(e,t,n){return this.throwIfDisposed(),Zl(this,e,t,n)},ei().prototype.cumsum=function(e,t,n){return this.throwIfDisposed(),Ql(this,e,t,n)},ei().prototype.depthToSpace=function(e,t){return this.throwIfDisposed(),tc(this,e,t)},ei().prototype.depthwiseConv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),nc(this,e,t,n,r,a,i)},ei().prototype.dilation2d=function(e,t,n,r,a){return this.throwIfDisposed(),ac(this,e,t,n,r,a)},ei().prototype.divNoNan=function(e){return this.throwIfDisposed(),oc(this,e)},ei().prototype.div=function(e){return this.throwIfDisposed(),wu(this,e)},ei().prototype.dot=function(e){return this.throwIfDisposed(),uc(this,e)},ei().prototype.elu=function(){return this.throwIfDisposed(),cc(this)},ei().prototype.equal=function(e){return this.throwIfDisposed(),ic(this,e)},ei().prototype.erf=function(){return this.throwIfDisposed(),pc(this)},ei().prototype.euclideanNorm=function(e,t){return this.throwIfDisposed(),Sc(this,e,t)},ei().prototype.exp=function(){return this.throwIfDisposed(),kc(this)},ei().prototype.expandDims=function(e){return this.throwIfDisposed(),Dc(this,e)},ei().prototype.expm1=function(){return this.throwIfDisposed(),Tc(this)},ei().prototype.fft=function(){return this.throwIfDisposed(),rd(this)},ei().prototype.flatten=function(){return this.throwIfDisposed(),_l(this,[this.size])},ei().prototype.floor=function(){return this.throwIfDisposed(),Cc(this)},ei().prototype.floorDiv=function(e){return this.throwIfDisposed(),_u(this,e)},ei().prototype.gather=function(e,t){return this.throwIfDisposed(),Ac(this,e,t)},ei().prototype.greaterEqual=function(e){return this.throwIfDisposed(),$c(this,e)},ei().prototype.greater=function(e){return this.throwIfDisposed(),Lc(this,e)},ei().prototype.ifft=function(){return this.throwIfDisposed(),ad(this)},ei().prototype.irfft=function(){return this.throwIfDisposed(),id(this)},ei().prototype.isFinite=function(){return this.throwIfDisposed(),Oc(this)},ei().prototype.isInf=function(){return this.throwIfDisposed(),Rc(this)},ei().prototype.isNaN=function(){return this.throwIfDisposed(),Fc(this)},ei().prototype.leakyRelu=function(e){return this.throwIfDisposed(),Yc(this,e)},ei().prototype.lessEqual=function(e){return this.throwIfDisposed(),Bc(this,e)},ei().prototype.less=function(e){return this.throwIfDisposed(),zc(this,e)},ei().prototype.localResponseNormalization=function(e,t,n,r){return this.throwIfDisposed(),Hc(this,e,t,n,r)},ei().prototype.logSigmoid=function(){return this.throwIfDisposed(),Wc(this)},ei().prototype.logSoftmax=function(e){return this.throwIfDisposed(),Vc(this,e)},ei().prototype.logSumExp=function(e,t){return this.throwIfDisposed(),Gc(this,e,t)},ei().prototype.log=function(){return this.throwIfDisposed(),jc(this)},ei().prototype.log1p=function(){return this.throwIfDisposed(),Uc(this)},ei().prototype.logicalAnd=function(e){return this.throwIfDisposed(),Kc(this,e)},ei().prototype.logicalNot=function(){return this.throwIfDisposed(),Jc(this)},ei().prototype.logicalOr=function(e){return this.throwIfDisposed(),Xc(this,e)},ei().prototype.logicalXor=function(e){return this.throwIfDisposed(),Zc(this,e)},ei().prototype.matMul=function(e,t,n){return this.throwIfDisposed(),eo(this,e,t,n)},ei().prototype.maxPool=function(e,t,n,r){return this.throwIfDisposed(),np(this,e,t,n,r)},ei().prototype.max=function(e,t){return this.throwIfDisposed(),vc(this,e,t)},ei().prototype.maximum=function(e){return this.throwIfDisposed(),ju(this,e)},ei().prototype.mean=function(e,t){return this.throwIfDisposed(),ip(this,e,t)},ei().prototype.min=function(e,t){return this.throwIfDisposed(),_c(this,e,t)},ei().prototype.minimum=function(e){return this.throwIfDisposed(),lp(this,e)},ei().prototype.mirrorPad=function(e,t){return this.throwIfDisposed(),cp(this,e,t)},ei().prototype.mod=function(e){return this.throwIfDisposed(),pp(this,e)},ei().prototype.mul=function(e){return this.throwIfDisposed(),Mu(this,e)},ei().prototype.neg=function(){return this.throwIfDisposed(),So(this)},ei().prototype.norm=function(e,t,n){return this.throwIfDisposed(),Nc(this,e,t,n)},ei().prototype.notEqual=function(e){return this.throwIfDisposed(),mp(this,e)},ei().prototype.oneHot=function(e,t=1,n=0){return this.throwIfDisposed(),to(this,e,t,n)},ei().prototype.onesLike=function(){return this.throwIfDisposed(),gp(this)},ei().prototype.pad=function(e,t){return this.throwIfDisposed(),bp(this,e,t)},ei().prototype.pool=function(e,t,n,r,a,i){return this.throwIfDisposed(),Np(this,e,t,n,r,a,i)},ei().prototype.pow=function(e){return this.throwIfDisposed(),zu(this,e)},ei().prototype.prelu=function(e){return this.throwIfDisposed(),Sp(this,e)},ei().prototype.prod=function(e,t){return this.throwIfDisposed(),kp(this,e,t)},ei().prototype.reciprocal=function(){return this.throwIfDisposed(),Rp(this)},ei().prototype.relu=function(){return this.throwIfDisposed(),Fp(this)},ei().prototype.relu6=function(){return this.throwIfDisposed(),Yp(this)},ei().prototype.reshapeAs=function(e){return this.throwIfDisposed(),_l(this,e.shape)},ei().prototype.reshape=function(e){return this.throwIfDisposed(),_l(this,e)},ei().prototype.resizeBilinear=function(e,t,n){return this.throwIfDisposed(),fh(this,e,t,n)},ei().prototype.resizeNearestNeighbor=function(e,t,n){return this.throwIfDisposed(),mh(this,e,t,n)},ei().prototype.reverse=function(e){return this.throwIfDisposed(),zp(this,e)},ei().prototype.rfft=function(){return this.throwIfDisposed(),od(this)},ei().prototype.round=function(){return this.throwIfDisposed(),Up(this)},ei().prototype.rsqrt=function(){return this.throwIfDisposed(),qp(this)},ei().prototype.selu=function(){return this.throwIfDisposed(),Wp(this)},ei().prototype.separableConv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),Vp(this,e,t,n,r,a,i)},ei().prototype.sigmoid=function(){return this.throwIfDisposed(),Sl(this)},ei().prototype.sign=function(){return this.throwIfDisposed(),Kp(this)},ei().prototype.sin=function(){return this.throwIfDisposed(),Jp(this)},ei().prototype.sinh=function(){return this.throwIfDisposed(),Xp(this)},ei().prototype.slice=function(e,t){return this.throwIfDisposed(),kl(this,e,t)},ei().prototype.softmax=function(e){return this.throwIfDisposed(),nd(this,e)},ei().prototype.softplus=function(){return this.throwIfDisposed(),qc(this)},ei().prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),Mp(this,e,t)},ei().prototype.split=function(e,t){return this.throwIfDisposed(),sd(this,e,t)},ei().prototype.sqrt=function(){return this.throwIfDisposed(),Nu(this)},ei().prototype.square=function(){return this.throwIfDisposed(),Su(this)},ei().prototype.squaredDifference=function(e){return this.throwIfDisposed(),ud(this,e)},ei().prototype.squeeze=function(e){return this.throwIfDisposed(),ld(this,e)},ei().prototype.stack=function(e,t){this.throwIfDisposed();const n=e instanceof Qa?[this,e]:[this,...e];return cd(n,t)},ei().prototype.step=function(e){return this.throwIfDisposed(),pd(this,e)},ei().prototype.stridedSlice=function(e,t,n,r,a,i,s,o){return this.throwIfDisposed(),dd(this,e,t,n,r,a,i,s,o)},ei().prototype.sub=function(e){return this.throwIfDisposed(),Bu(this,e)},ei().prototype.sum=function(e,t){return this.throwIfDisposed(),wc(this,e,t)},ei().prototype.tan=function(){return this.throwIfDisposed(),hd(this)},ei().prototype.tanh=function(){return this.throwIfDisposed(),Dl(this)},ei().prototype.tile=function(e){return this.throwIfDisposed(),Ic(this,e)},ei().prototype.toBool=function(){return this.throwIfDisposed(),Cs(this,"bool")},ei().prototype.toFloat=function(){return this.throwIfDisposed(),Cs(this,"float32")},ei().prototype.toInt=function(){return this.throwIfDisposed(),Cs(this,"int32")},ei().prototype.topk=function(e,t){return this.throwIfDisposed(),xd(this,e,t)},ei().prototype.transpose=function(e){return this.throwIfDisposed(),Do(this,e)},ei().prototype.unique=function(e){return this.throwIfDisposed(),_d(this,e)},ei().prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),wd(this,e,t)},ei().prototype.unstack=function(e){return this.throwIfDisposed(),Md(this,e)},ei().prototype.where=function(e,t){return this.throwIfDisposed(),sc(e,this,t)},ei().prototype.zerosLike=function(){return this.throwIfDisposed(),ku(this)};class yg extends Error{constructor(e){super(e),Object.setPrototypeOf(this,yg.prototype)}}class bg extends Error{constructor(e){super(e),Object.setPrototypeOf(this,bg.prototype)}}class xg extends Error{constructor(e){super(e),Object.setPrototypeOf(this,xg.prototype)}}class vg extends Error{constructor(e){super(e),Object.setPrototypeOf(this,vg.prototype)}}class _g extends Error{constructor(e){super(e),Object.setPrototypeOf(this,_g.prototype)}}Error;class wg{constructor(e){this.maxEntries=e||100,this.cache=new Map}get(e){let t;return this.cache.has(e)&&(t=this.cache.get(e),this.cache.delete(e),this.cache.set(e,t)),t}put(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxEntries){const e=this.cache.keys().next().value;this.cache.delete(e)}this.cache.set(e,t)}getMaxEntries(){return this.maxEntries}setMaxEntries(e){if(e<0)throw new Error(`The maxEntries of LRU caches must be at least 0, but got ${e}.`);if(this.maxEntries>e)for(let t=0;tt.toUpperCase()))}let Eg={};function Cg(e){if(null==e)return null;const t={};return t.className=e.getClassName(),t.config=e.getConfig(),t}function Ag(e){if(null!=e&&"object"==typeof e)if(Array.isArray(e))e.forEach((e=>Ag(e)));else{const t=Object.keys(e);for(const n of t){const t=e[n];null!=t&&"object"==typeof t&&(Array.isArray(t)||"ndarray"!==t.type||"number"!=typeof t.value?Ag(t):e[n]=t.value)}}}function Lg(e,t={},n={},r="object",a=!1){if("string"==typeof e){const a=e;let i;if(a in n)i=n[a];else if(a in Eg)i=Eg[a];else if(i=t[a],null==i)throw new xg(`Unknown ${r}: ${e}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return i}{const i=e;if(null==i.className||null==i.config)throw new xg(`${r}: Improper config format: ${JSON.stringify(i)}.\n'className' and 'config' must set.`);const s=i.className;let o,u;if(s in n?[o,u]=n[s]:s in Eg?[o,u]=Eg.className:s in t&&([o,u]=t[s]),null==o)throw new xg(`Unknown ${r}: ${s}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(null!=u){const e={};for(const t of Object.keys(Eg))e[t]=Eg[t];for(const t of Object.keys(n))e[t]=n[t];i.config.customObjects=e;const t=Object.assign({},Eg);for(const e of Object.keys(n))Eg[e]=n[e];Ag(i.config);const r=u(o,i.config,n,a);return Eg=Object.assign({},t),r}{const e=Object.assign({},Eg);for(const e of Object.keys(n))Eg[e]=n[e];const t=new o(i.config);return Eg=Object.assign({},e),t}}}function $g(e,t){return-1*function(e,t){return et?1:0}(e,t)}function Og(e){if(null==e)return e;const t=[];for(const n of e)-1===t.indexOf(n)&&t.push(n);return t}function Rg(e){if(null==e)throw new xg(`Invalid value in obj: ${JSON.stringify(e)}`);for(const t in e)if(e.hasOwnProperty(t))return!1;return!0}function Fg(e,t,n){if(null!=n&&e.indexOf(n)<0)throw new xg(`${n} is not a valid ${t}. Valid values are ${e} or null/undefined.`)}function Yg(e,t,n=0,r=1/0){return Ng(n>=0),Ng(r>=n),Array.isArray(e)&&e.length>=n&&e.length<=r&&e.every((e=>typeof e===t))}function zg(e,t){Array.isArray(e)?(ie(e.length>0,(()=>`${t} is unexpectedly an empty array.`)),e.forEach(((e,n)=>zg(e,`element ${n+1} of ${t}`)))):ie(Number.isInteger(e)&&e>0,(()=>`Expected ${t} to be a positive integer, but got ${Bg(e)}.`))}function Bg(e){return null===e?"null":Array.isArray(e)?"["+e.map((e=>Bg(e))).join(",")+"]":"string"==typeof e?`"${e}"`:`${e}`}function Pg(e){return"relu"===e?"relu":"linear"===e?"linear":"elu"===e?"elu":null}let Hg=0;function jg(){return Hg++}const Ug={};function qg(e=""){return e in Ug||(Ug[e]=0),Ug[e]+=1,e+Ug[e].toString()}const Wg=["channelsFirst","channelsLast"],Vg=["nearest","bilinear"],Gg=["valid","same","causal"],Kg=["max","avg"],Jg=["sum","mul","concat","ave"],Xg=new Map;function Zg(e){Fg(Wg,"DataFormat",e)}function Qg(e){Fg(Gg,"PaddingMode",e)}function ey(e){Fg(Kg,"PoolMode",e)}const ty=[];function ny(e,t){ty.push(e);try{const e=t();return ty.pop(),e}catch(e){throw ty.pop(),e}}function ry(e){if(!sy(e))throw new Error("Not a valid tensor name: '"+e+"'");return(0===ty.length?"":ty.join("/")+"/")+e}function ay(e){if(!sy(e))throw new Error("Not a valid tensor name: '"+e+"'");Xg.has(e)||Xg.set(e,0);const t=Xg.get(e);if(Xg.set(e,Xg.get(e)+1),t>0){const n=`${e}_${t}`;return Xg.set(n,1),n}return e}const iy=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function sy(e){return!!e.match(iy)}function oy(e,t,n){null==t&&(t=0),null==n&&(n=e.length);let r=1;for(let a=t;at&&(t=r)}return t}function cy(e,t){if(t{switch(e.rank){case 1:return Zp(e,t,n);case 2:return Qp(e,[t,0],[n,e.shape[1]]);case 3:return ed(e,[t,0,0],[n,e.shape[1],e.shape[2]]);case 4:return td(e,[t,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3]]);case 5:return kl(e,[t,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4]]);case 6:return kl(e,[t,0,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4],e.shape[5]]);default:throw new xg(`sliceAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}}))}function gy(e,t,n){return co((()=>{switch(e.rank){case 1:return Zp(e,t,n);case 2:return Qp(e,[0,t],[e.shape[0],n]);case 3:return ed(e,[0,0,t],[e.shape[0],e.shape[1],n]);case 4:return td(e,[0,0,0,t],[e.shape[0],e.shape[1],e.shape[2],n]);default:throw new xg(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}}))}function yy(e,t,n,r){return co((()=>{switch(e.rank){case 1:return Zp(e,t,n);case 2:switch(r){case 1:return my(e,t,n);case 2:return gy(e,t,n);default:throw new xg(`The axis is not within the rank of the tensor ${r}`)}case 3:switch(r){case 1:return my(e,t,n);case 2:return ed(e,[0,t,0],[e.shape[0],n,e.shape[2]]);case 3:return gy(e,t,n);default:throw new xg(`The axis is not within the rank of the tensor ${r}`)}case 4:switch(r){case 1:return my(e,t,n);case 2:return td(e,[0,t,0,0],[e.shape[0],n,e.shape[2],e.shape[3]]);case 3:return td(e,[0,0,t,0],[e.shape[0],e.shape[1],n,e.shape[3]]);case 4:return gy(e,t,n);default:throw new xg(`The axis is not within the rank of the tensor ${r}`)}default:throw new xg(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}}))}function by(e,t=-1){let n;return t<0&&(n=e[0].rank,t=0!==n?n:0),t===e[0].rank&&(t=-1),Nl(e,t)}function xy(e,t){switch(e.rank){case 1:return zl([e,t]);case 2:return Bl([e,t],0);case 3:return Pl([e,t],0);case 4:return Hl([e,t],0);default:throw new xg(`concatAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}}function vy(e,t){if(Array.isArray(t)||(t=[t]),e.rank!==t.length)throw new xg(`The length of input n (${t.length}) does not match the number of dimensions in input x (${e.rank})`);return Ic(e,t)}function _y(e,t=0,n=1,r,a){return Lp(e,t,n,r,a)}function wy(e,t,n,r){if(e.rank<2||t.rank<2)throw new vg(`dot requires both inputs to be rank >= 2 but got x shape = ${e.shape} and y shape = ${t.shape}`);if(t.rank>=3&&e.shape.slice(-1)[0]!==t.shape.slice(-2)[0])throw new vg(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${e.shape} and y shape = ${t.shape}`);if(2===e.rank&&2===t.rank)return Wd({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?Sy(e.rank,r,"channelsLast"):null,activation:n});{const a=e.shape.slice(),i=a.pop();e=_l(e,[-1,i]);const s=t.shape.slice(),o=s.pop(),u=s.pop(),l=[...s,o],c=Array.from({length:t.rank},((e,n)=>0===n?t.rank-2:n<=t.rank-2?n-1:n));t=_l(Do(t,c),[u,-1]);const p=[...a,...l];return _l(Wd({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?Sy(e.rank,r,"channelsLast"):null,activation:n}),p)}}function My(e,t,n){return co((()=>(t=Array.isArray(t)?fd(t,"int32"):Cs(t,"int32"),Ac(e,t,n))))}function Ny(e){return Mu(e,e)}function Sy(e,t,n){const r=t.shape;if(1!==t.rank&&t.rank!==e)throw new xg(`Unexpected bias dimensions: ${t.rank}; expected it to be 1 or ${e}`);if(5===e){if("channelsFirst"===n)return 1===r.length?_l(t,[1,r[0],1,1,1]):_l(t,[1,r[3],r[0],r[1],r[2]]);if("channelsLast"===n)return 1===r.length?_l(t,[1,1,1,1,r[0]]):_l(t,[1].concat(r))}else if(4===e){if("channelsFirst"===n)return 1===r.length?_l(t,[1,r[0],1,1]):_l(t,[1,r[2],r[0],r[1]]);if("channelsLast"===n)return 1===r.length?_l(t,[1,1,1,r[0]]):_l(t,[1].concat(r))}else if(3===e){if("channelsFirst"===n)return 1===r.length?_l(t,[1,r[0],1]):_l(t,[1,r[1],r[0]]);if("channelsLast"===n)return 1===r.length?_l(t,[1,1,r[0]]):_l(t,[1].concat(r))}else if(e<3)return t;throw new xg(`Unsupported input rank by biasAdd: ${t.rank}`)}function ky(e,t,n){return co((()=>(null==n&&(n="channelsLast"),Zg(n),vu(e,Sy(e.rank,t,n)))))}function Dy(e,t,n,r){return co((()=>Ld(e,t,n,r)))}function Ty(e,t,n=!1){return n?e():t()}const Iy=["fanIn","fanOut","fanAvg"],Ey=["normal","uniform","truncatedNormal"];class Cy extends iu{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}}class Ay extends Cy{apply(e,t){return sp(e,t)}}Ay.className="Zeros",ou(Ay);class Ly extends Cy{apply(e,t){return op(e,t)}}Ly.className="Ones",ou(Ly);class $y extends Cy{constructor(e){if(super(),"object"!=typeof e)throw new xg(`Expected argument of type ConstantConfig but got ${e}`);if(void 0===e.value)throw new xg(`config must have value set but got ${e}`);this.value=e.value}apply(e,t){return co((()=>Mu($u(this.value),op(e,t))))}getConfig(){return{value:this.value}}}$y.className="Constant",ou($y);class Oy extends Cy{constructor(e){super(),this.DEFAULT_MINVAL=-.05,this.DEFAULT_MAXVAL=.05,this.minval=e.minval||this.DEFAULT_MINVAL,this.maxval=e.maxval||this.DEFAULT_MAXVAL,this.seed=e.seed}apply(e,t){return $p(e,this.minval,this.maxval,t)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}Oy.className="RandomUniform",ou(Oy);class Ry extends Cy{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if("float32"!==(t=t||"float32")&&"int32"!==t)throw new vg(`randomNormal does not support dType ${t}.`);return _y(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}Ry.className="RandomNormal",ou(Ry);class Fy extends Cy{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if("float32"!==(t=t||"float32")&&"int32"!==t)throw new vg(`truncatedNormal does not support dType ${t}.`);return vd(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}Fy.className="TruncatedNormal",ou(Fy);class Yy extends Cy{constructor(e){super(),this.gain=null!=e.gain?e.gain:1}apply(e,t){return co((()=>{if(2!==e.length||e[0]!==e[1])throw new xg("Identity matrix initializer can only be used for 2D square matrices.");return Mu(this.gain,Ec(e[0]))}))}getConfig(){return{gain:this.gain}}}Yy.className="Identity",ou(Yy);class zy extends Cy{constructor(e){if(super(),e.scale<0)throw new xg(`scale must be a positive float. Got: ${e.scale}`);var t;this.scale=null==e.scale?1:e.scale,this.mode=null==e.mode?"fanIn":e.mode,t=this.mode,Fg(Iy,"FanMode",t),this.distribution=null==e.distribution?"normal":e.distribution,function(e){Fg(Ey,"Distribution",e)}(this.distribution),this.seed=e.seed}apply(e,t){const n=function(e,t="channelsLast"){let n,r;if(Zg(t),2===e.length)n=e[0],r=e[1];else if(-1!==[3,4,5].indexOf(e.length)){if("channelsFirst"===t){const t=oy(e,2);n=e[1]*t,r=e[0]*t}else if("channelsLast"===t){const t=oy(e,0,e.length-2);n=e[e.length-2]*t,r=e[e.length-1]*t}}else{const t=oy(e);n=Math.sqrt(t),r=Math.sqrt(t)}return[n,r]}(e),r=n[0],a=n[1];let i=this.scale;if("fanIn"===this.mode?i/=Math.max(1,r):"fanOut"===this.mode?i/=Math.max(1,a):i/=Math.max(1,(r+a)/2),"normal"===this.distribution){const n=Math.sqrt(i);if("float32"!==(t=t||"float32")&&"int32"!==t)throw new vg(`${this.getClassName()} does not support dType ${t}.`);return vd(e,0,n,t,this.seed)}{const n=Math.sqrt(3*i);return $p(e,-n,n,t)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}zy.className="VarianceScaling",ou(zy);class By extends zy{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return zy.className}}By.className="GlorotUniform",ou(By);class Py extends zy{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return zy.className}}Py.className="GlorotNormal",ou(Py);class Hy extends zy{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return zy.className}}Hy.className="HeNormal",ou(Hy);class jy extends zy{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return zy.className}}jy.className="HeUniform",ou(jy);class Uy extends zy{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return zy.className}}Uy.className="LeCunNormal",ou(Uy);class qy extends zy{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return zy.className}}qy.className="LeCunNormal",ou(qy);class Wy extends Cy{constructor(e){if(super(),this.DEFAULT_GAIN=1,this.gain=null==e.gain?this.DEFAULT_GAIN:e.gain,this.seed=e.seed,null!=this.seed)throw new vg("Random seed is not implemented for Orthogonal Initializer yet.")}apply(e,t){return co((()=>{if(e.length<2)throw new vg("Shape must be at least 2D.");e[0]*e[1]>2e3&&console.warn(`Orthogonal initializer is being called on a matrix with more than 2000 (${e[0]*e[1]}) elements: Slowness may result.`);const t=_y(e[0]>e[1]?[e[1],e[0]]:e,0,1,"float32");let n=Hh.gramSchmidt(t);return e[0]>e[1]&&(n=Do(n)),Mu(this.gain,n)}))}getConfig(){return{gain:this.gain,seed:this.seed}}}Wy.className="Orthogonal",ou(Wy);const Vy={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function Gy(e,t={}){return Lg(e,su.getMap().classNameMap,t,"initializer")}function Ky(e){return Cg(e)}function Jy(e){if("string"==typeof e){const t=e in Vy?Vy[e]:e;if("GlorotNormal"===t)return new Py;if("GlorotUniform"===t)return new By;if("HeNormal"===t)return new Hy;if("HeUniform"===t)return new jy;if("LeCunNormal"===t)return new Uy;if("LeCunUniform"===t)return new qy;{const e={};return e.className=t,e.config={},Gy(e)}}return e instanceof Cy?e:Gy(e)}function Xy(e){return Array.isArray(e)&&Array.isArray(e[0])}function Zy(e){return 0===e.length?[]:Array.isArray(e[0])?e:[e]}function Qy(e){let t;if(Array.isArray(e)){if(1!==e.length)throw new xg(`Expected Tensor length to be 1; got ${e.length}`);t=e[0]}else t=e;return t}function eb(e){if(Array.isArray(e)&&Array.isArray(e[0])){if(1===e.length)return e[0];throw new xg(`Expected exactly 1 Shape; got ${e.length}`)}return e}function tb(e){let t=0;for(const n of e)0===n.shape.length?t+=1:t+=n.shape.reduce(((e,t)=>e*t));return t}class nb{constructor(e,t="float32",n="Variable",r=!0,a=null){this.dtype=null==t?"float32":t,this.shape=e.shape,this.id=jg(),n=null==n?"Variable":n,this.originalName=ry(n),this.name=ay(this.originalName),this.trainable_=r,this.constraint=a,this.val=Sd(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),function(e,t){if(e.shape.toString()!==t.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}(this.val,e),this.val.id!==e.id&&(this.val.assign(e),null!=this.constraint&&this.val.assign(this.constraint.apply(this.val))),this}dispose(){this.assertNotDisposed(),this.val.dispose()}assertNotDisposed(){if(this.val.isDisposed)throw new Error(`LayersVariable ${this.name} is already disposed.`)}get trainable(){return this.trainable_}set trainable(e){this.trainable_=e,this.val.trainable=e}}function rb(e){return e.map((e=>e.read()))}function ab(e){e.forEach((e=>{e[0].write(e[1])}))}class ib{constructor(e){this.dtype=e.dtype,this.shape=e.shape,null!=e.shape?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}}class sb{constructor(e,t,n,r,a,i,s){this.dtype=e,this.shape=t,this.sourceLayer=n,this.inputs=r,this.callArgs=a,this.outputTensorIndex=s,this.id=jg(),null!=i&&(this.originalName=ry(i),this.name=ay(this.originalName)),this.rank=t.length}}let ob=0;class ub{constructor(e,t){this.callArgs=t,this.id=ob++,this.outboundLayer=e.outboundLayer,this.inboundLayers=e.inboundLayers,this.nodeIndices=e.nodeIndices,this.tensorIndices=e.tensorIndices,this.inputTensors=e.inputTensors,this.outputTensors=e.outputTensors,this.inputMasks=e.inputMasks,this.outputMasks=e.outputMasks,this.inputShapes=e.inputShapes,this.outputShapes=e.outputShapes;for(const t of e.inboundLayers)null!=t&&t.outboundNodes.push(this);e.outboundLayer.inboundNodes.push(this)}getConfig(){const e=[];for(const t of this.inboundLayers)null!=t?e.push(t.name):e.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let lb=0;class cb extends iu{constructor(e={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=lb++,this.activityRegularizer=null,this.inputSpec=null,this.supportsMasking=!1,this._trainableWeights=[],this._nonTrainableWeights=[],this._losses=[],this._updates=[],this._built=!1,this.inboundNodes=[],this.outboundNodes=[];let t=e.name;if(!t){const e=this.getClassName();t=Tg(e)+"_"+qg(e)}if(this.name=t,this.trainable_=null==e.trainable||e.trainable,null!=e.inputShape||null!=e.batchInputShape){let t;if(null!=e.batchInputShape)t=e.batchInputShape;else if(null!=e.inputShape){let n=null;null!=e.batchSize&&(n=e.batchSize),t=[n].concat(e.inputShape)}this.batchInputShape=t;let n=e.dtype;null==n&&(n=e.inputDType),null==n&&(n="float32"),this.dtype=n}null!=e.weights?this.initialWeights=e.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}static nodeKey(e,t){return e.name+"_ib-"+t.toString()}getNodeAtIndex(e,t){if(0===this.inboundNodes.length)throw new bg(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new xg(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return kg(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return kg(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new yg(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(0===this.inboundNodes.length)throw new yg(`Layer ${this.name} is not connected, no input to return.`);return kg(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(0===this.inboundNodes.length)throw new yg(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new yg(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return kg(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map((e=>e()))}get updates(){return this._updates}get built(){return this._built}set built(e){this._built=e}get trainable(){return this.trainable_}set trainable(e){this._trainableWeights.forEach((t=>t.trainable=e)),this.trainable_=e}get trainableWeights(){return this.trainable_?this._trainableWeights.filter((e=>e.trainable)):[]}set trainableWeights(e){this._trainableWeights=e}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter((e=>!e.trainable)).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(e){this._nonTrainableWeights=e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}get stateful(){return this._stateful}resetStates(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(e){if(e=Dg(e),null==this.inputSpec||0===this.inputSpec.length)return;const t=Dg(this.inputSpec);if(e.length!==t.length)throw new xg(`Layer ${this.name} expects ${t.length} inputs, but it received ${e.length} input tensors. Input received: ${e}`);for(let n=0;na.maxNDim)throw new xg(`Input ${n} is incompatible with layer ${this.name}: expected max_ndim=${a.maxNDim}, found ndim=${i}`);if(null!=a.minNDim&&i=0?e[r]:e[e.length+r];if(null!=i&&-1===[i,null].indexOf(s))throw new xg(`Input ${n} is incompatible with layer ${this.name}: expected axis ${r} of input shape to have value ${i} but got shape ${e}.`)}}if(null!=a.shape)for(let e=0;e{if(!this.built){this.assertInputCompatibility(e);const t=[];for(const n of Dg(e))t.push(n.shape);this.build(kg(t)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),null===this._refCount&&a&&(this._refCount=1)}if(this.assertInputCompatibility(e),a){let r=this.call(e,t);const a=Dg(r),i=[];for(let e of a)-1!==n.indexOf(e)&&(e=e.clone()),i.push(e);if(r=kg(i),null!=this.activityRegularizer)throw new vg("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return r}{const n=function(e){e=Dg(e);const t=[];for(const n of e)t.push(n.shape);return kg(t)}(e),r=this.computeOutputShape(n);let a;const i="float32";if(this.warnOnIncompatibleInputShape(Array.isArray(e)?n[0]:n),a=null!=r&&r.length>0&&Array.isArray(r[0])?r.map(((n,r)=>new sb(i,n,this,Dg(e),t,this.name,r))):new sb(i,r,this,Dg(e),t,this.name),this.addInboundNode(e,a,null,null,n,r,t),this._refCount++,null!=this.activityRegularizer)throw new vg("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return a}}))}warnOnIncompatibleInputShape(e){if(null!=this.batchInputShape)if(e.length!==this.batchInputShape.length)console.warn(`The rank of the input tensor provided (shape: ${JSON.stringify(e)}) does not match that of the batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer ${this.name}`);else{let t=!1;this.batchInputShape.forEach(((n,r)=>{null!=n&&null!=e[r]&&e[r]!==n&&(t=!0)})),t&&console.warn(`The shape of the input tensor (${JSON.stringify(e)}) does not match the expectation of layer ${this.name}: ${JSON.stringify(this.batchInputShape)}`)}}get outputShape(){if(null==this.inboundNodes||0===this.inboundNodes.length)throw new yg(`The layer ${this.name} has never been called and thus has no defined output shape.`);const e=[];for(const t of this.inboundNodes){const n=JSON.stringify(t.outputShapes);-1===e.indexOf(n)&&e.push(n)}if(1===e.length){const e=this.inboundNodes[0].outputShapes;return Array.isArray(e)&&Array.isArray(e[0])&&1===e.length?e[0]:e}throw new yg(`The layer ${this.name} has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.`)}countParams(){if(!this.built)throw new bg(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return tb(this.weights)}build(e){this.built=!0}getWeights(e=!1){return rb(e?this.trainableWeights:this.weights)}setWeights(e){co((()=>{const t=this.weights;if(t.length!==e.length)throw new xg(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${e.length}, but the layer was expecting ${t.length} weights. Provided weights: ${e}...`);if(0===t.length)return;const n=[],r=rb(t);for(let a=0;aa.apply(l.read()))),null==i&&(i=!0),i?this._trainableWeights.push(l):this._nonTrainableWeights.push(l),l}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){null==e||Array.isArray(e)&&0===e.length||(e=Dg(e),void 0!==this._losses&&null!==this._losses&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,t){if(!this.supportsMasking){if(null!=t){if(!Array.isArray(t))throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);t.forEach((e=>{if(null!=e)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)}))}return null}return t}addInboundNode(e,t,n,r,a,i,s=null){const o=Dg(e);t=Dg(t),n=Dg(n),r=Dg(r),a=Zy(a),i=Zy(i);const u=[],l=[],c=[];for(const e of o)u.push(e.sourceLayer),l.push(e.nodeIndex),c.push(e.tensorIndex);new ub({outboundLayer:this,inboundLayers:u,nodeIndices:l,tensorIndices:c,inputTensors:o,outputTensors:t,inputMasks:n,outputMasks:r,inputShapes:a,outputShapes:i},s);for(let e=0;ee.dispose())),this.weights.length}assertNotDisposed(){if(0===this._refCount)throw new Error(`Layer '${this.name}' is already disposed.`)}dispose(){if(!this.built)throw new Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`);if(null===this._refCount)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return 0==--this._refCount&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}}function pb(e,t,n){if((null==t||null!=n&&n>0)&&(t=e.sourceLayer,n=e.nodeIndex),0===t.inboundNodes.length)return[e];{const e=t.inboundNodes[n];if(0===e.inboundLayers.length)return e.inputTensors;{const t=[];for(let n=0;ne.name)),u=[],l=t.names();for(const e of o)-1!==l.indexOf(e)?u.push(t.getValue(e)):u.push(null);null!=r&&(r.maxNumTensors=-1/0,r.minNumTensors=1/0);const c=o.join(",")+"|"+t.names().sort().join(",");let p,d=mb.get(c);if(null==d){const e=function(e,t){ie(null!=e&&e.length>0,(()=>"Expected at least one fetch, got none"));let n=[],r={};if(1===e.length){const a=xb(e[0],t);n=a.sorted,r=a.recipientMap}else{const a=new Set;for(const i of e){const{sorted:e,recipientMap:s}=xb(i,t);for(const t of e)a.has(t.name)||(n.push(t),a.add(t.name));for(const e in s)null==r[e]&&(r[e]=new Set),s[e].forEach((t=>r[e].add(t)))}}return{sorted:n,recipientCounts:bb(r)}}(s,t);d=e.sorted,p=e.recipientCounts,mb.put(c,d),gb.put(c,p)}p={},a||Object.assign(p,gb.get(c));const h=new fb(t);for(let e=0;er.maxNumTensors&&(r.maxNumTensors=e),e0;){const e=i[i.length-1];if(n.has(e.name)){i.pop();continue}const t=s[s.length-1]===i.length-1;if(0===e.inputs.length||t)i.pop(),r.push(e),n.add(e.name),t&&s.pop();else{s.push(i.length-1);for(const t of e.inputs)null==a[t.name]&&(a[t.name]=new Set),a[t.name].add(e.name),n.has(t.name)||i.push(t)}}return{sorted:r,recipientMap:a}}function vb(e){let t;if(1===e.sourceLayer.inboundNodes.length)t=e.sourceLayer.output;else{let n=null;for(let t=0;tNu(wc(Mu(e,e),t,!0))))}Ve().registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES",(()=>100),(function(e){null!=mb&&mb.setMaxEntries(e),null!=gb&&gb.setMaxEntries(e)}));class wb extends iu{getConfig(){return{}}}class Mb extends wb{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return co((()=>{const t=_b(e,this.axis),n=Yl(t,0,this.maxValue);return Mu(e,wu(n,vu(dy(),t)))}))}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}Mb.className="MaxNorm",ou(Mb);class Nb extends wb{constructor(e){super(),this.defaultAxis=0,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return co((()=>wu(e,vu(dy(),_b(e,this.axis)))))}getConfig(){return{axis:this.axis}}}Nb.className="UnitNorm",ou(Nb);class Sb extends wb{apply(e){return Fp(e)}}Sb.className="NonNeg",ou(Sb);class kb extends wb{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=null!=e.minValue?e.minValue:this.defaultMinValue,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.rate=null!=e.rate?e.rate:this.defaultRate,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return co((()=>{const t=_b(e,this.axis),n=vu(Mu(this.rate,Yl(t,this.minValue,this.maxValue)),Mu(1-this.rate,t));return Mu(e,wu(n,vu(dy(),t)))}))}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}kb.className="MinMaxNorm",ou(kb);const Db={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function Tb(e){return Cg(e)}function Ib(e,t={}){return Lg(e,su.getMap().classNameMap,t,"constraint")}function Eb(e){return null==e?null:"string"==typeof e?Ib({className:e in Db?Db[e]:e,config:{}}):e instanceof wb?e:Ib(e)}function Cb(e){return new Mb(e)}function Ab(e){return new Nb(e)}function Lb(){return new Sb}function $b(e){return new kb(e)}function Ob(){return new Ay}function Rb(){return new Ly}function Fb(e){return new $y(e)}function Yb(e){return new Oy(e)}function zb(e){return new Ry(e)}function Bb(e){return new Fy(e)}function Pb(e){return new Yy(e)}function Hb(e){return new zy(e)}function jb(e){return new By(e)}function Ub(e){return new Py(e)}function qb(e){return new Hy(e)}function Wb(e){return new jy(e)}function Vb(e){return new Uy(e)}function Gb(e){return new qy(e)}function Kb(e){return new Wy(e)}async function Jb(e){if(null==e)return;const t=[],n=[],r=[];for(const a in e){const i=e[a];if("number"!=typeof i){const e=i;t.push(e.data()),n.push(a),r.push(e)}}if(t.length>0){const a=await Promise.all(t);for(let t=0;tvu(this.totals[e],Mu(r,n))));this.totals[e]=a,null!=t&&t.dispose()}}}async onEpochEnd(e,t){if(null!=t)for(const e of this.params.metrics)null!=this.totals[e]&&("number"==typeof this.totals[e]?t[e]=this.totals[e]/this.seen:co((()=>{const n=Mu(wu(1,this.seen),this.totals[e]);t[e]=n,this.totals[e].dispose(),ho(t[e])})))}}class nx extends Qb{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,t){null==t&&(t={}),this.epoch.push(e);for(const e in t)null==this.history[e]&&(this.history[e]=[]),this.history[e].push(t[e])}async syncData(){const e=[],t=[],n=[];for(const r in this.history){const a=this.history[r];for(let i=0;i{const s=null!=n?n():Fa();return s-anew rx(e,t)))}class ix{constructor(){}static registerCallbackConstructor(e,t){ie(e>=0&&Number.isInteger(e),(()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`)),ix.checkForDuplicate(t),null==ix.constructors[e]&&(ix.constructors[e]=[]),ix.constructors[e].push(t)}static checkForDuplicate(e){for(const t in ix.constructors)ix.constructors[+t].forEach((t=>{if(t===e)throw new xg("Duplicate callback constructor.")}))}static clear(){ix.constructors={}}static createCallbacks(e){const t=[];for(const n in ix.constructors){const r=+n;e>=r&&t.push(...ix.constructors[r])}return t.map((e=>new e))}}function sx(e,t,n,r,a,i,s,o,u){const l=new nx,c=[new tx,...ix.createCallbacks(t)];null!=e&&c.push(...e),c.push(l);const p=new ex(c);return p.setParams({epochs:n,initialEpoch:r,samples:a,steps:i,batchSize:s,verbose:t,doValidation:o,metrics:u}),{callbackList:p,history:l}}function ox(e,t={},n=!1){return Lg(e,su.getMap().classNameMap,t,"layer",n)}function ux(e,t){return co((()=>{"float32"!==e.dtype&&(e=Cs(e,"float32"));const n=wc(Ny(e),t,!0),r=Fu(n.shape,dy()),a=Nu(ju(n,r));return wu(e,a)}))}function lx(e,t){return co((()=>ip(Ny(Bu(t,e)),-1)))}function cx(e,t){return co((()=>ip(Hu(Bu(t,e)),-1)))}function px(e,t){return co((()=>{const n=Bu(e,t),r=Yl(Hu(e),dy(),Number.MAX_VALUE),a=Hu(wu(n,r));return Mu(100,ip(a,-1))}))}function dx(e,t,n=!1){return co((()=>{if(n)t=nd(t);else{const e=wc(t,t.shape.length-1,!0);t=wu(t,e)}return t=Yl(t,dy(),1-dy()),So(wc(Mu(Cs(e,"float32"),jc(t)),t.shape.length-1))}))}function hx(e,t,n=!1){return co((()=>{const r=Cs(Cc(function(e){const t=[oy(e.shape)];return _l(e,t)}(e)),"int32"),a=(t=Yl(t,dy(),1-dy())).shape;return dx(_l(to(r,a[a.length-1]),a),t,n)}))}function fx(e,t){return co((()=>{let n;return n=Yl(t,dy(),1-dy()),n=jc(wu(n,Bu(1,n))),ip(function(e,t){if(!pe(e.shape,t.shape))throw new xg(`logits and labels must have the same shape, but got shapes ${JSON.stringify(e.shape)} and ${JSON.stringify(t.shape)}`);return co((()=>{const n=Fp(t),r=So(Hu(t));return vu(Bu(n,Mu(t,e)),Uc(kc(r)))}))}(e,n),-1)}))}function mx(e,t){return co((()=>{const n=ux(e,-1),r=ux(t,-1),a=Mu(n,r);return So(wc(a,-1))}))}ix.constructors={};const gx={meanSquaredError:lx,meanAbsoluteError:cx,meanAbsolutePercentageError:px,meanSquaredLogarithmicError:function(e,t){return co((()=>{const n=Yl(t,dy(),Number.MAX_VALUE),r=jc(vu(1,n)),a=Yl(e,dy(),Number.MAX_VALUE),i=jc(vu(1,a));return ip(Ny(Bu(r,i)),-1)}))},squaredHinge:function(e,t){return co((()=>{const n=ju(0,Bu(1,Mu(e,t)));return ip(Ny(n),-1)}))},hinge:function(e,t){return co((()=>{const n=ju(0,Bu(1,Mu(e,t)));return ip(n,-1)}))},categoricalHinge:function(e,t){return co((()=>{const n=wc(Mu(e,t),-1),r=vc(Mu(Bu(1,e),t),-1);return ju(0,vu(1,Bu(r,n)))}))},logcosh:function(e,t){return co((()=>{const n=Math.log(2),r=Bu(t,e),a=Bu(vu(r,qc(Mu(-2,r))),n);return ip(a,-1)}))},categoricalCrossentropy:dx,sparseCategoricalCrossentropy:hx,binaryCrossentropy:fx,kullbackLeiblerDivergence:function(e,t){return co((()=>{const n=Yl(e,dy(),1),r=Yl(t,dy(),1);return wc(Mu(e,jc(wu(n,r))),-1)}))},poisson:function(e,t){return co((()=>{const n=jc(vu(dy(),t));return ip(Bu(t,Mu(e,n)),-1)}))},cosineProximity:mx};function yx(e){if("string"==typeof e){if(e in gx)return gx[e];let t=`Unknown loss ${e}`;throw e.toLowerCase().includes("softmaxcrossentropy")&&(t=`Unknown loss ${e}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new xg(t)}return e}function bx(e,t){return co((()=>{const n=Mu(.5,gp(t)),r=hy(Lc(t,n),e.dtype);return ip(ic(e,r),-1)}))}function xx(e,t){return co((()=>hy(ic(el(e,-1),el(t,-1)),"float32")))}function vx(e,t){return co((()=>Cs(wc(Kc(ic(e,1),ic(t,1))),"float32")))}function _x(e,t){return co((()=>{const n=vx(e,t),r=function(e,t){return co((()=>Cs(wc(Kc(ic(e,0),ic(t,1))),"float32")))}(e,t),a=vu(n,r);return Cs(sc(Lc(a,0),wu(n,a),0),"float32")}))}function wx(e,t){return fx(e,t)}function Mx(e,t){return e.rank===t.rank&&(e=ld(e,[e.rank-1])),(t=el(t,-1)).dtype!==e.dtype&&(t=Cs(t,e.dtype)),Cs(ic(e,t),"float32")}const Nx=dx,Sx=hx,kx={binaryAccuracy:bx,categoricalAccuracy:xx,precision:_x,categoricalCrossentropy:Nx,sparseCategoricalCrossentropy:Sx,mse:lx,MSE:lx,mae:cx,MAE:cx,mape:px,MAPE:px,cosine:mx};function Dx(e){if("string"==typeof e&&e in kx)return kx[e];if("string"!=typeof e&&null!=e)return e;throw new xg(`Unknown metric ${e}`)}function Tx(e){if(Ng(null!==e,`Unknown LossOrMetricFn ${e}`),"string"==typeof e)return e;{let t;for(const n of Object.keys(gx))if(gx[n]===e){t=n;break}if(void 0!==t)return t;for(const n of Object.keys(kx))if(kx[n]===e){t=n;break}return void 0!==t?t:e.name}}function Ix(e,t,n=!1){if(null==e||"object"!=typeof e||Object.getPrototypeOf(e)!==Object.prototype||!Ex(e))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){const n=JSON.stringify(e);n.length>1048576&&console.warn(`User-defined metadata of model "${t}" is too large in size (length=${n.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= 1048576.`)}}function Ex(e){if(null===e)return!0;if("object"==typeof e){if(Object.getPrototypeOf(e)===Object.prototype){const t=Object.keys(e);for(const n of t){if("string"!=typeof n)return!1;if(!Ex(e[n]))return!1}return!0}if(Array.isArray(e)){for(const t of e)if(!Ex(t))return!1;return!0}return!1}{const t=typeof e;return"string"===t||"number"===t||"boolean"===t}}function Cx(e,t,n=console.log){let r="";for(let n=0;n0&&(r=r.slice(0,r.length-1)+" "),r+=e[n],r=r.slice(0,t[n]),r+=" ".repeat(t[n]-r.length);n(r)}function Ax(e,t,n){let r,a;try{a=e.inboundNodes.map((e=>JSON.stringify(e.inputShapes))).join(",")}catch(e){a="multiple"}try{r=JSON.stringify(e.outputShape)}catch(e){r="multiple"}Cx([`${e.name} (${e.getClassName()})`,a,r,e.countParams().toString()],t,n)}function Lx(e,t,n,r){let a,i;try{i=e.inboundNodes.map((e=>JSON.stringify(e.inputShapes))).join(",")}catch(e){i="multiple"}try{a=JSON.stringify(e.outputShape)}catch(e){a="multiple"}const s=[];for(const t of e.inboundNodes)if(!(null!=n&&n.length>0&&-1===n.indexOf(t)))for(let e=0;ee.name))}`);Og(this.outputs).length!==this.outputs.length&&console.warn(`The list of outputs passed to the model is redundant. All outputs should only appear once. Found: ${this.outputs.map((e=>e.name))}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(const e of this.outputs){const t=e.sourceLayer,n=e.nodeIndex,r=e.tensorIndex;this.outputLayers.push(t),this.outputLayersNodeIndices.push(n),this.outputLayersTensorIndices.push(r)}for(const e of this.inputs){const t=e.sourceLayer,n=e.nodeIndex,r=e.tensorIndex;Ng(0===n,"input layer has >1 nodes"),Ng(0===r,"input layer has >1 tensors"),this.inputLayers.push(t),this.inputLayersNodeIndices.push(n),this.inputLayersTensorIndices.push(r)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let t=0;te.shape)),this.internalOutputShapes=this.outputs.map((e=>e.shape));const t={},n={},r={},a={},i={},s=[],o=(e,t,n,r,a,u)=>{null!=r&&null!=a&&null!=u||(r=e.sourceLayer,a=e.nodeIndex,u=e.tensorIndex);const l=r.inboundNodes[a];if(-1!==n.indexOf(l))throw new bg(`The tensor ${e.name} at layer "${r.name}" is part of a cycle.`);if(-1!==t.indexOf(l))return;this.containerNodes.add(Yx.nodeKey(r,a)),r.id in i||(i[r.id]=Object.keys(i).length),-1===n.indexOf(l)&&n.push(l);const c=l.inboundLayers.length;for(let e=0;e=0;)n.splice(n.indexOf(l),1);s.push(l)},u=[],l=[];for(const e of this.outputs)o(e,u,l);const c=s.slice().reverse();for(const e of c){n[e.id]=e,e.id in t||(t[e.id]=0);let i=t[e.id];const s=null==r[e.outboundLayer.id]?0:r[e.outboundLayer.id];i=Math.max(i,s),r[e.outboundLayer.id]=i,a[e.outboundLayer.id]=e.outboundLayer,t[e.id]=i;for(let r=0;rparseInt(e,10))).sort($g);this.layers=[];for(const e of h){const t=d[e];t.sort(((e,t)=>{const n=i[e.id],r=i[t.id];return nr?1:0}));for(const e of t)e instanceof Yx&&this.internalContainerRefs.push(e),this.layers.push(e)}this.layersByDepth=d,h=Object.keys(p).map((e=>parseInt(e,10))).sort($g);const f=this.inputs.slice(),m=[];for(const e of h)for(const t of p[e]){const e=t.outboundLayer;if(null!=e){for(const n of t.inputTensors)if(-1===f.indexOf(n))throw new bg(`Graph disconnected: cannot obtain value for tensor ${n} at layer "${e.name}". The following previous layers were accessed without issue: ${m}`);for(const e of t.outputTensors)f.push(e);m.push(e.name)}}this.nodesByDepth=p;const g=this.layers.map((e=>e.name));for(const e of g){const t=g.filter((t=>t===e)).length;if(1!==t)throw new bg(`The name "${e}" is used ${t} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(g))}this.outboundNodes=[],this.inboundNodes=[],new ub({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map((e=>null)),outputMasks:this.outputs.map((e=>null)),inputShapes:this.inputs.map((e=>e.shape)),outputShapes:this.outputs.map((e=>e.shape))}),this.built=!0,this._refCount=1}assertNotDisposed(){if(0===this._refCount)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();const e={refCountAfterDispose:null,numDisposedVariables:0};if(0==--this._refCount){for(const t of this.layers)e.numDisposedVariables+=t.dispose().numDisposedVariables;for(const t of this.internalContainerRefs)e.numDisposedVariables+=t.dispose().numDisposedVariables}return e.refCountAfterDispose=this._refCount,e}get trainable(){return this.trainable_}set trainable(e){this.layers.forEach((t=>{t._trainableWeights.forEach((t=>t.trainable=e))})),this.trainable_=e}get trainableWeights(){if(this._trainableWeights.length>0)throw new xg("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return[];let e=[];for(const t of this.layers)e=e.concat(t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.layers)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const e of this.layers)t.push(...e.trainableWeights);return t.concat(e)}return e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(e,t=!0){const n={};let r=0;for(const e of this.layers)for(const t of e.weights){if(null!=n[t.originalName])throw new xg(`Duplicate weight name: ${t.originalName}`);n[t.originalName]=t,r++}const a=[];for(const r in e){let i=r;if(null==n[r]){const e=r.split("/");i=e.slice(0,-2).concat([e[e.length-1]]).join("/")}if(null!=n[i])a.push([n[i],e[r]]);else if(t)throw new xg(`Provided weight data has no target variable: ${r}`);delete n[i]}if(t){const e=[];for(const t in n)e.push(t);if(e.length>0)throw new xg(`${e.length} of ${r} weights are not set: ${e}`)}ab(a)}updatedConfig(){const e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion=`tfjs-layers ${Fx}`,t.backend="TensorFlow.js",t}toJSON(e,t=!0){const n=Rx(this.updatedConfig());return t?JSON.stringify(n):n}call(e,t){return co((()=>{e=Dg(e);const n=new fb;for(let t=0;t{let n;return e=Dg(e),n=null==t?Mg(null,e.length):Dg(t),this.runInternalGraph(e,n)[1]}))}computeOutputShape(e){const t=Zy(e);if(t.length!==this.inputLayers.length)throw new xg(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`);const n={};for(let e=0;eparseInt(e,10))).sort($g);if(r.length>1)for(const e of r){const t=this.nodesByDepth[e];for(const e of t){const t=e.outboundLayer;if(-1!==this.inputLayers.map((e=>e.id)).indexOf(t.id))continue;const r=[];for(let t=0;tparseInt(e,10))).sort($g);for(const e of r){const t=this.nodesByDepth[e];for(const e of t){const t=e.outboundLayer,r=e.inputTensors,a=e.outputTensors,i=new Array;for(const e of r)e.id in n&&i.push(n[e.id]);if(i.length===r.length){let r,s,o,u,l={};if(null!=e.callArgs&&(l=e.callArgs),1===i.length){const[e,n]=i[0];null==l.mask&&(l.mask=n),o=Dg(t.call(e,l)),u=Dg(t.computeMask(e,n)),r=[e],s=[n]}else r=i.map((e=>e[0])),s=i.map((e=>e[1])),null==l.mask&&(l.mask=s),o=Dg(t.call(r,l)),u=Dg(t.computeMask(r,s));if(t.activityRegularizer)throw new vg("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let e=0;e{const e=[];for(const t of this.layers)for(let n=0;n0){const e=[];for(let n=0;n0&&e.apply(kg(n),r)}function u(e){const n=e.name,i=ox(e,null!=t.customObjects?t.customObjects:{});i.setFastWeightInitDuringBuild(r),a[n]=i,e.inboundNodes.forEach((e=>{if(!(e instanceof Array))throw new xg(`Corrupted configuration, expected array for nodeData: ${e}`);s(i,e)}))}const l=t.name,c=t.layers;for(const e of c)u(e);for(;!Rg(i);)for(const e of c){const t=a[e.name];if(t.name in i){const e=i[t.name];delete i[t.name];for(const n of e)o(t,n)}}const p=[],d=[],h=t.inputLayers;for(const e of h){const t=e[0],n=e[1],r=e[2];Ng(t in a);const i=a[t].inboundNodes[n].outputTensors;p.push(i[r])}const f=t.outputLayers;for(const e of f){const t=e[0],n=e[1],r=e[2];Ng(t in a);const i=a[t].inboundNodes[n].outputTensors;d.push(i[r])}return new e({inputs:p,outputs:d,name:l})}get stateful(){if(this._stateful)throw new xg("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");for(const e of this.layers)if(e.stateful)return!0;return!1}resetStates(){co((()=>{this.layers.forEach((e=>{e.stateful&&e.resetStates()}))}))}}function zx(e,t){return function(e,t,n){const r=t.length;if(null==e||Array.isArray(e)&&0===e.length)return t.map((e=>null));if(1===r)return Array.isArray(e)&&1===e.length?e:"object"==typeof e&&t[0]in e?[e[t[0]]]:[e];if(Array.isArray(e)){if(e.length!==r)throw new Error(`Provided ${n} is an array of ${e.length} element(s), but the model has ${r} outputs. Make sure a set of weights is provided for each model output.`);return e}if("object"==typeof e&&Object.keys(e).length>0&&"object"==typeof e[Object.keys(e)[0]]){const n=[];return t.forEach((t=>{t in e?n.push(e[t]):n.push(null)})),n}throw new Error(`The model has multiple (${r}) outputs, so ${n} must be either an array with ${r} elements or an object with ${t} keys. Provided ${n} not understood: ${JSON.stringify(e)}`)}(e,t,"classWeight")}async function Bx(e,t,n,r){if(null!=t||null!=r)throw new Error("Support sampleWeight is not implemented yet");if(null!=n){const t=co((()=>{if(1===e.shape.length)return As(e);if(2===e.shape.length){if(e.shape[1]>1)return el(e,1);if(1===e.shape[1])return _l(e,[e.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${e.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}throw new Error(`Unexpected rank of target (y) tensor (${e.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)})),r=Array.from(await t.data());po(t);const a=[];return r.forEach((e=>{if(null==n[e])throw new Error(`classWeight must contain all classes in the training data. The class ${e} exists in the data but not in classWeight`);a.push(n[e])})),fd(a,"float32")}return null}function Px(e,t){return Mu(e,t)}function Hx(e,t){let n,r;const a=t;n=a.xs,r=a.ys,ie(null!=n&&null!=r,(()=>`A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates ${t}`));const i=jx("input",e.inputNames,n),s=jx("output",e.outputNames,r),o=i[0].shape[0];ie(i.length===e.inputs.length,(()=>`LayersModel has ${e.inputs.length} inputs, but the dataset provides ${i.length} inputs. (Expected input keys: ${JSON.stringify(e.inputNames)})`)),ie(s.length===e.outputs.length,(()=>`LayersModel has ${e.outputs.length} outputs, but the dataset provides ${s.length} outputs. (Expected output keys: ${JSON.stringify(e.outputNames)})`));for(let t=0;t`Batch size mismatch: input ${e.inputNames[t]} has ${i[t].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`));for(let t=0;t`Batch size mismatch: output ${e.outputNames[t]} has ${s[t].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`));return{xs:i,ys:s}}function jx(e,t,n){if(n instanceof Qa)return[n];if(Array.isArray(n))return ie(n.length===t.length,(()=>`Received an array of ${n.length} Tensors, but expected ${t.length} to match the ${e} keys ${t}.`)),n;{const r=[];for(const a of t){if(null==n[a])throw new xg(`The feature data generated by the dataset lacks the required ${e} key '${a}'.`);r.push(n[a])}return r}}function Ux(e){return"function"==typeof e.iterator}function qx(e){ie(e>0&&Number.isInteger(e),(()=>`batchSize is required to be a positive integer, but got ${e}`))}function Wx(e,t,n){return null==e?[null]:Array.isArray(e)?e.map((e=>my(e,t,n-t))):my(e,t,n-t)}function Vx(e,t){return co((()=>null==e?null:Array.isArray(e)?e.map((e=>Vx(e,t))):My(e,"int32"===t.dtype?t:Cs(t,"int32"))))}function Gx(e,t){const n=[];let r=0,a=null;for(;r=e&&(a=e),n.push([r,a]),r=a;return n}function Kx(e){const t=[];e instanceof Qa&&(e=[e]);for(let n=0;nn.push(e.id)));else if(null!=t)for(const e in t){const r=t[e];n.push(r.id)}const r=[];if(e instanceof Qa)-1===n.indexOf(e.id)&&r.push(e);else if(Array.isArray(e))e.forEach((e=>{-1===n.indexOf(e.id)&&r.push(e)}));else if(null!=e)for(const t in e){const a=e[t];-1===n.indexOf(a.id)&&r.push(a)}r.forEach((e=>{e.isDisposed||e.dispose()}))}function Xx(e){return Array.isArray(e)}function Zx(e){return!function(e){return e instanceof Qa}(e)&&!Xx(e)}function Qx(e,t,n,r=!0,a=""){if(null==t||0===t.length){if(null!=e){let t=!1;if(Xx(e)&&e.length>0)t=!0;else if(Zx(e)){for(const n in e)if(e.hasOwnProperty(n)){t=!0;break}}else t=!0;if(t)throw new xg(`Error when checking model ${a} expected no data, but got ${e}`)}return[]}if(null==e)return t.map((e=>null));let i;if(Zx(e)){i=[];for(const n of t){if(null==e[n])throw new xg(`No data provided for "${n}". Need data for each key in: ${t}`);i.push(e[n])}}else if(Xx(e)){if(e.length!==t.length)throw new xg(`Error when checking model ${a}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${t.length} Tensor(s), but instead got the following list of Tensor(s): ${e}`);i=e}else{if(t.length>1)throw new xg(`The model ${a} expects ${t.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${e.shape}`);i=[e]}if(i=Kx(i),null!=n)for(let e=0;e=0&&i!==o)throw new xg(`${a} expected a batch of elements where each example has shape [${n[e].slice(1,n[e].length)}] (i.e.,tensor shape [*,${n[e].slice(1,n[e].length)}]) but the ${a} received an input with ${s.shape[0]} examples, each with shape [${s.shape.slice(1,s.shape.length)}] (tensor shape [${s.shape}])`)}}return i}function ev(e,t,n,r=!0,a=""){let i;if(Array.isArray(e)){if(e.length!==t.length)throw new xg(`Error when checking model ${a}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${t.length} Tensor(s), but instead got ${e.length} Tensors(s).`);i=e}else{if(t.length>1)throw new xg(`The model expects ${t.length} ${a} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(e.shape)}.`);i=[e]}if(null!=n)for(let e=0;e1||1===e.length&&e[0].inboundLayers.length>1){t=!1;break}r.push(...e)}if(t)for(const n of e.layers){let e=!1;for(const a of n.inboundNodes)if(-1!==r.indexOf(a)){if(e){t=!1;break}e=!0}if(!t)break}return t}(e),i=["Layer (type)","Input Shape","Output shape","Param #"];let s;if(a?(t=t||90,n=n||[.32,.61,.89,1]):(t=t||115,n=n||[.24,.48,.7,.8,1]),n[n.length-1]<=1&&(n=n.map((e=>Math.floor(t*e)))),!a){i.push("Receives inputs"),s=[];for(const t in e.nodesByDepth)s.push(...e.nodesByDepth[t])}r("_".repeat(t)),Cx(i,n,r),r("=".repeat(t));const o=e.layers;for(let e=0;eWh.adagrad(.01),Adadelta:()=>Wh.adadelta(1,.95,dy()),Adam:()=>Wh.adam(.001,.9,.999,dy()),Adamax:()=>Wh.adamax(.002,.9,.999,dy(),0),RMSProp:()=>Wh.rmsprop(.001,.9,0,dy()),SGD:()=>Wh.sgd(.01)};if(t.adagrad=t.Adagrad,t.adadelta=t.Adadelta,t.adam=t.Adam,t.adamax=t.Adamax,t.rmsprop=t.RMSProp,t.sgd=t.SGD,e in t)return t[e]();throw new xg(`Unknown Optimizer ${e}`)}(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof Ou))throw new xg("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let t=[];if(Array.isArray(e.loss)||"string"==typeof e.loss||"function"==typeof e.loss)if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new xg(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${e.loss}.`);const n=e.loss;t=n.map((e=>yx(e)))}else{const n=yx(e.loss);this.outputs.forEach((e=>{t.push(n)}))}else{e.loss=e.loss;for(const t in e.loss)if(-1===this.outputNames.indexOf(t))throw new xg(`Unknown entry in loss dictionary: "${t}". Only expected the following keys: ${this.outputNames}`);for(const n of this.outputNames)null==e.loss[n]&&console.warn(`Output "${n}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${n} during training`),t.push(yx(e.loss[n]))}this.lossFunctions=t,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let e=0;e{for(let e=0;e1&&(this.metricsTensors.push([t,e]),this.metricsNames.push(this.outputNames[e]+"_loss"))}}));const r=function(e,t){if(null==e||Array.isArray(e)&&0===e.length)return t.map((e=>[]));let n;if("string"==typeof e||"function"==typeof e)n=[e];else{if(!Array.isArray(e)&&"object"!=typeof e)throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${e}`);n=e}if(Array.isArray(n))return t.map((e=>n));{const e=[];for(const r of t){let t=n.hasOwnProperty(r)?n[r]:[];Array.isArray(t)||(t=[t]),e.push(t)}return e}}(e.metrics,this.outputNames),a=(e,t,n)=>{this.outputNames.length>1&&(t=this.outputNames[e]+"_"+t),this.metricsNames.push(t),this.metricsTensors.push([n,e])};ny("metric",(()=>{for(let e=0;e{let n,r,i;for(const s of t){if("string"==typeof s&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(s)){const t=this.internalOutputShapes[e];let a;1===t[t.length-1]||this.lossFunctions[e]===fx?-1!==["accuracy","acc"].indexOf(s)?r=bx:-1!==["crossentropy","ce"].indexOf(s)&&(r=wx):this.lossFunctions[e]===hx?-1!==["accuracy","acc"].indexOf(s)?r=Mx:-1!==["crossentropy","ce"].indexOf(s)&&(r=Sx):-1!==["accuracy","acc"].indexOf(s)?r=xx:-1!==["crossentropy","ce"].indexOf(s)&&(r=Nx),-1!==["accuracy","acc"].indexOf(s)?a="acc":-1!==["crossentropy","ce"].indexOf(s)&&(a="ce"),i=r,n=""+a}else{const e=Dx(s);i=e,n=""+Tx(s)}let t;ny(n,(()=>{t=i})),a(e,n,t)}})(r[e])})),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){null!=this.collectedTrainableWeights&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")}evaluate(e,t,n={}){const r=null==n.batchSize?32:n.batchSize;qx(r);const a=this.standardizeUserDataXY(e,t,!0,r);try{const i=a[0].concat(a[1]);this.makeTestFunction();const s=this.testFunction;return kg(this.testLoop(s,i,r,n.verbose,n.steps))}finally{Jx(a[0],e),Jx(a[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),async function(e,t,n){const r=null!=(n=n||{}).batches,a=e.testFunction;let i=[];if(n.verbose>0)throw new vg("Verbose mode is not implemented yet.");ie(!r||n.batches>0&&Number.isInteger(n.batches),(()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`));const s="function"==typeof t.next?t:await t.iterator();let o=0,u=0;for(;!r||u{if(t.value){const{xs:n,ys:r}=Hx(e,t.value),s=n.concat(r),l=co((()=>a(s)));if(po(s),0===u)for(let e=0;evu(i[e],Mu(c,t)))),u>0&&po(n)}po(l),o+=c,++u}return i})),t.done){r&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${n.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let e=0;ee.name));for(let r=0;r0){const n=[];throw t.forEach(((t,r)=>{null==t&&n.push(e[r])})),new xg(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(n)}`)}return t}predictLoop(e,t=32,n=!1){return co((()=>{const r=this.checkNumSamples(e);if(n)throw new vg("Verbose predictLoop() is not implemented yet.");const a=Gx(r,t),i=this.outputs.map((e=>[]));for(let t=0;t{const n=a[t][0],r=a[t][1],i=Wx(e,n,r),s=[];if(Array.isArray(i))for(let e=0;ei[t].push(e)))}return kg(i.map((e=>Nl(e,0))))}))}predict(e,t={}){const n=Kx(e);ev(n,this.inputNames,this.feedInputShapes,!1);try{const r=null==t.batchSize?32:t.batchSize;return qx(r),this.predictLoop(n,r)}finally{Jx(n,e)}}predictOnBatch(e){ev(e,this.inputNames,this.feedInputShapes,!0);const t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)}standardizeUserDataXY(e,t,n=!0,r){if(null==this.optimizer_)throw new bg("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const a=[];for(let e=0;ee.shape[0])));r.sort();const a=Og(t.map((e=>e.shape[0])));if(a.sort(),r.length>1)throw new xg(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map((e=>e.shape)))}`);if(a.length>1)throw new xg(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map((e=>e.shape)))}`);if(r.length>0&&a.length>0&&!pe(r,a))throw new xg(`Input Tensors should have the same number of samples as target Tensors. Found ${r[0]} input sample(s) and ${a[0]} target sample(s).`)}(e=Qx(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=Qx(t,this.feedOutputNames,a,!1,"target")),function(e,t,n){const r=[lx,fx,dx];for(let a=0;a0&&e[0].shape[0]%r!=0)throw new xg(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${r}. Found: ${e[0].shape[0]} sample(s).`);return[e,t]}async standardizeUserData(e,t,n,r,a=!0,i){const[s,o]=this.standardizeUserDataXY(e,t,a,i);if(null!=n)throw new Error("sample weight is not supported yet.");let u=null;if(null!=r){const e=zx(r,this.outputNames);u=[];for(let t=0;t{const i=this.checkNumSamples(t,n,a,"steps"),s=[];if(r>0)throw new vg("Verbose mode is not implemented yet.");if(null!=a)throw new vg("steps mode in testLoop() is not implemented yet");{const r=Gx(i,n),a=fd(cy(0,i));for(let n=0;n1&&(a+=`_${Sg(e.slice(0,n),r)}`),t.push(a)}return t}makeTrainFunction(){return e=>{const t=[],n=e.slice(0,this.inputs.length),r=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),a=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+2*this.outputs.length),i=[],s=this.collectedTrainableWeights.map((e=>e.read())),o=this.optimizer_.minimize((()=>{const e=[];for(let t=0;t1&&e{u=vu(u,e)})),u}),!0,s);return[o].concat(i)}}makeTestFunction(){this.testFunction=e=>co((()=>{const t=[];let n;const r=e.slice(0,this.inputs.length),a=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),i=[];for(let e=0;e0){if(y=!0,2!==r.validationData.length)throw 3===r.validationData.length?new vg("validationData including sample weights is not supported yet."):new xg(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${r.validationData} is invalid.`);u=r.validationData[0],l=r.validationData[1];const t=!0,n=await e.standardizeUserData(u,l,null,null,t,h);c=n[0],p=n[1],g=c.concat(p)}else if(null!=r.validationSplit&&r.validationSplit>0&&r.validationSplit<1){y=!0;const e=Math.floor(a[0].shape[0]*(1-r.validationSplit)),t=a[0].shape[0];c=Wx(a,e,t),s=a,a=Wx(a,0,e),p=Wx(i,e,t),o=i,i=Wx(i,0,e),g=c.concat(p)}else null!=r.validationSteps&&(y=!0);const b=a.concat(i).concat(d);e.checkTrainableWeightsConsistency();const x=e.makeTrainFunction(),v=e.getDedupedMetricsNames();let _,w;y?(e.makeTestFunction(),_=e.testFunction,w=v.slice().concat(v.map((e=>"val_"+e)))):(_=null,g=[],w=v.slice());const M=ax(r.callbacks,r.yieldEvery),N=await async function(e,t,n,r,a,i,s,o,u,l,c,p,d,h,f){null==a&&(a=32),null==i&&(i=1),null==c&&(c=!0),null==d&&(d=0);let m=!1;null!=u&&null!=l&&(m=!0);const g=e.checkNumSamples(n,a,h,"steps_per_epoch");let y;null!=g&&(y=cy(0,g)),null==s&&(s=1);const{callbackList:b,history:x}=sx(o,s,i,d,g,h,a,m,p);b.setModel(e),e.history=x,await b.onTrainBegin(),e.stopTraining_=!1;for(let s=d;s{const d=o[c][0],h=o[c][1],f=my(s,d,h-d);p.batch=c,p.size=h-d;const g=Vx(n,f),y=t(g);for(let e=0;e"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig).")),ie(null!=n,(()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call.")),ie(null!=n.epochs&&n.epochs>0&&Number.isInteger(n.epochs),(()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${n.epochs}`)),ie(!r||n.batchesPerEpoch>0&&Number.isInteger(n.batchesPerEpoch),(()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${n.batchesPerEpoch}`)),ie(null==n.validationSplit,(()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead.")),e.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");e.isTraining=!0;try{const a=null!=n.validationData;let i,s;if(a)if(Ux(n.validationData))ie(null==n.validationBatches||n.validationBatches>0&&Number.isInteger(n.validationBatches),(()=>`For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${n.validationBatches}`));else{const e=function(e){if(3===e.length)throw new vg("Validation with sample weights is not implemented yet.");return{xs:e[0],ys:e[1]}}(n.validationData);i=e.xs,s=e.ys}const o=e.makeTrainFunction(),u=e.getDedupedMetricsNames();let l;l=a?u.slice().concat(u.map((e=>"val_"+e))):u.slice();const c=ax(n.callbacks,n.yieldEvery),p=null==n.verbose?1:n.verbose,{callbackList:d,history:h}=sx(c,p,n.epochs,null,null,function(e,t){let n=null;return null!=t.batchesPerEpoch?n=t.batchesPerEpoch:Number.isFinite(e.size)&&(n=e.size),n}(t,n),null,a,l);d.setModel(e),e.history=h,await d.onTrainBegin(),e.stopTraining_=!1;let f=null==n.initialEpoch?0:n.initialEpoch,m=await t.iterator();for(;f=n.batchesPerEpoch:t.done){if(a){let t;t=Ux(n.validationData)?Dg(await e.evaluateDataset(n.validationData,{batches:n.validationBatches})):Dg(e.evaluate(i,s,{batchSize:null==n.validationBatchSize?32:n.validationBatchSize,verbose:0}));for(let n=0;nTg(e)))}else{const t=Object.keys(this.loss);e={};const n=this.loss;for(const r of t){if("string"!=typeof n[r])throw new Error("Serialization of non-string loss is not supported.");e[r]=Tg(n[r])}}return e}getMetricIdentifiers(){if("string"==typeof this.metrics||"function"==typeof this.metrics)return[Tg(Tx(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map((e=>Tg(Tx(e))));{const e={};for(const t in this.metrics)e[t]=Tg(Tx(this.metrics[t]));return e}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(e){if(null!=e.weighted_metrics)throw new Error("Loading weight_metrics is not supported yet.");if(null!=e.loss_weights)throw new Error("Loading loss_weights is not supported yet.");if(null!=e.sample_weight_mode)throw new Error("Loading sample_weight_mode is not supported yet.");const t=ox(Ox(e.optimizer_config));let n,r;if("string"==typeof e.loss)n=Ig(e.loss);else if(Array.isArray(e.loss))n=e.loss.map((e=>Ig(e)));else if(null!=e.loss){n={};for(const t in e.loss)n[t]=Ig(e.loss[t])}if(Array.isArray(e.metrics))r=e.metrics.map((e=>Ig(e)));else if(null!=e.metrics){r={};for(const t in e.metrics)r[t]=Ig(e.metrics[t])}this.compile({loss:n,metrics:r,optimizer:t})}async save(e,t){if("string"==typeof e){const t=Xi(e);if(0===t.length)throw new xg(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new xg(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw new xg("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const n=await Fi(this.getNamedWeights(t)),r={modelTopology:this.toJSON(null,!1),format:"layers-model",generatedBy:`TensorFlow.js tfjs-layers v${Fx}`,convertedBy:null};if(null!=t&&t.includeOptimizer&&null!=this.optimizer){r.trainingConfig=this.getTrainingConfig();const e="optimizer",{data:t,specs:a}=await Fi(await this.optimizer.getWeights(),e);n.specs.push(...a),n.data=Hi([n.data,t])}if(null!=this.userDefinedMetadata){const e=!0;Ix(this.userDefinedMetadata,this.name,e),r.userDefinedMetadata=this.userDefinedMetadata}return r.weightData=n.data,r.weightSpecs=n.specs,e.save(r)}setUserDefinedMetadata(e){Ix(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}}tv.className="Model",ou(tv);class nv extends tv{}async function rv(e,t){"modelTopology"in e||(e={modelTopology:e});let n=e.modelTopology;null!=n.model_config&&(n=n.model_config);const r=ox(Ox(n),t);if(null!=e.weightsManifest){const t=await Bs(e.weightsManifest,e.pathPrefix,r.weights.map((e=>e.originalName))),n={};for(const e of r.weights)n[e.originalName]=t[e.originalName];r.loadWeights(n),po(t)}return r}nv.className="Functional",ou(nv);class av extends tv{constructor(e){if(super({inputs:[],outputs:[]}),e=e||{},this.trainable=!0,this.built=!1,this.name=null!=e.name?e.name:qg("sequential_"),null!=e.layers)for(const t of e.layers)this.add(t)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some((e=>e<0)))throw new xg(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){const t=e instanceof av||e instanceof tv;let n;if(t){if(n=e,1!==n.outputs.length)throw new xg("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(1!==n.inputs.length)throw new xg("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(0===this.outputs.length){if(0===e.inboundNodes.length){if(null==e.batchInputShape)throw new xg("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");const t=hb({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(t)}if(t)this.outputs=n.outputs,this.inputs=n.inputs;else{if(1!==e.inboundNodes.length)throw new xg(`A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer ${e.name} which has ${e.inboundNodes.length} pre-existing inbound connections.`);if(1!==e.inboundNodes[0].outputTensors.length)throw new xg("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[e.inboundNodes[0].outputTensors[0]],this.inputs=pb(this.outputs[0])}this.inboundNodes=[],new ub({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:Mg(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map((e=>e.shape)),outputShapes:this.outputs[0].shape})}else{const t=e.apply(this.outputs[0]);if(Array.isArray(t))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[t],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(0===this.layers.length)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),0===this.layers.length)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{const e=this.layers.length-1;this.layers[e].outboundNodes=[],this.outputs=[this.layers[e].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}}call(e,t){return null==this.model&&this.build(),this.model.call(e,t)}build(e){if(eb(e),0===this.inputs.length||0===this.outputs.length)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new tv({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supportsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0}countParams(){return this.built||this.build(),super.countParams()}summary(e,t,n=console.log){this.built||this.build(),super.summary(e,t,n)}setWeights(e){null==this.model&&this.build(),this.model.setWeights(e)}evaluate(e,t,n={}){if(!this.built)throw new bg("The model needs to be compiled before being used.");return this.model.evaluate(e,t,n)}async evaluateDataset(e,t){if(!this.built)throw new bg("The model needs to be compiled before being used.");return this.model.evaluateDataset(e,t)}predict(e,t={}){return null==this.model&&this.build(),this.model.predict(e,t)}predictOnBatch(e){return null==this.model&&this.build(),this.model.predictOnBatch(e)}compile(e){this.build(),this.model.compile(e),this.optimizer_=this.model.optimizer,this.isOptimizerOwned=this.model.isOptimizerOwned,this.loss=this.model.loss,this.metrics=this.model.metrics,this.metricsTensors=this.model.metricsTensors,this.metricsNames=this.model.metricsNames}get optimizer(){return null==this.model?void 0:this.model.optimizer}set optimizer(e){this.model.optimizer=e}async fit(e,t,n={}){if(!this.built)throw new bg("The model needs to be compiled before being used.");return this.model.fit(e,t,n)}async fitDataset(e,t){if(!this.built)throw new bg("The model needs to be compiled before being used.");return this.model.fitDataset(e,t)}async trainOnBatch(e,t){return this.model.trainOnBatch(e,t)}static fromConfig(e,t,n={},r=!1){let a,i={};if(t instanceof Array){if(null==t[0].className||"Merge"===t[0].className)throw new xg("Legacy serialization format not supported yet.");a=t}else ie(null!=t.layers,(()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field.")),a=t.layers,delete t.layers,i=t;const s=new e(i);if(!(s instanceof av))throw new vg(`Sequential.fromConfig called on non-Sequential input: ${s}`);for(const e of a){const t=ox(e,void 0,r);r&&t.setFastWeightInitDuringBuild(!0),s.add(t)}return s}set stopTraining(e){if(null==this.model)throw new xg("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}get stopTraining(){if(null==this.model)throw new xg("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}getConfig(){const e=[];for(const t of this.layers){const n={};n.className=t.getClassName(),n.config=t.getConfig(),e.push(n)}return{name:this.name,layers:e}}}function iv(e){return new tv(e)}function sv(e){return new av(e)}function ov(e,t){return null==t&&(t={}),async function(e,t){if(null==t&&(t={}),"string"==typeof e){const n=Zi(e,t);if(0===n.length)n.push(Ws(e,t));else if(n.length>1)throw new xg(`Found more than one (${n.length}) load handlers for URL '${e}'`);e=n[0]}return async function(e,t,n){if(null==n&&(n={}),null==e.load)throw new xg("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const r=await e.load();let a=r.modelTopology;null!=a.model_config&&(a=a.model_config);const i=null==n.strict||n.strict,s=null!=r.weightData&&null!=r.weightSpecs&&i,o=ox(Ox(a),void 0,s),u=r.trainingConfig;if(null!=u&&o.loadTrainingConfig(u),null!=r.userDefinedMetadata&&o.setUserDefinedMetadata(r.userDefinedMetadata),null!=r.weightData){if(null==r.weightSpecs)throw new xg("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");const{modelWeights:e,optimizerWeights:t}=function(e,t){const n=Yi(e,t),r={},a=[];return t.forEach((e=>{"optimizer"===e.group?a.push({name:e.name,tensor:n[e.name]}):r[e.name]=n[e.name]})),{modelWeights:r,optimizerWeights:a}}(r.weightData,r.weightSpecs);o.loadWeights(e,i),null!=o.optimizer&&t.length>0&&await o.optimizer.setWeights(t),po(e),po(t.map((e=>e.tensor)))}return o}(e,0,t)}(e,t)}function uv(e){return hb(e)}function lv(e,t){ix.registerCallbackConstructor(e,t)}av.className="Sequential",ou(av);class cv extends iu{getConfig(){return{}}}class pv extends cv{apply(e,t=1){return function(e,t=1){if(1!==t)throw new vg(`Support for alpha values other than 1 (${t}) is not implemented yet.`);return cc(e)}(e,t)}}pv.className="elu",ou(pv);class dv extends cv{apply(e){return Wp(e)}}dv.className="selu",ou(dv);class hv extends cv{apply(e){return Fp(e)}}hv.className="relu",ou(hv);class fv extends cv{apply(e){return co((()=>lp(6,Fp(e))))}}fv.className="relu6",ou(fv);class mv extends cv{apply(e){return e}}mv.className="linear",ou(mv);class gv extends cv{apply(e){return Sl(e)}}gv.className="sigmoid",ou(gv);class yv extends cv{apply(e){return function(e){return co((()=>{const t=vu(.5,Mu(.2,e));return Yl(t,0,1)}))}(e)}}yv.className="hardSigmoid",ou(yv);class bv extends cv{apply(e){return qc(e)}}bv.className="softplus",ou(bv);class xv extends cv{apply(e){return function(e){return co((()=>wu(e,vu(Hu(e),1))))}(e)}}xv.className="softsign",ou(xv);class vv extends cv{apply(e){return Dl(e)}}vv.className="tanh",ou(vv);class _v extends cv{apply(e,t=-1){return nd(e,t)}}_v.className="softmax",ou(_v);class wv extends cv{apply(e,t=-1){return Vc(e,t)}}wv.className="logSoftmax",ou(wv);class Mv extends cv{apply(e,t=1){return co((()=>Mu(Sl(Mu(e,t)),e)))}}Mv.className="swish",ou(Mv);class Nv extends cv{apply(e){return co((()=>Mu(e,Dl(qc(e)))))}}function Sv(e){return e.getClassName()}function kv(e,t={}){return Lg(e,su.getMap().classNameMap,t,"activation")}function Dv(e){if(null==e){return kv({className:"linear",config:{}})}if("string"==typeof e){const t={};return t.className=e,t.config={},kv(t)}return e instanceof cv?e:kv(e)}function Tv(e){if(null!=e&&"object"!=typeof e)throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${e}`)}Nv.className="mish",ou(Nv);class Iv extends iu{}class Ev extends Iv{constructor(e){super(),Tv(e),this.l1=null==e||null==e.l1?.01:e.l1,this.l2=null==e||null==e.l2?.01:e.l2,this.hasL1=0!==this.l1,this.hasL2=0!==this.l2}apply(e){return co((()=>{let t=sp([1]);return this.hasL1&&(t=vu(t,wc(Mu(this.l1,Hu(e))))),this.hasL2&&(t=vu(t,wc(Mu(this.l2,Ny(e))))),_l(t,[])}))}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}}Ev.className="L1L2",ou(Ev);const Cv={l1l2:"L1L2"};function Av(e){return Cg(e)}function Lv(e,t={}){return Lg(e,su.getMap().classNameMap,t,"regularizer")}function $v(e){return null==e?null:"string"==typeof e?Lv({className:e in Cv?Cv[e]:e,config:{}}):e instanceof Iv?e:Lv(e)}class Ov extends cb{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,null!=e&&(this.maxValue=e.maxValue)}call(e,t){e=Qy(e);let n=Fp(e);return null!=this.maxValue&&(n=Yl(n,0,this.maxValue)),n}computeOutputShape(e){return e}getConfig(){const e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}}Ov.className="ReLU",ou(Ov);class Rv extends cb{constructor(e){super(null==e?{}:e),this.DEFAULT_ALPHA=.3,null==e&&(e={}),this.alpha=null==e.alpha?this.DEFAULT_ALPHA:e.alpha}call(e,t){const n=Qy(e);return Yc(n,this.alpha)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}}Rv.className="LeakyReLU",ou(Rv);class Fv extends cb{constructor(e){if(super(null==e?{}:e),this.DEFAULT_ALPHA_INITIALIZER="zeros",null==e&&(e={}),this.supportsMasking=!0,this.alphaInitializer=Jy(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=$v(e.alphaRegularizer),this.alphaConstraint=Eb(e.alphaConstraint),null==e.sharedAxes)this.sharedAxes=null;else if(Array.isArray(e.sharedAxes))this.sharedAxes=e.sharedAxes;else{if("number"!=typeof e.sharedAxes)throw new xg(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`);this.sharedAxes=[e.sharedAxes]}}build(e){const t=(e=eb(e)).slice(1);if(null!=this.sharedAxes)for(const e of this.sharedAxes)t[e-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);const n={};if(null!=this.sharedAxes)for(let t=1;t(Zg(t),"channelsFirst"===t?Do(e,[0,2,3,1]):e)))}function qv(e,t){return co((()=>(Zg(t),"channelsFirst"===t?Do(e,[0,2,3,4,1]):e)))}function Wv(e,t,n,r=[1,1],a="valid",i,s,o=null){return co((()=>{if(null==i&&(i="channelsLast"),Zg(i),3!==e.rank&&4!==e.rank)throw new xg(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${e.rank}.`);if(3!==t.rank&&4!==t.rank)throw new xg(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${e.rank}.`);let u=Uv(e,i);if("causal"===a)throw new vg("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return u=Hd({x:u,filter:t,strides:r,pad:"same"===a?"same":"valid",dilations:s,dataFormat:"NHWC",bias:n,activation:o}),"channelsFirst"===i&&(u=Do(u,[0,3,1,2])),u}))}Bv.className="Softmax",ou(Bv);class Vv extends cb{constructor(e,t){if(super(t),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",Vv.verifyArgs(t),this.rank=e,zg(this.rank,"rank"),1!==this.rank&&2!==this.rank&&3!==this.rank)throw new vg(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=Pv(t.kernelSize,e,"kernelSize"),this.strides=Pv(null==t.strides?1:t.strides,e,"strides"),this.padding=null==t.padding?"valid":t.padding,Qg(this.padding),this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,Zg(this.dataFormat),this.activation=Dv(t.activation),this.useBias=null==t.useBias||t.useBias,this.biasInitializer=Jy(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=Eb(t.biasConstraint),this.biasRegularizer=$v(t.biasRegularizer),this.activityRegularizer=$v(t.activityRegularizer),this.dilationRate=Pv(null==t.dilationRate?1:t.dilationRate,e,"dilationRate"),1===this.rank&&Array.isArray(this.dilationRate)&&1!==this.dilationRate.length)throw new xg(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(2===this.rank){if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate];else if(2!==this.dilationRate.length)throw new xg(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(3===this.rank)if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(3!==this.dilationRate.length)throw new xg(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}static verifyArgs(e){if(Ng("kernelSize"in e,"required key 'kernelSize' not in config"),"number"!=typeof e.kernelSize&&!Yg(e.kernelSize,"number",1,3))throw new xg(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(e.kernelSize)}.`)}getConfig(){const e={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:Sv(this.activation),useBias:this.useBias,biasInitializer:Ky(this.biasInitializer),biasRegularizer:Av(this.biasRegularizer),activityRegularizer:Av(this.activityRegularizer),biasConstraint:Tb(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}class Gv extends Vv{constructor(e,t){super(e,t),this.kernel=null,Gv.verifyArgs(t),this.filters=t.filters,zg(this.filters,"filters"),this.kernelInitializer=Jy(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=Eb(t.kernelConstraint),this.kernelRegularizer=$v(t.kernelRegularizer)}build(e){e=eb(e);const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new xg(`The channel dimension of the input should be defined. Found ${e[t]}`);const n=e[t],r=this.kernelSize.concat([n,this.filters]);this.kernel=this.addWeight("kernel",r,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[t]:n}}],this.built=!0}call(e,t){return co((()=>{let t;e=Qy(e);const n=null==this.bias?null:this.bias.read(),r=Pg(this.activation.getClassName());if(null!=r&&2===this.rank)t=Wv(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate,r);else{if(1===this.rank)t=function(e,t,n,r=1,a="valid",i,s=1){return co((()=>{if(null==i&&(i="channelsLast"),Zg(i),3!==e.shape.length)throw new xg(`The input of a conv1dWithBias operation should be 3, but is ${e.shape.length} instead.`);if(3!==t.shape.length)throw new xg(`The kernel for a conv1dWithBias operation should be 3, but is ${t.shape.length} instead`);if(null!=n&&1!==n.shape.length)throw new xg(`The bias for a conv1dWithBias operation should be 1, but is ${t.shape.length} instead`);if("channelsFirst"===i&&(e=Do(e,[0,2,1])),"causal"===a)throw new vg("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let o=Ul(e,t,r,"same"===a?"same":"valid","NWC",s);return null!=n&&(o=ky(o,n)),o}))}(e,this.kernel.read(),n,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(2===this.rank)t=Wv(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate);else{if(3!==this.rank)throw new vg("convolutions greater than 3D are not implemented yet.");t=function(e,t,n,r=[1,1,1],a="valid",i,s){return co((()=>{if(null==i&&(i="channelsLast"),Zg(i),4!==e.rank&&5!==e.rank)throw new xg(`conv3dWithBias expects input to be of rank 4 or 5, but received ${e.rank}.`);if(4!==t.rank&&5!==t.rank)throw new xg(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${e.rank}.`);let o=qv(e,i);if("causal"===a)throw new vg("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return o=Vl(o,t,r,"same"===a?"same":"valid","NDHWC",s),null!=n&&(o=ky(o,n)),"channelsFirst"===i&&(o=Do(o,[0,4,1,2,3])),o}))}(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate)}null!=this.activation&&(t=this.activation.apply(t))}return t}))}computeOutputShape(e){e=eb(e);const t=[],n="channelsLast"===this.dataFormat?e.slice(1,e.length-1):e.slice(2);for(let e=0;e 0 but got ${JSON.stringify(e.filters)}`)}}class Kv extends Gv{constructor(e){super(2,e),Kv.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&!Yg(e.kernelSize,"number",1,2))throw new xg(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}}Kv.className="Conv2D",ou(Kv);class Jv extends Gv{constructor(e){super(3,e),Jv.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&(!Array.isArray(e.kernelSize)||1!==e.kernelSize.length&&3!==e.kernelSize.length))throw new xg(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}}Jv.className="Conv3D",ou(Jv);class Xv extends Kv{constructor(e){if(super(e),this.inputSpec=[new ib({ndim:4})],"same"!==this.padding&&"valid"!==this.padding)throw new xg(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(4!==(e=eb(e)).length)throw new xg("Input should have rank 4; Received input shape: "+JSON.stringify(e));const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new xg("The channel dimension of the inputs should be defined. Found `None`.");const n=e[t],r=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",r,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new ib({ndim:4,axes:{[t]:n}})],this.built=!0}call(e,t){return co((()=>{let t=Qy(e);if(4!==t.shape.length)throw new xg(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`);const n=t.shape,r=n[0];let a,i;"channelsFirst"===this.dataFormat?(a=2,i=3):(a=1,i=2);const s=n[a],o=n[i],u=this.kernelSize[0],l=this.kernelSize[1],c=this.strides[0],p=this.strides[1],d=[r,jv(s,c,u,this.padding),jv(o,p,l,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(t=Do(t,[0,2,3,1]));let h=Wl(t,this.kernel.read(),d,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(h=Do(h,[0,3,1,2])),null!=this.bias&&(h=ky(h,this.bias.read(),this.dataFormat)),null!=this.activation&&(h=this.activation.apply(h)),h}))}computeOutputShape(e){const t=(e=eb(e)).slice();let n,r,a;"channelsFirst"===this.dataFormat?(n=1,r=2,a=3):(n=3,r=1,a=2);const i=this.kernelSize[0],s=this.kernelSize[1],o=this.strides[0],u=this.strides[1];return t[n]=this.filters,t[r]=jv(t[r],o,i,this.padding),t[a]=jv(t[a],u,s,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}Xv.className="Conv2DTranspose",ou(Xv);class Zv extends Jv{constructor(e){if(super(e),this.inputSpec=[new ib({ndim:5})],"same"!==this.padding&&"valid"!==this.padding)throw new xg(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(5!==(e=eb(e)).length)throw new xg("Input should have rank 5; Received input shape: "+JSON.stringify(e));const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new xg("The channel dimension of the inputs should be defined. Found `None`.");const n=e[t],r=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",r,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new ib({ndim:5,axes:{[t]:n}})],this.built=!0}call(e,t){return co((()=>{let t=Qy(e);if(5!==t.shape.length)throw new xg(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`);const n=t.shape,r=n[0];let a,i,s;"channelsFirst"===this.dataFormat?(s=2,a=3,i=4):(s=1,a=2,i=3);const o=n[s],u=n[a],l=n[i],c=this.kernelSize[0],p=this.kernelSize[1],d=this.kernelSize[2],h=this.strides[0],f=this.strides[1],m=this.strides[2],g=[r,jv(o,h,c,this.padding),jv(u,f,p,this.padding),jv(l,m,d,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(t=Do(t,[0,2,3,4,1]));let y=Kl(t,this.kernel.read(),g,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(y=Do(y,[0,4,1,2,3])),null!==this.bias&&(y=ky(y,this.bias.read(),this.dataFormat)),null!==this.activation&&(y=this.activation.apply(y)),y}))}computeOutputShape(e){const t=(e=eb(e)).slice();let n,r,a,i;"channelsFirst"===this.dataFormat?(n=1,r=2,a=3,i=4):(n=4,r=1,a=2,i=3);const s=this.kernelSize[0],o=this.kernelSize[1],u=this.kernelSize[2],l=this.strides[0],c=this.strides[1],p=this.strides[2];return t[n]=this.filters,t[r]=jv(t[r],l,s,this.padding),t[a]=jv(t[a],c,o,this.padding),t[i]=jv(t[i],p,u,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}Zv.className="Conv3DTranspose",ou(Zv);class Qv extends Gv{constructor(e,t){if(super(e,t),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,null==t.filters)throw new xg("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=t.kernelInitializer||null!=t.kernelRegularizer||null!=t.kernelConstraint)throw new xg("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(null!=t.padding&&"same"!==t.padding&&"valid"!==t.padding)throw new xg(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(t.padding)}`);this.depthMultiplier=null==t.depthMultiplier?1:t.depthMultiplier,this.depthwiseInitializer=Jy(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=$v(t.depthwiseRegularizer),this.depthwiseConstraint=Eb(t.depthwiseConstraint),this.pointwiseInitializer=Jy(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=$v(t.pointwiseRegularizer),this.pointwiseConstraint=Eb(t.pointwiseConstraint)}build(e){if((e=eb(e)).length{let t;if(e=Qy(e),1===this.rank)throw new vg("1D separable convolution is not implemented yet.");return 2===this.rank&&("channelsFirst"===this.dataFormat&&(e=Do(e,[0,2,3,1])),t=Vp(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(t=ky(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),"channelsFirst"===this.dataFormat&&(t=Do(t,[0,3,1,2])),t}))}getConfig(){const e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=Ky(this.depthwiseInitializer),e.pointwiseInitializer=Ky(this.pointwiseInitializer),e.depthwiseRegularizer=Av(this.depthwiseRegularizer),e.pointwiseRegularizer=Av(this.pointwiseRegularizer),e.depthwiseConstraint=Tb(this.depthwiseConstraint),e.pointwiseConstraint=Tb(this.pointwiseConstraint),e}}Qv.className="SeparableConv";class e_ extends Qv{constructor(e){super(2,e)}}e_.className="SeparableConv2D",ou(e_);class t_ extends Gv{constructor(e){super(1,e),t_.verifyArgs(e),this.inputSpec=[{ndim:3}]}getConfig(){const e=super.getConfig();return delete e.rank,delete e.dataFormat,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&!Yg(e.kernelSize,"number",1,1))throw new xg(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}}t_.className="Conv1D",ou(t_);class n_ extends cb{constructor(e){super(e),"number"==typeof e.cropping?this.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:"number"==typeof e.cropping[0]?this.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:this.cropping=e.cropping,this.dataFormat=void 0===e.dataFormat?"channelsLast":e.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(e){return"channelsFirst"===this.dataFormat?[e[0],e[1],e[2]-this.cropping[0][0]-this.cropping[0][1],e[3]-this.cropping[1][0]-this.cropping[1][1]]:[e[0],e[1]-this.cropping[0][0]-this.cropping[0][1],e[2]-this.cropping[1][0]-this.cropping[1][1],e[3]]}call(e,t){return co((()=>{if(e=Qy(e),"channelsLast"===this.dataFormat){const t=yy(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return yy(t,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}{const t=yy(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return yy(t,this.cropping[1][0],e.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}}))}getConfig(){const e={cropping:this.cropping,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}n_.className="Cropping2D",ou(n_);class r_ extends cb{constructor(e){var t;super(e),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=null==e.size?this.DEFAULT_SIZE:e.size,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Zg(this.dataFormat),this.interpolation=null==e.interpolation?"nearest":e.interpolation,t=this.interpolation,Fg(Vg,"InterpolationFormat",t)}computeOutputShape(e){if("channelsFirst"===this.dataFormat){const t=null==e[2]?null:this.size[0]*e[2],n=null==e[3]?null:this.size[1]*e[3];return[e[0],e[1],t,n]}{const t=null==e[1]?null:this.size[0]*e[1],n=null==e[2]?null:this.size[1]*e[2];return[e[0],t,n,e[3]]}}call(e,t){return co((()=>{let t=Qy(e);const n=t.shape;if("channelsFirst"===this.dataFormat){t=Do(t,[0,2,3,1]);const e=this.size[0]*n[2],r=this.size[1]*n[3],a="nearest"===this.interpolation?Ph.resizeNearestNeighbor(t,[e,r]):Ph.resizeBilinear(t,[e,r]);return Do(a,[0,3,1,2])}{const e=this.size[0]*n[1],r=this.size[1]*n[2];return"nearest"===this.interpolation?Ph.resizeNearestNeighbor(t,[e,r]):Ph.resizeBilinear(t,[e,r])}}))}getConfig(){const e={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},t=super.getConfig();return Object.assign(e,t),e}}r_.className="UpSampling2D",ou(r_);class a_ extends Vv{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=null==e.depthMultiplier?1:e.depthMultiplier,this.depthwiseInitializer=Jy(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=Eb(e.depthwiseConstraint),this.depthwiseRegularizer=$v(e.depthwiseRegularizer)}build(e){if((e=eb(e)).length<4)throw new xg(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);const t="channelsFirst"===this.dataFormat?1:3;if(null==e[t]||e[t]<0)throw new xg(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);const n=e[t],r=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",r,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[n*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return co((()=>{let t=function(e,t,n=[1,1],r="valid",a,i){return co((()=>{null==a&&(a="channelsLast"),Zg(a);let s=Uv(e,a);if(4!==e.rank)throw new xg(`Input for depthwiseConv2d is required to be 4-D, but is instead ${e.rank}-D`);if(4!==t.rank)throw new xg(`depthwiseKernel is required to be 4-D, but is instead ${t.rank}-D`);return s=nc(s,t,n,"same"===r?"same":"valid","NHWC",i),"channelsFirst"===a&&(s=Do(s,[0,3,1,2])),s}))}(e=Qy(e),this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(t=ky(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),t}))}computeOutputShape(e){e=eb(e);const t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],r="channelsFirst"===this.dataFormat?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,a=Hv(t,this.kernelSize[0],this.padding,this.strides[0]),i=Hv(n,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[e[0],r,a,i]:[e[0],a,i,r]}getConfig(){const e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=Ky(this.depthwiseInitializer),e.depthwiseRegularizer=Av(this.depthwiseRegularizer),e.depthwiseConstraint=Tb(this.depthwiseRegularizer),e}}function i_(e,t,n,r){if(Array.isArray(e)){if(null!=t||null!=n)throw new xg("When inputs is an array, neither initialState or constants should be provided");null!=r&&(n=e.slice(e.length-r,e.length),e=e.slice(0,e.length-r)),e.length>1&&(t=e.slice(1,e.length)),e=e[0]}function a(e){return null==e||Array.isArray(e)?e:[e]}return{inputs:e,initialState:t=a(t),constants:n=a(n)}}function s_(e,t,n,r=!1,a,i,s=!1,o=!1){return co((()=>{const u=t.shape.length;if(u<3)throw new xg(`Input should be at least 3D, but is ${u}D.`);const l=[1,0].concat(cy(2,u));if(t=Do(t,l),null!=i)throw new vg("The rnn() functoin of the deeplearn.js backend does not support constants yet.");s&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),null!=a&&((a=Cs(Cs(a,"bool"),"float32")).rank===u-1&&(a=Dc(a,-1)),a=Do(a,l)),r&&(t=zp(t,0),null!=a&&(a=zp(a,0)));const c=[];let p,d=n;const h=t.shape[0],f=Md(t);let m,g;null!=a&&(m=Md(a));for(let t=0;te(n,d)));if(null==a)p=r[0],d=r[1];else{const e=co((()=>{const e=m[t],n=Bu(gp(e),e),a=vu(Mu(r[0],e),Mu(d[0],n)),i=d.map(((t,a)=>vu(Mu(r[1][a],e),Mu(t,n))));return{output:a,newStates:i}}));p=e.output,d=e.newStates}o&&c.push(p)}return o&&(g=cd(c,1)),[p,g,d]}))}a_.className="DepthwiseConv2D",ou(a_);class o_ extends cb{constructor(e){let t;if(super(e),null==e.cell)throw new xg("cell property is missing for the constructor of RNN.");if(t=Array.isArray(e.cell)?new m_({cells:e.cell}):e.cell,null==t.stateSize)throw new xg("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=t,this.returnSequences=null!=e.returnSequences&&e.returnSequences,this.returnState=null!=e.returnState&&e.returnState,this.goBackwards=null!=e.goBackwards&&e.goBackwards,this._stateful=null!=e.stateful&&e.stateful,this.unroll=null!=e.unroll&&e.unroll,this.supportsMasking=!0,this.inputSpec=[new ib({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){return null==this.states_?cy(0,Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1).map((e=>null)):this.states_}setStates(e){this.states_=e}computeOutputShape(e){Xy(e)&&(e=e[0]);let t=this.cell.stateSize;Array.isArray(t)||(t=[t]);const n=t[0];let r;if(r=this.returnSequences?[e[0],e[1],n]:[e[0],n],this.returnState){const n=[];for(const r of t)n.push([e[0],r]);return[r].concat(n)}return r}computeMask(e,t){return co((()=>{Array.isArray(t)&&(t=t[0]);const e=this.returnSequences?t:null;if(this.returnState){const t=this.states.map((e=>null));return[e].concat(t)}return e}))}get states(){if(null==this.states_){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,t=[];for(let n=0;ne.shape[e.shape.length-1])),a))throw new xg(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is ${this.cell.stateSize}`)}else this.stateSpec=a.map((e=>new ib({shape:[null,e]})));this.stateful&&this.resetStates()}resetStates(e,t=!1){co((()=>{if(!this.stateful)throw new yg("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape[0];if(null==n)throw new xg("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==this.states_)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((e=>sp([n,e]))):this.states_=[sp([n,this.cell.stateSize])];else if(null==e)po(this.states_),null!=this.keptStates&&(po(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((e=>sp([n,e]))):this.states_[0]=sp([n,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new xg(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);!0===t?this.keptStates.push(this.states_.slice()):po(this.states_);for(let t=0;tho(e.clone())))}))}apply(e,t){let n=null==t?null:t.initialState,r=null==t?null:t.constants;null==t&&(t={});const a=i_(e,n,r,this.numConstants);e=a.inputs,n=a.initialState,r=a.constants;let i=[],s=[];if(null!=n){t.initialState=n,i=i.concat(n),this.stateSpec=[];for(const e of n)this.stateSpec.push(new ib({shape:e.shape}));s=s.concat(this.stateSpec)}if(null!=r&&(t.constants=r,i=i.concat(r),this.numConstants=r.length),i[0]instanceof sb){const n=[e].concat(i),r=this.inputSpec.concat(s),a=this.inputSpec;this.inputSpec=r;const o=super.apply(n,t);return this.inputSpec=a,o}return super.apply(e,t)}call(e,t){return co((()=>{const n=null==t?null:t.mask,r=null==t?null:t.training;let a=null==t?null:t.initialState;e=Qy(e),null==a&&(a=this.stateful?this.states_:this.getInitialState(e));const i=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(a.length!==i)throw new xg(`RNN Layer has ${i} state(s) but was passed ${a.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const s={training:r},o=s_(((e,t)=>{const n=this.cell.call([e].concat(t),s);return[n[0],n.slice(1)]}),e,a,this.goBackwards,n,null,this.unroll,this.returnSequences),u=o[0],l=o[1],c=o[2];this.stateful&&this.resetStates(c,r);const p=this.returnSequences?l:u;return this.returnState?[p].concat(c):p}))}getInitialState(e){return co((()=>{let t=sp(e.shape);return t=wc(t,[1,2]),t=fy(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map((e=>e>1?vy(t,[1,e]):t)):this.cell.stateSize>1?[vy(t,[1,this.cell.stateSize])]:[t]}))}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),null!=this.cell&&this.cell.setFastWeightInitDuringBuild(e)}getConfig(){const e=super.getConfig(),t={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};null!=this.numConstants&&(t.numConstants=this.numConstants);const n=this.cell.getConfig();return this.getClassName()===o_.className&&(t.cell={className:this.cell.getClassName(),config:n}),Object.assign({},n,e,t)}static fromConfig(e,t,n={}){const r=ox(t.cell,n);return new e(Object.assign(t,{cell:r}))}}o_.className="RNN",ou(o_);class u_ extends cb{}class l_ extends u_{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,zg(this.units,"units"),this.activation=Dv(null==e.activation?this.DEFAULT_ACTIVATION:e.activation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=Jy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Jy(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Jy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=$v(e.kernelRegularizer),this.recurrentRegularizer=$v(e.recurrentRegularizer),this.biasRegularizer=$v(e.biasRegularizer),this.kernelConstraint=Eb(e.kernelConstraint),this.recurrentConstraint=Eb(e.recurrentConstraint),this.biasConstraint=Eb(e.biasConstraint),this.dropout=uy([1,ly([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=uy([1,ly([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=eb(e),this.kernel=this.addWeight("kernel",[e[e.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return co((()=>{if(2!==e.length)throw new xg(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let n=e[1];e=e[0];const r=null!=t.training&&t.training;let a;0gp(e),rate:this.dropout,training:r,dropoutFunc:this.dropoutFunc})),0gp(n),rate:this.recurrentDropout,training:r,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,s=this.recurrentDropoutMask;a=wy(null!=i?Mu(e,i):e,this.kernel.read()),null!=this.bias&&(a=ky(a,this.bias.read())),null!=s&&(n=Mu(n,s));let o=vu(a,wy(n,this.recurrentKernel.read()));return null!=this.activation&&(o=this.activation.apply(o)),[o,o]}))}getConfig(){const e=super.getConfig(),t={units:this.units,activation:Sv(this.activation),useBias:this.useBias,kernelInitializer:Ky(this.kernelInitializer),recurrentInitializer:Ky(this.recurrentInitializer),biasInitializer:Ky(this.biasInitializer),kernelRegularizer:Av(this.kernelRegularizer),recurrentRegularizer:Av(this.recurrentRegularizer),biasRegularizer:Av(this.biasRegularizer),activityRegularizer:Av(this.activityRegularizer),kernelConstraint:Tb(this.kernelConstraint),recurrentConstraint:Tb(this.recurrentConstraint),biasConstraint:Tb(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign({},e,t)}}l_.className="SimpleRNNCell",ou(l_);class c_ extends o_{constructor(e){e.cell=new l_(e),super(e)}call(e,t){return co((()=>{null!=this.cell.dropoutMask&&(po(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(po(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}static fromConfig(e,t){return new e(t)}}c_.className="SimpleRNN",ou(c_);class p_ extends u_{constructor(e){if(super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.resetAfter)throw new xg("GRUCell does not support reset_after parameter set to true.");this.units=e.units,zg(this.units,"units"),this.activation=Dv(void 0===e.activation?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Dv(void 0===e.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=Jy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Jy(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Jy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=$v(e.kernelRegularizer),this.recurrentRegularizer=$v(e.recurrentRegularizer),this.biasRegularizer=$v(e.biasRegularizer),this.kernelConstraint=Eb(e.kernelConstraint),this.recurrentConstraint=Eb(e.recurrentConstraint),this.biasConstraint=Eb(e.biasConstraint),this.dropout=uy([1,ly([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=uy([1,ly([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){const t=(e=eb(e))[e.length-1];this.kernel=this.addWeight("kernel",[t,3*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,3*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[3*this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return co((()=>{if(2!==e.length)throw new xg(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);const n=null!=t.training&&t.training;let r=e[1];e=e[0],0gp(e),rate:this.dropout,training:n,count:3,dropoutFunc:this.dropoutFunc})),0gp(r),rate:this.recurrentDropout,training:n,count:3,dropoutFunc:this.dropoutFunc}));const a=this.dropoutMask,i=this.recurrentDropoutMask;let s,o,u;0{null!=this.cell.dropoutMask&&(po(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(po(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}static fromConfig(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)}}d_.className="GRU",ou(d_);class h_ extends u_{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,zg(this.units,"units"),this.activation=Dv(void 0===e.activation?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Dv(void 0===e.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=Jy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Jy(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Jy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=$v(e.kernelRegularizer),this.recurrentRegularizer=$v(e.recurrentRegularizer),this.biasRegularizer=$v(e.biasRegularizer),this.kernelConstraint=Eb(e.kernelConstraint),this.recurrentConstraint=Eb(e.recurrentConstraint),this.biasConstraint=Eb(e.biasConstraint),this.dropout=uy([1,ly([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=uy([1,ly([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){var t;const n=(e=eb(e))[e.length-1];let r;if(this.kernel=this.addWeight("kernel",[n,4*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,4*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){if(this.unitForgetBias){const e=this.biasInitializer,n=this.units;r=new((t=class extends Cy{apply(t,r){const a=e.apply([n]),i=(new Ly).apply([n]),s=e.apply([2*n]);return xy(xy(a,i),s)}}).className="CustomInit",t)}else r=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.units],null,r,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,t){return co((()=>{const n=null!=t.training&&t.training;if(3!==e.length)throw new xg(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let r=e[1];const a=e[2];e=e[0],0gp(e),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc})),0gp(r),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,s=this.recurrentDropoutMask;let o,u,l,c;0{null!=this.cell.dropoutMask&&(po(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(po(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}static fromConfig(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)}}f_.className="LSTM",ou(f_);class m_ extends u_{constructor(e){super(e),this.cells=e.cells}get stateSize(){const e=[];for(const t of this.cells.slice().reverse())Array.isArray(t.stateSize)?e.push(...t.stateSize):e.push(t.stateSize);return e}call(e,t){return co((()=>{let n=e.slice(1);const r=[];for(const e of this.cells.slice().reverse())Array.isArray(e.stateSize)?r.push(n.splice(0,e.stateSize.length)):r.push(n.splice(0,1));r.reverse();const a=[];let i;for(let s=0;s{ny(`RNNCell_${r}`,(()=>{n.build(e),t=Array.isArray(n.stateSize)?n.stateSize[0]:n.stateSize,e=[e[0],t]}))})),this.built=!0}getConfig(){const e=super.getConfig(),t={cells:this.cells.map((e=>({className:e.getClassName(),config:e.getConfig()})))};return Object.assign({},e,t)}static fromConfig(e,t,n={}){const r=[];for(const e of t.cells)r.push(ox(e,n));return new e({cells:r})}get trainableWeights(){if(!this.trainable)return[];const e=[];for(const t of this.cells)e.push(...t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.cells)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const e of this.cells)t.push(...e.trainableWeights);return t.concat(e)}return e}getWeights(){const e=[];for(const t of this.cells)e.push(...t.weights);return rb(e)}setWeights(e){const t=[];for(const n of this.cells){const r=n.weights.length,a=e.splice(r);for(let e=0;enull!=i?i(t(),n):Dy(t(),n),o=()=>Ty(s,t,r);return!a||a<=1?ho(o().clone()):Array(a).fill(void 0).map(o).map((e=>ho(e.clone())))}m_.className="StackedRNNCells",ou(m_);class y_ extends o_{constructor(e){if(e.unroll)throw new vg("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new vg("It is not possible at the moment to stack convolutional cells.");super(e),this.inputSpec=[new ib({ndim:5})]}call(e,t){return co((()=>{if(null!=this.cell.dropoutMask&&(po(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(po(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new xg("ConvRNN2D cell does not support constants");const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}computeOutputShape(e){let t=this.computeSingleOutputShape(e);return this.returnSequences||(t=[t[0],...t.slice(2)]),this.returnState&&(t=[t,...Array(2).fill([e[0],...t.slice(-3)])]),t}getInitialState(e){return co((()=>{const{stateSize:t}=this.cell,n=e.shape,r=this.computeSingleOutputShape(n),a=sp([r[0],...r.slice(2)]);return Array.isArray(t)?Array(t.length).fill(a):[a]}))}resetStates(e,t=!1){co((()=>{if(!this.stateful)throw new yg("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape,r=this.computeSingleOutputShape(n),a=[r[0],...r.slice(2)];if(null==n[0])throw new xg("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==this.getStates())Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>sp(a))):this.states_=[sp(a)];else if(null==e)po(this.states_),null!=this.keptStates&&(po(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>sp(a))):this.states_[0]=sp(a);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new xg(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t?this.keptStates.push(this.states_.slice()):po(this.states_);for(let t=0;tho(e.clone())))}))}computeSingleOutputShape(e){const{dataFormat:t,filters:n,kernelSize:r,padding:a,strides:i,dilationRate:s}=this.cell,o="channelsFirst"===t,u=e[o?3:2],l=e[o?4:3],c=Hv(u,r[0],a,i[0],s[0]),p=Hv(l,r[1],a,i[1],s[1]);return[...e.slice(0,2),...o?[n,c,p]:[c,p,n]]}}y_.className="ConvRNN2D";class b_ extends h_{constructor(e){const{filters:t,kernelSize:n,strides:r,padding:a,dataFormat:i,dilationRate:s}=e;super(Object.assign({},e,{units:t})),this.filters=t,zg(this.filters,"filters"),this.kernelSize=Pv(n,2,"kernelSize"),this.kernelSize.forEach((e=>zg(e,"kernelSize"))),this.strides=Pv(r||1,2,"strides"),this.strides.forEach((e=>zg(e,"strides"))),this.padding=a||"valid",Qg(this.padding),this.dataFormat=i||"channelsLast",Zg(this.dataFormat),this.dilationRate=Pv(s||1,2,"dilationRate"),this.dilationRate.forEach((e=>zg(e,"dilationRate")))}build(e){var t;e=eb(e);const n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n])throw new xg(`The channel dimension of the input should be defined. Found ${e[n]}`);const r=e[n],a=this.kernelSize.concat([r,4*this.filters]);this.kernel=this.addWeight("kernel",a,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const i=this.kernelSize.concat([this.filters,4*this.filters]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",i,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let e;if(this.unitForgetBias){const n=this.biasInitializer,r=this.filters;e=new((t=class extends Cy{apply(e,t){return by([n.apply([r]),op([r]),n.apply([2*r])])}}).className="CustomInit",t)}else e=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.filters],null,e,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return co((()=>{if(3!==e.length)throw new xg(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);const n=t.training||!1,r=e[0],a=e[1],i=e[2];0gp(r),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const s=this.dropoutMask,o=(e,t,n)=>t&&t[n]?Mu(t[n],e):e;let u=o(r,s,0),l=o(r,s,1),c=o(r,s,2),p=o(r,s,3);0gp(a),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const d=this.recurrentDropoutMask;let h=o(a,d,0),f=o(a,d,1),m=o(a,d,2),g=o(a,d,3);const[y,b,x,v]=sd(this.kernel.read(),4,3),[_,w,M,N]=this.useBias?sd(this.bias.read(),4):[null,null,null,null];u=this.inputConv(u,y,_,this.padding),l=this.inputConv(l,b,w,this.padding),c=this.inputConv(c,x,M,this.padding),p=this.inputConv(p,v,N,this.padding);const[S,k,D,T]=sd(this.recurrentKernel.read(),4,3);h=this.recurrentConv(h,S),f=this.recurrentConv(f,k),m=this.recurrentConv(m,D),g=this.recurrentConv(g,T);const I=this.recurrentActivation.apply(vu(u,h)),E=this.recurrentActivation.apply(vu(l,f)),C=vu(Mu(E,i),Mu(I,this.activation.apply(vu(c,m)))),A=Mu(this.recurrentActivation.apply(vu(p,g)),this.activation.apply(C));return[A,A,C]}))}getConfig(){const e=super.getConfig(),{units:t}=e,n=function(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 a=0;for(r=Object.getOwnPropertySymbols(e);a{this.invokeCallHook(e,t);const n=Qy(e);if(0Dy(n,this.rate,r,this.seed)),(()=>n),e)}return e}))}getConfig(){const e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},t=super.getConfig();return Object.assign(e,t),e}dispose(){return super.dispose()}}v_.className="Dropout",ou(v_);class __ extends v_{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){const t=e.shape;return[t[0],1,t[2]]}}__.className="SpatialDropout1D",ou(__);class w_ extends cb{constructor(e){if(super(e),this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",null==e.batchInputShape&&null==e.inputShape&&null!=e.inputDim){let t=null;null!=e.batchSize&&(t=e.batchSize),this.batchInputShape=[t,e.inputDim]}this.units=e.units,zg(this.units,"units"),this.activation=Dv(e.activation),null!=e.useBias&&(this.useBias=e.useBias),this.kernelInitializer=Jy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=Jy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=Eb(e.kernelConstraint),this.biasConstraint=Eb(e.biasConstraint),this.kernelRegularizer=$v(e.kernelRegularizer),this.biasRegularizer=$v(e.biasRegularizer),this.activityRegularizer=$v(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){const t=(e=eb(e))[e.length-1];null==this.kernel&&(this.kernel=this.addWeight("kernel",[t,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:{[-1]:t}}],this.built=!0}computeOutputShape(e){const t=(e=eb(e)).slice();return t[t.length-1]=this.units,t}call(e,t){return co((()=>{this.invokeCallHook(e,t);const n=Qy(e),r=Pg(this.activation.getClassName());let a;return null!=r?a=wy(n,this.kernel.read(),r,this.bias?this.bias.read():null):(a=wy(n,this.kernel.read()),null!=this.bias&&(a=ky(a,this.bias.read())),null!=this.activation&&(a=this.activation.apply(a))),a}))}getConfig(){const e={units:this.units,activation:Sv(this.activation),useBias:this.useBias,kernelInitializer:Ky(this.kernelInitializer),biasInitializer:Ky(this.biasInitializer),kernelRegularizer:Av(this.kernelRegularizer),biasRegularizer:Av(this.biasRegularizer),activityRegularizer:Av(this.activityRegularizer),kernelConstraint:Tb(this.kernelConstraint),biasConstraint:Tb(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}w_.className="Dense",ou(w_);class M_ extends cb{constructor(e){super(e=e||{}),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=eb(e);for(const t of e.slice(1))if(null==t)throw new xg(`The shape of the input to "Flatten" is not fully defined (got ${e.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`);return[e[0],oy(e,1)]}call(e,t){return co((()=>{this.invokeCallHook(e,t);let n=Qy(e);if("channelsFirst"===this.dataFormat&&n.rank>1){const e=[0];for(let t=2;t{this.invokeCallHook(e,t);const n=Qy(e);return this.activation.apply(n)}))}getConfig(){const e={activation:Sv(this.activation)},t=super.getConfig();return Object.assign(e,t),e}}N_.className="Activation",ou(N_);class S_ extends cb{constructor(e){super(e),this.n=e.n,this.inputSpec=[{ndim:2}]}computeOutputShape(e){return[e[0],this.n,e[1]]}call(e,t){return co((()=>{return e=Qy(e),t=e,n=this.n,co((()=>{if(2!==t.shape.length)throw new xg(`repeat() expects a rank-2 tensor, but received a rank-${t.shape.length} tensor.`);return vy(fy(t,1),[1,n,1])}));var t,n}))}getConfig(){const e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}}S_.className="RepeatVector",ou(S_);class k_ extends cb{constructor(e){super(e),this.targetShape=e.targetShape;for(let e=0;e{this.invokeCallHook(e,t);const n=Qy(e),r=n.shape,a=r.slice(0,1).concat(this.fixUnknownDimension(r.slice(1),this.targetShape));return _l(n,a)}))}getConfig(){const e={targetShape:this.targetShape},t=super.getConfig();return Object.assign(e,t),e}}k_.className="Reshape",ou(k_);class D_ extends cb{constructor(e){if(super(e),null==e.dims)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(e.dims))throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`);const t=cy(1,e.dims.length+1);if(!pe(e.dims.slice().sort(),t))throw new Error("Invalid permutation `dims`: "+JSON.stringify(e.dims)+" `dims` must contain consecutive integers starting from 1.");this.dims=e.dims,this.dimsIncludingBatch=[0].concat(this.dims),this.inputSpec=[new ib({ndim:this.dims.length+1})]}computeOutputShape(e){const t=(e=eb(e)).slice();return this.dims.forEach(((n,r)=>{t[r+1]=e[n]})),t}call(e,t){return Do(Qy(e),this.dimsIncludingBatch)}getConfig(){const e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}}D_.className="Permute",ou(D_);class T_ extends cb{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,this.maskValue=null!=e?null==e.maskValue?0:e.maskValue:0}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={maskValue:this.maskValue};return Object.assign(t,e),t}computeMask(e,t){const n=Qy(e);return Qu(mp(n,this.maskValue),-1)}call(e,t){return co((()=>{this.invokeCallHook(e,t);const n=Qy(e),r=Qu(mp(n,this.maskValue),-1,!0);return Mu(n,Cs(r,n.dtype))}))}}T_.className="Masking",ou(T_);class I_ extends cb{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==e.batchInputShape&&null==e.inputShape){let t=null;null!=e.batchSize&&(t=e.batchSize),null==e.inputLength?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(Dg(e.inputLength))}this.inputDim=e.inputDim,zg(this.inputDim,"inputDim"),this.outputDim=e.outputDim,zg(this.outputDim,"outputDim"),this.embeddingsInitializer=Jy(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=$v(e.embeddingsRegularizer),this.activityRegularizer=$v(e.activityRegularizer),this.embeddingsConstraint=Eb(e.embeddingsConstraint),this.maskZero=e.maskZero,this.supportsMasking=e.maskZero,this.inputLength=e.inputLength}build(e){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0}warnOnIncompatibleInputShape(e){}computeMask(e,t){return co((()=>this.maskZero?(e=Qy(e),mp(e,ku(e))):null))}computeOutputShape(e){if(e=eb(e),null==this.inputLength)return[...e,this.outputDim];const t=Dg(this.inputLength);if(t.length!==e.length-1)throw new xg(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let n=0;for(let r=0;r{this.invokeCallHook(e,t);let n=Qy(e);"int32"!==n.dtype&&(n=hy(n,"int32"));const r=My(this.embeddings.read(),_l(n,[n.size]));return _l(r,eb(this.computeOutputShape(n.shape)))}))}getConfig(){const e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:Ky(this.embeddingsInitializer),embeddingsRegularizer:Av(this.embeddingsRegularizer),activityRegularizer:Av(this.activityRegularizer),embeddingsConstraint:Tb(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}}I_.className="Embedding",ou(I_);class E_ extends cb{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new vg}computeElementwiseOpOutputShape(e,t){if(null==e||null==t)return null;if(e.length1)throw new xg(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let n=null==e[0]?null:e[0].slice(1);for(let t=1;te.length));-1===e.indexOf(null)&&1===Og(r).length?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return co((()=>{if(this.reshapeRequired){const t=[],n=e.map((e=>e.rank));if(-1===n.indexOf(null)){const r=ly(n);for(let n of e){const e=n.rank;for(let t=0;t1){const a=cy(1,e).concat([0]);t.push(Do(r,a)),n=!0}else t.push(r)}let r=this.mergeFunction(t);const a=r.rank;if(n)if(null==a){const e=r.shape,t=e[e.length-1],n=[t].concat(e.slice(0,e.length-1));r=_l(Do(_l(r,[-1,t]),[1,0]),n)}else if(a>1){const e=[a-1].concat(cy(0,a-1));r=Do(r,e)}return r}}return this.mergeFunction(e)}))}computeOutputShape(e){let t;t=null==e[0]?null:e[0].slice(1);for(let n=1;n{if(null==t)return null;if(!Array.isArray(t))throw new xg("`mask` should be an Array");if(!Array.isArray(e))throw new xg("`inputs` should be an Array");if(t.length!==e.length)throw new xg(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every((e=>null==e)))return null;let n=(t=t.map((e=>null==e?e:Dc(e,0))))[0];for(let e=1;e{let t=e[0].clone();for(let n=1;n{let t=e[0].clone();for(let n=1;n{let t=e[0].clone();for(let n=1;n{let t=e[0];for(let n=1;n{let t=e[0];for(let n=1;n1)throw new xg("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return co((()=>by(e,this.axis)))}computeOutputShape(e){if(!Array.isArray(e)||!Array.isArray(e[0]))throw new xg("A `Concatenate` layer should be called on a list of inputs.");const t=e,n=t[0].slice(),r=this.axis<0?n.length+this.axis:this.axis;for(const e of t.slice(1)){if(null==n[r]||null==e[r]){n[r]=null;break}n[r]+=e[r]}return n}computeMask(e,t){if(null==t)return null;if(!Array.isArray(t))throw new xg("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new xg("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new xg(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return co((()=>{let n=!0;if(t.forEach((e=>{null==e||(n=!1)})),n)return null;const r=[];for(let n=0;n"A `Dot` layer should be called on a list of exactly 2 inputs."));const t=e[0],n=e[1];if(t.length>3||n.length>3)throw new vg("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(t,n);if(t[r[0]]!==n[r[1]])throw new xg(`Dimension incompatibility: ${t[r[0]]} !== ${n[r[1]]}`)}mergeFunction(e){if(2!==e.length)throw new xg(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let t,n=e[0],r=e[1];return t=Array.isArray(this.axes)?this.axes.map(((t,n)=>F_(t,e[n].shape.length))):[F_(this.axes,n.shape.length),F_(this.axes,r.shape.length)],this.normalize&&(n=ux(n,t[0]),r=ux(r,t[1])),function(e,t,n){if(e.shape.length>3||t.shape.length>3)throw new vg("batchDot is not implemented for tensors of 4D or higher rank yet");if(ie(e.shape.length>=2,(()=>`batchDot requires the rank of x to be >= 2, but got ${e.shape.length}`)),ie(e.shape.length>=2,(()=>`batchDot requires the rank of y to be >= 2, but got ${t.shape.length}`)),"number"==typeof n&&(n=[n,n]),"complex64"===e.dtype||"complex64"===t.dtype)throw new vg("batchDot is not implemented for complex64-type Tensors yet.");const r=e.shape.length,a=t.shape.length;null==n&&(n=[r-1,a-2]);const i=n;return co((()=>{let n,s;if(r>a){n=r-a;const e=[];for(let t=0;tr){n=a-r;const t=[];for(let e=0;e0){let e;e=r>a?r+a-3:r-1;const t=[];for(let r=e;r"A `Dot` layer should be called on a list of exactly 2 inputs."));const t=e[0].slice(),n=e[1].slice();if(t.length>3||n.length>3)throw new vg("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(t,n);t.splice(r[0],1),n.splice(r[1],1),n.splice(0,1);const a=t.concat(n);return 1===a.length&&a.push(1),a}computeMask(e,t){return null}getConfig(){const e={axes:this.axes,normalize:this.normalize},t=super.getConfig();return Object.assign(e,t),e}}Y_.className="Dot",ou(Y_);class z_ extends cb{constructor(e){super(e),this.supportsMasking=!0,this.stddev=e.stddev}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={stddev:this.stddev};return Object.assign(t,e),t}call(e,t){return co((()=>{this.invokeCallHook(e,t);const n=Qy(e);return Ty((()=>vu(_y(n.shape,0,this.stddev),n)),(()=>n),t.training||!1)}))}}z_.className="GaussianNoise",ou(z_);class B_ extends cb{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return co((()=>{this.invokeCallHook(e,t);const n=Qy(e);return this.rate>0&&this.rate<1?Ty((()=>{const e=Math.sqrt(this.rate/(1-this.rate));return Mu(n,_y(n.shape,1,e))}),(()=>n),t.training||!1):n}))}}B_.className="GaussianDropout",ou(B_);class P_ extends cb{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||Qy(e).shape}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return co((()=>{if(this.rate<1&&this.rate>0){const n=this._getNoiseShape(e),r=()=>{const t=Qy(e),r=-1.7580993408473766;let a=$c($p(n),this.rate);a=hy(a,"float32");const i=((1-this.rate)*(1+this.rate*r**2))**-.5,s=-i*r*this.rate,o=vu(Mu(t,a),Mu(vu(a,-1),r));return vu(Mu(o,i),s)};return Ty(r,(()=>Qy(e)),t.training||!1)}return e}))}}function H_(e,t,n,r,a,i=.001){let s;if(2===e.rank)s=Cl(e,t,n,r,a,i);else if(3===e.rank)s=Al(e,t,n,r,a,i);else{if(4!==e.rank)throw new vg(`batchNormalization is not implemented for array of rank ${e.rank} yet`);s=Ll(e,t,n,r,a,i)}return s}P_.className="AlphaDropout",ou(P_);class j_ extends cb{constructor(e){null==e&&(e={}),super(e),this.supportsMasking=!0,this.axis=null==e.axis?-1:e.axis,this.momentum=null==e.momentum?.99:e.momentum,this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=Jy(e.betaInitializer||"zeros"),this.gammaInitializer=Jy(e.gammaInitializer||"ones"),this.movingMeanInitializer=Jy(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=Jy(e.movingVarianceInitializer||"ones"),this.betaConstraint=Eb(e.betaConstraint),this.gammaConstraint=Eb(e.gammaConstraint),this.betaRegularizer=$v(e.betaRegularizer),this.gammaRegularizer=$v(e.gammaRegularizer)}build(e){e=eb(e);const t=this.axis>=0?this.axis:this.axis+e.length,n=e[t];if(null==n)throw new xg(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new ib({ndim:e.length,axes:{[t]:n}})];const r=[n];this.scale&&(this.gamma=this.addWeight("gamma",r,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",r,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",r,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",r,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return co((()=>{const n=null!=t.training&&t.training,r=Qy(e),a=r.shape,i=a.length,s=cy(0,i),o=this.axis>=0?this.axis:this.axis+i;s.splice(o,1);const u=Mg(1,i);u[o]=a[o];const l=s.slice();l.sort();const c=!pe(l,cy(0,i).slice(0,i-1));if(!n)return(()=>{if(c){const e=_l(this.movingMean.read(),u),t=_l(this.movingVariance.read(),u),n=this.center?_l(this.beta.read(),u):null,a=this.scale?_l(this.gamma.read(),u):null;return H_(r,e,t,n,a,this.epsilon)}return H_(r,this.movingMean.read(),this.movingVariance.read(),null==this.beta?null:this.beta.read(),null==this.gamma?null:this.gamma.read(),this.epsilon)})();const[p,d,h]=function(e,t,n,r,a=.001){return pe(r.slice().sort(),cy(0,e.rank-1))?function(e,t,n,r,a=.001){return co((()=>{const i=dp(e,r),s=i.mean,o=i.variance;return[H_(e,s,o,n,t,a),s,o]}))}(e,t,n,r,a):function(e,t,n,r,a=.001){return co((()=>{const i=dp(e,r),s=i.mean,o=i.variance,u=[];for(const t of cy(0,e.rank))-1!==r.indexOf(t)?u.push(1):u.push(e.shape[t]);const l=_l(s,u),c=_l(o,u),p=null==t?null:_l(t,u),d=null==n?null:_l(n,u);return[H_(e,l,c,d,p,a),s,o]}))}(e,t,n,r,a)}(r,this.gamma.read(),this.beta.read(),s,this.epsilon),f=(e,t,n)=>{co((()=>{const r=1-n,a=e.read(),i=Mu(Bu(a,t),r);e.write(Bu(a,i))}))};return(()=>{f(this.movingMean,d,this.momentum),f(this.movingVariance,h,this.momentum)})(),p}))}getConfig(){const e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Ky(this.betaInitializer),gammaInitializer:Ky(this.gammaInitializer),movingMeanInitializer:Ky(this.movingMeanInitializer),movingVarianceInitializer:Ky(this.movingVarianceInitializer),betaRegularizer:Av(this.betaRegularizer),gammaRegularizer:Av(this.gammaRegularizer),betaConstraint:Tb(this.betaConstraint),gammaConstraint:Tb(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}}j_.className="BatchNormalization",ou(j_);class U_ extends cb{constructor(e){if(null==e&&(e={}),super(e),this.axis=null==e.axis?-1:e.axis,"number"==typeof this.axis){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else{if(!Array.isArray(this.axis))throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);for(const e of this.axis)if(!Number.isInteger(e))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=Jy(e.betaInitializer||"zeros"),this.gammaInitializer=Jy(e.gammaInitializer||"ones"),this.betaRegularizer=$v(e.betaRegularizer),this.gammaRegularizer=$v(e.gammaRegularizer),this.supportsMasking=!0}build(e){const t=(e=eb(e)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(let e=0;e=t)throw new Error(`Invalid axis: ${e}`);if(this.axis.length!==Og(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const n=this.axis.map((t=>e[t]));this.scale?this.gamma=this.addWeight("gamma",n,"float32",this.gammaInitializer,this.gammaRegularizer,!0):this.gamma=null,this.center?this.beta=this.addWeight("beta",n,"float32",this.betaInitializer,this.betaRegularizer,!0):this.beta=null,this.built=!0}call(e,t){const n=Qy(e),r=n.shape,a=r.length;return co((()=>{let{mean:e,variance:t}=dp(n,this.axis,!0);const i=Mg(1,a);for(const e of this.axis)i[e]=r[e];const s=e=>null!=e&&e.shape.length!==a?_l(e,i):e;let o=this.scale?s(this.gamma.read()):null,u=this.center?s(this.beta.read()):null;const l=[],c=[];for(let e=0;e=0?e[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[3]&&e[3]>=0?e[3]+this.padding[1][0]+this.padding[1][1]:null,[e[0],e[1],t,n]):(t=null!=e[1]&&e[1]>=0?e[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[2]&&e[2]>=0?e[2]+this.padding[1][0]+this.padding[1][1]:null,[e[0],t,n,e[3]])}call(e,t){return co((()=>{return t=Qy(e),n=this.padding,r=this.dataFormat,co((()=>{if(4!==t.rank)throw new xg(`temporalPadding expects input tensor to be 4-D, but received a ${t.rank}-D tensor.`);if(null==n&&(n=[[1,1],[1,1]]),2!==n.length||2!==n[0].length||2!==n[1].length)throw new xg("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==r&&(r="channelsLast"),"channelsLast"!==r&&"channelsFirst"!==r)throw new xg(`Unknown data format: ${r}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let e;return e="channelsFirst"===r?[[0,0],[0,0],n[0],n[1]]:[[0,0],n[0],n[1],[0,0]],bp(t,e)}));var t,n,r}))}getConfig(){const e={padding:this.padding,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}function W_(e,t,n,r,a,i){return co((()=>{let s;Zg(a),ey(i),Qg(r),null==n&&(n=[1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),e=Uv(e,a);const o="same"===r?"same":"valid";return s="max"===i?np(e,t,n,o):wl(e,t,n,o),"channelsFirst"===a&&(s=Do(s,[0,3,1,2])),s}))}function V_(e,t,n,r,a,i){return co((()=>{let s;Zg(a),ey(i),Qg(r),null==n&&(n=[1,1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),e=qv(e,a);const o="same"===r?"same":"valid";return s="max"===i?rp(e,t,n,o):Ml(e,t,n,o),"channelsFirst"===a&&(s=Do(s,[0,4,1,2,3])),s}))}q_.className="ZeroPadding2D",ou(q_);class G_ extends cb{constructor(e){if(null==e.poolSize&&(e.poolSize=2),super(e),"number"==typeof e.poolSize)this.poolSize=[e.poolSize];else{if(!Array.isArray(e.poolSize)||1!==e.poolSize.length||"number"!=typeof e.poolSize[0])throw new xg(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);this.poolSize=e.poolSize}if(zg(this.poolSize,"poolSize"),null==e.strides)this.strides=this.poolSize;else if("number"==typeof e.strides)this.strides=[e.strides];else{if(!Array.isArray(e.strides)||1!==e.strides.length||"number"!=typeof e.strides[0])throw new xg(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);this.strides=e.strides}zg(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,Qg(this.padding),this.inputSpec=[new ib({ndim:3})]}computeOutputShape(e){const t=Hv((e=eb(e))[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return co((()=>{this.invokeCallHook(e,t),e=fy(Qy(e),2);const n=this.poolingFunction(Qy(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return ld(n,[2])}))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}}class K_ extends G_{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return Zg(a),Qg(r),W_(e,t,n,r,a,"max")}}K_.className="MaxPooling1D",ou(K_);class J_ extends G_{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return Zg(a),Qg(r),W_(e,t,n,r,a,"avg")}}J_.className="AveragePooling1D",ou(J_);class X_ extends cb{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(2!==e.strides.length)throw new xg(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides];zg(this.poolSize,"poolSize"),zg(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Zg(this.dataFormat),Qg(this.padding),this.inputSpec=[new ib({ndim:4})]}computeOutputShape(e){e=eb(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2];return t=Hv(t,this.poolSize[0],this.padding,this.strides[0]),n=Hv(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n]:[e[0],t,n,e[3]]}call(e,t){return co((()=>(this.invokeCallHook(e,t),this.poolingFunction(Qy(e),this.poolSize,this.strides,this.padding,this.dataFormat))))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class Z_ extends X_{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return Zg(a),Qg(r),W_(e,t,n,r,a,"max")}}Z_.className="MaxPooling2D",ou(Z_);class Q_ extends X_{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return Zg(a),Qg(r),W_(e,t,n,r,a,"avg")}}Q_.className="AveragePooling2D",ou(Q_);class ew extends cb{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(3!==e.strides.length)throw new xg(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides,e.strides];zg(this.poolSize,"poolSize"),zg(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Zg(this.dataFormat),Qg(this.padding),this.inputSpec=[new ib({ndim:5})]}computeOutputShape(e){e=eb(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],r="channelsFirst"===this.dataFormat?e[4]:e[3];return t=Hv(t,this.poolSize[0],this.padding,this.strides[0]),n=Hv(n,this.poolSize[1],this.padding,this.strides[1]),r=Hv(r,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n,r]:[e[0],t,n,r,e[4]]}call(e,t){return co((()=>(this.invokeCallHook(e,t),this.poolingFunction(Qy(e),this.poolSize,this.strides,this.padding,this.dataFormat))))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class tw extends ew{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return Zg(a),Qg(r),V_(e,t,n,r,a,"max")}}tw.className="MaxPooling3D",ou(tw);class nw extends ew{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return Zg(a),Qg(r),V_(e,t,n,r,a,"avg")}}nw.className="AveragePooling3D",ou(nw);class rw extends cb{constructor(e){super(e),this.inputSpec=[new ib({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new vg}}class aw extends rw{constructor(e){super(e||{})}call(e,t){return co((()=>{const t=Qy(e);return ip(t,1)}))}}aw.className="GlobalAveragePooling1D",ou(aw);class iw extends rw{constructor(e){super(e||{})}call(e,t){return co((()=>{const t=Qy(e);return vc(t,1)}))}}iw.className="GlobalMaxPooling1D",ou(iw);class sw extends cb{constructor(e){super(e),this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Zg(this.dataFormat),this.inputSpec=[new ib({ndim:4})]}computeOutputShape(e){return"channelsLast"===this.dataFormat?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new vg}getConfig(){const e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class ow extends sw{call(e,t){return co((()=>{const t=Qy(e);return"channelsLast"===this.dataFormat?ip(t,[1,2]):ip(t,[2,3])}))}}ow.className="GlobalAveragePooling2D",ou(ow);class uw extends sw{call(e,t){return co((()=>{const t=Qy(e);return"channelsLast"===this.dataFormat?vc(t,[1,2]):vc(t,[2,3])}))}}uw.className="GlobalMaxPooling2D",ou(uw);class lw extends cb{constructor(e){super(e),this.layer=e.layer}build(e){this.built=!0}get trainable(){return null!=this.layer&&this.layer.trainable}set trainable(e){null!=this.layer&&(this.layer.trainable=e)}get trainableWeights(){return this.layer.trainableWeights}get nonTrainableWeights(){return this.layer.nonTrainableWeights}get updates(){return this.layer._updates}get losses(){return this.layer.losses}getWeights(){return this.layer.getWeights()}setWeights(e){this.layer.setWeights(e)}getConfig(){const e={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},t=super.getConfig();return Object.assign(e,t),e}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(e)}static fromConfig(e,t,n={}){const r=ox(t.layer,n);delete t.layer;const a={layer:r};return Object.assign(a,t),new e(a)}}class cw extends lw{constructor(e){super(e),this.supportsMasking=!0}build(e){if((e=eb(e)).length<3)throw new xg(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(e)}`);this.inputSpec=[{shape:e}];const t=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(t),this.layer.built=!0),super.build(e)}computeOutputShape(e){const t=[(e=eb(e))[0]].concat(e.slice(2)),n=this.layer.computeOutputShape(t),r=e[1];return[n[0],r].concat(n.slice(1))}call(e,t){return co((()=>s_(((e,n)=>[Qy(this.layer.call(e,t)),[]]),e=Qy(e),[],!1,null,null,!1,!0)[1]))}}cw.className="TimeDistributed",ou(cw);class pw extends lw{constructor(e){super(e);const t=e.layer.getConfig(),n={};n.className=e.layer.getClassName(),n.config=t,this.forwardLayer=ox(n),t.goBackwards=!0!==t.goBackwards;const r={};var a;if(r.className=e.layer.getClassName(),r.config=t,this.backwardLayer=ox(r),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=void 0===e.mergeMode?"concat":e.mergeMode,a=this.mergeMode,Fg(Jg,"BidirectionalMergeMode",a),e.weights)throw new vg("weights support is not implemented for Bidirectional layer yet.");this._stateful=e.layer.stateful,this.returnSequences=e.layer.returnSequences,this.returnState=e.layer.returnState,this.supportsMasking=!0,this._trainable=!0,this.inputSpec=e.layer.inputSpec,this.numConstants=null}get trainable(){return this._trainable}set trainable(e){this._trainable=e,null!=this.forwardLayer&&(this.forwardLayer.trainable=e),null!=this.backwardLayer&&(this.backwardLayer.trainable=e)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(e){const t=e.length,n=Math.floor(t/2);this.forwardLayer.setWeights(e.slice(0,n)),this.backwardLayer.setWeights(e.slice(n))}computeOutputShape(e){let t,n,r,a=this.forwardLayer.computeOutputShape(e);return Array.isArray(a)&&Array.isArray(a[0])||(a=[a]),this.returnState?(r=a.slice(1),t=a[0]):t=a[0],"concat"===this.mergeMode?(t[t.length-1]*=2,n=[t]):n=null==this.mergeMode?[t,t.slice()]:[t],this.returnState?null==this.mergeMode?n.concat(r).concat(r.slice()):[t].concat(r).concat(r.slice()):kg(n)}apply(e,t){let n=null==t?null:t.initialState,r=null==t?null:t.constants;null==t&&(t={});const a=i_(e,n,r,this.numConstants);if(e=a.inputs,n=a.initialState,r=a.constants,Array.isArray(e)&&(n=e.slice(1),e=e[0]),(null==n||0===n.length)&&null==r)return super.apply(e,t);const i=[],s=[];if(null!=n){const e=n.length;if(e%2>0)throw new xg("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");t.initialState=n,i.push(...n);const r=n.map((e=>new ib({shape:e.shape})));this.forwardLayer.stateSpec=r.slice(0,e/2),this.backwardLayer.stateSpec=r.slice(e/2),s.push(...r)}if(null!=r)throw new vg("Support for constants in Bidirectional layers is not implemented yet.");const o=i[0]instanceof sb;for(const e of i)if(e instanceof sb!==o)throw new xg("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(o){const n=[e].concat(i),r=this.inputSpec.concat(s),a=this.inputSpec;this.inputSpec=r;const o=super.apply(n,t);return this.inputSpec=a,o}return super.apply(e,t)}call(e,t){return co((()=>{const n=t.initialState;let r,a,i,s;if(null==n)r=this.forwardLayer.call(e,t),a=this.backwardLayer.call(e,t);else{const i=n.slice(0,n.length/2),s=n.slice(n.length/2);r=this.forwardLayer.call(e,Object.assign(t,{initialState:i})),a=this.backwardLayer.call(e,Object.assign(t,{initialState:s}))}return this.returnState&&(Array.isArray(r)&&(i=r.slice(1).concat(a.slice(1))),r=r[0],a=a[0]),this.returnSequences&&(a=zp(a,1)),"concat"===this.mergeMode?s=by([r,a]):"sum"===this.mergeMode?s=vu(r,a):"ave"===this.mergeMode?s=Mu(.5,vu(r,a)):"mul"===this.mergeMode?s=Mu(r,a):null==this.mergeMode&&(s=[r,a]),this.returnState?null==this.mergeMode?s.concat(i):[s].concat(i):s}))}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){ny(this.forwardLayer.name,(()=>{this.forwardLayer.build(e)})),ny(this.backwardLayer.name,(()=>{this.backwardLayer.build(e)})),this.built=!0}computeMask(e,t){let n;if(Array.isArray(t)&&(t=t[0]),n=this.returnSequences?null==this.mergeMode?[t,t]:t:null==this.mergeMode?[null,null]:null,this.returnState){const e=this.forwardLayer.states.map((e=>null));return Array.isArray(n)?n.concat(e).concat(e):[n].concat(e).concat(e)}return n}get trainableWeights(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}get nonTrainableWeights(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),null!=this.forwardLayer&&this.forwardLayer.setFastWeightInitDuringBuild(e),null!=this.backwardLayer&&this.backwardLayer.setFastWeightInitDuringBuild(e)}getConfig(){const e={mergeMode:this.mergeMode},t=super.getConfig();return Object.assign(e,t),e}static fromConfig(e,t){const n=ox(t.layer);if(delete t.layer,null!=t.numConstants)throw new vg("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");const r=t;return r.layer=n,new e(r)}}function dw(e){return new db(e)}function hw(e){return new Yv(e)}function fw(e){return new Ov(e)}function mw(e){return new Rv(e)}function gw(e){return new Fv(e)}function yw(e){return new Bv(e)}function bw(e){return new zv(e)}function xw(e){return new t_(e)}function vw(e){return new Kv(e)}function _w(e){return new Xv(e)}function ww(e){return new Jv(e)}function Mw(e){return new Zv(e)}function Nw(e){return new e_(e)}function Sw(e){return new n_(e)}function kw(e){return new r_(e)}function Dw(e){return new a_(e)}function Tw(e){return new N_(e)}function Iw(e){return new w_(e)}function Ew(e){return new v_(e)}function Cw(e){return new __(e)}function Aw(e){return new M_(e)}function Lw(e){return new S_(e)}function $w(e){return new k_(e)}function Ow(e){return new D_(e)}function Rw(e){return new I_(e)}function Fw(e){return new C_(e)}function Yw(e){return new L_(e)}function zw(e){return new R_(e)}function Bw(e){return new $_(e)}function Pw(e){return new O_(e)}function Hw(e){return new A_(e)}function jw(e){return new Y_(e)}function Uw(e){return new j_(e)}function qw(e){return new U_(e)}function Ww(e){return new q_(e)}function Vw(e){return new J_(e)}function Gw(e){return Vw(e)}function Kw(e){return Vw(e)}function Jw(e){return new Q_(e)}function Xw(e){return Jw(e)}function Zw(e){return Jw(e)}function Qw(e){return new nw(e)}function eM(e){return Qw(e)}function tM(e){return Qw(e)}function nM(e){return new aw(e)}function rM(e){return new ow(e)}function aM(e){return new iw(e)}function iM(e){return new uw(e)}function sM(e){return new K_(e)}function oM(e){return new Z_(e)}function uM(e){return new tw(e)}function lM(e){return new d_(e)}function cM(e){return new p_(e)}function pM(e){return new f_(e)}function dM(e){return new h_(e)}function hM(e){return new c_(e)}function fM(e){return new l_(e)}function mM(e){return new x_(e)}function gM(e){return new b_(e)}function yM(e){return new o_(e)}function bM(e){return new m_(e)}function xM(e){return new pw(e)}function vM(e){return new cw(e)}pw.className="Bidirectional",ou(pw);const _M=aM,wM=iM,MM=sM,NM=oM;function SM(e){return new z_(e)}function kM(e){return new B_(e)}function DM(e){return new P_(e)}function TM(e){return new T_(e)}function IM(e,t){return bx(e,t)}function EM(e,t){return wx(e,t)}function CM(e,t){return Mx(e,t)}function AM(e,t){return xx(e,t)}function LM(e,t){return Nx(e,t)}function $M(e,t){return _x(e,t)}function OM(e,t){return function(e,t){return co((()=>{const n=vx(e,t),r=function(e,t){return co((()=>Cs(wc(Kc(ic(e,1),ic(t,0))),"float32")))}(e,t),a=vu(n,r);return Cs(sc(Lc(a,0),wu(n,a),0),"float32")}))}(e,t)}function RM(e,t){return mx(e,t)}function FM(e,t){return cx(e,t)}function YM(e,t){return px(e,t)}function zM(e,t){return px(e,t)}function BM(e,t){return px(e,t)}function PM(e,t){return lx(e,t)}function HM(e,t){return lx(e,t)}function jM(e,t){return lx(e,t)}function UM(e){return new Ev(e)}function qM(e){return Tv(t=e),new Ev({l1:null!=t?t.l1:null,l2:0});var t}function WM(e){return Tv(t=e),new Ev({l2:null!=t?t.l2:null,l1:0});var t}class VM extends Qb{constructor(){super(...arguments),this.model=null}setModel(e){if(!(e instanceof tv))throw new Error("model must be a LayersModel, not some other Container");this.model=e}}function GM(e,t){return et}class JM extends VM{constructor(e){if(super(),null==e&&(e={}),e.restoreBestWeights)throw new vg("restoreBestWeights = True is not implemented in EarlyStopping yet.");this.monitor=e.monitor||"val_loss",this.minDelta=Math.abs(e.minDelta||0),this.patience=e.patience||0,this.verbose=e.verbose||0,this.mode=e.mode||"auto",this.baseline=e.baseline,-1===["auto","min","max"].indexOf(this.mode)&&(console.warn(`EarlyStopping mode '${this.mode}' is invalid. Falling back to mode 'auto'.`),this.mode="auto"),"min"===this.mode?this.monitorFunc=GM:"max"===this.mode||-1!==this.monitor.indexOf("acc")?this.monitorFunc=KM:this.monitorFunc=GM,this.monitorFunc===GM&&(this.minDelta*=-1)}async onTrainBegin(e){this.wait=0,this.stoppedEpoch=0,null!=this.baseline?this.best=this.baseline:this.best=this.monitorFunc===GM?1/0:-1/0}async onEpochEnd(e,t){await Jb(t);const n=this.getMonitorValue(t);null!=n&&(this.monitorFunc(n-this.minDelta,this.best)?(this.best=n,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=e,this.model.stopTraining=!0)))}async onTrainEnd(e){this.stoppedEpoch>0&&this.verbose&&console.log(`Epoch ${this.stoppedEpoch}: early stopping.`)}getMonitorValue(e){null==e&&(e={});const t=e[this.monitor];return null==t&&console.warn(`Metric for EarlyStopping ${this.monitor} is not available. Available metrics are: ${Object.keys(e)}`),t}}const XM={earlyStopping:function(e){return new JM(e)}};var ZM,QM;Ve().registerFlag("KEEP_INTERMEDIATE_TENSORS",(()=>!1),(e=>{e&&console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.")})),function(e){e[e.DT_INVALID=0]="DT_INVALID",e[e.DT_FLOAT=1]="DT_FLOAT",e[e.DT_DOUBLE=2]="DT_DOUBLE",e[e.DT_INT32=3]="DT_INT32",e[e.DT_UINT8=4]="DT_UINT8",e[e.DT_INT16=5]="DT_INT16",e[e.DT_INT8=6]="DT_INT8",e[e.DT_STRING=7]="DT_STRING",e[e.DT_COMPLEX64=8]="DT_COMPLEX64",e[e.DT_INT64=9]="DT_INT64",e[e.DT_BOOL=10]="DT_BOOL",e[e.DT_QINT8=11]="DT_QINT8",e[e.DT_QUINT8=12]="DT_QUINT8",e[e.DT_QINT32=13]="DT_QINT32",e[e.DT_BFLOAT16=14]="DT_BFLOAT16",e[e.DT_QINT16=15]="DT_QINT16",e[e.DT_QUINT16=16]="DT_QUINT16",e[e.DT_UINT16=17]="DT_UINT16",e[e.DT_COMPLEX128=18]="DT_COMPLEX128",e[e.DT_HALF=19]="DT_HALF",e[e.DT_RESOURCE=20]="DT_RESOURCE",e[e.DT_VARIANT=21]="DT_VARIANT",e[e.DT_UINT32=22]="DT_UINT32",e[e.DT_UINT64=23]="DT_UINT64",e[e.DT_FLOAT_REF=101]="DT_FLOAT_REF",e[e.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",e[e.DT_INT32_REF=103]="DT_INT32_REF",e[e.DT_UINT8_REF=104]="DT_UINT8_REF",e[e.DT_INT16_REF=105]="DT_INT16_REF",e[e.DT_INT8_REF=106]="DT_INT8_REF",e[e.DT_STRING_REF=107]="DT_STRING_REF",e[e.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",e[e.DT_INT64_REF=109]="DT_INT64_REF",e[e.DT_BOOL_REF=110]="DT_BOOL_REF",e[e.DT_QINT8_REF=111]="DT_QINT8_REF",e[e.DT_QUINT8_REF=112]="DT_QUINT8_REF",e[e.DT_QINT32_REF=113]="DT_QINT32_REF",e[e.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",e[e.DT_QINT16_REF=115]="DT_QINT16_REF",e[e.DT_QUINT16_REF=116]="DT_QUINT16_REF",e[e.DT_UINT16_REF=117]="DT_UINT16_REF",e[e.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",e[e.DT_HALF_REF=119]="DT_HALF_REF",e[e.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",e[e.DT_VARIANT_REF=121]="DT_VARIANT_REF",e[e.DT_UINT32_REF=122]="DT_UINT32_REF",e[e.DT_UINT64_REF=123]="DT_UINT64_REF"}(ZM||(ZM={})),function(e){let t;!function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"}(t=e.CheckpointFormatVersion||(e.CheckpointFormatVersion={}))}(QM||(QM={}));const eN={};function tN(e,t){const n={tfOpName:e,category:"custom",inputs:[],attrs:[],customExecutor:t};eN[e]=n}function nN(e){return eN[e]}function rN(e){delete eN[e]}function aN(e,t,n,r,a){const i=t.inputParams[e];if(i&&void 0!==i.inputIndexStart){const e=i.inputIndexStart,s=0===i.inputIndexEnd?void 0:void 0===i.inputIndexEnd?e+1:i.inputIndexEnd;if("tensor"===i.type)return iN(t.inputNames[i.inputIndexStart],n,r,a);if("tensors"===i.type)return t.inputNames.slice(e,s).map((e=>iN(e,n,r,a)));const o=iN(t.inputNames.slice(e)[0],n,r,a),u=o.dataSync();return"number"===i.type?u[0]:Fe(o.shape,u)}const s=t.attrParams[e];return s&&s.value}function iN(e,t,n,r){const[a,i]=uN(e);if(null!=r){const e=r.getHashTableHandleByName(a);if(null!=e)return e}const s=n.currentContextIds.find((e=>!!t[oN(a,e)]));return void 0!==s?t[oN(a,s)][i]:void 0}function sN(e,t){const[n,r,a]=uN(e);return[oN(n,t&&t.currentContextId),r,a]}function oN(e,t){return t?`${e}-${t}`:e}function uN(e){const t=e.split(":");if(1===t.length)return[e,0,void 0];const n=t[0],r=3===t.length?t[1]:void 0;return[n,Number(t[t.length-1]),r]}function lN(e,t,n){let r=aN("pad",e,t,n);if("explicit"===r){r=aN("explicitPaddings",e,t,n);const a=[[0,0],[0,0],[0,0],[0,0]];for(let e=0;e<4;e++)a[e][0]=r[2*e],a[e][1]=r[2*e+1];return a}return r}function cN(e){return e.kept?e:As(e)}const pN=[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],dN=[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Prod",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axes",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],hN=[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}],fN=[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number"}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"Dilation2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"rates",name:"dilations",type:"number[]"},{tfName:"padding",name:"pad",type:"string"}]}],mN=[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}],gN=[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],yN=[{tfOpName:"LowerBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"UpperBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}],bN=[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0},{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}],xN=[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]}],vN=[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]},{tfOpName:"ImageProjectiveTransformV3",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"transforms",type:"tensor"},{start:2,name:"outputShape",type:"number[]"},{start:3,name:"fillValue",type:"number"}],attrs:[{tfName:"interpolation",name:"interpolation",type:"string"},{tfName:"fill_mode",name:"fillMode",type:"string"}]}],_N=[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],wN=[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]}],MN=[{tfOpName:"EuclideanNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",defaultValue:!1}]},{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"SparseToDense",category:"normalization",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!0,notSupported:!0}]}],NN=[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}],SN=[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool[]"}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}],kN=[{tfOpName:"SparseFillEmptyRows",category:"sparse",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"denseShape",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}]},{tfOpName:"SparseReshape",category:"sparse",inputs:[{start:0,name:"inputIndices",type:"tensor"},{start:1,name:"inputShape",type:"tensor"},{start:2,name:"newShape",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SparseSegmentMean",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]},{tfOpName:"SparseSegmentSum",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]}],DN=[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}],TN=[{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}],IN=[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}];class EN{static get Instance(){return this._instance||(this._instance=new this)}constructor(){const e=[].concat(...[N,S,k,D,T,I,E,C,A,L,$,O,R,F,Y,z,B,P,H].map((e=>e.json)));this.opMappers=e.reduce(((e,t)=>(e[t.tfOpName]=t,e)),{})}transformGraph(e,t={}){const n=e.node,r=[],a=[],i=[],s=n.reduce(((e,t)=>(e[t.name]=this.mapNode(t),t.op.startsWith("Placeholder")?r.push(e[t.name]):"Const"===t.op?a.push(e[t.name]):null!=t.input&&0!==t.input.length||i.push(e[t.name]),e)),{});let o=[];const u=[];let l={},c={};null!=t&&(l=this.mapSignatureEntries(t.inputs),c=this.mapSignatureEntries(t.outputs));const p=Object.keys(s);p.forEach((e=>{const t=s[e];t.inputNames.forEach(((e,n)=>{const[r,,a]=sN(e),i=s[r];if(null!=i.outputs){const e=i.outputs.indexOf(a);if(-1!==e){const a=`${r}:${e}`;t.inputNames[n]=a}}t.inputs.push(i),i.children.push(t)}))})),0===Object.keys(c).length?p.forEach((e=>{const t=s[e];0===t.children.length&&u.push(t)})):Object.keys(c).forEach((e=>{const[t]=sN(e),n=s[t];null!=n&&(n.signatureKey=c[e],u.push(n))})),Object.keys(l).length>0?Object.keys(l).forEach((e=>{const[t]=sN(e),n=s[t];n&&(n.signatureKey=l[e],o.push(n))})):o=r;let d={};null!=e.library&&null!=e.library.function&&(d=e.library.function.reduce(((e,t)=>(e[t.signature.name]=this.mapFunction(t),e)),{}));const h={nodes:s,inputs:o,outputs:u,weights:a,placeholders:r,signature:t,functions:d};return i.length>0&&(h.initNodes=i),h}mapSignatureEntries(e){return Object.keys(e||{}).reduce(((t,n)=>(t[e[n].name]=n,t)),{})}mapNode(e){const t=nN(e.op)||this.opMappers[e.op]||{};null==e.attr&&(e.attr={});const n={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map((e=>e.startsWith("^")?e.slice(1):e)),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return null!=t.inputs&&(n.inputParams=t.inputs.reduce(((e,t)=>(e[t.name]={type:t.type,inputIndexStart:t.start,inputIndexEnd:t.end},e)),{})),null!=t.attrs&&(n.attrParams=t.attrs.reduce(((t,n)=>{const r=n.type;let a;switch(n.type){case"string":a=AN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=AN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":a=HN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=HN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":a=$N(e.attr,n.tfName,n.defaultValue||0),void 0===a&&n.tfDeprecatedName&&(a=$N(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":a=PN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=PN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":a=LN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=LN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":a=UN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=UN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":a=BN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=BN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":a=jN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=jN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":a=FN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=FN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":a=YN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=YN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":a=RN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=RN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${n.type} for op: ${e.op}`)}return t[n.name]={value:a,type:r},t}),{})),n}mapFunction(e){const t=e.nodeDef,n=[];let r={};null!=t&&(r=t.reduce(((e,t)=>(e[t.name]=this.mapNode(t),"Const"===t.op&&n.push(e[t.name]),e)),{}));const a=[],i=[];e.signature.inputArg.forEach((e=>{const[t]=sN(e.name),n={name:t,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:ON(e.type),type:"dtype"}},children:[]};n.signatureKey=e.name,a.push(n),r[t]=n})),Object.keys(r).forEach((e=>{const t=r[e];t.inputNames.forEach(((e,n)=>{const[a,,i]=sN(e),s=r[a];if(null!=s.outputs){const e=s.outputs.indexOf(i);if(-1!==e){const r=`${a}:${e}`;t.inputNames[n]=r}}t.inputs.push(s),s.children.push(t)}))}));const s=e.ret;e.signature.outputArg.forEach((e=>{const[t,n]=sN(s[e.name]),a=r[t];null!=a&&(a.defaultOutput=n,i.push(a))}));const o=this.mapArgsToSignature(e);return{nodes:r,inputs:a,outputs:i,weights:n,placeholders:[],signature:o}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce(((e,t)=>(e[t.name]=this.mapArgToTensorInfo(t),e)),{}),outputs:e.signature.outputArg.reduce(((t,n)=>(t[n.name]=this.mapArgToTensorInfo(n,e.ret),t)),{})}}mapArgToTensorInfo(e,t){let n=e.name;return null!=t&&(n=t[n]),{name:n,dtype:e.type}}}function CN(e,t){const n=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){const t=Ve().global;if(void 0!==t.atob)return t.atob(e);if("undefined"!=typeof Buffer)return new Buffer(e,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(e);return t?n:n.toLowerCase()}function AN(e,t,n,r=!1){const a=e[t];return null!=a?CN(a.s,r):n}function LN(e,t,n){const r=e[t];return r?r.b:n}function $N(e,t,n){const r=e[t]||{},a=null!=r.i?r.i:null!=r.f?r.f:n;return"number"==typeof a?a:parseInt(a,10)}function ON(e){switch("string"==typeof e&&(e=ZM[e]),e){case ZM.DT_FLOAT:case ZM.DT_HALF:return"float32";case ZM.DT_INT32:case ZM.DT_INT64:case ZM.DT_INT8:case ZM.DT_UINT8:return"int32";case ZM.DT_BOOL:return"bool";case ZM.DT_DOUBLE:return"float32";case ZM.DT_STRING:return"string";default:return null}}function RN(e,t,n){const r=e[t];return r&&r.func?r.func.name:n}function FN(e,t,n){const r=e[t];return r&&r.type?ON(r.type):n}function YN(e,t,n){const r=e[t];return r&&r.list&&r.list.type?r.list.type.map((e=>ON(e))):n}function zN(e){if(!e.unknownRank)return null!=e.dim?e.dim.map((e=>"number"==typeof e.size?e.size:parseInt(e.size,10))):[]}function BN(e,t,n){const r=e[t];return r&&r.shape?zN(r.shape):n}function PN(e,t,n){const r=e[t];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map((e=>"number"==typeof e?e:parseInt(e,10))):n}function HN(e,t,n,r=!1){const a=e[t];return a&&a.list&&a.list.s?a.list.s.map((e=>CN(e,r))):n}function jN(e,t,n){const r=e[t];return r&&r.list&&r.list.shape?r.list.shape.map((e=>zN(e))):n}function UN(e,t,n){const r=e[t];return r&&r.list&&r.list.b?r.list.b:n}class qN{constructor(e,t,n){this.node=e,this.tensorMap=t,this.context=n,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map((e=>this.getInput(e))),null!=e.rawAttrs&&(this.attrs=Object.keys(e.rawAttrs).reduce(((e,t)=>(e[t]=this.getAttr(t),e)),{}))}getInput(e){return iN(e,this.tensorMap,this.context)}getAttr(e,t){const n=this.node.rawAttrs[e];if(null!=n.tensor)return iN(e,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return $N(this.node.rawAttrs,e,t);if(null!=n.s)return AN(this.node.rawAttrs,e,t);if(null!=n.b)return LN(this.node.rawAttrs,e,t);if(null!=n.shape)return BN(this.node.rawAttrs,e,t);if(null!=n.type)return FN(this.node.rawAttrs,e,t);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return PN(this.node.rawAttrs,e,t);if(null!=n.list.s)return HN(this.node.rawAttrs,e,t);if(null!=n.list.shape)return jN(this.node.rawAttrs,e,t);if(null!=n.list.b)return UN(this.node.rawAttrs,e,t);if(null!=n.list.type)return YN(this.node.rawAttrs,e,t)}return t}}function WN(e,t,n=""){if("number"!=typeof e&&"number"!=typeof t){ie(e.length===t.length,(()=>n+` Shapes ${e} and ${t} must match`));for(let r=0;rn+` Shapes ${e} and ${t} must match`))}}}function VN(e){return"number"!=typeof e&&!e.some((e=>e<0))}function GN(e,t,n){let r=KN(e,n);const a=!VN(r);if(a&&0===t.length)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${r}`);if(a&&t.forEach((e=>{r=KN(e.shape,r)})),!VN(r))throw new Error(`Non-fully-defined elementShape: ${r}`);return r}function KN(e,t){if("number"==typeof e)return t;if("number"==typeof t)return e;if(e.length!==t.length)throw new Error(`Incompatible ranks during merge: ${e} vs. ${t}`);const n=[];for(let r=0;r=0&&i>=0&&a!==i)throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`);n[r]=a>=0?a:i}return n}class JN{constructor(e,t,n,r,a,i,s){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=r,this.identicalElementShapes=a,this.dynamicSize=i,this.clearAfterRead=s,this.tensors=[],this.closed_=!1,this.idTensor=$u(0),ho(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.tensor.id)||t.tensor.dispose()})),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(e){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||e>=this.size())throw new Error(`Tried to read from index ${e}, but array size is: ${this.size()}`);const t=this.tensors[e];if(t.cleared)throw new Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(t.cleared=!0),t.read=!0,t.tensor}readMany(e){return e.map((e=>this.read(e)))}write(e,t){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||!this.dynamicSize&&e>=this.maxSize)throw new Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`);const n=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e},\n because the value dtype is ${t.dtype}, but TensorArray dtype is ${this.dtype}.`);if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=t.shape),WN(this.elementShape,t.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${e}.`),n.read)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`);if(n.written)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`);n.tensor=t,ho(t),n.written=!0,this.tensors[e]=n}writeMany(e,t){if(e.length!==t.length)throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t.length}.`);e.forEach(((e,n)=>this.write(e,t[n])))}gather(e,t){if(t&&t!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`);if(e)e=e.slice(0,this.size());else{e=[];for(let t=0;t=this.maxSize)throw new Error(`Max index must be < array size (${n} vs. ${this.maxSize})`);this.writeMany(e,Md(t,0))}split(e,t){if(t.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);let n=0;const r=e.map((e=>(n+=e,n)));if(n!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${n}, and tensor's shape is: ${t.shape}`);if(!this.dynamicSize&&e.length!==this.maxSize)throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${e.length}), and the TensorArray is not marked as dynamically resizeable`);const a=0===n?0:t.size/n,i=[];co((()=>{t=_l(t,[1,n,a]);for(let n=0;n{if(n!==e.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${e.dtype}`);WN(t,e.shape,"TensorList shape mismatch: "),ho(e)})),this.idTensor=$u(0),this.maxNumElements=r,ho(this.idTensor)}get id(){return this.idTensor.id}copy(){return new XN([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.id)||t.dispose()})),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(e,t,n=-1){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(-1!==n&&this.tensors.length!==n)throw new Error(`Operation expected a list with ${n} elements but got a list with ${this.tensors.length} elements.`);WN(e,this.elementShape,"TensorList shape mismatch: ");const r=GN(this.elementShape,this.tensors,e);return co((()=>{const e=this.tensors.map((e=>_l(e,r)));return cd(e,0)}))}popBack(e,t){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(0===this.size())throw new Error("Trying to pop from an empty list.");const n=GN(this.elementShape,this.tensors,e),r=this.tensors.pop();return WN(r.shape,e,"TensorList shape mismatch: "),_l(r,n)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(WN(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");ho(e),this.tensors.push(e)}resize(e){if(e<0)throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`);if(-1!==this.maxNumElements&&e>this.maxNumElements)throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`);const t=new XN([],this.elementShape,this.elementDtype,this.maxNumElements);t.tensors.length=e;for(let n=0;nthis.tensors.length)throw new Error(`Trying to access element ${e} in a list with ${this.tensors.length} elements.`);if(null==this.tensors[e])throw new Error(`element at index ${e} is null.`);WN(this.tensors[e].shape,t,"TensorList shape mismatch: ");const r=GN(this.elementShape,this.tensors,t);return _l(this.tensors[e],r)}setItem(e,t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||-1!==this.maxNumElements&&e>=this.maxNumElements)throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);WN(this.elementShape,t.shape,"TensorList shape mismatch: "),ho(t),this.tensors[e]=t}gather(e,t,n){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);WN(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());const r=GN(this.elementShape,this.tensors,n);return 0===e.length?Oi([],[0].concat(r)):co((()=>{const t=e.map((e=>_l(this.tensors[e],r)));return cd(t,0)}))}concat(e,t){if(e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);WN(this.elementShape,t,"TensorList shape mismatch: ");const n=GN(this.elementShape,this.tensors,t);return 0===this.size()?Oi([],[0].concat(n)):co((()=>{const e=this.tensors.map((e=>_l(e,n)));return Nl(e,0)}))}}function ZN(e,t,n){const[r,a]=aN("fusedOps",e,t,n),i="biasadd"===r,s=!i,o="prelu"===a,u="fusedbatchnorm"===r,l=aN("numArgs",e,t,n);if(i){if(o&&2!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&i&&1!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(u)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");const c=aN("strides",e,t,n),p=lN(e,t,n),d=aN("dataFormat",e,t,n).toUpperCase(),h=aN("dilations",e,t,n);let[f,m]=aN("args",e,t,n);return s&&(m=f,f=void 0),{stride:c,pad:p,dataFormat:d,dilations:h,biasArg:f,preluArg:m,activationFunc:a,leakyreluAlpha:aN("leakyreluAlpha",e,t,n)}}function QN(e,t,n){return{boxes:aN("boxes",e,t,n),scores:aN("scores",e,t,n),maxOutputSize:aN("maxOutputSize",e,t,n),iouThreshold:aN("iouThreshold",e,t,n),scoreThreshold:aN("scoreThreshold",e,t,n),softNmsSigma:aN("softNmsSigma",e,t,n)}}class eS{constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=$u(0),this.tensorMap=new Map,ho(this.handle)}get id(){return this.handle.id}clearAndClose(){this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return $u(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);const n=await e.data();return this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),co((()=>{const e=Md(t),r=n.length,a=e.length;ie(r===a,(()=>`The number of elements doesn't match, keys has ${r} elements, the values has ${a} elements.`));for(let t=0;t{const e=[];for(let r=0;r{switch(e.category){case"arithmetic":return co((()=>((e,t,n)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[vu(aN("a",e,t,n),aN("b",e,t,n))];case"AddN":return[Xu(aN("tensors",e,t,n))];case"FloorMod":case"Mod":return[pp(aN("a",e,t,n),aN("b",e,t,n))];case"Mul":return[Mu(aN("a",e,t,n),aN("b",e,t,n))];case"RealDiv":case"Div":return[wu(aN("a",e,t,n),aN("b",e,t,n))];case"DivNoNan":return[oc(aN("a",e,t,n),aN("b",e,t,n))];case"FloorDiv":return[_u(aN("a",e,t,n),aN("b",e,t,n))];case"Sub":return[Bu(aN("a",e,t,n),aN("b",e,t,n))];case"Minimum":return[lp(aN("a",e,t,n),aN("b",e,t,n))];case"Maximum":return[ju(aN("a",e,t,n),aN("b",e,t,n))];case"Pow":return[zu(aN("a",e,t,n),aN("b",e,t,n))];case"SquaredDifference":return[ud(aN("a",e,t,n),aN("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"basic_math":return co((()=>((e,t,n)=>{switch(e.op){case"Abs":case"ComplexAbs":return[Hu(aN("x",e,t,n))];case"Acos":return[Ku(aN("x",e,t,n))];case"Acosh":return[Ju(aN("x",e,t,n))];case"Asin":return[nl(aN("x",e,t,n))];case"Asinh":return[rl(aN("x",e,t,n))];case"Atan":return[al(aN("x",e,t,n))];case"Atan2":return[il(aN("x",e,t,n),aN("y",e,t,n))];case"Atanh":return[sl(aN("x",e,t,n))];case"Ceil":return[Fl(aN("x",e,t,n))];case"Complex":return[Li(aN("real",e,t,n),aN("imag",e,t,n))];case"Cos":return[Jl(aN("x",e,t,n))];case"Cosh":return[Xl(aN("x",e,t,n))];case"Elu":return[cc(aN("x",e,t,n))];case"Erf":return[pc(aN("x",e,t,n))];case"Exp":return[kc(aN("x",e,t,n))];case"Expm1":return[Tc(aN("x",e,t,n))];case"Floor":return[Cc(aN("x",e,t,n))];case"Log":return[jc(aN("x",e,t,n))];case"Log1p":return[Uc(aN("x",e,t,n))];case"Imag":return[No(aN("x",e,t,n))];case"Neg":return[So(aN("x",e,t,n))];case"Reciprocal":return[Rp(aN("x",e,t,n))];case"Real":return[ko(aN("x",e,t,n))];case"Relu":return[Fp(aN("x",e,t,n))];case"Round":return[Up(aN("x",e,t,n))];case"Selu":return[Wp(aN("x",e,t,n))];case"Sigmoid":return[Sl(aN("x",e,t,n))];case"Sin":return[Jp(aN("x",e,t,n))];case"Sign":return[Kp(aN("x",e,t,n))];case"Sinh":return[Xp(aN("x",e,t,n))];case"Softplus":return[qc(aN("x",e,t,n))];case"Sqrt":return[Nu(aN("x",e,t,n))];case"Square":return[Su(aN("x",e,t,n))];case"Tanh":return[Dl(aN("x",e,t,n))];case"Tan":return[hd(aN("x",e,t,n))];case"ClipByValue":return[Yl(aN("x",e,t,n),aN("clipValueMin",e,t,n),aN("clipValueMax",e,t,n))];case"Relu6":return[Yp(aN("x",e,t,n))];case"Rsqrt":return[qp(iN(e.inputNames[0],t,n))];case"Prod":return[kp(aN("x",e,t,n),aN("axes",e,t,n))];case"LeakyRelu":return[Yc(aN("x",e,t,n),aN("alpha",e,t,n))];case"Prelu":return[Sp(aN("x",e,t,n),aN("alpha",e,t,n))];case"IsNan":return[Fc(iN(e.inputNames[0],t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"control":return(async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{const r=aN("thenBranch",e,t,n),a=aN("elseBranch",e,t,n),i=aN("cond",e,t,n),s=aN("args",e,t,n);return(await i.data())[0]?n.functionMap[r].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap):n.functionMap[a].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{const r=aN("body",e,t,n),a=aN("cond",e,t,n),i=aN("args",e,t,n),s=await n.functionMap[a].executeFunctionAsync(i,n.tensorArrayMap,n.tensorListMap),o=i.map((e=>e.id));let u=await s[0].data();s.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||e.dispose()}));let l=i;for(;u[0];){const e=l;l=await n.functionMap[r].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);const t=l.map((e=>e.id));e.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}));const i=await n.functionMap[a].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);u=await i[0].data(),i.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}))}return l}case"LoopCond":return[cN(aN("pred",e,t,n))];case"Switch":{const r=aN("pred",e,t,n);let a=aN("data",e,t,n);return a.kept||(a=cN(a)),(await r.data())[0]?[void 0,a]:[a,void 0]}case"Merge":{const r=e.inputNames.find((e=>void 0!==iN(e,t,n)));return r?[cN(iN(r,t,n))]:void 0}case"Enter":{const r=aN("frameName",e,t,n),a=aN("tensor",e,t,n);return n.enterFrame(r),[cN(a)]}case"Exit":{const r=aN("tensor",e,t,n);return n.exitFrame(),[cN(r)]}case"NextIteration":{const r=aN("tensor",e,t,n);return n.nextIteration(),[cN(r)]}case"TensorArrayV3":{const r=aN("size",e,t,n),a=aN("dtype",e,t,n),i=aN("elementShape",e,t,n),s=aN("dynamicSize",e,t,n),o=aN("clearAfterRead",e,t,n),u=aN("identicalElementShapes",e,t,n),l=aN("name",e,t,n),c=new JN(l,a,r,i,u,s,o);return n.addTensorArray(c),[c.idTensor,$u(1)]}case"TensorArrayWriteV3":{const r=aN("tensorArrayId",e,t,n),a=aN("index",e,t,n),i=aN("tensor",e,t,n),s=n.getTensorArray(r.id);return s.write(a,i),[s.idTensor]}case"TensorArrayReadV3":{const r=aN("tensorArrayId",e,t,n),a=aN("index",e,t,n);return[n.getTensorArray(r.id).read(a)]}case"TensorArrayGatherV3":{const r=aN("tensorArrayId",e,t,n),a=aN("indices",e,t,n),i=aN("dtype",e,t,n);return[n.getTensorArray(r.id).gather(a,i)]}case"TensorArrayScatterV3":{const r=aN("tensorArrayId",e,t,n),a=aN("indices",e,t,n),i=aN("tensor",e,t,n),s=n.getTensorArray(r.id);return s.scatter(a,i),[s.idTensor]}case"TensorArrayConcatV3":{const r=aN("tensorArrayId",e,t,n),a=n.getTensorArray(r.id),i=aN("dtype",e,t,n);return[a.concat(i)]}case"TensorArraySplitV3":{const r=aN("tensorArrayId",e,t,n),a=aN("tensor",e,t,n),i=aN("lengths",e,t,n),s=n.getTensorArray(r.id);return s.split(i,a),[s.idTensor]}case"TensorArraySizeV3":{const r=aN("tensorArrayId",e,t,n);return[$u(n.getTensorArray(r.id).size(),"int32")]}case"TensorArrayCloseV3":{const r=aN("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return a.clearAndClose(),[a.idTensor]}case"TensorListSetItem":{const r=aN("tensorListId",e,t,n),a=aN("index",e,t,n),i=aN("tensor",e,t,n),s=n.getTensorList(r.id);return s.setItem(a,i),[s.idTensor]}case"TensorListGetItem":{const r=aN("tensorListId",e,t,n),a=aN("index",e,t,n),i=aN("elementShape",e,t,n),s=aN("elementDType",e,t,n);return[n.getTensorList(r.id).getItem(a,i,s)]}case"TensorListScatterV2":case"TensorListScatter":{const r=aN("indices",e,t,n),a=function(e,t,n,r){if(t.length!==e.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);const a=Math.max(...t);if(null!=r&&-1!==r&&a>=r)throw new Error(`Max index must be < array size (${a} vs. ${r})`);const i=new XN([],n,e.dtype,r),s=Md(e,0);return t.forEach(((e,t)=>{i.setItem(e,s[t])})),i}(aN("tensor",e,t,n),r,aN("elementShape",e,t,n),aN("numElements",e,t,n));return n.addTensorList(a),[a.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const r=aN("elementShape",e,t,n),a=aN("elementDType",e,t,n);let i;i="TensorListReserve"===e.op?"numElements":"maxNumElements";const s=function(e,t,n){return new XN([],e,t,n)}(r,a,aN(i,e,t,n));return n.addTensorList(s),[s.idTensor]}case"TensorListGather":{const r=aN("tensorListId",e,t,n),a=aN("indices",e,t,n),i=aN("elementShape",e,t,n),s=aN("elementDType",e,t,n);return[n.getTensorList(r.id).gather(a,s,i)]}case"TensorListStack":{const r=aN("tensorListId",e,t,n),a=aN("elementShape",e,t,n),i=aN("elementDType",e,t,n),s=aN("numElements",e,t,n);return[n.getTensorList(r.id).stack(a,i,s)]}case"TensorListFromTensor":{const r=function(e,t,n){const r=e.dtype;if(e.shape.length<1)throw new Error(`Tensor must be at least a vector, but saw shape: ${e.shape}`);if(e.dtype!==n)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${n}`);WN(e.shape.slice(1),t,"TensorList shape mismatch: ");const a=Md(e);return new XN(a,t,r)}(aN("tensor",e,t,n),aN("elementShape",e,t,n),aN("elementDType",e,t,n));return n.addTensorList(r),[r.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{const r=aN("tensorListId",e,t,n),a=n.getTensorList(r.id),i=aN("dtype",e,t,n),s=aN("elementShape",e,t,n);return[a.concat(i,s)]}case"TensorListPushBack":{const r=aN("tensorListId",e,t,n),a=aN("tensor",e,t,n),i=n.getTensorList(r.id);return i.pushBack(a),[i.idTensor]}case"TensorListPopBack":{const r=aN("tensorListId",e,t,n),a=aN("elementShape",e,t,n),i=aN("elementDType",e,t,n);return[n.getTensorList(r.id).popBack(a,i)]}case"TensorListSplit":{const r=aN("tensor",e,t,n),a=aN("elementShape",e,t,n),i=function(e,t,n){let r=0;const a=t.map((e=>(r+=e,r)));if(r!==e.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${r}, and tensor's shape is: ${e.shape}`);const i=KN(e.shape.slice(1),n),s=0===r?0:e.size/r,o=co((()=>{const n=[];e=_l(e,[1,r,s]);for(let r=0;r((e,t,n)=>{switch(e.op){case"Conv1D":{const r=aN("stride",e,t,n),a=aN("pad",e,t,n),i=aN("dataFormat",e,t,n).toUpperCase(),s=aN("dilation",e,t,n);return[Ul(aN("x",e,t,n),aN("filter",e,t,n),r,a,i,s)]}case"Conv2D":{const r=aN("strides",e,t,n),a=lN(e,t,n),i=aN("dataFormat",e,t,n).toUpperCase(),s=aN("dilations",e,t,n);return[jl(aN("x",e,t,n),aN("filter",e,t,n),[r[1],r[2]],a,i,[s[1],s[2]])]}case"_FusedConv2D":{const{stride:r,pad:a,dataFormat:i,dilations:s,biasArg:o,preluArg:u,activationFunc:l,leakyreluAlpha:c}=ZN(e,t,n);return[Hd({x:aN("x",e,t,n),filter:aN("filter",e,t,n),strides:[r[1],r[2]],pad:a,dataFormat:i,dilations:[s[1],s[2]],bias:o,activation:l,preluActivationWeights:u,leakyreluAlpha:c})]}case"FusedDepthwiseConv2dNative":{const{stride:r,pad:a,dataFormat:i,dilations:s,biasArg:o,preluArg:u,activationFunc:l,leakyreluAlpha:c}=ZN(e,t,n);return[qd({x:aN("x",e,t,n),filter:aN("filter",e,t,n),strides:[r[1],r[2]],pad:a,dataFormat:i,dilations:[s[1],s[2]],bias:o,activation:l,preluActivationWeights:u,leakyreluAlpha:c})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const r=aN("outputShape",e,t,n),a=aN("strides",e,t,n),i=lN(e,t,n);return[Wl(aN("x",e,t,n),aN("filter",e,t,n),r,[a[1],a[2]],i)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const r=aN("strides",e,t,n),a=lN(e,t,n),i=aN("dilations",e,t,n),s=aN("dataFormat",e,t,n).toUpperCase();return[nc(aN("input",e,t,n),aN("filter",e,t,n),[r[1],r[2]],a,s,[i[1],i[2]])]}case"Conv3D":{const r=aN("strides",e,t,n),a=aN("pad",e,t,n),i=aN("dataFormat",e,t,n).toUpperCase(),s=aN("dilations",e,t,n);return[Vl(aN("x",e,t,n),aN("filter",e,t,n),[r[1],r[2],r[3]],a,i,[s[1],s[2],s[3]])]}case"AvgPool":{const r=aN("strides",e,t,n),a=aN("pad",e,t,n),i=aN("kernelSize",e,t,n);return[wl(aN("x",e,t,n),[i[1],i[2]],[r[1],r[2]],a)]}case"MaxPool":{const r=aN("strides",e,t,n),a=aN("pad",e,t,n),i=aN("kernelSize",e,t,n);return[np(aN("x",e,t,n),[i[1],i[2]],[r[1],r[2]],a)]}case"MaxPoolWithArgmax":{const r=aN("strides",e,t,n),a=aN("pad",e,t,n),i=aN("kernelSize",e,t,n),s=aN("includeBatchInIndex",e,t,n),{result:o,indexes:u}=ap(aN("x",e,t,n),[i[1],i[2]],[r[1],r[2]],a,s);return[o,u]}case"AvgPool3D":{const r=aN("strides",e,t,n),a=aN("pad",e,t,n),i=aN("kernelSize",e,t,n);return[Ml(aN("x",e,t,n),[i[1],i[2],i[3]],[r[1],r[2],r[3]],a)]}case"MaxPool3D":{const r=aN("strides",e,t,n),a=aN("pad",e,t,n),i=aN("kernelSize",e,t,n);return[rp(aN("x",e,t,n),[i[1],i[2],i[3]],[r[1],r[2],r[3]],a)]}case"Dilation2D":{const r=aN("strides",e,t,n),a=aN("pad",e,t,n),i=aN("dilations",e,t,n),s=r[1],o=r[2],u=i[1],l=i[2];return[ac(aN("x",e,t,n),aN("filter",e,t,n),[s,o],a,[u,l],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"creation":return co((()=>((e,t,n)=>{switch(e.op){case"Fill":{const r=aN("shape",e,t,n),a=aN("dtype",e,t,n);return[Fu(r,aN("value",e,t,n),a)]}case"LinSpace":return[Pc(aN("start",e,t,n),aN("stop",e,t,n),aN("num",e,t,n))];case"Multinomial":{const r=aN("logits",e,t,n),a=aN("numSamples",e,t,n),i=aN("seed",e,t,n);return[fp(r,a,i)]}case"OneHot":{const r=aN("indices",e,t,n),a=aN("depth",e,t,n),i=aN("onValue",e,t,n),s=aN("offValue",e,t,n);return[to(r,a,i,s)]}case"Ones":return[op(aN("shape",e,t,n),aN("dtype",e,t,n))];case"OnesLike":return[gp(aN("x",e,t,n))];case"RandomUniform":return[$p(aN("shape",e,t,n),aN("minval",e,t,n),aN("maxval",e,t,n),aN("dtype",e,t,n))];case"Range":return[Op(aN("start",e,t,n),aN("stop",e,t,n),aN("step",e,t,n),aN("dtype",e,t,n))];case"TruncatedNormal":{const r=aN("shape",e,t,n),a=aN("mean",e,t,n),i=aN("stdDev",e,t,n),s=aN("seed",e,t,n);return[vd(r,a,i,aN("dtype",e,t,n),s)]}case"Zeros":return[sp(aN("shape",e,t,n),aN("dtype",e,t,n))];case"ZerosLike":return[ku(aN("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"dynamic":return(async(e,t,n)=>{switch(e.op){case"NonMaxSuppressionV5":{const{boxes:r,scores:a,maxOutputSize:i,iouThreshold:s,scoreThreshold:o,softNmsSigma:u}=QN(e,t,n),l=await Ph.nonMaxSuppressionWithScoreAsync(r,a,i,s,o,u);return[l.selectedIndices,l.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:r,scores:a,maxOutputSize:i,iouThreshold:s,scoreThreshold:o}=QN(e,t,n),u=aN("padToMaxOutputSize",e,t,n),l=await Ph.nonMaxSuppressionPaddedAsync(r,a,i,s,o,u);return[l.selectedIndices,l.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:r,scores:a,maxOutputSize:i,iouThreshold:s,scoreThreshold:o}=QN(e,t,n);return[await Ph.nonMaxSuppressionAsync(r,a,i,s,o)]}case"Where":{const r=Cs(aN("condition",e,t,n),"bool"),a=[await Dd(r)];return r.dispose(),a}case"ListDiff":return Gp(aN("x",e,t,n),aN("y",e,t,n));default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n);case"evaluation":return co((()=>((e,t,n)=>{switch(e.op){case"LowerBound":return[tp(aN("sortedSequence",e,t,n),aN("values",e,t,n))];case"TopKV2":{const r=aN("x",e,t,n),a=aN("k",e,t,n),i=aN("sorted",e,t,n),s=xd(r,a,i);return[s.values,s.indices]}case"UpperBound":return[Nd(aN("sortedSequence",e,t,n),aN("values",e,t,n))];case"Unique":{const r=aN("x",e,t,n),a=_d(r);return[a.values,a.indices]}case"UniqueV2":{const r=aN("x",e,t,n),a=aN("axis",e,t,n),i=_d(r,a);return[i.values,i.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"image":return co((()=>((e,t,n)=>{switch(e.op){case"ResizeBilinear":{const r=aN("images",e,t,n),a=aN("size",e,t,n),i=aN("alignCorners",e,t,n),s=aN("halfPixelCenters",e,t,n);return[Ph.resizeBilinear(r,[a[0],a[1]],i,s)]}case"ResizeNearestNeighbor":{const r=aN("images",e,t,n),a=aN("size",e,t,n),i=aN("alignCorners",e,t,n),s=aN("halfPixelCenters",e,t,n);return[Ph.resizeNearestNeighbor(r,[a[0],a[1]],i,s)]}case"CropAndResize":{const r=aN("image",e,t,n),a=aN("boxes",e,t,n),i=aN("boxInd",e,t,n),s=aN("cropSize",e,t,n),o=aN("method",e,t,n),u=aN("extrapolationValue",e,t,n);return[Ph.cropAndResize(r,a,i,s,o,u)]}case"ImageProjectiveTransformV3":{const r=aN("images",e,t,n),a=aN("transforms",e,t,n),i=aN("outputShape",e,t,n),s=aN("fillValue",e,t,n),o=aN("interpolation",e,t,n),u=aN("fillMode",e,t,n);return[Ph.transform(r,a,o.toLowerCase(),u.toLowerCase(),s,i)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"graph":return co((()=>((e,t,n)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":const r=aN("default",e,t,n);return[iN(e.name,t,n)||r];case"Placeholder":return[iN(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":case"Snapshot":return[cN(aN("x",e,t,n))];case"IdentityN":return aN("x",e,t,n).map((e=>cN(e)));case"Shape":return[fd(aN("x",e,t,n).shape,"int32")];case"ShapeN":return aN("x",e,t,n).map((e=>fd(e.shape)));case"Size":return[$u(aN("x",e,t,n).size,"int32")];case"Rank":return[$u(aN("x",e,t,n).rank,"int32")];case"NoOp":return[$u(1)];case"Print":const a=aN("x",e,t,n),i=aN("data",e,t,n),s=aN("message",e,t,n),o=aN("summarize",e,t,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(s);for(let e=0;e((e,t,n)=>{switch(e.op){case"Equal":return[ic(aN("a",e,t,n),aN("b",e,t,n))];case"NotEqual":return[mp(aN("a",e,t,n),aN("b",e,t,n))];case"Greater":return[Lc(aN("a",e,t,n),aN("b",e,t,n))];case"GreaterEqual":return[$c(aN("a",e,t,n),aN("b",e,t,n))];case"Less":return[zc(aN("a",e,t,n),aN("b",e,t,n))];case"LessEqual":return[Bc(aN("a",e,t,n),aN("b",e,t,n))];case"LogicalAnd":return[Kc(aN("a",e,t,n),aN("b",e,t,n))];case"LogicalNot":return[Jc(aN("a",e,t,n))];case"LogicalOr":return[Xc(aN("a",e,t,n),aN("b",e,t,n))];case"Select":case"SelectV2":return[sc(aN("condition",e,t,n),aN("a",e,t,n),aN("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"matrices":return co((()=>((e,t,n)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[eo(aN("a",e,t,n),aN("b",e,t,n),aN("transposeA",e,t,n),aN("transposeB",e,t,n))];case"Einsum":return[lc(aN("equation",e,t,n),...aN("tensors",e,t,n))];case"Transpose":return[Do(aN("x",e,t,n),aN("perm",e,t,n))];case"_FusedMatMul":const[r,a]=aN("fusedOps",e,t,n),i="biasadd"===r,s="prelu"===a,o=aN("numArgs",e,t,n),u=aN("leakyreluAlpha",e,t,n);if(i){if(s&&2!==o)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!s&&1!==o)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[l,c]=aN("args",e,t,n);return[Wd({a:aN("a",e,t,n),b:aN("b",e,t,n),transposeA:aN("transposeA",e,t,n),transposeB:aN("transposeB",e,t,n),bias:l,activation:a,preluActivationWeights:c,leakyreluAlpha:u})];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"normalization":return co((()=>((e,t,n)=>{switch(e.op){case"EuclideanNorm":return[Sc(aN("x",e,t,n),aN("axis",e,t,n),aN("keepDims",e,t,n))];case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[El(aN("x",e,t,n),aN("mean",e,t,n),aN("variance",e,t,n),aN("offset",e,t,n),aN("scale",e,t,n),aN("epsilon",e,t,n))];case"LRN":return[Hc(aN("x",e,t,n),aN("radius",e,t,n),aN("bias",e,t,n),aN("alpha",e,t,n),aN("beta",e,t,n))];case"Softmax":return[nd(aN("x",e,t,n))];case"LogSoftmax":return[Vc(aN("x",e,t,n))];case"SparseToDense":return[Cd(aN("sparseIndices",e,t,n),aN("outputShape",e,t,n),aN("sparseValues",e,t,n),aN("defaultValue",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"reduction":return co((()=>((e,t,n)=>{switch(e.op){case"Max":{const r=aN("axis",e,t,n),a=aN("keepDims",e,t,n);return[vc(aN("x",e,t,n),r,a)]}case"Mean":{const r=aN("axis",e,t,n),a=aN("keepDims",e,t,n);return[ip(aN("x",e,t,n),r,a)]}case"Min":{const r=aN("axis",e,t,n),a=aN("keepDims",e,t,n);return[_c(aN("x",e,t,n),r,a)]}case"Sum":{const r=aN("axis",e,t,n),a=aN("keepDims",e,t,n);return[wc(aN("x",e,t,n),r,a)]}case"All":{const r=aN("axis",e,t,n),a=aN("keepDims",e,t,n);return[Zu(aN("x",e,t,n),r,a)]}case"Any":{const r=aN("axis",e,t,n),a=aN("keepDims",e,t,n);return[Qu(aN("x",e,t,n),r,a)]}case"ArgMax":{const r=aN("axis",e,t,n);return[el(aN("x",e,t,n),r)]}case"ArgMin":{const r=aN("axis",e,t,n);return[tl(aN("x",e,t,n),r)]}case"Prod":{const r=aN("axis",e,t,n),a=aN("keepDims",e,t,n);return[kp(aN("x",e,t,n),r,a)]}case"Cumprod":{const r=aN("axis",e,t,n),a=aN("exclusive",e,t,n),i=aN("reverse",e,t,n);return[Zl(aN("x",e,t,n),r,a,i)]}case"Cumsum":{const r=aN("axis",e,t,n),a=aN("exclusive",e,t,n),i=aN("reverse",e,t,n);return[Ql(aN("x",e,t,n),r,a,i)]}case"Bincount":const r=aN("x",e,t,n),a=aN("weights",e,t,n),i=aN("size",e,t,n);return[$l(r,a,i)];case"DenseBincount":{const r=aN("x",e,t,n),a=aN("weights",e,t,n),i=aN("size",e,t,n),s=aN("binaryOutput",e,t,n);return[ec(r,a,i,s)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"slice_join":return co((()=>((e,t,n)=>{switch(e.op){case"ConcatV2":case"Concat":{const r=aN("n",e,t,n),a=aN("axis",e,t,n);let i=aN("tensors",e,t,n);return i=i.slice(0,r),[Nl(i,a)]}case"Gather":{const r=aN("x",e,t,n),a=aN("indices",e,t,n);return[Ac(r,Cs(a,"int32"),0)]}case"GatherV2":{const r=aN("axis",e,t,n),a=aN("batchDims",e,t,n),i=aN("x",e,t,n),s=aN("indices",e,t,n);return[Ac(i,Cs(s,"int32"),r,a)]}case"Reverse":{const r=aN("dims",e,t,n),a=[];for(let e=0;e{const r=aN("axis",e,t,n),a=aN("tensors",e,t,n),i=a[0].shape,s=ld(a[0]).shape,o=a.map((e=>{const t=pe(e.shape,i);if(!t&&!pe(ld(e).shape,s))throw new Error("the input tensors shape does not match");return t?e:_l(e,i)}));return[cd(o,r)]}));case"Unpack":{const r=aN("axis",e,t,n),a=aN("tensor",e,t,n);return Md(a,r)}case"Tile":{const r=aN("reps",e,t,n);return[Ic(aN("x",e,t,n),r)]}case"Split":case"SplitV":{const r=aN("axis",e,t,n),a=aN("numOrSizeSplits",e,t,n),i=aN("x",e,t,n);return sd(i,a,r)}case"ScatterNd":{const r=aN("indices",e,t,n),a=aN("values",e,t,n),i=aN("shape",e,t,n);return[Ed(r,a,i)]}case"GatherNd":{const r=aN("x",e,t,n),a=aN("indices",e,t,n);return[Ad(r,a)]}case"SparseToDense":{const r=aN("sparseIndices",e,t,n),a=aN("outputShape",e,t,n),i=aN("sparseValues",e,t,n),s=aN("defaultValue",e,t,n);return[Cd(r,i,a,i.dtype===s.dtype?s:Cs(s,i.dtype))]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"sparse":return co((()=>((e,t,n)=>{switch(e.op){case"SparseFillEmptyRows":{const{outputIndices:r,outputValues:a,emptyRowIndicator:i,reverseIndexMap:s}=Uh.sparseFillEmptyRows(aN("indices",e,t,n),aN("values",e,t,n),aN("denseShape",e,t,n),aN("defaultValue",e,t,n));return[r,a,i,s]}case"SparseReshape":{const{outputIndices:r,outputShape:a}=Uh.sparseReshape(aN("inputIndices",e,t,n),aN("inputShape",e,t,n),aN("newShape",e,t,n));return[r,a]}case"SparseSegmentMean":return[Uh.sparseSegmentMean(aN("data",e,t,n),aN("indices",e,t,n),aN("segmentIds",e,t,n))];case"SparseSegmentSum":return[Uh.sparseSegmentSum(aN("data",e,t,n),aN("indices",e,t,n),aN("segmentIds",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"spectral":return co((()=>((e,t,n)=>{switch(e.op){case"FFT":return[rd(aN("x",e,t,n))];case"IFFT":return[ad(aN("x",e,t,n))];case"RFFT":return[od(aN("x",e,t,n))];case"IRFFT":return[id(aN("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"string":return co((()=>((e,t,n)=>{switch(e.op){case"StringNGrams":{const{nGrams:r,nGramsSplits:a}=qh.stringNGrams(aN("data",e,t,n),aN("dataSplits",e,t,n),aN("separator",e,t,n),aN("nGramWidths",e,t,n),aN("leftPad",e,t,n),aN("rightPad",e,t,n),aN("padWidth",e,t,n),aN("preserveShortSequences",e,t,n));return[r,a]}case"StringSplit":{const{indices:r,values:a,shape:i}=qh.stringSplit(aN("input",e,t,n),aN("delimiter",e,t,n),aN("skipEmpty",e,t,n));return[r,a,i]}case"StringToHashBucketFast":return[qh.stringToHashBucketFast(aN("input",e,t,n),aN("numBuckets",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"transformation":return co((()=>((e,t,n)=>{switch(e.op){case"Cast":return[Cs(aN("x",e,t,n),aN("dtype",e,t,n))];case"ExpandDims":{const r=aN("axis",e,t,n);return[Dc(aN("x",e,t,n),r)]}case"Squeeze":{const r=aN("axis",e,t,n);return[ld(aN("x",e,t,n),r)]}case"Reshape":return[_l(aN("x",e,t,n),aN("shape",e,t,n))];case"MirrorPad":return[cp(aN("x",e,t,n),aN("padding",e,t,n),aN("mode",e,t,n))];case"PadV2":case"Pad":return[bp(aN("x",e,t,n),aN("padding",e,t,n),aN("constantValue",e,t,n))];case"SpaceToBatchND":{const r=aN("blockShape",e,t,n),a=aN("paddings",e,t,n);return[Mp(aN("x",e,t,n),r,a)]}case"BatchToSpaceND":{const r=aN("blockShape",e,t,n),a=aN("crops",e,t,n);return[Il(aN("x",e,t,n),r,a)]}case"DepthToSpace":{const r=aN("blockSize",e,t,n),a=aN("dataFormat",e,t,n).toUpperCase();return[tc(aN("x",e,t,n),r,a)]}case"BroadcastTo":return[Rl(aN("x",e,t,n),aN("shape",e,t,n))];case"BroadcastArgs":return[Ol(aN("s0",e,t,n),aN("s1",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"hash_table":return(async(e,t,n,r)=>{switch(e.op){case"HashTable":case"HashTableV2":{const a=aN("keyDType",e,t,n),i=aN("valueDType",e,t,n),s=new eS(a,i);return r.addHashTable(e.name,s),[s.handle]}case"LookupTableImport":case"LookupTableImportV2":{const a=aN("tableHandle",e,t,n,r),i=aN("keys",e,t,n),s=aN("values",e,t,n),o=r.getHashTableById(a.id);return[await o.import(i,s)]}case"LookupTableFind":case"LookupTableFindV2":{const a=aN("tableHandle",e,t,n,r),i=aN("keys",e,t,n),s=aN("defaultValue",e,t,n),o=r.getHashTableById(a.id);return[await o.find(i,s)]}case"LookupTableSize":case"LookupTableSizeV2":{const a=aN("tableHandle",e,t,n,r);return[r.getHashTableById(a.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n,r);case"custom":const a=nN(e.op);if(a&&a.customExecutor)return a.customExecutor(new qN(e,t,n));throw TypeError(`Custom op ${e.op} is not registered.`);default:throw TypeError(`Unknown op '${e.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(e,t,n);return Ue(a)?a.then((e=>[].concat(e))):[].concat(a)}class nS{constructor(e={},t={},n={},r={}){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=r,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){const e=[];for(let t=0;t0===e.id&&0===e.iterationId?"":`${e.frameName}-${e.iterationId}`)).join("/"):""}enterFrame(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))}exitFrame(){if(!(this.contexts&&this.contexts.length>1))throw new Error("Cannot exit frame, the context is empty");this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift()}nextIteration(){if(!(this.contexts&&this.contexts.length>0))throw new Error("Cannot increase frame iteration, the context is empty");{this.contexts=this.contexts.slice(),this.lastId++;const e=Object.assign({},this.contexts[this.contexts.length-1]);e.iterationId+=1,e.id=this.lastId,this.contexts.splice(-1,1,e),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}}getWeight(e){return this.weightMap[e]}addTensorArray(e){this.tensorArrayMap[e.id]=e}getTensorArray(e){return this.tensorArrayMap[e]}addTensorList(e){this.tensorListMap[e.id]=e}getTensorList(e){return this.tensorListMap[e]}dispose(e){for(const t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(const t in this.tensorListMap)this.tensorListMap[t].clearAndClose(e)}}function rS(e,t,n,r){const a=new Set,i=[];let s=null,o=null;const u=new Set,l=Object.keys(e).map((e=>uN(e)[0]));let c=[];null!=r&&(c=r.map((e=>uN(e.name)[0])));const p=[...t];for(;p.length>0;){const e=p.pop();(oS(e)||uS(e)||lS(e))&&null==s&&(s=e,o=s.children.map((e=>e.name)).filter((e=>a.has(e)))),a.add(e.name),null==n[e.name]&&-1===l.indexOf(e.name)&&-1===c.indexOf(e.name)&&(0!==e.inputs.length?e.inputs.forEach((e=>{u.has(e.name)||(u.add(e.name),p.push(e))})):i.push(e.name))}return{inputs:e,outputs:t,usedNodes:a,missingInputs:i,dynamicNode:s,syncInputs:o}}const aS=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],iS=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],sS=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function oS(e){return aS.indexOf(e.op)>=0}function uS(e){return iS.indexOf(e.op)>=0}function lS(e){return sS.indexOf(e.op)>=0}class cS{constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this.intermediateTensors={},this.keepTensorForDebug=!1,this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,null!=e.functions&&Object.keys(e.functions).forEach((t=>{this._functionExecutorMap[t]=new cS(e.functions[t],this)}))}get weightIds(){return this.parent?this.parent.weightIds:this._weightIds}get functionExecutorMap(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap}get weightMap(){return this.parent?this.parent.weightMap:this._weightMap}set weightMap(e){const t=Object.keys(e).map((t=>e[t].map((e=>e.id))));this._weightIds=[].concat(...t),this._weightMap=e}set resourceManager(e){this._resourceManager=e}get inputs(){return this._inputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get outputs(){return this._outputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get inputNodes(){return this._inputs.map((e=>e.signatureKey||e.name))}get outputNodes(){return this._outputs.map((e=>{const t=e.signatureKey||e.name;return e.defaultOutput?`${t}:${e.defaultOutput}`:t}))}get functions(){return Object.keys(this._functions).reduce(((e,t)=>(e[t]=this._functions[t].signature,e)),{})}getCompilationKey(e,t){const n=e.map((e=>e.name)).sort(),r=t.map((e=>e.name)).sort();return n.join(this.SEPERATOR)+"--"+r.join(this.SEPERATOR)}compile(e,t){const n=rS(e,t,this.weightMap,this._initNodes),{missingInputs:r,dynamicNode:a,syncInputs:i}=n;if(null!=a)throw new Error(`This execution contains the node '${a.name}', which has the dynamic op '${a.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${i}]`);if(r.length>0){const n=t.map((e=>e.name)),a=Object.keys(e);throw new Error(`Cannot compute the outputs [${n}] from the provided inputs [${a}]. Missing the following inputs: [${r}]`)}return function(e,t,n){const{usedNodes:r,inputs:a}=n,i=[],s=Object.keys(a).map((e=>uN(e)[0])).map((t=>e.nodes[t])),o=e.initNodes;s.forEach((e=>{r.has(e.name)&&i.push(e)})),e.weights.forEach((e=>{r.has(e.name)&&i.push(e)})),null!=o&&o.forEach((e=>{r.has(e.name)&&i.push(e)}));const u=new Set,l=[];for(;i.length>0;){const e=i.pop();u.add(e.name),t[e.name]||l.push(e),e.children.forEach((e=>{!u.has(e.name)&&r.has(e.name)&&e.inputs.every((e=>u.has(e.name)))&&i.push(e)}))}return l}(this.graph,this.weightMap,n)}execute(e,t){e=this.mapInputs(e);const n=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);const r=n.map((e=>this.graph.nodes[uN(e)[0]])),a=t.map((e=>uN(e)[0]));let i=a.map((e=>this.graph.nodes[e]));this.resetIntermediateTensors(),0===i.length&&(i=this._outputs);const s=this.getCompilationKey(r,i);let o=this.compiledMap.get(s);null==o&&(o=this.compile(e,i),this.compiledMap.set(s,o));const u={},l={};return co((()=>{const n=new nS(this.weightMap,u,l,this.functionExecutorMap),r=Object.assign({},this.weightMap);Object.keys(e).forEach((t=>{const[n,a]=uN(t),i=[];i[a]=e[t],r[n]=i}));const i=this.getFrozenTensorIds(r),s={};for(let e=0;eiN(e,r,n)))}))}getFrozenTensorIds(e){const t=[].concat.apply([],Object.keys(e).map((t=>e[t])).map((e=>e.map((e=>e.id)))));return new Set(t)}checkTensorForDisposal(e,t,n,r,a,i,s){"control"!==t.category&&-1===i.indexOf(e)&&(n[e].forEach((e=>{null!=e&&(s[e.id]=(s[e.id]||0)+t.children.length)})),t.inputs.forEach((e=>{if("control"!==e.category){const i=function(e,t,n){return t[oN(e,n.currentContextId)]}(e.name,n,r);null!=i&&i.forEach((e=>{if(e&&!e.kept&&!a.has(e.id)){const n=s[e.id];if(1===n){if(this.keepTensorForDebug){const[n,a]=sN(t.name,r);this.intermediateTensors[n]||(this.intermediateTensors[n]=[]),this.intermediateTensors[n][a]=e}else e.dispose();delete s[e.id]}else null!=n&&s[e.id]--}}))}})))}async executeAsync(e,t){return this._executeAsync(e,t)}disposeIntermediateTensors(){this.intermediateTensors&&(Object.keys(this.intermediateTensors).forEach((e=>this.intermediateTensors[e].forEach((e=>e.dispose())))),this.disposeTensorsMap())}disposeTensorsMap(){this.tensorsMap&&Object.keys(this.tensorsMap).forEach((e=>{this.tensorsMap[e].forEach((e=>{!e||e.kept||e.isDisposed||this.keepIds.has(e.id)||e.dispose()}))}))}getIntermediateTensors(){return this.tensorsMap}resetIntermediateTensors(){for(const e in this.intermediateTensors)this.intermediateTensors[e].forEach((e=>e.dispose())),delete this.intermediateTensors[e]}async _executeAsync(e,t,n=!1,r={},a={}){n||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));try{this.keepTensorForDebug=Ve().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){console.warn(e.message)}this.resetIntermediateTensors();const i=new nS(this.weightMap,r,a,this.functionExecutorMap);this.tensorsMap=await this.executeWithControlFlow(e,i,t,n);const s=t.map((e=>iN(e,this.tensorsMap,i))),o=s.map((e=>e.id)),u=Object.keys(e).map((t=>e[t].id));return this.keepIds=new Set([...o,...u,...this.weightIds]),this.keepTensorForDebug||this.disposeTensorsMap(),null==this.parent&&i.dispose(this.keepIds),s}async executeFunctionAsync(e,t,n){const r=e.reduce(((e,t,n)=>(e[this.inputs[n].name]=t,e)),{});return this._executeAsync(r,this.outputNodes,!0,t,n)}async executeWithControlFlow(e,t,n,r){const a=Object.keys(e),i=a.map((e=>this.graph.nodes[uN(e)[0]])),s=n.map((e=>uN(e)[0]));let o=s.map((e=>this.graph.nodes[e]));0===o.length&&(o=this._outputs);const{usedNodes:u,missingInputs:l,dynamicNode:c,syncInputs:p}=rS(e,o,this.weightMap,this._initNodes),d=[...i,...this.graph.weights,...this._initNodes||[]].map((e=>({node:e,contexts:t.currentContext}))),h=Object.assign({},this.weightMap);Object.keys(e).forEach((t=>{const[n,r]=uN(t),a=[];a[r]=e[t],h[n]=a}));const f={},m=this.getFrozenTensorIds(h),g={};for(;d.length>0;){const e=this.processStack(i,d,t,h,g,m,s,f,u);await Promise.all(e)}null!=c||r||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");const y=o.filter((e=>!oS(e)&&!iN(e.name,h,t))).map((e=>e.name));if(y.length>0){let e="";throw null!=c&&(e=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${p}]`),new Error(`Cannot compute the outputs [${y}] from the provided inputs [${a}]. Consider providing the following inputs: [${l}]. ${e}`)}return h}processStack(e,t,n,r,a,i,s,o,u){const l=[];for(;t.length>0;){const e=t.pop();n.currentContext=e.contexts;let c="";if("Enter"===e.node.op&&aN("isConstant",e.node,r,n)&&([c]=sN(e.node.name,n)),null==r[e.node.name]){const p=tS(e.node,r,n,this._resourceManager);c||([c]=sN(e.node.name,n));const d=n.currentContext;Ue(p)?l.push(p.then((l=>(r[c]=l,n.currentContext=d,this.checkTensorForDisposal(c,e.node,r,n,i,s,o),this.processChildNodes(e.node,t,n,r,a,u),l)))):(r[c]=p,this.checkTensorForDisposal(c,e.node,r,n,i,s,o),this.processChildNodes(e.node,t,n,r,a,u))}else this.processChildNodes(e.node,t,n,r,a,u)}return l}processChildNodes(e,t,n,r,a,i){e.children.forEach((e=>{const[s]=sN(e.name,n);!a[s]&&i.has(e.name)&&("Merge"===e.op?e.inputNames.some((e=>!!iN(e,r,n)))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})):e.inputNames.every((e=>!!iN(e,r,n)))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})))}))}dispose(){Object.keys(this.weightMap).forEach((e=>this.weightMap[e].forEach((e=>e.dispose()))))}checkInputShapeAndType(e){Object.keys(e).forEach((t=>{const n=e[t],[r]=uN(t),a=this.graph.nodes[r];if(a.attrParams.shape&&a.attrParams.shape.value){const e=a.attrParams.shape.value,t=e.length===n.shape.length&&n.shape.every(((t,n)=>-1===e[n]||e[n]===t));ie(t,(()=>`The shape of dict['${a.name}'] provided in model.execute(dict) must be [${e}], but was [${n.shape}]`))}a.attrParams.dtype&&a.attrParams.dtype.value&&ie(n.dtype===a.attrParams.dtype.value,(()=>`The dtype of dict['${a.name}'] provided in model.execute(dict) must be ${a.attrParams.dtype.value}, but was ${n.dtype}`))}))}mapInputs(e){const t={};for(const n in e)null!=this._signature&&null!=this._signature.inputs&&null!=this._signature.inputs[n]?t[this._signature.inputs[n].name]=e[n]:t[n]=e[n];return t}checkInputs(e){const t=Object.keys(e).filter((e=>{const[t]=uN(e);return null==this.graph.nodes[t]}));if(t.length>0)throw new Error(`The dict provided in model.execute(dict) has keys: [${t}] that are not part of graph`)}mapOutputs(e){return e.map((e=>null!=this._signature&&null!=this._signature.outputs&&null!=this._signature.outputs[e]?this._signature.outputs[e].name:e),{})}checkOutputs(e){e.forEach((e=>{const[t]=uN(e);if(!this.graph.nodes[t])throw new Error(`The output '${e}' is not found in the graph`)}))}}class pS{constructor(e={},t={}){this.hashTableNameToHandle=e,this.hashTableMap=t}addHashTable(e,t){this.hashTableNameToHandle[e]=t.handle,this.hashTableMap[t.id]=t}getHashTableHandleByName(e){return this.hashTableNameToHandle[e]}getHashTableById(e){return this.hashTableMap[e]}dispose(){for(const e in this.hashTableMap)this.hashTableMap[e].clearAndClose(),delete this.hashTableMap[e];for(const e in this.hashTableNameToHandle)this.hashTableNameToHandle[e].dispose(),delete this.hashTableNameToHandle[e]}}class dS{constructor(e,t={}){this.modelUrl=e,this.loadOptions=t,this.version="n/a",null==t&&(this.loadOptions={}),this.resourceManager=new pS}get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}findIOHandler(){const e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=Ws(e,this.loadOptions);else{const t=Zi(e,this.loadOptions);if(0===t.length)t.push(Ws(e,this.loadOptions));else if(t.length>1)throw new Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`);this.handler=t[0]}}load(){if(this.findIOHandler(),null==this.handler.load)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const e=this.handler.load();return Ue(e)?e.then((e=>this.loadSync(e))):this.loadSync(e)}loadSync(e){this.artifacts=e;const t=this.artifacts.modelTopology;let n;n=null!=this.artifacts.userDefinedMetadata&&null!=this.artifacts.userDefinedMetadata.signature?this.artifacts.userDefinedMetadata.signature:this.artifacts.signature,this.signature=n,this.version=`${t.versions.producer}.${t.versions.minConsumer}`;const r=Yi(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new cS(EN.Instance.transformGraph(t,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),this.executor.resourceManager=this.resourceManager,null!=e.modelInitializer&&null!=e.modelInitializer.node){const t=EN.Instance.transformGraph(e.modelInitializer);this.initializer=new cS(t),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0}async save(e,t){if("string"==typeof e){const t=Xi(e);if(0===t.length)throw new Error(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new Error(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return e.save(this.artifacts)}predict(e,t){return this.execute(e,this.outputNodes)}normalizeInputs(e){if(!(e instanceof Qa||Array.isArray(e)))return e;if((e=Array.isArray(e)?e:[e]).length!==this.inputNodes.length)throw new Error(`Input tensor count mismatch,the graph model has ${this.inputNodes.length} placeholders, while there are ${e.length} input tensors.`);return this.inputNodes.reduce(((t,n,r)=>(t[n]=e[r],t)),{})}normalizeOutputs(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}execute(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=this.executor.execute(e,t);return n.length>1?n:n[0]}async executeAsync(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=await this.executor.executeAsync(e,t);return n.length>1?n:n[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(e){return Object.keys(e).reduce(((t,n)=>(t[n]=[e[n]],t)),{})}dispose(){this.executor.dispose(),this.initializer&&this.initializer.dispose(),this.resourceManager.dispose()}}async function hS(e,t={}){if(null==e)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");null==t&&(t={}),t.fromTFHub&&"string"==typeof e&&(e=function(e){return e.endsWith("/")||(e+="/"),`${e}model.json?tfjs-format=file`}(e));const n=new dS(e,t);return await n.load(),n}function fS(e){if(null==e)throw new Error("modelUrl in loadGraphModelSync() cannot be null. Please provide a url or an IOHandler that loads the model");if(!e.load)throw new Error(`modelUrl IO Handler ${e} has no load function`);const t=new dS(e);return t.load(),t}const mS="3.18.0";var gS,yS=n(6377);function bS(e,t,n=new Map,r=new Set){if(null==e)return null;if("function"==typeof Blob&&e instanceof Blob)return e.slice();if(r.has(e))throw new Error("Circular references are not supported.");if(n.has(e))return n.get(e);const a=t(e);if(a.recurse&&null!==a.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(a.recurse){if(MS(e)){const a=Array.isArray(e)?[]:{};r.add(e);for(const i in e){const s=bS(e[i],t,n,r);a[i]=s}return r.delete(e),e.__proto__&&(a.__proto__=e.__proto__),a}throw new Error(`Can't recurse into non-iterable type: ${e}`)}return n.set(e,a.value),a.value}function xS(e,t=_S){return vS(e,t)}function vS(e,t,n=new Set){const r=e[0];if(n.has(r))throw new Error("Circular references are not supported.");const a=t(e);if(a.recurse&&null!==a.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(a.recurse){if(MS(r)){const a=Array.isArray(r)?[]:{};n.add(r);for(const i in r){const r=vS(e.map((e=>e[i])),t,n);a[i]=r}return n.delete(r),a}throw new Error(`Can't recurse into non-iterable type: ${r}`)}return a.value}function _S(e){return null===e?null:MS(e[0])?{value:null,recurse:!0}:{value:e,recurse:!1}}async function wS(e,t){const n=new Map;bS(e,t,n);for(const e of Array.from(n.keys())){const t=n.get(e);if(Ue(t)){const r=await t;n.set(e,r)}}return bS(e,t,n)}function MS(e){let t=!1;if(Ve().get("IS_BROWSER"))t=e instanceof TextDecoder;else{const{StringDecoder:r}=n(4977);t=e instanceof r}return null!=e&&!ArrayBuffer.isView(e)&&(Array.isArray(e)||"object"==typeof e&&!(e instanceof Qa)&&!(e instanceof Promise)&&!t)}function NS(e){return e instanceof Qa?{value:e.clone(),recurse:!1}:MS(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}class SS{constructor(e){if(this.capacity=e,this.begin=0,this.end=0,null==e)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(e<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(e),this.doubledCapacity=2*e}wrap(e){for(;e<0;)e+=this.doubledCapacity;return e%this.doubledCapacity}get(e){if(e<0)throw new RangeError("Can't get item at a negative index.");return this.data[e%this.capacity]}set(e,t){if(e<0)throw new RangeError("Can't set item at a negative index.");this.data[e%this.capacity]=t}length(){let e=this.end-this.begin;return e<0&&(e=this.doubledCapacity+e),e}isFull(){return this.length()===this.capacity}isEmpty(){return 0===this.length()}push(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,e),this.end=this.wrap(this.end+1)}pushAll(e){for(const t of e)this.push(t)}pop(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);const e=this.get(this.end);return this.set(this.end,void 0),e}unshift(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,e)}shift(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const e=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),e}shuffleExcise(e){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const t=this.wrap(this.begin+e),n=this.get(t);return this.set(t,this.pop()),n}}class kS extends SS{constructor(){super(kS.INITIAL_CAPACITY)}isFull(){return!1}push(e){super.isFull()&&this.expand(),super.push(e)}unshift(e){super.isFull()&&this.expand(),super.unshift(e)}expand(){const e=2*this.capacity,t=new Array(e),n=this.length();for(let e=0;e!0===e))}rowMajorBatch(e,t=!0){return new OS(this,e,t)}columnMajorBatch(e,t=!0,n=_S){return this.rowMajorBatch(e,t).map((e=>xS(e,n)))}concatenate(e,t){return new HS(DS([this,e]),t)}take(e){return e<0||null==e?this:new $S(this,e)}skip(e){return e<0||null==e?this:new LS(this,e)}prefetch(e){return new US(this,e)}shuffle(e,t){return new qS(this,e,t)}serial(){return new AS(this)}}class ES extends IS{constructor(e){super(),this.items=e,this.trav=0}summary(){return`Array of ${this.items.length} items`}async next(){if(this.trav>=this.items.length)return{value:null,done:!0};const e=this.items[this.trav];return this.trav++,{value:(t=e,function(e,t){return bS(e,t)}(t,NS)),done:!1};var t}}class CS extends IS{constructor(e){super(),this.nextFn=e}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(e){throw e.message=`Error thrown while iterating through a dataset: ${e.message}`,e}}}class AS extends IS{constructor(e){super(),this.upstream=e,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Serial`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){return this.upstream.next()}}class LS extends IS{constructor(e,t){super(),this.upstream=e,this.maxCount=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Skip`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;this.count++ Take`}async next(){return this.count++>=this.maxCount?{value:null,done:!0}:this.upstream.next()}}class OS extends IS{constructor(e,t,n=!0){super(),this.upstream=e,this.batchSize=t,this.enableSmallLastBatch=n,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> RowMajorBatch`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){const e=[];for(;e.length0?{value:e,done:!1}:{value:null,done:!0};e.push(t.value)}return{value:e,done:!1}}}class RS extends IS{constructor(e,t){super(),this.upstream=e,this.predicate=t,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Filter`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;){const e=await this.upstream.next();if(e.done||this.predicate(e.value))return e;po(e.value)}}}class FS extends IS{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Map`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const t=hi(e.value),n=this.transform(e.value),r=hi(n);for(const e of t)di(e,r)||e.dispose();return{value:n,done:!1}}}class YS extends IS{constructor(e,t){super(),this.upstream=e,this.handler=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> handleErrors`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;)try{return await this.upstream.next()}catch(e){if(!this.handler(e))return{value:null,done:!0}}}}class zS extends IS{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> AsyncMap`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const t=hi(e.value),n=await this.transform(e.value),r=hi(n);for(const e of t)di(e,r)||e.dispose();return{value:n,done:!1}}}class BS extends IS{constructor(){super(),this.outputQueue=new kS,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;0===this.outputQueue.length();)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}}class PS extends BS{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Flatmap`}async pump(){const e=await this.upstream.next();if(e.done)return!1;const t=hi(e.value),n=this.transform(e.value),r=hi(n);this.outputQueue.pushAll(n);for(const e of t)di(e,r)||e.dispose();return!0}}class HS extends IS{constructor(e,t){super(),this.baseErrorHandler=t,this.lastRead=null,this.iterator=null,this.moreIterators=e}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(e){if(await e,null==this.iterator){const e=await this.moreIterators.next();if(e.done)return{value:null,done:!0};this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}const t=await this.iterator.next();return t.done?(this.iterator=null,this.readFromChain(e)):t}}!function(e){e[e.FAIL=0]="FAIL",e[e.SHORTEST=1]="SHORTEST",e[e.LONGEST=2]="LONGEST"}(gS||(gS={}));class jS extends IS{constructor(e,t=gS.FAIL){super(),this.iterators=e,this.mismatchMode=t,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(e){await e;let t=0,n=0;const r=await wS(this.iterators,(function(e){return e instanceof IS?{value:e.next().then((e=>(t++,e.done&&n++,e.value))),recurse:!1}:{value:null,recurse:!0}}));if(t===n)return{value:null,done:!0};if(n>0)switch(this.mismatchMode){case gS.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case gS.SHORTEST:return{value:null,done:!0};case gS.LONGEST:}return this.count++,{value:r,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class US extends IS{constructor(e,t){super(),this.upstream=e,this.bufferSize=t,this.buffer=new SS(t)}summary(){return`${this.upstream.summary()} -> Prefetch`}refill(){for(;!this.buffer.isFull();){const e=this.upstream.next();this.buffer.push(e)}}next(){return this.refill(),this.buffer.shift()}}class qS extends US{constructor(e,t,n){super(e,t),this.upstream=e,this.windowSize=t,this.upstreamExhausted=!1,this.random=yS.alea(n||Fa().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}randomInt(e){return Math.floor(this.random()*e)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){const e=this.chooseIndex(),t=await this.buffer.shuffleExcise(e);if(!t.done)return this.refill(),t;this.upstreamExhausted=!0}return{value:null,done:!0}}}class WS{constructor(){this.size=null}batch(e,t=!0){const n=this;let r;return ie(e>0,(()=>`batchSize needs to be positive, but it is\n ${e}`)),r=this.size===1/0||null==this.size?this.size:t?Math.ceil(this.size/e):Math.floor(this.size/e),VS((async()=>(await n.iterator()).columnMajorBatch(e,t,JS)),r)}concatenate(e){const t=this;let n;return n=this.size===1/0||e.size===1/0?1/0:null!=this.size&&null!=e.size?this.size+e.size:null,VS((async()=>(await t.iterator()).concatenate(await e.iterator())),n)}filter(e){const t=this;let n;return n=this.size===1/0?1/0:null,VS((async()=>(await t.iterator()).filter((t=>co((()=>e(t)))))),n)}async forEachAsync(e){return(await this.iterator()).forEachAsync(e)}map(e){const t=this;return VS((async()=>(await t.iterator()).map((t=>co((()=>e(t)))))),this.size)}mapAsync(e){const t=this;return VS((async()=>(await t.iterator()).mapAsync(e)),this.size)}prefetch(e){if(null==e)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");const t=this;return VS((async()=>(await t.iterator()).prefetch(e)),this.size)}repeat(e){const t=this;let n;return n=null!=this.size&&e>0?this.size*e:0===e?0:null!=this.size&&(void 0===e||e<0)?1/0:null,VS((async()=>{return n=TS((async()=>({value:await t.iterator(),done:!1}))).take(e),new HS(n,r);var n,r}),n)}skip(e){const t=this;let n;return n=null!=this.size&&e>=0&&this.size>=e?this.size-e:null!=this.size&&(this.size(await t.iterator()).skip(e)),n)}shuffle(e,t,n=!0){if(null==e||e<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);const r=this,a=yS.alea(t||Fa().toString());return VS((async()=>{let t=a.int32();return n&&(t+=a.int32()),(await r.iterator()).shuffle(e,t.toString())}),this.size)}take(e){const t=this;let n;return n=null!=this.size&&this.size>e?e:null!=this.size&&this.size<=e?this.size:null,VS((async()=>(await t.iterator()).take(e)),n)}async toArray(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}}function VS(e,t=null){return new class extends WS{constructor(){super(...arguments),this.size=t}async iterator(){return e()}}}function GS(e){return VS((async()=>DS(e)),e.length)}function KS(e){if(!MS(e))throw new Error("The argument to zip() must be an object or array.");let t;if(Array.isArray(e))for(let n=0;nfunction(e,t=gS.FAIL){return new jS(e,t)}(await wS(e,(e=>{if(e instanceof WS)return{value:e.iterator(),recurse:!1};if(MS(e))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})),gS.SHORTEST)),t)}function JS(e){if(null===e)return null;return null==(t=e[0])||null===(n=t)||"object"!=typeof n&&"function"!=typeof n||Array.isArray(t)||"object"==typeof t&&t instanceof Qa||ke(t)?{value:function(e){if(0===e.length)throw new Error("Can't make a batch of zero elements.");return e[0]instanceof Qa?cd(e):Oi(e)}(e),recurse:!1}:{value:null,recurse:!0};var t,n}WS.MAX_BUFFER_SIZE=1e4;class XS extends WS{constructor(e){super(),this.input=e}async iterator(){const e=(await this.input.iterator()).decodeUTF8().split("\n").map((e=>(e.endsWith("\r")&&(e=e.slice(0,-1)),e)));return e}}const ZS='"',QS=Symbol("out"),ek=Symbol("field"),tk=Symbol("quote"),nk=Symbol("quoteafterquote"),rk=Symbol("quoteinquote");class ak extends WS{constructor(e,t){super(),this.input=e,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new XS(e),t||(t={}),this.hasHeader=!1!==t.hasHeader,this.fullColumnNames=t.columnNames,this.columnConfigs=t.columnConfigs,this.configuredColumnsOnly=t.configuredColumnsOnly,t.delimWhitespace?(ie(null==t.delimiter,(()=>"Delimiter should not be provided when delimWhitespace is true.")),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=t.delimiter?t.delimiter:","}async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){const e=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!e)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&e&&ie(e.length===this.fullColumnNames.length,(()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+e.length.toString()+").")),this.fullColumnNames||(this.fullColumnNames=e);const t=this.fullColumnNames.reduce(((e,t)=>(e[t]=e[t]+1||1,e)),{}),n=Object.keys(t).filter((e=>t[e]>1));if(ie(0===n.length,(()=>"Duplicate column names found: "+n.toString())),this.columnConfigs)for(const e of Object.keys(this.columnConfigs))if(-1===this.fullColumnNames.indexOf(e))throw new Error('The key "'+e+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").");this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){const e=await this.base.iterator(),t=await e.next();if(t.done)throw new Error("No data was found for CSV parsing.");const n=t.value;return this.parseRow(n,!1)}return null}async iterator(){this.columnNamesValidated||await this.setColumnNames();let e=await this.base.iterator();return this.hasHeader&&(e=e.skip(1)),e.map((e=>this.makeDataElement(e)))}makeDataElement(e){const t=this.parseRow(e),n={},r={};for(let a=0;a14||!Number.isInteger(t))throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`);if(this.numFrames=e.numFramesPerSpectrogram||43,this.sampleRateHz=e.sampleRateHz,this.columnTruncateLength=e.columnTruncateLength||this.fftSize,this.audioTrackConstraints=e.audioTrackConstraints,this.smoothingTimeConstant=e.smoothingTimeConstant||0,this.includeSpectrogram=!1!==e.includeSpectrogram,this.includeWaveform=!0===e.includeWaveform,!this.includeSpectrogram&&!this.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(e={}){if(!Ve().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");const t=new ik(e);return await t.start(),t}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})}catch(e){throw new Error(`Error thrown while initializing video stream: ${e.message}`)}if(!this.stream)throw new Error("Could not obtain audio from microphone.");const e=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new e,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`)}else this.sampleRateHz=this.audioContext.sampleRate;const t=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,t.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){if(this.isClosed)return{value:null,done:!0};let e,t;const n=await this.getAudioData();if(this.includeSpectrogram){const t=this.flattenQueue(n.freqDataQueue);e=this.getTensorFromAudioDataArray(t,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){const e=this.flattenQueue(n.timeDataQueue);t=this.getTensorFromAudioDataArray(e,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:e,waveform:t},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){const e=[],t=[];let n=0;return new Promise((r=>{const a=setInterval((()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&r({freqDataQueue:e,timeDataQueue:t}),e.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),t.push(this.timeData.slice())),++n===this.numFrames&&(clearInterval(a),r({freqDataQueue:e,timeDataQueue:t}))}),this.fftSize/this.sampleRateHz*1e3)}))}stop(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw new Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(e){const t=e[0].length,n=new Float32Array(e.length*t);return e.forEach(((e,r)=>n.set(e,r*t))),n}getTensorFromAudioDataArray(e,t){const n=new Float32Array(le(t));return n.set(e,n.length-e.length),Oi(n,t)}}class sk extends IS{constructor(e,t){if(super(),this.webcamVideoElement=e,this.webcamConfig=t,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=fd([0],"int32"),this.webcamConfig.centerCrop){const e=1*this.webcamConfig.resizeWidth/this.webcamVideoElement.width,t=1*this.webcamConfig.resizeHeight/this.webcamVideoElement.height,n=(1-e)/2,r=(1-t)/2,a=n+e,i=t+r;this.cropBox=md([r,n,i,a],[1,4])}else this.cropBox=md([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(e,t={}){if(!Ve().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!e){if(e=document.createElement("video"),!t.resizeWidth||!t.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");e.width=t.resizeWidth,e.height=t.resizeHeight}const n=new sk(e,t);return await n.start(),n}async start(){this.webcamConfig.facingMode&&ie("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(()=>`Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`));try{this.stream=await navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})}catch(e){throw e.message=`Error thrown while initializing video stream: ${e.message}`,e}if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(e){console.log(e),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise((e=>{this.webcamVideoElement.onloadedmetadata=()=>{e()}}))}async next(){if(this.isClosed)return{value:null,done:!0};let e;try{e=Fo(this.webcamVideoElement)}catch(e){throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(e)}`)}if(!this.resize)return{value:e,done:!1};try{return{value:this.cropAndResizeFrame(e),done:!1}}catch(e){throw new Error(`Error thrown cropping the video: ${e.message}`)}finally{e.dispose()}}needToResize(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)}cropAndResizeFrame(e){return co((()=>{const t=Dc(Cs(e,"float32"),0);let n;n=Ph.cropAndResize(t,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");const r=n.shape;return _l(n,r.slice(1))}))}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach((e=>e.stop()));try{this.webcamVideoElement.srcObject=null}catch(e){console.log(e),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}}class ok{}class uk extends IS{split(e){return new lk(this,e)}}class lk extends uk{constructor(e,t){super(),this.upstream=e,this.impl=new ck(e,t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class ck extends BS{constructor(e,t){super(),this.upstream=e,this.separator=t,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){const e=await this.upstream.next();if(e.done)return""!==this.carryover&&(this.outputQueue.push(this.carryover),this.carryover="",!0);const t=e.value.split(this.separator);t[0]=this.carryover+t[0];for(const e of t.slice(0,-1))this.outputQueue.push(e);return this.carryover=t[t.length-1],!0}}class pk extends IS{decodeUTF8(){return new dk(this)}}class dk extends uk{constructor(e){super(),this.upstream=e,this.impl=new hk(e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class hk extends BS{constructor(e){if(super(),this.upstream=e,Ve().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{const{StringDecoder:e}=n(1601);this.decoder=new e("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){const e=await this.upstream.next();let t,n;return!e.done&&(t=e.value,n=Ve().get("IS_BROWSER")?this.decoder.decode(t,{stream:!0}):this.decoder.write(Buffer.from(t.buffer)),this.outputQueue.push(n),!0)}}class fk extends pk{constructor(e,t={}){super(),this.file=e,this.options=t,ie(e instanceof Uint8Array||!!Ve().get("IS_BROWSER")&&(e instanceof File||e instanceof Blob),(()=>"FileChunkIterator only supports File, Blob and Uint8Array right now.")),this.offset=t.offset||0,this.chunkSize=t.chunkSize||1048576}summary(){return`FileChunks ${this.file}`}async next(){if(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))return{value:null,done:!0};const e=new Promise(((e,t)=>{const n=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)e(new Uint8Array(this.file.slice(this.offset,n)));else{const r=new FileReader;r.onload=n=>{let a=r.result;if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),!(a instanceof Uint8Array))return t(new TypeError("FileReader returned unknown type."));e(a)},r.onabort=e=>t(new Error("Aborted")),r.onerror=e=>t(new Error(e.type));const a=this.file.slice(this.offset,n);r.readAsArrayBuffer(a)}this.offset=n}));return{value:await e,done:!1}}}function mk(e){return"string"==typeof e&&"file://"===e.slice(0,7)}class gk extends ok{constructor(e,t={}){super(),this.input=e,this.options=t}async iterator(){if(mk(this.input)&&Ve().get("IS_NODE")){const e=n(7792);this.input=e.readFileSync(this.input.slice(7))}return new fk(this.input,this.options)}}class yk extends ok{constructor(e,t={}){super(),this.url=e,this.fileOptions=t}async iterator(){return mk(this.url)?new gk(this.url,this.fileOptions).iterator():async function(e,t={},n){let r,a;var i;"string"==typeof e?r=e:(r=e.url,a={method:(i=e).method,headers:i.headers,body:i.body,mode:i.mode,credentials:i.credentials,cache:i.cache,redirect:i.redirect,referrer:i.referrer,integrity:i.integrity});const s=await(n||Ya)(r,a);if(s.ok){const e=new Uint8Array(await s.arrayBuffer());return new fk(e,t)}throw new Error(s.statusText)}(this.url,this.fileOptions)}}function bk(e,t={}){return new ak(new yk(e),t)}function xk(e){const t=TS(e);return VS((async()=>t))}function vk(e){return VS((async()=>{const t=await e();return TS((()=>t.next()))}))}async function _k(e,t){return sk.create(e,t)}async function wk(e){return ik.create(e)}const Mk="3.18.0";function Nk(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&ie("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the CPU backend.`))}))}const Sk=kd;class kk extends K{constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new G(this,oo())}nextDataId(){return kk.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,Ve().get("IS_NODE")&&ua("\n============================\nHi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. \n============================"));const r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:n,refCount:1}),r}makeTensorInfo(e,t,n){let r;if("string"===t&&null!=n&&n.length>0&&Ie(n[0])){const a=n.map((e=>za(e)));r=this.write(a,e,t)}else r=this.write(n,e,t);return{dataId:r,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){this.data.get(e).refCount++}decRef(e){this.data.has(e)&&this.data.get(e).refCount--}move(e,t,n,r,a){this.data.set(e,{values:t,dtype:r,refCount:a})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:t,complexTensorInfos:n}=this.data.get(e);return"complex64"===t?ff(this.readSync(n.real.dataId),this.readSync(n.imag.dataId)):this.data.get(e).values}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map((e=>Ba(e)));return Es(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return Es(e.shape,e.dtype,t)}makeOutput(e,t,n){return oo().makeTensorFromTensorInfo(this.makeTensorInfo(t,n,e),this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;const{complexTensorInfos:n}=this.data.get(e);null!=n&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const t=Fa();return e(),{kernelMs:Fa()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){Nk([e],"where");const t=this.readSync(e.dataId);return Sk(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}function Dk(e,t,n){return({inputs:r,attrs:a,backend:i})=>{const{x:s}=r;if(Nk(s,e),"string"===s.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const o=i,u=o.data.get(s.dataId).values,l=le(s.shape),c=n||s.dtype,p=we(c,l);for(let e=0;e{const{x:s}=r;if(Nk(s,e),"string"===s.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const o=i,u=o.data.get(s.dataId).values,l=n||s.dtype,c=t(u,l,a);return o.makeTensorInfo(s.shape,l,c)}}kk.nextDataId=0,_o("cpu",(()=>new kk),1);const Ik=Dk(Kt,(e=>e>=0?e:Math.exp(e)-1)),Ek={kernelName:Kt,backendName:"cpu",kernelFunc:Ik};function Ck(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const Ak={kernelName:hn,backendName:"cpu",kernelFunc:Ck};function Lk(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{alpha:i}=r;Nk([a],"leakyRelu");const s=le(a.shape),o=n.data.get(a.dataId).values,u=_e("float32",s);for(let e=0;e{const s=Co(t,n),o=s.length,u=Oe(s),l=_e(i,le(s)),c=t.length,p=n.length,d=Oe(t),h=Oe(n),f=Io(t,s),m=Io(n,s);if(f.length+m.length===0)for(let t=0;ti[e]=0));const s=He(i,c,d),g=n.slice(-p);m.forEach((e=>g[e]=0));const y=He(g,p,h);l[t]=e(r[s],a[y])}return[l,s]}}const Rk=Ok(((e,t)=>e<0?t*e:e));function Fk(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t;Nk([r,a],"prelu");const i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,[o,u]=Rk(r.shape,a.shape,i,s,"float32");return n.makeTensorInfo(u,"float32",o)}const Yk={kernelName:rr,backendName:"cpu",kernelFunc:Fk},zk=Dk(ur,(e=>Math.max(0,e))),Bk={kernelName:ur,backendName:"cpu",kernelFunc:zk},Pk=Dk(fr,(e=>Math.min(Math.max(0,e),6))),Hk={kernelName:fr,backendName:"cpu",kernelFunc:Pk};function jk(e){return(t,n,r)=>{const a=_e(n,t.length);for(let n=0;n1/(1+Math.exp(-e)))),qk=Dk(kr,(e=>1/(1+Math.exp(-e)))),Wk={kernelName:kr,backendName:"cpu",kernelFunc:qk};function Vk(e,t,n,r,a){if("linear"===n)return Ck({inputs:{x:t},backend:e});if("relu"===n)return zk({inputs:{x:t},backend:e});if("elu"===n)return Ik({inputs:{x:t},backend:e});if("relu6"===n)return Pk({inputs:{x:t},backend:e});if("prelu"===n)return Fk({inputs:{x:t,alpha:r},backend:e});if("leakyrelu"===n)return Lk({inputs:{x:t},backend:e,attrs:{alpha:a}});if("sigmoid"===n)return qk({inputs:{x:t},backend:e});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}function Gk(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,o=n.makeTensorInfo(r.shape,"complex64");return n.data.get(o.dataId).complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",i),imag:n.makeTensorInfo(a.shape,"float32",s)},o}const Kk={kernelName:Nt,backendName:"cpu",kernelFunc:Gk};function Jk(e,t,n="float32"){if("complex64"===n)return Gk({inputs:{real:Jk(e,t,"float32"),imag:Jk(e,t,"float32")},backend:e});const r=ze(le(t),n);return e.makeTensorInfo(t,n,r)}function Xk(e){const{inputs:t,backend:n}=e,{input:r}=t,a=n.data.get(r.dataId).complexTensorInfos.real,i=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,i)}const Zk={kernelName:sr,backendName:"cpu",kernelFunc:Xk};function Qk(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dtype:i}=r;if("complex64"===i){if("complex64"===a.dtype)return Ck({inputs:{x:a},backend:n});const e=Jk(n,a.shape,a.dtype),t=Qk({inputs:{x:a},backend:n,attrs:{dtype:"float32"}}),r=Gk({inputs:{real:t,imag:e},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),r}if("complex64"===a.dtype){const e=Xk({inputs:{input:a},backend:n}),t=Qk({inputs:{x:e},backend:n,attrs:{dtype:i}});return n.disposeIntermediateTensorInfo(e),t}if(!Se(a.dtype,i)){const e=Ck({inputs:{x:a},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:i}}if("int32"===i){const e=n.data.get(a.dataId).values,t=Int32Array.from(e);return n.makeTensorInfo(a.shape,"int32",t)}if("bool"===i){const e=n.data.get(a.dataId).values,t=Ra([0],a.dtype),[r,i]=Ok(((e,t)=>e!==t?1:0))(a.shape,[],e,t,"bool");return n.makeTensorInfo(i,"bool",r)}throw new Error(`Error in Cast: failed to cast ${a.dtype} to ${i}`)}const eD={kernelName:_t,backendName:"cpu",kernelFunc:Qk};function tD(e,t,n,r){return null==n?({inputs:n,backend:a})=>{const{a:i,b:s}=n,o=a;Nk([i,s],e);const u=o.data.get(i.dataId).values,l=o.data.get(s.dataId).values,c="string"===i.dtype?qf(u):u,p="string"===i.dtype?qf(l):l,d=r||i.dtype,[h,f]=t(i.shape,s.shape,c,p,d);return o.makeTensorInfo(f,d,h)}:({inputs:e,backend:a})=>{const{a:i,b:s}=e,o=a;if("complex64"===i.dtype||"complex64"===s.dtype){const e=Qk({inputs:{x:i},backend:o,attrs:{dtype:"complex64"}}),t=o.data.get(e.dataId),r=t.complexTensorInfos.real,a=t.complexTensorInfos.imag,u=o.data.get(r.dataId).values,l=o.data.get(a.dataId).values,c=Qk({inputs:{x:s},backend:o,attrs:{dtype:"complex64"}}),p=o.data.get(c.dataId),d=p.complexTensorInfos.real,h=p.complexTensorInfos.imag,f=o.data.get(d.dataId).values,m=o.data.get(h.dataId).values,[g,y,b]=n(i.shape,s.shape,u,l,f,m),x=o.makeTensorInfo(b,"float32",g),v=o.makeTensorInfo(b,"float32",y),_=Gk({inputs:{real:x,imag:v},backend:o});return o.disposeIntermediateTensorInfo(e),o.disposeIntermediateTensorInfo(c),o.disposeIntermediateTensorInfo(x),o.disposeIntermediateTensorInfo(v),_}{const e=o.data.get(i.dataId).values,n=o.data.get(s.dataId).values,a=r||i.dtype,[u,l]=t(i.shape,s.shape,e,n,a);return o.makeTensorInfo(l,a,u)}}}function nD(e){return(t,n,r,a,i,s)=>{const o=Co(t,n),u=le(o),l=o.length,c=Oe(o),p=_e("float32",u),d=_e("float32",u),h=Io(t,o),f=Io(n,o),m=ff(r,a),g=ff(i,s),y=t.length,b=Oe(t),x=n.length,v=Oe(n);if(h.length+f.length===0)for(let t=0;tr[e]=0));const a=He(r,y,b),i=n.slice(-x);f.forEach((e=>i[e]=0));const s=He(i,x,v),o=e(m[2*a],m[2*a+1],g[2*s],g[2*s+1]);p[t]=o.real,d[t]=o.imag}return[p,d,o]}}const rD=Ok(((e,t)=>e+t)),aD=nD(((e,t,n,r)=>({real:e+n,imag:t+r}))),iD=tD(tt,rD,aD),sD={kernelName:tt,backendName:"cpu",kernelFunc:iD};function oD(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{shape:i}=r,s=le(a.shape),o=be(i,s),u=le(o);ie(s===u,(()=>`The new shape (${o}) has ${u} elements and the old shape (${a.shape}) has ${s} elements. The new shape and old shape must have the same number of elements.`)),n.incRef(a.dataId);const l=n.data.get(a.dataId);if(null!=l.complexTensorInfos){const e=l.complexTensorInfos.real,t=l.complexTensorInfos.imag;e.shape=o,t.shape=o}return{dataId:a.dataId,shape:o,dtype:a.dtype}}const uD={kernelName:lr,backendName:"cpu",kernelFunc:oD};function lD(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i}=t,{transposeA:s,transposeB:o}=r;Nk([a,i],"matMul");const u=a.shape.length,l=i.shape.length,c=s?a.shape[u-2]:a.shape[u-1],p=o?i.shape[l-1]:i.shape[l-2],d=s?a.shape[u-1]:a.shape[u-2],h=o?i.shape[l-2]:i.shape[l-1],f=a.shape.slice(0,-2),m=i.shape.slice(0,-2),g=le(f),y=le(m),b=Co(a.shape.slice(0,-2),i.shape.slice(0,-2)).concat([d,h]);ie(c===p,(()=>`Error in matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${a.shape} and ${i.shape} and transposeA=${s} and transposeB=${o} must match.`));const x=o?[y,h,p]:[y,p,h],v=oD({inputs:{x:a},backend:n,attrs:{shape:s?[g,c,d]:[g,d,c]}}),_=oD({inputs:{x:i},backend:n,attrs:{shape:x}}),w=s?v.shape[1]:v.shape[2],M=s?v.shape[2]:v.shape[1],N=o?_.shape[1]:_.shape[2],S=Math.max(g,y),k=n.data.get(v.dataId).values,D=n.data.get(_.dataId).values,T=Oe(v.shape),I=Oe(_.shape),[E,C,A]=s?[T[0],1,T[1]]:[T[0],T[1],1],[L,$,O]=o?[1,I[1],I[0]]:[I[1],1,I[0]],R=M*N,F=Es([S,M,N],v.dtype),Y=F.values,z=n.blockSize;for(let e=0;e{const{x:t}=e.inputs,n=e.backend;Nk(t,"abs");let r=new Float32Array(le(t.shape));return r=dD(n.data.get(t.dataId).values),n.makeOutput(r,t.shape,t.dtype)}},fD=Dk(Qe,(e=>Math.acos(e))),mD={kernelName:Qe,backendName:"cpu",kernelFunc:fD},gD=Dk(et,(e=>Math.acosh(e))),yD={kernelName:et,backendName:"cpu",kernelFunc:gD},bD={kernelName:nt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,r=t;Nk(t,"addN");const a=r.map((e=>n.data.get(e.dataId).values)),i=Es(r[0].shape,r[0].dtype),s=i.values;for(let e=0;en&&(n=a,r=e)}d[e]=r}return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(c,"int32",d)}},SD={kernelName:st,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;Nk(a,"argMin");let s=xe(i,a.shape);const o=yc(s,a.shape.length);let u=a;const l=[];null!=o&&(u=vD({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=xc(s.length,u.shape.length)),s=[s[0]],gc("argMin",s,u.shape.length);const[c,p]=fc(u.shape,s),d=ze(le(c),"int32"),h=le(p),f=n.data.get(u.dataId).values;for(let e=0;en.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(c,"int32",d)}},kD=Dk(ot,(e=>Math.asin(e))),DD={kernelName:ot,backendName:"cpu",kernelFunc:kD},TD=Dk(ut,(e=>Math.asinh(e))),ID={kernelName:ut,backendName:"cpu",kernelFunc:TD},ED=Dk(lt,(e=>Math.atan(e))),CD={kernelName:lt,backendName:"cpu",kernelFunc:ED},AD=Ok(((e,t)=>Math.atan2(e,t))),LD=tD(pt,AD),$D={kernelName:pt,backendName:"cpu",kernelFunc:LD},OD=Dk(ct,(e=>Math.atanh(e))),RD={kernelName:ct,backendName:"cpu",kernelFunc:OD};function FD(e,t,n,r,a,i){const s=a.strideHeight,o=a.strideWidth,u=a.dilationHeight,l=a.dilationWidth,c=a.effectiveFilterHeight,p=a.effectiveFilterWidth,d=a.padInfo.top,h=a.padInfo.left,f="max"===i?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=Es(a.outShape,n),g=m.values,y=a.outShape[1]*a.outShape[2]*a.outShape[3],b=a.outShape[2]*a.outShape[3],x=a.outShape[3];for(let t=0;ty?y=s:"avg"===i&&(b+=s,v++)}if(isNaN(y))break}g[M+n*x+t]="avg"===i?b/v:y}}}return m}function YD(e,t,n,r,a=!1,i=!1){const s=Es(r.outShape,"int32"),o=r.strideHeight,u=r.strideWidth,l=r.dilationHeight,c=r.dilationWidth,p=r.effectiveFilterHeight,d=r.effectiveFilterWidth,h=r.padInfo.top,f=r.padInfo.left,m=Es(t,n,e);for(let e=0;ev&&(v=l,_=a?i?((e*r.inHeight+n)*r.inWidth+o)*r.inChannels+t:(n*r.inWidth+o)*r.inChannels+t:s*d+u)}}s.set(_,e,n,o,t)}}return s}function zD(e,t,n,r,a,i){const s=a.strideDepth,o=a.strideHeight,u=a.strideWidth,l=a.dilationDepth,c=a.dilationHeight,p=a.dilationWidth,d=a.effectiveFilterDepth,h=a.effectiveFilterHeight,f=a.effectiveFilterWidth,m=a.padInfo.front,g=a.padInfo.top,y=a.padInfo.left,b="max"===i?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,x=Es(a.outShape,n),v=x.values,_=a.outShape[1]*a.outShape[2]*a.outShape[3]*a.outShape[4],w=a.outShape[2]*a.outShape[3]*a.outShape[4],M=a.outShape[3]*a.outShape[4],N=a.outShape[4];for(let t=0;tw?w=a:"avg"===i&&(M+=a,S++),isNaN(w))break}if(isNaN(w))break}if(isNaN(w))break}v[g+t]="avg"===i?M/S:w}}}}return x}const BD={kernelName:dt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;Nk(a,"avgPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;ie(bl(s,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=ul(a.shape,i,s,1,o,u);let c;if(1===l.filterWidth&&1===l.filterHeight&&pe(l.inShape,l.outShape))c=Ck({inputs:{x:a},backend:n});else{const e=n.data.get(a.dataId).values,t=Oe(a.shape),r=FD(e,a.shape,a.dtype,t,l,"avg");c=n.makeTensorInfo(l.outShape,a.dtype,r.values)}return c}},PD={kernelName:ft,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u,dataFormat:l}=r;Nk(a,"avgPool3d");const c=ll(a.shape,i,s,1,o,u,l),p=zD(n.data.get(a.dataId).values,a.shape,a.dtype,Oe(a.shape),c,"avg");return n.makeTensorInfo(p.shape,"float32",p.values)}},HD={kernelName:mt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,{filterSize:s,strides:o,pad:u,dimRoundingMode:l}=r;Nk([a,i],"avgPool3DGrad");const c=ll(i.shape,s,o,1,u,l),p=c.strideDepth,d=c.strideHeight,h=c.strideWidth,f=c.filterDepth,m=c.filterHeight,g=c.filterWidth,y=c.dilationDepth,b=c.dilationHeight,x=c.dilationWidth,v=c.effectiveFilterDepth,_=c.effectiveFilterHeight,w=c.effectiveFilterWidth,M=v-1-c.padInfo.front,N=w-1-c.padInfo.left,S=_-1-c.padInfo.top,k=Es(i.shape,"float32"),D=1/(f*m*g),T=n.bufferSync(a);for(let e=0;e=c.outDepth||Math.floor(r)!==r))for(let n=0;n<_;n+=b){const a=(s+n)/d;if(!(a<0||a>=c.outHeight||Math.floor(a)!==a))for(let n=0;n=c.outWidth||Math.floor(i)!==i||(u+=T.get(e,r,a,i,t))}}}k.set(u*D,e,n,r,a,t)}return n.makeTensorInfo(k.shape,k.dtype,k.values)}},jD={kernelName:ht,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i;Nk([a,i],"avgPoolGrad");const{filterSize:o,strides:u,pad:l}=r,c=ul(s.shape,o,u,1,l),p=c.strideHeight,d=c.strideWidth,h=c.filterHeight,f=c.filterWidth,m=c.dilationHeight,g=c.dilationWidth,y=c.effectiveFilterHeight,b=c.effectiveFilterWidth,x=b-1-c.padInfo.left,v=y-1-c.padInfo.top,_=Es(s.shape,"float32"),w=1/(h*f),M=n.data.get(a.dataId).values,N=Es(a.shape,"float32",M);for(let e=0;e=c.outHeight||Math.floor(r)!==r))for(let n=0;n=c.outWidth||Math.floor(a)!==a||(s+=N.get(e,r,a,t))}}_.set(s*w,e,n,r,t)}return n.makeTensorInfo(_.shape,_.dtype,_.values)}},UD={kernelName:un,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,scale:i,offset:s,mean:o,variance:u}=t;ie(o.shape.length===u.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),ie(null==s||o.shape.length===s.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),ie(null==i||o.shape.length===i.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks.")),Nk([a,o,u,i,s],"batchNorm");let{varianceEpsilon:l}=r;null==l&&(l=.001);const c=n.data.get(a.dataId).values,p=n.data.get(o.dataId).values,d=n.data.get(u.dataId).values,h=i?n.data.get(i.dataId).values:new Float32Array([1]),f=s?n.data.get(s.dataId).values:new Float32Array([0]),m=new Float32Array(c.length),g=f.length,y=h.length,b=d.length,x=p.length;let v=0,_=0,w=0,M=0;for(let e=0;e=g&&(v=0),_>=x&&(_=0),w>=y&&(w=0),M>=b&&(M=0);return n.makeTensorInfo(a.shape,a.dtype,m)}};function qD(e,t,n,r,a){const i=eu(r,t,n),s=le(n),o=Oe(r);if(i){const n=tu(t,o);return"string"===a?e.slice(n,n+s):e.subarray(n,n+s)}const u=Es(r,a,"string"===a?qf(e):e),l=Es(n,a);for(let e=0;ee+t[n]));l.set(u.get(...r),...n)}return"string"===a?Wf(l.values):l.values}function WD(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,size:s}=r;Nk(a,"slice");const[o,u]=nu(a,i,s);Ho(a,o,u);const l=qD(n.data.get(a.dataId).values,o,u,a.shape,a.dtype);return n.makeTensorInfo(u,a.dtype,l)}const VD={kernelName:wr,backendName:"cpu",kernelFunc:WD},GD={kernelName:yt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,crops:s}=r;Nk([a],"batchToSpaceND");const o=i.reduce(((e,t)=>e*t)),u=ef(a.shape,i,o),l=tf(u.length,i.length),c=nf(a.shape,i,o),p=rf(s,i.length),d=af(c,s,i.length),h=oD({inputs:{x:a},backend:n,attrs:{shape:u}}),f=vD({inputs:{x:h},backend:n,attrs:{perm:l}}),m=oD({inputs:{x:f},backend:n,attrs:{shape:c}}),g=WD({inputs:{x:m},backend:n,attrs:{begin:p,size:d}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}};function KD(e,t,n,r,a){const i=le(r),s=ze(a,n);for(let n=0;n=a||(s[r]+=i>0?t[n]:1)}return s}function JD(e,t,n,r=!1){const a=e.shape[0],i=e.shape[1],s=Es([a,n],t.dtype);for(let o=0;o=n||(r?s.set(1,o,i):t.size>0?s.set(s.get(o,i)+t.get(o,a),o,i):s.set(s.get(o,i)+1,o,i))}return s}const XD={kernelName:bt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:i}=t,{size:s}=r,o=KD(n.data.get(a.dataId).values,n.data.get(i.dataId).values,i.dtype,i.shape,s);return n.makeTensorInfo([s],i.dtype,o)}},ZD={kernelName:vt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{s0:r,s1:a}=t,i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,o=Co(Array.from(i),Array.from(s));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}},QD=jk((e=>Math.ceil(e))),eT=Tk(wt,QD),tT={kernelName:wt,backendName:"cpu",kernelFunc:eT},nT=Dk(Mt,((e,t)=>{const n=t;return e>n.clipValueMax?n.clipValueMax:e{const{x:t}=e.inputs,n=e.backend,r=new Float32Array(le(t.shape)),a=n.data.get(t.dataId),i=a.complexTensorInfos.real,s=a.complexTensorInfos.imag,o=n.data.get(i.dataId).values,u=n.data.get(s.dataId).values;for(let e=0;e{const n=le(e.shape);a.set(e.vals,t),t+=n}))}else{let r=0;e.forEach((e=>{const i="string"===n?qf(e.vals):e.vals;let s=0;for(let n=0;ne.shape)),i);if(0===le(s))return n.makeTensorInfo(s,t[0].dtype,[]);const o=t.filter((e=>le(e.shape)>0));if(1===o.length)return Ck({inputs:{x:o[0]},backend:n});if(Kh(o.map((e=>e.shape)),i),"complex64"===o[0].dtype){const e=o.map((e=>Xk({inputs:{input:e},backend:n}))),t=o.map((e=>sT({inputs:{input:e},backend:n}))),r=uT({inputs:e,backend:n,attrs:{axis:i}}),a=uT({inputs:t,backend:n,attrs:{axis:i}}),s=Gk({inputs:{real:r,imag:a},backend:n});return e.forEach((e=>n.disposeIntermediateTensorInfo(e))),t.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),s}const u=o.map((e=>{const t=le(e.shape.slice(i));return oD({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),l=u.map((e=>({vals:n.data.get(e.dataId).values,shape:e.shape})));s=Jh(u.map((e=>e.shape)),1);const c=1===u[0].shape[0],p=iT(l,s,t[0].dtype,c),d=Jh(o.map((e=>e.shape)),i),h=n.makeTensorInfo(d,t[0].dtype,p);return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),h}const lT={kernelName:kt,backendName:"cpu",kernelFunc:uT};function cT(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dataFormat:u,dilations:l,dimRoundingMode:c}=r;Nk([a,i],"conv2d");const p=xl(u),d=cl(a.shape,i.shape,s,l,o,c,!1,p),h=d.filterHeight,f=d.filterWidth,m=d.dilationHeight,g=d.dilationWidth,y=d.padInfo.left,b=d.padInfo.top,x="channelsLast"===d.dataFormat,v=new Ka(d.outShape,a.dtype),_=Oe(a.shape),w=Oe(i.shape),M=_[0],N=x?_[1]:_[2],S=x?_[2]:1,k=x?1:_[1],D=v.strides[0],T=x?v.strides[1]:v.strides[2],I=x?v.strides[2]:1,E=x?1:v.strides[1],C=n.data.get(a.dataId).values,A=n.data.get(i.dataId).values,L=v.values;for(let e=0;e=d.inHeight)continue;const i=e*w[0],s=t+n*N;for(let e=0;e=d.inWidth)continue;const a=s+r*S;let o=i+e*w[1];for(let e=0;e=l.inDepth)continue;const i=e*S[0],s=t+n*N[1];for(let e=0;e=l.inHeight)continue;const a=i+e*S[1],o=s+r*N[2];for(let e=0;e=l.inWidth)continue;const i=a+e*S[2],s=o+t*l.inChannels;let u=i;for(let e=0;eMath.cos(e))),bT={kernelName:Lt,backendName:"cpu",kernelFunc:yT},xT=Dk($t,(e=>Math.cosh(e))),vT={kernelName:$t,backendName:"cpu",kernelFunc:xT},_T={kernelName:Ft,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:i,boxInd:s}=t,{cropSize:o,method:u,extrapolationValue:l}=r,[c,p,d,h]=a.shape,f=i.shape[0],[m,g]=o,y=Es([f,m,g,h],"float32"),b=n.data.get(i.dataId).values,x=n.data.get(s.dataId).values,v=n.data.get(a.dataId).values,_=Oe(a.shape),w=Oe(y.shape);for(let e=0;e=c)continue;const o=m>1?(a-n)*(p-1)/(m-1):0,f=g>1?(i-r)*(d-1)/(g-1):0;for(let t=0;t1?n*(p-1)+t*o:.5*(n+a)*(p-1);if(c<0||c>p-1)for(let n=0;n1?r*(d-1)+u*f:.5*(r+i)*(d-1);if(c<0||c>d-1){for(let n=0;n1?r*(d-1)+n*f:.5*(r+i)*(d-1);if(a<0||a>d-1){for(let r=0;re+f-t-1:(e,t)=>e+t;for(let e=0;ee+f-t-1:(e,t)=>e+t;for(let e=0;e`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${s}`));const o=a.shape[0],u=a.shape[1],l=a.shape[2],c=a.shape[3],p=u*i,d=l*i,h=c/(i*i),f=n.data.get(a.dataId).values,m=new Float32Array(o*p*d*h);let g=0;for(let e=0;e`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${d}'`));const h=cl(a.shape,i.shape,s,d,o,l,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:y,padInfo:b}=h,x=b.left,v=b.top,_=h.outChannels/h.inChannels,w=new Ka(h.outShape,a.dtype),M=n.data.get(a.dataId).values,N=n.data.get(i.dataId).values,S=w.values;for(let e=0;e=h.inHeight)continue;const i=e*p[0],s=t+n*c[1];for(let e=0;e=h.inWidth)continue;const a=i+e*p[1],o=s+r*h.inChannels;let u=t,l=a;for(let e=0;e{const{x:r,filter:a}=e,{strides:i,pad:s,dilations:o}=n,u=t,l=u.data.get(r.dataId).values,c=r.shape.length,p=u.data.get(a.dataId).values,d=a.shape.length,{batchSize:h,inHeight:f,inWidth:m,inChannels:g,outHeight:y,outWidth:b,padInfo:x,strideHeight:v,strideWidth:_,filterHeight:w,filterWidth:M,dilationHeight:N,dilationWidth:S,outShape:k}=ol(r.shape,a.shape,i,s,"NHWC",o),D=le(k),T=k.length,I=we(r.dtype,D);for(let e=0;e=0&&i=0&&hu&&(u=m)}}}I[He([e,t,i,o],T,Oe(k))]=u}}}return{dataId:u.write(Ra(I,r.dtype),k,r.dtype),shape:k,dtype:r.dtype}}},AT={kernelName:Wt,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,filter:a,dy:i}=e,{strides:s,pad:o,dilations:u}=n,l=t,c=Fe(r.shape,l.data.get(r.dataId).values),p=Fe(a.shape,l.data.get(a.dataId).values),{batchSize:d,inHeight:h,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:b,strideHeight:x,strideWidth:v,filterHeight:_,filterWidth:w,dilationHeight:M,dilationWidth:N,outShape:S}=ol(r.shape,a.shape,s,o,"NHWC",u);ie(i.rank===S.length,(()=>`Error in ${Wt}, dy must have the same rank as output ${S.length}, but got ${i.rank}`));const k=Fe(S,l.data.get(i.dataId).values),D=Be(a.shape,a.dtype);for(let e=0;e=0&&r=0&&ls&&(s=a,o=t,u=n)}}}D[o][u][i]+=k[e][t][r][i]}}}return{dataId:l.write(Ra(D,r.dtype),a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},LT={kernelName:qt,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,filter:a,dy:i}=e,{strides:s,pad:o,dilations:u}=n,l=t,c=Fe(r.shape,l.data.get(r.dataId).values),p=Fe(a.shape,l.data.get(a.dataId).values),{batchSize:d,inHeight:h,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:b,strideHeight:x,strideWidth:v,filterHeight:_,filterWidth:w,dilationHeight:M,dilationWidth:N,outShape:S}=ol(r.shape,a.shape,s,o,"NHWC",u);ie(i.rank===S.length,(()=>`Error in ${qt}, dy must have the same rank as output ${S.length}, but got ${i.rank}`));const k=Fe(S,l.data.get(i.dataId).values),D=Be(r.shape,r.dtype);for(let e=0;e=0&&r=0&&ls&&(s=a,o=r,u=l)}}}D[e][o][u][i]+=k[e][t][r][i]}}}return{dataId:l.write(Ra(D,r.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},$T=Ok(((e,t)=>e*t)),OT=nD(((e,t,n,r)=>({real:e*n-t*r,imag:e*r+t*n}))),RT=tD(qn,$T,OT),FT={kernelName:qn,backendName:"cpu",kernelFunc:RT};function YT(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r;let o;Nk(a,"sum"),o="bool"===a.dtype?Qk({inputs:{x:a},backend:n,attrs:{dtype:"int32"}}):Ck({inputs:{x:a},backend:n});const u=o.shape.length,l=xe(i,o.shape),c=yc(l,u);let p=l,d=o;null!=c&&(d=vD({inputs:{x:o},backend:n,attrs:{perm:c}}),p=xc(p.length,u)),gc("sum",p,d.shape.length);const[h,f]=fc(d.shape,p);let m=Jk(n,h,ui(d.dtype,"int32"));const g=le(f),y=n.data.get(m.dataId).values,b=n.data.get(d.dataId).values;for(let e=0;e=0&&(d=YT({inputs:{x:d},backend:n,attrs:{axis:l[e]-(s.length-h),keepDims:!1}}),f.push(d)),h--)}for(const e of f)e!==d&&n.disposeIntermediateTensorInfo(e);return d}},PT={kernelName:Jt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{dy:r,y:a}=t;Nk([r,a],"eluGrad");const i=new Float32Array(le(a.shape)),s=n.data.get(a.dataId).values,o=n.data.get(r.dataId).values;for(let e=0;e=1?o[e]:o[e]*(t+1)}return n.makeTensorInfo(a.shape,"float32",i)}},HT=Ok(((e,t)=>e===t?1:0)),jT=tD(Zt,HT,null,"bool"),UT={kernelName:Zt,backendName:"cpu",kernelFunc:jT},qT=uf,WT=lf,VT=cf,GT=pf,KT=df,JT=hf,XT=Dk(Xt,(e=>{const t=Math.sign(e),n=Math.abs(e),r=1/(1+qT*n);return t*(1-((((JT*r+KT)*r+GT)*r+VT)*r+WT)*r*Math.exp(-n*n))})),ZT={kernelName:Xt,backendName:"cpu",kernelFunc:XT},QT=jk((e=>Math.exp(e))),eI=Tk(Qt,QT,"float32"),tI={kernelName:Qt,backendName:"cpu",kernelFunc:eI};function nI(e){const{inputs:t,backend:n,attrs:r}=e,{input:a}=t,{dim:i}=r,s=a.shape.length,o=a.shape.slice();let u=i;return i<0&&(ie(-(s+1)<=i,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+i+1),o.splice(u,0,1),oD({inputs:{x:a},backend:n,attrs:{shape:o}})}const rI={kernelName:en,backendName:"cpu",kernelFunc:nI},aI=jk((e=>Math.expm1(e))),iI=Tk(tn,aI),sI={kernelName:tn,backendName:"cpu",kernelFunc:iI},oI=Ok(((e,t)=>e/t)),uI=tD(Vt,oI),lI={kernelName:Vt,backendName:"cpu",kernelFunc:uI},cI=Ok(((e,t)=>e-t)),pI=nD(((e,t,n,r)=>({real:e-n,imag:t-r}))),dI=tD(Ur,cI,pI),hI={kernelName:Ur,backendName:"cpu",kernelFunc:dI};function fI(e,t,n){const r=e.shape,a=r[0],i=r[1],s=n.data.get(e.dataId),o=s.complexTensorInfos.real,u=s.complexTensorInfos.imag,l=[a,i],c=le(l),p=_e("float32",c),d=_e("float32",c);for(let e=0;e{const{image:r}=e,a=n,i=_e(r.dtype,le(r.shape)),[s,o,u,l]=r.shape,c=a.data.get(r.dataId).values;for(let e=0;e=0&&sMath.floor(e))),wI=Tk(sn,_I),MI={kernelName:sn,backendName:"cpu",kernelFunc:wI},NI=Ok(((e,t)=>Math.floor(e/t))),SI=tD(on,NI,null,"int32"),kI={kernelName:on,backendName:"cpu",kernelFunc:SI},DI={kernelName:sa,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r;let m=cT({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d}});if(s){const e=m;if("NCHW"===c&&1===s.shape.length&&1!==s.shape[0]){const e=oD({inputs:{x:s},backend:n,attrs:{shape:[s.shape[0],1,1]}});m=iD({inputs:{a:m,b:e},backend:n}),n.disposeIntermediateTensorInfo(e)}else m=iD({inputs:{a:m,b:s},backend:n});n.disposeIntermediateTensorInfo(e)}if(h){const e=m;if("NCHW"===c&&"prelu"===h&&1===o.shape.length&&1!==o.shape[0]){const e=oD({inputs:{x:o},backend:n,attrs:{shape:[o.shape[0],1,1]}});m=Vk(n,m,h,e,f),n.disposeIntermediateTensorInfo(e)}else m=Vk(n,m,h,o,f);n.disposeIntermediateTensorInfo(e)}return m}},TI={kernelName:oa,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r;let m=kT({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d}});if(s){const e=m;m=iD({inputs:{a:m,b:s},backend:n}),n.disposeIntermediateTensorInfo(e)}if(h){const e=m;m=Vk(n,m,h,o,f),n.disposeIntermediateTensorInfo(e)}return m}};function II(e,t,n,r,a,i,s,o,u){const l=Es([r,i],n);for(let n=0;n=u/i)throw new Error(`Invalid indices: ${r} does not index into ${o}`);for(let e=0;e=0,(()=>`GatherV2: the index value ${t} is not in [0, ${c-1}]`))}let p=o;null==o&&(p=0);const d=le(i.shape),h=Uf(a,i,u,p),f=oD({inputs:{x:a},backend:n,attrs:{shape:[h.batchSize,h.outerSize,h.dimSize,h.sliceSize]}}),m=oD({inputs:{x:i},backend:n,attrs:{shape:[h.batchSize,d/h.batchSize]}}),g=[h.batchSize,h.outerSize,d/h.batchSize,h.sliceSize],y=n.bufferSync(m),b=CI(n.bufferSync(f),y,g);return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.makeTensorInfo(h.outputShape,b.dtype,b.values)}},LI=Ok(((e,t)=>e>t?1:0)),$I=tD(pn,LI,null,"bool"),OI={kernelName:pn,backendName:"cpu",kernelFunc:$I},RI=Ok(((e,t)=>e>=t?1:0)),FI=tD(dn,RI,null,"bool"),YI={kernelName:dn,backendName:"cpu",kernelFunc:FI},zI={kernelName:fn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t,a=le(r.shape),i=r.shape[r.shape.length-1],s=oD({inputs:{x:r},backend:n,attrs:{shape:[a/i,i]}}),o=fI(s,!0,n),u=oD({inputs:{x:o},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(o),u}},BI=Dk(gn,(e=>Number.isFinite(e)?1:0),"bool"),PI={kernelName:gn,backendName:"cpu",kernelFunc:BI},HI=Dk(yn,(e=>Math.abs(e)===1/0?1:0),"bool"),jI={kernelName:yn,backendName:"cpu",kernelFunc:HI},UI=Dk(bn,(e=>Number.isNaN(e)?1:0),"bool"),qI={kernelName:bn,backendName:"cpu",kernelFunc:UI},WI=Ok(((e,t)=>ee<=t?1:0)),JI=tD(_n,KI,null,"bool"),XI={kernelName:_n,backendName:"cpu",kernelFunc:JI};function ZI(e,t,n){const r=(t-e)/(n-1),a=ze(n,"float32");a[0]=e;for(let e=1;eMath.log(e))),tE=Tk(Mn,eE),nE={kernelName:Mn,backendName:"cpu",kernelFunc:tE},rE=Dk(Nn,(e=>Math.log1p(e))),aE={kernelName:Nn,backendName:"cpu",kernelFunc:rE},iE=Ok(((e,t)=>e&&t)),sE=tD(Sn,iE,null,"bool"),oE={kernelName:Sn,backendName:"cpu",kernelFunc:sE},uE=Dk(kn,(e=>e?0:1),"bool"),lE={kernelName:kn,backendName:"cpu",kernelFunc:uE},cE=Ok(((e,t)=>e||t)),pE=tD(Dn,cE,null,"bool"),dE={kernelName:Dn,backendName:"cpu",kernelFunc:pE},hE={kernelName:En,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{depthRadius:i,bias:s,alpha:o,beta:u}=r;Nk(a,"LRN");const l=a.shape[3],c=l-1,p=n.data.get(a.dataId).values,d=le(a.shape),h=new Float32Array(d);function f(e){const t=e%l;let n=e-t+Math.max(0,t-i);const r=e-t+Math.min(t+i,c);let a=0;for(;n<=r;n++){const e=p[n];a+=e*e}return a}for(let e=0;ei)&&(i=t)}a[n]=i}return a}function gE(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reductionIndices:i,keepDims:s}=r,o=n;let u=a.shape;const l=u.length,c=xe(i,u);let p=c;const d=yc(p,l);let h=o.data.get(a.dataId).values;if(null!=d){const e=new Array(l);for(let t=0;tMath.max(e,t))),xE=tD(Ln,bE),vE={kernelName:Ln,backendName:"cpu",kernelFunc:xE},_E={kernelName:$n,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;Nk(a,"maxPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;ie(bl(s,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=ul(a.shape,i,s,1,o,u);let c;if(1===l.filterWidth&&1===l.filterHeight&&pe(l.inShape,l.outShape))c=Ck({inputs:{x:a},backend:n});else{const e=n.data.get(a.dataId).values,t=Oe(a.shape),r=FD(e,a.shape,a.dtype,t,l,"max");c=n.makeTensorInfo(l.outShape,a.dtype,r.values)}return c}},wE={kernelName:Rn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u,dataFormat:l}=r;Nk(a,"maxPool3d");const c=ll(a.shape,i,s,1,o,u,l),p=zD(n.data.get(a.dataId).values,a.shape,a.dtype,Oe(a.shape),c,"max");return n.makeTensorInfo(p.shape,"float32",p.values)}},ME={kernelName:Fn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,{filterSize:s,strides:o,pad:u,dimRoundingMode:l}=r;Nk([a,i],"maxPool3DGrad");const c=ll(i.shape,s,o,1,u,l),p=function(e,t){const n=Es(t.outShape,"int32"),r=t.strideDepth,a=t.strideHeight,i=t.strideWidth,s=t.dilationDepth,o=t.dilationHeight,u=t.dilationWidth,l=t.effectiveFilterDepth,c=t.effectiveFilterHeight,p=t.effectiveFilterWidth,d=t.padInfo.front,h=t.padInfo.top,f=t.padInfo.left;for(let m=0;m=N&&(N=o,S=n*c*p+a*c+s)}}}n.set(S,m,y,r,a,g)}}}return n}(n.bufferSync(i),c),d=c.strideDepth,h=c.strideHeight,f=c.strideWidth,m=c.dilationDepth,g=c.dilationHeight,y=c.dilationWidth,b=c.effectiveFilterDepth,x=c.effectiveFilterHeight,v=c.effectiveFilterWidth,_=b-1-c.padInfo.front,w=v-1-c.padInfo.left,M=x-1-c.padInfo.top,N=Es(i.shape,"float32"),S=n.bufferSync(a);for(let e=0;e=c.outDepth||Math.floor(r)!==r))for(let a=0;a=c.outHeight||Math.floor(i)!==i))for(let s=0;s=c.outWidth||Math.floor(l)!==l)continue;const d=b*x*v-1-p.get(e,r,i,l,t)===n*x*v+a*v+s?1:0;0!==d&&(u+=S.get(e,r,i,l,t)*d)}}}N.set(u,e,n,r,a,t)}return n.makeTensorInfo(N.shape,N.dtype,N.values)}},NE={kernelName:On,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i,output:s}=t,o=i;Nk([i,s],"maxPoolGrad");const{filterSize:u,strides:l,pad:c,dimRoundingMode:p}=r,d=ul(o.shape,u,l,1,c,p),h=n.data.get(o.dataId).values,f=Es(d.outShape,o.dtype,YD(h,o.shape,o.dtype,d).values),m=d.strideHeight,g=d.strideWidth,y=d.dilationHeight,b=d.dilationWidth,x=d.effectiveFilterHeight,v=d.effectiveFilterWidth,_=v-1-d.padInfo.left,w=x-1-d.padInfo.top,M=Es(o.shape,"float32"),N=n.data.get(a.dataId).values,S=Es(a.shape,"float32",N);for(let e=0;e=d.outHeight||Math.floor(r)!==r))for(let a=0;a=d.outWidth||Math.floor(o)!==o)continue;const u=x*v-1-f.get(e,r,o,t)===n*v+a?1:0;0!==u&&(s+=S.get(e,r,o,t)*u)}}M.set(s,e,n,r,t)}return n.makeTensorInfo(M.shape,M.dtype,M.values)}},SE={kernelName:Yn,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{filterSize:a,strides:i,pad:s,includeBatchInIndex:o}=t,u=n;Nk(r,"MaxPoolWithArgmax");const l=u.data.get(r.dataId).values,c=ul(r.shape,a,i,[1,1],s),[p,d]=function(e,t,n,r,a){const i=FD(e,0,n,Oe(t),a,"max"),s=YD(e,t,n,a,!0,r);return[i.values,s.values]}(l,r.shape,r.dtype,o,c),h=u.write(p,c.outShape,r.dtype),f=u.write(d,c.outShape,r.dtype);return[{dataId:h,shape:c.outShape,dtype:r.dtype},{dataId:f,shape:c.outShape,dtype:"int32"}]}},kE={kernelName:zn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=xe(i,a.shape),u=le(fc(a.shape,o)[1]),l=[],c=n.makeTensorInfo([],"float32",new Float32Array([u]));l.push(c);const p=Qk({inputs:{x:a},backend:n,attrs:{dtype:"float32"}});l.push(p);const d=uI({inputs:{a:p,b:c},backend:n});l.push(d);const h=YT({inputs:{x:d},backend:n,attrs:{axis:i,keepDims:s}});return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),h}},DE={kernelName:Bn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r;Nk(a,"min");const o=xe(i,a.shape);let u=o;const l=yc(u,a.shape.length);let c=a;null!=l&&(c=vD({inputs:{x:a},backend:n,attrs:{perm:l}}),u=xc(u.length,a.shape.length)),gc("min",u,c.shape.length);const[p,d]=fc(c.shape,u),h=le(d),f=ze(le(p),c.dtype),m=n.data.get(c.dataId).values;for(let e=0;eMath.min(e,t))),IE=tD(Pn,TE),EE={kernelName:Pn,backendName:"cpu",kernelFunc:IE},CE={kernelName:Hn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,mode:s}=r;Nk(a,"mirrorPad");const o=i.map(((e,t)=>e[0]+a.shape[t]+e[1])),u=i.map((e=>e[0])),l=i.map(((e,t)=>e[0]+a.shape[t])),c="reflect"===s?0:1,p=n.data.get(a.dataId).values,d=a.shape.length,h=Oe(a.shape),f=le(o),m=o.length,g=Oe(o),y=_e(a.dtype,f);for(let e=0;e=l[e]&&(t[e]=2*(l[e]-1)-t[e]+c);t=t.map(((e,t)=>e-u[t]));const n=He(t,d,h);y[e]=p[n]}return{dataId:n.write(y,o,a.dtype),shape:o,dtype:a.dtype}}},AE=Ok(((e,t)=>{const n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t})),LE=tD(jn,AE),$E={kernelName:jn,backendName:"cpu",kernelFunc:LE};var OE=n(2948);function RE(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{dim:i}=r,s=a.shape.length;let o=i;if(-1===o&&(o=s-1),o!==s-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${s} and dim was ${o}`);const u=xe([o],a.shape),l=gE({inputs:{x:a},backend:n,attrs:{reductionIndices:u,keepDims:!1}}),c=mc(l.shape,u),p=oD({inputs:{x:l},backend:n,attrs:{shape:c}}),d=dI({inputs:{a,b:p},backend:n}),h=eI({inputs:{x:d},backend:n}),f=YT({inputs:{x:h},backend:n,attrs:{axis:u,keepDims:!1}}),m=oD({inputs:{x:f},backend:n,attrs:{shape:c}}),g=uI({inputs:{a:h,b:m},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}const FE={kernelName:Ar,backendName:"cpu",kernelFunc:RE},YE={kernelName:Un,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{numSamples:i,seed:s,normalized:o}=r;Nk(a,"multinomial");const u=o?a:RE({inputs:{logits:a},backend:n,attrs:{dim:-1}}),l=u.shape[0],c=u.shape[1],p=n.data.get(u.dataId).values,d=[l,i],h=ze(le(d),"int32");for(let e=0;ee!==t?1:0)),GE=tD(Vn,VE,null,"bool"),KE={kernelName:Vn,backendName:"cpu",kernelFunc:GE},JE={kernelName:Zn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{indices:a}=t,{depth:i,onValue:s,offValue:o}=r;Nk(a,"oneHot");const u=le(a.shape),l=new Float32Array(u*i);l.fill(o);const c=n.data.get(a.dataId).values;for(let e=0;e=0&&c[e]{se(i,e.shape,"All tensors passed to stack must have matching shapes"),ie(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],u=uT({inputs:t.map((e=>{const t=nI({inputs:{input:e},backend:n,attrs:{dim:a}});return o.push(t),t})),backend:n,attrs:{axis:a}});return o.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}const tC={kernelName:Qn,backendName:"cpu",kernelFunc:eC},nC={kernelName:er,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,constantValue:s}=r;Nk(a,"pad");const o=i.map(((e,t)=>e[0]+a.shape[t]+e[1])),u=i.map((e=>e[0])),l=n.data.get(a.dataId).values,c=le(a.shape),p=a.shape.length,d=Oe(a.shape),h=le(o),f=o.length,m=Oe(o),g=_e(a.dtype,h);0!==s&&g.fill(s);for(let e=0;ee+u[t])),f,m)]=l[e];return{dataId:n.write(g,o,a.dtype),shape:o,dtype:a.dtype}}},rC=Ok(((e,t)=>Math.pow(e,t))),aC=tD(nr,rC),iC={kernelName:nr,backendName:"cpu",kernelFunc:aC};function sC(e,t,n,r){const[a,i]=fc(e,r),s=ui(t,"int32"),o=ze(le(a),s),u=le(i);for(let e=0;en.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(y,g,f)}};function uC(e,t,n,r){if(e===t||e1)return ze(0,r);const a=ze(Math.abs(Math.ceil((t-e)/n)),r);t1/e)),pC={kernelName:or,backendName:"cpu",kernelFunc:cC},dC={kernelName:dr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r;Nk(a,"resizeBilinear");const u=Oe(a.shape),[l,c]=o,[p,d,h,f]=a.shape,m=n.data.get(a.dataId).values,g=new Float32Array(le([p,l,c,f])),y=[i&&l>1?d-1:d,i&&c>1?h-1:h],b=[i&&l>1?l-1:l,i&&c>1?c-1:c];let x=0;const v=y[0]/b[0],_=y[1]/b[1];for(let e=0;e1?l-1:l,s&&h>1?c-1:c],g=[s&&d>1?d-1:d,s&&h>1?h-1:h],y=m[0]/g[0],b=m[1]/g[1],x=n.data.get(i.dataId).values;let v=0;for(let e=0;e1?d-1:d,i&&c>1?h-1:h],b=[i&&l>1?l-1:l,i&&c>1?c-1:c],x=y[0]/b[0],v=y[1]/b[1];let _=0;for(let e=0;e1?c-1:c,s&&f>1?p-1:p],b=[s&&h>1?h-1:h,s&&f>1?f-1:f],x=y[0]/b[0],v=y[1]/b[1],_=1/x,w=1/v,M=2*Math.ceil(_)+2,N=2*Math.ceil(w)+2;for(let e=0;e=h)continue;const d=t+l*u[1],m=l*x;if(e===Math.min(c-1,s?Math.round(m):Math.floor(m)))for(let e=0;e=f)continue;const a=d+t*u[2],i=t*v;r===Math.min(p-1,s?Math.round(i):Math.floor(i))&&(o+=g[a+n])}}m[i+n]=o}}}}return n.makeTensorInfo(a.shape,a.dtype,m)}},gC={kernelName:mr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:i}=r;Nk(a,"reverse");const s=a.shape.length,o=xe(i,a.shape);if(0===s)return Ck({inputs:{x:a},backend:n});const u=new Ka(a.shape,a.dtype),l=n.bufferSync(a);for(let e=0;en[e]=a.shape[e]-1-n[e])),u.set(l.get(...n),...t)}return n.makeTensorInfo(u.shape,u.dtype,u.values)}},yC={kernelName:aa,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:r}=e,{radians:a,fillValue:i,center:s}=t,o=n,u=_e(r.dtype,le(r.shape)),[l,c,p,d]=r.shape,[h,f]=Qh(s,c,p),m=Math.sin(a),g=Math.cos(a),y=o.data.get(r.dataId).values;for(let e=0;e=0&&v=0&&_{const t=Math.floor(e);return e-t<.5?Math.floor(e):e-t>.5?Math.ceil(e):t%2==0?t:t+1})),xC={kernelName:gr,backendName:"cpu",kernelFunc:bC},vC=jk((e=>1/Math.sqrt(e))),_C=Tk(yr,vC),wC={kernelName:yr,backendName:"cpu",kernelFunc:_C};function MC(e,t,n,r,a,i,s,o,u,l){const c=[r/a,a],p=e.values,d=t.values;if(0===r)return Es(n,t.dtype);const h=Es(c,t.dtype);"string"==typeof u||"number"==typeof u?h.values.fill(u):"boolean"==typeof u&&h.values.fill(+u);for(let e=0;e=r/a)throw new Error(`Invalid indices: ${i} does not index into ${n}`);for(let n=0;n1||1===a.shape.length?1:le(a.shape.slice(1));for(let e=0;ee>=0?EC*e:IC*(Math.exp(e)-1))),AC={kernelName:_r,backendName:"cpu",kernelFunc:CC},LC=Dk(Sr,(e=>e<0?-1:e>0?1:0)),$C={kernelName:Sr,backendName:"cpu",kernelFunc:LC},OC=Dk(Mr,(e=>Math.sin(e))),RC={kernelName:Mr,backendName:"cpu",kernelFunc:OC},FC=Dk(Nr,(e=>Math.sinh(e))),YC={kernelName:Nr,backendName:"cpu",kernelFunc:FC},zC=Math.log(1.1920928955078125e-7)+2,BC=Dk(Dr,(e=>{const t=e>-zC,n=e=u)throw new Error(Af(t,n,u));++f[n],d=d&&n>=h,h=n}let m=!0;for(let e=0;e0&&(f[e]+=f[e-1])}if(m&&d){const t=e,n=r;for(let e=0;eNumber(e))))),n.makeTensorInfo([m.length],r.dtype,new Int32Array(m))]}};function qC(e,t,n,r,a){const i=le(r),s=t[0],o=a.length,u=[];let l=1,c=-1;for(let e=0;e0){d[p-1]=1;for(let e=p-2;e>=0;--e)d[e]=d[e+1]*r[e+1]}const h=[];if(o>0){h[o-1]=1;for(let e=o-2;e>=0;--e)h[e]=h[e+1]*u[e+1]}const f=we(n,s*o);for(let t=0;t0?a[o-1]+1:0;if(c<0)throw new Error("segment ids must be >= 0");const p=t.slice();p[0]=c;const d=p.reduce(((e,t)=>e*t),1),h=we(n,d);if(0===o)return c>0&&h.fill(s),[h,p];if(c<=0)throw new Error("segment ids must be >= 0");let f=0,m=1,g=0,y=a[f];for(;;){let t=0;if(m=t)throw new Error("segment ids are not increasing")}if(y<0||y>=c)throw new Error(Bf(y,c));y>g&&h.fill(s,g*l,y*l);for(let t=f;t=u[0])throw new Error(Pf(t,r[t],u[0]));for(let t=0;to)break}return g{const t=[...c];t[o]=e;const r=WD({inputs:{x:a},backend:n,attrs:{begin:l,size:t}});return l[o]+=e,r}))}},ZC=jk((e=>Math.sqrt(e))),QC=Dk(Tr,(e=>Math.sqrt(e))),eA={kernelName:Tr,backendName:"cpu",kernelFunc:QC},tA={kernelName:zr,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{const{x:n}=e,r=t;Nk(n,"square");const a=r.data.get(n.dataId).values,i=new Float32Array(a.length);for(let e=0;e{const n=e-t;return n*n})),rA=tD(Yr,nA),aA={kernelName:Yr,backendName:"cpu",kernelFunc:rA},iA=Dk(na,((e,t)=>{const n=t;return isNaN(e)?NaN:e>0?1:n.alpha})),sA={kernelName:na,backendName:"cpu",kernelFunc:iA};function oA(e,t,n,r){const a=Es(e,t.dtype);for(let e=0;e=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=Uo(b,x,v),t=WD({inputs:{x:a},backend:n,attrs:{begin:b,size:e}});_=oD({inputs:{x:t},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(t)}else{const e=oA(h,n.bufferSync(a),v,b);_=n.makeTensorInfo(f,e.dtype,e.values)}return _}};class lA{constructor(e,t,n,r,a,i){this.separator=za(e),this.nGramWidths=t,this.leftPad=za(n),this.rightPad=za(r),this.padWidth=a,this.preserveShort=i}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){const n=this.getPadWidth(t);return Math.max(0,e+2*n-t+1)}createNGrams(e,t,n,r,a,i){for(let s=0;s0?0:s-o);let d=0;d+=u*this.leftPad.length;for(let t=0;te.forEach((e=>h[f++]=e));for(let e=0;e0){m(e[p+c-1]);for(let e=0;e0){let e=t[0];if(0!==e)throw new Error(`First split value must be 0, got ${e}`);for(let a=1;a=e;if(r=r&&t[a]<=n,!r)throw new Error(`Invalid split value ${t[a]}, must be in [${e}, ${n}]`);e=t[a]}if(e!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${e}`)}const a=r-1,i=we("int32",r);if(0===n||0===r){const e=new Array(n);for(let e=0;e<=a;++e)i[e]=0;return[e,i]}i[0]=0;for(let e=1;e<=a;++e){const n=t[e]-t[e-1];let r=0;this.nGramWidths.forEach((e=>{r+=this.getNumNGrams(n,e)})),this.preserveShort&&n>0&&0===r&&(r=1),i[e]=i[e-1]+r}const s=new Array(i[a]);for(let n=0;n{const o=t[n+1]-t[n],u=this.getNumNGrams(o,i);this.createNGrams(e,r,s,a,u,i),a+=u})),this.preserveShort&&a===i[n]){const i=t[n+1]-t[n];if(0===i)continue;const o=i+2*this.padWidth,u=1;this.createNGrams(e,r,s,a,u,o)}}return[s,i]}}function cA(e,t,n,r,a,i,s,o){return new lA(n,r,a,i,s,o).compute(e,t)}const pA={kernelName:Pr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{separator:a,nGramWidths:i,leftPad:s,rightPad:o,padWidth:u,preserveShortSequences:l}=r,{data:c,dataSplits:p}=t,d=n.data.get(c.dataId).values,h=n.data.get(p.dataId).values,[f,m]=cA(d,h,a,i,s,o,u,l);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}};function dA(e,t,n,r){if(!e.length)return;if(0===t.length){for(let t=0;tMath.tan(e))),bA={kernelName:qr,backendName:"cpu",kernelFunc:yA},xA=Dk(Wr,(e=>Math.tanh(e)));function vA(e,t){const n=new Array(e.rank);for(let r=0;r{const n=t.value-e.value;return 0===n?e.index-t.index:n};function MA(e,t,n=0,r=e.length-1){for(;r>n;){if(r-n>600){const a=r-n+1,i=t-n+1,s=Math.log(a),o=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*o*(a-o)/a)*Math.sign(i-a/2);MA(e,t,Math.max(n,Math.floor(t-i*o/a+u)),Math.min(r,Math.floor(t+(a-i)*o/a+u)))}const a=e[t];let i=n,s=r;for(te(e,n,t),wA(e[r],a)>0&&te(e,n,r);i0;)s-=1}0===wA(e[n],a)?te(e,n,s):(s+=1,te(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function NA(e,t,n,r,a){const i=t[t.length-1],[s,o]=[e.length/i,i],u=_e(n,s*r),l=_e("int32",s*r);for(let t=0;ts[t]={value:e,index:t})),rt-1)if(t<=1)n=0;else{const e=2*t;n-=e*Math.trunc(n/e),n>=t&&(n=e-n-1)}return Q(0,n,t-1)}(e,t);case"wrap":return function(e,t){let n=e;if(n<0)if(t<=1)n=0;else{const e=t-1;n+=t*(Math.trunc(-n/e)+1)}else if(n>t-1)if(t<=1)n=0;else{const e=t-1;n-=t*Math.trunc(n/e)}return Q(0,n,t-1)}(e,t);case"nearest":return function(e,t){return Q(0,e,t-1)}(e,t);default:return function(e,t){return e}(e)}}function TA(e,t,n,r,a,i,s,o,u,l,c){return 0<=o&&o{for(let n=0;nn.disposeIntermediateTensorInfo(e))),p}},OA=[pD,hD,mD,yD,sD,bD,wD,MD,ND,SD,DD,ID,CD,$D,RD,BD,PD,HD,jD,cD,UD,GD,XD,ZD,eD,tT,rT,Kk,aT,lT,pT,dT,hT,fT,mT,gT,bT,vT,_T,wT,MT,NT,ST,DT,TT,IT,ET,CT,AT,LT,BT,Ek,PT,UT,ZT,tI,rI,sI,yI,xI,vI,MI,kI,DI,TI,EI,AI,OI,YI,Ak,zI,oT,PI,jI,qI,$k,GI,XI,QI,nE,aE,oE,lE,dE,hE,fE,yE,vE,_E,wE,ME,NE,SE,kE,DE,EE,CE,$E,YE,FT,BE,HE,UE,WE,KE,JE,QE,tC,nC,iC,Yk,oC,lC,Zk,lI,pC,Bk,Hk,uD,dC,hC,fC,mC,gC,yC,xC,wC,NC,DC,TC,AC,Wk,$C,RC,YC,VD,FE,PC,HC,UC,WC,GC,KC,JC,XC,eA,tA,aA,sA,uA,pA,fA,gA,hI,zT,bA,{kernelName:Wr,backendName:"cpu",kernelFunc:xA},_A,SA,kA,_D,AA,LA,$A,ZE];for(const e of OA)ma(e);const RA={},FA={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function YA(e,t){if(!(e in RA)||null!=t){const n=function(e,t){if(1!==e&&2!==e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const n=null==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):t;return n.addEventListener("webglcontextlost",(t=>{t.preventDefault(),delete RA[e]}),!1),1===e?n.getContext("webgl",FA)||n.getContext("experimental-webgl",FA):n.getContext("webgl2",FA)}(e,t);if(null===n)return console.log("Could not get context for WebGL version",e),null;RA[e]=n}const n=RA[e];return null==n||n.isContextLost()?(delete RA[e],YA(e)):(n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.disable(n.BLEND),n.disable(n.DITHER),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SAMPLE_COVERAGE),n.enable(n.SCISSOR_TEST),n.enable(n.CULL_FACE),n.cullFace(n.BACK),RA[e])}var zA,BA,PA;function HA(e,t){return[t,e]}function jA(e){const t=le(e);return fe(Math.ceil(t/4))}function UA(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function qA(e,t){const n=e;let r,a,i,s,o,u,l,c,p,d;return 2===Ve().getNumber("WEBGL_VERSION")?(r=n.R32F,a=n.R16F,i=n.RGBA16F,s=n.RGBA32F,o=n.RED,l=4,c=1,p=n.HALF_FLOAT,d=n.FLOAT,u=n.RGBA8):(r=e.RGBA,a=e.RGBA,i=e.RGBA,s=n.RGBA,o=e.RGBA,l=4,c=4,p=null!=t?t.HALF_FLOAT_OES:null,d=e.FLOAT,u=e.RGBA),{internalFormatFloat:r,internalFormatHalfFloat:a,internalFormatPackedHalfFloat:i,internalFormatPackedFloat:s,textureFormatFloat:o,downloadTextureFormat:u,downloadUnpackNumChannels:l,defaultNumChannels:c,textureTypeHalfFloat:p,textureTypeFloat:d}}function WA(e,t){const n=t();return Ve().getBool("DEBUG")&&function(e){const t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+function(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}`}}(e,t))}(e),n}function VA(e){return!!(Ve().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||5.96e-8e.getExtension(t)),'Extension "'+t+'" not supported on this browser.')}!function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"}(zA||(zA={})),function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"}(BA||(BA={})),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"}(PA||(PA={}));const KA=/ERROR: [0-9]+:([0-9]+):/g;function JA(e,t){const n=KA.exec(t);if(null==n)return console.log(`Couldn't parse line number in error: ${t}`),void console.log(e);const r=+n[1],a=e.split("\n"),i=a.length.toString().length+2,s=a.map(((e,t)=>ge((t+1).toString(),i)+e));let o=0;for(let e=0;ee.validateProgram(t))),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function ZA(e,t,n,r,a,i,s){const o=e.getAttribLocation(t,n);return-1!==o&&(WA(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,r))),WA(e,(()=>e.vertexAttribPointer(o,a,e.FLOAT,!1,i,s))),WA(e,(()=>e.enableVertexAttribArray(o))),!0)}function QA(e,t,n,r){WA(e,(()=>function(e,t,n){(function(e,t){const n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+e.TEXTURE0;if(rn)throw new Error(`textureUnit must be in [gl.TEXTURE0, gl.TEXTURE${n}].`)})(e,n),WA(e,(()=>e.activeTexture(e.TEXTURE0+n))),WA(e,(()=>e.bindTexture(e.TEXTURE_2D,t)))}(e,t,r))),WA(e,(()=>e.uniform1i(n,r)))}function eL(e,t,n){WA(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,n))),WA(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)))}function tL(e,t){WA(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,t))),WA(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)))}function nL(e){const t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+function(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}`}}(e,t))}function rL(e,t,n){const r=WA(e,(()=>t()));if(null==r)throw new Error(n);return r}function aL(e,t=2){return le(e.slice(0,e.length-t))}function iL(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 sL(e){let t=[1,1,1];return 0===e.length||1===e.length&&1===e[0]||(t=[aL(e),...iL(e)]),t}function oL(e){return e%2==0}function uL(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){const n=e.slice(-1)[0],r=t.slice(-1)[0];if(n===r)return!0;if(oL(n)&&oL(r)&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&oL(e[0])&&oL(t[0])}let lL,cL;function pL(e,t){return null!=e.getExtension(t)}function dL(e){try{if(null!=YA(e))return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function hL(e){const t=qA(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);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);const a=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),a}function fL(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&ie("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the WebGL backend.`))}))}const mL=Ve();function gL(){let e,t,n,r,a,i,s,o,u,l;return 2===Ve().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",n="out",r="in",a="texture",i="outputColor",s="out vec4 outputColor;",o="\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\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="",l="\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",a="texture2D",i="gl_FragColor",s="",o="\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 ",l="\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:a,output:i,defineOutput:s,defineSpecialNaN:o,defineSpecialInf:u,defineRound:l}}function yL(e,t,n="index"){const r=Oe(t);return r.map(((t,a)=>`int ${e[a]} = ${n} / ${t}; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * ${t}`:`index -= ${e[a]} * ${t}`};`)).join("")}function bL(e,t,n="index"){const r=Oe(t);return r.map(((t,a)=>`int ${e[a]} = ${n} / outShapeStrides[${a}]; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * outShapeStrides[${a}]`:`index -= ${e[a]} * outShapeStrides[${a}]`};`)).join("")}function xL(e){const t=Oe(e).map((e=>e.toString()));return`\n int getFlatIndex(ivec3 coords) {\n return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;\n }\n`}mL.registerFlag("HAS_WEBGL",(()=>mL.getNumber("WEBGL_VERSION")>0)),mL.registerFlag("WEBGL_VERSION",(()=>dL(2)?2:dL(1)?1:0)),mL.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",(()=>!1)),mL.registerFlag("WEBGL_BUFFER_SUPPORTED",(()=>2===mL.get("WEBGL_VERSION"))),mL.registerFlag("WEBGL_CPU_FORWARD",(()=>!0)),mL.registerFlag("WEBGL_FORCE_F16_TEXTURES",(()=>!1)),mL.registerFlag("WEBGL_PACK",(()=>mL.getBool("HAS_WEBGL"))),mL.registerFlag("WEBGL_PACK_NORMALIZATION",(()=>mL.getBool("WEBGL_PACK"))),mL.registerFlag("WEBGL_PACK_CLIP",(()=>mL.getBool("WEBGL_PACK"))),mL.registerFlag("WEBGL_PACK_DEPTHWISECONV",(()=>mL.getBool("WEBGL_PACK"))),mL.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(()=>mL.getBool("WEBGL_PACK"))),mL.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(()=>mL.getBool("WEBGL_PACK"))),mL.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(()=>mL.getBool("WEBGL_PACK"))),mL.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(()=>mL.getBool("WEBGL_PACK"))),mL.registerFlag("WEBGL_PACK_REDUCE",(()=>mL.getBool("WEBGL_PACK"))),mL.registerFlag("WEBGL_LAZILY_UNPACK",(()=>mL.getBool("WEBGL_PACK"))),mL.registerFlag("WEBGL_CONV_IM2COL",(()=>mL.getBool("WEBGL_PACK"))),mL.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(()=>function(e){if(null==lL){const t=YA(e);lL=t.getParameter(t.MAX_TEXTURE_SIZE)}return lL}(mL.getNumber("WEBGL_VERSION")))),mL.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(()=>function(e){if(null==cL){const t=YA(e);cL=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,cL)}(mL.getNumber("WEBGL_VERSION")))),mL.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(()=>{const e=mL.getNumber("WEBGL_VERSION");return 0===e?0:function(e){if(0===e)return 0;let t;const n=YA(e);return t=pL(n,"EXT_disjoint_timer_query_webgl2")&&2===e?2:pL(n,"EXT_disjoint_timer_query")?1:0,t}(e)})),mL.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(()=>mL.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!Mi())),mL.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(()=>function(e){if(0===e)return!1;const t=YA(e);if(1===e){if(!pL(t,"OES_texture_float"))return!1}else if(!pL(t,"EXT_color_buffer_float"))return!1;return hL(t)}(mL.getNumber("WEBGL_VERSION")))),mL.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(()=>!mL.getBool("WEBGL_FORCE_F16_TEXTURES")&&mL.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))),mL.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(()=>function(e){if(0===e)return!1;const t=YA(e);if(1!==e){if(pL(t,"EXT_color_buffer_float"))return hL(t);const e="EXT_color_buffer_half_float";if(pL(t,e)){const n=t.getExtension(e);return function(e,t){const n=qA(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);const a=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);const i=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(a),i}(t,n)}return!1}return!!pL(t,"OES_texture_float")&&!!pL(t,"WEBGL_color_buffer_float")&&hL(t)}(mL.getNumber("WEBGL_VERSION")))),mL.registerFlag("WEBGL_FENCE_API_ENABLED",(()=>{return 2===(e=mL.getNumber("WEBGL_VERSION"))&&null!=YA(e).fenceSync;var e})),mL.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(()=>mL.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0)),mL.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",(()=>-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`)})),mL.registerFlag("WEBGL_FLUSH_THRESHOLD",(()=>Mi()?1:-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`)})),mL.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",(()=>128)),mL.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",(()=>!1)),mL.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",(()=>1e5)),mL.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",(()=>128));const vL="\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",{getBroadcastDims:_L}=g;function wL(e,t,n){const r=[];if(e.forEach((e=>{const t=le(e.shapeInfo.logicalShape);if(e.shapeInfo.isUniform?r.push(`uniform float ${e.name}${t>1?`[${t}]`:""};`):(r.push(`uniform sampler2D ${e.name};`),r.push(`uniform int offset${e.name};`)),n.enableShapeUniforms){const{uniformShape:t}=AL(n.packedInputs,e.shapeInfo.logicalShape,e.shapeInfo.texShape);switch(t.length){case 1:r.push(`uniform int ${e.name}Shape;`);break;case 2:r.push(`uniform ivec2 ${e.name}Shape;`);break;case 3:r.push(`uniform ivec3 ${e.name}Shape;`);break;case 4:r.push(`uniform ivec4 ${e.name}Shape;`)}r.push(`uniform ivec2 ${e.name}TexShape;`)}})),n.enableShapeUniforms){switch(t.logicalShape.length){case 1:r.push("uniform int outShape;");break;case 2:r.push("uniform ivec2 outShape;"),r.push("uniform int outShapeStrides;");break;case 3:r.push("uniform ivec3 outShape;"),r.push("uniform ivec2 outShapeStrides;");break;case 4:r.push("uniform ivec4 outShape;"),r.push("uniform ivec3 outShapeStrides;")}r.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach((e=>{r.push(`uniform ${e.type} ${e.name}${e.arrayIndex?`[${e.arrayIndex}]`:""};`)}));const a=r.join("\n"),i=e.map((e=>function(e,t,n=!1,r){let a="";a+=n?NL(e,r):ML(e,r);const i=e.shapeInfo.logicalShape,s=t.logicalShape;return i.length<=s.length&&(a+=n?function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",i=e.shapeInfo.logicalShape.length,s=t.logicalShape.length,o=_L(e.shapeInfo.logicalShape,t.logicalShape),u=CL(s),l=s-i;let c;const p=["x","y","z","w","u","v"];c=0===i?"":s<2&&o.length>=1?"coords = 0;":o.map((e=>`coords.${p[e+l]} = 0;`)).join("\n");let d="";d=s<2&&i>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${p[t+l]}`)).join(", ");let h="return outputValue;";const f=1===le(e.shapeInfo.logicalShape),m=1===le(t.logicalShape);if(1!==i||f||m){if(f&&!m)h=1===s?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(o.length){const e=i-2,t=i-1;o.indexOf(e)>-1&&o.indexOf(t)>-1?h="return vec4(outputValue.x);":o.indexOf(e)>-1?h="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":o.indexOf(t)>-1&&(h="return vec4(outputValue.xx, outputValue.zz);")}}else h="\n return vec4(outputValue.xy, outputValue.xy);\n ";return`\n vec4 ${a}() {\n ${u} coords = getOutputCoords();\n ${c}\n vec4 outputValue = get${r}(${d});\n ${h}\n }\n `}(e,t):function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",i=t.texShape,s=e.shapeInfo.texShape,o=e.shapeInfo.logicalShape.length,u=t.logicalShape.length;if(!e.shapeInfo.isUniform&&o===u&&null==e.shapeInfo.flatOffset&&pe(s,i))return`\n float ${a}() {\n return sampleTexture(${n}, resultUV);\n }\n `;const l=CL(u),c=_L(e.shapeInfo.logicalShape,t.logicalShape),p=u-o;let d;const h=["x","y","z","w","u","v"];d=0===o?"":u<2&&c.length>=1?"coords = 0;":c.map((e=>`coords.${h[e+p]} = 0;`)).join("\n");let f="";return f=u<2&&o>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${h[t+p]}`)).join(", "),`\n float ${a}() {\n ${l} coords = getOutputCoords();\n ${d}\n return get${r}(${f});\n }\n `}(e,t)),a}(e,t,n.packedInputs,n.enableShapeUniforms))).join("\n"),s=t.texShape,o=gL(),u=function(e){return`\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ${e.texture2D}(textureSampler, uv).r;\n }\n `}(o);let l,c,p=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 ${SL}\n ${kL}\n ${DL}\n `}(o);return t.isPacked?(l=function(e,t,n){switch(e.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return 1===r[0]?n?"\n int getOutputCoords() {\n return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.x * ${r[1]}.0);\n }\n `:1===r[1]?n?"\n int getOutputCoords() {\n return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.y * ${r[0]}.0);\n }\n `:n?"\n int getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);\n }\n ":`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n return 2 * (resTexRC.x * ${r[1]} + resTexRC.y);\n }\n `}(0,t,n);case 2:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(pe(e,t))return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n ":`\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2(${r[0]}, ${r[1]}));\n }\n `;const a=Math.ceil(e[1]/2);return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec2(r, c);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec2(r, c);\n }\n `}(e,t,n);case 3:return function(e,t,n){if(n)return"\n ivec3 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec3(b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[2]/2),i=a*Math.ceil(e[1]/2);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[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 `}(e,t,n);default:return function(e,t,n){if(n)return"\n ivec4 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatchN = texelsInBatch * outShape[1];\n\n int b2 = index / texelsInBatchN;\n index -= b2 * texelsInBatchN;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec4(b2, b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[e.length-1]/2),i=a*Math.ceil(e[e.length-2]/2);let s=i,o="",u="b, r, c";for(let t=2;t1&&!pe(t,n)&&r.lengthe[t])).join(", ")}function OL(e,t,n){const r={},a={},i={},s=[];let o,u,l,c=null,p=null;p=e.getUniformLocation(n,"NAN",!1),1===Ve().getNumber("WEBGL_VERSION")&&(c=e.getUniformLocation(n,"INFINITY",!1));const d=!1;for(let s=0;s{s[r]=e.getUniformLocation(n,t.name,d)})),{uniformLocations:r,customUniformLocations:s,infLoc:c,nanLoc:p,inShapesLocations:a,inTexShapesLocations:i,outShapeLocation:o,outShapeStridesLocation:l,outTexShapeLocation:u}}function RL(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(((e,n)=>{const r=e.logicalShape,a=t[n],i=a.shape;if(!pe(r,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${i} must match`);if(e.isUniform&&a.isUniform)return;const s=e.texShape,o=a.isUniform?null:a.texData.texShape;if(!pe(s,o))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${s} and ${o} must match`)}))}function FL(e){return Ve().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}class YL{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=zA.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=gL();this.outputShape=e,this.enableShapeUniforms=FL(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?bL(["r","c","d"],e):yL(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[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 ${t.output} = result;\n }\n `}}class zL{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=zA.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=gL();this.outputShape=e,this.enableShapeUniforms=FL(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?bL(["r","c","d"],e):yL(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[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 ${t.output} = result;\n }\n `}}class BL{constructor(e){this.variableNames=["A"],this.outTexUsage=BA.DOWNLOAD;const t=gL();this.outputShape=e,this.userCode=`\n ${vL}\n\n void main() {\n float x = getAAtOutCoords();\n ${t.output} = encode_float(x);\n }\n `}}class PL{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=BA.DOWNLOAD;const t=gL();this.outputShape=e,this.userCode=`\n ${vL}\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 `}}class HL{constructor(e,t=!1){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=gL();this.outputShape=e,this.enableShapeUniforms=FL(this.outputShape.length);let r="result";t&&(r="floor(result * 255. + 0.5)"),this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":xL(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 / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n vec4 values = ${n.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 ${n.output} = vec4(${r}, 0., 0., 0.);\n }\n `}}class jL{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=gL();this.outputShape=e,this.enableShapeUniforms=FL(this.outputShape.length);let r="",a="result";t&&(a="floor(result * 255. + 0.5)");for(let t=0;t<=1;t++)for(let a=0;a<=1;a++){const i=2*t+a;r+=`\n localCoords = coords;\n if(localCoords[2] + ${a} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) {\n localCoords[2] += ${a};\n if (localCoords[1] + ${t} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) {\n localCoords[1] += ${t};\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n values = ${n.texture2D}(A, uv);\n\n if (offset == 0) {\n result[${i}] = values[0];\n } else if (offset == 1) {\n result[${i}] = values[1];\n } else if (offset == 2) {\n result[${i}] = values[2];\n } else {\n result[${i}] = values[3];\n }\n }\n }\n `}this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":xL(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 ${r}\n\n ${n.output} = ${a};\n }\n `}}function UL(e,t,n,r,a,i){!function(e,t){const n=Ve().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0)throw new Error(`Requested texture size [${e}x${t}] is invalid.`);if(e>n||t>n)throw new Error(`Requested texture size [${e}x${t}] greater than WebGL maximum on this browser / GPU [${n}x${n}].`)}(t,n);const s=function(e){return rL(e,(()=>e.createTexture()),"Unable to create WebGLTexture.")}(e),o=e.TEXTURE_2D;return WA(e,(()=>e.bindTexture(o,s))),WA(e,(()=>e.texParameteri(o,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE))),WA(e,(()=>e.texParameteri(o,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE))),WA(e,(()=>e.texParameteri(o,e.TEXTURE_MIN_FILTER,e.NEAREST))),WA(e,(()=>e.texParameteri(o,e.TEXTURE_MAG_FILTER,e.NEAREST))),1===Ve().getNumber("WEBGL_VERSION")?WA(e,(()=>e.texImage2D(o,0,r,t,n,0,a,i,null))):WA(e,(()=>e.texStorage2D(o,1,r,t,n))),WA(e,(()=>e.bindTexture(e.TEXTURE_2D,null))),{texture:s,texShape:[n,t]}}function qL(e){return e.internalFormatFloat}function WL(e){return e.internalFormatHalfFloat}function VL(e){return e.downloadTextureFormat}function GL(e){return e.internalFormatPackedFloat}function KL(e){return e.internalFormatPackedHalfFloat}class JL{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];const t=Ve().getNumber("WEBGL_VERSION");null!=e?(this.gl=e,function(e,t){RA[e]=t}(t,e)):this.gl=YA(t);let n="WEBGL_color_buffer_float";const r="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),1===Ve().getNumber("WEBGL_VERSION")){const e="OES_texture_float",t="OES_texture_half_float";if(this.textureFloatExtension=GA(this.gl,e),pL(this.gl,t))this.textureHalfFloatExtension=GA(this.gl,t);else if(Ve().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),pL(this.gl,r))this.colorBufferHalfFloatExtension=GA(this.gl,r);else if(Ve().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",pL(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!pL(this.gl,r))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension(r)}this.vertexBuffer=function(e){return function(e,t){const n=rL(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return WA(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),WA(e,(()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW))),n}(e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}(this.gl),this.indexBuffer=function(e){return function(e,t){const n=rL(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return WA(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n))),WA(e,(()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW))),n}(e,new Uint16Array([0,1,2,2,1,3]))}(this.gl),this.framebuffer=function(e){return rL(e,(()=>e.createFramebuffer()),"Unable to create WebGLFramebuffer.")}(this.gl),this.textureConfig=qA(this.gl,this.textureHalfFloatExtension)}get debug(){return Ve().getBool("DEBUG")}dispose(){if(this.disposed)return;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.");const e=this.gl;WA(e,(()=>e.finish())),WA(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,null))),WA(e,(()=>e.deleteFramebuffer(this.framebuffer))),WA(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,null))),WA(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null))),WA(e,(()=>e.deleteBuffer(this.indexBuffer))),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=HA(t,n);return UL(e,a,i,qL(r),r.textureFormatFloat,e.FLOAT)}(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=HA(t,n);return UL(e,a,i,WL(r),r.textureFormatFloat,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=HA(t,n);return UL(e,a,i,VL(r),e.RGBA,e.UNSIGNED_BYTE)}(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),function(e,t,n){WA(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),n.data instanceof Uint8Array?2===Ve().getNumber("WEBGL_VERSION")?WA(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,e.RGBA,e.UNSIGNED_BYTE,n.data))):WA(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data))):2===Ve().getNumber("WEBGL_VERSION")?WA(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n))):WA(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n))),WA(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,n,r){this.throwIfDisposed(),function(e,t,n,r,a,i){let s,o,u;WA(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),a instanceof Uint8Array?(s=new Uint8Array(n*r*4),o=e.UNSIGNED_BYTE,u=e.RGBA):(s=new Float32Array(n*r*4),o=e.FLOAT,u=i.internalFormatPackedFloat),s.set(a),2===Ve().getNumber("WEBGL_VERSION")?WA(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n,r,e.RGBA,o,s))):WA(e,(()=>e.texImage2D(e.TEXTURE_2D,0,u,n,r,0,e.RGBA,o,s))),WA(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}(this.gl,e,t,n,r,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=UA(t,n);return UL(e,a,i,KL(r),e.RGBA,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=UA(t,n);return UL(e,a,i,GL(r),e.RGBA,e.FLOAT)}(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(tL(this.gl,this.framebuffer),this.outputTexture=null),WA(this.gl,(()=>this.gl.deleteTexture(e)))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>function(e,t,n,r){const[a,i]=HA(t,n),s=new Uint8Array(t*n*4);return WA(e,(()=>e.readPixels(0,0,a,i,r.downloadTextureFormat,e.UNSIGNED_BYTE,s))),new Float32Array(s.buffer)}(this.gl,t,n,this.textureConfig)))}downloadPackedMatrixFromBuffer(e,t,n,r,a,i){return function(e,t,n,r,a,i,s,o){const u=e,l=new Float32Array(function(e,t){const[n,r]=UA(e,t);return n*r*4}(i,s));return u.bindBuffer(u.PIXEL_PACK_BUFFER,t),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,l),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),l}(this.gl,e,0,0,0,a,i,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return function(e,t,n){const r=e,a=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,a),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),a}(this.gl,e,t)}createBufferFromTexture(e,t,n){this.bindTextureToFrameBuffer(e);const r=function(e,t,n,r){const a=e.createBuffer();WA(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,a)));const i=16*t*n;return WA(e,(()=>e.bufferData(e.PIXEL_PACK_BUFFER,i,e.STREAM_READ))),WA(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0))),WA(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null))),a}(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,n;if(Ve().getBool("WEBGL_FENCE_API_ENABLED")){const r=e,a=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=()=>{const e=r.clientWaitSync(a,0,0);return e===r.ALREADY_SIGNALED||e===r.CONDITION_SATISFIED},t=a}else Ve().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(t,Ve().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:t,isFencePassed:n}}downloadMatrixFromPackedTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>function(e,t,n){const r=new Float32Array(t*n*4);return WA(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,r))),r}(this.gl,t,n)))}createProgram(e){this.throwIfDisposed();const t=this.gl;null==this.vertexShader&&(this.vertexShader=function(e){const t=gL();return function(e,t){const n=rL(e,(()=>e.createShader(e.VERTEX_SHADER)),"Unable to create vertex WebGLShader.");if(WA(e,(()=>e.shaderSource(n,t))),WA(e,(()=>e.compileShader(n))),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw console.log(e.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}(e,`${t.version}\n precision highp float;\n ${t.attribute} vec3 clipSpacePos;\n ${t.attribute} vec2 uv;\n ${t.varyingVs} vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }`)}(t));const n=function(e){return rL(e,(()=>e.createProgram()),"Unable to create WebGLProgram.")}(t);return WA(t,(()=>t.attachShader(n,this.vertexShader))),WA(t,(()=>t.attachShader(n,e))),function(e,t){if(WA(e,(()=>e.linkProgram(t))),!Ve().get("ENGINE_COMPILE_ONLY")&&!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")}(t,n),this.debug&&XA(t,n),this.vertexAttrsAreBound||(this.setProgram(n),this.vertexAttrsAreBound=function(e,t,n){return WA(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),ZA(e,t,"clipSpacePos",n,3,20,0)&&ZA(e,t,"uv",n,2,20,12)}(t,this.program,this.vertexBuffer)),n}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&WA(this.gl,(()=>this.gl.deleteProgram(e)))}setProgram(e){this.throwIfDisposed(),this.program=e,null!=this.program&&this.debug&&XA(this.gl,this.program),WA(this.gl,(()=>this.gl.useProgram(e)))}getUniformLocation(e,t,n=!0){return this.throwIfDisposed(),n?function(e,t,n){return rL(e,(()=>e.getUniformLocation(t,n)),'uniform "'+n+'" not present in program.')}(this.gl,e,t):function(e,t,n){return e.getUniformLocation(t,n)}(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),WA(this.gl,(()=>this.gl.getAttribLocation(e,t)))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,n){this.throwIfDisposed(),this.throwIfNoProgram(),QA(this.gl,e,t,n)}setOutputMatrixTexture(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)}setOutputPackedMatrixTexture(e,t,n){this.throwIfDisposed();const[r,a]=UA(t,n);this.setOutputMatrixTextureDriver(e,r,a)}setOutputMatrixWriteRegion(e,t,n,r){this.setOutputMatrixWriteRegionDriver(n,e,r,t)}setOutputPackedMatrixWriteRegion(e,t,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&XA(this.gl,this.program),nL(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;this.debug&&this.debugValidate(),WA(e,(()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),WA(this.gl,(()=>this.gl.finish()))}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=GA(this.gl,2===Ve().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(2===Ve().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2(),n=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,n),n}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(2===Ve().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2();return void e.endQuery(t.TIME_ELAPSED_EXT)}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await ye((()=>this.disposed||this.isQueryAvailable(e,Ve().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")))),this.getQueryTime(e,Ve().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(0===t)return null;if(2===t){const t=this.gl;return t.getQueryParameter(e,t.QUERY_RESULT)/1e6}{const t=this.getQueryTimerExtensionWebGL1();return t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(0===t)return!0;if(2===t){const t=this.gl,n=this.getQueryTimerExtensionWebGL2(),r=t.getQueryParameter(e,t.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),r&&!this.disjoint}{const t=this.getQueryTimerExtensionWebGL1(),n=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(t.GPU_DISJOINT_EXT)),n&&!this.disjoint}}pollFence(e){return new Promise((t=>{this.addItemToPoll((()=>e.isFencePassed()),(()=>t()))}))}pollItems(){const e=function(e){let t=0;for(;te.isDoneFn)));for(let t=0;t<=e;++t){const{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1||ye((()=>(this.pollItems(),0===this.itemsToPoll.length)))}bindTextureToFrameBuffer(e){this.throwIfDisposed(),eL(this.gl,e,this.framebuffer),this.debug&&nL(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?(eL(this.gl,this.outputTexture,this.framebuffer),this.debug&&nL(this.gl)):tL(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const n=t();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(e,t,n){this.throwIfDisposed();const r=this.gl;eL(r,e,this.framebuffer),this.debug&&nL(r),this.outputTexture=e,WA(r,(()=>r.viewport(0,0,t,n))),WA(r,(()=>r.scissor(0,0,t,n)))}setOutputMatrixWriteRegionDriver(e,t,n,r){this.throwIfDisposed(),WA(this.gl,(()=>this.gl.scissor(e,t,n,r)))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(null==this.program)throw new Error("No GPU program is currently set.")}}const{addImpl:XL,bincountImpl:ZL,bincountReduceImpl:QL,ceilImpl:e$,concatImpl:t$,equalImpl:n$,expImpl:r$,expm1Impl:a$,floorImpl:i$,gatherNdImpl:s$,gatherV2Impl:o$,greaterImpl:u$,greaterEqualImpl:l$,lessImpl:c$,lessEqualImpl:p$,linSpaceImpl:d$,logImpl:h$,maxImpl:f$,maximumImpl:m$,minimumImpl:g$,multiplyImpl:y$,negImpl:b$,notEqualImpl:x$,prodImpl:v$,rangeImpl:_$,rsqrtImpl:w$,scatterImpl:M$,sigmoidImpl:N$,simpleAbsImpl:S$,sliceImpl:k$,sparseFillEmptyRowsImpl:D$,sparseReshapeImpl:T$,sparseSegmentReductionImpl:I$,sqrtImpl:E$,stridedSliceImpl:C$,stringNGramsImpl:A$,stringSplitImpl:L$,stringToHashBucketFastImpl:$$,subImpl:O$,tileImpl:R$,topKImpl:F$,transposeImpl:Y$,uniqueImpl:z$}=U;function B$(e,t){return["x","y","z","w","u","v"].slice(0,t).map((t=>`${e}.${t}`))}function P$(e,t){return 1===t?[e]:B$(e,t)}class H${constructor(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=FL(this.outputShape.length),0===this.rank)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{const e=P$("rc",this.rank),t=CL(this.rank),n=this.getOutOfBoundsCondition(e),r=this.getSetup(e),a=this.getOutput(e);this.userCode=`\n void main() {\n ${t} rc = getOutputCoords();\n\n if(${n}) {\n setOutput(vec4(0));\n } else {\n ${r}\n\n setOutput(vec4(${a}));\n }\n }\n `}}getSourceCoordsArr(e){const t=[];for(let n=0;n<=1;n++)for(let r=0;r<=1;r++){let a=`${0===n?"r":"rp1"}, ${0===r?"c":"cp1"}`;for(let t=2;t ${this.enableShapeUniforms?"outShape":this.outputShape[0]}`;let t="";for(let n=this.rank-2;n= ${this.enableShapeUniforms?`outShape[${n}]`:this.outputShape[n]}`,n= ${n};\n bool rEdge = rp1 >= ${r};\n `}getOutput(e){const t=this.getSourceCoordsArr(e);return 1===this.rank?`getA(rc), (rc + 1 >= ${this.enableShapeUniforms?"outShape":this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0`:`getA(${t[0]}),\n cEdge ? 0. : getA(${t[1]}),\n rEdge ? 0. : getA(${t[2]}),\n rEdge || cEdge ? 0. : getA(${t[3]})`}}class j${constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=FL(this.outputShape.length);let n="";for(let e=0;e<4;e++){let t="thisRC = rc;";e%2==1&&(t+="thisRC.z += 1;"),e>1&&(t+="thisRC.y += 1;"),n+=`\n ${t}\n ${e>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[${e}] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n ${e>0?"}":""}\n `}var r,a;this.userCode=`\n ${r=t,a=this.enableShapeUniforms,`\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ${a?function(e,t,n="index"){const r=e.map(((e,t)=>t)),a=function(e,t){const n=e.length,r=e.map((e=>`${t}[${e}]`)),a=new Array(n-1);a[n-2]=r[n-1];for(let e=n-3;e>=0;--e)a[e]=`(${a[e+1]} * ${r[e+1]})`;return a}(r,t);return a.map(((t,r)=>`int ${e[r]} = ${n} / ${a[r]}; ${r===a.length-1?`int ${e[r+1]} = ${n} - ${e[r]} * ${a[r]}`:`index -= ${e[r]} * ${a[r]}`};`)).join("")}(["r","c","d"],"inputShape"):yL(["r","c","d"],r)}\n return ivec3(r, c, d);\n }\n `}\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":xL(e)}\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]};\n int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]};\n\n ${n}\n\n setOutput(result);\n }\n `}}class U${constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}acquireTexture(e,t,n){const r=W$(t,n),a=V$(e,r,n);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);const i=q$(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=i,this.log();const e=this.freeTextures[a].shift();return this.usedTextures[a].push(e),e}let s;return r===PA.PACKED_2X2_FLOAT32?s=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===PA.PACKED_2X2_FLOAT16?s=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===PA.UNPACKED_FLOAT32?s=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===PA.UNPACKED_FLOAT16?s=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===PA.PACKED_4X1_UNSIGNED_BYTE&&(s=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[a].push(s),this.numUsedTextures++,this._numBytesAllocated+=i,this.log(),s}releaseTexture(e,t,n,r){if(null==this.freeTextures)return;const a=W$(n,r),i=V$(t,a,r);i in this.freeTextures||(this.freeTextures[i]=[]);const s=q$(t,a,this.gpgpu.gl,this.gpgpu.textureConfig,r),o=Ve().get("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==o&&this._numBytesAllocated>o?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=s):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=s),this.numUsedTextures--;const u=this.usedTextures[i],l=u.indexOf(e);if(l<0)throw new Error("Cannot release a texture that was never provided by this texture manager");u.splice(l,1),this.log()}log(){if(!this.logEnabled)return;const e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);const t=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*t)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(null!=this.freeTextures){for(const e in this.freeTextures)this.freeTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e.texture)}));for(const e in this.usedTextures)this.usedTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e.texture)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function q$(e,t,n,r,a){const i=function(e,t){switch(e){case PA.PACKED_2X2_FLOAT32:return GL(t);case PA.PACKED_2X2_FLOAT16:return KL(t);case PA.UNPACKED_FLOAT32:return qL(t);case PA.UNPACKED_FLOAT16:return WL(t);case PA.PACKED_4X1_UNSIGNED_BYTE:return VL(t);default:throw new Error(`Unknown physical texture type ${e}`)}}(t,r);let s;if(a){const[t,n]=UA(e[0],e[1]);s=t*n}else{const[t,n]=HA(e[0],e[1]);s=t*n}const o=function(e,t){const n=e;if(t===n.R32F)return 4;if(t===n.R16F)return 2;if(t===n.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===n.RGBA16F)return 8;if(t===n.RGBA8)return 4;throw new Error(`Unknown internal format ${t}`)}(n,i);return s*o}function W$(e,t){if(e===BA.UPLOAD)return PA.PACKED_2X2_FLOAT32;if(e===BA.RENDER||null==e)return function(e){return Ve().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?PA.PACKED_2X2_FLOAT32:PA.UNPACKED_FLOAT32:e?PA.PACKED_2X2_FLOAT16:PA.UNPACKED_FLOAT16}(t);if(e===BA.DOWNLOAD||e===BA.PIXELS)return PA.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function V$(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`}class G${constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=FL(this.outputShape.length),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 `}}const K$="return abs(x);",J$="return x;";class X${constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=FL(this.outputShape.length),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 `}}class Z${constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=FL(this.outputShape.length);const t=e.length,n=P$("rc",t),r=CL(t),a=function(e,t){if(1===e)return"rc";let n="";for(let r=0;rt.push(e)))}const t=this.texData.get(e),{values:n,shape:r,slice:a,dtype:i,complexTensorInfos:s,isPacked:o}=t;if(null!=a){let t;t=o?new X$(r,J$):new G$(r,J$);const n=this.runWebGLProgram(t,[{dataId:e,shape:r,dtype:i}],i),a=this.read(n.dataId);return this.disposeIntermediateTensorInfo(n),a}if(null!=n)return this.convertAndCacheOnCPU(e);if(Ve().getBool("DEBUG")&&!Ve().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===Ve().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let u,l,c=null;if("complex64"!==i&&Ve().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);const t=this.texData.get(u.dataId);c=this.gpgpu.createBufferFromTexture(t.texture.texture,...jA(r))}if(this.pendingRead.set(e,[]),"complex64"!==i&&await this.gpgpu.createAndWaitForFence(),"complex64"===i){const e=await Promise.all([this.read(s.real.dataId),this.read(s.imag.dataId)]);l=ff(e[0],e[1])}else if(null==c)l=this.getValuesFromTexture(e);else{const e=le(r);l=this.gpgpu.downloadFloat32MatrixFromBuffer(c,e)}if(null!=u&&this.disposeIntermediateTensorInfo(u),null!=c){const e=this.gpgpu.gl;WA(e,(()=>e.deleteBuffer(c)))}const p=this.convertAndCacheOnCPU(e,l),d=this.pendingRead.get(e);return this.pendingRead.delete(e),d.forEach((e=>e(p))),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&oo().removeDataId(e,this),this.pendingDeletes--),p}readToGPU(e,t={}){const n=this.texData.get(e),{values:r,shape:a,slice:i,dtype:s,isPacked:o,texture:u}=n;if("complex64"===s)throw new Error("Does not support reading texture for complex64 dtype.");if(null!=i){let n;n=o?new X$(a,J$):new G$(a,J$);const r=this.runWebGLProgram(n,[{dataId:e,shape:a,dtype:s}],s),i=this.readToGPU(r,t);return this.disposeIntermediateTensorInfo(r),i}if(null==u)throw null!=r?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const l=this.decode(e,t.customTexShape),c=oo().makeTensorFromTensorInfo(l),p=this.texData.get(l.dataId);return Object.assign({tensorRef:c},p.texture)}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map((e=>Ba(e)));return Es(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return Es(e.shape,e.dtype,t)}checkNumericalProblems(e){if(null!=e)for(let t=0;t0}time(e){const t=this.activeTimers,n=[];let r=!1;null==this.programTimersStack?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,e();const a=ue(this.activeTimers.map((e=>e.query))).filter((e=>null!=e)),i=ue(this.activeTimers.map((e=>e.name))).filter((e=>null!=e));this.activeTimers=t,r&&(this.programTimersStack=null);const s={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(Ve().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const e=await Promise.all(a);s.kernelMs=ne(e),s.getExtraProfileInfo=()=>e.map(((e,t)=>({name:i[t],ms:e}))).map((e=>`${e.name}: ${e.ms}`)).join(", ")}else s.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,s})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return Ve().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:Fa(),endMs:null}}endTimer(e){return Ve().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=Fa(),e)}async getQueryTime(e){if(Ve().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(e);const t=e;return t.endMs-t.startMs}disposeData(e,t=!1){if(this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(t?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!t&&this.texData.get(e).refCount>0)return!1;if(this.pendingRead.has(e))return this.pendingDisposal.add(e),this.pendingDeletes++,!1;this.releaseGPUData(e);const{complexTensorInfos:n}=this.texData.get(e);return null!=n&&(this.disposeData(n.real.dataId,t),this.disposeData(n.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:n,texShape:r,usage:a,isPacked:i,slice:s}=this.texData.get(e),o=s&&s.origDataId||e,u=this.dataRefCount.get(o);u>1?this.dataRefCount.set(o,u-1):(this.dataRefCount.delete(o),null!=t&&(this.numBytesInGPU-=this.computeBytes(r,n),this.textureManager.releaseTexture(t,r,a,i)));const l=this.texData.get(e);l.texture=null,l.texShape=null,l.isPacked=!1,l.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=tO){return Ve().getBool("WEBGL_CPU_FORWARD")&&e.every((e=>null==this.texData.get(e.dataId).texture&&le(e.shape)0&&Ie(n[0])){const a=n.map((e=>za(e)));r=this.write(a,e,t)}else r=this.write(n,e,t);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:t}}makeOutput(e,t,n){return oo().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,n),this)}unpackTensor(e){const t=new Z$(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new H$(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const n=[aL(e.shape),...iL(e.shape)],r={dtype:e.dtype,shape:n,dataId:e.dataId},a=[aL(t),...iL(t)],i=new j$(a,n),s=[n],o=this.runWebGLProgram(i,[r],e.dtype,s,!0);return{dataId:o.dataId,shape:t,dtype:o.dtype}}decode(e,t){const n=this.texData.get(e),{isPacked:r,shape:a,dtype:i}=n;null!=t&&ie(le(a)<=t[0]*t[1]*4,(()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data."));const s=sL(a);let o;o=r?new zL(s):new YL(s);const u=[null!=t?t:jA(s)];return{dtype:i,shape:a,dataId:this.runWebGLProgram(o,[{shape:s,dtype:i,dataId:e}],i,u,!0,t).dataId}}runWebGLProgram(e,t,n,r,a=!1,i){const s=this.makeTensorInfo(e.outputShape,n),o=this.texData.get(s.dataId);if(e.packedOutput&&(o.isPacked=!0),e.outPackingScheme===zA.DENSE){const t=null!=i?i:jA(e.outputShape);o.texShape=t.map((e=>2*e))}if(null!=e.outTexUsage&&(o.usage=e.outTexUsage),0===le(s.shape))return o.values=_e(s.dtype,0),s;const u=[],l=t.map((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.");let n=this.texData.get(t.dataId);if(null==n.texture){if(!e.packedInputs&&le(t.shape)<=Ve().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)}if(this.uploadToGPU(t.dataId),!!n.isPacked!=!!e.packedInputs)t=n.isPacked?this.unpackTensor(t):this.packTensor(t),u.push(t),n=this.texData.get(t.dataId);else if(n.isPacked&&!uL(n.shape,t.shape)){const e=t,r=t.shape;t.shape=n.shape,t=this.packedReshape(t,r),u.push(t),n=this.texData.get(t.dataId),e.shape=r}return{shape:t.shape,texData:n,isUniform:!1}}));this.uploadToGPU(s.dataId);const c={shape:s.shape,texData:o,isUniform:!1},p=function(e,t,n){let r="";t.concat(n).forEach((t=>{const a=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0;if(e.enableShapeUniforms&&!t.isUniform){const i=t.texData.texShape,{useSqueezeShape:s,uniformShape:o,keptDims:u}=AL(e.packedInputs,t.shape,i);let l="",c="",p="";if(1===o.length&&e.packedInputs){const e=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)];l=`${e[0]>1}_${e[1]>1}`}else if(2!==o.length||e.packedInputs){if(o.length>2&&!e.packedInputs){const e=Oe(o);p=`${e[0]===i[1]}_${e[e.length-1]===i[1]}`}}else c=`${o[0]>1}_${o[1]>1}`;const d=t.shape.length,h=2===o.length&&pe(t.shape,i),f=1===le(t.shape),m=Io(t.shape,n.shape),g=!e.packedInputs&&d===n.shape.length&&pe(i,n.texData.texShape),y=e.packedInputs||o.length>2?"":`${i[0]>1}_${i[1]>1}`;r+=`${d}_${g}_${s?u:""}_${o.length}_${f}_${m}_${h}_${l}_${c}_${p}_${y}_${a}`}else{const e=t.isUniform?"uniform":t.texData.texShape;r+=`${t.shape}_${e}_${a}`}}));const a=e.userCode;let i=e.constructor.name;return i+="_"+r+"_"+a+`${Ve().getNumber("WEBGL_VERSION")}`,i}(e,l,c),d=this.getAndSaveBinary(p,(()=>function(e,t,n,r){const a=n.map(((e,n)=>{const 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((e=>e.shapeInfo)),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},o=wL(a,s,t),u=function(e,t){const n=rL(e,(()=>e.createShader(e.FRAGMENT_SHADER)),"Unable to create fragment WebGLShader.");if(WA(e,(()=>e.shaderSource(n,t))),WA(e,(()=>e.compileShader(n))),Ve().get("ENGINE_COMPILE_ONLY"))return n;if(!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw JA(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}(e.gl,o),l=e.createProgram(u);return Ve().get("ENGINE_COMPILE_ONLY")?{program:t,fragmentShader:u,source:o,webGLProgram:l,inShapeInfos:i,outShapeInfo:s,uniformLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,inShapesLocations:null,inTexShapesLocations:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:Object.assign({program:t,fragmentShader:u,source:o,webGLProgram:l,inShapeInfos:i,outShapeInfo:s},OL(e,t,l))}(this.gpgpu,e,l,c))),h=null!=this.activeTimers;let f;h&&(f=this.startTimer()),Ve().get("ENGINE_COMPILE_ONLY")||function(e,t,n,r,a){t.program.enableShapeUniforms||(RL(t.inShapeInfos,n),RL([t.outShapeInfo],[r]));const i=r.texData.texture,s=r.texData.texShape;r.texData.isPacked?e.setOutputPackedMatrixTexture(i.texture,s[0],s[1]):e.setOutputMatrixTexture(i.texture,s[0],s[1]),e.setProgram(t.webGLProgram),1===Ve().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach(((n,r)=>{const a=t.program.variableNames[r],i=t.uniformLocations[a],s=t.uniformLocations[`offset${a}`],o=t.inShapesLocations[`${a}Shape`],u=t.inTexShapesLocations[`${a}TexShape`];if(o){const{uniformShape:r}=AL(t.program.packedInputs,n.shape,n.texData.texShape);switch(r.length){case 1:e.gl.uniform1iv(o,new Int32Array(r));break;case 2:e.gl.uniform2iv(o,new Int32Array(r));break;case 3:e.gl.uniform3iv(o,new Int32Array(r));break;case 4:e.gl.uniform4iv(o,new Int32Array(r))}}if(u&&e.gl.uniform2i(u,n.texData.texShape[0],n.texData.texShape[1]),null!=i)if(n.isUniform)if(le(n.shape)<2)e.gl.uniform1f(i,n.uniformValues[0]);else{let t=n.uniformValues;t instanceof Float32Array||(t=new Float32Array(t)),e.gl.uniform1fv(i,t)}else null!=n.texData.slice&&null!=s&&e.gl.uniform1i(s,n.texData.slice.flatOffset),e.setInputMatrixTexture(n.texData.texture.texture,i,r)}));const o=t.outShapeLocation;if(o)switch(r.shape.length){case 1:e.gl.uniform1iv(o,new Int32Array(r.shape));break;case 2:e.gl.uniform2iv(o,new Int32Array(r.shape));break;case 3:e.gl.uniform3iv(o,new Int32Array(r.shape));break;case 4:e.gl.uniform4iv(o,new Int32Array(r.shape))}if(t.outShapeStridesLocation){const n=Oe(r.shape);switch(r.shape.length){case 2:e.gl.uniform1iv(t.outShapeStridesLocation,new Int32Array(n));break;case 3:e.gl.uniform2iv(t.outShapeStridesLocation,new Int32Array(n));break;case 4:e.gl.uniform3iv(t.outShapeStridesLocation,new Int32Array(n))}}t.outTexShapeLocation&&e.gl.uniform2i(t.outTexShapeLocation,r.texData.texShape[0],r.texData.texShape[1]),t.program.customUniforms&&a&&t.program.customUniforms.forEach(((n,r)=>{const i=t.customUniformLocations[r],s=a[r];if("float"===n.type)e.gl.uniform1fv(i,s);else if("vec2"===n.type)e.gl.uniform2fv(i,s);else if("vec3"===n.type)e.gl.uniform3fv(i,s);else if("vec4"===n.type)e.gl.uniform4fv(i,s);else if("int"===n.type)e.gl.uniform1iv(i,s);else if("ivec2"===n.type)e.gl.uniform2iv(i,s);else if("ivec3"===n.type)e.gl.uniform3iv(i,s);else{if("ivec4"!==n.type)throw Error(`uniform type ${n.type} is not supported yet.`);e.gl.uniform4iv(i,s)}})),e.executeProgram()}(this.gpgpu,d,l,c,r),u.forEach((e=>this.disposeIntermediateTensorInfo(e))),h&&(f=this.endTimer(f),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(f)}));const m=Ve().get("WEBGL_FLUSH_THRESHOLD");if(m>0){const e=Fa();e-this.lastGlFlushTime>m&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=e)}if(!Ve().getBool("WEBGL_LAZILY_UNPACK")&&o.isPacked&&!1===a){const e=this.unpackTensor(s);return this.disposeIntermediateTensorInfo(s),e}return s}compileAndRun(e,t,n,r,a=!1){return n=n||t[0].dtype,this.runWebGLProgram(e,t,n,r,a)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(Ve().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach((e=>{this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram),delete this.binaryCache[e]})),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)}floatPrecision(){return null==this.floatPrecisionValue&&(this.floatPrecisionValue=co((()=>{if(!Ve().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=Ve().getBool("DEBUG");Ve().set("DEBUG",!1);const t=this.abs($u(1e-8)).dataSync()[0];if(Ve().set("DEBUG",e),t>0)return 32}return 16}))),this.floatPrecisionValue}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}uploadToGPU(e){const t=this.texData.get(e),{shape:n,dtype:r,values:a,texture:i,usage:s,isPacked:o}=t;if(null!=i)return;const u=null!=this.activeTimers;let l;u&&(l=Fa());let c=t.texShape;if(null==c&&(c=function(e,t=!1){let n=Ve().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t&&(n*=2,e=e.map(((t,n)=>n>=e.length-2?ee(e[n]):e[n])),1===e.length&&(e=[2,e[0]])),2!==e.length){const t=ve(e);e=t.newShape}let r=le(e);if(e.length<=1&&r<=n)return[1,r];if(2===e.length&&e[0]<=n&&e[1]<=n)return e;if(3===e.length&&e[0]*e[1]<=n&&e[2]<=n)return[e[0]*e[1],e[2]];if(3===e.length&&e[0]<=n&&e[1]*e[2]<=n)return[e[0],e[1]*e[2]];if(4===e.length&&e[0]*e[1]*e[2]<=n&&e[3]<=n)return[e[0]*e[1]*e[2],e[3]];if(4===e.length&&e[0]<=n&&e[1]*e[2]*e[3]<=n)return[e[0],e[1]*e[2]*e[3]];if(t){const t=aL(e);let n=2,a=2;return e.length&&([n,a]=iL(e)),r=t*(n/2)*(a/2),fe(r).map((e=>2*e))}return fe(r)}(n,o),t.texShape=c),null!=a){const e=sL(n);let i,s=c[1],p=c[0];const d=a instanceof Uint8Array||a instanceof Uint8ClampedArray;!o&&d||([s,p]=UA(c[0],c[1])),i=o?new jL(e,d):new HL(e,d);const h=d?[p,s]:c,f=this.makeTensorInfo(h,r),m=this.texData.get(f.dataId);m.usage=d?BA.PIXELS:BA.UPLOAD,m.texShape=h,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(f.dataId),s,p,a);const g=[[p,s]],y=!0,b=this.runWebGLProgram(i,[f],r,g,y),x=this.texData.get(b.dataId);t.texShape=x.texShape,t.isPacked=x.isPacked,t.usage=x.usage,Ve().get("ENGINE_COMPILE_ONLY")?this.disposeData(b.dataId):(t.texture=x.texture,t.values=null,this.texData.delete(b.dataId)),this.disposeIntermediateTensorInfo(f),u&&(this.uploadWaitMs+=Fa()-l)}else{const e=this.acquireTexture(c,s,r,o);t.texture=e}}convertAndCacheOnCPU(e,t){const n=this.texData.get(e),{dtype:r}=n;return this.releaseGPUData(e),null!=t&&(n.values=function(e,t){if("float32"===t||"complex64"===t)return e;if("int32"===t||"bool"===t){const n="int32"===t?new Int32Array(e.length):new Uint8Array(e.length);for(let t=0;t1024*this.numMBBeforeWarning*1024){const e=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${e} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,r)}computeBytes(e,t){return e[0]*e[1]*De(t)}checkCompileCompletion(){for(const[,e]of Object.entries(this.binaryCache))this.checkCompletion_(e)}async checkCompileCompletionAsync(){const e=[];if(this.gpgpu.parallelCompilationExtension){for(const[,t]of Object.entries(this.binaryCache))e.push(this.checkCompletionAsync_(t));return Promise.all(e)}for(const[,t]of Object.entries(this.binaryCache)){const n=new Promise((e=>{try{this.checkCompletion_(t),e(!0)}catch(e){throw e}}));e.push(n)}return Promise.all(e)}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await Gh(),this.checkCompletionAsync_(e))}checkCompletion_(e){if(!1===this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)){if(console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)),!1===this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS))throw JA(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.");throw new Error("Failed to link vertex and fragment shaders.")}return!0}getUniformLocations(){for(const[,e]of Object.entries(this.binaryCache)){const{uniformLocations:t,customUniformLocations:n,infLoc:r,nanLoc:a,inShapesLocations:i,inTexShapesLocations:s,outShapeLocation:o,outShapeStridesLocation:u,outTexShapeLocation:l}=OL(this.gpgpu,e.program,e.webGLProgram);e.uniformLocations=t,e.customUniformLocations=n,e.infLoc=r,e.nanLoc=a,e.inShapesLocations=i,e.inTexShapesLocations=s,e.outShapeLocation=o,e.outShapeStridesLocation=u,e.outTexShapeLocation=l}}}nO.nextDataId=0,Ni()&&_o("webgl",(()=>new nO),2);class rO{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=Co(t,n),this.enableShapeUniforms=FL(this.outputShape.length),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 `}}class aO{constructor(e,t,n,r=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=Co(t,n);const a=this.outputShape.length;this.enableShapeUniforms=FL(a);let i="";if(r)if(0===a||1===le(this.outputShape))i="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else if(i=`\n ${CL(a)} coords = getOutputCoords();\n `,1===a)this.enableShapeUniforms?i+="\n result.y = (coords + 1) >= outShape ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ":i+=`\n result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n `;else{const e=P$("coords",a);this.enableShapeUniforms?i+=`\n bool nextRowOutOfBounds =\n (${e[a-2]} + 1) >= outShape[${a} - 2];\n bool nextColOutOfBounds =\n (${e[a-1]} + 1) >= outShape[${a} - 1];\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `:i+=`\n bool nextRowOutOfBounds =\n (${e[a-2]} + 1) >= ${this.outputShape[a-2]};\n bool nextColOutOfBounds =\n (${e[a-1]} + 1) >= ${this.outputShape[a-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 ${i}\n\n setOutput(result);\n }\n `}}function iO(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const sO={kernelName:hn,backendName:"webgl",kernelFunc:iO};function oO(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,i=n.makeTensorInfo(r.shape,"complex64"),s=n.texData.get(i.dataId),o=iO({inputs:{x:r},backend:n}),u=iO({inputs:{x:a},backend:n});return s.complexTensorInfos={real:o,imag:u},i}const uO={kernelName:Nt,backendName:"webgl",kernelFunc:oO},lO="return (a < 0.) ? b * a : a;",cO="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",pO={kernelName:xn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{alpha:i}=r,s=n.makeTensorInfo([],"float32",Oa(i,"float32")),o=Ve().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new aO(cO,a.shape,s.shape):new rO(lO,a.shape,s.shape),u=n.runWebGLProgram(o,[a,s],"float32");return n.disposeIntermediateTensorInfo(s),u}},dO="return (a < 0.) ? b * a : a;",hO="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",fO={kernelName:rr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t,i=Ve().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new aO(hO,r.shape,a.shape):new rO(dO,r.shape,a.shape);return n.runWebGLProgram(i,[r,a],"float32")}};function mO({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:n,dtype:r}){return({inputs:a,backend:i})=>{const{x:s}=a,o=i,u=r||s.dtype;if(o.shouldExecuteOnCPU([s])&&null!=n){const e=o.texData.get(s.dataId),t=n(e.values,u);return o.makeTensorInfo(s.shape,u,t)}let l;return l=Ve().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=t?new X$(s.shape,t):new G$(s.shape,e),o.runWebGLProgram(l,[s],u)}}function gO({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:r=!1,cpuKernelImpl:a,dtype:i}){return({inputs:s,backend:o})=>{const{a:u,b:l}=s,c=o;if(r&&"complex64"===u.dtype){const t=c.texData.get(u.dataId),n=c.texData.get(l.dataId),[r,a]=[[t.complexTensorInfos.real,n.complexTensorInfos.real],[t.complexTensorInfos.imag,n.complexTensorInfos.imag]].map((t=>{const[n,r]=t,a={dataId:n.dataId,dtype:n.dtype,shape:u.shape},i={dataId:r.dataId,dtype:r.dtype,shape:l.shape},s=new rO(e,u.shape,l.shape);return c.runWebGLProgram(s,[a,i],ui(n.dtype,r.dtype))})),i=oO({inputs:{real:r,imag:a},backend:c});return c.disposeIntermediateTensorInfo(r),c.disposeIntermediateTensorInfo(a),i}const p=i||ui(u.dtype,l.dtype);if(("string"===u.dtype||"string"===l.dtype||c.shouldExecuteOnCPU([u,l]))&&null!=a){const e=c.texData.get(u.dataId).values,t=c.texData.get(l.dataId).values,n="string"===u.dtype?qf(e):e,r="string"===u.dtype?qf(t):t,[i,s]=a(u.shape,l.shape,n,r,p),o=c.makeTensorInfo(s,p);return c.texData.get(o.dataId).values=i,o}let d;return d=Ve().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=t?new aO(t,u.shape,l.shape,n):new rO(e,u.shape,l.shape),c.runWebGLProgram(d,[u,l],p)}}function yO(e,t=!1){if("linear"===e)return"return x;";if("relu"===e)return t?"\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":"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : x;\n";if("elu"===e)return t?"\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":"return (x >= 0.0) ? x : (exp(x) - 1.0);";if("relu6"===e)return t?"\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":"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : min(6.0, x);\n";if("prelu"===e)return t?hO:dO;if("leakyrelu"===e)return t?cO:lO;if("sigmoid"===e)return"return 1.0 / (1.0 + exp(-1.0 * x));";throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)}class bO{constructor(e,t,n,r=!1,a=!1,i=!1,s=null,o=!1,u=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n,this.enableShapeUniforms=FL(this.outputShape.length);const l=r?e[1]:e[2],c=Math.ceil(l/2),p=r?"i * 2, rc.y":"rc.y, i * 2",d=a?"rc.z, i * 2":"i * 2, rc.z",h=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let m="",g="";s&&(m=o?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${s}\n }`:u?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${s}\n }`:`vec4 activation(vec4 x) {\n ${s}\n }`,g="result = activation(result);");const y=i?"result += getBiasAtOutCoords();":"";i&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights"),u&&this.variableNames.push("leakyreluAlpha");let b="rc.x",x="rc.x";e[0]`The new shape (${u}) has ${l} elements and the old shape (${a.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`));const c=s.texData.get(a.dataId);return!c.isPacked||uL(a.shape,u)||null!==c.texture&&uL(c.shape,u)?(s.incRef(a.dataId),{dataId:a.dataId,shape:u,dtype:a.dtype}):function(e,t,n){const r=[aL(e.shape),...iL(e.shape)],a={dtype:e.dtype,shape:r,dataId:e.dataId},i=[aL(t),...iL(t)],s=new j$(i,r),o=[r],u=n.runWebGLProgram(s,[a],e.dtype,o,!0);return{dataId:u.dataId,shape:t,dtype:u.dtype}}(a,u,s)}const NO={kernelName:lr,backendName:"webgl",kernelFunc:MO};class SO{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:a,outSize:i}=e;this.outputShape=[r,i];const s=4*Math.floor(n/4),o=n%4;let u="sumValue += dot(values, ones);";if(null!=t){const e=1/t;u=`sumValue += dot(values * ${de(e)?e.toPrecision(2):e}, ones);`}let l="";a%n>0&&(l=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return 0.0;\n }\n `),this.userCode=`\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${l}\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 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 ${u}\n }\n\n int inIdx = inOffset + ${s};\n if (${1===o}) {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n ${u}\n } else if (${2===o}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n ${u}\n } else if (${3===o}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2), 0.0);\n\n ${u}\n }\n setOutput(sumValue);\n }\n `}}class kO{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:a,outSize:i}=e;this.outputShape=[r,i];let s="0.0",o="";"prod"===t?s="1.0":"min"===t?(s="1.0 / 1e-20",o="min"):"max"===t&&(s="-1.0 / 1e-20",o="max");let 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");const l=4*Math.floor(n/4),c=n%4;let p=`\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 = ${o}(values, minMaxValue);\n if (${"min"===t} || ${"max"===t}) {\n minMaxValue = ${o}(values, minMaxValue);\n bvec4 isNaN = isnan(values);\n if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {\n minMaxValue = vec4(NAN);\n }\n }\n }\n `,d="vec4";"all"===t?(s="1.0",p="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",d="bvec4"):"any"===t&&(s="0.0",p="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",d="bvec4");let h="";a%n>0&&(h=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return initializationValue;\n }\n `),this.userCode=`\n const float initializationValue = ${s};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${h}\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(${s});\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 < ${l}; i += 4) {\n int inIdx = inOffset + i;\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${p}\n }\n\n int inIdx = inOffset + ${l};\n if (${1===c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${2===c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${3===c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n ${p}\n }\n setOutput(${u});\n }\n `}}function DO(e,t,n,r){const a=function(e){const t=[];for(;0===t.length||1!==t[t.length-1].outSize;){const n=t.length?t[t.length-1].outSize:e[1],r=Zh(n);t.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return t}(e.shape);let i=e;for(let s=0;s6)throw Error(`Transpose for rank ${t} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(t);for(let t=0;t6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const r=CL(this.rank),a=B$("rc",this.rank),i=new Array(this.rank);for(let e=0;e`Error in matMul: inner shapes (${p}) and (${d}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${r} must match.`));const v=n?[y,p,h]:[y,h,p],_=r?[b,f,d]:[b,d,f],w=MO({inputs:{x:e},backend:a,attrs:{shape:v}}),M=MO({inputs:{x:t},backend:a,attrs:{shape:_}}),N=[w,M],S=Math.max(y,b),k=n?w.shape[1]:w.shape[2],D=null!=i,T=null!=s,I="leakyrelu"===u,E=null!=u?yO(u,!0):null;let C;if((1===h||1===f)&&k>1e3&&!1===(D||T||I||null!=E)){let e=w,t=M;n&&(e=LO({inputs:{x:w},backend:a,attrs:{perm:[0,2,1]}}),N.push(e)),r&&(t=LO({inputs:{x:M},backend:a,attrs:{perm:[0,2,1]}}),N.push(t));const i=1===f;let s=e;1!==f&&(s=MO({inputs:{x:e},backend:a,attrs:{shape:[S,k,1]}}),N.push(s));const o=1===f?2:1;let u=t;i&&(u=MO({inputs:{x:t},backend:a,attrs:{shape:[S,1,k]}}),N.push(u));const l=_O({inputs:{a:s,b:u},backend:a});C=CO({inputs:{x:l},backend:a,attrs:{axis:o,keepDims:!0}}),N.push(l)}else{const u=ui(e.dtype,t.dtype),l=new bO(v,_,[S,h,f],n,r,D,E,T,I),c=[w,M];if(null!=i&&c.push(i),T&&c.push(s),I){const e=a.makeTensorInfo([],"float32",Oa(o,"float32"));c.push(e),N.push(e)}C=a.runWebGLProgram(l,c,u)}const A=MO({inputs:{x:C},backend:a,attrs:{shape:x}});N.push(C);for(const e of N)a.disposeIntermediateTensorInfo(e);return A}const RO={kernelName:ia,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i,bias:s,preluActivationWeights:o}=t,{transposeA:u,transposeB:l,activation:c,leakyreluAlpha:p}=r;return OO({a,b:i,transposeA:u,transposeB:l,backend:n,bias:s,preluActivationWeights:o,leakyreluAlpha:p,activation:c})}},FO="return abs(x);",YO={kernelName:Ze,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])&&"complex64"!==r.dtype){const e=n.texData.get(r.dataId),t=S$(e.values);return n.makeTensorInfo(r.shape,r.dtype,t)}let a;return a=Ve().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new X$(r.shape,FO):new G$(r.shape,FO),n.runWebGLProgram(a,[r],r.dtype)}},zO=mO({opSnippet:"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n"}),BO={kernelName:Qe,backendName:"webgl",kernelFunc:zO},PO=mO({opSnippet:"if (isnan(x)) return x;\n if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));"}),HO={kernelName:et,backendName:"webgl",kernelFunc:PO},jO="return a + b;",UO=gO({opSnippet:jO,packedOpSnippet:jO,supportsComplex:!0,cpuKernelImpl:XL}),qO={kernelName:tt,backendName:"webgl",kernelFunc:UO};class WO{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map(((e,t)=>`T${t}`));const n=[];this.variableNames.forEach((e=>{n.push(`float v${e} = get${e}AtOutCoords();`)}));const r=this.variableNames.map((e=>`v${e}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n float result = ${r};\n setOutput(result);\n }\n `}}class VO{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map(((e,t)=>`T${t}`));const n=[];this.variableNames.forEach((e=>{n.push(`vec4 v${e} = get${e}AtOutCoords();`)}));const r=this.variableNames.map((e=>`v${e}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n vec4 result = ${r};\n setOutput(result);\n }\n `}}const GO={kernelName:nt,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r}=t,a=n;if(1===a.length)return iO({inputs:{x:a[0]},backend:r});if(a.length>Ve().get("WEBGL_MAX_TEXTURES_IN_SHADER")){const t=Math.floor(a.length/2),n=e({inputs:a.slice(0,t),backend:r}),i=e({inputs:a.slice(t),backend:r});return e({inputs:[n,i],backend:r})}const i=a.map((e=>e.dtype)).reduce(((e,t)=>ui(e,t))),s=a.map((e=>e.shape)),o=Ve().getBool("WEBGL_PACK")?new VO(a[0].shape,s):new WO(a[0].shape,s);return r.runWebGLProgram(o,a,i)}},KO={kernelName:rt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=a.shape.length,u=xe(i,a.shape);let l=u;const c=yc(l,o);let p=a;null!=c&&(p=LO({inputs:{x:a},backend:n,attrs:{perm:c}}),l=xc(l.length,o)),gc("all",l,o);const[d,h]=fc(p.shape,l),f=MO({inputs:{x:p},backend:n,attrs:{shape:[-1,le(h)]}}),m=DO(f,f.dtype,"all",n);let g;return g=MO(s?{inputs:{x:m},backend:n,attrs:{shape:mc(d,u)}}:{inputs:{x:m},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),null!=c&&n.disposeIntermediateTensorInfo(p),g}},JO={kernelName:at,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=a.shape.length,u=xe(i,a.shape);let l=u;const c=yc(l,o);let p=a;null!=c&&(p=LO({inputs:{x:a},backend:n,attrs:{perm:c}}),l=xc(l.length,o)),gc("any",l,o);const[d,h]=fc(p.shape,l),f=MO({inputs:{x:p},backend:n,attrs:{shape:[-1,le(h)]}}),m=DO(f,f.dtype,"any",n);let g;return g=MO(s?{inputs:{x:m},backend:n,attrs:{shape:mc(d,u)}}:{inputs:{x:m},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),null!=c&&n.disposeIntermediateTensorInfo(p),g}};class XO{constructor(e,t,n){this.variableNames=["A"];const{windowSize:r,batchSize:a,outSize:i}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[a,i];const s="max"===t?">":"<",o=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 = ${o};\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 `}}class ZO{constructor(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,ie(e.length>2,(()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`));const a=e[e.length-1],i=Math.ceil(a/t);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),r||this.variableNames.push("bestIndicesA");const s=this.outputShape,o=s.length,u=CL(o),l=P$("coords",o);let c,p;if(1===i){p=o+1;const e=CL(p);c=`\n ${e} sourceLocR = ${e}(${l.join()}, 0);\n ++${l[o-1]};\n ${e} sourceLocG = ${e}(${l.join()}, 0);\n ++${l[o-2]};\n ${e} sourceLocA = ${e}(${l.join()}, 0);\n --${l[o-1]};\n ${e} sourceLocB = ${e}(${l.join()}, 0);\n --${l[o-2]};`}else p=o,c=`\n ${u} sourceLocR = coords;\n ++${l[o-1]};\n ${u} sourceLocG = coords;\n ++${l[o-2]};\n ${u} sourceLocA = coords;\n --${l[o-1]};\n ${u} sourceLocB = coords;\n --${l[o-2]};`;const d=["x","y","z","w","u","v"].slice(0,p),h="."+d[p-1],f=d.map((e=>"int "+e)),m=P$("sourceLocR",p-1).concat("inIdx.r"),g=P$("sourceLocG",p-1).concat("inIdx.g"),y=P$("sourceLocB",p-1).concat("inIdx.b"),b=P$("sourceLocA",p-1).concat("inIdx.a"),x="max"===n?"greaterThan":"lessThan",v=r?"":`\n inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),\n getBestIndicesAChannel(${g.join()}),\n getBestIndicesAChannel(${y.join()}),\n getBestIndicesAChannel(${b.join()})));`,_=`vec4(\n getAChannel(${m.join()}),\n hasNextCol ? getAChannel(${g.join()}) : 0.,\n hasNextRow ? getAChannel(${y.join()}) : 0.,\n hasNextRow && hasNextCol ? getAChannel(${b.join()}) : 0.)`,w=r?"":`\n float getBestIndicesAChannel(${f.join()}) {\n return getChannel(getBestIndicesA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }`;this.userCode=`\n float getAChannel(${f.join()}) {\n return getChannel(getA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }\n ${w}\n void main() {\n ${u} coords = getOutputCoords();\n bool hasNextCol = ${l[o-1]} < ${s[o-1]-1};\n bool hasNextRow = ${l[o-2]} < ${s[o-2]-1};\n ${c}\n ivec4 srcIdx = ivec4(sourceLocR${h}, sourceLocG${h},\n sourceLocB${h}, sourceLocA${h}) * ${t};\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = ${_};\n\n for (int i = 0; i < ${t}; i++) {\n inIdx = srcIdx;\n ${v}\n vec4 candidate = ${_};\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 `}}function QO(e,t,n,r=null){let a=t.shape[0],i=t.shape[1];null!=r&&(a=r.shape[0],i=r.shape[1]);const s=Zh(i),o={windowSize:s,inSize:i,batchSize:a,outSize:Math.ceil(i/s)},u=new XO(o,n,null==r),l=[t];null!=r&&l.push(r);const c=e.runWebGLProgram(u,l,"int32");if(1===c.shape[1])return c;const p=QO(e,t,n,c);return e.disposeIntermediateTensorInfo(c),p}function eR(e,t,n,r=null){const a=null!=r?r.shape:t.shape,i=Zh(a[a.length-1]),s=new ZO(a,i,n,null==r),o=null==r?[t]:[t,r],u=e.runWebGLProgram(s,o,"int32");if(u.shape.length===t.shape.length){const r=eR(e,t,n,u);return e.disposeIntermediateTensorInfo(u),r}return u}function tR(e,t,n,r){const a=[n];if(gc("arg"+r.charAt(0).toUpperCase()+r.slice(1),a,t.shape.length),!Ve().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){const n=[],i=e.texData.get(t.dataId);let s=t;null!==i&&i.isPacked&&(s=e.unpackTensor(t),n.push(s));const[o,u]=fc(s.shape,a),l=le(u),c=MO({inputs:{x:s},backend:e,attrs:{shape:[-1,l]}});n.push(c);const p=QO(e,c,r);n.push(p);const d=MO({inputs:{x:p},backend:e,attrs:{shape:o}});return n.forEach((t=>e.disposeIntermediateTensorInfo(t))),d}return eR(e,t,r)}const nR={kernelName:it,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;let s=xe(i,a.shape);const o=yc(s,a.shape.length);let u=a;const l=[];null!=o&&(u=LO({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=xc(s.length,u.shape.length)),gc("argMax",[s[0]],u.shape.length);const c=tR(n,u,s[0],"max");return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}},rR={kernelName:st,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;let s=xe(i,a.shape);const o=yc(s,a.shape.length);let u=a;const l=[];null!=o&&(u=LO({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=xc(s.length,u.shape.length)),gc("argMin",[s[0]],u.shape.length);const c=tR(n,u,s[0],"min");return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}},aR=mO({opSnippet:"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n"}),iR={kernelName:ot,backendName:"webgl",kernelFunc:aR},sR=mO({opSnippet:"if (isnan(x)) return x;return log(x + sqrt(x * x + 1.0));"}),oR={kernelName:ut,backendName:"webgl",kernelFunc:sR},uR=mO({opSnippet:"if (isnan(x)) return x;\n return atan(x);\n"}),lR={kernelName:lt,backendName:"webgl",kernelFunc:uR},cR=gO({opSnippet:"\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return atan(a, b);\n",packedOpSnippet:"\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"}),pR={kernelName:pt,backendName:"webgl",kernelFunc:cR},dR=mO({opSnippet:"if (isnan(x)) return x;\n if ((x < -1.0) || (x > 1.0)) return NAN;\nreturn (log(1.0 + x) - log(1.0 - x)) / 2.0;"}),hR={kernelName:ct,backendName:"webgl",kernelFunc:dR};class fR{constructor(e,t,n,r=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const i=e.filterWidth,s=e.strideHeight,o=e.strideWidth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterHeight,p=e.effectiveFilterWidth,d=e.padInfo.top,h=e.padInfo.left;this.outputShape=e.outShape;const f="avg"===t,m=`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,g=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`;let y="0.0";if(f||(y="-1.0 / 1e-20"),n){const t=">=";return void(this.userCode=`\n const ivec2 strides = ivec2(${s}, ${o});\n const ivec2 pads = ivec2(${d}, ${h});\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 < ${c};\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 < ${p};\n wC += ${l}) {\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 ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r?a?m:g:`wR * ${p} + wC`};\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let b=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(b="avgValue / count");const x=4*Math.floor(i/4),v=i%4,_=`\n if (${f}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec2 strides = ivec2(${s}, ${o});\n const ivec2 pads = ivec2(${d}, ${h});\n const float initializationValue = ${y};\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(${y});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < ${c};\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 < ${x}; wC += 4) {\n int xC = xCCorner + wC * ${l};\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n getValue(batch, xR, xC + 3 * ${l}, d)\n );\n\n ${_}\n }\n\n int xC = xCCorner + ${x};\n if (${1===v}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${_}\n } else if (${2===v}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n initializationValue,\n initializationValue\n );\n\n ${_}\n } else if (${3===v}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n initializationValue\n );\n\n ${_}\n }\n }\n setOutput(${b});\n }\n `}}class mR{constructor(e,t,n,r=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const i=e.filterWidth,s=e.strideDepth,o=e.strideHeight,u=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,p=e.dilationWidth,d=e.effectiveFilterDepth,h=e.effectiveFilterHeight,f=e.effectiveFilterWidth,m=e.padInfo.front,g=e.padInfo.top,y=e.padInfo.left;this.outputShape=e.outShape;const b="avg"===t;let x="0.0";if(b||(x="-1.0 / 1e-20"),n){const t=">=";return void(this.userCode=`\n const ivec3 strides =\n ivec3(${s}, ${o}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\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 < ${d};\n wD += ${l}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${h};\n wR += ${c}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${f};\n wC += ${p}) {\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 ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r?a?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${h} * ${f} +\n wR * ${f} + wC`};\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let v=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(v="avgValue / count");const _=4*Math.floor(i/4),w=i%4,M=`\n if (${b}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec3 strides =\n ivec3(${s}, ${o}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\n const float initializationValue = ${x};\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(${x});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < ${d};\n wD += ${l}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${h};\n wR += ${c}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${_}; wC += 4) {\n int xC = xCCorner + wC * ${p};\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n getValue(batch, xD, xR, xC + 2 * ${p}, ch),\n getValue(batch, xD, xR, xC + 3 * ${p}, ch)\n );\n\n ${M}\n }\n\n int xC = xCCorner + ${_};\n if (${1===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${M}\n } else if (${2===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n initializationValue,\n initializationValue\n );\n\n ${M}\n } else if (${3===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n getValue(batch, xD, xR, xC + 2 * ${p}, ch),\n initializationValue\n );\n\n ${M}\n }\n }\n setOutput(${v});\n }\n }\n `}}const gR={kernelName:dt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;fL(a,"avgPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;ie(bl(s,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=ul(a.shape,i,s,1,o,u);if(1===l.filterWidth&&1===l.filterHeight&&pe(l.inShape,l.outShape))return iO({inputs:{x:a},backend:n});const c=new fR(l,"avg",!1);return n.runWebGLProgram(c,[a],"float32")}},yR={kernelName:ft,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u,dataFormat:l}=r,c=ll(a.shape,i,s,[1,1,1],o,u,l),p=new mR(c,"avg",!1);return n.runWebGLProgram(p,[a],"float32")}};class bR{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i=e.dilationHeight,s=e.dilationWidth,o=e.effectiveFilterHeight,u=e.effectiveFilterWidth,l=o-1-e.padInfo.top,c=u-1-e.padInfo.left,p=1/(t*n);this.userCode=`\n const ivec2 pads = ivec2(${l}, ${c});\n const float avgMultiplier = float(${p});\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 += ${i}) {\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+= ${s}) {\n float dyC = float(dyCCorner + wC) / ${a}.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 `}}class xR{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,i=e.strideHeight,s=e.strideWidth,o=e.dilationDepth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterDepth,p=e.effectiveFilterHeight,d=e.effectiveFilterWidth,h=c-1-e.padInfo.front,f=p-1-e.padInfo.top,m=d-1-e.padInfo.left,g=1/(t*n*r);this.userCode=`\n const ivec3 pads = ivec3(${h}, ${f}, ${m});\n const float avgMultiplier = float(${g});\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 < ${c};\n wD += ${o}) {\n float dyD = float(dyDCorner + wD) / ${a}.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 < ${p};\n wR += ${u}) {\n float dyR = float(dyRCorner + wR) / ${i}.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 < ${d};\n wC += ${l}) {\n float dyC = float(dyCCorner + wC) / ${s}.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 `}}const vR={kernelName:mt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i,{filterSize:o,strides:u,pad:l,dimRoundingMode:c}=r,p=ll(s.shape,o,u,[1,1,1],l,c),d=new xR(p);return n.runWebGLProgram(d,[a],s.dtype)}},_R={kernelName:ht,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i;fL([a,i],"avgPoolGrad");const{filterSize:o,strides:u,pad:l}=r,c=ul(s.shape,o,u,1,l),p=new bR(c);return n.runWebGLProgram(p,[a],s.dtype)}},wR={kernelName:gt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i}=t,{transposeA:s,transposeB:o}=r;return OO({a,b:i,transposeA:s,transposeB:o,backend:n})}};class MR{constructor(e,t,n,r,a,i){this.outputShape=[],this.variableNames=["x","mean","variance"],Co(e,t),Co(e,n);let s="0.0";null!=r&&(Co(e,r),this.variableNames.push("offset"),s="getOffsetAtOutCoords()");let o="1.0";null!=a&&(Co(e,a),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = ${s};\n float scale = ${o};\n float inv = scale * inversesqrt(variance + float(${i}));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n `}}class NR{constructor(e,t,n,r,a,i){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],Co(e,t),Co(e,n);let s="vec4(0.0)";null!=r&&(Co(e,r),this.variableNames.push("offset"),s="getOffsetAtOutCoords()");let o="vec4(1.0)";null!=a&&(Co(e,a),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n void main() {\n vec4 offset = ${s};\n vec4 scale = ${o};\n\n vec4 x = getXAtOutCoords();\n vec4 mean = getMeanAtOutCoords();\n vec4 variance = getVarianceAtOutCoords();\n\n vec4 inv = scale * inversesqrt(variance + vec4(${i}));\n\n setOutput((x - mean) * inv + offset);\n }\n `}}const SR={kernelName:un,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,mean:a,variance:i,offset:s,scale:o}=e;ie(a.shape.length===i.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),ie(null==s||a.shape.length===s.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),ie(null==o||a.shape.length===o.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));let{varianceEpsilon:u}=n;null==u&&(u=.001);const l=[r,a,i];let c=null;null!=s&&(c=s.shape,l.push(s));let p=null;null!=o&&(p=o.shape,l.push(o));const d=Ve().getBool("WEBGL_PACK_NORMALIZATION")?new NR(r.shape,a.shape,i.shape,c,p,u):new MR(r.shape,a.shape,i.shape,c,p,u);return t.runWebGLProgram(d,l,l[0].dtype)}};class kR{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=CL(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const n=function(e){if(1===e)return"sourceLoc";if(e<=6)return DR.slice(0,e).map((e=>"sourceLoc."+e)).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}(this.rank);let r;const a=e.map(((e,t)=>`sourceLoc.${DR[t]} = start[${t}] + coords.${DR[t]};`));r=`\n ${t} sourceLoc;\n ${t} coords = getOutputCoords();\n ${a.join("\n")}\n `,this.userCode=`\n void main() {\n ${r}\n setOutput(getSource(${n}));\n }\n `}}const DR=["x","y","z","w","u","v"];class TR{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const t=CL(this.rank),n=P$("coords",this.rank),r=P$("sourceLoc",this.rank),a=1===this.rank?"sourceLoc":`vec2(${r.slice(-2).join()})`,i=`getChannel(getSource(${r.join()}), ${a})`,s=`\n result.x = ${i};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.y = ${i};\n --${r[this.rank-1]};\n }\n `,o=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 = ${i};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.w = ${i};\n }\n }\n `,u=this.rank<=4?`sourceLoc = coords +\n ${t}(${e.map(((e,t)=>`start[${t}]`)).join()});`:e.map(((e,t)=>`${r[t]} = ${n[t]} + start[${t}];`)).join("\n");this.userCode=`\n void main() {\n ${t} coords = getOutputCoords();\n ${t} sourceLoc;\n ${u}\n vec4 result = vec4(0.);\n ${s}\n ${o}\n setOutput(result);\n }\n `}}function IR(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,size:s}=r,[o,u]=nu(a,i,s);if(Ho(a,o,u),0===le(u))return n.makeTensorInfo(u,a.dtype,[]);if(n.shouldExecuteOnCPU([a])||"string"===a.dtype){const e=n.texData.get(a.dataId),t=k$(e.values,o,u,a.shape,a.dtype);return n.makeTensorInfo(u,a.dtype,t)}const{isPacked:l}=n.texData.get(a.dataId),c=eu(a.shape,o,u);if(l||!c){const e=Ve().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new TR(u):new kR(u),t=[o];return n.runWebGLProgram(e,[a],a.dtype,t)}return n.uploadToGPU(a.dataId),function(e,t,n,r){const a=r.texData.get(e.dataId),i=r.makeTensorInfo(n,e.dtype),s=r.texData.get(i.dataId);Object.assign(s,a),s.refCount=1,s.shape=n,s.dtype=e.dtype;let o=tu(t,Oe(e.shape));a.slice&&(o+=a.slice.flatOffset),s.slice={flatOffset:o,origDataId:a.slice&&a.slice.origDataId||e.dataId};const u=r.dataRefCount.get(s.slice.origDataId)||1;return r.dataRefCount.set(s.slice.origDataId,u+1),i}(a,o,u,n)}const ER={kernelName:wr,backendName:"webgl",kernelFunc:IR},CR={kernelName:yt,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,crops:s}=r;ie(a.shape.length<=4,(()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"));const o=i.reduce(((e,t)=>e*t)),u=ef(a.shape,i,o),l=tf(u.length,i.length),c=nf(a.shape,i,o),p=rf(s,i.length),d=af(c,s,i.length),h=[],f=MO({inputs:{x:a},backend:n,attrs:{shape:u}}),m=LO({inputs:{x:f},backend:n,attrs:{perm:l}}),g=MO({inputs:{x:m},backend:n,attrs:{shape:c}}),y=IR({inputs:{x:g},backend:n,attrs:{begin:p,size:d}});return h.push(f),h.push(m),h.push(g),h.forEach((e=>n.disposeIntermediateTensorInfo(e))),y}},AR={kernelName:bt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:i}=t,{size:s}=r,o=n.readSync(a.dataId),u=n.readSync(i.dataId),l=ZL(o,u,i.dtype,i.shape,s);return n.makeTensorInfo([s],i.dtype,l)}},LR={kernelName:vt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{s0:r,s1:a}=t,i=n.readSync(r.dataId),s=n.readSync(a.dataId),o=Co(Array.from(i),Array.from(s));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}},$R=gO({opSnippet:"return float(a != b);",cpuKernelImpl:x$,dtype:"bool"}),OR={kernelName:Vn,backendName:"webgl",kernelFunc:$R};function RR(e){const{inputs:t,backend:n}=e,{input:r}=t;return iO({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.real},backend:n})}const FR={kernelName:sr,backendName:"webgl",kernelFunc:RR},YR={kernelName:_t,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r,attrs:a}=t,{x:i}=n,{dtype:s}=a;if("complex64"===s){if("complex64"===i.dtype)return iO({inputs:{x:i},backend:r});const t=sp(i.shape),n=e({inputs:{x:i},backend:r,attrs:{dtype:"float32"}}),a=oO({inputs:{real:n,imag:t},backend:r});return t.dispose(),r.disposeIntermediateTensorInfo(n),a}if("complex64"===i.dtype){const t=RR({inputs:{input:i},backend:r}),n=e({inputs:{x:t},backend:r,attrs:{dtype:s}});return r.disposeIntermediateTensorInfo(t),n}if(!Se(i.dtype,s)){const e=iO({inputs:{x:i},backend:r});return{dataId:e.dataId,shape:e.shape,dtype:s}}if("int32"===s)return function(e,t){const n=new G$(e.shape,"return float(int(x));"),r=t.runWebGLProgram(n,[e],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}(i,r);if("bool"===s){const e=r.makeTensorInfo([],"bool",_e("bool",1)),t=$R({inputs:{a:i,b:e},backend:r});return r.disposeIntermediateTensorInfo(e),t}throw new Error(`Error in Cast: failed to cast ${i.dtype} to ${s}`)}},zR="return ceil(x);",BR=mO({opSnippet:zR,packedOpSnippet:zR,cpuKernelImpl:e$}),PR={kernelName:wt,backendName:"webgl",kernelFunc:BR};class HR{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\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 "}}class jR{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\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 "}}const UR={kernelName:Mt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{clipValueMin:i,clipValueMax:s}=r;let o;o=Ve().getBool("WEBGL_PACK_CLIP")?new jR(a.shape):new HR(a.shape);const u=[[i],[s]];return n.runWebGLProgram(o,[a],a.dtype,u)}};class qR{constructor(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 "}}function WR(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}const VR={kernelName:St,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t,a=n.texData.get(r.dataId),i=new qR(r.shape),s=[WR(r,a.complexTensorInfos.real),WR(r,a.complexTensorInfos.imag)];return n.runWebGLProgram(i,s,s[0].dtype)}};class GR{constructor(e){this.outputShape=[],this.outputShape=Jh(e,1),this.variableNames=e.map(((e,t)=>`T${t}`));const t=new Array(e.length-1);t[0]=e[0][1];for(let n=1;n`T${t}`));const o=new Array(e.length-1);o[0]=e[0][t];for(let n=1;n= ${o[e-1]}) {\n return getChannel(\n getT${e}(${JR(s,u,t)}),\n vec2(${JR(l,u,t)}));\n }`}const d=o.length,h=o[o.length-1];p+=`\n return getChannel(\n getT${d}(${JR(s,u,h)}),\n vec2(${JR(l,u,h)}));`,this.userCode=`\n float getValue(${s.map((e=>"int "+e))}) {\n ${p}\n }\n\n void main() {\n ${a} coords = getOutputCoords();\n vec4 result = vec4(getValue(${i}), 0., 0., 0.);\n\n ${i[r-1]} = ${i[r-1]} + 1;\n if (${i[r-1]} < ${n[r-1]}) {\n result.g = getValue(${i});\n }\n\n ${i[r-2]} = ${i[r-2]} + 1;\n if (${i[r-2]} < ${n[r-2]}) {\n result.a = getValue(${i});\n }\n\n ${i[r-1]} = ${i[r-1]} - 1;\n if (${i[r-2]} < ${n[r-2]} &&\n ${i[r-1]} < ${n[r-1]}) {\n result.b = getValue(${i});\n }\n setOutput(result);\n }\n `}}function JR(e,t,n){const r=e.indexOf(t);return e.map(((e,t)=>t===r?`${e} - ${n}`:e)).join()}function XR(e){const{inputs:t,backend:n}=e,{input:r}=t;return iO({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.imag},backend:n})}const ZR={kernelName:mn,backendName:"webgl",kernelFunc:XR};function QR(e,t,n){const r=e[0].dtype;if("complex64"===r){const r=e.map((e=>RR({inputs:{input:e},backend:n}))),a=e.map((e=>XR({inputs:{input:e},backend:n}))),i=QR(r,t,n),s=QR(a,t,n),o=oO({inputs:{real:i,imag:s},backend:n});return r.forEach((e=>n.disposeIntermediateTensorInfo(e))),a.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(s),o}let a=n.shouldExecuteOnCPU(e);if("string"===r&&(a=!0),a){const a=e.map((e=>{const r=le(e.shape.slice(t));return MO({inputs:{x:e},backend:n,attrs:{shape:[-1,r]}})})),i=a.map((e=>({vals:n.readSync(e.dataId),shape:e.shape}))),s=Jh(a.map((e=>e.shape)),1),o=1===a[0].shape[0],u=t$(i,s,r,o),l=Jh(e.map((e=>e.shape)),t),c=n.makeTensorInfo(l,r,u);return a.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}if(e.length>Ve().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){const r=Math.floor(e.length/2),a=QR(e.slice(0,r),t,n),i=QR(e.slice(r),t,n),s=QR([a,i],t,n);return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(i),s}if(Ve().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&e[0].shape.length>1){const a=new KR(e.map((e=>e.shape)),t);return n.runWebGLProgram(a,e,r)}const{tensors2D:i,outShape:s}=function(e,t,n){const r=Jh(e.map((e=>e.shape)),t);return{tensors2D:e.map((e=>MO({inputs:{x:e},attrs:{shape:[-1,le(e.shape.slice(t))]},backend:n}))),outShape:r}}(e,t,n),o=new GR(i.map((e=>e.shape))),u=n.runWebGLProgram(o,i,r);i.forEach((e=>n.disposeIntermediateTensorInfo(e)));const l=MO({inputs:{x:u},attrs:{shape:s},backend:n});return n.disposeIntermediateTensorInfo(u),l}function eF(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r,i=xe(a,t[0].shape)[0],s=Jh(t.map((e=>e.shape)),i);if(0===le(s))return n.makeTensorInfo(s,t[0].dtype,[]);const o=t.filter((e=>le(e.shape)>0));return 1===o.length?iO({inputs:{x:o[0]},backend:n}):(Kh(o.map((e=>e.shape)),i),QR(o,i,n))}const tF={kernelName:kt,backendName:"webgl",kernelFunc:eF};class nF{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const i=e.padInfo.top,s=e.padInfo.left,o=e.strideHeight,u=e.strideWidth,l=e.dilationHeight,c=e.dilationWidth,p=e.filterHeight,d=e.filterWidth,h=4*Math.floor(e.inChannels/4),f=e.inChannels%4,m="channelsLast"===e.dataFormat,g=m?1:2,y=m?2:3,b=m?3:1;let x="",v="";n&&(x=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,v="result = activation(result);");const _=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${x}\n\n const ivec2 strides = ivec2(${o}, ${u});\n const ivec2 pads = ivec2(${i}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[${b}];\n\n ivec2 xRCCorner =\n ivec2(coords[${g}], coords[${y}]) * 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 < ${p}; wR++) {\n int xR = xRCorner + wR * ${l};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${d}; 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 (${m}) {\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===f}) {\n\n if (${m}) {\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===f}) {\n vec2 wValues = vec2(\n getW(wR, wC, ${h}, d2),\n getW(wR, wC, ${h} + 1, d2)\n );\n\n if (${m}) {\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===f}) {\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 (${m}) {\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 ${_}\n ${v}\n setOutput(result);\n }\n `}}class rF{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const t=e.padInfo.front,n=e.padInfo.top,r=e.padInfo.left,a=e.strideDepth,i=e.strideHeight,s=e.strideWidth,o=e.dilationDepth,u=e.dilationHeight,l=e.dilationWidth,c=e.filterDepth,p=e.filterHeight,d=e.filterWidth,h=4*Math.floor(e.inChannels/4),f=e.inChannels%4;this.userCode=`\n const ivec3 strides = ivec3(${a}, ${i}, ${s});\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 < ${c}; wF++) {\n int xF = xFCorner + wF * ${o};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${p}; 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 < ${d}; wC++) {\n int xC = xCCorner + wC * ${l};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${h}; 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===f}) {\n dotProd +=\n getX(batch, xF, xR, xC, ${h}) *\n getW(wF, wR, wC, ${h}, d2);\n } else if (${2===f}) {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, ${h}),\n getX(batch, xF, xR, xC, ${h} + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, ${h}, d2),\n getW(wF, wR, wC, ${h} + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if (${3===f}) {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, ${h}),\n getX(batch, xF, xR, xC, ${h} + 1),\n getX(batch, xF, xR, xC, ${h} + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, ${h}, d2),\n getW(wF, wR, wC, ${h} + 1, d2),\n getW(wF, wR, wC, ${h} + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class aF{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=e,this.enableShapeUniforms=FL(this.outputShape.length);const{dataFormat:n}=t,r=gL(),a="channelsLast"===n,i=a?0:1,s=a?1:2,o=this.enableShapeUniforms?"if(blockIndex < outShape[1] && pos < outShape[0]) {":`if(blockIndex < ${e[1]} && pos < ${e[0]}) {`;let u="";for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)u+=`\n blockIndex = rc.y + ${t};\n pos = rc.x + ${e};\n\n ${o}\n offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];\n d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);\n\n if(d0 < inputShape[${i}] && d0 >= 0) {\n // Use custom imod instead mod. On Intel GPU, mod may generate\n // unexpected value.\n // https://github.com/tensorflow/tfjs/issues/5447\n offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1];\n d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /\n inChannels);\n\n if(d1 < inputShape[${s}] && d1 >= 0) {\n\n ch = imod(pos, inChannels);\n\n if (${a}) {\n innerDims = vec2(d1, ch);\n result[${2*e+t}] = getChannel(\n getA(d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result[${2*e+t}] = 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 ${u}\n\n ${r.output} = result;\n }\n `}}function iF({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:i=null,leakyreluAlpha:s=0,activation:o=null}){const u=e.shape,l=r.texData.get(e.dataId),c=n.inChannels,p=u[0]*u[1]*u[2],d=n.outChannels,h="channelsLast"===n.dataFormat;let f;const m=[];if(null!=i&&!h&&3===i.shape.length){const e=LO({inputs:{x:i},backend:r,attrs:{perm:[1,2,0]}});m.push(e),i=e}if((1!==p&&1!==d||!(c>1e3))&&l.isPacked&&h&&null!=l.texture&&u[2]%2!=0&&pe(l.shape.slice(-3),u.slice(-3))){const c=u[0]*u[1]*(u[2]+1),p={dataId:e.dataId,shape:[1,c,n.inChannels],dtype:e.dtype},d=l.shape;l.shape=l.shape.slice(),l.shape[l.shape.length-2]++,ie(uL(l.shape,p.shape),(()=>`packed reshape ${l.shape} to ${p.shape} isn't free`));const h=MO({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}});m.push(h);const g=OO({a:p,b:h,backend:r,transposeA:!1,transposeB:!1,bias:a,activation:o,preluActivationWeights:i,leakyreluAlpha:s}),y=r.texData.get(g.dataId);ie(y.isPacked,(()=>"batchMatMul result is expected to be packed")),l.shape=d,y.shape=n.outShape,f=iO({inputs:{x:g},backend:r}),f.shape=n.outShape,m.push(g)}else{const u=h?e:LO({inputs:{x:e},backend:r,attrs:{perm:[0,2,3,1]}}),l=u.shape,c=MO({inputs:{x:u},backend:r,attrs:{shape:[1,l[0]*l[1]*l[2],n.inChannels]}}),p=MO({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}}),d=OO({a:c,b:p,transposeA:!1,transposeB:!1,backend:r,bias:a,activation:o,preluActivationWeights:i,leakyreluAlpha:s}),g=MO({inputs:{x:d},backend:r,attrs:{shape:[n.batchSize,n.outHeight,n.outWidth,n.outChannels]}});f=h?g:LO({inputs:{x:g},backend:r,attrs:{perm:[0,3,1,2]}}),h||(m.push(u),m.push(g)),m.push(c),m.push(p),m.push(d)}for(const e of m)r.disposeIntermediateTensorInfo(e);return f}function sF({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:i=null,leakyreluAlpha:s=0,activation:o=null}){const{filterWidth:u,filterHeight:l,inChannels:c,outWidth:p,outHeight:d,dataFormat:h}=n,f="channelsLast"===h,m=u*l*c,g=d*p,y=[m,g],b=[];if(null!=i&&!f&&3===i.shape.length){const e=LO({inputs:{x:i},backend:r,attrs:{perm:[1,2,0]}});b.push(e),i=e}const x=MO({inputs:{x:e},backend:r,attrs:{shape:e.shape.slice(1)}}),v=MO({inputs:{x:t},backend:r,attrs:{shape:[1,m,le(t.shape)/m]}});b.push(x),b.push(v);const _=new aF(y,n),w=[x.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],M=r.runWebGLProgram(_,[x],"float32",w),N=MO({inputs:{x:M},backend:r,attrs:{shape:[1,y[0],y[1]]}});b.push(M),b.push(N);const S=null!=a,k=null!=i,D="leakyrelu"===o,T=o?yO(o,!0):null,I=new bO(N.shape,v.shape,[1,g,n.outChannels],!0,!1,S,T,k,D),E=[N,v];if(a&&E.push(a),k&&E.push(i),D){const e=r.makeTensorInfo([],"float32",Oa(s,"float32"));E.push(e),b.push(e)}const C=r.runWebGLProgram(I,E,"float32"),A=MO({inputs:{x:C},backend:r,attrs:{shape:[1,d,p,n.outChannels]}}),L=f?A:LO({inputs:{x:A},backend:r,attrs:{perm:[0,3,1,2]}});f||b.push(A),b.push(C);for(const e of b)r.disposeIntermediateTensorInfo(e);return L}const oF={kernelName:Dt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dataFormat:u,dilations:l,dimRoundingMode:c}=r,p=xl(u),d=cl(a.shape,i.shape,s,l,o,c,!1,p);let h;if(1!==d.filterHeight||1!==d.filterWidth||1!==d.dilationHeight||1!==d.dilationWidth||1!==d.strideHeight||1!==d.strideWidth||"SAME"!==d.padInfo.type&&"VALID"!==d.padInfo.type)if(Ve().getBool("WEBGL_CONV_IM2COL")&&1===a.shape[0])h=sF({x:a,filter:i,convInfo:d,backend:n});else{const e=new nF(d);h=n.runWebGLProgram(e,[a,i],"float32")}else h=iF({x:a,filter:i,convInfo:d,backend:n});const f=MO({inputs:{x:h},backend:n,attrs:{shape:d.outShape}});return n.disposeIntermediateTensorInfo(h),f}};class uF{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,i="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} - ${a};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n if (${i}) {\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 `}}class lF{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i="channelsLast"===e.dataFormat,s=t-1-e.padInfo.top,o=n-1-e.padInfo.left,u=i?1:2,l=i?2:3,c=i?3:1;this.userCode=`\n const ivec2 pads = ivec2(${s}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[${c}];\n\n ivec2 dyCorner = ivec2(coords[${u}], coords[${l}]) - 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) / ${a}.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 (${i}) {\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 `}}class cF{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.padInfo.front,i=e.padInfo.top,s=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} - ${a};\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} - ${i};\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} - ${s};\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 `}}class pF{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,i=e.strideHeight,s=e.strideWidth,o=t-1-e.padInfo.front,u=n-1-e.padInfo.top,l=r-1-e.padInfo.left;this.userCode=`\n const ivec3 pads = ivec3(${o}, ${u}, ${l});\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) / ${a}.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) / ${i}.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) / ${s}.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 `}}const dF={kernelName:Tt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,dy:i}=t,{strides:s,pad:o,dataFormat:u,dimRoundingMode:l,filterShape:c}=r,p=xl(u),d=cl(a.shape,c,s,1,o,l,!1,p),h=new uF(d);return n.runWebGLProgram(h,[a,i],"float32")}},hF={kernelName:It,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{inputShape:s,strides:o,pad:u,dataFormat:l,dimRoundingMode:c}=r,p=xl(l),d=cl(s,i.shape,o,1,u,c,!1,p),h=new lF(d);return n.runWebGLProgram(h,[a,i],"float32")}},fF={kernelName:Et,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dilations:u}=r,l=pl(a.shape,i.shape,s,u,o),c=new rF(l);return n.runWebGLProgram(c,[a,i],"float32")}},mF={kernelName:Ct,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,dy:i}=t,{strides:s,pad:o,filterShape:u}=r,l=pl(a.shape,u,s,1,o),c=new cF(l);return n.runWebGLProgram(c,[a,i],"float32")}},gF={kernelName:At,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{pad:s,strides:o,inputShape:u}=r,l=pl(u,i.shape,o,1,s),c=new pF(l);return n.runWebGLProgram(c,[a,i],"float32")}},yF=mO({opSnippet:"if (isnan(x)) return x;\n return cos(x);\n"}),bF={kernelName:Lt,backendName:"webgl",kernelFunc:yF},xF=mO({opSnippet:"\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n"}),vF={kernelName:$t,backendName:"webgl",kernelFunc:xF};class _F{constructor(e,t,n,r,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[i,s,o,u]=e,[l]=t,[c,p]=n;this.outputShape=[l,c,p,u];const d="bilinear"===r?1:0,[h,f]=[s-1+".0",o-1+".0"],[m,g,y]=c>1?[""+(s-1)/(c-1),"(y2-y1) * height_ratio",`y1*${h} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${h}`],[b,x,v]=p>1?[""+(o-1)/(p-1),"(x2-x1) * width_ratio",`x1*${f} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${f}`];this.userCode=`\n const float height_ratio = float(${m});\n const float width_ratio = float(${b});\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 >= ${i}) {\n return;\n }\n\n float height_scale = ${g};\n float width_scale = ${x};\n\n float in_y = ${y};\n if( in_y < 0.0 || in_y > ${h} ) {\n setOutput(float(${a}));\n return;\n }\n float in_x = ${v};\n if( in_x < 0.0 || in_x > ${f} ) {\n setOutput(float(${a}));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if(${d} == 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 `}}const wF={kernelName:Ft,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:i,boxInd:s}=t,{cropSize:o,method:u,extrapolationValue:l}=r,c=new _F(a.shape,i.shape,o,u,l);return n.runWebGLProgram(c,[a,i,s],"float32")}};var MF;!function(e){e.Prod="*",e.Sum="+"}(MF||(MF={}));class NF{constructor(e,t,n,r){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const a=this.outputShape.length,i=this.op===MF.Prod?"1.0":"0.0",s=n?i:`getX(${SF(a,"coords",this.op)})`,o=this.outputShape[this.outputShape.length-1];let u="",l="";n?(u=r?"end != "+(o-1):"end != 0",l=r?"end + 1":"end - 1"):(u=r?`end + pow2 < ${o}`:"end >= pow2",l=r?"end + pow2":"end - pow2"),this.userCode=`\n void main() {\n ${CL(a)} coords = getOutputCoords();\n int end = ${kF(a,"coords",this.op)};\n float val = ${s};\n int pow2 = int(pow(2.0, index));\n if (${u}) {\n int idx = ${l};\n ${kF(a,"coords",this.op)} = idx;\n val ${this.op}= getX(${SF(a,"coords",this.op)});\n }\n setOutput(val);\n }\n `}}function SF(e,t,n){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 new Error(`Cumulative ${n} for rank ${e} is not yet supported`)}function kF(e,t,n){if(1===e)return`${t}`;if(2===e)return`${t}.y`;if(3===e)return`${t}.z`;if(4===e)return`${t}.w`;throw new Error(`Cumulative ${n} for rank ${e} is not yet supported`)}function DF(e,t,n,r,a,i){const s=t.shape.length,o=yc([r],s);let u=t;null!=o&&(u=LO({inputs:{x:t},backend:n,attrs:{perm:o}}));const l=xc(1,s)[0];if(l!==s-1)throw new Error(`WebGL cumprod shader expects an inner-most axis=${t.shape.length-1} but got axis=${r}`);const c=u.shape[l];let p=iO({inputs:{x:u},backend:n});for(let t=0;t<=Math.ceil(Math.log2(c))-1;t++){const r=new NF(e,u.shape,!1,i),a=[[t]],s=p;p=n.runWebGLProgram(r,[p],p.dtype,a),n.disposeIntermediateTensorInfo(s)}if(a){const t=new NF(e,u.shape,a,i),r=p;p=n.runWebGLProgram(t,[p],p.dtype),n.disposeIntermediateTensorInfo(r)}if(null!=o){const e=LO({inputs:{x:p},backend:n,attrs:{perm:bc(o)}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(u),e}return p}const TF={kernelName:Ot,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,exclusive:s,reverse:o}=r;return DF(MF.Prod,a,n,i,s,o)}},IF={kernelName:Rt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,exclusive:s,reverse:o}=r;return DF(MF.Sum,a,n,i,s,o)}},EF={kernelName:Yt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:i}=t,{size:s,binaryOutput:o}=r;if(1===a.shape.length){const e=n.readSync(a.dataId),t=n.readSync(i.dataId),r=ZL(e,t,i.dtype,i.shape,s);return n.makeTensorInfo([s],i.dtype,r)}if(2===a.shape.length){const e=n.bufferSync(a),t=n.bufferSync(i),r=QL(e,t,s,o);return n.makeTensorInfo(r.shape,i.dtype,r.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${a.shape.length}.`)}};class CF{constructor(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 `}getHeightCoordString(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"}getWidthCoordString(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"}getDepthCoordString(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"}getOutputDepthSize(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}}const AF={kernelName:zt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockSize:i,dataFormat:s}=r,o=a.shape[0],u=("NHWC"===s?a.shape[1]:a.shape[2])*i,l=("NHWC"===s?a.shape[2]:a.shape[3])*i,c=("NHWC"===s?a.shape[3]:a.shape[1])/(i*i),p=new CF("NHWC"===s?[o,u,l,c]:[o,c,u,l],i,s);return n.runWebGLProgram(p,[a],a.dtype)}};class LF{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=FL(this.outputShape.length);const i=e.filterHeight,s=e.filterWidth,o=e.outChannels/e.inChannels;let u="",l="";n&&(u=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,l="result = activation(result);");const c=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${u}\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 / ${o};\n int q = d2 - d1 * ${o};\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 < ${i}; wR++) {\n int xR = xRCorner + wR * dilations[0];\n\n if (xR < 0 || xR >= inDims[0]) {\n continue;\n }\n\n for (int wC = 0; wC < ${s}; wC++) {\n int xC = xCCorner + wC * dilations[1];\n\n if (xC < 0 || xC >= inDims[1]) {\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 ${c}\n ${l}\n setOutput(result);\n }\n `}}class $F{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=FL(this.outputShape.length);const i=e.outChannels/e.inChannels,s=e.padInfo.left,o=e.strideWidth,u=e.dilationWidth,l=e.filterHeight,c=e.filterWidth,p=c;let d="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let e=0;e=0 && xR < inDims[0]) {\n ";for(let e=0;e<(p+1)/2;e++){const t=2*e;if(d+=`\n xC = xCCorner + ${t*u};\n `,1===o){if(t= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n `,d+=1===u&&t>0?`\n xC${t} = vec4(xTexelC${t-2}.zw, xTexelC${t}.xy);\n `:`\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${t} = vec4(previous.zw, xTexelC${t}.xy);\n } else {\n xC${t} = vec4(0.0, 0.0, xTexelC${t}.xy);\n }\n `):d+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xC${t} = xTexelC${t};\n `,t+1= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n `,u>1&&(d+=`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n xTexelC${t}Ready = 1;\n }\n `),d+=`\n xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.xy);\n `):d+=1===e?`\n xC${t+1} = xTexelC${t};\n `:`\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t+1} = xTexelC${t+1};\n `}}else t= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw);\n `,t+1= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${t+1} = vec4(xTexelC${t+1}.xy, final.xy);\n `)):(d+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(\n xTexelC${t}.xy, xTexelC${t+1}.xy);\n `,t+1`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${c}'`));const p=cl(a.shape,i.shape,s,c,o,l,!0);let d;d=Ve().getBool("WEBGL_PACK_DEPTHWISECONV")&&p.strideWidth<=2&&p.outChannels/p.inChannels==1?new $F(p):new LF(p);const h=[[p.padInfo.top,p.padInfo.left],[p.strideHeight,p.strideWidth],[p.dilationHeight,p.dilationWidth],[p.inHeight,p.inWidth]];return n.runWebGLProgram(d,[a,i],"float32",h)}};class RF{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,i=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 * ${i} + 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} - ${a};\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 `}}class FF{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i=t-1-e.padInfo.top,s=n-1-e.padInfo.left,o=e.outChannels/e.inChannels;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[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) / ${a}.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 < ${o}; dm++) {\n int d2 = d1 * ${o} + 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 `}}const YF={kernelName:Pt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,dy:i}=t,{strides:s,dilations:o,pad:u,dimRoundingMode:l,filterShape:c}=r,p=cl(a.shape,c,s,o,u,l,!0),d=new RF(p);return n.runWebGLProgram(d,[a,i],"float32")}},zF={kernelName:Ht,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{strides:s,dilations:o,pad:u,dimRoundingMode:l,inputShape:c}=r,p=cl(c,i.shape,s,o,u,l,!0),d=new FF(p);return n.runWebGLProgram(d,[a,i],"float32")}};class BF{constructor(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 "}}const PF={kernelName:jt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t,a=[...r.shape,...r.shape],i=le(r.shape),s=MO({inputs:{x:r},backend:n,attrs:{shape:[i]}}),o=new BF(i),u=n.runWebGLProgram(o,[s],s.dtype),l=MO({inputs:{x:u},backend:n,attrs:{shape:a}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(u),l}};class HF{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:t,inWidth:n,padInfo:r,strideHeight:a,strideWidth:i,filterHeight:s,filterWidth:o,dilationHeight:u,dilationWidth:l}=e,{top:c,left:p}=r;this.userCode=`\n const ivec2 strides = ivec2(${a}, ${i});\n const ivec2 pads = ivec2(${c}, ${p});\n const float neg_infinity = -3.4e38;\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.w;\n ivec2 outTopLeftCorner =\n coords.yz * strides - pads;\n int hBeg = outTopLeftCorner.x;\n int wBeg = outTopLeftCorner.y;\n\n float curVal = neg_infinity;\n for (int h = 0; h < ${s}; h++) {\n int hIn = hBeg + h * ${u};\n\n if (hIn >= 0 && hIn < ${t}) {\n for (int w = 0; w < ${o}; w++) {\n int wIn = wBeg + w * ${l};\n\n if (wIn >= 0 && wIn < ${n}) {\n float xVal = getX(batch, hIn, wIn, d1);\n float wVal = getW(h, w, d1);\n\n float val = xVal + wVal;\n if (val > curVal) {\n curVal = val;\n }\n }\n }\n }\n }\n\n float result = curVal;\n setOutput(result);\n }\n `}}const jF={kernelName:Ut,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dilations:u}=r,l=ol(a.shape,i.shape,s,o,"NHWC",u);let c;const p=new HF(l);c=n.runWebGLProgram(p,[a,i],"float32");const d=MO({inputs:{x:c},backend:n,attrs:{shape:l.outShape}});return n.disposeIntermediateTensorInfo(c),d}},UF={kernelName:Gt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{equation:a}=r,i=t,{allDims:s,summedDims:o,idDims:u}=Mf(a,i.length);Sf(s.length,u,i);const{path:l,steps:c}=kf(o,u),p=c.length;let d=null,h=s.length;const f=[];for(let e=0;e=0&&(d=CO({inputs:{x:d},backend:n,attrs:{axis:l[e]-(s.length-h),keepDims:!1}}),f.push(d)),h--)}for(const e of f)e!==d&&n.disposeIntermediateTensorInfo(e);return d}},qF=mO({opSnippet:"return (x >= 0.0) ? x : (exp(x) - 1.0);",packedOpSnippet:"\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"}),WF={kernelName:Kt,backendName:"webgl",kernelFunc:qF},VF={kernelName:Jt,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n}=e,{dy:r,y:a}=t,i=Ve().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new aO("\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",r.shape,a.shape):new rO("return (b >= 1.0) ? a : a * (b + 1.0);",r.shape,a.shape);return n.runWebGLProgram(i,[r,a],r.dtype)}},GF=gO({opSnippet:"return float(a == b);",packedOpSnippet:"\n return vec4(equal(a, b));\n",dtype:"bool",cpuKernelImpl:n$}),KF={kernelName:Zt,backendName:"webgl",kernelFunc:GF},JF=mO({opSnippet:`\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 = ${uf};\n float a1 = ${lf};\n float a2 = ${cf};\n float a3 = ${pf};\n float a4 = ${df};\n float a5 = ${hf};\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`}),XF={kernelName:Xt,backendName:"webgl",kernelFunc:JF},ZF=mO({opSnippet:"if (isnan(x)) return x;\n return exp(x);\n",packedOpSnippet:"\n vec4 result = exp(x);\n bvec4 isNaN = isnan(x);\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",cpuKernelImpl:r$,dtype:"float32"}),QF={kernelName:Qt,backendName:"webgl",kernelFunc:ZF};function eY(e){const{inputs:t,attrs:n,backend:r}=e,{dim:a}=n,{input:i}=t,s=i.shape.length,o=i.shape.slice();let u=a;return a<0&&(ie(-(s+1)<=a,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+a+1),o.splice(u,0,1),MO({inputs:{x:i},backend:r,attrs:{shape:o}})}const tY={kernelName:en,backendName:"webgl",kernelFunc:eY},nY="return exp(x) - 1.0;",rY=mO({opSnippet:nY,packedOpSnippet:nY,cpuKernelImpl:a$}),aY={kernelName:tn,backendName:"webgl",kernelFunc:rY};class iY{constructor(e,t,n){this.variableNames=["real","imag"];const r=t[1];this.outputShape=t;const a=n?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,i=n?`${r}.0`:"1.0";let s;if("real"===e)s="return real * expR - imag * expI;";else{if("imag"!==e)throw new Error(`FFT component must be either "real" or "imag", got ${e}.`);s="return real * expI + imag * expR;"}this.userCode=`\n const float exponentMultiplier = ${a};\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n ${s}\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) / ${i};\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n `}}function sY(e,t,n){const r=n.texData.get(e.dataId),a=le(e.shape),i=e.shape[e.shape.length-1],s=MO({inputs:{x:e},backend:n,attrs:{shape:[a/i,i]}}),o=s.shape,u=new iY("real",o,t),l=new iY("imag",o,t),c=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:o},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:o}],p=n.runWebGLProgram(u,c,"float32"),d=n.runWebGLProgram(l,c,"float32"),h=oO({inputs:{real:p,imag:d},backend:n});n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d);const f=MO({inputs:{x:h},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(h),f}const oY={kernelName:nn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t;return sY(r,!1,n)}};class uY{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode="\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "}}function lY(e){const{backend:t,attrs:n}=e,{shape:r,value:a}=n;let{dtype:i}=n;if(i=i||Ae(a),"string"===i){const e=we(i,le(r));return e.fill(a),t.makeTensorInfo(r,i,e)}{const e=new uY(r,a),n=[[a]];return t.runWebGLProgram(e,[],i,n)}}const cY={kernelName:rn,backendName:"webgl",kernelFunc:lY};class pY{constructor(e){this.variableNames=["Image"],this.outputShape=[];const t=e[2];this.outputShape=e,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n\n int coordX = ${t} - x - 1;\n float outputValue;\n if(coordX >= 0 && coordX < ${t}) {\n outputValue = getImage(coords[0], coords[1], coordX, coords[3]);\n } else {\n outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);\n }\n setOutput(outputValue);\n }\n `}}const dY={kernelName:an,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{const{image:n}=e,r=t,a=new pY(n.shape);return r.runWebGLProgram(a,[n],n.dtype)}},hY="return floor(x);",fY=mO({opSnippet:hY,packedOpSnippet:hY,cpuKernelImpl:i$}),mY={kernelName:sn,backendName:"webgl",kernelFunc:fY},gY=gO({opSnippet:"\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",packedOpSnippet:"\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",dtype:"int32"}),yY={kernelName:on,backendName:"webgl",kernelFunc:gY};class bY{constructor(e){this.variableNames=["A"];const t=gL(),[n,r]=e;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 `}}class xY{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=gL(),[n,r]=e;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 `}}const vY={kernelName:ra,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e;let{pixels:a}=t;const{numChannels:i}=r,s="undefined"!=typeof HTMLVideoElement&&a instanceof HTMLVideoElement,o="undefined"!=typeof HTMLImageElement&&a instanceof HTMLImageElement,[u,l]=s?[a.videoWidth,a.videoHeight]:[a.width,a.height],c=[l,u],p=[l,u,i];(o||s)&&(null==_Y&&(_Y=document.createElement("canvas").getContext("2d")),_Y.canvas.width=u,_Y.canvas.height=l,_Y.drawImage(a,0,0,u,l),a=_Y.canvas);const d=n.makeTensorInfo(c,"int32");n.texData.get(d.dataId).usage=BA.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(d.dataId),a);const h=Ve().getBool("WEBGL_PACK")?new xY(p):new bY(p),f=n.runWebGLProgram(h,[d],"int32");return n.disposeData(d.dataId),f}};let _Y;const wY={kernelName:sa,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r,m=xl(c),g=cl(a.shape,i.shape,u,p,l,d,!1,m);let y;const b=[];if(1!==g.filterHeight||1!==g.filterWidth||1!==g.dilationHeight||1!==g.dilationWidth||1!==g.strideHeight||1!==g.strideWidth||"SAME"!==g.padInfo.type&&"VALID"!==g.padInfo.type)if(Ve().getBool("WEBGL_CONV_IM2COL")&&1===a.shape[0])y=sF({x:a,filter:i,convInfo:g,backend:n,bias:s,activation:h,preluActivationWeights:o,leakyreluAlpha:f});else{const e=null!=s,t=null!=o,r="leakyrelu"===h,u=h?yO(h,!1):null,l=new nF(g,e,u,t,r),p=[a,i],d=(e,t)=>{if("NCHW"===t&&1===e.shape.length&&1!==e.shape[0]){const t=MO({inputs:{x:e},backend:n,attrs:{shape:[e.shape[0],1,1]}});return b.push(t),t}return e};if(e&&p.push(d(s,c)),t&&p.push(d(o,c)),r){const e=n.makeTensorInfo([],"float32",Oa(f,"float32"));p.push(e),b.push(e)}y=n.runWebGLProgram(l,p,"float32")}else y=iF({x:a,filter:i,convInfo:g,backend:n,bias:s,activation:h,preluActivationWeights:o,leakyreluAlpha:f});const x=MO({inputs:{x:y},backend:n,attrs:{shape:g.outShape}});return b.push(y),b.forEach((e=>n.disposeIntermediateTensorInfo(e))),x}},MY={kernelName:oa,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dilations:c,dimRoundingMode:p,activation:d,leakyreluAlpha:h}=r,f=[];let m=c;null==m&&(m=[1,1]),ie(bl(u,m),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${m}'`));const g=cl(a.shape,i.shape,u,m,l,p,!0),y=Ve().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,b=d?yO(d,y):null,x=[a,i],v=null!=s,_=null!=o,w="leakyrelu"===d;if(v&&x.push(s),_&&x.push(o),w){const e=n.makeTensorInfo([],"float32",Oa(h,"float32"));x.push(e),f.push(e)}let M;M=y?new $F(g,v,b,_,w):new LF(g,v,b,_,w);const N=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],S=n.runWebGLProgram(M,x,"float32",N);return f.forEach((e=>n.disposeIntermediateTensorInfo(e))),S}};class NY{constructor(e,t,n){this.sliceDim=e,this.strides=t,this.variableNames=["x","indices"],this.outputShape=n;const r=CL(t.length),a=CL(n.length),i=this.sliceDim>1?"strides[j]":"strides";this.userCode=`\n ${r} strides = ${r}(${this.strides});\n void main() {\n ${a} 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 * ${i};\n }\n setOutput(getX(flattenIndex, coords[1]));\n }\n `}}const SY={kernelName:cn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{params:r,indices:a}=t,i=a.shape,s=i[i.length-1],o=le(r.shape),[u,l,c,p]=Yo(r,a),d=MO({inputs:{x:a},backend:n,attrs:{shape:[l,s]}}),h=MO({inputs:{x:r},backend:n,attrs:{shape:[le(r.shape)/c,c]}});if(n.shouldExecuteOnCPU([r,a])||"string"===r.dtype){const e=n.readSync(a.dataId),t=n.bufferSync(r),i=s$(e,t,r.dtype,l,s,c,p,r.shape,o);return n.makeTensorInfo(u,r.dtype,i.values)}const f=new NY(s,p,[l,c]),m=n.runWebGLProgram(f,[h,d],h.dtype),g=MO({inputs:{x:m},backend:n,attrs:{shape:u}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(m),g}};class kY{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;const n=CL(this.rank),r=function(e,t){const n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[];for(let t=0;t= 0) && (index < ${e[2]}) ? 1.0 : 0.0;\n setOutput(inBounds * getA(${r}));\n }\n `}}function DY(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,indices:i}=t,{axis:s,batchDims:o}=r,u=xe(s,a.shape)[0];if(Ve().get("DEBUG")){const e=n.readSync(i.dataId),t=a.shape[u];for(let n=0;n=0,(()=>`GatherV2: the index value ${r} is not in [0, ${t-1}]`))}}const l=Uf(a,i,u,o),c=le(i.shape),p=[],d=MO({inputs:{x:a},backend:n,attrs:{shape:[l.batchSize,l.outerSize,l.dimSize,l.sliceSize]}}),h=MO({inputs:{x:i},backend:n,attrs:{shape:[l.batchSize,c/l.batchSize]}});p.push(d),p.push(h);const f=[l.batchSize,l.outerSize,c/l.batchSize,l.sliceSize];if(n.shouldExecuteOnCPU([a,i])||"string"===a.dtype){const e=n.bufferSync(h),t=n.bufferSync(d),r=o$(t,e,f);return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(l.outputShape,r.dtype,r.values)}const m=new kY(d.shape,f),g=n.runWebGLProgram(m,[d,h],d.dtype);p.push(g);const y=MO({inputs:{x:g},backend:n,attrs:{shape:l.outputShape}});return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),y}const TY={kernelName:ln,backendName:"webgl",kernelFunc:DY},IY=gO({opSnippet:"return float(a > b);",packedOpSnippet:"\n return vec4(greaterThan(a, b));\n",cpuKernelImpl:u$,dtype:"bool"}),EY={kernelName:pn,backendName:"webgl",kernelFunc:IY},CY=gO({opSnippet:"return float(a >= b);",packedOpSnippet:"\n return vec4(greaterThanEqual(a, b));\n",dtype:"bool",cpuKernelImpl:l$}),AY={kernelName:dn,backendName:"webgl",kernelFunc:CY},LY={kernelName:fn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t;return sY(r,!0,n)}},$Y=mO({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"}),OY={kernelName:gn,backendName:"webgl",kernelFunc:$Y},RY=mO({opSnippet:"return float(isinf(x));",dtype:"bool"}),FY={kernelName:yn,backendName:"webgl",kernelFunc:RY},YY=mO({opSnippet:"return float(isnan(x));",dtype:"bool"}),zY={kernelName:bn,backendName:"webgl",kernelFunc:YY},BY=gO({opSnippet:"return float(a < b);",packedOpSnippet:"\n return vec4(lessThan(a, b));\n",cpuKernelImpl:c$,dtype:"bool"}),PY={kernelName:vn,backendName:"webgl",kernelFunc:BY},HY=gO({opSnippet:"return float(a <= b);",packedOpSnippet:"\n return vec4(lessThanEqual(a, b));\n",cpuKernelImpl:p$,dtype:"bool"}),jY={kernelName:_n,backendName:"webgl",kernelFunc:HY},UY={kernelName:wn,backendName:"webgl",kernelFunc:function(e){const{backend:t,attrs:n}=e,{start:r,stop:a,num:i}=n,s=d$(r,a,i);return t.makeTensorInfo([s.length],"float32",s)}},qY=mO({opSnippet:"if (isnan(x)) return x;\n return x < 0.0 ? 0./0. : log(x);\n",packedOpSnippet:"\n vec4 result = log(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r);\n result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g);\n result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b);\n result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a);\n return result;\n",cpuKernelImpl:h$}),WY={kernelName:Mn,backendName:"webgl",kernelFunc:qY},VY=mO({opSnippet:"if (isnan(x)) return x;\n return log(1.0 + x);\n"}),GY={kernelName:Nn,backendName:"webgl",kernelFunc:VY},KY=gO({opSnippet:"return float(a >= 1.0 && b >= 1.0);",packedOpSnippet:"\n return vec4(\n vec4(greaterThanEqual(a, vec4(1.0))) *\n vec4(greaterThanEqual(b, vec4(1.0))));\n",dtype:"bool"}),JY={kernelName:Sn,backendName:"webgl",kernelFunc:KY},XY=mO({opSnippet:"return float(!(x >= 1.0));"}),ZY={kernelName:kn,backendName:"webgl",kernelFunc:XY},QY=gO({opSnippet:"return float(a >= 1.0 || b >= 1.0);",packedOpSnippet:"\n return min(\n vec4(greaterThanEqual(a, vec4(1.0))) +\n vec4(greaterThanEqual(b, vec4(1.0))),\n vec4(1.0));\n",dtype:"bool"}),ez={kernelName:Dn,backendName:"webgl",kernelFunc:QY};class tz{constructor(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[];const i=t,s=e[3]-1;let o;this.outputShape=e;const u=`float(${n}) + float(${r}) * sum`;o=.5===a?`inversesqrt(${u})`:1===a?`1.0/(${u})`:`exp(log(${u}) * float(-${a}));`,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 * ${o};\n setOutput(val);\n }\n `}}class nz{constructor(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const i=t,s=e[3]-1;let o;this.outputShape=e;const u=`float(${n}) + float(${r}) * sum`;o=.5===a?`inversesqrt(${u})`:1===a?`1.0/(${u})`:`exp(log(${u}) * float(-${a}));`,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 * ${o};\n setOutput(result);\n }\n `}}const rz={kernelName:En,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{depthRadius:i,bias:s,alpha:o,beta:u}=r,l=Ve().getBool("WEBGL_PACK_NORMALIZATION")?new nz(a.shape,i,s,o,u):new tz(a.shape,i,s,o,u);return n.runWebGLProgram(l,[a],a.dtype)}};class az{constructor(e,t,n,r,a){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=a,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(${a})\n * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * ${a});\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 `}}const iz={kernelName:Cn,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a,y:i,dy:s}=t,{depthRadius:o,bias:u,alpha:l,beta:c}=r,p=new az(a.shape,o,u,l,c);return n.runWebGLProgram(p,[a,i,s],a.dtype)}};function sz(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reductionIndices:i,keepDims:s}=r,o=a.shape.length,u=xe(i,a.shape);let l=u;const c=yc(l,o),p=null!=c,d=n.shouldExecuteOnCPU([a]);let h=a;if(p){if(d){const e=n.texData.get(h.dataId).values,t=new Array(o);for(let e=0;e 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",cpuKernelImpl:m$}),lz={kernelName:Ln,backendName:"webgl",kernelFunc:uz},cz={kernelName:$n,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;fL(a,"maxPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;ie(bl(s,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=ul(a.shape,i,s,1,o,u);if(1===l.filterWidth&&1===l.filterHeight&&pe(l.inShape,l.outShape))return iO({inputs:{x:a},backend:n});const c=new fR(l,"max",!1);return n.runWebGLProgram(c,[a],a.dtype)}},pz={kernelName:Rn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dataFormat:u,dimRoundingMode:l}=r,c=ll(a.shape,i,s,[1,1,1],o,l,u),p=new mR(c,"max",!1);return n.runWebGLProgram(p,[a],a.dtype)}};class dz{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideHeight,n=e.strideWidth,r=e.dilationHeight,a=e.effectiveFilterHeight,i=e.effectiveFilterWidth,s=a-1-e.padInfo.top,o=i-1-e.padInfo.left,u=a*i-1;this.userCode=`\n const ivec2 pads = ivec2(${s}, ${o});\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 < ${a};\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 < ${i}; 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 * ${i} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n `}}class hz{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.dilationDepth,i=e.dilationHeight,s=e.dilationWidth,o=e.effectiveFilterDepth,u=e.effectiveFilterHeight,l=e.effectiveFilterWidth,c=o-1-e.padInfo.front,p=u-1-e.padInfo.top,d=l-1-e.padInfo.left,h=o*u*l-1;this.userCode=`\n const ivec3 pads = ivec3(${c}, ${p}, ${d});\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 < ${o};\n wD += ${a}) {\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 += ${i}) {\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 < ${l};\n wC += ${s}) {\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 = ${h} -\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} * ${l} +\n wR * ${l} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const fz={kernelName:Fn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i,{filterSize:o,strides:u,pad:l,dimRoundingMode:c}=r,p=ll(s.shape,o,u,[1,1,1],l,c),d=new mR(p,"max",!0),h=n.runWebGLProgram(d,[s],s.dtype),f=new hz(p),m=n.runWebGLProgram(f,[a,h],s.dtype);return n.disposeIntermediateTensorInfo(h),m}},mz={kernelName:On,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i,output:s}=t,o=i;fL([i,s],"maxPoolGrad");const{filterSize:u,strides:l,pad:c,dimRoundingMode:p}=r,d=ul(o.shape,u,l,1,c,p),h=new fR(d,"max",!0),f=n.runWebGLProgram(h,[o],o.dtype),m=new dz(d),g=n.runWebGLProgram(m,[a,f],o.dtype);return n.disposeIntermediateTensorInfo(f),g}},gz={kernelName:Yn,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{filterSize:a,strides:i,pad:s,includeBatchInIndex:o}=t,u=n;ie(4===r.shape.length,(()=>`Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`));const l=[1,1];ie(bl(i,l),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${l}'`));const c=ul(r.shape,a,i,l,s),[p,d]=function(e,t,n,r){let a=new fR(n,"max",!1);const i=r.runWebGLProgram(a,[e],"float32");return a=new fR(n,"max",!0,!0,t),[i,r.runWebGLProgram(a,[e],"float32")]}(r,o,c,u);return[p,d]}},yz={kernelName:zn,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{keepDims:a,axis:i}=t,s=n,o=r.shape.length,u=xe(i,r.shape);let l=u;const c=yc(l,o),p=null!=c,d=s.shouldExecuteOnCPU([r]),h=[];let f=r;if(p){if(d){const e=s.texData.get(f.dataId).values,t=new Array(o);for(let e=0;e 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",cpuKernelImpl:g$}),vz={kernelName:Pn,backendName:"webgl",kernelFunc:xz};class _z{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=CL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),u="reflect"===n?0:1;this.userCode=1!==r?`\n ${a} start = ${a}(${i});\n ${a} end = ${a}(${s});\n\n void main() {\n ${a} outC = getOutputCoords();\n for (int i = 0; i < ${r}; i++) {\n if (outC[i] < start[i]) {\n outC[i] = start[i] * 2 - outC[i] - ${u};\n } else if(outC[i] >= end[i]) {\n outC[i] = (end[i] - 1) * 2 - outC[i] + ${u};\n }\n }\n ${a} coords = outC - start;\n setOutput(getX(${o}));\n }\n `:`\n int start = ${i};\n int end = ${s};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start) {\n outC = start * 2 - outC - ${u};\n } else if(outC >= end) {\n outC = (end - 1) * 2 - outC + ${u};\n }\n setOutput(getX(outC - start));\n }\n `}}class wz{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=CL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=P$("rc",r),u=P$("source",r),l=`${o[r-1]} < ${this.outputShape[r-1]}`,c=1===r?"source":`vec2(${u.slice(-2).join()})`,p="reflect"===n?0:1;let d="";if(1===r){const e=`\n ${a} source = rc;\n if (source < start) {\n source = start * 2 - source - ${p};\n } else if (source >= end) {\n source = (end - 1) * 2 - source + ${p};\n }\n source -= start;\n `;d=`\n ${a} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${c});\n ${o[r-1]} += 1;\n if(${l}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${c});\n }\n `}else{const e=`\n ${a} source = rc;\n ${a} lt = ${a}(lessThan(source, start));\n ${a} gte = ${a}(greaterThanEqual(source, end));\n ${a} orig = 1 - (lt + gte);\n source = orig * source +\n lt * (start * 2 - source - ${p}) +\n gte * ((end - 1) * 2 - source + ${p});\n source -= start;\n `;d=`\n ${a} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${c});\n ${o[r-1]} += 1;\n if(${l}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${c});\n }\n rc = outputLoc;\n ${o[r-2]} += 1;\n if(${o[r-2]} < ${this.outputShape[r-2]}) {\n ${e}\n result[2] = getChannel(getX(${u.join()}), ${c});\n ${o[r-1]} += 1;\n if(${l}) {\n ${e}\n result[3] = getChannel(getX(${u.join()}), ${c});\n }\n }\n `}this.userCode=`\n const ${a} start = ${a}(${i});\n const ${a} end = ${a}(${s});\n\n void main() {\n ${a} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${d}\n setOutput(result);\n }\n `}}const Mz={kernelName:Hn,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r}=e,{paddings:a,mode:i}=n,s=Ve().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new wz(r.shape,a,i):new _z(r.shape,a,i);return t.runWebGLProgram(s,[r],r.dtype)}},Nz=gO({opSnippet:"if (b == 0.0) return NAN;\n return mod(a, b);",packedOpSnippet:"\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"}),Sz={kernelName:jn,backendName:"webgl",kernelFunc:Nz};class kz{constructor(e,t,n){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,n],this.userCode=`\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 `}}const Dz=gO({opSnippet:"\nif (a == b) {\n return 1.0;\n};\nreturn a / b;",packedOpSnippet:"\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",checkOutOfBounds:!0}),Tz={kernelName:Vt,backendName:"webgl",kernelFunc:Dz},Iz="return a - b;",Ez=gO({opSnippet:Iz,packedOpSnippet:Iz,supportsComplex:!0,cpuKernelImpl:O$}),Cz={kernelName:Ur,backendName:"webgl",kernelFunc:Ez};function Az(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{dim:i}=r,s=xe([i],a.shape),o=sz({inputs:{x:a},backend:n,attrs:{reductionIndices:s,keepDims:!1}}),u=mc(o.shape,s),l=MO({inputs:{x:o},backend:n,attrs:{shape:u}}),c=Ez({inputs:{a,b:l},backend:n}),p=ZF({inputs:{x:c},backend:n}),d=CO({inputs:{x:p},backend:n,attrs:{axis:s,keepDims:!1}}),h=MO({inputs:{x:d},backend:n,attrs:{shape:u}}),f=Dz({inputs:{a:p,b:h},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),f}const Lz={kernelName:Ar,backendName:"webgl",kernelFunc:Az},$z={kernelName:Un,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{numSamples:i,seed:s,normalized:o}=r,u=o?a:Az({inputs:{logits:a},backend:n,attrs:{dim:a.shape.length-1}}),l=u.shape[0],c=u.shape[1],p=new kz(l,c,i),d=[[s]],h=n.runWebGLProgram(p,[u],"int32",d);return o||n.disposeIntermediateTensorInfo(u),h}},Oz={kernelName:Wn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])){const e=n.texData.get(r.dataId),[t,a]=b$(e.values,r.shape,r.dtype);return n.makeTensorInfo(a,r.dtype,t)}let a;return a=Ve().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new X$(r.shape,"\n vec4 result = -x;\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"):new G$(r.shape,"if (isnan(x)) return x;\n return -x;\n"),n.runWebGLProgram(a,[r],r.dtype)}},Rz=ih,Fz={kernelName:Gn,backendName:"webgl",kernelFunc:function(e){ua("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:i}=t,{maxOutputSize:s,iouThreshold:o,scoreThreshold:u}=r,l=n.readSync(a.dataId),c=n.readSync(i.dataId),{selectedIndices:p}=Rz(l,c,s,o,u);return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}},Yz=sh,zz={kernelName:Kn,backendName:"webgl",kernelFunc:function(e){ua("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:i}=t,{maxOutputSize:s,iouThreshold:o,scoreThreshold:u,padToMaxOutputSize:l}=r,c=n.readSync(a.dataId),p=n.readSync(i.dataId),{selectedIndices:d,validOutputs:h}=Yz(c,p,s,o,u,l);return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([h]))]}},Bz=oh,Pz={kernelName:Jn,backendName:"webgl",kernelFunc:function(e){ua("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:i}=t,{maxOutputSize:s,iouThreshold:o,scoreThreshold:u,softNmsSigma:l}=r,c=n.readSync(a.dataId),p=n.readSync(i.dataId),d=s,h=o,f=u,m=l,{selectedIndices:g,selectedScores:y}=Bz(c,p,d,h,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([y.length],"float32",new Float32Array(y))]}};class Hz{constructor(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 `}}const jz={kernelName:Zn,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{indices:a}=t,{depth:i,onValue:s,offValue:o}=r,u=le(a.shape),l=new Hz(u,i,s,o),c=MO({inputs:{x:a},backend:n,attrs:{shape:[u]}}),p=n.runWebGLProgram(l,[c],a.dtype);n.disposeIntermediateTensorInfo(c);const d=MO({inputs:{x:p},backend:n,attrs:{shape:[...a.shape,i]}});return n.disposeIntermediateTensorInfo(p),d}};function Uz(e){const{inputs:t,backend:n}=e,{x:r}=t;if("complex64"===r.dtype){const e=RR({inputs:{input:r},backend:n}),t=Uz({inputs:{x:e},backend:n}),a=XR({inputs:{input:r},backend:n}),i=Uz({inputs:{x:a},backend:n}),s=oO({inputs:{real:t,imag:i},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(i),s}return lY({attrs:{shape:r.shape,dtype:r.dtype,value:"string"===r.dtype?"":0},backend:n})}const qz={kernelName:ta,backendName:"webgl",kernelFunc:Uz},Wz={kernelName:Xn,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r}=t,{x:a}=n;if("string"===a.dtype)throw new Error("onesLike is not supported under string dtype");if("complex64"===a.dtype){const t=RR({inputs:{input:a},backend:r}),n=e({inputs:{x:t},backend:r}),i=XR({inputs:{input:a},backend:r}),s=Uz({inputs:{x:i},backend:r}),o=oO({inputs:{real:n,imag:s},backend:r});return r.disposeIntermediateTensorInfo(t),r.disposeIntermediateTensorInfo(n),r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(s),o}return lY({attrs:{shape:a.shape,dtype:a.dtype,value:1},backend:r})}},Vz={kernelName:Qn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r;if(1===t.length)return eY({inputs:{input:t[0]},backend:n,attrs:{dim:a}});const i=t[0].shape,s=t[0].dtype;t.forEach((e=>{se(i,e.shape,"All tensors passed to stack must have matching shapes"),ie(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],u=eF({inputs:t.map((e=>{const t=eY({inputs:{input:e},backend:n,attrs:{dim:a}});return o.push(t),t})),backend:n,attrs:{axis:a}});return o.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}};class Gz{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=CL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?`\n ${a} start = ${a}(${i});\n ${a} end = ${a}(${s});\n\n void main() {\n ${a} outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(value);\n } else {\n ${a} coords = outC - start;\n setOutput(getX(${o}));\n }\n }\n `:`\n int start = ${i};\n int end = ${s};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(value);\n } else {\n setOutput(getX(outC - start));\n }\n }\n `}}class Kz{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=CL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=P$("rc",r),u=P$("source",r),l=`${o[r-1]} < ${this.outputShape[r-1]}`,c=1===r?"source":`vec2(${u.slice(-2).join()})`,p=[`${a} rc = outputLoc;`,`${o[r-1]} += 1;\n if(${l}) {\n `,1===r?"":`}\n rc = outputLoc;\n ${o[r-2]} += 1;\n if(${o[r-2]} < ${this.outputShape[r-2]}) {`,1===r?"":` ${o[r-1]} += 1;\n if(${l}) {`],d=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let h="";for(let e=0,t=1===r?2:4;e{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,constantValue:s}=r;if(0===le(a.shape)){const e=i.map(((e,t)=>e[0]+a.shape[t]+e[1]));return lY({backend:n,attrs:{shape:e,value:s,dtype:a.dtype}})}const o=Ve().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Kz(a.shape,i,s):new Gz(a.shape,i,s),u=[[s]];return n.runWebGLProgram(o,[a],a.dtype,u)},Xz={kernelName:er,backendName:"webgl",kernelFunc:Jz},Zz=gO({opSnippet:"\n if(a < 0.0 && floor(b) < b){\n return NAN;\n }\n if (b == 0.0) {\n return 1.0;\n }\n return (round(mod(b, 2.0)) != 1) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",packedOpSnippet:"\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"}),Qz={kernelName:nr,backendName:"webgl",kernelFunc:Zz},eB={kernelName:ar,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=a.shape.length,u=[],l=xe(i,a.shape);let c=l;const p=yc(c,o);let d,h=a;if(null!=p&&(h=LO({inputs:{x:a},backend:n,attrs:{perm:p}}),c=xc(c.length,o),u.push(h)),gc("prod",c,o),n.shouldExecuteOnCPU([h])){const e=n.texData.get(h.dataId).values,{outVals:t,outShape:r,outDtype:a}=v$(h.shape,h.dtype,e,c);d=n.makeTensorInfo(r,a,t)}else{const[e,t]=fc(h.shape,c),r=le(t),i=MO({inputs:{x:h},backend:n,attrs:{shape:[-1,r]}}),s=DO(i,li(a.dtype),"prod",n);d=MO({inputs:{x:s},backend:n,attrs:{shape:e}}),u.push(i),u.push(s)}if(s){u.push(d);const e=mc(d.shape,l);d=MO({inputs:{x:d},backend:n,attrs:{shape:e}})}return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),d}},tB=e=>{const{backend:t,attrs:n}=e,{start:r,stop:a,step:i,dtype:s}=n,o=_$(r,a,i,s);return t.makeTensorInfo([o.length],s,o)},nB={kernelName:ir,backendName:"webgl",kernelFunc:tB},rB=mO({opSnippet:"return 1.0 / x;"}),aB={kernelName:or,backendName:"webgl",kernelFunc:rB},iB=mO({opSnippet:"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : x;\n",packedOpSnippet:"\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"}),sB={kernelName:ur,backendName:"webgl",kernelFunc:iB},oB=mO({opSnippet:"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",packedOpSnippet:"\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"}),uB={kernelName:fr,backendName:"webgl",kernelFunc:oB};class lB{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];let p;p=a?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0]/c[0]},\n ${l[1]/c[1]});\n const vec2 inputShapeRC = vec2(${s}.0, ${o}.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 = ${p};\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\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 `}}class cB{constructor(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];let p;p=a?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0]/c[0]},\n ${l[1]/c[1]},\n ${l[1]/c[1]});\n const vec3 inputShapeRC = vec3(${s}.0, ${o}.0,\n ${o}.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 = ${p};\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\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 < ${u-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 `}}const pB={kernelName:dr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r,[u,l]=o,c=Ve().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new cB(a.shape,u,l,i,s):new lB(a.shape,u,l,i,s);return n.runWebGLProgram(c,[a],"float32")}};class dB{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,a]=t,[,i,s]=e,o=[n&&i>1?r-1:r,n&&s>1?a-1:a],u=[n&&i>1?i-1:i,n&&s>1?s-1:s],l=o[0]/u[0],c=o[1]/u[1],p=1/l,d=1/c,h=2*Math.ceil(p)+2,f=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(${l});\n const float widthScale = float(${c});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${h});\n const int winWidth = int(${f});\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 >= ${i}) {\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 >= ${s}) {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), ${r-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 `}}const hB={kernelName:hr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a,dy:i}=t,{alignCorners:s}=r,o=new dB(i.shape,a.shape,s);return n.runWebGLProgram(o,[i],i.dtype)}};class fB{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],p=r?"0.5":"0.0";let d;d=a?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0]/c[0]},\n ${l[1]/c[1]});\n const vec2 inputShapeRC = vec2(${s}.0, ${o}.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 = ${d};\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n `}}class mB{constructor(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],p=r?"0.5":"0.0";let d;d=a?"max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0]/c[0]},\n ${l[1]/c[1]},\n ${l[1]/c[1]});\n const vec3 inputShapeRC = vec3(${s}.0, ${o}.0,\n ${o}.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 = ${d};\n\n // Compute the coordinators of nearest neighbor point.\n ivec3 sourceNearestRC = ivec3(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u-1};\n bool hasNextRow = coords.z < ${n-1};\n\n vec4 newValue = vec4(\n getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d),\n hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0);\n\n setOutput(newValue);\n }\n `}}const gB={kernelName:cr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r,[u,l]=o,c=Ve().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new mB(a.shape,u,l,i,s):new fB(a.shape,u,l,i,s);return n.runWebGLProgram(c,[a],a.dtype)}};class yB{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,a]=t,[,i,s]=e,o=[n&&i>1?r-1:r,n&&s>1?a-1:a],u=[n&&i>1?i-1:i,n&&s>1?s-1:s],l=o[0]/u[0],c=o[1]/u[1],p=1/l,d=1/c,h=2*Math.ceil(p)+2,f=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(${l});\n const float widthScale = float(${c});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${h});\n const int winWidth = int(${f});\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 >= ${i}) {\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 >= ${s}) {\n continue;\n }\n\n float sourceFracRow =\n float(${o[0]}) *\n (float(dyR) / float(${u[0]}));\n\n float sourceFracCol =\n float(${o[1]}) *\n (float(dyC) / float(${u[1]}));\n\n int sourceNearestRow = int(min(\n float(int(${r}) - 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 `}}const bB={kernelName:pr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a,dy:i}=t,{alignCorners:s}=r,o=new yB(i.shape,a.shape,s);return n.runWebGLProgram(o,[i],i.dtype)}};class xB{constructor(e,t){this.variableNames=["x"];const 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)return void(this.userCode=`\n void main() {\n int coord = getOutputCoords();\n setOutput(getX(${e[0]} - coord - 1));\n }\n `);const r=e.map(((n,r)=>(n=>-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - coords[${n}] - 1`:`coords[${n}]`)(r))).join(","),a=CL(n);this.userCode=`\n void main() {\n ${a} coords = getOutputCoords();\n setOutput(getX(${r}));\n }\n `}}class vB{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=e;const r=P$("rc",n),a=`${r[n-1]} + 1 < ${this.outputShape[n-1]}`,i=`${r[n-2]} + 1 < ${this.outputShape[n-2]}`,s=CL(n);function o(n){const r=e.map(((r,a)=>function(n,r){return-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - ${r[n]} - 1`:`${r[n]}`}(a,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(${a}){\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 ${s} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = ${function(e){return o(e)}(r.slice())};\n if(${a}){\n result.g = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",o(e)}(r.slice())};\n }\n if(${i}) {\n result.b = ${function(e){return e[n-2]="("+e[n-2]+" + 1)",o(e)}(r.slice())};\n if(${a}) {\n result.a = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",e[n-2]="("+e[n-2]+" + 1)",o(e)}(r.slice())};\n }\n }\n setOutput(result);\n }\n `}}const _B={kernelName:mr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:i}=r,s=a.shape.length,o=xe(i,a.shape);if(0===s)return iO({inputs:{x:a},backend:n});const u=Ve().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new vB(a.shape,o):new xB(a.shape,o);return n.runWebGLProgram(u,[a],a.dtype)}};class wB{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const n=e[1],r=e[2];this.outputShape=e;let a="";a="number"==typeof t?`float outputValue = ${t.toFixed(2)};`:`\n vec3 fill = vec3(${t.join(",")});\n float outputValue = fill[coords[3]];`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n int y = coords[1];\n float coordXFloat = (float(x) - params[0]) * params[3] -\n (float(y) - params[1]) * params[2];\n float coordYFloat = (float(x) - params[0]) * params[2] +\n (float(y) - params[1]) * params[3];\n int coordX = int(round(coordXFloat + params[0]));\n int coordY = int(round(coordYFloat + params[1]));\n ${a}\n if(coordX >= 0 && coordX < ${r} && coordY >= 0 && coordY < ${n}) {\n outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n }\n setOutput(outputValue);\n }\n `}}const MB={kernelName:aa,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:r}=e,{radians:a,fillValue:i,center:s}=t,o=n,u=new wB(r.shape,i),[l,c]=Qh(s,r.shape[1],r.shape[2]),p=[[l,c,Math.sin(a),Math.cos(a)]];return o.runWebGLProgram(u,[r],r.dtype,p)}},NB=mO({opSnippet:"\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"}),SB={kernelName:gr,backendName:"webgl",kernelFunc:NB},kB=mO({opSnippet:"return inversesqrt(x);",cpuKernelImpl:w$}),DB={kernelName:yr,backendName:"webgl",kernelFunc:kB};class TB{constructor(e,t,n,r,a,i,s=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=i;const o=CL(a.length),u=CL(i.length);let l="";1===n?l="i":2===n&&(l="i, j");const c=`getIndices(${l})`;let p="";1===r?p="i":2===r&&(p="i, coords[1]");const d=`getUpdates(${p})`,h=t>1?"strides[j]":"strides";this.userCode=`\n ${o} strides = ${o}(${a});\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(${c});\n flattenedIndex += index * ${h};\n }\n if (flattenedIndex == coords[0]) {\n sum += ${d};\n found = true;\n }\n }\n setOutput(mix(getDefaultValue(), sum, float(found)));\n }\n `}}const IB={kernelName:br,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{indices:a,updates:i}=t,{shape:s}=r,{sliceRank:o,numUpdates:u,sliceSize:l,strides:c,outputSize:p}=Po(0,a,s),d=[p/l,l];if(0===p)return n.makeTensorInfo(s,a.dtype);const h=MO({inputs:{x:a},backend:n,attrs:{shape:[u,o]}}),f=MO({inputs:{x:i},backend:n,attrs:{shape:[u,l]}}),m=n.makeTensorInfo([],"float32",new Float32Array([0])),g=new TB(u,o,h.shape.length,f.shape.length,c,d),y=n.runWebGLProgram(g,[f,h,m],f.dtype),b=MO({inputs:{x:y},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(m),b}};class EB{constructor(e,t,n,r){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,n];const a=`for (int i = 0; i < ${Math.ceil(Math.log2(t+1))}; ++i) { if (left >= right) break;`,i=2===Ve().getNumber("WEBGL_VERSION")?"while (left < right) {":a,s="left"===r?"<":"<=";this.userCode=`\n int findBound(int batch, float value) {\n int left = 0;\n int right = numInputs;\n int mid;\n ${i}\n mid = (left + right) / 2;\n if (getSortedSequence(batch, mid) ${s} value) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return right;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int valueIndex = coords[1];\n\n float value = getValues(batch, valueIndex);\n\n setOutput(float(findBound(batch, value)));\n }\n `}}const CB={kernelName:xr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{sortedSequence:a,values:i}=t,{side:s}=r,o=new EB(a.shape[0],a.shape[1],i.shape[1],s),u=[[a.shape[1]]];return n.runWebGLProgram(o,[a,i],"int32",u)}};class AB{constructor(e,t,n){let r,a;if(this.variableNames=["c","a","b"],this.outputShape=t,n>4)throw Error(`Where for rank ${n} is not yet supported`);if(1===n)a="resRC",r="resRC";else{const n=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[],s=[];for(let r=0;r= 1.0) {\n setOutput(getA(${a}));\n } else {\n setOutput(getB(${a}));\n }\n }\n `}}const LB={kernelName:vr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{condition:r,t:a,e:i}=t,s=new AB(r.shape.length,a.shape,a.shape.length);return n.runWebGLProgram(s,[r,a,i],ui(a.dtype,i.dtype))}},$B=mO({opSnippet:`\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = ${sf};\n float scale = ${of};\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n`}),OB={kernelName:_r,backendName:"webgl",kernelFunc:$B},RB=mO({opSnippet:"if (isnan(x)) return x;\n return 1.0 / (1.0 + exp(-1.0 * x));\n",packedOpSnippet:"\n vec4 result = 1.0 / (1.0 + exp(-1.0 * x));\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",cpuKernelImpl:N$}),FB={kernelName:kr,backendName:"webgl",kernelFunc:RB},YB=mO({opSnippet:"\n if (isnan(x)) { return 0.0; }\n return sign(x);\n"}),zB={kernelName:Sr,backendName:"webgl",kernelFunc:YB},BB=mO({opSnippet:"if (isnan(x)) return x;\n return sin(x);\n"}),PB={kernelName:Mr,backendName:"webgl",kernelFunc:BB},HB=mO({opSnippet:"\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n"}),jB={kernelName:Nr,backendName:"webgl",kernelFunc:HB},UB=mO({opSnippet:"\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"}),qB={kernelName:Dr,backendName:"webgl",kernelFunc:UB},WB={kernelName:Er,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,paddings:s}=r;ie(a.shape.length<=4,(()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"));const o=i.reduce(((e,t)=>e*t)),u=[[0,0]];u.push(...s);for(let e=1+i.length;en.disposeIntermediateTensorInfo(e))),g}},VB={kernelName:Lr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{indices:r,values:a,denseShape:i,defaultValue:s}=t;if(1!==i.shape.length)throw new Error(`Dense shape must be a vector, saw:\n ${i.shape}`);if(2!==r.shape.length)throw new Error(`Indices must be a matrix, saw:\n ${r.shape}`);if(1!==a.shape.length)throw new Error(`Values must be a vector, saw:\n ${a.shape}`);if(0!==s.shape.length)throw new Error(`Default value must be a scalar, saw:\n ${s.shape}`);const o=n.readSync(r.dataId),u=n.readSync(a.dataId),l=n.readSync(i.dataId),c=n.readSync(s.dataId)[0],[p,d,h,f,m]=D$(o,r.shape,r.dtype,u,a.dtype,l,c);return[n.makeTensorInfo(d,r.dtype,p),n.makeTensorInfo([d[0]],a.dtype,h),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map((e=>Number(e))))),n.makeTensorInfo([m.length],r.dtype,new Int32Array(m))]}},GB={kernelName:$r,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{inputIndices:r,inputShape:a,newShape:i}=t;if(2!==r.shape.length)throw new Error(`Input indices should be a matrix but received shape ${r.shape}`);if(1!==a.shape.length)throw new Error(`Input shape should be a vector but received shape ${a.shape}`);if(1!==i.shape.length)throw new Error(`Target shape should be a vector but received shape ${i.shape}`);const s=Array.from(n.readSync(a.dataId)),o=n.readSync(r.dataId),u=Array.from(n.readSync(i.dataId)),[l,c,p]=T$(o,r.shape,r.dtype,s,u);return[n.makeTensorInfo(c,r.dtype,l),n.makeTensorInfo([p.length],i.dtype,new Int32Array(p))]}},KB={kernelName:Or,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:i}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error(`Indices should be a vector but received shape\n ${a.shape}`);if(1!==i.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${i.shape}`);const s=n.readSync(r.dataId),o=n.readSync(a.dataId),u=n.readSync(i.dataId),[l,c]=I$(s,r.shape,r.dtype,o,u,!0);return n.makeTensorInfo(c,r.dtype,l)}},JB={kernelName:Rr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:i}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error(`Indices should be a vector but received shape\n ${a.shape}`);if(1!==i.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${i.shape}`);const s=n.readSync(r.dataId),o=n.readSync(a.dataId),u=n.readSync(i.dataId),[l,c]=I$(s,r.shape,r.dtype,o,u);return n.makeTensorInfo(c,r.dtype,l)}},XB={kernelName:Fr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{sparseIndices:a,sparseValues:i,defaultValue:s}=t,{outputShape:o}=r,{sliceRank:u,numUpdates:l,sliceSize:c,strides:p,outputSize:d}=Po(0,a,o);if("string"===i.dtype){const e=n.bufferSync(a),t=n.bufferSync(i),r=Ba(n.readSync(s.dataId)[0]),h=M$(e,t,o,d,c,l,u,p,r,!1);return n.makeTensorInfo(o,h.dtype,h.values)}const h=new TB(l,u,a.shape.length,i.shape.length,p,[d,1],!1),f=n.runWebGLProgram(h,[i,a,s],i.dtype),m=MO({inputs:{x:f},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(f),m}},ZB={kernelName:Cr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{numOrSizeSplits:i,axis:s}=r,o=xe(s,a.shape)[0],u=If(a,i,o),l=a.shape.length,c=new Array(l).fill(0),p=a.shape.slice();return u.map((e=>{const t=[...p];t[o]=e;const r=IR({inputs:{x:a},backend:n,attrs:{begin:c,size:t}});return c[o]+=e,r}))}},QB="return sqrt(x);",eP=mO({opSnippet:QB,packedOpSnippet:QB,cpuKernelImpl:E$}),tP={kernelName:Tr,backendName:"webgl",kernelFunc:eP},nP=mO({opSnippet:"return x * x;"}),rP={kernelName:zr,backendName:"webgl",kernelFunc:nP},aP="return (a - b) * (a - b);",iP=gO({opSnippet:aP,packedOpSnippet:aP}),sP={kernelName:Yr,backendName:"webgl",kernelFunc:iP},oP={kernelName:na,backendName:"webgl",kernelFunc:function({inputs:e,attrs:t,backend:n}){const{x:r}=e,a=`if (isnan(x)) return x;\n return x > 0.0 ? 1.0 : float(${t.alpha});\n `,i=new G$(r.shape,a);return n.runWebGLProgram(i,[r],r.dtype)}};class uP{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;const r=n.length,a=CL(n.length),i=CL(n.length);let s="";if(1===r)s="coords * strides + begin";else{let e=0;s=n.map(((t,r)=>(e++,1===n.length?`coords * strides[${r}] + begin[${r}]`:`coords[${e-1}] * strides[${r}] + begin[${r}]`))).join(",")}this.userCode=`\n ${a} begin = ${a}(${e});\n ${a} strides = ${a}(${t});\n\n void main() {\n ${i} coords = getOutputCoords();\n setOutput(getX(${s}));\n }\n `}}const lP={kernelName:Br,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,end:s,strides:o,beginMask:u,endMask:l,ellipsisMask:c,newAxisMask:p,shrinkAxisMask:d}=r,{finalShapeSparse:h,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:y,begin:b,end:x,strides:v}=ru(a.shape,i,s,o,u,l,c,p,d);let _;if(m)_=MO({inputs:{x:a},backend:n,attrs:{shape:f}});else if(g||y){ie(a.shape.length>=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=Uo(b,x,v),t=IR({inputs:{x:a},backend:n,attrs:{begin:b,size:e}});_=MO({inputs:{x:t},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(t)}else if(n.shouldExecuteOnCPU([a])){const e=n.readSync(a.dataId),t=Es(a.shape,a.dtype,e),r=C$(h,t,v,b);_=n.makeTensorInfo(f,a.dtype,r.values)}else{const e=new uP(b,v,h);_=n.runWebGLProgram(e,[a],a.dtype)}const w=MO({inputs:{x:_},backend:n,attrs:{shape:f}});return n.disposeIntermediateTensorInfo(_),w}},cP={kernelName:Pr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{separator:a,nGramWidths:i,leftPad:s,rightPad:o,padWidth:u,preserveShortSequences:l}=r,{data:c,dataSplits:p}=t,d=n.readSync(c.dataId),h=n.readSync(p.dataId),[f,m]=A$(d,h,a,i,s,o,u,l);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}},pP={kernelName:Hr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{skipEmpty:a}=r,{input:i,delimiter:s}=t;if("string"!==i.dtype)throw new Error("Input must be of datatype string");if(1!==i.shape.length)throw new Error(`Input must be a vector, got shape: ${i.shape}`);if(0!==s.shape.length)throw new Error(`Delimiter must be a scalar, got shape: ${s.shape}`);const o=n.readSync(i.dataId),u=n.readSync(s.dataId)[0],[l,c,p]=L$(o,u,a),d=c.length;return[n.makeTensorInfo([d,2],"int32",l),n.makeTensorInfo([d],"string",c),n.makeTensorInfo([2],"int32",new Int32Array(p))]}},dP={kernelName:jr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{numBuckets:a}=r,{input:i}=t;if("string"!==i.dtype)throw new Error("Input must be of datatype string");if(a<=0)throw new Error("Number of buckets must be at least 1");const s=n.readSync(i.dataId),o=$$(s,a);return n.makeTensorInfo(i.shape,"int32",o)}},hP=mO({opSnippet:"return tan(x);"}),fP={kernelName:qr,backendName:"webgl",kernelFunc:hP},mP=mO({opSnippet:"\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n"}),gP={kernelName:Wr,backendName:"webgl",kernelFunc:mP};class yP{constructor(e,t){this.variableNames=["A"];const n=new Array(e.length);for(let r=0;r5)throw Error(`Tile for rank ${t} is not yet supported`);if(1===t)return`imod(resRC, ${e[0]})`;const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[];for(let t=0;t5){const e=n.readSync(a.dataId),t="string"===a.dtype?e.map((e=>Ba(e))):e,r=Es(a.shape,a.dtype,t),s=R$(r,i);return n.makeTensorInfo(s.shape,s.dtype,s.values)}const s=new yP(a.shape,i);return n.runWebGLProgram(s,[a],a.dtype)}const xP={kernelName:Vr,backendName:"webgl",kernelFunc:bP};class vP{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"negativeInf",type:"float"},{name:"dir",type:"int"},{name:"inc",type:"int"}],this.outputShape=e,this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // We compare elements pair-wise within a group of size 2 * inc.\n // The comparing rule for each group alternates between ascending\n // and descending. Within each group, we compare each pair at\n // positions i and i+inc. To decide whether an element at position i\n // is x0 or x1, we mod it by 2 * inc, if the result is smaller than\n // inc, it is in the first half of the group, we denote it as x0,\n // otherwise we denote it as x1.\n // For example, as shown in the Bitonic top K paper referenced above,\n // Figure5(a) shows that element[1] is in the\n // second half of the group when group size is 2, but it is in the\n // first half of the group when group size is 4.\n\n bool isFirstInPair = imod(elemIdx, 2 * inc) < inc;\n int i = isFirstInPair ? elemIdx : elemIdx - inc;\n\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc));\n float x0 = i0 < n ? getX(batch, i0) : negativeInf;\n float x1 = i1 < n ? getX(batch, i1) : negativeInf;\n\n // Denotes which direction indices are in (ascending or descending).\n bool reverse = imod(elemIdx, 2 * dir) >= dir;\n bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0);\n if (reverse == isGreater) { // Elements in opposite order of direction\n int iTemp = i0;\n i0 = i1;\n i1 = iTemp;\n }\n if (isFirstInPair) {\n setOutput(float(i0));\n } else {\n setOutput(float(i1));\n }\n }\n "}}class _P{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=e,this.userCode="\n void main() {\n // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ...\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // The output size is half of the previous size.\n // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4),\n // we only need to output the indices at positions |, the indices at\n // positions _ can be thrown away, see Figure5(b) After Phase 2\n // (Merge phase) in the Bitonic Top K paper referenced above.\n // For example, the paper shows we only need to output the orange bars.\n // The output sequence should look like this | | | | | | | |.\n // Because the sequence is halved, to map the output index back\n // to the previous sequence to find the corresponding value,\n // we need to double the index. When we double the index,\n // we basically interpolate a position, so 2i looks like\n // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position\n // of each 2k positions by - elemIdx % k. E.g. for output at\n // index 4,5,6,7, we want to get the corresponding element at\n // original index 8,9,10,11, for output at index 8,9,10,11,\n // we want to get the corresponding element at original index\n // 16,17,18,19, so on and so forth.\n\n int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k));\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k));\n\n float x0 = getX(batch, i0);\n float x1 = i1 < n ? getX(batch, i1) : x0;\n\n setOutput(x0 >= x1 ? float(i0) : float(i1));\n }\n "}}function wP(e,t){null!==t&&e.disposeIntermediateTensorInfo(t)}function MP(e){let t=1;for(;tu){const e=n.readSync(a.dataId),[t,r]=F$(e,l,a.dtype,i,s);return[n.makeTensorInfo(t.shape,t.dtype,t.values),n.makeTensorInfo(r.shape,r.dtype,r.values)]}if(0===i)return l[l.length-1]=0,[n.makeTensorInfo(l,a.dtype,[]),n.makeTensorInfo(l,"int32",[])];if(1===c)return[a,lY({attrs:{shape:l,dtype:"int32",value:0},backend:n})];const p=n.texData.get(a.dataId),d=null!==p&&p.isPacked,h=d?n.unpackTensor(a):a,f=le(l)/c,m=MO({inputs:{x:h},attrs:{shape:[f,c]},backend:n});d&&wP(n,h);const g=MP(i),y=MP(c);let b=null;const x=()=>null===b?[m,m]:[m,b],v=(e,t,r)=>{const a=x(),i=new vP(r),s=[[c],[null===b?1:0],[Number.NEGATIVE_INFINITY],[e],[t]],o=b;b=n.runWebGLProgram(i,a,"int32",s),wP(n,o)};for(let e=1;e=1;n/=2)v(t,n,[f,y])}for(let e=y;e>g;e/=2){const t=x(),r=new _P([f,e/2]),a=[[c],[null===b?1:0],[g]],i=b;b=n.runWebGLProgram(r,t,"int32",a),wP(n,i);const s=g/2,o=2*s;for(let e=s;e>=1;e/=2)v(o,e,b.shape)}let _=b;b=IR({inputs:{x:b},backend:n,attrs:{begin:0,size:[f,i]}}),wP(n,_);let w=DY({inputs:{x:m,indices:b},backend:n,attrs:{axis:1,batchDims:1}});wP(n,m);const M=l.slice(0,-1);M.push(i),_=b,b=MO({inputs:{x:b},attrs:{shape:M},backend:n}),wP(n,_);const N=w;return w=MO({inputs:{x:w},attrs:{shape:M},backend:n}),wP(n,N),[w,b]}};class SP{constructor(e,t,n,r,a,i){this.variableNames=["Image","Transforms"],this.outputShape=i;const s="nearest"===n?1:2;let o;switch(r){case"constant":default:o=1;break;case"reflect":o=2;break;case"wrap":o=3;break;case"nearest":o=4}this.userCode=`\n float mapCoord(float outCoord, float len) {\n float inCoord = outCoord;\n if(${o} == 2) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n if (inCoord < sz2) {\n inCoord = sz2 * float(int(float(-inCoord / sz2))) +\n inCoord;\n }\n inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n inCoord -= sz2 * float(int(float(inCoord / sz2)));\n if (inCoord >= len) {\n inCoord = sz2 - inCoord - 1.0;\n }\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${o} == 3) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord -= len * float(int(float(inCoord / sz)));\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${o} == 4) {\n return clamp(outCoord, 0.0, len - 1.0);\n } else {\n return outCoord;\n }\n }\n\n float readWithFillValue(int batch, int coordY, int coordX,\n int channel) {\n float outputValue;\n if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) {\n outputValue = getImage(batch, coordY, coordX, channel);\n } else {\n outputValue = float(${a});\n }\n return outputValue;\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n float outputValue;\n int batch = coords[0];\n int x = coords[2];\n int y = coords[1];\n int channel = coords[3];\n float xf = float(x);\n float yf = float(y);\n float a1 = getTransforms(batch, 0);\n float a2 = getTransforms(batch, 1);\n float a3 = getTransforms(batch, 2);\n float b1 = getTransforms(batch, 3);\n float b2 = getTransforms(batch, 4);\n float b3 = getTransforms(batch, 5);\n float c1 = getTransforms(batch, 6);\n float c2 = getTransforms(batch, 7);\n float projection = c1 * xf + c2 * yf + 1.0;\n if (projection == 0.0) {\n outputValue = float(${a});\n } else {\n float inX = (a1 * xf + a2 * yf + a3) / projection;\n float inY = (b1 * xf + b2 * yf + b3) / projection;\n float mapX = mapCoord(inX, float(${t}));\n float mapY = mapCoord(inY, float(${e}));\n\n if (${s} == 1) {\n int coordY = int(round(mapY));\n int coordX = int(round(mapX));\n outputValue = readWithFillValue(batch, coordY, coordX,\n channel);\n } else {\n float yFloor = floor(mapY);\n float xFloor = floor(mapX);\n float yCeil = yFloor + 1.0;\n float xCeil = xFloor + 1.0;\n float valueYFloor = (xCeil - mapX) *\n readWithFillValue(batch, int(yFloor), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yFloor), int(xCeil), channel);\n float valueYCeil = (xCeil - mapX) *\n readWithFillValue(batch, int(yCeil), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yCeil), int(xCeil), channel);\n outputValue = (yCeil - mapY) * valueYFloor +\n (mapY - yFloor) * valueYCeil;\n }\n }\n setOutput(outputValue);\n }\n `}}const kP={kernelName:Kr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a,transforms:i}=t,{interpolation:s,fillMode:o,fillValue:u,outputShape:l}=r,[c,p,d,h]=a.shape,[f,m]=null!=l?l:[p,d],g=new SP(p,d,s,o,u,[c,f,m,h]);return n.runWebGLProgram(g,[a,i],"float32")}},DP={kernelName:Xr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{axis:a}=n,{x:i}=t;fL(i,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const s=r.readSync(i.dataId),{outputValues:o,outputShape:u,indices:l}=z$(s,a,i.shape,i.dtype);return[r.makeTensorInfo(u,i.dtype,o),r.makeTensorInfo([l.length],"int32",l)]}},TP={kernelName:Zr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{value:a}=t;let{axis:i}=r;i<0&&(i+=a.shape.length);const s=a,o=s.shape.length,u=a.shape[i],l=new Array(o-1);let c=0;for(let e=0;en.disposeIntermediateTensorInfo(e))),f}};class IP{constructor(e,t){this.variableNames=["x","segmentIds"];const n=e.windowSize,r=e.batchSize,a=e.inSize,i=e.numSegments,s=i*Math.ceil(a/n);this.outputShape=[r,s];const o=4*Math.floor(n/4),u=n%4,l="\n sumValue += dot(values, segFilter);\n ";let c="";a%n>0&&(c=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return initializationValue;\n }\n `);let p="";a%n>0&&(p=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return -1.0;\n }\n `),this.userCode=`\n const float initializationValue = 0.0;\n\n float getValue(int batch, int inIdx) {\n ${c}\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n ${p}\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 ${i})) * float(${n}));\n int currentSeg = int(mod(float(outIdx), float(${i})));\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${o}; 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 ${l}\n }\n\n int inIdx = inOffset + ${o};\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 ${l}\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 ${l}\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 ${l}\n }\n setOutput(sumValue);\n }\n `}}const EP={kernelName:Qr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,segmentIds:i}=t,{numSegments:s}=r,o=a.shape.length,u=[];let l=0;const c=yc([l],o);let p=a;null!=c&&(p=LO({inputs:{x:a},backend:n,attrs:{perm:c}}),u.push(p),l=xc(1,o)[0]);const d=jf(p.shape,l,s),h=le([p.shape[l]]),f=MO({inputs:{x:p},backend:n,attrs:{shape:[-1,h]}});u.push(f);const m=li(a.dtype),g=(e,t,r,a,i)=>{const s=e.shape[0],o=e.shape[1],l=Hf(o,i),c=new IP({windowSize:l,inSize:o,batchSize:s,numSegments:i},t),p=n.compileAndRun(c,[e,r],a);if(u.push(p),p.shape[1]===i)return p;const d=tB({backend:n,attrs:{start:0,stop:i,step:1,dtype:"float32"}}),h=bP({inputs:{x:d},backend:n,attrs:{reps:[o/l]}});return u.push(d),u.push(h),g(p,t,h,a,i)},y=MO({inputs:{x:g(f,"unsortedSegmentSum",i,m,s)},backend:n,attrs:{shape:d}});let b=y;if(null!=c){u.push(y);const e=bc(c);b=LO({inputs:{x:b},backend:n,attrs:{perm:e}})}return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),b}},CP=[RO,YO,BO,HO,qO,GO,KO,JO,nR,rR,iR,oR,lR,pR,hR,gR,yR,vR,_R,wR,SR,CR,AR,LR,YR,PR,UR,uO,VR,tF,oF,dF,hF,fF,mF,gF,bF,vF,wF,TF,IF,EF,AF,OF,YF,zF,PF,jF,UF,WF,VF,KF,XF,QF,tY,aY,oY,cY,dY,mY,yY,vY,wY,MY,SY,TY,EY,AY,sO,LY,ZR,OY,FY,zY,pO,PY,jY,UY,WY,GY,JY,ZY,ez,rz,iz,oz,lz,cz,pz,fz,mz,gz,yz,bz,vz,Mz,Sz,$z,wO,Oz,Fz,zz,Pz,OR,jz,Wz,Vz,Xz,Qz,fO,eB,nB,FR,Tz,aB,sB,uB,NO,pB,hB,gB,bB,_B,MB,SB,DB,IB,CB,LB,OB,FB,zB,PB,jB,ER,Lz,qB,WB,VB,GB,KB,JB,XB,ZB,tP,rP,sP,oP,lP,cP,pP,dP,Cz,AO,fP,gP,xP,NP,kP,$O,DP,TP,EP,qz];for(const e of CP)ma(e);const AP={"tfjs-core":xu,"tfjs-backend-cpu":"3.18.0","tfjs-backend-webgl":"3.18.0","tfjs-data":Mk,"tfjs-layers":Fx,"tfjs-converter":mS,tfjs:"3.18.0"};function LP(){return LP=Object.assign?Object.assign.bind():function(e){for(var t=1;te[t]))}var EH=["Matrix","Array"],CH=["number","BigNumber","Fraction"];function AH(e,t){function n(n){if(n){var r=_H(e,vH);LH(n,"matrix",EH),LH(n,"number",CH),MH(e,n);var a=_H(e,vH),i=_H(n,vH);return t("config",a,r,i),a}return _H(e,vH)}return n.MATRIX_OPTIONS=EH,n.NUMBER_OPTIONS=CH,Object.keys($P).forEach((t=>{Object.defineProperty(n,t,{get:()=>e[t],enumerable:!0,configurable:!0})})),n}function LH(e,t,n){void 0===e[t]||function(e,t){return-1!==e.indexOf(t)}(n,e[t])||console.warn('Warning: Unknown value "'+e[t]+'" for configuration option "'+t+'". Available options: '+n.map((e=>JSON.stringify(e))).join(", ")+".")}var $H=function(e){if(e)throw new Error("The global config is readonly. \nPlease create a mathjs instance if you want to change the default configuration. \nExample:\n\n import { create, all } from 'mathjs';\n const mathjs = create(all);\n mathjs.config({ number: 'BigNumber' });\n");return Object.freeze($P)};LP($H,$P,{MATRIX_OPTIONS:EH,NUMBER_OPTIONS:CH});var OH=n(3776);function RH(e,t,n,r){function a(r){var a=function(e,t){for(var n={},r=0;r!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==n[e]))){var r=t.filter((e=>void 0===n[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(r.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,t,r),n(a)}return a.isFactory=!0,a.fn=e,a.dependencies=t.slice().sort(),r&&(a.meta=r),a}function FH(e){return"function"==typeof e&&"string"==typeof e.fn&&Array.isArray(e.dependencies)}function YH(e){return e&&"?"===e[0]?e.slice(1):e}var zH=RH("BigNumber",["?on","config"],(e=>{var{on:t,config:n}=e,r=OH.clone({precision:n.precision,modulo:OH.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(e){return new r(e.value)},t&&t("config",(function(e,t){e.precision!==t.precision&&r.config({precision:e.precision})})),r}),{isClass:!0}),BH=n(1977);function PH(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var HH=Math.sign||function(e){return e>0?1:e<0?-1:0},jH=Math.log2||function(e){return Math.log(e)/Math.LN2},UH=Math.log10||function(e){return Math.log(e)/Math.LN10},qH=Math.log1p||function(e){return Math.log(e+1)},WH=Math.cbrt||function(e){if(0===e)return e;var t,n=e<0;return n&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,n?-t:t},VH=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function GH(e,t,n){var r={2:"0b",8:"0o",16:"0x"}[t],a="";if(n){if(n<1)throw new Error("size must be in greater than 0");if(!PH(n))throw new Error("size must be an integer");if(e>2**(n-1)-1||e<-(2**(n-1)))throw new Error("Value must be in range [-2^".concat(n-1,", 2^").concat(n-1,"-1]"));if(!PH(e))throw new Error("Value must be an integer");e<0&&(e+=2**n),a="i".concat(n)}var i="";return e<0&&(e=-e,i="-"),"".concat(i).concat(r).concat(e.toString(t)).concat(a)}function KH(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var n,r,a="auto";if(t&&(t.notation&&(a=t.notation),OP(t)?n=t:OP(t.precision)&&(n=t.precision),t.wordSize&&"number"!=typeof(r=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return XH(e,n);case"exponential":return ZH(e,n);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=QH(JH(e),t),r=n.exponent,a=n.coefficients,i=r%3==0?r:r<0?r-3-r%3:r-r%3;if(OP(t))for(;t>a.length||r-i+1>a.length;)a.push(0);else for(var s=Math.abs(r-i)-(a.length-1),o=0;o0;)l++,u--;var c=a.slice(l).join(""),p=OP(t)&&c.length||c.match(/[1-9]/)?"."+c:"",d=a.slice(0,l).join("")+p+"e"+(r>=0?"+":"")+i.toString();return n.sign+d}(e,n);case"bin":return GH(e,2,r);case"oct":return GH(e,8,r);case"hex":return GH(e,16,r);case"auto":return function(e,t,n){if(isNaN(e)||!isFinite(e))return String(e);var r=n&&void 0!==n.lowerExp?n.lowerExp:-3,a=n&&void 0!==n.upperExp?n.upperExp:5,i=JH(e),s=t?QH(i,t):i;if(s.exponent=a)return ZH(e,t);var o=s.coefficients,u=s.exponent;o.length0?u:0;return l<(o=ej(-u).concat(o)).length-1&&o.splice(l+1,0,"."),s.sign+o.join("")}(e,n,t&&t).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t}));default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function JH(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var n=t[1],r=t[2],a=parseFloat(t[4]||"0"),i=r.indexOf(".");a+=-1!==i?i-1:r.length-1;var s=r.replace(".","").replace(/^0*/,(function(e){return a-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===s.length&&(s.push(0),a++),{sign:n,coefficients:s,exponent:a}}function XH(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=JH(e),r="number"==typeof t?QH(n,n.exponent+1+t):n,a=r.coefficients,i=r.exponent+1,s=i+(t||0);return a.length0?"."+a.join(""):"")+"e"+(i>=0?"+":"")+i}function QH(e,t){for(var n={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},r=n.coefficients;t<=0;)r.unshift(0),n.exponent++,t++;if(r.length>t&&r.splice(t,r.length-t)[0]>=5){var a=t-1;for(r[a]++;10===r[a];)r.pop(),0===a&&(r.unshift(0),n.exponent++,a++),r[--a]++}return n}function ej(e){for(var t=[],n=0;n(BH.prototype.type="Complex",BH.prototype.isComplex=!0,BH.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},BH.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},BH.prototype.format=function(e){var t=this.im,n=this.re,r=KH(this.re,e),a=KH(this.im,e),i=OP(e)?e:e?e.precision:null;if(null!==i){var s=Math.pow(10,-i);Math.abs(n/t)t.re?1:e.ret.im?1:e.im1&&void 0!==arguments[1]?arguments[1]:{};return n=null==n?Number.POSITIVE_INFINITY:n,t=null==t?JSON.stringify:t,function r(){"object"!=typeof r.cache&&(r.cache={values:new Map,lru:cj(n||Number.POSITIVE_INFINITY)});for(var a=[],i=0;i!0)),wj=RH("false",[],(()=>!1)),Mj=RH("null",[],(()=>null)),Nj=Bj("Infinity",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(1/0):1/0})),Sj=Bj("NaN",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(NaN):NaN})),kj=Bj("pi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?mj(n):bj})),Dj=Bj("tau",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?gj(n):xj})),Tj=Bj("e",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?hj(n):vj})),Ij=Bj("phi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?fj(n):1.618033988749895})),Ej=Bj("LN2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(2).ln():Math.LN2})),Cj=Bj("LN10",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(10).ln():Math.LN10})),Aj=Bj("LOG2E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(1).div(new n(2).ln()):Math.LOG2E})),Lj=Bj("LOG10E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(1).div(new n(10).ln()):Math.LOG10E})),$j=Bj("SQRT1_2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n("0.5").sqrt():Math.SQRT1_2})),Oj=Bj("SQRT2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(2).sqrt():Math.SQRT2})),Rj=Bj("i",["Complex"],(e=>{var{Complex:t}=e;return t.I})),Fj=RH("PI",["pi"],(e=>{var{pi:t}=e;return t})),Yj=RH("E",["e"],(e=>{var{e:t}=e;return t})),zj=RH("version",[],(()=>"10.6.4"));function Bj(e,t,n){return RH(e,t,n,{recreateOnConfigChange:!0})}var Pj=FU("speedOfLight","299792458","m s^-1"),Hj=FU("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),jj=FU("planckConstant","6.62607015e-34","J s"),Uj=FU("reducedPlanckConstant","1.0545718176461565e-34","J s"),qj=FU("magneticConstant","1.25663706212e-6","N A^-2"),Wj=FU("electricConstant","8.8541878128e-12","F m^-1"),Vj=FU("vacuumImpedance","376.730313667","ohm"),Gj=FU("coulomb","8.987551792261171e9","N m^2 C^-2"),Kj=FU("elementaryCharge","1.602176634e-19","C"),Jj=FU("bohrMagneton","9.2740100783e-24","J T^-1"),Xj=FU("conductanceQuantum","7.748091729863649e-5","S"),Zj=FU("inverseConductanceQuantum","12906.403729652257","ohm"),Qj=FU("magneticFluxQuantum","2.0678338484619295e-15","Wb"),eU=FU("nuclearMagneton","5.0507837461e-27","J T^-1"),tU=FU("klitzing","25812.807459304513","ohm"),nU=FU("bohrRadius","5.29177210903e-11","m"),rU=FU("classicalElectronRadius","2.8179403262e-15","m"),aU=FU("electronMass","9.1093837015e-31","kg"),iU=FU("fermiCoupling","1.1663787e-5","GeV^-2"),sU=YU("fineStructure",.0072973525693),oU=FU("hartreeEnergy","4.3597447222071e-18","J"),uU=FU("protonMass","1.67262192369e-27","kg"),lU=FU("deuteronMass","3.3435830926e-27","kg"),cU=FU("neutronMass","1.6749271613e-27","kg"),pU=FU("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),dU=FU("rydberg","10973731.568160","m^-1"),hU=FU("thomsonCrossSection","6.6524587321e-29","m^2"),fU=YU("weakMixingAngle",.2229),mU=YU("efimovFactor",22.7),gU=FU("atomicMass","1.66053906660e-27","kg"),yU=FU("avogadro","6.02214076e23","mol^-1"),bU=FU("boltzmann","1.380649e-23","J K^-1"),xU=FU("faraday","96485.33212331001","C mol^-1"),vU=FU("firstRadiation","3.7417718521927573e-16","W m^2"),_U=FU("loschmidt","2.686780111798444e25","m^-3"),wU=FU("gasConstant","8.31446261815324","J K^-1 mol^-1"),MU=FU("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),NU=FU("molarVolume","0.022413969545014137","m^3 mol^-1"),SU=YU("sackurTetrode",-1.16487052358),kU=FU("secondRadiation","0.014387768775039337","m K"),DU=FU("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),TU=FU("wienDisplacement","2.897771955e-3","m K"),IU=FU("molarMass","0.99999999965e-3","kg mol^-1"),EU=FU("molarMassC12","11.9999999958e-3","kg mol^-1"),CU=FU("gravity","9.80665","m s^-2"),AU=FU("planckLength","1.616255e-35","m"),LU=FU("planckMass","2.176435e-8","kg"),$U=FU("planckTime","5.391245e-44","s"),OU=FU("planckCharge","1.87554603778e-18","C"),RU=FU("planckTemperature","1.416785e+32","K");function FU(e,t,n){return RH(e,["config","Unit","BigNumber"],(e=>{var{config:r,Unit:a,BigNumber:i}=e,s=new a("BigNumber"===r.number?new i(t):parseFloat(t),n);return s.fixPrefix=!0,s}))}function YU(e,t){return RH(e,["config","BigNumber"],(e=>{var{config:n,BigNumber:r}=e;return"BigNumber"===n.number?new r(t):t}))}var zU=n(5628),BU=RH("Fraction",[],(()=>(zU.prototype.type="Fraction",zU.prototype.isFraction=!0,zU.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},zU.fromJSON=function(e){return new zU(e)},zU)),{isClass:!0}),PU=RH("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,n){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,n){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0}),HU=RH("Range",[],(()=>{function e(t,n,r){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var a=null!=t,i=null!=n,s=null!=r;if(a)if(RP(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(i)if(RP(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter end must be a number");if(s)if(RP(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter step must be a number");this.start=a?parseFloat(t):0,this.end=i?parseFloat(n):0,this.step=s?parseFloat(r):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if("string"!=typeof t)return null;var n=t.split(":").map((function(e){return parseFloat(e)})),r=n.some((function(e){return isNaN(e)}));if(r)return null;switch(n.length){case 2:return new e(n[0],n[1]);case 3:return new e(n[0],n[2],n[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,n=this.step,r=this.end-t;return HH(n)===HH(r)?e=Math.ceil(r/n):0===r&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var t=this.start,n=this.step,r=this.end,a=0;if(n>0)for(;tr;)e(t,[a],this),t+=n,a++},e.prototype.map=function(e){var t=[];return this.forEach((function(n,r,a){t[r[0]]=e(n,r,a)})),t},e.prototype.toArray=function(){var e=[];return this.forEach((function(t,n){e[n[0]]=t})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=KH(this.start,e);return 1!==this.step&&(t+=":"+KH(this.step,e)),t+":"+KH(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e}),{isClass:!0}),jU=RH("ResultSet",[],(()=>{function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=t||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e}),{isClass:!0});function UU(e,t,n){var r=new(0,e.constructor)(2),a="";if(n){if(n<1)throw new Error("size must be in greater than 0");if(!PH(n))throw new Error("size must be an integer");if(e.greaterThan(r.pow(n-1).sub(1))||e.lessThan(r.pow(n-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(n-1,", 2^").concat(n-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(r.pow(n))),a="i".concat(n)}switch(t){case 2:return"".concat(e.toBinary()).concat(a);case 8:return"".concat(e.toOctal()).concat(a);case 16:return"".concat(e.toHexadecimal()).concat(a);default:throw new Error("Base ".concat(t," not supported "))}}function qU(e,t){return void 0!==t?e.toExponential(t-1):e.toExponential()}function WU(e,t){var n=e.length-t.length,r=e.length;return e.substring(n,r)===t}function VU(e,t){var n=function(e,t){return"number"==typeof e?KH(e,t):RP(e)?function(e,t){if("function"==typeof t)return t(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var n,r,a="auto";if(void 0!==t&&(t.notation&&(a=t.notation),"number"==typeof t?n=t:t.precision&&(n=t.precision),t.wordSize&&"number"!=typeof(r=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return function(e,t){return e.toFixed(t)}(e,n);case"exponential":return qU(e,n);case"engineering":return function(e,t){var n=e.e,r=n%3==0?n:n<0?n-3-n%3:n-n%3,a=e.mul(Math.pow(10,-r)),i=a.toPrecision(t);return-1!==i.indexOf("e")&&(i=a.toString()),i+"e"+(n>=0?"+":"")+r.toString()}(e,n);case"bin":return UU(e,2,r);case"oct":return UU(e,8,r);case"hex":return UU(e,16,r);case"auto":var i=t&&void 0!==t.lowerExp?t.lowerExp:-3,s=t&&void 0!==t.upperExp?t.upperExp:5;if(e.isZero())return"0";var o=e.toSignificantDigits(n),u=o.e;return(u>=i&&u'"'+n+'": '+VU(e[n],t))).join(", ")+"}":String(e)}(e,t);return t&&"object"==typeof t&&"truncate"in t&&n.length>t.truncate?n.substring(0,t.truncate-3)+"...":n}function GU(e){for(var t=String(e),n="",r=0;r/g,">")}function JU(e,t){if(Array.isArray(e)){for(var n="[",r=e.length,a=0;at?1:-1}function ZU(e,t,n){if(!(this instanceof ZU))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=n,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function QU(e,t,n){if(!(this instanceof QU))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=n),void 0!==this.min&&this.index=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function eq(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function tq(e,t,n){var r,a=e.length;if(a!==t[n])throw new ZU(a,t[n]);if(n")}function nq(e,t){if(0===t.length){if(Array.isArray(e))throw new ZU(e.length,0)}else tq(e,t,0)}function rq(e,t){if(!OP(e)||!PH(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new QU(e,t)}function aq(e,t,n){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach((function(e){if(!OP(e)||!PH(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+VU(t)+")")})),iq(e,t,0,void 0!==n?n:0),e}function iq(e,t,n,r){var a,i,s=e.length,o=t[n],u=Math.min(s,o);if(e.length=o,n=0){if(t%n!=0)throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-n);r[a]=-t/n}return r}function uq(e){return e.reduce(((e,t)=>e*t),1)}function lq(e,t){for(var n=t||eq(e);Array.isArray(e)&&1===e.length;)e=e[0],n.shift();for(var r=n.length;1===n[r-1];)r--;return rt.test(e)))}function bq(e,t){return Array.prototype.join.call(e,t)}function xq(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],n=0;t[0]={value:e[0],identifier:0};for(var r=1;r{var{Matrix:t}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!BP(t))throw new Error("Invalid datatype: "+t);if(HP(e))"DenseMatrix"===e.type?(this._data=vH(e._data),this._size=vH(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&PP(e.data)&&PP(e.size))this._data=e.data,this._size=e.size,nq(this._data,this._size),this._datatype=t||e.datatype;else if(PP(e))this._data=l(e),this._size=eq(this._data),nq(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+xH(e)+")");this._data=[],this._size=[0],this._datatype=t}}function r(e,t){if(!VP(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var r=t.size();if(r.length!==e._size.length)throw new ZU(r.length,e._size.length);for(var i=t.min(),s=t.max(),o=0,u=e._size.length;o");var p=t.max().map((function(e){return e+1}));u(e,p,r);var d=i.length;s(e._data,t,n,d,0)}return e}function s(e,t,n,r,a){var i=a===r-1,o=t.dimension(a);i?o.forEach((function(t,r){rq(t),e[t]=n[r[0]]})):o.forEach((function(i,o){rq(i),s(e[i],t,n[o[0]],r,a+1)}))}function o(e,t,n){if(0===t.length){for(var r=e._data;PP(r);)r=r[0];return r}return e._size=t.slice(0),e._data=aq(e._data,e._size,n),e}function u(e,t,n){for(var r=e._size.slice(0),a=!1;r.lengthr[i]&&(r[i]=t[i],a=!0);a&&o(e,r,n)}function l(e){for(var t=0,n=e.length;tArray.isArray(e)&&1===e.length?e[0]:e));return o(n?this.clone():this,r,t)},n.prototype.reshape=function(e,t){var n=t?this.clone():this;n._data=sq(n._data,e);var r=n._size.reduce(((e,t)=>e*t));return n._size=oq(e,r),n},n.prototype.clone=function(){return new n({data:vH(this._data),size:vH(this._size),datatype:this._datatype})},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(e){var t=this,r=function n(r,a){return PP(r)?r.map((function(e,t){return n(e,a.concat(t))})):e(r,a,t)}(this._data,[]);return new n(r,void 0!==this._datatype?_q(r,xH):void 0)},n.prototype.forEach=function(e){var t=this;!function n(r,a){PP(r)?r.forEach((function(e,t){n(e,a.concat(t))})):e(r,a,t)}(this._data,[])},n.prototype[Symbol.iterator]=function*(){yield*function*e(t,n){if(PP(t))for(var r=0;r[e[r]]));t.push(new n(i,e._datatype))},s=0;s0?e:0,r=e<0?-e:0,a=this._size[0],i=this._size[1],s=Math.min(a-r,i-t),o=[],u=0;u0?r:0,o=r<0?-r:0,u=e[0],l=e[1],c=Math.min(u-o,l-s);if(PP(t)){if(t.length!==c)throw new Error("Invalid value array length");i=function(e){return t[e]}}else if(HP(t)){var p=t.size();if(1!==p.length||p[0]!==c)throw new Error("Invalid matrix length");i=function(e){return t.get([e])}}else i=function(){return t};a||(a=RP(i(0))?i(0).mul(0):0);var d=[];if(e.length>0){d=aq(d,e,a);for(var h=0;hfunction(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}})),Sq=n(2287);function kq(e,t){if(Eq(e)&&Tq(e,t))return e[t];if("function"==typeof e[t]&&Iq(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function Dq(e,t,n){if(Eq(e)&&Tq(e,t))return e[t]=n,n;throw new Error('No access to property "'+t+'"')}function Tq(e,t){return!(!e||"object"!=typeof e||!TH(Cq,t)&&(t in Object.prototype||t in Function.prototype))}function Iq(e,t){return!(null==e||"function"!=typeof e[t]||TH(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)||!TH(Aq,t)&&(t in Object.prototype||t in Function.prototype))}function Eq(e){return"object"==typeof e&&e&&e.constructor===Object}var Cq={length:!0,name:!0},Aq={toString:!0,valueOf:!0,toLocaleString:!0};class Lq{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return kq(this.wrappedObject,e)}set(e,t){return Dq(this.wrappedObject,e,t),this}has(e){return e in this.wrappedObject}}function $q(){return new Map}function Oq(e){if(!e)return $q();if(Rq(e))return e;if(eH(e))return new Lq(e);throw new Error("createMap can create maps from objects or Maps")}function Rq(e){return!!e&&(e instanceof Map||e instanceof Lq||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function Fq(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t(e)}},{from:"number",to:"Complex",convert:function(e){return n||Pq(e),new n(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return n||Pq(e),new n(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return n||Pq(e),new n(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){a||Hq(e);var t=new a(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(e){t||Bq(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){a||Hq(e);try{return new a(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){n||Pq(e);try{return new n(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return t||Bq(e),new t(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return a||Hq(e),new a(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return r||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new r(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],i}));function Bq(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function Pq(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function Hq(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}function jq(e){var t,n,r=e.length,a=e[0].length,i=[];for(n=0;n=r.length)throw new QU(t,r.length);return HP(e)?e.create(Gq(e.valueOf(),t,n)):Gq(e,t,n)}function Gq(e,t,n){var r,a,i,s;if(t<=0){if(Array.isArray(e[0])){for(s=jq(e),a=[],r=0;r0)return e-t*Math.floor(e/t);if(0===t)return e;throw new Error("Cannot calculate mod for a negative divisor")}function dW(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=t<0;if(n&&(t=-t),0===t)throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return n?1/0:0;if(!isFinite(e))return n?0:e;var r=Math.pow(Math.abs(e),1/t);return r=e<0?-r:r,n?1/r:r}function hW(e){return HH(e)}function fW(e){return e*e}function mW(e,t){var n,r,a,i=0,s=1,o=1,u=0;if(!PH(e)||!PH(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)a=e-(r=Math.floor(e/t))*t,n=i,i=s-r*i,s=n,n=o,o=u-r*o,u=n,e=t,t=a;return e<0?[-e,-s,-u]:[e,e?s:0,u]}function gW(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function yW(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!PH(t)||t<0||t>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(XH(e,t))}Zq.signature=Jq,Qq.signature=Xq,eW.signature=Xq,tW.signature=Jq,nW.signature=Jq,rW.signature=Jq,aW.signature=Jq,iW.signature=Jq,sW.signature=Jq,oW.signature=Xq,uW.signature=Xq,lW.signature=Jq,cW.signature=Jq,pW.signature=Xq,hW.signature=Jq,fW.signature=Jq,mW.signature=Xq,gW.signature=Xq;var bW="unaryPlus",xW=RH(bW,["typed","config","BigNumber"],(e=>{var{typed:t,config:n,BigNumber:r}=e;return t(bW,{number:nW,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return Wq(e,this,!0)},"boolean | string":function(e){return"BigNumber"===n.number?new r(+e):+e}})})),vW=RH("abs",["typed"],(e=>{var{typed:t}=e;return t("abs",{number:Zq,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},Fraction:function(e){return e.abs()},"Array | Matrix":function(e){return Wq(e,this,!0)},Unit:function(e){return e.abs()}})})),_W="acos",wW=RH(_W,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(_W,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.acos(e):new r(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return Wq(e,this)}})})),MW="number";function NW(e){return rj(e)}function SW(e){return Math.atan(1/e)}function kW(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function DW(e){return Math.asin(1/e)}function TW(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function IW(e){return Math.acos(1/e)}function EW(e){var t=1/e,n=Math.sqrt(t*t-1);return Math.log(n+t)}function CW(e){return aj(e)}function AW(e){return ij(e)}function LW(e){return 1/Math.tan(e)}function $W(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function OW(e){return 1/Math.sin(e)}function RW(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*HH(e)}function FW(e){return 1/Math.cos(e)}function YW(e){return 2/(Math.exp(e)+Math.exp(-e))}function zW(e){return oj(e)}NW.signature=MW,SW.signature=MW,kW.signature=MW,DW.signature=MW,TW.signature=MW,IW.signature=MW,EW.signature=MW,CW.signature=MW,AW.signature=MW,LW.signature=MW,$W.signature=MW,OW.signature=MW,RW.signature=MW,FW.signature=MW,YW.signature=MW,zW.signature=MW;var BW="acot",PW=RH(BW,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(BW,{number:SW,Complex:function(e){return e.acot()},BigNumber:function(e){return new n(1).div(e).atan()},"Array | Matrix":function(e){return Wq(e,this)}})})),HW="acsc",jW=RH(HW,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(HW,{number:function(e){return e<=-1||e>=1||n.predictable?DW(e):new r(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new a(1).div(e).asin()},"Array | Matrix":function(e){return Wq(e,this)}})})),UW="addScalar",qW=RH(UW,["typed"],(e=>{var{typed:t}=e;return t(UW,{"number, number":Qq,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":function(e,t){if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var n=e.clone();return n.value=this(n.value,t.value),n.fixPrefix=!1,n}})})),WW=RH("arg",["typed"],(e=>{var{typed:t}=e;return t("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return Wq(e,this)}})})),VW="asech",GW=RH(VW,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(VW,{number:function(e){if(e<=1&&e>=-1||n.predictable){var t=1/e;if(t>0||n.predictable)return EW(e);var a=Math.sqrt(t*t-1);return new r(Math.log(a-t),Math.PI)}return new r(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new a(1).div(e).acosh()},"Array | Matrix":function(e){return Wq(e,this)}})})),KW=RH("asinh",["typed"],(e=>{var{typed:t}=e;return t("asinh",{number:CW,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return Wq(e,this,!0)}})})),JW=RH("atan",["typed"],(e=>{var{typed:t}=e;return t("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()},"Array | Matrix":function(e){return Wq(e,this,!0)}})})),XW="atanh",ZW=RH(XW,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(XW,{number:function(e){return e<=1&&e>=-1||n.predictable?AW(e):new r(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return Wq(e,this,!0)}})})),QW=RH("bignumber",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("bignumber",{"":function(){return new n(0)},number:function(e){return new n(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var r=t[2],a=n(t[1]),i=new n(2).pow(Number(r));if(a.gt(i.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var s=new n(2).pow(Number(r)-1);return a.gte(s)?a.sub(i):a}return new n(e)},BigNumber:function(e){return e},Fraction:function(e){return new n(e.n).div(e.d).times(e.s)},null:function(e){return new n(0)},"Array | Matrix":function(e){return Wq(e,this)}})}));function eV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new n(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new n(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new n(0):e}return rV(e,t,(function(e,t){return e&t}))}function tV(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,n=t.precision;t.config({precision:1e9});var r=e.plus(new t(1));return r.s=-r.s||null,t.config({precision:n}),r}function nV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);var r=new n(-1);return e.isZero()||t.eq(r)||e.eq(t)?t:t.isZero()||e.eq(r)?e:e.isFinite()&&t.isFinite()?rV(e,t,(function(e,t){return e|t})):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?r:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function rV(e,t,n){var r,a,i,s,o,u=e.constructor,l=+(e.s<0),c=+(t.s<0);if(l){r=aV(tV(e));for(var p=0;p0;)n(i[--h],s[--f])===m&&(g=g.plus(y)),y=y.times(b);for(;f>0;)n(o,s[--f])===m&&(g=g.plus(y)),y=y.times(b);return u.config({precision:x}),0===m&&(g.s=-g.s),g}function aV(e){for(var t=e.d,n=t[0]+"",r=1;r0)if(++o>l)for(o-=l;o--;)u+="0";else o1&&(null!==c[h+1]&&void 0!==c[h+1]||(c[h+1]=0),c[h+1]+=c[h]>>1,c[h]&=1)}return c.reverse()}function iV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new n(0);var r=new n(-1);return e.eq(r)?tV(t):t.eq(r)?tV(e):e.isFinite()&&t.isFinite()?rV(e,t,(function(e,t){return e^t})):e.isFinite()||t.isFinite()?new n(e.isNegative()===t.isNegative()?1/0:-1/0):r}function sV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new n(2).pow(t)):new n(NaN)}function oV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new n(2).pow(t)).floor():e.isNegative()?new n(-1):e.isFinite()?new n(0):new n(NaN)}var uV="number, number";function lV(e,t){if(!PH(e)||!PH(t))throw new Error("Integers expected in function bitAnd");return e&t}function cV(e){if(!PH(e))throw new Error("Integer expected in function bitNot");return~e}function pV(e,t){if(!PH(e)||!PH(t))throw new Error("Integers expected in function bitOr");return e|t}function dV(e,t){if(!PH(e)||!PH(t))throw new Error("Integers expected in function bitXor");return e^t}function hV(e,t){if(!PH(e)||!PH(t))throw new Error("Integers expected in function leftShift");return e<>t}function mV(e,t){if(!PH(e)||!PH(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}lV.signature=uV,cV.signature="number",pV.signature=uV,dV.signature=uV,hV.signature=uV,fV.signature=uV,mV.signature=uV;var gV="bitNot",yV=RH(gV,["typed"],(e=>{var{typed:t}=e;return t(gV,{number:cV,BigNumber:tV,"Array | Matrix":function(e){return Wq(e,this)}})})),bV="boolean",xV=RH(bV,["typed"],(e=>{var{typed:t}=e;return t(bV,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var n=Number(e);if(""!==e&&!isNaN(n))return!!n;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return Wq(e,this)}})})),vV="clone",_V=RH(vV,["typed"],(e=>{var{typed:t}=e;return t(vV,{any:vH})}));function wV(e,t){if(t>1;return wV(e,n)*wV(n+1,t)}function MV(e,t){if(!PH(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!PH(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");for(var n=e-t,r=1,a=2,i=t{var{typed:t}=e;return t(NV,{"number, number":MV,"BigNumber, BigNumber":function(e,t){var n,r,a=e.constructor,i=e.minus(t),s=new a(1);if(!kV(e)||!kV(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(n=s,t.lt(i))for(r=s;r.lte(i);r=r.plus(s))n=n.times(t.plus(r)).dividedBy(r);else for(r=s;r.lte(t);r=r.plus(s))n=n.times(i.plus(r)).dividedBy(r);return n}})}));function kV(e){return e.isInteger()&&e.gte(0)}var DV=RH("complex",["typed","Complex"],(e=>{var{typed:t,Complex:n}=e;return t("complex",{"":function(){return n.ZERO},number:function(e){return new n(e,0)},"number, number":function(e,t){return new n(e,t)},"BigNumber, BigNumber":function(e,t){return new n(e.toNumber(),t.toNumber())},Fraction:function(e){return new n(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return n(e)},null:function(e){return n(0)},Object:function(e){if("re"in e&&"im"in e)return new n(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new n(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return Wq(e,this)}})})),TV="conj",IV=RH(TV,["typed"],(e=>{var{typed:t}=e;return t(TV,{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return Wq(e,this)}})})),EV="cosh",CV=RH(EV,["typed"],(e=>{var{typed:t}=e;return t(EV,{number:sj,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(e.value)},"Array | Matrix":function(e){return Wq(e,this)}})})),AV="coth",LV=RH(AV,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(AV,{number:$W,Complex:function(e){return e.coth()},BigNumber:function(e){return new n(1).div(e.tanh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(e.value)},"Array | Matrix":function(e){return Wq(e,this)}})})),$V=RH("csc",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("csc",{number:OW,Complex:function(e){return e.csc()},BigNumber:function(e){return new n(1).div(e.sin())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(e.value)},"Array | Matrix":function(e){return Wq(e,this)}})})),OV="cube",RV=RH(OV,["typed"],(e=>{var{typed:t}=e;return t(OV,{number:aW,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},"Array | Matrix":function(e){return Wq(e,this,!0)},Unit:function(e){return e.pow(3)}})}));function FV(e,t,n){if(null==n)return e.eq(t);if(e.eq(t))return!0;if(e.isNaN()||t.isNaN())return!1;if(e.isFinite()&&t.isFinite()){var r=e.minus(t).abs();if(r.isZero())return!0;var a=e.constructor.max(e.abs(),t.abs());return r.lte(a.times(n))}return!1}var YV="equalScalar",zV=RH(YV,["typed","config"],(e=>{var{typed:t,config:n}=e;return t(YV,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return nj(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||FV(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,n){return nj(e.re,t.re,n)&&nj(e.im,t.im,n)}(e,t,n.epsilon)},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)}})})),BV=(RH(YV,["typed","config"],(e=>{var{typed:t,config:n}=e;return t(YV,{"number, number":function(e,t){return nj(e,t,n.epsilon)}})})),RH("erf",["typed"],(e=>{var{typed:t}=e;return t("name",{number:function(e){var t=Math.abs(e);return t>=qV?HH(e):t<=PV?HH(e)*function(e){var t,n=e*e,r=jV[0][4]*n,a=n;for(t=0;t<3;t+=1)r=(r+jV[0][t])*n,a=(a+UV[0][t])*n;return e*(r+jV[0][3])/(a+UV[0][3])}(t):t<=4?HH(e)*(1-function(e){var t,n=jV[1][8]*e,r=e;for(t=0;t<7;t+=1)n=(n+jV[1][t])*e,r=(r+UV[1][t])*e;var a=(n+jV[1][7])/(r+UV[1][7]),i=parseInt(16*e)/16,s=(e-i)*(e+i);return Math.exp(-i*i)*Math.exp(-s)*a}(t)):HH(e)*(1-function(e){var t,n=1/(e*e),r=jV[2][5]*n,a=n;for(t=0;t<4;t+=1)r=(r+jV[2][t])*n,a=(a+UV[2][t])*n;var i=n*(r+jV[2][4])/(a+UV[2][4]);i=(HV-i)/e;var s=(e-(n=parseInt(16*e)/16))*(e+n);return Math.exp(-n*n)*Math.exp(-s)*i}(t))},"Array | Matrix":function(e){return Wq(e,this)}})}))),PV=.46875,HV=.5641895835477563,jV=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],UV=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],qV=Math.pow(2,53),WV=RH("exp",["typed"],(e=>{var{typed:t}=e;return t("exp",{number:iW,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return Wq(e,this)}})})),VV="expm1",GV=RH(VV,["typed","Complex"],(e=>{var{typed:t,Complex:n}=e;return t(VV,{number:sW,Complex:function(e){var t=Math.exp(e.re);return new n(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)},"Array | Matrix":function(e){return Wq(e,this)}})})),KV=RH("filter",["typed"],(e=>{var{typed:t}=e;return t("filter",{"Array, function":JV,"Matrix, function":function(e,t){return e.create(JV(e.toArray(),t))},"Array, RegExp":yq,"Matrix, RegExp":function(e,t){return e.create(yq(e.toArray(),t))}})}));function JV(e,t){var n=dj(t);return gq(e,(function(e,r,a){return 1===n?t(e):2===n?t(e,[r]):t(e,[r],a)}))}var XV="forEach",ZV=RH(XV,["typed"],(e=>{var{typed:t}=e;return t(XV,{"Array, function":QV,"Matrix, function":function(e,t){return e.forEach(t)}})}));function QV(e,t){var n=dj(t);!function r(a,i){Array.isArray(a)?mq(a,(function(e,t){r(e,i.concat(t))})):1===n?t(a):2===n?t(a,i):t(a,i,e)}(e,[])}var eG="format",tG=RH(eG,["typed"],(e=>{var{typed:t}=e;return t(eG,{any:VU,"any, Object | function | number":VU})})),nG="getMatrixDataType",rG=RH(nG,["typed"],(e=>{var{typed:t}=e;return t(nG,{Array:function(e){return _q(e,xH)},Matrix:function(e){return e.getDataType()}})})),aG=RH("hex",["typed","format"],(e=>{var{typed:t,format:n}=e;return t("hex",{"number | BigNumber":function(e){return n(e,{notation:"hex"})},"number | BigNumber, number":function(e,t){return n(e,{notation:"hex",wordSize:t})}})})),iG=RH("im",["typed"],(e=>{var{typed:t}=e;return t("im",{number:function(e){return 0},BigNumber:function(e){return e.mul(0)},Fraction:function(e){return e.mul(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return Wq(e,this)}})})),sG="isInteger",oG=RH(sG,["typed"],(e=>{var{typed:t}=e;return t(sG,{number:PH,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":function(e){return Wq(e,this)}})})),uG="number";function lG(e){return e<0}function cG(e){return e>0}function pG(e){return 0===e}function dG(e){return Number.isNaN(e)}lG.signature=uG,cG.signature=uG,pG.signature=uG,dG.signature=uG;var hG="isNegative",fG=RH(hG,["typed"],(e=>{var{typed:t}=e;return t(hG,{number:lG,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return Wq(e,this)}})})),mG="isPositive",gG=RH(mG,["typed"],(e=>{var{typed:t}=e;return t(mG,{number:cG,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return Wq(e,this)}})})),yG="isZero",bG=RH(yG,["typed"],(e=>{var{typed:t}=e;return t(yG,{number:pG,BigNumber:function(e){return e.isZero()},Complex:function(e){return 0===e.re&&0===e.im},Fraction:function(e){return 1===e.d&&0===e.n},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return Wq(e,this)}})}));function xG(e){var t;if(PH(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:wV(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*xG(1-e));if(e>=171.35)return 1/0;if(e>85){var n=e*e,r=n*e,a=r*e,i=a*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*n)-139/(51840*r)-571/(2488320*a)+163879/(209018880*i)+5246819/(75246796800*i*e))}--e,t=_G[0];for(var s=1;s<_G.length;++s)t+=_G[s]/(e+s);var o=e+vG+.5;return Math.sqrt(2*Math.PI)*Math.pow(o,e+.5)*Math.exp(-o)*t}xG.signature="number";var vG=4.7421875,_G=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],wG=.9189385332046728,MG=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function NG(e){if(e<0)return NaN;if(0===e)return 1/0;if(!isFinite(e))return e;if(e<.5)return Math.log(Math.PI/Math.sin(Math.PI*e))-NG(1-e);for(var t=5+(e-=1)+.5,n=MG[0],r=6;r>=1;r--)n+=MG[r]/(e+r);return wG+(e+.5)*Math.log(t)-t+Math.log(n)}NG.signature="number";var SG="lgamma",kG=RH(SG,["Complex","typed"],(e=>{var{Complex:t,typed:n}=e,r=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return n(SG,{number:NG,Complex:function(e){var n,r;if(e.isNaN())return new t(NaN,NaN);if(0===e.im)return new t(NG(e.re),0);if(e.re>=7||Math.abs(e.im)>=7)return a(e);if(e.re<=.1){var s=(n=6.283185307179586,(!0^((r=e.im)>0||!(r<0)&&1/r==1/0)?-n:n)*Math.floor(.5*e.re+.25)),o=e.mul(Math.PI).sin().log(),u=this(new t(1-e.re,-e.im));return new t(1.1447298858494002,s).sub(o).sub(u)}return e.im>=0?i(e):i(e.conjugate()).conjugate()},BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function a(e){for(var n=e.sub(.5).mul(e.log()).sub(e).add(wG),a=new t(1,0).div(e),i=a.div(e),s=r[0],o=r[1],u=2*i.re,l=i.re*i.re+i.im*i.im,c=2;c<8;c++){var p=o;o=-l*s+r[c],s=u*s+p}var d=a.mul(i.mul(s).add(o));return n.add(d)}function i(e){var n=0,r=0,i=e;for(e=e.add(1);e.re<=7;){var s=(i=i.mul(e)).im<0?1:0;0!==s&&0===r&&n++,r=s,e=e.add(1)}return a(e).sub(i.log()).sub(new t(0,2*n*Math.PI*1))}})),DG="log10",TG=RH(DG,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(DG,{number:function(e){return e>=0||n.predictable?lW(e):new r(e,0).log().div(Math.LN10)},Complex:function(e){return new r(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||n.predictable?e.log():new r(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return Wq(e,this)}})})),IG="log2",EG=RH(IG,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(IG,{number:function(e){return e>=0||n.predictable?cW(e):a(new r(e,0))},Complex:a,BigNumber:function(e){return!e.isNegative()||n.predictable?e.log(2):a(new r(e.toNumber(),0))},"Array | Matrix":function(e){return Wq(e,this)}});function a(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new r(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),CG=RH("map",["typed"],(e=>{var{typed:t}=e;return t("map",{"Array, function":AG,"Matrix, function":function(e,t){return e.map(t)}})}));function AG(e,t){var n=dj(t);return function r(a,i){if(Array.isArray(a))return a.map((function(e,t){return r(e,i.concat(t))}));try{return 1===n?t(a):2===n?t(a,i):t(a,i,e)}catch(t){if(t instanceof TypeError&&"data"in t&&"wrongType"===t.data.category){var s="map attempted to call '".concat(t.data.fn,"(").concat(a),o=JSON.stringify(i);throw 2===n?s+=","+o:1!==n&&(s+=",".concat(o,",").concat(e)),s+=")' but argument ".concat(t.data.index+1," of type "),s+="".concat(t.data.actual," does not match expected type "),s+=t.data.expected.join(" or "),new TypeError(s)}throw t}}(e,[])}var LG=RH("multiplyScalar",["typed"],(e=>{var{typed:t}=e;return t("multiplyScalar",{"number, number":eW,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":function(e,t){var n=t.clone();return n.value=null===n.value?n._normalize(e):this(n.value,e),n},"Unit, number | Fraction | BigNumber | Complex":function(e,t){var n=e.clone();return n.value=null===n.value?n._normalize(t):this(n.value,t),n},"Unit, Unit":function(e,t){return e.multiply(t)}})})),$G="number, number";function OG(e){return!e}function RG(e,t){return!(!e&&!t)}function FG(e,t){return!!e!=!!t}function YG(e,t){return!(!e||!t)}OG.signature="number",RG.signature=$G,FG.signature=$G,YG.signature=$G;var zG=RH("not",["typed"],(e=>{var{typed:t}=e;return t("not",{number:OG,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||this(e.value)},"Array | Matrix":function(e){return Wq(e,this)}})})),BG=RH("number",["typed"],(e=>{var{typed:t}=e,n=t("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t=function(e){var t=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);return t?{input:e,radix:{"0b":2,"0o":8,"0x":16}[t[1]],integerPart:t[2],fractionalPart:t[3]}:null}(e);if(t)return function(e){for(var t=parseInt(e.integerPart,e.radix),n=0,r=0;r2**n-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));a>=2**(n-1)&&(a-=2**n)}return a},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return Wq(e,this)}});return n.fromJSON=function(e){return parseFloat(e.value)},n})),PG=RH("oct",["typed","format"],(e=>{var{typed:t,format:n}=e;return t("oct",{"number | BigNumber":function(e){return n(e,{notation:"oct"})},"number | BigNumber, number":function(e,t){return n(e,{notation:"oct",wordSize:t})}})})),HG=n(4676),jG=HG(Date.now());function UG(e){var t,n;return t=null===(n=e)?jG:HG(String(n)),function(){return t()}}var qG="pickRandom",WG=RH(qG,["typed","config","?on"],(e=>{var{typed:t,config:n,on:r}=e,a=UG(n.randomSeed);return r&&r("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=UG(e.randomSeed))})),t(qG,{"Array | Matrix":function(e){return i(e,{})},"Array | Matrix, Object":function(e,t){return i(e,t)},"Array | Matrix, number":function(e,t){return i(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return i(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,n){return i(e,{number:n,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,n){return i(e,{number:t,weights:n})}});function i(e,t){var{number:n,weights:r,elementWise:i=!0}=t,s=void 0===n;s&&(n=1);var o=HP(e)?e.create:HP(r)?r.create:null;e=e.valueOf(),r&&(r=r.valueOf()),!0===i&&(e=hq(e),r=hq(r));var u=0;if(void 0!==r){if(r.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var l=0,c=r.length;l{var{typed:t}=e;return t(VG,{"string, Object | Array":KG,"string, Object | Array, number | Object":KG})}));function KG(e,t,n){return e.replace(/\$([\w.]+)/g,(function(e,r){for(var a=r.split("."),i=t[a.shift()];a.length&&void 0!==i;){var s=a.shift();i=s?i[s]:i+"."}return void 0!==i?BP(i)?i:VU(i,n):e}))}function JG(e,t){var n=[];if((e=e.slice(0)).length>1)for(var r=0,a=e.shift();r{var{typed:t,config:n,on:r}=e,a=UG(n.randomSeed);return r&&r("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=UG(e.randomSeed))})),t(XG,{"":()=>s(0,1),number:e=>s(0,e),"number, number":(e,t)=>s(e,t),"Array | Matrix":e=>i(e,0,1),"Array | Matrix, number":(e,t)=>i(e,0,t),"Array | Matrix, number, number":(e,t,n)=>i(e,t,n)});function i(e,t,n){var r=JG(e.valueOf(),(()=>s(t,n)));return HP(e)?e.create(r):r}function s(e,t){return e+a()*(t-e)}})),QG=RH("re",["typed"],(e=>{var{typed:t}=e;return t("re",{number:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return Wq(e,this)}})})),eK=RH("sec",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("sec",{number:FW,Complex:function(e){return e.sec()},BigNumber:function(e){return new n(1).div(e.cos())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(e.value)},"Array | Matrix":function(e){return Wq(e,this)}})})),tK="sign",nK=RH(tK,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:t,BigNumber:n,complex:r,Fraction:a}=e;return t(tK,{number:hW,Complex:function(e){return 0===e.im?r(hW(e.re)):e.sign()},BigNumber:function(e){return new n(e.cmp(0))},Fraction:function(e){return new a(e.s,1)},"Array | Matrix":function(e){return Wq(e,this,!0)},Unit:function(e){if(!e._isDerived()&&0!==e.units[0].unit.offset)throw new TypeError("sign is ambiguous for units with offset");return this(e.value)}})})),rK=RH("sin",["typed"],(e=>{var{typed:t}=e;return t("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(e.value)},"Array | Matrix":function(e){return Wq(e,this,!0)}})})),aK=RH("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:t,equalScalar:n,Matrix:r}=e;function a(e,t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!BP(t))throw new Error("Invalid datatype: "+t);if(HP(e))!function(e,t,n){"SparseMatrix"===t.type?(e._values=t._values?vH(t._values):void 0,e._index=vH(t._index),e._ptr=vH(t._ptr),e._size=vH(t._size),e._datatype=n||t._datatype):i(e,t.valueOf(),n||t._datatype)}(this,e,t);else if(e&&PP(e.index)&&PP(e.ptr)&&PP(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(PP(e))i(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+xH(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}}function i(e,r,a){e._values=[],e._index=[],e._ptr=[],e._datatype=a;var i=r.length,s=0,o=n,u=0;if(BP(a)&&(o=t.find(n,[a,a])||n,u=t.convert(0,a)),i>0){var l=0;do{e._ptr.push(e._index.length);for(var c=0;c");if(1===i.length)t.dimension(0).forEach((function(t,a){rq(t),e.set([t,0],n[a[0]],r)}));else{var l=t.dimension(0),c=t.dimension(1);l.forEach((function(t,a){rq(t),c.forEach((function(i,s){rq(i),e.set([t,i],n[a[0]][s[0]],r)}))}))}}return e}function u(e,t,n,r){if(n-t==0)return n;for(var a=t;af){for(c=f;ch){if(d){var m=0;for(c=0;cr-1&&(e._values.splice(p,1),e._index.splice(p,1),y++)}e._ptr[c]=e._values.length}return e._size[0]=r,e._size[1]=a,e}function p(e,t,n,r,a){var i,s,o=r[0],u=r[1],l=[];for(i=0;io-1||s>p-1)&&(c(this,Math.max(i+1,o),Math.max(s+1,p),a),o=this._size[0],p=this._size[1]),rq(i,o),rq(s,p);var f=u(i,this._ptr[s],this._ptr[s+1],this._index);return fArray.isArray(e)&&1===e.length?e[0]:e));if(2!==r.length)throw new Error("Only two dimensions matrix are supported");return r.forEach((function(e){if(!OP(e)||!PH(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+VU(r)+")")})),c(n?this.clone():this,r[0],r[1],t)},a.prototype.reshape=function(e,t){if(!PP(e))throw new TypeError("Array expected");if(2!==e.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(t){if(!OP(t)||!PH(t)||t<=-2||0===t)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+VU(e)+")")}));var n=this._size[0]*this._size[1];if(n!==(e=oq(e,n))[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var r=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return r;for(var a=[],i=0;i=0&&v<=i&&m(e._values[x],v-0,g-0)}else{for(var _={},w=y;w "+(this._values?VU(this._values[u],e):"X");return a},a.prototype.toString=function(){return VU(this.toArray())},a.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},a.prototype.diagonal=function(e){if(e){if(RP(e)&&(e=e.toNumber()),!OP(e)||!PH(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,n=e<0?-e:0,r=this._size[0],i=this._size[1],s=Math.min(r-n,i-t),o=[],u=[],l=[];l[0]=0;for(var c=t;c0?i:0,d=i<0?-i:0,h=e[0],f=e[1],m=Math.min(h-d,f-p);if(PP(r)){if(r.length!==m)throw new Error("Invalid value array length");c=function(e){return r[e]}}else if(HP(r)){var g=r.size();if(1!==g.length||g[0]!==m)throw new Error("Invalid matrix length");c=function(e){return r.get([e])}}else c=function(){return r};for(var y=[],b=[],x=[],v=0;v=0&&_=l||a[p]!==t)){var h=r?r[c]:void 0;a.splice(p,0,t),r&&r.splice(p,0,h),a.splice(p<=c?c+1:c,1),r&&r.splice(p<=c?c+1:c,1)}else if(p=l||a[c]!==e)){var f=r?r[p]:void 0;a.splice(c,0,e),r&&r.splice(c,0,f),a.splice(c<=p?p+1:p,1),r&&r.splice(c<=p?p+1:p,1)}}},a}),{isClass:!0}),iK="splitUnit",sK=RH(iK,["typed"],(e=>{var{typed:t}=e;return t(iK,{"Unit, Array":function(e,t){return e.splitUnit(t)}})})),oK="square",uK=RH(oK,["typed"],(e=>{var{typed:t}=e;return t(oK,{number:fW,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},"Array | Matrix":function(e){return Wq(e,this,!0)},Unit:function(e){return e.pow(2)}})})),lK="string",cK=RH(lK,["typed"],(e=>{var{typed:t}=e;return t(lK,{"":function(){return""},number:KH,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return Wq(e,this)},any:function(e){return String(e)}})})),pK=RH("tan",["typed"],(e=>{var{typed:t}=e;return t("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(e.value)},"Array | Matrix":function(e){return Wq(e,this,!0)}})})),dK="typeOf",hK=RH(dK,["typed"],(e=>{var{typed:t}=e;return t(dK,{any:xH})})),fK="acosh",mK=RH(fK,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(fK,{number:function(e){return e>=1||n.predictable?NW(e):e<=-1?new r(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new r(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return Wq(e,this)}})})),gK="acsch",yK=RH(gK,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(gK,{number:TW,Complex:function(e){return e.acsch()},BigNumber:function(e){return new n(1).div(e).asinh()},"Array | Matrix":function(e){return Wq(e,this)}})})),bK="apply",xK=RH(bK,["typed","isInteger"],(e=>{var{typed:t,isInteger:n}=e;return t(bK,{"Array | Matrix, number | BigNumber, function":function(e,t,r){if(!n(t))throw new TypeError("Integer number expected for dimension");var a=Array.isArray(e)?eq(e):e.size();if(t<0||t>=a.length)throw new QU(t,a.length);return HP(e)?e.create(vK(e.valueOf(),t,r)):vK(e,t,r)}})}));function vK(e,t,n){var r,a,i;if(t<=0){if(Array.isArray(e[0])){for(i=function(e){var t,n,r=e.length,a=e[0].length,i=[];for(n=0;n{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(_K,{number:function(e){return e<=-1||e>=1||n.predictable?IW(e):new r(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new a(1).div(e).acos()},"Array | Matrix":function(e){return Wq(e,this)}})})),MK=RH("bin",["typed","format"],(e=>{var{typed:t,format:n}=e;return t("bin",{"number | BigNumber":function(e){return n(e,{notation:"bin"})},"number | BigNumber, number":function(e,t){return n(e,{notation:"bin",wordSize:t})}})})),NK="combinationsWithRep",SK=RH(NK,["typed"],(e=>{var{typed:t}=e;return t(NK,{"number, number":function(e,t){if(!PH(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!PH(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t{var{typed:t}=e;return t("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(e.value)},"Array | Matrix":function(e){return Wq(e,this)}})})),TK="csch",IK=RH(TK,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(TK,{number:RW,Complex:function(e){return e.csch()},BigNumber:function(e){return new n(1).div(e.sinh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(e.value)},"Array | Matrix":function(e){return Wq(e,this)}})})),EK="isNaN",CK=RH(EK,["typed"],(e=>{var{typed:t}=e;return t(EK,{number:dG,BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return Wq(e,Number.isNaN)}})})),AK="isPrime",LK=RH(AK,["typed"],(e=>{var{typed:t}=e;return t(AK,{number:function(e){if(0*e!=0)return!1;if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t==0||e%(t+2)==0)return!1;return!0},BigNumber:function(e){if(0*e.toNumber()!=0)return!1;if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(Math.pow(2,32))){for(var t=e.toNumber(),n=5;n*n<=t;n+=6)if(t%n==0||t%(n+2)==0)return!1;return!0}function r(e,t,n){for(var r=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(n)):(t=t.sub(1),r=e.mul(r).mod(n));return r}for(var a=e.constructor.clone({precision:2*e.toFixed(0).length}),i=0,s=(e=new a(e)).sub(1);s.mod(2).eq(0);)s=s.div(2),i+=1;var o=null;if(e.lt("3317044064679887385961981"))o=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((t=>t{var{typed:t,config:n,on:r}=e,a=UG(n.randomSeed);return r&&r("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=UG(e.randomSeed))})),t($K,{"":()=>s(0,1),number:e=>s(0,e),"number, number":(e,t)=>s(e,t),"Array | Matrix":e=>i(e,0,1),"Array | Matrix, number":(e,t)=>i(e,0,t),"Array | Matrix, number, number":(e,t,n)=>i(e,t,n)});function i(e,t,n){var r=JG(e.valueOf(),(()=>s(t,n)));return HP(e)?e.create(r):r}function s(e,t){return Math.floor(e+a()*(t-e))}})),RK="sech",FK=RH(RK,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(RK,{number:YW,Complex:function(e){return e.sech()},BigNumber:function(e){return new n(1).div(e.cosh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(e.value)},"Array | Matrix":function(e){return Wq(e,this)}})})),YK="sinh",zK=RH(YK,["typed"],(e=>{var{typed:t}=e;return t(YK,{number:zW,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(e.value)},"Array | Matrix":function(e){return Wq(e,this,!0)}})})),BK="sparse",PK=RH(BK,["typed","SparseMatrix"],(e=>{var{typed:t,SparseMatrix:n}=e;return t(BK,{"":function(){return new n([])},string:function(e){return new n([],e)},"Array | Matrix":function(e){return new n(e)},"Array | Matrix, string":function(e,t){return new n(e,t)}})})),HK=RH("sqrt",["config","typed","Complex"],(e=>{var{config:t,typed:n,Complex:r}=e;return n("sqrt",{number:a,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():a(e.toNumber())},"Array | Matrix":function(e){return Wq(e,this,!0)},Unit:function(e){return e.pow(.5)}});function a(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new r(e,0).sqrt()}})),jK=RH("tanh",["typed"],(e=>{var{typed:t}=e;return t("tanh",{number:uj,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(e.value)},"Array | Matrix":function(e){return Wq(e,this,!0)}})})),UK="unaryMinus",qK=RH(UK,["typed"],(e=>{var{typed:t}=e;return t(UK,{number:tW,Complex:function(e){return e.neg()},BigNumber:function(e){return e.neg()},Fraction:function(e){return e.neg()},Unit:function(e){var t=e.clone();return t.value=this(e.value),t},"Array | Matrix":function(e){return Wq(e,this,!0)}})})),WK="acoth",VK=RH(WK,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(WK,{number:function(e){return e>=1||e<=-1||n.predictable?kW(e):new r(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new a(1).div(e).atanh()},"Array | Matrix":function(e){return Wq(e,this)}})})),GK=RH("cot",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("cot",{number:LW,Complex:function(e){return e.cot()},BigNumber:function(e){return new n(1).div(e.tan())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(e.value)},"Array | Matrix":function(e){return Wq(e,this)}})})),KK=RH("fraction",["typed","Fraction"],(e=>{var{typed:t,Fraction:n}=e;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new n(e)},string:function(e){return new n(e)},"number, number":function(e,t){return new n(e,t)},null:function(e){return new n(0)},BigNumber:function(e){return new n(e.toString())},Fraction:function(e){return e},Object:function(e){return new n(e)},"Array | Matrix":function(e){return Wq(e,this)}})})),JK="isNumeric",XK=RH(JK,["typed"],(e=>{var{typed:t}=e;return t(JK,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(e){return Wq(e,this)}})})),ZK="matrix",QK=RH(ZK,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,Matrix:n,DenseMatrix:r,SparseMatrix:a}=e;return t(ZK,{"":function(){return i([])},string:function(e){return i([],e)},"string, string":function(e,t){return i([],e,t)},Array:function(e){return i(e)},Matrix:function(e){return i(e,e.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(e,t,n){if("dense"===t||"default"===t||void 0===t)return new r(e,n);if("sparse"===t)return new a(e,n);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}})),eJ="matrixFromFunction",tJ=RH(eJ,["typed","matrix","isZero"],(e=>{var{typed:t,matrix:n,isZero:r}=e;return t(eJ,{"Array | Matrix, function, string, string":function(e,t,n,r){return a(e,t,n,r)},"Array | Matrix, function, string":function(e,t,n){return a(e,t,n)},"Matrix, function":function(e,t){return a(e,t,"dense")},"Array, function":function(e,t){return a(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,n){return a(e,n,t)},"Array | Matrix, string, string, function":function(e,t,n,r){return a(e,r,t,n)}});function a(e,t,a,i){var s;return(s=void 0!==i?n(a,i):n(a)).resize(e),s.forEach((function(e,n){var a=t(n);r(a)||s.set(n,a)})),s}})),nJ=RH("algorithm02",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return function(e,r,a,i){var s=e._data,o=e._size,u=e._datatype,l=r._values,c=r._index,p=r._ptr,d=r._size,h=r._datatype;if(o.length!==d.length)throw new ZU(o.length,d.length);if(o[0]!==d[0]||o[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+d+")");if(!l)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var f,m=o[0],g=o[1],y=n,b=0,x=a;"string"==typeof u&&u===h&&(f=u,y=t.find(n,[f,f]),b=t.convert(0,f),x=t.find(a,[f,f]));for(var v=[],_=[],w=[],M=0;M{var{typed:t}=e;return function(e,n,r,a){var i=e._data,s=e._size,o=e._datatype,u=n._values,l=n._index,c=n._ptr,p=n._size,d=n._datatype;if(s.length!==p.length)throw new ZU(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,f=s[0],m=s[1],g=0,y=r;"string"==typeof o&&o===d&&(h=o,g=t.convert(0,h),y=t.find(r,[h,h]));for(var b=[],x=0;x{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new ZU(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");var m,g=u[0],y=u[1],b=n,x=0,v=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),x=t.convert(0,m),v=t.find(a,[m,m]));var _,w,M,N,S=i&&c?[]:void 0,k=[],D=[],T=S?[]:void 0,I=S?[]:void 0,E=[],C=[];for(w=0;w{var{typed:t,equalScalar:n}=e;return function(e,r,a,i){var s=e._values,o=e._index,u=e._ptr,l=e._size,c=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p,d=l[0],h=l[1],f=n,m=0,g=a;"string"==typeof c&&(p=c,f=t.find(n,[p,p]),m=t.convert(0,p),r=t.convert(r,p),g=t.find(a,[p,p]));for(var y=[],b=[],x=[],v=0;v{var{typed:t,DenseMatrix:n}=e;return function(e,r,a,i){var s=e._values,o=e._index,u=e._ptr,l=e._size,c=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p,d=l[0],h=l[1],f=a;"string"==typeof c&&(p=c,r=t.convert(r,p),f=t.find(a,[p,p]));for(var m=[],g=[],y=[],b=0;b{var{typed:t}=e;return function(e,r,a){var i,s=e._data,o=e._size,u=e._datatype,l=r._data,c=r._size,p=r._datatype,d=[];if(o.length!==c.length)throw new ZU(o.length,c.length);for(var h=0;h0?n(f,0,d,d[0],s,l):[];return e.createDenseMatrix({data:m,size:d,datatype:i})};function n(e,t,r,a,i,s){var o=[];if(t===r.length-1)for(var u=0;u{var{typed:t}=e;return function(e,r,a,i){var s,o=e._data,u=e._size,l=e._datatype,c=a;"string"==typeof l&&(s=l,r=t.convert(r,s),c=t.find(a,[s,s]));var p=u.length>0?n(c,0,u,u[0],o,r,i):[];return e.createDenseMatrix({data:p,size:vH(u),datatype:s})};function n(e,t,r,a,i,s,o){var u=[];if(t===r.length-1)for(var l=0;l{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=nJ({typed:t,equalScalar:r}),s=rJ({typed:t}),o=aJ({typed:t,equalScalar:r}),u=iJ({typed:t,equalScalar:r}),l=sJ({typed:t,DenseMatrix:a}),c=oJ({typed:t}),p=uJ({typed:t});return t("mod",{"number, number":pW,"BigNumber, BigNumber":function(e,t){if(t.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){if(t.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return e.compare(0)>=0?e.mod(t):e.mod(t).add(t).mod(t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(n(t),e,this,!0).valueOf()}})})),cJ=RH("algorithm01",["typed"],(e=>{var{typed:t}=e;return function(e,n,r,a){var i=e._data,s=e._size,o=e._datatype,u=n._values,l=n._index,c=n._ptr,p=n._size,d=n._datatype;if(s.length!==p.length)throw new ZU(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,f,m=s[0],g=s[1],y="string"==typeof o&&o===d?o:void 0,b=y?t.find(r,[y,y]):r,x=[];for(h=0;h{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._size,o=e._datatype,u=r._values,l=r._size,c=r._datatype;if(s.length!==l.length)throw new ZU(s.length,l.length);if(s[0]!==l[0]||s[1]!==l[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+l+")");var p,d=s[0],h=s[1],f=n,m=0,g=a;"string"==typeof o&&o===c&&(p=o,f=t.find(n,[p,p]),m=t.convert(0,p),g=t.find(a,[p,p]));for(var y=i&&u?[]:void 0,b=[],x=[],v=y?[]:void 0,_=[],w=[],M=0;M{var{typed:t,matrix:n,equalScalar:r,BigNumber:a}=e,i=cJ({typed:t}),s=nJ({typed:t,equalScalar:r}),o=pJ({typed:t,equalScalar:r}),u=iJ({typed:t,equalScalar:r}),l=oJ({typed:t}),c=uJ({typed:t}),p="Complex number not supported in function nthRoot. Use nthRoots instead.";return t(dJ,{number:dW,"number, number":dW,BigNumber:function(e){return d(e,new a(2))},Complex:function(e){throw new Error(p)},"Complex, number":function(e,t){throw new Error(p)},"BigNumber, BigNumber":d,"Array | Matrix":function(e){return this(e,2)},"SparseMatrix, SparseMatrix":function(e,t){if(1===t.density())return o(e,t,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){if(1===t.density())return i(e,t,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){if(1===t.density())return u(t,e,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}});function d(e,t){var n=a.precision,r=a.clone({precision:n+2}),i=new a(0),s=new r(1),o=t.isNegative();if(o&&(t=t.neg()),t.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return o?new r(1/0):0;if(!e.isFinite())return o?i:e;var u=e.abs().pow(s.div(t));return u=e.isNeg()?u.neg():u,new a((o?s.div(u):u).toPrecision(n))}}));function fJ(){throw new Error('No "bignumber" implementation available')}function mJ(){throw new Error('No "fraction" implementation available')}function gJ(){throw new Error('No "matrix" implementation available')}var yJ=RH("numeric",["number","?bignumber","?fraction"],(e=>{var{number:t,bignumber:n,fraction:r}=e,a={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:e=>t(e),BigNumber:n?e=>n(e):fJ,Fraction:r?e=>r(e):mJ};return function(e,t){var n=xH(e);if(!(n in a))throw new TypeError("Cannot convert "+e+' of type "'+n+'"; valid input types are '+Object.keys(a).join(", "));if(!(t in i))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(i).join(", "));return t===n?e:i[t](e)}})),bJ=RH("or",["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=rJ({typed:t}),s=aJ({typed:t,equalScalar:r}),o=sJ({typed:t,DenseMatrix:a}),u=oJ({typed:t}),l=uJ({typed:t});return t("or",{"number, number":RG,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,this,!0).valueOf()}})}));function xJ(e,t,n){var r;return-1!==String(e).indexOf("Unexpected type")?(r=arguments.length>2?" (type: "+xH(n)+", value: "+JSON.stringify(n)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):-1!==String(e).indexOf("complex numbers")?(r=arguments.length>2?" (type: "+xH(n)+", value: "+JSON.stringify(n)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):e}var vJ="prod",_J=RH(vJ,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:t,config:n,multiplyScalar:r,numeric:a}=e;return t(vJ,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return i(e)}});function i(e){var t;if(qq(e,(function(e){try{t=void 0===t?e:r(t,e)}catch(t){throw xJ(t,"prod",e)}})),"string"==typeof t&&(t=a(t,n.number)),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}})),wJ="reshape",MJ=RH(wJ,["typed","isInteger","matrix"],(e=>{var{typed:t,isInteger:n}=e;return t(wJ,{"Matrix, Array":function(e,t){return e.reshape(t)},"Array, Array":function(e,t){return t.forEach((function(e){if(!n(e))throw new TypeError("Invalid size for dimension: "+e)})),sq(e,t)}})})),NJ="size",SJ=RH(NJ,["typed","config","?matrix"],(e=>{var{typed:t,config:n,matrix:r}=e;return t(NJ,{Matrix:function(e){return e.create(e.size())},Array:eq,string:function(e){return"Array"===n.matrix?[e.length]:r([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===n.matrix?[]:r?r([]):gJ()}})})),kJ=RH("algorithm07",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:n}=e;return function(e,a,i){var s=e._size,o=e._datatype,u=a._size,l=a._datatype;if(s.length!==u.length)throw new ZU(s.length,u.length);if(s[0]!==u[0]||s[1]!==u[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+u+")");var c,p,d,h=s[0],f=s[1],m=0,g=i;"string"==typeof o&&o===l&&(c=o,m=t.convert(0,c),g=t.find(i,[c,c]));var y=[];for(p=0;p{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=rJ({typed:t}),s=kJ({typed:t,DenseMatrix:a}),o=sJ({typed:t,DenseMatrix:a}),u=oJ({typed:t}),l=uJ({typed:t});return t(DJ,{"boolean, boolean":function(e,t){return e{var{typed:t,matrix:n}=e;return t(IJ,{Array:function(e){return lq(vH(e))},Matrix:function(e){var t=lq(e.toArray());return Array.isArray(t)?n(t):t},any:function(e){return vH(e)}})})),CJ="subset",AJ=RH(CJ,["typed","matrix"],(e=>{var{typed:t,matrix:n}=e;return t(CJ,{"Array, Index":function(e,t){var r=n(e).subset(t);return t.isScalar()?r:r.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":OJ,"string, Index":LJ,"Array, Index, any":function(e,t,r){return n(vH(e)).subset(t,r,void 0).valueOf()},"Array, Index, any, any":function(e,t,r,a){return n(vH(e)).subset(t,r,a).valueOf()},"Matrix, Index, any":function(e,t,n){return e.clone().subset(t,n)},"Matrix, Index, any, any":function(e,t,n,r){return e.clone().subset(t,n,r)},"string, Index, string":$J,"string, Index, string, string":$J,"Object, Index, any":RJ})}));function LJ(e,t){if(!VP(t))throw new TypeError("Index expected");if(1!==t.size().length)throw new ZU(t.size().length,1);var n=e.length;rq(t.min()[0],n),rq(t.max()[0],n);var r=t.dimension(0),a="";return r.forEach((function(t){a+=e.charAt(t)})),a}function $J(e,t,n,r){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new ZU(t.size().length,1);if(void 0!==r){if("string"!=typeof r||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";var a=t.dimension(0);if(a.size()[0]!==n.length)throw new ZU(a.size()[0],n.length);var i=e.length;rq(t.min()[0]),rq(t.max()[0]);for(var s=[],o=0;oi)for(var u=i-1,l=s.length;u{var{typed:t,DenseMatrix:n}=e;return function(e,r,a,i){var s=e._values,o=e._index,u=e._ptr,l=e._size,c=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p,d=l[0],h=l[1],f=a;"string"==typeof c&&(p=c,r=t.convert(r,p),f=t.find(a,[p,p]));for(var m=[],g=[],y=[],b=0;b{var{typed:t,matrix:n,equalScalar:r,addScalar:a,unaryMinus:i,DenseMatrix:s}=e,o=cJ({typed:t}),u=rJ({typed:t}),l=aJ({typed:t,equalScalar:r}),c=FJ({typed:t,DenseMatrix:s}),p=oJ({typed:t}),d=uJ({typed:t});return t(YJ,{"number, number":function(e,t){return e-t},"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":function(e,t){if(null===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var n=e.clone();return n.value=this(n.value,t.value),n.fixPrefix=!1,n},"SparseMatrix, SparseMatrix":function(e,t){return BJ(e,t),l(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return BJ(e,t),u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return BJ(e,t),o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return BJ(e,t),p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return c(e,i(t),a)},"DenseMatrix, any":function(e,t){return d(e,t,this)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return d(t,e,this,!0)},"Array, any":function(e,t){return d(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return d(n(t),e,this,!0).valueOf()}})}));function BJ(e,t){var n=e.size(),r=t.size();if(n.length!==r.length)throw new ZU(n.length,r.length)}var PJ=RH("to",["typed","matrix"],(e=>{var{typed:t,matrix:n}=e,r=oJ({typed:t}),a=uJ({typed:t});return t("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return r(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"Matrix, any":function(e,t){return a(e,t,this,!1)},"any, Matrix":function(e,t){return a(t,e,this,!0)},"Array, any":function(e,t){return a(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return a(n(t),e,this,!0).valueOf()}})})),HJ=RH("transpose",["typed","matrix"],(e=>{var{typed:t,matrix:n}=e;return t("transpose",{Array:function(e){return this(n(e)).valueOf()},Matrix:function(e){var t,n=e.size();switch(n.length){case 1:t=e.clone();break;case 2:var r=n[0],a=n[1];if(0===a)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+VU(n)+")");switch(e.storage()){case"dense":t=function(e,t,n){for(var r,a=e._data,i=[],s=0;s{var{typed:t,config:n,matrix:r,BigNumber:a}=e;return t(jJ,{"number, number":function(e,t){var a=mW(e,t);return"Array"===n.matrix?a:r(a)},"BigNumber, BigNumber":function(e,t){var i,s,o,u,l=new a(0),c=new a(1),p=l,d=c,h=c,f=l;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)s=e.div(t).floor(),o=e.mod(t),i=p,p=d.minus(s.times(p)),d=i,i=h,h=f.minus(s.times(h)),f=i,e=t,t=o;return u=e.lt(l)?[e.neg(),d.neg(),f.neg()]:[e,e.isZero()?0:d,f],"Array"===n.matrix?u:r(u)}})})),qJ="zeros",WJ=RH(qJ,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:n,matrix:r,BigNumber:a}=e;return t(qJ,{"":function(){return"Array"===n.matrix?i([]):i([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return i(e,t)}return"Array"===n.matrix?i(e):i(e,"default")},Array:i,Matrix:function(e){var t=e.storage();return i(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return i(e.valueOf(),t)}});function i(e,t){var n=function(e){var t=!1;return e.forEach((function(e,n,r){RP(e)&&(t=!0,r[n]=e.toNumber())})),t}(e),i=n?new a(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!PH(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}))}(e),t){var s=r(t);return e.length>0?s.resize(e,i):s}var o=[];return e.length>0?aq(o,e,i):o}})),VJ=RH("and",["typed","matrix","equalScalar","zeros","not"],(e=>{var{typed:t,matrix:n,equalScalar:r,zeros:a,not:i}=e,s=nJ({typed:t,equalScalar:r}),o=pJ({typed:t,equalScalar:r}),u=iJ({typed:t,equalScalar:r}),l=oJ({typed:t}),c=uJ({typed:t});return t("and",{"number, number":YG,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return i(t)?a(e.size(),e.storage()):u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return i(t)?a(e.size(),e.storage()):c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return i(e)?a(e.size(),e.storage()):u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return i(e)?a(e.size(),e.storage()):c(t,e,this,!0)},"Array, any":function(e,t){return this(n(e),t).valueOf()},"any, Array":function(e,t){return this(e,n(t)).valueOf()}})})),GJ="bitAnd",KJ=RH(GJ,["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:n,equalScalar:r}=e,a=nJ({typed:t,equalScalar:r}),i=pJ({typed:t,equalScalar:r}),s=iJ({typed:t,equalScalar:r}),o=oJ({typed:t}),u=uJ({typed:t});return t(GJ,{"number, number":lV,"BigNumber, BigNumber":eV,"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,this,!0).valueOf()}})})),JJ="bitXor",XJ=RH(JJ,["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:n,DenseMatrix:r}=e,a=rJ({typed:t}),i=kJ({typed:t,DenseMatrix:r}),s=sJ({typed:t,DenseMatrix:r}),o=oJ({typed:t}),u=uJ({typed:t});return t(JJ,{"number, number":dV,"BigNumber, BigNumber":iV,"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,this,!0).valueOf()}})})),ZJ="cbrt",QJ=RH(ZJ,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:t,typed:n,isNegative:r,unaryMinus:a,matrix:i,Complex:s,BigNumber:o,Fraction:u}=e;return n(ZJ,{number:rW,Complex:l,"Complex, boolean":l,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&FP(e.value)){var t=e.clone();return t.value=1,(t=t.pow(1/3)).value=l(e.value),t}var n,i=r(e.value);i&&(e.value=a(e.value)),n=RP(e.value)?new o(1).div(3):YP(e.value)?new u(1,3):1/3;var s=e.pow(n);return i&&(s.value=a(s.value)),s},"Array | Matrix":function(e){return Wq(e,this,!0)}});function l(e,n){var r=e.arg()/3,a=e.abs(),o=new s(rW(a),0).mul(new s(0,r).exp());if(n){var u=[o,new s(rW(a),0).mul(new s(0,r+2*Math.PI/3).exp()),new s(rW(a),0).mul(new s(0,r-2*Math.PI/3).exp())];return"Array"===t.matrix?u:i(u)}return o}})),eX="compare",tX=RH(eX,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],(e=>{var{typed:t,config:n,equalScalar:r,matrix:a,BigNumber:i,Fraction:s,DenseMatrix:o}=e,u=rJ({typed:t}),l=aJ({typed:t,equalScalar:r}),c=sJ({typed:t,DenseMatrix:o}),p=oJ({typed:t}),d=uJ({typed:t});return t(eX,{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"number, number":function(e,t){return nj(e,t,n.epsilon)?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return FV(e,t,n.epsilon)?new i(0):new i(e.cmp(t))},"Fraction, Fraction":function(e,t){return new s(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return l(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return this(a(e),t)},"Matrix, Array":function(e,t){return this(e,a(t))},"SparseMatrix, any":function(e,t){return c(e,t,this,!1)},"DenseMatrix, any":function(e,t){return d(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return d(t,e,this,!0)},"Array, any":function(e,t){return d(a(e),t,this,!1).valueOf()},"any, Array":function(e,t){return d(a(t),e,this,!0).valueOf()}})})),nX="compareText",rX=RH(nX,["typed","matrix"],(e=>{var{typed:t,matrix:n}=e,r=oJ({typed:t}),a=uJ({typed:t});return t(nX,{"any, any":XU,"DenseMatrix, DenseMatrix":function(e,t){return r(e,t,XU)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"DenseMatrix, any":function(e,t){return a(e,t,XU,!1)},"any, DenseMatrix":function(e,t){return a(t,e,XU,!0)},"Array, any":function(e,t){return a(n(e),t,XU,!1).valueOf()},"any, Array":function(e,t){return a(n(t),e,XU,!0).valueOf()}})})),aX="concat",iX=RH(aX,["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:n,isInteger:r}=e;return t(aX,{"...Array | Matrix | number | BigNumber":function(e){var t,a,i=e.length,s=-1,o=!1,u=[];for(t=0;t0&&s>a)throw new QU(s,a+1)}else{var c=vH(l).valueOf(),p=eq(c);if(u[t]=c,a=s,s=p.length-1,t>0&&s!==a)throw new ZU(a+1,s+1)}}if(0===u.length)throw new SyntaxError("At least one matrix expected");for(var d=u.shift();u.length;)d=sX(d,u.shift(),s,0);return o?n(d):d},"...string":function(e){return e.join("")}})}));function sX(e,t,n,r){if(r{var{typed:t,size:n,prod:r}=e;return t(oX,{string:function(e){return e.length},"Matrix | Array":function(e){return r(n(e))}})})),lX="ctranspose",cX=RH(lX,["typed","transpose","conj"],(e=>{var{typed:t,transpose:n,conj:r}=e;return t(lX,{any:function(e){return r(n(e))}})})),pX="diag",dX=RH(pX,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:n,DenseMatrix:r,SparseMatrix:a}=e;return t(pX,{Array:function(e){return i(e,0,eq(e),null)},"Array, number":function(e,t){return i(e,t,eq(e),null)},"Array, BigNumber":function(e,t){return i(e,t.toNumber(),eq(e),null)},"Array, string":function(e,t){return i(e,0,eq(e),t)},"Array, number, string":function(e,t,n){return i(e,t,eq(e),n)},"Array, BigNumber, string":function(e,t,n){return i(e,t.toNumber(),eq(e),n)},Matrix:function(e){return i(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return i(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return i(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return i(e,0,e.size(),t)},"Matrix, number, string":function(e,t,n){return i(e,t,e.size(),n)},"Matrix, BigNumber, string":function(e,t,n){return i(e,t.toNumber(),e.size(),n)}});function i(e,t,i,s){if(!PH(t))throw new TypeError("Second parameter in function diag must be an integer");var o=t>0?t:0,u=t<0?-t:0;switch(i.length){case 1:return function(e,t,n,i,s,o){var u=[i+s,i+o];if(n&&"sparse"!==n&&"dense"!==n)throw new TypeError("Unknown matrix type ".concat(n,'"'));var l="sparse"===n?a.diagonal(u,e,t):r.diagonal(u,e,t);return null!==n?l:l.valueOf()}(e,t,s,i[0],u,o);case 2:return function(e,t,r,a,i,s){if(HP(e)){var o=e.diagonal(t);return null!==r?r!==o.storage()?n(o,r):o:o.valueOf()}for(var u=Math.min(a[0]-i,a[1]-s),l=[],c=0;c{var{typed:t,numeric:n}=e;return t(hX,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Fraction | BigNumber":function(e,t){var r=e.clone(),a=n(1,xH(t));return r.value=this(null===r.value?r._normalize(a):r.value,t),r},"number | Fraction | BigNumber, Unit":function(e,t){var r=t.clone();r=r.pow(-1);var a=n(1,xH(e));return r.value=this(e,null===t.value?t._normalize(a):t.value),r},"Unit, Unit":function(e,t){return e.divide(t)}})})),mX="dotDivide",gX=RH(mX,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,divideScalar:a,DenseMatrix:i}=e,s=nJ({typed:t,equalScalar:r}),o=rJ({typed:t}),u=kJ({typed:t,DenseMatrix:i}),l=iJ({typed:t,equalScalar:r}),c=sJ({typed:t,DenseMatrix:i}),p=oJ({typed:t}),d=uJ({typed:t});return t(mX,{"any, any":a,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,a,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,a,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,a,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,a)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return l(e,t,a,!1)},"DenseMatrix, any":function(e,t){return d(e,t,a,!1)},"any, SparseMatrix":function(e,t){return c(t,e,a,!0)},"any, DenseMatrix":function(e,t){return d(t,e,a,!0)},"Array, any":function(e,t){return d(n(e),t,a,!1).valueOf()},"any, Array":function(e,t){return d(n(t),e,a,!0).valueOf()}})})),yX="equal",bX=RH(yX,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=rJ({typed:t}),s=kJ({typed:t,DenseMatrix:a}),o=sJ({typed:t,DenseMatrix:a}),u=oJ({typed:t}),l=uJ({typed:t});return t(yX,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,r)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,r,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,r,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,r)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,r,!1)},"DenseMatrix, any":function(e,t){return l(e,t,r,!1)},"any, SparseMatrix":function(e,t){return o(t,e,r,!0)},"any, DenseMatrix":function(e,t){return l(t,e,r,!0)},"Array, any":function(e,t){return l(n(e),t,r,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,r,!0).valueOf()}})})),xX=(RH(yX,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return t(yX,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:n(e,t)}})})),RH("fft",["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i"],(e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:a,divideScalar:i,exp:s,tau:o,i:u}=e;return t("fft",{Array:l,Matrix:function(e){return e.create(l(e.toArray()))}});function l(e){var t=eq(e);return 1===t.length?p(e,t[0]):c(e.map((e=>l(e,t.slice(1)))),0)}function c(e,t){var n=eq(e);if(0!==t)return new Array(n[0]).fill(0).map(((n,r)=>c(e[r],t-1)));if(1===n.length)return p(e);function r(e){var t=eq(e);return new Array(t[1]).fill(0).map(((n,r)=>new Array(t[0]).fill(0).map(((t,n)=>e[n][r]))))}return r(c(r(e),1))}function p(e){var t=e.length;if(1===t)return[e[0]];if(t%2==0){for(var n=[...p(e.filter(((e,t)=>t%2==0))),...p(e.filter(((e,t)=>t%2==1)))],l=0;l{var{typed:t,matrix:n}=e;return t(vX,{Array:function(e){return hq(vH(e))},Matrix:function(e){var t=hq(vH(e.toArray()));return n(t)}})})),wX=RH("algorithm04",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new ZU(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");var m,g=u[0],y=u[1],b=n,x=0,v=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),x=t.convert(0,m),v=t.find(a,[m,m]));var _,w,M,N,S,k=i&&c?[]:void 0,D=[],T=[],I=i&&c?[]:void 0,E=i&&c?[]:void 0,C=[],A=[];for(w=0;w{var{typed:t,matrix:n,equalScalar:r,BigNumber:a,DenseMatrix:i}=e,s=cJ({typed:t}),o=wX({typed:t,equalScalar:r}),u=FJ({typed:t,DenseMatrix:i}),l=oJ({typed:t}),c=uJ({typed:t});return t("gcd",{"number, number":oW,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var n=new a(0);!t.isZero();){var r=e.mod(t);e=t,t=r}return e.lt(n)?e.neg():e},"Fraction, Fraction":function(e,t){return e.gcd(t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return c(n(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return c(n(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,n){for(var r=this(e,t),a=0;a{var{typed:t,isNumeric:n}=e;return t(NX,{string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return n(e)}})})),kX="hypot",DX=RH(kX,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:t,abs:n,addScalar:r,divideScalar:a,multiplyScalar:i,sqrt:s,smaller:o,isPositive:u}=e;return t(kX,{"... number | BigNumber":function(e){for(var t=0,l=0,c=0;c{var{typed:t,fft:n,dotDivide:r,conj:a}=e;return t(TX,{"Array | Matrix":function(e){var t=HP(e)?e.size():eq(e);return r(a(n(a(e))),t.reduce(((e,t)=>e*t),1))}})})),EX="kron",CX=RH(EX,["typed","matrix","multiplyScalar"],(e=>{var{typed:t,matrix:n,multiplyScalar:r}=e;return t(EX,{"Matrix, Matrix":function(e,t){return n(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(a(e.toArray(),t))},"Array, Matrix":function(e,t){return n(a(e,t.toArray()))},"Array, Array":a});function a(e,t){if(1===eq(e).length&&(e=[e]),1===eq(t).length&&(t=[t]),eq(e).length>2||eq(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(t.length)+")");var n=[],a=[];return e.map((function(e){return t.map((function(t){return a=[],n.push(a),e.map((function(e){return t.map((function(t){return a.push(r(e,t))}))}))}))}))&&n}})),AX="largerEq",LX=RH(AX,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=rJ({typed:t}),s=kJ({typed:t,DenseMatrix:a}),o=sJ({typed:t,DenseMatrix:a}),u=oJ({typed:t}),l=uJ({typed:t});return t(AX,{"boolean, boolean":function(e,t){return e>=t},"number, number":function(e,t){return e>=t||nj(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)||FV(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return-1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(r(t),e,this,!0).valueOf()}})})),$X=RH("algorithm08",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new ZU(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");if(!i||!c)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var m,g=u[0],y=u[1],b=n,x=0,v=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),x=t.convert(0,m),v=t.find(a,[m,m]));for(var _,w,M,N,S=[],k=[],D=[],T=[],I=[],E=0;E{var{typed:t,matrix:n,equalScalar:r,zeros:a,DenseMatrix:i}=e,s=cJ({typed:t}),o=nJ({typed:t,equalScalar:r}),u=$X({typed:t,equalScalar:r}),l=FJ({typed:t,DenseMatrix:i}),c=iJ({typed:t,equalScalar:r}),p=oJ({typed:t}),d=uJ({typed:t});return t(OX,{"number, number":hV,"BigNumber, BigNumber":sV,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():d(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):d(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}})}));function FX(e){var{DenseMatrix:t}=e;return function(e,n,r){var a=e.size();if(2!==a.length)throw new RangeError("Matrix must be two dimensional (size: "+VU(a)+")");var i=a[0];if(i!==a[1])throw new RangeError("Matrix must be square (size: "+VU(a)+")");var s=[];if(HP(n)){var o=n.size(),u=n._data;if(1===o.length){if(o[0]!==i)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var l=0;l{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=FX({DenseMatrix:o});return t(YX,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=(t=u(e,t,!0))._data,l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=[],m=0;mm&&(b.push(p[w]),x.push(M))}if(s(y,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var N=r(g,y),S=0,k=x.length;S{var{typed:t,matrix:n,flatten:r,size:a}=e;return t(BX,{"...Array":function(e){return i(e)},"...Matrix":function(e){return n(i(e.map((e=>e.toArray()))))}});function i(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var t=s(e[0]),n=[],a=0;a{var{typed:t,config:n,numeric:r,smaller:a}=e;return t("min",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return Vq(e,t.valueOf(),i)},"...":function(e){if(Uq(e))throw new TypeError("Scalar values expected in function min");return s(e)}});function i(e,t){try{return a(e,t)?e:t}catch(e){throw xJ(e,"min",t)}}function s(e){var t;if(qq(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||a(e,t))&&(t=e)}catch(t){throw xJ(t,"min",e)}})),void 0===t)throw new Error("Cannot calculate min of an empty array");return"string"==typeof t&&(t=r(t,n.number)),t}})),jX="mode",UX=RH(jX,["typed","isNaN","isNumeric"],(e=>{var{typed:t,isNaN:n,isNumeric:r}=e;return t(jX,{"Array | Matrix":a,"...":function(e){return a(e)}});function a(e){if(0===(e=hq(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},a=[],i=0,s=0;si&&(i=t[o],a=[o])}return a}})),qX="nthRoots",WX=RH(qX,["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:n,divideScalar:r,Complex:a}=e,i=[function(e){return new a(e,0)},function(e){return new a(0,e)},function(e){return new a(-e,0)},function(e){return new a(0,-e)}];function s(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new a(0,0)];var n,r="number"==typeof e;(r||0===e.re||0===e.im)&&(n=r?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var s=e.arg(),o=e.abs(),u=[],l=Math.pow(o,1/t),c=0;c{var{typed:t,config:n,matrix:r,BigNumber:a}=e;return t("ones",{"":function(){return"Array"===n.matrix?i([]):i([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return i(e,t)}return"Array"===n.matrix?i(e):i(e,"default")},Array:i,Matrix:function(e){var t=e.storage();return i(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return i(e.valueOf(),t)}});function i(e,t){var n=function(e){var t=!1;return e.forEach((function(e,n,r){RP(e)&&(t=!0,r[n]=e.toNumber())})),t}(e),i=n?new a(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!PH(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}))}(e),t){var s=r(t);return e.length>0?s.resize(e,i):s}var o=[];return e.length>0?aq(o,e,i):o}})),GX="partitionSelect",KX=RH(GX,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:t,isNumeric:n,isNaN:r,compare:a}=e,i=a,s=(e,t)=>-a(e,t);return t(GX,{"Array | Matrix, number":function(e,t){return o(e,t,i)},"Array | Matrix, number, string":function(e,t,n){if("asc"===n)return o(e,t,i);if("desc"===n)return o(e,t,s);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":o});function o(e,t,n){if(!PH(t)||t<0)throw new Error("k must be a non-negative integer");if(HP(e)){if(e.size().length>1)throw new Error("Only one dimensional matrices supported");return u(e.valueOf(),t,n)}if(Array.isArray(e))return u(e,t,n)}function u(e,t,a){if(t>=e.length)throw new Error("k out of bounds");for(var i=0;i=0){var p=e[l];e[l]=e[u],e[u]=p,--l}else++u;a(e[u],c)>0&&--u,t<=u?o=u:s=u+1}return e[t]}}));function JX(e,t,n,r){if(!(this instanceof JX))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=n,this.max=r,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+n+(null!=r?"-"+r:"")+" expected)",this.stack=(new Error).stack}JX.prototype=new Error,JX.prototype.constructor=Error,JX.prototype.name="ArgumentsError",JX.prototype.isArgumentsError=!0;var XX=RH("resize",["config","matrix"],(e=>{var{config:t,matrix:n}=e;return function(e,a,i){if(2!==arguments.length&&3!==arguments.length)throw new JX("resize",arguments.length,2,3);if(HP(a)&&(a=a.valueOf()),RP(a[0])&&(a=a.map((function(e){return RP(e)?e.toNumber():e}))),HP(e))return e.resize(a,i,!0);if("string"==typeof e)return r(e,a,i);var s=!Array.isArray(e)&&"Array"!==t.matrix;if(0===a.length){for(;Array.isArray(e);)e=e[0];return vH(e)}Array.isArray(e)||(e=[e]);var o=aq(e=vH(e),a,i);return s?n(o):o};function r(e,t,n){if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";if(1!==t.length)throw new ZU(t.length,1);var r=t[0];if("number"!=typeof r||!PH(r))throw new TypeError("Invalid size, must contain positive integers (size: "+VU(t)+")");if(e.length>r)return e.substring(0,r);if(e.length{var{typed:t,matrix:n,equalScalar:r,zeros:a,DenseMatrix:i}=e,s=cJ({typed:t}),o=nJ({typed:t,equalScalar:r}),u=$X({typed:t,equalScalar:r}),l=FJ({typed:t,DenseMatrix:i}),c=iJ({typed:t,equalScalar:r}),p=oJ({typed:t}),d=uJ({typed:t});return t(ZX,{"number, number":fV,"BigNumber, BigNumber":oV,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():d(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):d(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}})})),eZ="Number of decimals in function round must be an integer",tZ="round",nZ=RH(tZ,["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,zeros:a,BigNumber:i,DenseMatrix:s}=e,o=iJ({typed:t,equalScalar:r}),u=sJ({typed:t,DenseMatrix:s}),l=uJ({typed:t});return t(tZ,{number:yW,"number, number":yW,"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(eZ);return new i(e).toDecimalPlaces(t.toNumber())},Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(eZ);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(eZ);var n=t.toNumber();return e.round(n)},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(eZ);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(eZ);return e.round(t)},"Fraction, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(eZ);return e.round(t.toNumber())},"Array | Matrix":function(e){return Wq(e,this,!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"Array, number | BigNumber":function(e,t){return l(n(e),t,this,!1).valueOf()},"number | Complex | BigNumber | Fraction, SparseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):u(t,e,this,!0)},"number | Complex | BigNumber | Fraction, DenseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):l(t,e,this,!0)},"number | Complex | BigNumber | Fraction, Array":function(e,t){return l(n(t),e,this,!0).valueOf()}})})),rZ="smallerEq",aZ=RH(rZ,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=rJ({typed:t}),s=kJ({typed:t,DenseMatrix:a}),o=sJ({typed:t,DenseMatrix:a}),u=oJ({typed:t}),l=uJ({typed:t});return t(rZ,{"boolean, boolean":function(e,t){return e<=t},"number, number":function(e,t){return e<=t||nj(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)||FV(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return 1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(r(t),e,this,!0).valueOf()}})})),iZ="unequal",sZ=RH(iZ,["typed","config","equalScalar","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,equalScalar:r,matrix:a,DenseMatrix:i}=e,s=rJ({typed:t}),o=kJ({typed:t,DenseMatrix:i}),u=sJ({typed:t,DenseMatrix:i}),l=oJ({typed:t}),c=uJ({typed:t});return t("unequal",{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:p(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,p)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,p,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,p,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,p)},"Array, Array":function(e,t){return this(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return this(a(e),t)},"Matrix, Array":function(e,t){return this(e,a(t))},"SparseMatrix, any":function(e,t){return u(e,t,p,!1)},"DenseMatrix, any":function(e,t){return c(e,t,p,!1)},"any, SparseMatrix":function(e,t){return u(t,e,p,!0)},"any, DenseMatrix":function(e,t){return c(t,e,p,!0)},"Array, any":function(e,t){return c(a(e),t,p,!1).valueOf()},"any, Array":function(e,t){return c(a(t),e,p,!0).valueOf()}});function p(e,t){return!r(e,t)}})),oZ=(RH(iZ,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return t(iZ,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!n(e,t)}})})),"usolve"),uZ=RH(oZ,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=FX({DenseMatrix:o});return t(oZ,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=(t=u(e,t,!0))._data,l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=[],m=c-1;m>=0;m--){var g=n[m][0]||0;if(s(g,0))f[m]=[0];else{for(var y=0,b=[],x=[],v=h[m],_=h[m+1]-1;_>=v;_--){var w=d[_];w===m?y=p[_]:w=0;h--){var f=n[h][0]||0,m=void 0;if(s(f,0))m=0;else{var g=d[h][h];if(s(g,0))throw new Error("Linear system cannot be solved since matrix is singular");m=r(f,g);for(var y=h-1;y>=0;y--)n[y]=[i(n[y][0]||0,a(m,d[y][h]))]}p[h]=[m]}return new o({data:p,size:[l,1]})}})),lZ=RH("xor",["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:n,DenseMatrix:r}=e,a=rJ({typed:t}),i=kJ({typed:t,DenseMatrix:r}),s=sJ({typed:t,DenseMatrix:r}),o=oJ({typed:t}),u=uJ({typed:t});return t("xor",{"number, number":FG,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,this,!0).valueOf()}})})),cZ=RH("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:n,addScalar:r,equalScalar:a,DenseMatrix:i,SparseMatrix:s}=e,o=cJ({typed:t}),u=wX({typed:t,equalScalar:a}),l=FJ({typed:t,DenseMatrix:i}),c=oJ({typed:t}),p=uJ({typed:t});return t("add",wH({"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,r)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,r,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,r,!0)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,r)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"DenseMatrix, any":function(e,t){return p(e,t,r,!1)},"SparseMatrix, any":function(e,t){return l(e,t,r,!1)},"any, DenseMatrix":function(e,t){return p(t,e,r,!0)},"any, SparseMatrix":function(e,t){return l(t,e,r,!0)},"Array, any":function(e,t){return p(n(e),t,r,!1).valueOf()},"any, Array":function(e,t){return p(n(t),e,r,!0).valueOf()},"any, any":r,"any, any, ...any":function(e,t,n){for(var r=this(e,t),a=0;a{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new ZU(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");var m,g=u[0],y=u[1],b=n,x=0,v=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),x=t.convert(0,m),v=t.find(a,[m,m]));var _,w,M,N,S,k=i&&c?[]:void 0,D=[],T=[],I=k?[]:void 0,E=[];for(w=0;w{var{typed:t,matrix:n,equalScalar:r,BigNumber:a,DenseMatrix:i}=e,s=nJ({typed:t,equalScalar:r}),o=rJ({typed:t}),u=pZ({typed:t,equalScalar:r}),l=iJ({typed:t,equalScalar:r}),c=sJ({typed:t,DenseMatrix:i}),p=oJ({typed:t}),d=uJ({typed:t});return t(dZ,{"number, number":Math.atan2,"BigNumber, BigNumber":function(e,t){return a.atan2(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return d(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return d(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return d(n(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return d(n(t),e,this,!0).valueOf()}})})),fZ="bitOr",mZ=RH(fZ,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=cJ({typed:t}),s=wX({typed:t,equalScalar:r}),o=FJ({typed:t,DenseMatrix:a}),u=oJ({typed:t}),l=uJ({typed:t});return t(fZ,{"number, number":pV,"BigNumber, BigNumber":nV,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,this,!0).valueOf()}})})),gZ="catalan",yZ=RH(gZ,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:t,addScalar:n,divideScalar:r,multiplyScalar:a,combinations:i,isNegative:s,isInteger:o}=e;return t(gZ,{"number | BigNumber":function(e){if(!o(e)||s(e))throw new TypeError("Non-negative integer value expected in function catalan");return r(i(a(e,2),e),n(e,1))}})})),bZ=n(3228),xZ="compareNatural",vZ=RH(xZ,["typed","compare"],(e=>{var{typed:t,compare:n}=e,r=n.signatures["boolean,boolean"];return t(xZ,{"any, any":function(e,t){var s,o=xH(e),u=xH(t);if(!("number"!==o&&"BigNumber"!==o&&"Fraction"!==o||"number"!==u&&"BigNumber"!==u&&"Fraction"!==u))return"0"!==(s=n(e,t)).toString()?s>0?1:-1:bZ(o,u);if("Array"===o||"Matrix"===o||"Array"===u||"Matrix"===u)return 0!==(s=a(this,e,t))?s:bZ(o,u);if(o!==u)return bZ(o,u);if("Complex"===o)return function(e,t){return e.re>t.re?1:e.ret.im?1:e.imn.length?1:t.length{var{typed:t,add:n,unaryPlus:r}=e;return t(_Z,{Array:a,Matrix:function(e){return e.create(a(e.valueOf()))},"Array, number | BigNumber":s,"Matrix, number | BigNumber":function(e,t){return e.create(s(e.valueOf(),t))},"...":function(e){if(Uq(e))throw new TypeError("All values expected to be scalar in function cumsum");return a(e)}});function a(e){try{return i(e)}catch(e){throw xJ(e,_Z)}}function i(e){if(0===e.length)return[];for(var t=[r(e[0])],a=1;a=n.length)throw new QU(t,n.length);try{return o(e,t)}catch(e){throw xJ(e,_Z)}}function o(e,t){var n,r,a;if(t<=0){var s=e[0][0];if(Array.isArray(s)){for(a=jq(e),r=[],n=0;n{var{typed:t,equal:n}=e;return t(MZ,{"any, any":function(e,t){return r(e.valueOf(),t.valueOf())}});function r(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var a=e.length;if(a!==t.length)return!1;for(var i=0;i{var{typed:t,matrix:n,subtract:r,number:a}=e;return t(SZ,{"Array | Matrix":function(e){return HP(e)?n(s(e.toArray())):s(e)},"Array | Matrix, number":function(e,t){if(!PH(t))throw new RangeError("Dimension must be a whole number");return HP(e)?n(i(e.toArray(),t)):i(e,t)},"Array | Matrix, BigNumber":function(e,t){return this(e,a(t))}});function i(e,t){if(HP(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(t>0){var n=[];return e.forEach((e=>{n.push(i(e,t-1))})),n}if(0===t)return s(e);throw RangeError("Cannot have negative dimension")}function s(e){var t=[],n=e.length;if(n<2)return e;for(var r=1;r{var{typed:t,addScalar:n,multiplyScalar:r,conj:a,size:i}=e;return t("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,i){var u=s(e,i),l=HP(e)?e._data:e,c=HP(e)?e._datatype:void 0,p=HP(i)?i._data:i,d=HP(i)?i._datatype:void 0,h=2===o(e).length,f=2===o(i).length,m=n,g=r;if(c&&d&&c===d&&"string"==typeof c){var y=c;m=t.find(n,[y,y]),g=t.find(r,[y,y])}if(!h&&!f){for(var b=g(a(l[0]),p[0]),x=1;xm?h++:f===m&&(l=c(l,p(i[d],u[h])),d++,h++)}return l}});function s(e,t){var n,r,a=o(e),i=o(t);if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(1===i.length)r=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");r=i[0]}if(n!==r)throw new RangeError("Vectors must have equal length ("+n+" != "+r+")");if(0===n)throw new RangeError("Cannot calculate the dot product of empty vectors");return n}function o(e){return HP(e)?e.size():i(e)}})),TZ="equalText",IZ=RH(TZ,["typed","compareText","isZero"],(e=>{var{typed:t,compareText:n,isZero:r}=e;return t(TZ,{"any, any":function(e,t){return r(n(e,t))}})})),EZ="floor",CZ=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],AZ=RH(EZ,["typed","config","round"],(e=>{var{typed:t,config:n,round:r}=e;return t(EZ,{number:function(e){return nj(e,r(e),n.epsilon)?r(e):Math.floor(e)},"number, number":function(e,t){if(nj(e,r(e,t),n.epsilon))return r(e,t);var[a,i]="".concat(e,"e").split("e"),s=Math.floor(Number("".concat(a,"e").concat(Number(i)+t)));return[a,i]="".concat(s,"e").split("e"),Number("".concat(a,"e").concat(Number(i)-t))}})})),LZ=RH(EZ,CZ,(e=>{var{typed:t,config:n,round:r,matrix:a,equalScalar:i,zeros:s,DenseMatrix:o}=e,u=iJ({typed:t,equalScalar:i}),l=sJ({typed:t,DenseMatrix:o}),c=uJ({typed:t}),p=AZ({typed:t,config:n,round:r});return t("floor",{number:p.signatures.number,"number,number":p.signatures["number,number"],Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},"Complex, BigNumber":function(e,t){return e.floor(t.toNumber())},BigNumber:function(e){return FV(e,r(e),n.epsilon)?r(e):e.floor()},"BigNumber, BigNumber":function(e,t){return FV(e,r(e,t),n.epsilon)?r(e,t):e.toDecimalPlaces(t.toNumber(),OH.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Fraction, BigNumber":function(e,t){return e.floor(t.toNumber())},"Array | Matrix":function(e){return Wq(e,this,!0)},"Array, number | BigNumber":function(e,t){return Wq(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(e,t){return c(a(t),e,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(e,t){return i(e,0)?s(t.size(),t.storage()):"dense"===t.storage()?c(t,e,this,!0):l(t,e,this,!0)}})})),$Z="identity",OZ=RH($Z,["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,config:n,matrix:r,BigNumber:a,DenseMatrix:i,SparseMatrix:s}=e;return t($Z,{"":function(){return"Matrix"===n.matrix?r([]):[]},string:function(e){return r(e)},"number | BigNumber":function(e){return u(e,e,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return u(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return u(e,t,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,n){return u(e,t,n)},Array:function(e){return o(e)},"Array, string":function(e,t){return o(e,t)},Matrix:function(e){return o(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){switch(e.length){case 0:return t?r(t):[];case 1:return u(e[0],e[0],t);case 2:return u(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function u(e,t,n){var r=RP(e)||RP(t)?a:null;if(RP(e)&&(e=e.toNumber()),RP(t)&&(t=t.toNumber()),!PH(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!PH(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var o=r?new a(1):1,u=r?new r(0):0,l=[e,t];if(n){if("sparse"===n)return s.diagonal(l,o,0,u);if("dense"===n)return i.diagonal(l,o,0,u);throw new TypeError('Unknown matrix type "'.concat(n,'"'))}for(var c=aq([],l,u),p=e{var{typed:t,config:n,BigNumber:r,xgcd:a,equal:i,smaller:s,mod:o,add:u,isInteger:l}=e;return t(RZ,{"number, number":c,"BigNumber, BigNumber":c});function c(e,t){if(!l(e)||!l(t))throw new Error("Parameters in function invmod must be integer numbers");if(e=o(e,t),i(t,0))throw new Error("Divisor must be non zero");var n=a(e,t);n=n.valueOf();var[c,p]=n;return i(c,r(1))?(p=o(p,t),s(p,r(0))&&(p=u(p,t)),p):NaN}})),YZ="larger",zZ=RH(YZ,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=rJ({typed:t}),s=kJ({typed:t,DenseMatrix:a}),o=sJ({typed:t,DenseMatrix:a}),u=oJ({typed:t}),l=uJ({typed:t});return t(YZ,{"boolean, boolean":function(e,t){return e>t},"number, number":function(e,t){return e>t&&!nj(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!FV(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return 1===e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(r(t),e,this,!0).valueOf()}})})),BZ=RH("log",["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:n,divideScalar:r,Complex:a}=e;return t("log",{number:function(e){return e>=0||n.predictable?function(e,t){return Math.log(e)}(e):new a(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||n.predictable?e.ln():new a(e.toNumber(),0).log()},"Array | Matrix":function(e){return Wq(e,this)},"any, any":function(e,t){return r(this(e),this(t))}})})),PZ="lsolveAll",HZ=RH(PZ,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=FX({DenseMatrix:o});return t(PZ,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=0;ff&&(b.push(p[M]),x.push(N))}if(s(w,0))if(s(y[f],0)){if(0===g){var S=[...y];S[f]=1;for(var k=0,D=x.length;knew o({data:e.map((e=>[e])),size:[l,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map((e=>e.valueOf()))}});function l(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._data,c=e._size[0],p=e._size[1],d=0;dnew o({data:e.map((e=>[e])),size:[c,1]})))}})),jZ="matrixFromRows",UZ=RH(jZ,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:n,flatten:r,size:a}=e;return t(jZ,{"...Array":function(e){return i(e)},"...Matrix":function(e){return n(i(e.map((e=>e.toArray()))))}});function i(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var t=s(e[0]),n=[];for(var a of e){var i=s(a);if(i!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|i));n.push(r(a))}return n}function s(e){var t=a(e);if(1===t.length)return t[0];if(2===t.length){if(1===t[0])return t[1];if(1===t[1])return t[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),qZ="multiply",WZ=RH(qZ,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:a,equalScalar:i,dot:s}=e,o=iJ({typed:t,equalScalar:i}),u=uJ({typed:t});function l(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}var c=t("_multiplyMatrixVector",{"DenseMatrix, any":function(e,n){var i,s=e._data,o=e._size,u=e._datatype,l=n._data,c=n._datatype,p=o[0],d=o[1],h=r,f=a;u&&c&&u===c&&"string"==typeof u&&(i=u,h=t.find(r,[i,i]),f=t.find(a,[i,i]));for(var m=[],g=0;gk)for(var T=0,I=0;I{var{typed:t,matrix:n,zeros:r,identity:a,isZero:i,equal:s,sign:o,sqrt:u,conj:l,unaryMinus:c,addScalar:p,divideScalar:d,multiplyScalar:h,subtract:f,complex:m}=e;return LP(t("qr",{DenseMatrix:function(e){return y(e)},SparseMatrix:function(e){return function(e){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var t=y(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t,n,m,g=e._size[0],y=e._size[1],b=a([g],"dense"),x=b._data,v=e.clone(),_=v._data,w=r([g],"");for(m=0;m0)for(var r="Complex"===n[0][0].type?m(0):0,a=0;a{var{typed:t,config:n,matrix:r,bignumber:a,smaller:i,smallerEq:s,larger:o,largerEq:u}=e;return t(GZ,{string:c,"string, boolean":c,"number, number":function(e,t){return l(p(e,t,1))},"number, number, number":function(e,t,n){return l(p(e,t,n))},"number, number, boolean":function(e,t,n){return l(n?d(e,t,1):p(e,t,1))},"number, number, number, boolean":function(e,t,n,r){return l(r?d(e,t,n):p(e,t,n))},"BigNumber, BigNumber":function(e,t){return l(h(e,t,new(0,e.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(e,t,n){return l(h(e,t,n))},"BigNumber, BigNumber, boolean":function(e,t,n){var r=e.constructor;return l(n?f(e,t,new r(1)):h(e,t,new r(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,n,r){return l(r?f(e,t,n):h(e,t,n))}});function l(e){return"Matrix"===n.matrix?r?r(e):gJ():e}function c(e,t){var r=function(e){var t=e.split(":").map((function(e){return Number(e)})),n=t.some((function(e){return isNaN(e)}));if(n)return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(e);if(!r)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===n.number?(void 0===a&&fJ(),l((t?f:h)(a(r.start),a(r.end),a(r.step)))):l((t?d:p)(r.start,r.end,r.step))}function p(e,t,n){var r=[],a=e;if(n>0)for(;i(a,t);)r.push(a),a+=n;else if(n<0)for(;o(a,t);)r.push(a),a+=n;return r}function d(e,t,n){var r=[],a=e;if(n>0)for(;s(a,t);)r.push(a),a+=n;else if(n<0)for(;u(a,t);)r.push(a),a+=n;return r}function h(e,t,n){var r=a(0),s=[],u=e;if(n.gt(r))for(;i(u,t);)s.push(u),u=u.plus(n);else if(n.lt(r))for(;o(u,t);)s.push(u),u=u.plus(n);return s}function f(e,t,n){var r=a(0),i=[],o=e;if(n.gt(r))for(;s(o,t);)i.push(o),o=o.plus(n);else if(n.lt(r))for(;u(o,t);)i.push(o),o=o.plus(n);return i}})),JZ="rightLogShift",XZ=RH(JZ,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,zeros:a,DenseMatrix:i}=e,s=cJ({typed:t}),o=nJ({typed:t,equalScalar:r}),u=$X({typed:t,equalScalar:r}),l=FJ({typed:t,DenseMatrix:i}),c=iJ({typed:t,equalScalar:r}),p=oJ({typed:t}),d=uJ({typed:t});return t(JZ,{"number, number":mV,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():d(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):d(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}})})),ZZ="setSize",QZ=RH(ZZ,["typed","compareNatural"],(e=>{var{typed:t,compareNatural:n}=e;return t(ZZ,{"Array | Matrix":function(e){return Array.isArray(e)?hq(e).length:hq(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?hq(e).length:hq(e.toArray()).length;for(var r=hq(Array.isArray(e)?e:e.toArray()).sort(n),a=1,i=1;i=0;){var u=n[s+o],l=n[r+u];-1===l?(o--,i[t++]=u):(n[r+u]=n[a+l],n[s+ ++o]=l)}return t}function tQ(e){return-e-2}var nQ=RH("csAmd",["add","multiply","transpose"],(e=>{var{add:t,multiply:n,transpose:r}=e;return function(e,s){if(!s||e<=0||e>3)return null;var o=s._size,u=o[0],l=o[1],c=0,p=Math.max(16,10*Math.sqrt(l)),d=function(e,a,i,s,o){var u=r(a);if(1===e&&s===i)return t(a,u);if(2===e){for(var l=u._index,c=u._ptr,p=0,d=0;do))for(var f=c[d+1];hs)n[o+d]=0,n[a+d]=-1,p++,t[d]=tQ(e),n[o+e]++;else{var f=n[u+h];-1!==f&&(l[f]=d),n[c+d]=n[u+h],n[u+h]=d}}return p}(l,E,L,Y,F,z,p,$,R,P,O),U=0;jq?(b=m,x=G,v=L[0+m]-q):(x=E[b=I[G++]],v=L[0+b]),y=1;y<=v;y++)(_=L[$+(h=I[x++])])<=0||(V+=_,L[$+h]=-_,I[J++]=h,-1!==L[O+h]&&(P[L[O+h]]=P[h]),-1!==P[h]?L[O+P[h]]=L[O+h]:L[R+L[Y+h]]=L[O+h]);b!==m&&(E[b]=tQ(m),L[z+b]=0)}for(0!==q&&(C=J),L[Y+m]=V,E[m]=K,L[0+m]=J-K,L[F+m]=-2,H=a(H,c,L,z,l),w=K;w=H?L[z+b]-=_:0!==L[z+b]&&(L[z+b]=L[Y+b]+X)}for(w=K;w0?(T+=Z,I[k++]=b,D+=b):(E[b]=tQ(m),L[z+b]=0)}L[F+h]=k-N+1;var Q=k,ee=N+L[0+h];for(G=S+1;G=0))for(h=L[B+(D=P[h])],L[B+D]=-1;-1!==h&&-1!==L[O+h];h=L[O+h],H++){for(v=L[0+h],M=L[F+h],G=E[h]+1;G<=E[h]+v-1;G++)L[z+I[G]]=H;var ne=h;for(f=L[O+h];-1!==f;){var re=L[0+f]===v&&L[F+f]===M;for(G=E[f]+1;re&&G<=E[f]+v-1;G++)L[z+I[G]]!==H&&(re=0);re?(E[f]=tQ(h),L[$+h]+=L[$+f],L[$+f]=0,L[F+f]=-1,f=L[O+f],L[O+ne]=f):(ne=f,f=L[O+f])}}for(G=K,w=K;w=0;f--)L[$+f]>0||(L[O+f]=L[R+E[f]],L[R+E[f]]=f);for(b=l;b>=0;b--)L[$+b]<=0||-1!==E[b]&&(L[O+b]=L[R+E[b]],L[R+E[b]]=b);for(m=0,h=0;h<=l;h++)-1===E[h]&&(m=eQ(h,m,L,R,O,A,z));return A.splice(A.length-1,1),A};function a(e,t,n,r,a){if(e<2||e+t<0){for(var i=0;i{var{transpose:t}=e;return function(e,n,r,a){if(!e||!n||!r)return null;var i,s,o,u,l,c,p,d=e._size,h=d[0],f=d[1],m=4*f+(a?f+h+1:0),g=[],y=f,b=2*f,x=3*f,v=4*f,_=5*f+1;for(o=0;o=1&&w[s]++,2===k.jleaf&&w[k.q]--}-1!==n[s]&&(g[0+s]=n[s])}for(s=0;s{var{add:t,multiply:n,transpose:r}=e,a=nQ({add:t,multiply:n,transpose:r}),i=aQ({transpose:r});return function(e,t,n){var r,s=t._ptr,o=t._size[1],u={};if(u.q=a(e,t),e&&!u.q)return null;if(n){var l=e?function(e,t,n,r){for(var a=e._values,i=e._index,s=e._ptr,o=e._size,u=e._datatype,l=o[0],c=o[1],p=null,d=[],h=[],f=0,m=0;m=0;n--)-1!==e[n]&&(i[s+n]=i[0+e[n]],i[0+e[n]]=n);for(n=0;n=0;u--)for(c=n[u],p=n[u+1],l=c;l=0;o--)h[o]=-1,-1!==(u=f[o])&&(0==m[b+u]++&&(m[y+u]=o),m[0+o]=m[g+u],m[g+u]=o);for(t.lnz=0,t.m2=i,u=0;u=0;){e=r[p];var d=a?a[e]:e;sQ(l,e)||(oQ(l,e),r[c+p]=d<0?0:uQ(l[d]));var h=1;for(s=r[c+p],o=d<0?0:uQ(l[d+1]);s{var{divideScalar:t,multiply:n,subtract:r}=e;return function(e,a,i,s,o,u,l){var c,p,d,h,f=e._values,m=e._index,g=e._ptr,y=e._size[1],b=a._values,x=a._index,v=a._ptr,_=function(e,t,n,r,a){var i,s,o,u=e._ptr,l=e._size,c=t._index,p=t._ptr,d=l[1],h=d;for(s=p[n],o=p[n+1],i=s;i{var{abs:t,divideScalar:n,multiply:r,subtract:a,larger:i,largerEq:s,SparseMatrix:o}=e,u=cQ({divideScalar:n,multiply:r,subtract:a});return function(e,a,l){if(!e)return null;var c,p=e._size[1],d=100,h=100;a&&(c=a.q,d=a.lnz||d,h=a.unz||h);var f,m,g=[],y=[],b=[],x=new o({values:g,index:y,ptr:b,size:[p,p]}),v=[],_=[],w=[],M=new o({values:v,index:_,ptr:w,size:[p,p]}),N=[],S=[],k=[];for(f=0;f{var{typed:t,abs:n,add:r,multiply:a,transpose:i,divideScalar:s,subtract:o,larger:u,largerEq:l,SparseMatrix:c}=e,p=iQ({add:r,multiply:a,transpose:i}),d=pQ({abs:n,divideScalar:s,multiply:a,subtract:o,larger:u,largerEq:l,SparseMatrix:c});return t("slu",{"SparseMatrix, number, number":function(e,t,n){if(!PH(t)||t<0||t>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(n<0||n>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var r=p(t,e,!1),a=d(e,r,n);return{L:a.L,U:a.U,p:a.pinv,q:r.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})})),hQ=RH("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:n,add:r,numeric:a}=e;return t("sum",{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{return Vq(e,t,r)}catch(e){throw xJ(e,"sum")}},"...":function(e){if(Uq(e))throw new TypeError("Scalar values expected in function sum");return i(e)}});function i(e){var t;return qq(e,(function(e){try{t=void 0===t?e:r(t,e)}catch(t){throw xJ(t,"sum",e)}})),void 0===t&&(t=a(0,n.number)),"string"==typeof t&&(t=a(t,n.number)),t}})),fQ=RH("trace",["typed","matrix","add"],(e=>{var{typed:t,matrix:n,add:r}=e;return t("trace",{Array:function(e){return a(n(e))},SparseMatrix:function(e){var t=e._values,n=e._index,a=e._ptr,i=e._size,s=i[0],o=i[1];if(s===o){var u=0;if(t.length>0)for(var l=0;ll)break}return u}throw new RangeError("Matrix must be square (size: "+VU(i)+")")},DenseMatrix:a,any:vH});function a(e){var t=e._size,n=e._data;switch(t.length){case 1:if(1===t[0])return vH(n[0]);throw new RangeError("Matrix must be square (size: "+VU(t)+")");case 2:var a=t[0];if(a===t[1]){for(var i=0,s=0;s{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=FX({DenseMatrix:o});return t(mQ,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=c-1;f>=0;f--)for(var m=n.length,g=0;g=v;w--){var M=d[w];M===f?_=p[w]:Mnew o({data:e.map((e=>[e])),size:[l,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map((e=>e.valueOf()))}});function l(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._data,c=e._size[0],p=e._size[1]-1;p>=0;p--)for(var d=n.length,h=0;h=0;g--)m[g]=i(m[g],l[g][p]);n.push(m)}}else{if(0===h)return[];n.splice(h,1),h-=1,d-=1}else{f[p]=r(f[p],l[p][p]);for(var y=p-1;y>=0;y--)f[y]=i(f[y],a(f[p],l[y][p]))}}return n.map((e=>new o({data:e.map((e=>[e])),size:[c,1]})))}})),yQ="asin",bQ=RH(yQ,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(yQ,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.asin(e):new r(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return Wq(e,this,!0)}})})),xQ="ceil",vQ=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],_Q=RH(xQ,["typed","config","round"],(e=>{var{typed:t,config:n,round:r}=e;return t(xQ,{number:function(e){return nj(e,r(e),n.epsilon)?r(e):Math.ceil(e)},"number, number":function(e,t){if(nj(e,r(e,t),n.epsilon))return r(e,t);var[a,i]="".concat(e,"e").split("e"),s=Math.ceil(Number("".concat(a,"e").concat(Number(i)+t)));return[a,i]="".concat(s,"e").split("e"),Number("".concat(a,"e").concat(Number(i)-t))}})})),wQ=RH(xQ,vQ,(e=>{var{typed:t,config:n,round:r,matrix:a,equalScalar:i,zeros:s,DenseMatrix:o}=e,u=iJ({typed:t,equalScalar:i}),l=sJ({typed:t,DenseMatrix:o}),c=uJ({typed:t}),p=_Q({typed:t,config:n,round:r});return t("ceil",{number:p.signatures.number,"number,number":p.signatures["number,number"],Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},"Complex, BigNumber":function(e,t){return e.ceil(t.toNumber())},BigNumber:function(e){return FV(e,r(e),n.epsilon)?r(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return FV(e,r(e,t),n.epsilon)?r(e,t):e.toDecimalPlaces(t.toNumber(),OH.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Fraction, BigNumber":function(e,t){return e.ceil(t.toNumber())},"Array | Matrix":function(e){return Wq(e,this,!0)},"Array, number | BigNumber":function(e,t){return Wq(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(e,t){return c(a(t),e,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(e,t){return i(e,0)?s(t.size(),t.storage()):"dense"===t.storage()?c(t,e,this,!0):l(t,e,this,!0)}})})),MQ="composition",NQ=RH(MQ,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:t,addScalar:n,combinations:r,isPositive:a,isNegative:i,isInteger:s,larger:o}=e;return t(MQ,{"number | BigNumber, number | BigNumber":function(e,t){if(!(s(e)&&a(e)&&s(t)&&a(t)))throw new TypeError("Positive integer value expected in function composition");if(o(t,e))throw new TypeError("k must be less than or equal to n in function composition");return r(n(e,-1),n(t,-1))}})})),SQ="cross",kQ=RH(SQ,["typed","matrix","subtract","multiply"],(e=>{var{typed:t,matrix:n,subtract:r,multiply:a}=e;return t(SQ,{"Matrix, Matrix":function(e,t){return n(i(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(i(e.toArray(),t))},"Array, Matrix":function(e,t){return n(i(e,t.toArray()))},"Array, Array":i});function i(e,t){var n=Math.max(eq(e).length,eq(t).length);e=lq(e),t=lq(t);var i=eq(e),s=eq(t);if(1!==i.length||1!==s.length||3!==i[0]||3!==s[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+i.join(", ")+"], B = ["+s.join(", ")+"])");var o=[r(a(e[1],t[2]),a(e[2],t[1])),r(a(e[2],t[0]),a(e[0],t[2])),r(a(e[0],t[1]),a(e[1],t[0]))];return n>1?[o]:o}})),DQ=RH("det",["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],(e=>{var{typed:t,matrix:n,subtract:r,multiply:a,divideScalar:i,isZero:s,unaryMinus:o}=e;return t("det",{any:function(e){return vH(e)},"Array | Matrix":function(e){var t;switch((t=HP(e)?e.size():Array.isArray(e)?(e=n(e)).size():[]).length){case 0:return vH(e);case 1:if(1===t[0])return vH(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+VU(t)+")");case 2:var u=t[0];if(u===t[1])return function(e,t,n){if(1===t)return vH(e[0][0]);if(2===t)return r(a(e[0][0],e[1][1]),a(e[1][0],e[0][1]));for(var u=!1,l=new Array(t).fill(0).map(((e,t)=>t)),c=0;c{var{typed:t,addScalar:n,subtract:r,multiplyScalar:a,divideScalar:i,unaryMinus:s,sqrt:o,abs:u}=e;return t(TQ,{"Array, Array, Array":function(e,t,n){if(2===e.length&&2===t.length&&2===n.length){if(!c(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!c(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!c(n))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var o=i(r(n[1],n[0]),r(t[1],t[0])),u=a(a(o,o),t[0]),l=s(a(o,t[0])),p=e[1];return m(e[0],e[1],u,l,p)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,t,n){if(2===Object.keys(e).length&&2===Object.keys(t).length&&2===Object.keys(n).length){if(!c(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!c(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!c(n))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in n&&"lineTwoPtY"in n){var o=i(r(n.lineTwoPtY,n.lineTwoPtX),r(t.lineOnePtY,t.lineOnePtX)),u=a(a(o,o),t.lineOnePtX),l=s(a(o,t.lineOnePtX)),p=e.pointX;return m(e.pointX,e.pointY,u,l,p)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!c(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!p(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return m(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!p(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&e.length>0){if(!d(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!d(t))throw new TypeError("All values of an array should be numbers or BigNumbers");return y(e,t)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!c(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return m(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!h(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!c(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!c(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return y([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return y([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&l(e[0][0])&&l(e[0][1])){if(e.some((e=>2!==e.length||!l(e[0])||!l(e[1]))))return!1}else{if(!(3===e[0].length&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])))return!1;if(e.some((e=>3!==e.length||!l(e[0])||!l(e[1])||!l(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var t=[],n=[],r=[],a=0;a{var{typed:t,matrix:n,equalScalar:r,multiplyScalar:a}=e,i=nJ({typed:t,equalScalar:r}),s=pZ({typed:t,equalScalar:r}),o=iJ({typed:t,equalScalar:r}),u=oJ({typed:t}),l=uJ({typed:t});return t(EQ,{"any, any":a,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,a,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,a,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,a,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,a)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,a,!1)},"DenseMatrix, any":function(e,t){return l(e,t,a,!1)},"any, SparseMatrix":function(e,t){return o(t,e,a,!0)},"any, DenseMatrix":function(e,t){return l(t,e,a,!0)},"Array, any":function(e,t){return l(n(e),t,a,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,a,!0).valueOf()}})})),AQ=RH("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:t,larger:n}=e,r=1/Math.log((1+Math.sqrt(5))/2);function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function i(e,t,n){t.left.right=t.right,t.right.left=t.left,n.degree--,n.child===t&&(n.child=t.right),0===n.degree&&(n.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function s(e,t){var n=t.parent;n&&(t.mark?(i(e,t,n),s(n)):t.mark=!0)}a.prototype.type="FibonacciHeap",a.prototype.isFibonacciHeap=!0,a.prototype.insert=function(e,n){var r={key:e,value:n,degree:0};if(this._minimum){var a=this._minimum;r.left=a,r.right=a.right,a.right=r,r.right.left=r,t(e,a.key)&&(this._minimum=r)}else r.left=r,r.right=r,this._minimum=r;return this._size++,r},a.prototype.size=function(){return this._size},a.prototype.clear=function(){this._minimum=null,this._size=0},a.prototype.isEmpty=function(){return 0===this._size},a.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var a=this._minimum,i=e.degree,s=e.child;i>0;){var u=s.right;s.left.right=s.right,s.right.left=s.left,s.left=a,s.right=a.right,a.right=s,s.right.left=s,s.parent=null,s=u,i--}return e.left.right=e.right,e.right.left=e.left,a=e===e.right?null:function(e,a){var i,s=Math.floor(Math.log(a)*r)+1,u=new Array(s),l=0,c=e;if(c)for(l++,c=c.right;c!==e;)l++,c=c.right;for(;l>0;){for(var p=c.degree,d=c.right;i=u[p];){if(n(c.key,i.key)){var h=i;i=c,c=h}o(i,c),u[p]=null,p++}u[p]=c,c=d,l--}e=null;for(var f=0;f{var{typed:t,ceil:n,floor:r}=e;return t(LQ,{number:function(e){return e>0?r(e):n(e)},"number, number":function(e,t){return e>0?r(e,t):n(e,t)}})})),RQ=RH(LQ,$Q,(e=>{var{typed:t,Complex:n,matrix:r,ceil:a,floor:i,equalScalar:s,zeros:o,DenseMatrix:u}=e,l=sJ({typed:t,DenseMatrix:u}),c=uJ({typed:t}),p=OQ({typed:t,ceil:a,floor:i});return t("fix",{number:p.signatures.number,"number, number | BigNumber":p.signatures["number,number"],Complex:function(e){return new n(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number":function(e,t){return new n(e.re>0?i(e.re,t):a(e.re,t),e.im>0?i(e.im,t):a(e.im,t))},"Complex, BigNumber":function(e,t){var r=t.toNumber();return new n(e.re>0?i(e.re,r):a(e.re,r),e.im>0?i(e.im,r):a(e.im,r))},BigNumber:function(e){return e.isNegative()?a(e):i(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?a(e,t):i(e,t)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0?a(e,t):i(e,t)},"Array | Matrix":function(e){return Wq(e,this,!0)},"Array | Matrix, number | BigNumber":function(e,t){return Wq(e,(e=>this(e,t)),!0)},"number | Complex | Fraction | BigNumber, Array":function(e,t){return c(r(t),e,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(e,t){return s(e,0)?o(t.size(),t.storage()):"dense"===t.storage()?c(t,e,this,!0):l(t,e,this,!0)}})})),FQ=RH("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:t,DenseMatrix:n}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!BP(t))throw new Error("Invalid datatype: "+t);if(HP(e)||PP(e)){var a=new n(e,t);this._data=a._data,this._size=a._size,this._datatype=a._datatype,this._min=null,this._max=null}else if(e&&PP(e.data)&&PP(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+xH(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return r.prototype=new n,r.prototype.type="ImmutableDenseMatrix",r.prototype.isImmutableDenseMatrix=!0,r.prototype.subset=function(e){switch(arguments.length){case 1:var t=n.prototype.subset.call(this,e);return HP(t)?new r({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},r.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},r.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},r.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},r.prototype.clone=function(){return new r({data:vH(this._data),size:vH(this._size),datatype:this._datatype})},r.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},r.fromJSON=function(e){return new r(e)},r.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},r.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(n){(null===e||t(n,e))&&(e=n)})),this._min=null!==e?e:void 0}return this._min},r.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(n){(null===e||t(e,n))&&(e=n)})),this._max=null!==e?e:void 0}return this._max},r}),{isClass:!0}),YQ=RH("Index",["ImmutableDenseMatrix"],(e=>{var{ImmutableDenseMatrix:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var t=0,a=arguments.length;t{var{typed:t,config:n,abs:r,add:a,addScalar:i,matrix:s,multiply:o,multiplyScalar:u,divideScalar:l,subtract:c,smaller:p,equalScalar:d,flatten:h,isZero:f,isNumeric:m}=e;return t("intersect",{"Array, Array, Array":g,"Array, Array, Array, Array":y,"Matrix, Matrix, Matrix":function(e,t,n){var r=g(e.valueOf(),t.valueOf(),n.valueOf());return null===r?null:s(r)},"Matrix, Matrix, Matrix, Matrix":function(e,t,n,r){var a=y(e.valueOf(),t.valueOf(),n.valueOf(),r.valueOf());return null===a?null:s(a)}});function g(e,t,n){if(e=b(e),t=b(t),n=b(n),!v(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!v(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&m(e[0])&&m(e[1])&&m(e[2])&&m(e[3])}(n))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,t,n,r,a,s,o,p,d,h){var f=u(e,o),m=u(r,o),g=u(t,p),y=u(a,p),b=u(n,d),x=u(s,d),v=c(c(c(h,f),g),b),_=c(c(c(i(i(m,y),x),f),g),b),w=l(v,_);return[i(e,u(w,c(r,e))),i(t,u(w,c(a,t))),i(n,u(w,c(s,n)))]}(e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],n[3])}function y(e,t,s,h){if(e=b(e),t=b(t),s=b(s),h=b(h),2===e.length){if(!x(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!x(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!x(s))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!x(h))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,t,s,d){var h=e,m=s,g=c(h,t),y=c(m,d),b=c(u(g[0],y[1]),u(y[0],g[1]));if(f(b))return null;if(p(r(b),n.epsilon))return null;var x=u(y[0],h[1]),v=u(y[1],h[0]),_=u(y[0],m[1]),w=u(y[1],m[0]),M=l(i(c(c(x,v),_),w),b);return a(o(g,M),h)}(e,t,s,h)}if(3===e.length){if(!v(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!v(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!v(s))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!v(h))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return function(e,t,n,r,a,s,o,p,h,m,g,y){var b=_(e,o,m,o,t,p,g,p,n,h,y,h),x=_(m,o,r,e,g,p,a,t,y,h,s,n),v=_(e,o,r,e,t,p,a,t,n,h,s,n),w=_(m,o,m,o,g,p,g,p,y,h,y,h),M=_(r,e,r,e,a,t,a,t,s,n,s,n),N=c(u(b,x),u(v,w)),S=c(u(M,w),u(x,x));if(f(S))return null;var k=l(N,S),D=l(i(b,u(k,x)),w),T=i(e,u(k,c(r,e))),I=i(t,u(k,c(a,t))),E=i(n,u(k,c(s,n))),C=i(o,u(D,c(m,o))),A=i(p,u(D,c(g,p))),L=i(h,u(D,c(y,h)));return d(T,C)&&d(I,A)&&d(E,L)?[T,I,E]:null}(e[0],e[1],e[2],t[0],t[1],t[2],s[0],s[1],s[2],h[0],h[1],h[2])}throw new TypeError("Arrays with two or thee dimensional points expected")}function b(e){return 1===e.length?e[0]:e.length>1&&Array.isArray(e[0])&&e.every((e=>Array.isArray(e)&&1===e.length))?h(e):e}function x(e){return 2===e.length&&m(e[0])&&m(e[1])}function v(e){return 3===e.length&&m(e[0])&&m(e[1])&&m(e[2])}function _(e,t,n,r,a,s,o,l,p,d,h,f){var m=u(c(e,t),c(n,r)),g=u(c(a,s),c(o,l)),y=u(c(p,d),c(h,f));return i(i(m,g),y)}})),BQ=RH("lcm",["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:n,equalScalar:r}=e,a=nJ({typed:t,equalScalar:r}),i=pJ({typed:t,equalScalar:r}),s=iJ({typed:t,equalScalar:r}),o=oJ({typed:t}),u=uJ({typed:t});return t("lcm",{"number, number":uW,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;for(var n=e.times(t);!t.isZero();){var r=t;t=e.mod(r),e=r}return n.div(e).abs()},"Fraction, Fraction":function(e,t){return e.lcm(t)},"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return s(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return u(n(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return u(n(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,n){for(var r=this(e,t),a=0;a{var{typed:t,config:n,divideScalar:r,log:a,Complex:i}=e;return t(PQ,{number:function(e){return e>=-1||n.predictable?qH(e):s(new i(e,0))},Complex:s,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||n.predictable?t.ln():s(new i(e.toNumber(),0))},"Array | Matrix":function(e){return Wq(e,this)},"any, any":function(e,t){return r(this(e),a(t))}});function s(e){var t=e.re+1;return new i(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}})),jQ=RH("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:n,numeric:r,larger:a}=e;return t("max",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return Vq(e,t.valueOf(),i)},"...":function(e){if(Uq(e))throw new TypeError("Scalar values expected in function max");return s(e)}});function i(e,t){try{return a(e,t)?e:t}catch(e){throw xJ(e,"max",t)}}function s(e){var t;if(qq(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||a(e,t))&&(t=e)}catch(t){throw xJ(t,"max",e)}})),void 0===t)throw new Error("Cannot calculate max of an empty array");return"string"==typeof t&&(t=r(t,n.number)),t}})),UQ=RH("quantileSeq",["typed","add","multiply","partitionSelect","compare"],(e=>{var{typed:t,add:n,multiply:r,partitionSelect:a,compare:i}=e;function s(e,t,s){var u=hq(e),l=u.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");if(OP(t)){var c=t*(l-1),p=c%1;if(0===p){var d=s?u[c]:a(u,c);return o(d),d}var h,f,m=Math.floor(c);if(s)h=u[m],f=u[m+1];else{f=a(u,m+1),h=u[m];for(var g=0;g0&&(h=u[g])}return o(h),o(f),n(r(h,1-p),r(f,p))}var y=t.times(l-1);if(y.isInteger()){y=y.toNumber();var b=s?u[y]:a(u,y);return o(b),b}var x,v,_=y.floor(),w=y.minus(_),M=_.toNumber();if(s)x=u[M],v=u[M+1];else{v=a(u,M+1),x=u[M];for(var N=0;N0&&(x=u[N])}o(x),o(v);var S=new w.constructor(1);return n(r(x,S.minus(w)),r(v,w))}var o=t({"number | BigNumber | Unit":function(e){return e}});return function(e,t,n){var r,a,i;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(jP(e)){if("boolean"==typeof(n=n||!1)){if(a=e.valueOf(),OP(t)){if(t<0)throw new Error("N/prob must be non-negative");if(t<=1)return s(a,t,n);if(t>1){if(!PH(t))throw new Error("N must be a positive integer");var o=t+1;r=new Array(t);for(var u=0;u4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var p=new l(c+1);r=new Array(c);for(var d=0;d1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!RP(f))throw new TypeError("Unexpected type of argument in function quantileSeq");if(i=new f.constructor(1),f.isNegative()||f.gt(i))throw new Error("Probability must be between 0 and 1, inclusive")}r[h]=s(a,f,n)}return r}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}})),qQ=RH("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e;return t("row",{"Matrix, number":i,"Array, number":function(e,t){return i(r(vH(e)),t).valueOf()}});function i(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");rq(t,e.size()[0]);var r=a(0,e.size()[1]),i=new n(t,r);return e.subset(i)}})),WQ="setCartesian",VQ=RH(WQ,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(WQ,{"Array | Matrix, Array | Matrix":function(e,t){var o=[];if(0!==r(n(e),new i(0))&&0!==r(n(t),new i(0))){var u=hq(Array.isArray(e)?e:e.toArray()).sort(a),l=hq(Array.isArray(t)?t:t.toArray()).sort(a);o=[];for(var c=0;c{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(GQ,{"Array | Matrix":function(e){var t;if(0===r(n(e),new i(0)))t=[];else{var o=hq(Array.isArray(e)?e:e.toArray()).sort(a);(t=[]).push(o[0]);for(var u=1;u{var{typed:t,size:n,subset:r,compareNatural:a,Index:i}=e;return t(JQ,{"Array | Matrix, Array | Matrix":function(e,t){if(0===r(n(e),new i(0)))return!0;if(0===r(n(t),new i(0)))return!1;for(var s,o=xq(hq(Array.isArray(e)?e:e.toArray()).sort(a)),u=xq(hq(Array.isArray(t)?t:t.toArray()).sort(a)),l=0;l{var{typed:t,size:n,subset:r,compareNatural:a,Index:i}=e;return t(ZQ,{"Array | Matrix":function(e){if(0===r(n(e),new i(0)))return[];for(var t=hq(Array.isArray(e)?e:e.toArray()).sort(a),o=[],u=0;u.toString(2).length<=t.length;)o.push(s(t,u.toString(2).split("").reverse())),u++;return function(e){for(var t=[],n=e.length-1;n>0;n--)for(var r=0;re[r+1].length&&(t=e[r],e[r]=e[r+1],e[r+1]=t);return e}(o)}});function s(e,t){for(var n=[],r=0;r{var{typed:t,matrix:n,compare:r,compareNatural:a}=e,i=r,s=(e,t)=>-r(e,t);return t(e0,{Array:function(e){return u(e),e.sort(i)},Matrix:function(e){return l(e),n(e.toArray().sort(i),e.storage())},"Array, function":function(e,t){return u(e),e.sort(t)},"Matrix, function":function(e,t){return l(e),n(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return u(e),e.sort(o(t))},"Matrix, string":function(e,t){return l(e),n(e.toArray().sort(o(t)),e.storage())}});function o(e){if("asc"===e)return i;if("desc"===e)return s;if("natural"===e)return a;throw new Error('String "asc", "desc", or "natural" expected')}function u(e){if(1!==eq(e).length)throw new Error("One dimensional array expected")}function l(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}})),n0="column",r0=RH(n0,["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e;return t(n0,{"Matrix, number":i,"Array, number":function(e,t){return i(r(vH(e)),t).valueOf()}});function i(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");rq(t,e.size()[1]);var r=a(0,e.size()[0]),i=new n(r,t);return e.subset(i)}})),a0="index",i0=RH(a0,["typed","Index"],(e=>{var{typed:t,Index:n}=e;return t(a0,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map((function(e){return RP(e)?e.toNumber():Array.isArray(e)||HP(e)?e.map((function(e){return RP(e)?e.toNumber():e})):e})),r=new n;return n.apply(r,t),r}})})),s0=RH("inv",["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],(e=>{var{typed:t,matrix:n,divideScalar:r,addScalar:a,multiply:i,unaryMinus:s,det:o,identity:u,abs:l}=e;return t("inv",{"Array | Matrix":function(e){var t=HP(e)?e.size():eq(e);switch(t.length){case 1:if(1===t[0])return HP(e)?n([r(1,e.valueOf()[0])]):[r(1,e[0])];throw new RangeError("Matrix must be square (size: "+VU(t)+")");case 2:var a=t[0],i=t[1];if(a===i)return HP(e)?n(c(e.valueOf(),a,i),e.storage()):c(e,a,i);throw new RangeError("Matrix must be square (size: "+VU(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+VU(t)+")")}},any:function(e){return r(1,e)}});function c(e,t,n){var c,p,d,h,f;if(1===t){if(0===(h=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,h)]]}if(2===t){var m=o(e);if(0===m)throw Error("Cannot calculate inverse, determinant is zero");return[[r(e[1][1],m),r(s(e[0][1]),m)],[r(s(e[1][0]),m),r(e[0][0],m)]]}var g=e.concat();for(c=0;cx&&(x=l(g[c][b]),v=c),c++;if(0===x)throw Error("Cannot calculate inverse, determinant is zero");(c=v)!==b&&(f=g[b],g[b]=g[c],g[c]=f,f=y[b],y[b]=y[c],y[c]=f);var _=g[b],w=y[b];for(c=0;c{var{typed:t,matrix:n,inv:r,deepEqual:a,equal:i,dotDivide:s,dot:o,ctranspose:u,divideScalar:l,multiply:c,add:p,Complex:d}=e;return t(o0,{"Array | Matrix":function(e){var t=HP(e)?e.size():eq(e);switch(t.length){case 1:return m(e)?u(e):1===t[0]?r(e):s(u(e),o(e,e));case 2:if(m(e))return u(e);var a=t[0],i=t[1];if(a===i)try{return r(e)}catch(e){if(!(e instanceof Error&&e.message.match(/Cannot calculate inverse, determinant is zero/)))throw e}return HP(e)?n(h(e.valueOf(),a,i),e.storage()):h(e,a,i);default:throw new RangeError("Matrix must be two dimensional (size: "+VU(t)+")")}},any:function(e){return i(e,0)?vH(e):l(1,e)}});function h(e,t,n){var{C:a,F:i}=function(e,t,n){var r=function(e,t,n){for(var r=vH(e),a=0,i=0;ie.filter(((e,n)=>n!f(o(r[t],r[t]))));return{C:a,F:i}}(e,t,n),l=c(r(c(u(a),a)),u(a)),d=c(u(i),r(c(i,u(i))));return c(d,l)}function f(e){return i(p(e,d(1,1)),p(0,d(1,1)))}function m(e){return a(p(e,d(1,1)),p(c(e,0),d(1,1)))}})),l0=RH("pow",["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],(e=>{var{typed:t,config:n,identity:r,multiply:a,matrix:i,inv:s,number:o,fraction:u,Complex:l}=e;return t("pow",{"number, number":c,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||n.predictable?e.pow(t):new l(e.toNumber(),0).pow(t.toNumber(),0)},"Fraction, Fraction":function(e,t){var r=e.pow(t);if(null!=r)return r;if(n.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(e.valueOf(),t.valueOf())},"Array, number":p,"Array, BigNumber":function(e,t){return p(e,t.toNumber())},"Matrix, number":d,"Matrix, BigNumber":function(e,t){return d(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function c(e,t){if(n.predictable&&!PH(t)&&e<0)try{var r=u(t),a=o(r);if((t===a||Math.abs((t-a)/t)<1e-14)&&r.d%2==1)return(r.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return n.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:PH(t)||e>=0||n.predictable?gW(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new l(e,0).pow(t,0)}function p(e,t){if(!PH(t))throw new TypeError("For A^b, b must be an integer (value is "+t+")");var n=eq(e);if(2!==n.length)throw new Error("For A^b, A must be 2 dimensional (A has "+n.length+" dimensions)");if(n[0]!==n[1])throw new Error("For A^b, A must be square (size is "+n[0]+"x"+n[1]+")");if(t<0)try{return p(s(e),-t)}catch(e){if("Cannot calculate inverse, determinant is zero"===e.message)throw new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+t+")");throw e}for(var i=r(n[0]).valueOf(),o=e;t>=1;)1==(1&t)&&(i=a(o,i)),t>>=1,o=a(o,o);return i}function d(e,t){return i(p(e.valueOf(),t))}})),c0="setDifference",p0=RH(c0,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(c0,{"Array | Matrix, Array | Matrix":function(e,t){var o;if(0===r(n(e),new i(0)))o=[];else{if(0===r(n(t),new i(0)))return hq(e.toArray());var u,l=xq(hq(Array.isArray(e)?e:e.toArray()).sort(a)),c=xq(hq(Array.isArray(t)?t:t.toArray()).sort(a));o=[];for(var p=0;p{var{typed:t,size:n,subset:r,compareNatural:a,Index:i}=e;return t(d0,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===r(n(t),new i(0)))return 0;for(var s=hq(Array.isArray(t)?t:t.toArray()),o=0,u=0;u{var{addScalar:t,equalScalar:n,FibonacciHeap:r}=e;function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new r}return a.prototype.type="Spa",a.prototype.isSpa=!0,a.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var n=this._heap.insert(e,t);this._values[e]=n}},a.prototype.get=function(e){var t=this._values[e];return t?t.value:0},a.prototype.accumulate=function(e,n){var r=this._values[e];r?r.value=t(r.value,n):(r=this._heap.insert(e,n),this._values[e]=r)},a.prototype.forEach=function(e,t,r){var a=this._heap,i=this._values,s=[],o=a.extractMinimum();for(o&&s.push(o);o&&o.key<=t;)o.key>=e&&(n(o.value,0)||r(o.key,o.value,this)),(o=a.extractMinimum())&&s.push(o);for(var u=0;u{var{typed:t,abs:n,add:r,multiply:a,sqrt:i,subtract:s,inv:o,size:u,max:l,identity:c}=e,p=1e-6;function d(e){var t,i=0,d=e,h=c(u(e));do{var f=d;if(d=a(.5,r(f,o(h))),h=a(.5,r(h,o(f))),(t=l(n(s(d,f))))>p&&++i>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(t>p);return d}return t(m0,{"Array | Matrix":function(e){var t=HP(e)?e.size():eq(e);switch(t.length){case 1:if(1===t[0])return i(e);throw new RangeError("Matrix must be square (size: "+VU(t)+")");case 2:if(t[0]===t[1])return d(e);throw new RangeError("Matrix must be square (size: "+VU(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+VU(t)+")")}}})}));function y0(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b0(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 x0(e){for(var t=1;t{var t,n,r,{on:a,config:i,addScalar:s,subtract:o,multiplyScalar:u,divideScalar:l,pow:c,abs:p,fix:d,round:h,equal:f,isNumeric:m,format:g,number:y,Complex:b,BigNumber:x,Fraction:v}=e,_=y;function w(e,t){if(!(this instanceof w))throw new Error("Constructor must be called with the new operator");if(null!=e&&!m(e)&&!FP(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==t&&("string"!=typeof t||""===t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==t){var n=w.parse(t);this.units=n.units,this.dimensions=n.dimensions}else{this.units=[{unit:R,prefix:A.NONE,power:0}],this.dimensions=[];for(var r=0;r="0"&&e<="9"}function S(){n++,r=t.charAt(n)}function k(e){n=e,r=t.charAt(n)}function D(){var e="",t=n;if("+"===r?S():"-"===r&&(e+=r,S()),!function(e){return e>="0"&&e<="9"||"."===e}(r))return k(t),null;if("."===r){if(e+=r,S(),!N(r))return k(t),null}else{for(;N(r);)e+=r,S();"."===r&&(e+=r,S())}for(;N(r);)e+=r,S();if("E"===r||"e"===r){var a="",i=n;if(a+=r,S(),"+"!==r&&"-"!==r||(a+=r,S()),!N(r))return k(i),e;for(e+=a;N(r);)e+=r,S()}return e}function T(){for(var e="";N(r)||w.isValidAlpha(r);)e+=r,S();var t=e.charAt(0);return w.isValidAlpha(t)?e:null}function I(e){return r===e?(S(),e):null}w.prototype.type="Unit",w.prototype.isUnit=!0,w.parse=function(e,a){if(a=a||{},n=-1,r="","string"!=typeof(t=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var s=new w;s.units=[];var o=1,u=!1;S(),M();var l=D(),c=null;if(l){if("BigNumber"===i.number)c=new x(l);else if("Fraction"===i.number)try{c=new v(l)}catch(e){c=parseFloat(l)}else c=parseFloat(l);M(),I("*")?(o=1,u=!0):I("/")&&(o=-1,u=!0)}for(var p=[],d=1;;){for(M();"("===r;)p.push(o),d*=o,o=1,S(),M();var h;if(!r)break;var f=r;if(null===(h=T()))throw new SyntaxError('Unexpected "'+f+'" in "'+t+'" at index '+n.toString());var m=E(h);if(null===m)throw new SyntaxError('Unit "'+h+'" not found.');var g=o*d;if(M(),I("^")){M();var y=D();if(null===y)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');g*=y}s.units.push({unit:m.unit,prefix:m.prefix,power:g});for(var b=0;b1||Math.abs(this.units[0].power-1)>1e-15)},w.prototype._normalize=function(e){if(null==e||0===this.units.length)return e;for(var t=e,n=w._getNumberConverter(xH(e)),r=0;r{if(TH(F,e)){var t=F[e];return{unit:t,prefix:t.prefixes[""]}}for(var n in F)if(TH(F,n)&&WU(e,n)){var r=F[n],a=e.length-n.length,i=e.substring(0,a),s=TH(r.prefixes,i)?r.prefixes[i]:void 0;if(void 0!==s)return{unit:r,prefix:s}}return null}),{hasher:e=>e[0],limit:100});function C(e){return e.equalBase($.NONE)&&null!==e.value&&!i.predictable?e.value:e}w.isValuelessUnit=function(e){return null!==E(e)},w.prototype.hasBase=function(e){if("string"==typeof e&&(e=$[e]),!e)return!1;for(var t=0;t1e-12)return!1;return!0},w.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},w.prototype.equals=function(e){return this.equalBase(e)&&f(this.value,e.value)},w.prototype.multiply=function(e){for(var t=this.clone(),n=0;n1e-12&&(TH(P,o)?r.push({unit:P[o].unit,prefix:P[o].prefix,power:n.dimensions[s]||0}):i=!0)}r.length1e-12){if(!TH(B.si,r))throw new Error("Cannot express custom unit "+r+" in SI units");t.push({unit:B.si[r].unit,prefix:B.si[r].prefix,power:e.dimensions[n]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},w.prototype.formatUnits=function(){for(var e="",t="",n=0,r=0,a=0;a0?(n++,e+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power-1)>1e-15&&(e+="^"+this.units[a].power)):this.units[a].power<0&&r++;if(r>0)for(var i=0;i0?(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power+1)>1e-15&&(t+="^"+-this.units[i].power)):(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,t+="^"+this.units[i].power));e=e.substr(1),t=t.substr(1),n>1&&r>0&&(e="("+e+")"),r>1&&n>0&&(t="("+t+")");var s=e;return n>0&&r>0&&(s+=" / "),s+t},w.prototype.format=function(e){var t=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),n=!1;for(var r in void 0!==t.value&&null!==t.value&&FP(t.value)&&(n=Math.abs(t.value.re)<1e-14),t.units)TH(t.units,r)&&t.units[r].unit&&("VA"===t.units[r].unit.name&&n?t.units[r].unit=F.VAR:"VAR"!==t.units[r].unit.name||n||(t.units[r].unit=F.VA));1!==t.units.length||t.fixPrefix||Math.abs(t.units[0].power-Math.round(t.units[0].power))<1e-14&&(t.units[0].prefix=t._bestPrefix());var a=t._denormalize(t.value),i=null!==t.value?g(a,e||{}):"",s=t.formatUnits();return t.value&&FP(t.value)&&(i="("+i+")"),s.length>0&&i.length>0&&(i+=" "),i+s},w.prototype._bestPrefix=function(){if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var e=null!==this.value?p(this.value):0,t=p(this.units[0].unit.value),n=this.units[0].prefix;if(0===e)return n;var r=this.units[0].power,a=Math.log(e/Math.pow(n.value*t,r))/Math.LN10-1.2;if(a>-2.200001&&a<1.800001)return n;a=Math.abs(a);var i=this.units[0].unit.prefixes;for(var s in i)if(TH(i,s)){var o=i[s];if(o.scientific){var u=Math.abs(Math.log(e/Math.pow(o.value*t,r))/Math.LN10-1.2);(u0))},F={meter:{name:"meter",base:$.LENGTH,prefixes:A.LONG,value:1,offset:0},inch:{name:"inch",base:$.LENGTH,prefixes:A.NONE,value:.0254,offset:0},foot:{name:"foot",base:$.LENGTH,prefixes:A.NONE,value:.3048,offset:0},yard:{name:"yard",base:$.LENGTH,prefixes:A.NONE,value:.9144,offset:0},mile:{name:"mile",base:$.LENGTH,prefixes:A.NONE,value:1609.344,offset:0},link:{name:"link",base:$.LENGTH,prefixes:A.NONE,value:.201168,offset:0},rod:{name:"rod",base:$.LENGTH,prefixes:A.NONE,value:5.0292,offset:0},chain:{name:"chain",base:$.LENGTH,prefixes:A.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:$.LENGTH,prefixes:A.NONE,value:1e-10,offset:0},m:{name:"m",base:$.LENGTH,prefixes:A.SHORT,value:1,offset:0},in:{name:"in",base:$.LENGTH,prefixes:A.NONE,value:.0254,offset:0},ft:{name:"ft",base:$.LENGTH,prefixes:A.NONE,value:.3048,offset:0},yd:{name:"yd",base:$.LENGTH,prefixes:A.NONE,value:.9144,offset:0},mi:{name:"mi",base:$.LENGTH,prefixes:A.NONE,value:1609.344,offset:0},li:{name:"li",base:$.LENGTH,prefixes:A.NONE,value:.201168,offset:0},rd:{name:"rd",base:$.LENGTH,prefixes:A.NONE,value:5.02921,offset:0},ch:{name:"ch",base:$.LENGTH,prefixes:A.NONE,value:20.1168,offset:0},mil:{name:"mil",base:$.LENGTH,prefixes:A.NONE,value:254e-7,offset:0},m2:{name:"m2",base:$.SURFACE,prefixes:A.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:$.SURFACE,prefixes:A.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:$.SURFACE,prefixes:A.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:$.SURFACE,prefixes:A.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:$.SURFACE,prefixes:A.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:$.SURFACE,prefixes:A.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:$.SURFACE,prefixes:A.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:$.SURFACE,prefixes:A.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:$.SURFACE,prefixes:A.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:$.SURFACE,prefixes:A.NONE,value:1e4,offset:0},m3:{name:"m3",base:$.VOLUME,prefixes:A.CUBIC,value:1,offset:0},L:{name:"L",base:$.VOLUME,prefixes:A.SHORT,value:.001,offset:0},l:{name:"l",base:$.VOLUME,prefixes:A.SHORT,value:.001,offset:0},litre:{name:"litre",base:$.VOLUME,prefixes:A.LONG,value:.001,offset:0},cuin:{name:"cuin",base:$.VOLUME,prefixes:A.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:$.VOLUME,prefixes:A.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:$.VOLUME,prefixes:A.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:$.VOLUME,prefixes:A.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:$.VOLUME,prefixes:A.NONE,value:15e-6,offset:0},drop:{name:"drop",base:$.VOLUME,prefixes:A.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:$.VOLUME,prefixes:A.NONE,value:5e-8,offset:0},minim:{name:"minim",base:$.VOLUME,prefixes:A.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:$.VOLUME,prefixes:A.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:$.VOLUME,prefixes:A.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:$.VOLUME,prefixes:A.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:$.VOLUME,prefixes:A.NONE,value:1e-6,offset:0},cup:{name:"cup",base:$.VOLUME,prefixes:A.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:$.VOLUME,prefixes:A.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:$.VOLUME,prefixes:A.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:$.VOLUME,prefixes:A.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:$.VOLUME,prefixes:A.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:$.VOLUME,prefixes:A.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:$.VOLUME,prefixes:A.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:$.VOLUME,prefixes:A.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:$.VOLUME,prefixes:A.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:$.VOLUME,prefixes:A.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:$.VOLUME,prefixes:A.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:$.VOLUME,prefixes:A.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:$.VOLUME,prefixes:A.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:$.VOLUME,prefixes:A.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:$.VOLUME,prefixes:A.NONE,value:.1173478,offset:0},obl:{name:"obl",base:$.VOLUME,prefixes:A.NONE,value:.1589873,offset:0},g:{name:"g",base:$.MASS,prefixes:A.SHORT,value:.001,offset:0},gram:{name:"gram",base:$.MASS,prefixes:A.LONG,value:.001,offset:0},ton:{name:"ton",base:$.MASS,prefixes:A.SHORT,value:907.18474,offset:0},t:{name:"t",base:$.MASS,prefixes:A.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:$.MASS,prefixes:A.LONG,value:1e3,offset:0},grain:{name:"grain",base:$.MASS,prefixes:A.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:$.MASS,prefixes:A.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:$.MASS,prefixes:A.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:$.MASS,prefixes:A.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:$.MASS,prefixes:A.NONE,value:45.359237,offset:0},stick:{name:"stick",base:$.MASS,prefixes:A.NONE,value:.115,offset:0},stone:{name:"stone",base:$.MASS,prefixes:A.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:$.MASS,prefixes:A.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:$.MASS,prefixes:A.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:$.MASS,prefixes:A.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:$.MASS,prefixes:A.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:$.MASS,prefixes:A.NONE,value:45.359237,offset:0},s:{name:"s",base:$.TIME,prefixes:A.SHORT,value:1,offset:0},min:{name:"min",base:$.TIME,prefixes:A.NONE,value:60,offset:0},h:{name:"h",base:$.TIME,prefixes:A.NONE,value:3600,offset:0},second:{name:"second",base:$.TIME,prefixes:A.LONG,value:1,offset:0},sec:{name:"sec",base:$.TIME,prefixes:A.LONG,value:1,offset:0},minute:{name:"minute",base:$.TIME,prefixes:A.NONE,value:60,offset:0},hour:{name:"hour",base:$.TIME,prefixes:A.NONE,value:3600,offset:0},day:{name:"day",base:$.TIME,prefixes:A.NONE,value:86400,offset:0},week:{name:"week",base:$.TIME,prefixes:A.NONE,value:604800,offset:0},month:{name:"month",base:$.TIME,prefixes:A.NONE,value:2629800,offset:0},year:{name:"year",base:$.TIME,prefixes:A.NONE,value:31557600,offset:0},decade:{name:"decade",base:$.TIME,prefixes:A.NONE,value:315576e3,offset:0},century:{name:"century",base:$.TIME,prefixes:A.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:$.TIME,prefixes:A.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:$.FREQUENCY,prefixes:A.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:$.FREQUENCY,prefixes:A.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:$.ANGLE,prefixes:A.SHORT,value:1,offset:0},radian:{name:"radian",base:$.ANGLE,prefixes:A.LONG,value:1,offset:0},deg:{name:"deg",base:$.ANGLE,prefixes:A.SHORT,value:null,offset:0},degree:{name:"degree",base:$.ANGLE,prefixes:A.LONG,value:null,offset:0},grad:{name:"grad",base:$.ANGLE,prefixes:A.SHORT,value:null,offset:0},gradian:{name:"gradian",base:$.ANGLE,prefixes:A.LONG,value:null,offset:0},cycle:{name:"cycle",base:$.ANGLE,prefixes:A.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:$.ANGLE,prefixes:A.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:$.ANGLE,prefixes:A.NONE,value:null,offset:0},A:{name:"A",base:$.CURRENT,prefixes:A.SHORT,value:1,offset:0},ampere:{name:"ampere",base:$.CURRENT,prefixes:A.LONG,value:1,offset:0},K:{name:"K",base:$.TEMPERATURE,prefixes:A.NONE,value:1,offset:0},degC:{name:"degC",base:$.TEMPERATURE,prefixes:A.NONE,value:1,offset:273.15},degF:{name:"degF",base:$.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:$.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:$.TEMPERATURE,prefixes:A.NONE,value:1,offset:0},celsius:{name:"celsius",base:$.TEMPERATURE,prefixes:A.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:$.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:$.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:$.AMOUNT_OF_SUBSTANCE,prefixes:A.SHORT,value:1,offset:0},mole:{name:"mole",base:$.AMOUNT_OF_SUBSTANCE,prefixes:A.LONG,value:1,offset:0},cd:{name:"cd",base:$.LUMINOUS_INTENSITY,prefixes:A.SHORT,value:1,offset:0},candela:{name:"candela",base:$.LUMINOUS_INTENSITY,prefixes:A.LONG,value:1,offset:0},N:{name:"N",base:$.FORCE,prefixes:A.SHORT,value:1,offset:0},newton:{name:"newton",base:$.FORCE,prefixes:A.LONG,value:1,offset:0},dyn:{name:"dyn",base:$.FORCE,prefixes:A.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:$.FORCE,prefixes:A.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:$.FORCE,prefixes:A.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:$.FORCE,prefixes:A.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:$.FORCE,prefixes:A.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:$.FORCE,prefixes:A.NONE,value:9.80665,offset:0},J:{name:"J",base:$.ENERGY,prefixes:A.SHORT,value:1,offset:0},joule:{name:"joule",base:$.ENERGY,prefixes:A.SHORT,value:1,offset:0},erg:{name:"erg",base:$.ENERGY,prefixes:A.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:$.ENERGY,prefixes:A.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:$.ENERGY,prefixes:A.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:$.ENERGY,prefixes:A.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:$.ENERGY,prefixes:A.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:$.POWER,prefixes:A.SHORT,value:1,offset:0},watt:{name:"watt",base:$.POWER,prefixes:A.LONG,value:1,offset:0},hp:{name:"hp",base:$.POWER,prefixes:A.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:$.POWER,prefixes:A.SHORT,value:b.I,offset:0},VA:{name:"VA",base:$.POWER,prefixes:A.SHORT,value:1,offset:0},Pa:{name:"Pa",base:$.PRESSURE,prefixes:A.SHORT,value:1,offset:0},psi:{name:"psi",base:$.PRESSURE,prefixes:A.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:$.PRESSURE,prefixes:A.NONE,value:101325,offset:0},bar:{name:"bar",base:$.PRESSURE,prefixes:A.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:$.PRESSURE,prefixes:A.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:$.PRESSURE,prefixes:A.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:$.PRESSURE,prefixes:A.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:$.PRESSURE,prefixes:A.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:$.ELECTRIC_CHARGE,prefixes:A.LONG,value:1,offset:0},C:{name:"C",base:$.ELECTRIC_CHARGE,prefixes:A.SHORT,value:1,offset:0},farad:{name:"farad",base:$.ELECTRIC_CAPACITANCE,prefixes:A.LONG,value:1,offset:0},F:{name:"F",base:$.ELECTRIC_CAPACITANCE,prefixes:A.SHORT,value:1,offset:0},volt:{name:"volt",base:$.ELECTRIC_POTENTIAL,prefixes:A.LONG,value:1,offset:0},V:{name:"V",base:$.ELECTRIC_POTENTIAL,prefixes:A.SHORT,value:1,offset:0},ohm:{name:"ohm",base:$.ELECTRIC_RESISTANCE,prefixes:A.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:$.ELECTRIC_INDUCTANCE,prefixes:A.LONG,value:1,offset:0},H:{name:"H",base:$.ELECTRIC_INDUCTANCE,prefixes:A.SHORT,value:1,offset:0},siemens:{name:"siemens",base:$.ELECTRIC_CONDUCTANCE,prefixes:A.LONG,value:1,offset:0},S:{name:"S",base:$.ELECTRIC_CONDUCTANCE,prefixes:A.SHORT,value:1,offset:0},weber:{name:"weber",base:$.MAGNETIC_FLUX,prefixes:A.LONG,value:1,offset:0},Wb:{name:"Wb",base:$.MAGNETIC_FLUX,prefixes:A.SHORT,value:1,offset:0},tesla:{name:"tesla",base:$.MAGNETIC_FLUX_DENSITY,prefixes:A.LONG,value:1,offset:0},T:{name:"T",base:$.MAGNETIC_FLUX_DENSITY,prefixes:A.SHORT,value:1,offset:0},b:{name:"b",base:$.BIT,prefixes:A.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:$.BIT,prefixes:A.BINARY_LONG,value:1,offset:0},B:{name:"B",base:$.BIT,prefixes:A.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:$.BIT,prefixes:A.BINARY_LONG,value:8,offset:0}},Y={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function z(e){if("BigNumber"===e.number){var t=mj(x);F.rad.value=new x(1),F.deg.value=t.div(180),F.grad.value=t.div(200),F.cycle.value=t.times(2),F.arcsec.value=t.div(648e3),F.arcmin.value=t.div(10800)}else F.rad.value=1,F.deg.value=Math.PI/180,F.grad.value=Math.PI/200,F.cycle.value=2*Math.PI,F.arcsec.value=Math.PI/648e3,F.arcmin.value=Math.PI/10800;F.radian.value=F.rad.value,F.degree.value=F.deg.value,F.gradian.value=F.grad.value}z(i),a&&a("config",(function(e,t){e.number!==t.number&&z(e)}));var B={si:{NONE:{unit:R,prefix:A.NONE[""]},LENGTH:{unit:F.m,prefix:A.SHORT[""]},MASS:{unit:F.g,prefix:A.SHORT.k},TIME:{unit:F.s,prefix:A.SHORT[""]},CURRENT:{unit:F.A,prefix:A.SHORT[""]},TEMPERATURE:{unit:F.K,prefix:A.SHORT[""]},LUMINOUS_INTENSITY:{unit:F.cd,prefix:A.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:F.mol,prefix:A.SHORT[""]},ANGLE:{unit:F.rad,prefix:A.SHORT[""]},BIT:{unit:F.bits,prefix:A.SHORT[""]},FORCE:{unit:F.N,prefix:A.SHORT[""]},ENERGY:{unit:F.J,prefix:A.SHORT[""]},POWER:{unit:F.W,prefix:A.SHORT[""]},PRESSURE:{unit:F.Pa,prefix:A.SHORT[""]},ELECTRIC_CHARGE:{unit:F.C,prefix:A.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:F.F,prefix:A.SHORT[""]},ELECTRIC_POTENTIAL:{unit:F.V,prefix:A.SHORT[""]},ELECTRIC_RESISTANCE:{unit:F.ohm,prefix:A.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:F.H,prefix:A.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:F.S,prefix:A.SHORT[""]},MAGNETIC_FLUX:{unit:F.Wb,prefix:A.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:F.T,prefix:A.SHORT[""]},FREQUENCY:{unit:F.Hz,prefix:A.SHORT[""]}}};B.cgs=JSON.parse(JSON.stringify(B.si)),B.cgs.LENGTH={unit:F.m,prefix:A.SHORT.c},B.cgs.MASS={unit:F.g,prefix:A.SHORT[""]},B.cgs.FORCE={unit:F.dyn,prefix:A.SHORT[""]},B.cgs.ENERGY={unit:F.erg,prefix:A.NONE[""]},B.us=JSON.parse(JSON.stringify(B.si)),B.us.LENGTH={unit:F.ft,prefix:A.NONE[""]},B.us.MASS={unit:F.lbm,prefix:A.NONE[""]},B.us.TEMPERATURE={unit:F.degF,prefix:A.NONE[""]},B.us.FORCE={unit:F.lbf,prefix:A.NONE[""]},B.us.ENERGY={unit:F.BTU,prefix:A.BTU[""]},B.us.POWER={unit:F.hp,prefix:A.NONE[""]},B.us.PRESSURE={unit:F.psi,prefix:A.NONE[""]},B.auto=JSON.parse(JSON.stringify(B.si));var P=B.auto;for(var H in w.setUnitSystem=function(e){if(!TH(B,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(B).join(", "));P=B[e]},w.getUnitSystem=function(){for(var e in B)if(TH(B,e)&&B[e]===P)return e},w.typeConverters={BigNumber:function(e){return new x(e+"")},Fraction:function(e){return new v(e)},Complex:function(e){return e},number:function(e){return e}},w._getNumberConverter=function(e){if(!w.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return w.typeConverters[e]},F)if(TH(F,H)){var j=F[H];j.dimensions=j.base.dimensions}for(var U in Y)if(TH(Y,U)){var q=F[Y[U]],W={};for(var V in q)TH(q,V)&&(W[V]=q[V]);W.name=U,F[U]=W}return w.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},w.createUnit=function(e,t){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var n in e)if(TH(e,n)&&w.deleteUnit(n),e[n].aliases)for(var r=0;r0&&!w.isValidAlpha(r)&&!N(r))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var a,i,s,o=null,u=[],l=0;if(t&&"Unit"===t.type)o=t.clone();else if("string"==typeof t)""!==t&&(a=t);else{if("object"!=typeof t)throw new TypeError('Cannot create unit "'+e+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');a=t.definition,i=t.prefixes,l=t.offset,s=t.baseName,t.aliases&&(u=t.aliases.valueOf())}if(u)for(var c=0;c1e-12){f=!1;break}if(f){d=!0,p.base=$[h];break}}if(!d){s=s||e+"_STUFF";var g={dimensions:o.dimensions.slice(0)};g.key=s,$[s]=g,P[s]={unit:p,prefix:A.NONE[""]},p.base=$[s]}}else{if(s=s||e+"_STUFF",L.indexOf(s)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var y in L.push(s),$)TH($,y)&&($[y].dimensions[L.length-1]=0);for(var b={dimensions:[]},x=0;x{var{typed:t,Unit:n}=e;return t(_0,{"Object, Object":function(e,t){return n.createUnit(e,t)},Object:function(e){return n.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,r){var a={};return a[e]=t,n.createUnit(a,r)},"string, Unit | string | Object":function(e,t){var r={};return r[e]=t,n.createUnit(r,{})},string:function(e){var t={};return t[e]={},n.createUnit(t,{})}})})),M0="dotPow",N0=RH(M0,["typed","equalScalar","matrix","pow","DenseMatrix"],(e=>{var{typed:t,equalScalar:n,matrix:r,pow:a,DenseMatrix:i}=e,s=rJ({typed:t}),o=kJ({typed:t,DenseMatrix:i}),u=iJ({typed:t,equalScalar:n}),l=sJ({typed:t,DenseMatrix:i}),c=oJ({typed:t}),p=uJ({typed:t});return t(M0,{"any, any":a,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,a,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,a,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,a,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,a)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})})),S0="expm",k0=RH(S0,["typed","abs","add","identity","inv","multiply"],(e=>{var{typed:t,abs:n,add:r,identity:a,inv:i,multiply:s}=e;return t(S0,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+VU(t)+")");for(var u=t[0],l=function(e){for(var t=e.size()[0],r=0,a=0;a1&&(y=s(y,h),b=-b),f=r(f,s(g=g*(p-x+1)/((2*p-x+1)*x),y)),m=r(m,s(g*b,y));for(var v=s(i(m),f),_=0;_{var{typed:t,config:n,multiplyScalar:r,pow:a,BigNumber:i,Complex:s}=e;return t(D0,{number:xG,Complex:function(e){if(0===e.im)return this(e.re);if(e.re<.5){var t=new s(1-e.re,-e.im),n=new s(Math.PI*e.re,Math.PI*e.im);return new s(Math.PI).div(n.sin()).div(this(t))}e=new s(e.re-1,e.im);for(var r=new s(_G[0],0),a=1;a<_G.length;++a){var i=new s(_G[a],0);r=r.add(i.div(e.add(a)))}var o=new s(e.re+vG+.5,e.im),u=Math.sqrt(2*Math.PI),l=o.pow(e.add(.5)),c=o.neg().exp();return r.mul(u).mul(l).mul(c)},BigNumber:function(e){if(e.isInteger())return e.isNegative()||e.isZero()?new i(1/0):o(e.minus(1));if(!e.isFinite())return new i(e.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")},"Array | Matrix":function(e){return Wq(e,this)}});function o(e){if(e<8)return new i([1,1,2,6,24,120,720,5040][e]);var t=n.precision+(0|Math.log(e.toNumber())),r=i.clone({precision:t});if(e%2==1)return e.times(o(new i(e-1)));for(var a=e,s=new r(e),u=e.toNumber();a>2;)u+=a-=2,s=s.times(u);return new i(s.toPrecision(i.precision))}})),I0="setIntersect",E0=RH(I0,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(I0,{"Array | Matrix, Array | Matrix":function(e,t){var o;if(0===r(n(e),new i(0))||0===r(n(t),new i(0)))o=[];else{var u=xq(hq(Array.isArray(e)?e:e.toArray()).sort(a)),l=xq(hq(Array.isArray(t)?t:t.toArray()).sort(a));o=[];for(var c=0;c{var{typed:t,matrix:n,multiply:r,equalScalar:a,divideScalar:i,inv:s}=e,o=iJ({typed:t,equalScalar:a}),u=uJ({typed:t});return t("divide",wH({"Array | Matrix, Array | Matrix":function(e,t){return r(e,s(t))},"DenseMatrix, any":function(e,t){return u(e,t,i,!1)},"SparseMatrix, any":function(e,t){return o(e,t,i,!1)},"Array, any":function(e,t){return u(n(e),t,i,!1).valueOf()},"any, Array | Matrix":function(e,t){return r(e,s(t))}},i.signatures))})),A0="factorial",L0=RH(A0,["typed","gamma"],(e=>{var{typed:t,gamma:n}=e;return t(A0,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return n(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return n(e.plus(1))},"Array | Matrix":function(e){return Wq(e,this)}})})),$0=RH("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:t,matrix:n,abs:r,addScalar:a,divideScalar:i,multiplyScalar:s,subtract:o,larger:u,equalScalar:l,unaryMinus:c,DenseMatrix:p,SparseMatrix:d,Spa:h}=e;return t("lup",{DenseMatrix:function(e){return f(e)},SparseMatrix:function(e){return function(e){var t,n,a,o=e._size[0],p=e._size[1],f=Math.min(o,p),m=e._values,g=e._index,y=e._ptr,b=[],x=[],v=[],_=[o,f],w=[],M=[],N=[],S=[f,p],k=[],D=[];for(t=0;t0&&e.forEach(0,n-1,(function(t,n){d._forEachRow(t,b,x,v,(function(r,a){r>t&&e.accumulate(r,c(s(a,n)))}))}));var T,I,E,C,A=n,L=e.get(n),$=r(L);e.forEach(n+1,o-1,(function(e,t){var n=r(t);u(n,$)&&(A=e,$=n,L=t)})),n!==A&&(d._swapRows(n,A,_[1],b,x,v),d._swapRows(n,A,S[1],w,M,N),e.swap(n,A),I=A,E=D[T=n],C=D[I],k[E]=I,k[C]=T,D[T]=C,D[I]=E),e.forEach(0,o-1,(function(e,t){e<=n?(w.push(t),M.push(e)):(t=i(t,L),l(t,0)||(b.push(t),x.push(e)))}))};for(n=0;n0)for(t=0;t{var{typed:t,add:n,divide:r,multiply:a,factorial:i,isInteger:s,isPositive:o}=e;return t(O0,{"Array | Matrix":function(e){var t=0,u=1;return qq(e,(function(e){if(!s(e)||!o(e))throw new TypeError("Positive integer value expected in function multinomial");t=n(t,e),u=a(u,i(e))})),r(i(t),u)}})})),F0="permutations",Y0=RH(F0,["typed","factorial"],(e=>{var{typed:t,factorial:n}=e;return t(F0,{"number | BigNumber":n,"number, number":function(e,t){if(!PH(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!PH(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");return wV(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var n,r;if(!z0(e)||!z0(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(n=e.mul(0).add(1),r=e.minus(t).plus(1);r.lte(e);r=r.plus(1))n=n.times(r);return n}})}));function z0(e){return e.isInteger()&&e.gte(0)}var B0="stirlingS2",P0=RH(B0,["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],(e=>{var{typed:t,addScalar:n,subtract:r,multiplyScalar:a,divideScalar:i,pow:s,factorial:o,combinations:u,isNegative:l,isInteger:c,number:p,bignumber:d,larger:h}=e,f=[],m=[];return t(B0,{"number | BigNumber, number | BigNumber":function(e,t){if(!c(e)||l(e)||!c(t)||l(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(h(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");var r=!(OP(e)&&OP(t)),i=r?m:f,s=r?d:p,o=p(e),u=p(t);if(i[o]&&i[o].length>u)return i[o][u];for(var g=0;g<=o;++g)if(i[g]||(i[g]=[s(0===g?1:0)]),0!==g)for(var y=i[g],b=i[g-1],x=y.length;x<=g&&x<=u;++x)y[x]=x===g?1:n(a(s(x),b[x]),b[x-1]);return i[o][u]}})})),H0="unit",j0=RH(H0,["typed","Unit"],(e=>{var{typed:t,Unit:n}=e;return t(H0,{Unit:function(e){return e.clone()},string:function(e){return n.isValuelessUnit(e)?new n(null,e):n.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(e,t){return new n(e,t)},"Array | Matrix":function(e){return Wq(e,this)}})})),U0="bellNumbers",q0=RH(U0,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:t,addScalar:n,isNegative:r,isInteger:a,stirlingS2:i}=e;return t(U0,{"number | BigNumber":function(e){if(!a(e)||r(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,s=0;s<=e;s++)t=n(t,i(e,s));return t}})}));var W0=RH("eigs",["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],(e=>{var{config:t,typed:n,matrix:r,addScalar:a,subtract:i,equal:s,abs:o,atan:u,cos:l,sin:c,multiplyScalar:p,divideScalar:d,inv:h,bignumber:f,multiply:m,add:g,larger:y,column:b,flatten:x,number:v,complex:_,sqrt:w,diag:M,qr:N,usolve:S,usolveAll:k,im:D,re:T,smaller:I,matrixFromColumns:E,dot:C}=e,A=function(e){var{config:t,addScalar:n,subtract:r,abs:a,atan:i,cos:s,sin:o,multiplyScalar:u,inv:l,bignumber:c,multiply:p,add:d}=e;function h(e,n){for(var r,a=e.length,i=Math.abs(n/a),s=new Array(a),o=0;o=Math.abs(i);){var l=u[0][0],c=u[0][1];e=b(e,(p=e[l][l],d=e[c][c],h=e[l][c],f=void 0,f=d-p,r=Math.abs(f)<=t.epsilon?Math.PI/4:.5*Math.atan(2*h/(d-p))),l,c),s=m(s,r,l,c),u=x(e)}for(var p,d,h,f,g=w(a,0),y=0;y=a(d);){var b=m[0][0],x=m[0][1];e=y(e,(M=e[b][b],N=e[x][x],S=e[b][x],k=void 0,k=r(N,M),s=a(k)<=t.epsilon?c(-1).acos().div(4):u(.5,i(p(2,S,l(k))))),b,x),h=g(h,s,b,x),m=v(e)}for(var M,N,S,k,D=w(o,0),T=0;T2&&void 0!==arguments[2]?arguments[2]:t.epsilon,a=arguments.length>3?arguments[3]:void 0;if("number"===a)return h(e,r);if("BigNumber"===a)return f(e,r);throw TypeError("Unsupported data type: "+a)}}({config:t,addScalar:a,subtract:i,column:b,flatten:x,equal:s,abs:o,atan:u,cos:l,sin:c,multiplyScalar:p,inv:h,bignumber:f,complex:_,multiply:m,add:g}),L=function(e){var{addScalar:t,subtract:n,flatten:r,multiply:a,multiplyScalar:i,divideScalar:s,sqrt:o,abs:u,bignumber:l,diag:c,inv:p,qr:d,usolve:h,usolveAll:f,equal:m,complex:g,larger:y,smaller:b,matrixFromColumns:x,dot:v}=e;function _(e,t,r,a,i,s,o,c){var p="BigNumber"===c,d="Complex"===c,h=p?l(0):d?g(0):0,f=p?l(1):d?g(1):1;if(b(u(r),o))return[[f,h],[h,f]];if(y(u(n(i,s)),o))return[[n(i,a),n(s,a)],[r,r]];var m=n(e,i),x=n(t,i),v=n(r,i),_=n(a,i);return b(u(x),o)?[[m,f],[v,h]]:[[x,h],[_,f]]}function w(e,t){for(var n=0;n=5)return null;for(o=0;;){var u=h(e,i);if(b(D(k(i,[u])),r))break;if(++o>=10)return null;i=T(u)}return i}function S(e,t,n){var r="BigNumber"===n,a="Complex"===n,i=Array(e).fill(0).map((e=>2*Math.random()-1));return r&&(i=i.map((e=>l(e)))),a&&(i=i.map((e=>g(e)))),T(i=k(i,t),n)}function k(e,t){for(var r of t)e=n(e,a(s(v(r,e),v(r,r)),r));return e}function D(e){return u(o(v(e,e)))}function T(e,t){var n="Complex"===t,r="BigNumber"===t?l(1):n?g(1):1;return a(s(r,D(e)),e)}return function(e,h,v,S,k){void 0===k&&(k=!0);var D=function(e,n,r,a,o){var p,d="BigNumber"===a,h="Complex"===a,f=d?l(0):0,x=d?l(1):h?g(1):1,v=d?l(1):1,_=d?l(10):2,w=i(_,_);o&&(p=Array(n).fill(x));for(var M=!1;!M;){M=!0;for(var N=0;N1&&($=c(Array(C-1).fill(y)))),C-=1,I.pop();for(var B=0;B2&&($=c(Array(C-2).fill(y)))),C-=2,I.pop(),I.pop();for(var H=0;H+n(u(e),u(t)))),O>100){var j=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+E.join(", "));throw j.values=E,j.vectors=[],j}var U=h?a(L,function(e,t){for(var n=[],r=0;ra(m,e))),T.push(...c.map((e=>r(e))))},$=0;${var{typed:t,add:n,divide:r}=e;return t(V0,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){try{var a=Vq(e,t,n),i=Array.isArray(e)?eq(e):e.size();return r(a,i[t])}catch(e){throw xJ(e,"mean")}},"...":function(e){if(Uq(e))throw new TypeError("Scalar values expected in function mean");return a(e)}});function a(e){var t,a=0;if(qq(e,(function(e){try{t=void 0===t?e:n(t,e),a++}catch(t){throw xJ(t,"mean",e)}})),0===a)throw new Error("Cannot calculate the mean of an empty array");return r(t,a)}})),K0="setSymDifference",J0=RH(K0,["typed","size","concat","subset","setDifference","Index"],(e=>{var{typed:t,size:n,concat:r,subset:a,setDifference:i,Index:s}=e;return t(K0,{"Array | Matrix, Array | Matrix":function(e,t){if(0===a(n(e),new s(0)))return hq(t);if(0===a(n(t),new s(0)))return hq(e);var o=hq(e),u=hq(t);return r(i(o,u),i(u,o))}})}));function X0(e,t){var n,r=t.length,a=[];if(e)for(n=0;n{var{typed:t,matrix:n,lup:r,slu:a,usolve:i,lsolve:s,DenseMatrix:o}=e,u=FX({DenseMatrix:o});return t(Z0,{"Array, Array | Matrix":function(e,t){e=n(e);var a=r(e);return c(a.L,a.U,a.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var n=r(e);return c(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var n=r(e);return c(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,n,r){var i=a(e,n,r);return c(i.L,i.U,i.p,i.q,t)},"Object, Array | Matrix":function(e,t){return c(e.L,e.U,e.p,e.q,t)}});function l(e){if(HP(e))return e;if(PP(e))return n(e);throw new TypeError("Invalid Matrix LU decomposition")}function c(e,t,n,r,a){e=l(e),t=l(t),n&&((a=u(e,a,!0))._data=X0(n,a._data));var o=s(e,a),c=i(t,o);return r&&(c._data=X0(r,c._data)),c}})),t1="median",n1=["typed","add","divide","compare","partitionSelect"],r1=RH(t1,n1,(e=>{var{typed:t,add:n,divide:r,compare:a,partitionSelect:i}=e;function s(e){try{var t=(e=hq(e.valueOf())).length;if(0===t)throw new Error("Cannot calculate median of an empty array");if(t%2==0){for(var n=t/2-1,r=i(e,n+1),s=e[n],l=0;l0&&(s=e[l]);return u(s,r)}var c=i(e,(t-1)/2);return o(c)}catch(e){throw xJ(e,"median")}}var o=t({"number | BigNumber | Complex | Unit":function(e){return e}}),u=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return r(n(e,t),2)}});return t(t1,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(Uq(e))throw new TypeError("Scalar values expected in function median");return s(e)}})})),a1="setUnion",i1=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],s1=RH(a1,i1,(e=>{var{typed:t,size:n,concat:r,subset:a,setIntersect:i,setSymDifference:s,Index:o}=e;return t(a1,{"Array | Matrix, Array | Matrix":function(e,t){if(0===a(n(e),new o(0)))return hq(t);if(0===a(n(t),new o(0)))return hq(e);var u=hq(e),l=hq(t);return r(s(u,l),i(u,l))}})})),o1="unbiased",u1="variance",l1=["typed","add","subtract","multiply","divide","apply","isNaN"],c1=RH(u1,l1,(e=>{var{typed:t,add:n,subtract:r,multiply:a,divide:i,apply:s,isNaN:o}=e;return t(u1,{"Array | Matrix":function(e){return u(e,o1)},"Array | Matrix, string":u,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,o1)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return u(e,o1)}});function u(e,t){var s,u=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(qq(e,(function(e){try{s=void 0===s?e:n(s,e),u++}catch(t){throw xJ(t,"variance",e)}})),0===u)throw new Error("Cannot calculate variance of an empty array");var l=i(s,u);if(s=void 0,qq(e,(function(e){var t=r(e,l);s=void 0===s?a(t,t):n(s,a(t,t))})),o(s))return s;switch(t){case"uncorrected":return i(s,u);case"biased":return i(s,u+1);case"unbiased":var c=RP(s)?s.mul(0):0;return 1===u?c:i(s,u-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function l(e,t,n){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(e,t,(e=>u(e,n)))}catch(e){throw xJ(e,"variance")}}})),p1="kldivergence",d1=["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],h1=RH(p1,d1,(e=>{var{typed:t,matrix:n,divide:r,sum:a,multiply:i,dotDivide:s,log:o,isNumeric:u}=e;return t(p1,{"Array, Array":function(e,t){return l(n(e),n(t))},"Matrix, Array":function(e,t){return l(e,n(t))},"Array, Matrix":function(e,t){return l(n(e),t)},"Matrix, Matrix":function(e,t){return l(e,t)}});function l(e,t){var n=t.size().length,l=e.size().length;if(n>1)throw new Error("first object must be one dimensional");if(l>1)throw new Error("second object must be one dimensional");if(n!==l)throw new Error("Length of two vectors must be equal");if(0===a(e))throw new Error("Sum of elements in first object must be non zero");if(0===a(t))throw new Error("Sum of elements in second object must be non zero");var c=r(e,a(e)),p=r(t,a(t)),d=a(i(c,o(s(c,p))));return u(d)?d:Number.NaN}})),f1="norm",m1=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],g1=RH(f1,m1,(e=>{var{typed:t,abs:n,add:r,pow:a,conj:i,sqrt:s,multiply:o,equalScalar:u,larger:l,smaller:c,matrix:p,ctranspose:d,eigs:h}=e;return t(f1,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return f(p(e),2)},Matrix:function(e){return f(e,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(e){return this(e)},"Array, number | BigNumber | string":function(e,t){return f(p(e),t)},"Matrix, number | BigNumber | string":function(e,t){return f(e,t)}});function f(e,t){var p=e.size();if(1===p.length)return function(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=0;return e.forEach((function(e){var r=n(e);l(r,t)&&(t=r)}),!0),t}(e);if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return function(e){var t;return e.forEach((function(e){var r=n(e);t&&!c(r,t)||(t=r)}),!0),t||0}(e);if("fro"===t)return f(e,2);if("number"==typeof t&&!isNaN(t)){if(!u(t,0)){var i=0;return e.forEach((function(e){i=r(a(n(e),t),i)}),!0),a(i,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}(e,t);if(2===p.length){if(p[0]&&p[1])return function(e,t){if(1===t)return function(e){var t=[],a=0;return e.forEach((function(e,i){var s=i[1],o=r(t[s]||0,n(e));l(o,a)&&(a=o),t[s]=o}),!0),a}(e);if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=[],a=0;return e.forEach((function(e,i){var s=i[0],o=r(t[s]||0,n(e));l(o,a)&&(a=o),t[s]=o}),!0),a}(e);if("fro"===t)return function(e){var t=0;return e.forEach((function(e,n){t=r(t,o(e,i(e)))})),n(s(t))}(e);if(2===t)return function(e){var t=e.size();if(t[0]!==t[1])throw new RangeError("Invalid matrix dimensions");var r=d(e),a=o(r,e),i=h(a).values.toArray(),u=i[i.length-1];return n(s(u))}(e);throw new Error("Unsupported parameter value "+t)}(e,t);throw new RangeError("Invalid matrix dimensions")}}})),y1="rotationMatrix",b1=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],x1=RH(y1,b1,(e=>{var{typed:t,config:n,multiplyScalar:r,addScalar:a,unaryMinus:i,norm:s,BigNumber:o,matrix:u,DenseMatrix:l,SparseMatrix:c,cos:p,sin:d}=e;return t(y1,{"":function(){return"Matrix"===n.matrix?u([]):[]},string:function(e){return u(e)},"number | BigNumber | Complex | Unit":function(e){return h(e,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return h(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var n=u(t);return f(n),y(e,n,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){f(t);var r=t.storage()||("Matrix"===n.matrix?"dense":void 0);return y(e,t,r)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,n){var r=u(t);return f(r),y(e,r,n)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,n){return f(t),y(e,t,n)}});function h(e,t){var n=RP(e)?new o(-1):-1,a=p(e),i=d(e);return g([[a,r(n,i)],[i,a]],t)}function f(e){var t=e.size();if(t.length<1||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3")}function m(e){return e.reduce(((e,t)=>r(e,t)))}function g(e,t){if(t){if("sparse"===t)return new c(e);if("dense"===t)return new l(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function y(e,t,n){var r=s(t);if(0===r)throw new RangeError("Rotation around zero vector");var u=RP(e)?o:null,l=u?new u(1):1,c=u?new u(-1):-1,h=u?new u(t.get([0])/r):t.get([0])/r,f=u?new u(t.get([1])/r):t.get([1])/r,y=u?new u(t.get([2])/r):t.get([2])/r,b=p(e),x=a(l,i(b)),v=d(e);return g([[a(b,m([h,h,x])),a(m([h,f,x]),m([c,y,v])),a(m([h,y,x]),m([f,v]))],[a(m([h,f,x]),m([y,v])),a(b,m([f,f,x])),a(m([f,y,x]),m([c,h,v]))],[a(m([h,y,x]),m([c,f,v])),a(m([f,y,x]),m([h,v])),a(b,m([y,y,x]))]],n)}})),v1=["typed","sqrt","variance"],_1=RH("std",v1,(e=>{var{typed:t,sqrt:n,variance:r}=e;return t("std",{"Array | Matrix":a,"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":a,"Array | Matrix, number | BigNumber, string":a,"...":function(e){return a(e)}});function a(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return n(r.apply(null,arguments))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),w1=["typed","abs","map","median","subtract"],M1=RH("mad",w1,(e=>{var{typed:t,abs:n,map:r,median:a,subtract:i}=e;return t("mad",{"Array | Matrix":s,"...":function(e){return s(e)}});function s(e){if(0===(e=hq(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=a(e);return a(r(e,(function(e){return n(i(e,t))})))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):xJ(e,"mad")}}})),N1="rotate",S1=["typed","multiply","rotationMatrix"],k1=RH(N1,S1,(e=>{var{typed:t,multiply:n,rotationMatrix:r}=e;return t(N1,{"Array , number | BigNumber | Complex | Unit":function(e,t){return a(e,2),n(r(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return a(e,2),n(r(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,i){return a(e,3),n(r(t,i),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,i){return a(e,3),n(r(t,i),e)}});function a(e,t){var n=Array.isArray(e)?eq(e):e.size();if(n.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(t));if(2===n.length&&1!==n[1])throw new RangeError("Vector must be of dimensions 1x".concat(t));if(n[0]!==t)throw new RangeError("Vector must be of dimensions 1x".concat(t))}})),D1=zH({config:$H}),T1=lj({}),I1=Tj({BigNumber:D1,config:$H}),E1=wj({}),C1=sU({BigNumber:D1,config:$H}),A1=BU({}),L1=Rj({Complex:T1}),$1=Nj({BigNumber:D1,config:$H}),O1=Cj({BigNumber:D1,config:$H}),R1=Lj({BigNumber:D1,config:$H}),F1=PU({}),Y1=Sj({BigNumber:D1,config:$H}),z1=Mj({}),B1=Ij({BigNumber:D1,config:$H}),P1=HU({}),H1=jU({}),j1=$j({BigNumber:D1,config:$H}),U1=SU({BigNumber:D1,config:$H}),q1=Dj({BigNumber:D1,config:$H}),W1=_j({}),V1=zj({}),G1=Mq({Matrix:F1}),K1=mU({BigNumber:D1,config:$H}),J1=Ej({BigNumber:D1,config:$H}),X1=kj({BigNumber:D1,config:$H}),Z1=Nq({}),Q1=Oj({BigNumber:D1,config:$H}),e2=zq({BigNumber:D1,Complex:T1,DenseMatrix:G1,Fraction:A1}),t2=xW({BigNumber:D1,config:$H,typed:e2}),n2=fU({BigNumber:D1,config:$H}),r2=vW({typed:e2}),a2=wW({Complex:T1,config:$H,typed:e2}),i2=PW({BigNumber:D1,typed:e2}),s2=jW({BigNumber:D1,Complex:T1,config:$H,typed:e2}),o2=qW({typed:e2}),u2=WW({typed:e2}),l2=GW({BigNumber:D1,Complex:T1,config:$H,typed:e2}),c2=KW({typed:e2}),p2=JW({typed:e2}),d2=ZW({Complex:T1,config:$H,typed:e2}),h2=QW({BigNumber:D1,typed:e2}),f2=yV({typed:e2}),m2=xV({typed:e2}),g2=_V({typed:e2}),y2=SV({typed:e2}),b2=DV({Complex:T1,typed:e2}),x2=IV({typed:e2}),v2=CV({typed:e2}),_2=LV({BigNumber:D1,typed:e2}),w2=$V({BigNumber:D1,typed:e2}),M2=RV({typed:e2}),N2=zV({config:$H,typed:e2}),S2=BV({typed:e2}),k2=WV({typed:e2}),D2=GV({Complex:T1,typed:e2}),T2=KV({typed:e2}),I2=ZV({typed:e2}),E2=tG({typed:e2}),C2=rG({typed:e2}),A2=aG({format:E2,typed:e2}),L2=iG({typed:e2}),$2=oG({typed:e2}),O2=fG({typed:e2}),R2=gG({typed:e2}),F2=bG({typed:e2}),Y2=Aj({BigNumber:D1,config:$H}),z2=kG({Complex:T1,typed:e2}),B2=TG({Complex:T1,config:$H,typed:e2}),P2=EG({Complex:T1,config:$H,typed:e2}),H2=CG({typed:e2}),j2=LG({typed:e2}),U2=zG({typed:e2}),q2=BG({typed:e2}),W2=PG({format:E2,typed:e2}),V2=WG({config:$H,typed:e2}),G2=GG({typed:e2}),K2=ZG({config:$H,typed:e2}),J2=QG({typed:e2}),X2=eK({BigNumber:D1,typed:e2}),Z2=nK({BigNumber:D1,Fraction:A1,complex:b2,typed:e2}),Q2=rK({typed:e2}),e3=aK({Matrix:F1,equalScalar:N2,typed:e2}),t3=sK({typed:e2}),n3=uK({typed:e2}),r3=cK({typed:e2}),a3=pK({typed:e2}),i3=hK({typed:e2}),s3=mK({Complex:T1,config:$H,typed:e2}),o3=yK({BigNumber:D1,typed:e2}),u3=xK({isInteger:$2,typed:e2}),l3=wK({BigNumber:D1,Complex:T1,config:$H,typed:e2}),c3=MK({format:E2,typed:e2}),p3=SK({typed:e2}),d3=DK({typed:e2}),h3=IK({BigNumber:D1,typed:e2}),f3=CK({typed:e2}),m3=LK({typed:e2}),g3=OK({config:$H,typed:e2}),y3=FK({BigNumber:D1,typed:e2}),b3=zK({typed:e2}),x3=PK({SparseMatrix:e3,typed:e2}),v3=HK({Complex:T1,config:$H,typed:e2}),_3=jK({typed:e2}),w3=qK({typed:e2}),M3=VK({BigNumber:D1,Complex:T1,config:$H,typed:e2}),N3=GK({BigNumber:D1,typed:e2}),S3=KK({Fraction:A1,typed:e2}),k3=XK({typed:e2}),D3=QK({DenseMatrix:G1,Matrix:F1,SparseMatrix:e3,typed:e2}),T3=tJ({isZero:F2,matrix:D3,typed:e2}),I3=lJ({DenseMatrix:G1,equalScalar:N2,matrix:D3,typed:e2}),E3=hJ({BigNumber:D1,equalScalar:N2,matrix:D3,typed:e2}),C3=yJ({bignumber:h2,fraction:S3,number:q2}),A3=bJ({DenseMatrix:G1,equalScalar:N2,matrix:D3,typed:e2}),L3=_J({config:$H,multiplyScalar:j2,numeric:C3,typed:e2}),$3=MJ({isInteger:$2,matrix:D3,typed:e2}),O3=SJ({matrix:D3,config:$H,typed:e2}),R3=TJ({DenseMatrix:G1,config:$H,matrix:D3,typed:e2}),F3=EJ({matrix:D3,typed:e2}),Y3=AJ({matrix:D3,typed:e2}),z3=zJ({DenseMatrix:G1,addScalar:o2,equalScalar:N2,matrix:D3,typed:e2,unaryMinus:w3}),B3=PJ({matrix:D3,typed:e2}),P3=HJ({matrix:D3,typed:e2}),H3=UJ({BigNumber:D1,config:$H,matrix:D3,typed:e2}),j3=WJ({BigNumber:D1,config:$H,matrix:D3,typed:e2}),U3=VJ({equalScalar:N2,matrix:D3,not:U2,typed:e2,zeros:j3}),q3=KJ({equalScalar:N2,matrix:D3,typed:e2}),W3=XJ({DenseMatrix:G1,matrix:D3,typed:e2}),V3=QJ({BigNumber:D1,Complex:T1,Fraction:A1,config:$H,isNegative:O2,matrix:D3,typed:e2,unaryMinus:w3}),G3=tX({BigNumber:D1,DenseMatrix:G1,Fraction:A1,config:$H,equalScalar:N2,matrix:D3,typed:e2}),K3=rX({matrix:D3,typed:e2}),J3=iX({isInteger:$2,matrix:D3,typed:e2}),X3=uX({prod:L3,size:O3,typed:e2}),Z3=cX({conj:x2,transpose:P3,typed:e2}),Q3=dX({DenseMatrix:G1,SparseMatrix:e3,matrix:D3,typed:e2}),e4=fX({numeric:C3,typed:e2}),t4=gX({DenseMatrix:G1,divideScalar:e4,equalScalar:N2,matrix:D3,typed:e2}),n4=bX({DenseMatrix:G1,equalScalar:N2,matrix:D3,typed:e2}),r4=xX({addScalar:o2,divideScalar:e4,exp:k2,i:L1,matrix:D3,multiplyScalar:j2,tau:q1,typed:e2}),a4=_X({matrix:D3,typed:e2}),i4=MX({BigNumber:D1,DenseMatrix:G1,equalScalar:N2,matrix:D3,typed:e2}),s4=SX({isNumeric:k3,typed:e2}),o4=DX({abs:r2,addScalar:o2,divideScalar:e4,isPositive:R2,multiplyScalar:j2,smaller:R3,sqrt:v3,typed:e2}),u4=IX({conj:x2,dotDivide:t4,fft:r4,typed:e2}),l4=CX({matrix:D3,multiplyScalar:j2,typed:e2}),c4=LX({DenseMatrix:G1,config:$H,matrix:D3,typed:e2}),p4=RX({DenseMatrix:G1,equalScalar:N2,matrix:D3,typed:e2,zeros:j3}),d4=zX({DenseMatrix:G1,divideScalar:e4,equalScalar:N2,matrix:D3,multiplyScalar:j2,subtract:z3,typed:e2}),h4=PX({flatten:a4,matrix:D3,size:O3,typed:e2}),f4=HX({config:$H,numeric:C3,smaller:R3,typed:e2}),m4=UX({isNaN:f3,isNumeric:k3,typed:e2}),g4=WX({Complex:T1,config:$H,divideScalar:e4,typed:e2}),y4=VX({BigNumber:D1,config:$H,matrix:D3,typed:e2}),b4=KX({compare:G3,isNaN:f3,isNumeric:k3,typed:e2}),x4=XX({config:$H,matrix:D3}),v4=QX({DenseMatrix:G1,equalScalar:N2,matrix:D3,typed:e2,zeros:j3}),_4=nZ({BigNumber:D1,DenseMatrix:G1,equalScalar:N2,matrix:D3,typed:e2,zeros:j3}),w4=aZ({DenseMatrix:G1,config:$H,matrix:D3,typed:e2}),M4=sZ({DenseMatrix:G1,config:$H,equalScalar:N2,matrix:D3,typed:e2}),N4=uZ({DenseMatrix:G1,divideScalar:e4,equalScalar:N2,matrix:D3,multiplyScalar:j2,subtract:z3,typed:e2}),S4=lZ({DenseMatrix:G1,matrix:D3,typed:e2}),k4=cZ({DenseMatrix:G1,SparseMatrix:e3,addScalar:o2,equalScalar:N2,matrix:D3,typed:e2}),D4=hZ({BigNumber:D1,DenseMatrix:G1,equalScalar:N2,matrix:D3,typed:e2}),T4=mZ({DenseMatrix:G1,equalScalar:N2,matrix:D3,typed:e2}),I4=yZ({addScalar:o2,combinations:y2,divideScalar:e4,isInteger:$2,isNegative:O2,multiplyScalar:j2,typed:e2}),E4=vZ({compare:G3,typed:e2}),C4=wZ({add:k4,typed:e2,unaryPlus:t2}),A4=NZ({equal:n4,typed:e2}),L4=kZ({matrix:D3,number:q2,subtract:z3,typed:e2}),$4=DZ({addScalar:o2,conj:x2,multiplyScalar:j2,size:O3,typed:e2}),O4=IZ({compareText:K3,isZero:F2,typed:e2}),R4=LZ({DenseMatrix:G1,config:$H,equalScalar:N2,matrix:D3,round:_4,typed:e2,zeros:j3}),F4=OZ({BigNumber:D1,DenseMatrix:G1,SparseMatrix:e3,config:$H,matrix:D3,typed:e2}),Y4=FZ({BigNumber:D1,add:k4,config:$H,equal:n4,isInteger:$2,mod:I3,smaller:R3,typed:e2,xgcd:H3}),z4=zZ({DenseMatrix:G1,config:$H,matrix:D3,typed:e2}),B4=BZ({Complex:T1,config:$H,divideScalar:e4,typed:e2}),P4=HZ({DenseMatrix:G1,divideScalar:e4,equalScalar:N2,matrix:D3,multiplyScalar:j2,subtract:z3,typed:e2}),H4=UZ({flatten:a4,matrix:D3,size:O3,typed:e2}),j4=WZ({addScalar:o2,dot:$4,equalScalar:N2,matrix:D3,multiplyScalar:j2,typed:e2}),U4=VZ({addScalar:o2,complex:b2,conj:x2,divideScalar:e4,equal:n4,identity:F4,isZero:F2,matrix:D3,multiplyScalar:j2,sign:Z2,sqrt:v3,subtract:z3,typed:e2,unaryMinus:w3,zeros:j3}),q4=KZ({bignumber:h2,matrix:D3,config:$H,larger:z4,largerEq:c4,smaller:R3,smallerEq:w4,typed:e2}),W4=XZ({DenseMatrix:G1,equalScalar:N2,matrix:D3,typed:e2,zeros:j3}),V4=QZ({compareNatural:E4,typed:e2}),G4=dQ({SparseMatrix:e3,abs:r2,add:k4,divideScalar:e4,larger:z4,largerEq:c4,multiply:j4,subtract:z3,transpose:P3,typed:e2}),K4=hQ({add:k4,config:$H,numeric:C3,typed:e2}),J4=fQ({add:k4,matrix:D3,typed:e2}),X4=gQ({DenseMatrix:G1,divideScalar:e4,equalScalar:N2,matrix:D3,multiplyScalar:j2,subtract:z3,typed:e2}),Z4=bQ({Complex:T1,config:$H,typed:e2}),Q4=wQ({DenseMatrix:G1,config:$H,equalScalar:N2,matrix:D3,round:_4,typed:e2,zeros:j3}),e5=NQ({addScalar:o2,combinations:y2,isInteger:$2,isNegative:O2,isPositive:R2,larger:z4,typed:e2}),t5=kQ({matrix:D3,multiply:j4,subtract:z3,typed:e2}),n5=DQ({divideScalar:e4,isZero:F2,matrix:D3,multiply:j4,subtract:z3,typed:e2,unaryMinus:w3}),r5=IQ({abs:r2,addScalar:o2,divideScalar:e4,multiplyScalar:j2,sqrt:v3,subtract:z3,typed:e2,unaryMinus:w3}),a5=CQ({equalScalar:N2,matrix:D3,multiplyScalar:j2,typed:e2}),i5=AQ({larger:z4,smaller:R3}),s5=RQ({Complex:T1,DenseMatrix:G1,ceil:Q4,equalScalar:N2,floor:R4,matrix:D3,typed:e2,zeros:j3}),o5=FQ({DenseMatrix:G1,smaller:R3}),u5=YQ({ImmutableDenseMatrix:o5}),l5=zQ({abs:r2,add:k4,addScalar:o2,config:$H,divideScalar:e4,equalScalar:N2,flatten:a4,isNumeric:k3,isZero:F2,matrix:D3,multiply:j4,multiplyScalar:j2,smaller:R3,subtract:z3,typed:e2}),c5=BQ({equalScalar:N2,matrix:D3,typed:e2}),d5=HQ({Complex:T1,config:$H,divideScalar:e4,log:B4,typed:e2}),h5=jQ({config:$H,larger:z4,numeric:C3,typed:e2}),f5=UQ({add:k4,compare:G3,multiply:j4,partitionSelect:b4,typed:e2}),m5=qQ({Index:u5,matrix:D3,range:q4,typed:e2}),g5=VQ({DenseMatrix:G1,Index:u5,compareNatural:E4,size:O3,subset:Y3,typed:e2}),y5=KQ({DenseMatrix:G1,Index:u5,compareNatural:E4,size:O3,subset:Y3,typed:e2}),b5=XQ({Index:u5,compareNatural:E4,size:O3,subset:Y3,typed:e2}),x5=QQ({Index:u5,compareNatural:E4,size:O3,subset:Y3,typed:e2}),v5=t0({compare:G3,compareNatural:E4,matrix:D3,typed:e2}),_5=r0({Index:u5,matrix:D3,range:q4,typed:e2}),w5=i0({Index:u5,typed:e2}),M5=s0({abs:r2,addScalar:o2,det:n5,divideScalar:e4,identity:F4,matrix:D3,multiply:j4,typed:e2,unaryMinus:w3}),N5=u0({Complex:T1,add:k4,ctranspose:Z3,deepEqual:A4,divideScalar:e4,dot:$4,dotDivide:t4,equal:n4,inv:M5,matrix:D3,multiply:j4,typed:e2}),S5=l0({Complex:T1,config:$H,fraction:S3,identity:F4,inv:M5,matrix:D3,multiply:j4,number:q2,typed:e2}),k5=p0({DenseMatrix:G1,Index:u5,compareNatural:E4,size:O3,subset:Y3,typed:e2}),D5=h0({Index:u5,compareNatural:E4,size:O3,subset:Y3,typed:e2}),T5=f0({FibonacciHeap:i5,addScalar:o2,equalScalar:N2}),I5=g0({abs:r2,add:k4,identity:F4,inv:M5,max:h5,multiply:j4,size:O3,sqrt:v3,subtract:z3,typed:e2}),E5=v0({BigNumber:D1,Complex:T1,Fraction:A1,abs:r2,addScalar:o2,config:$H,divideScalar:e4,equal:n4,fix:s5,format:E2,isNumeric:k3,multiplyScalar:j2,number:q2,pow:S5,round:_4,subtract:z3}),C5=Vj({BigNumber:D1,Unit:E5,config:$H}),A5=TU({BigNumber:D1,Unit:E5,config:$H}),L5=gU({BigNumber:D1,Unit:E5,config:$H}),$5=Jj({BigNumber:D1,Unit:E5,config:$H}),O5=bU({BigNumber:D1,Unit:E5,config:$H}),R5=Xj({BigNumber:D1,Unit:E5,config:$H}),F5=w0({Unit:E5,typed:e2}),Y5=lU({BigNumber:D1,Unit:E5,config:$H}),z5=N0({DenseMatrix:G1,equalScalar:N2,matrix:D3,pow:S5,typed:e2}),B5=Wj({BigNumber:D1,Unit:E5,config:$H}),P5=Kj({BigNumber:D1,Unit:E5,config:$H}),H5=k0({abs:r2,add:k4,identity:F4,inv:M5,multiply:j4,typed:e2}),j5=xU({BigNumber:D1,Unit:E5,config:$H}),U5=vU({BigNumber:D1,Unit:E5,config:$H}),q5=T0({BigNumber:D1,Complex:T1,config:$H,multiplyScalar:j2,pow:S5,typed:e2}),W5=Hj({BigNumber:D1,Unit:E5,config:$H}),V5=oU({BigNumber:D1,Unit:E5,config:$H}),G5=tU({BigNumber:D1,Unit:E5,config:$H}),K5=_U({BigNumber:D1,Unit:E5,config:$H}),J5=qj({BigNumber:D1,Unit:E5,config:$H}),X5=IU({BigNumber:D1,Unit:E5,config:$H}),Z5=MU({BigNumber:D1,Unit:E5,config:$H}),Q5=cU({BigNumber:D1,Unit:E5,config:$H}),e6=eU({BigNumber:D1,Unit:E5,config:$H}),t6=OU({BigNumber:D1,Unit:E5,config:$H}),n6=AU({BigNumber:D1,Unit:E5,config:$H}),r6=RU({BigNumber:D1,Unit:E5,config:$H}),a6=uU({BigNumber:D1,Unit:E5,config:$H}),i6=Uj({BigNumber:D1,Unit:E5,config:$H}),s6=dU({BigNumber:D1,Unit:E5,config:$H}),o6=E0({DenseMatrix:G1,Index:u5,compareNatural:E4,size:O3,subset:Y3,typed:e2}),u6=Pj({BigNumber:D1,Unit:E5,config:$H}),l6=DU({BigNumber:D1,Unit:E5,config:$H}),c6=hU({BigNumber:D1,Unit:E5,config:$H}),p6=yU({BigNumber:D1,Unit:E5,config:$H}),d6=nU({BigNumber:D1,Unit:E5,config:$H}),h6=Gj({BigNumber:D1,Unit:E5,config:$H}),f6=C0({divideScalar:e4,equalScalar:N2,inv:M5,matrix:D3,multiply:j4,typed:e2}),m6=aU({BigNumber:D1,Unit:E5,config:$H}),g6=L0({gamma:q5,typed:e2}),y6=CU({BigNumber:D1,Unit:E5,config:$H}),b6=Zj({BigNumber:D1,Unit:E5,config:$H}),x6=$0({DenseMatrix:G1,Spa:T5,SparseMatrix:e3,abs:r2,addScalar:o2,divideScalar:e4,equalScalar:N2,larger:z4,matrix:D3,multiplyScalar:j2,subtract:z3,typed:e2,unaryMinus:w3}),v6=Qj({BigNumber:D1,Unit:E5,config:$H}),_6=EU({BigNumber:D1,Unit:E5,config:$H}),w6=R0({add:k4,divide:f6,factorial:g6,isInteger:$2,isPositive:R2,multiply:j4,typed:e2}),M6=Y0({factorial:g6,typed:e2}),N6=LU({BigNumber:D1,Unit:E5,config:$H}),S6=pU({BigNumber:D1,Unit:E5,config:$H}),k6=kU({BigNumber:D1,Unit:E5,config:$H}),D6=P0({bignumber:h2,addScalar:o2,combinations:y2,divideScalar:e4,factorial:g6,isInteger:$2,isNegative:O2,larger:z4,multiplyScalar:j2,number:q2,pow:S5,subtract:z3,typed:e2}),T6=j0({Unit:E5,typed:e2}),I6=q0({addScalar:o2,isInteger:$2,isNegative:O2,stirlingS2:D6,typed:e2}),E6=W0({abs:r2,add:k4,addScalar:o2,atan:p2,bignumber:h2,column:_5,complex:b2,config:$H,cos:d3,diag:Q3,divideScalar:e4,dot:$4,equal:n4,flatten:a4,im:L2,inv:M5,larger:z4,matrix:D3,matrixFromColumns:h4,multiply:j4,multiplyScalar:j2,number:q2,qr:U4,re:J2,sin:Q2,smaller:R3,sqrt:v3,subtract:z3,typed:e2,usolve:N4,usolveAll:X4}),C6=iU({BigNumber:D1,Unit:E5,config:$H}),A6=G0({add:k4,divide:f6,typed:e2}),L6=NU({BigNumber:D1,Unit:E5,config:$H}),$6=jj({BigNumber:D1,Unit:E5,config:$H}),O6=J0({Index:u5,concat:J3,setDifference:k5,size:O3,subset:Y3,typed:e2}),R6=rU({BigNumber:D1,Unit:E5,config:$H}),F6=e1({DenseMatrix:G1,lsolve:d4,lup:x6,matrix:D3,slu:G4,typed:e2,usolve:N4}),Y6=r1({add:k4,compare:G3,divide:f6,partitionSelect:b4,typed:e2}),z6=s1({Index:u5,concat:J3,setIntersect:o6,setSymDifference:O6,size:O3,subset:Y3,typed:e2}),B6=c1({add:k4,apply:u3,divide:f6,isNaN:f3,multiply:j4,subtract:z3,typed:e2}),P6=h1({divide:f6,dotDivide:t4,isNumeric:k3,log:B4,matrix:D3,multiply:j4,sum:K4,typed:e2}),H6=g1({abs:r2,add:k4,conj:x2,ctranspose:Z3,eigs:E6,equalScalar:N2,larger:z4,matrix:D3,multiply:j4,pow:S5,smaller:R3,sqrt:v3,typed:e2}),j6=$U({BigNumber:D1,Unit:E5,config:$H}),U6=x1({BigNumber:D1,DenseMatrix:G1,SparseMatrix:e3,addScalar:o2,config:$H,cos:d3,matrix:D3,multiplyScalar:j2,norm:H6,sin:Q2,typed:e2,unaryMinus:w3}),q6=wU({BigNumber:D1,Unit:E5,config:$H}),W6=_1({sqrt:v3,typed:e2,variance:B6}),V6=M1({abs:r2,map:H2,median:Y6,subtract:z3,typed:e2}),G6=k1({multiply:j4,rotationMatrix:U6,typed:e2}),K6=RH("Chain",["?on","math"],(e=>{var{on:t,math:n}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");bH(e)?this.value=e.value:this.value=e}function a(e,t){DH(r.prototype,e,(function(){var e=t();if("function"==typeof e)return i(e)}))}function i(e){return function(){for(var t=[this.value],n=0;ne[t]))};for(var o in e)n(o)}var u,l};var s={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return r.createProxy(n),t&&t("import",(function(e,t,n){n||a(e,t)})),r}),{isClass:!0}),J6=new Set(["end"]),X6=RH("Node",["mathWithTransform"],(e=>{var{mathWithTransform:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator")}return n.prototype.evaluate=function(e){return this.compile().evaluate(e)},n.prototype.type="Node",n.prototype.isNode=!0,n.prototype.comment="",n.prototype.compile=function(){var e=this._compile(t,{}),n={};return{evaluate:function(t){var r=Oq(t);return function(e){for(var t of[...J6])if(e.has(t))throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword')}(r),e(r,n,null)}}},n.prototype._compile=function(e,t){throw new Error("Method _compile should be implemented by type "+this.type)},n.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},n.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},n.prototype._ifNode=function(e){if(!dH(e))throw new TypeError("Callback function must return a Node");return e},n.prototype.traverse=function(e){e(this,null,null),function e(t,n){t.forEach((function(t,r,a){n(t,r,a),e(t,n)}))}(this,e)},n.prototype.transform=function(e){return function t(n,r,a){var i=e(n,r,a);return i!==n?i:n.map(t)}(this,null,null)},n.prototype.filter=function(e){var t=[];return this.traverse((function(n,r,a){e(n,r,a)&&t.push(n)})),t},n.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},n.prototype.cloneDeep=function(){return this.map((function(e){return e.cloneDeep()}))},n.prototype.equals=function(e){return!!e&&NH(this,e)},n.prototype.toString=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)},n.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},n.prototype.toHTML=function(e){var t=this._getCustomString(e);return void 0!==t?t:this.toHTML(e)},n.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},n.prototype.toTex=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)},n.prototype._toTex=function(e){throw new Error("_toTex not implemented for "+this.type)},n.prototype._getCustomString=function(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}},n.prototype.getIdentifier=function(){return this.type},n.prototype.getContent=function(){return this},n}),{isClass:!0,isNode:!0}),Z6=RH("ObjectNode",["Node"],(e=>{var{Node:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(t){return dH(e[t])}))))throw new TypeError("Object containing Nodes expected")}return n.prototype=new t,n.prototype.type="ObjectNode",n.prototype.isObjectNode=!0,n.prototype._compile=function(e,t){var n={};for(var r in this.properties)if(TH(this.properties,r)){var a=GU(r),i=JSON.parse(a);if(!Tq(this.properties,i))throw new Error('No access to property "'+i+'"');n[i]=this.properties[r]._compile(e,t)}return function(e,t,r){var a={};for(var i in n)TH(n,i)&&(a[i]=n[i](e,t,r));return a}},n.prototype.forEach=function(e){for(var t in this.properties)TH(this.properties,t)&&e(this.properties[t],"properties["+GU(t)+"]",this)},n.prototype.map=function(e){var t={};for(var r in this.properties)TH(this.properties,r)&&(t[r]=this._ifNode(e(this.properties[r],"properties["+GU(r)+"]",this)));return new n(t)},n.prototype.clone=function(){var e={};for(var t in this.properties)TH(this.properties,t)&&(e[t]=this.properties[t]);return new n(e)},n.prototype._toString=function(e){var t=[];for(var n in this.properties)TH(this.properties,n)&&t.push(GU(n)+": "+this.properties[n].toString(e));return"{"+t.join(", ")+"}"},n.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},n.fromJSON=function(e){return new n(e.properties)},n.prototype.toHTML=function(e){var t=[];for(var n in this.properties)TH(this.properties,n)&&t.push(''+KU(n)+':'+this.properties[n].toHTML(e));return'{'+t.join(',')+'}'},n.prototype._toTex=function(e){var t=[];for(var n in this.properties)TH(this.properties,n)&&t.push("\\mathbf{"+n+":} & "+this.properties[n].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(t.join("\n"),"\\end{array}\\right\\}")},n}),{isClass:!0,isNode:!0}),Q6=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function e7(e,t){var n=e;"keep"!==t&&(n=e.getContent());for(var r=n.getIdentifier(),a=0;a>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},s7={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(i7.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(i7.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(i7.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(i7.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(i7.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(i7.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(i7.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(i7.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(i7.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(i7.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(i7.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(i7.bitAnd,"${args[1]}\\right)")},bitNot:{1:i7.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(i7.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(i7.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(i7.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(i7.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(i7.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(i7.and,"${args[1]}\\right)")},not:{1:i7.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(i7.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(i7.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(i7.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:"{${args[0]}}".concat(i7.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(i7.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(i7.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(i7.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(i7.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(i7.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(i7.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(i7.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(i7.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(i7.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(a7.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},o7={deg:"^\\circ"};function u7(e){return r7(e,{preserveFormatting:!0})}function l7(e,t){return(t=void 0!==t&&t)?TH(o7,e)?o7[e]:"\\mathrm{"+u7(e)+"}":TH(a7,e)?a7[e]:u7(e)}var c7=RH("OperatorNode",["Node"],(e=>{var{Node:t}=e;function n(e,t,r,a,i){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(r)||!r.every(dH))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===a,this.isPercentage=!0===i,this.op=e,this.fn=t,this.args=r||[]}function r(e,t,n,r,a){var i,s=e7(e,t),o=t7(e,t);if("all"===t||r.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return r.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(r.length){case 0:i=[];break;case 1:var u=e7(r[0],t);if(a&&null!==u){var l,c;if("keep"===t?(l=r[0].getIdentifier(),c=e.getIdentifier()):(l=r[0].getContent().getIdentifier(),c=e.getContent().getIdentifier()),!1===Q6[s][c].latexLeftParens){i=[!1];break}if(!1===Q6[u][l].latexParens){i=[!1];break}}if(null===u){i=[!1];break}if(u<=s){i=[!0];break}i=[!1];break;case 2:var p,d,h=e7(r[0],t),f=n7(e,r[0],t);p=null!==h&&(h===s&&"right"===o&&!f||h=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"auto"===t&&"hide"===n&&(i=r.map((function(e,t){var n="ParenthesisNode"===e.getIdentifier();return!(!i[t]&&!n)}))),i}return n.prototype=new t,n.prototype.type="OperatorNode",n.prototype.isOperatorNode=!0,n.prototype._compile=function(e,t){if("string"!=typeof this.fn||!Iq(e,this.fn))throw e[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var n=kq(e,this.fn),r=fq(this.args,(function(n){return n._compile(e,t)}));if(1===r.length){var a=r[0];return function(e,t,r){return n(a(e,t,r))}}if(2===r.length){var i=r[0],s=r[1];return function(e,t,r){return n(i(e,t,r),s(e,t,r))}}return function(e,t,a){return n.apply(null,fq(r,(function(n){return n(e,t,a)})))}},n.prototype.forEach=function(e){for(var t=0;t2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var p=a.map((function(t,n){return t=t.toString(e),i[n]&&(t="("+t+")"),t}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?p.join(" "):p.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"},n.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}},n.fromJSON=function(e){return new n(e.op,e.fn,e.args,e.implicit,e.isPercentage)},n.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=e&&e.implicit?e.implicit:"hide",a=this.args,i=r(this,t,n,a,!1);if(1===a.length){var s=t7(this,t),o=a[0].toHTML(e);return i[0]&&(o='('+o+')'),"right"===s?''+KU(this.op)+""+o:o+''+KU(this.op)+""}if(2===a.length){var u=a[0].toHTML(e),l=a[1].toHTML(e);return i[0]&&(u='('+u+')'),i[1]&&(l='('+l+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?u+''+l:u+''+KU(this.op)+""+l}var c=a.map((function(t,n){return t=t.toHTML(e),i[n]&&(t='('+t+')'),t}));return a.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?c.join(''):c.join(''+KU(this.op)+""):''+KU(this.fn)+'('+c.join(',')+')'},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=e&&e.implicit?e.implicit:"hide",a=this.args,i=r(this,t,n,a,!0),s=i7[this.fn];if(s=void 0===s?this.op:s,1===a.length){var o=t7(this,t),u=a[0].toTex(e);return i[0]&&(u="\\left(".concat(u,"\\right)")),"right"===o?s+u:u+s}if(2===a.length){var l=a[0],c=l.toTex(e);i[0]&&(c="\\left(".concat(c,"\\right)"));var p,d=a[1].toTex(e);switch(i[1]&&(d="\\left(".concat(d,"\\right)")),p="keep"===t?l.getIdentifier():l.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return s+"{"+c+"}{"+d+"}";case"OperatorNode:pow":switch(c="{"+c+"}",d="{"+d+"}",p){case"ConditionalNode":case"OperatorNode:divide":c="\\left(".concat(c,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===n)return c+"~"+d}return c+s+d}if(a.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var h=a.map((function(t,n){return t=t.toTex(e),i[n]&&(t="\\left(".concat(t,"\\right)")),t}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit?h.join("~"):h.join(s)}return"\\mathrm{"+this.fn+"}\\left("+a.map((function(t){return t.toTex(e)})).join(",")+"\\right)"},n.prototype.getIdentifier=function(){return this.type+":"+this.fn},n}),{isClass:!0,isNode:!0}),p7=RH("ParenthesisNode",["Node"],(e=>{var{Node:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!dH(e))throw new TypeError('Node expected for parameter "content"');this.content=e}return n.prototype=new t,n.prototype.type="ParenthesisNode",n.prototype.isParenthesisNode=!0,n.prototype._compile=function(e,t){return this.content._compile(e,t)},n.prototype.getContent=function(){return this.content.getContent()},n.prototype.forEach=function(e){e(this.content,"content",this)},n.prototype.map=function(e){return new n(e(this.content,"content",this))},n.prototype.clone=function(){return new n(this.content)},n.prototype._toString=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},n.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},n.fromJSON=function(e){return new n(e.content)},n.prototype.toHTML=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'('+this.content.toHTML(e)+')':this.content.toHTML(e)},n.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},n}),{isClass:!0,isNode:!0}),d7=RH("RelationalNode",["Node"],(e=>{var{Node:t}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return n.prototype=new t,n.prototype.type="RelationalNode",n.prototype.isRelationalNode=!0,n.prototype._compile=function(e,t){var n=this,r=this.params.map((n=>n._compile(e,t)));return function(t,a,i){for(var s,o=r[0](t,a,i),u=0;ue(t,"params["+n+"]",this)),this)},n.prototype.map=function(e){return new n(this.conditionals.slice(),this.params.map(((t,n)=>this._ifNode(e(t,"params["+n+"]",this))),this))},n.prototype.clone=function(){return new n(this.conditionals,this.params)},n.prototype._toString=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",n=e7(this,t),r=this.params.map((function(r,a){var i=e7(r,t);return"all"===t||null!==i&&i<=n?"("+r.toString(e)+")":r.toString(e)})),a={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},i=r[0],s=0;s('+r.toHTML(e)+')':r.toHTML(e)})),a={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},i=r[0],s=0;s'+KU(a[this.conditionals[s]])+""+r[s+1];return i},n.prototype._toTex=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",n=e7(this,t),r=this.params.map((function(r,a){var i=e7(r,t);return"all"===t||null!==i&&i<=n?"\\left("+r.toTex(e)+"\right)":r.toTex(e)})),a=r[0],i=0;i{var{Node:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(dH))throw new TypeError("Array containing Nodes expected")}return n.prototype=new t,n.prototype.type="ArrayNode",n.prototype.isArrayNode=!0,n.prototype._compile=function(e,t){var n=fq(this.items,(function(n){return n._compile(e,t)}));if("Array"!==e.config.matrix){var r=e.matrix;return function(e,t,a){return r(fq(n,(function(n){return n(e,t,a)})))}}return function(e,t,r){return fq(n,(function(n){return n(e,t,r)}))}},n.prototype.forEach=function(e){for(var t=0;t['+this.items.map((function(t){return t.toHTML(e)})).join(',')+']'},n.prototype._toTex=function(e){return function t(n,r){var a=n.some(aH)&&!n.every(aH),i=r||a,s=i?"&":"\\\\",o=n.map((function(n){return n.items?t(n.items,!r):n.toTex(e)})).join(s);return a||!i||i&&!r?"\\begin{bmatrix}"+o+"\\end{bmatrix}":o}(this.items,!1)},n}),{isClass:!0,isNode:!0}),f7=RH("BlockNode",["ResultSet","Node"],(e=>{var{ResultSet:t,Node:n}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map((function(e){var t=e&&e.node,n=!e||void 0===e.visible||e.visible;if(!dH(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof n)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:n}}))}return r.prototype=new n,r.prototype.type="BlockNode",r.prototype.isBlockNode=!0,r.prototype._compile=function(e,n){var r=fq(this.blocks,(function(t){return{evaluate:t.node._compile(e,n),visible:t.visible}}));return function(e,n,a){var i=[];return mq(r,(function(t){var r=t.evaluate(e,n,a);t.visible&&i.push(r)})),new t(i)}},r.prototype.forEach=function(e){for(var t=0;t;')})).join('
')},r.prototype._toTex=function(e){return this.blocks.map((function(t){return t.node.toTex(e)+(t.visible?"":";")})).join("\\;\\;\n")},r}),{isClass:!0,isNode:!0}),m7=RH("ConditionalNode",["Node"],(e=>{var{Node:t}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!dH(e))throw new TypeError("Parameter condition must be a Node");if(!dH(t))throw new TypeError("Parameter trueExpr must be a Node");if(!dH(r))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=r}return n.prototype=new t,n.prototype.type="ConditionalNode",n.prototype.isConditionalNode=!0,n.prototype._compile=function(e,t){var n=this.condition._compile(e,t),r=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,i){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(RP(e))return!e.isZero();if(FP(e))return!(!e.re&&!e.im);if(zP(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+xH(e)+'"')}(n(e,t,i))?r(e,t,i):a(e,t,i)}},n.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},n.prototype.map=function(e){return new n(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},n.prototype.clone=function(){return new n(this.condition,this.trueExpr,this.falseExpr)},n.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=e7(this,t),r=this.condition.toString(e),a=e7(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==a&&a<=n)&&(r="("+r+")");var i=this.trueExpr.toString(e),s=e7(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==s&&s<=n)&&(i="("+i+")");var o=this.falseExpr.toString(e),u=e7(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=n)&&(o="("+o+")"),r+" ? "+i+" : "+o},n.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},n.fromJSON=function(e){return new n(e.condition,e.trueExpr,e.falseExpr)},n.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=e7(this,t),r=this.condition.toHTML(e),a=e7(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==a&&a<=n)&&(r='('+r+')');var i=this.trueExpr.toHTML(e),s=e7(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==s&&s<=n)&&(i='('+i+')');var o=this.falseExpr.toHTML(e),u=e7(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=n)&&(o='('+o+')'),r+'?'+i+':'+o},n.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},n}),{isClass:!0,isNode:!0}),g7=RH("ConstantNode",["Node"],(e=>{var{Node:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return n.prototype=new t,n.prototype.type="ConstantNode",n.prototype.isConstantNode=!0,n.prototype._compile=function(e,t){var n=this.value;return function(){return n}},n.prototype.forEach=function(e){},n.prototype.map=function(e){return this.clone()},n.prototype.clone=function(){return new n(this.value)},n.prototype._toString=function(e){return VU(this.value,e)},n.prototype.toHTML=function(e){var t=this._toString(e);switch(xH(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}},n.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},n.fromJSON=function(e){return new n(e.value)},n.prototype._toTex=function(e){var t=this._toString(e);switch(xH(this.value)){case"string":return"\\mathtt{"+u7(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var n=t.toLowerCase().indexOf("e");return-1!==n?t.substring(0,n)+"\\cdot10^{"+t.substring(n+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},n}),{isClass:!0,isNode:!0}),y7=RH("RangeNode",["Node"],(e=>{var{Node:t}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!dH(e))throw new TypeError("Node expected");if(!dH(t))throw new TypeError("Node expected");if(r&&!dH(r))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=r||null}function r(e,t){var n=e7(e,t),r={},a=e7(e.start,t);if(r.start=null!==a&&a<=n||"all"===t,e.step){var i=e7(e.step,t);r.step=null!==i&&i<=n||"all"===t}var s=e7(e.end,t);return r.end=null!==s&&s<=n||"all"===t,r}return n.prototype=new t,n.prototype.type="RangeNode",n.prototype.isRangeNode=!0,n.prototype.needsEnd=function(){return this.filter((function(e){return yH(e)&&"end"===e.name})).length>0},n.prototype._compile=function(e,t){var n=e.range,r=this.start._compile(e,t),a=this.end._compile(e,t);if(this.step){var i=this.step._compile(e,t);return function(e,t,s){return n(r(e,t,s),a(e,t,s),i(e,t,s))}}return function(e,t,i){return n(r(e,t,i),a(e,t,i))}},n.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},n.prototype.map=function(e){return new n(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},n.prototype.clone=function(){return new n(this.start,this.end,this.step&&this.step)},n.prototype._toString=function(e){var t,n=r(this,e&&e.parenthesis?e.parenthesis:"keep"),a=this.start.toString(e);if(n.start&&(a="("+a+")"),t=a,this.step){var i=this.step.toString(e);n.step&&(i="("+i+")"),t+=":"+i}var s=this.end.toString(e);return n.end&&(s="("+s+")"),t+":"+s},n.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},n.fromJSON=function(e){return new n(e.start,e.end,e.step)},n.prototype.toHTML=function(e){var t,n=r(this,e&&e.parenthesis?e.parenthesis:"keep"),a=this.start.toHTML(e);if(n.start&&(a='('+a+')'),t=a,this.step){var i=this.step.toHTML(e);n.step&&(i='('+i+')'),t+=':'+i}var s=this.end.toHTML(e);return n.end&&(s='('+s+')'),t+':'+s},n.prototype._toTex=function(e){var t=r(this,e&&e.parenthesis?e.parenthesis:"keep"),n=this.start.toTex(e);if(t.start&&(n="\\left(".concat(n,"\\right)")),this.step){var a=this.step.toTex(e);t.step&&(a="\\left(".concat(a,"\\right)")),n+=":"+a}var i=this.end.toTex(e);return t.end&&(i="\\left(".concat(i,"\\right)")),n+":"+i},n}),{isClass:!0,isNode:!0}),b7=RH("reviver",["classes"],(e=>{var{classes:t}=e;return function(e,n){var r=t[n&&n.mathjs];return r&&"function"==typeof r.fromJSON?r.fromJSON(n):n}})),x7="chain",v7=RH(x7,["typed","Chain"],(e=>{var{typed:t,Chain:n}=e;return t(x7,{"":function(){return new n},any:function(e){return new n(e)}})})),_7=RH("FunctionAssignmentNode",["typed","Node"],(e=>{var{typed:t,Node:n}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!dH(n))throw new TypeError('Node expected for parameter "expr"');if(J6.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map((function(e){return e&&e.name||e})),this.types=t.map((function(e){return e&&e.type||"any"})),this.expr=n}function a(e,t){var n=e7(e,t),r=e7(e.expr,t);return"all"===t||null!==r&&r<=n}return r.prototype=new n,r.prototype.type="FunctionAssignmentNode",r.prototype.isFunctionAssignmentNode=!0,r.prototype._compile=function(e,n){var r=Object.create(n);mq(this.params,(function(e){r[e]=!0}));var a=this.expr._compile(e,r),i=this.name,s=this.params,o=bq(this.types,","),u=i+"("+bq(this.params,", ")+")";return function(e,n,r){var l={};l[o]=function(){for(var t=Object.create(n),i=0;i'+KU(this.params[r])+"");var i=this.expr.toHTML(e);return a(this,t)&&(i='('+i+')'),''+KU(this.name)+'('+n.join(',')+')='+i},r.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=this.expr.toTex(e);return a(this,t)&&(n="\\left(".concat(n,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(l7).join(",")+"\\right):="+n},r}),{isClass:!0,isNode:!0});function w7(e){return e&&e.isIndexError?new QU(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function M7(e){var{subset:t}=e;return function(e,n){try{if(Array.isArray(e))return t(e,n);if(e&&"function"==typeof e.subset)return e.subset(n);if("string"==typeof e)return t(e,n);if("object"==typeof e){if(!n.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return kq(e,n.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw w7(e)}}}var N7=RH("AccessorNode",["subset","Node"],(e=>{var{subset:t,Node:n}=e,r=M7({subset:t});function a(e,t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!dH(e))throw new TypeError('Node expected for parameter "object"');if(!pH(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e||null,this.index=t,Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function i(e){return!(rH(e)||aH(e)||uH(e)||cH(e)||hH(e)||mH(e)||yH(e))}return a.prototype=new n,a.prototype.type="AccessorNode",a.prototype.isAccessorNode=!0,a.prototype._compile=function(e,t){var n=this.object._compile(e,t),a=this.index._compile(e,t);if(this.index.isObjectProperty()){var i=this.index.getObjectProperty();return function(e,t,r){return kq(n(e,t,r),i)}}return function(e,t,i){var s=n(e,t,i),o=a(e,t,s);return r(s,o)}},a.prototype.forEach=function(e){e(this.object,"object",this),e(this.index,"index",this)},a.prototype.map=function(e){return new a(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))},a.prototype.clone=function(){return new a(this.object,this.index)},a.prototype._toString=function(e){var t=this.object.toString(e);return i(this.object)&&(t="("+t+")"),t+this.index.toString(e)},a.prototype.toHTML=function(e){var t=this.object.toHTML(e);return i(this.object)&&(t='('+t+')'),t+this.index.toHTML(e)},a.prototype._toTex=function(e){var t=this.object.toTex(e);return i(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},a.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},a.fromJSON=function(e){return new a(e.object,e.index)},a}),{isClass:!0,isNode:!0}),S7=RH("AssignmentNode",["subset","?matrix","Node"],(e=>{var{subset:t,matrix:n,Node:r}=e,a=M7({subset:t}),i=function(e){var{subset:t,matrix:n}=e;return function(e,r,a){try{if(Array.isArray(e))return n(e).subset(r,a).valueOf();if(e&&"function"==typeof e.subset)return e.subset(r,a);if("string"==typeof e)return t(e,r,a);if("object"==typeof e){if(!r.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return Dq(e,r.getObjectProperty(),a),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw w7(e)}}}({subset:t,matrix:n});function s(e,t,n){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=e,this.index=n?t:null,this.value=n||t,!yH(e)&&!rH(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(yH(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!pH(this.index))throw new TypeError('IndexNode expected as "index"');if(!dH(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function o(e,t){t||(t="keep");var n=e7(e,t),r=e7(e.value,t);return"all"===t||null!==r&&r<=n}return s.prototype=new r,s.prototype.type="AssignmentNode",s.prototype.isAssignmentNode=!0,s.prototype._compile=function(e,t){var n=this.object._compile(e,t),r=this.index?this.index._compile(e,t):null,s=this.value._compile(e,t),o=this.object.name;if(this.index){if(this.index.isObjectProperty()){var u=this.index.getObjectProperty();return function(e,t,r){var a=n(e,t,r),i=s(e,t,r);return Dq(a,u,i),i}}if(yH(this.object))return function(e,t,a){var u=n(e,t,a),l=s(e,t,a),c=r(e,t,u);return e.set(o,i(u,c,l)),l};var l=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var c=this.object.index.getObjectProperty();return function(e,t,n){var a=l(e,t,n),o=kq(a,c),u=r(e,t,o),p=s(e,t,n);return Dq(a,c,i(o,u,p)),p}}var p=this.object.index._compile(e,t);return function(e,t,n){var o=l(e,t,n),u=p(e,t,o),c=a(o,u),d=r(e,t,c),h=s(e,t,n);return i(o,u,i(c,d,h)),h}}if(!yH(this.object))throw new TypeError("SymbolNode expected as object");return function(e,t,n){var r=s(e,t,n);return e.set(o,r),r}},s.prototype.forEach=function(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)},s.prototype.map=function(e){return new s(this._ifNode(e(this.object,"object",this)),this.index?this._ifNode(e(this.index,"index",this)):null,this._ifNode(e(this.value,"value",this)))},s.prototype.clone=function(){return new s(this.object,this.index,this.value)},s.prototype._toString=function(e){var t=this.object.toString(e),n=this.index?this.index.toString(e):"",r=this.value.toString(e);return o(this,e&&e.parenthesis)&&(r="("+r+")"),t+n+" = "+r},s.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},s.fromJSON=function(e){return new s(e.object,e.index,e.value)},s.prototype.toHTML=function(e){var t=this.object.toHTML(e),n=this.index?this.index.toHTML(e):"",r=this.value.toHTML(e);return o(this,e&&e.parenthesis)&&(r='('+r+')'),t+n+'='+r},s.prototype._toTex=function(e){var t=this.object.toTex(e),n=this.index?this.index.toTex(e):"",r=this.value.toTex(e);return o(this,e&&e.parenthesis)&&(r="\\left(".concat(r,"\\right)")),t+n+":="+r},s}),{isClass:!0,isNode:!0}),k7=RH("IndexNode",["Node","size"],(e=>{var{Node:t,size:n}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(dH))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}return r.prototype=new t,r.prototype.type="IndexNode",r.prototype.isIndexNode=!0,r.prototype._compile=function(e,t){var r=fq(this.dimensions,(function(r,a){if(r.filter((e=>e.isSymbolNode&&"end"===e.name)).length>0){var i=Object.create(t);i.end=!0;var s=r._compile(e,i);return function(e,t,r){if(!HP(r)&&!PP(r)&&!BP(r))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+xH(r));var i=n(r).valueOf(),o=Object.create(t);return o.end=i[a],s(e,o,r)}}return r._compile(e,t)})),a=kq(e,"index");return function(e,t,n){var i=fq(r,(function(r){return r(e,t,n)}));return a(...i)}},r.prototype.forEach=function(e){for(var t=0;t.'+KU(this.getObjectProperty())+"":'['+t.join(',')+']'},r.prototype._toTex=function(e){var t=this.dimensions.map((function(t){return t.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+t.join(",")+"}"},r}),{isClass:!0,isNode:!0}),D7=RH("SymbolNode",["math","?Unit","Node"],(e=>{var{math:t,Unit:n,Node:r}=e;function a(e){return!!n&&n.isValuelessUnit(e)}function i(e){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}return i.prototype=new r,i.prototype.type="SymbolNode",i.prototype.isSymbolNode=!0,i.prototype._compile=function(e,t){var r=this.name;if(!0===t[r])return function(e,t,n){return t[r]};if(r in e)return function(t,n,a){return t.has(r)?t.get(r):kq(e,r)};var s=a(r);return function(e,t,a){return e.has(r)?e.get(r):s?new n(null,r):i.onUndefinedSymbol(r)}},i.prototype.forEach=function(e){},i.prototype.map=function(e){return this.clone()},i.onUndefinedSymbol=function(e){throw new Error("Undefined symbol "+e)},i.prototype.clone=function(){return new i(this.name)},i.prototype._toString=function(e){return this.name},i.prototype.toHTML=function(e){var t=KU(this.name);return"true"===t||"false"===t?''+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},i.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},i.fromJSON=function(e){return new i(e.name)},i.prototype._toTex=function(e){var n=!1;void 0===t[this.name]&&a(this.name)&&(n=!0);var r=l7(this.name,n);return"\\"===r[0]?r:" "+r},i}),{isClass:!0,isNode:!0});function T7(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{var{math:t,Node:n,SymbolNode:r}=e;function a(e,t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"==typeof e&&(e=new r(e)),!dH(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(dH))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[],Object.defineProperty(this,"name",{get:function(){return this.fn.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}a.prototype=new n,a.prototype.type="FunctionNode",a.prototype.isFunctionNode=!0;var i=e=>VU(e,{truncate:78});a.prototype._compile=function(e,t){if(!(this instanceof a))throw new TypeError("No valid FunctionNode");var n=this.args.map((n=>n._compile(e,t)));if(!yH(this.fn)){if(rH(this.fn)&&pH(this.fn.index)&&this.fn.index.isObjectProperty()){var r=this.fn.object._compile(e,t),s=this.fn.index.getObjectProperty(),o=this.args;return function(t,a,i){var u=r(t,a,i);if(function(e,t){if(!Iq(e,t))throw new Error('No access to method "'+t+'"')}(u,s),u[s]&&u[s].rawArgs)return u[s](o,e,T7(t,a),t);var l=n.map((e=>e(t,a,i)));return u[s].apply(u,l)}}var u=this.fn.toString(),l=this.fn._compile(e,t),c=this.args;return function(t,r,a){var s=l(t,r,a);if("function"!=typeof s)throw new TypeError("Expression '".concat(u,"' did not evaluate to a function; value is:")+"\n ".concat(i(s)));if(s.rawArgs)return s(c,e,T7(t,r),t);var o=n.map((e=>e(t,r,a)));return s.apply(s,o)}}var p=this.fn.name;if(t[p]){var d=this.args;return function(t,r,a){var s=r[p];if("function"!=typeof s)throw new TypeError("Argument '".concat(p,"' was not a function; received: ").concat(i(s)));if(s.rawArgs)return s(d,e,T7(t,r),t);var o=n.map((e=>e(t,r,a)));return s.apply(s,o)}}var h=p in e?kq(e,p):void 0,f="function"==typeof h&&!0===h.rawArgs,m=t=>{var n;if(t.has(p))n=t.get(p);else{if(!(p in e))return a.onUndefinedFunction(p);n=kq(e,p)}if("function"==typeof n)return n;throw new TypeError("'".concat(p,"' is not a function; its value is:\n ").concat(i(n)))};if(f){var g=this.args;return function(t,n,r){return m(t)(g,e,T7(t,n),t)}}switch(n.length){case 0:return function(e,t,n){return m(e)()};case 1:return function(e,t,r){return m(e)((0,n[0])(e,t,r))};case 2:return function(e,t,r){var a=m(e),i=n[0],s=n[1];return a(i(e,t,r),s(e,t,r))};default:return function(e,t,r){return m(e)(...n.map((n=>n(e,t,r))))}}},a.prototype.forEach=function(e){e(this.fn,"fn",this);for(var t=0;t'+KU(this.fn)+'('+t.join(',')+')'};var u=a.prototype.toTex;return a.prototype.toTex=function(e){var t;return e&&"object"==typeof e.handler&&TH(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:u.call(this,e)},a.prototype._toTex=function(e){var n,r,a=this.args.map((function(t){return t.toTex(e)}));switch(s7[this.name]&&(n=s7[this.name]),!t[this.name]||"function"!=typeof t[this.name].toTex&&"object"!=typeof t[this.name].toTex&&"string"!=typeof t[this.name].toTex||(n=t[this.name].toTex),typeof n){case"function":r=n(this,e);break;case"string":r=o(n,this,e);break;case"object":switch(typeof n[a.length]){case"function":r=n[a.length](this,e);break;case"string":r=o(n[a.length],this,e)}}return void 0!==r?r:o("\\mathrm{${name}}\\left(${args}\\right)",this,e)},a.prototype.getIdentifier=function(){return this.type+":"+this.name},a}),{isClass:!0,isNode:!0}),E7="parse",C7=RH(E7,["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],(e=>{var{typed:t,numeric:n,config:r,AccessorNode:a,ArrayNode:i,AssignmentNode:s,BlockNode:o,ConditionalNode:u,ConstantNode:l,FunctionAssignmentNode:c,FunctionNode:p,IndexNode:d,ObjectNode:h,OperatorNode:f,ParenthesisNode:m,RangeNode:g,RelationalNode:y,SymbolNode:b}=e,x=t(E7,{string:function(e){return $(e,{})},"Array | Matrix":function(e){return v(e,{})},"string, Object":function(e,t){return $(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":v});function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=void 0!==t.nodes?t.nodes:{};return Wq(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return $(e,n)}))}var _={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},w={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},M={true:!0,false:!1,null:null,undefined:void 0},N=["NaN","Infinity"];function S(e,t){return e.expression.substr(e.index,t)}function k(e){return S(e,1)}function D(e){e.index++}function T(e){return e.expression.charAt(e.index-1)}function I(e){return e.expression.charAt(e.index+1)}function E(e){for(e.tokenType=0,e.token="",e.comment="";;){if("#"===k(e))for(;"\n"!==k(e)&&""!==k(e);)e.comment+=k(e),D(e);if(!x.isWhitespace(k(e),e.nestingLevel))break;D(e)}if(""!==k(e)){if("\n"===k(e)&&!e.nestingLevel)return e.tokenType=1,e.token=k(e),void D(e);var t=k(e),n=S(e,2),r=S(e,3);if(3===r.length&&_[r])return e.tokenType=1,e.token=r,D(e),D(e),void D(e);if(2===n.length&&_[n])return e.tokenType=1,e.token=n,D(e),void D(e);if(_[t])return e.tokenType=1,e.token=t,void D(e);if(x.isDigitDot(t)){e.tokenType=2;var a=S(e,2);if("0b"===a||"0o"===a||"0x"===a){for(e.token+=k(e),D(e),e.token+=k(e),D(e);x.isHexDigit(k(e));)e.token+=k(e),D(e);if("."===k(e))for(e.token+=".",D(e);x.isHexDigit(k(e));)e.token+=k(e),D(e);else if("i"===k(e))for(e.token+="i",D(e);x.isDigit(k(e));)e.token+=k(e),D(e);return}if("."===k(e)){if(e.token+=k(e),D(e),!x.isDigit(k(e)))return void(e.tokenType=1)}else{for(;x.isDigit(k(e));)e.token+=k(e),D(e);x.isDecimalMark(k(e),I(e))&&(e.token+=k(e),D(e))}for(;x.isDigit(k(e));)e.token+=k(e),D(e);if("E"===k(e)||"e"===k(e))if(x.isDigit(I(e))||"-"===I(e)||"+"===I(e)){if(e.token+=k(e),D(e),"+"!==k(e)&&"-"!==k(e)||(e.token+=k(e),D(e)),!x.isDigit(k(e)))throw ne(e,'Digit expected, got "'+k(e)+'"');for(;x.isDigit(k(e));)e.token+=k(e),D(e);if(x.isDecimalMark(k(e),I(e)))throw ne(e,'Digit expected, got "'+k(e)+'"')}else if("."===I(e))throw D(e),ne(e,'Digit expected, got "'+k(e)+'"')}else{if(!x.isAlpha(k(e),T(e),I(e))){for(e.tokenType=4;""!==k(e);)e.token+=k(e),D(e);throw ne(e,'Syntax error in part "'+e.token+'"')}for(;x.isAlpha(k(e),T(e),I(e))||x.isDigit(k(e));)e.token+=k(e),D(e);TH(w,e.token)?e.tokenType=1:e.tokenType=3}}else e.tokenType=1}function C(e){do{E(e)}while("\n"===e.token)}function A(e){e.nestingLevel++}function L(e){e.nestingLevel--}function $(e,t){var n={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:0,nestingLevel:0,conditionalLevel:null};LP(n,{expression:e,extraNodes:t}),E(n);var r=function(e){var t,n,r=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=O(e)).comment=e.comment);"\n"===e.token||";"===e.token;)0===r.length&&t&&(n=";"!==e.token,r.push({node:t,visible:n})),E(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=O(e)).comment=e.comment,n=";"!==e.token,r.push({node:t,visible:n}));return r.length>0?new o(r):(t||((t=new l(void 0)).comment=e.comment),t)}(n);if(""!==n.token)throw 1===n.tokenType?re(n,"Unexpected operator "+n.token):ne(n,'Unexpected part "'+n.token+'"');return r}function O(e){var t,n,r,a,i=function(e){for(var t=function(e){for(var t=R(e);"or"===e.token;)C(e),t=new f("or","or",[t,R(e)]);return t}(e);"?"===e.token;){var n=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,C(e);var r=t,a=O(e);if(":"!==e.token)throw ne(e,"False part of conditional expression expected");e.conditionalLevel=null,C(e);var i=O(e);t=new u(r,a,i),e.conditionalLevel=n}return t}(e);if("="===e.token){if(yH(i))return t=i.name,C(e),r=O(e),new s(new b(t),r);if(rH(i))return C(e),r=O(e),new s(i.object,i.index,r);if(cH(i)&&yH(i.fn)&&(a=!0,n=[],t=i.name,i.args.forEach((function(e,t){yH(e)?n[t]=e.name:a=!1})),a))return C(e),r=O(e),new c(t,n,r);throw ne(e,"Invalid left hand side of assignment operator =")}return i}function R(e){for(var t=F(e);"xor"===e.token;)C(e),t=new f("xor","xor",[t,F(e)]);return t}function F(e){for(var t=Y(e);"and"===e.token;)C(e),t=new f("and","and",[t,Y(e)]);return t}function Y(e){for(var t=z(e);"|"===e.token;)C(e),t=new f("|","bitOr",[t,z(e)]);return t}function z(e){for(var t=B(e);"^|"===e.token;)C(e),t=new f("^|","bitXor",[t,B(e)]);return t}function B(e){for(var t=P(e);"&"===e.token;)C(e),t=new f("&","bitAnd",[t,P(e)]);return t}function P(e){for(var t=[H(e)],n=[],r={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};TH(r,e.token);){var a={name:e.token,fn:r[e.token]};n.push(a),C(e),t.push(H(e))}return 1===t.length?t[0]:2===t.length?new f(n[0].name,n[0].fn,t):new y(n.map((e=>e.fn)),t)}function H(e){var t,n,r,a;t=j(e);for(var i={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};TH(i,e.token);)r=i[n=e.token],C(e),a=[t,j(e)],t=new f(n,r,a);return t}function j(e){var t,n,r,a;t=U(e);for(var i={to:"to",in:"to"};TH(i,e.token);)r=i[n=e.token],C(e),"in"===n&&""===e.token?t=new f("*","multiply",[t,new b("in")],!0):(a=[t,U(e)],t=new f(n,r,a));return t}function U(e){var t,n=[];if(t=":"===e.token?new l(1):q(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(n.push(t);":"===e.token&&n.length<3;)C(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?n.push(new b("end")):n.push(q(e));t=3===n.length?new g(n[0],n[2],n[1]):new g(n[0],n[1])}return t}function q(e){var t,n,r,a;t=W(e);for(var i={"+":"add","-":"subtract"};TH(i,e.token);){r=i[n=e.token],C(e);var s=W(e);a=s.isPercentage?[t,new f("*","multiply",[t,s])]:[t,s],t=new f(n,r,a)}return t}function W(e){var t,n,r,a;n=t=V(e);for(var i={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};TH(i,e.token);)a=i[r=e.token],C(e),n=V(e),t=new f(r,a,[t,n]);return t}function V(e){var t,n;for(n=t=G(e);3===e.tokenType||"in"===e.token&&uH(t)||!(2!==e.tokenType||uH(n)||fH(n)&&"!"!==n.op)||"("===e.token;)n=G(e),t=new f("*","multiply",[t,n],!0);return t}function G(e){for(var t=K(e),n=t,r=[];"/"===e.token&&uH(n);){if(r.push(LP({},e)),C(e),2!==e.tokenType){LP(e,r.pop());break}if(r.push(LP({},e)),C(e),3!==e.tokenType&&"("!==e.token){r.pop(),LP(e,r.pop());break}LP(e,r.pop()),r.pop(),n=K(e),t=new f("/","divide",[t,n])}return t}function K(e){var t,n,r,a;t=J(e);for(var i={"%":"mod",mod:"mod"};TH(i,e.token);)r=i[n=e.token],C(e),"%"===n&&1===e.tokenType&&"("!==e.token?t=new f("/","divide",[t,new l(100)],!1,!0):(a=[t,J(e)],t=new f(n,r,a));return t}function J(e){var t,a,s,o={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return TH(o,e.token)?(s=o[e.token],t=e.token,C(e),a=[J(e)],new f(t,s,a)):function(e){var t,a,s,o;return t=function(e){var t,a,s;t=function(e){var t=[];if(3===e.tokenType&&TH(e.extraNodes,e.token)){var a=e.extraNodes[e.token];if(E(e),"("===e.token){if(t=[],A(e),E(e),")"!==e.token)for(t.push(O(e));","===e.token;)E(e),t.push(O(e));if(")"!==e.token)throw ne(e,"Parenthesis ) expected");L(e),E(e)}return new a(t)}return function(e){var t;return 3===e.tokenType||1===e.tokenType&&e.token in w?(t=e.token,E(e),X(e,TH(M,t)?new l(M[t]):-1!==N.indexOf(t)?new l(n(t,"number")):new b(t))):function(e){var t;return'"'===e.token?(t=Z(e),X(e,new l(t))):function(e){var t;return"'"===e.token?(t=Q(e),X(e,new l(t))):function(e){var t,a,s,o;if("["===e.token){if(A(e),E(e),"]"!==e.token){var u=ee(e);if(";"===e.token){for(s=1,a=[u];";"===e.token;)E(e),a[s]=ee(e),s++;if("]"!==e.token)throw ne(e,"End of matrix ] expected");L(e),E(e),o=a[0].items.length;for(var c=1;c0},x.isDecimalMark=function(e,t){return"."===e&&"/"!==t&&"*"!==t&&"^"!==t},x.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},x.isDigit=function(e){return e>="0"&&e<="9"},x.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},x})),A7=RH("resolve",["parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{parse:t,ConstantNode:n,FunctionNode:r,OperatorNode:a,ParenthesisNode:i}=e;return function e(s,o){var u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;if(!o)return s;if(Rq(o)||(o=Oq(o)),yH(s)){if(u.has(s.name)){var l=Array.from(u).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(l,"}"))}var c=o.get(s.name);if(dH(c)){var p=new Set(u);return p.add(s.name),e(c,o,p)}return"number"==typeof c?t(String(c)):void 0!==c?new n(c):s}if(fH(s)){var d=s.args.map((function(t){return e(t,o,u)}));return new a(s.op,s.fn,d,s.implicit)}if(mH(s))return new i(e(s.content,o,u));if(cH(s)){var h=s.args.map((function(t){return e(t,o,u)}));return new r(s.name,h)}return s.map((t=>e(t,o,u)))}}));function L7(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 $7(e){for(var t=1;t{var{FunctionNode:t,OperatorNode:n,SymbolNode:r}=e,a=!0,i=!1,s="defaultF",o={add:{trivial:a,total:a,commutative:a,associative:a},unaryPlus:{trivial:a,total:a,commutative:a,associative:a},subtract:{trivial:i,total:a,commutative:i,associative:i},multiply:{trivial:a,total:a,commutative:a,associative:a},divide:{trivial:i,total:a,commutative:i,associative:i},paren:{trivial:a,total:a,commutative:a,associative:i},defaultF:{trivial:i,total:a,commutative:i,associative:i}};function u(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,r=s;if("string"==typeof e?r=e:fH(e)?r=e.fn.toString():cH(e)?r=e.name:mH(e)&&(r="paren"),TH(n,r)){var a=n[r];if(TH(a,t))return a[t];if(TH(o,r))return o[r][t]}if(TH(n,s)){var i=n.defaultF;return TH(i,t)?i[t]:o.defaultF[t]}if(TH(o,r)){var u=o[r];if(TH(u,t))return u[t]}return o.defaultF[t]}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o;return u(e,"associative",t)}function c(e,t){var n,r=[];return l(e,t)?(n=e.op,function e(t){for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:o;return u(e,"commutative",t)},isAssociative:l,mergeContext:function(e,t){var n=$7({},e);for(var r in t)TH(e,r)?n[r]=$7($7({},t[r]),e[r]):n[r]=t[r];return n},flatten:function e(t,n){if(!t.args||0===t.args.length)return t;t.args=c(t,n);for(var r=0;r2&&l(t,n)){for(var s=t.args.pop();t.args.length>0;)s=r([t.args.pop(),s]);t.args=s.args}}},unflattenl:function e(t,n){if(t.args&&0!==t.args.length){for(var r=p(t),a=t.args.length,i=0;i2&&l(t,n)){for(var s=t.args.shift();t.args.length>0;)s=r([s,t.args.shift()]);t.args=s.args}}},defaultContext:o,realContext:{divide:{total:i},log:{total:i}},positiveContext:{subtract:{total:i},abs:{trivial:a},log:{total:a}}}})),R7=RH("simplifyCore",["equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{equal:t,isZero:n,add:r,subtract:a,multiply:i,divide:s,pow:o,AccessorNode:u,ArrayNode:l,ConstantNode:c,FunctionNode:p,IndexNode:d,ObjectNode:h,OperatorNode:f,ParenthesisNode:m,SymbolNode:g}=e,y=new c(0),b=new c(1),{hasProperty:x,isCommutative:v}=O7({FunctionNode:p,OperatorNode:f,SymbolNode:g});return function e(m,g){var _=g?g.context:void 0;if(x(m,"trivial",_)){if(cH(m)&&1===m.args.length)return e(m.args[0],g);var w=!1,M=0;if(m.forEach((t=>{1==++M&&(w=e(t,g))})),1===M)return w}if(fH(m)&&m.isUnary()){var N=e(m.args[0],g);if("-"===m.op){if(fH(N)){if(N.isUnary()&&"-"===N.op)return N.args[0];if(N.isBinary()&&"subtract"===N.fn)return new f("-","subtract",[N.args[1],N.args[0]])}return new f(m.op,m.fn,[N])}}else{if(fH(m)&&m.isBinary()){var S=e(m.args[0],g),k=e(m.args[1],g);if("+"===m.op){if(uH(S)){if(n(S.value))return k;if(uH(k))return new c(r(S.value,k.value))}return uH(k)&&n(k.value)?S:fH(k)&&k.isUnary()&&"-"===k.op?new f("-","subtract",[S,k.args[0]]):new f(m.op,m.fn,k?[S,k]:[S])}if("-"===m.op){if(uH(S)&&k){if(uH(k))return new c(a(S.value,k.value));if(n(S.value))return new f("-","unaryMinus",[k])}if("subtract"===m.fn)return uH(k)&&n(k.value)?S:fH(k)&&k.isUnary()&&"-"===k.op?e(new f("+","add",[S,k.args[0]]),g):new f(m.op,m.fn,[S,k])}else{if("*"===m.op){if(uH(S)){if(n(S.value))return y;if(t(S.value,1))return k;if(uH(k))return new c(i(S.value,k.value))}if(uH(k)){if(n(k.value))return y;if(t(k.value,1))return S;if(fH(S)&&S.isBinary()&&S.op===m.op&&v(m,_)){var D=S.args[0];if(uH(D)){var T=new c(i(D.value,k.value));return new f(m.op,m.fn,[T,S.args[1]],m.implicit)}}return v(m,_)?new f(m.op,m.fn,[k,S],m.implicit):new f(m.op,m.fn,[S,k],m.implicit)}return new f(m.op,m.fn,[S,k],m.implicit)}if("/"===m.op){if(uH(S)){if(n(S.value))return y;if(uH(k)&&(t(k.value,1)||t(k.value,2)||t(k.value,4)))return new c(s(S.value,k.value))}return new f(m.op,m.fn,[S,k])}if("^"===m.op&&uH(k)){if(n(k.value))return b;if(t(k.value,1))return S;if(uH(S))return new c(o(S.value,k.value));if(fH(S)&&S.isBinary()&&"^"===S.op){var I=S.args[1];if(uH(I))return new f(m.op,m.fn,[S.args[0],new c(i(I.value,k.value))])}}}return new f(m.op,m.fn,[S,k])}if(cH(m))return new p(e(m.fn),m.args.map((t=>e(t,g))));if(aH(m))return new l(m.items.map((t=>e(t,g))));if(rH(m))return new u(e(m.object,g),e(m.index,g));if(pH(m))return new d(m.dimensions.map((t=>e(t,g))));if(hH(m)){var E={};for(var C in m.properties)E[C]=e(m.properties[C],g);return new h(E)}}return m}})),F7="compile",Y7=RH(F7,["typed","parse"],(e=>{var{typed:t,parse:n}=e;return t(F7,{string:function(e){return n(e).compile()},"Array | Matrix":function(e){return Wq(e,(function(e){return n(e).compile()}))}})})),z7=RH("Help",["parse"],(e=>{var{parse:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return n.prototype.type="Help",n.prototype.isHelp=!0,n.prototype.toString=function(){var e=this.doc||{},n="\n";if(e.name&&(n+="Name: "+e.name+"\n\n"),e.category&&(n+="Category: "+e.category+"\n\n"),e.description&&(n+="Description:\n "+e.description+"\n\n"),e.syntax&&(n+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){n+="Examples:\n";for(var r={},a=0;a"mathjs"!==e)).forEach((n=>{t[n]=e[n]})),new n(t)},n.prototype.valueOf=n.prototype.toString,n}),{isClass:!0}),B7="leafCount",P7=RH(B7,["parse","typed"],(e=>{var{parse:t,typed:n}=e;function r(e){var t=0;return e.forEach((e=>{t+=r(e)})),t||1}return n(B7,{string:function(e){return this(t(e))},Node:function(e){return r(e)}})})),H7=RH("simplifyConstant",["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],(e=>{var{typed:t,config:n,mathWithTransform:r,matrix:a,fraction:i,bignumber:s,AccessorNode:o,ArrayNode:u,ConstantNode:l,FunctionNode:c,IndexNode:p,ObjectNode:d,OperatorNode:h,SymbolNode:f}=e,{isCommutative:m,isAssociative:g,allChildren:y,createMakeNodeFunction:b}=O7({FunctionNode:c,OperatorNode:h,SymbolNode:f});function x(e,t){return M(T(e,t))}function v(e){return YP(e)?e.valueOf():e instanceof Array?e.map(v):HP(e)?a(v(e.valueOf())):e}function _(e,t,n){try{return r[e].apply(null,t)}catch(a){return t=t.map(v),S(r[e].apply(null,t),n)}}var w=t({Fraction:function(e){var t,n=e.s*e.n;return t=n<0?new h("-","unaryMinus",[new l(-n)]):new l(n),1===e.d?t:new h("/","divide",[t,new l(e.d)])},number:function(e){return e<0?k(new l(-e)):new l(e)},BigNumber:function(e){return e<0?k(new l(-e)):new l(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")},string:function(e){return new l(e)},Matrix:function(e){return new u(e.valueOf().map((e=>w(e))))}});function M(e){return dH(e)?e:w(e)}function N(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&i){var n=i(e),r=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(n.valueOf()===e&&n.nT(e,t)));if(!n.some(dH))try{return _(e.name,n,t)}catch(e){}if("size"===e.name&&1===n.length&&aH(n[0])){for(var i=[],s=n[0];aH(s);)i.push(s.items.length),s=s.items[0];return a(i)}return new c(e.name,n.map(M))}case"OperatorNode":var h,f,v=e.fn.toString(),w=b(e);if(fH(e)&&e.isUnary())f=dH((h=[T(e.args[0],t)])[0])?w(h):_(v,h,t);else if(g(e,t.context))if(h=(h=y(e,t.context)).map((e=>T(e,t))),m(v,t.context)){for(var N=[],k=[],I=0;I1?(f=D(v,N,w,t),k.unshift(f),f=D(v,k,w,t)):f=D(v,h,w,t)}else f=D(v,h,w,t);else h=e.args.map((e=>T(e,t))),f=D(v,h,w,t);return f;case"ParenthesisNode":return T(e.content,t);case"AccessorNode":return function(e,t,n){if(!pH(t))return new o(M(e),M(t));if(aH(e)||HP(e)){for(var r=Array.from(t.dimensions);r.length>0;)if(uH(r[0])&&"string"!=typeof r[0].value){var i=S(r.shift().value,n);aH(e)?e=e.items[i-1]:(e=e.valueOf()[i-1])instanceof Array&&(e=a(e))}else{if(!(r.length>1&&uH(r[1])&&"string"!=typeof r[1].value))break;var s=S(r[1].value,n),c=[],d=aH(e)?e.items:e.valueOf();for(var h of d)if(aH(h))c.push(h.items[s-1]);else{if(!HP(e))break;c.push(h[s-1])}if(c.length!==d.length)break;e=aH(e)?new u(c):a(c),r.splice(1,1)}return r.length===t.dimensions.length?new o(M(e),t):r.length>0?(t=new p(r),new o(M(e),t)):e}if(hH(e)&&1===t.dimensions.length&&uH(t.dimensions[0])){var f=t.dimensions[0].value;return f in e.properties?e.properties[f]:new l}return new o(M(e),t)}(T(e.object,t),T(e.index,t),t);case"ArrayNode":var E=e.items.map((e=>T(e,t)));return E.some(dH)?new u(E.map(M)):a(E);case"IndexNode":return new p(e.dimensions.map((e=>x(e,t))));case"ObjectNode":var C={};for(var A in e.properties)C[A]=x(e.properties[A],t);return new d(C);default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return x})),j7=RH("simplify",["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","resolve","simplifyCore","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{config:t,typed:n,parse:r,add:a,subtract:i,multiply:s,divide:o,pow:u,isZero:l,equal:c,resolve:p,simplifyCore:d,fraction:h,bignumber:f,mathWithTransform:m,matrix:g,AccessorNode:y,ArrayNode:b,ConstantNode:x,FunctionNode:v,IndexNode:_,ObjectNode:w,OperatorNode:M,ParenthesisNode:N,SymbolNode:S}=e,k=H7({typed:n,config:t,mathWithTransform:m,matrix:g,fraction:h,bignumber:f,AccessorNode:y,ArrayNode:b,ConstantNode:x,FunctionNode:v,IndexNode:_,ObjectNode:w,OperatorNode:M,SymbolNode:S}),{hasProperty:D,isCommutative:T,isAssociative:I,mergeContext:E,flatten:C,unflattenr:A,unflattenl:L,createMakeNodeFunction:$,defaultContext:O,realContext:R,positiveContext:F}=O7({FunctionNode:v,OperatorNode:M,SymbolNode:S}),Y=n("simplify",{string:function(e){return this(r(e),this.rules,$q(),{})},"string, Map | Object":function(e,t){return this(r(e),this.rules,t,{})},"string, Map | Object, Object":function(e,t,n){return this(r(e),this.rules,t,n)},"string, Array":function(e,t){return this(r(e),t,$q(),{})},"string, Array, Map | Object":function(e,t,n){return this(r(e),t,n,{})},"string, Array, Map | Object, Object":function(e,t,n,a){return this(r(e),t,n,a)},"Node, Map | Object":function(e,t){return this(e,this.rules,t,{})},"Node, Map | Object, Object":function(e,t,n){return this(e,this.rules,t,n)},Node:function(e){return this(e,this.rules,$q(),{})},"Node, Array":function(e,t){return this(e,t,$q(),{})},"Node, Array, Map | Object":function(e,t,n){return this(e,t,n,{})},"Node, Array, Object, Object":function(e,t,n,r){return this(e,t,Oq(n),r)},"Node, Array, Map, Object":function(e,t,n,r){var a=r.consoleDebug;t=function(e,t){for(var n=[],r=0;r ").concat(t[l].r.toString()))),a){var d=i.toString({parenthesis:"all"});d!==u&&(console.log("Applying",c,"produced",d),u=d)}L(i,r.context)}o=i.toString({parenthesis:"all"})}return i}});function z(e){return e.transform((function(e,t,n){return mH(e)?z(e.content):e}))}Y.defaultContext=O,Y.realContext=R,Y.positiveContext=F;var B={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};function P(e,t){var n={};if(e.s){var a=e.s.split("->");if(2!==a.length)throw SyntaxError("Could not parse rule: "+e.s);n.l=a[0],n.r=a[1]}else n.l=e.l,n.r=e.r;for(var i of(n.l=z(r(n.l)),n.r=z(r(n.r)),["imposeContext","repeat","assuming"]))i in e&&(n[i]=e[i]);if(e.evaluate&&(n.evaluate=r(e.evaluate)),I(n.l,t)){var s=$(n.l),o=new S("_p"+H++);n.expanded={},n.expanded.l=s([n.l.clone(),o]),C(n.expanded.l,t),A(n.expanded.l,t),n.expanded.r=s([n.r,o])}return n}Y.rules=[d,{l:"log(e)",r:"1"},{s:"n-n1 -> n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(c*v) -> v * (-c)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(c*v) -> (-c) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*c) -> v * (-c)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" v * ( v * n1 + n2)",r:"v^2 * n1 + v * n2"},{s:" v * (v^n4 * n1 + n2) -> v^(1+n4) * n1 + v * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * ( v * n1 + n2) -> v^(n3+1) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * (v^n4 * n1 + n2) -> v^(n3+n4) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},k,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"v*n + v",r:"v*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*v + v -> (n+1)*v",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*c + c",r:"(n+1)*c"},{s:"c*n + c -> c*(n+1)",assuming:{multiply:{commutative:!1}}},k,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"c+v -> v+c",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"v*c -> c*v",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];var H=0;function j(e,t,n){var r=e;if(e)for(var a=0;a=2&&2===e.args.length){for(var i=function(e,t){var n,r,a=[],i=$(e);if(T(e,t))for(var s=0;s1&&(u=i(e.args.slice(0,o))),n=1===(r=e.args.slice(o)).length?r[0]:i(r),a.push(i([u,n]))}return a}(t,n),s=[],o=0;o2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var l=[],p=0;p2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var h=V(e.args[0],t.args[1],n);if(0===h.length)return[];var f=V(e.args[1],t.args[0],n);if(0===f.length)return[];l=[h,f]}a=function(e){if(0===e.length)return e;for(var t=e.reduce(W),n=[],r={},a=0;a{var{parse:t,simplify:n,typed:r,OperatorNode:a}=e;return r(U7,{"string, string":function(e,n){return this(t(e),t(n),{})},"string, string, Object":function(e,n,r){return this(t(e),t(n),r)},"Node, string":function(e,n){return this(e,t(n),{})},"Node, string, Object":function(e,n,r){return this(e,t(n),r)},"string, Node":function(e,n){return this(t(e),n,{})},"string, Node, Object":function(e,n,r){return this(t(e),n,r)},"Node, Node":function(e,t){return this(e,t,{})},"Node, Node, Object":function(e,t,r){var i=new a("-","subtract",[e,t]),s=n(i,{},r);return uH(s)&&!s.value}})})),W7="evaluate",V7=RH(W7,["typed","parse"],(e=>{var{typed:t,parse:n}=e;return t(W7,{string:function(e){var t=$q();return n(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return n(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=$q();return Wq(e,(function(e){return n(e).compile().evaluate(t)}))},"Array | Matrix, Map | Object":function(e,t){return Wq(e,(function(e){return n(e).compile().evaluate(t)}))}})})),G7={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},K7={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},J7={bignumber:{name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},boolean:{name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},complex:{name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},index:{name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},matrix:{name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},number:{name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},splitUnit:{name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},string:{name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},unit:{name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},e:G7,E:G7,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},Infinity:{name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},LOG10E:{name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:K7,PI:K7,phi:{name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},SQRT1_2:{name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:{name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},lsolve:{name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},lsolveAll:{name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},lup:{name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},lusolve:{name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},leafCount:{name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},resolve:{name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},simplify:{name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},simplifyCore:{name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","evaluate"]},symbolicEqual:{name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},usolve:{name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},usolveAll:{name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},qr:{name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},cbrt:{name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},cube:{name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},divide:{name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},dotDivide:{name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},dotMultiply:{name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},dotPow:{name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},exp:{name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},expm:{name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},expm1:{name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},gcd:{name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},log:{name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},log2:{name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},log1p:{name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},log10:{name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},mod:{name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},multiply:{name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},norm:{name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)","math.pow([[1, 2], [4, 3]], 2)","math.pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},invmod:{name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","math.invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},count:{name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diff:{name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},pinv:{name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},kron:{name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},ones:{name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]},range:{name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},reshape:{name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]},rotate:{name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},rotationMatrix:{name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},size:{name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},fft:{name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},ifft:{name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},lgamma:{name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(math.i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},cumsum:{name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},print:{name:"print",category:"Utils",syntax:["print(template, values)","print(template, values, precision)"],description:"Interpolate values into a string template.",examples:['print("Lucy is $age years old", {age: 5})','print("The value of pi is $pi", {pi: pi}, 3)','print("Hello, $user.name!", {user: {name: "John"}})','print("Values: $0, $1, $2", [6, 9, 4])'],seealso:["format"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},X7="help",Z7=RH(X7,["typed","mathWithTransform","Help"],(e=>{var{typed:t,mathWithTransform:n,Help:r}=e;return t(X7,{any:function(e){var t,a=e;if("string"!=typeof e)for(t in n)if(TH(n,t)&&e===n[t]){a=t;break}var i=kq(J7,a);if(!i){var s="function"==typeof a?a.name:a;throw new Error('No documentation found on "'+s+'"')}return new r(i)}})})),Q7=RH("Parser",["evaluate"],(e=>{var{evaluate:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:$q(),writable:!1})}return n.prototype.type="Parser",n.prototype.isParser=!0,n.prototype.evaluate=function(e){return t(e,this.scope)},n.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},n.prototype.getAll=function(){return function(e){if(e instanceof Lq)return e.wrappedObject;var t={};for(var n of e.keys())Dq(t,n,e.get(n));return t}(this.scope)},n.prototype.getAllAsMap=function(){return this.scope},n.prototype.set=function(e,t){return this.scope.set(e,t),t},n.prototype.remove=function(e){this.scope.delete(e)},n.prototype.clear=function(){this.scope.clear()},n}),{isClass:!0}),e8="rationalize",t8=RH(e8,["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],(e=>{var{config:t,typed:n,equal:r,isZero:a,add:i,subtract:s,multiply:o,divide:u,pow:l,parse:c,simplifyCore:p,simplify:d,fraction:h,bignumber:f,mathWithTransform:m,matrix:g,AccessorNode:y,ArrayNode:b,ConstantNode:x,FunctionNode:v,IndexNode:_,ObjectNode:w,OperatorNode:M,SymbolNode:N,ParenthesisNode:S}=e,k=H7({typed:n,config:t,mathWithTransform:m,matrix:g,fraction:h,bignumber:f,AccessorNode:y,ArrayNode:b,ConstantNode:x,FunctionNode:v,IndexNode:_,ObjectNode:w,OperatorNode:M,SymbolNode:N});return n(e8,{string:function(e){return this(c(e),{},!1)},"string, boolean":function(e,t){return this(c(e),{},t)},"string, Object":function(e,t){return this(c(e),t,!1)},"string, Object, boolean":function(e,t,n){return this(c(e),t,n)},Node:function(e){return this(e,{},!1)},"Node, boolean":function(e,t){return this(e,{},t)},"Node, Object":function(e,t){return this(e,t,!1)},"Node, Object, boolean":function(e,t,n){var r=function(){var e=[p,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},k,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],t=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],n=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],r={};return r.firstRules=e.concat(t,n),r.distrDivRules=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],r.sucDivRules=n,r.firstRulesAgain=e.concat(t),r.finalRules=[p,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},k,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],r}(),a=function(e,t,n,r){var a=[],i=d(e,r,t,{exactFractions:!1}),s="+-*"+((n=!!n)?"/":"");!function e(t){var n=t.type;if("FunctionNode"===n)throw new Error("There is an unsolved function call");if("OperatorNode"===n)if("^"===t.op){if("ConstantNode"!==t.args[1].type||!PH(parseFloat(t.args[1].value)))throw new Error("There is a non-integer exponent");e(t.args[0])}else{if(-1===s.indexOf(t.op))throw new Error("Operator "+t.op+" invalid in polynomial expression");for(var r=0;r=1){var u,l;e=D(e);var c,h=!0,f=!1;for(e=d(e,r.firstRules,{},s);l=h?r.distrDivRules:r.sucDivRules,h=!h,(c=(e=d(e,l,{},o)).toString())!==u;)f=!0,u=c;f&&(e=d(e,r.firstRulesAgain,{},s)),e=d(e,r.finalRules,{},s)}var m=[],g={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===i&&(e.args[0]=T(e.args[0],m),e.args[1]=T(e.args[1])),n&&(g.numerator=e.args[0],g.denominator=e.args[1])):(1===i&&(e=T(e,m)),n&&(g.numerator=e,g.denominator=null)),n?(g.coefficients=m,g.variables=a.variables,g.expression=e,g):e}});function D(e,t,n){var r=e.type,a=arguments.length>1;if("OperatorNode"===r&&e.isBinary()){var i,s=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(s=(i=parseFloat(e.args[1].value))>=2&&PH(i))),s){if(i>2){var o=e.args[0],u=new M("^","pow",[e.args[0].cloneDeep(),new x(i-1)]);e=new M("*","multiply",[o,u])}else e=new M("*","multiply",[e.args[0],e.args[0].cloneDeep()]);a&&("content"===n?t.content=e:t.args[n]=e)}}if("ParenthesisNode"===r)D(e.content,e,"content");else if("ConstantNode"!==r&&"SymbolNode"!==r)for(var l=0;ln&&(t[l]=0),t[l]+=s.cte*("+"===s.oper?1:-1),void(n=Math.max(l,n))}s.cte=l,""===s.fire&&(t[0]+=s.cte*("+"===s.oper?1:-1))}}(e,null,{cte:1,oper:"+",fire:""});for(var a,i=!0,s=n=t.length-1;s>=0;s--)if(0!==t[s]){var o=new x(i?t[s]:Math.abs(t[s])),u=t[s]<0?"-":"+";if(s>0){var l=new N(r);if(s>1){var c=new x(s);l=new M("^","pow",[l,c])}o=-1===t[s]&&i?new M("-","unaryMinus",[l]):1===Math.abs(t[s])?l:new M("*","multiply",[o,l])}a=i?o:"+"===u?new M("+","add",[a,o]):new M("-","subtract",[a,o]),i=!1}return i?new x(0):a}})),n8=RH("derivative",["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,config:n,parse:r,simplify:a,equal:i,isZero:s,numeric:o,ConstantNode:u,FunctionNode:l,OperatorNode:c,ParenthesisNode:p,SymbolNode:d}=e,h=t("derivative",{"Node, SymbolNode, Object":function(e,t,n){var r={};m(r,e,t.name);var i=g(e,r);return n.simplify?a(i):i},"Node, SymbolNode":function(e,t){return this(e,t,{simplify:!0})},"string, SymbolNode":function(e,t){return this(r(e),t)},"string, SymbolNode, Object":function(e,t,n){return this(r(e),t,n)},"string, string":function(e,t){return this(r(e),r(t))},"string, string, Object":function(e,t,n){return this(r(e),r(t),n)},"Node, string":function(e,t){return this(e,r(t))},"Node, string, Object":function(e,t,n){return this(e,r(t),n)}});h._simplify=!0,h.toTex=function(e){return f.apply(null,e.args)};var f=t("_derivTex",{"Node, SymbolNode":function(e,t){return uH(e)&&"string"===xH(e.value)?f(r(e.value).toString(),t.toString(),1):f(e.toTex(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===xH(t.value))return f(e,r(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,n){return f(e.toString(),t.name,n.value)},"string, string, number":function(e,t,n){return(1===n?"{d\\over d"+t+"}":"{d^{"+n+"}\\over d"+t+"^{"+n+"}}")+"\\left[".concat(e,"\\right]")}}),m=t("constTag",{"Object, ConstantNode, string":function(e,t){return e[t]=!0,!0},"Object, SymbolNode, string":function(e,t,n){return t.name!==n&&(e[t]=!0,!0)},"Object, ParenthesisNode, string":function(e,t,n){return m(e,t.content,n)},"Object, FunctionAssignmentNode, string":function(e,t,n){return-1===t.params.indexOf(n)?(e[t]=!0,!0):m(e,t.expr,n)},"Object, FunctionNode | OperatorNode, string":function(e,t,n){if(t.args.length>0){for(var r=m(e,t.args[0],n),a=1;a0){var r=e.args.filter((function(e){return void 0===t[e]})),a=1===r.length?r[0]:new c("*","multiply",r),o=n.concat(g(a,t));return new c("*","multiply",o)}return new c("+","add",e.args.map((function(n){return new c("*","multiply",e.args.map((function(e){return e===n?g(e,t):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var u=e.args[0],p=e.args[1];return void 0!==t[p]?new c("/","divide",[g(u,t),p]):void 0!==t[u]?new c("*","multiply",[new c("-","unaryMinus",[u]),new c("/","divide",[g(p,t),new c("^","pow",[p.clone(),y(2)])])]):new c("/","divide",[new c("-","subtract",[new c("*","multiply",[g(u,t),p.clone()]),new c("*","multiply",[u.clone(),g(p,t)])]),new c("^","pow",[p.clone(),y(2)])])}if("^"===e.op&&e.isBinary()){var d=e.args[0],h=e.args[1];if(void 0!==t[d])return uH(d)&&(s(d.value)||i(d.value,1))?y(0):new c("*","multiply",[e,new c("*","multiply",[new l("log",[d.clone()]),g(h.clone(),t)])]);if(void 0!==t[h]){if(uH(h)){if(s(h.value))return y(0);if(i(h.value,1))return g(d,t)}var f=new c("^","pow",[d.clone(),new c("-","subtract",[h,y(1)])]);return new c("*","multiply",[h.clone(),new c("*","multiply",[g(d,t),f])])}return new c("*","multiply",[new c("^","pow",[d.clone(),h.clone()]),new c("+","add",[new c("*","multiply",[g(d,t),new c("/","divide",[h.clone(),d.clone()])]),new c("*","multiply",[g(h,t),new l("log",[d.clone()])])])])}throw new Error('Operator "'+e.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function y(e,t){return new u(o(e,t||n.number))}return h})),r8="parser",a8=RH(r8,["typed","Parser"],(e=>{var{typed:t,Parser:n}=e;return t(r8,{"":function(){return new n}})}));function i8(e,t,n){var r=e.filter((function(e){return yH(e)&&!(e.name in t)&&!n.has(e.name)}))[0];if(!r)throw new Error('No undefined variable found in inline expression "'+e+'"');var a=r.name,i=T7(n),s=e.compile();return function(e){return i.set(a,e),s.evaluate(i)}}var s8=RH("filter",["typed"],(e=>{var{typed:t}=e;function n(e,t,n){var a,i;return e[0]&&(a=e[0].compile().evaluate(n)),e[1]&&(i=yH(e[1])||lH(e[1])?e[1].compile().evaluate(n):i8(e[1],t,n)),r(a,i)}n.rawArgs=!0;var r=t("filter",{"Array, function":o8,"Matrix, function":function(e,t){return e.create(o8(e.toArray(),t))},"Array, RegExp":yq,"Matrix, RegExp":function(e,t){return e.create(yq(e.toArray(),t))}});return n}),{isTransformFunction:!0});function o8(e,t){var n=dj(t);return gq(e,(function(e,r,a){return 1===n?t(e):2===n?t(e,[r+1]):t(e,[r+1],a)}))}var u8=RH("forEach",["typed"],(e=>{var{typed:t}=e;function n(e,t,n){var a,i;return e[0]&&(a=e[0].compile().evaluate(n)),e[1]&&(i=yH(e[1])||lH(e[1])?e[1].compile().evaluate(n):i8(e[1],t,n)),r(a,i)}n.rawArgs=!0;var r=t("forEach",{"Array | Matrix, function":function(e,t){var n=dj(t);!function r(a,i){Array.isArray(a)?mq(a,(function(e,t){r(e,i.concat(t+1))})):1===n?t(a):2===n?t(a,i):t(a,i,e)}(e.valueOf(),[])}});return n}),{isTransformFunction:!0}),l8=RH("map",["typed"],(e=>{var{typed:t}=e;function n(e,t,n){var a,i;return e[0]&&(a=e[0].compile().evaluate(n)),e[1]&&(i=yH(e[1])||lH(e[1])?e[1].compile().evaluate(n):i8(e[1],t,n)),r(a,i)}n.rawArgs=!0;var r=t("map",{"Array, function":function(e,t){return c8(e,t,e)},"Matrix, function":function(e,t){return e.create(c8(e.valueOf(),t,e))}});return n}),{isTransformFunction:!0});function c8(e,t,n){var r=dj(t);return function e(a,i){return Array.isArray(a)?fq(a,(function(t,n){return e(t,i.concat(n+1))})):1===r?t(a):2===r?t(a,i):t(a,i,n)}(e,[])}var p8=RH("apply",["typed","isInteger"],(e=>{var{typed:t,isInteger:n}=e,r=xK({typed:t,isInteger:n});return t("apply",{"...any":function(e){var t=e[1];OP(t)?e[1]=t-1:RP(t)&&(e[1]=t.minus(1));try{return r.apply(null,e)}catch(e){throw w7(e)}}})}),{isTransformFunction:!0});function d8(e){if(2===e.length&&jP(e[0])){var t=(e=e.slice())[1];OP(t)?e[1]=t-1:RP(t)&&(e[1]=t.minus(1))}return e}var h8="diff",f8=RH(h8,["typed","matrix","subtract","number","bignumber"],(e=>{var{typed:t,matrix:n,subtract:r,number:a,bignumber:i}=e,s=kZ({typed:t,matrix:n,subtract:r,number:a,bignumber:i});return t(h8,{"...any":function(e){e=d8(e);try{return s.apply(null,e)}catch(e){throw w7(e)}}})}),{isTransformFunction:!0}),m8=RH("subset",["typed","matrix"],(e=>{var{typed:t,matrix:n}=e,r=AJ({typed:t,matrix:n});return t("subset",{"...any":function(e){try{return r.apply(null,e)}catch(e){throw w7(e)}}})}),{isTransformFunction:!0}),g8=RH("concat",["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:n,isInteger:r}=e,a=iX({typed:t,matrix:n,isInteger:r});return t("concat",{"...any":function(e){var t=e.length-1,n=e[t];OP(n)?e[t]=n-1:RP(n)&&(e[t]=n.minus(1));try{return a.apply(null,e)}catch(e){throw w7(e)}}})}),{isTransformFunction:!0}),y8=RH("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:n,numeric:r,larger:a}=e,i=jQ({typed:t,config:n,numeric:r,larger:a});return t("max",{"...any":function(e){e=d8(e);try{return i.apply(null,e)}catch(e){throw w7(e)}}})}),{isTransformFunction:!0}),b8=RH("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:n,numeric:r,smaller:a}=e,i=HX({typed:t,config:n,numeric:r,smaller:a});return t("min",{"...any":function(e){e=d8(e);try{return i.apply(null,e)}catch(e){throw w7(e)}}})}),{isTransformFunction:!0}),x8=RH("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:n,matrix:r,bignumber:a,smaller:i,smallerEq:s,larger:o,largerEq:u}=e,l=KZ({typed:t,config:n,matrix:r,bignumber:a,smaller:i,smallerEq:s,larger:o,largerEq:u});return t("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),l.apply(null,e)}})}),{isTransformFunction:!0}),v8=RH("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:n,add:r,numeric:a}=e,i=hQ({typed:t,config:n,add:r,numeric:a});return t("sum",{"...any":function(e){e=d8(e);try{return i.apply(null,e)}catch(e){throw w7(e)}}})}),{isTransformFunction:!0}),_8="cumsum",w8=RH(_8,["typed","add","unaryPlus"],(e=>{var{typed:t,add:n,unaryPlus:r}=e,a=wZ({typed:t,add:n,unaryPlus:r});return t(_8,{"...any":function(e){if(2===e.length&&jP(e[0])){var t=e[1];OP(t)?e[1]=t-1:RP(t)&&(e[1]=t.minus(1))}try{return a.apply(null,e)}catch(e){throw w7(e)}}})}),{isTransformFunction:!0}),M8=RH("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e,i=qQ({typed:t,Index:n,matrix:r,range:a});return t("row",{"...any":function(e){var t=e.length-1,n=e[t];OP(n)&&(e[t]=n-1);try{return i.apply(null,e)}catch(e){throw w7(e)}}})}),{isTransformFunction:!0}),N8=RH("column",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e,i=r0({typed:t,Index:n,matrix:r,range:a});return t("column",{"...any":function(e){var t=e.length-1,n=e[t];OP(n)&&(e[t]=n-1);try{return i.apply(null,e)}catch(e){throw w7(e)}}})}),{isTransformFunction:!0}),S8=RH("index",["Index"],(e=>{var{Index:t}=e;return function(){for(var e=[],n=0,r=arguments.length;n0?0:2;else if(a&&!0===a.isSet)a=a.map((function(e){return e-1}));else if(PP(a)||HP(a))a=a.map((function(e){return e-1}));else if(OP(a))a--;else if(RP(a))a=a.toNumber()-1;else if("string"!=typeof a)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");e[n]=a}var i=new t;return t.apply(i,e),i}}),{isTransformFunction:!0}),k8=RH("mean",["typed","add","divide"],(e=>{var{typed:t,add:n,divide:r}=e,a=G0({typed:t,add:n,divide:r});return t("mean",{"...any":function(e){e=d8(e);try{return a.apply(null,e)}catch(e){throw w7(e)}}})}),{isTransformFunction:!0}),D8="variance",T8=RH(D8,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:n,subtract:r,multiply:a,divide:i,apply:s,isNaN:o}=e,u=c1({typed:t,add:n,subtract:r,multiply:a,divide:i,apply:s,isNaN:o});return t(D8,{"...any":function(e){e=d8(e);try{return u.apply(null,e)}catch(e){throw w7(e)}}})}),{isTransformFunction:!0}),I8=RH("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:n,variance:r}=e,a=_1({typed:t,sqrt:n,variance:r});return t("std",{"...any":function(e){e=d8(e);try{return a.apply(null,e)}catch(e){throw w7(e)}}})}),{isTransformFunction:!0}),E8={},C8={},A8={},L8=K6({math:E8}),$8=X6({mathWithTransform:C8}),O8=Z6({Node:$8}),R8=c7({Node:$8}),F8=p7({Node:$8}),Y8=d7({Node:$8}),z8=h7({Node:$8}),B8=f7({Node:$8,ResultSet:H1}),P8=m7({Node:$8}),H8=g7({Node:$8}),j8=y7({Node:$8}),U8=b7({classes:A8}),q8=v7({Chain:L8,typed:e2}),W8=_7({Node:$8,typed:e2}),V8=N7({Node:$8,subset:Y3}),G8=S7({matrix:D3,Node:$8,subset:Y3}),K8=k7({Node:$8,size:O3}),J8=D7({Unit:E5,Node:$8,math:E8}),X8=I7({Node:$8,SymbolNode:J8,math:E8}),Z8=C7({AccessorNode:V8,ArrayNode:z8,AssignmentNode:G8,BlockNode:B8,ConditionalNode:P8,ConstantNode:H8,FunctionAssignmentNode:W8,FunctionNode:X8,IndexNode:K8,ObjectNode:O8,OperatorNode:R8,ParenthesisNode:F8,RangeNode:j8,RelationalNode:Y8,SymbolNode:J8,config:$H,numeric:C3,typed:e2}),Q8=A7({ConstantNode:H8,FunctionNode:X8,OperatorNode:R8,ParenthesisNode:F8,parse:Z8}),e9=R7({AccessorNode:V8,ArrayNode:z8,ConstantNode:H8,FunctionNode:X8,IndexNode:K8,ObjectNode:O8,OperatorNode:R8,ParenthesisNode:F8,SymbolNode:J8,add:k4,divide:f6,equal:n4,isZero:F2,multiply:j4,pow:S5,subtract:z3}),t9=Y7({parse:Z8,typed:e2}),n9=z7({parse:Z8}),r9=P7({parse:Z8,typed:e2}),a9=j7({bignumber:h2,fraction:S3,AccessorNode:V8,ArrayNode:z8,ConstantNode:H8,FunctionNode:X8,IndexNode:K8,ObjectNode:O8,OperatorNode:R8,ParenthesisNode:F8,SymbolNode:J8,add:k4,config:$H,divide:f6,equal:n4,isZero:F2,mathWithTransform:C8,matrix:D3,multiply:j4,parse:Z8,pow:S5,resolve:Q8,simplifyCore:e9,subtract:z3,typed:e2}),i9=q7({OperatorNode:R8,parse:Z8,simplify:a9,typed:e2}),s9=V7({parse:Z8,typed:e2}),o9=Z7({Help:n9,mathWithTransform:C8,typed:e2}),u9=Q7({evaluate:s9}),l9=t8({bignumber:h2,fraction:S3,AccessorNode:V8,ArrayNode:z8,ConstantNode:H8,FunctionNode:X8,IndexNode:K8,ObjectNode:O8,OperatorNode:R8,ParenthesisNode:F8,SymbolNode:J8,add:k4,config:$H,divide:f6,equal:n4,isZero:F2,mathWithTransform:C8,matrix:D3,multiply:j4,parse:Z8,pow:S5,simplify:a9,simplifyCore:e9,subtract:z3,typed:e2}),c9=n8({ConstantNode:H8,FunctionNode:X8,OperatorNode:R8,ParenthesisNode:F8,SymbolNode:J8,config:$H,equal:n4,isZero:F2,numeric:C3,parse:Z8,simplify:a9,typed:e2}),p9=a8({Parser:u9,typed:e2});LP(E8,{e:I1,false:E1,fineStructure:C1,i:L1,Infinity:$1,LN10:O1,LOG10E:R1,NaN:Y1,null:z1,phi:B1,SQRT1_2:j1,sackurTetrode:U1,tau:q1,true:W1,E:I1,version:V1,efimovFactor:K1,LN2:J1,pi:X1,replacer:Z1,reviver:U8,SQRT2:Q1,typed:e2,unaryPlus:t2,PI:X1,weakMixingAngle:n2,abs:r2,acos:a2,acot:i2,acsc:s2,addScalar:o2,arg:u2,asech:l2,asinh:c2,atan:p2,atanh:d2,bignumber:h2,bitNot:f2,boolean:m2,chain:q8,clone:g2,combinations:y2,complex:b2,conj:x2,cosh:v2,coth:_2,csc:w2,cube:M2,equalScalar:N2,erf:S2,exp:k2,expm1:D2,filter:T2,forEach:I2,format:E2,getMatrixDataType:C2,hex:A2,im:L2,isInteger:$2,isNegative:O2,isPositive:R2,isZero:F2,LOG2E:Y2,lgamma:z2,log10:B2,log2:P2,map:H2,multiplyScalar:j2,not:U2,number:q2,oct:W2,pickRandom:V2,print:G2,random:K2,re:J2,sec:X2,sign:Z2,sin:Q2,splitUnit:t3,square:n3,string:r3,tan:a3,typeOf:i3,acosh:s3,acsch:o3,apply:u3,asec:l3,bin:c3,combinationsWithRep:p3,cos:d3,csch:h3,isNaN:f3,isPrime:m3,randomInt:g3,sech:y3,sinh:b3,sparse:x3,sqrt:v3,tanh:_3,unaryMinus:w3,acoth:M3,cot:N3,fraction:S3,isNumeric:k3,matrix:D3,matrixFromFunction:T3,mod:I3,nthRoot:E3,numeric:C3,or:A3,prod:L3,reshape:$3,size:O3,smaller:R3,squeeze:F3,subset:Y3,subtract:z3,to:B3,transpose:P3,xgcd:H3,zeros:j3,and:U3,bitAnd:q3,bitXor:W3,cbrt:V3,compare:G3,compareText:K3,concat:J3,count:X3,ctranspose:Z3,diag:Q3,divideScalar:e4,dotDivide:t4,equal:n4,fft:r4,flatten:a4,gcd:i4,hasNumericValue:s4,hypot:o4,ifft:u4,kron:l4,largerEq:c4,leftShift:p4,lsolve:d4,matrixFromColumns:h4,min:f4,mode:m4,nthRoots:g4,ones:y4,partitionSelect:b4,resize:x4,rightArithShift:v4,round:_4,smallerEq:w4,unequal:M4,usolve:N4,xor:S4,add:k4,atan2:D4,bitOr:T4,catalan:I4,compareNatural:E4,cumsum:C4,deepEqual:A4,diff:L4,dot:$4,equalText:O4,floor:R4,identity:F4,invmod:Y4,larger:z4,log:B4,lsolveAll:P4,matrixFromRows:H4,multiply:j4,qr:U4,range:q4,rightLogShift:W4,setSize:V4,slu:G4,sum:K4,trace:J4,usolveAll:X4,asin:Z4,ceil:Q4,composition:e5,cross:t5,det:n5,distance:r5,dotMultiply:a5,fix:s5,intersect:l5,lcm:c5,log1p:d5,max:h5,quantileSeq:f5,row:m5,setCartesian:g5,setDistinct:y5,setIsSubset:b5,setPowerset:x5,sort:v5,column:_5,index:w5,inv:M5,pinv:N5,pow:S5,setDifference:k5,setMultiplicity:D5,sqrtm:I5,vacuumImpedance:C5,wienDisplacement:A5,atomicMass:L5,bohrMagneton:$5,boltzmann:O5,conductanceQuantum:R5,createUnit:F5,deuteronMass:Y5,dotPow:z5,electricConstant:B5,elementaryCharge:P5,expm:H5,faraday:j5,firstRadiation:U5,gamma:q5,gravitationConstant:W5,hartreeEnergy:V5,klitzing:G5,loschmidt:K5,magneticConstant:J5,molarMass:X5,molarPlanckConstant:Z5,neutronMass:Q5,nuclearMagneton:e6,planckCharge:t6,planckLength:n6,planckTemperature:r6,protonMass:a6,reducedPlanckConstant:i6,rydberg:s6,setIntersect:o6,speedOfLight:u6,stefanBoltzmann:l6,thomsonCrossSection:c6,avogadro:p6,bohrRadius:d6,coulomb:h6,divide:f6,electronMass:m6,factorial:g6,gravity:y6,inverseConductanceQuantum:b6,lup:x6,magneticFluxQuantum:v6,molarMassC12:_6,multinomial:w6,parse:Z8,permutations:M6,planckMass:N6,quantumOfCirculation:S6,resolve:Q8,secondRadiation:k6,simplifyCore:e9,stirlingS2:D6,unit:T6,bellNumbers:I6,compile:t9,eigs:E6,fermiCoupling:C6,leafCount:r9,mean:A6,molarVolume:L6,planckConstant:$6,setSymDifference:O6,simplify:a9,symbolicEqual:i9,classicalElectronRadius:R6,evaluate:s9,help:o9,lusolve:F6,median:Y6,rationalize:l9,setUnion:z6,variance:B6,derivative:c9,kldivergence:P6,norm:H6,planckTime:j6,rotationMatrix:U6,gasConstant:q6,parser:p9,std:W6,mad:V6,rotate:G6,config:$H}),LP(C8,E8,{filter:s8({typed:e2}),forEach:u8({typed:e2}),map:l8({typed:e2}),apply:p8({isInteger:$2,typed:e2}),diff:f8({bignumber:h2,matrix:D3,number:q2,subtract:z3,typed:e2}),subset:m8({matrix:D3,typed:e2}),concat:g8({isInteger:$2,matrix:D3,typed:e2}),max:y8({config:$H,larger:z4,numeric:C3,typed:e2}),min:b8({config:$H,numeric:C3,smaller:R3,typed:e2}),range:x8({bignumber:h2,matrix:D3,config:$H,larger:z4,largerEq:c4,smaller:R3,smallerEq:w4,typed:e2}),sum:v8({add:k4,config:$H,numeric:C3,typed:e2}),cumsum:w8({add:k4,typed:e2,unaryPlus:t2}),row:M8({Index:u5,matrix:D3,range:q4,typed:e2}),column:N8({Index:u5,matrix:D3,range:q4,typed:e2}),index:S8({Index:u5}),mean:k8({add:k4,divide:f6,typed:e2}),variance:T8({add:k4,apply:u3,divide:f6,isNaN:f3,multiply:j4,subtract:z3,typed:e2}),std:I8({sqrt:v3,typed:e2,variance:B6})}),LP(A8,{BigNumber:D1,Chain:L8,Complex:T1,Fraction:A1,Matrix:F1,Node:$8,ObjectNode:O8,OperatorNode:R8,ParenthesisNode:F8,Range:P1,RelationalNode:Y8,ResultSet:H1,ArrayNode:z8,BlockNode:B8,ConditionalNode:P8,ConstantNode:H8,DenseMatrix:G1,RangeNode:j8,FunctionAssignmentNode:W8,SparseMatrix:e3,AccessorNode:V8,AssignmentNode:G8,IndexNode:K8,FibonacciHeap:i5,ImmutableDenseMatrix:o5,Index:u5,Spa:T5,Unit:E5,SymbolNode:J8,FunctionNode:X8,Help:n9,Parser:u9}),L8.createProxy(E8);var d9={createBigNumberClass:zH},h9={createComplexClass:lj},f9={createMatrixClass:PU},m9={MatrixDependencies:f9,createDenseMatrixClass:Mq},g9={createFractionClass:BU},y9={BigNumberDependencies:d9,ComplexDependencies:h9,DenseMatrixDependencies:m9,FractionDependencies:g9,createTyped:zq},b9={typedDependencies:y9,createAbs:vW},x9={createNode:X6},v9={typedDependencies:y9,createEqualScalar:zV},_9={MatrixDependencies:f9,equalScalarDependencies:v9,typedDependencies:y9,createSparseMatrixClass:aK},w9={DenseMatrixDependencies:m9,MatrixDependencies:f9,SparseMatrixDependencies:_9,typedDependencies:y9,createMatrix:QK},M9={matrixDependencies:w9,typedDependencies:y9,createSubset:AJ},N9={NodeDependencies:x9,subsetDependencies:M9,createAccessorNode:N7},S9={ComplexDependencies:h9,typedDependencies:y9,createAcos:wW},k9={ComplexDependencies:h9,typedDependencies:y9,createAcosh:mK},D9={BigNumberDependencies:d9,typedDependencies:y9,createAcot:PW},T9={BigNumberDependencies:d9,ComplexDependencies:h9,typedDependencies:y9,createAcoth:VK},I9={BigNumberDependencies:d9,ComplexDependencies:h9,typedDependencies:y9,createAcsc:jW},E9={BigNumberDependencies:d9,typedDependencies:y9,createAcsch:yK},C9={typedDependencies:y9,createAddScalar:qW},A9={DenseMatrixDependencies:m9,SparseMatrixDependencies:_9,addScalarDependencies:C9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,createAdd:cZ},L9={typedDependencies:y9,createNot:zG},$9={BigNumberDependencies:d9,matrixDependencies:w9,typedDependencies:y9,createZeros:WJ},O9={equalScalarDependencies:v9,matrixDependencies:w9,notDependencies:L9,typedDependencies:y9,zerosDependencies:$9,createAnd:VJ},R9={typedDependencies:y9,createIsInteger:oG},F9={isIntegerDependencies:R9,typedDependencies:y9,createApply:xK},Y9={isIntegerDependencies:R9,typedDependencies:y9,createApplyTransform:p8},z9={typedDependencies:y9,createArg:WW},B9={NodeDependencies:x9,createArrayNode:h7},P9={BigNumberDependencies:d9,ComplexDependencies:h9,typedDependencies:y9,createAsec:wK},H9={BigNumberDependencies:d9,ComplexDependencies:h9,typedDependencies:y9,createAsech:GW},j9={ComplexDependencies:h9,typedDependencies:y9,createAsin:bQ},U9={typedDependencies:y9,createAsinh:KW},q9={matrixDependencies:w9,NodeDependencies:x9,subsetDependencies:M9,createAssignmentNode:S7},W9={typedDependencies:y9,createAtan:JW},V9={BigNumberDependencies:d9,DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,createAtan2:hZ},G9={ComplexDependencies:h9,typedDependencies:y9,createAtanh:ZW},K9={BigNumberDependencies:d9,typedDependencies:y9,createBignumber:QW},J9={FractionDependencies:g9,typedDependencies:y9,createFraction:KK},X9={typedDependencies:y9,createNumber:BG},Z9={bignumberDependencies:K9,fractionDependencies:J9,numberDependencies:X9,createNumeric:yJ},Q9={numericDependencies:Z9,typedDependencies:y9,createDivideScalar:fX},eee={DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,createEqual:bX},tee={BigNumberDependencies:d9,DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,zerosDependencies:$9,createRound:nZ},nee={DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,roundDependencies:tee,typedDependencies:y9,zerosDependencies:$9,createCeil:wQ},ree={DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,roundDependencies:tee,typedDependencies:y9,zerosDependencies:$9,createFloor:LZ},aee={ComplexDependencies:h9,DenseMatrixDependencies:m9,ceilDependencies:nee,equalScalarDependencies:v9,floorDependencies:ree,matrixDependencies:w9,typedDependencies:y9,zerosDependencies:$9,createFix:RQ},iee={typedDependencies:y9,createFormat:tG},see={typedDependencies:y9,createIsNumeric:XK},oee={typedDependencies:y9,createMultiplyScalar:LG},uee={BigNumberDependencies:d9,DenseMatrixDependencies:m9,SparseMatrixDependencies:_9,matrixDependencies:w9,typedDependencies:y9,createIdentity:OZ},lee={typedDependencies:y9,createIsZero:bG},cee={typedDependencies:y9,createConj:IV},pee={matrixDependencies:w9,typedDependencies:y9,createSize:SJ},dee={addScalarDependencies:C9,conjDependencies:cee,multiplyScalarDependencies:oee,sizeDependencies:pee,typedDependencies:y9,createDot:DZ},hee={addScalarDependencies:C9,dotDependencies:dee,equalScalarDependencies:v9,matrixDependencies:w9,multiplyScalarDependencies:oee,typedDependencies:y9,createMultiply:WZ},fee={typedDependencies:y9,createUnaryMinus:qK},mee={DenseMatrixDependencies:m9,addScalarDependencies:C9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,unaryMinusDependencies:fee,createSubtract:zJ},gee={divideScalarDependencies:Q9,isZeroDependencies:lee,matrixDependencies:w9,multiplyDependencies:hee,subtractDependencies:mee,typedDependencies:y9,unaryMinusDependencies:fee,createDet:DQ},yee={absDependencies:b9,addScalarDependencies:C9,detDependencies:gee,divideScalarDependencies:Q9,identityDependencies:uee,matrixDependencies:w9,multiplyDependencies:hee,typedDependencies:y9,unaryMinusDependencies:fee,createInv:s0},bee={ComplexDependencies:h9,fractionDependencies:J9,identityDependencies:uee,invDependencies:yee,matrixDependencies:w9,multiplyDependencies:hee,numberDependencies:X9,typedDependencies:y9,createPow:l0},xee={BigNumberDependencies:d9,ComplexDependencies:h9,FractionDependencies:g9,absDependencies:b9,addScalarDependencies:C9,divideScalarDependencies:Q9,equalDependencies:eee,fixDependencies:aee,formatDependencies:iee,isNumericDependencies:see,multiplyScalarDependencies:oee,numberDependencies:X9,powDependencies:bee,roundDependencies:tee,subtractDependencies:mee,createUnitClass:v0},vee={BigNumberDependencies:d9,UnitDependencies:xee,createAtomicMass:gU},_ee={BigNumberDependencies:d9,UnitDependencies:xee,createAvogadro:yU},wee={typedDependencies:y9,createIsNegative:fG},Mee={typedDependencies:y9,createCombinations:SV},Nee={BigNumberDependencies:d9,ComplexDependencies:h9,multiplyScalarDependencies:oee,powDependencies:bee,typedDependencies:y9,createGamma:T0},See={gammaDependencies:Nee,typedDependencies:y9,createFactorial:L0},kee={DenseMatrixDependencies:m9,matrixDependencies:w9,typedDependencies:y9,createLarger:zZ},Dee={bignumberDependencies:K9,addScalarDependencies:C9,combinationsDependencies:Mee,divideScalarDependencies:Q9,factorialDependencies:See,isIntegerDependencies:R9,isNegativeDependencies:wee,largerDependencies:kee,multiplyScalarDependencies:oee,numberDependencies:X9,powDependencies:bee,subtractDependencies:mee,typedDependencies:y9,createStirlingS2:P0},Tee={addScalarDependencies:C9,isIntegerDependencies:R9,isNegativeDependencies:wee,stirlingS2Dependencies:Dee,typedDependencies:y9,createBellNumbers:q0},Iee={formatDependencies:iee,typedDependencies:y9,createBin:MK},Eee={equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,createBitAnd:KJ},Cee={typedDependencies:y9,createBitNot:yV},Aee={DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,createBitOr:mZ},Lee={DenseMatrixDependencies:m9,matrixDependencies:w9,typedDependencies:y9,createBitXor:XJ},$ee={createResultSet:jU},Oee={NodeDependencies:x9,ResultSetDependencies:$ee,createBlockNode:f7},Ree={BigNumberDependencies:d9,UnitDependencies:xee,createBohrMagneton:Jj},Fee={BigNumberDependencies:d9,UnitDependencies:xee,createBohrRadius:nU},Yee={BigNumberDependencies:d9,UnitDependencies:xee,createBoltzmann:bU},zee={typedDependencies:y9,createBoolean:xV},Bee={addScalarDependencies:C9,combinationsDependencies:Mee,divideScalarDependencies:Q9,isIntegerDependencies:R9,isNegativeDependencies:wee,multiplyScalarDependencies:oee,typedDependencies:y9,createCatalan:yZ},Pee={BigNumberDependencies:d9,ComplexDependencies:h9,FractionDependencies:g9,isNegativeDependencies:wee,matrixDependencies:w9,typedDependencies:y9,unaryMinusDependencies:fee,createCbrt:QJ},Hee={createChainClass:K6},jee={ChainDependencies:Hee,typedDependencies:y9,createChain:v7},Uee={BigNumberDependencies:d9,UnitDependencies:xee,createClassicalElectronRadius:rU},qee={typedDependencies:y9,createClone:_V},Wee={DenseMatrixDependencies:m9,matrixDependencies:w9,typedDependencies:y9,createSmaller:TJ},Vee={DenseMatrixDependencies:m9,smallerDependencies:Wee,createImmutableDenseMatrixClass:FQ},Gee={ImmutableDenseMatrixDependencies:Vee,createIndexClass:YQ},Kee={DenseMatrixDependencies:m9,matrixDependencies:w9,typedDependencies:y9,createLargerEq:LX},Jee={DenseMatrixDependencies:m9,matrixDependencies:w9,typedDependencies:y9,createSmallerEq:aZ},Xee={bignumberDependencies:K9,matrixDependencies:w9,largerDependencies:kee,largerEqDependencies:Kee,smallerDependencies:Wee,smallerEqDependencies:Jee,typedDependencies:y9,createRange:KZ},Zee={IndexDependencies:Gee,matrixDependencies:w9,rangeDependencies:Xee,typedDependencies:y9,createColumn:r0},Qee={IndexDependencies:Gee,matrixDependencies:w9,rangeDependencies:Xee,typedDependencies:y9,createColumnTransform:N8},ete={typedDependencies:y9,createCombinationsWithRep:SK},tte={BigNumberDependencies:d9,DenseMatrixDependencies:m9,FractionDependencies:g9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,createCompare:tX},nte={compareDependencies:tte,typedDependencies:y9,createCompareNatural:vZ},rte={matrixDependencies:w9,typedDependencies:y9,createCompareText:rX},ate={NodeDependencies:x9,createConditionalNode:m7},ite={NodeDependencies:x9,createConstantNode:g7},ste={NodeDependencies:x9,typedDependencies:y9,createFunctionAssignmentNode:_7},ote={UnitDependencies:xee,NodeDependencies:x9,createSymbolNode:D7},ute={NodeDependencies:x9,SymbolNodeDependencies:ote,createFunctionNode:I7},lte={NodeDependencies:x9,sizeDependencies:pee,createIndexNode:k7},cte={NodeDependencies:x9,createObjectNode:Z6},pte={NodeDependencies:x9,createOperatorNode:c7},dte={NodeDependencies:x9,createParenthesisNode:p7},hte={NodeDependencies:x9,createRangeNode:y7},fte={NodeDependencies:x9,createRelationalNode:d7},mte={AccessorNodeDependencies:N9,ArrayNodeDependencies:B9,AssignmentNodeDependencies:q9,BlockNodeDependencies:Oee,ConditionalNodeDependencies:ate,ConstantNodeDependencies:ite,FunctionAssignmentNodeDependencies:ste,FunctionNodeDependencies:ute,IndexNodeDependencies:lte,ObjectNodeDependencies:cte,OperatorNodeDependencies:pte,ParenthesisNodeDependencies:dte,RangeNodeDependencies:hte,RelationalNodeDependencies:fte,SymbolNodeDependencies:ote,numericDependencies:Z9,typedDependencies:y9,createParse:C7},gte={parseDependencies:mte,typedDependencies:y9,createCompile:Y7},yte={ComplexDependencies:h9,typedDependencies:y9,createComplex:DV},bte={typedDependencies:y9,createIsPositive:gG},xte={addScalarDependencies:C9,combinationsDependencies:Mee,isIntegerDependencies:R9,isNegativeDependencies:wee,isPositiveDependencies:bte,largerDependencies:kee,typedDependencies:y9,createComposition:NQ},vte={isIntegerDependencies:R9,matrixDependencies:w9,typedDependencies:y9,createConcat:iX},_te={isIntegerDependencies:R9,matrixDependencies:w9,typedDependencies:y9,createConcatTransform:g8},wte={BigNumberDependencies:d9,UnitDependencies:xee,createConductanceQuantum:Xj},Mte={typedDependencies:y9,createCos:DK},Nte={typedDependencies:y9,createCosh:CV},Ste={BigNumberDependencies:d9,typedDependencies:y9,createCot:GK},kte={BigNumberDependencies:d9,typedDependencies:y9,createCoth:LV},Dte={BigNumberDependencies:d9,UnitDependencies:xee,createCoulomb:Gj},Tte={multiplyScalarDependencies:oee,numericDependencies:Z9,typedDependencies:y9,createProd:_J},Ite={prodDependencies:Tte,sizeDependencies:pee,typedDependencies:y9,createCount:uX},Ete={UnitDependencies:xee,typedDependencies:y9,createCreateUnit:w0},Cte={matrixDependencies:w9,multiplyDependencies:hee,subtractDependencies:mee,typedDependencies:y9,createCross:kQ},Ate={BigNumberDependencies:d9,typedDependencies:y9,createCsc:$V},Lte={BigNumberDependencies:d9,typedDependencies:y9,createCsch:IK},$te={matrixDependencies:w9,typedDependencies:y9,createTranspose:HJ},Ote={conjDependencies:cee,transposeDependencies:$te,typedDependencies:y9,createCtranspose:cX},Rte={typedDependencies:y9,createCube:RV},Fte={BigNumberDependencies:d9,typedDependencies:y9,createUnaryPlus:xW},Yte={addDependencies:A9,typedDependencies:y9,unaryPlusDependencies:Fte,createCumSum:wZ},zte={addDependencies:A9,typedDependencies:y9,unaryPlusDependencies:Fte,createCumSumTransform:w8},Bte={equalDependencies:eee,typedDependencies:y9,createDeepEqual:NZ},Pte={divideScalarDependencies:Q9,equalScalarDependencies:v9,invDependencies:yee,matrixDependencies:w9,multiplyDependencies:hee,typedDependencies:y9,createDivide:C0},Hte={ConstantNodeDependencies:ite,FunctionNodeDependencies:ute,OperatorNodeDependencies:pte,ParenthesisNodeDependencies:dte,parseDependencies:mte,createResolve:A7},jte={AccessorNodeDependencies:N9,ArrayNodeDependencies:B9,ConstantNodeDependencies:ite,FunctionNodeDependencies:ute,IndexNodeDependencies:lte,ObjectNodeDependencies:cte,OperatorNodeDependencies:pte,ParenthesisNodeDependencies:dte,SymbolNodeDependencies:ote,addDependencies:A9,divideDependencies:Pte,equalDependencies:eee,isZeroDependencies:lee,multiplyDependencies:hee,powDependencies:bee,subtractDependencies:mee,createSimplifyCore:R7},Ute={bignumberDependencies:K9,fractionDependencies:J9,AccessorNodeDependencies:N9,ArrayNodeDependencies:B9,ConstantNodeDependencies:ite,FunctionNodeDependencies:ute,IndexNodeDependencies:lte,ObjectNodeDependencies:cte,OperatorNodeDependencies:pte,ParenthesisNodeDependencies:dte,SymbolNodeDependencies:ote,addDependencies:A9,divideDependencies:Pte,equalDependencies:eee,isZeroDependencies:lee,matrixDependencies:w9,multiplyDependencies:hee,parseDependencies:mte,powDependencies:bee,resolveDependencies:Hte,simplifyCoreDependencies:jte,subtractDependencies:mee,typedDependencies:y9,createSimplify:j7},qte={ConstantNodeDependencies:ite,FunctionNodeDependencies:ute,OperatorNodeDependencies:pte,ParenthesisNodeDependencies:dte,SymbolNodeDependencies:ote,equalDependencies:eee,isZeroDependencies:lee,numericDependencies:Z9,parseDependencies:mte,simplifyDependencies:Ute,typedDependencies:y9,createDerivative:n8},Wte={BigNumberDependencies:d9,UnitDependencies:xee,createDeuteronMass:lU},Vte={DenseMatrixDependencies:m9,SparseMatrixDependencies:_9,matrixDependencies:w9,typedDependencies:y9,createDiag:dX},Gte={matrixDependencies:w9,numberDependencies:X9,subtractDependencies:mee,typedDependencies:y9,createDiff:kZ},Kte={bignumberDependencies:K9,matrixDependencies:w9,numberDependencies:X9,subtractDependencies:mee,typedDependencies:y9,createDiffTransform:f8},Jte={ComplexDependencies:h9,typedDependencies:y9,createSqrt:HK},Xte={absDependencies:b9,addScalarDependencies:C9,divideScalarDependencies:Q9,multiplyScalarDependencies:oee,sqrtDependencies:Jte,subtractDependencies:mee,typedDependencies:y9,unaryMinusDependencies:fee,createDistance:IQ},Zte={DenseMatrixDependencies:m9,divideScalarDependencies:Q9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,createDotDivide:gX},Qte={equalScalarDependencies:v9,matrixDependencies:w9,multiplyScalarDependencies:oee,typedDependencies:y9,createDotMultiply:CQ},ene={DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,powDependencies:bee,typedDependencies:y9,createDotPow:N0},tne={BigNumberDependencies:d9,createE:Tj},nne={BigNumberDependencies:d9,createEfimovFactor:mU},rne={matrixDependencies:w9,typedDependencies:y9,createFlatten:_X},ane={typedDependencies:y9,createIm:iG},ine={flattenDependencies:rne,matrixDependencies:w9,sizeDependencies:pee,typedDependencies:y9,createMatrixFromColumns:PX},sne={BigNumberDependencies:d9,FractionDependencies:g9,complexDependencies:yte,typedDependencies:y9,createSign:nK},one={addScalarDependencies:C9,complexDependencies:yte,conjDependencies:cee,divideScalarDependencies:Q9,equalDependencies:eee,identityDependencies:uee,isZeroDependencies:lee,matrixDependencies:w9,multiplyScalarDependencies:oee,signDependencies:sne,sqrtDependencies:Jte,subtractDependencies:mee,typedDependencies:y9,unaryMinusDependencies:fee,zerosDependencies:$9,createQr:VZ},une={typedDependencies:y9,createRe:QG},lne={typedDependencies:y9,createSin:rK},cne={DenseMatrixDependencies:m9,divideScalarDependencies:Q9,equalScalarDependencies:v9,matrixDependencies:w9,multiplyScalarDependencies:oee,subtractDependencies:mee,typedDependencies:y9,createUsolve:uZ},pne={DenseMatrixDependencies:m9,divideScalarDependencies:Q9,equalScalarDependencies:v9,matrixDependencies:w9,multiplyScalarDependencies:oee,subtractDependencies:mee,typedDependencies:y9,createUsolveAll:gQ},dne={absDependencies:b9,addDependencies:A9,addScalarDependencies:C9,atanDependencies:W9,bignumberDependencies:K9,columnDependencies:Zee,complexDependencies:yte,cosDependencies:Mte,diagDependencies:Vte,divideScalarDependencies:Q9,dotDependencies:dee,equalDependencies:eee,flattenDependencies:rne,imDependencies:ane,invDependencies:yee,largerDependencies:kee,matrixDependencies:w9,matrixFromColumnsDependencies:ine,multiplyDependencies:hee,multiplyScalarDependencies:oee,numberDependencies:X9,qrDependencies:one,reDependencies:une,sinDependencies:lne,smallerDependencies:Wee,sqrtDependencies:Jte,subtractDependencies:mee,typedDependencies:y9,usolveDependencies:cne,usolveAllDependencies:pne,createEigs:W0},hne={BigNumberDependencies:d9,UnitDependencies:xee,createElectricConstant:Wj},fne={BigNumberDependencies:d9,UnitDependencies:xee,createElectronMass:aU},mne={BigNumberDependencies:d9,UnitDependencies:xee,createElementaryCharge:Kj},gne={compareTextDependencies:rte,isZeroDependencies:lee,typedDependencies:y9,createEqualText:IZ},yne={typedDependencies:y9,createErf:BV},bne={parseDependencies:mte,typedDependencies:y9,createEvaluate:V7},xne={typedDependencies:y9,createExp:WV},vne={absDependencies:b9,addDependencies:A9,identityDependencies:uee,invDependencies:yee,multiplyDependencies:hee,typedDependencies:y9,createExpm:k0},_ne={ComplexDependencies:h9,typedDependencies:y9,createExpm1:GV},wne={createFalse:wj},Mne={BigNumberDependencies:d9,UnitDependencies:xee,createFaraday:xU},Nne={BigNumberDependencies:d9,UnitDependencies:xee,createFermiCoupling:iU},Sne={ComplexDependencies:h9,createI:Rj},kne={BigNumberDependencies:d9,createTau:Dj},Dne={addScalarDependencies:C9,divideScalarDependencies:Q9,expDependencies:xne,iDependencies:Sne,matrixDependencies:w9,multiplyScalarDependencies:oee,tauDependencies:kne,typedDependencies:y9,createFft:xX},Tne={largerDependencies:kee,smallerDependencies:Wee,createFibonacciHeapClass:AQ},Ine={typedDependencies:y9,createFilter:KV},Ene={typedDependencies:y9,createFilterTransform:s8},Cne={BigNumberDependencies:d9,createFineStructure:sU},Ane={BigNumberDependencies:d9,UnitDependencies:xee,createFirstRadiation:vU},Lne={typedDependencies:y9,createForEach:ZV},$ne={typedDependencies:y9,createForEachTransform:u8},One={BigNumberDependencies:d9,UnitDependencies:xee,createGasConstant:wU},Rne={BigNumberDependencies:d9,DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,createGcd:MX},Fne={typedDependencies:y9,createGetMatrixDataType:rG},Yne={BigNumberDependencies:d9,UnitDependencies:xee,createGravitationConstant:Hj},zne={BigNumberDependencies:d9,UnitDependencies:xee,createGravity:CU},Bne={BigNumberDependencies:d9,UnitDependencies:xee,createHartreeEnergy:oU},Pne={isNumericDependencies:see,typedDependencies:y9,createHasNumericValue:SX},Hne={parseDependencies:mte,createHelpClass:z7},jne={HelpDependencies:Hne,typedDependencies:y9,createHelp:Z7},Une={formatDependencies:iee,typedDependencies:y9,createHex:aG},qne={absDependencies:b9,addScalarDependencies:C9,divideScalarDependencies:Q9,isPositiveDependencies:bte,multiplyScalarDependencies:oee,smallerDependencies:Wee,sqrtDependencies:Jte,typedDependencies:y9,createHypot:DX},Wne={conjDependencies:cee,dotDivideDependencies:Zte,fftDependencies:Dne,typedDependencies:y9,createIfft:IX},Vne={IndexDependencies:Gee,typedDependencies:y9,createIndex:i0},Gne={IndexDependencies:Gee,createIndexTransform:S8},Kne={BigNumberDependencies:d9,createInfinity:Nj},Jne={absDependencies:b9,addDependencies:A9,addScalarDependencies:C9,divideScalarDependencies:Q9,equalScalarDependencies:v9,flattenDependencies:rne,isNumericDependencies:see,isZeroDependencies:lee,matrixDependencies:w9,multiplyDependencies:hee,multiplyScalarDependencies:oee,smallerDependencies:Wee,subtractDependencies:mee,typedDependencies:y9,createIntersect:zQ},Xne={BigNumberDependencies:d9,UnitDependencies:xee,createInverseConductanceQuantum:Zj},Zne={DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,createMod:lJ},Qne={BigNumberDependencies:d9,matrixDependencies:w9,typedDependencies:y9,createXgcd:UJ},ere={BigNumberDependencies:d9,addDependencies:A9,equalDependencies:eee,isIntegerDependencies:R9,modDependencies:Zne,smallerDependencies:Wee,typedDependencies:y9,xgcdDependencies:Qne,createInvmod:FZ},tre={typedDependencies:y9,createIsNaN:CK},nre={typedDependencies:y9,createIsPrime:LK},rre={ComplexDependencies:h9,divideScalarDependencies:Q9,typedDependencies:y9,createLog:BZ},are={addDependencies:A9,numericDependencies:Z9,typedDependencies:y9,createSum:hQ},ire={divideDependencies:Pte,dotDivideDependencies:Zte,isNumericDependencies:see,logDependencies:rre,matrixDependencies:w9,multiplyDependencies:hee,sumDependencies:are,typedDependencies:y9,createKldivergence:h1},sre={BigNumberDependencies:d9,UnitDependencies:xee,createKlitzing:tU},ore={matrixDependencies:w9,multiplyScalarDependencies:oee,typedDependencies:y9,createKron:CX},ure={BigNumberDependencies:d9,createLN10:Cj},lre={BigNumberDependencies:d9,createLN2:Ej},cre={BigNumberDependencies:d9,createLOG10E:Lj},pre={BigNumberDependencies:d9,createLOG2E:Aj},dre={equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,createLcm:BQ},hre={parseDependencies:mte,typedDependencies:y9,createLeafCount:P7},fre={DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,zerosDependencies:$9,createLeftShift:RX},mre={ComplexDependencies:h9,typedDependencies:y9,createLgamma:kG},gre={ComplexDependencies:h9,typedDependencies:y9,createLog10:TG},yre={ComplexDependencies:h9,divideScalarDependencies:Q9,logDependencies:rre,typedDependencies:y9,createLog1p:HQ},bre={ComplexDependencies:h9,typedDependencies:y9,createLog2:EG},xre={BigNumberDependencies:d9,UnitDependencies:xee,createLoschmidt:_U},vre={DenseMatrixDependencies:m9,divideScalarDependencies:Q9,equalScalarDependencies:v9,matrixDependencies:w9,multiplyScalarDependencies:oee,subtractDependencies:mee,typedDependencies:y9,createLsolve:zX},_re={DenseMatrixDependencies:m9,divideScalarDependencies:Q9,equalScalarDependencies:v9,matrixDependencies:w9,multiplyScalarDependencies:oee,subtractDependencies:mee,typedDependencies:y9,createLsolveAll:HZ},wre={FibonacciHeapDependencies:Tne,addScalarDependencies:C9,equalScalarDependencies:v9,createSpaClass:f0},Mre={DenseMatrixDependencies:m9,SpaDependencies:wre,SparseMatrixDependencies:_9,absDependencies:b9,addScalarDependencies:C9,divideScalarDependencies:Q9,equalScalarDependencies:v9,largerDependencies:kee,matrixDependencies:w9,multiplyScalarDependencies:oee,subtractDependencies:mee,typedDependencies:y9,unaryMinusDependencies:fee,createLup:$0},Nre={SparseMatrixDependencies:_9,absDependencies:b9,addDependencies:A9,divideScalarDependencies:Q9,largerDependencies:kee,largerEqDependencies:Kee,multiplyDependencies:hee,subtractDependencies:mee,transposeDependencies:$te,typedDependencies:y9,createSlu:dQ},Sre={DenseMatrixDependencies:m9,lsolveDependencies:vre,lupDependencies:Mre,matrixDependencies:w9,sluDependencies:Nre,typedDependencies:y9,usolveDependencies:cne,createLusolve:e1},kre={typedDependencies:y9,createMap:CG},Dre={compareDependencies:tte,isNaNDependencies:tre,isNumericDependencies:see,typedDependencies:y9,createPartitionSelect:KX},Tre={addDependencies:A9,compareDependencies:tte,divideDependencies:Pte,partitionSelectDependencies:Dre,typedDependencies:y9,createMedian:r1},Ire={absDependencies:b9,mapDependencies:kre,medianDependencies:Tre,subtractDependencies:mee,typedDependencies:y9,createMad:M1},Ere={BigNumberDependencies:d9,UnitDependencies:xee,createMagneticConstant:qj},Cre={BigNumberDependencies:d9,UnitDependencies:xee,createMagneticFluxQuantum:Qj},Are={typedDependencies:y9,createMapTransform:l8},Lre={isZeroDependencies:lee,matrixDependencies:w9,typedDependencies:y9,createMatrixFromFunction:tJ},$re={flattenDependencies:rne,matrixDependencies:w9,sizeDependencies:pee,typedDependencies:y9,createMatrixFromRows:UZ},Ore={largerDependencies:kee,numericDependencies:Z9,typedDependencies:y9,createMax:jQ},Rre={largerDependencies:kee,numericDependencies:Z9,typedDependencies:y9,createMaxTransform:y8},Fre={addDependencies:A9,divideDependencies:Pte,typedDependencies:y9,createMean:G0},Yre={addDependencies:A9,divideDependencies:Pte,typedDependencies:y9,createMeanTransform:k8},zre={numericDependencies:Z9,smallerDependencies:Wee,typedDependencies:y9,createMin:HX},Bre={numericDependencies:Z9,smallerDependencies:Wee,typedDependencies:y9,createMinTransform:b8},Pre={isNaNDependencies:tre,isNumericDependencies:see,typedDependencies:y9,createMode:UX},Hre={BigNumberDependencies:d9,UnitDependencies:xee,createMolarMass:IU},jre={BigNumberDependencies:d9,UnitDependencies:xee,createMolarMassC12:EU},Ure={BigNumberDependencies:d9,UnitDependencies:xee,createMolarPlanckConstant:MU},qre={BigNumberDependencies:d9,UnitDependencies:xee,createMolarVolume:NU},Wre={addDependencies:A9,divideDependencies:Pte,factorialDependencies:See,isIntegerDependencies:R9,isPositiveDependencies:bte,multiplyDependencies:hee,typedDependencies:y9,createMultinomial:R0},Vre={BigNumberDependencies:d9,createNaN:Sj},Gre={BigNumberDependencies:d9,UnitDependencies:xee,createNeutronMass:cU},Kre={absDependencies:b9,addDependencies:A9,conjDependencies:cee,ctransposeDependencies:Ote,eigsDependencies:dne,equalScalarDependencies:v9,largerDependencies:kee,matrixDependencies:w9,multiplyDependencies:hee,powDependencies:bee,smallerDependencies:Wee,sqrtDependencies:Jte,typedDependencies:y9,createNorm:g1},Jre={BigNumberDependencies:d9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,createNthRoot:hJ},Xre={ComplexDependencies:h9,divideScalarDependencies:Q9,typedDependencies:y9,createNthRoots:WX},Zre={BigNumberDependencies:d9,UnitDependencies:xee,createNuclearMagneton:eU},Qre={createNull:Mj},eae={formatDependencies:iee,typedDependencies:y9,createOct:PG},tae={BigNumberDependencies:d9,matrixDependencies:w9,typedDependencies:y9,createOnes:VX},nae={DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,createOr:bJ},rae={evaluateDependencies:bne,createParserClass:Q7},aae={ParserDependencies:rae,typedDependencies:y9,createParser:a8},iae={factorialDependencies:See,typedDependencies:y9,createPermutations:Y0},sae={BigNumberDependencies:d9,createPhi:Ij},oae={BigNumberDependencies:d9,createPi:kj},uae={typedDependencies:y9,createPickRandom:WG},lae={ComplexDependencies:h9,addDependencies:A9,ctransposeDependencies:Ote,deepEqualDependencies:Bte,divideScalarDependencies:Q9,dotDependencies:dee,dotDivideDependencies:Zte,equalDependencies:eee,invDependencies:yee,matrixDependencies:w9,multiplyDependencies:hee,typedDependencies:y9,createPinv:u0},cae={BigNumberDependencies:d9,UnitDependencies:xee,createPlanckCharge:OU},pae={BigNumberDependencies:d9,UnitDependencies:xee,createPlanckConstant:jj},dae={BigNumberDependencies:d9,UnitDependencies:xee,createPlanckLength:AU},hae={BigNumberDependencies:d9,UnitDependencies:xee,createPlanckMass:LU},fae={BigNumberDependencies:d9,UnitDependencies:xee,createPlanckTemperature:RU},mae={BigNumberDependencies:d9,UnitDependencies:xee,createPlanckTime:$U},gae={typedDependencies:y9,createPrint:GG},yae={BigNumberDependencies:d9,UnitDependencies:xee,createProtonMass:uU},bae={addDependencies:A9,compareDependencies:tte,multiplyDependencies:hee,partitionSelectDependencies:Dre,typedDependencies:y9,createQuantileSeq:UQ},xae={BigNumberDependencies:d9,UnitDependencies:xee,createQuantumOfCirculation:pU},vae={typedDependencies:y9,createRandom:ZG},_ae={typedDependencies:y9,createRandomInt:OK},wae={createRangeClass:HU},Mae={bignumberDependencies:K9,matrixDependencies:w9,largerDependencies:kee,largerEqDependencies:Kee,smallerDependencies:Wee,smallerEqDependencies:Jee,typedDependencies:y9,createRangeTransform:x8},Nae={bignumberDependencies:K9,fractionDependencies:J9,AccessorNodeDependencies:N9,ArrayNodeDependencies:B9,ConstantNodeDependencies:ite,FunctionNodeDependencies:ute,IndexNodeDependencies:lte,ObjectNodeDependencies:cte,OperatorNodeDependencies:pte,ParenthesisNodeDependencies:dte,SymbolNodeDependencies:ote,addDependencies:A9,divideDependencies:Pte,equalDependencies:eee,isZeroDependencies:lee,matrixDependencies:w9,multiplyDependencies:hee,parseDependencies:mte,powDependencies:bee,simplifyDependencies:Ute,simplifyCoreDependencies:jte,subtractDependencies:mee,typedDependencies:y9,createRationalize:t8},Sae={BigNumberDependencies:d9,UnitDependencies:xee,createReducedPlanckConstant:Uj},kae={createReplacer:Nq},Dae={isIntegerDependencies:R9,matrixDependencies:w9,typedDependencies:y9,createReshape:MJ},Tae={matrixDependencies:w9,createResize:XX},Iae={createReviver:b7},Eae={DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,zerosDependencies:$9,createRightArithShift:QX},Cae={DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,zerosDependencies:$9,createRightLogShift:XZ},Aae={BigNumberDependencies:d9,DenseMatrixDependencies:m9,SparseMatrixDependencies:_9,addScalarDependencies:C9,cosDependencies:Mte,matrixDependencies:w9,multiplyScalarDependencies:oee,normDependencies:Kre,sinDependencies:lne,typedDependencies:y9,unaryMinusDependencies:fee,createRotationMatrix:x1},Lae={multiplyDependencies:hee,rotationMatrixDependencies:Aae,typedDependencies:y9,createRotate:k1},$ae={IndexDependencies:Gee,matrixDependencies:w9,rangeDependencies:Xee,typedDependencies:y9,createRow:qQ},Oae={IndexDependencies:Gee,matrixDependencies:w9,rangeDependencies:Xee,typedDependencies:y9,createRowTransform:M8},Rae={BigNumberDependencies:d9,UnitDependencies:xee,createRydberg:dU},Fae={BigNumberDependencies:d9,createSQRT1_2:$j},Yae={BigNumberDependencies:d9,createSQRT2:Oj},zae={BigNumberDependencies:d9,createSackurTetrode:SU},Bae={BigNumberDependencies:d9,typedDependencies:y9,createSec:eK},Pae={BigNumberDependencies:d9,typedDependencies:y9,createSech:FK},Hae={BigNumberDependencies:d9,UnitDependencies:xee,createSecondRadiation:kU},jae={DenseMatrixDependencies:m9,IndexDependencies:Gee,compareNaturalDependencies:nte,sizeDependencies:pee,subsetDependencies:M9,typedDependencies:y9,createSetCartesian:VQ},Uae={DenseMatrixDependencies:m9,IndexDependencies:Gee,compareNaturalDependencies:nte,sizeDependencies:pee,subsetDependencies:M9,typedDependencies:y9,createSetDifference:p0},qae={DenseMatrixDependencies:m9,IndexDependencies:Gee,compareNaturalDependencies:nte,sizeDependencies:pee,subsetDependencies:M9,typedDependencies:y9,createSetDistinct:KQ},Wae={DenseMatrixDependencies:m9,IndexDependencies:Gee,compareNaturalDependencies:nte,sizeDependencies:pee,subsetDependencies:M9,typedDependencies:y9,createSetIntersect:E0},Vae={IndexDependencies:Gee,compareNaturalDependencies:nte,sizeDependencies:pee,subsetDependencies:M9,typedDependencies:y9,createSetIsSubset:XQ},Gae={IndexDependencies:Gee,compareNaturalDependencies:nte,sizeDependencies:pee,subsetDependencies:M9,typedDependencies:y9,createSetMultiplicity:h0},Kae={IndexDependencies:Gee,compareNaturalDependencies:nte,sizeDependencies:pee,subsetDependencies:M9,typedDependencies:y9,createSetPowerset:QQ},Jae={compareNaturalDependencies:nte,typedDependencies:y9,createSetSize:QZ},Xae={IndexDependencies:Gee,concatDependencies:vte,setDifferenceDependencies:Uae,sizeDependencies:pee,subsetDependencies:M9,typedDependencies:y9,createSetSymDifference:J0},Zae={IndexDependencies:Gee,concatDependencies:vte,setIntersectDependencies:Wae,setSymDifferenceDependencies:Xae,sizeDependencies:pee,subsetDependencies:M9,typedDependencies:y9,createSetUnion:s1},Qae={typedDependencies:y9,createSinh:zK},eie={compareDependencies:tte,compareNaturalDependencies:nte,matrixDependencies:w9,typedDependencies:y9,createSort:t0},tie={SparseMatrixDependencies:_9,typedDependencies:y9,createSparse:PK},nie={BigNumberDependencies:d9,UnitDependencies:xee,createSpeedOfLight:Pj},rie={typedDependencies:y9,createSplitUnit:sK},aie={absDependencies:b9,addDependencies:A9,identityDependencies:uee,invDependencies:yee,maxDependencies:Ore,multiplyDependencies:hee,sizeDependencies:pee,sqrtDependencies:Jte,subtractDependencies:mee,typedDependencies:y9,createSqrtm:g0},iie={typedDependencies:y9,createSquare:uK},sie={matrixDependencies:w9,typedDependencies:y9,createSqueeze:EJ},oie={addDependencies:A9,applyDependencies:F9,divideDependencies:Pte,isNaNDependencies:tre,multiplyDependencies:hee,subtractDependencies:mee,typedDependencies:y9,createVariance:c1},uie={sqrtDependencies:Jte,typedDependencies:y9,varianceDependencies:oie,createStd:_1},lie={sqrtDependencies:Jte,typedDependencies:y9,varianceDependencies:oie,createStdTransform:I8},cie={BigNumberDependencies:d9,UnitDependencies:xee,createStefanBoltzmann:DU},pie={typedDependencies:y9,createString:cK},die={matrixDependencies:w9,typedDependencies:y9,createSubsetTransform:m8},hie={addDependencies:A9,numericDependencies:Z9,typedDependencies:y9,createSumTransform:v8},fie={OperatorNodeDependencies:pte,parseDependencies:mte,simplifyDependencies:Ute,typedDependencies:y9,createSymbolicEqual:q7},mie={typedDependencies:y9,createTan:pK},gie={typedDependencies:y9,createTanh:jK},yie={BigNumberDependencies:d9,UnitDependencies:xee,createThomsonCrossSection:hU},bie={matrixDependencies:w9,typedDependencies:y9,createTo:PJ},xie={addDependencies:A9,matrixDependencies:w9,typedDependencies:y9,createTrace:fQ},vie={createTrue:_j},_ie={typedDependencies:y9,createTypeOf:hK},wie={DenseMatrixDependencies:m9,equalScalarDependencies:v9,matrixDependencies:w9,typedDependencies:y9,createUnequal:sZ},Mie={UnitDependencies:xee,typedDependencies:y9,createUnitFunction:j0},Nie={eDependencies:tne,createUppercaseE:Yj},Sie={piDependencies:oae,createUppercasePi:Fj},kie={BigNumberDependencies:d9,UnitDependencies:xee,createVacuumImpedance:Vj},Die={addDependencies:A9,applyDependencies:F9,divideDependencies:Pte,isNaNDependencies:tre,multiplyDependencies:hee,subtractDependencies:mee,typedDependencies:y9,createVarianceTransform:T8},Tie={createVersion:zj},Iie={BigNumberDependencies:d9,createWeakMixingAngle:fU},Eie={BigNumberDependencies:d9,UnitDependencies:xee,createWienDisplacement:TU},Cie={DenseMatrixDependencies:m9,matrixDependencies:w9,typedDependencies:y9,createXor:lZ},Aie=W,Lie=n(4279);function $ie(e,t){var n=LP({},$P,t);if("function"!=typeof Object.create)throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");var r,a,i=(r={isNumber:OP,isComplex:FP,isBigNumber:RP,isFraction:YP,isUnit:zP,isString:BP,isArray:PP,isMatrix:HP,isCollection:jP,isDenseMatrix:UP,isSparseMatrix:qP,isRange:WP,isIndex:VP,isBoolean:GP,isResultSet:KP,isHelp:JP,isFunction:XP,isDate:ZP,isRegExp:QP,isObject:eH,isNull:tH,isUndefined:nH,isAccessorNode:rH,isArrayNode:aH,isAssignmentNode:iH,isBlockNode:sH,isConditionalNode:oH,isConstantNode:uH,isFunctionAssignmentNode:lH,isFunctionNode:cH,isIndexNode:pH,isNode:dH,isObjectNode:hH,isOperatorNode:fH,isParenthesisNode:mH,isRangeNode:gH,isSymbolNode:yH,isChain:bH},a=new Lie,r.on=a.on.bind(a),r.off=a.off.bind(a),r.once=a.once.bind(a),r.emit=a.emit.bind(a),r);i.config=AH(n,i.emit),i.expression={transform:{},mathWithTransform:{config:i.config}};var s={},o=function(e,t,n,r){function a(t,a,s){if(s.wrap&&"function"==typeof a&&(u=function(){for(var e=[],t=0,r=arguments.length;t2&&void 0!==arguments[2]?arguments[2]:t.fn;if(wq(i,"."))throw new Error("Factory name should not contain a nested path. Name: "+JSON.stringify(i));var o=d(t)?n.expression.transform:n,u=i in n.expression.transform,c=TH(o,i)?o[i]:void 0,h=function(){var r={};t.dependencies.map(YH).forEach((e=>{if(wq(e,"."))throw new Error("Factory dependency should not contain a nested path. Name: "+JSON.stringify(e));"math"===e?r.math=n:"mathWithTransform"===e?r.mathWithTransform=n.expression.mathWithTransform:"classes"===e?r.classes=n:r[e]=n[e]}));var s=t(r);if(s&&"function"==typeof s.transform)throw new Error('Transforms cannot be attached to factory functions. Please create a separate function for it with exports.path="expression.transform"');if(void 0===c||a.override)return s;if(l(c)&&l(s))return e(c,s);if(a.silent)return c;throw new Error('Cannot import "'+i+'": already exists')};t.meta&&!1===t.meta.lazy?(o[i]=h(),c&&u?s(i):(d(t)||p(t))&&DH(n.expression.mathWithTransform,i,(()=>o[i]))):(DH(o,i,h),c&&u?s(i):(d(t)||p(t))&&DH(n.expression.mathWithTransform,i,(()=>o[i]))),r[i]=t,n.emit("import",i,h)}function u(e){return"function"==typeof e||"number"==typeof e||"string"==typeof e||"boolean"==typeof e||null===e||zP(e)||FP(e)||RP(e)||YP(e)||HP(e)||Array.isArray(e)}function l(e){return"function"==typeof e&&"object"==typeof e.signatures}function c(e){return!TH(h,e)}function p(e){return!(-1!==e.fn.indexOf(".")||TH(h,e.fn)||e.meta&&e.meta.isClass)}function d(e){return void 0!==e&&void 0!==e.meta&&!0===e.meta.isTransformFunction||!1}var h={expression:!0,type:!0,docs:!0,error:!0,json:!0,chain:!0};return function(e,t){var n=arguments.length;if(1!==n&&2!==n)throw new JX("import",n,1,2);function r(e,n,a){if(Array.isArray(n))n.forEach((t=>r(e,t)));else if("object"==typeof n)for(var i in n)TH(n,i)&&r(e,n[i],i);else if(FH(n)||void 0!==a){var s=FH(n)?d(n)?n.fn+".transform":n.fn:a;if(TH(e,s)&&e[s]!==n&&!t.silent)throw new Error('Cannot import "'+s+'" twice');e[s]=n}else if(!t.silent)throw new TypeError("Factory, Object, or Array expected")}t||(t={});var i={};for(var s in r(i,e),i)if(TH(i,s)){var l=i[s];if(FH(l))o(l,t);else if(u(l))a(s,l,t);else if(!t.silent)throw new TypeError("Factory, Object, or Array expected")}}}((function(){for(var e=arguments.length,t=new Array(e),n=0;n{IH(s).forEach((e=>{e&&e.meta&&e.meta.recreateOnConfigChange&&o(e,{override:!0})}))})),i.create=$ie.bind(null,e),i.factory=RH,i.import(IH(SH(e))),i.ArgumentsError=JX,i.DimensionError=ZU,i.IndexError=QU,i}class Oie{constructor(e){this.pInst=e,this.turtle={},this.home()}home(){this.turtle.x=this.pInst.width/2,this.turtle.y=this.pInst.height/2,this.turtle.angle=0,this.turtle.pen=!0,this.turtle.pencolor="black",this.turtle.penwidth=1}pencolor(e){this.turtle.pencolor=e}pensize(e){this.turtle.penwidth=e}pendown(){this.turtle.pen=!0}penup(){this.turtle.pen=!1}setposition(e,t){this.turtle.x=e,this.turtle.y=t}position(){return[this.turtle.x,this.turtle.y]}left(e){this.turtle.angle-=e}right(e){this.turtle.angle+=e}setheading(e){this.turtle.angle=e}heading(){return this.turtle.angle}forward(e){const t=this._angleMode;this.pInst.angleMode(this.pInst.DEGREES);const n=this.turtle.x+e*this.pInst.cos(this.turtle.angle-90),r=this.turtle.y+e*this.pInst.sin(this.turtle.angle-90);this.pInst.angleMode(t),this.turtle.pen&&(this.pInst.push(),this.pInst.strokeWeight(this.turtle.penwidth),this.pInst.stroke(this.turtle.pencolor),this.pInst.line(this.turtle.x,this.turtle.y,n,r),this.pInst.pop()),this.turtle.x=n,this.turtle.y=r}back(e){this.forward(-e)}circle(e){this.turtle.pen&&(this.pInst.push(),this.pInst.strokeWeight(this.turtle.penwidth),this.pInst.stroke(this.turtle.pencolor),this.pInst.circle(this.turtle.x,this.turtle.y,2*e),this.pInst.pop())}}const Rie=p5.prototype.circle;p5.prototype.circle=function(){Rie&&(1!==arguments.length?Rie.call(this,...arguments):this.getDefaultTurtle().circle(arguments[0]))},p5.prototype.createTurtle=function(){return new Oie(this)},p5.prototype.getDefaultTurtle=function(){return this.defaultTurtle||(this.defaultTurtle=this.createTurtle()),this.defaultTurtle},p5.prototype.home=function(){this.getDefaultTurtle().home()},p5.prototype.pencolor=function(e){this.getDefaultTurtle().pencolor(e)},p5.prototype.pensize=function(e){this.getDefaultTurtle().pensize(e)},p5.prototype.pendown=function(){this.getDefaultTurtle().pendown()},p5.prototype.penup=function(){this.getDefaultTurtle().penup()},p5.prototype.setposition=function(e,t){this.getDefaultTurtle().setposition(e,t)},p5.prototype.position=function(){return this.getDefaultTurtle().position()},p5.prototype.left=function(e){this.getDefaultTurtle().left(e)},p5.prototype.right=function(e){this.getDefaultTurtle().right(e)},p5.prototype.setheading=function(e){this.getDefaultTurtle().setheading(e)},p5.prototype.heading=function(){return this.getDefaultTurtle().heading()},p5.prototype.forward=function(e){this.getDefaultTurtle().forward(e)},p5.prototype.back=function(e){this.getDefaultTurtle().back(e)};var Fie=t9,Yie=c9,zie=s9,Bie=Z8,Pie=a9;const Hie=p5;var jie=Hie.prototype.createVector,Uie=function(){function e(t){if(this.isComplex=!1,"number"==typeof t)this.tensor=$u(t);else if(t instanceof Array)this.tensor=Oi(t);else if(t instanceof Hie.Vector){var n=t.array();this.tensor=Oi(n)}else if(t instanceof e)this.tensor=t.tensor;else{if(!(t instanceof Qa))throw new Error("Tensors must be created from Numbers, Arrays, or p5.Vectors.");this.tensor=t}this.shape=this.tensor.shape}return e.prototype.toString=function(){return this.tensor.toString()},e.prototype.print=function(){this.tensor.print()},e.prototype.array=function(){return function(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}(this,void 0,void 0,(function(){var e,t;return function(e,t){var n,r,a,i,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(i){return function(o){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]100)throw new Error("Percentile must be in the range [0, 100].");r.push(n*(e/100))})),r}if(t<0||t>100)throw new Error("Percentile must be in the range [0, 100].");return n*(t/100)},Jse=function(e,t){var n=Gse(e);if(t instanceof Array){var r=[];return t.forEach((function(e){if(e<0||e>1)throw new Error("Quantile must be in the range [0, 1].");r.push(n*e)})),r}if(t<0||t>1)throw new Error("Quantile must be in the range [0, 1].");return n*t},Xse=function(e,t,n){var r=e.tensor.mean(t,n);return new Uie(r)},Zse=function(e,t){if(t instanceof Uie){var n=e.mult(t),r=n.sum(),a=t.sum(),i=r.div(a);return n.dispose(),r.dispose(),a.dispose(),i}return Xse(e)},Qse=function(e){var t=co((function(){var t=Xse(e),n=e.sub(t).sq().sum(),r=e.shape.reduce((function(e,t){return e*t}));return n.div(r).sqrt().tensor}));return new Uie(t)},eoe=function(e){var t=Qse(e),n=t.sq();return t.dispose(),n};const toe=function(e){var t=e.pg,n=e.originX,r=e.originY,a=e.width,i=e.height,s=e.annotationsPalette;t.push(),t.fill(s.backgroundColor),t.strokeWeight(1),t.stroke(s.backgroundColor),t.rect(n,r,a,-i),t.pop()};var noe=n(7484),roe=function(e,t,n){void 0===n&&(n=50);for(var r=[],a=(t-e)/(n-1),i=0;it.value?1:e.value100?t.round(x,0):t.round(x,1)),t.text(b,f[y],g)}t.pop()}(this.props):function(e){var t=e.pg,n=e.dataset,r=e.x,a=e.y,i=e.originX,s=e.originY,o=e.majorTicks,u=e.minorTicks,l=e.tickSize,c=e.annotationsPalette,p=e.xRange;t.push(),t.fill(c.fontColor),t.noStroke(),t.textAlign(t.CENTER,t.CENTER),t.translate(i,s);for(var d=n.getSorted(r,a),h=p||d.xRange,f=aoe(e),m=roe(h.min,h.max,o+1),g=4*l,y=0;y100?t.round(x,0):t.round(x,1)),t.text(b,f[y],g)}t.pop()}(this.props)},e.prototype.yticks=function(e){this.props=Aoe(Aoe({},this.props),e),function(e){var t,n=e.pg,r=e.dataset,a=e.x,i=e.y,s=e.originX,o=e.originY,u=e.majorTicks,l=e.minorTicks,c=e.tickSize,p=e.annotationsPalette,d=e.numBins,h=e.yRange;n.push(),n.fill(p.fontColor),n.noStroke(),n.textAlign(n.CENTER,n.CENTER),n.translate(s,o),t=h||(d>0?r.getBinned(a,d).xRange:r.getSorted(a,i).yRange);for(var f=ioe(e),m=roe(t.min,t.max,u+1),g=-5*c,y=0;y100?n.round(x,0):n.round(x,1)),n.text(b,g,-f[y])}n.pop()}(this.props)},e.prototype.background=function(e){this.props.annotationsPalette.backgroundColor=e||this.props.annotationsPalette.backgroundColor,this.layers.unshift({props:this.props,operation:toe})},e.prototype.margin=function(e){this.props.annotationsPalette.marginColor=e||this.props.annotationsPalette.marginColor,this.layers.unshift({props:this.props,operation:foe})},e.prototype.bar=function(e){this.props=Aoe(Aoe({},this.props),e),this.props.numBins=this.props.numBins||20,this.layers.push({props:this.props,operation:Moe})},e.prototype.point=function(e){this.props=Aoe(Aoe({},this.props),e),this.layers.push({props:this.props,operation:Noe})},e.prototype.line=function(e){this.props=Aoe(Aoe({},this.props),e),this.layers.push({props:this.props,operation:Soe})},e}();p5.prototype.registerMethod("init",(function(){this._plots=[]})),p5.prototype.createPlot=function(e){var t=new Loe(this,e);return this._plots.push(t),t},p5.prototype.registerMethod("post",(function(){this._plots.forEach((function(e){e.clear()}))})),p5.prototype.registerMethod("remove",(function(){this._plots.forEach((function(e){return e.props.pg.remove()})),this._plots=void 0}));var $oe=function(e,t,n){if(n||2===arguments.length)for(var r,a=0,i=t.length;ae.rows.length?(u=this,o=e):(o=this,u=e);for(var l=function(e){var t=i.addRow(),n=u.rows[e];if(u.columns.forEach((function(e){t.set(e,n.get(e))})),e=0,r=e.columns.indexOf(t)>=0;if(!n||!r)throw new Error("Both tables must have the same key.");var a=new Hie.Table,i=this.columns.filter((function(e){return e!==t})),s=e.columns.filter((function(e){return e!==t}));return a.columns=Poe(Poe([t],i,!0),s,!0),this.rows.forEach((function(n){var r=n.get(t);e.rows.forEach((function(e){var o=e.get(t);if(r===o){var u=a.addRow(),l=n.get(t);u.set(t,l),i.forEach((function(e){l=n.get(e),u.set(e,l)})),s.forEach((function(t){l=e.get(t),u.set(t,l)}))}}))})),a};var Hoe=function(){return Hoe=Object.assign||function(e){for(var t,n=1,r=arguments.length;na-i;s-=1)n[s]={},n[s][t]=this.get(s,t).toString()}else{n={};var o=function(e){n[e]={},u.columns.forEach((function(t){n[e][t]=r.get(e,t),noe.isDayjs(n[e][t])&&(n[e][t]=n[e][t].toString())}))},u=this;for(s=a;s>a-i;s-=1)o(s)}console.table(n)},Hie.Table.prototype.inferTypes=function(){var e=this;this.columns.forEach((function(t){try{!function(e,t){e.rows.forEach((function(e){var n=e.getNum(t);e.setNum(t,n)}))}(e,t)}catch(e){}}))},Hie.Table.prototype.isNull=function(){var e=new Hie.Table;return e.columns=this.columns.slice(),this.rows.forEach((function(t){var n=e.addRow();e.columns.forEach((function(e){var r=t.get(e);null==r||Number.isNaN(r)?n.set(e,!0):n.set(e,!1)}))})),e},Hie.Table.prototype.notNull=function(){var e=new Hie.Table;return e.columns=this.columns.slice(),this.rows.forEach((function(t){var n=e.addRow();e.columns.forEach((function(e){var r=t.get(e);null==r||Number.isNaN(r)?n.set(e,!1):n.set(e,!0)}))})),e},Hie.Table.prototype.any=function(e){var t=this;if(void 0===e){var n=new Hie.Table;n.columns=this.columns.slice();var r=n.addRow();return n.columns.forEach((function(e){var n=t.getColumn(e).reduce((function(e,t){return e||t}));r.set(e,n)})),n}return this.getColumn(e).reduce((function(e,t){return e||t}))},Hie.Table.prototype.all=function(e){var t=this;if(void 0===e){var n=new Hie.Table;n.columns=this.columns.slice();var r=n.addRow();return n.columns.forEach((function(e){var n=t.getColumn(e).reduce((function(e,t){return e&&t}));r.set(e,n)})),n}return this.getColumn(e).reduce((function(e,t){return e&&t}))},Hie.Table.prototype.map=function(e,t){var n=new Hie.Table;return t&&this.columns.includes(t)?n.columns=[t]:n.columns=this.columns.slice(),this.rows.forEach((function(t){var r=n.addRow();n.columns.forEach((function(n){r.set(n,e(t.get(n)))}))})),n},Hie.Table.prototype.isin=function(e){var t=new Hie.Table;return t.columns=this.columns.slice(),this.rows.forEach((function(n){var r=t.addRow();t.columns.forEach((function(t){r.set(t,!1);var a=n.get(t);e.every((function(e){return a!==e||(r.set(t,!0),!1)}))}))})),t},p5.prototype.createTable=function(e){var t;if(e instanceof Array&&e[0]instanceof Hie.TableRow)t=new Hie.Table(e);else if(e instanceof Array&&"string"==typeof e[0])(t=new Hie.Table).columns=e.slice();else if(e instanceof Object){(t=new Hie.Table).columns=Object.keys(e);var n=void 0,r=e[t.columns[0]];r instanceof Array?n=r.length:r instanceof Object&&(n=Object.keys(r).length);for(var a=function(n){var r=t.addRow();t.columns.forEach((function(t){var a=e[t][n];r.set(t,a)}))},i=0;i{var e={1977:function(e,t){var n;!function(r){"use strict";var a=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:.5*(Math.exp(e)+Math.exp(-e))},i=Math.sinh||function(e){return Math.abs(e)<1e-9?e:.5*(Math.exp(e)-Math.exp(-e))},s=function(){throw SyntaxError("Invalid Param")};function o(e,t){var n=Math.abs(e),r=Math.abs(t);return 0===e?Math.log(r):0===t?Math.log(n):n<3e3&&r<3e3?.5*Math.log(e*e+t*t):(e/=2,t/=2,.5*Math.log(e*e+t*t)+Math.LN2)}function u(e,t){if(!(this instanceof u))return new u(e,t);var n=function(e,t){var n={re:0,im:0};if(null==e)n.re=n.im=0;else if(void 0!==t)n.re=e,n.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)n.re=e.re,n.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return u.INFINITY;n.re=e.abs*Math.cos(e.arg),n.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return u.INFINITY;n.re=e.r*Math.cos(e.phi),n.im=e.r*Math.sin(e.phi)}else 2===e.length?(n.re=e[0],n.im=e[1]):s();break;case"string":n.im=n.re=0;var r=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),a=1,i=0;null===r&&s();for(var o=0;o0&&s();break;case"number":n.im=0,n.re=e;break;default:s()}return isNaN(n.re)||isNaN(n.im),n}(e,t);this.re=n.re,this.im=n.im}u.prototype={re:0,im:0,sign:function(){var e=this.abs();return new u(this.re/e,this.im/e)},add:function(e,t){var n=new u(e,t);return this.isInfinite()&&n.isInfinite()?u.NAN:this.isInfinite()||n.isInfinite()?u.INFINITY:new u(this.re+n.re,this.im+n.im)},sub:function(e,t){var n=new u(e,t);return this.isInfinite()&&n.isInfinite()?u.NAN:this.isInfinite()||n.isInfinite()?u.INFINITY:new u(this.re-n.re,this.im-n.im)},mul:function(e,t){var n=new u(e,t);return this.isInfinite()&&n.isZero()||this.isZero()&&n.isInfinite()?u.NAN:this.isInfinite()||n.isInfinite()?u.INFINITY:0===n.im&&0===this.im?new u(this.re*n.re,0):new u(this.re*n.re-this.im*n.im,this.re*n.im+this.im*n.re)},div:function(e,t){var n=new u(e,t);if(this.isZero()&&n.isZero()||this.isInfinite()&&n.isInfinite())return u.NAN;if(this.isInfinite()||n.isZero())return u.INFINITY;if(this.isZero()||n.isInfinite())return u.ZERO;e=this.re,t=this.im;var r,a,i=n.re,s=n.im;return 0===s?new u(e/i,t/i):Math.abs(i)0)return new u(Math.pow(e,n.re),0);if(0===e)switch((n.re%4+4)%4){case 0:return new u(Math.pow(t,n.re),0);case 1:return new u(0,Math.pow(t,n.re));case 2:return new u(-Math.pow(t,n.re),0);case 3:return new u(0,-Math.pow(t,n.re))}}if(0===e&&0===t&&n.re>0&&n.im>=0)return u.ZERO;var r=Math.atan2(t,e),a=o(e,t);return e=Math.exp(n.re*a-n.im*r),t=n.im*a+n.re*r,new u(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,n=this.re,r=this.im,a=this.abs();if(n>=0){if(0===r)return new u(Math.sqrt(n),0);e=.5*Math.sqrt(2*(a+n))}else e=Math.abs(r)/Math.sqrt(2*(a-n));return t=n<=0?.5*Math.sqrt(2*(a-n)):Math.abs(r)/Math.sqrt(2*(a+n)),new u(e,r<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new u(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(-t>e||e>t)return Math.cos(e)-1;var n=e*e;return n*(n*(n*(n*(n*(n*(n*(n/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new u(o(e,t),Math.atan2(t,e))},abs:function(){return e=this.re,t=this.im,n=Math.abs(e),r=Math.abs(t),n<3e3&&r<3e3?Math.sqrt(n*n+r*r):(n1&&0===t,r=1-e,a=1+e,i=r*r+t*t,s=0!==i?new u((a*r-t*t)/i,(t*r+a*t)/i):new u(-1!==e?e/0:0,0!==t?t/0:0),l=s.re;return s.re=o(s.re,s.im)/2,s.im=Math.atan2(s.im,l)/2,n&&(s.im=-s.im),s},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(0,Math.PI/2);var n=e*e+t*t;return 0!==n?new u(e/n,-t/n).atanh():new u(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var n=e*e+t*t;return 0!==n?new u(e/n,-t/n).asinh():new u(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return u.INFINITY;var n=e*e+t*t;return 0!==n?new u(e/n,-t/n).acosh():new u(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,t=this.im,n=e*e+t*t;return new u(e/n,-t/n)},conjugate:function(){return new u(this.re,-this.im)},neg:function(){return new u(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new u(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new u(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new u(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){var n=new u(e,t);return Math.abs(n.re-this.re)<=u.EPSILON&&Math.abs(n.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){var e=this.re,t=this.im,n="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)=t?e:""+Array(t+1-r.length).join(n)+e},y={s:g,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),a=n%60;return(t<=0?"+":"-")+g(r,2,"0")+":"+g(a,2,"0")},m:function e(t,n){if(t.date()1)return e(s[0])}else{var o=t.name;x[o]=t,a=o}return!r&&a&&(b=a),a||!r&&b},w=function(e,t){if(v(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new N(n)},M=y;M.l=_,M.i=v,M.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var N=function(){function m(e){this.$L=_(e.locale,null,!0),this.parse(e)}var g=m.prototype;return g.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(M.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(h);if(r){var a=r[2]-1||0,i=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],a,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)):new Date(r[1],a,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)}}return new Date(t)}(e),this.$x=e.x||{},this.init()},g.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},g.$utils=function(){return M},g.isValid=function(){return!(this.$d.toString()===d)},g.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},g.isAfter=function(e,t){return w(e)12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},7719:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-iq",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"كانون الثاني_شباط_آذار_نيسان_أيار_حزيران_تموز_آب_أيلول_تشرين الأول_ تشرين الثاني_كانون الأول".split("_"),weekStart:1,weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"كانون الثاني_شباط_آذار_نيسان_أيار_حزيران_تموز_آب_أيلول_تشرين الأول_ تشرين الثاني_كانون الأول".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},2376:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-kw",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekdaysShort:"احد_اثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},8540:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-ly",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekStart:6,weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},meridiem:function(e){return e>12?"م":"ص"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"D/‏M/‏YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},6817:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-ma",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekStart:6,weekdaysShort:"احد_إثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},1573:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-sa",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},9339:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-tn",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekStart:1,weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},3939:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),r={1:"١",2:"٢",3:"٣",4:"٤",5:"٥",6:"٦",7:"٧",8:"٨",9:"٩",0:"٠"},a={"١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","٠":"0"},i={name:"ar",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),months:n,monthsShort:n,weekStart:6,relativeTime:{future:"بعد %s",past:"منذ %s",s:"ثانية واحدة",m:"دقيقة واحدة",mm:"%d دقائق",h:"ساعة واحدة",hh:"%d ساعات",d:"يوم واحد",dd:"%d أيام",M:"شهر واحد",MM:"%d أشهر",y:"عام واحد",yy:"%d أعوام"},preparse:function(e){return e.replace(/[١٢٣٤٥٦٧٨٩٠]/g,(function(e){return a[e]})).replace(/،/g,",")},postformat:function(e){return e.replace(/\d/g,(function(e){return r[e]})).replace(/,/g,"،")},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"D/‏M/‏YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"}};return t.default.locale(i,null,!0),i}(n(7484))},8092:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"az",weekdays:"Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə".split("_"),weekdaysShort:"Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən".split("_"),weekdaysMin:"Bz_BE_ÇA_Çə_CA_Cü_Şə".split("_"),months:"yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr".split("_"),monthsShort:"yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., H:mm",LLLL:"dddd, D MMMM YYYY г., H:mm"},relativeTime:{future:"%s sonra",past:"%s əvvəl",s:"bir neçə saniyə",m:"bir dəqiqə",mm:"%d dəqiqə",h:"bir saat",hh:"%d saat",d:"bir gün",dd:"%d gün",M:"bir ay",MM:"%d ay",y:"bir il",yy:"%d il"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},504:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"be",weekdays:"нядзелю_панядзелак_аўторак_сераду_чацвер_пятніцу_суботу".split("_"),months:"студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня".split("_"),weekStart:1,weekdaysShort:"нд_пн_ат_ср_чц_пт_сб".split("_"),monthsShort:"студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж".split("_"),weekdaysMin:"нд_пн_ат_ср_чц_пт_сб".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., HH:mm",LLLL:"dddd, D MMMM YYYY г., HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},9091:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bg",weekdays:"неделя_понеделник_вторник_сряда_четвъртък_петък_събота".split("_"),weekdaysShort:"нед_пон_вто_сря_чет_пет_съб".split("_"),weekdaysMin:"нд_пн_вт_ср_чт_пт_сб".split("_"),months:"януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември".split("_"),monthsShort:"янр_фев_мар_апр_май_юни_юли_авг_сеп_окт_ное_дек".split("_"),weekStart:1,ordinal:function(e){var t=e%100;if(t>10&&t<20)return e+"-ти";var n=e%10;return 1===n?e+"-ви":2===n?e+"-ри":7===n||8===n?e+"-ми":e+"-ти"},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY H:mm",LLLL:"dddd, D MMMM YYYY H:mm"},relativeTime:{future:"след %s",past:"преди %s",s:"няколко секунди",m:"минута",mm:"%d минути",h:"час",hh:"%d часа",d:"ден",dd:"%d дена",M:"месец",MM:"%d месеца",y:"година",yy:"%d години"}};return t.default.locale(n,null,!0),n}(n(7484))},9149:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bi",weekdays:"Sande_Mande_Tusde_Wenesde_Tosde_Fraede_Sarade".split("_"),months:"Januari_Februari_Maj_Eprel_Mei_Jun_Julae_Okis_Septemba_Oktoba_Novemba_Disemba".split("_"),weekStart:1,weekdaysShort:"San_Man_Tus_Wen_Tos_Frae_Sar".split("_"),monthsShort:"Jan_Feb_Maj_Epr_Mai_Jun_Jul_Oki_Sep_Okt_Nov_Dis".split("_"),weekdaysMin:"San_Ma_Tu_We_To_Fr_Sar".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"lo %s",past:"%s bifo",s:"sam seken",m:"wan minit",mm:"%d minit",h:"wan haoa",hh:"%d haoa",d:"wan dei",dd:"%d dei",M:"wan manis",MM:"%d manis",y:"wan yia",yy:"%d yia"}};return t.default.locale(n,null,!0),n}(n(7484))},5287:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bm",weekdays:"Kari_Ntɛnɛn_Tarata_Araba_Alamisa_Juma_Sibiri".split("_"),months:"Zanwuyekalo_Fewuruyekalo_Marisikalo_Awirilikalo_Mɛkalo_Zuwɛnkalo_Zuluyekalo_Utikalo_Sɛtanburukalo_ɔkutɔburukalo_Nowanburukalo_Desanburukalo".split("_"),weekStart:1,weekdaysShort:"Kar_Ntɛ_Tar_Ara_Ala_Jum_Sib".split("_"),monthsShort:"Zan_Few_Mar_Awi_Mɛ_Zuw_Zul_Uti_Sɛt_ɔku_Now_Des".split("_"),weekdaysMin:"Ka_Nt_Ta_Ar_Al_Ju_Si".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"MMMM [tile] D [san] YYYY",LLL:"MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm",LLLL:"dddd MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm"},relativeTime:{future:"%s kɔnɔ",past:"a bɛ %s bɔ",s:"sanga dama dama",m:"miniti kelen",mm:"miniti %d",h:"lɛrɛ kelen",hh:"lɛrɛ %d",d:"tile kelen",dd:"tile %d",M:"kalo kelen",MM:"kalo %d",y:"san kelen",yy:"san %d"}};return t.default.locale(n,null,!0),n}(n(7484))},5254:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={1:"১",2:"২",3:"৩",4:"৪",5:"৫",6:"৬",7:"৭",8:"৮",9:"৯",0:"০"},r={"১":"1","২":"2","৩":"3","৪":"4","৫":"5","৬":"6","৭":"7","৮":"8","৯":"9","০":"0"},a={name:"bn",weekdays:"রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পতিবার_শুক্রবার_শনিবার".split("_"),months:"জানুয়ারি_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর".split("_"),weekdaysShort:"রবি_সোম_মঙ্গল_বুধ_বৃহস্পতি_শুক্র_শনি".split("_"),monthsShort:"জানু_ফেব্রু_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্ট_অক্টো_নভে_ডিসে".split("_"),weekdaysMin:"রবি_সোম_মঙ্গ_বুধ_বৃহঃ_শুক্র_শনি".split("_"),preparse:function(e){return e.replace(/[১২৩৪৫৬৭৮৯০]/g,(function(e){return r[e]}))},postformat:function(e){return e.replace(/\d/g,(function(e){return n[e]}))},ordinal:function(e){return e},formats:{LT:"A h:mm সময়",LTS:"A h:mm:ss সময়",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm সময়",LLLL:"dddd, D MMMM YYYY, A h:mm সময়"},relativeTime:{future:"%s পরে",past:"%s আগে",s:"কয়েক সেকেন্ড",m:"এক মিনিট",mm:"%d মিনিট",h:"এক ঘন্টা",hh:"%d ঘন্টা",d:"এক দিন",dd:"%d দিন",M:"এক মাস",MM:"%d মাস",y:"এক বছর",yy:"%d বছর"}};return t.default.locale(a,null,!0),a}(n(7484))},2502:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bo",weekdays:"གཟའ་ཉི་མ་_གཟའ་ཟླ་བ་_གཟའ་མིག་དམར་_གཟའ་ལྷག་པ་_གཟའ་ཕུར་བུ_གཟའ་པ་སངས་_གཟའ་སྤེན་པ་".split("_"),weekdaysShort:"ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་".split("_"),weekdaysMin:"ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་".split("_"),months:"ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ".split("_"),monthsShort:"ཟླ་དང་པོ_ཟླ་གཉིས་པ_ཟླ་གསུམ་པ_ཟླ་བཞི་པ_ཟླ་ལྔ་པ_ཟླ་དྲུག་པ_ཟླ་བདུན་པ_ཟླ་བརྒྱད་པ_ཟླ་དགུ་པ_ཟླ་བཅུ་པ_ཟླ་བཅུ་གཅིག་པ_ཟླ་བཅུ་གཉིས་པ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm",LLLL:"dddd, D MMMM YYYY, A h:mm"},relativeTime:{future:"%s ལ་",past:"%s སྔོན་ལ་",s:"ཏོག་ཙམ་",m:"སྐར་མ་གཅིག་",mm:"སྐར་མ་ %d",h:"ཆུ་ཚོད་གཅིག་",hh:"ཆུ་ཚོད་ %d",d:"ཉིན་གཅིག་",dd:"ཉིན་ %d",M:"ཟླ་བ་གཅིག་",MM:"ཟླ་བ་ %d",y:"ལོ་གཅིག་",yy:"ལོ་ %d"}};return t.default.locale(n,null,!0),n}(n(7484))},8864:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e>9?n(e%10):e}function r(e,t,n){return e+" "+function(e,t){return 2===t?function(e){return{m:"v",b:"v",d:"z"}[e.charAt(0)]+e.substring(1)}(e):e}({mm:"munutenn",MM:"miz",dd:"devezh"}[n],e)}var a={name:"br",weekdays:"Sul_Lun_Meurzh_Mercʼher_Yaou_Gwener_Sadorn".split("_"),months:"Genver_Cʼhwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu".split("_"),weekStart:1,weekdaysShort:"Sul_Lun_Meu_Mer_Yao_Gwe_Sad".split("_"),monthsShort:"Gen_Cʼhwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker".split("_"),weekdaysMin:"Su_Lu_Me_Mer_Ya_Gw_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"h[e]mm A",LTS:"h[e]mm:ss A",L:"DD/MM/YYYY",LL:"D [a viz] MMMM YYYY",LLL:"D [a viz] MMMM YYYY h[e]mm A",LLLL:"dddd, D [a viz] MMMM YYYY h[e]mm A"},relativeTime:{future:"a-benn %s",past:"%s ʼzo",s:"un nebeud segondennoù",m:"ur vunutenn",mm:r,h:"un eur",hh:"%d eur",d:"un devezh",dd:r,M:"ur miz",MM:r,y:"ur bloaz",yy:function(e){switch(n(e)){case 1:case 3:case 4:case 5:case 9:return e+" bloaz";default:return e+" vloaz"}}},meridiem:function(e){return e<12?"a.m.":"g.m."}};return t.default.locale(a,null,!0),a}(n(7484))},4502:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bs",weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),months:"januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar".split("_"),weekStart:1,weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),monthsShort:"jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},3646:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ca",weekdays:"Diumenge_Dilluns_Dimarts_Dimecres_Dijous_Divendres_Dissabte".split("_"),weekdaysShort:"Dg._Dl._Dt._Dc._Dj._Dv._Ds.".split("_"),weekdaysMin:"Dg_Dl_Dt_Dc_Dj_Dv_Ds".split("_"),months:"Gener_Febrer_Març_Abril_Maig_Juny_Juliol_Agost_Setembre_Octubre_Novembre_Desembre".split("_"),monthsShort:"Gen._Febr._Març_Abr._Maig_Juny_Jul._Ag._Set._Oct._Nov._Des.".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM [de] YYYY",LLL:"D MMMM [de] YYYY [a les] H:mm",LLLL:"dddd D MMMM [de] YYYY [a les] H:mm",ll:"D MMM YYYY",lll:"D MMM YYYY, H:mm",llll:"ddd D MMM YYYY, H:mm"},relativeTime:{future:"d'aquí %s",past:"fa %s",s:"uns segons",m:"un minut",mm:"%d minuts",h:"una hora",hh:"%d hores",d:"un dia",dd:"%d dies",M:"un mes",MM:"%d mesos",y:"un any",yy:"%d anys"},ordinal:function(e){return e+(1===e||3===e?"r":2===e?"n":4===e?"t":"è")}};return t.default.locale(n,null,!0),n}(n(7484))},8507:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e>1&&e<5&&1!=~~(e/10)}function r(e,t,r,a){var i=e+" ";switch(r){case"s":return t||a?"pár sekund":"pár sekundami";case"m":return t?"minuta":a?"minutu":"minutou";case"mm":return t||a?i+(n(e)?"minuty":"minut"):i+"minutami";case"h":return t?"hodina":a?"hodinu":"hodinou";case"hh":return t||a?i+(n(e)?"hodiny":"hodin"):i+"hodinami";case"d":return t||a?"den":"dnem";case"dd":return t||a?i+(n(e)?"dny":"dní"):i+"dny";case"M":return t||a?"měsíc":"měsícem";case"MM":return t||a?i+(n(e)?"měsíce":"měsíců"):i+"měsíci";case"y":return t||a?"rok":"rokem";case"yy":return t||a?i+(n(e)?"roky":"let"):i+"lety"}}var a={name:"cs",weekdays:"neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota".split("_"),weekdaysShort:"ne_po_út_st_čt_pá_so".split("_"),weekdaysMin:"ne_po_út_st_čt_pá_so".split("_"),months:"leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec".split("_"),monthsShort:"led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro".split("_"),weekStart:1,yearStart:4,ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd D. MMMM YYYY H:mm",l:"D. M. YYYY"},relativeTime:{future:"za %s",past:"před %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},6636:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"cv",weekdays:"вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун".split("_"),months:"кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав".split("_"),weekStart:1,weekdaysShort:"выр_тун_ытл_юн_кӗҫ_эрн_шӑм".split("_"),monthsShort:"кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш".split("_"),weekdaysMin:"вр_тн_ыт_юн_кҫ_эр_шм".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]",LLL:"YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm",LLLL:"dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8792:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"cy",weekdays:"Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn".split("_"),months:"Ionawr_Chwefror_Mawrth_Ebrill_Mai_Mehefin_Gorffennaf_Awst_Medi_Hydref_Tachwedd_Rhagfyr".split("_"),weekStart:1,weekdaysShort:"Sul_Llun_Maw_Mer_Iau_Gwe_Sad".split("_"),monthsShort:"Ion_Chwe_Maw_Ebr_Mai_Meh_Gor_Aws_Med_Hyd_Tach_Rhag".split("_"),weekdaysMin:"Su_Ll_Ma_Me_Ia_Gw_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"mewn %s",past:"%s yn ôl",s:"ychydig eiliadau",m:"munud",mm:"%d munud",h:"awr",hh:"%d awr",d:"diwrnod",dd:"%d diwrnod",M:"mis",MM:"%d mis",y:"blwyddyn",yy:"%d flynedd"}};return t.default.locale(n,null,!0),n}(n(7484))},7427:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"da",weekdays:"søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),weekdaysShort:"søn._man._tirs._ons._tors._fre._lør.".split("_"),weekdaysMin:"sø._ma._ti._on._to._fr._lø.".split("_"),months:"januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december".split("_"),monthsShort:"jan._feb._mar._apr._maj_juni_juli_aug._sept._okt._nov._dec.".split("_"),weekStart:1,ordinal:function(e){return e+"."},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd [d.] D. MMMM YYYY [kl.] HH:mm"},relativeTime:{future:"om %s",past:"%s siden",s:"få sekunder",m:"et minut",mm:"%d minutter",h:"en time",hh:"%d timer",d:"en dag",dd:"%d dage",M:"en måned",MM:"%d måneder",y:"et år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},3237:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"ein paar Sekunden",m:["eine Minute","einer Minute"],mm:"%d Minuten",h:["eine Stunde","einer Stunde"],hh:"%d Stunden",d:["ein Tag","einem Tag"],dd:["%d Tage","%d Tagen"],M:["ein Monat","einem Monat"],MM:["%d Monate","%d Monaten"],y:["ein Jahr","einem Jahr"],yy:["%d Jahre","%d Jahren"]};function r(e,t,r){var a=n[r];return Array.isArray(a)&&(a=a[t?0:1]),a.replace("%d",e)}var a={name:"de-at",weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),months:"Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jän._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.".split("_"),ordinal:function(e){return e+"."},weekStart:1,formats:{LTS:"HH:mm:ss",LT:"HH:mm",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd, D. MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"vor %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},6148:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"ein paar Sekunden",m:["eine Minute","einer Minute"],mm:"%d Minuten",h:["eine Stunde","einer Stunde"],hh:"%d Stunden",d:["ein Tag","einem Tag"],dd:["%d Tage","%d Tagen"],M:["ein Monat","einem Monat"],MM:["%d Monate","%d Monaten"],y:["ein Jahr","einem Jahr"],yy:["%d Jahre","%d Jahren"]};function r(e,t,r){var a=n[r];return Array.isArray(a)&&(a=a[t?0:1]),a.replace("%d",e)}var a={name:"de-ch",weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),months:"Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.".split("_"),ordinal:function(e){return e+"."},weekStart:1,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd, D. MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"vor %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},790:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"ein paar Sekunden",m:["eine Minute","einer Minute"],mm:"%d Minuten",h:["eine Stunde","einer Stunde"],hh:"%d Stunden",d:["ein Tag","einem Tag"],dd:["%d Tage","%d Tagen"],M:["ein Monat","einem Monat"],MM:["%d Monate","%d Monaten"],y:["ein Jahr","einem Jahr"],yy:["%d Jahre","%d Jahren"]};function r(e,t,r){var a=n[r];return Array.isArray(a)&&(a=a[t?0:1]),a.replace("%d",e)}var a={name:"de",weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),months:"Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sept._Okt._Nov._Dez.".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,formats:{LTS:"HH:mm:ss",LT:"HH:mm",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd, D. MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"vor %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},1794:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"dv",weekdays:"އާދިއްތަ_ހޯމަ_އަންގާރަ_ބުދަ_ބުރާސްފަތި_ހުކުރު_ހޮނިހިރު".split("_"),months:"ޖެނުއަރީ_ފެބްރުއަރީ_މާރިޗު_އޭޕްރީލު_މޭ_ޖޫން_ޖުލައި_އޯގަސްޓު_ސެޕްޓެމްބަރު_އޮކްޓޯބަރު_ނޮވެމްބަރު_ޑިސެމްބަރު".split("_"),weekStart:7,weekdaysShort:"އާދިއްތަ_ހޯމަ_އަންގާރަ_ބުދަ_ބުރާސްފަތި_ހުކުރު_ހޮނިހިރު".split("_"),monthsShort:"ޖެނުއަރީ_ފެބްރުއަރީ_މާރިޗު_އޭޕްރީލު_މޭ_ޖޫން_ޖުލައި_އޯގަސްޓު_ސެޕްޓެމްބަރު_އޮކްޓޯބަރު_ނޮވެމްބަރު_ޑިސެމްބަރު".split("_"),weekdaysMin:"އާދި_ހޯމަ_އަން_ބުދަ_ބުރާ_ހުކު_ހޮނި".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"D/M/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"ތެރޭގައި %s",past:"ކުރިން %s",s:"ސިކުންތުކޮޅެއް",m:"މިނިޓެއް",mm:"މިނިޓު %d",h:"ގަޑިއިރެއް",hh:"ގަޑިއިރު %d",d:"ދުވަހެއް",dd:"ދުވަސް %d",M:"މަހެއް",MM:"މަސް %d",y:"އަހަރެއް",yy:"އަހަރު %d"}};return t.default.locale(n,null,!0),n}(n(7484))},5423:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"el",weekdays:"Κυριακή_Δευτέρα_Τρίτη_Τετάρτη_Πέμπτη_Παρασκευή_Σάββατο".split("_"),weekdaysShort:"Κυρ_Δευ_Τρι_Τετ_Πεμ_Παρ_Σαβ".split("_"),weekdaysMin:"Κυ_Δε_Τρ_Τε_Πε_Πα_Σα".split("_"),months:"Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος".split("_"),monthsShort:"Ιαν_Φεβ_Μαρ_Απρ_Μαι_Ιουν_Ιουλ_Αυγ_Σεπτ_Οκτ_Νοε_Δεκ".split("_"),ordinal:function(e){return e},weekStart:1,relativeTime:{future:"σε %s",past:"πριν %s",s:"μερικά δευτερόλεπτα",m:"ένα λεπτό",mm:"%d λεπτά",h:"μία ώρα",hh:"%d ώρες",d:"μία μέρα",dd:"%d μέρες",M:"ένα μήνα",MM:"%d μήνες",y:"ένα χρόνο",yy:"%d χρόνια"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"}};return t.default.locale(n,null,!0),n}(n(7484))},5109:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-au",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},5105:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-ca",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"YYYY-MM-DD",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},9517:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-gb",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekStart:1,yearStart:4,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}};return t.default.locale(n,null,!0),n}(n(7484))},758:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-ie",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},5805:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-il",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},8529:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-in",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekStart:1,yearStart:4,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}};return t.default.locale(n,null,!0),n}(n(7484))},302:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-nz",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},5941:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-sg",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},6183:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-tt",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekStart:1,yearStart:4,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}};return t.default.locale(n,null,!0),n}(n(7484))},5054:function(e){e.exports=function(){"use strict";return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")}}()},4990:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"eo",weekdays:"dimanĉo_lundo_mardo_merkredo_ĵaŭdo_vendredo_sabato".split("_"),months:"januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro".split("_"),weekStart:1,weekdaysShort:"dim_lun_mard_merk_ĵaŭ_ven_sab".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec".split("_"),weekdaysMin:"di_lu_ma_me_ĵa_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D[-a de] MMMM, YYYY",LLL:"D[-a de] MMMM, YYYY HH:mm",LLLL:"dddd, [la] D[-a de] MMMM, YYYY HH:mm"},relativeTime:{future:"post %s",past:"antaŭ %s",s:"sekundoj",m:"minuto",mm:"%d minutoj",h:"horo",hh:"%d horoj",d:"tago",dd:"%d tagoj",M:"monato",MM:"%d monatoj",y:"jaro",yy:"%d jaroj"}};return t.default.locale(n,null,!0),n}(n(7484))},3864:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-do",weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekStart:1,relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY h:mm A",LLLL:"dddd, D [de] MMMM [de] YYYY h:mm A"}};return t.default.locale(n,null,!0),n}(n(7484))},7118:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-mx",weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},3521:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-pr",monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),weekStart:1,formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"MM/DD/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY h:mm A",LLLL:"dddd, D [de] MMMM [de] YYYY h:mm A"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},6165:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-us",weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"MM/DD/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY h:mm A",LLLL:"dddd, D [de] MMMM [de] YYYY h:mm A"}};return t.default.locale(n,null,!0),n}(n(7484))},7763:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es",monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},9670:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e,t,n,r){var a={s:["mõne sekundi","mõni sekund","paar sekundit"],m:["ühe minuti","üks minut"],mm:["%d minuti","%d minutit"],h:["ühe tunni","tund aega","üks tund"],hh:["%d tunni","%d tundi"],d:["ühe päeva","üks päev"],M:["kuu aja","kuu aega","üks kuu"],MM:["%d kuu","%d kuud"],y:["ühe aasta","aasta","üks aasta"],yy:["%d aasta","%d aastat"]};return t?(a[n][2]?a[n][2]:a[n][1]).replace("%d",e):(r?a[n][0]:a[n][1]).replace("%d",e)}var r={name:"et",weekdays:"pühapäev_esmaspäev_teisipäev_kolmapäev_neljapäev_reede_laupäev".split("_"),weekdaysShort:"P_E_T_K_N_R_L".split("_"),weekdaysMin:"P_E_T_K_N_R_L".split("_"),months:"jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember".split("_"),monthsShort:"jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"%s pärast",past:"%s tagasi",s:n,m:n,mm:n,h:n,hh:n,d:n,dd:"%d päeva",M:n,MM:n,y:n,yy:n},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"}};return t.default.locale(r,null,!0),r}(n(7484))},6629:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"eu",weekdays:"igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata".split("_"),months:"urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua".split("_"),weekStart:1,weekdaysShort:"ig._al._ar._az._og._ol._lr.".split("_"),monthsShort:"urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.".split("_"),weekdaysMin:"ig_al_ar_az_og_ol_lr".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY[ko] MMMM[ren] D[a]",LLL:"YYYY[ko] MMMM[ren] D[a] HH:mm",LLLL:"dddd, YYYY[ko] MMMM[ren] D[a] HH:mm",l:"YYYY-M-D",ll:"YYYY[ko] MMM D[a]",lll:"YYYY[ko] MMM D[a] HH:mm",llll:"ddd, YYYY[ko] MMM D[a] HH:mm"},relativeTime:{future:"%s barru",past:"duela %s",s:"segundo batzuk",m:"minutu bat",mm:"%d minutu",h:"ordu bat",hh:"%d ordu",d:"egun bat",dd:"%d egun",M:"hilabete bat",MM:"%d hilabete",y:"urte bat",yy:"%d urte"}};return t.default.locale(n,null,!0),n}(n(7484))},6953:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fa",weekdays:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysShort:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysMin:"ی_د_س_چ_پ_ج_ش".split("_"),weekStart:6,months:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),monthsShort:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"در %s",past:"%s پیش",s:"چند ثانیه",m:"یک دقیقه",mm:"%d دقیقه",h:"یک ساعت",hh:"%d ساعت",d:"یک روز",dd:"%d روز",M:"یک ماه",MM:"%d ماه",y:"یک سال",yy:"%d سال"}};return t.default.locale(n,null,!0),n}(n(7484))},7822:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e,t,n,r){var a={s:"muutama sekunti",m:"minuutti",mm:"%d minuuttia",h:"tunti",hh:"%d tuntia",d:"päivä",dd:"%d päivää",M:"kuukausi",MM:"%d kuukautta",y:"vuosi",yy:"%d vuotta",numbers:"nolla_yksi_kaksi_kolme_neljä_viisi_kuusi_seitsemän_kahdeksan_yhdeksän".split("_")},i={s:"muutaman sekunnin",m:"minuutin",mm:"%d minuutin",h:"tunnin",hh:"%d tunnin",d:"päivän",dd:"%d päivän",M:"kuukauden",MM:"%d kuukauden",y:"vuoden",yy:"%d vuoden",numbers:"nollan_yhden_kahden_kolmen_neljän_viiden_kuuden_seitsemän_kahdeksan_yhdeksän".split("_")},s=r&&!t?i:a,o=s[n];return e<10?o.replace("%d",s.numbers[e]):o.replace("%d",e)}var r={name:"fi",weekdays:"sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai".split("_"),weekdaysShort:"su_ma_ti_ke_to_pe_la".split("_"),weekdaysMin:"su_ma_ti_ke_to_pe_la".split("_"),months:"tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu".split("_"),monthsShort:"tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,relativeTime:{future:"%s päästä",past:"%s sitten",s:n,m:n,mm:n,h:n,hh:n,d:n,dd:n,M:n,MM:n,y:n,yy:n},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD.MM.YYYY",LL:"D. MMMM[ta] YYYY",LLL:"D. MMMM[ta] YYYY, [klo] HH.mm",LLLL:"dddd, D. MMMM[ta] YYYY, [klo] HH.mm",l:"D.M.YYYY",ll:"D. MMM YYYY",lll:"D. MMM YYYY, [klo] HH.mm",llll:"ddd, D. MMM YYYY, [klo] HH.mm"}};return t.default.locale(r,null,!0),r}(n(7484))},9197:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fo",weekdays:"sunnudagur_mánadagur_týsdagur_mikudagur_hósdagur_fríggjadagur_leygardagur".split("_"),months:"januar_februar_mars_apríl_mai_juni_juli_august_september_oktober_november_desember".split("_"),weekStart:1,weekdaysShort:"sun_mán_týs_mik_hós_frí_ley".split("_"),monthsShort:"jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des".split("_"),weekdaysMin:"su_má_tý_mi_hó_fr_le".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D. MMMM, YYYY HH:mm"},relativeTime:{future:"um %s",past:"%s síðani",s:"fá sekund",m:"ein minuttur",mm:"%d minuttir",h:"ein tími",hh:"%d tímar",d:"ein dagur",dd:"%d dagar",M:"ein mánaður",MM:"%d mánaðir",y:"eitt ár",yy:"%d ár"}};return t.default.locale(n,null,!0),n}(n(7484))},7989:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fr-ca",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"}};return t.default.locale(n,null,!0),n}(n(7484))},4254:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fr-ch",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),weekStart:1,weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"}};return t.default.locale(n,null,!0),n}(n(7484))},6023:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fr",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"},ordinal:function(e){return e+(1===e?"er":"e")}};return t.default.locale(n,null,!0),n}(n(7484))},3220:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fy",weekdays:"snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon".split("_"),months:"jannewaris_febrewaris_maart_april_maaie_juny_july_augustus_septimber_oktober_novimber_desimber".split("_"),monthsShort:"jan._feb._mrt._apr._mai_jun._jul._aug._sep._okt._nov._des.".split("_"),weekStart:1,weekdaysShort:"si._mo._ti._wo._to._fr._so.".split("_"),weekdaysMin:"Si_Mo_Ti_Wo_To_Fr_So".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"oer %s",past:"%s lyn",s:"in pear sekonden",m:"ien minút",mm:"%d minuten",h:"ien oere",hh:"%d oeren",d:"ien dei",dd:"%d dagen",M:"ien moanne",MM:"%d moannen",y:"ien jier",yy:"%d jierren"}};return t.default.locale(n,null,!0),n}(n(7484))},7467:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ga",weekdays:"Dé Domhnaigh_Dé Luain_Dé Máirt_Dé Céadaoin_Déardaoin_Dé hAoine_Dé Satharn".split("_"),months:"Eanáir_Feabhra_Márta_Aibreán_Bealtaine_Méitheamh_Iúil_Lúnasa_Meán Fómhair_Deaireadh Fómhair_Samhain_Nollaig".split("_"),weekStart:1,weekdaysShort:"Dom_Lua_Mái_Céa_Déa_hAo_Sat".split("_"),monthsShort:"Eaná_Feab_Márt_Aibr_Beal_Méit_Iúil_Lúna_Meán_Deai_Samh_Noll".split("_"),weekdaysMin:"Do_Lu_Má_Ce_Dé_hA_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"i %s",past:"%s ó shin",s:"cúpla soicind",m:"nóiméad",mm:"%d nóiméad",h:"uair an chloig",hh:"%d uair an chloig",d:"lá",dd:"%d lá",M:"mí",MM:"%d mí",y:"bliain",yy:"%d bliain"}};return t.default.locale(n,null,!0),n}(n(7484))},4855:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gd",weekdays:"Didòmhnaich_Diluain_Dimàirt_Diciadain_Diardaoin_Dihaoine_Disathairne".split("_"),months:"Am Faoilleach_An Gearran_Am Màrt_An Giblean_An Cèitean_An t-Ògmhios_An t-Iuchar_An Lùnastal_An t-Sultain_An Dàmhair_An t-Samhain_An Dùbhlachd".split("_"),weekStart:1,weekdaysShort:"Did_Dil_Dim_Dic_Dia_Dih_Dis".split("_"),monthsShort:"Faoi_Gear_Màrt_Gibl_Cèit_Ògmh_Iuch_Lùn_Sult_Dàmh_Samh_Dùbh".split("_"),weekdaysMin:"Dò_Lu_Mà_Ci_Ar_Ha_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"ann an %s",past:"bho chionn %s",s:"beagan diogan",m:"mionaid",mm:"%d mionaidean",h:"uair",hh:"%d uairean",d:"latha",dd:"%d latha",M:"mìos",MM:"%d mìosan",y:"bliadhna",yy:"%d bliadhna"}};return t.default.locale(n,null,!0),n}(n(7484))},229:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gl",weekdays:"domingo_luns_martes_mércores_xoves_venres_sábado".split("_"),months:"xaneiro_febreiro_marzo_abril_maio_xuño_xullo_agosto_setembro_outubro_novembro_decembro".split("_"),weekStart:1,weekdaysShort:"dom._lun._mar._mér._xov._ven._sáb.".split("_"),monthsShort:"xan._feb._mar._abr._mai._xuñ._xul._ago._set._out._nov._dec.".split("_"),weekdaysMin:"do_lu_ma_mé_xo_ve_sá".split("_"),ordinal:function(e){return e+"º"},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},relativeTime:{future:"en %s",past:"fai %s",s:"uns segundos",m:"un minuto",mm:"%d minutos",h:"unha hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un ano",yy:"%d anos"}};return t.default.locale(n,null,!0),n}(n(7484))},6312:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gom-latn",weekdays:"Aitar_Somar_Mongllar_Budvar_Brestar_Sukrar_Son'var".split("_"),months:"Janer_Febrer_Mars_Abril_Mai_Jun_Julai_Agost_Setembr_Otubr_Novembr_Dezembr".split("_"),weekStart:1,weekdaysShort:"Ait._Som._Mon._Bud._Bre._Suk._Son.".split("_"),monthsShort:"Jan._Feb._Mars_Abr._Mai_Jun_Jul._Ago._Set._Otu._Nov._Dez.".split("_"),weekdaysMin:"Ai_Sm_Mo_Bu_Br_Su_Sn".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm [vazta]",LTS:"A h:mm:ss [vazta]",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY A h:mm [vazta]",LLLL:"dddd, MMMM[achea] Do, YYYY, A h:mm [vazta]",llll:"ddd, D MMM YYYY, A h:mm [vazta]"}};return t.default.locale(n,null,!0),n}(n(7484))},7632:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gu",weekdays:"રવિવાર_સોમવાર_મંગળવાર_બુધ્વાર_ગુરુવાર_શુક્રવાર_શનિવાર".split("_"),months:"જાન્યુઆરી_ફેબ્રુઆરી_માર્ચ_એપ્રિલ_મે_જૂન_જુલાઈ_ઑગસ્ટ_સપ્ટેમ્બર_ઑક્ટ્બર_નવેમ્બર_ડિસેમ્બર".split("_"),weekdaysShort:"રવિ_સોમ_મંગળ_બુધ્_ગુરુ_શુક્ર_શનિ".split("_"),monthsShort:"જાન્યુ._ફેબ્રુ._માર્ચ_એપ્રિ._મે_જૂન_જુલા._ઑગ._સપ્ટે._ઑક્ટ્._નવે._ડિસે.".split("_"),weekdaysMin:"ર_સો_મં_બુ_ગુ_શુ_શ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm વાગ્યે",LTS:"A h:mm:ss વાગ્યે",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm વાગ્યે",LLLL:"dddd, D MMMM YYYY, A h:mm વાગ્યે"},relativeTime:{future:"%s મા",past:"%s પેહલા",s:"અમુક પળો",m:"એક મિનિટ",mm:"%d મિનિટ",h:"એક કલાક",hh:"%d કલાક",d:"એક દિવસ",dd:"%d દિવસ",M:"એક મહિનો",MM:"%d મહિનો",y:"એક વર્ષ",yy:"%d વર્ષ"}};return t.default.locale(n,null,!0),n}(n(7484))},5418:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"מספר שניות",ss:"%d שניות",m:"דקה",mm:"%d דקות",h:"שעה",hh:"%d שעות",hh2:"שעתיים",d:"יום",dd:"%d ימים",dd2:"יומיים",M:"חודש",MM:"%d חודשים",MM2:"חודשיים",y:"שנה",yy:"%d שנים",yy2:"שנתיים"};function r(e,t,r){return(n[r+(2===e?"2":"")]||n[r]).replace("%d",e)}var a={name:"he",weekdays:"ראשון_שני_שלישי_רביעי_חמישי_שישי_שבת".split("_"),weekdaysShort:"א׳_ב׳_ג׳_ד׳_ה׳_ו׳_ש׳".split("_"),weekdaysMin:"א׳_ב׳_ג׳_ד׳_ה׳_ו_ש׳".split("_"),months:"ינואר_פברואר_מרץ_אפריל_מאי_יוני_יולי_אוגוסט_ספטמבר_אוקטובר_נובמבר_דצמבר".split("_"),monthsShort:"ינו_פבר_מרץ_אפר_מאי_יונ_יול_אוג_ספט_אוק_נוב_דצמ".split("_"),relativeTime:{future:"בעוד %s",past:"לפני %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r},ordinal:function(e){return e},format:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [ב]MMMM YYYY",LLL:"D [ב]MMMM YYYY HH:mm",LLLL:"dddd, D [ב]MMMM YYYY HH:mm",l:"D/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY HH:mm",llll:"ddd, D MMM YYYY HH:mm"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [ב]MMMM YYYY",LLL:"D [ב]MMMM YYYY HH:mm",LLLL:"dddd, D [ב]MMMM YYYY HH:mm",l:"D/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY HH:mm",llll:"ddd, D MMM YYYY HH:mm"}};return t.default.locale(a,null,!0),a}(n(7484))},7573:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"hi",weekdays:"रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार".split("_"),months:"जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर".split("_"),weekdaysShort:"रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि".split("_"),monthsShort:"जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.".split("_"),weekdaysMin:"र_सो_मं_बु_गु_शु_श".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm बजे",LTS:"A h:mm:ss बजे",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm बजे",LLLL:"dddd, D MMMM YYYY, A h:mm बजे"},relativeTime:{future:"%s में",past:"%s पहले",s:"कुछ ही क्षण",m:"एक मिनट",mm:"%d मिनट",h:"एक घंटा",hh:"%d घंटे",d:"एक दिन",dd:"%d दिन",M:"एक महीने",MM:"%d महीने",y:"एक वर्ष",yy:"%d वर्ष"}};return t.default.locale(n,null,!0),n}(n(7484))},6257:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="siječnja_veljače_ožujka_travnja_svibnja_lipnja_srpnja_kolovoza_rujna_listopada_studenoga_prosinca".split("_"),r="siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac".split("_"),a=/D[oD]?(\[[^[\]]*\]|\s)+MMMM?/,i=function(e,t){return a.test(t)?n[e.month()]:r[e.month()]};i.s=r,i.f=n;var s={name:"hr",weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),months:i,monthsShort:"sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"},relativeTime:{future:"za %s",past:"prije %s",s:"sekunda",m:"minuta",mm:"%d minuta",h:"sat",hh:"%d sati",d:"dan",dd:"%d dana",M:"mjesec",MM:"%d mjeseci",y:"godina",yy:"%d godine"},ordinal:function(e){return e+"."}};return t.default.locale(s,null,!0),s}(n(7484))},8889:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ht",weekdays:"dimanch_lendi_madi_mèkredi_jedi_vandredi_samdi".split("_"),months:"janvye_fevriye_mas_avril_me_jen_jiyè_out_septanm_oktòb_novanm_desanm".split("_"),weekdaysShort:"dim._len._mad._mèk._jed._van._sam.".split("_"),monthsShort:"jan._fev._mas_avr._me_jen_jiyè._out_sept._okt._nov._des.".split("_"),weekdaysMin:"di_le_ma_mè_je_va_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"nan %s",past:"sa gen %s",s:"kèk segond",m:"yon minit",mm:"%d minit",h:"inèdtan",hh:"%d zè",d:"yon jou",dd:"%d jou",M:"yon mwa",MM:"%d mwa",y:"yon ane",yy:"%d ane"}};return t.default.locale(n,null,!0),n}(n(7484))},8562:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"hu",weekdays:"vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat".split("_"),weekdaysShort:"vas_hét_kedd_sze_csüt_pén_szo".split("_"),weekdaysMin:"v_h_k_sze_cs_p_szo".split("_"),months:"január_február_március_április_május_június_július_augusztus_szeptember_október_november_december".split("_"),monthsShort:"jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"%s múlva",past:"%s",s:function(e,t,n,r){return"néhány másodperc"+(r||t?"":"e")},m:function(e,t,n,r){return"egy perc"+(r||t?"":"e")},mm:function(e,t,n,r){return e+" perc"+(r||t?"":"e")},h:function(e,t,n,r){return"egy "+(r||t?"óra":"órája")},hh:function(e,t,n,r){return e+" "+(r||t?"óra":"órája")},d:function(e,t,n,r){return"egy "+(r||t?"nap":"napja")},dd:function(e,t,n,r){return e+" "+(r||t?"nap":"napja")},M:function(e,t,n,r){return"egy "+(r||t?"hónap":"hónapja")},MM:function(e,t,n,r){return e+" "+(r||t?"hónap":"hónapja")},y:function(e,t,n,r){return"egy "+(r||t?"év":"éve")},yy:function(e,t,n,r){return e+" "+(r||t?"év":"éve")}},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"YYYY.MM.DD.",LL:"YYYY. MMMM D.",LLL:"YYYY. MMMM D. H:mm",LLLL:"YYYY. MMMM D., dddd H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8242:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"hy-am",weekdays:"կիրակի_երկուշաբթի_երեքշաբթի_չորեքշաբթի_հինգշաբթի_ուրբաթ_շաբաթ".split("_"),months:"հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի".split("_"),weekStart:1,weekdaysShort:"կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ".split("_"),monthsShort:"հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ".split("_"),weekdaysMin:"կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY թ.",LLL:"D MMMM YYYY թ., HH:mm",LLLL:"dddd, D MMMM YYYY թ., HH:mm"},relativeTime:{future:"%s հետո",past:"%s առաջ",s:"մի քանի վայրկյան",m:"րոպե",mm:"%d րոպե",h:"ժամ",hh:"%d ժամ",d:"օր",dd:"%d օր",M:"ամիս",MM:"%d ամիս",y:"տարի",yy:"%d տարի"}};return t.default.locale(n,null,!0),n}(n(7484))},3783:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"id",weekdays:"Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu".split("_"),months:"Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember".split("_"),weekdaysShort:"Min_Sen_Sel_Rab_Kam_Jum_Sab".split("_"),monthsShort:"Jan_Feb_Mar_Apr_Mei_Jun_Jul_Agt_Sep_Okt_Nov_Des".split("_"),weekdaysMin:"Mg_Sn_Sl_Rb_Km_Jm_Sb".split("_"),weekStart:1,formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] HH.mm",LLLL:"dddd, D MMMM YYYY [pukul] HH.mm"},relativeTime:{future:"dalam %s",past:"%s yang lalu",s:"beberapa detik",m:"semenit",mm:"%d menit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},8980:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:["nokkrar sekúndur","nokkrar sekúndur","nokkrum sekúndum"],m:["mínúta","mínútu","mínútu"],mm:["mínútur","mínútur","mínútum"],h:["klukkustund","klukkustund","klukkustund"],hh:["klukkustundir","klukkustundir","klukkustundum"],d:["dagur","dag","degi"],dd:["dagar","daga","dögum"],M:["mánuður","mánuð","mánuði"],MM:["mánuðir","mánuði","mánuðum"],y:["ár","ár","ári"],yy:["ár","ár","árum"]};function r(e,t,r,a){var i=function(e,t,r,a){var i=a?0:r?1:2,s=2===e.length&&t%10==1?e[0]:e,o=n[s][i];return 1===e.length?o:"%d "+o}(r,e,a,t);return i.replace("%d",e)}var a={name:"is",weekdays:"sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur".split("_"),months:"janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember".split("_"),weekStart:1,weekdaysShort:"sun_mán_þri_mið_fim_fös_lau".split("_"),monthsShort:"jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des".split("_"),weekdaysMin:"Su_Má_Þr_Mi_Fi_Fö_La".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] H:mm",LLLL:"dddd, D. MMMM YYYY [kl.] H:mm"},relativeTime:{future:"eftir %s",past:"fyrir %s síðan",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},3706:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"it-ch",weekdays:"domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato".split("_"),months:"gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre".split("_"),weekStart:1,weekdaysShort:"dom_lun_mar_mer_gio_ven_sab".split("_"),monthsShort:"gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic".split("_"),weekdaysMin:"do_lu_ma_me_gi_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"tra %s",past:"%s fa",s:"alcuni secondi",m:"un minuto",mm:"%d minuti",h:"un'ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"}};return t.default.locale(n,null,!0),n}(n(7484))},5551:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"it",weekdays:"domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato".split("_"),weekdaysShort:"dom_lun_mar_mer_gio_ven_sab".split("_"),weekdaysMin:"do_lu_ma_me_gi_ve_sa".split("_"),months:"gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre".split("_"),weekStart:1,monthsShort:"gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic".split("_"),formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"tra %s",past:"%s fa",s:"qualche secondo",m:"un minuto",mm:"%d minuti",h:"un' ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},6831:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ja",weekdays:"日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日".split("_"),weekdaysShort:"日_月_火_水_木_金_土".split("_"),weekdaysMin:"日_月_火_水_木_金_土".split("_"),months:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e){return e+"日"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日 HH:mm",LLLL:"YYYY年M月D日 dddd HH:mm",l:"YYYY/MM/DD",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日(ddd) HH:mm"},meridiem:function(e){return e<12?"午前":"午後"},relativeTime:{future:"%s後",past:"%s前",s:"数秒",m:"1分",mm:"%d分",h:"1時間",hh:"%d時間",d:"1日",dd:"%d日",M:"1ヶ月",MM:"%dヶ月",y:"1年",yy:"%d年"}};return t.default.locale(n,null,!0),n}(n(7484))},2641:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"jv",weekdays:"Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu".split("_"),months:"Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember".split("_"),weekStart:1,weekdaysShort:"Min_Sen_Sel_Reb_Kem_Jem_Sep".split("_"),monthsShort:"Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des".split("_"),weekdaysMin:"Mg_Sn_Sl_Rb_Km_Jm_Sp".split("_"),ordinal:function(e){return e},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] HH.mm",LLLL:"dddd, D MMMM YYYY [pukul] HH.mm"},relativeTime:{future:"wonten ing %s",past:"%s ingkang kepengker",s:"sawetawis detik",m:"setunggal menit",mm:"%d menit",h:"setunggal jam",hh:"%d jam",d:"sedinten",dd:"%d dinten",M:"sewulan",MM:"%d wulan",y:"setaun",yy:"%d taun"}};return t.default.locale(n,null,!0),n}(n(7484))},6622:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ka",weekdays:"კვირა_ორშაბათი_სამშაბათი_ოთხშაბათი_ხუთშაბათი_პარასკევი_შაბათი".split("_"),weekdaysShort:"კვი_ორშ_სამ_ოთხ_ხუთ_პარ_შაბ".split("_"),weekdaysMin:"კვ_ორ_სა_ოთ_ხუ_პა_შა".split("_"),months:"იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი".split("_"),monthsShort:"იან_თებ_მარ_აპრ_მაი_ივნ_ივლ_აგვ_სექ_ოქტ_ნოე_დეკ".split("_"),weekStart:1,formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"%s შემდეგ",past:"%s წინ",s:"წამი",m:"წუთი",mm:"%d წუთი",h:"საათი",hh:"%d საათის",d:"დღეს",dd:"%d დღის განმავლობაში",M:"თვის",MM:"%d თვის",y:"წელი",yy:"%d წლის"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},2921:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"kk",weekdays:"жексенбі_дүйсенбі_сейсенбі_сәрсенбі_бейсенбі_жұма_сенбі".split("_"),weekdaysShort:"жек_дүй_сей_сәр_бей_жұм_сен".split("_"),weekdaysMin:"жк_дй_сй_ср_бй_жм_сн".split("_"),months:"қаңтар_ақпан_наурыз_сәуір_мамыр_маусым_шілде_тамыз_қыркүйек_қазан_қараша_желтоқсан".split("_"),monthsShort:"қаң_ақп_нау_сәу_мам_мау_шіл_там_қыр_қаз_қар_жел".split("_"),weekStart:1,relativeTime:{future:"%s ішінде",past:"%s бұрын",s:"бірнеше секунд",m:"бір минут",mm:"%d минут",h:"бір сағат",hh:"%d сағат",d:"бір күн",dd:"%d күн",M:"бір ай",MM:"%d ай",y:"бір жыл",yy:"%d жыл"},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},5567:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"km",weekdays:"អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍".split("_"),months:"មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_"),weekStart:1,weekdaysShort:"អា_ច_អ_ព_ព្រ_សុ_ស".split("_"),monthsShort:"មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_"),weekdaysMin:"អា_ច_អ_ព_ព្រ_សុ_ស".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%sទៀត",past:"%sមុន",s:"ប៉ុន្មានវិនាទី",m:"មួយនាទី",mm:"%d នាទី",h:"មួយម៉ោង",hh:"%d ម៉ោង",d:"មួយថ្ងៃ",dd:"%d ថ្ងៃ",M:"មួយខែ",MM:"%d ខែ",y:"មួយឆ្នាំ",yy:"%d ឆ្នាំ"}};return t.default.locale(n,null,!0),n}(n(7484))},1113:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"kn",weekdays:"ಭಾನುವಾರ_ಸೋಮವಾರ_ಮಂಗಳವಾರ_ಬುಧವಾರ_ಗುರುವಾರ_ಶುಕ್ರವಾರ_ಶನಿವಾರ".split("_"),months:"ಜನವರಿ_ಫೆಬ್ರವರಿ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂಬರ್_ಅಕ್ಟೋಬರ್_ನವೆಂಬರ್_ಡಿಸೆಂಬರ್".split("_"),weekdaysShort:"ಭಾನು_ಸೋಮ_ಮಂಗಳ_ಬುಧ_ಗುರು_ಶುಕ್ರ_ಶನಿ".split("_"),monthsShort:"ಜನ_ಫೆಬ್ರ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂ_ಅಕ್ಟೋ_ನವೆಂ_ಡಿಸೆಂ".split("_"),weekdaysMin:"ಭಾ_ಸೋ_ಮಂ_ಬು_ಗು_ಶು_ಶ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm",LLLL:"dddd, D MMMM YYYY, A h:mm"},relativeTime:{future:"%s ನಂತರ",past:"%s ಹಿಂದೆ",s:"ಕೆಲವು ಕ್ಷಣಗಳು",m:"ಒಂದು ನಿಮಿಷ",mm:"%d ನಿಮಿಷ",h:"ಒಂದು ಗಂಟೆ",hh:"%d ಗಂಟೆ",d:"ಒಂದು ದಿನ",dd:"%d ದಿನ",M:"ಒಂದು ತಿಂಗಳು",MM:"%d ತಿಂಗಳು",y:"ಒಂದು ವರ್ಷ",yy:"%d ವರ್ಷ"}};return t.default.locale(n,null,!0),n}(n(7484))},9132:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ko",weekdays:"일요일_월요일_화요일_수요일_목요일_금요일_토요일".split("_"),weekdaysShort:"일_월_화_수_목_금_토".split("_"),weekdaysMin:"일_월_화_수_목_금_토".split("_"),months:"1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월".split("_"),monthsShort:"1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"YYYY.MM.DD.",LL:"YYYY년 MMMM D일",LLL:"YYYY년 MMMM D일 A h:mm",LLLL:"YYYY년 MMMM D일 dddd A h:mm",l:"YYYY.MM.DD.",ll:"YYYY년 MMMM D일",lll:"YYYY년 MMMM D일 A h:mm",llll:"YYYY년 MMMM D일 dddd A h:mm"},meridiem:function(e){return e<12?"오전":"오후"},relativeTime:{future:"%s 후",past:"%s 전",s:"몇 초",m:"1분",mm:"%d분",h:"한 시간",hh:"%d시간",d:"하루",dd:"%d일",M:"한 달",MM:"%d달",y:"일 년",yy:"%d년"}};return t.default.locale(n,null,!0),n}(n(7484))},4888:function(e,t,n){!function(e,t){"use strict";var n=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(t),r={1:"١",2:"٢",3:"٣",4:"٤",5:"٥",6:"٦",7:"٧",8:"٨",9:"٩",0:"٠"},a={"١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","٠":"0"},i=["کانوونی دووەم","شوبات","ئادار","نیسان","ئایار","حوزەیران","تەممووز","ئاب","ئەیلوول","تشرینی یەکەم","تشرینی دووەم","کانوونی یەکەم"],s={name:"ku",months:i,monthsShort:i,weekdays:"یەکشەممە_دووشەممە_سێشەممە_چوارشەممە_پێنجشەممە_هەینی_شەممە".split("_"),weekdaysShort:"یەکشەم_دووشەم_سێشەم_چوارشەم_پێنجشەم_هەینی_شەممە".split("_"),weekStart:6,weekdaysMin:"ی_د_س_چ_پ_هـ_ش".split("_"),preparse:function(e){return e.replace(/[١٢٣٤٥٦٧٨٩٠]/g,(function(e){return a[e]})).replace(/،/g,",")},postformat:function(e){return e.replace(/\d/g,(function(e){return r[e]})).replace(/,/g,"،")},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},meridiem:function(e){return e<12?"پ.ن":"د.ن"},relativeTime:{future:"لە %s",past:"لەمەوپێش %s",s:"چەند چرکەیەک",m:"یەک خولەک",mm:"%d خولەک",h:"یەک کاتژمێر",hh:"%d کاتژمێر",d:"یەک ڕۆژ",dd:"%d ڕۆژ",M:"یەک مانگ",MM:"%d مانگ",y:"یەک ساڵ",yy:"%d ساڵ"}};n.default.locale(s,null,!0),e.default=s,e.englishToArabicNumbersMap=r,Object.defineProperty(e,"__esModule",{value:!0})}(t,n(7484))},466:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ky",weekdays:"Жекшемби_Дүйшөмбү_Шейшемби_Шаршемби_Бейшемби_Жума_Ишемби".split("_"),months:"январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь".split("_"),weekStart:1,weekdaysShort:"Жек_Дүй_Шей_Шар_Бей_Жум_Ише".split("_"),monthsShort:"янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек".split("_"),weekdaysMin:"Жк_Дй_Шй_Шр_Бй_Жм_Иш".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%s ичинде",past:"%s мурун",s:"бирнече секунд",m:"бир мүнөт",mm:"%d мүнөт",h:"бир саат",hh:"%d саат",d:"бир күн",dd:"%d күн",M:"бир ай",MM:"%d ай",y:"бир жыл",yy:"%d жыл"}};return t.default.locale(n,null,!0),n}(n(7484))},1796:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"lb",weekdays:"Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg".split("_"),months:"Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),weekStart:1,weekdaysShort:"So._Mé._Dë._Më._Do._Fr._Sa.".split("_"),monthsShort:"Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.".split("_"),weekdaysMin:"So_Mé_Dë_Më_Do_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm [Auer]",LTS:"H:mm:ss [Auer]",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm [Auer]",LLLL:"dddd, D. MMMM YYYY H:mm [Auer]"}};return t.default.locale(n,null,!0),n}(n(7484))},8894:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"lo",weekdays:"ອາທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ".split("_"),months:"ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ".split("_"),weekdaysShort:"ທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ".split("_"),monthsShort:"ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ".split("_"),weekdaysMin:"ທ_ຈ_ອຄ_ພ_ພຫ_ສກ_ສ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"ວັນdddd D MMMM YYYY HH:mm"},relativeTime:{future:"ອີກ %s",past:"%sຜ່ານມາ",s:"ບໍ່ເທົ່າໃດວິນາທີ",m:"1 ນາທີ",mm:"%d ນາທີ",h:"1 ຊົ່ວໂມງ",hh:"%d ຊົ່ວໂມງ",d:"1 ມື້",dd:"%d ມື້",M:"1 ເດືອນ",MM:"%d ເດືອນ",y:"1 ປີ",yy:"%d ປີ"}};return t.default.locale(n,null,!0),n}(n(7484))},8768:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="sausio_vasario_kovo_balandžio_gegužės_birželio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio".split("_"),r="sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis".split("_"),a=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?|MMMM?(\[[^\[\]]*\]|\s)+D[oD]?/,i=function(e,t){return a.test(t)?n[e.month()]:r[e.month()]};i.s=r,i.f=n;var s={name:"lt",weekdays:"sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis".split("_"),weekdaysShort:"sek_pir_ant_tre_ket_pen_šeš".split("_"),weekdaysMin:"s_p_a_t_k_pn_š".split("_"),months:i,monthsShort:"sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"už %s",past:"prieš %s",s:"kelias sekundes",m:"minutę",mm:"%d minutes",h:"valandą",hh:"%d valandas",d:"dieną",dd:"%d dienas",M:"mėnesį",MM:"%d mėnesius",y:"metus",yy:"%d metus"},format:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY [m.] MMMM D [d.]",LLL:"YYYY [m.] MMMM D [d.], HH:mm [val.]",LLLL:"YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]",l:"YYYY-MM-DD",ll:"YYYY [m.] MMMM D [d.]",lll:"YYYY [m.] MMMM D [d.], HH:mm [val.]",llll:"YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY [m.] MMMM D [d.]",LLL:"YYYY [m.] MMMM D [d.], HH:mm [val.]",LLLL:"YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]",l:"YYYY-MM-DD",ll:"YYYY [m.] MMMM D [d.]",lll:"YYYY [m.] MMMM D [d.], HH:mm [val.]",llll:"YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]"}};return t.default.locale(s,null,!0),s}(n(7484))},953:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"lv",weekdays:"svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena".split("_"),months:"janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris".split("_"),weekStart:1,weekdaysShort:"Sv_P_O_T_C_Pk_S".split("_"),monthsShort:"jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec".split("_"),weekdaysMin:"Sv_P_O_T_C_Pk_S".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY.",LL:"YYYY. [gada] D. MMMM",LLL:"YYYY. [gada] D. MMMM, HH:mm",LLLL:"YYYY. [gada] D. MMMM, dddd, HH:mm"},relativeTime:{future:"pēc %s",past:"pirms %s",s:"dažām sekundēm",m:"minūtes",mm:"%d minūtēm",h:"stundas",hh:"%d stundām",d:"dienas",dd:"%d dienām",M:"mēneša",MM:"%d mēnešiem",y:"gada",yy:"%d gadiem"}};return t.default.locale(n,null,!0),n}(n(7484))},8066:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"me",weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),months:"januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar".split("_"),weekStart:1,weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),monthsShort:"jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8602:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mi",weekdays:"Rātapu_Mane_Tūrei_Wenerei_Tāite_Paraire_Hātarei".split("_"),months:"Kohi-tāte_Hui-tanguru_Poutū-te-rangi_Paenga-whāwhā_Haratua_Pipiri_Hōngoingoi_Here-turi-kōkā_Mahuru_Whiringa-ā-nuku_Whiringa-ā-rangi_Hakihea".split("_"),weekStart:1,weekdaysShort:"Ta_Ma_Tū_We_Tāi_Pa_Hā".split("_"),monthsShort:"Kohi_Hui_Pou_Pae_Hara_Pipi_Hōngoi_Here_Mahu_Whi-nu_Whi-ra_Haki".split("_"),weekdaysMin:"Ta_Ma_Tū_We_Tāi_Pa_Hā".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [i] HH:mm",LLLL:"dddd, D MMMM YYYY [i] HH:mm"},relativeTime:{future:"i roto i %s",past:"%s i mua",s:"te hēkona ruarua",m:"he meneti",mm:"%d meneti",h:"te haora",hh:"%d haora",d:"he ra",dd:"%d ra",M:"he marama",MM:"%d marama",y:"he tau",yy:"%d tau"}};return t.default.locale(n,null,!0),n}(n(7484))},1560:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mk",weekdays:"недела_понеделник_вторник_среда_четврток_петок_сабота".split("_"),months:"јануари_февруари_март_април_мај_јуни_јули_август_септември_октомври_ноември_декември".split("_"),weekStart:1,weekdaysShort:"нед_пон_вто_сре_чет_пет_саб".split("_"),monthsShort:"јан_фев_мар_апр_мај_јун_јул_авг_сеп_окт_ное_дек".split("_"),weekdaysMin:"нe_пo_вт_ср_че_пе_сa".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY H:mm",LLLL:"dddd, D MMMM YYYY H:mm"},relativeTime:{future:"после %s",past:"пред %s",s:"неколку секунди",m:"минута",mm:"%d минути",h:"час",hh:"%d часа",d:"ден",dd:"%d дена",M:"месец",MM:"%d месеци",y:"година",yy:"%d години"}};return t.default.locale(n,null,!0),n}(n(7484))},4017:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ml",weekdays:"ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച".split("_"),months:"ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ".split("_"),weekdaysShort:"ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി".split("_"),monthsShort:"ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.".split("_"),weekdaysMin:"ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm -നു",LTS:"A h:mm:ss -നു",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm -നു",LLLL:"dddd, D MMMM YYYY, A h:mm -നു"},relativeTime:{future:"%s കഴിഞ്ഞ്",past:"%s മുൻപ്",s:"അൽപ നിമിഷങ്ങൾ",m:"ഒരു മിനിറ്റ്",mm:"%d മിനിറ്റ്",h:"ഒരു മണിക്കൂർ",hh:"%d മണിക്കൂർ",d:"ഒരു ദിവസം",dd:"%d ദിവസം",M:"ഒരു മാസം",MM:"%d മാസം",y:"ഒരു വർഷം",yy:"%d വർഷം"}};return t.default.locale(n,null,!0),n}(n(7484))},4717:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mn",weekdays:"Ням_Даваа_Мягмар_Лхагва_Пүрэв_Баасан_Бямба".split("_"),months:"Нэгдүгээр сар_Хоёрдугаар сар_Гуравдугаар сар_Дөрөвдүгээр сар_Тавдугаар сар_Зургадугаар сар_Долдугаар сар_Наймдугаар сар_Есдүгээр сар_Аравдугаар сар_Арван нэгдүгээр сар_Арван хоёрдугаар сар".split("_"),weekdaysShort:"Ням_Дав_Мяг_Лха_Пүр_Баа_Бям".split("_"),monthsShort:"1 сар_2 сар_3 сар_4 сар_5 сар_6 сар_7 сар_8 сар_9 сар_10 сар_11 сар_12 сар".split("_"),weekdaysMin:"Ня_Да_Мя_Лх_Пү_Ба_Бя".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY оны MMMMын D",LLL:"YYYY оны MMMMын D HH:mm",LLLL:"dddd, YYYY оны MMMMын D HH:mm"},relativeTime:{future:"%s",past:"%s",s:"саяхан",m:"м",mm:"%dм",h:"1ц",hh:"%dц",d:"1ө",dd:"%dө",M:"1с",MM:"%dс",y:"1ж",yy:"%dж"}};return t.default.locale(n,null,!0),n}(n(7484))},5473:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mr",weekdays:"रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार".split("_"),months:"जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर".split("_"),weekdaysShort:"रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि".split("_"),monthsShort:"जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.".split("_"),weekdaysMin:"र_सो_मं_बु_गु_शु_श".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm वाजता",LTS:"A h:mm:ss वाजता",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm वाजता",LLLL:"dddd, D MMMM YYYY, A h:mm वाजता"}};return t.default.locale(n,null,!0),n}(n(7484))},7387:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ms-my",weekdays:"Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu".split("_"),months:"Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember".split("_"),weekStart:1,weekdaysShort:"Ahd_Isn_Sel_Rab_Kha_Jum_Sab".split("_"),monthsShort:"Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis".split("_"),weekdaysMin:"Ah_Is_Sl_Rb_Km_Jm_Sb".split("_"),ordinal:function(e){return e},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] HH.mm",LLLL:"dddd, D MMMM YYYY [pukul] HH.mm"},relativeTime:{future:"dalam %s",past:"%s yang lepas",s:"beberapa saat",m:"seminit",mm:"%d minit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"}};return t.default.locale(n,null,!0),n}(n(7484))},5742:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ms",weekdays:"Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu".split("_"),weekdaysShort:"Ahd_Isn_Sel_Rab_Kha_Jum_Sab".split("_"),weekdaysMin:"Ah_Is_Sl_Rb_Km_Jm_Sb".split("_"),months:"Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember".split("_"),monthsShort:"Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis".split("_"),weekStart:1,formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH.mm",LLLL:"dddd, D MMMM YYYY HH.mm"},relativeTime:{future:"dalam %s",past:"%s yang lepas",s:"beberapa saat",m:"seminit",mm:"%d minit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},8477:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mt",weekdays:"Il-Ħadd_It-Tnejn_It-Tlieta_L-Erbgħa_Il-Ħamis_Il-Ġimgħa_Is-Sibt".split("_"),months:"Jannar_Frar_Marzu_April_Mejju_Ġunju_Lulju_Awwissu_Settembru_Ottubru_Novembru_Diċembru".split("_"),weekStart:1,weekdaysShort:"Ħad_Tne_Tli_Erb_Ħam_Ġim_Sib".split("_"),monthsShort:"Jan_Fra_Mar_Apr_Mej_Ġun_Lul_Aww_Set_Ott_Nov_Diċ".split("_"),weekdaysMin:"Ħa_Tn_Tl_Er_Ħa_Ġi_Si".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"f’ %s",past:"%s ilu",s:"ftit sekondi",m:"minuta",mm:"%d minuti",h:"siegħa",hh:"%d siegħat",d:"ġurnata",dd:"%d ġranet",M:"xahar",MM:"%d xhur",y:"sena",yy:"%d sni"}};return t.default.locale(n,null,!0),n}(n(7484))},2966:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"my",weekdays:"တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ".split("_"),months:"ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ".split("_"),weekStart:1,weekdaysShort:"နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ".split("_"),monthsShort:"ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ".split("_"),weekdaysMin:"နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"လာမည့် %s မှာ",past:"လွန်ခဲ့သော %s က",s:"စက္ကန်.အနည်းငယ်",m:"တစ်မိနစ်",mm:"%d မိနစ်",h:"တစ်နာရီ",hh:"%d နာရီ",d:"တစ်ရက်",dd:"%d ရက်",M:"တစ်လ",MM:"%d လ",y:"တစ်နှစ်",yy:"%d နှစ်"}};return t.default.locale(n,null,!0),n}(n(7484))},9682:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nb",weekdays:"søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),weekdaysShort:"sø._ma._ti._on._to._fr._lø.".split("_"),weekdaysMin:"sø_ma_ti_on_to_fr_lø".split("_"),months:"januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember".split("_"),monthsShort:"jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] HH:mm",LLLL:"dddd D. MMMM YYYY [kl.] HH:mm"},relativeTime:{future:"om %s",past:"%s siden",s:"noen sekunder",m:"ett minutt",mm:"%d minutter",h:"en time",hh:"%d timer",d:"en dag",dd:"%d dager",M:"en måned",MM:"%d måneder",y:"ett år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},4149:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ne",weekdays:"आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार".split("_"),weekdaysShort:"आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.".split("_"),weekdaysMin:"आ._सो._मं._बु._बि._शु._श.".split("_"),months:"जनवरी_फेब्रुवरी_मार्च_अप्रिल_मे_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर".split("_"),monthsShort:"जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.".split("_"),relativeTime:{future:"%s पछि",past:"%s अघि",s:"सेकेन्ड",m:"एक मिनेट",mm:"%d मिनेट",h:"घन्टा",hh:"%d घन्टा",d:"एक दिन",dd:"%d दिन",M:"एक महिना",MM:"%d महिना",y:"एक वर्ष",yy:"%d वर्ष"},ordinal:function(e){return(""+e).replace(/\d/g,(function(e){return"०१२३४५६७८९"[e]}))},formats:{LT:"Aको h:mm बजे",LTS:"Aको h:mm:ss बजे",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, Aको h:mm बजे",LLLL:"dddd, D MMMM YYYY, Aको h:mm बजे"}};return t.default.locale(n,null,!0),n}(n(7484))},7496:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nl-be",weekdays:"zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),months:"januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),monthsShort:"jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.".split("_"),weekStart:1,weekdaysShort:"zo._ma._di._wo._do._vr._za.".split("_"),weekdaysMin:"zo_ma_di_wo_do_vr_za".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"over %s",past:"%s geleden",s:"een paar seconden",m:"één minuut",mm:"%d minuten",h:"één uur",hh:"%d uur",d:"één dag",dd:"%d dagen",M:"één maand",MM:"%d maanden",y:"één jaar",yy:"%d jaar"}};return t.default.locale(n,null,!0),n}(n(7484))},9182:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nl",weekdays:"zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),weekdaysShort:"zo._ma._di._wo._do._vr._za.".split("_"),weekdaysMin:"zo_ma_di_wo_do_vr_za".split("_"),months:"januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec".split("_"),ordinal:function(e){return e+(1===e||8===e||e>=20?"ste":"de")},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"over %s",past:"%s geleden",s:"een paar seconden",m:"een minuut",mm:"%d minuten",h:"een uur",hh:"%d uur",d:"een dag",dd:"%d dagen",M:"een maand",MM:"%d maanden",y:"een jaar",yy:"%d jaar"}};return t.default.locale(n,null,!0),n}(n(7484))},2722:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nn",weekdays:"sundag_måndag_tysdag_onsdag_torsdag_fredag_laurdag".split("_"),weekdaysShort:"sun_mån_tys_ons_tor_fre_lau".split("_"),weekdaysMin:"su_må_ty_on_to_fr_la".split("_"),months:"januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember".split("_"),monthsShort:"jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"om %s",past:"for %s sidan",s:"nokre sekund",m:"eitt minutt",mm:"%d minutt",h:"ein time",hh:"%d timar",d:"ein dag",dd:"%d dagar",M:"ein månad",MM:"%d månadar",y:"eitt år",yy:"%d år"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] H:mm",LLLL:"dddd D. MMMM YYYY [kl.] HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},6159:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"oc-lnc",weekdays:"dimenge_diluns_dimars_dimècres_dijòus_divendres_dissabte".split("_"),weekdaysShort:"Dg_Dl_Dm_Dc_Dj_Dv_Ds".split("_"),weekdaysMin:"dg_dl_dm_dc_dj_dv_ds".split("_"),months:"genièr_febrièr_març_abrial_mai_junh_julhet_agost_setembre_octòbre_novembre_decembre".split("_"),monthsShort:"gen_feb_març_abr_mai_junh_julh_ago_set_oct_nov_dec".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM [de] YYYY",LLL:"D MMMM [de] YYYY [a] H:mm",LLLL:"dddd D MMMM [de] YYYY [a] H:mm"},relativeTime:{future:"d'aquí %s",past:"fa %s",s:"unas segondas",m:"una minuta",mm:"%d minutas",h:"una ora",hh:"%d oras",d:"un jorn",dd:"%d jorns",M:"un mes",MM:"%d meses",y:"un an",yy:"%d ans"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},5914:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"pa-in",weekdays:"ਐਤਵਾਰ_ਸੋਮਵਾਰ_ਮੰਗਲਵਾਰ_ਬੁਧਵਾਰ_ਵੀਰਵਾਰ_ਸ਼ੁੱਕਰਵਾਰ_ਸ਼ਨੀਚਰਵਾਰ".split("_"),months:"ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ".split("_"),weekdaysShort:"ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ".split("_"),monthsShort:"ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ".split("_"),weekdaysMin:"ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm ਵਜੇ",LTS:"A h:mm:ss ਵਜੇ",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm ਵਜੇ",LLLL:"dddd, D MMMM YYYY, A h:mm ਵਜੇ"},relativeTime:{future:"%s ਵਿੱਚ",past:"%s ਪਿਛਲੇ",s:"ਕੁਝ ਸਕਿੰਟ",m:"ਇਕ ਮਿੰਟ",mm:"%d ਮਿੰਟ",h:"ਇੱਕ ਘੰਟਾ",hh:"%d ਘੰਟੇ",d:"ਇੱਕ ਦਿਨ",dd:"%d ਦਿਨ",M:"ਇੱਕ ਮਹੀਨਾ",MM:"%d ਮਹੀਨੇ",y:"ਇੱਕ ਸਾਲ",yy:"%d ਸਾਲ"}};return t.default.locale(n,null,!0),n}(n(7484))},1987:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e%10<5&&e%10>1&&~~(e/10)%10!=1}function r(e,t,r){var a=e+" ";switch(r){case"m":return t?"minuta":"minutę";case"mm":return a+(n(e)?"minuty":"minut");case"h":return t?"godzina":"godzinę";case"hh":return a+(n(e)?"godziny":"godzin");case"MM":return a+(n(e)?"miesiące":"miesięcy");case"yy":return a+(n(e)?"lata":"lat")}}var a="stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia".split("_"),i="styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień".split("_"),s=/D MMMM/,o=function(e,t){return s.test(t)?a[e.month()]:i[e.month()]};o.s=i,o.f=a;var u={name:"pl",weekdays:"niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota".split("_"),weekdaysShort:"ndz_pon_wt_śr_czw_pt_sob".split("_"),weekdaysMin:"Nd_Pn_Wt_Śr_Cz_Pt_So".split("_"),months:o,monthsShort:"sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,relativeTime:{future:"za %s",past:"%s temu",s:"kilka sekund",m:r,mm:r,h:r,hh:r,d:"1 dzień",dd:"%d dni",M:"miesiąc",MM:r,y:"rok",yy:r},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(u,null,!0),u}(n(7484))},7548:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"pt-br",weekdays:"domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado".split("_"),weekdaysShort:"dom_seg_ter_qua_qui_sex_sáb".split("_"),weekdaysMin:"Do_2ª_3ª_4ª_5ª_6ª_Sá".split("_"),months:"janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro".split("_"),monthsShort:"jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez".split("_"),ordinal:function(e){return e+"º"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY [às] HH:mm",LLLL:"dddd, D [de] MMMM [de] YYYY [às] HH:mm"},relativeTime:{future:"em %s",past:"há %s",s:"poucos segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"}};return t.default.locale(n,null,!0),n}(n(7484))},5001:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"pt",weekdays:"domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado".split("_"),weekdaysShort:"dom_seg_ter_qua_qui_sex_sab".split("_"),weekdaysMin:"Do_2ª_3ª_4ª_5ª_6ª_Sa".split("_"),months:"janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro".split("_"),monthsShort:"jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez".split("_"),ordinal:function(e){return e+"º"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY [às] HH:mm",LLLL:"dddd, D [de] MMMM [de] YYYY [às] HH:mm"},relativeTime:{future:"em %s",past:"há %s",s:"alguns segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"}};return t.default.locale(n,null,!0),n}(n(7484))},123:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"rn",weekdays:"Ku wa Mungu_Ku wa Mbere_Ku wa Kabiri_Ku wa Gatatu_Ku wa Kane_Ku wa Gatanu_Ku wa Gatandatu".split("_"),weekdaysShort:"Kngu_Kmbr_Kbri_Ktat_Kkan_Ktan_Kdat".split("_"),weekdaysMin:"K7_K1_K2_K3_K4_K5_K6".split("_"),months:"Nzero_Ruhuhuma_Ntwarante_Ndamukiza_Rusama_Ruhenshi_Mukakaro_Myandagaro_Nyakanga_Gitugutu_Munyonyo_Kigarama".split("_"),monthsShort:"Nzer_Ruhuh_Ntwar_Ndam_Rus_Ruhen_Muk_Myand_Nyak_Git_Muny_Kig".split("_"),weekStart:1,ordinal:function(e){return e},relativeTime:{future:"mu %s",past:"%s",s:"amasegonda",m:"Umunota",mm:"%d iminota",h:"isaha",hh:"%d amasaha",d:"Umunsi",dd:"%d iminsi",M:"ukwezi",MM:"%d amezi",y:"umwaka",yy:"%d imyaka"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8146:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ro",weekdays:"Duminică_Luni_Marți_Miercuri_Joi_Vineri_Sâmbătă".split("_"),weekdaysShort:"Dum_Lun_Mar_Mie_Joi_Vin_Sâm".split("_"),weekdaysMin:"Du_Lu_Ma_Mi_Jo_Vi_Sâ".split("_"),months:"Ianuarie_Februarie_Martie_Aprilie_Mai_Iunie_Iulie_August_Septembrie_Octombrie_Noiembrie_Decembrie".split("_"),monthsShort:"Ian._Febr._Mart._Apr._Mai_Iun._Iul._Aug._Sept._Oct._Nov._Dec.".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY H:mm",LLLL:"dddd, D MMMM YYYY H:mm"},relativeTime:{future:"peste %s",past:"acum %s",s:"câteva secunde",m:"un minut",mm:"%d minute",h:"o oră",hh:"%d ore",d:"o zi",dd:"%d zile",M:"o lună",MM:"%d luni",y:"un an",yy:"%d ani"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},600:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря".split("_"),r="январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь".split("_"),a="янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.".split("_"),i="янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.".split("_"),s=/D[oD]?(\[[^[\]]*\]|\s)+MMMM?/;function o(e,t,n){var r,a;return"m"===n?t?"минута":"минуту":e+" "+(r=+e,a={mm:t?"минута_минуты_минут":"минуту_минуты_минут",hh:"час_часа_часов",dd:"день_дня_дней",MM:"месяц_месяца_месяцев",yy:"год_года_лет"}[n].split("_"),r%10==1&&r%100!=11?a[0]:r%10>=2&&r%10<=4&&(r%100<10||r%100>=20)?a[1]:a[2])}var u=function(e,t){return s.test(t)?n[e.month()]:r[e.month()]};u.s=r,u.f=n;var l=function(e,t){return s.test(t)?a[e.month()]:i[e.month()]};l.s=i,l.f=a;var c={name:"ru",weekdays:"воскресенье_понедельник_вторник_среда_четверг_пятница_суббота".split("_"),weekdaysShort:"вск_пнд_втр_срд_чтв_птн_сбт".split("_"),weekdaysMin:"вс_пн_вт_ср_чт_пт_сб".split("_"),months:u,monthsShort:l,weekStart:1,yearStart:4,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., H:mm",LLLL:"dddd, D MMMM YYYY г., H:mm"},relativeTime:{future:"через %s",past:"%s назад",s:"несколько секунд",m:o,mm:o,h:"час",hh:o,d:"день",dd:o,M:"месяц",MM:o,y:"год",yy:o},ordinal:function(e){return e},meridiem:function(e){return e<4?"ночи":e<12?"утра":e<17?"дня":"вечера"}};return t.default.locale(c,null,!0),c}(n(7484))},6509:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"rw",weekdays:"Ku Cyumweru_Kuwa Mbere_Kuwa Kabiri_Kuwa Gatatu_Kuwa Kane_Kuwa Gatanu_Kuwa Gatandatu".split("_"),months:"Mutarama_Gashyantare_Werurwe_Mata_Gicurasi_Kamena_Nyakanga_Kanama_Nzeri_Ukwakira_Ugushyingo_Ukuboza".split("_"),relativeTime:{future:"mu %s",past:"%s",s:"amasegonda",m:"Umunota",mm:"%d iminota",h:"isaha",hh:"%d amasaha",d:"Umunsi",dd:"%d iminsi",M:"ukwezi",MM:"%d amezi",y:"umwaka",yy:"%d imyaka"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},5437:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sd",weekdays:"آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر".split("_"),months:"جنوري_فيبروري_مارچ_اپريل_مئي_جون_جولاءِ_آگسٽ_سيپٽمبر_آڪٽوبر_نومبر_ڊسمبر".split("_"),weekStart:1,weekdaysShort:"آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر".split("_"),monthsShort:"جنوري_فيبروري_مارچ_اپريل_مئي_جون_جولاءِ_آگسٽ_سيپٽمبر_آڪٽوبر_نومبر_ڊسمبر".split("_"),weekdaysMin:"آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd، D MMMM YYYY HH:mm"},relativeTime:{future:"%s پوء",past:"%s اڳ",s:"چند سيڪنڊ",m:"هڪ منٽ",mm:"%d منٽ",h:"هڪ ڪلاڪ",hh:"%d ڪلاڪ",d:"هڪ ڏينهن",dd:"%d ڏينهن",M:"هڪ مهينو",MM:"%d مهينا",y:"هڪ سال",yy:"%d سال"}};return t.default.locale(n,null,!0),n}(n(7484))},772:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"se",weekdays:"sotnabeaivi_vuossárga_maŋŋebárga_gaskavahkku_duorastat_bearjadat_lávvardat".split("_"),months:"ođđajagemánnu_guovvamánnu_njukčamánnu_cuoŋománnu_miessemánnu_geassemánnu_suoidnemánnu_borgemánnu_čakčamánnu_golggotmánnu_skábmamánnu_juovlamánnu".split("_"),weekStart:1,weekdaysShort:"sotn_vuos_maŋ_gask_duor_bear_láv".split("_"),monthsShort:"ođđj_guov_njuk_cuo_mies_geas_suoi_borg_čakč_golg_skáb_juov".split("_"),weekdaysMin:"s_v_m_g_d_b_L".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"MMMM D. [b.] YYYY",LLL:"MMMM D. [b.] YYYY [ti.] HH:mm",LLLL:"dddd, MMMM D. [b.] YYYY [ti.] HH:mm"},relativeTime:{future:"%s geažes",past:"maŋit %s",s:"moadde sekunddat",m:"okta minuhta",mm:"%d minuhtat",h:"okta diimmu",hh:"%d diimmut",d:"okta beaivi",dd:"%d beaivvit",M:"okta mánnu",MM:"%d mánut",y:"okta jahki",yy:"%d jagit"}};return t.default.locale(n,null,!0),n}(n(7484))},7109:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"si",weekdays:"ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්‍රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා".split("_"),months:"දුරුතු_නවම්_මැදින්_බක්_වෙසක්_පොසොන්_ඇසළ_නිකිණි_බිනර_වප්_ඉල්_උඳුවප්".split("_"),weekdaysShort:"ඉරි_සඳු_අඟ_බදා_බ්‍රහ_සිකු_සෙන".split("_"),monthsShort:"දුරු_නව_මැදි_බක්_වෙස_පොසො_ඇස_නිකි_බින_වප්_ඉල්_උඳු".split("_"),weekdaysMin:"ඉ_ස_අ_බ_බ්‍ර_සි_සෙ".split("_"),ordinal:function(e){return e},formats:{LT:"a h:mm",LTS:"a h:mm:ss",L:"YYYY/MM/DD",LL:"YYYY MMMM D",LLL:"YYYY MMMM D, a h:mm",LLLL:"YYYY MMMM D [වැනි] dddd, a h:mm:ss"},relativeTime:{future:"%sකින්",past:"%sකට පෙර",s:"තත්පර කිහිපය",m:"විනාඩිය",mm:"විනාඩි %d",h:"පැය",hh:"පැය %d",d:"දිනය",dd:"දින %d",M:"මාසය",MM:"මාස %d",y:"වසර",yy:"වසර %d"}};return t.default.locale(n,null,!0),n}(n(7484))},5627:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e>1&&e<5&&1!=~~(e/10)}function r(e,t,r,a){var i=e+" ";switch(r){case"s":return t||a?"pár sekúnd":"pár sekundami";case"m":return t?"minúta":a?"minútu":"minútou";case"mm":return t||a?i+(n(e)?"minúty":"minút"):i+"minútami";case"h":return t?"hodina":a?"hodinu":"hodinou";case"hh":return t||a?i+(n(e)?"hodiny":"hodín"):i+"hodinami";case"d":return t||a?"deň":"dňom";case"dd":return t||a?i+(n(e)?"dni":"dní"):i+"dňami";case"M":return t||a?"mesiac":"mesiacom";case"MM":return t||a?i+(n(e)?"mesiace":"mesiacov"):i+"mesiacmi";case"y":return t||a?"rok":"rokom";case"yy":return t||a?i+(n(e)?"roky":"rokov"):i+"rokmi"}}var a={name:"sk",weekdays:"nedeľa_pondelok_utorok_streda_štvrtok_piatok_sobota".split("_"),weekdaysShort:"ne_po_ut_st_št_pi_so".split("_"),weekdaysMin:"ne_po_ut_st_št_pi_so".split("_"),months:"január_február_marec_apríl_máj_jún_júl_august_september_október_november_december".split("_"),monthsShort:"jan_feb_mar_apr_máj_jún_júl_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd D. MMMM YYYY H:mm",l:"D. M. YYYY"},relativeTime:{future:"za %s",past:"pred %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},2544:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sl",weekdays:"nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota".split("_"),months:"januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december".split("_"),weekStart:1,weekdaysShort:"ned._pon._tor._sre._čet._pet._sob.".split("_"),monthsShort:"jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_to_sr_če_pe_so".split("_"),ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"},relativeTime:{future:"čez %s",past:"pred %s",s:"nekaj sekund",m:"minuta",mm:"%d minut",h:"ura",hh:"%d ur",d:"dan",dd:"%d dni",M:"mesec",MM:"%d mesecev",y:"leto",yy:"%d let"}};return t.default.locale(n,null,!0),n}(n(7484))},8341:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sq",weekdays:"E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë".split("_"),months:"Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor".split("_"),weekStart:1,weekdaysShort:"Die_Hën_Mar_Mër_Enj_Pre_Sht".split("_"),monthsShort:"Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj".split("_"),weekdaysMin:"D_H_Ma_Më_E_P_Sh".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"në %s",past:"%s më parë",s:"disa sekonda",m:"një minutë",mm:"%d minuta",h:"një orë",hh:"%d orë",d:"një ditë",dd:"%d ditë",M:"një muaj",MM:"%d muaj",y:"një vit",yy:"%d vite"}};return t.default.locale(n,null,!0),n}(n(7484))},7101:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={words:{m:["један минут","једног минута"],mm:["%d минут","%d минута","%d минута"],h:["један сат","једног сата"],hh:["%d сат","%d сата","%d сати"],d:["један дан","једног дана"],dd:["%d дан","%d дана","%d дана"],M:["један месец","једног месеца"],MM:["%d месец","%d месеца","%d месеци"],y:["једну годину","једне године"],yy:["%d годину","%d године","%d година"]},correctGrammarCase:function(e,t){return e%10>=1&&e%10<=4&&(e%100<10||e%100>=20)?e%10==1?t[0]:t[1]:t[2]},relativeTimeFormatter:function(e,t,r,a){var i=n.words[r];if(1===r.length)return"y"===r&&t?"једна година":a||t?i[0]:i[1];var s=n.correctGrammarCase(e,i);return"yy"===r&&t&&"%d годину"===s?e+" година":s.replace("%d",e)}},r={name:"sr-cyrl",weekdays:"Недеља_Понедељак_Уторак_Среда_Четвртак_Петак_Субота".split("_"),weekdaysShort:"Нед._Пон._Уто._Сре._Чет._Пет._Суб.".split("_"),weekdaysMin:"не_по_ут_ср_че_пе_су".split("_"),months:"Јануар_Фебруар_Март_Април_Мај_Јун_Јул_Август_Септембар_Октобар_Новембар_Децембар".split("_"),monthsShort:"Јан._Феб._Мар._Апр._Мај_Јун_Јул_Авг._Сеп._Окт._Нов._Дец.".split("_"),weekStart:1,relativeTime:{future:"за %s",past:"пре %s",s:"неколико секунди",m:n.relativeTimeFormatter,mm:n.relativeTimeFormatter,h:n.relativeTimeFormatter,hh:n.relativeTimeFormatter,d:n.relativeTimeFormatter,dd:n.relativeTimeFormatter,M:n.relativeTimeFormatter,MM:n.relativeTimeFormatter,y:n.relativeTimeFormatter,yy:n.relativeTimeFormatter},ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D. M. YYYY.",LL:"D. MMMM YYYY.",LLL:"D. MMMM YYYY. H:mm",LLLL:"dddd, D. MMMM YYYY. H:mm"}};return t.default.locale(r,null,!0),r}(n(7484))},617:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={words:{m:["jedan minut","jednog minuta"],mm:["%d minut","%d minuta","%d minuta"],h:["jedan sat","jednog sata"],hh:["%d sat","%d sata","%d sati"],d:["jedan dan","jednog dana"],dd:["%d dan","%d dana","%d dana"],M:["jedan mesec","jednog meseca"],MM:["%d mesec","%d meseca","%d meseci"],y:["jednu godinu","jedne godine"],yy:["%d godinu","%d godine","%d godina"]},correctGrammarCase:function(e,t){return e%10>=1&&e%10<=4&&(e%100<10||e%100>=20)?e%10==1?t[0]:t[1]:t[2]},relativeTimeFormatter:function(e,t,r,a){var i=n.words[r];if(1===r.length)return"y"===r&&t?"jedna godina":a||t?i[0]:i[1];var s=n.correctGrammarCase(e,i);return"yy"===r&&t&&"%d godinu"===s?e+" godina":s.replace("%d",e)}},r={name:"sr",weekdays:"Nedelja_Ponedeljak_Utorak_Sreda_Četvrtak_Petak_Subota".split("_"),weekdaysShort:"Ned._Pon._Uto._Sre._Čet._Pet._Sub.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),months:"Januar_Februar_Mart_April_Maj_Jun_Jul_Avgust_Septembar_Oktobar_Novembar_Decembar".split("_"),monthsShort:"Jan._Feb._Mar._Apr._Maj_Jun_Jul_Avg._Sep._Okt._Nov._Dec.".split("_"),weekStart:1,relativeTime:{future:"za %s",past:"pre %s",s:"nekoliko sekundi",m:n.relativeTimeFormatter,mm:n.relativeTimeFormatter,h:n.relativeTimeFormatter,hh:n.relativeTimeFormatter,d:n.relativeTimeFormatter,dd:n.relativeTimeFormatter,M:n.relativeTimeFormatter,MM:n.relativeTimeFormatter,y:n.relativeTimeFormatter,yy:n.relativeTimeFormatter},ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D. M. YYYY.",LL:"D. MMMM YYYY.",LLL:"D. MMMM YYYY. H:mm",LLLL:"dddd, D. MMMM YYYY. H:mm"}};return t.default.locale(r,null,!0),r}(n(7484))},4127:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ss",weekdays:"Lisontfo_Umsombuluko_Lesibili_Lesitsatfu_Lesine_Lesihlanu_Umgcibelo".split("_"),months:"Bhimbidvwane_Indlovana_Indlov'lenkhulu_Mabasa_Inkhwekhweti_Inhlaba_Kholwane_Ingci_Inyoni_Imphala_Lweti_Ingongoni".split("_"),weekStart:1,weekdaysShort:"Lis_Umb_Lsb_Les_Lsi_Lsh_Umg".split("_"),monthsShort:"Bhi_Ina_Inu_Mab_Ink_Inh_Kho_Igc_Iny_Imp_Lwe_Igo".split("_"),weekdaysMin:"Li_Us_Lb_Lt_Ls_Lh_Ug".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"nga %s",past:"wenteka nga %s",s:"emizuzwana lomcane",m:"umzuzu",mm:"%d emizuzu",h:"lihora",hh:"%d emahora",d:"lilanga",dd:"%d emalanga",M:"inyanga",MM:"%d tinyanga",y:"umnyaka",yy:"%d iminyaka"}};return t.default.locale(n,null,!0),n}(n(7484))},6421:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sv-fi",weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),weekdaysMin:"sö_må_ti_on_to_fr_lö".split("_"),months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){var t=e%10;return"["+e+(1===t||2===t?"a":"e")+"]"},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY, [kl.] HH.mm",LLLL:"dddd, D. MMMM YYYY, [kl.] HH.mm",l:"D.M.YYYY",ll:"D. MMM YYYY",lll:"D. MMM YYYY, [kl.] HH.mm",llll:"ddd, D. MMM YYYY, [kl.] HH.mm"},relativeTime:{future:"om %s",past:"för %s sedan",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},1876:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sv",weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),weekdaysMin:"sö_må_ti_on_to_fr_lö".split("_"),months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){var t=e%10;return"["+e+(1===t||2===t?"a":"e")+"]"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [kl.] HH:mm",LLLL:"dddd D MMMM YYYY [kl.] HH:mm",lll:"D MMM YYYY HH:mm",llll:"ddd D MMM YYYY HH:mm"},relativeTime:{future:"om %s",past:"för %s sedan",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},9723:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sw",weekdays:"Jumapili_Jumatatu_Jumanne_Jumatano_Alhamisi_Ijumaa_Jumamosi".split("_"),weekdaysShort:"Jpl_Jtat_Jnne_Jtan_Alh_Ijm_Jmos".split("_"),weekdaysMin:"J2_J3_J4_J5_Al_Ij_J1".split("_"),months:"Januari_Februari_Machi_Aprili_Mei_Juni_Julai_Agosti_Septemba_Oktoba_Novemba_Desemba".split("_"),monthsShort:"Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ago_Sep_Okt_Nov_Des".split("_"),weekStart:1,ordinal:function(e){return e},relativeTime:{future:"%s baadaye",past:"tokea %s",s:"hivi punde",m:"dakika moja",mm:"dakika %d",h:"saa limoja",hh:"masaa %d",d:"siku moja",dd:"masiku %d",M:"mwezi mmoja",MM:"miezi %d",y:"mwaka mmoja",yy:"miaka %d"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},5596:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ta",weekdays:"ஞாயிற்றுக்கிழமை_திங்கட்கிழமை_செவ்வாய்கிழமை_புதன்கிழமை_வியாழக்கிழமை_வெள்ளிக்கிழமை_சனிக்கிழமை".split("_"),months:"ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்".split("_"),weekdaysShort:"ஞாயிறு_திங்கள்_செவ்வாய்_புதன்_வியாழன்_வெள்ளி_சனி".split("_"),monthsShort:"ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்".split("_"),weekdaysMin:"ஞா_தி_செ_பு_வி_வெ_ச".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, HH:mm",LLLL:"dddd, D MMMM YYYY, HH:mm"},relativeTime:{future:"%s இல்",past:"%s முன்",s:"ஒரு சில விநாடிகள்",m:"ஒரு நிமிடம்",mm:"%d நிமிடங்கள்",h:"ஒரு மணி நேரம்",hh:"%d மணி நேரம்",d:"ஒரு நாள்",dd:"%d நாட்கள்",M:"ஒரு மாதம்",MM:"%d மாதங்கள்",y:"ஒரு வருடம்",yy:"%d ஆண்டுகள்"}};return t.default.locale(n,null,!0),n}(n(7484))},5159:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"te",weekdays:"ఆదివారం_సోమవారం_మంగళవారం_బుధవారం_గురువారం_శుక్రవారం_శనివారం".split("_"),months:"జనవరి_ఫిబ్రవరి_మార్చి_ఏప్రిల్_మే_జూన్_జులై_ఆగస్టు_సెప్టెంబర్_అక్టోబర్_నవంబర్_డిసెంబర్".split("_"),weekdaysShort:"ఆది_సోమ_మంగళ_బుధ_గురు_శుక్ర_శని".split("_"),monthsShort:"జన._ఫిబ్ర._మార్చి_ఏప్రి._మే_జూన్_జులై_ఆగ._సెప్._అక్టో._నవ._డిసె.".split("_"),weekdaysMin:"ఆ_సో_మం_బు_గు_శు_శ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm",LLLL:"dddd, D MMMM YYYY, A h:mm"},relativeTime:{future:"%s లో",past:"%s క్రితం",s:"కొన్ని క్షణాలు",m:"ఒక నిమిషం",mm:"%d నిమిషాలు",h:"ఒక గంట",hh:"%d గంటలు",d:"ఒక రోజు",dd:"%d రోజులు",M:"ఒక నెల",MM:"%d నెలలు",y:"ఒక సంవత్సరం",yy:"%d సంవత్సరాలు"}};return t.default.locale(n,null,!0),n}(n(7484))},9157:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tet",weekdays:"Domingu_Segunda_Tersa_Kuarta_Kinta_Sesta_Sabadu".split("_"),months:"Janeiru_Fevereiru_Marsu_Abril_Maiu_Juñu_Jullu_Agustu_Setembru_Outubru_Novembru_Dezembru".split("_"),weekStart:1,weekdaysShort:"Dom_Seg_Ters_Kua_Kint_Sest_Sab".split("_"),monthsShort:"Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),weekdaysMin:"Do_Seg_Te_Ku_Ki_Ses_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"iha %s",past:"%s liuba",s:"minutu balun",m:"minutu ida",mm:"minutu %d",h:"oras ida",hh:"oras %d",d:"loron ida",dd:"loron %d",M:"fulan ida",MM:"fulan %d",y:"tinan ida",yy:"tinan %d"}};return t.default.locale(n,null,!0),n}(n(7484))},9928:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tg",weekdays:"якшанбе_душанбе_сешанбе_чоршанбе_панҷшанбе_ҷумъа_шанбе".split("_"),months:"январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр".split("_"),weekStart:1,weekdaysShort:"яшб_дшб_сшб_чшб_пшб_ҷум_шнб".split("_"),monthsShort:"янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек".split("_"),weekdaysMin:"яш_дш_сш_чш_пш_ҷм_шб".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"баъди %s",past:"%s пеш",s:"якчанд сония",m:"як дақиқа",mm:"%d дақиқа",h:"як соат",hh:"%d соат",d:"як рӯз",dd:"%d рӯз",M:"як моҳ",MM:"%d моҳ",y:"як сол",yy:"%d сол"}};return t.default.locale(n,null,!0),n}(n(7484))},2019:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"th",weekdays:"อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์".split("_"),weekdaysShort:"อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์".split("_"),weekdaysMin:"อา._จ._อ._พ._พฤ._ศ._ส.".split("_"),months:"มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม".split("_"),monthsShort:"ม.ค._ก.พ._มี.ค._เม.ย._พ.ค._มิ.ย._ก.ค._ส.ค._ก.ย._ต.ค._พ.ย._ธ.ค.".split("_"),formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY เวลา H:mm",LLLL:"วันddddที่ D MMMM YYYY เวลา H:mm"},relativeTime:{future:"อีก %s",past:"%sที่แล้ว",s:"ไม่กี่วินาที",m:"1 นาที",mm:"%d นาที",h:"1 ชั่วโมง",hh:"%d ชั่วโมง",d:"1 วัน",dd:"%d วัน",M:"1 เดือน",MM:"%d เดือน",y:"1 ปี",yy:"%d ปี"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},5817:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tk",weekdays:"Ýekşenbe_Duşenbe_Sişenbe_Çarşenbe_Penşenbe_Anna_Şenbe".split("_"),weekdaysShort:"Ýek_Duş_Siş_Çar_Pen_Ann_Şen".split("_"),weekdaysMin:"Ýk_Dş_Sş_Çr_Pn_An_Şn".split("_"),months:"Ýanwar_Fewral_Mart_Aprel_Maý_Iýun_Iýul_Awgust_Sentýabr_Oktýabr_Noýabr_Dekabr".split("_"),monthsShort:"Ýan_Few_Mar_Apr_Maý_Iýn_Iýl_Awg_Sen_Okt_Noý_Dek".split("_"),weekStart:1,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%s soň",past:"%s öň",s:"birnäçe sekunt",m:"bir minut",mm:"%d minut",h:"bir sagat",hh:"%d sagat",d:"bir gün",dd:"%d gün",M:"bir aý",MM:"%d aý",y:"bir ýyl",yy:"%d ýyl"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},6513:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tl-ph",weekdays:"Linggo_Lunes_Martes_Miyerkules_Huwebes_Biyernes_Sabado".split("_"),months:"Enero_Pebrero_Marso_Abril_Mayo_Hunyo_Hulyo_Agosto_Setyembre_Oktubre_Nobyembre_Disyembre".split("_"),weekStart:1,weekdaysShort:"Lin_Lun_Mar_Miy_Huw_Biy_Sab".split("_"),monthsShort:"Ene_Peb_Mar_Abr_May_Hun_Hul_Ago_Set_Okt_Nob_Dis".split("_"),weekdaysMin:"Li_Lu_Ma_Mi_Hu_Bi_Sab".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"MM/D/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY HH:mm",LLLL:"dddd, MMMM DD, YYYY HH:mm"},relativeTime:{future:"sa loob ng %s",past:"%s ang nakalipas",s:"ilang segundo",m:"isang minuto",mm:"%d minuto",h:"isang oras",hh:"%d oras",d:"isang araw",dd:"%d araw",M:"isang buwan",MM:"%d buwan",y:"isang taon",yy:"%d taon"}};return t.default.locale(n,null,!0),n}(n(7484))},7296:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tlh",weekdays:"lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj".split("_"),months:"tera’ jar wa’_tera’ jar cha’_tera’ jar wej_tera’ jar loS_tera’ jar vagh_tera’ jar jav_tera’ jar Soch_tera’ jar chorgh_tera’ jar Hut_tera’ jar wa’maH_tera’ jar wa’maH wa’_tera’ jar wa’maH cha’".split("_"),weekStart:1,weekdaysShort:"lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj".split("_"),monthsShort:"jar wa’_jar cha’_jar wej_jar loS_jar vagh_jar jav_jar Soch_jar chorgh_jar Hut_jar wa’maH_jar wa’maH wa’_jar wa’maH cha’".split("_"),weekdaysMin:"lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},3035:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tr",weekdays:"Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi".split("_"),weekdaysShort:"Paz_Pts_Sal_Çar_Per_Cum_Cts".split("_"),weekdaysMin:"Pz_Pt_Sa_Ça_Pe_Cu_Ct".split("_"),months:"Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık".split("_"),monthsShort:"Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara".split("_"),weekStart:1,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%s sonra",past:"%s önce",s:"birkaç saniye",m:"bir dakika",mm:"%d dakika",h:"bir saat",hh:"%d saat",d:"bir gün",dd:"%d gün",M:"bir ay",MM:"%d ay",y:"bir yıl",yy:"%d yıl"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},7797:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tzl",weekdays:"Súladi_Lúneçi_Maitzi_Márcuri_Xhúadi_Viénerçi_Sáturi".split("_"),months:"Januar_Fevraglh_Març_Avrïu_Mai_Gün_Julia_Guscht_Setemvar_Listopäts_Noemvar_Zecemvar".split("_"),weekStart:1,weekdaysShort:"Súl_Lún_Mai_Már_Xhú_Vié_Sát".split("_"),monthsShort:"Jan_Fev_Mar_Avr_Mai_Gün_Jul_Gus_Set_Lis_Noe_Zec".split("_"),weekdaysMin:"Sú_Lú_Ma_Má_Xh_Vi_Sá".split("_"),ordinal:function(e){return e},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD.MM.YYYY",LL:"D. MMMM [dallas] YYYY",LLL:"D. MMMM [dallas] YYYY HH.mm",LLLL:"dddd, [li] D. MMMM [dallas] YYYY HH.mm"}};return t.default.locale(n,null,!0),n}(n(7484))},261:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tzm-latn",weekdays:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),months:"innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir".split("_"),weekStart:6,weekdaysShort:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),monthsShort:"innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir".split("_"),weekdaysMin:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dadkh s yan %s",past:"yan %s",s:"imik",m:"minuḍ",mm:"%d minuḍ",h:"saɛa",hh:"%d tassaɛin",d:"ass",dd:"%d ossan",M:"ayowr",MM:"%d iyyirn",y:"asgas",yy:"%d isgasn"}};return t.default.locale(n,null,!0),n}(n(7484))},4722:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tzm",weekdays:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),months:"ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ".split("_"),weekStart:6,weekdaysShort:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),monthsShort:"ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ".split("_"),weekdaysMin:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ %s",past:"ⵢⴰⵏ %s",s:"ⵉⵎⵉⴽ",m:"ⵎⵉⵏⵓⴺ",mm:"%d ⵎⵉⵏⵓⴺ",h:"ⵙⴰⵄⴰ",hh:"%d ⵜⴰⵙⵙⴰⵄⵉⵏ",d:"ⴰⵙⵙ",dd:"%d oⵙⵙⴰⵏ",M:"ⴰⵢoⵓⵔ",MM:"%d ⵉⵢⵢⵉⵔⵏ",y:"ⴰⵙⴳⴰⵙ",yy:"%d ⵉⵙⴳⴰⵙⵏ"}};return t.default.locale(n,null,!0),n}(n(7484))},313:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ug-cn",weekdays:"يەكشەنبە_دۈشەنبە_سەيشەنبە_چارشەنبە_پەيشەنبە_جۈمە_شەنبە".split("_"),months:"يانۋار_فېۋرال_مارت_ئاپرېل_ماي_ئىيۇن_ئىيۇل_ئاۋغۇست_سېنتەبىر_ئۆكتەبىر_نويابىر_دېكابىر".split("_"),weekStart:1,weekdaysShort:"يە_دۈ_سە_چا_پە_جۈ_شە".split("_"),monthsShort:"يانۋار_فېۋرال_مارت_ئاپرېل_ماي_ئىيۇن_ئىيۇل_ئاۋغۇست_سېنتەبىر_ئۆكتەبىر_نويابىر_دېكابىر".split("_"),weekdaysMin:"يە_دۈ_سە_چا_پە_جۈ_شە".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY-يىلىM-ئاينىڭD-كۈنى",LLL:"YYYY-يىلىM-ئاينىڭD-كۈنى، HH:mm",LLLL:"dddd، YYYY-يىلىM-ئاينىڭD-كۈنى، HH:mm"},relativeTime:{future:"%s كېيىن",past:"%s بۇرۇن",s:"نەچچە سېكونت",m:"بىر مىنۇت",mm:"%d مىنۇت",h:"بىر سائەت",hh:"%d سائەت",d:"بىر كۈن",dd:"%d كۈن",M:"بىر ئاي",MM:"%d ئاي",y:"بىر يىل",yy:"%d يىل"}};return t.default.locale(n,null,!0),n}(n(7484))},4144:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня".split("_"),r="січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень".split("_"),a=/D[oD]?(\[[^[\]]*\]|\s)+MMMM?/;function i(e,t,n){var r,a;return"m"===n?t?"хвилина":"хвилину":"h"===n?t?"година":"годину":e+" "+(r=+e,a={ss:t?"секунда_секунди_секунд":"секунду_секунди_секунд",mm:t?"хвилина_хвилини_хвилин":"хвилину_хвилини_хвилин",hh:t?"година_години_годин":"годину_години_годин",dd:"день_дні_днів",MM:"місяць_місяці_місяців",yy:"рік_роки_років"}[n].split("_"),r%10==1&&r%100!=11?a[0]:r%10>=2&&r%10<=4&&(r%100<10||r%100>=20)?a[1]:a[2])}var s=function(e,t){return a.test(t)?n[e.month()]:r[e.month()]};s.s=r,s.f=n;var o={name:"uk",weekdays:"неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота".split("_"),weekdaysShort:"ндл_пнд_втр_срд_чтв_птн_сбт".split("_"),weekdaysMin:"нд_пн_вт_ср_чт_пт_сб".split("_"),months:s,monthsShort:"січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд".split("_"),weekStart:1,relativeTime:{future:"за %s",past:"%s тому",s:"декілька секунд",m:i,mm:i,h:i,hh:i,d:"день",dd:i,M:"місяць",MM:i,y:"рік",yy:i},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY р.",LLL:"D MMMM YYYY р., HH:mm",LLLL:"dddd, D MMMM YYYY р., HH:mm"}};return t.default.locale(o,null,!0),o}(n(7484))},2957:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ur",weekdays:"اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ".split("_"),months:"جنوری_فروری_مارچ_اپریل_مئی_جون_جولائی_اگست_ستمبر_اکتوبر_نومبر_دسمبر".split("_"),weekStart:1,weekdaysShort:"اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ".split("_"),monthsShort:"جنوری_فروری_مارچ_اپریل_مئی_جون_جولائی_اگست_ستمبر_اکتوبر_نومبر_دسمبر".split("_"),weekdaysMin:"اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd، D MMMM YYYY HH:mm"},relativeTime:{future:"%s بعد",past:"%s قبل",s:"چند سیکنڈ",m:"ایک منٹ",mm:"%d منٹ",h:"ایک گھنٹہ",hh:"%d گھنٹے",d:"ایک دن",dd:"%d دن",M:"ایک ماہ",MM:"%d ماہ",y:"ایک سال",yy:"%d سال"}};return t.default.locale(n,null,!0),n}(n(7484))},8727:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"uz-latn",weekdays:"Yakshanba_Dushanba_Seshanba_Chorshanba_Payshanba_Juma_Shanba".split("_"),months:"Yanvar_Fevral_Mart_Aprel_May_Iyun_Iyul_Avgust_Sentabr_Oktabr_Noyabr_Dekabr".split("_"),weekStart:1,weekdaysShort:"Yak_Dush_Sesh_Chor_Pay_Jum_Shan".split("_"),monthsShort:"Yan_Fev_Mar_Apr_May_Iyun_Iyul_Avg_Sen_Okt_Noy_Dek".split("_"),weekdaysMin:"Ya_Du_Se_Cho_Pa_Ju_Sha".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"D MMMM YYYY, dddd HH:mm"},relativeTime:{future:"Yaqin %s ichida",past:"Bir necha %s oldin",s:"soniya",m:"bir daqiqa",mm:"%d daqiqa",h:"bir soat",hh:"%d soat",d:"bir kun",dd:"%d kun",M:"bir oy",MM:"%d oy",y:"bir yil",yy:"%d yil"}};return t.default.locale(n,null,!0),n}(n(7484))},7486:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"uz",weekdays:"Якшанба_Душанба_Сешанба_Чоршанба_Пайшанба_Жума_Шанба".split("_"),months:"январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр".split("_"),weekStart:1,weekdaysShort:"Якш_Душ_Сеш_Чор_Пай_Жум_Шан".split("_"),monthsShort:"янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек".split("_"),weekdaysMin:"Як_Ду_Се_Чо_Па_Жу_Ша".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"D MMMM YYYY, dddd HH:mm"},relativeTime:{future:"Якин %s ичида",past:"Бир неча %s олдин",s:"фурсат",m:"бир дакика",mm:"%d дакика",h:"бир соат",hh:"%d соат",d:"бир кун",dd:"%d кун",M:"бир ой",MM:"%d ой",y:"бир йил",yy:"%d йил"}};return t.default.locale(n,null,!0),n}(n(7484))},7553:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"vi",weekdays:"chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy".split("_"),months:"tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12".split("_"),weekStart:1,weekdaysShort:"CN_T2_T3_T4_T5_T6_T7".split("_"),monthsShort:"Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12".split("_"),weekdaysMin:"CN_T2_T3_T4_T5_T6_T7".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM [năm] YYYY",LLL:"D MMMM [năm] YYYY HH:mm",LLLL:"dddd, D MMMM [năm] YYYY HH:mm",l:"DD/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY HH:mm",llll:"ddd, D MMM YYYY HH:mm"},relativeTime:{future:"%s tới",past:"%s trước",s:"vài giây",m:"một phút",mm:"%d phút",h:"một giờ",hh:"%d giờ",d:"một ngày",dd:"%d ngày",M:"một tháng",MM:"%d tháng",y:"một năm",yy:"%d năm"}};return t.default.locale(n,null,!0),n}(n(7484))},5321:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"x-pseudo",weekdays:"S~úñdá~ý_Mó~ñdáý~_Túé~sdáý~_Wéd~ñésd~áý_T~húrs~dáý_~Fríd~áý_S~átúr~dáý".split("_"),months:"J~áñúá~rý_F~ébrú~árý_~Márc~h_Áp~ríl_~Máý_~Júñé~_Júl~ý_Áú~gúst~_Sép~témb~ér_Ó~ctób~ér_Ñ~óvém~bér_~Décé~mbér".split("_"),weekStart:1,weekdaysShort:"S~úñ_~Móñ_~Túé_~Wéd_~Thú_~Frí_~Sát".split("_"),monthsShort:"J~áñ_~Féb_~Már_~Ápr_~Máý_~Júñ_~Júl_~Áúg_~Sép_~Óct_~Ñóv_~Déc".split("_"),weekdaysMin:"S~ú_Mó~_Tú_~Wé_T~h_Fr~_Sá".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"í~ñ %s",past:"%s á~gó",s:"á ~féw ~sécó~ñds",m:"á ~míñ~úté",mm:"%d m~íñú~tés",h:"á~ñ hó~úr",hh:"%d h~óúrs",d:"á ~dáý",dd:"%d d~áýs",M:"á ~móñ~th",MM:"%d m~óñt~hs",y:"á ~ýéár",yy:"%d ý~éárs"}};return t.default.locale(n,null,!0),n}(n(7484))},4724:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"yo",weekdays:"Àìkú_Ajé_Ìsẹ́gun_Ọjọ́rú_Ọjọ́bọ_Ẹtì_Àbámẹ́ta".split("_"),months:"Sẹ́rẹ́_Èrèlè_Ẹrẹ̀nà_Ìgbé_Èbibi_Òkùdu_Agẹmo_Ògún_Owewe_Ọ̀wàrà_Bélú_Ọ̀pẹ̀̀".split("_"),weekStart:1,weekdaysShort:"Àìk_Ajé_Ìsẹ́_Ọjr_Ọjb_Ẹtì_Àbá".split("_"),monthsShort:"Sẹ́r_Èrl_Ẹrn_Ìgb_Èbi_Òkù_Agẹ_Ògú_Owe_Ọ̀wà_Bél_Ọ̀pẹ̀̀".split("_"),weekdaysMin:"Àì_Aj_Ìs_Ọr_Ọb_Ẹt_Àb".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"ní %s",past:"%s kọjá",s:"ìsẹjú aayá die",m:"ìsẹjú kan",mm:"ìsẹjú %d",h:"wákati kan",hh:"wákati %d",d:"ọjọ́ kan",dd:"ọjọ́ %d",M:"osù kan",MM:"osù %d",y:"ọdún kan",yy:"ọdún %d"}};return t.default.locale(n,null,!0),n}(n(7484))},3852:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh-cn",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,t){var n=100*e+t;return n<600?"凌晨":n<900?"早上":n<1100?"上午":n<1300?"中午":n<1800?"下午":"晚上"}};return t.default.locale(n,null,!0),n}(n(7484))},2390:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh-hk",months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"週日_週一_週二_週三_週四_週五_週六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),ordinal:function(e,t){return"W"===t?e+"週":e+"日"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日 HH:mm",LLLL:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s內",past:"%s前",s:"幾秒",m:"一分鐘",mm:"%d 分鐘",h:"一小時",hh:"%d 小時",d:"一天",dd:"%d 天",M:"一個月",MM:"%d 個月",y:"一年",yy:"%d 年"}};return t.default.locale(n,null,!0),n}(n(7484))},3901:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh-tw",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"週日_週一_週二_週三_週四_週五_週六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"週":e+"日"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日 HH:mm",LLLL:"YYYY年M月D日dddd HH:mm",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s內",past:"%s前",s:"幾秒",m:"1 分鐘",mm:"%d 分鐘",h:"1 小時",hh:"%d 小時",d:"1 天",dd:"%d 天",M:"1 個月",MM:"%d 個月",y:"1 年",yy:"%d 年"}};return t.default.locale(n,null,!0),n}(n(7484))},2009:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s后",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,t){var n=100*e+t;return n<600?"凌晨":n<900?"早上":n<1100?"上午":n<1300?"中午":n<1800?"下午":"晚上"}};return t.default.locale(n,null,!0),n}(n(7484))},285:function(e){e.exports=function(){"use strict";var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,a=/\d*[^-_:/,()\s\d]+/,i={},s=function(e){return(e=+e)+(e>68?1900:2e3)},o=function(e){return function(t){this[e]=+t}},u=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e)}],l=function(e){var t=i[e];return t&&(t.indexOf?t:t.s.concat(t.f))},c=function(e,t){var n,r=i.meridiem;if(r){for(var a=1;a<=24;a+=1)if(e.indexOf(r(a,0,t))>-1){n=a>12;break}}else n=e===(t?"pm":"PM");return n},p={A:[a,function(e){this.afternoon=c(e,!1)}],a:[a,function(e){this.afternoon=c(e,!0)}],S:[/\d/,function(e){this.milliseconds=100*+e}],SS:[n,function(e){this.milliseconds=10*+e}],SSS:[/\d{3}/,function(e){this.milliseconds=+e}],s:[r,o("seconds")],ss:[r,o("seconds")],m:[r,o("minutes")],mm:[r,o("minutes")],H:[r,o("hours")],h:[r,o("hours")],HH:[r,o("hours")],hh:[r,o("hours")],D:[r,o("day")],DD:[n,o("day")],Do:[a,function(e){var t=i.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r)}],M:[r,o("month")],MM:[n,o("month")],MMM:[a,function(e){var t=l("months"),n=(l("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n}],MMMM:[a,function(e){var t=l("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t}],Y:[/[+-]?\d+/,o("year")],YY:[n,function(e){this.year=s(e)}],YYYY:[/\d{4}/,o("year")],Z:u,ZZ:u};function d(n){var r,a;r=n,a=i&&i.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var i=r&&r.toUpperCase();return n||a[r]||e[r]||a[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),o=s.length,u=0;u-1)return new Date(("X"===t?1e3:1)*e);var r=d(t)(e),a=r.year,i=r.month,s=r.day,o=r.hours,u=r.minutes,l=r.seconds,c=r.milliseconds,p=r.zone,h=new Date,f=s||(a||i?1:h.getDate()),m=a||h.getFullYear(),g=0;a&&!i||(g=i>0?i-1:h.getMonth());var y=o||0,b=u||0,x=l||0,v=c||0;return p?new Date(Date.UTC(m,g,f,y,b,x,v+60*p.offset*1e3)):n?new Date(Date.UTC(m,g,f,y,b,x,v)):new Date(m,g,f,y,b,x,v)}catch(e){return new Date("")}}(t,o,r),this.init(),p&&!0!==p&&(this.$L=this.locale(p).$L),c&&t!=this.format(o)&&(this.$d=new Date("")),i={}}else if(o instanceof Array)for(var h=o.length,f=1;f<=h;f+=1){s[1]=o[f-1];var m=n.apply(this,s);if(m.isValid()){this.$d=m.$d,this.$L=m.$L,this.init();break}f===h&&(this.$d=new Date(""))}else a.call(this,e)}}}()},2997:function(e){e.exports=function(){"use strict";return function(e,t,n){t.prototype.dayOfYear=function(e){var t=Math.round((n(this).startOf("day")-n(this).startOf("year"))/864e5)+1;return null==e?t:this.add(e-t,"day")}}}()},6036:function(e){e.exports=function(){"use strict";return function(e,t,n){var r=t.prototype,a=function(e){return e&&(e.indexOf?e:e.s)},i=function(e,t,n,r,i){var s=e.name?e:e.$locale(),o=a(s[t]),u=a(s[n]),l=o||u.map((function(e){return e.slice(0,r)}));if(!i)return l;var c=s.weekStart;return l.map((function(e,t){return l[(t+(c||0))%7]}))},s=function(){return n.Ls[n.locale()]},o=function(e,t){return e.formats[t]||function(e){return e.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}(e.formats[t.toUpperCase()])},u=function(){var e=this;return{months:function(t){return t?t.format("MMMM"):i(e,"months")},monthsShort:function(t){return t?t.format("MMM"):i(e,"monthsShort","months",3)},firstDayOfWeek:function(){return e.$locale().weekStart||0},weekdays:function(t){return t?t.format("dddd"):i(e,"weekdays")},weekdaysMin:function(t){return t?t.format("dd"):i(e,"weekdaysMin","weekdays",2)},weekdaysShort:function(t){return t?t.format("ddd"):i(e,"weekdaysShort","weekdays",3)},longDateFormat:function(t){return o(e.$locale(),t)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};r.localeData=function(){return u.bind(this)()},n.localeData=function(){var e=s();return{firstDayOfWeek:function(){return e.weekStart||0},weekdays:function(){return n.weekdays()},weekdaysShort:function(){return n.weekdaysShort()},weekdaysMin:function(){return n.weekdaysMin()},months:function(){return n.months()},monthsShort:function(){return n.monthsShort()},longDateFormat:function(t){return o(e,t)},meridiem:e.meridiem,ordinal:e.ordinal}},n.months=function(){return i(s(),"months")},n.monthsShort=function(){return i(s(),"monthsShort","months",3)},n.weekdays=function(e){return i(s(),"weekdays",null,null,e)},n.weekdaysShort=function(e){return i(s(),"weekdaysShort","weekdays",3,e)},n.weekdaysMin=function(e){return i(s(),"weekdaysMin","weekdays",2,e)}}}()},6176:function(e){e.exports=function(){"use strict";var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(t,n,r){var a=n.prototype,i=a.format;r.en.formats=e,a.format=function(t){void 0===t&&(t="YYYY-MM-DDTHH:mm:ssZ");var n=this.$locale().formats,r=function(t,n){return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,r,a){var i=a&&a.toUpperCase();return r||n[a]||e[a]||n[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))}(t,void 0===n?{}:n);return i.call(this,r)}}}()},178:function(e){e.exports=function(){"use strict";var e="minute",t=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(r,a,i){var s=a.prototype;i.utc=function(e){return new a({date:e,utc:!0,args:arguments})},s.utc=function(t){var n=i(this.toDate(),{locale:this.$L,utc:!0});return t?n.add(this.utcOffset(),e):n},s.local=function(){return i(this.toDate(),{locale:this.$L,utc:!1})};var o=s.parse;s.parse=function(e){e.utc&&(this.$u=!0),this.$utils().u(e.$offset)||(this.$offset=e.$offset),o.call(this,e)};var u=s.init;s.init=function(){if(this.$u){var e=this.$d;this.$y=e.getUTCFullYear(),this.$M=e.getUTCMonth(),this.$D=e.getUTCDate(),this.$W=e.getUTCDay(),this.$H=e.getUTCHours(),this.$m=e.getUTCMinutes(),this.$s=e.getUTCSeconds(),this.$ms=e.getUTCMilliseconds()}else u.call(this)};var l=s.utcOffset;s.utcOffset=function(r,a){var i=this.$utils().u;if(i(r))return this.$u?0:i(this.$offset)?l.call(this):this.$offset;if("string"==typeof r&&(r=function(e){void 0===e&&(e="");var r=e.match(t);if(!r)return null;var a=(""+r[0]).match(n)||["-",0,0],i=a[0],s=60*+a[1]+ +a[2];return 0===s?0:"+"===i?s:-s}(r),null===r))return this;var s=Math.abs(r)<=16?60*r:r,o=this;if(a)return o.$offset=s,o.$u=0===r,o;if(0!==r){var u=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(s+u,e)).$offset=s,o.$x.$localOffset=u}else o=this.utc();return o};var c=s.format;s.format=function(e){var t=e||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,t)},s.valueOf=function(){var e=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*e},s.isUTC=function(){return!!this.$u},s.toISOString=function(){return this.toDate().toISOString()},s.toString=function(){return this.toDate().toUTCString()};var p=s.toDate;s.toDate=function(e){return"s"===e&&this.$offset?i(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():p.call(this)};var d=s.diff;s.diff=function(e,t,n){if(e&&this.$u===e.$u)return d.call(this,e,t,n);var r=this.local(),a=i(e).local();return d.call(r,a,t,n)}}}()},3776:function(e,t,n){var r;!function(a){"use strict";var i,s,o,u=9e15,l=1e9,c="0123456789abcdef",p="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",d="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",h={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-u,maxE:u,crypto:!1},f=!0,m="[DecimalError] ",g=m+"Invalid argument: ",y=m+"Precision limit exceeded",b=m+"crypto unavailable",x="[object Decimal]",v=Math.floor,_=Math.pow,w=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,M=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,N=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,S=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,k=1e7,D=p.length-1,T=d.length-1,I={toStringTag:x};function E(e){var t,n,r,a=e.length-1,i="",s=e[0];if(a>0){for(i+=s,t=1;tn)throw Error(g+e)}function A(e,t,n,r){var a,i,s,o;for(i=e[0];i>=10;i/=10)--t;return--t<0?(t+=7,a=0):(a=Math.ceil((t+1)/7),t%=7),i=_(10,7-t),o=e[a]%i|0,null==r?t<3?(0==t?o=o/100|0:1==t&&(o=o/10|0),s=n<4&&99999==o||n>3&&49999==o||5e4==o||0==o):s=(n<4&&o+1==i||n>3&&o+1==i/2)&&(e[a+1]/i/100|0)==_(10,t-2)-1||(o==i/2||0==o)&&0==(e[a+1]/i/100|0):t<4?(0==t?o=o/1e3|0:1==t?o=o/100|0:2==t&&(o=o/10|0),s=(r||n<4)&&9999==o||!r&&n>3&&4999==o):s=((r||n<4)&&o+1==i||!r&&n>3&&o+1==i/2)&&(e[a+1]/i/1e3|0)==_(10,t-3)-1,s}function L(e,t,n){for(var r,a,i=[0],s=0,o=e.length;sn-1&&(void 0===i[r+1]&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}I.absoluteValue=I.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),O(e)},I.ceil=function(){return O(new this.constructor(this),this.e+1,2)},I.clampedTo=I.clamp=function(e,t){var n=this,r=n.constructor;if(e=new r(e),t=new r(t),!e.s||!t.s)return new r(NaN);if(e.gt(t))throw Error(g+t);return n.cmp(e)<0?e:n.cmp(t)>0?t:new r(n)},I.comparedTo=I.cmp=function(e){var t,n,r,a,i=this,s=i.d,o=(e=new i.constructor(e)).d,u=i.s,l=e.s;if(!s||!o)return u&&l?u!==l?u:s===o?0:!s^u<0?1:-1:NaN;if(!s[0]||!o[0])return s[0]?u:o[0]?-l:0;if(u!==l)return u;if(i.e!==e.e)return i.e>e.e^u<0?1:-1;for(t=0,n=(r=s.length)<(a=o.length)?r:a;to[t]^u<0?1:-1;return r===a?0:r>a^u<0?1:-1},I.cosine=I.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+7,r.rounding=1,n=function(e,t){var n,r,a;if(t.isZero())return t;(r=t.d.length)<32?a=(1/X(4,n=Math.ceil(r/3))).toString():(n=16,a="2.3283064365386962890625e-10"),e.precision+=n,t=J(e,1,t.times(a),new e(1));for(var i=n;i--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return e.precision-=n,t}(r,Z(r,n)),r.precision=e,r.rounding=t,O(2==o||3==o?n.neg():n,e,t,!0)):new r(1):new r(NaN)},I.cubeRoot=I.cbrt=function(){var e,t,n,r,a,i,s,o,u,l,c=this,p=c.constructor;if(!c.isFinite()||c.isZero())return new p(c);for(f=!1,(i=c.s*_(c.s*c,1/3))&&Math.abs(i)!=1/0?r=new p(i.toString()):(n=E(c.d),(i=((e=c.e)-n.length+1)%3)&&(n+=1==i||-2==i?"0":"00"),i=_(n,1/3),e=v((e+1)/3)-(e%3==(e<0?-1:2)),(r=new p(n=i==1/0?"5e"+e:(n=i.toExponential()).slice(0,n.indexOf("e")+1)+e)).s=c.s),s=(e=p.precision)+3;;)if(l=(u=(o=r).times(o).times(o)).plus(c),r=$(l.plus(c).times(o),l.plus(u),s+2,1),E(o.d).slice(0,s)===(n=E(r.d)).slice(0,s)){if("9999"!=(n=n.slice(s-3,s+1))&&(a||"4999"!=n)){+n&&(+n.slice(1)||"5"!=n.charAt(0))||(O(r,e+1,1),t=!r.times(r).times(r).eq(c));break}if(!a&&(O(o,e+1,0),o.times(o).times(o).eq(c))){r=o;break}s+=4,a=1}return f=!0,O(r,e,p.rounding,t)},I.decimalPlaces=I.dp=function(){var e,t=this.d,n=NaN;if(t){if(n=7*((e=t.length-1)-v(this.e/7)),e=t[e])for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},I.dividedBy=I.div=function(e){return $(this,new this.constructor(e))},I.dividedToIntegerBy=I.divToInt=function(e){var t=this.constructor;return O($(this,new t(e),0,1,1),t.precision,t.rounding)},I.equals=I.eq=function(e){return 0===this.cmp(e)},I.floor=function(){return O(new this.constructor(this),this.e+1,3)},I.greaterThan=I.gt=function(e){return this.cmp(e)>0},I.greaterThanOrEqualTo=I.gte=function(e){var t=this.cmp(e);return 1==t||0===t},I.hyperbolicCosine=I.cosh=function(){var e,t,n,r,a,i=this,s=i.constructor,o=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return o;n=s.precision,r=s.rounding,s.precision=n+Math.max(i.e,i.sd())+4,s.rounding=1,(a=i.d.length)<32?t=(1/X(4,e=Math.ceil(a/3))).toString():(e=16,t="2.3283064365386962890625e-10"),i=J(s,1,i.times(t),new s(1),!0);for(var u,l=e,c=new s(8);l--;)u=i.times(i),i=o.minus(u.times(c.minus(u.times(c))));return O(i,s.precision=n,s.rounding=r,!0)},I.hyperbolicSine=I.sinh=function(){var e,t,n,r,a=this,i=a.constructor;if(!a.isFinite()||a.isZero())return new i(a);if(t=i.precision,n=i.rounding,i.precision=t+Math.max(a.e,a.sd())+4,i.rounding=1,(r=a.d.length)<3)a=J(i,2,a,a,!0);else{e=(e=1.4*Math.sqrt(r))>16?16:0|e,a=J(i,2,a=a.times(1/X(5,e)),a,!0);for(var s,o=new i(5),u=new i(16),l=new i(20);e--;)s=a.times(a),a=a.times(o.plus(s.times(u.times(s).plus(l))))}return i.precision=t,i.rounding=n,O(a,t,n,!0)},I.hyperbolicTangent=I.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,$(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},I.inverseCosine=I.acos=function(){var e,t=this,n=t.constructor,r=t.abs().cmp(1),a=n.precision,i=n.rounding;return-1!==r?0===r?t.isNeg()?z(n,a,i):new n(0):new n(NaN):t.isZero()?z(n,a+4,i).times(.5):(n.precision=a+6,n.rounding=1,t=t.asin(),e=z(n,a+4,i).times(.5),n.precision=a,n.rounding=i,e.minus(t))},I.inverseHyperbolicCosine=I.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,f=!1,n=n.times(n).minus(1).sqrt().plus(n),f=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},I.inverseHyperbolicSine=I.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,f=!1,n=n.times(n).plus(1).sqrt().plus(n),f=!0,r.precision=e,r.rounding=t,n.ln())},I.inverseHyperbolicTangent=I.atanh=function(){var e,t,n,r,a=this,i=a.constructor;return a.isFinite()?a.e>=0?new i(a.abs().eq(1)?a.s/0:a.isZero()?a:NaN):(e=i.precision,t=i.rounding,r=a.sd(),Math.max(r,e)<2*-a.e-1?O(new i(a),e,t,!0):(i.precision=n=r-a.e,a=$(a.plus(1),new i(1).minus(a),n+e,1),i.precision=e+4,i.rounding=1,a=a.ln(),i.precision=e,i.rounding=t,a.times(.5))):new i(NaN)},I.inverseSine=I.asin=function(){var e,t,n,r,a=this,i=a.constructor;return a.isZero()?new i(a):(t=a.abs().cmp(1),n=i.precision,r=i.rounding,-1!==t?0===t?((e=z(i,n+4,r).times(.5)).s=a.s,e):new i(NaN):(i.precision=n+6,i.rounding=1,a=a.div(new i(1).minus(a.times(a)).sqrt().plus(1)).atan(),i.precision=n,i.rounding=r,a.times(2)))},I.inverseTangent=I.atan=function(){var e,t,n,r,a,i,s,o,u,l=this,c=l.constructor,p=c.precision,d=c.rounding;if(l.isFinite()){if(l.isZero())return new c(l);if(l.abs().eq(1)&&p+4<=T)return(s=z(c,p+4,d).times(.25)).s=l.s,s}else{if(!l.s)return new c(NaN);if(p+4<=T)return(s=z(c,p+4,d).times(.5)).s=l.s,s}for(c.precision=o=p+10,c.rounding=1,e=n=Math.min(28,o/7+2|0);e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(f=!1,t=Math.ceil(o/7),r=1,u=l.times(l),s=new c(l),a=l;-1!==e;)if(a=a.times(u),i=s.minus(a.div(r+=2)),a=a.times(u),void 0!==(s=i.plus(a.div(r+=2))).d[t])for(e=t;s.d[e]===i.d[e]&&e--;);return n&&(s=s.times(2<this.d.length-2},I.isNaN=function(){return!this.s},I.isNegative=I.isNeg=function(){return this.s<0},I.isPositive=I.isPos=function(){return this.s>0},I.isZero=function(){return!!this.d&&0===this.d[0]},I.lessThan=I.lt=function(e){return this.cmp(e)<0},I.lessThanOrEqualTo=I.lte=function(e){return this.cmp(e)<1},I.logarithm=I.log=function(e){var t,n,r,a,i,s,o,u,l=this,c=l.constructor,p=c.precision,d=c.rounding;if(null==e)e=new c(10),t=!0;else{if(n=(e=new c(e)).d,e.s<0||!n||!n[0]||e.eq(1))return new c(NaN);t=e.eq(10)}if(n=l.d,l.s<0||!n||!n[0]||l.eq(1))return new c(n&&!n[0]?-1/0:1!=l.s?NaN:n?0:1/0);if(t)if(n.length>1)i=!0;else{for(a=n[0];a%10==0;)a/=10;i=1!==a}if(f=!1,s=W(l,o=p+5),r=t?Y(c,o+10):W(e,o),A((u=$(s,r,o,1)).d,a=p,d))do{if(s=W(l,o+=10),r=t?Y(c,o+10):W(e,o),u=$(s,r,o,1),!i){+E(u.d).slice(a+1,a+15)+1==1e14&&(u=O(u,p+1,0));break}}while(A(u.d,a+=10,d));return f=!0,O(u,p,d)},I.minus=I.sub=function(e){var t,n,r,a,i,s,o,u,l,c,p,d,h=this,m=h.constructor;if(e=new m(e),!h.d||!e.d)return h.s&&e.s?h.d?e.s=-e.s:e=new m(e.d||h.s!==e.s?h:NaN):e=new m(NaN),e;if(h.s!=e.s)return e.s=-e.s,h.plus(e);if(l=h.d,d=e.d,o=m.precision,u=m.rounding,!l[0]||!d[0]){if(d[0])e.s=-e.s;else{if(!l[0])return new m(3===u?-0:0);e=new m(h)}return f?O(e,o,u):e}if(n=v(e.e/7),c=v(h.e/7),l=l.slice(),i=c-n){for((p=i<0)?(t=l,i=-i,s=d.length):(t=d,n=c,s=l.length),i>(r=Math.max(Math.ceil(o/7),s)+2)&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for((p=(r=l.length)<(s=d.length))&&(s=r),r=0;r0;--r)l[s++]=0;for(r=d.length;r>i;){if(l[--r](s=(i=Math.ceil(o/7))>s?i+1:s+1)&&(a=s,n.length=1),n.reverse();a--;)n.push(0);n.reverse()}for((s=l.length)-(a=c.length)<0&&(a=s,n=c,c=l,l=n),t=0;a;)t=(l[--a]=l[a]+c[a]+t)/k|0,l[a]%=k;for(t&&(l.unshift(t),++r),s=l.length;0==l[--s];)l.pop();return e.d=l,e.e=F(l,r),f?O(e,o,u):e},I.precision=I.sd=function(e){var t,n=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(g+e);return n.d?(t=B(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},I.round=function(){var e=this,t=e.constructor;return O(new t(e),e.e+1,t.rounding)},I.sine=I.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+7,r.rounding=1,n=function(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:J(e,2,t,t);n=(n=1.4*Math.sqrt(r))>16?16:0|n,t=J(e,2,t=t.times(1/X(5,n)),t);for(var a,i=new e(5),s=new e(16),o=new e(20);n--;)a=t.times(t),t=t.times(i.plus(a.times(s.times(a).minus(o))));return t}(r,Z(r,n)),r.precision=e,r.rounding=t,O(o>2?n.neg():n,e,t,!0)):new r(NaN)},I.squareRoot=I.sqrt=function(){var e,t,n,r,a,i,s=this,o=s.d,u=s.e,l=s.s,c=s.constructor;if(1!==l||!o||!o[0])return new c(!l||l<0&&(!o||o[0])?NaN:o?s:1/0);for(f=!1,0==(l=Math.sqrt(+s))||l==1/0?(((t=E(o)).length+u)%2==0&&(t+="0"),l=Math.sqrt(t),u=v((u+1)/2)-(u<0||u%2),r=new c(t=l==1/0?"5e"+u:(t=l.toExponential()).slice(0,t.indexOf("e")+1)+u)):r=new c(l.toString()),n=(u=c.precision)+3;;)if(r=(i=r).plus($(s,i,n+2,1)).times(.5),E(i.d).slice(0,n)===(t=E(r.d)).slice(0,n)){if("9999"!=(t=t.slice(n-3,n+1))&&(a||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(O(r,u+1,1),e=!r.times(r).eq(s));break}if(!a&&(O(i,u+1,0),i.times(i).eq(s))){r=i;break}n+=4,a=1}return f=!0,O(r,u,c.rounding,e)},I.tangent=I.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,(n=n.sin()).s=1,n=$(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,O(2==o||4==o?n.neg():n,e,t,!0)):new r(NaN)},I.times=I.mul=function(e){var t,n,r,a,i,s,o,u,l,c=this,p=c.constructor,d=c.d,h=(e=new p(e)).d;if(e.s*=c.s,!(d&&d[0]&&h&&h[0]))return new p(!e.s||d&&!d[0]&&!h||h&&!h[0]&&!d?NaN:d&&h?0*e.s:e.s/0);for(n=v(c.e/7)+v(e.e/7),(u=d.length)<(l=h.length)&&(i=d,d=h,h=i,s=u,u=l,l=s),i=[],r=s=u+l;r--;)i.push(0);for(r=l;--r>=0;){for(t=0,a=u+r;a>r;)o=i[a]+h[r]*d[a-r-1]+t,i[a--]=o%k|0,t=o/k|0;i[a]=(i[a]+t)%k|0}for(;!i[--s];)i.pop();return t?++n:i.shift(),e.d=i,e.e=F(i,n),f?O(e,p.precision,p.rounding):e},I.toBinary=function(e,t){return Q(this,2,e,t)},I.toDecimalPlaces=I.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),void 0===e?n:(C(e,0,l),void 0===t?t=r.rounding:C(t,0,8),O(n,e+n.e+1,t))},I.toExponential=function(e,t){var n,r=this,a=r.constructor;return void 0===e?n=R(r,!0):(C(e,0,l),void 0===t?t=a.rounding:C(t,0,8),n=R(r=O(new a(r),e+1,t),!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n},I.toFixed=function(e,t){var n,r,a=this,i=a.constructor;return void 0===e?n=R(a):(C(e,0,l),void 0===t?t=i.rounding:C(t,0,8),n=R(r=O(new i(a),e+a.e+1,t),!1,e+r.e+1)),a.isNeg()&&!a.isZero()?"-"+n:n},I.toFraction=function(e){var t,n,r,a,i,s,o,u,l,c,p,d,h=this,m=h.d,y=h.constructor;if(!m)return new y(h);if(l=n=new y(1),r=u=new y(0),s=(i=(t=new y(r)).e=B(m)-h.e-1)%7,t.d[0]=_(10,s<0?7+s:s),null==e)e=i>0?t:l;else{if(!(o=new y(e)).isInt()||o.lt(l))throw Error(g+o);e=o.gt(t)?i>0?t:l:o}for(f=!1,o=new y(E(m)),c=y.precision,y.precision=i=7*m.length*2;p=$(o,t,0,1,1),1!=(a=n.plus(p.times(r))).cmp(e);)n=r,r=a,a=l,l=u.plus(p.times(a)),u=a,a=t,t=o.minus(p.times(a)),o=a;return a=$(e.minus(n),r,0,1,1),u=u.plus(a.times(l)),n=n.plus(a.times(r)),u.s=l.s=h.s,d=$(l,r,i,1).minus(h).abs().cmp($(u,n,i,1).minus(h).abs())<1?[l,r]:[u,n],y.precision=c,f=!0,d},I.toHexadecimal=I.toHex=function(e,t){return Q(this,16,e,t)},I.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),null==e){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),void 0===t?t=r.rounding:C(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(f=!1,n=$(n,e,0,t,1).times(e),f=!0,O(n)):(e.s=n.s,n=e),n},I.toNumber=function(){return+this},I.toOctal=function(e,t){return Q(this,8,e,t)},I.toPower=I.pow=function(e){var t,n,r,a,i,s,o=this,u=o.constructor,l=+(e=new u(e));if(!(o.d&&e.d&&o.d[0]&&e.d[0]))return new u(_(+o,l));if((o=new u(o)).eq(1))return o;if(r=u.precision,i=u.rounding,e.eq(1))return O(o,r,i);if((t=v(e.e/7))>=e.d.length-1&&(n=l<0?-l:l)<=9007199254740991)return a=H(u,o,n,r),e.s<0?new u(1).div(a):O(a,r,i);if((s=o.s)<0){if(tu.maxE+1||t0?s/0:0):(f=!1,u.rounding=o.s=1,n=Math.min(12,(t+"").length),(a=q(e.times(W(o,r+n)),r)).d&&A((a=O(a,r+5,1)).d,r,i)&&(t=r+10,+E((a=O(q(e.times(W(o,t+n)),t),t+5,1)).d).slice(r+1,r+15)+1==1e14&&(a=O(a,r+1,0))),a.s=s,f=!0,u.rounding=i,O(a,r,i))},I.toPrecision=function(e,t){var n,r=this,a=r.constructor;return void 0===e?n=R(r,r.e<=a.toExpNeg||r.e>=a.toExpPos):(C(e,1,l),void 0===t?t=a.rounding:C(t,0,8),n=R(r=O(new a(r),e,t),e<=r.e||r.e<=a.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n},I.toSignificantDigits=I.toSD=function(e,t){var n=this.constructor;return void 0===e?(e=n.precision,t=n.rounding):(C(e,1,l),void 0===t?t=n.rounding:C(t,0,8)),O(new n(this),e,t)},I.toString=function(){var e=this,t=e.constructor,n=R(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n},I.truncated=I.trunc=function(){return O(new this.constructor(this),this.e+1,1)},I.valueOf=I.toJSON=function(){var e=this,t=e.constructor,n=R(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};var $=function(){function e(e,t,n){var r,a=0,i=e.length;for(e=e.slice();i--;)r=e[i]*t+a,e[i]=r%n|0,a=r/n|0;return a&&e.unshift(a),e}function t(e,t,n,r){var a,i;if(n!=r)i=n>r?1:-1;else for(a=i=0;at[a]?1:-1;break}return i}function n(e,t,n,r){for(var a=0;n--;)e[n]-=a,a=e[n]1;)e.shift()}return function(r,a,i,o,u,l){var c,p,d,h,f,m,g,y,b,x,_,w,M,N,S,D,T,I,E,C,A=r.constructor,L=r.s==a.s?1:-1,$=r.d,R=a.d;if(!($&&$[0]&&R&&R[0]))return new A(r.s&&a.s&&($?!R||$[0]!=R[0]:R)?$&&0==$[0]||!R?0*L:L/0:NaN);for(l?(f=1,p=r.e-a.e):(l=k,f=7,p=v(r.e/f)-v(a.e/f)),E=R.length,T=$.length,x=(b=new A(L)).d=[],d=0;R[d]==($[d]||0);d++);if(R[d]>($[d]||0)&&p--,null==i?(N=i=A.precision,o=A.rounding):N=u?i+(r.e-a.e)+1:i,N<0)x.push(1),m=!0;else{if(N=N/f+2|0,d=0,1==E){for(h=0,R=R[0],N++;(d1&&(R=e(R,h,l),$=e($,h,l),E=R.length,T=$.length),D=E,w=(_=$.slice(0,E)).length;w=l/2&&++I;do{h=0,(c=t(R,_,E,w))<0?(M=_[0],E!=w&&(M=M*l+(_[1]||0)),(h=M/I|0)>1?(h>=l&&(h=l-1),1==(c=t(g=e(R,h,l),_,y=g.length,w=_.length))&&(h--,n(g,E=10;h/=10)d++;b.e=d+p*f-1,O(b,u?i+b.e+1:i,o,m)}return b}}();function O(e,t,n,r){var a,i,s,o,u,l,c,p,d,h=e.constructor;e:if(null!=t){if(!(p=e.d))return e;for(a=1,o=p[0];o>=10;o/=10)a++;if((i=t-a)<0)i+=7,s=t,u=(c=p[d=0])/_(10,a-s-1)%10|0;else if((d=Math.ceil((i+1)/7))>=(o=p.length)){if(!r)break e;for(;o++<=d;)p.push(0);c=u=0,a=1,s=(i%=7)-7+1}else{for(c=o=p[d],a=1;o>=10;o/=10)a++;u=(s=(i%=7)-7+a)<0?0:c/_(10,a-s-1)%10|0}if(r=r||t<0||void 0!==p[d+1]||(s<0?c:c%_(10,a-s-1)),l=n<4?(u||r)&&(0==n||n==(e.s<0?3:2)):u>5||5==u&&(4==n||r||6==n&&(i>0?s>0?c/_(10,a-s):0:p[d-1])%10&1||n==(e.s<0?8:7)),t<1||!p[0])return p.length=0,l?(t-=e.e+1,p[0]=_(10,(7-t%7)%7),e.e=-t||0):p[0]=e.e=0,e;if(0==i?(p.length=d,o=1,d--):(p.length=d+1,o=_(10,7-i),p[d]=s>0?(c/_(10,a-s)%_(10,s)|0)*o:0),l)for(;;){if(0==d){for(i=1,s=p[0];s>=10;s/=10)i++;for(s=p[0]+=o,o=1;s>=10;s/=10)o++;i!=o&&(e.e++,p[0]==k&&(p[0]=1));break}if(p[d]+=o,p[d]!=k)break;p[d--]=0,o=1}for(i=p.length;0===p[--i];)p.pop()}return f&&(e.e>h.maxE?(e.d=null,e.e=NaN):e.e0?i=i.charAt(0)+"."+i.slice(1)+P(r):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):a<0?(i="0."+P(-a-1)+i,n&&(r=n-s)>0&&(i+=P(r))):a>=s?(i+=P(a+1-s),n&&(r=n-a-1)>0&&(i=i+"."+P(r))):((r=a+1)0&&(a+1===s&&(i+="."),i+=P(r))),i}function F(e,t){var n=e[0];for(t*=7;n>=10;n/=10)t++;return t}function Y(e,t,n){if(t>D)throw f=!0,n&&(e.precision=n),Error(y);return O(new e(p),t,1,!0)}function z(e,t,n){if(t>T)throw Error(y);return O(new e(d),t,n,!0)}function B(e){var t=e.length-1,n=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function P(e){for(var t="";e--;)t+="0";return t}function H(e,t,n,r){var a,i=new e(1),s=Math.ceil(r/7+4);for(f=!1;;){if(n%2&&ee((i=i.times(t)).d,s)&&(a=!0),0===(n=v(n/2))){n=i.d.length-1,a&&0===i.d[n]&&++i.d[n];break}ee((t=t.times(t)).d,s)}return f=!0,i}function j(e){return 1&e.d[e.d.length-1]}function U(e,t,n){for(var r,a=new e(t[0]),i=0;++i17)return new d(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(f=!1,u=m):u=t,o=new d(.03125);e.e>-2;)e=e.times(o),p+=5;for(u+=r=Math.log(_(2,p))/Math.LN10*2+5|0,n=i=s=new d(1),d.precision=u;;){if(i=O(i.times(e),u,1),n=n.times(++c),E((o=s.plus($(i,n,u,1))).d).slice(0,u)===E(s.d).slice(0,u)){for(a=p;a--;)s=O(s.times(s),u,1);if(null!=t)return d.precision=m,s;if(!(l<3&&A(s.d,u-r,h,l)))return O(s,d.precision=m,h,f=!0);d.precision=u+=10,n=i=o=new d(1),c=0,l++}s=o}}function W(e,t){var n,r,a,i,s,o,u,l,c,p,d,h=1,m=e,g=m.d,y=m.constructor,b=y.rounding,x=y.precision;if(m.s<0||!g||!g[0]||!m.e&&1==g[0]&&1==g.length)return new y(g&&!g[0]?-1/0:1!=m.s?NaN:g?0:m);if(null==t?(f=!1,c=x):c=t,y.precision=c+=10,r=(n=E(g)).charAt(0),!(Math.abs(i=m.e)<15e14))return l=Y(y,c+2,x).times(i+""),m=W(new y(r+"."+n.slice(1)),c-10).plus(l),y.precision=x,null==t?O(m,x,b,f=!0):m;for(;r<7&&1!=r||1==r&&n.charAt(1)>3;)r=(n=E((m=m.times(e)).d)).charAt(0),h++;for(i=m.e,r>1?(m=new y("0."+n),i++):m=new y(r+"."+n.slice(1)),p=m,u=s=m=$(m.minus(1),m.plus(1),c,1),d=O(m.times(m),c,1),a=3;;){if(s=O(s.times(d),c,1),E((l=u.plus($(s,new y(a),c,1))).d).slice(0,c)===E(u.d).slice(0,c)){if(u=u.times(2),0!==i&&(u=u.plus(Y(y,c+2,x).times(i+""))),u=$(u,new y(h),c,1),null!=t)return y.precision=x,u;if(!A(u.d,c-10,b,o))return O(u,y.precision=x,b,f=!0);y.precision=c+=10,l=s=m=$(p.minus(1),p.plus(1),c,1),d=O(m.times(m),c,1),a=o=1}u=l,a+=2}}function V(e){return String(e.s*e.s/0)}function G(e,t){var n,r,a;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;48===t.charCodeAt(r);r++);for(a=t.length;48===t.charCodeAt(a-1);--a);if(t=t.slice(r,a)){if(a-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%7,n<0&&(r+=7),re.constructor.maxE?(e.d=null,e.e=NaN):e.e-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),S.test(t))return G(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(M.test(t))n=16,t=t.toLowerCase();else if(w.test(t))n=2;else{if(!N.test(t))throw Error(g+t);n=8}for((s=t.search(/p/i))>0?(l=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),o=(s=t.indexOf("."))>=0,r=e.constructor,o&&(s=(u=(t=t.replace(".","")).length)-s,a=H(r,new r(n),s,2*s)),s=p=(c=L(t,n,k)).length-1;0===c[s];--s)c.pop();return s<0?new r(0*e.s):(e.e=F(c,p),e.d=c,f=!1,o&&(e=$(e,a,4*u)),l&&(e=e.times(Math.abs(l)<54?_(2,l):i.pow(2,l))),f=!0,e)}function J(e,t,n,r,a){var i,s,o,u,l=e.precision,c=Math.ceil(l/7);for(f=!1,u=n.times(n),o=new e(r);;){if(s=$(o.times(u),new e(t++*t++),l,1),o=a?r.plus(s):r.minus(s),r=$(s.times(u),new e(t++*t++),l,1),void 0!==(s=o.plus(r)).d[c]){for(i=c;s.d[i]===o.d[i]&&i--;);if(-1==i)break}i=o,o=r,r=s,s=i}return f=!0,s.d.length=c+1,s}function X(e,t){for(var n=e;--t;)n*=e;return n}function Z(e,t){var n,r=t.s<0,a=z(e,e.precision,1),i=a.times(.5);if((t=t.abs()).lte(i))return o=r?4:1,t;if((n=t.divToInt(a)).isZero())o=r?3:2;else{if((t=t.minus(n.times(a))).lte(i))return o=j(n)?r?2:3:r?4:1,t;o=j(n)?r?1:4:r?3:2}return t.minus(a).abs()}function Q(e,t,n,r){var a,i,o,u,p,d,h,f,m,g=e.constructor,y=void 0!==n;if(y?(C(n,1,l),void 0===r?r=g.rounding:C(r,0,8)):(n=g.precision,r=g.rounding),e.isFinite()){for(y?(a=2,16==t?n=4*n-3:8==t&&(n=3*n-2)):a=t,(o=(h=R(e)).indexOf("."))>=0&&(h=h.replace(".",""),(m=new g(1)).e=h.length-o,m.d=L(R(m),10,a),m.e=m.d.length),i=p=(f=L(h,10,a)).length;0==f[--p];)f.pop();if(f[0]){if(o<0?i--:((e=new g(e)).d=f,e.e=i,f=(e=$(e,m,n,r,0,a)).d,i=e.e,d=s),o=f[n],u=a/2,d=d||void 0!==f[n+1],d=r<4?(void 0!==o||d)&&(0===r||r===(e.s<0?3:2)):o>u||o===u&&(4===r||d||6===r&&1&f[n-1]||r===(e.s<0?8:7)),f.length=n,d)for(;++f[--n]>a-1;)f[n]=0,n||(++i,f.unshift(1));for(p=f.length;!f[p-1];--p);for(o=0,h="";o1)if(16==t||8==t){for(o=16==t?4:3,--p;p%o;p++)h+="0";for(p=(f=L(h,a,t)).length;!f[p-1];--p);for(o=1,h="1.";op)for(i-=p;i--;)h+="0";else it)return e.length=t,!0}function te(e){return new this(e).abs()}function ne(e){return new this(e).acos()}function re(e){return new this(e).acosh()}function ae(e,t){return new this(e).plus(t)}function ie(e){return new this(e).asin()}function se(e){return new this(e).asinh()}function oe(e){return new this(e).atan()}function ue(e){return new this(e).atanh()}function le(e,t){e=new this(e),t=new this(t);var n,r=this.precision,a=this.rounding,i=r+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(n=t.s<0?z(this,r,a):new this(0)).s=e.s:!e.d||t.isZero()?(n=z(this,i,1).times(.5)).s=e.s:t.s<0?(this.precision=i,this.rounding=1,n=this.atan($(e,t,i,1)),t=z(this,i,1),this.precision=r,this.rounding=a,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan($(e,t,i,1)):(n=z(this,i,1).times(t.s>0?.25:.75)).s=e.s:n=new this(NaN),n}function ce(e){return new this(e).cbrt()}function pe(e){return O(e=new this(e),e.e+1,2)}function de(e,t,n){return new this(e).clamp(t,n)}function he(e){if(!e||"object"!=typeof e)throw Error(m+"Object expected");var t,n,r,a=!0===e.defaults,i=["precision",1,l,"rounding",0,8,"toExpNeg",-u,0,"toExpPos",0,u,"maxE",0,u,"minE",-u,0,"modulo",0,9];for(t=0;t=i[t+1]&&r<=i[t+2]))throw Error(g+n+": "+r);this[n]=r}if(n="crypto",a&&(this[n]=h[n]),void 0!==(r=e[n])){if(!0!==r&&!1!==r&&0!==r&&1!==r)throw Error(g+n+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(b);this[n]=!0}else this[n]=!1}return this}function fe(e){return new this(e).cos()}function me(e){return new this(e).cosh()}function ge(e,t){return new this(e).div(t)}function ye(e){return new this(e).exp()}function be(e){return O(e=new this(e),e.e+1,3)}function xe(){var e,t,n=new this(0);for(f=!1,e=0;e=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:o[i++]=a%1e7;else{if(!crypto.randomBytes)throw Error(b);for(t=crypto.randomBytes(r*=4);i=214e7?crypto.randomBytes(4).copy(t,i):(o.push(a%1e7),i+=4);i=r/4}else for(;i=10;a/=10)r++;r<7&&(n-=7-r)}return s.e=n,s.d=o,s}function Ce(e){return O(e=new this(e),e.e+1,this.rounding)}function Ae(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function Le(e){return new this(e).sin()}function $e(e){return new this(e).sinh()}function Oe(e){return new this(e).sqrt()}function Re(e,t){return new this(e).sub(t)}function Fe(){var e=0,t=arguments,n=new this(t[e]);for(f=!1;n.s&&++ei.maxE?(a.e=NaN,a.d=null):e.e=10;n/=10)t++;return void(f?t>i.maxE?(a.e=NaN,a.d=null):t{"use strict";var t=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{},s=i.preserveFormatting,o=void 0!==s&&s,u=i.escapeMapFn,l=void 0===u?a:u,c=String(e),p="",d=l(t({},n),o?t({},r):{}),h=Object.keys(d),f=function(){var e=!1;h.forEach((function(t,n){e||c.length>=t.length&&c.slice(0,t.length)===t&&(p+=d[h[n]],c=c.slice(t.length,c.length),e=!0)})),e||(p+=c.slice(0,1),c=c.slice(1,c.length))};c;)f();return p}},5628:function(e,t){var n;!function(r){"use strict";var a={s:1,n:0,d:1};function i(e,t){if(isNaN(e=parseInt(e,10)))throw c.InvalidParameter;return e*t}function s(e,t){if(0===t)throw c.DivisionByZero;var n=Object.create(c.prototype);n.s=e<0?-1:1;var r=l(e=e<0?-e:e,t);return n.n=e/r,n.d=t/r,n}function o(e){for(var t={},n=e,r=2,a=4;a<=n;){for(;n%r==0;)n/=r,t[r]=(t[r]||0)+1;a+=1+2*r++}return n!==e?n>1&&(t[n]=(t[n]||0)+1):t[e]=(t[e]||0)+1,t}var u=function(e,t){var n,r=0,s=1,o=1,u=0,l=0,p=0,d=1,h=1,f=0,m=1,g=1,y=1,b=1e7;if(null==e);else if(void 0!==t){if(o=(r=e)*(s=t),r%1!=0||s%1!=0)throw c.NonIntegerParameter}else switch(typeof e){case"object":if("d"in e&&"n"in e)r=e.n,s=e.d,"s"in e&&(r*=e.s);else{if(!(0 in e))throw c.InvalidParameter;r=e[0],1 in e&&(s=e[1])}o=r*s;break;case"number":if(e<0&&(o=e,e=-e),e%1==0)r=e;else if(e>0){for(e>=1&&(e/=h=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));m<=b&&y<=b;){if(e===(n=(f+g)/(m+y))){m+y<=b?(r=f+g,s=m+y):y>m?(r=g,s=y):(r=f,s=m);break}e>n?(f+=g,m+=y):(g+=f,y+=m),m>b?(r=g,s=y):(r=f,s=m)}r*=h}else(isNaN(e)||isNaN(t))&&(s=r=NaN);break;case"string":if(null===(m=e.match(/\d+|./g)))throw c.InvalidParameter;if("-"===m[f]?(o=-1,f++):"+"===m[f]&&f++,m.length===f+1?l=i(m[f++],o):"."===m[f+1]||"."===m[f]?("."!==m[f]&&(u=i(m[f++],o)),(1+ ++f===m.length||"("===m[f+1]&&")"===m[f+3]||"'"===m[f+1]&&"'"===m[f+3])&&(l=i(m[f],o),d=Math.pow(10,m[f].length),f++),("("===m[f]&&")"===m[f+2]||"'"===m[f]&&"'"===m[f+2])&&(p=i(m[f+1],o),h=Math.pow(10,m[f+1].length)-1,f+=3)):"/"===m[f+1]||":"===m[f+1]?(l=i(m[f],o),d=i(m[f+2],1),f+=3):"/"===m[f+3]&&" "===m[f+1]&&(u=i(m[f],o),l=i(m[f+2],o),d=i(m[f+4],1),f+=5),m.length<=f){o=r=p+(s=d*h)*u+h*l;break}default:throw c.InvalidParameter}if(0===s)throw c.DivisionByZero;a.s=o<0?-1:1,a.n=Math.abs(r),a.d=Math.abs(s)};function l(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function c(e,t){if(u(e,t),!(this instanceof c))return s(a.s*a.n,a.d);e=l(a.d,a.n),this.s=a.s,this.n=a.n/e,this.d=a.d/e}c.DivisionByZero=new Error("Division by Zero"),c.InvalidParameter=new Error("Invalid argument"),c.NonIntegerParameter=new Error("Parameters must be integer"),c.prototype={s:1,n:0,d:1,abs:function(){return s(this.n,this.d)},neg:function(){return s(-this.s*this.n,this.d)},add:function(e,t){return u(e,t),s(this.s*this.n*a.d+a.s*this.d*a.n,this.d*a.d)},sub:function(e,t){return u(e,t),s(this.s*this.n*a.d-a.s*this.d*a.n,this.d*a.d)},mul:function(e,t){return u(e,t),s(this.s*a.s*this.n*a.n,this.d*a.d)},div:function(e,t){return u(e,t),s(this.s*a.s*this.n*a.d,this.d*a.n)},clone:function(){return s(this.s*this.n,this.d)},mod:function(e,t){if(isNaN(this.n)||isNaN(this.d))return new c(NaN);if(void 0===e)return s(this.s*this.n%this.d,1);if(u(e,t),0===a.n&&0===this.d)throw c.DivisionByZero;return s(this.s*(a.d*this.n)%(a.n*this.d),a.d*this.d)},gcd:function(e,t){return u(e,t),s(l(a.n,this.n)*l(a.d,this.d),a.d*this.d)},lcm:function(e,t){return u(e,t),0===a.n&&0===this.n?s(0,1):s(a.n*this.n,l(a.n,this.n)*l(a.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):s(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):s(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):s(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return s(this.s*this.d,this.n)},pow:function(e,t){if(u(e,t),1===a.d)return a.s<0?s(Math.pow(this.s*this.d,a.n),Math.pow(this.n,a.n)):s(Math.pow(this.s*this.n,a.n),Math.pow(this.d,a.n));if(this.s<0)return null;var n=o(this.n),r=o(this.d),i=1,l=1;for(var c in n)if("1"!==c){if("0"===c){i=0;break}if(n[c]*=a.n,n[c]%a.d!=0)return null;n[c]/=a.d,i*=Math.pow(c,n[c])}for(var c in r)if("1"!==c){if(r[c]*=a.n,r[c]%a.d!=0)return null;r[c]/=a.d,l*=Math.pow(c,r[c])}return a.s<0?s(l,i):s(i,l)},equals:function(e,t){return u(e,t),this.s*this.n*a.d==a.s*a.n*this.d},compare:function(e,t){u(e,t);var n=this.s*this.n*a.d-a.s*a.n*this.d;return(0=0;i--)a=a.inverse().add(n[i]);if(a.sub(t).abs().valueOf()0&&(n+=t,n+=" ",r%=a),n+=r,n+="/",n+=a),n},toLatex:function(e){var t,n="",r=this.n,a=this.d;return this.s<0&&(n+="-"),1===a?n+=r:(e&&(t=Math.floor(r/a))>0&&(n+=t,r%=a),n+="\\frac{",n+=r,n+="}{",n+=a,n+="}"),n},toContinued:function(){var e,t=this.n,n=this.d,r=[];if(isNaN(t)||isNaN(n))return r;do{r.push(Math.floor(t/n)),e=t%n,t=n,n=e}while(1!==t);return r},toString:function(e){var t=this.n,n=this.d;if(isNaN(t)||isNaN(n))return"NaN";e=e||15;var r=function(e,t){for(;t%2==0;t/=2);for(;t%5==0;t/=5);if(1===t)return 0;for(var n=10%t,r=1;1!==n;r++)if(n=10*n%t,r>2e3)return 0;return r}(0,n),a=function(e,t,n){for(var r=1,a=function(e,t,n){for(var r=1;t>0;e=e*e%n,t>>=1)1&t&&(r=r*e%n);return r}(10,n,t),i=0;i<300;i++){if(r===a)return i;r=10*r%t,a=10*a%t}return 0}(0,n,r),i=this.s<0?"-":"";if(i+=t/n|0,t%=n,(t*=10)&&(i+="."),r){for(var s=a;s--;)i+=t/n|0,t%=n,t*=10;for(i+="(",s=r;s--;)i+=t/n|0,t%=n,t*=10;i+=")"}else for(s=e;t&&s--;)i+=t/n|0,t%=n,t*=10;return i}},void 0===(n=function(){return c}.apply(t,[]))||(e.exports=n)}()},3228:e=>{e.exports=function e(t,n){"use strict";var r,a,i=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,s=/(^[ ]*|[ ]*$)/g,o=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,l=/^0/,c=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},p=c(t).replace(s,"")||"",d=c(n).replace(s,"")||"",h=p.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),f=d.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=parseInt(p.match(u),16)||1!==h.length&&p.match(o)&&Date.parse(p),g=parseInt(d.match(u),16)||m&&d.match(o)&&Date.parse(d)||null;if(g){if(mg)return 1}for(var y=0,b=Math.max(h.length,f.length);ya)return 1}return 0}},3720:e=>{e.exports=n;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function n(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function r(e){return!0===(e&&e.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=r;var a={},i={};function s(e,t){var n,r,s;return t?(s=0<=(e>>>=0)&&e<256)&&(r=i[e])?r:(n=u(e,(0|e)<0?-1:0,!0),s&&(i[e]=n),n):(s=-128<=(e|=0)&&e<128)&&(r=a[e])?r:(n=u(e,e<0?-1:0,!1),s&&(a[e]=n),n)}function o(e,t){if(isNaN(e))return t?y:g;if(t){if(e<0)return y;if(e>=h)return w}else{if(e<=-f)return M;if(e+1>=f)return _}return e<0?o(-e,t).neg():u(e%d|0,e/d|0,t)}function u(e,t,r){return new n(e,t,r)}n.fromInt=s,n.fromNumber=o,n.fromBits=u;var l=Math.pow;function c(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return g;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||360)throw Error("interior hyphen");if(0===r)return c(e.substring(1),t,n).neg();for(var a=o(l(n,8)),i=g,s=0;s>>0:this.low},N.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},N.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((i=u).isZero())return c+s;for(;c.length<6;)c="0"+c;s=""+c+s}},N.getHighBits=function(){return this.high},N.getHighBitsUnsigned=function(){return this.high>>>0},N.getLowBits=function(){return this.low},N.getLowBitsUnsigned=function(){return this.low>>>0},N.getNumBitsAbs=function(){if(this.isNegative())return this.eq(M)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<=0},N.isOdd=function(){return 1==(1&this.low)},N.isEven=function(){return 0==(1&this.low)},N.equals=function(e){return r(e)||(e=p(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},N.eq=N.equals,N.notEquals=function(e){return!this.eq(e)},N.neq=N.notEquals,N.ne=N.notEquals,N.lessThan=function(e){return this.comp(e)<0},N.lt=N.lessThan,N.lessThanOrEqual=function(e){return this.comp(e)<=0},N.lte=N.lessThanOrEqual,N.le=N.lessThanOrEqual,N.greaterThan=function(e){return this.comp(e)>0},N.gt=N.greaterThan,N.greaterThanOrEqual=function(e){return this.comp(e)>=0},N.gte=N.greaterThanOrEqual,N.ge=N.greaterThanOrEqual,N.compare=function(e){if(r(e)||(e=p(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},N.comp=N.compare,N.negate=function(){return!this.unsigned&&this.eq(M)?M:this.not().add(b)},N.neg=N.negate,N.add=function(e){r(e)||(e=p(e));var t=this.high>>>16,n=65535&this.high,a=this.low>>>16,i=65535&this.low,s=e.high>>>16,o=65535&e.high,l=e.low>>>16,c=0,d=0,h=0,f=0;return h+=(f+=i+(65535&e.low))>>>16,d+=(h+=a+l)>>>16,c+=(d+=n+o)>>>16,c+=t+s,u((h&=65535)<<16|(f&=65535),(c&=65535)<<16|(d&=65535),this.unsigned)},N.subtract=function(e){return r(e)||(e=p(e)),this.add(e.neg())},N.sub=N.subtract,N.multiply=function(e){if(this.isZero())return g;if(r(e)||(e=p(e)),t)return u(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return g;if(this.eq(M))return e.isOdd()?M:g;if(e.eq(M))return this.isOdd()?M:g;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(m)&&e.lt(m))return o(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,a=65535&this.high,i=this.low>>>16,s=65535&this.low,l=e.high>>>16,c=65535&e.high,d=e.low>>>16,h=65535&e.low,f=0,y=0,b=0,x=0;return b+=(x+=s*h)>>>16,y+=(b+=i*h)>>>16,b&=65535,y+=(b+=s*d)>>>16,f+=(y+=a*h)>>>16,y&=65535,f+=(y+=i*d)>>>16,y&=65535,f+=(y+=s*c)>>>16,f+=n*h+a*d+i*c+s*l,u((b&=65535)<<16|(x&=65535),(f&=65535)<<16|(y&=65535),this.unsigned)},N.mul=N.multiply,N.divide=function(e){if(r(e)||(e=p(e)),e.isZero())throw Error("division by zero");var n,a,i;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?u((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?y:g;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return y;if(e.gt(this.shru(1)))return x;i=y}else{if(this.eq(M))return e.eq(b)||e.eq(v)?M:e.eq(M)?b:(n=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?b:v:(a=this.sub(e.mul(n)),i=n.add(a.div(e)));if(e.eq(M))return this.unsigned?y:g;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=g}for(a=this;a.gte(e);){n=Math.max(1,Math.floor(a.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(n)/Math.LN2),c=s<=48?1:l(2,s-48),d=o(n),h=d.mul(e);h.isNegative()||h.gt(a);)h=(d=o(n-=c,this.unsigned)).mul(e);d.isZero()&&(d=b),i=i.add(d),a=a.sub(h)}return i},N.div=N.divide,N.modulo=function(e){return r(e)||(e=p(e)),t?u((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},N.mod=N.modulo,N.rem=N.modulo,N.not=function(){return u(~this.low,~this.high,this.unsigned)},N.and=function(e){return r(e)||(e=p(e)),u(this.low&e.low,this.high&e.high,this.unsigned)},N.or=function(e){return r(e)||(e=p(e)),u(this.low|e.low,this.high|e.high,this.unsigned)},N.xor=function(e){return r(e)||(e=p(e)),u(this.low^e.low,this.high^e.high,this.unsigned)},N.shiftLeft=function(e){return r(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?u(this.low<>>32-e,this.unsigned):u(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):u(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},N.shr=N.shiftRight,N.shiftRightUnsigned=function(e){if(r(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?u(this.low>>>e|t<<32-e,t>>>e,this.unsigned):u(32===e?t:t>>>e-32,0,this.unsigned)},N.shru=N.shiftRightUnsigned,N.shr_u=N.shiftRightUnsigned,N.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},N.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},N.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},N.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},N.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},n.fromBytes=function(e,t,r){return r?n.fromBytesLE(e,t):n.fromBytesBE(e,t)},n.fromBytesLE=function(e,t){return new n(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},n.fromBytesBE=function(e,t){return new n(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},6377:(e,t,n)=>{var r=n(4832),a=n(8652),i=n(801),s=n(2030),o=n(3618),u=n(9049),l=n(1971);l.alea=r,l.xor128=a,l.xorwow=i,l.xorshift7=s,l.xor4096=o,l.tychei=u,e.exports=l},4832:function(e,t,n){var r;!function(e,a,i){function s(e){var t,n=this,r=(t=4022871197,function(e){e=String(e);for(var n=0;n>>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 u(e,t){var n=new s(e),r=t&&t.state,a=n.next;return a.int32=function(){return 4294967296*n.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.alea=u}(0,e=n.nmd(e),n.amdD)},9049:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,a=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^a,t.a=a-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>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.tychei=u}(0,e=n.nmd(e),n.amdD)},8652:function(e,t,n){var r;!function(e,a,i){function s(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>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor128=u}(0,e=n.nmd(e),n.amdD)},3618:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.w,a=t.X,i=t.i;return t.w=r=r+1640531527|0,n=a[i+34&127],e=a[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=a[i]=n^e,t.i=i,n+(r^r>>>16)|0},function(e,t){var n,r,a,i,s,o=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),a=0,i=-32;i>>15,r^=r<<4,r^=r>>>13,i>=0&&(s=s+1640531527|0,a=0==(n=o[127&i]^=r+s)?a+1:0);for(a>=128&&(o[127&(t&&t.length||0)]=-1),a=127,i=512;i>0;--i)r=o[a+34&127],n=o[a=a+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,o[a]=r^n;e.w=s,e.X=o,e.i=a}(t,e)}function o(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.X&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor4096=u}(0,e=n.nmd(e),n.amdD)},2030:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.x,a=t.i;return e=r[a],n=(e^=e>>>7)^e<<24,n^=(e=r[a+1&7])^e>>>10,n^=(e=r[a+3&7])^e>>>3,n^=(e=r[a+4&7])^e<<7,e=r[a+7&7],n^=(e^=e<<13)^e<<9,r[a]=n,t.i=a+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n0;--n)e.next()}(t,e)}function o(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.x&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorshift7=u}(0,e=n.nmd(e),n.amdD)},801:function(e,t,n){var r;!function(e,a,i){function s(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>>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 u(e,t){var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorwow=u}(0,e=n.nmd(e),n.amdD)},1971:function(e,t,n){var r;!function(a,i,s){var o,u=256,l=s.pow(u,6),c=s.pow(2,52),p=2*c,d=255;function h(e,t,n){var r=[],d=y(g((t=1==t?{entropy:!0}:t||{}).entropy?[e,b(i)]:null==e?function(){try{var e;return o&&(e=o.randomBytes)?e=e(u):(e=new Uint8Array(u),(a.crypto||a.msCrypto).getRandomValues(e)),b(e)}catch(e){var t=a.navigator,n=t&&t.plugins;return[+new Date,a,n,a.screen,b(i)]}}():e,3),r),h=new f(r),x=function(){for(var e=h.g(6),t=l,n=0;e=p;)e/=2,t/=2,n>>>=1;return(e+n)/t};return x.int32=function(){return 0|h.g(4)},x.quick=function(){return h.g(4)/4294967296},x.double=x,y(b(h.S),i),(t.pass||n||function(e,t,n,r){return r&&(r.S&&m(r,h),e.state=function(){return m(h,{})}),n?(s.random=e,t):e})(x,d,"global"in t?t.global:this==s,t.state)}function f(e){var t,n=e.length,r=this,a=0,i=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);a{function t(){}t.prototype={on:function(e,t,n){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function a(){r.off(e,a),t.apply(n,arguments)}return a._=t,this.on(e,a,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),r=0,a=n.length;r3?e.slice(3):"any":e).split("|").map(L).filter($).filter(A),a=function(e,t){var n={};return e.forEach((function(e){-1!==t.indexOf(e.from)||-1===t.indexOf(e.to)||n[e.from]||(n[e.from]=e)})),Object.keys(n).map((function(e){return n[e]}))}(t,r),i=r.map((function(e){var t=l(e);return{name:e,typeIndex:c(t),test:t.test,conversion:null,conversionIndex:-1}})),s=a.map((function(e){var n=l(e.from);return{name:e.from,typeIndex:c(n),test:n.test,conversion:e,conversionIndex:t.indexOf(e)}}));return{types:i.concat(s),restParam:n}}function f(e){var t=F(e);return!!t&&t.restParam}function m(e){return e.types.some((function(e){return null!=e.conversion}))}function g(t){if(t&&0!==t.types.length){if(1===t.types.length)return l(t.types[0].name).test;if(2===t.types.length){var n=l(t.types[0].name).test,r=l(t.types[1].name).test;return function(e){return n(e)||r(e)}}var a=t.types.map((function(e){return l(e.name).test}));return function(e){for(var t=0;t=i+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(n=g(e[0]),function(e){return n(e[0])&&1===e.length}):2===e.length?(n=g(e[0]),r=g(e[1]),function(e){return n(e[0])&&r(e[1])&&2===e.length}):(t=e.map(g),function(e){for(var n=0;n0){var l=p(t[i]);return(r=new TypeError("Unexpected type of argument in function "+s+" (expected: "+a.join(" or ")+", actual: "+l+", index: "+i+")")).data={category:"wrongType",fn:s,index:i,actual:l,expected:a},r}}else o=u}var c=o.map((function(e){return f(e.params)?1/0:e.params.length}));if(t.lengthd?((r=new TypeError("Too many arguments in function "+s+" (expected: "+d+", actual: "+t.length+")")).data={category:"tooManyArgs",fn:s,index:t.length,expectedLength:d},r):((r=new TypeError('Arguments of type "'+t.join(", ")+'" do not match any of the defined signatures of function '+s+".")).data={category:"mismatch",actual:t.map(p)},r)}function N(e){for(var t=999,n=0;n=a:o?a>=i:a===i}(t,e)}));if(t)throw new TypeError('Conflicting signatures "'+d(t.params)+'" and "'+d(e.params)+'".');a.push(e)}));var i=P(a,(function(e){return(e?I(e.params,!1):[]).map((function(t){return{params:t,fn:e.fn}}))})).filter(O);i.sort(D);var s=i[0]&&i[0].params.length<=2&&!f(i[0].params),o=i[1]&&i[1].params.length<=2&&!f(i[1].params),l=i[2]&&i[2].params.length<=2&&!f(i[2].params),c=i[3]&&i[3].params.length<=2&&!f(i[3].params),p=i[4]&&i[4].params.length<=2&&!f(i[4].params),b=i[5]&&i[5].params.length<=2&&!f(i[5].params),v=s&&o&&l&&c&&p&&b,_=i.map((function(e){return y(e.params)})),w=s?g(i[0].params[0]):t,M=o?g(i[1].params[0]):t,N=l?g(i[2].params[0]):t,S=c?g(i[3].params[0]):t,k=p?g(i[4].params[0]):t,E=b?g(i[5].params[0]):t,C=s?g(i[0].params[1]):t,A=o?g(i[1].params[1]):t,$=l?g(i[2].params[1]):t,F=c?g(i[3].params[1]):t,H=p?g(i[4].params[1]):t,j=b?g(i[5].params[1]):t,U=i.map((function(e){return function(e,t){var n=t;if(e.some(m)){var r=f(e),a=e.map(T);n=function(){for(var e=[],n=r?arguments.length-1:arguments.length,i=0;i{},8628:()=>{},1601:()=>{},7792:()=>{},4977:()=>{},5042:()=>{}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.amdD=function(){throw new Error("define cannot be used indirect")},n.amdO={},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})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var r={};(()=>{"use strict";n.r(r),n.d(r,{Tensor:()=>qie,Turtle:()=>Rie,abs:()=>Zie,acos:()=>dse,add:()=>Vie,asin:()=>hse,atan:()=>fse,atan2:()=>mse,average:()=>Qse,ceil:()=>Qie,compile:()=>Yie,complex:()=>xse,concat:()=>Ase,constrain:()=>ese,copy:()=>vse,cos:()=>gse,derivative:()=>zie,dispose:()=>qse,div:()=>Jie,dot:()=>Xie,endScope:()=>jse,evaluate:()=>Bie,exp:()=>tse,eye:()=>_se,fft:()=>zse,fill:()=>wse,flatten:()=>Ise,floor:()=>nse,fromImage:()=>Vse,getBackend:()=>que,keep:()=>Use,linspace:()=>Mse,log:()=>rse,math:()=>G,max:()=>ase,mean:()=>Zse,memory:()=>Bse,min:()=>ise,mod:()=>sse,mult:()=>Kie,ones:()=>Nse,pad:()=>Ese,parse:()=>Pie,percentile:()=>Jse,pow:()=>ose,ptp:()=>Kse,quantile:()=>Xse,random:()=>Sse,randomGaussian:()=>kse,range:()=>Dse,reshape:()=>Cse,reverse:()=>Lse,round:()=>use,scope:()=>Pse,sd:()=>eoe,setBackend:()=>Uue,simplify:()=>Hie,sin:()=>yse,slice:()=>$se,sort:()=>Yse,split:()=>Ose,sq:()=>lse,sqrt:()=>cse,stack:()=>Rse,startScope:()=>Hse,sub:()=>Gie,sum:()=>pse,tan:()=>bse,tf:()=>W,toDateTime:()=>jue,toImage:()=>Gse,unstack:()=>Fse,variance:()=>toe,zeros:()=>Tse});var e={};n.r(e),n.d(e,{arraysEqual:()=>de,assert:()=>se,assertNonNegativeIntegerDimensions:()=>He,assertNonNull:()=>ue,assertShapesMatch:()=>oe,bytesFromStringArray:()=>Ie,bytesPerElement:()=>Te,checkConversionForErrors:()=>Ne,clamp:()=>ee,computeStrides:()=>Re,createScalarValue:()=>Fa,createShuffledIndices:()=>ge,decodeString:()=>Ha,distSquared:()=>ie,encodeString:()=>Pa,fetch:()=>Ba,fingerPrint64:()=>Ra,flatten:()=>le,getArrayFromDType:()=>Me,getTypedArrayFromDType:()=>we,hasEncodingLoss:()=>ke,hexToLong:()=>Sa,indexToLoc:()=>Ue,inferDtype:()=>Le,inferFromImplicitShape:()=>xe,isBoolean:()=>Ce,isFunction:()=>$e,isInt:()=>he,isNumber:()=>Ae,isPromise:()=>qe,isScalarShape:()=>pe,isString:()=>Ee,isTypedArray:()=>De,isValidDtype:()=>Se,locToIndex:()=>je,makeOnesTypedArray:()=>ze,makeZerosNestedTypedArray:()=>Pe,makeZerosTypedArray:()=>Be,nearestDivisor:()=>Oe,nearestLargerEven:()=>te,now:()=>za,parseAxisParam:()=>ve,randUniform:()=>ae,repeatedTry:()=>be,rightPad:()=>ye,shuffle:()=>Z,shuffleCombo:()=>Q,sizeFromShape:()=>ce,sizeToSquarishShape:()=>me,squeezeShape:()=>_e,sum:()=>re,swap:()=>ne,tanh:()=>fe,toNestedArray:()=>Ye,toTypedArray:()=>Ya});var t={};n.r(t),n.d(t,{assertTypesMatch:()=>hi,getTensorsInContainer:()=>mi,isTensorInList:()=>fi,makeTypesMatch:()=>di});var a={};n.r(a),n.d(a,{isBrowser:()=>ki,isMobile:()=>Si,mockIsMobile:()=>Ni});var i={};n.r(i),n.d(i,{browserFiles:()=>zs,browserHTTPRequest:()=>Gs,concatenateArrayBuffers:()=>Ui,copyModel:()=>Ts,decodeWeights:()=>Bi,encodeWeights:()=>zi,fromMemory:()=>Zs,fromMemorySync:()=>Qs,getLoadHandlers:()=>es,getModelArtifactsForJSON:()=>Vi,getModelArtifactsInfoForJSON:()=>Gi,getSaveHandlers:()=>Qi,http:()=>Vs,isHTTPScheme:()=>qs,listModels:()=>ks,loadWeights:()=>Hs,moveModel:()=>Is,registerLoadRouter:()=>Zi,registerSaveRouter:()=>Xi,removeModel:()=>Ds,weightsLoaderFactory:()=>js,withSaveHandler:()=>eo,withSaveHandlerSync:()=>to});var s={};n.r(s),n.d(s,{confusionMatrix:()=>Eo});var o={};n.r(o),n.d(o,{assertAndGetBroadcastShape:()=>Lo,getBroadcastDims:()=>Co,getReductionAxes:()=>Ao});var u={};n.r(u),n.d(u,{fromPixels:()=>zo,fromPixelsAsync:()=>Fo,toPixels:()=>Yo});var l={};n.r(l),n.d(l,{prepareAndValidate:()=>Bo});var c={};n.r(c),n.d(c,{calculateShapes:()=>jo,validateInput:()=>Ho,validateUpdateShape:()=>Po});var p={};n.r(p),n.d(p,{assertParamsValid:()=>Uo,computeFlatOffset:()=>ru,computeOutShape:()=>Wo,getNormalizedAxes:()=>Jo,isSliceContinous:()=>nu,maskToAxes:()=>qo,parseSliceParams:()=>au,sliceInfo:()=>iu,startForAxis:()=>eu,startIndicesWithElidedDims:()=>Xo,stopForAxis:()=>tu,stopIndicesWithElidedDims:()=>Zo,stridesForAxis:()=>Qo,stridesWithElidedDims:()=>Vo});var d={};n.r(d),n.d(d,{Serializable:()=>ou,SerializationMap:()=>uu,registerClass:()=>lu});var h={};n.r(h),n.d(h,{TEST_EPSILON_FLOAT16:()=>cu,encodeStrings:()=>vu,expectArrayBuffersEqual:()=>xu,expectArraysClose:()=>pu,expectArraysEqual:()=>mu,expectNumbersClose:()=>gu,expectPromiseToFail:()=>fu,expectValuesInRange:()=>bu,testEpsilon:()=>du});var f={};n.r(f),n.d(f,{conv2d:()=>qd,depthwiseConv2d:()=>Gd,matMul:()=>Kd});var m={};n.r(m),n.d(m,{collectGatherOpShapeInfo:()=>Vf,computeOutShape:()=>Wf,segOpComputeOptimalWindowSize:()=>qf});var g={};n.r(g),n.d(g,{ERF_A1:()=>df,ERF_A2:()=>hf,ERF_A3:()=>ff,ERF_A4:()=>mf,ERF_A5:()=>gf,ERF_P:()=>pf,PARALLELIZE_THRESHOLD:()=>ef,SELU_SCALE:()=>cf,SELU_SCALEALPHA:()=>lf,applyActivation:()=>jd,assertAndGetBroadcastShape:()=>Lo,assertAxesAreInnerMostDims:()=>bc,assertParamsConsistent:()=>Zh,assignToTypedArray:()=>wf,axesAreInnerMostDims:()=>fc,calculateShapes:()=>jo,checkEinsumDimSizes:()=>Tf,checkPadOnDimRoundingMode:()=>wl,combineLocations:()=>mc,complexWithEvenIndex:()=>xf,complexWithOddIndex:()=>vf,computeConv2DInfo:()=>dl,computeConv3DInfo:()=>hl,computeDefaultPad:()=>fl,computeDilation2DInfo:()=>ll,computeOptimalWindowSize:()=>tf,computeOutAndReduceShapes:()=>gc,computeOutShape:()=>Qh,computePool2DInfo:()=>cl,computePool3DInfo:()=>pl,convertConv2DDataFormat:()=>_l,decodeEinsumEquation:()=>kf,eitherStridesOrDilationsAreOne:()=>vl,expandShapeToKeepDim:()=>yc,exponent:()=>Nf,exponents:()=>Mf,fromStringArrayToUint8:()=>Kf,fromUint8ToStringArray:()=>Gf,getAxesPermutation:()=>xc,getBroadcastDims:()=>Co,getComplexWithIndex:()=>_f,getEinsumComputePath:()=>If,getEinsumPermutation:()=>Df,getFusedBiasGradient:()=>Hd,getFusedDyActivation:()=>Pd,getImageCenter:()=>nf,getInnerMostAxes:()=>_c,getPermuted:()=>af,getReductionAxes:()=>Ao,getReshaped:()=>rf,getReshapedPermuted:()=>sf,getSliceBeginCoords:()=>of,getSliceSize:()=>uf,getSparseFillEmptyRowsIndicesDenseShapeMismatch:()=>Lf,getSparseFillEmptyRowsNegativeIndexErrorMessage:()=>$f,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:()=>Of,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:()=>Yf,getSparseReshapeInputOutputMismatchErrorMessage:()=>Bf,getSparseReshapeInputOutputMultipleErrorMessage:()=>zf,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:()=>Rf,getSparseReshapeNegativeOutputDimErrorMessage:()=>Ff,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:()=>Uf,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:()=>Pf,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:()=>Hf,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:()=>jf,getUndoAxesPermutation:()=>vc,isIdentityPermutation:()=>Ef,log:()=>pa,mergeRealAndImagArrays:()=>yf,prepareAndValidate:()=>Bo,prepareSplitSize:()=>Af,segment_util:()=>m,shouldFuse:()=>Ud,slice_util:()=>p,splitRealAndImagArrays:()=>bf,tupleValuesAreOne:()=>xl,upcastType:()=>ci,validateInput:()=>Ho,validateUpdateShape:()=>Po,warn:()=>ca});var y={};n.r(y),n.d(y,{nonMaxSuppressionV3Impl:()=>uh,nonMaxSuppressionV4Impl:()=>lh,nonMaxSuppressionV5Impl:()=>ch,whereImpl:()=>Id});var b={};n.r(b),n.d(b,{maxNorm:()=>$b,minMaxNorm:()=>Fb,nonNeg:()=>Rb,unitNorm:()=>Ob});var x={};n.r(x),n.d(x,{constant:()=>Bb,glorotNormal:()=>Vb,glorotUniform:()=>Wb,heNormal:()=>Gb,heUniform:()=>Kb,identity:()=>Ub,leCunNormal:()=>Jb,leCunUniform:()=>Xb,ones:()=>zb,orthogonal:()=>Zb,randomNormal:()=>Hb,randomUniform:()=>Pb,truncatedNormal:()=>jb,varianceScaling:()=>qb,zeros:()=>Yb});var v={};n.r(v),n.d(v,{Layer:()=>hb,RNN:()=>c_,RNNCell:()=>p_,activation:()=>Cw,add:()=>Bw,alphaDropout:()=>EM,average:()=>Pw,averagePooling1d:()=>Jw,averagePooling2d:()=>Qw,averagePooling3d:()=>nM,avgPool1d:()=>Xw,avgPool2d:()=>eM,avgPool3d:()=>rM,avgPooling1d:()=>Zw,avgPooling2d:()=>tM,avgPooling3d:()=>aM,batchNormalization:()=>Vw,bidirectional:()=>wM,concatenate:()=>Hw,conv1d:()=>ww,conv2d:()=>Mw,conv2dTranspose:()=>Nw,conv3d:()=>Sw,conv3dTranspose:()=>kw,convLstm2d:()=>bM,convLstm2dCell:()=>xM,cropping2D:()=>Tw,dense:()=>Aw,depthwiseConv2d:()=>Ew,dot:()=>Ww,dropout:()=>Lw,elu:()=>gw,embedding:()=>zw,flatten:()=>Ow,gaussianDropout:()=>IM,gaussianNoise:()=>TM,globalAveragePooling1d:()=>iM,globalAveragePooling2d:()=>sM,globalMaxPool1d:()=>NM,globalMaxPool2d:()=>SM,globalMaxPooling1d:()=>oM,globalMaxPooling2d:()=>uM,gru:()=>dM,gruCell:()=>hM,input:()=>pv,inputLayer:()=>mw,layerNormalization:()=>Gw,leakyReLU:()=>bw,lstm:()=>fM,lstmCell:()=>mM,masking:()=>CM,maxPool1d:()=>kM,maxPool2d:()=>DM,maxPooling1d:()=>lM,maxPooling2d:()=>cM,maxPooling3d:()=>pM,maximum:()=>jw,minimum:()=>Uw,multiply:()=>qw,permute:()=>Yw,prelu:()=>xw,reLU:()=>yw,repeatVector:()=>Rw,reshape:()=>Fw,rnn:()=>vM,separableConv2d:()=>Dw,simpleRNN:()=>gM,simpleRNNCell:()=>yM,softmax:()=>vw,spatialDropout1d:()=>$w,stackedRNNCells:()=>_M,thresholdedReLU:()=>_w,timeDistributed:()=>MM,upSampling2d:()=>Iw,zeroPadding2d:()=>Kw});var _={};n.r(_),n.d(_,{MAPE:()=>HM,MSE:()=>qM,binaryAccuracy:()=>AM,binaryCrossentropy:()=>LM,categoricalAccuracy:()=>OM,categoricalCrossentropy:()=>RM,cosineProximity:()=>zM,mape:()=>jM,meanAbsoluteError:()=>BM,meanAbsolutePercentageError:()=>PM,meanSquaredError:()=>UM,mse:()=>WM,precision:()=>FM,recall:()=>YM,sparseCategoricalAccuracy:()=>$M});var w={};n.r(w),n.d(w,{modelFromJSON:()=>sv});var M={};n.r(M),n.d(M,{l1:()=>GM,l1l2:()=>VM,l2:()=>KM});var N={};n.r(N),n.d(N,{json:()=>fN});var S={};n.r(S),n.d(S,{json:()=>mN});var k={};n.r(k),n.d(k,{json:()=>gN});var D={};n.r(D),n.d(D,{json:()=>yN});var T={};n.r(T),n.d(T,{json:()=>bN});var I={};n.r(I),n.d(I,{json:()=>xN});var E={};n.r(E),n.d(E,{json:()=>vN});var C={};n.r(C),n.d(C,{json:()=>_N});var A={};n.r(A),n.d(A,{json:()=>wN});var L={};n.r(L),n.d(L,{json:()=>MN});var $={};n.r($),n.d($,{json:()=>NN});var O={};n.r(O),n.d(O,{json:()=>SN});var R={};n.r(R),n.d(R,{json:()=>kN});var F={};n.r(F),n.d(F,{json:()=>DN});var Y={};n.r(Y),n.d(Y,{json:()=>TN});var z={};n.r(z),n.d(z,{json:()=>IN});var B={};n.r(B),n.d(B,{json:()=>EN});var P={};n.r(P),n.d(P,{json:()=>CN});var H={};n.r(H),n.d(H,{json:()=>AN});var j={};n.r(j),n.d(j,{OP_SCOPE_SUFFIX:()=>Li,abs:()=>Uu,acos:()=>Xu,acosh:()=>Zu,add:()=>wu,addN:()=>Qu,all:()=>el,any:()=>tl,argMax:()=>nl,argMin:()=>rl,asin:()=>al,asinh:()=>il,atan:()=>sl,atan2:()=>ol,atanh:()=>ul,avgPool:()=>Nl,avgPool3d:()=>Sl,basicLSTMCell:()=>El,batchNorm:()=>Al,batchNorm2d:()=>Ll,batchNorm3d:()=>$l,batchNorm4d:()=>Ol,batchToSpaceND:()=>Cl,bincount:()=>Rl,booleanMaskAsync:()=>Cd,broadcastArgs:()=>Fl,broadcastTo:()=>Yl,buffer:()=>As,cast:()=>Ls,ceil:()=>zl,clipByValue:()=>Bl,clone:()=>$s,complex:()=>Oi,concat:()=>kl,concat1d:()=>Pl,concat2d:()=>Hl,concat3d:()=>jl,concat4d:()=>Ul,conv1d:()=>Wl,conv2d:()=>ql,conv2dTranspose:()=>Gl,conv3d:()=>Kl,conv3dTranspose:()=>Xl,cos:()=>Zl,cosh:()=>Ql,cosineWindow:()=>Yd,cumprod:()=>ec,cumsum:()=>tc,denseBincount:()=>nc,depthToSpace:()=>rc,depthwiseConv2d:()=>ac,diag:()=>ic,dilation2d:()=>sc,div:()=>Nu,divNoNan:()=>lc,dot:()=>cc,dropout:()=>Rd,einsum:()=>pc,elu:()=>dc,enclosingPowerOfTwo:()=>Fd,equal:()=>oc,erf:()=>hc,euclideanNorm:()=>Dc,exp:()=>Tc,expandDims:()=>Ic,expm1:()=>Ec,eye:()=>Ac,fft:()=>sd,fill:()=>zu,floor:()=>Lc,floorDiv:()=>Mu,fused:()=>f,gather:()=>$c,gatherND:()=>Od,greater:()=>Oc,greaterEqual:()=>Rc,ifft:()=>od,imag:()=>ko,image:()=>Uh,inTopKAsync:()=>zd,irfft:()=>ud,isFinite:()=>Fc,isInf:()=>Yc,isNaN:()=>zc,leakyRelu:()=>Bc,less:()=>Pc,lessEqual:()=>Hc,linalg:()=>qh,linspace:()=>jc,localResponseNormalization:()=>Uc,log:()=>qc,log1p:()=>Wc,logSigmoid:()=>Gc,logSoftmax:()=>Kc,logSumExp:()=>Jc,logicalAnd:()=>Xc,logicalNot:()=>Zc,logicalOr:()=>Qc,logicalXor:()=>ep,losses:()=>Wh,lowerBound:()=>rp,matMul:()=>no,max:()=>wc,maxPool:()=>ap,maxPool3d:()=>ip,maxPoolWithArgmax:()=>sp,maximum:()=>qu,mean:()=>op,meshgrid:()=>cp,min:()=>Mc,minimum:()=>pp,mirrorPad:()=>dp,mod:()=>hp,moments:()=>fp,movingAverage:()=>Ad,mul:()=>Su,multiRNNCell:()=>mp,multinomial:()=>gp,neg:()=>Do,norm:()=>kc,notEqual:()=>yp,oneHot:()=>ro,ones:()=>lp,onesLike:()=>bp,op:()=>$i,outerProduct:()=>xp,pad:()=>vp,pad1d:()=>_p,pad2d:()=>wp,pad3d:()=>Mp,pad4d:()=>Np,pool:()=>kp,pow:()=>Pu,prelu:()=>Dp,print:()=>Os,prod:()=>Tp,rand:()=>Ip,randomGamma:()=>$p,randomNormal:()=>Op,randomStandardNormal:()=>Rp,randomUniform:()=>Fp,range:()=>Yp,real:()=>To,reciprocal:()=>zp,relu:()=>Bp,relu6:()=>Pp,reshape:()=>Ml,reverse:()=>Hp,reverse1d:()=>jp,reverse2d:()=>Up,reverse3d:()=>qp,reverse4d:()=>Wp,rfft:()=>cd,round:()=>Vp,rsqrt:()=>Gp,scalar:()=>Ru,scatterND:()=>Ld,searchSorted:()=>np,selu:()=>Kp,separableConv2d:()=>Jp,setdiff1dAsync:()=>Xp,sigmoid:()=>Dl,sign:()=>Zp,signal:()=>jh,sin:()=>Qp,sinh:()=>ed,slice:()=>Tl,slice1d:()=>td,slice2d:()=>nd,slice3d:()=>rd,slice4d:()=>ad,softmax:()=>id,softplus:()=>Vc,spaceToBatchND:()=>Sp,sparse:()=>Vh,sparseToDense:()=>$d,spectral:()=>Hh,split:()=>ld,sqrt:()=>ku,square:()=>Du,squaredDifference:()=>pd,squeeze:()=>dd,stack:()=>hd,step:()=>fd,stridedSlice:()=>md,string:()=>Gh,sub:()=>Hu,sum:()=>Nc,tan:()=>gd,tanh:()=>Il,tensor:()=>Fi,tensor1d:()=>yd,tensor2d:()=>bd,tensor3d:()=>$o,tensor4d:()=>xd,tensor5d:()=>vd,tensor6d:()=>_d,tile:()=>Cc,topk:()=>wd,transpose:()=>Io,truncatedNormal:()=>Md,unique:()=>Nd,unsortedSegmentSum:()=>Sd,unstack:()=>kd,upperBound:()=>Dd,variable:()=>Td,where:()=>uc,whereAsync:()=>Ed,zeros:()=>up,zerosLike:()=>Tu});var U={};n.r(U),n.d(U,{CSVDataset:()=>sk,Dataset:()=>GS,FileDataSource:()=>bk,TextLineDataset:()=>QS,URLDataSource:()=>xk,array:()=>JS,csv:()=>vk,func:()=>_k,generator:()=>wk,microphone:()=>Nk,version_data:()=>Sk,webcam:()=>Mk,zip:()=>XS});var q={};n.r(q),n.d(q,{addImpl:()=>iD,bincountImpl:()=>XD,bincountReduceImpl:()=>ZD,ceilImpl:()=>tT,concatImpl:()=>oT,equalImpl:()=>UT,expImpl:()=>tI,expm1Impl:()=>sI,floorImpl:()=>MI,gatherNdImpl:()=>CI,gatherV2Impl:()=>LI,greaterEqualImpl:()=>YI,greaterImpl:()=>OI,lessEqualImpl:()=>XI,lessImpl:()=>GI,linSpaceImpl:()=>eE,logImpl:()=>nE,maxImpl:()=>yE,maximumImpl:()=>vE,minimumImpl:()=>EE,multiplyImpl:()=>RT,negImpl:()=>BE,notEqualImpl:()=>GE,prodImpl:()=>oC,rangeImpl:()=>lC,rsqrtImpl:()=>_C,scatterImpl:()=>NC,sigmoidImpl:()=>Wk,simpleAbsImpl:()=>fD,sliceImpl:()=>VD,sparseFillEmptyRowsImpl:()=>UC,sparseReshapeImpl:()=>WC,sparseSegmentReductionImpl:()=>GC,sqrtImpl:()=>QC,squaredDifferenceImpl:()=>rA,stridedSliceImpl:()=>uA,stringNGramsImpl:()=>pA,stringSplitImpl:()=>fA,stringToHashBucketFastImpl:()=>gA,subImpl:()=>dI,tileImpl:()=>_A,topKImpl:()=>SA,transposeImpl:()=>_D,uniqueImpl:()=>AA});var W={};n.r(W),n.d(W,{Abs:()=>Qe,Acos:()=>et,Acosh:()=>tt,AdadeltaOptimizer:()=>Yu,AdagradOptimizer:()=>Bu,AdamOptimizer:()=>ju,AdamaxOptimizer:()=>Wu,Add:()=>nt,AddN:()=>rt,All:()=>at,Any:()=>it,ArgMax:()=>st,ArgMin:()=>ot,Asin:()=>ut,Asinh:()=>lt,Atan:()=>ct,Atan2:()=>dt,Atanh:()=>pt,AvgPool:()=>ht,AvgPool3D:()=>mt,AvgPool3DGrad:()=>gt,AvgPoolGrad:()=>ft,BatchMatMul:()=>yt,BatchToSpaceND:()=>bt,Bincount:()=>xt,BroadcastArgs:()=>_t,BroadcastTo:()=>vt,Callback:()=>JM,CallbackList:()=>rx,Cast:()=>wt,Ceil:()=>Mt,ClipByValue:()=>Nt,Complex:()=>St,ComplexAbs:()=>kt,Concat:()=>Dt,Conv2D:()=>Tt,Conv2DBackpropFilter:()=>It,Conv2DBackpropInput:()=>Et,Conv3D:()=>Ct,Conv3DBackpropFilterV2:()=>At,Conv3DBackpropInputV2:()=>Lt,Cos:()=>$t,Cosh:()=>Ot,CropAndResize:()=>Yt,Cumprod:()=>Rt,Cumsum:()=>Ft,CustomCallback:()=>sx,DataStorage:()=>K,DenseBincount:()=>zt,DepthToSpace:()=>Bt,DepthwiseConv2dNative:()=>Pt,DepthwiseConv2dNativeBackpropFilter:()=>Ht,DepthwiseConv2dNativeBackpropInput:()=>jt,Diag:()=>Ut,Dilation2D:()=>qt,Dilation2DBackpropFilter:()=>Vt,Dilation2DBackpropInput:()=>Wt,ENV:()=>Je,EarlyStopping:()=>QM,Einsum:()=>Kt,Elu:()=>Jt,EluGrad:()=>Xt,Environment:()=>We,Equal:()=>Qt,Erf:()=>Zt,Exp:()=>en,ExpandDims:()=>tn,Expm1:()=>nn,FFT:()=>rn,Fill:()=>an,FlipLeftRight:()=>sn,Floor:()=>on,FloorDiv:()=>un,FromPixels:()=>ia,FusedBatchNorm:()=>ln,FusedConv2D:()=>ua,FusedDepthwiseConv2D:()=>la,GatherNd:()=>pn,GatherV2:()=>cn,GraphModel:()=>mS,Greater:()=>dn,GreaterEqual:()=>hn,History:()=>ix,IFFT:()=>mn,Identity:()=>fn,Imag:()=>gn,InputSpec:()=>ub,IsFinite:()=>yn,IsInf:()=>bn,IsNan:()=>xn,KernelBackend:()=>J,LRN:()=>An,LRNGrad:()=>Ln,LayerVariable:()=>ib,LayersModel:()=>av,LeakyRelu:()=>vn,Less:()=>_n,LessEqual:()=>wn,LinSpace:()=>Mn,Log:()=>Nn,Log1p:()=>Sn,LogSoftmax:()=>En,LogicalAnd:()=>kn,LogicalNot:()=>Dn,LogicalOr:()=>Tn,LogicalXor:()=>In,LowerBound:()=>Cn,Max:()=>$n,MaxPool:()=>Rn,MaxPool3D:()=>Yn,MaxPool3DGrad:()=>zn,MaxPoolGrad:()=>Fn,MaxPoolWithArgmax:()=>Bn,Maximum:()=>On,Mean:()=>Pn,Min:()=>Hn,Minimum:()=>jn,MirrorPad:()=>Un,Mod:()=>qn,MomentumOptimizer:()=>Gu,Multinomial:()=>Wn,Multiply:()=>Vn,Neg:()=>Gn,NonMaxSuppressionV3:()=>Jn,NonMaxSuppressionV4:()=>Xn,NonMaxSuppressionV5:()=>Zn,NotEqual:()=>Kn,OP_SCOPE_SUFFIX:()=>Li,OneHot:()=>er,OnesLike:()=>Qn,Optimizer:()=>Fu,OptimizerConstructors:()=>Ju,Pack:()=>tr,PadV2:()=>nr,Pool:()=>rr,Pow:()=>ar,Prelu:()=>ir,Prod:()=>sr,RMSPropOptimizer:()=>Ku,RNN:()=>c_,Range:()=>or,Rank:()=>ai,Real:()=>ur,RealDiv:()=>Gt,Reciprocal:()=>lr,Reduction:()=>Sh,Relu:()=>cr,Relu6:()=>gr,Reshape:()=>pr,ResizeBilinear:()=>fr,ResizeBilinearGrad:()=>mr,ResizeNearestNeighbor:()=>dr,ResizeNearestNeighborGrad:()=>hr,Reverse:()=>yr,RotateWithOffset:()=>sa,Round:()=>br,Rsqrt:()=>xr,SGDOptimizer:()=>Vu,ScatterNd:()=>vr,SearchSorted:()=>_r,Select:()=>wr,Selu:()=>Mr,Sequential:()=>ov,Sigmoid:()=>Tr,Sign:()=>Dr,Sin:()=>Sr,Sinh:()=>kr,Slice:()=>Nr,Softmax:()=>$r,Softplus:()=>Ir,SpaceToBatchND:()=>Ar,SparseFillEmptyRows:()=>Or,SparseReshape:()=>Rr,SparseSegmentMean:()=>Fr,SparseSegmentSum:()=>Yr,SparseToDense:()=>zr,SplitV:()=>Lr,Sqrt:()=>Er,Square:()=>Pr,SquaredDifference:()=>Br,Step:()=>aa,StridedSlice:()=>Hr,StringNGrams:()=>jr,StringSplit:()=>Ur,StringToHashBucketFast:()=>qr,Sub:()=>Wr,Sum:()=>Cr,SymbolicTensor:()=>lb,Tan:()=>Vr,Tanh:()=>Gr,Tensor:()=>ti,TensorBuffer:()=>Xa,Tile:()=>Kr,TopK:()=>Jr,Transform:()=>Xr,Transpose:()=>Zr,Unique:()=>Qr,Unpack:()=>ea,UnsortedSegmentSum:()=>ta,UpperBound:()=>na,Variable:()=>ri,ZerosLike:()=>ra,_FusedMatMul:()=>oa,abs:()=>Uu,acos:()=>Xu,acosh:()=>Zu,add:()=>wu,addN:()=>Qu,all:()=>el,any:()=>tl,argMax:()=>nl,argMin:()=>rl,asin:()=>al,asinh:()=>il,atan:()=>sl,atan2:()=>ol,atanh:()=>ul,avgPool:()=>Nl,avgPool3d:()=>Sl,backend:()=>No,backend_util:()=>g,basicLSTMCell:()=>El,batchNorm:()=>Al,batchNorm2d:()=>Ll,batchNorm3d:()=>$l,batchNorm4d:()=>Ol,batchToSpaceND:()=>Cl,bincount:()=>Rl,booleanMaskAsync:()=>Cd,broadcastArgs:()=>Fl,broadcastTo:()=>Yl,broadcast_util:()=>o,browser:()=>u,buffer:()=>As,callbacks:()=>eN,cast:()=>Ls,ceil:()=>zl,clipByValue:()=>Bl,clone:()=>$s,complex:()=>Oi,concat:()=>kl,concat1d:()=>Pl,concat2d:()=>Hl,concat3d:()=>jl,concat4d:()=>Ul,constraints:()=>b,conv1d:()=>Wl,conv2d:()=>ql,conv2dTranspose:()=>Gl,conv3d:()=>Kl,conv3dTranspose:()=>Xl,copyRegisteredKernels:()=>_a,cos:()=>Zl,cosh:()=>Ql,cosineWindow:()=>Yd,cumprod:()=>ec,cumsum:()=>tc,customGrad:()=>$u,data:()=>U,denseBincount:()=>nc,deprecationWarn:()=>oo,depthToSpace:()=>rc,depthwiseConv2d:()=>ac,deregisterOp:()=>sN,device_util:()=>a,diag:()=>ic,dilation2d:()=>sc,disableDeprecationWarnings:()=>so,dispose:()=>fo,disposeVariables:()=>uo,div:()=>Nu,divNoNan:()=>lc,dot:()=>cc,dropout:()=>Rd,einsum:()=>pc,elu:()=>dc,enableDebugMode:()=>io,enableProdMode:()=>ao,enclosingPowerOfTwo:()=>Fd,engine:()=>lo,env:()=>Ge,equal:()=>oc,erf:()=>hc,euclideanNorm:()=>Dc,exp:()=>Tc,expandDims:()=>Ic,expm1:()=>Ec,eye:()=>Ac,fft:()=>sd,fill:()=>zu,findBackend:()=>_o,findBackendFactory:()=>wo,floor:()=>Lc,floorDiv:()=>Mu,fused:()=>f,gather:()=>$c,gatherND:()=>Od,gather_util:()=>l,getBackend:()=>xo,getGradient:()=>ma,getKernel:()=>fa,getKernelsForBackend:()=>ga,grad:()=>Iu,grads:()=>Eu,greater:()=>Oc,greaterEqual:()=>Rc,ifft:()=>od,imag:()=>ko,image:()=>Uh,inTopKAsync:()=>zd,initializers:()=>x,input:()=>pv,io:()=>i,irfft:()=>ud,isFinite:()=>Fc,isInf:()=>Yc,isNaN:()=>zc,keep:()=>mo,kernel_impls:()=>y,layers:()=>v,leakyRelu:()=>Bc,less:()=>Pc,lessEqual:()=>Hc,linalg:()=>qh,linspace:()=>jc,loadGraphModel:()=>gS,loadGraphModelSync:()=>yS,loadLayersModel:()=>cv,localResponseNormalization:()=>Uc,log:()=>qc,log1p:()=>Wc,logSigmoid:()=>Gc,logSoftmax:()=>Kc,logSumExp:()=>Jc,logicalAnd:()=>Xc,logicalNot:()=>Zc,logicalOr:()=>Qc,logicalXor:()=>ep,losses:()=>Wh,lowerBound:()=>rp,matMul:()=>no,math:()=>s,max:()=>wc,maxPool:()=>ap,maxPool3d:()=>ip,maxPoolWithArgmax:()=>sp,maximum:()=>qu,mean:()=>op,memory:()=>co,meshgrid:()=>cp,metrics:()=>_,min:()=>Mc,minimum:()=>pp,mirrorPad:()=>dp,mod:()=>hp,model:()=>uv,models:()=>w,moments:()=>fp,movingAverage:()=>Ad,mul:()=>Su,multiRNNCell:()=>mp,multinomial:()=>gp,neg:()=>Do,nextFrame:()=>Xh,norm:()=>kc,notEqual:()=>yp,oneHot:()=>ro,ones:()=>lp,onesLike:()=>bp,op:()=>$i,outerProduct:()=>xp,pad:()=>vp,pad1d:()=>_p,pad2d:()=>wp,pad3d:()=>Mp,pad4d:()=>Np,pool:()=>kp,pow:()=>Pu,prelu:()=>Dp,print:()=>Os,prod:()=>Tp,profile:()=>po,rand:()=>Ip,randomGamma:()=>$p,randomNormal:()=>Op,randomStandardNormal:()=>Rp,randomUniform:()=>Fp,range:()=>Yp,ready:()=>bo,real:()=>To,reciprocal:()=>zp,registerBackend:()=>Mo,registerCallbackConstructor:()=>dv,registerGradient:()=>ba,registerKernel:()=>ya,registerOp:()=>aN,regularizers:()=>M,relu:()=>Bp,relu6:()=>Pp,removeBackend:()=>vo,reshape:()=>Ml,reverse:()=>Hp,reverse1d:()=>jp,reverse2d:()=>Up,reverse3d:()=>qp,reverse4d:()=>Wp,rfft:()=>cd,round:()=>Vp,rsqrt:()=>Gp,scalar:()=>Ru,scatterND:()=>Ld,scatter_util:()=>c,searchSorted:()=>np,selu:()=>Kp,separableConv2d:()=>Jp,sequential:()=>lv,serialization:()=>d,setBackend:()=>yo,setPlatform:()=>So,setdiff1dAsync:()=>Xp,sigmoid:()=>Dl,sign:()=>Zp,signal:()=>jh,sin:()=>Qp,sinh:()=>ed,slice:()=>Tl,slice1d:()=>td,slice2d:()=>nd,slice3d:()=>rd,slice4d:()=>ad,slice_util:()=>p,softmax:()=>id,softplus:()=>Vc,spaceToBatchND:()=>Sp,sparse:()=>Vh,sparseToDense:()=>$d,spectral:()=>Hh,split:()=>ld,sqrt:()=>ku,square:()=>Du,squaredDifference:()=>pd,squeeze:()=>dd,stack:()=>hd,step:()=>fd,stridedSlice:()=>md,string:()=>Gh,sub:()=>Hu,sum:()=>Nc,sumOutType:()=>pi,tan:()=>gd,tanh:()=>Il,tensor:()=>Fi,tensor1d:()=>yd,tensor2d:()=>bd,tensor3d:()=>$o,tensor4d:()=>xd,tensor5d:()=>vd,tensor6d:()=>_d,tensor_util:()=>t,test_util:()=>h,tidy:()=>ho,tile:()=>Cc,time:()=>go,topk:()=>wd,train:()=>Kh,transpose:()=>Io,truncatedNormal:()=>Md,unique:()=>Nd,unregisterGradient:()=>va,unregisterKernel:()=>xa,unsortedSegmentSum:()=>Sd,unstack:()=>kd,upcastType:()=>ci,upperBound:()=>Dd,util:()=>e,valueAndGrad:()=>Cu,valueAndGrads:()=>Au,variable:()=>Td,variableGrads:()=>Lu,version:()=>$P,version_converter:()=>bS,version_core:()=>_u,version_layers:()=>Bx,where:()=>uc,whereAsync:()=>Ed,zeros:()=>up,zerosLike:()=>Tu});var V={};n.r(V),n.d(V,{createAbs:()=>wW,createAccessorNode:()=>S7,createAcos:()=>NW,createAcosh:()=>gK,createAcot:()=>jW,createAcoth:()=>GK,createAcsc:()=>qW,createAcsch:()=>bK,createAdd:()=>pZ,createAddScalar:()=>VW,createAnd:()=>GJ,createApply:()=>vK,createApplyTransform:()=>d8,createArg:()=>GW,createArrayNode:()=>f7,createAsec:()=>MK,createAsech:()=>JW,createAsin:()=>xQ,createAsinh:()=>XW,createAssignmentNode:()=>k7,createAtan:()=>ZW,createAtan2:()=>fZ,createAtanh:()=>eV,createAtomicMass:()=>bU,createAvogadro:()=>xU,createBellNumbers:()=>W0,createBigNumberClass:()=>PH,createBignumber:()=>tV,createBin:()=>NK,createBitAnd:()=>JJ,createBitNot:()=>xV,createBitOr:()=>gZ,createBitXor:()=>ZJ,createBlockNode:()=>m7,createBohrMagneton:()=>Zj,createBohrRadius:()=>aU,createBoltzmann:()=>vU,createBoolean:()=>_V,createCatalan:()=>bZ,createCbrt:()=>eX,createCeil:()=>MQ,createChain:()=>_7,createChainClass:()=>J6,createClassicalElectronRadius:()=>iU,createClone:()=>MV,createColumn:()=>a0,createColumnTransform:()=>S8,createCombinations:()=>DV,createCombinationsWithRep:()=>kK,createCompare:()=>nX,createCompareNatural:()=>_Z,createCompareText:()=>aX,createCompile:()=>z7,createComplex:()=>IV,createComplexClass:()=>pj,createComposition:()=>SQ,createConcat:()=>sX,createConcatTransform:()=>y8,createConditionalNode:()=>g7,createConductanceQuantum:()=>Qj,createConj:()=>CV,createConstantNode:()=>y7,createCos:()=>TK,createCosh:()=>LV,createCot:()=>KK,createCoth:()=>OV,createCoulomb:()=>Jj,createCount:()=>lX,createCreateUnit:()=>M0,createCross:()=>DQ,createCsc:()=>RV,createCsch:()=>EK,createCtranspose:()=>pX,createCube:()=>YV,createCumSum:()=>MZ,createCumSumTransform:()=>M8,createDeepEqual:()=>SZ,createDenseMatrixClass:()=>Sq,createDerivative:()=>r8,createDet:()=>TQ,createDeuteronMass:()=>pU,createDiag:()=>hX,createDiff:()=>DZ,createDiffTransform:()=>m8,createDistance:()=>EQ,createDivide:()=>A0,createDivideScalar:()=>mX,createDot:()=>TZ,createDotDivide:()=>yX,createDotMultiply:()=>AQ,createDotPow:()=>S0,createE:()=>Ej,createEfimovFactor:()=>yU,createEigs:()=>V0,createElectricConstant:()=>Gj,createElectronMass:()=>sU,createElementaryCharge:()=>Xj,createEqual:()=>xX,createEqualScalar:()=>PV,createEqualText:()=>EZ,createErf:()=>HV,createEvaluate:()=>G7,createExp:()=>GV,createExpm:()=>D0,createExpm1:()=>JV,createFactorial:()=>$0,createFalse:()=>Nj,createFaraday:()=>_U,createFermiCoupling:()=>oU,createFft:()=>vX,createFibonacciHeapClass:()=>LQ,createFilter:()=>XV,createFilterTransform:()=>o8,createFineStructure:()=>uU,createFirstRadiation:()=>wU,createFix:()=>FQ,createFlatten:()=>wX,createFloor:()=>$Z,createForEach:()=>eG,createForEachTransform:()=>l8,createFormat:()=>rG,createFraction:()=>JK,createFractionClass:()=>HU,createFunctionAssignmentNode:()=>w7,createFunctionNode:()=>E7,createGamma:()=>I0,createGasConstant:()=>NU,createGcd:()=>NX,createGetMatrixDataType:()=>iG,createGravitationConstant:()=>Uj,createGravity:()=>LU,createHartreeEnergy:()=>lU,createHasNumericValue:()=>kX,createHelp:()=>Q7,createHelpClass:()=>B7,createHex:()=>sG,createHypot:()=>TX,createI:()=>Yj,createIdentity:()=>RZ,createIfft:()=>EX,createIm:()=>oG,createImmutableDenseMatrixClass:()=>YQ,createIndex:()=>s0,createIndexClass:()=>zQ,createIndexNode:()=>D7,createIndexTransform:()=>k8,createInfinity:()=>kj,createIntersect:()=>BQ,createInv:()=>o0,createInverseConductanceQuantum:()=>eU,createInvmod:()=>YZ,createIsInteger:()=>lG,createIsNaN:()=>AK,createIsNegative:()=>gG,createIsNumeric:()=>ZK,createIsPositive:()=>bG,createIsPrime:()=>$K,createIsZero:()=>vG,createKldivergence:()=>f1,createKlitzing:()=>rU,createKron:()=>AX,createLN10:()=>Lj,createLN2:()=>Aj,createLOG10E:()=>Oj,createLOG2E:()=>$j,createLarger:()=>BZ,createLargerEq:()=>$X,createLcm:()=>PQ,createLeafCount:()=>H7,createLeftShift:()=>FX,createLgamma:()=>TG,createLog:()=>PZ,createLog10:()=>EG,createLog1p:()=>jQ,createLog2:()=>AG,createLoschmidt:()=>MU,createLsolve:()=>BX,createLsolveAll:()=>jZ,createLup:()=>O0,createLusolve:()=>t1,createMad:()=>N1,createMagneticConstant:()=>Vj,createMagneticFluxQuantum:()=>tU,createMap:()=>LG,createMapTransform:()=>c8,createMatrix:()=>eJ,createMatrixClass:()=>jU,createMatrixFromColumns:()=>HX,createMatrixFromFunction:()=>nJ,createMatrixFromRows:()=>qZ,createMax:()=>UQ,createMaxTransform:()=>b8,createMean:()=>K0,createMeanTransform:()=>D8,createMedian:()=>a1,createMin:()=>jX,createMinTransform:()=>x8,createMod:()=>cJ,createMode:()=>qX,createMolarMass:()=>CU,createMolarMassC12:()=>AU,createMolarPlanckConstant:()=>SU,createMolarVolume:()=>kU,createMultinomial:()=>F0,createMultiply:()=>VZ,createMultiplyScalar:()=>OG,createNaN:()=>Dj,createNeutronMass:()=>dU,createNode:()=>Z6,createNorm:()=>y1,createNot:()=>PG,createNthRoot:()=>fJ,createNthRoots:()=>VX,createNuclearMagneton:()=>nU,createNull:()=>Sj,createNumber:()=>HG,createNumeric:()=>bJ,createObjectNode:()=>Q6,createOct:()=>jG,createOnes:()=>GX,createOperatorNode:()=>p7,createOr:()=>xJ,createParenthesisNode:()=>d7,createParse:()=>A7,createParser:()=>i8,createParserClass:()=>e8,createPartitionSelect:()=>JX,createPermutations:()=>z0,createPhi:()=>Cj,createPi:()=>Tj,createPickRandom:()=>VG,createPinv:()=>l0,createPlanckCharge:()=>FU,createPlanckConstant:()=>qj,createPlanckLength:()=>$U,createPlanckMass:()=>OU,createPlanckTemperature:()=>YU,createPlanckTime:()=>RU,createPow:()=>c0,createPrint:()=>KG,createProd:()=>wJ,createProtonMass:()=>cU,createQr:()=>GZ,createQuantileSeq:()=>qQ,createQuantumOfCirculation:()=>hU,createRandom:()=>QG,createRandomInt:()=>RK,createRange:()=>JZ,createRangeClass:()=>UU,createRangeNode:()=>b7,createRangeTransform:()=>v8,createRationalize:()=>n8,createRe:()=>eK,createReducedPlanckConstant:()=>Wj,createRelationalNode:()=>h7,createReplacer:()=>kq,createReshape:()=>NJ,createResize:()=>ZX,createResolve:()=>L7,createResultSet:()=>qU,createReviver:()=>x7,createRightArithShift:()=>eZ,createRightLogShift:()=>ZZ,createRotate:()=>D1,createRotationMatrix:()=>v1,createRound:()=>rZ,createRow:()=>WQ,createRowTransform:()=>N8,createRydberg:()=>fU,createSQRT1_2:()=>Rj,createSQRT2:()=>Fj,createSackurTetrode:()=>DU,createSec:()=>tK,createSech:()=>YK,createSecondRadiation:()=>TU,createSetCartesian:()=>GQ,createSetDifference:()=>d0,createSetDistinct:()=>JQ,createSetIntersect:()=>C0,createSetIsSubset:()=>ZQ,createSetMultiplicity:()=>f0,createSetPowerset:()=>e0,createSetSize:()=>eQ,createSetSymDifference:()=>X0,createSetUnion:()=>o1,createSign:()=>rK,createSimplify:()=>U7,createSimplifyCore:()=>F7,createSin:()=>aK,createSinh:()=>BK,createSize:()=>kJ,createSlu:()=>hQ,createSmaller:()=>IJ,createSmallerEq:()=>iZ,createSort:()=>n0,createSpaClass:()=>m0,createSparse:()=>HK,createSparseMatrixClass:()=>iK,createSpeedOfLight:()=>jj,createSplitUnit:()=>oK,createSqrt:()=>jK,createSqrtm:()=>y0,createSquare:()=>lK,createSqueeze:()=>CJ,createStd:()=>w1,createStdTransform:()=>E8,createStefanBoltzmann:()=>IU,createStirlingS2:()=>H0,createString:()=>pK,createSubset:()=>LJ,createSubsetTransform:()=>g8,createSubtract:()=>BJ,createSum:()=>fQ,createSumTransform:()=>_8,createSymbolNode:()=>T7,createSymbolicEqual:()=>W7,createTan:()=>dK,createTanh:()=>UK,createTau:()=>Ij,createThomsonCrossSection:()=>mU,createTo:()=>HJ,createTrace:()=>mQ,createTranspose:()=>jJ,createTrue:()=>Mj,createTypeOf:()=>fK,createTyped:()=>Pq,createUnaryMinus:()=>WK,createUnaryPlus:()=>_W,createUnequal:()=>oZ,createUnitClass:()=>_0,createUnitFunction:()=>U0,createUppercaseE:()=>Bj,createUppercasePi:()=>zj,createUsolve:()=>lZ,createUsolveAll:()=>yQ,createVacuumImpedance:()=>Kj,createVariance:()=>p1,createVarianceTransform:()=>I8,createVersion:()=>Pj,createWeakMixingAngle:()=>gU,createWienDisplacement:()=>EU,createXgcd:()=>qJ,createXor:()=>cZ,createZeros:()=>VJ});var G={};n.r(G),n.d(G,{AccessorNode:()=>G8,AccessorNodeDependencies:()=>S9,ArgumentsError:()=>XX,ArrayNode:()=>B8,ArrayNodeDependencies:()=>P9,AssignmentNode:()=>K8,AssignmentNodeDependencies:()=>W9,BigNumber:()=>T1,BigNumberDependencies:()=>h9,BlockNode:()=>P8,BlockNodeDependencies:()=>Ree,Chain:()=>$8,ChainDependencies:()=>jee,Complex:()=>I1,ComplexDependencies:()=>f9,ConditionalNode:()=>H8,ConditionalNodeDependencies:()=>ite,ConstantNode:()=>j8,ConstantNodeDependencies:()=>ste,DenseMatrix:()=>K1,DenseMatrixDependencies:()=>g9,DimensionError:()=>eq,EDependencies:()=>Sie,FibonacciHeap:()=>s5,FibonacciHeapDependencies:()=>Ine,Fraction:()=>L1,FractionDependencies:()=>y9,FunctionAssignmentNode:()=>V8,FunctionAssignmentNodeDependencies:()=>ote,FunctionNode:()=>Z8,FunctionNodeDependencies:()=>lte,Help:()=>r9,HelpDependencies:()=>jne,ImmutableDenseMatrix:()=>u5,ImmutableDenseMatrixDependencies:()=>Gee,Index:()=>l5,IndexDependencies:()=>Kee,IndexError:()=>tq,IndexNode:()=>J8,IndexNodeDependencies:()=>cte,InfinityDependencies:()=>Jne,LN10:()=>R1,LN10Dependencies:()=>lre,LN2:()=>X1,LN2Dependencies:()=>cre,LOG10E:()=>F1,LOG10EDependencies:()=>pre,LOG2E:()=>z2,LOG2EDependencies:()=>dre,Matrix:()=>Y1,MatrixDependencies:()=>m9,NaNDependencies:()=>Gre,Node:()=>O8,NodeDependencies:()=>v9,ObjectNode:()=>R8,ObjectNodeDependencies:()=>pte,OperatorNode:()=>F8,OperatorNodeDependencies:()=>dte,PIDependencies:()=>kie,ParenthesisNode:()=>Y8,ParenthesisNodeDependencies:()=>hte,Parser:()=>l9,ParserDependencies:()=>aae,Range:()=>H1,RangeDependencies:()=>Mae,RangeNode:()=>U8,RangeNodeDependencies:()=>fte,RelationalNode:()=>z8,RelationalNodeDependencies:()=>mte,ResultSet:()=>j1,ResultSetDependencies:()=>Oee,SQRT1_2:()=>U1,SQRT1_2Dependencies:()=>Yae,SQRT2:()=>e2,SQRT2Dependencies:()=>zae,Spa:()=>I5,SpaDependencies:()=>Mre,SparseMatrix:()=>t3,SparseMatrixDependencies:()=>w9,SymbolNode:()=>X8,SymbolNodeDependencies:()=>ute,Unit:()=>C5,UnitDependencies:()=>vee,_Infinity:()=>O1,_NaN:()=>z1,_false:()=>C1,_null:()=>B1,_true:()=>V1,abs:()=>a2,absDependencies:()=>x9,acos:()=>i2,acosDependencies:()=>k9,acosh:()=>o3,acoshDependencies:()=>D9,acot:()=>s2,acotDependencies:()=>T9,acoth:()=>N3,acothDependencies:()=>I9,acsc:()=>o2,acscDependencies:()=>E9,acsch:()=>u3,acschDependencies:()=>C9,add:()=>D4,addDependencies:()=>L9,addScalar:()=>u2,addScalarDependencies:()=>A9,all:()=>Lie,and:()=>q3,andDependencies:()=>R9,apply:()=>l3,applyDependencies:()=>Y9,applyTransformDependencies:()=>z9,arg:()=>l2,argDependencies:()=>B9,asec:()=>c3,asecDependencies:()=>H9,asech:()=>c2,asechDependencies:()=>j9,asin:()=>Q4,asinDependencies:()=>U9,asinh:()=>p2,asinhDependencies:()=>q9,atan:()=>d2,atan2:()=>T4,atan2Dependencies:()=>G9,atanDependencies:()=>V9,atanh:()=>h2,atanhDependencies:()=>K9,atomicMass:()=>$5,atomicMassDependencies:()=>_ee,avogadro:()=>d6,avogadroDependencies:()=>wee,bellNumbers:()=>E6,bellNumbersDependencies:()=>Iee,bignumber:()=>f2,bignumberDependencies:()=>J9,bin:()=>p3,binDependencies:()=>Eee,bitAnd:()=>W3,bitAndDependencies:()=>Cee,bitNot:()=>m2,bitNotDependencies:()=>Aee,bitOr:()=>I4,bitOrDependencies:()=>Lee,bitXor:()=>V3,bitXorDependencies:()=>$ee,bohrMagneton:()=>O5,bohrMagnetonDependencies:()=>Fee,bohrRadius:()=>h6,bohrRadiusDependencies:()=>Yee,boltzmann:()=>R5,boltzmannDependencies:()=>zee,boolean:()=>g2,booleanDependencies:()=>Bee,catalan:()=>E4,catalanDependencies:()=>Pee,cbrt:()=>G3,cbrtDependencies:()=>Hee,ceil:()=>e5,ceilDependencies:()=>ree,chain:()=>W8,chainDependencies:()=>Uee,classicalElectronRadius:()=>F6,classicalElectronRadiusDependencies:()=>qee,clone:()=>y2,cloneDependencies:()=>Wee,column:()=>w5,columnDependencies:()=>Qee,columnTransformDependencies:()=>ete,combinations:()=>b2,combinationsDependencies:()=>Nee,combinationsWithRep:()=>d3,combinationsWithRepDependencies:()=>tte,compare:()=>K3,compareDependencies:()=>nte,compareNatural:()=>C4,compareNaturalDependencies:()=>rte,compareText:()=>J3,compareTextDependencies:()=>ate,compile:()=>n9,compileDependencies:()=>yte,complex:()=>x2,complexDependencies:()=>bte,composition:()=>t5,compositionDependencies:()=>vte,concat:()=>X3,concatDependencies:()=>_te,concatTransformDependencies:()=>wte,conductanceQuantum:()=>F5,conductanceQuantumDependencies:()=>Mte,config:()=>RH,conj:()=>v2,conjDependencies:()=>pee,cos:()=>h3,cosDependencies:()=>Nte,cosh:()=>_2,coshDependencies:()=>Ste,cot:()=>S3,cotDependencies:()=>kte,coth:()=>w2,cothDependencies:()=>Dte,coulomb:()=>f6,coulombDependencies:()=>Tte,count:()=>Z3,countDependencies:()=>Ete,create:()=>Oie,createAbs:()=>wW,createAccessorNode:()=>S7,createAcos:()=>NW,createAcosh:()=>gK,createAcot:()=>jW,createAcoth:()=>GK,createAcsc:()=>qW,createAcsch:()=>bK,createAdd:()=>pZ,createAddScalar:()=>VW,createAnd:()=>GJ,createApply:()=>vK,createApplyTransform:()=>d8,createArg:()=>GW,createArrayNode:()=>f7,createAsec:()=>MK,createAsech:()=>JW,createAsin:()=>xQ,createAsinh:()=>XW,createAssignmentNode:()=>k7,createAtan:()=>ZW,createAtan2:()=>fZ,createAtanh:()=>eV,createAtomicMass:()=>bU,createAvogadro:()=>xU,createBellNumbers:()=>W0,createBigNumberClass:()=>PH,createBignumber:()=>tV,createBin:()=>NK,createBitAnd:()=>JJ,createBitNot:()=>xV,createBitOr:()=>gZ,createBitXor:()=>ZJ,createBlockNode:()=>m7,createBohrMagneton:()=>Zj,createBohrRadius:()=>aU,createBoltzmann:()=>vU,createBoolean:()=>_V,createCatalan:()=>bZ,createCbrt:()=>eX,createCeil:()=>MQ,createChain:()=>_7,createChainClass:()=>J6,createClassicalElectronRadius:()=>iU,createClone:()=>MV,createColumn:()=>a0,createColumnTransform:()=>S8,createCombinations:()=>DV,createCombinationsWithRep:()=>kK,createCompare:()=>nX,createCompareNatural:()=>_Z,createCompareText:()=>aX,createCompile:()=>z7,createComplex:()=>IV,createComplexClass:()=>pj,createComposition:()=>SQ,createConcat:()=>sX,createConcatTransform:()=>y8,createConditionalNode:()=>g7,createConductanceQuantum:()=>Qj,createConj:()=>CV,createConstantNode:()=>y7,createCos:()=>TK,createCosh:()=>LV,createCot:()=>KK,createCoth:()=>OV,createCoulomb:()=>Jj,createCount:()=>lX,createCreateUnit:()=>M0,createCross:()=>DQ,createCsc:()=>RV,createCsch:()=>EK,createCtranspose:()=>pX,createCube:()=>YV,createCumSum:()=>MZ,createCumSumTransform:()=>M8,createDeepEqual:()=>SZ,createDenseMatrixClass:()=>Sq,createDerivative:()=>r8,createDet:()=>TQ,createDeuteronMass:()=>pU,createDiag:()=>hX,createDiff:()=>DZ,createDiffTransform:()=>m8,createDistance:()=>EQ,createDivide:()=>A0,createDivideScalar:()=>mX,createDot:()=>TZ,createDotDivide:()=>yX,createDotMultiply:()=>AQ,createDotPow:()=>S0,createE:()=>Ej,createEfimovFactor:()=>yU,createEigs:()=>V0,createElectricConstant:()=>Gj,createElectronMass:()=>sU,createElementaryCharge:()=>Xj,createEqual:()=>xX,createEqualScalar:()=>PV,createEqualText:()=>EZ,createErf:()=>HV,createEvaluate:()=>G7,createExp:()=>GV,createExpm:()=>D0,createExpm1:()=>JV,createFactorial:()=>$0,createFalse:()=>Nj,createFaraday:()=>_U,createFermiCoupling:()=>oU,createFft:()=>vX,createFibonacciHeapClass:()=>LQ,createFilter:()=>XV,createFilterTransform:()=>o8,createFineStructure:()=>uU,createFirstRadiation:()=>wU,createFix:()=>FQ,createFlatten:()=>wX,createFloor:()=>$Z,createForEach:()=>eG,createForEachTransform:()=>l8,createFormat:()=>rG,createFraction:()=>JK,createFractionClass:()=>HU,createFunctionAssignmentNode:()=>w7,createFunctionNode:()=>E7,createGamma:()=>I0,createGasConstant:()=>NU,createGcd:()=>NX,createGetMatrixDataType:()=>iG,createGravitationConstant:()=>Uj,createGravity:()=>LU,createHartreeEnergy:()=>lU,createHasNumericValue:()=>kX,createHelp:()=>Q7,createHelpClass:()=>B7,createHex:()=>sG,createHypot:()=>TX,createI:()=>Yj,createIdentity:()=>RZ,createIfft:()=>EX,createIm:()=>oG,createImmutableDenseMatrixClass:()=>YQ,createIndex:()=>s0,createIndexClass:()=>zQ,createIndexNode:()=>D7,createIndexTransform:()=>k8,createInfinity:()=>kj,createIntersect:()=>BQ,createInv:()=>o0,createInverseConductanceQuantum:()=>eU,createInvmod:()=>YZ,createIsInteger:()=>lG,createIsNaN:()=>AK,createIsNegative:()=>gG,createIsNumeric:()=>ZK,createIsPositive:()=>bG,createIsPrime:()=>$K,createIsZero:()=>vG,createKldivergence:()=>f1,createKlitzing:()=>rU,createKron:()=>AX,createLN10:()=>Lj,createLN2:()=>Aj,createLOG10E:()=>Oj,createLOG2E:()=>$j,createLarger:()=>BZ,createLargerEq:()=>$X,createLcm:()=>PQ,createLeafCount:()=>H7,createLeftShift:()=>FX,createLgamma:()=>TG,createLog:()=>PZ,createLog10:()=>EG,createLog1p:()=>jQ,createLog2:()=>AG,createLoschmidt:()=>MU,createLsolve:()=>BX,createLsolveAll:()=>jZ,createLup:()=>O0,createLusolve:()=>t1,createMad:()=>N1,createMagneticConstant:()=>Vj,createMagneticFluxQuantum:()=>tU,createMap:()=>LG,createMapTransform:()=>c8,createMatrix:()=>eJ,createMatrixClass:()=>jU,createMatrixFromColumns:()=>HX,createMatrixFromFunction:()=>nJ,createMatrixFromRows:()=>qZ,createMax:()=>UQ,createMaxTransform:()=>b8,createMean:()=>K0,createMeanTransform:()=>D8,createMedian:()=>a1,createMin:()=>jX,createMinTransform:()=>x8,createMod:()=>cJ,createMode:()=>qX,createMolarMass:()=>CU,createMolarMassC12:()=>AU,createMolarPlanckConstant:()=>SU,createMolarVolume:()=>kU,createMultinomial:()=>F0,createMultiply:()=>VZ,createMultiplyScalar:()=>OG,createNaN:()=>Dj,createNeutronMass:()=>dU,createNode:()=>Z6,createNorm:()=>y1,createNot:()=>PG,createNthRoot:()=>fJ,createNthRoots:()=>VX,createNuclearMagneton:()=>nU,createNull:()=>Sj,createNumber:()=>HG,createNumeric:()=>bJ,createObjectNode:()=>Q6,createOct:()=>jG,createOnes:()=>GX,createOperatorNode:()=>p7,createOr:()=>xJ,createParenthesisNode:()=>d7,createParse:()=>A7,createParser:()=>i8,createParserClass:()=>e8,createPartitionSelect:()=>JX,createPermutations:()=>z0,createPhi:()=>Cj,createPi:()=>Tj,createPickRandom:()=>VG,createPinv:()=>l0,createPlanckCharge:()=>FU,createPlanckConstant:()=>qj,createPlanckLength:()=>$U,createPlanckMass:()=>OU,createPlanckTemperature:()=>YU,createPlanckTime:()=>RU,createPow:()=>c0,createPrint:()=>KG,createProd:()=>wJ,createProtonMass:()=>cU,createQr:()=>GZ,createQuantileSeq:()=>qQ,createQuantumOfCirculation:()=>hU,createRandom:()=>QG,createRandomInt:()=>RK,createRange:()=>JZ,createRangeClass:()=>UU,createRangeNode:()=>b7,createRangeTransform:()=>v8,createRationalize:()=>n8,createRe:()=>eK,createReducedPlanckConstant:()=>Wj,createRelationalNode:()=>h7,createReplacer:()=>kq,createReshape:()=>NJ,createResize:()=>ZX,createResolve:()=>L7,createResultSet:()=>qU,createReviver:()=>x7,createRightArithShift:()=>eZ,createRightLogShift:()=>ZZ,createRotate:()=>D1,createRotationMatrix:()=>v1,createRound:()=>rZ,createRow:()=>WQ,createRowTransform:()=>N8,createRydberg:()=>fU,createSQRT1_2:()=>Rj,createSQRT2:()=>Fj,createSackurTetrode:()=>DU,createSec:()=>tK,createSech:()=>YK,createSecondRadiation:()=>TU,createSetCartesian:()=>GQ,createSetDifference:()=>d0,createSetDistinct:()=>JQ,createSetIntersect:()=>C0,createSetIsSubset:()=>ZQ,createSetMultiplicity:()=>f0,createSetPowerset:()=>e0,createSetSize:()=>eQ,createSetSymDifference:()=>X0,createSetUnion:()=>o1,createSign:()=>rK,createSimplify:()=>U7,createSimplifyCore:()=>F7,createSin:()=>aK,createSinh:()=>BK,createSize:()=>kJ,createSlu:()=>hQ,createSmaller:()=>IJ,createSmallerEq:()=>iZ,createSort:()=>n0,createSpaClass:()=>m0,createSparse:()=>HK,createSparseMatrixClass:()=>iK,createSpeedOfLight:()=>jj,createSplitUnit:()=>oK,createSqrt:()=>jK,createSqrtm:()=>y0,createSquare:()=>lK,createSqueeze:()=>CJ,createStd:()=>w1,createStdTransform:()=>E8,createStefanBoltzmann:()=>IU,createStirlingS2:()=>H0,createString:()=>pK,createSubset:()=>LJ,createSubsetTransform:()=>g8,createSubtract:()=>BJ,createSum:()=>fQ,createSumTransform:()=>_8,createSymbolNode:()=>T7,createSymbolicEqual:()=>W7,createTan:()=>dK,createTanh:()=>UK,createTau:()=>Ij,createThomsonCrossSection:()=>mU,createTo:()=>HJ,createTrace:()=>mQ,createTranspose:()=>jJ,createTrue:()=>Mj,createTypeOf:()=>fK,createTyped:()=>Pq,createUnaryMinus:()=>WK,createUnaryPlus:()=>_W,createUnequal:()=>oZ,createUnit:()=>Y5,createUnitClass:()=>_0,createUnitDependencies:()=>Cte,createUnitFunction:()=>U0,createUppercaseE:()=>Bj,createUppercasePi:()=>zj,createUsolve:()=>lZ,createUsolveAll:()=>yQ,createVacuumImpedance:()=>Kj,createVariance:()=>p1,createVarianceTransform:()=>I8,createVersion:()=>Pj,createWeakMixingAngle:()=>gU,createWienDisplacement:()=>EU,createXgcd:()=>qJ,createXor:()=>cZ,createZeros:()=>VJ,cross:()=>n5,crossDependencies:()=>Ate,csc:()=>M2,cscDependencies:()=>Lte,csch:()=>f3,cschDependencies:()=>$te,ctranspose:()=>Q3,ctransposeDependencies:()=>Rte,cube:()=>N2,cubeDependencies:()=>Fte,cumsum:()=>A4,cumsumDependencies:()=>zte,cumsumTransformDependencies:()=>Bte,deepEqual:()=>L4,deepEqualDependencies:()=>Pte,derivative:()=>p9,derivativeDependencies:()=>Wte,det:()=>r5,detDependencies:()=>yee,deuteronMass:()=>z5,deuteronMassDependencies:()=>Vte,diag:()=>e4,diagDependencies:()=>Gte,diff:()=>$4,diffDependencies:()=>Kte,diffTransformDependencies:()=>Jte,distance:()=>a5,distanceDependencies:()=>Zte,divide:()=>m6,divideDependencies:()=>Hte,divideScalar:()=>t4,divideScalarDependencies:()=>eee,docs:()=>X7,dot:()=>O4,dotDependencies:()=>hee,dotDivide:()=>n4,dotDivideDependencies:()=>Qte,dotMultiply:()=>i5,dotMultiplyDependencies:()=>ene,dotPow:()=>B5,dotPowDependencies:()=>tne,e:()=>E1,eDependencies:()=>nne,efimovFactor:()=>J1,efimovFactorDependencies:()=>rne,eigs:()=>C6,eigsDependencies:()=>hne,electricConstant:()=>P5,electricConstantDependencies:()=>fne,electronMass:()=>g6,electronMassDependencies:()=>mne,elementaryCharge:()=>H5,elementaryChargeDependencies:()=>gne,equal:()=>r4,equalDependencies:()=>tee,equalScalar:()=>S2,equalScalarDependencies:()=>_9,equalText:()=>R4,equalTextDependencies:()=>yne,erf:()=>k2,erfDependencies:()=>bne,evaluate:()=>o9,evaluateDependencies:()=>xne,exp:()=>D2,expDependencies:()=>vne,expm:()=>j5,expm1:()=>T2,expm1Dependencies:()=>wne,expmDependencies:()=>_ne,factorial:()=>y6,factorialDependencies:()=>kee,factory:()=>YH,falseDependencies:()=>Mne,faraday:()=>U5,faradayDependencies:()=>Nne,fermiCoupling:()=>A6,fermiCouplingDependencies:()=>Sne,fft:()=>a4,fftDependencies:()=>Tne,filter:()=>I2,filterDependencies:()=>Ene,filterTransformDependencies:()=>Cne,fineStructure:()=>A1,fineStructureDependencies:()=>Ane,firstRadiation:()=>q5,firstRadiationDependencies:()=>Lne,fix:()=>o5,fixDependencies:()=>iee,flatten:()=>i4,flattenDependencies:()=>ane,floor:()=>F4,floorDependencies:()=>aee,forEach:()=>E2,forEachDependencies:()=>$ne,forEachTransformDependencies:()=>One,format:()=>C2,formatDependencies:()=>see,fraction:()=>k3,fractionDependencies:()=>X9,gamma:()=>W5,gammaDependencies:()=>See,gasConstant:()=>W6,gasConstantDependencies:()=>Rne,gcd:()=>s4,gcdDependencies:()=>Fne,getMatrixDataType:()=>A2,getMatrixDataTypeDependencies:()=>Yne,gravitationConstant:()=>V5,gravitationConstantDependencies:()=>zne,gravity:()=>b6,gravityDependencies:()=>Bne,hartreeEnergy:()=>G5,hartreeEnergyDependencies:()=>Pne,hasNumericValue:()=>o4,hasNumericValueDependencies:()=>Hne,help:()=>u9,helpDependencies:()=>Une,hex:()=>L2,hexDependencies:()=>qne,hypot:()=>u4,hypotDependencies:()=>Wne,i:()=>$1,iDependencies:()=>kne,identity:()=>Y4,identityDependencies:()=>lee,ifft:()=>l4,ifftDependencies:()=>Vne,im:()=>$2,imDependencies:()=>ine,index:()=>M5,indexDependencies:()=>Gne,indexTransformDependencies:()=>Kne,intersect:()=>c5,intersectDependencies:()=>Xne,inv:()=>N5,invDependencies:()=>bee,inverseConductanceQuantum:()=>x6,inverseConductanceQuantumDependencies:()=>Zne,invmod:()=>z4,invmodDependencies:()=>tre,isAccessorNode:()=>iH,isArray:()=>jP,isArrayNode:()=>sH,isAssignmentNode:()=>oH,isBigNumber:()=>YP,isBlockNode:()=>uH,isBoolean:()=>JP,isChain:()=>vH,isCollection:()=>qP,isComplex:()=>zP,isConditionalNode:()=>lH,isConstantNode:()=>cH,isDate:()=>eH,isDenseMatrix:()=>WP,isFraction:()=>BP,isFunction:()=>QP,isFunctionAssignmentNode:()=>pH,isFunctionNode:()=>dH,isHelp:()=>ZP,isIndex:()=>KP,isIndexNode:()=>hH,isInteger:()=>O2,isIntegerDependencies:()=>F9,isMatrix:()=>UP,isNaN:()=>m3,isNaNDependencies:()=>nre,isNegative:()=>R2,isNegativeDependencies:()=>Mee,isNode:()=>fH,isNull:()=>rH,isNumber:()=>FP,isNumeric:()=>D3,isNumericDependencies:()=>oee,isObject:()=>nH,isObjectNode:()=>mH,isOperatorNode:()=>gH,isParenthesisNode:()=>yH,isPositive:()=>F2,isPositiveDependencies:()=>xte,isPrime:()=>g3,isPrimeDependencies:()=>rre,isRange:()=>GP,isRangeNode:()=>bH,isRegExp:()=>tH,isResultSet:()=>XP,isSparseMatrix:()=>VP,isString:()=>HP,isSymbolNode:()=>xH,isUndefined:()=>aH,isUnit:()=>PP,isZero:()=>Y2,isZeroDependencies:()=>cee,kldivergence:()=>H6,kldivergenceDependencies:()=>sre,klitzing:()=>K5,klitzingDependencies:()=>ore,kron:()=>c4,kronDependencies:()=>ure,larger:()=>B4,largerDependencies:()=>Dee,largerEq:()=>p4,largerEqDependencies:()=>Jee,lcm:()=>d5,lcmDependencies:()=>hre,leafCount:()=>a9,leafCountDependencies:()=>fre,leftShift:()=>d4,leftShiftDependencies:()=>mre,lgamma:()=>B2,lgammaDependencies:()=>gre,log:()=>P4,log10:()=>P2,log10Dependencies:()=>yre,log1p:()=>h5,log1pDependencies:()=>bre,log2:()=>H2,log2Dependencies:()=>xre,logDependencies:()=>are,loschmidt:()=>J5,loschmidtDependencies:()=>vre,lsolve:()=>h4,lsolveAll:()=>H4,lsolveAllDependencies:()=>wre,lsolveDependencies:()=>_re,lup:()=>v6,lupDependencies:()=>Nre,lusolve:()=>Y6,lusolveDependencies:()=>kre,mad:()=>G6,madDependencies:()=>Ere,magneticConstant:()=>X5,magneticConstantDependencies:()=>Cre,magneticFluxQuantum:()=>_6,magneticFluxQuantumDependencies:()=>Are,map:()=>j2,mapDependencies:()=>Dre,mapTransformDependencies:()=>Lre,matrix:()=>T3,matrixDependencies:()=>M9,matrixFromColumns:()=>f4,matrixFromColumnsDependencies:()=>sne,matrixFromFunction:()=>I3,matrixFromFunctionDependencies:()=>$re,matrixFromRows:()=>j4,matrixFromRowsDependencies:()=>Ore,max:()=>f5,maxDependencies:()=>Rre,maxTransformDependencies:()=>Fre,mean:()=>L6,meanDependencies:()=>Yre,meanTransformDependencies:()=>zre,median:()=>z6,medianDependencies:()=>Ire,min:()=>m4,minDependencies:()=>Bre,minTransformDependencies:()=>Pre,mod:()=>E3,modDependencies:()=>Qne,mode:()=>g4,modeDependencies:()=>Hre,molarMass:()=>Z5,molarMassC12:()=>w6,molarMassC12Dependencies:()=>Ure,molarMassDependencies:()=>jre,molarPlanckConstant:()=>Q5,molarPlanckConstantDependencies:()=>qre,molarVolume:()=>$6,molarVolumeDependencies:()=>Wre,multinomial:()=>M6,multinomialDependencies:()=>Vre,multiply:()=>U4,multiplyDependencies:()=>fee,multiplyScalar:()=>U2,multiplyScalarDependencies:()=>uee,neutronMass:()=>e6,neutronMassDependencies:()=>Kre,norm:()=>j6,normDependencies:()=>Jre,not:()=>q2,notDependencies:()=>$9,nthRoot:()=>C3,nthRootDependencies:()=>Xre,nthRoots:()=>y4,nthRootsDependencies:()=>Zre,nuclearMagneton:()=>t6,nuclearMagnetonDependencies:()=>Qre,nullDependencies:()=>eae,number:()=>W2,numberDependencies:()=>Z9,numeric:()=>A3,numericDependencies:()=>Q9,oct:()=>V2,octDependencies:()=>tae,ones:()=>b4,onesDependencies:()=>nae,or:()=>L3,orDependencies:()=>rae,parse:()=>Q8,parseDependencies:()=>gte,parser:()=>d9,parserDependencies:()=>iae,partitionSelect:()=>x4,partitionSelectDependencies:()=>Tre,permutations:()=>N6,permutationsDependencies:()=>sae,phi:()=>P1,phiDependencies:()=>oae,pi:()=>Z1,piDependencies:()=>uae,pickRandom:()=>G2,pickRandomDependencies:()=>lae,pinv:()=>S5,pinvDependencies:()=>cae,planckCharge:()=>n6,planckChargeDependencies:()=>pae,planckConstant:()=>O6,planckConstantDependencies:()=>dae,planckLength:()=>r6,planckLengthDependencies:()=>hae,planckMass:()=>S6,planckMassDependencies:()=>fae,planckTemperature:()=>a6,planckTemperatureDependencies:()=>mae,planckTime:()=>U6,planckTimeDependencies:()=>gae,pow:()=>k5,powDependencies:()=>xee,print:()=>K2,printDependencies:()=>yae,prod:()=>$3,prodDependencies:()=>Ite,protonMass:()=>i6,protonMassDependencies:()=>bae,qr:()=>q4,qrDependencies:()=>une,quantileSeq:()=>m5,quantileSeqDependencies:()=>xae,quantumOfCirculation:()=>k6,quantumOfCirculationDependencies:()=>vae,random:()=>J2,randomDependencies:()=>_ae,randomInt:()=>y3,randomIntDependencies:()=>wae,range:()=>W4,rangeDependencies:()=>Zee,rangeTransformDependencies:()=>Nae,rationalize:()=>c9,rationalizeDependencies:()=>Sae,re:()=>X2,reDependencies:()=>lne,reducedPlanckConstant:()=>s6,reducedPlanckConstantDependencies:()=>kae,replacer:()=>Q1,replacerDependencies:()=>Dae,reshape:()=>O3,reshapeDependencies:()=>Tae,resize:()=>v4,resizeDependencies:()=>Iae,resolve:()=>e9,resolveDependencies:()=>jte,reviver:()=>q8,reviverDependencies:()=>Eae,rightArithShift:()=>_4,rightArithShiftDependencies:()=>Cae,rightLogShift:()=>V4,rightLogShiftDependencies:()=>Aae,rotate:()=>K6,rotateDependencies:()=>$ae,rotationMatrix:()=>q6,rotationMatrixDependencies:()=>Lae,round:()=>w4,roundDependencies:()=>nee,row:()=>g5,rowDependencies:()=>Oae,rowTransformDependencies:()=>Rae,rydberg:()=>o6,rydbergDependencies:()=>Fae,sackurTetrode:()=>q1,sackurTetrodeDependencies:()=>Bae,sec:()=>Z2,secDependencies:()=>Pae,sech:()=>b3,sechDependencies:()=>Hae,secondRadiation:()=>D6,secondRadiationDependencies:()=>jae,setCartesian:()=>y5,setCartesianDependencies:()=>Uae,setDifference:()=>D5,setDifferenceDependencies:()=>qae,setDistinct:()=>b5,setDistinctDependencies:()=>Wae,setIntersect:()=>u6,setIntersectDependencies:()=>Vae,setIsSubset:()=>x5,setIsSubsetDependencies:()=>Gae,setMultiplicity:()=>T5,setMultiplicityDependencies:()=>Kae,setPowerset:()=>v5,setPowersetDependencies:()=>Jae,setSize:()=>G4,setSizeDependencies:()=>Xae,setSymDifference:()=>R6,setSymDifferenceDependencies:()=>Zae,setUnion:()=>B6,setUnionDependencies:()=>Qae,sign:()=>Q2,signDependencies:()=>one,simplify:()=>i9,simplifyCore:()=>t9,simplifyCoreDependencies:()=>Ute,simplifyDependencies:()=>qte,sin:()=>e3,sinDependencies:()=>cne,sinh:()=>x3,sinhDependencies:()=>eie,size:()=>R3,sizeDependencies:()=>dee,slu:()=>K4,sluDependencies:()=>Sre,smaller:()=>F3,smallerDependencies:()=>Vee,smallerEq:()=>M4,smallerEqDependencies:()=>Xee,sort:()=>_5,sortDependencies:()=>tie,sparse:()=>v3,sparseDependencies:()=>nie,speedOfLight:()=>l6,speedOfLightDependencies:()=>rie,splitUnit:()=>n3,splitUnitDependencies:()=>aie,sqrt:()=>_3,sqrtDependencies:()=>Xte,sqrtm:()=>E5,sqrtmDependencies:()=>iie,square:()=>r3,squareDependencies:()=>sie,squeeze:()=>Y3,squeezeDependencies:()=>oie,std:()=>V6,stdDependencies:()=>lie,stdTransformDependencies:()=>cie,stefanBoltzmann:()=>c6,stefanBoltzmannDependencies:()=>pie,stirlingS2:()=>T6,stirlingS2Dependencies:()=>Tee,string:()=>a3,stringDependencies:()=>die,subset:()=>z3,subsetDependencies:()=>N9,subsetTransformDependencies:()=>hie,subtract:()=>B3,subtractDependencies:()=>gee,sum:()=>J4,sumDependencies:()=>ire,sumTransformDependencies:()=>fie,symbolicEqual:()=>s9,symbolicEqualDependencies:()=>mie,tan:()=>i3,tanDependencies:()=>gie,tanh:()=>w3,tanhDependencies:()=>yie,tau:()=>W1,tauDependencies:()=>Dne,thomsonCrossSection:()=>p6,thomsonCrossSectionDependencies:()=>bie,to:()=>P3,toDependencies:()=>xie,trace:()=>X4,traceDependencies:()=>vie,transpose:()=>H3,transposeDependencies:()=>Ote,trueDependencies:()=>_ie,typeOf:()=>s3,typeOfDependencies:()=>wie,typed:()=>t2,typedDependencies:()=>b9,unaryMinus:()=>M3,unaryMinusDependencies:()=>mee,unaryPlus:()=>n2,unaryPlusDependencies:()=>Yte,unequal:()=>N4,unequalDependencies:()=>Mie,unit:()=>I6,unitDependencies:()=>Nie,usolve:()=>S4,usolveAll:()=>Z4,usolveAllDependencies:()=>dne,usolveDependencies:()=>pne,vacuumImpedance:()=>A5,vacuumImpedanceDependencies:()=>Die,variance:()=>P6,varianceDependencies:()=>uie,varianceTransformDependencies:()=>Tie,version:()=>G1,versionDependencies:()=>Iie,weakMixingAngle:()=>r2,weakMixingAngleDependencies:()=>Eie,wienDisplacement:()=>L5,wienDisplacementDependencies:()=>Cie,xgcd:()=>j3,xgcdDependencies:()=>ere,xor:()=>k4,xorDependencies:()=>Aie,zeros:()=>U3,zerosDependencies:()=>O9});class K{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class J{refCount(e){return X("refCount")}incRef(e){return X("incRef")}timerAvailable(){return!0}time(e){return X("time")}read(e){return X("read")}readSync(e){return X("readSync")}readToGPU(e,t){return X("readToGPU")}numDataIds(){return X("numDataIds")}disposeData(e,t){return X("disposeData")}write(e,t,n){return X("write")}move(e,t,n,r,a){return X("move")}memory(){return X("memory")}floatPrecision(){return X("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return X("dispose")}}function X(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}function Z(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,ne(e,t,n)}function Q(e,t){if(e.length!==t.length)throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`);let n=e.length,r=0;for(;n>0;)r=Math.random()*n|0,n--,ne(e,n,r),ne(t,n,r)}function ee(e,t,n){return Math.max(e,Math.min(t,n))}function te(e){return e%2==0?e:e+1}function ne(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function re(e){let t=0;for(let n=0;nn+` Shapes ${e} and ${t} must match`))}function ue(e){se(null!=e,(()=>"The input to the tensor constructor must be a non-null value."))}function le(e,t=[],n=!1){if(null==t&&(t=[]),Array.isArray(e)||De(e)&&!n)for(let r=0;r0),n){return new Promise(((r,a)=>{let i=0;const s=()=>{if(e())return void r();i++;const o=t(i);null!=n&&i>=n?a():setTimeout(s,o)};s()}))}function xe(e,t){let n=1,r=-1;for(let t=0;t=0)n*=e[t];else if(-1===e[t]){if(-1!==r)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${t}`);r=t}else if(e[t]<0)throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`);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}`);const a=e.slice();return a[r]=t/n,a}function ve(e,t){const n=t.length;return e=null==e?t.map(((e,t)=>t)):[].concat(e),se(e.every((e=>e>=-n&&e`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)),se(e.every((e=>he(e))),(()=>`All values in axis param must be integers but got axis ${e}`)),e.map((e=>e<0?n+e:e))}function _e(e,t){const n=[],r=[],a=null!=t&&Array.isArray(t)&&0===t.length,i=null==t||a?null:ve(t,e).sort();let s=0;for(let t=0;tt)&&1===e[t]&&(n.push(e[t]),r.push(t)),i[s]<=t&&s++}1!==e[t]&&(n.push(e[t]),r.push(t))}return{newShape:n,keptDims:r}}function we(e,t){let 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 Me(e,t){let 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 Ne(e,t){for(let n=0;nt+=e.length)),t}function Ee(e){return"string"==typeof e||e instanceof String}function Ce(e){return"boolean"==typeof e}function Ae(e){return"number"==typeof e}function Le(e){return Array.isArray(e)?Le(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":Ae(e)?"float32":Ee(e)?"string":Ce(e)?"bool":"float32"}function $e(e){return!!(e&&e.constructor&&e.call&&e.apply)}function Oe(e,t){for(let n=t;n=0;--r)n[r]=n[r+1]*e[r+1];return n}function Fe(e,t,n,r=!1){const a=new Array;if(1===t.length){const i=t[0]*(r?2:1);for(let t=0;te*t))*(r?2:1);for(let t=0;te*t))*(n?2:1);if(0===r)return[];if(r!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return Fe(0,e,t,n)}function ze(e,t){const n=Be(e,t);for(let e=0;ee*t),1);if(null==t||"float32"===t)return Ye(e,new Float32Array(n));if("int32"===t)return Ye(e,new Int32Array(n));if("bool"===t)return Ye(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function He(e){e.forEach((t=>{se(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function je(e,t,n){if(0===t)return 0;if(1===t)return e[0];let r=e[e.length-1];for(let t=0;t{const[t,n]=e.split(":");this.urlFlags[t]=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}.`)}(t,n)}))}}function Ve(e){const t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((e,...n)=>(function(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}(t,n[0],n[1]),n.join("=")))),t}function Ge(){return Je}let Ke,Je=null;function Xe(){if(null==Ke){let e;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}Ke=e}return Ke}function Ze(e,t){const n=function(){const e=Xe();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(n.has(e))return n.get(e);{const r=t();return n.set(e,r),n.get(e)}}const Qe="Abs",et="Acos",tt="Acosh",nt="Add",rt="AddN",at="All",it="Any",st="ArgMax",ot="ArgMin",ut="Asin",lt="Asinh",ct="Atan",pt="Atanh",dt="Atan2",ht="AvgPool",ft="AvgPoolGrad",mt="AvgPool3D",gt="AvgPool3DGrad",yt="BatchMatMul",bt="BatchToSpaceND",xt="Bincount",vt="BroadcastTo",_t="BroadcastArgs",wt="Cast",Mt="Ceil",Nt="ClipByValue",St="Complex",kt="ComplexAbs",Dt="Concat",Tt="Conv2D",It="Conv2DBackpropFilter",Et="Conv2DBackpropInput",Ct="Conv3D",At="Conv3DBackpropFilterV2",Lt="Conv3DBackpropInputV2",$t="Cos",Ot="Cosh",Rt="Cumprod",Ft="Cumsum",Yt="CropAndResize",zt="DenseBincount",Bt="DepthToSpace",Pt="DepthwiseConv2dNative",Ht="DepthwiseConv2dNativeBackpropFilter",jt="DepthwiseConv2dNativeBackpropInput",Ut="Diag",qt="Dilation2D",Wt="Dilation2DBackpropInput",Vt="Dilation2DBackpropFilter",Gt="RealDiv",Kt="Einsum",Jt="Elu",Xt="EluGrad",Zt="Erf",Qt="Equal",en="Exp",tn="ExpandDims",nn="Expm1",rn="FFT",an="Fill",sn="FlipLeftRight",on="Floor",un="FloorDiv",ln="FusedBatchNorm",cn="GatherV2",pn="GatherNd",dn="Greater",hn="GreaterEqual",fn="Identity",mn="IFFT",gn="Imag",yn="IsFinite",bn="IsInf",xn="IsNan",vn="LeakyRelu",_n="Less",wn="LessEqual",Mn="LinSpace",Nn="Log",Sn="Log1p",kn="LogicalAnd",Dn="LogicalNot",Tn="LogicalOr",In="LogicalXor",En="LogSoftmax",Cn="LowerBound",An="LRN",Ln="LRNGrad",$n="Max",On="Maximum",Rn="MaxPool",Fn="MaxPoolGrad",Yn="MaxPool3D",zn="MaxPool3DGrad",Bn="MaxPoolWithArgmax",Pn="Mean",Hn="Min",jn="Minimum",Un="MirrorPad",qn="Mod",Wn="Multinomial",Vn="Multiply",Gn="Neg",Kn="NotEqual",Jn="NonMaxSuppressionV3",Xn="NonMaxSuppressionV4",Zn="NonMaxSuppressionV5",Qn="OnesLike",er="OneHot",tr="Pack",nr="PadV2",rr="Pool",ar="Pow",ir="Prelu",sr="Prod",or="Range",ur="Real",lr="Reciprocal",cr="Relu",pr="Reshape",dr="ResizeNearestNeighbor",hr="ResizeNearestNeighborGrad",fr="ResizeBilinear",mr="ResizeBilinearGrad",gr="Relu6",yr="Reverse",br="Round",xr="Rsqrt",vr="ScatterNd",_r="SearchSorted",wr="Select",Mr="Selu",Nr="Slice",Sr="Sin",kr="Sinh",Dr="Sign",Tr="Sigmoid",Ir="Softplus",Er="Sqrt",Cr="Sum",Ar="SpaceToBatchND",Lr="SplitV",$r="Softmax",Or="SparseFillEmptyRows",Rr="SparseReshape",Fr="SparseSegmentMean",Yr="SparseSegmentSum",zr="SparseToDense",Br="SquaredDifference",Pr="Square",Hr="StridedSlice",jr="StringNGrams",Ur="StringSplit",qr="StringToHashBucketFast",Wr="Sub",Vr="Tan",Gr="Tanh",Kr="Tile",Jr="TopK",Xr="Transform",Zr="Transpose",Qr="Unique",ea="Unpack",ta="UnsortedSegmentSum",na="UpperBound",ra="ZerosLike",aa="Step",ia="FromPixels",sa="RotateWithOffset",oa="_FusedMatMul",ua="FusedConv2D",la="FusedDepthwiseConv2D";function ca(...e){Ge().getBool("IS_TEST")||Ge().getBool("PROD")||console.warn(...e)}function pa(...e){Ge().getBool("IS_TEST")||Ge().getBool("PROD")||console.log(...e)}const da=Ze("kernelRegistry",(()=>new Map)),ha=Ze("gradRegistry",(()=>new Map));function fa(e,t){const n=wa(e,t);return da.get(n)}function ma(e){return ha.get(e)}function ga(e){const t=da.entries(),n=[];for(;;){const{done:r,value:a}=t.next();if(r)break;const[i,s]=a,[o]=i.split("_");o===e&&n.push(s)}return n}function ya(e){const{kernelName:t,backendName:n}=e,r=wa(t,n);da.has(r)&&ca(`The kernel '${t}' for backend '${n}' is already registered`),da.set(r,e)}function ba(e){const{kernelName:t}=e;ha.has(t)&&Ge().getBool("DEBUG")&&ca(`Overriding the gradient for '${t}'`),ha.set(t,e)}function xa(e,t){const n=wa(e,t);if(!da.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);da.delete(n)}function va(e){if(!ha.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);ha.delete(e)}function _a(e,t){ga(e).forEach((e=>{ya(Object.assign({},e,{backendName:t}))}))}function wa(e,t){return`${t}_${e}`}var Ma=n(3720);const Na=n.n(Ma)()||Ma;function Sa(e){return Na.fromString(e,!0,16)}const ka=Sa("c3a5c85c97cb3127"),Da=Sa("b492b66fbe98f273"),Ta=Sa("9ae16a3b2f90404f");function Ia(e){return e.xor(e.shru(47))}function Ea(e,t,n){const r=e.slice(t,t+n);return Na.fromBytes(Array.from(r),!0,!0)}function Ca(e,t){return Ea(e,t,8)}function Aa(e,t){return Ea(e,t,4)}function La(e,t){return 0===t?e:e.shru(t).or(e.shl(64-t))}function $a(e,t,n=Sa("9ddfea08eb382d69")){let r=e.xor(t).mul(n);r=r.xor(r.shru(47));let a=t.xor(r).mul(n);return a=a.xor(a.shru(47)),a=a.mul(n),a}function Oa(e,t,n,r){return function(e,t,n,r,a,i){a=a.add(e),i=La(i.add(a).add(r),21);const s=a;return a=(a=a.add(t)).add(n),i=i.add(La(a,44)),[a.add(r),i.add(s)]}(Ca(e,t),Ca(e,t+8),Ca(e,t+16),Ca(e,t+24),n,r)}function Ra(e,t=e.length){const n=Na.fromNumber(81,!0);if(t<=32)return t<=16?function(e,t=e.length){if(t>=8){const n=Ta.add(2*t),r=Ca(e,0).add(Ta),a=Ca(e,t-8);return $a(La(a,37).mul(n).add(r),La(r,25).add(a).mul(n),n)}if(t>=4){const n=Ta.add(2*t);return $a(Aa(e,0).shl(3).add(t),Aa(e,t-4),n)}if(t>0){const n=e[0]+(e[t>>1]<<8),r=t+(e[t-1]<<2);return Ia(Ta.mul(n).xor(ka.mul(r))).mul(Ta)}return Ta}(e,t):function(e,t=e.length){const n=Ta.add(2*t),r=Ca(e,0).mul(Da),a=Ca(e,8),i=Ca(e,t-8).mul(n),s=Ca(e,t-16).mul(Ta);return $a(La(r.add(a),43).add(La(i,30)).add(s),r.add(La(a.add(Ta),18)).add(i),n)}(e,t);if(t<=64)return function(e,t=e.length){const n=Ta.add(2*t),r=Ca(e,0).mul(Ta),a=Ca(e,8),i=Ca(e,t-8).mul(n),s=Ca(e,t-16).mul(Ta),o=La(r.add(a),43).add(La(i,30)).add(s),u=$a(o,r.add(La(a.add(Ta),18)).add(i),n),l=Ca(e,16).mul(n),c=Ca(e,24),p=o.add(Ca(e,t-32)).mul(n),d=u.add(Ca(e,t-24)).mul(n);return $a(La(l.add(c),43).add(La(p,30)).add(d),l.add(La(c.add(r),18)).add(p),n)}(e,t);let r=n,a=n.mul(Da).add(113),i=Ia(a.mul(Ta).add(113)).mul(Ta),s=[Na.UZERO,Na.UZERO],o=[Na.UZERO,Na.UZERO];r=r.mul(Ta).add(Ca(e,0));let u=0;const l=64*(t-1>>6),c=l+(t-1&63)-63;do{r=La(r.add(a).add(s[0]).add(Ca(e,u+8)),37).mul(Da),a=La(a.add(s[1]).add(Ca(e,u+48)),42).mul(Da),r=r.xor(o[1]),a=a.add(s[0]).add(Ca(e,u+40)),i=La(i.add(o[0]),33).mul(Da),s=Oa(e,u,s[1].mul(Da),r.add(o[0])),o=Oa(e,u+32,i.add(o[1]),a.add(Ca(e,u+16))),[i,r]=[r,i],u+=64}while(u!==l);const p=Da.add(i.and(255).shl(1));return u=c,o[0]=o[0].add(t-1&63),s[0]=s[0].add(o[0]),o[0]=o[0].add(s[0]),r=La(r.add(a).add(s[0]).add(Ca(e,u+8)),37).mul(p),a=La(a.add(s[1]).add(Ca(e,u+48)),42).mul(p),r=r.xor(o[1].mul(9)),a=a.add(s[0].mul(9).add(Ca(e,u+40))),i=La(i.add(o[0]),33).mul(p),s=Oa(e,u,s[1].mul(p),r.add(o[0])),o=Oa(e,u+32,i.add(o[1]),a.add(Ca(e,u+16))),[i,r]=[r,i],$a($a(s[0],o[0],p).add(Ia(a).mul(ka)).add(i),$a(s[1],o[1],p).add(r),p)}function Fa(e,t){return"string"===t?Pa(e):Ya([e],t)}function Ya(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=le(e)),Ge().getBool("DEBUG")&&Ne(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){const t=new Uint8Array(e.length);for(let n=0;n{r=n()};let i;const s=za();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(a);else{a();for(const e of r)e.dataSync();i=Promise.resolve({kernelMs:za()-s})}if(Ge().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t{Ua(t,n.dtype,e)}))}return{kernelName:e,outputs:r,inputs:t,timeMs:i.then((e=>e.kernelMs)),extraInfo:i.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:r,inputs:a,extraInfo:i}=e;n.forEach((e=>{Promise.all([e.data(),r,i]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],a,n[2])}))}))}}function Ua(e,t,n){if("float32"!==t)return!1;for(let t=0;t0?r:""} `}}console.log(`%c${o}\t%c${s}\t%c${u}D ${c}\t%c${l}\t%c${p}\t%c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}function Wa(e,t,n,r){const a=Re(t),i=function(e,t,n,r){const a=ce(t),i=r[r.length-1],s=new Array(i).fill(0),o=t.length,u="complex64"===n?Ja(e):e;if(o>1)for(let e=0;e
" "+e)).join("\n")),u.join("\n")}function Va(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(7))} + ${parseFloat(e[1].toFixed(7))}j`:Ee(e)?`'${e}'`:"bool"===n?Ga(e):parseFloat(e.toFixed(7)).toString(),ye(r,t)}function Ga(e){return 0===e?"false":"true"}function Ka(e,t,n,r,a,i=!0){const s="complex64"===n?2:1,o=t[0],u=t.length;if(0===u)return"complex64"===n?[Va(Ja(e)[0],0,n)]:"bool"===n?[Ga(e[0])]:[e[0].toString()];if(1===u){if(o>20){const t=3*s;let r=Array.from(e.slice(0,t)),i=Array.from(e.slice((o-3)*s,o*s));return"complex64"===n&&(r=Ja(r),i=Ja(i)),["["+r.map(((e,t)=>Va(e,a[t],n))).join(", ")+", ..., "+i.map(((e,t)=>Va(e,a[o-3+t],n))).join(", ")+"]"]}return["["+("complex64"===n?Ja(e):Array.from(e)).map(((e,t)=>Va(e,a[t],n))).join(", ")+"]"]}const l=t.slice(1),c=r.slice(1),p=r[0]*s,d=[];if(o>20){for(let t=0;t<3;t++){const r=t*p,i=r+p;d.push(...Ka(e.slice(r,i),l,n,c,a,!1))}d.push("...");for(let t=o-3;t`Length of values '${e}' does not match the size inferred by the shape '${this.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||Me(t,this.size),this.strides=Re(e)}set(e,...t){0===t.length&&(t=[0]),se(t.length===this.rank,(()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`));const n=this.locToIndex(t);this.values[n]=e}get(...e){0===e.length&&(e=[0]);let t=0;for(const n of e){if(n<0||n>=this.shape[t]){const t=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(t)}t++}let n=e[e.length-1];for(let t=0;tHa(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}dataToGPU(e){return this.throwIfDisposed(),Za().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=Za().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>Ha(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}async bytes(){this.throwIfDisposed();const e=await Za().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(Za().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Qa.print(this,e)}clone(){return this.throwIfDisposed(),Qa.clone(this)}toString(e=!1){return Wa(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Qa.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),Za().makeVariable(this,e,t,n)}}function ni(){return Ze("Tensor",(()=>ti))}Object.defineProperty(ti,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),ni();class ri extends ti{constructor(e,t,n,r){super(e.shape,e.dtype,e.dataId,r),this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!de(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Za().disposeTensor(this),this.dataId=e.dataId,Za().incRef(this,null)}dispose(){Za().disposeVariable(this),this.isDisposedInternal=!0}}var ai,ii,si,oi,ui;Object.defineProperty(ri,Symbol.hasInstance,{value:e=>e instanceof ti&&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"}(ai||(ai={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(ii||(ii={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(si||(si={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(oi||(oi={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(ui||(ui={}));const li={float32:oi,int32:ii,bool:si,complex64:ui};function ci(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return li[e][t]}function pi(e){return ci(e,"int32")}function di(e,t){if(e.dtype===t.dtype)return[e,t];const n=ci(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function hi(e,t){se(e.dtype===t.dtype,(()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`))}function fi(e,t){return t.some((t=>t.id===e.id))}function mi(e){const t=[];return gi(e,t,new Set),t}function gi(e,t,n){if(null==e)return;if(e instanceof ti)return void t.push(e);if(r=e,!Array.isArray(r)&&"object"!=typeof r)return;var r;const a=e;for(const e in a){const r=a[e];n.has(r)||(n.add(r),gi(r,t,n))}}function yi(e){return null!=e.kernelName}class bi{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map((e=>e.name))))}}}dispose(){for(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class xi{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new bi}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const e=this.getSortedBackends();for(let t=0;t{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){ga(e).forEach((t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])}))}initializeBackend(e){const t=this.registryFactory[e];if(null==t)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const n=t.factory();if(!n||n instanceof J||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,r=n.then((n=>!(t(tthis.registryFactory[t].priority-this.registryFactory[e].priority))}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;tthis.startScope(r)),(()=>this.endScope(n)),(()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(e,t,n){e();try{const e=n();return t(),e}catch(e){throw t(),e}}nextTensorId(){return xi.nextTensorId++}nextVariableId(){return xi.nextVariableId++}clone(e){const t=_i.runKernel(fn,{x:e}),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],(e=>({x:()=>{const t={x:e};return _i.runKernel(wt,t,{dtype:"float32"})}})),[],{}),t}runKernel(e,t,n){if(null==this.backendName&&this.backend,null==fa(e,this.backendName))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){const r=this.backend.numDataIds();let a=0;n.forEach((e=>{a+="complex64"===e.dtype?3:1}));const i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],s=r-t-a-i;if(s>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${s} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const r=this.isTapeOn(),a=this.state.numBytes,i=this.state.numTensors;let s,o;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;const u=yi(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(yi(e)){const{kernelName:t,inputs:a,attrs:i}=e;null==this.backendName&&this.backend;const u=fa(t,this.backendName);se(null!=u,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),s=()=>{const e=this.backend.numDataIds();o=u.kernelFunc({inputs:a,attrs:i,backend:this.backend});const s=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,s);const l=s.map((e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e)));if(r){const e=this.getTensorsForGradient(t,a,l);n=this.saveTensorsForBackwardMode(e)}return l}}else{const{forwardFunc:t}=e,a=e=>{r&&(n=e.map((e=>this.keep(this.clone(e)))))};s=()=>{const e=this.backend.numDataIds();o=this.tidy((()=>t(this.backend,a)));const n=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(u,e,n),n}}const{inputs:l,attrs:c}=e,p=yi(e)?null:e.backwardsFunc;let d;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(d=this.profiler.profileKernel(u,l,(()=>s())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(d),t=d.outputs):t=s()})),r&&this.addTapeNode(u,l,t,p,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:u,bytesAdded:this.state.numBytes-a,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(l).map((e=>null!=l[e]?l[e].shape:null)),outputShapes:t.map((e=>e.shape)),kernelTimeMs:d.timeMs,extraInfo:d.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){const t=e.map((e=>this.keep(this.clone(e))));return t}getTensorsForGradient(e,t,n){const r=ma(e);if(null!=r){const e=r.inputsToSave||[],a=r.outputsToSave||[];let i;r.saveAllInputs?(se(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),i=Object.keys(t).map((e=>t[e]))):i=e.map((e=>t[e]));const s=n.filter(((e,t)=>a[t]));return i.concat(s)}return[]}makeTensor(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;let a=e;"string"===n&&Ee(e[0])&&(a=e.map((e=>Pa(e))));const i=r.write(a,t,n),s=new ti(t,n,i,this.nextTensorId());if(this.trackTensor(s,r),"string"===n){const e=this.state.tensorInfo.get(i),t=Ie(a);this.state.numBytes+=t-e.bytes,e.bytes=t}return s}makeTensorFromDataId(e,t,n,r){const a={dataId:e,shape:t,dtype:n=n||"float32"};return this.makeTensorFromTensorInfo(a,r)}makeTensorFromTensorInfo(e,t){const{dataId:n,shape:r,dtype:a}=e,i=new ti(r,a,n,this.nextTensorId());return this.trackTensor(i,t),i}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));const a=new ri(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw new Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*Te(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof ri||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){const t=e.size*Te(e.dtype);this.state.numBytes-=t}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]}memory(){const e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;const t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map((e=>e.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const e of this.state.activeProfile.kernels)e.kernelTimeMs=await e.kernelTimeMs,e.extraInfo=await e.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(e,t,n,r,a,i){const s={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},o=ma(e);null!=o&&(r=o.gradFunc),null!=r&&(s.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=Be(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],a,i))),this.state.activeTape.push(s)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=mi(e),n=new Set(t.map((e=>e.id)));for(let e=0;e{e.kept||e.scopeId!==r.id||this.track(e)}))}gradients(e,t,n,r=!1){if(se(t.length>0,(()=>"gradients() received an empty list of xs.")),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const a=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));se(a instanceof ti,(()=>"The result y returned by f() must be a tensor."));const i=function(e,t,n){const r={},a={};for(let e=0;er[e.id]=!0)),o=!0,a[i.id]=!0;break}if(o)break}}const i={};i[n.id]=!0;const s={};for(let t=e.length-1;t>=0;t--){const n=e[t],r=n.inputs;for(let e=0;e0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",(()=>{const e={};e[a.id]=null==n?function(e){const t=ze(ce(e),"float32");return _i.makeTensor(t,e,"float32")}(a.shape):n,function(e,t,n,r){for(let a=t.length-1;a>=0;a--){const i=t[a],s=[];if(i.outputs.forEach((t=>{const n=e[t.id];null!=n?s.push(n):s.push(null)})),null==i.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${i.kernelName}.`);const o=i.gradient(s);for(const t in i.inputs){if(!(t in o))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(o)}.`);const a=n((()=>o[t]()));if("float32"!==a.dtype)throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${a.dtype}'`);const s=i.inputs[t];if(!de(a.shape,s.shape))throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input '${t}' has shape '${a.shape}', which does not match the shape of the input '${s.shape}'`);if(null==e[s.id])e[s.id]=a;else{const t=e[s.id];e[s.id]=r(t,a),t.dispose()}}}}(e,i,(e=>this.tidy(e)),wi);const r=t.map((t=>e[t.id]));return 0===this.state.gradientDepth&&(this.state.activeTape.forEach((e=>{for(const t of e.saved)t.dispose()})),this.state.activeTape=null),{value:a,grads:r}}))}customGrad(e){return se($e(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;se(t.every((e=>e instanceof ti)),(()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors"));const r={};return t.forEach(((e,t)=>{r[t]=e})),this.runKernelFunc({forwardFunc:(r,a)=>(n=e(...t,a),se(n.value instanceof ti,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),se($e(n.gradFunc),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")),n.value),backwardsFunc:(e,r)=>{const a=n.gradFunc(e,r),i=Array.isArray(a)?a:[a];se(i.length===t.length,(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).")),se(i.every((e=>e instanceof ti)),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."));const s={};return i.forEach(((e,t)=>{s[t]=()=>e})),s},inputs:r})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){const t=za(),n=await this.backend.time(e);return n.wallMs=za()-t,n}track(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new bi;for(const e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function vi(){const e=Xe();if(null==e._tfengine){const t=new We(e);e._tfengine=new xi(t)}var t;return t=e._tfengine.ENV,Je=t,Za=()=>e._tfengine,e._tfengine}xi.nextTensorId=0,xi.nextVariableId=0;const _i=vi();function wi(e,t){const n={a:e,b:t};return _i.runKernel(nt,n)}let Mi;function Ni(e){Mi=e}function Si(e){if(void 0!==Mi)return Mi;if(e||"undefined"!=typeof navigator&&null!=navigator){if(e||(e=navigator),"ReactNative"===e.product)return!0;const t=e.userAgent||e.vendor||("undefined"!=typeof window?window.opera:"");if(!t){const t=e;return t.userAgentData&&t.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}function ki(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}const Di=Ge();function Ti(e,t){let n=e;if(De(e))return"string"===t?[]:[e.length];if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||De(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&Ge().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&Ii(e,r,[]),r}function Ii(e,t,n){if(n=n||[],!Array.isArray(e)&&!De(e))return void se(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));se(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),se(e.length===t[0],(()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`));const r=t.slice(1);for(let t=0;t=0&&(a=r),Ei(r,a,t,n),null==e||!De(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){const r=null==e?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${r}'`)}const i=Ti(e,a);De(e)||Array.isArray(e)||(e=[e]);const s="string"!==a?Ya(e,a):le(e,[],!0);return _i.makeTensor(s,i,a)}function Ai(e,t,n,r="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map(((e,a)=>Ci(e,`${t}[${a}]`,n,r)))}Di.registerFlag("DEBUG",(()=>!1),(e=>{e&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")})),Di.registerFlag("IS_BROWSER",(()=>ki())),Di.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),Di.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),Di.registerFlag("PROD",(()=>!1)),Di.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>Di.getBool("DEBUG"))),Di.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),Di.registerFlag("IS_TEST",(()=>!1)),Di.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>!0)),Di.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),Di.registerFlag("ENGINE_COMPILE_ONLY",(()=>!1));const Li="__op";function $i(e){const 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.`);let n=t[0];const r=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=Li;const a=(...e)=>{_i.startScope(n);try{const t=r(...e);return qe(t)&&console.error("Cannot return a Promise inside of tidy."),_i.endScope(t),t}catch(e){throw _i.endScope(null),e}};return Object.defineProperty(a,"name",{value:n,configurable:!0}),a}const Oi=$i({complex_:function(e,t){const n=Ci(e,"real","complex"),r=Ci(t,"imag","complex");oe(n.shape,r.shape,`real and imag shapes, ${n.shape} and ${r.shape}, must match in call to tf.complex().`);const a={real:n,imag:r};return _i.runKernel(St,a)}});function Ri(e,t,n,r){if(null==r&&(r=Le(e)),"complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!De(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){He(t);const e=ce(t),r=ce(n);se(e===r,(()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${r}`));for(let e=0;e`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return De(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?Ya(e,r):le(e,[],!0),_i.makeTensor(e,t,r)}function Fi(e,t,n){return Ri(e,t,Ti(e,n),n)}const Yi={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};async function zi(e,t){const n=[],r=[],a=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);for(let i=0;i{const t=await o.bytes(),n=t.reduce(((e,t)=>e+t.length),0)+4*t.length,r=new Uint8Array(n);let a=0;for(let e=0;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}`)}));const r=new Uint8Array(t);let a=0;return n.forEach((e=>{r.set(new Uint8Array(e.buffer),a),a+=e.byteLength})),r.buffer}const Hi="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function ji(e){return Hi?Buffer.byteLength(e):new Blob([e]).size}function Ui(e){if(1===e.length)return e[0];let t=0;e.forEach((e=>{t+=e.byteLength}));const n=new Uint8Array(t);let r=0;return e.forEach((e=>{n.set(new Uint8Array(e),r),r+=e.byteLength})),n.buffer}function qi(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);const t=e.split("/");return t[t.length-1]}function Wi(e,t){const n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),n}async function Vi(e,t){const n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),null!=e.weightsManifest){const[r,a]=await t(e.weightsManifest);n.weightSpecs=r,n.weightData=a}return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),n}function Gi(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:ji(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:ji(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:e.weightData.byteLength}}function Ki(){const e=function(){const e=e=>{let t=e<<13,n=0;for(;0==(8388608&t);)n-=8388608,t<<=1;return t&=-8388609,n+=947912704,t|n},t=new Uint32Array(2048);t[0]=0;for(let n=1;n<1024;n++)t[n]=e(n);for(let e=1024;e<2048;e++)t[e]=939524096+(e-1024<<13);return t}(),t=function(){const e=new Uint32Array(64);e[0]=0,e[31]=1199570944,e[32]=2147483648,e[63]=3347054592;for(let t=1;t<31;t++)e[t]=t<<23;for(let t=33;t<63;t++)e[t]=2147483648+(t-32<<23);return e}(),n=function(){const e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}();return r=>{const a=new ArrayBuffer(4*r.length),i=new Uint32Array(a);for(let a=0;a>10]+(1023&s)]+t[s>>10];i[a]=o}return new Float32Array(a)}}class Ji{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==Ji.instance&&(Ji.instance=new Ji),Ji.instance}static registerSaveRouter(e){Ji.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Ji.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Ji.getHandlers(e,"save")}static getLoadHandlers(e,t){return Ji.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?Ji.getInstance().loadRouters:Ji.getInstance().saveRouters).forEach((t=>{const a=t(e,n);null!==a&&r.push(a)})),r}}const Xi=e=>Ji.registerSaveRouter(e),Zi=e=>Ji.registerLoadRouter(e),Qi=e=>Ji.getSaveHandlers(e),es=(e,t)=>Ji.getLoadHandlers(e,t),ts="tensorflowjs",ns="models_store",rs="model_info_store";function as(){if(!Ge().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self: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 is(e){const t=e.result;t.createObjectStore(ns,{keyPath:"modelPath"}),t.createObjectStore(rs,{keyPath:"modelPath"})}class ss{constructor(e){if(this.indexedDB=as(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise(((e,n)=>{const r=this.indexedDB.open(ts,1);r.onupgradeneeded=()=>is(r),r.onsuccess=()=>{const a=r.result;if(null==t){const t=a.transaction(ns,"readonly"),r=t.objectStore(ns).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return a.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(a.close(),n(r.error)),t.oncomplete=()=>a.close()}else{const r=Gi(t),i=a.transaction(rs,"readwrite");let s=i.objectStore(rs);const o=s.put({modelPath:this.modelPath,modelArtifactsInfo:r});let u;o.onsuccess=()=>{u=a.transaction(ns,"readwrite");const o=u.objectStore(ns).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r});o.onsuccess=()=>e({modelArtifactsInfo:r}),o.onerror=e=>{s=i.objectStore(rs);const t=s.delete(this.modelPath);t.onsuccess=()=>(a.close(),n(o.error)),t.onerror=e=>(a.close(),n(o.error))}},o.onerror=e=>(a.close(),n(o.error)),i.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}}},r.onerror=e=>n(r.error)}))}}ss.URL_SCHEME="indexeddb://";const os=e=>{return Ge().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(ss.URL_SCHEME)?(t=e.slice(ss.URL_SCHEME.length),new ss(t)):null;var t};Ji.registerSaveRouter(os),Ji.registerLoadRouter(os);class us{constructor(){this.indexedDB=as()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(ts,1);n.onupgradeneeded=()=>is(n),n.onsuccess=()=>{const r=n.result,a=r.transaction(rs,"readonly"),i=a.objectStore(rs).getAll();i.onsuccess=()=>{const t={};for(const e of i.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},i.onerror=e=>(r.close(),t(i.error)),a.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(ss.URL_SCHEME)?t.slice(ss.URL_SCHEME.length):t,new Promise(((t,n)=>{const r=this.indexedDB.open(ts,1);r.onupgradeneeded=()=>is(r),r.onsuccess=()=>{const a=r.result,i=a.transaction(rs,"readwrite"),s=i.objectStore(rs),o=s.get(e);let u;o.onsuccess=()=>{if(null==o.result)return a.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=s.delete(e),i=()=>{u=a.transaction(ns,"readwrite");const r=u.objectStore(ns).delete(e);r.onsuccess=()=>t(o.result.modelArtifactsInfo),r.onerror=e=>n(o.error)};r.onsuccess=i,r.onerror=e=>(i(),a.close(),n(o.error))}},o.onerror=e=>(a.close(),n(o.error)),i.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}},r.onerror=e=>n(r.error)}))}}const ls="/",cs="tensorflowjs_models",ps="info",ds="model_topology",hs="weight_specs",fs="weight_data",ms="model_metadata";function gs(e){return{info:[cs,e,ps].join(ls),topology:[cs,e,ds].join(ls),weightSpecs:[cs,e,hs].join(ls),weightData:[cs,e,fs].join(ls),modelMetadata:[cs,e,ms].join(ls)}}function ys(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function bs(e){const t=e.split(ls);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(ls)}class xs{constructor(e){if(!Ge().getBool("IS_BROWSER")||"undefined"==typeof window||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=gs(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),r=Gi(e);try{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,function(e){if(Hi)return Buffer.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,r=t.length;e{return Ge().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(xs.URL_SCHEME)?(t=e.slice(xs.URL_SCHEME.length),new xs(t)):null;var t};Ji.registerSaveRouter(vs),Ji.registerLoadRouter(vs);class _s{constructor(){se(Ge().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),se("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=cs+ls,n=ls+ps;for(let r=0;r"scheme must not be undefined or null.")),e.endsWith(ws)&&(e=e.slice(0,e.indexOf(ws))),se(e.length>0,(()=>"scheme must not be an empty string."));const n=Ms.getInstance();se(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=Ms.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(Ms.getInstance().managers)}}function Ns(e){if(-1===e.indexOf(ws))throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Ms.getSchemes().join(",")}`);return{scheme:e.split(ws)[0],path:e.split(ws)[1]}}async function Ss(e,t,n=!1){se(e!==t,(()=>`Old path and new path are the same: '${e}'`));const r=Ji.getLoadHandlers(e);se(r.length>0,(()=>`Copying failed because no load handler is found for source URL ${e}.`)),se(r.length<2,(()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`));const a=r[0],i=Ji.getSaveHandlers(t);se(i.length>0,(()=>`Copying failed because no save handler is found for destination URL ${t}.`)),se(i.length<2,(()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`));const s=i[0],o=Ns(e).scheme,u=Ns(e).path,l=o===Ns(e).scheme,c=await a.load();n&&l&&await Ms.getManager(o).removeModel(u);const p=await s.save(c);return n&&!l&&await Ms.getManager(o).removeModel(u),p.modelArtifactsInfo}async function ks(){const e=Ms.getSchemes(),t={};for(const n of e){const e=await Ms.getManager(n).listModels();for(const r in e)t[n+ws+r]=e[r]}return t}async function Ds(e){const t=Ns(e);return Ms.getManager(t.scheme).removeModel(t.path)}async function Ts(e,t){return Ss(e,t,!1)}async function Is(e,t){return Ss(e,t,!0)}class Es{fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(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)}decode(e,t){return new TextDecoder(t).decode(e)}}if(Ge().get("IS_BROWSER")){Ge().setPlatform("browser",new Es);try{Ms.registerManager(xs.URL_SCHEME,new _s)}catch(e){}try{Ms.registerManager(ss.URL_SCHEME,new us)}catch(e){}}let Cs;function As(e,t="float32",n){return t=t||"float32",He(e),new Xa(e,t,n)}Ge().get("IS_NODE")&&!Ge().get("IS_BROWSER")&&Ge().setPlatform("node",new class{constructor(){this.util=n(8628),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=Ge().global.fetch?Ge().global.fetch(e,t):(null==Cs&&(Cs=n(5410)),Cs(e,t))}now(){const e=process.hrtime();return 1e3*e[0]+e[1]/1e6}encode(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)}decode(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)}});const Ls=$i({cast_:function(e,t){const n=Ci(e,"x","cast");if(!Se(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");const r={x:n},a={dtype:t};return _i.runKernel(wt,r,a)}}),$s=$i({clone_:function(e){const t={x:Ci(e,"x","clone","string_or_numeric")};return _i.runKernel(fn,t)}});function Os(e,t=!1){console.log(e.toString(t))}function Rs(e){return new Promise((e=>setTimeout(e))).then(e)}vi(),Qa={buffer:As,cast:Ls,clone:$s,print:Os};class Fs{constructor(e){if(!Ge().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Fs.URL_SCHEME)&&(e=e.slice(Fs.URL_SCHEME.length)),null!=e&&0!==e.length||(e="model"),this.modelJsonFileName=e+".json",this.weightDataFileName=e+".weights.bin"}async save(e){if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");const t=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"}));if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{const n=Wi(e,[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}]),r=window.URL.createObjectURL(new Blob([JSON.stringify(n)],{type:"application/json"})),a=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor;if(a.download=this.modelJsonFileName,a.href=r,await Rs((()=>a.dispatchEvent(new MouseEvent("click")))),null!=e.weightData){const e=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;e.download=this.weightDataFileName,e.href=t,await Rs((()=>e.dispatchEvent(new MouseEvent("click"))))}return{modelArtifactsInfo:Gi(e)}}}}Fs.URL_SCHEME="downloads://";class Ys{constructor(e){if(null==e||e.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise(((e,t)=>{const n=new FileReader;n.onload=n=>{const r=JSON.parse(n.target.result),a=r.modelTopology;if(null==a)return void t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));if(null==r.weightsManifest)return void t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));if(0===this.weightsFiles.length)return void e({modelTopology:a});const i=Vi(r,(e=>this.loadWeights(e)));e(i)},n.onerror=e=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),n.readAsText(this.jsonFile)}))}loadWeights(e){const t=[],n=[];for(const r of e)t.push(...r.weights),n.push(...r.paths);const r=this.checkManifestAndWeightFiles(e),a=n.map((e=>this.loadWeightsFile(e,r[e])));return Promise.all(a).then((e=>[t,Ui(e)]))}loadWeightsFile(e,t){return new Promise(((n,r)=>{const a=new FileReader;a.onload=e=>{const t=e.target.result;n(t)},a.onerror=t=>r(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)}))}checkManifestAndWeightFiles(e){const t=[],n=this.weightsFiles.map((e=>qi(e.name))),r={};for(const a of e)a.paths.forEach((e=>{const a=qi(e);if(-1!==t.indexOf(a))throw new Error(`Duplicate file basename found in weights manifest: '${a}'`);if(t.push(a),-1===n.indexOf(a))throw new Error(`Weight file with basename '${a}' is not provided.`);r[e]=this.weightsFiles[n.indexOf(a)]}));if(t.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return r}}function zs(e){return new Ys(e)}function Bs(e,t,n,r){!function(e){se(null!=e&&Array.isArray(e)&&e.length>0,(()=>"promises must be a none empty array"))}(e),function(e,t){se(e>=0&&e<=1,(()=>`Progress fraction must be in range [0, 1], but got startFraction ${e}`)),se(t>=0&&t<=1,(()=>`Progress fraction must be in range [0, 1], but got endFraction ${t}`)),se(t>=e,(()=>`startFraction must be no more than endFraction, but got startFraction ${e} and endFraction ${t}`))}(n=null==n?0:n,r=null==r?1:r);let a=0;return Promise.all(e.map((i=>(i.then((i=>{const s=n+ ++a/e.length*(r-n);return t(s),i})),i))))}async function Ps(e,t){null==t&&(t={});const n=null==t.fetchFunc?Ge().platform.fetch:t.fetchFunc,r=e.map((e=>n(e,t.requestInit,{isBinary:!0}))),a=(null==t.onProgress?await Promise.all(r):await Bs(r,t.onProgress,0,.5)).map((e=>e.arrayBuffer()));return null==t.onProgress?await Promise.all(a):await Bs(a,t.onProgress,.5,1)}async function Hs(e,t="",n,r){return js((e=>Ps(e,{requestInit:r})))(e,t,n)}function js(e){return async(t,n="",r)=>{const a=t.map((()=>!1)),i={},s=null!=r?r.map((()=>!1)):[],o=[];if(t.forEach(((e,t)=>{let n=0;e.weights.forEach((e=>{const u="quantization"in e?e.quantization.dtype:e.dtype,l=Yi[u]*ce(e.shape),c=()=>{a[t]=!0,null==i[t]&&(i[t]=[]),i[t].push({manifestEntry:e,groupOffset:n,sizeBytes:l})};null!=r?r.forEach(((t,n)=>{t===e.name&&(c(),s[n]=!0)})):c(),o.push(e.name),n+=l}))})),!s.every((e=>e))){const e=r.filter(((e,t)=>!s[t]));throw new Error(`Could not find weights in manifest with names: ${e.join(", ")}. \nManifest JSON has weights with names: ${o.join(", ")}.`)}const u=a.reduce(((e,t,n)=>(t&&e.push(n),e)),[]),l=[];u.forEach((e=>{t[e].paths.forEach((e=>{const t=n+(n.endsWith("/")?"":"/")+e;l.push(t)}))}));const c=await e(l),p={};let d=0;return u.forEach((e=>{const n=t[e].paths.length;let r=0;for(let e=0;e{const t=Bi(a.slice(e.groupOffset,e.groupOffset+e.sizeBytes),[e.manifestEntry]);for(const e in t)p[e]=t[e]})),d+=n})),p}}Ji.registerSaveRouter((e=>Ge().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Fs.URL_SCHEME)?function(e="model"){return new Fs(e)}(e.slice(Fs.URL_SCHEME.length)):null));class Us{constructor(e,t){if(this.DEFAULT_METHOD="POST",null==t&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,null!=t.fetchFunc?(se("function"==typeof t.fetchFunc,(()=>"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=Ge().platform.fetch,se(null!=e&&e.length>0,(()=>"URL path for http must not be null, undefined or empty.")),Array.isArray(e)&&se(2===e.length,(()=>`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||{}}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;const n=Wi(e,[{paths:["./model.weights.bin"],weights:e.weightSpecs}]);t.body.append("model.json",new Blob([JSON.stringify(n)],{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");const r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Gi(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async load(){const e=await this.fetch(this.path,this.requestInit);if(!e.ok)throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`);let t;try{t=await e.json()}catch(e){let t=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?t+=" 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.":t+=" Please make sure the server is serving valid JSON for this request.",new Error(t)}const n=t.modelTopology,r=t.weightsManifest;if(null==n&&null==r)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return Vi(t,(e=>this.loadWeights(e)))}async loadWeights(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[n,r]=function(e){const t=e.lastIndexOf("/"),n=e.lastIndexOf("?");return[e.substring(0,t)+"/",n>t?e.substring(n):""]}(t),a=this.weightPathPrefix||n,i=[];for(const t of e)i.push(...t.weights);const s=[],o=[];for(const t of e)for(const e of t.paths)null!=this.weightUrlConverter?o.push(this.weightUrlConverter(e)):s.push(a+e+r);return this.weightUrlConverter&&s.push(...await Promise.all(o)),[i,Ui(await Ps(s,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress}))]}}function qs(e){return null!=e.match(Us.URL_SCHEME_REGEX)}Us.URL_SCHEME_REGEX=/^https?:\/\//;const Ws=(e,t)=>{if("undefined"==typeof fetch&&(null==t||null==t.fetchFunc))return null;{let n=!0;if(n=Array.isArray(e)?e.every((e=>qs(e))):qs(e),n)return Vs(e,t)}return null};function Vs(e,t){return new Us(e,t)}function Gs(e,t){return Vs(e,t)}Ji.registerSaveRouter(Ws),Ji.registerLoadRouter(Ws);class Ks{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}}class Js{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}}class Xs{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}}function Zs(e,t,n,r){const a=arguments;return new Xs(Qs(...a))}function Qs(e,t,n,r){return 1===arguments.length?null!=e.modelTopology||null!=e.weightSpecs?new Ks(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 Ks({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 Ks({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r}))}function eo(e){return new Js(e)}function to(e){return new Js(e)}const no=$i({matMul_:function(e,t,n=!1,r=!1){let a=Ci(e,"a","matMul"),i=Ci(t,"b","matMul");[a,i]=di(a,i);const s={a,b:i},o={transposeA:n,transposeB:r};return _i.runKernel(yt,s,o)}}),ro=$i({oneHot_:function(e,t,n=1,r=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);const a={indices:Ci(e,"indices","oneHot","int32")},i={depth:t,onValue:n,offValue:r};return _i.runKernel(er,a,i)}});function ao(){Ge().set("PROD",!0)}function io(){Ge().set("DEBUG",!0)}function so(){Ge().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function oo(e){Ge().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function uo(){_i.disposeVariables()}function lo(){return _i}function co(){return _i.memory()}function po(e){return _i.profile(e)}function ho(e,t){return _i.tidy(e,t)}function fo(e){mi(e).forEach((e=>e.dispose()))}function mo(e){return _i.keep(e)}function go(e){return _i.time(e)}function yo(e){return _i.setBackend(e)}function bo(){return _i.ready()}function xo(){return _i.backendName}function vo(e){_i.removeBackend(e)}function _o(e){return _i.findBackend(e)}function wo(e){return _i.findBackendFactory(e)}function Mo(e,t,n=1){return _i.registerBackend(e,t,n)}function No(){return _i.backend}function So(e,t){Ge().setPlatform(e,t)}ei=oo;const ko=$i({imag_:function(e){const t={input:Ci(e,"input","imag")};return _i.runKernel(gn,t)}}),Do=$i({neg_:function(e){const t={x:Ci(e,"x","neg")};return _i.runKernel(Gn,t)}}),To=$i({real_:function(e){const t={input:Ci(e,"input","real")};return _i.runKernel(ur,t)}}),Io=$i({transpose_:function(e,t,n){const r=Ci(e,"x","transpose");if(null==t&&(t=r.shape.map(((e,t)=>t)).reverse()),se(r.rank===t.length,(()=>`Error in transpose: rank of input ${r.rank} must match length of perm ${t}.`)),t.forEach((e=>{se(e>=0&&e"All entries in 'perm' must be between 0 and "+(r.rank-1)+` but got ${t}`))})),r.rank<=1)return r.clone();const a={x:r},i={perm:t};return"complex64"===r.dtype?ho((()=>{let e=To(r),t=ko(r);return e=_i.runKernel(Zr,{x:e},i),t=_i.runKernel(Zr,{x:t},i),n&&(t=Do(t)),Oi(e,t)})):_i.runKernel(Zr,a,i)}}),Eo=$i({confusionMatrix_:function(e,t,n){const r=Ci(e,"labels","confusionMatrix"),a=Ci(t,"predictions","confusionMatrix");se(null==n||n>0&&Number.isInteger(n),(()=>`If provided, numClasses must be a positive integer, but got ${n}`)),se(1===r.rank,(()=>`Expected the rank of labels to be 1, but got ${r.rank}`)),se(1===a.rank,(()=>`Expected the rank of predictions to be 1, but got ${a.rank}`)),se(r.shape[0]===a.shape[0],(()=>`Mismatch in the number of examples: ${r.shape[0]} vs. ${a.shape[0]}. Labels and predictions should have the same number of elements.`)),se(n>0&&Number.isInteger(n),(()=>`numClasses is required to be a positive integer, but got ${n}`));const i=ro(Ls(r,"int32"),n),s=ro(Ls(a,"int32"),n),o=Io(i),u=no(o,s);return Ls(u,"int32")}});function Co(e,t){const n=e.length,r=[];for(let a=0;a1&&1===s&&r.unshift(i)}return r}function Ao(e,t){const n=[];for(let r=0;r1)&&n.unshift(i)}return n}function Lo(e,t){const n=[],r=Math.max(e.length,t.length);for(let a=0;a4)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");let n=!1,r=!1,a=!1,i=!1,s=!1,o=!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)a=!0;else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)i=!0;else if(null!=e.getContext)s=!0;else{if(!("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap))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}`);o=!0}if(a){const t=2;if(a&&e.readyState element.")}if(null!=fa(ia,_i.backendName)){const n={pixels:e},r={numChannels:t};return _i.runKernel(ia,n,r)}const[u,l]=a?[e.videoWidth,e.videoHeight]:[e.width,e.height];let c,p;if(s)c=e.getContext("2d").getImageData(0,0,u,l).data;else if(r||n)c=e.data;else if(i||a||o){if(null==Oo)if("undefined"==typeof document){if("undefined"==typeof OffscreenCanvas||"undefined"==typeof OffscreenCanvasRenderingContext2D)throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");Oo=new OffscreenCanvas(1,1).getContext("2d")}else Oo=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});Oo.canvas.width=u,Oo.canvas.height=l,Oo.drawImage(e,0,0,u,l),c=Oo.getImageData(0,0,u,l).data}if(4===t)p=new Int32Array(c);else{const e=u*l;p=new Int32Array(e*t);for(let n=0;n4||2===i)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${i}`);if("float32"!==n.dtype&&"int32"!==n.dtype)throw new Error(`Unsupported type for toPixels: ${n.dtype}. Please use float32 or int32 tensors.`);const s=await n.data(),o="float32"===n.dtype?255:1,u=new Uint8ClampedArray(a*r*4);for(let e=0;e1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${a}.`)}else if("int32"===n.dtype&&(a<0||a>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${a}.`);1===i?(t[0]=a*o,t[1]=a*o,t[2]=a*o):t[r]=a*o}const r=4*e;u[r+0]=Math.round(t[0]),u[r+1]=Math.round(t[1]),u[r+2]=Math.round(t[2]),u[r+3]=Math.round(t[3])}if(null!=t){t.width=a,t.height=r;const e=t.getContext("2d"),n=new ImageData(u,a,r);e.putImageData(n,0,0)}return n!==e&&n.dispose(),u}const zo=$i({fromPixels_:Ro});function Bo(e,t){const n=e.shape.length,r=t.shape.length;if(n<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);if(r<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);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[r-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r-1]} vs. ${n}`);if(0===ce(e.shape))throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);const a=t.shape,i=a[a.length-1];let s=1;for(let e=0;ee/l)),1].slice(0,i);return[u,s,l,c]}function Po(e,t,n){const r=t.rank>1?t.shape[t.rank-1]:1,a=t.rank>1?t.rank-1:1,i=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${r}, and batchDim: ${a}.`;if(n.rank1?t.shape[r-1]:1,i=n.length;let s=1;for(let e=a;e`Error in slice${r}D: Length of begin ${t} must match the rank of the array (${r}).`)),se(r===n.length,(()=>`Error in slice${r}D: Length of size ${n} must match the rank of the array (${r}).`));for(let a=0;a`Error in slice${r}D: begin[${a}] + size[${a}] (${t[a]+n[a]}) would overflow input.shape[${a}] (${e.shape[a]})`))}function qo(e){const t=[];let n=0;for(;e>0;)1&e&&t.push(n),e/=2,n++;return t}function Wo(e,t,n){const r=[];for(let a=0;a0){const u=t[0],l=n+1;c=Xo(s,u,l,r,e),p=Zo(o,u,l,a,e),d=Vo(i,u,l,e)}else for(let t=0;t-1)i[a]=0;else{const s=Go(t,n,a);let o=r[s];e&1<-1)i[a]=Number.MAX_SAFE_INTEGER;else{const s=Go(t,n,a);let o=r[s];e&1<0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=ee(0,s,u-1),s}function tu(e,t,n,r,a,i){let s=t[a];const o=n[a]||1;(e&1<0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=o>0?ee(0,s,u):ee(-1,s,u-1),s}function nu(e,t,n){let r=n.length;for(let e=0;e1){r=e;break}for(let a=r+1;a0||n[a]!==e[a])return!1;return!0}function ru(e,t){let n=e.length>0?e[e.length-1]:1;for(let r=0;r{se(-1!==e,(()=>"slice() does not support negative begin indexing."))})),i=null==n?new Array(a).fill(-1):"number"==typeof n?[n,...new Array(a-1).fill(-1)]:n.lengtht>=0?t:(se(-1===t,(()=>`Negative size values should be exactly -1 but got ${t} for the slice() size at index ${n}.`)),e.shape[n]-r[n]))),[r,i]}function iu(e,t,n,r,a,i,s,o,u){let l;if(null==r?(l=new Array(t.length),l.fill(1)):l=r,null!=s&&0!=(s&s-1))throw new Error("Multiple ellipses in slice is not allowed.");let c=!1;const p={dims:l.length,numAddAxisAfterEllipsis:0,begin:t.slice(),end:n.slice(),strides:l.slice(),beginMask:a,endMask:i,ellipsisMask:s,newAxisMask:o,shrinkAxisMask:u};for(let e=0;e0?0:-1,d.strides[t]>0?r:r-1];if(n&&d.strides[t]<=0)throw Error("only stride 1 allowed on non-range indexing.");m=m&&1===d.strides[t];const s=!!(d.beginMask&1<=r)throw Error(`slice index ${d.begin[t]} of dimension ${t} out of bounds.`)}else d.begin[t]=su(d.begin[t],0,d.strides[t],r,a,i),d.end[t]=su(d.end[t],1,d.strides[t],r,a,i);const e=1===d.strides[t]&&0===d.begin[t]&&d.end[t]===r;h=h&&e,f=f&&(0===t&&1===d.strides[t]||e)}else h=h&&1===d.strides[t]&&s,f=f&&(0===t&&1===d.strides[t]||s);let o,u=!1;if(d.beginValid&&d.endValid?(o=d.end[t]-d.begin[t],u=!0):n?(o=1,u=!0):s&&r>=0&&(o=d.strides[t]<0?-r:r,u=!0),u){let e;e=0===o||o<0!=d.strides[t]<0?0:Math.trunc(o/d.strides[t])+(o%d.strides[t]!=0?1:0),g.push(e)}else g.push(-1)}for(let e=0;e=0?y.push(g[t]):-2===t&&y.push(1)}const b=y.filter(((e,t)=>-2!==d.finalShapeGatherIndices[t]));return{finalShapeSparse:b,finalShape:y,isIdentity:h,sliceDim0:f,isSimpleSlice:m,begin:d.begin,end:d.end,strides:d.strides}}function su(e,t,n,r,a,i){if(a[t])return n>0?i[t]:i[t+1&1];{const t=e<0?r+e:e;return ti[1]?i[1]:t}}class ou{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class uu{constructor(){this.classNameMap={}}static getMap(){return null==uu.instance&&(uu.instance=new uu),uu.instance}static register(e){uu.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function lu(e){se(null!=e.className,(()=>"Class being registered does not have the static className property defined.")),se("string"==typeof e.className,(()=>"className is required to be a string, but got type "+typeof e.className)),se(e.className.length>0,(()=>"Class being registered has an empty-string as its className, which is disallowed.")),uu.register(e)}const cu=.1;function pu(e,t,n){return null==n&&(n=du()),hu(e,t,((e,t)=>yu(e,t,n)))}function du(){return 32===_i.backend.floatPrecision()?.001:cu}function hu(e,t,n){let r=!0;if((De(e)||De(t))&&(r=!1),De(e)&&De(t)&&(r=!0),r){const n=e.constructor.name,r=t.constructor.name;if(n!==r)throw new Error(`Arrays are of different type. Actual: ${n}. Expected: ${r}`)}if(Array.isArray(e)&&Array.isArray(t)){const n=Ti(e),r=Ti(t);if(!de(n,r))throw new Error(`Arrays have different shapes. Actual: [${n}]. Expected: [${r}]`)}const a=De(e)?e:le(e),i=De(t)?t:le(t);if(a.length!==i.length)throw new Error(`Arrays have different lengths actual: ${a.length} vs expected: ${i.length}.\nActual: ${a}.\nExpected: ${i}.`);for(let e=0;et.fail()),(()=>t()))}function mu(e,t){const n="string"==typeof t||"number"==typeof t||"boolean"==typeof t?[t]:t;return Ee(e)||Ee(e[0])||Ee(t)||Ee(t[0])?hu(e,n,((e,t)=>e==t)):hu(e,t,((e,t)=>yu(e,t,0)))}function gu(e,t,n){if(null==n&&(n=du()),!yu(e,t,n))throw new Error(`Numbers differ: actual === ${e}, expected === ${t}`)}function yu(e,t,n){return!isFinite(e)&&!isFinite(t)||!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}function bu(e,t,n){for(let r=0;rn)throw new Error(`Value out of range:${e[r]} low: ${t}, high: ${n}`)}function xu(e,t){const n=new Float32Array(e),r=new Float32Array(t);if(n.length!==r.length)throw new Error(`Expected ArrayBuffer to be of length ${r.length}, but it was ${n.length}`);for(let e=0;e"The f passed in grad(f) must be a function")),(t,n)=>{const r=Ci(t,"x","tf.grad","string_or_numeric"),a=null!=n?Ci(n,"dy","tf.grad"):null;return _i.tidy((()=>{const{value:t,grads:n}=_i.gradients((()=>e(r)),[r],a);return null!=a&&oe(t.shape,a.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),Ou(n),n[0]}))}}function Eu(e){return se($e(e),(()=>"The f passed in grads(f) must be a function")),(t,n)=>{se(Array.isArray(t),(()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"));const r=Ai(t,"args","tf.grads","string_or_numeric"),a=null!=n?Ci(n,"dy","tf.grads"):null;return _i.tidy((()=>{const{value:t,grads:n}=_i.gradients((()=>e(...r)),r,a);return null!=a&&oe(t.shape,a.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Ou(n),n}))}}function Cu(e){return se($e(e),(()=>"The f passed in valueAndGrad(f) must be a function")),(t,n)=>{se(t instanceof ti,(()=>"The x passed in valueAndGrad(f)(x) must be a tensor")),se(null==n||n instanceof ti,(()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor"));const{grads:r,value:a}=_i.gradients((()=>e(t)),[t],n);return Ou(r),{grad:r[0],value:a}}}function Au(e){return se($e(e),(()=>"The f passed in valueAndGrads(f) must be a function")),(t,n)=>{se(Array.isArray(t)&&t.every((e=>e instanceof ti)),(()=>"The args passed in valueAndGrads(f)(args) must be array of tensors")),se(null==n||n instanceof ti,(()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor"));const r=_i.gradients((()=>e(...t)),t,n);return null!=n&&oe(r.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Ou(r.grads),r}}function Lu(e,t){se($e(e),(()=>"The f passed in variableGrads(f) must be a function")),se(null==t||Array.isArray(t)&&t.every((e=>e instanceof ri)),(()=>"The varList passed in variableGrads(f, varList) must be an array of variables"));const n=null!=t;if(!n){t=[];for(const e in _i.registeredVariables)t.push(_i.registeredVariables[e])}const r=n?t.filter((e=>!e.trainable)):null,a=t.length;t=t.filter((e=>e.trainable)),se(t.length>0,(()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${a} variables is trainable.`));const{value:i,grads:s}=_i.gradients(e,t,null,!0);se(s.some((e=>null!=e)),(()=>"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().")),se(0===i.rank,(()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${i.rank} tensor`));const o={};return t.forEach(((e,t)=>{null!=s[t]&&(o[e.name]=s[t])})),null!=r&&r.forEach((e=>o[e.name]=null)),{value:i,grads:o}}function $u(e){return _i.customGrad(e)}function Ou(e){if(e.filter((e=>null==e)).length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that\n the f you passed encloses all operations that lead from x to y.")}function Ru(e,t){if((De(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&&De(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return Ri(e,[],[],t)}class Fu extends ou{minimize(e,t=!1,n){const{value:r,grads:a}=this.computeGradients(e,n);if(null!=n){const e=n.map((e=>({name:e.name,tensor:a[e.name]})));this.applyGradients(e)}else this.applyGradients(a);return fo(a),t?r:(r.dispose(),null)}get iterations(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return Lu(e,t)}dispose(){null!=this.iterations_&&fo(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:Ru(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(e){throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`)}async extractIterations(e){return this.iterations_=(await e[0].tensor.data())[0],e.slice(1)}}Object.defineProperty(Fu,Symbol.hasInstance,{value:e=>null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients});class Yu extends Fu{constructor(e,t,n=null){super(),this.learningRate=e,this.rho=t,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],null==n&&(this.epsilon=_i.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=_i.registeredVariables[t];null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:`${t}/accum_grad`,variable:ho((()=>Tu(r).variable(!1)))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:`${t}/accum_var`,variable:ho((()=>Tu(r).variable(!1)))});const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const i=this.accumulatedGrads[n].variable,s=this.accumulatedUpdates[n].variable;ho((()=>{const e=wu(Su(i,this.rho),Su(Du(a),1-this.rho)),t=Su(Nu(ku(wu(s,this.epsilon)),ku(wu(i,this.epsilon))),a),n=wu(Su(s,this.rho),Su(Du(t),1-this.rho));i.assign(e),s.assign(n);const o=wu(Su(t,-this.learningRate),r);r.assign(o)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&(fo(this.accumulatedGrads.map((e=>e.variable))),fo(this.accumulatedUpdates.map((e=>e.variable))))}async getWeights(){const e=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){const t=(e=await this.extractIterations(e)).length/2;this.accumulatedGrads=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)}))),this.accumulatedUpdates=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}}function zu(e,t,n){const r={shape:e,value:t,dtype:n};return _i.runKernel(an,{},r)}Yu.className="Adadelta",lu(Yu);class Bu extends Fu{constructor(e,t=.1){super(),this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=_i.registeredVariables[t];if(null==this.accumulatedGrads[n]){const e=!1;this.accumulatedGrads[n]={originalName:`${t}/accumulator`,variable:ho((()=>zu(r.shape,this.initialAccumulatorValue).variable(e)))}}const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const i=this.accumulatedGrads[n].variable;ho((()=>{const e=wu(i,Du(a));i.assign(e);const t=wu(Su(Nu(a,ku(wu(e,_i.backend.epsilon()))),-this.learningRate),r);r.assign(t)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&fo(this.accumulatedGrads.map((e=>e.variable)))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e),this.accumulatedGrads=e.map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}}Bu.className="Adagrad",lu(Bu);const Pu=$i({pow_:function(e,t){let n=Ci(e,"base","pow"),r=Ci(t,"exp","pow");[n,r]=di(n,r);const a={a:n,b:r};return _i.runKernel(ar,a)}}),Hu=$i({sub_:function(e,t){let n=Ci(e,"a","sub"),r=Ci(t,"b","sub");[n,r]=di(n,r);const a={a:n,b:r};return _i.runKernel(Wr,a)}});class ju extends Fu{constructor(e,t,n,r=null){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],ho((()=>{this.accBeta1=Ru(t).variable(),this.accBeta2=Ru(n).variable()})),null==r&&(this.epsilon=_i.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);ho((()=>{const n=Hu(1,this.accBeta1),r=Hu(1,this.accBeta2);t.forEach(((t,a)=>{const i=_i.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:ho((()=>Tu(i).variable(!1)))}),null==this.accumulatedSecondMoment[a]&&(this.accumulatedSecondMoment[a]={originalName:`${t}/v`,variable:ho((()=>Tu(i).variable(!1)))});const s=Array.isArray(e)?e[a].tensor:e[t];if(null==s)return;const o=this.accumulatedFirstMoment[a].variable,u=this.accumulatedSecondMoment[a].variable,l=wu(Su(o,this.beta1),Su(s,1-this.beta1)),c=wu(Su(u,this.beta2),Su(Du(s),1-this.beta2)),p=Nu(l,n),d=Nu(c,r);o.assign(l),u.assign(c);const h=wu(Su(Nu(p,wu(ku(d),this.epsilon)),-this.learningRate),i);i.assign(h)})),this.accBeta1.assign(Su(this.accBeta1,this.beta1)),this.accBeta2.assign(Su(this.accBeta2,this.beta2))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&fo(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedSecondMoment&&fo(this.accumulatedSecondMoment.map((e=>e.variable)))}async getWeights(){const e=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e),ho((()=>{this.accBeta1.assign(Pu(this.beta1,this.iterations_+1)),this.accBeta2.assign(Pu(this.beta2,this.iterations_+1))}));const t=e.length/2;this.accumulatedFirstMoment=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)}))),this.accumulatedSecondMoment=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)}}ju.className="Adam",lu(ju);const Uu=$i({abs_:function(e){const t=Ci(e,"x","abs");if("complex64"===t.dtype){const e={x:t};return _i.runKernel(kt,e)}{const e={x:t};return _i.runKernel(Qe,e)}}}),qu=$i({maximum_:function(e,t){let n=Ci(e,"a","maximum"),r=Ci(t,"b","maximum");[n,r]=di(n,r),"bool"===n.dtype&&(n=Ls(n,"int32"),r=Ls(r,"int32")),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(On,a)}});class Wu extends Fu{constructor(e,t,n,r=null,a=0){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.decay=a,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],ho((()=>{this.iteration=Ru(0).variable(),this.accBeta1=Ru(t).variable()})),null==r&&(this.epsilon=_i.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);ho((()=>{const n=Hu(1,this.accBeta1),r=Nu(-this.learningRate,wu(Su(this.iteration,this.decay),1));t.forEach(((t,a)=>{const i=_i.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:Tu(i).variable(!1)}),null==this.accumulatedWeightedInfNorm[a]&&(this.accumulatedWeightedInfNorm[a]={originalName:`${t}/v`,variable:Tu(i).variable(!1)});const s=Array.isArray(e)?e[a].tensor:e[t];if(null==s)return;const o=this.accumulatedFirstMoment[a].variable,u=this.accumulatedWeightedInfNorm[a].variable,l=wu(Su(o,this.beta1),Su(s,1-this.beta1)),c=Su(u,this.beta2),p=Uu(s),d=qu(c,p);o.assign(l),u.assign(d);const h=wu(Su(Nu(r,n),Nu(l,wu(d,this.epsilon))),i);i.assign(h)})),this.iteration.assign(wu(this.iteration,1)),this.accBeta1.assign(Su(this.accBeta1,this.beta1))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&fo(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedWeightedInfNorm&&fo(this.accumulatedWeightedInfNorm.map((e=>e.variable)))}async getWeights(){throw new Error("getWeights() is not implemented for Adamax yet.")}async setWeights(e){throw new Error("setWeights() is not implemented for Adamax yet.")}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)}}Wu.className="Adamax",lu(Wu);class Vu extends Fu{constructor(e){super(),this.learningRate=e,this.setLearningRate(e)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=Array.isArray(e)?e[n].tensor:e[t];if(null==r)return;const a=_i.registeredVariables[t];ho((()=>{const e=wu(Su(this.c,r),a);a.assign(e)}))})),this.incrementIterations()}setLearningRate(e){this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=mo(Ru(-e))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(0!==(e=await this.extractIterations(e)).length)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}}Vu.className="SGD",lu(Vu);class Gu extends Vu{constructor(e,t,n=!1){super(e),this.learningRate=e,this.momentum=t,this.useNesterov=n,this.accumulations=[],this.m=Ru(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=_i.registeredVariables[t];if(null==this.accumulations[n]){const e=!1;this.accumulations[n]={originalName:`${t}/momentum`,variable:ho((()=>Tu(r).variable(e)))}}const a=this.accumulations[n].variable,i=Array.isArray(e)?e[n].tensor:e[t];null!=i&&ho((()=>{let e;const t=wu(Su(this.m,a),i);e=this.useNesterov?wu(Su(this.c,wu(i,Su(t,this.m))),r):wu(Su(this.c,t),r),a.assign(t),r.assign(e)}))})),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&fo(this.accumulations.map((e=>e.variable)))}setMomentum(e){this.momentum=e}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e),this.accumulations=e.map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}}Gu.className="Momentum",lu(Gu);class Ku extends Fu{constructor(e,t=.9,n=0,r=null,a=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=r,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=a,null==r&&(this.epsilon=_i.backend.epsilon()),null==e)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=_i.registeredVariables[t],a=!1;null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:`${t}/rms`,variable:ho((()=>Tu(r).variable(a)))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:`${t}/momentum`,variable:ho((()=>Tu(r).variable(a)))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${t}/mg`,variable:ho((()=>Tu(r).variable(a)))});const i=Array.isArray(e)?e[n].tensor:e[t];if(null==i)return;const s=this.accumulatedMeanSquares[n].variable,o=this.accumulatedMoments[n].variable;ho((()=>{const e=wu(Su(s,this.decay),Su(Du(i),1-this.decay));if(this.centered){const t=this.accumulatedMeanGrads[n].variable,a=wu(Su(t,this.decay),Su(i,1-this.decay)),u=Nu(Su(i,this.learningRate),ku(Hu(e,wu(Du(a),this.epsilon)))),l=wu(Su(o,this.momentum),u);s.assign(e),t.assign(a),o.assign(l);const c=Hu(r,l);r.assign(c)}else{const e=wu(Su(s,this.decay),Su(Du(i),1-this.decay)),t=wu(Su(o,this.momentum),Nu(Su(i,this.learningRate),ku(wu(e,this.epsilon))));s.assign(e),o.assign(t);const n=Hu(r,t);r.assign(n)}}))})),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&fo(this.accumulatedMeanSquares.map((e=>e.variable))),null!=this.accumulatedMeanGrads&&this.centered&&fo(this.accumulatedMeanGrads.map((e=>e.variable))),null!=this.accumulatedMoments&&fo(this.accumulatedMoments.map((e=>e.variable)))}async getWeights(){const e=[...this.accumulatedMeanSquares,...this.accumulatedMoments];return this.centered&&e.push(...this.accumulatedMeanGrads),[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e);const t=this.centered?e.length/3:e.length/2,n=!1;this.accumulatedMeanSquares=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))),this.accumulatedMoments=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))),this.centered&&(this.accumulatedMeanGrads=e.slice(2*t,3*t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))))}getConfig(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}static fromConfig(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)}}Ku.className="RMSProp",lu(Ku);class Ju{static sgd(e){return new Vu(e)}static momentum(e,t,n=!1){return new Gu(e,t,n)}static rmsprop(e,t=.9,n=0,r=null,a=!1){return new Ku(e,t,n,r,a)}static adam(e=.001,t=.9,n=.999,r=null){return new ju(e,t,n,r)}static adadelta(e=.001,t=.95,n=null){return new Yu(e,t,n)}static adamax(e=.002,t=.9,n=.999,r=null,a=0){return new Wu(e,t,n,r,a)}static adagrad(e,t=.1){return new Bu(e,t)}}const Xu=$i({acos_:function(e){const t={x:Ci(e,"x","acos")};return _i.runKernel(et,t)}}),Zu=$i({acosh_:function(e){const t={x:Ci(e,"x","acosh")};return _i.runKernel(tt,t)}}),Qu=$i({addN_:function(e){se(Array.isArray(e),(()=>"The argument passed to tf.addN() must be a list of tensors")),se(e.length>=1,(()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`));const t=e.map(((e,t)=>Ci(e,`tensors${t}`,"addN"))),n=t[0];t.forEach((e=>{if(e.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),t.forEach((e=>{if(!de(e.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));const r=t;return _i.runKernel(rt,r)}}),el=$i({all_:function(e,t=null,n=!1){const r={x:Ci(e,"x","all","bool")},a={axis:t,keepDims:n};return _i.runKernel(at,r,a)}}),tl=$i({any_:function(e,t=null,n=!1){const r={x:Ci(e,"x","any","bool")},a={axis:t,keepDims:n};return _i.runKernel(it,r,a)}}),nl=$i({argMax_:function(e,t=0){const n={x:Ci(e,"x","argMax")},r={axis:t};return _i.runKernel(st,n,r)}}),rl=$i({argMin_:function(e,t=0){const n={x:Ci(e,"x","argMin")},r={axis:t};return _i.runKernel(ot,n,r)}}),al=$i({asin_:function(e){const t={x:Ci(e,"x","asin")};return _i.runKernel(ut,t)}}),il=$i({asinh_:function(e){const t={x:Ci(e,"x","asinh")};return _i.runKernel(lt,t)}}),sl=$i({atan_:function(e){const t={x:Ci(e,"x","atan")};return _i.runKernel(ct,t)}}),ol=$i({atan2_:function(e,t){let n=Ci(e,"a","atan2"),r=Ci(t,"b","atan2");[n,r]=di(n,r);const a={a:n,b:r};return _i.runKernel(dt,a)}}),ul=$i({atanh_:function(e){const t={x:Ci(e,"x","atanh")};return _i.runKernel(pt,t)}});function ll(e,t,n,r,a="NHWC",i){return dl(e,[...t,e[3]],n,i,r,null,null,_l(a))}function cl(e,t,n,r,a,i,s="channelsLast"){const[o,u]=ml(t);let l;if("channelsLast"===s)l=[o,u,e[3],e[3]];else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);l=[o,u,e[1],e[1]]}return dl(e,l,n,r,a,i,!1,s)}function pl(e,t,n,r,a,i,s="NDHWC"){const[o,u,l]=gl(t);let c,p;if("NDHWC"===s)p="channelsLast",c=[o,u,l,e[4],e[4]];else{if("NCDHW"!==s)throw new Error(`Unknown dataFormat ${s}`);p="channelsFirst",c=[o,u,l,e[1],e[1]]}return hl(e,c,n,r,a,!1,p,i)}function dl(e,t,n,r,a,i,s=!1,o="channelsLast"){let[u,l,c,p]=[-1,-1,-1,-1];if("channelsLast"===o)[u,l,c,p]=e;else{if("channelsFirst"!==o)throw new Error(`Unknown dataFormat ${o}`);[u,p,l,c]=e}const[d,h,,f]=t,[m,g]=ml(n),[y,b]=ml(r),x=yl(d,y),v=yl(h,b),{padInfo:_,outHeight:w,outWidth:M}=function(e,t,n,r,a,i,s,o,u){let l,c,p;if("number"==typeof e){l={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};const a=function(e,t,n,r,a){null==r&&(r=fl(e,t,n));const i=e[1];return[bl((e[0]-t+2*r)/n+1,a),bl((i-t+2*r)/n+1,a)]}([t,n],i,r,e,o);c=a[0],p=a[1]}else if("same"===e){c=Math.ceil(t/r),p=Math.ceil(n/a);const e=Math.max(0,(c-1)*r+i-t),o=Math.max(0,(p-1)*a+s-n),u=Math.floor(e/2),d=e-u,h=Math.floor(o/2);l={top:u,bottom:d,left:h,right:o-h,type:"SAME"}}else if("valid"===e)l={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((t-i+1)/r),p=Math.ceil((n-s+1)/a);else{if("object"!=typeof e)throw Error(`Unknown padding parameter: ${e}`);{const d="channelsLast"===u?e[1][0]:e[2][0],h="channelsLast"===u?e[1][1]:e[2][1],f="channelsLast"===u?e[2][0]:e[3][0],m="channelsLast"===u?e[2][1]:e[3][1];l={top:d,bottom:h,left:f,right:m,type:0===d&&0===h&&0===f&&0===m?"VALID":"EXPLICIT"},c=bl((t-i+d+h)/r+1,o),p=bl((n-s+f+m)/a+1,o)}}return{padInfo:l,outHeight:c,outWidth:p}}(a,l,c,m,g,x,v,i,o),N=s?f*p:f;let S;return"channelsFirst"===o?S=[u,N,w,M]:"channelsLast"===o&&(S=[u,w,M,N]),{batchSize:u,dataFormat:o,inHeight:l,inWidth:c,inChannels:p,outHeight:w,outWidth:M,outChannels:N,padInfo:_,strideHeight:m,strideWidth:g,filterHeight:d,filterWidth:h,effectiveFilterHeight:x,effectiveFilterWidth:v,dilationHeight:y,dilationWidth:b,inShape:e,outShape:S,filterShape:t}}function hl(e,t,n,r,a,i=!1,s="channelsLast",o){let[u,l,c,p,d]=[-1,-1,-1,-1,-1];if("channelsLast"===s)[u,l,c,p,d]=e;else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);[u,d,l,c,p]=e}const[h,f,m,,g]=t,[y,b,x]=gl(n),[v,_,w]=gl(r),M=yl(h,v),N=yl(f,_),S=yl(m,w),{padInfo:k,outDepth:D,outHeight:T,outWidth:I}=function(e,t,n,r,a,i,s,o,u,l,c){let p,d,h,f;if("number"==typeof e){p={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};const i=function(e,t,n,r,a,i){null==a&&(a=fl(e,t,r));const s=e[1],o=e[2];return[bl((e[0]-t+2*a)/r+1,i),bl((s-t+2*a)/r+1,i),bl((o-t+2*a)/r+1,i),1]}([t,n,r,1],o,0,a,e,c);d=i[0],h=i[1],f=i[2]}else if("same"===e){d=Math.ceil(t/a),h=Math.ceil(n/i),f=Math.ceil(r/s);const e=(d-1)*a+o-t,c=(h-1)*i+u-n,m=(f-1)*s+l-r,g=Math.floor(e/2),y=e-g,b=Math.floor(c/2),x=c-b,v=Math.floor(m/2);p={top:b,bottom:x,left:v,right:m-v,front:g,back:y,type:"SAME"}}else{if("valid"!==e)throw Error(`Unknown padding parameter: ${e}`);p={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},d=Math.ceil((t-o+1)/a),h=Math.ceil((n-u+1)/i),f=Math.ceil((r-l+1)/s)}return{padInfo:p,outDepth:d,outHeight:h,outWidth:f}}(a,l,c,p,y,b,x,M,N,S,o),E=i?g*d:g;let C;return"channelsFirst"===s?C=[u,E,D,T,I]:"channelsLast"===s&&(C=[u,D,T,I,E]),{batchSize:u,dataFormat:s,inDepth:l,inHeight:c,inWidth:p,inChannels:d,outDepth:D,outHeight:T,outWidth:I,outChannels:E,padInfo:k,strideDepth:y,strideHeight:b,strideWidth:x,filterDepth:h,filterHeight:f,filterWidth:m,effectiveFilterDepth:M,effectiveFilterHeight:N,effectiveFilterWidth:S,dilationDepth:v,dilationHeight:_,dilationWidth:w,inShape:e,outShape:C,filterShape:t}}function fl(e,t,n,r=1){const a=yl(t,r);return Math.floor((e[0]*(n-1)-n+a)/2)}function ml(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function gl(e){return"number"==typeof e?[e,e,e]:e}function yl(e,t){return t<=1?e:e+(e-1)*(t-1)}function bl(e,t){if(!t)return Math.trunc(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 xl(e){const[t,n,r]=ml(e);return 1===t&&1===n&&1===r}function vl(e,t){return xl(e)||xl(t)}function _l(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}function wl(e,t,n){if(null!=n){if("string"==typeof t)throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);if("number"==typeof t)se(he(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`));else{if("object"!=typeof t)throw Error(`Error in ${e}: Unknown padding parameter: ${t}`);t.forEach((t=>{t.forEach((t=>{se(he(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`))}))}))}}}const Ml=$i({reshape_:function(e,t){const n={x:Ci(e,"x","reshape","string_or_numeric")},r={shape:t};return _i.runKernel(pr,n,r)}}),Nl=$i({avgPool_:function(e,t,n,r,a){const i=Ci(e,"x","avgPool","float32");se(vl(n,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`));let s=i,o=!1;3===i.rank&&(o=!0,s=Ml(i,[1,i.shape[0],i.shape[1],i.shape[2]])),se(4===s.rank,(()=>`Error in avgPool: x must be rank 4 but got rank ${s.rank}.`)),wl("avgPool",r,a);const u={x:s},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a};let c=_i.runKernel(ht,u,l);return c=Ls(c,i.dtype),o?Ml(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),Sl=$i({avgPool3d_:function(e,t,n,r,a,i="NDHWC"){const s=Ci(e,"x","avgPool3d","float32");let o=s,u=!1;4===s.rank&&(u=!0,o=Ml(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),se(5===o.rank,(()=>`Error in avgPool3d: x must be rank 5 but got rank ${o.rank}.`)),se("NDHWC"===i,(()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${i}`)),wl("avgPool3d",r,a);const l={x:o},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i};let p=_i.runKernel(mt,l,c);return p=Ls(p,o.dtype),u?Ml(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}}),kl=$i({concat_:function(e,t=0){se(e.length>=1,(()=>"Pass at least one tensor to concat"));const n=Ai(e,"tensors","concat","string_or_numeric");if("complex64"===n[0].dtype&&n.forEach((e=>{if("complex64"!==e.dtype)throw new Error(`Cannot concatenate complex64 tensors with a tensor\n with dtype ${e.dtype}. `)})),1===n.length)return $s(n[0]);const r=n,a={axis:t};return _i.runKernel(Dt,r,a)}}),Dl=$i({sigmoid_:function(e){const t={x:Ci(e,"x","sigmoid","float32")};return _i.runKernel(Tr,t)}}),Tl=$i({slice_:function(e,t,n){const r=Ci(e,"x","slice","string_or_numeric");if(0===r.rank)throw new Error("Slicing scalar is not possible");const a={x:r},i={begin:t,size:n};return _i.runKernel(Nr,a,i)}}),Il=$i({tanh_:function(e){const t={x:Ci(e,"x","tanh","float32")};return _i.runKernel(Gr,t)}}),El=$i({basicLSTMCell_:function(e,t,n,r,a,i){const s=Ci(e,"forgetBias","basicLSTMCell"),o=Ci(t,"lstmKernel","basicLSTMCell"),u=Ci(n,"lstmBias","basicLSTMCell"),l=Ci(r,"data","basicLSTMCell"),c=Ci(a,"c","basicLSTMCell"),p=Ci(i,"h","basicLSTMCell"),d=kl([l,p],1),h=no(d,o),f=wu(h,u),m=f.shape[0],g=f.shape[1]/4,y=[m,g],b=Tl(f,[0,0],y),x=Tl(f,[0,g],y),v=Tl(f,[0,2*g],y),_=Tl(f,[0,3*g],y),w=wu(Su(Dl(b),Il(x)),Su(c,Dl(wu(s,v))));return[w,Su(Il(w),Dl(_))]}}),Cl=$i({batchToSpaceND_:function(e,t,n){const r=Ci(e,"x","batchToSpaceND"),a=t.reduce(((e,t)=>e*t));se(r.rank>=1+t.length,(()=>`input rank is ${r.rank} but should be > than blockShape.length ${t.length}`)),se(n.length===t.length,(()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`)),se(r.shape[0]%a==0,(()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${a}`));const i={x:r},s={blockShape:t,crops:n};return _i.runKernel(bt,i,s)}}),Al=$i({batchNorm_:function(e,t,n,r,a,i){null==i&&(i=.001);const s=Ci(e,"x","batchNorm"),o=Ci(t,"mean","batchNorm"),u=Ci(n,"variance","batchNorm");let l,c;null!=a&&(l=Ci(a,"scale","batchNorm")),null!=r&&(c=Ci(r,"offset","batchNorm")),se(o.rank===u.rank,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),se(null==c||o.rank===c.rank,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),se(null==l||o.rank===l.rank,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));const p=function(e){let t;return t=0===e.rank||1===e.rank?Ml(e,[1,1,1,e.size]):2===e.rank?Ml(e,[1,1,e.shape[0],e.shape[1]]):3===e.rank?Ml(e,[1,e.shape[0],e.shape[1],e.shape[2]]):e,t}(s),d={x:p,scale:l,offset:c,mean:o,variance:u},h={varianceEpsilon:i},f=_i.runKernel(ln,d,h);return Ml(f,s.shape)}}),Ll=$i({batchNorm2d_:function(e,t,n,r,a,i){const s=Ci(e,"x","batchNorm"),o=Ci(t,"mean","batchNorm"),u=Ci(n,"variance","batchNorm");let l,c;return null!=a&&(l=Ci(a,"scale","batchNorm")),null!=r&&(c=Ci(r,"offset","batchNorm")),se(2===s.rank,(()=>`Error in batchNorm2D: x must be rank 2 but got rank ${s.rank}.`)),se(2===o.rank||1===o.rank,(()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${o.rank}.`)),se(2===u.rank||1===u.rank,(()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${u.rank}.`)),null!=l&&se(2===l.rank||1===l.rank,(()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`)),null!=c&&se(2===c.rank||1===c.rank,(()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`)),Al(s,o,u,c,l,i)}}),$l=$i({batchNorm3d_:function(e,t,n,r,a,i){const s=Ci(e,"x","batchNorm"),o=Ci(t,"mean","batchNorm"),u=Ci(n,"variance","batchNorm");let l,c;return null!=a&&(l=Ci(a,"scale","batchNorm")),null!=r&&(c=Ci(r,"offset","batchNorm")),se(3===s.rank,(()=>`Error in batchNorm3D: x must be rank 3 but got rank ${s.rank}.`)),se(3===o.rank||1===o.rank,(()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${o.rank}.`)),se(3===u.rank||1===u.rank,(()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${u.rank}.`)),null!=l&&se(3===l.rank||1===l.rank,(()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`)),null!=c&&se(3===c.rank||1===c.rank,(()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`)),Al(s,o,u,c,l,i)}}),Ol=$i({batchNorm4d_:function(e,t,n,r,a,i){const s=Ci(e,"x","batchNorm"),o=Ci(t,"mean","batchNorm"),u=Ci(n,"variance","batchNorm");let l,c;return null!=a&&(l=Ci(a,"scale","batchNorm")),null!=r&&(c=Ci(r,"offset","batchNorm")),se(4===s.rank,(()=>`Error in batchNorm4D: x must be rank 4 but got rank ${s.rank}.`)),se(4===o.rank||1===o.rank,(()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${o.rank}.`)),se(4===u.rank||1===u.rank,(()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${u.rank}.`)),null!=l&&se(4===l.rank||1===l.rank,(()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`)),null!=c&&se(4===c.rank||1===c.rank,(()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`)),Al(s,o,u,c,l,i)}}),Rl=$i({bincount_:function(e,t,n){const r=Ci(e,"x","bincount"),a=Ci(t,"weights","bincount");se("int32"===r.dtype,(()=>`Error in bincount: input dtype must be int32, but got ${r.dtype}`)),se(n>=0,(()=>`size must be non-negative, but got ${n}.`)),se(a.size===r.size||0===a.size,(()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${a.shape}.`));const i={x:r,weights:a},s={size:n};return _i.runKernel(xt,i,s)}}),Fl=$i({broadcastArgs_:function(e,t){const n=Ci(e,"s0","broadcastArgs","int32"),r=Ci(t,"s1","broadcastArgs","int32");if(1!==n.rank)throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${n.rank}`);if(1!==r.rank)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${r.rank}`);const a={s0:n,s1:r};return _i.runKernel(_t,a)}}),Yl=$i({broadcastTo_:function(e,t){let n=Ci(e,"broadcastTo","x");const r=n.shape;if(t.some((e=>!(e>0)||e%1!=0)))throw new Error(`broadcastTo(): Invalid broadcast shape [${t}].`);if(t.lengthn.rank){const e=n.shape.slice();for(;e.length=0;e--)if(a[e]===t[e])i[e]=1;else if(1!==n.shape[e])throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${t}].`);const s=i.map(((e,t)=>e>1?t:-1)).filter((e=>e>=0));if(0===s.length)return $s(n);const o={x:n},u={reps:i};return _i.runKernel(Kr,o,u)}}),zl=$i({ceil_:function(e){const t={x:Ci(e,"x","ceil","float32")};return _i.runKernel(Mt,t)}}),Bl=$i({clipByValue_:function(e,t,n){const r=Ci(e,"x","clipByValue");se(t<=n,(()=>`Error in clip: min (${t}) must be less than or equal to max (${n}).`));const a={x:r},i={clipValueMin:t,clipValueMax:n};return _i.runKernel(Nt,a,i)}}),Pl=$i({concat1d_:function(e){return kl(e,0)}}),Hl=$i({concat2d_:function(e,t){return kl(e,t)}}),jl=$i({concat3d_:function(e,t){return kl(e,t)}}),Ul=$i({concat4d_:function(e,t){return kl(e,t)}}),ql=$i({conv2d_:function(e,t,n,r,a="NHWC",i=[1,1],s){const o=Ci(e,"x","conv2d","float32"),u=Ci(t,"filter","conv2d","float32");let l=o,c=!1;3===o.rank&&(c=!0,l=Ml(o,[1,o.shape[0],o.shape[1],o.shape[2]])),se(4===l.rank,(()=>`Error in conv2d: input must be rank 4, but got rank ${l.rank}.`)),se(4===u.rank,(()=>`Error in conv2d: filter must be rank 4, but got rank ${u.rank}.`)),wl("conv2d",r,s);const p="NHWC"===a?l.shape[3]:l.shape[1];se(p===u.shape[2],(()=>`Error in conv2d: depth of input (${p}) must match input depth for filter ${u.shape[2]}.`)),se(vl(n,i),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`));const d={x:l,filter:u},h={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s},f=_i.runKernel(Tt,d,h);return c?Ml(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),Wl=$i({conv1d_:function(e,t,n,r,a="NWC",i=1,s){const o=Ci(e,"x","conv1d"),u=Ci(t,"filter","conv1d");let l=o,c=!1;2===o.rank&&(c=!0,l=Ml(o,[1,o.shape[0],o.shape[1]])),se(3===l.rank,(()=>`Error in conv1d: input must be rank 3, but got rank ${l.rank}.`)),se(3===u.rank,(()=>`Error in conv1d: filter must be rank 3, but got rank ${u.rank}.`)),wl("conv1d",r,s),se(l.shape[2]===u.shape[1],(()=>`Error in conv1d: depth of input (${l.shape[2]}) must match input depth for filter ${u.shape[1]}.`)),se(vl(n,i),(()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${i}'`)),se("NWC"===a,(()=>`Error in conv1d: got dataFormat of ${a} but only NWC is currently supported.`));const p=Ml(u,[1,u.shape[0],u.shape[1],u.shape[2]]),d=Ml(l,[l.shape[0],1,l.shape[1],l.shape[2]]),h=ql(d,p,[1,n],r,"NHWC",[1,i],s);return Ml(h,c?[h.shape[2],h.shape[3]]:[h.shape[0],h.shape[2],h.shape[3]])}}),Vl=$i({conv2DBackpropInput_:function(e,t,n,r,a,i="NHWC",s){se(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let o=e,u=t,l=!1;3===t.rank&&(l=!0,u=Ml(t,[1,t.shape[0],t.shape[1],t.shape[2]]),o=[1,e[0],e[1],e[2]]),se(4===o.length,(()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${o.length}.`)),se(4===u.rank,(()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${u.rank}`)),se(4===n.rank,(()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`));const c="NHWC"===i?o[3]:o[1],p="NHWC"===i?u.shape[3]:u.shape[1];se(c===n.shape[2],(()=>`Error in conv2dDerInput: depth of input (${c}) must match input depth for filter ${n.shape[2]}.`)),se(p===n.shape[3],(()=>`Error in conv2dDerInput: depth of output (${p}) must match output depth for filter ${n.shape[3]}.`)),wl("conv2dDerInput",a,s);const d={dy:u,filter:n},h={strides:r,pad:a,dataFormat:i,dimRoundingMode:s,inputShape:o},f=_i.runKernel(Et,d,h);return l?Ml(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),Gl=$i({conv2dTranspose_:function(e,t,n,r,a,i){const s=Ci(e,"x","conv2dTranspose"),o=Ci(t,"filter","conv2dTranspose");return Vl(n,s,o,r,a,"NHWC",i)}}),Kl=$i({conv3d_:function(e,t,n,r,a="NDHWC",i=[1,1,1]){const s=Ci(e,"x","conv3d"),o=Ci(t,"filter","conv3d");let u=s,l=!1;4===s.rank&&(l=!0,u=Ml(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),se(5===u.rank,(()=>`Error in conv3d: input must be rank 5, but got rank ${u.rank}.`)),se(5===o.rank,(()=>`Error in conv3d: filter must be rank 5, but got rank ${o.rank}.`)),se(u.shape[4]===o.shape[3],(()=>`Error in conv3d: depth of input (${u.shape[4]}) must match input depth for filter ${o.shape[3]}.`)),se(vl(n,i),(()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`)),se("NDHWC"===a,(()=>`Error in conv3d: got dataFormat of ${a} but only NDHWC is currently supported.`));const c={x:u,filter:o},p={strides:n,pad:r,dataFormat:a,dilations:i},d=_i.runKernel(Ct,c,p);return l?Ml(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),Jl=$i({conv3DBackpropInput_:function(e,t,n,r,a){se(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let i=e,s=t,o=!1;4===t.rank&&(o=!0,s=Ml(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),i=[1,e[0],e[1],e[2],e[3]]);const u=i[4],l=s.shape[4];se(5===i.length,(()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${i.length}.`)),se(5===s.rank,(()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${s.rank}`)),se(5===n.rank,(()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`)),se(u===n.shape[3],(()=>`Error in conv3dDerInput: depth of input (${u}) must match input depth for filter ${n.shape[3]}.`)),se(l===n.shape[4],(()=>`Error in conv3dDerInput: depth of output (${l}) must match output depth for filter ${n.shape[4]}.`));const c={dy:s,filter:n},p={pad:a,strides:r,inputShape:i},d=_i.runKernel(Lt,c,p);return o?Ml(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),Xl=$i({conv3dTranspose_:function(e,t,n,r,a){const i=Ci(e,"x","conv3dTranspose"),s=Ci(t,"filter","conv3dTranspose");return Jl(n,i,s,r,a)}}),Zl=$i({cos_:function(e){const t={x:Ci(e,"x","cos","float32")};return _i.runKernel($t,t)}}),Ql=$i({cosh_:function(e){const t={x:Ci(e,"x","cosh","float32")};return _i.runKernel(Ot,t)}}),ec=$i({cumprod_:function(e,t=0,n=!1,r=!1){const a={x:Ci(e,"x","cumprod")},i={axis:t,exclusive:n,reverse:r};return _i.runKernel(Rt,a,i)}}),tc=$i({cumsum_:function(e,t=0,n=!1,r=!1){const a={x:Ci(e,"x","cumsum")},i={axis:t,exclusive:n,reverse:r};return _i.runKernel(Ft,a,i)}}),nc=$i({denseBincount_:function(e,t,n,r=!1){const a=Ci(e,"x","denseBincount"),i=Ci(t,"weights","denseBincount");se("int32"===a.dtype,(()=>`Error in denseBincount: input dtype must be int32, but got ${a.dtype}`)),se(a.rank<=2,(()=>`Error in denseBincount: input must be at most rank 2, but got rank ${a.rank}.`)),se(n>=0,(()=>`size must be non-negative, but got ${n}.`)),se(i.size===a.size||0===i.size,(()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${a.shape}, weights shape: ${i.shape}.`));const s={x:a,weights:i},o={size:n,binaryOutput:r};return _i.runKernel(zt,s,o)}}),rc=$i({depthToSpace_:function(e,t,n="NHWC"){const r=Ci(e,"x","depthToSpace","float32"),a="NHWC"===n?r.shape[1]:r.shape[2],i="NHWC"===n?r.shape[2]:r.shape[3],s="NHWC"===n?r.shape[3]:r.shape[1];se(t>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${t}`)),se(a*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${a} and ${t} for depthToSpace with input shape\n ${r.shape}`)),se(i*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${i} and ${t} for depthToSpace with input shape\n ${r.shape}`)),se(s%(t*t)==0,(()=>`Dimension size must be evenly divisible by ${t*t} but is ${s} for depthToSpace with input shape ${r.shape}`));const o={x:r},u={blockSize:t,dataFormat:n};return _i.runKernel(Bt,o,u)}}),ac=$i({depthwiseConv2d_:function(e,t,n,r,a="NHWC",i=[1,1],s){const o=Ci(e,"x","depthwiseConv2d","float32"),u=Ci(t,"filter","depthwiseConv2d","float32");let l=o,c=!1;3===o.rank&&(c=!0,l=Ml(o,[1,o.shape[0],o.shape[1],o.shape[2]])),se(4===l.rank,(()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${l.rank}.`)),se(4===u.rank,(()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${u.rank}.`));const p="NHWC"===a?l.shape[3]:l.shape[1];se(p===u.shape[2],(()=>`Error in depthwiseConv2d: number of input channels (${p}) must match the inChannels dimension in filter ${u.shape[2]}.`)),wl("depthwiseConv2d",r,s);const d={x:l,filter:u},h={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s},f=_i.runKernel(Pt,d,h);return c?Ml(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),ic=$i({diag_:function(e){const t={x:Ci(e,"x","diag")};return _i.runKernel(Ut,t)}}),sc=$i({dilation2d_:function(e,t,n,r,a=[1,1],i="NHWC"){const s=Ci(e,"x","dilation2d"),o=Ci(t,"filter","dilation2d");se(3===s.rank||4===s.rank,(()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${s.rank}.`)),se(3===o.rank,(()=>`Error in dilation2d: filter must be rank 3, but got rank ${o.rank}.`)),se("NHWC"===i,(()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${i}`));let u=s,l=!1;3===s.rank&&(u=Ml(s,[1,s.shape[0],s.shape[1],s.shape[2]]),l=!0);const c={x:u,filter:o},p={strides:n,pad:r,dilations:a},d=_i.runKernel(qt,c,p);return l?Ml(d,[d.shape[1],d.shape[2],d.shape[3]]):d}}),oc=$i({equal_:function(e,t){let n=Ci(e,"a","equal","string_or_numeric"),r=Ci(t,"b","equal","string_or_numeric");[n,r]=di(n,r),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(Qt,a)}}),uc=$i({where_:function(e,t,n){const r=Ci(t,"a","where"),a=Ci(n,"b","where"),i=Ci(e,"condition","where","bool"),s=Lo(Lo(i.shape,r.shape),a.shape),o={condition:Yl(i,s),t:Yl(r,s),e:Yl(a,s)};return _i.runKernel(wr,o)}}),lc=$i({divNoNan_:function(e,t){let n=Ci(e,"a","div"),r=Ci(t,"b","div");[n,r]=di(n,r);const a=Nu(n,r),i=Tu(a),s=oc(r,i);return uc(s,i,a)}}),cc=$i({dot_:function(e,t){const n=Ci(e,"t1","dot"),r=Ci(t,"t2","dot");se(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),(()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${r.rank}.`));const a=1===n.rank?n.size:n.shape[1],i=1===r.rank?r.size:r.shape[0];if(se(a===i,(()=>`Error in dot: inner dimensions of inputs must match, but got ${a} and ${i}.`)),1===n.rank&&1===r.rank){const e=Ml(n,[1,-1]),t=Ml(r,[-1,1]),a=no(e,t);return Ml(a,[])}if(1===n.rank&&2===r.rank){const e=Ml(n,[1,-1]),t=Ml(r,[r.shape[0],r.shape[1]]),a=no(e,t);return Ml(a,[a.size])}if(2===n.rank&&1===r.rank){const e=Ml(r,[-1,1]),t=no(n,e);return Ml(t,[t.size])}{const e=Ml(r,[r.shape[0],r.shape[1]]);return no(n,e)}}}),pc=$i({einsum_:function(e,...t){const n=t.map(((e,t)=>Ci(e,`tensors${t}`,"einsum"))),r={equation:e};return _i.runKernel(Kt,n,r)}}),dc=$i({elu_:function(e){const t={x:Ci(e,"x","elu","float32")};return _i.runKernel(Jt,t)}}),hc=$i({erf_:function(e){let t=Ci(e,"x","erf");se("int32"===t.dtype||"float32"===t.dtype,(()=>"Input dtype must be `int32` or `float32`.")),"int32"===t.dtype&&(t=Ls(t,"float32"));const n={x:t};return _i.runKernel(Zt,n)}});function fc(e,t){for(let n=0;ne[t]))]}function yc(e,t){return mc(e,t.map((e=>1)),t)}function bc(e,t,n){se(fc(t,n),(()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`))}function xc(e,t){if(fc(e,t))return null;const n=[];for(let r=0;rn.push(e))),n}function vc(e){return e.map(((e,t)=>[t,e])).sort(((e,t)=>e[1]-t[1])).map((e=>e[0]))}function _c(e,t){const n=[];for(let r=t-e;r"Axis must be <= rank of the tensor"));const r={input:n},a={dim:t};return _i.runKernel(tn,r,a)}}),Ec=$i({expm1_:function(e){const t={x:Ci(e,"x","expm1")};return _i.runKernel(nn,t)}}),Cc=$i({tile_:function(e,t){const n=Ci(e,"x","tile","string_or_numeric");se(n.rank===t.length,(()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`));const r={x:n},a={reps:t};return _i.runKernel(Kr,r,a)}}),Ac=$i({eye_:function(e,t,n,r="float32"){null==t&&(t=e);const a=As([e,t],r),i=e<=t?e:t;for(let e=0;e`Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ${i.rank}.`)),se(he(t),(()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`));let s=i,o=!1;3===i.rank&&(o=!0,s=Ml(i,[1,i.shape[0],i.shape[1],i.shape[2]]));const u={x:s},l={depthRadius:t,bias:n,alpha:r,beta:a},c=_i.runKernel(An,u,l);return o?Ml(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),qc=$i({log_:function(e){const t={x:Ci(e,"x","log","float32")};return _i.runKernel(Nn,t)}}),Wc=$i({log1p_:function(e){const t={x:Ci(e,"x","log1p")};return _i.runKernel(Sn,t)}}),Vc=$i({softplus_:function(e){const t={x:Ci(e,"x","softplus")};return _i.runKernel(Ir,t)}}),Gc=$i({logSigmoid_:function(e){const t=Ci(e,"x","logSigmoid"),n=$u((e=>({value:Do(Vc(Do(e))),gradFunc:t=>Su(t,Dl(Do(e)))})));return n(t)}}),Kc=$i({logSoftmax_:function(e,t=-1){const n=Ci(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}`);const r=$u(((e,n)=>{const r=wc(e,t,!0),a=Hu(e,r),i=Hu(Ls(a,"float32"),qc(Nc(Tc(a),t,!0)));return n([i]),{value:i,gradFunc:(e,n)=>{const[r]=n,a=Tc(r);return Hu(e,Su(Nc(e,t,!0),a))}}}));return r(n)}}),Jc=$i({logSumExp_:function(e,t=null,n=!1){const r=Ci(e,"x","logSumExp"),a=ve(t,r.shape),i=wc(r,a,!0),s=Hu(r,i),o=Tc(s),u=Nc(o,a),l=qc(u),c=wu(Ml(i,l.shape),l);if(n){const e=yc(c.shape,a);return Ml(c,e)}return c}}),Xc=$i({logicalAnd_:function(e,t){const n=Ci(e,"a","logicalAnd","bool"),r=Ci(t,"b","logicalAnd","bool");Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(kn,a)}}),Zc=$i({logicalNot_:function(e){const t={x:Ci(e,"x","logicalNot","bool")};return _i.runKernel(Dn,t)}}),Qc=$i({logicalOr_:function(e,t){const n=Ci(e,"a","logicalOr","bool"),r=Ci(t,"b","logicalOr","bool");Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(Tn,a)}}),ep=$i({logicalXor_:function(e,t){const n=Ci(e,"a","logicalXor","bool"),r=Ci(t,"b","logicalXor","bool");return Lo(n.shape,r.shape),Xc(Qc(e,t),Zc(Xc(e,t)))}}),tp=2147483648,np=$i({searchSorted_:function(e,t,n="left"){const r=Ci(e,"sortedSequence","searchSorted"),a=Ci(t,"values","searchSorted"),i=r.shape[r.shape.length-1],s=a.shape[a.shape.length-1],o=Ml(r,[-1,i]),u=Ml(a,[-1,s]);if(o.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(o.shape[0]!==u.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if(ce(u.shape)>=tp)throw new Error("values tensor size must less than 2147483648");if(o.shape[1]>=tp)throw new Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${o.shape[1]}`);const l={sortedSequence:o,values:u},c={side:n};return _i.runKernel(_r,l,c)}});function rp(e,t){return np(e,t,"left")}const ap=$i({maxPool_:function(e,t,n,r,a){const i=Ci(e,"x","maxPool");let s=i,o=!1;3===i.rank&&(o=!0,s=Ml(i,[1,i.shape[0],i.shape[1],i.shape[2]])),se(4===s.rank,(()=>`Error in maxPool: input must be rank 4 but got rank ${s.rank}.`)),se(vl(n,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)),wl("maxPool",r,a);const u={x:s},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a},c=_i.runKernel(Rn,u,l);return o?Ml(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),ip=$i({maxPool3d_:function(e,t=[1,1,1],n,r,a,i="NDHWC"){const s=Ci(e,"x","maxPool3d");let o=s,u=!1;4===s.rank&&(u=!0,o=Ml(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),se(5===o.rank,(()=>`Error in maxPool3d: x must be rank 5 but got rank ${o.rank}.`)),se("NDHWC"===i,(()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${i}`)),wl("maxPool3d",r,a);const l={x:o},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i},p=_i.runKernel(Yn,l,c);return u?Ml(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}}),sp=$i({maxPoolWithArgmax_:function(e,t,n,r,a=!1){const i={x:Ci(e,"x","maxPoolWithArgmax")},s={filterSize:t,strides:n,pad:r,includeBatchInIndex:a},o=_i.runKernel(Bn,i,s);return{result:o[0],indexes:o[1]}}}),op=$i({mean_:function(e,t=null,n=!1){const r={x:Ci(e,"x","mean")},a={axis:t,keepDims:n};return _i.runKernel(Pn,r,a)}});function up(e,t="float32"){if("complex64"===t){const t=up(e,"float32"),n=up(e,"float32");return Oi(t,n)}const n=Be(ce(e),t);return _i.makeTensor(n,e,t)}function lp(e,t="float32"){if("complex64"===t){const t=lp(e,"float32"),n=up(e,"float32");return Oi(t,n)}const n=ze(ce(e),t);return _i.makeTensor(n,e,t)}function cp(e,t,{indexing:n="xy"}={}){if("xy"!==n&&"ij"!==n)throw new TypeError(`${n} is not a valid third argument to meshgrid`);if(void 0===e)return[];let r=Ci(e,"x","meshgrid",e instanceof ti?e.dtype:"float32");if(void 0===t)return[r];let a=Ci(t,"y","meshgrid",t instanceof ti?t.dtype:"float32");const i=ce(r.shape),s=ce(a.shape);return"xy"===n?(r=Ml(r,[1,-1]),a=Ml(a,[-1,1]),[no(lp([s,1],r.dtype),r),no(a,lp([1,i],a.dtype))]):(r=Ml(r,[-1,1]),a=Ml(a,[1,-1]),[no(r,lp([1,s],r.dtype)),no(lp([i,1],a.dtype),a)])}const pp=$i({minimum_:function(e,t){let n=Ci(e,"a","minimum"),r=Ci(t,"b","minimum");[n,r]=di(n,r),"bool"===n.dtype&&(n=Ls(n,"int32"),r=Ls(r,"int32")),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(jn,a)}}),dp=$i({mirrorPad_:function(e,t,n){se("reflect"===n||"symmetric"===n,(()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`));const r=Ci(e,"x","mirrorPad");if(0===r.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");se(t.length===r.rank,(()=>`Padding doesn't match input. Must be ${r.rank}. Got ${t.length}.`));const a="reflect"===n?1:0;for(let e=0;e"Invalid number of paddings. Must be length of 2 each.")),se(t[e][0]>=0&&t[e][0]<=r.shape[e]-a&&t[e][1]>=0&&t[e][1]<=r.shape[e]-a,(()=>`Padding in dimension ${e} cannot be greater than or equal to ${r.shape[e]-a} or less than 0 for input of shape ${r.shape}`));const i={paddings:t,mode:n},s={x:r};return _i.runKernel(Un,s,i)}}),hp=$i({mod_:function(e,t){let n=Ci(e,"a","mod"),r=Ci(t,"b","mod");[n,r]=di(n,r);const a={a:n,b:r};return _i.runKernel(qn,a)}}),fp=$i({moments_:function(e,t=null,n=!1){const r=ve(t,(e=Ci(e,"x","moments")).shape),a=op(e,r,n);let i=a.shape;n||(i=yc(a.shape,r));const s=Du(Hu(Ls(e,"float32"),Ml(a,i)));return{mean:a,variance:op(s,r,n)}}}),mp=$i({multiRNNCell_:function(e,t,n,r){const a=Ci(t,"data","multiRNNCell"),i=Ai(n,"c","multiRNNCell"),s=Ai(r,"h","multiRNNCell");let o=a;const u=[];for(let t=0;t2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${s}`);n=n||Math.random();const o={logits:1===s?Ml(a,[1,-1]):a},u={numSamples:t,seed:n,normalized:r},l=_i.runKernel(Wn,o,u);return 1===s?Ml(l,[l.size]):l}}),yp=$i({notEqual_:function(e,t){let n=Ci(e,"a","notEqual","string_or_numeric"),r=Ci(t,"b","notEqual","string_or_numeric");[n,r]=di(n,r),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(Kn,a)}}),bp=$i({onesLike_:function(e){const t={x:Ci(e,"x","onesLike")};return _i.runKernel(Qn,t)}}),xp=$i({outerProduct_:function(e,t){const n=Ci(e,"v1","outerProduct"),r=Ci(t,"v2","outerProduct");se(1===n.rank&&1===r.rank,(()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${r.rank}.`));const a=Ml(n,[-1,1]),i=Ml(r,[1,-1]);return no(a,i)}}),vp=$i({pad_:function(e,t,n=0){const r=Ci(e,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const a={paddings:t,constantValue:n},i={x:r};return _i.runKernel(nr,i,a)}}),_p=$i({pad1d_:function(e,t,n=0){return se(2===t.length,(()=>"Invalid number of paddings. Must be length of 2.")),vp(e,[t],n)}}),wp=$i({pad2d_:function(e,t,n=0){return se(2===t.length&&2===t[0].length&&2===t[1].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),vp(e,t,n)}}),Mp=$i({pad3d_:function(e,t,n=0){return se(3===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),vp(e,t,n)}}),Np=$i({pad4d_:function(e,t,n=0){return se(4===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length&&2===t[3].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),vp(e,t,n)}}),Sp=$i({spaceToBatchND_:function(e,t,n){const r=Ci(e,"x","spaceToBatchND");se(r.rank>=1+t.length,(()=>`input rank ${r.rank} should be > than [blockShape] ${t.length}`)),se(n.length===t.length,(()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`)),se(r.shape.reduce(((e,r,a)=>a>0&&a<=t.length?e&&(r+n[a-1][0]+n[a-1][1])%t[a-1]==0:e),!0),(()=>`input spatial dimensions ${r.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`));const a={x:r},i={blockShape:t,paddings:n};return _i.runKernel(Ar,a,i)}}),kp=$i({pool_:function(e,t,n,r,a,i,s){null==a&&(a=[1,1]),null==i&&(i=1),0===r&&(r="valid");const o=Ci(e,"x","maxPool");let u=o,l=!1;3===o.rank&&(l=!0,u=Ml(o,[1,o.shape[0],o.shape[1],o.shape[2]])),se(vl(i,a),(()=>`Error in pool: Either strides or dilations must be 1. Got strides ${i} and dilations '${a}'`));const c=cl(u.shape,t,i,a,r),p=[c.dilationHeight,c.dilationWidth];let d;d="same"===r?function(e,t){const n=e.map(((e,n)=>e+(e-1)*(t[n]-1))),r=n.map((e=>e-1)),a=r.map((e=>Math.floor(e/2))),i=r.map(((e,t)=>e-a[t]));return r.map(((e,t)=>[a[t],i[t]]))}([c.filterHeight,c.filterWidth],p):[[0,0],[0,0]];const h=1===p[0]&&1===p[1],[f,m]=function(e,t,n){const r=n.map((e=>e[0])),a=n.map((e=>e[1])),i=e.concat(r,a),s=t.map(((e,t)=>(e-i[t]%e)%e)),o=a.map(((e,t)=>e+s[t])),u=t.map(((e,t)=>[r[t],o[t]])),l=t.map(((e,t)=>[0,s[t]]));return[u,l]}([c.inHeight,c.inWidth],p,d),g=h?r:"valid",y=h?u:Sp(u,p,f),b=("avg"===n?()=>Nl(y,t,i,g,s):()=>ap(y,t,i,g,s))(),x=h?b:Cl(b,p,m);return l?Ml(x,[x.shape[1],x.shape[2],x.shape[3]]):x}}),Dp=$i({prelu_:function(e,t){const n={x:Ci(e,"x","prelu"),alpha:Ci(t,"alpha","prelu")};return _i.runKernel(ir,n)}}),Tp=$i({prod_:function(e,t=null,n=!1){let r=Ci(e,"x","prod");"bool"===r.dtype&&(r=Ls(r,"int32"));const a={x:r},i={axis:t,keepDims:n};return _i.runKernel(sr,a,i)}}),Ip=$i({rand_:function(e,t,n){const r=ce(e);let a=null;if(null==n||"float32"===n)a=new Float32Array(r);else if("int32"===n)a=new Int32Array(r);else{if("bool"!==n)throw new Error(`Unknown data type ${n}`);a=new Uint8Array(r)}for(let e=0;e=1||0===i);const s=Math.sqrt(-2*Math.log(i)/i);e=this.mean+this.stdDev*r*s,t=this.mean+this.stdDev*a*s,this.truncated&&!this.isValidTruncated(e)||(n=!0)}return this.truncated&&!this.isValidTruncated(t)||(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class Ap{constructor(e,t,n,r){this.alpha=e,this.beta=1/t,this.dtype=n;const a=r||Math.random();this.randu=Ep.alea(a.toString()),this.randn=new Cp(0,1,n,!1,this.randu()),this.d=e<1?e+2/3:e-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let e,t,n,r,a,i;for(;;){do{r=this.randn.nextValue(),i=1+this.c*r}while(i<=0);if(i*=i*i,e=r*r,t=1-.331*e*e,n=.5*e+this.d*(1-i+Math.log(i)),a=this.randu(),anull==this.dtype||"float32"===this.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=Ep.alea(r)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}const $p=$i({randomGamma_:function(e,t,n=1,r="float32",a){if(null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error(`Unsupported data type ${r}`);const i=new Ap(t,n,r,a),s=As(e,r);for(let e=0;e`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`)),Hp(t,0)}}),Up=$i({reverse2d_:function(e,t){const n=Ci(e,"x","reverse");return se(2===n.rank,(()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`)),Hp(n,t)}}),qp=$i({reverse3d_:function(e,t){const n=Ci(e,"x","reverse");return se(3===n.rank,(()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`)),Hp(n,t)}}),Wp=$i({reverse4d_:function(e,t){const n=Ci(e,"x","reverse");return se(4===n.rank,(()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`)),Hp(n,t)}}),Vp=$i({round_:function(e){const t={x:Ci(e,"x","round")};return _i.runKernel(br,t)}}),Gp=$i({rsqrt_:function(e){const t={x:Ci(e,"x","rsqrt","float32")};return _i.runKernel(xr,t)}}),Kp=$i({selu_:function(e){const t={x:Ci(e,"x","selu")};return _i.runKernel(Mr,t)}}),Jp=$i({separableConv2d_:function(e,t,n,r,a,i=[1,1],s="NHWC"){const o=Ci(e,"x","separableConv2d"),u=Ci(t,"depthwiseFilter","separableConv2d"),l=Ci(n,"pointwiseFilter","separableConv2d");let c=o,p=!1;if(3===o.rank&&(p=!0,c=Ml(o,[1,o.shape[0],o.shape[1],o.shape[2]])),"NCHW"===s)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");se(4===c.rank,(()=>`Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`)),se(4===u.rank,(()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${u.rank}.`)),se(4===l.rank,(()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${u.rank}.`)),se(1===l.shape[0],(()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${l.shape[0]}.`)),se(1===l.shape[1],(()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${l.shape[1]}.`));const d=u.shape[2],h=u.shape[3];se(l.shape[2]===d*h,(()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${d*h}, but got ${l.shape[2]}.`));const f=ac(c,u,r,a,s,i),m=ql(f,l,1,"valid",s);return p?Ml(m,[m.shape[1],m.shape[2],m.shape[3]]):m}}),Xp=async function(e,t){const n=Ci(e,"x","setdiff1d"),r=Ci(t,"y","setdiff1d");se(n.dtype===r.dtype,(()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${r.dtype}).`)),se(1===n.rank,(()=>`x should be 1D tensor, but got x (${n.shape}).`)),se(1===r.rank,(()=>`y should be 1D tensor, but got y (${r.shape}).`));const a=await n.data(),i=await r.data(),s=new Set(i);let o=0;for(let e=0;e`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`)),Tl(r,[t],[n])}}),nd=$i({slice2d_:function(e,t,n){const r=Ci(e,"x","slice2d");return se(2===r.rank,(()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`)),Tl(r,t,n)}}),rd=$i({slice3d_:function(e,t,n){const r=Ci(e,"x","slice3d");return se(3===r.rank,(()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`)),Tl(r,t,n)}}),ad=$i({slice4d_:function(e,t,n){const r=Ci(e,"x","slice4d");return se(4===r.rank,(()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`)),Tl(r,t,n)}}),id=$i({softmax_:function(e,t=-1){const n=Ci(e,"logits","softmax","float32");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}`);const r={logits:n},a={dim:t};return _i.runKernel($r,r,a)}}),sd=$i({fft_:function(e){se("complex64"===e.dtype,(()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`));const t={input:e};return _i.runKernel(rn,t)}}),od=$i({ifft_:function(e){se("complex64"===e.dtype,(()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`));const t={input:e};return _i.runKernel(mn,t)}}),ud=$i({irfft_:function(e){const t=e.shape[e.shape.length-1],n=e.size/t;let r;if(t<=2){const a=Ml(e,[n,t]);r=od(a)}else{const a=[n,2*(t-1)],i=Ml(To(e),[n,t]),s=Ml(ko(e),[n,t]),o=Hp(Tl(i,[0,1],[n,t-2]),1),u=Su(Hp(Tl(s,[0,1],[n,t-2]),1),Ru(-1)),l=kl([i,o],1),c=kl([s,u],1),p=Ml(Oi(l,c),[a[0],a[1]]);r=od(p)}if(r=To(r),3===e.rank&&0!==e.shape[0]){const t=r,n=e.shape[0];r=Ml(r,[n,r.shape[0]/n,r.shape[1]]),t.dispose()}return r}}),ld=$i({split_:function(e,t,n=0){const r={x:Ci(e,"x","split")},a={numOrSizeSplits:t,axis:n};return _i.runKernel(Lr,r,a)}}),cd=$i({rfft_:function(e,t){se("float32"===e.dtype,(()=>`The dtype for rfft() must be real value but got ${e.dtype}`));let n=e.shape[e.shape.length-1];const r=e.size/n;let a;if(null!=t&&t0)),i=e.shape.map((e=>e));i[e.shape.length-1]=t,a=Tl(e,r,i),n=t}else if(null!=t&&t>n){const r=e.shape.map((e=>e));r[e.shape.length-1]=t-n,a=kl([e,up(r)],e.shape.length-1),n=t}else a=e;const i=Tu(a),s=Ml(Oi(a,i),[r,n]),o=sd(s),u=Math.floor(n/2)+1,l=To(o),c=ko(o),p=ld(l,[u,n-u],l.shape.length-1),d=ld(c,[u,n-u],c.shape.length-1),h=a.shape.slice();return h[a.shape.length-1]=u,Ml(Oi(p[0],d[0]),h)}}),pd=$i({squaredDifference_:function(e,t){let n=Ci(e,"a","squaredDifference"),r=Ci(t,"b","squaredDifference");[n,r]=di(n,r),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(Br,a,{})}}),dd=$i({squeeze_:function(e,t){const n=Ci(e,"x","squeeze","string_or_numeric");return Ml(n,_e(n.shape,t).newShape)}}),hd=$i({stack_:function(e,t=0){const n=Ai(e,"tensors","stack","string_or_numeric");se(n.length>=1,(()=>"Pass at least one tensor to tf.stack")),n.length>0&&se(t<=n[0].rank,(()=>"Axis must be <= rank of the tensor"));const r=n,a={axis:t};return _i.runKernel(tr,r,a)}}),fd=$i({step_:function(e,t=0){const n={x:Ci(e,"x","step")},r={alpha:t};return _i.runKernel(aa,n,r)}}),md=$i({stridedSlice_:function(e,t,n,r,a=0,i=0,s=0,o=0,u=0){const l={x:Ci(e,"x","stridedSlice","string_or_numeric")},c={begin:t,end:n,strides:r,beginMask:a,endMask:i,ellipsisMask:s,newAxisMask:o,shrinkAxisMask:u};return _i.runKernel(Hr,l,c)}}),gd=$i({tan_:function(e){const t={x:Ci(e,"x","tan","float32")};return _i.runKernel(Vr,t)}});function yd(e,t){ue(e);const n=Ti(e,t);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return Ri(e,null,n,t)}function bd(e,t,n){if(ue(e),null!=t&&2!==t.length)throw new Error("tensor2d() requires shape to have two numbers");const r=Ti(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 Ri(e,t,r,n)}function xd(e,t,n){if(ue(e),null!=t&&4!==t.length)throw new Error("tensor4d() requires shape to have four numbers");const r=Ti(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 Ri(e,t,r,n)}function vd(e,t,n){if(ue(e),null!=t&&5!==t.length)throw new Error("tensor5d() requires shape to have five numbers");const r=Ti(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 Ri(e,t,r,n)}function _d(e,t,n){if(ue(e),null!=t&&6!==t.length)throw new Error("tensor6d() requires shape to have six numbers");const r=Ti(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 Ri(e,t=t||r,r,n)}const wd=$i({topk_:function(e,t=1,n=!0){const r=Ci(e,"x","topk");if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");const a=r.shape[r.shape.length-1];if(t<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${t}`);if(t>a)throw new Error(`'k' passed to topk() must be <= the last dimension (${a}) but got ${t}`);const i={x:r},s={k:t,sorted:n},[o,u]=_i.runKernel(Jr,i,s);return{values:o,indices:u}}}),Md=$i({truncatedNormal_:function(e,t=0,n=1,r,a){if(null!=r&&"bool"===r)throw new Error("Unsupported data type $ { dtype }");const i=new Cp(t,n,r,!0,a),s=As(e,r);for(let e=0;e0,(()=>"The input tensor must be at least 1D"));const r={x:n},a={axis:t},[i,s]=_i.runKernel(Qr,r,a);return{values:i,indices:s}}}),Sd=$i({unsortedSegmentSum_:function(e,t,n){const r=Ci(e,"x","unsortedSegmentSum"),a=Ci(t,"segmentIds","unsortedSegmentSum","int32");se(he(n),(()=>"numSegments must be of dtype int"));const i={x:r,segmentIds:a},s={numSegments:n};return _i.runKernel(ta,i,s)}}),kd=$i({unstack_:function(e,t=0){const n=Ci(e,"x","unstack","string_or_numeric");se(t>=-n.shape.length&&t`Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`));const r={value:n},a={axis:t};return _i.runKernel(ea,r,a)}});function Dd(e,t){return np(e,t,"right")}function Td(e,t=!0,n,r){return _i.makeVariable(e,t,n,r)}function Id(e,t){const n=[];for(let e=0;e0,(()=>"mask cannot be scalar")),oe(o.slice(i,i+s),a.shape,"mask's shape must match the first K dimensions of tensor's shape,");let u=1;for(let e=i;e"Shape mismatch in v and x"));const u=Ru(1),l=Hu(u,o);let c=Su(Hu(s,i),l);if(a){se(null!=r,(()=>"When using zeroDebias: true, step is required."));const e=Ci(r,"step","movingAverage");c=Nu(c,Hu(u,Pu(o,e)))}return wu(i,c)}}),Ld=$i({scatterND_:function(e,t,n){const r=Ci(e,"indices","scatterND","int32"),a=Ci(t,"updates","scatterND");Ho(a,r,n);const i={indices:r,updates:a},s={shape:n};return _i.runKernel(vr,i,s)}}),$d=$i({sparseToDense_:function(e,t,n,r=0){const a=Ci(e,"sparseIndices","sparseToDense","int32"),i=Ci(t,"sparseValues","sparseToDense","string_or_numeric"),s=Ci(r,"defaultValue","sparseToDense",i.dtype);!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}.`);const a=e.rank>0?e.shape[0]:1,i=e.rank>1?e.shape[1]:1;if(n.length!==i)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${i}.`);const s=t.size;if(0!==t.rank&&(1!==t.rank||s!==a))throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${a}]`);if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(a,i,n,s);const o={sparseIndices:a,sparseValues:i,defaultValue:s},u={outputShape:n};return _i.runKernel(zr,o,u)}}),Od=$i({gatherND_:function(e,t){const n=Ci(t,"indices","gatherND","int32"),r={params:Ci(e,"x","gatherND","string_or_numeric"),indices:n};return _i.runKernel(pn,r)}}),Rd=$i({dropout_:function(e,t,n,r){const a=Ci(e,"x","dropout");if(se("float32"===a.dtype,(()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${a.dtype} tensor instead.`)),se(t>=0&&t<1,(()=>`rate must be a float in the range [0, 1), but got ${t}.`)),0===t)return e instanceof ti?a.clone():a;const i=function(e,t){if(null==t)return e.shape.slice();if(de(e.shape,t))return t;if(e.shape.length===t.length){const n=[];for(let r=0;r1,(()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`)),se(r.rank-1===a.rank,(()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${a.rank}`)),oe(r.shape.slice(0,r.shape.length-1),a.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const i=r.shape[r.shape.length-1];se(n>0&&n<=i,(()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${i}), but got ${n}`));const s=await r.data(),o=await a.data(),[u,l]=[s.length/i,i],c=we("bool",u);for(let e=0;et.value-e.value)),c[e]=0;for(let t=0;t`Error in conv2dDerFilter: input must be rank 4, but got shape ${o.shape}.`)),se(4===u.rank,(()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${u.shape}.`)),se(4===n.length,(()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`));const l="NHWC"===i?o.shape[3]:o.shape[1],c="NHWC"===i?u.shape[3]:u.shape[1];se(l===n[2],(()=>`Error in conv2dDerFilter: depth of input ${l}) must match input depth in filter (${n[2]}.`)),se(c===n[3],(()=>`Error in conv2dDerFilter: depth of dy (${c}) must match output depth for filter (${n[3]}).`)),wl("conv2dDerFilter",a,s);const p={x:o,dy:u},d={strides:r,pad:a,dataFormat:i,dimRoundingMode:s,filterShape:n};return _i.runKernel(It,p,d)}});function Pd(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return Su(e,fd(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function Hd(e,t){let n=t;const r=Ao(e.shape,t.shape);return r.length>0&&(n=Nc(n,r)),Ml(n,e.shape)}function jd(e,t,n,r){if("linear"===t)return e;if("relu"===t)return Bp(e);if("elu"===t)return dc(e);if("relu6"===t)return Pp(e);if("prelu"===t)return Dp(e,n);if("leakyrelu"===t)return Bc(e,r);if("sigmoid"===t)return Dl(e);throw new Error(`Unknown fused activation ${t}.`)}const Ud=(e,t)=>!(e>0)||"linear"===t,qd=$i({fusedConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:i=[1,1],dimRoundingMode:s,bias:o,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(u=u||"linear",!1===Ud(_i.state.gradientDepth,u)){se("NHWC"===a,(()=>`Error in fused conv2d: got dataFormat of ${a} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`));let p=ql(e,t,n,r,a,i,s);return null!=o&&(p=wu(p,o)),jd(p,u,l,c)}const p=Ci(e,"x","conv2d","float32"),d=Ci(t,"filter","conv2d","float32");let h=p,f=!1;3===p.rank&&(f=!0,h=Ml(p,[1,p.shape[0],p.shape[1],p.shape[2]])),se(4===h.rank,(()=>`Error in fused conv2d: input must be rank 4, but got rank ${h.rank}.`)),se(4===d.rank,(()=>`Error in fused conv2d: filter must be rank 4, but got rank ${d.rank}.`)),wl("fused conv2d",r,s);const m="NHWC"===a?h.shape[3]:h.shape[1];se(d.shape[2]===m,(()=>`Error in conv2d: depth of input (${m}) must match input depth for filter ${d.shape[2]}.`)),se(vl(n,i),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`));const g=dl(h.shape,d.shape,n,i,r,s);let y,b;if(null!=o&&(y=Ci(o,"bias","fused conv2d"),[y]=di(y,p),"NHWC"===a?Lo(g.outShape,y.shape):(se(y.shape.length<=1,(()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${y.shape.length}.`)),se(0===y.shape.length||y.shape[0]===g.outChannels||1===y.shape[0],(()=>`Error in fused conv2d: bias shape (${y.shape}) is not compatible with the number of output channels (${g.outChannels})`)))),null!=l){const e=l.shape;if(se(e.length<=1||3===e.length,(()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${e.length}.`)),1===e.length)se(1===e[0]||e[0]===g.outChannels,(()=>`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the number of output channels (${g.outChannels}).`));else if(3===e.length)try{Lo(e,g.outShape)}catch(t){const n=`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the output shape of the conv2d (${g.outShape}).`;throw Error(n)}b=Ci(l,"prelu weights","fused conv2d")}const x=(e,t)=>{se("NHWC"===a,(()=>`Error in gradient of fused conv2D: got dataFormat of ${a} but only NHWC is currently supported.`));const[s,o,l,c]=t,p=Pd(e,l,u);se(xl(i),(()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${i}'`));const d=[Vl(o.shape,p,s,n,r),Bd(o,p,s.shape,n,r)];if(null!=c){const e=Hd(c,p);d.push(e)}return d},v={x:h,filter:d,bias:y,preluActivationWeights:b},_={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s,activation:u,leakyreluAlpha:c};if(null==o){const e=$u(((e,t,n)=>{let r=_i.runKernel(ua,v,_);return n([t,e,r]),f&&(r=Ml(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:x}}));return e(h,d)}{const e=$u(((e,t,n,r)=>{let a=_i.runKernel(ua,v,_);return r([t,e,a,n]),f&&(a=Ml(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:x}}));return e(h,d,y)}}}),Wd=$i({depthwiseConv2dNativeBackpropFilter_:function(e,t,n,r,a,i=[1,1],s){let o=e;3===e.rank&&(o=Ml(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let u=t;3===u.rank&&(u=Ml(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const l={x:o,dy:u},c={strides:r,pad:a,dimRoundingMode:s,dilations:i,filterShape:n};return _i.runKernel(Ht,l,c)}}),Vd=$i({depthwiseConv2dNativeBackpropInput_:function(e,t,n,r,a,i=[1,1],s){let o=t,u=!1;3===t.rank&&(u=!0,o=Ml(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const l={dy:o,filter:n},c={strides:r,pad:a,dimRoundingMode:s,dilations:i,inputShape:e},p=_i.runKernel(jt,l,c);return u?Ml(p,[p.shape[1],p.shape[2],p.shape[3]]):p}}),Gd=$i({fusedDepthwiseConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:i=[1,1],dimRoundingMode:s,bias:o,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(!1===Ud(_i.state.gradientDepth,u)){let p=ac(e,t,n,r,a,i,s);return null!=o&&(p=wu(p,o)),jd(p,u,l,c)}const p=Ci(e,"x","depthwiseConv2d","float32"),d=Ci(t,"filter","depthwiseConv2d","float32");let h=p,f=!1;3===p.rank&&(f=!0,h=Ml(p,[1,p.shape[0],p.shape[1],p.shape[2]])),se(4===h.rank,(()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${h.rank}.`)),se(4===d.rank,(()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${d.rank}.`)),se(h.shape[3]===d.shape[2],(()=>`Error in fused depthwiseConv2d: number of input channels (${h.shape[3]}) must match the inChannels dimension in filter ${d.shape[2]}.`)),null==i&&(i=[1,1]),se(vl(n,i),(()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`)),wl("fused depthwiseConv2d",r,s);const m=dl(h.shape,d.shape,n,i,r,s,!0);let g,y;null!=o&&(g=Ci(o,"bias","fused conv2d"),[g]=di(g,p),Lo(m.outShape,g.shape)),null!=l&&(y=Ci(l,"prelu weights","fused depthwiseConv2d"));const b=(e,t)=>{se(xl(i),(()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${i}'`));const[a,o,l,c]=t,p=Pd(e,l,u),d=Vd(o.shape,p,a,n,r,i,s),h=Wd(o,p,a.shape,n,r,i,s);return null!=c?[d,h,Hd(g,p)]:[d,h]},x={x:h,filter:d,bias:g,preluActivationWeights:y},v={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s,activation:u,leakyreluAlpha:c};if(null==o){const e=$u(((e,t,n)=>{let r=_i.runKernel(la,x,v);return n([t,e,r]),f&&(r=Ml(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:b}}));return e(h,d)}{const e=$u(((e,t,n,r)=>{let a=_i.runKernel(la,x,v);return r([t,e,a,n]),f&&(a=Ml(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:b}}));return e(h,d,g)}}}),Kd=$i({fusedMatMul_:function({a:e,b:t,transposeA:n=!1,transposeB:r=!1,bias:a,activation:i="linear",preluActivationWeights:s,leakyreluAlpha:o=.2}){if(!1===Ud(_i.state.gradientDepth,i)){let u=no(e,t,n,r);return null!=a&&(u=wu(u,a)),jd(u,i,s,o)}let u=Ci(e,"a","fused matMul"),l=Ci(t,"b","fused matMul");[u,l]=di(u,l);const c=n?u.shape[u.rank-2]:u.shape[u.rank-1],p=r?l.shape[l.rank-1]:l.shape[l.rank-2],d=n?u.shape[u.rank-1]:u.shape[u.rank-2],h=r?l.shape[l.rank-2]:l.shape[l.rank-1],f=u.shape.slice(0,-2),m=l.shape.slice(0,-2),g=ce(f),y=ce(m);se(c===p,(()=>`Error in fused matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${u.shape} and ${l.shape} and transposeA=${n} and transposeB=${r} must match.`));const b=Lo(u.shape.slice(0,-2),l.shape.slice(0,-2)).concat([d,h]),x=Ml(u,n?[g,c,d]:[g,d,c]),v=Ml(l,r?[y,h,p]:[y,p,h]);let _,w;null!=a&&(_=Ci(a,"bias","fused matMul"),[_]=di(_,u),Lo(b,_.shape)),null!=s&&(w=Ci(s,"prelu weights","fused matMul"));const M=(e,t)=>{const[s,o,u,l]=t,c=Pd(Ml(e,u.shape),u,i);let p,d;return n||r?!n&&r?(p=no(c,o,!1,!1),d=no(c,s,!0,!1)):n&&!r?(p=no(o,c,!1,!0),d=no(s,c,!1,!1)):(p=no(o,c,!0,!0),d=no(c,s,!0,!0)):(p=no(c,o,!1,!0),d=no(s,c,!0,!1)),null!=a?[p,d,Hd(l,c)]:[p,d]},N={a:x,b:v,bias:_,preluActivationWeights:w},S={transposeA:n,transposeB:r,activation:i,leakyreluAlpha:o};if(null==a){const e=$u(((e,t,n)=>{const r=_i.runKernel(oa,N,S);return n([e,t,r]),{value:Ml(r,b),gradFunc:M}}));return e(x,v)}{const e=$u(((e,t,n,r)=>{const a=_i.runKernel(oa,N,S);return r([e,t,a,n]),{value:Ml(a,b),gradFunc:M}}));return e(x,v,_)}}}),Jd=$i({hammingWindow_:function(e){return Yd(e,.54,.46)}}),Xd=$i({hannWindow_:function(e){return Yd(e,.5,.5)}}),Zd=$i({frame_:function(e,t,n,r=!1,a=0){let i=0;const s=[];for(;i+t<=e.size;)s.push(Tl(e,i,t)),i+=n;if(r)for(;i`Error in cropAndResize: image must be rank 4,but got rank ${s.rank}.`)),se(2===o.rank&&4===o.shape[1],(()=>`Error in cropAndResize: boxes must be have size [${l},4] but had shape ${o.shape}.`)),se(1===u.rank&&u.shape[0]===l,(()=>`Error in cropAndResize: boxInd must be have size [${l}] but had shape ${o.shape}.`)),se(2===r.length,(()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`)),se(r[0]>=1&&r[1]>=1,(()=>`cropSize must be atleast [1,1], but was ${r}`)),se("bilinear"===a||"nearest"===a,(()=>`method must be bilinear or nearest, but was ${a}`));const c={image:s,boxes:o,boxInd:u},p={method:a,extrapolationValue:i,cropSize:r};return _i.runKernel(Yt,c,p)}}),th=$i({flipLeftRight_:function(e){const t=Ci(e,"image","flipLeftRight","float32");se(4===t.rank,(()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`));const n={image:t};return _i.runKernel(sn,n,{})}}),nh=$i({grayscaleToRGB_:function(e){const t=Ci(e,"image","grayscaleToRGB"),n=t.rank-1,r=t.shape[n];se(t.rank>=2,(()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`)),se(1===r,(()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`));const a=new Array(t.rank);return a.fill(1,0,n),a[n]=3,Cc(t,a)}}),rh=$i({rotateWithOffset_:function(e,t,n=0,r=.5){const a=Ci(e,"image","rotateWithOffset","float32");se(4===a.rank,(()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${a.rank}.`));const i={image:a},s={radians:t,fillValue:n,center:r};return _i.runKernel(sa,i,s)}});function ah(e,t,n,r,a,i){null==r&&(r=.5),null==a&&(a=Number.NEGATIVE_INFINITY),null==i&&(i=0);const s=e.shape[0];return n=Math.min(n,s),se(0<=r&&r<=1,(()=>`iouThreshold must be in [0, 1], but was '${r}'`)),se(2===e.rank,(()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`)),se(4===e.shape[1],(()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`)),se(1===t.rank,(()=>"scores must be a 1D tensor")),se(t.shape[0]===s,(()=>`scores has incompatible shape with boxes. Expected ${s}, but was ${t.shape[0]}`)),se(0<=i&&i<=1,(()=>`softNmsSigma must be in [0, 1], but was '${i}'`)),{maxOutputSize:n,iouThreshold:r,scoreThreshold:a,softNmsSigma:i}}const ih=$i({nonMaxSuppression_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const i=Ci(e,"boxes","nonMaxSuppression","float32"),s=Ci(t,"scores","nonMaxSuppression","float32"),o=ah(i,s,n,r,a),u={maxOutputSize:n=o.maxOutputSize,iouThreshold:r=o.iouThreshold,scoreThreshold:a=o.scoreThreshold};return _i.runKernel(Jn,{boxes:i,scores:s},u)}});function sh(e,t,n){const r=function(e,t,n){return function(e,t,n){let r=0,a=e.length,i=0,s=!1;for(;r>>1);const o=n(t,e[i]);o>0?r=i+1:(a=i,s=!o)}return s?r:-r-1}(e,t,n||oh)}(e,t,n),a=r<0?-(r+1):r;e.splice(a,0,t)}function oh(e,t){return e>t?1:ea&&l.push({score:t[e],boxIndex:e,suppressBeginIndex:0});l.sort(fh);const c=i>0?-.5/i:0,p=[],d=[];for(;p.length0;){const t=l.pop(),{score:n,boxIndex:i,suppressBeginIndex:s}=t;if(n=s;--n){const s=dh(e,i,p[n]);if(s>=r){o=!0;break}if(t.score=t.score*hh(r,c,s),t.score<=a)break}t.suppressBeginIndex=p.length,o||(t.score===n?(p.push(i),d.push(t.score)):t.score>a&&sh(l,t,fh))}const h=p.length,f=n-h;o&&f>0&&(p.push(...new Array(f).fill(0)),d.push(...new Array(f).fill(0)));const m={selectedIndices:p};return s&&(m.selectedScores=d),u&&(m.validOutputs=h),m}function dh(e,t,n){const r=e.subarray(4*t,4*t+4),a=e.subarray(4*n,4*n+4),i=Math.min(r[0],r[2]),s=Math.min(r[1],r[3]),o=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),l=Math.min(a[0],a[2]),c=Math.min(a[1],a[3]),p=Math.max(a[0],a[2]),d=Math.max(a[1],a[3]),h=(o-i)*(u-s),f=(p-l)*(d-c);if(h<=0||f<=0)return 0;const m=Math.max(i,l),g=Math.max(s,c),y=Math.min(o,p),b=Math.min(u,d),x=Math.max(y-m,0)*Math.max(b-g,0);return x/(h+f-x)}function hh(e,t,n){const r=Math.exp(t*n*n);return n<=e?r:0}function fh(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}const mh=$i({nonMaxSuppressionWithScore_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=0){const s=Ci(e,"boxes","nonMaxSuppression"),o=Ci(t,"scores","nonMaxSuppression"),u=ah(s,o,n,r,a,i),l={boxes:s,scores:o},c={maxOutputSize:n=u.maxOutputSize,iouThreshold:r=u.iouThreshold,scoreThreshold:a=u.scoreThreshold,softNmsSigma:i=u.softNmsSigma},p=_i.runKernel(Zn,l,c);return{selectedIndices:p[0],selectedScores:p[1]}}}),gh=$i({nonMaxSuppressionPadded_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=!1){const s=Ci(e,"boxes","nonMaxSuppression"),o=Ci(t,"scores","nonMaxSuppression"),u=ah(s,o,n,r,a,null),l={boxes:s,scores:o},c={maxOutputSize:u.maxOutputSize,iouThreshold:u.iouThreshold,scoreThreshold:u.scoreThreshold,padToMaxOutputSize:i},p=_i.runKernel(Xn,l,c);return{selectedIndices:p[0],validOutputs:p[1]}}}),yh=$i({resizeBilinear_:function(e,t,n=!1,r=!1){const a=Ci(e,"images","resizeBilinear");se(3===a.rank||4===a.rank,(()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${a.rank}.`)),se(2===t.length,(()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`)),se(!1===r||!1===n,(()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false."));let i=a,s=!1;3===a.rank&&(s=!0,i=Ml(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const[]=t,o={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=_i.runKernel(fr,o,u);return s?Ml(l,[l.shape[1],l.shape[2],l.shape[3]]):l}}),bh=$i({resizeNearestNeighbor_:function(e,t,n=!1,r=!1){const a=Ci(e,"images","resizeNearestNeighbor");se(3===a.rank||4===a.rank,(()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${a.rank}.`)),se(2===t.length,(()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`)),se("float32"===a.dtype||"int32"===a.dtype,(()=>"`images` must have `int32` or `float32` as dtype")),se(!1===r||!1===n,(()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."));let i=a,s=!1;3===a.rank&&(s=!0,i=Ml(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const[]=t,o={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=_i.runKernel(dr,o,u);return s?Ml(l,[l.shape[1],l.shape[2],l.shape[3]]):l}}),xh=$i({threshold_:function(e,t="binary",n=!1,r=.5){const a=Ci(e,"image","threshold"),i=a.shape[0]*a.shape[1];let s,o,u,l,c=Su(yd([r]),255);if(se(3===a.rank,(()=>`Error in threshold: image must be rank 3,but got rank ${a.rank}.`)),se(3===a.shape[2]||1===a.shape[2],(()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${a.shape[2]}.`)),se("int32"===a.dtype||"float32"===a.dtype,(()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${a.dtype}.`)),se("otsu"===t||"binary"===t,(()=>`Method must be binary or otsu, but was ${t}`)),3===a.shape[2]){[s,o,u]=ld(a,[1,1,1],-1);const e=Su(s,.2989),t=Su(o,.587),n=Su(u,.114);l=wu(wu(e,t),n)}else l=e;"otsu"===t&&(c=function(e,t){let n,r,a,i,s,o,u=yd([-1]),l=yd([0]),c=yd([0]);for(let p=0;p`Error in transform: image must be rank 4,but got rank ${s.rank}.`)),se(2===o.rank&&(o.shape[0]===s.shape[0]||1===o.shape[0])&&8===o.shape[1],(()=>"Error in transform: Input transform should be batch x 8 or 1 x 8")),se(null==i||2===i.length,(()=>`Error in transform: outputShape must be [height, width] or null, but got ${i}.`));const u={image:s,transforms:o},l={interpolation:n,fillMode:r,fillValue:a,outputShape:i};return _i.runKernel(Xr,u,l)}}),_h=$i({bandPart_:function(e,t,n){se(t%1==0,(()=>`bandPart(): numLower must be an integer, got ${t}.`)),se(n%1==0,(()=>`bandPart(): numUpper must be an integer, got ${n}.`));const r=Ci(e,"a","bandPart");se(r.rank>=2,(()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`));const a=r.shape,[i,s]=r.shape.slice(-2);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);const o=Ml(Yp(0,i,1,"int32"),[-1,1]),u=Yp(0,s,1,"int32"),l=Hu(o,u),c=Xc(Hc(l,Ru(+t,"int32")),Rc(l,Ru(-n,"int32"))),p=up([i,s],r.dtype);return Ml(hd(kd(Ml(r,[-1,i,s])).map((e=>uc(c,e,p)))),a)}}),wh=$i({gramSchmidt_:function(e){let t;if(Array.isArray(e)){t=!1,se(null!=e&&e.length>0,(()=>"Gram-Schmidt process: input must not be null, undefined, or empty"));const n=e[0].shape[0];for(let t=1;t`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${n})`))}else t=!0,e=ld(e,e.shape[0],0).map((e=>dd(e,[0])));se(e.length<=e[0].shape[0],(()=>`Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`));const n=[],r=e;for(let t=0;t{let e=r[t];if(t>0)for(let r=0;r{se(2===e.shape.length,(()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`));const n=e.shape[0],r=e.shape[1];let a=Ac(n),i=$s(e);const s=bd([[1]],[1,1]);let o=$s(s);const u=n>=r?r:n;for(let e=0;e{const t=Tl(i,[e,e],[n-e,1]),u=kc(t),l=Tl(i,[e,e],[1,1]),c=uc(Oc(l,0),bd([[-1]]),bd([[1]])),p=Hu(l,Su(c,u)),d=Nu(t,p);o=1===d.shape[0]?$s(s):kl([s,Tl(d,[1,0],[d.shape[0]-1,d.shape[1]])],0);const h=Do(Nu(no(c,p),u)),f=Tl(i,[e,0],[n-e,r]),m=Su(h,o),g=Io(o);if(0===e)i=Hu(f,no(m,no(g,f)));else{const t=Hu(f,no(m,no(g,f)));i=kl([Tl(i,[0,0],[e,r]),t],0)}const y=Io(m),b=Tl(a,[0,e],[n,a.shape[1]-e]);if(0===e)a=Hu(b,no(no(b,o),y));else{const t=Hu(b,no(no(b,o),y));a=kl([Tl(a,[0,0],[n,e]),t],1)}return[o,i,a]})),fo([t,u,l])}return!t&&n>r&&(a=Tl(a,[0,0],[n,r]),i=Tl(i,[0,0],[r,r])),[a,i]}))}const Nh=$i({qr_:function(e,t=!1){if(se(e.rank>=2,(()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`)),2===e.rank)return Mh(e,t);{const n=e.shape.slice(0,e.shape.length-2).reduce(((e,t)=>e*t)),r=kd(Ml(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],i=[];return r.forEach((e=>{const[n,r]=Mh(e,t);a.push(n),i.push(r)})),[Ml(hd(a,0),e.shape),Ml(hd(i,0),e.shape)]}}});var Sh;!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"}(Sh||(Sh={}));const kh=$i({computeWeightedLoss_:function(e,t,n=Sh.SUM_BY_NONZERO_WEIGHTS){const r=Ci(e,"losses","computeWeightedLoss");let a=null;null!=t&&(a=Ci(t,"weights","computeWeightedLoss"));const i=null==a?r:Su(r,a);if(n===Sh.NONE)return i;if(n===Sh.SUM)return Nc(i);if(n===Sh.MEAN){if(null==a)return op(i);{const e=r.size/a.size,t=Nu(Nc(i),Nc(a));return e>1?Nu(t,Ru(e)):t}}if(n===Sh.SUM_BY_NONZERO_WEIGHTS){if(null==a)return Nu(Nc(i),Ru(r.size));{const e=Su(a,lp(r.shape)),t=Ls(Nc(yp(e,Ru(0))),"float32");return Nu(Nc(i),t)}}throw Error(`Unknown reduction: ${n}`)}}),Dh=$i({absoluteDifference_:function(e,t,n,r=Sh.SUM_BY_NONZERO_WEIGHTS){const a=Ci(e,"labels","absoluteDifference"),i=Ci(t,"predictions","absoluteDifference");let s=null;null!=n&&(s=Ci(n,"weights","absoluteDifference")),oe(a.shape,i.shape,"Error in absoluteDifference: ");const o=Uu(Hu(a,i));return kh(o,s,r)}}),Th=$i({cosineDistance_:function(e,t,n,r,a=Sh.SUM_BY_NONZERO_WEIGHTS){const i=Ci(e,"labels","cosineDistance"),s=Ci(t,"predictions","cosineDistance");let o=null;null!=r&&(o=Ci(r,"weights","cosineDistance")),oe(i.shape,s.shape,"Error in cosineDistance: ");const u=Ru(1),l=Hu(u,Nc(Su(i,s),n,!0));return kh(l,o,a)}}),Ih=$i({hingeLoss_:function(e,t,n,r=Sh.SUM_BY_NONZERO_WEIGHTS){let a=Ci(e,"labels","hingeLoss");const i=Ci(t,"predictions","hingeLoss");let s=null;null!=n&&(s=Ci(n,"weights","hingeLoss")),oe(a.shape,i.shape,"Error in hingeLoss: ");const o=Ru(1);a=Hu(Su(Ru(2),a),o);const u=Bp(Hu(o,Su(a,i)));return kh(u,s,r)}}),Eh=$i({huberLoss_:function(e,t,n,r=1,a=Sh.SUM_BY_NONZERO_WEIGHTS){const i=Ci(e,"labels","huberLoss"),s=Ci(t,"predictions","huberLoss");let o=null;null!=n&&(o=Ci(n,"weights","huberLoss")),oe(i.shape,s.shape,"Error in huberLoss: ");const u=Ru(r),l=Uu(Hu(s,i)),c=pp(l,u),p=Hu(l,c),d=wu(Su(Ru(.5),Du(c)),Su(u,p));return kh(d,o,a)}}),Ch=$i({logLoss_:function(e,t,n,r=1e-7,a=Sh.SUM_BY_NONZERO_WEIGHTS){const i=Ci(e,"labels","logLoss"),s=Ci(t,"predictions","logLoss");let o=null;null!=n&&(o=Ci(n,"weights","logLoss")),oe(i.shape,s.shape,"Error in logLoss: ");const u=Ru(1),l=Ru(r),c=Do(Su(i,qc(wu(s,l)))),p=Su(Hu(u,i),qc(wu(Hu(u,s),l))),d=Hu(c,p);return kh(d,o,a)}}),Ah=$i({meanSquaredError_:function(e,t,n,r=Sh.SUM_BY_NONZERO_WEIGHTS){const a=Ci(e,"labels","meanSquaredError"),i=Ci(t,"predictions","meanSquaredError");let s=null;null!=n&&(s=Ci(n,"weights","meanSquaredError")),oe(a.shape,i.shape,"Error in meanSquaredError: ");const o=pd(a,i);return kh(o,s,r)}}),Lh=$i({sigmoidCrossEntropy_:function(e,t,n,r=0,a=Sh.SUM_BY_NONZERO_WEIGHTS){let i=Ci(e,"multiClassLabels","sigmoidCrossEntropy");const s=Ci(t,"logits","sigmoidCrossEntropy");let o=null;if(null!=n&&(o=Ci(n,"weights","sigmoidCrossEntropy")),oe(i.shape,s.shape,"Error in sigmoidCrossEntropy: "),r>0){const e=Ru(r),t=Ru(1),n=Ru(.5);i=wu(Su(i,Hu(t,e)),Su(n,e))}const u=function(e,t){const n=Ci(e,"labels","sigmoidCrossEntropyWithLogits"),r=Ci(t,"logits","sigmoidCrossEntropyWithLogits");oe(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");const a=Bp(r),i=Su(r,n),s=Wc(Tc(Do(Uu(r))));return wu(Hu(a,i),s)}(i,s);return kh(u,o,a)}}),$h=$i({softmaxCrossEntropy_:function(e,t,n,r=0,a=Sh.SUM_BY_NONZERO_WEIGHTS){let i=Ci(e,"onehotLabels","softmaxCrossEntropy");const s=Ci(t,"logits","softmaxCrossEntropy");let o=null;if(null!=n&&(o=Ci(n,"weights","softmaxCrossEntropy")),oe(i.shape,s.shape,"Error in softmaxCrossEntropy: "),r>0){const e=Ru(r),t=Ru(1),n=Ru(i.shape[1]);i=wu(Su(i,Hu(t,e)),Nu(e,n))}const u=function(e,t,n=-1){if(-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}`);const r=$u(((e,t,r)=>{const a=Jc(t,[n],!0),i=Hu(Ls(t,"float32"),a);r([e,i]);const s=Do(Su(i,e));return{value:Nc(s,[n]),gradFunc:(e,t)=>{const[r,a]=t,i=yc(e.shape,[n]);return[Su(Ml(e,i),Hu(Ls(r,"float32"),Tc(a))),Su(Ml(e,i),Hu(Tc(a),Ls(r,"float32")))]}}}));return r(e,t)}(i,s);return kh(u,o,a)}}),Oh=$i({sparseFillEmptyRows_:function(e,t,n,r){const a=Ci(e,"indices","sparseFillEmptyRows","int32"),i=Ci(t,"values","sparseFillEmptyRows"),s=Ci(n,"denseShape","sparseFillEmptyRows","int32"),o=Ci(r,"defaultValue","sparseFillEmptyRows",i.dtype);if(2!==a.rank)throw new Error(`Indices should be Tensor2D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Values should be Tensor1D but received shape ${i.shape}`);if(1!==s.rank)throw new Error(`Dense shape should be Tensor1D but received shape ${s.shape}`);if(0!==o.rank)throw new Error(`Default value should be a scalar but received shape ${o.shape}`);const u={indices:a,values:i,denseShape:s,defaultValue:o},l=_i.runKernel(Or,u);return{outputIndices:l[0],outputValues:l[1],emptyRowIndicator:l[2],reverseIndexMap:l[3]}}}),Rh=$i({sparseReshape_:function(e,t,n){const r=Ci(e,"inputIndices","sparseReshape","int32"),a=Ci(t,"inputShape","sparseReshape","int32"),i=Ci(n,"newShape","sparseReshape","int32");if(2!==r.rank)throw new Error(`Input indices should be Tensor2D but received shape\n ${r.shape}`);if(1!==a.rank)throw new Error(`Input shape should be Tensor1D but received shape ${a.shape}`);if(1!==i.rank)throw new Error(`New shape should be Tensor1D but received shape ${i.shape}`);const s={inputIndices:r,inputShape:a,newShape:i},o=_i.runKernel(Rr,s);return{outputIndices:o[0],outputShape:o[1]}}}),Fh=$i({sparseSegmentMean_:function(e,t,n){const r=Ci(e,"data","sparseSegmentMean"),a=Ci(t,"indices","sparseSegmentMean","int32"),i=Ci(n,"segmentIds","sparseSegmentMean","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${i.shape}`);const s={data:r,indices:a,segmentIds:i};return _i.runKernel(Fr,s)}}),Yh=$i({sparseSegmentSum_:function(e,t,n){const r=Ci(e,"data","sparseSegmentSum"),a=Ci(t,"indices","sparseSegmentSum","int32"),i=Ci(n,"segmentIds","sparseSegmentSum","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${i.shape}`);const s={data:r,indices:a,segmentIds:i};return _i.runKernel(Yr,s)}}),zh=$i({stringNGrams_:function(e,t,n,r,a,i,s,o){const u=Ci(e,"data","stringNGrams","string");if("string"!==u.dtype)throw new Error("Data must be of datatype string");if(1!==u.shape.length)throw new Error(`Data must be a vector, saw: ${u.shape}`);const l=Ci(t,"dataSplits","stringNGrams");if("int32"!==l.dtype)throw new Error("Data splits must be of datatype int32");const c={separator:n,nGramWidths:r,leftPad:a,rightPad:i,padWidth:s,preserveShortSequences:o},p={data:u,dataSplits:l},d=_i.runKernel(jr,p,c);return{nGrams:d[0],nGramsSplits:d[1]}}}),Bh=$i({stringSplit_:function(e,t,n=!0){const r=Ci(e,"input","stringSplit","string"),a=Ci(t,"delimiter","stringSplit","string");if(1!==r.rank)throw new Error(`Input should be Tensor1D but received shape ${r.shape}`);if(0!==a.rank)throw new Error(`Delimiter should be a scalar but received shape ${a.shape}`);const i={skipEmpty:n},s={input:r,delimiter:a},o=_i.runKernel(Ur,s,i);return{indices:o[0],values:o[1],shape:o[2]}}}),Ph=$i({stringToHashBucketFast_:function(e,t){const n=Ci(e,"input","stringToHashBucketFast","string"),r={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");const a={input:n};return _i.runKernel(qr,a,r)}}),Hh={fft:sd,ifft:od,rfft:cd,irfft:ud},jh={hammingWindow:Jd,hannWindow:Xd,frame:Zd,stft:Qd},Uh={flipLeftRight:th,grayscaleToRGB:nh,resizeNearestNeighbor:bh,resizeBilinear:yh,rotateWithOffset:rh,cropAndResize:eh,nonMaxSuppression:ih,nonMaxSuppressionAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const i=Ci(e,"boxes","nonMaxSuppressionAsync"),s=Ci(t,"scores","nonMaxSuppressionAsync"),o=ah(i,s,n,r,a);n=o.maxOutputSize,r=o.iouThreshold,a=o.scoreThreshold;const u=await Promise.all([i.data(),s.data()]),l=u[0],c=u[1],{selectedIndices:p}=uh(l,c,n,r,a);return i!==e&&i.dispose(),s!==t&&s.dispose(),yd(p,"int32")},nonMaxSuppressionWithScore:mh,nonMaxSuppressionWithScoreAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=0){const s=Ci(e,"boxes","nonMaxSuppressionAsync"),o=Ci(t,"scores","nonMaxSuppressionAsync"),u=ah(s,o,n,r,a,i);n=u.maxOutputSize,r=u.iouThreshold,a=u.scoreThreshold,i=u.softNmsSigma;const l=await Promise.all([s.data(),o.data()]),c=l[0],p=l[1],{selectedIndices:d,selectedScores:h}=ch(c,p,n,r,a,i);return s!==e&&s.dispose(),o!==t&&o.dispose(),{selectedIndices:yd(d,"int32"),selectedScores:yd(h)}},nonMaxSuppressionPadded:gh,nonMaxSuppressionPaddedAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=!1){const s=Ci(e,"boxes","nonMaxSuppressionAsync"),o=Ci(t,"scores","nonMaxSuppressionAsync"),u=ah(s,o,n,r,a,null),l=u.maxOutputSize,c=u.iouThreshold,p=u.scoreThreshold,[d,h]=await Promise.all([s.data(),o.data()]),{selectedIndices:f,validOutputs:m}=lh(d,h,l,c,p,i);return s!==e&&s.dispose(),o!==t&&o.dispose(),{selectedIndices:yd(f,"int32"),validOutputs:Ru(m,"int32")}},threshold:xh,transform:vh},qh={bandPart:_h,gramSchmidt:wh,qr:Nh},Wh={absoluteDifference:Dh,computeWeightedLoss:kh,cosineDistance:Th,hingeLoss:Ih,huberLoss:Eh,logLoss:Ch,meanSquaredError:Ah,sigmoidCrossEntropy:Lh,softmaxCrossEntropy:$h},Vh={sparseFillEmptyRows:Oh,sparseReshape:Rh,sparseSegmentMean:Fh,sparseSegmentSum:Yh},Gh={stringNGrams:zh,stringSplit:Bh,stringToHashBucketFast:Ph},Kh={sgd:Ju.sgd,momentum:Ju.momentum,adadelta:Ju.adadelta,adagrad:Ju.adagrad,rmsprop:Ju.rmsprop,adamax:Ju.adamax,adam:Ju.adam},Jh="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:e=>e();function Xh(){return new Promise((e=>Jh((()=>e()))))}function Zh(e,t){const n=e[0].length;e.forEach(((e,t)=>{se(e.length===n,(()=>`Error in concat${n}D: rank of tensors[${t}] must be the same as the rank of the rest (${n})`))})),se(t>=0&&t`Error in concat${n}D: axis must be between 0 and ${n-1}.`));const r=e[0];e.forEach(((e,a)=>{for(let i=0;i`Error in concat${n}D: Shape of tensors[${a}] (${e}) does not match the shape of the rest (${r}) along the non-concatenated axis ${a}.`))}))}function Qh(e,t){const n=e[0].slice();for(let r=1;r=2*t+1||r%2==1?a.push(r):n.push(r);r.push(...n),r.push(0),r.push(...a)}return r}function sf(e,t,n,r=!0){const a=[];r?a.push(e[0]/n):a.push(e[0]*n);for(let n=1;n/g;function kf(e,t){const n=((e=e.replace(/\s/g,"")).length-e.replace(Sf,"").length)/"->".length;if(n<1)throw new Error("Equations without an arrow are not supported.");if(n>1)throw new Error('Equation must contain exactly one arrow ("->").');const[r,a]=e.split("->");se(-1===r.indexOf("..."),(()=>'The ellipsis notation ("...") is not supported yet.'));const i=r.split(","),s=i.length;if(t!==s)throw new Error(`Expected ${s} input tensors, received ${t}`);if(s>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const o=[];for(let e=0;e-1!==e.indexOf(t))))throw new Error(`Output subscripts contain the label ${t} not present in the input subscripts.`);-1===o.indexOf(t)&&o.push(t)}for(let e=0;e-1!==e)),{permutationIndices:n,expandDims:r}}function Tf(e,t,n){const r=new Array(e);for(let e=0;e`Expected dimension ${r[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(a)}, but got dimension ${a[n]}`))}}function If(e,t){const n=e,r=[];let a=0;0===e.length&&n.push(-1),a=e.length+1;for(let e=0;ee===t))}function Cf(e,t){const n=[];for(let r=0;r"Number of splits must evenly divide the axis.")),r=new Array(t).fill(e.shape[n]/t);else{const a=t.reduce(((e,t)=>(-1===t&&(e+=1),e)),0);se(a<=1,(()=>"There should be only one negative value in split array."));const i=t.indexOf(-1);if(-1!==i){const r=t.reduce(((e,t)=>t>0?e+t:e));t[i]=e.shape[n]-r}se(e.shape[n]===t.reduce(((e,t)=>e+t)),(()=>"The sum of sizes must match the size of the axis dimension.")),r=t}return r}function Lf(e){return`Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = ${e}`}function $f(e,t){return`indices(${e}, 0) is invalid: ${t} < 0`}function Of(e,t,n){return`indices(${e}, 0) is invalid: ${t} >= ${n}`}function Rf(e,t){return`only one output dimension may be -1, not both ${e} and ${t}`}function Ff(e,t){return`size ${e} must be non-negative, not ${t}`}function Yf(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function zf(e,t){return`Input to reshape is a SparseTensor with ${ce(e)}\n dense values, but the requested shape requires a multiple of ${ce(t)}. inputShape=${e} outputShape= ${t}`}function Bf(e,t){return`Input to reshape is a tensor with ${ce(e)} dense values, but the requested shape has ${ce(t)}. inputShape=${e} outputShape=${t}`}function Pf(){return"segment ids must be >= 0"}function Hf(){return"segment ids are not increasing"}function jf(e,t){return`Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.`}function Uf(e,t,n){return`Bad: indices[${e}] == ${t} out of range [0, ${n})`}function qf(e,t){let n,r=!1;for(e<=ef?(n=e,r=!0):n=Oe(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=Oe(e,n+1);return n}function Wf(e,t,n){const r=[],a=e.length;for(let i=0;ia))throw new Error(`Expect batchDims in the range of [-${a}, ${a}], but got ${r}`);if(r<0&&(r+=a),r>i)throw new Error(`batchDims (${r}) must be less than rank(x) (\n ${i}).`);if(nHa(e)))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function Kf(e){return e.map((e=>Pa(e)))}const Jf={kernelName:Qe,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,fd(Ls(n,"float32"),-1))}}},Xf={kernelName:et,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=Du(Ls(n,"float32")),r=ku(Hu(Ru(1),t));return Do(Nu(e,r))}}}},Zf={kernelName:tt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=ku(Hu(Du(Ls(n,"float32")),1));return Nu(e,t)}}}},Qf={kernelName:nt,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{let t=e;const r=Ao(n.shape,a);return r.length>0&&(t=Nc(t,r)),Ml(t,n.shape)},b:()=>{let t=e;const n=Ao(r.shape,a);return n.length>0&&(t=Nc(t,n)),Ml(t,r.shape)}}}},em={kernelName:rt,saveAllInputs:!0,gradFunc:(e,t)=>{const n={};return t.forEach(((t,r)=>{n[r]=()=>e.clone()})),n}},tm={kernelName:st,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Tu(n)}}},nm={kernelName:ot,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Tu(n)}}},rm={kernelName:ut,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,ku(Hu(Ru(1),Du(Ls(n,"float32")))))}}},am={kernelName:lt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=ku(wu(Ru(1),Du(Ls(n,"float32"))));return Nu(e,t)}}}},im={kernelName:dt,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=wu(Du(n),Du(r));let i=Su(e,Nu(r,t));const s=Ao(n.shape,a);return s.length>0&&(i=Nc(i,s)),Ml(i,n.shape)},b:()=>{const t=wu(Du(n),Du(r));let i=Do(Su(e,Nu(n,t)));const s=Ao(r.shape,a);return s.length>0&&(i=Nc(i,s)),Ml(i,r.shape)}}}},sm={kernelName:ct,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,wu(Du(Ls(n,"float32")),1))}}},om={kernelName:pt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Hu(Ru(1),Du(Ls(n,"float32"))))}}},um=$i({avgPool3dGrad_:function(e,t,n,r,a,i){const s=Ci(e,"dy","avgPool3dGrad"),o=Ci(t,"input","avgPool3dGrad");let u=s,l=o,c=!1;4===o.rank&&(c=!0,u=Ml(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]]),l=Ml(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),se(5===u.rank,(()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`)),se(5===l.rank,(()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${l.rank}.`)),wl("avgPool3dGrad",a,i);const p={dy:u,input:l},d={filterSize:n,strides:r,pad:a,dimRoundingMode:i},h=_i.runKernel(gt,p,d);return c?Ml(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}}),lm={kernelName:mt,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{filterSize:a,strides:i,pad:s,dimRoundingMode:o}=n;return{x:()=>um(e,r,a,i,s,o)}}},cm=$i({avgPoolGrad_:function(e,t,n,r,a){const i=Ci(e,"dy","avgPoolGrad"),s=Ci(t,"input","avgPoolGrad");se(s.rank===i.rank,(()=>`Rank of input (${s.rank}) does not match rank of dy (${i.rank})`));let o=s,u=i,l=!1;3===s.rank&&(l=!0,o=Ml(s,[1,s.shape[0],s.shape[1],s.shape[2]]),u=Ml(i,[1,i.shape[0],i.shape[1],i.shape[2]])),se(4===u.rank,(()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${u.rank}.`)),se(4===o.rank,(()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${o.rank}.`));const c={dy:u,input:o},p={filterSize:n,strides:r,pad:a},d=_i.runKernel(ft,c,p);return l?Ml(d,[d.shape[1],d.shape[2],d.shape[3]]):d}}),pm={kernelName:ht,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{filterSize:a,strides:i,pad:s}=n;return{x:()=>cm(e,r,a,i,s)}}},dm={kernelName:yt,inputsToSave:["a","b"],gradFunc:(e,t,n)=>{const[r,a]=t,{transposeA:i,transposeB:s}=n;return i||s?!i&&s?{a:()=>no(e,a,!1,!1),b:()=>no(e,r,!0,!1)}:i&&!s?{a:()=>no(a,e,!1,!0),b:()=>no(r,e,!1,!1)}:{a:()=>no(a,e,!0,!0),b:()=>no(e,r,!0,!0)}:{a:()=>no(e,a,!1,!0),b:()=>no(r,e,!0,!1)}}},hm={kernelName:bt,gradFunc:(e,t,n)=>{const{blockShape:r,crops:a}=n;return{x:()=>Sp(e,r,a)}}},fm={kernelName:vt,gradFunc:(e,t,n)=>{const r=n,a=r.inputShape,i=r.shape,s=Array.from(i);for(let e=a.length-1;e>=0;e--)if(a[e]===i[e])s[e]=1;else if(1!==a[e])throw new Error(`broadcastTo(): [${a}] cannot be broadcast to [${i}].`);const o=[];for(let e=0;e1&&o.push(e);return{x:()=>Nc(e,o,!0)}}},mm={kernelName:wt,gradFunc:e=>({x:()=>e.clone()})},gm={kernelName:Mt,gradFunc:e=>({x:()=>Tu(e)})},ym={kernelName:Nt,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{clipValueMin:a,clipValueMax:i}=n;return{x:()=>uc(Xc(Rc(r,a),Hc(r,i)),e,Tu(e))}}},bm={kernelName:kt,inputsToSave:["x"],gradFunc:Jf.gradFunc},xm={kernelName:Dt,saveAllInputs:!0,gradFunc:(e,t,n)=>{const r=t.map((e=>e.shape)),{axis:a}=n,i=ve(a,t[0].shape)[0],s=r.map((e=>e[i]));return ld(e,s,i).map((e=>()=>e))}},vm={kernelName:Tt,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const[r,a]=t,{dilations:i,strides:s,pad:o,dataFormat:u}=n;return se(xl(i),(()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${i}'`)),{x:()=>Vl(r.shape,e,a,s,o,u),filter:()=>Bd(r,e,a.shape,s,o,u)}}},_m={kernelName:Et,inputsToSave:["dy","filter"],gradFunc:(e,t,n)=>{const[r,a]=t,{strides:i,pad:s,dataFormat:o,dimRoundingMode:u}=n;return{dy:()=>ql(e,a,i,s,o,1,u),filter:()=>Bd(e,r,a.shape,i,s,o,u)}}},wm=$i({conv3DBackpropFilter_:function(e,t,n,r,a){let i=e;4===e.rank&&(i=Ml(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));let s=t;4===s.rank&&(s=Ml(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),se(5===i.rank,(()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${i.shape}.`)),se(5===s.rank,(()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${s.shape}.`)),se(5===n.length,(()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`)),se(i.shape[4]===n[3],(()=>`Error in conv3dDerFilter: depth of input ${i.shape[4]}) must match input depth in filter (${n[3]}.`)),se(s.shape[4]===n[4],(()=>`Error in conv3dDerFilter: depth of dy (${s.shape[4]}) must match output depth for filter (${n[4]}).`));const o={x:i,dy:s},u={strides:r,pad:a,filterShape:n};return _i.runKernel(At,o,u)}}),Mm={kernelName:Ct,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const{dilations:r,strides:a,pad:i}=n;se(xl(r),(()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`));const[s,o]=t;return{x:()=>Jl(s.shape,e,o,a,i),filter:()=>wm(s,e,o.shape,a,i)}}},Nm={kernelName:$t,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(Do(Qp(Ls(n,"float32"))),e)}}},Sm={kernelName:Ot,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(ed(Ls(n,"float32")),e)}}},km={kernelName:Ft,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{axis:a,exclusive:i,reverse:s}=n;return{x:()=>{const t=xc([a],r.rank);let n=tc(e,a,i,!s);return null!=t&&(n=Io(n,t)),n}}}},Dm={kernelName:Pt,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const{dilations:r,strides:a,pad:i,dimRoundingMode:s}=n,o=null==r?[1,1]:r;se(xl(o),(()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${o}'`));const[u,l]=t;return se(4===u.rank,(()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${u.rank}.`)),se(4===l.rank,(()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${l.rank}.`)),se(u.shape[3]===l.shape[2],(()=>`Error in gradient of depthwiseConv2d: number of input channels (${u.shape[3]}) must match the inChannels dimension in filter ${l.shape[2]}.`)),se(vl(a,o),(()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${o}'.`)),wl("depthwiseConv2d",i,s),{x:()=>Vd(u.shape,e,l,a,i,o,s),filter:()=>Wd(u,e,l.shape,a,i,o,s)}}},Tm={kernelName:qt,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const[r,a]=t,i={x:r,filter:a,dy:e},s={x:r,filter:a,dy:e};return{x:()=>_i.runKernel(Wt,i,n),filter:()=>_i.runKernel(Vt,s,n)}}},Im={kernelName:Jt,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t,r={dy:e,y:n};return{x:()=>_i.runKernel(Xt,r)}}},Em={kernelName:Zt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t,r=Su(Tc(Do(Du(n))),2/Math.sqrt(Math.PI));return{x:()=>Su(e,r)}}},Cm={kernelName:en,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,n)}}},Am={kernelName:tn,inputsToSave:["input"],gradFunc:(e,t)=>{const[n]=t;return{input:()=>Ml(e,n.shape)}}},Lm={kernelName:nn,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,Tc(n))}}},$m={kernelName:on,gradFunc:e=>({x:()=>Tu(e)})},Om={kernelName:un,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=Nu(e,Ls(r,"float32")),i=Ao(n.shape,a);return i.length>0?Ml(Nc(t,i),n.shape):t},b:()=>{let t=Su(e,Ls(n,"float32"));const i=Ao(r.shape,a);i.length>0&&(t=Ml(Nc(t,i),r.shape));const s=Du(r);return Do(Nu(t,Ls(s,"float32")))}}}},Rm={kernelName:ln,inputsToSave:["x","mean","variance","scale"],gradFunc:(e,t,n)=>{const{varianceEpsilon:r}=n,[a,i,s,o]=t,u=null==o?Ru(1):o,l=Ao(i.shape,a.shape),c=[];if(1===i.rank){for(let e=0;e1===i.rank?Ml(Su(Su(e,Cc(Ml(h,[1,1,1,i.shape[0]]),c)),u),a.shape):Ml(Su(Su(e,h),u),a.shape),mean:()=>{let e=Su(Su(h,Ru(-1)),d);return 1===i.rank&&(e=Nc(e,l)),Ml(e,i.shape)},variance:()=>{let e=Su(Su(f,p),d);return 1===i.rank&&(e=Nc(e,l)),Ml(e,i.shape)},scale:()=>{const t=Su(p,h);let n=Su(e,t);return 1===i.rank&&(n=Nc(n,l)),Ml(n,i.shape)},offset:()=>{let t=e;return 1===i.rank&&(t=Nc(t,l)),Ml(t,i.shape)}}}},Fm={kernelName:cn,inputsToSave:["x","indices"],gradFunc:(e,t,n)=>{const[r,a]=t,{axis:i}=n,s=ve(i,r.shape)[0];return{x:()=>{const t=r.shape,n=a.size,o=t.slice(0,s),u=o.length,l=t.slice(i,t.length).slice(1),c=l.length,p=Ym(0,u),d=Ym(u+1,u+1+c),h=zm([o,[n],l]),f=Ml(e,h),m=Ml(a,[n]),g=zm([[u],p,d]),y=Io(f,g);let b=Sd(y,m,r.shape[s]);const x=vc(g);return b=Io(b,x),b},indices:()=>a}}};function Ym(e,t){const n=[];for(let r=e;r{const[n,r]=t;return{a:()=>Tu(n),b:()=>Tu(r)}}},Pm={kernelName:fn,gradFunc:e=>({x:()=>Ls(e,"float32")})},Hm={kernelName:yn,gradFunc:e=>({x:()=>Tu(e)})},jm={kernelName:bn,gradFunc:e=>({x:()=>Tu(e)})},Um={kernelName:xn,gradFunc:e=>({x:()=>Tu(e)})},qm={kernelName:vn,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{alpha:a}=n,i=Oc(r,0);return{x:()=>uc(i,e,Su(e,a))}}},Wm={kernelName:Sn,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,wu(n,1))}}},Vm={kernelName:Nn,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Ls(n,"float32"))}}},Gm={kernelName:En,inputsToSave:[],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r]=t,{axis:a}=n;return{logits:()=>{const t=Tc(r);return Hu(e,Su(Nc(e,a,!0),t))}}}},Km=$i({localResponseNormalizationBackprop_:function(e,t,n,r=5,a=1,i=1,s=.5){const o={x:e,y:t,dy:n},u={depthRadius:r,bias:a,alpha:i,beta:s};return _i.runKernel(Ln,o,u)}}),Jm={kernelName:An,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r,a]=t,{depthRadius:i,bias:s,alpha:o,beta:u}=n;return{x:()=>Km(r,a,e,i,s,o,u)}}};function Xm(e,t,n,r){return t.rankSu(e,Ls(oc(n,t),e.dtype))}}const Zm={kernelName:$n,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const r=n,{reductionIndices:a}=r,i=t[0],s=Xm(e,t[1],i,ve(a,i.shape));return{x:()=>s.x()}}},Qm={kernelName:On,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t;return{a:()=>Su(e,Ls(Rc(n,r),"float32")),b:()=>Su(e,Ls(Pc(n,r),"float32"))}}},eg=$i({maxPool3dGrad_:function(e,t,n,r,a,i,s){const o=Ci(e,"dy","maxPool3dGrad"),u=Ci(t,"input","maxPool3dGrad"),l=Ci(n,"output","maxPool3dGrad");let c=o,p=u,d=l,h=!1;4===u.rank&&(h=!0,c=Ml(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),p=Ml(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]]),d=Ml(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]])),se(5===c.rank,(()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${c.rank}.`)),se(5===p.rank,(()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${p.rank}.`)),se(5===d.rank,(()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${d.rank}.`)),wl("maxPool3dGrad",i,s);const f={dy:c,input:p,output:d},m={filterSize:r,strides:a,pad:i,dimRoundingMode:s},g=_i.runKernel(zn,f,m);return h?Ml(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}}),tg={kernelName:Yn,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r,a]=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=n;return{x:()=>eg(e,r,a,i,s,o,u)}}},ng=$i({maxPoolGrad_:function(e,t,n,r,a,i,s){const o=Ci(e,"dy","maxPoolGrad"),u=Ci(t,"input","maxPoolGrad"),l=Ci(n,"output","maxPoolGrad");se(u.rank===o.rank,(()=>`Rank of input (${u.rank}) does not match rank of dy (${o.rank})`)),se(4===o.rank,(()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${o.rank}.`)),se(4===u.rank,(()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${u.rank}.`)),wl("maxPoolGrad",i,s);const c={dy:o,input:u,output:l},p={filterSize:r,strides:a,pad:i,dimRoundingMode:s};return _i.runKernel(Fn,c,p)}}),rg={kernelName:Rn,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r,a]=t,{filterSize:i,strides:s,pad:o}=n;return{x:()=>ng(e,r,a,i,s,o)}}},ag={kernelName:Pn,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{axis:a}=n,i=ve(a,r.shape),s=ce(gc(r.shape,i)[1]);return{x:()=>{const t=r.shape.slice();i.forEach((e=>{t[e]=1}));const n=Ml(e,t);return Nu(Su(n,lp(r.shape,"float32")),s)}}}},ig={kernelName:Hn,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const r=n,{axis:a}=r,[i,s]=t,o=Xm(e,s,i,ve(a,i.shape));return{x:()=>o.x()}}},sg={kernelName:Un,inputsToSave:["x"],gradFunc:(e,t,n)=>{const r=t[0],{paddings:a}=n,i=a.map((e=>e[0]));return{x:()=>Tl(e,i,r.shape)}}},og={kernelName:tr,saveAllInputs:!0,gradFunc:(e,t,n)=>{const{axis:r}=n;return kd(e,r).map((e=>()=>e))}},ug={kernelName:nr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const r=t[0],{paddings:a}=n,i=a.map((e=>e[0]));return{x:()=>Tl(e,i,r.shape)}}},lg={kernelName:ar,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(e,t)=>{const[n,r,a]=t,i=n,s=r,o=Lo(i.shape,s.shape);return{a:()=>{const t=Ls(s,"float32");let n=Su(e,Su(t,Pu(i,Hu(t,Ru(1)))));const r=Ao(i.shape,o);return r.length>0&&(n=Nc(n,r)),Ml(n,i.shape)},b:()=>{const t=Oc(i,0),n=uc(t,qc(i),Tu(i));let r=Su(e,Su(a,n));const u=Ao(s.shape,o);return u.length>0&&(r=Nc(r,u)),Ml(r,s.shape)}}}};const cg={kernelName:sr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{axis:a}=n;let i=[];return i=null==a?r.shape.map(((e,t)=>t)):"number"==typeof a?[a]:a,{x:()=>function(e,t,n){const r=e.shape.length,a=r-n.length,i=xc(n,r);let s=e;null!=i&&(s=Io(e,i));const o=s.shape.slice(),u=o.splice(r-n.length,n.length).reduce(((e,t)=>e*t),1);o.push(u);let l=function(e,t,n){const r=e.shape.slice();r[n]=1;const a=Ml(t,r),i=ec(e,n,!0,!1),s=ec(e,n,!0,!0),o=Su(i,s);return Su(a,o)}(s.reshape(o),t,a);if(l=l.reshape(s.shape),null!=i){const e=vc(i);l=Io(l,e)}return l}(r,e,i)}}},pg={kernelName:Mr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=Oc(n,Ru(0)),r=Ru(lf),a=Ru(cf),i=Su(e,a),s=Su(Su(e,r),Tc(Ls(n,"float32")));return uc(t,i,s)}}}},dg={kernelName:Nr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{begin:a,size:i}=n,s=r.shape,[o,u]=au(r,a,i),l=[];for(let t=0;tvp(e,l)}}},hg={kernelName:Ar,gradFunc:(e,t,n)=>{const{blockShape:r,paddings:a}=n;return{x:()=>Cl(e,r,a)}}},fg={kernelName:Lr,gradFunc:(e,t,n)=>{const{axis:r}=n;return{x:()=>kl(e,r)}}},mg={kernelName:Cr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,a=r.shape.slice(),{axis:i}=n;ve(i,r.shape).forEach((e=>{a[e]=1}));const s=Ml(e,a),o=Su(s,lp(r.shape,"float32"));return{x:()=>o}}},gg={kernelName:Kr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{reps:a}=n;return{x:()=>{let t=Tu(r);if(1===r.rank)for(let n=0;n{const r=n,{axis:a}=r;return{value:()=>hd(e,a)}}},bg={kernelName:ta,inputsToSave:["segmentIds"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>function(e,t){const n=qu(t,Tu(t)),r=$c(e,n);let a=Rc(t,Ru(0,"int32"));const i=r.rank-a.rank;for(let e=0;e{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=Nu(e,Ls(r,"float32")),i=Ao(n.shape,a);return i.length>0?Ml(Nc(t,i),n.shape):t},b:()=>{let t=Su(e,Ls(n,"float32"));const i=Ao(r.shape,a);i.length>0&&(t=Ml(Nc(t,i),r.shape));const s=Du(r);return Do(Nu(t,Ls(s,"float32")))}}}},Im,Em,Cm,Am,Lm,Om,$m,Rm,Fm,Bm,Pm,Hm,jm,Um,qm,Wm,Vm,Gm,Jm,Zm,Zm,Qm,tg,rg,ag,ig,{kernelName:jn,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t;return{a:()=>Su(e,Ls(Hc(n,r),"float32")),b:()=>Su(e,Ls(Oc(n,r),"float32"))}}},sg,{kernelName:qn,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=Ao(n.shape,a);return t.length>0?Ml(Nc(e,t),n.shape):e},b:()=>{const t=Su(e,Do(Lc(Nu(n,r)))),i=Ao(r.shape,a);return i.length>0?Ml(Nc(t,i),r.shape):t}}}},{kernelName:Vn,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=Su(e,Ls(r,"float32")),i=Ao(n.shape,a);return i.length>0?Ml(Nc(t,i),n.shape):t},b:()=>{const t=Su(e,Ls(n,"float32")),i=Ao(r.shape,a);return i.length>0?Ml(Nc(t,i),r.shape):t}}}},{kernelName:Gn,gradFunc:e=>({x:()=>Do(e)})},{kernelName:er,inputsToSave:["indices"],gradFunc:(e,t)=>{const n=t[0];return{indices:()=>up(n.shape,"float32")}}},{kernelName:Qn,gradFunc:e=>({x:()=>Tu(e)})},og,ug,ug,lg,{kernelName:ir,inputsToSave:["x","alpha"],gradFunc:(e,t)=>{const[n,r]=t,a=Oc(n,0);return{x:()=>uc(a,e,Su(e,r)),alpha:()=>{let t=uc(a,Tu(e),Su(e,n));const i=Ao(r.shape,e.shape);return i.length>0&&(t=Nc(t,i)),Ml(t,r.shape)}}}},cg,{kernelName:lr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Do(Du(n)))}}},{kernelName:gr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t,r=Su(Hc(n,6),fd(n));return{x:()=>Su(e,Ls(r,"float32"))}}},{kernelName:cr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,Ls(fd(n),"float32"))}}},{kernelName:pr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ml(e,n.shape)}}},{kernelName:fr,inputsToSave:["images"],gradFunc:(e,t,n)=>{const[r]=t,a={dy:e,images:r};return{images:()=>_i.runKernel(mr,a,n)}}},{kernelName:dr,inputsToSave:["images"],gradFunc:(e,t,n)=>{const[r]=t,a={dy:e,images:r};return{images:()=>_i.runKernel(hr,a,n)}}},{kernelName:yr,gradFunc:(e,t,n)=>{const{dims:r}=n,a=ve(r,e.shape);return{x:()=>Hp(e,a)}}},{kernelName:br,gradFunc:e=>({x:()=>Tu(e)})},{kernelName:xr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Do(Nu(e,Su(Pu(n,1.5),2)))}}},{kernelName:wr,inputsToSave:["condition"],gradFunc:(e,t)=>{const[n]=t;return{condition:()=>Ls(Tu(n),"float32"),t:()=>Su(e,Ls(n,e.dtype)),e:()=>Su(e,Ls(Zc(n),e.dtype))}}},pg,{kernelName:Tr,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,Su(n,Hu(Ru(1),n)))}}},{kernelName:Dr,gradFunc:e=>({x:()=>Tu(e)})},{kernelName:Sr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(Zl(Ls(n,"float32")),e)}}},{kernelName:kr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(Ql(Ls(n,"float32")),e)}}},dg,{kernelName:$r,outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r]=t,{dim:a}=n,i=Su(e,r);return{logits:()=>Hu(i,Su(Nc(i,[a],!0),r))}}},{kernelName:Ir,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,Dl(n))}}},hg,hg,fg,fg,{kernelName:Er,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Su(ku(Ls(n,"float32")),2))}}},{kernelName:Br,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Ru(2);return{a:()=>Su(e,Su(a,Hu(n,r))),b:()=>Su(e,Su(a,Hu(r,n)))}}},{kernelName:Pr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,Su(Ls(n,"float32"),2))}}},{kernelName:aa,gradFunc:e=>({x:()=>Tu(e)})},{kernelName:Wr,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{let t=e;const r=Ao(n.shape,a);return r.length>0&&(t=Nc(t,r)),Ml(t,n.shape)},b:()=>{let t=e;const n=Ao(r.shape,a);return n.length>0&&(t=Nc(t,n)),Ml(Do(t),r.shape)}}}},mg,{kernelName:Vr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Du(Zl(n)))}}},{kernelName:Gr,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(Hu(Ru(1),Du(n)),e)}}},gg,{kernelName:Zr,gradFunc:(e,t,n)=>{const r=n,{perm:a}=r,i=vc(a);return{x:()=>Io(e,i)}}},yg,bg,{kernelName:ra,gradFunc:e=>({x:()=>Tu(e)})}];for(const e of xg)ba(e);ni().prototype.abs=function(){return this.throwIfDisposed(),Uu(this)},ni().prototype.acos=function(){return this.throwIfDisposed(),Xu(this)},ni().prototype.acosh=function(){return this.throwIfDisposed(),Zu(this)},ni().prototype.add=function(e){return this.throwIfDisposed(),wu(this,e)},ni().prototype.all=function(e,t){return this.throwIfDisposed(),el(this,e,t)},ni().prototype.any=function(e,t){return this.throwIfDisposed(),tl(this,e,t)},ni().prototype.argMax=function(e){return this.throwIfDisposed(),nl(this,e)},ni().prototype.argMin=function(e){return this.throwIfDisposed(),rl(this,e)},ni().prototype.asScalar=function(){return this.throwIfDisposed(),se(1===this.size,(()=>"The array must have only 1 element.")),Ml(this,[])},ni().prototype.asType=function(e){return this.throwIfDisposed(),Ls(this,e)},ni().prototype.as1D=function(){return this.throwIfDisposed(),Ml(this,[this.size])},ni().prototype.as2D=function(e,t){return this.throwIfDisposed(),Ml(this,[e,t])},ni().prototype.as3D=function(e,t,n){return this.throwIfDisposed(),Ml(this,[e,t,n])},ni().prototype.as4D=function(e,t,n,r){return this.throwIfDisposed(),Ml(this,[e,t,n,r])},ni().prototype.as5D=function(e,t,n,r,a){return this.throwIfDisposed(),Ml(this,[e,t,n,r,a])},ni().prototype.asin=function(){return this.throwIfDisposed(),al(this)},ni().prototype.asinh=function(){return this.throwIfDisposed(),il(this)},ni().prototype.atan=function(){return this.throwIfDisposed(),sl(this)},ni().prototype.atan2=function(e){return this.throwIfDisposed(),ol(this,e)},ni().prototype.atanh=function(){return this.throwIfDisposed(),ul(this)},ni().prototype.avgPool=function(e,t,n,r){return this.throwIfDisposed(),Nl(this,e,t,n,r)},ni().prototype.batchToSpaceND=function(e,t){return this.throwIfDisposed(),Cl(this,e,t)},ni().prototype.batchNorm=function(e,t,n,r,a){return this.throwIfDisposed(),Al(this,e,t,n,r,a)},ni().prototype.broadcastTo=function(e){return this.throwIfDisposed(),Yl(this,e)},ni().prototype.cast=function(e){return this.throwIfDisposed(),Ls(this,e)},ni().prototype.ceil=function(){return this.throwIfDisposed(),zl(this)},ni().prototype.clipByValue=function(e,t){return this.throwIfDisposed(),Bl(this,e,t)},ni().prototype.concat=function(e,t){return this.throwIfDisposed(),e instanceof ti&&(e=[e]),kl([this,...e],t)},ni().prototype.conv1d=function(e,t,n,r,a,i){return this.throwIfDisposed(),Wl(this,e,t,n,r,a,i)},ni().prototype.conv2dTranspose=function(e,t,n,r,a){return this.throwIfDisposed(),Gl(this,e,t,n,r,a)},ni().prototype.conv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),ql(this,e,t,n,r,a,i)},ni().prototype.cos=function(){return this.throwIfDisposed(),Zl(this)},ni().prototype.cosh=function(){return this.throwIfDisposed(),Ql(this)},ni().prototype.cumprod=function(e,t,n){return this.throwIfDisposed(),ec(this,e,t,n)},ni().prototype.cumsum=function(e,t,n){return this.throwIfDisposed(),tc(this,e,t,n)},ni().prototype.depthToSpace=function(e,t){return this.throwIfDisposed(),rc(this,e,t)},ni().prototype.depthwiseConv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),ac(this,e,t,n,r,a,i)},ni().prototype.dilation2d=function(e,t,n,r,a){return this.throwIfDisposed(),sc(this,e,t,n,r,a)},ni().prototype.divNoNan=function(e){return this.throwIfDisposed(),lc(this,e)},ni().prototype.div=function(e){return this.throwIfDisposed(),Nu(this,e)},ni().prototype.dot=function(e){return this.throwIfDisposed(),cc(this,e)},ni().prototype.elu=function(){return this.throwIfDisposed(),dc(this)},ni().prototype.equal=function(e){return this.throwIfDisposed(),oc(this,e)},ni().prototype.erf=function(){return this.throwIfDisposed(),hc(this)},ni().prototype.euclideanNorm=function(e,t){return this.throwIfDisposed(),Dc(this,e,t)},ni().prototype.exp=function(){return this.throwIfDisposed(),Tc(this)},ni().prototype.expandDims=function(e){return this.throwIfDisposed(),Ic(this,e)},ni().prototype.expm1=function(){return this.throwIfDisposed(),Ec(this)},ni().prototype.fft=function(){return this.throwIfDisposed(),sd(this)},ni().prototype.flatten=function(){return this.throwIfDisposed(),Ml(this,[this.size])},ni().prototype.floor=function(){return this.throwIfDisposed(),Lc(this)},ni().prototype.floorDiv=function(e){return this.throwIfDisposed(),Mu(this,e)},ni().prototype.gather=function(e,t){return this.throwIfDisposed(),$c(this,e,t)},ni().prototype.greaterEqual=function(e){return this.throwIfDisposed(),Rc(this,e)},ni().prototype.greater=function(e){return this.throwIfDisposed(),Oc(this,e)},ni().prototype.ifft=function(){return this.throwIfDisposed(),od(this)},ni().prototype.irfft=function(){return this.throwIfDisposed(),ud(this)},ni().prototype.isFinite=function(){return this.throwIfDisposed(),Fc(this)},ni().prototype.isInf=function(){return this.throwIfDisposed(),Yc(this)},ni().prototype.isNaN=function(){return this.throwIfDisposed(),zc(this)},ni().prototype.leakyRelu=function(e){return this.throwIfDisposed(),Bc(this,e)},ni().prototype.lessEqual=function(e){return this.throwIfDisposed(),Hc(this,e)},ni().prototype.less=function(e){return this.throwIfDisposed(),Pc(this,e)},ni().prototype.localResponseNormalization=function(e,t,n,r){return this.throwIfDisposed(),Uc(this,e,t,n,r)},ni().prototype.logSigmoid=function(){return this.throwIfDisposed(),Gc(this)},ni().prototype.logSoftmax=function(e){return this.throwIfDisposed(),Kc(this,e)},ni().prototype.logSumExp=function(e,t){return this.throwIfDisposed(),Jc(this,e,t)},ni().prototype.log=function(){return this.throwIfDisposed(),qc(this)},ni().prototype.log1p=function(){return this.throwIfDisposed(),Wc(this)},ni().prototype.logicalAnd=function(e){return this.throwIfDisposed(),Xc(this,e)},ni().prototype.logicalNot=function(){return this.throwIfDisposed(),Zc(this)},ni().prototype.logicalOr=function(e){return this.throwIfDisposed(),Qc(this,e)},ni().prototype.logicalXor=function(e){return this.throwIfDisposed(),ep(this,e)},ni().prototype.matMul=function(e,t,n){return this.throwIfDisposed(),no(this,e,t,n)},ni().prototype.maxPool=function(e,t,n,r){return this.throwIfDisposed(),ap(this,e,t,n,r)},ni().prototype.max=function(e,t){return this.throwIfDisposed(),wc(this,e,t)},ni().prototype.maximum=function(e){return this.throwIfDisposed(),qu(this,e)},ni().prototype.mean=function(e,t){return this.throwIfDisposed(),op(this,e,t)},ni().prototype.min=function(e,t){return this.throwIfDisposed(),Mc(this,e,t)},ni().prototype.minimum=function(e){return this.throwIfDisposed(),pp(this,e)},ni().prototype.mirrorPad=function(e,t){return this.throwIfDisposed(),dp(this,e,t)},ni().prototype.mod=function(e){return this.throwIfDisposed(),hp(this,e)},ni().prototype.mul=function(e){return this.throwIfDisposed(),Su(this,e)},ni().prototype.neg=function(){return this.throwIfDisposed(),Do(this)},ni().prototype.norm=function(e,t,n){return this.throwIfDisposed(),kc(this,e,t,n)},ni().prototype.notEqual=function(e){return this.throwIfDisposed(),yp(this,e)},ni().prototype.oneHot=function(e,t=1,n=0){return this.throwIfDisposed(),ro(this,e,t,n)},ni().prototype.onesLike=function(){return this.throwIfDisposed(),bp(this)},ni().prototype.pad=function(e,t){return this.throwIfDisposed(),vp(this,e,t)},ni().prototype.pool=function(e,t,n,r,a,i){return this.throwIfDisposed(),kp(this,e,t,n,r,a,i)},ni().prototype.pow=function(e){return this.throwIfDisposed(),Pu(this,e)},ni().prototype.prelu=function(e){return this.throwIfDisposed(),Dp(this,e)},ni().prototype.prod=function(e,t){return this.throwIfDisposed(),Tp(this,e,t)},ni().prototype.reciprocal=function(){return this.throwIfDisposed(),zp(this)},ni().prototype.relu=function(){return this.throwIfDisposed(),Bp(this)},ni().prototype.relu6=function(){return this.throwIfDisposed(),Pp(this)},ni().prototype.reshapeAs=function(e){return this.throwIfDisposed(),Ml(this,e.shape)},ni().prototype.reshape=function(e){return this.throwIfDisposed(),Ml(this,e)},ni().prototype.resizeBilinear=function(e,t,n){return this.throwIfDisposed(),yh(this,e,t,n)},ni().prototype.resizeNearestNeighbor=function(e,t,n){return this.throwIfDisposed(),bh(this,e,t,n)},ni().prototype.reverse=function(e){return this.throwIfDisposed(),Hp(this,e)},ni().prototype.rfft=function(){return this.throwIfDisposed(),cd(this)},ni().prototype.round=function(){return this.throwIfDisposed(),Vp(this)},ni().prototype.rsqrt=function(){return this.throwIfDisposed(),Gp(this)},ni().prototype.selu=function(){return this.throwIfDisposed(),Kp(this)},ni().prototype.separableConv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),Jp(this,e,t,n,r,a,i)},ni().prototype.sigmoid=function(){return this.throwIfDisposed(),Dl(this)},ni().prototype.sign=function(){return this.throwIfDisposed(),Zp(this)},ni().prototype.sin=function(){return this.throwIfDisposed(),Qp(this)},ni().prototype.sinh=function(){return this.throwIfDisposed(),ed(this)},ni().prototype.slice=function(e,t){return this.throwIfDisposed(),Tl(this,e,t)},ni().prototype.softmax=function(e){return this.throwIfDisposed(),id(this,e)},ni().prototype.softplus=function(){return this.throwIfDisposed(),Vc(this)},ni().prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),Sp(this,e,t)},ni().prototype.split=function(e,t){return this.throwIfDisposed(),ld(this,e,t)},ni().prototype.sqrt=function(){return this.throwIfDisposed(),ku(this)},ni().prototype.square=function(){return this.throwIfDisposed(),Du(this)},ni().prototype.squaredDifference=function(e){return this.throwIfDisposed(),pd(this,e)},ni().prototype.squeeze=function(e){return this.throwIfDisposed(),dd(this,e)},ni().prototype.stack=function(e,t){this.throwIfDisposed();const n=e instanceof ti?[this,e]:[this,...e];return hd(n,t)},ni().prototype.step=function(e){return this.throwIfDisposed(),fd(this,e)},ni().prototype.stridedSlice=function(e,t,n,r,a,i,s,o){return this.throwIfDisposed(),md(this,e,t,n,r,a,i,s,o)},ni().prototype.sub=function(e){return this.throwIfDisposed(),Hu(this,e)},ni().prototype.sum=function(e,t){return this.throwIfDisposed(),Nc(this,e,t)},ni().prototype.tan=function(){return this.throwIfDisposed(),gd(this)},ni().prototype.tanh=function(){return this.throwIfDisposed(),Il(this)},ni().prototype.tile=function(e){return this.throwIfDisposed(),Cc(this,e)},ni().prototype.toBool=function(){return this.throwIfDisposed(),Ls(this,"bool")},ni().prototype.toFloat=function(){return this.throwIfDisposed(),Ls(this,"float32")},ni().prototype.toInt=function(){return this.throwIfDisposed(),Ls(this,"int32")},ni().prototype.topk=function(e,t){return this.throwIfDisposed(),wd(this,e,t)},ni().prototype.transpose=function(e){return this.throwIfDisposed(),Io(this,e)},ni().prototype.unique=function(e){return this.throwIfDisposed(),Nd(this,e)},ni().prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),Sd(this,e,t)},ni().prototype.unstack=function(e){return this.throwIfDisposed(),kd(this,e)},ni().prototype.where=function(e,t){return this.throwIfDisposed(),uc(e,this,t)},ni().prototype.zerosLike=function(){return this.throwIfDisposed(),Tu(this)};class vg extends Error{constructor(e){super(e),Object.setPrototypeOf(this,vg.prototype)}}class _g extends Error{constructor(e){super(e),Object.setPrototypeOf(this,_g.prototype)}}class wg extends Error{constructor(e){super(e),Object.setPrototypeOf(this,wg.prototype)}}class Mg extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Mg.prototype)}}class Ng extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Ng.prototype)}}Error;class Sg{constructor(e){this.maxEntries=e||100,this.cache=new Map}get(e){let t;return this.cache.has(e)&&(t=this.cache.get(e),this.cache.delete(e),this.cache.set(e,t)),t}put(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxEntries){const e=this.cache.keys().next().value;this.cache.delete(e)}this.cache.set(e,t)}getMaxEntries(){return this.maxEntries}setMaxEntries(e){if(e<0)throw new Error(`The maxEntries of LRU caches must be at least 0, but got ${e}.`);if(this.maxEntries>e)for(let t=0;tt.toUpperCase()))}let Lg={};function $g(e){if(null==e)return null;const t={};return t.className=e.getClassName(),t.config=e.getConfig(),t}function Og(e){if(null!=e&&"object"==typeof e)if(Array.isArray(e))e.forEach((e=>Og(e)));else{const t=Object.keys(e);for(const n of t){const t=e[n];null!=t&&"object"==typeof t&&(Array.isArray(t)||"ndarray"!==t.type||"number"!=typeof t.value?Og(t):e[n]=t.value)}}}function Rg(e,t={},n={},r="object",a=!1){if("string"==typeof e){const a=e;let i;if(a in n)i=n[a];else if(a in Lg)i=Lg[a];else if(i=t[a],null==i)throw new wg(`Unknown ${r}: ${e}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return i}{const i=e;if(null==i.className||null==i.config)throw new wg(`${r}: Improper config format: ${JSON.stringify(i)}.\n'className' and 'config' must set.`);const s=i.className;let o,u;if(s in n?[o,u]=n[s]:s in Lg?[o,u]=Lg.className:s in t&&([o,u]=t[s]),null==o)throw new wg(`Unknown ${r}: ${s}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(null!=u){const e={};for(const t of Object.keys(Lg))e[t]=Lg[t];for(const t of Object.keys(n))e[t]=n[t];i.config.customObjects=e;const t=Object.assign({},Lg);for(const e of Object.keys(n))Lg[e]=n[e];Og(i.config);const r=u(o,i.config,n,a);return Lg=Object.assign({},t),r}{const e=Object.assign({},Lg);for(const e of Object.keys(n))Lg[e]=n[e];const t=new o(i.config);return Lg=Object.assign({},e),t}}}function Fg(e,t){return-1*function(e,t){return et?1:0}(e,t)}function Yg(e){if(null==e)return e;const t=[];for(const n of e)-1===t.indexOf(n)&&t.push(n);return t}function zg(e){if(null==e)throw new wg(`Invalid value in obj: ${JSON.stringify(e)}`);for(const t in e)if(e.hasOwnProperty(t))return!1;return!0}function Bg(e,t,n){if(null!=n&&e.indexOf(n)<0)throw new wg(`${n} is not a valid ${t}. Valid values are ${e} or null/undefined.`)}function Pg(e,t,n=0,r=1/0){return Dg(n>=0),Dg(r>=n),Array.isArray(e)&&e.length>=n&&e.length<=r&&e.every((e=>typeof e===t))}function Hg(e,t){Array.isArray(e)?(se(e.length>0,(()=>`${t} is unexpectedly an empty array.`)),e.forEach(((e,n)=>Hg(e,`element ${n+1} of ${t}`)))):se(Number.isInteger(e)&&e>0,(()=>`Expected ${t} to be a positive integer, but got ${jg(e)}.`))}function jg(e){return null===e?"null":Array.isArray(e)?"["+e.map((e=>jg(e))).join(",")+"]":"string"==typeof e?`"${e}"`:`${e}`}function Ug(e){return"relu"===e?"relu":"linear"===e?"linear":"elu"===e?"elu":null}let qg=0;function Wg(){return qg++}const Vg={};function Gg(e=""){return e in Vg||(Vg[e]=0),Vg[e]+=1,e+Vg[e].toString()}const Kg=["channelsFirst","channelsLast"],Jg=["nearest","bilinear"],Xg=["valid","same","causal"],Zg=["max","avg"],Qg=["sum","mul","concat","ave"],ey=new Map;function ty(e){Bg(Kg,"DataFormat",e)}function ny(e){Bg(Xg,"PaddingMode",e)}function ry(e){Bg(Zg,"PoolMode",e)}const ay=[];function iy(e,t){ay.push(e);try{const e=t();return ay.pop(),e}catch(e){throw ay.pop(),e}}function sy(e){if(!ly(e))throw new Error("Not a valid tensor name: '"+e+"'");return(0===ay.length?"":ay.join("/")+"/")+e}function oy(e){if(!ly(e))throw new Error("Not a valid tensor name: '"+e+"'");ey.has(e)||ey.set(e,0);const t=ey.get(e);if(ey.set(e,ey.get(e)+1),t>0){const n=`${e}_${t}`;return ey.set(n,1),n}return e}const uy=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function ly(e){return!!e.match(uy)}function cy(e,t,n){null==t&&(t=0),null==n&&(n=e.length);let r=1;for(let a=t;at&&(t=r)}return t}function hy(e,t){if(t{switch(e.rank){case 1:return td(e,t,n);case 2:return nd(e,[t,0],[n,e.shape[1]]);case 3:return rd(e,[t,0,0],[n,e.shape[1],e.shape[2]]);case 4:return ad(e,[t,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3]]);case 5:return Tl(e,[t,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4]]);case 6:return Tl(e,[t,0,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4],e.shape[5]]);default:throw new wg(`sliceAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}}))}function xy(e,t,n){return ho((()=>{switch(e.rank){case 1:return td(e,t,n);case 2:return nd(e,[0,t],[e.shape[0],n]);case 3:return rd(e,[0,0,t],[e.shape[0],e.shape[1],n]);case 4:return ad(e,[0,0,0,t],[e.shape[0],e.shape[1],e.shape[2],n]);default:throw new wg(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}}))}function vy(e,t,n,r){return ho((()=>{switch(e.rank){case 1:return td(e,t,n);case 2:switch(r){case 1:return by(e,t,n);case 2:return xy(e,t,n);default:throw new wg(`The axis is not within the rank of the tensor ${r}`)}case 3:switch(r){case 1:return by(e,t,n);case 2:return rd(e,[0,t,0],[e.shape[0],n,e.shape[2]]);case 3:return xy(e,t,n);default:throw new wg(`The axis is not within the rank of the tensor ${r}`)}case 4:switch(r){case 1:return by(e,t,n);case 2:return ad(e,[0,t,0,0],[e.shape[0],n,e.shape[2],e.shape[3]]);case 3:return ad(e,[0,0,t,0],[e.shape[0],e.shape[1],n,e.shape[3]]);case 4:return xy(e,t,n);default:throw new wg(`The axis is not within the rank of the tensor ${r}`)}default:throw new wg(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}}))}function _y(e,t=-1){let n;return t<0&&(n=e[0].rank,t=0!==n?n:0),t===e[0].rank&&(t=-1),kl(e,t)}function wy(e,t){switch(e.rank){case 1:return Pl([e,t]);case 2:return Hl([e,t],0);case 3:return jl([e,t],0);case 4:return Ul([e,t],0);default:throw new wg(`concatAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}}function My(e,t){if(Array.isArray(t)||(t=[t]),e.rank!==t.length)throw new wg(`The length of input n (${t.length}) does not match the number of dimensions in input x (${e.rank})`);return Cc(e,t)}function Ny(e,t=0,n=1,r,a){return Op(e,t,n,r,a)}function Sy(e,t,n,r){if(e.rank<2||t.rank<2)throw new Mg(`dot requires both inputs to be rank >= 2 but got x shape = ${e.shape} and y shape = ${t.shape}`);if(t.rank>=3&&e.shape.slice(-1)[0]!==t.shape.slice(-2)[0])throw new Mg(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${e.shape} and y shape = ${t.shape}`);if(2===e.rank&&2===t.rank)return Kd({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?Ty(e.rank,r,"channelsLast"):null,activation:n});{const a=e.shape.slice(),i=a.pop();e=Ml(e,[-1,i]);const s=t.shape.slice(),o=s.pop(),u=s.pop(),l=[...s,o],c=Array.from({length:t.rank},((e,n)=>0===n?t.rank-2:n<=t.rank-2?n-1:n));t=Ml(Io(t,c),[u,-1]);const p=[...a,...l];return Ml(Kd({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?Ty(e.rank,r,"channelsLast"):null,activation:n}),p)}}function ky(e,t,n){return ho((()=>(t=Array.isArray(t)?yd(t,"int32"):Ls(t,"int32"),$c(e,t,n))))}function Dy(e){return Su(e,e)}function Ty(e,t,n){const r=t.shape;if(1!==t.rank&&t.rank!==e)throw new wg(`Unexpected bias dimensions: ${t.rank}; expected it to be 1 or ${e}`);if(5===e){if("channelsFirst"===n)return 1===r.length?Ml(t,[1,r[0],1,1,1]):Ml(t,[1,r[3],r[0],r[1],r[2]]);if("channelsLast"===n)return 1===r.length?Ml(t,[1,1,1,1,r[0]]):Ml(t,[1].concat(r))}else if(4===e){if("channelsFirst"===n)return 1===r.length?Ml(t,[1,r[0],1,1]):Ml(t,[1,r[2],r[0],r[1]]);if("channelsLast"===n)return 1===r.length?Ml(t,[1,1,1,r[0]]):Ml(t,[1].concat(r))}else if(3===e){if("channelsFirst"===n)return 1===r.length?Ml(t,[1,r[0],1]):Ml(t,[1,r[1],r[0]]);if("channelsLast"===n)return 1===r.length?Ml(t,[1,1,r[0]]):Ml(t,[1].concat(r))}else if(e<3)return t;throw new wg(`Unsupported input rank by biasAdd: ${t.rank}`)}function Iy(e,t,n){return ho((()=>(null==n&&(n="channelsLast"),ty(n),wu(e,Ty(e.rank,t,n)))))}function Ey(e,t,n,r){return ho((()=>Rd(e,t,n,r)))}function Cy(e,t,n=!1){return n?e():t()}const Ay=["fanIn","fanOut","fanAvg"],Ly=["normal","uniform","truncatedNormal"];class $y extends ou{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}}class Oy extends $y{apply(e,t){return up(e,t)}}Oy.className="Zeros",lu(Oy);class Ry extends $y{apply(e,t){return lp(e,t)}}Ry.className="Ones",lu(Ry);class Fy extends $y{constructor(e){if(super(),"object"!=typeof e)throw new wg(`Expected argument of type ConstantConfig but got ${e}`);if(void 0===e.value)throw new wg(`config must have value set but got ${e}`);this.value=e.value}apply(e,t){return ho((()=>Su(Ru(this.value),lp(e,t))))}getConfig(){return{value:this.value}}}Fy.className="Constant",lu(Fy);class Yy extends $y{constructor(e){super(),this.DEFAULT_MINVAL=-.05,this.DEFAULT_MAXVAL=.05,this.minval=e.minval||this.DEFAULT_MINVAL,this.maxval=e.maxval||this.DEFAULT_MAXVAL,this.seed=e.seed}apply(e,t){return Fp(e,this.minval,this.maxval,t)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}Yy.className="RandomUniform",lu(Yy);class zy extends $y{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if("float32"!==(t=t||"float32")&&"int32"!==t)throw new Mg(`randomNormal does not support dType ${t}.`);return Ny(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}zy.className="RandomNormal",lu(zy);class By extends $y{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if("float32"!==(t=t||"float32")&&"int32"!==t)throw new Mg(`truncatedNormal does not support dType ${t}.`);return Md(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}By.className="TruncatedNormal",lu(By);class Py extends $y{constructor(e){super(),this.gain=null!=e.gain?e.gain:1}apply(e,t){return ho((()=>{if(2!==e.length||e[0]!==e[1])throw new wg("Identity matrix initializer can only be used for 2D square matrices.");return Su(this.gain,Ac(e[0]))}))}getConfig(){return{gain:this.gain}}}Py.className="Identity",lu(Py);class Hy extends $y{constructor(e){if(super(),e.scale<0)throw new wg(`scale must be a positive float. Got: ${e.scale}`);var t;this.scale=null==e.scale?1:e.scale,this.mode=null==e.mode?"fanIn":e.mode,t=this.mode,Bg(Ay,"FanMode",t),this.distribution=null==e.distribution?"normal":e.distribution,function(e){Bg(Ly,"Distribution",e)}(this.distribution),this.seed=e.seed}apply(e,t){const n=function(e,t="channelsLast"){let n,r;if(ty(t),2===e.length)n=e[0],r=e[1];else if(-1!==[3,4,5].indexOf(e.length)){if("channelsFirst"===t){const t=cy(e,2);n=e[1]*t,r=e[0]*t}else if("channelsLast"===t){const t=cy(e,0,e.length-2);n=e[e.length-2]*t,r=e[e.length-1]*t}}else{const t=cy(e);n=Math.sqrt(t),r=Math.sqrt(t)}return[n,r]}(e),r=n[0],a=n[1];let i=this.scale;if("fanIn"===this.mode?i/=Math.max(1,r):"fanOut"===this.mode?i/=Math.max(1,a):i/=Math.max(1,(r+a)/2),"normal"===this.distribution){const n=Math.sqrt(i);if("float32"!==(t=t||"float32")&&"int32"!==t)throw new Mg(`${this.getClassName()} does not support dType ${t}.`);return Md(e,0,n,t,this.seed)}{const n=Math.sqrt(3*i);return Fp(e,-n,n,t)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}Hy.className="VarianceScaling",lu(Hy);class jy extends Hy{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}jy.className="GlorotUniform",lu(jy);class Uy extends Hy{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}Uy.className="GlorotNormal",lu(Uy);class qy extends Hy{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}qy.className="HeNormal",lu(qy);class Wy extends Hy{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}Wy.className="HeUniform",lu(Wy);class Vy extends Hy{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}Vy.className="LeCunNormal",lu(Vy);class Gy extends Hy{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}Gy.className="LeCunNormal",lu(Gy);class Ky extends $y{constructor(e){if(super(),this.DEFAULT_GAIN=1,this.gain=null==e.gain?this.DEFAULT_GAIN:e.gain,this.seed=e.seed,null!=this.seed)throw new Mg("Random seed is not implemented for Orthogonal Initializer yet.")}apply(e,t){return ho((()=>{if(e.length<2)throw new Mg("Shape must be at least 2D.");e[0]*e[1]>2e3&&console.warn(`Orthogonal initializer is being called on a matrix with more than 2000 (${e[0]*e[1]}) elements: Slowness may result.`);const t=Ny(e[0]>e[1]?[e[1],e[0]]:e,0,1,"float32");let n=qh.gramSchmidt(t);return e[0]>e[1]&&(n=Io(n)),Su(this.gain,n)}))}getConfig(){return{gain:this.gain,seed:this.seed}}}Ky.className="Orthogonal",lu(Ky);const Jy={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function Xy(e,t={}){return Rg(e,uu.getMap().classNameMap,t,"initializer")}function Zy(e){return $g(e)}function Qy(e){if("string"==typeof e){const t=e in Jy?Jy[e]:e;if("GlorotNormal"===t)return new Uy;if("GlorotUniform"===t)return new jy;if("HeNormal"===t)return new qy;if("HeUniform"===t)return new Wy;if("LeCunNormal"===t)return new Vy;if("LeCunUniform"===t)return new Gy;{const e={};return e.className=t,e.config={},Xy(e)}}return e instanceof $y?e:Xy(e)}function eb(e){return Array.isArray(e)&&Array.isArray(e[0])}function tb(e){return 0===e.length?[]:Array.isArray(e[0])?e:[e]}function nb(e){let t;if(Array.isArray(e)){if(1!==e.length)throw new wg(`Expected Tensor length to be 1; got ${e.length}`);t=e[0]}else t=e;return t}function rb(e){if(Array.isArray(e)&&Array.isArray(e[0])){if(1===e.length)return e[0];throw new wg(`Expected exactly 1 Shape; got ${e.length}`)}return e}function ab(e){let t=0;for(const n of e)0===n.shape.length?t+=1:t+=n.shape.reduce(((e,t)=>e*t));return t}class ib{constructor(e,t="float32",n="Variable",r=!0,a=null){this.dtype=null==t?"float32":t,this.shape=e.shape,this.id=Wg(),n=null==n?"Variable":n,this.originalName=sy(n),this.name=oy(this.originalName),this.trainable_=r,this.constraint=a,this.val=Td(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),function(e,t){if(e.shape.toString()!==t.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}(this.val,e),this.val.id!==e.id&&(this.val.assign(e),null!=this.constraint&&this.val.assign(this.constraint.apply(this.val))),this}dispose(){this.assertNotDisposed(),this.val.dispose()}assertNotDisposed(){if(this.val.isDisposed)throw new Error(`LayersVariable ${this.name} is already disposed.`)}get trainable(){return this.trainable_}set trainable(e){this.trainable_=e,this.val.trainable=e}}function sb(e){return e.map((e=>e.read()))}function ob(e){e.forEach((e=>{e[0].write(e[1])}))}class ub{constructor(e){this.dtype=e.dtype,this.shape=e.shape,null!=e.shape?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}}class lb{constructor(e,t,n,r,a,i,s){this.dtype=e,this.shape=t,this.sourceLayer=n,this.inputs=r,this.callArgs=a,this.outputTensorIndex=s,this.id=Wg(),null!=i&&(this.originalName=sy(i),this.name=oy(this.originalName)),this.rank=t.length}}let cb=0;class pb{constructor(e,t){this.callArgs=t,this.id=cb++,this.outboundLayer=e.outboundLayer,this.inboundLayers=e.inboundLayers,this.nodeIndices=e.nodeIndices,this.tensorIndices=e.tensorIndices,this.inputTensors=e.inputTensors,this.outputTensors=e.outputTensors,this.inputMasks=e.inputMasks,this.outputMasks=e.outputMasks,this.inputShapes=e.inputShapes,this.outputShapes=e.outputShapes;for(const t of e.inboundLayers)null!=t&&t.outboundNodes.push(this);e.outboundLayer.inboundNodes.push(this)}getConfig(){const e=[];for(const t of this.inboundLayers)null!=t?e.push(t.name):e.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let db=0;class hb extends ou{constructor(e={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=db++,this.activityRegularizer=null,this.inputSpec=null,this.supportsMasking=!1,this._trainableWeights=[],this._nonTrainableWeights=[],this._losses=[],this._updates=[],this._built=!1,this.inboundNodes=[],this.outboundNodes=[];let t=e.name;if(!t){const e=this.getClassName();t=Cg(e)+"_"+Gg(e)}if(this.name=t,this.trainable_=null==e.trainable||e.trainable,null!=e.inputShape||null!=e.batchInputShape){let t;if(null!=e.batchInputShape)t=e.batchInputShape;else if(null!=e.inputShape){let n=null;null!=e.batchSize&&(n=e.batchSize),t=[n].concat(e.inputShape)}this.batchInputShape=t;let n=e.dtype;null==n&&(n=e.inputDType),null==n&&(n="float32"),this.dtype=n}null!=e.weights?this.initialWeights=e.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}static nodeKey(e,t){return e.name+"_ib-"+t.toString()}getNodeAtIndex(e,t){if(0===this.inboundNodes.length)throw new _g(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new wg(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return Ig(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return Ig(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new vg(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(0===this.inboundNodes.length)throw new vg(`Layer ${this.name} is not connected, no input to return.`);return Ig(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(0===this.inboundNodes.length)throw new vg(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new vg(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return Ig(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map((e=>e()))}get updates(){return this._updates}get built(){return this._built}set built(e){this._built=e}get trainable(){return this.trainable_}set trainable(e){this._trainableWeights.forEach((t=>t.trainable=e)),this.trainable_=e}get trainableWeights(){return this.trainable_?this._trainableWeights.filter((e=>e.trainable)):[]}set trainableWeights(e){this._trainableWeights=e}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter((e=>!e.trainable)).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(e){this._nonTrainableWeights=e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}get stateful(){return this._stateful}resetStates(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(e){if(e=Eg(e),null==this.inputSpec||0===this.inputSpec.length)return;const t=Eg(this.inputSpec);if(e.length!==t.length)throw new wg(`Layer ${this.name} expects ${t.length} inputs, but it received ${e.length} input tensors. Input received: ${e}`);for(let n=0;na.maxNDim)throw new wg(`Input ${n} is incompatible with layer ${this.name}: expected max_ndim=${a.maxNDim}, found ndim=${i}`);if(null!=a.minNDim&&i=0?e[r]:e[e.length+r];if(null!=i&&-1===[i,null].indexOf(s))throw new wg(`Input ${n} is incompatible with layer ${this.name}: expected axis ${r} of input shape to have value ${i} but got shape ${e}.`)}}if(null!=a.shape)for(let e=0;e{if(!this.built){this.assertInputCompatibility(e);const t=[];for(const n of Eg(e))t.push(n.shape);this.build(Ig(t)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),null===this._refCount&&a&&(this._refCount=1)}if(this.assertInputCompatibility(e),a){let r=this.call(e,t);const a=Eg(r),i=[];for(let e of a)-1!==n.indexOf(e)&&(e=e.clone()),i.push(e);if(r=Ig(i),null!=this.activityRegularizer)throw new Mg("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return r}{const n=function(e){e=Eg(e);const t=[];for(const n of e)t.push(n.shape);return Ig(t)}(e),r=this.computeOutputShape(n);let a;const i="float32";if(this.warnOnIncompatibleInputShape(Array.isArray(e)?n[0]:n),a=null!=r&&r.length>0&&Array.isArray(r[0])?r.map(((n,r)=>new lb(i,n,this,Eg(e),t,this.name,r))):new lb(i,r,this,Eg(e),t,this.name),this.addInboundNode(e,a,null,null,n,r,t),this._refCount++,null!=this.activityRegularizer)throw new Mg("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return a}}))}warnOnIncompatibleInputShape(e){if(null!=this.batchInputShape)if(e.length!==this.batchInputShape.length)console.warn(`The rank of the input tensor provided (shape: ${JSON.stringify(e)}) does not match that of the batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer ${this.name}`);else{let t=!1;this.batchInputShape.forEach(((n,r)=>{null!=n&&null!=e[r]&&e[r]!==n&&(t=!0)})),t&&console.warn(`The shape of the input tensor (${JSON.stringify(e)}) does not match the expectation of layer ${this.name}: ${JSON.stringify(this.batchInputShape)}`)}}get outputShape(){if(null==this.inboundNodes||0===this.inboundNodes.length)throw new vg(`The layer ${this.name} has never been called and thus has no defined output shape.`);const e=[];for(const t of this.inboundNodes){const n=JSON.stringify(t.outputShapes);-1===e.indexOf(n)&&e.push(n)}if(1===e.length){const e=this.inboundNodes[0].outputShapes;return Array.isArray(e)&&Array.isArray(e[0])&&1===e.length?e[0]:e}throw new vg(`The layer ${this.name} has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.`)}countParams(){if(!this.built)throw new _g(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return ab(this.weights)}build(e){this.built=!0}getWeights(e=!1){return sb(e?this.trainableWeights:this.weights)}setWeights(e){ho((()=>{const t=this.weights;if(t.length!==e.length)throw new wg(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${e.length}, but the layer was expecting ${t.length} weights. Provided weights: ${e}...`);if(0===t.length)return;const n=[],r=sb(t);for(let a=0;aa.apply(l.read()))),null==i&&(i=!0),i?this._trainableWeights.push(l):this._nonTrainableWeights.push(l),l}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){null==e||Array.isArray(e)&&0===e.length||(e=Eg(e),void 0!==this._losses&&null!==this._losses&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,t){if(!this.supportsMasking){if(null!=t){if(!Array.isArray(t))throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);t.forEach((e=>{if(null!=e)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)}))}return null}return t}addInboundNode(e,t,n,r,a,i,s=null){const o=Eg(e);t=Eg(t),n=Eg(n),r=Eg(r),a=tb(a),i=tb(i);const u=[],l=[],c=[];for(const e of o)u.push(e.sourceLayer),l.push(e.nodeIndex),c.push(e.tensorIndex);new pb({outboundLayer:this,inboundLayers:u,nodeIndices:l,tensorIndices:c,inputTensors:o,outputTensors:t,inputMasks:n,outputMasks:r,inputShapes:a,outputShapes:i},s);for(let e=0;ee.dispose())),this.weights.length}assertNotDisposed(){if(0===this._refCount)throw new Error(`Layer '${this.name}' is already disposed.`)}dispose(){if(!this.built)throw new Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`);if(null===this._refCount)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return 0==--this._refCount&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}}function fb(e,t,n){if((null==t||null!=n&&n>0)&&(t=e.sourceLayer,n=e.nodeIndex),0===t.inboundNodes.length)return[e];{const e=t.inboundNodes[n];if(0===e.inboundLayers.length)return e.inputTensors;{const t=[];for(let n=0;ne.name)),u=[],l=t.names();for(const e of o)-1!==l.indexOf(e)?u.push(t.getValue(e)):u.push(null);null!=r&&(r.maxNumTensors=-1/0,r.minNumTensors=1/0);const c=o.join(",")+"|"+t.names().sort().join(",");let p,d=bb.get(c);if(null==d){const e=function(e,t){se(null!=e&&e.length>0,(()=>"Expected at least one fetch, got none"));let n=[],r={};if(1===e.length){const a=wb(e[0],t);n=a.sorted,r=a.recipientMap}else{const a=new Set;for(const i of e){const{sorted:e,recipientMap:s}=wb(i,t);for(const t of e)a.has(t.name)||(n.push(t),a.add(t.name));for(const e in s)null==r[e]&&(r[e]=new Set),s[e].forEach((t=>r[e].add(t)))}}return{sorted:n,recipientCounts:_b(r)}}(s,t);d=e.sorted,p=e.recipientCounts,bb.put(c,d),xb.put(c,p)}p={},a||Object.assign(p,xb.get(c));const h=new yb(t);for(let e=0;er.maxNumTensors&&(r.maxNumTensors=e),e0;){const e=i[i.length-1];if(n.has(e.name)){i.pop();continue}const t=s[s.length-1]===i.length-1;if(0===e.inputs.length||t)i.pop(),r.push(e),n.add(e.name),t&&s.pop();else{s.push(i.length-1);for(const t of e.inputs)null==a[t.name]&&(a[t.name]=new Set),a[t.name].add(e.name),n.has(t.name)||i.push(t)}}return{sorted:r,recipientMap:a}}function Mb(e){let t;if(1===e.sourceLayer.inboundNodes.length)t=e.sourceLayer.output;else{let n=null;for(let t=0;tku(Nc(Su(e,e),t,!0))))}Ge().registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES",(()=>100),(function(e){null!=bb&&bb.setMaxEntries(e),null!=xb&&xb.setMaxEntries(e)}));class Sb extends ou{getConfig(){return{}}}class kb extends Sb{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return ho((()=>{const t=Nb(e,this.axis),n=Bl(t,0,this.maxValue);return Su(e,Nu(n,wu(my(),t)))}))}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}kb.className="MaxNorm",lu(kb);class Db extends Sb{constructor(e){super(),this.defaultAxis=0,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return ho((()=>Nu(e,wu(my(),Nb(e,this.axis)))))}getConfig(){return{axis:this.axis}}}Db.className="UnitNorm",lu(Db);class Tb extends Sb{apply(e){return Bp(e)}}Tb.className="NonNeg",lu(Tb);class Ib extends Sb{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=null!=e.minValue?e.minValue:this.defaultMinValue,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.rate=null!=e.rate?e.rate:this.defaultRate,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return ho((()=>{const t=Nb(e,this.axis),n=wu(Su(this.rate,Bl(t,this.minValue,this.maxValue)),Su(1-this.rate,t));return Su(e,Nu(n,wu(my(),t)))}))}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}Ib.className="MinMaxNorm",lu(Ib);const Eb={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function Cb(e){return $g(e)}function Ab(e,t={}){return Rg(e,uu.getMap().classNameMap,t,"constraint")}function Lb(e){return null==e?null:"string"==typeof e?Ab({className:e in Eb?Eb[e]:e,config:{}}):e instanceof Sb?e:Ab(e)}function $b(e){return new kb(e)}function Ob(e){return new Db(e)}function Rb(){return new Tb}function Fb(e){return new Ib(e)}function Yb(){return new Oy}function zb(){return new Ry}function Bb(e){return new Fy(e)}function Pb(e){return new Yy(e)}function Hb(e){return new zy(e)}function jb(e){return new By(e)}function Ub(e){return new Py(e)}function qb(e){return new Hy(e)}function Wb(e){return new jy(e)}function Vb(e){return new Uy(e)}function Gb(e){return new qy(e)}function Kb(e){return new Wy(e)}function Jb(e){return new Vy(e)}function Xb(e){return new Gy(e)}function Zb(e){return new Ky(e)}async function Qb(e){if(null==e)return;const t=[],n=[],r=[];for(const a in e){const i=e[a];if("number"!=typeof i){const e=i;t.push(e.data()),n.push(a),r.push(e)}}if(t.length>0){const a=await Promise.all(t);for(let t=0;twu(this.totals[e],Su(r,n))));this.totals[e]=a,null!=t&&t.dispose()}}}async onEpochEnd(e,t){if(null!=t)for(const e of this.params.metrics)null!=this.totals[e]&&("number"==typeof this.totals[e]?t[e]=this.totals[e]/this.seen:ho((()=>{const n=Su(Nu(1,this.seen),this.totals[e]);t[e]=n,this.totals[e].dispose(),mo(t[e])})))}}class ix extends nx{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,t){null==t&&(t={}),this.epoch.push(e);for(const e in t)null==this.history[e]&&(this.history[e]=[]),this.history[e].push(t[e])}async syncData(){const e=[],t=[],n=[];for(const r in this.history){const a=this.history[r];for(let i=0;i{const s=null!=n?n():za();return s-anew sx(e,t)))}class ux{constructor(){}static registerCallbackConstructor(e,t){se(e>=0&&Number.isInteger(e),(()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`)),ux.checkForDuplicate(t),null==ux.constructors[e]&&(ux.constructors[e]=[]),ux.constructors[e].push(t)}static checkForDuplicate(e){for(const t in ux.constructors)ux.constructors[+t].forEach((t=>{if(t===e)throw new wg("Duplicate callback constructor.")}))}static clear(){ux.constructors={}}static createCallbacks(e){const t=[];for(const n in ux.constructors){const r=+n;e>=r&&t.push(...ux.constructors[r])}return t.map((e=>new e))}}function lx(e,t,n,r,a,i,s,o,u){const l=new ix,c=[new ax,...ux.createCallbacks(t)];null!=e&&c.push(...e),c.push(l);const p=new rx(c);return p.setParams({epochs:n,initialEpoch:r,samples:a,steps:i,batchSize:s,verbose:t,doValidation:o,metrics:u}),{callbackList:p,history:l}}function cx(e,t={},n=!1){return Rg(e,uu.getMap().classNameMap,t,"layer",n)}function px(e,t){return ho((()=>{"float32"!==e.dtype&&(e=Ls(e,"float32"));const n=Nc(Dy(e),t,!0),r=zu(n.shape,my()),a=ku(qu(n,r));return Nu(e,a)}))}function dx(e,t){return ho((()=>op(Dy(Hu(t,e)),-1)))}function hx(e,t){return ho((()=>op(Uu(Hu(t,e)),-1)))}function fx(e,t){return ho((()=>{const n=Hu(e,t),r=Bl(Uu(e),my(),Number.MAX_VALUE),a=Uu(Nu(n,r));return Su(100,op(a,-1))}))}function mx(e,t,n=!1){return ho((()=>{if(n)t=id(t);else{const e=Nc(t,t.shape.length-1,!0);t=Nu(t,e)}return t=Bl(t,my(),1-my()),Do(Nc(Su(Ls(e,"float32"),qc(t)),t.shape.length-1))}))}function gx(e,t,n=!1){return ho((()=>{const r=Ls(Lc(function(e){const t=[cy(e.shape)];return Ml(e,t)}(e)),"int32"),a=(t=Bl(t,my(),1-my())).shape;return mx(Ml(ro(r,a[a.length-1]),a),t,n)}))}function yx(e,t){return ho((()=>{let n;return n=Bl(t,my(),1-my()),n=qc(Nu(n,Hu(1,n))),op(function(e,t){if(!de(e.shape,t.shape))throw new wg(`logits and labels must have the same shape, but got shapes ${JSON.stringify(e.shape)} and ${JSON.stringify(t.shape)}`);return ho((()=>{const n=Bp(t),r=Do(Uu(t));return wu(Hu(n,Su(t,e)),Wc(Tc(r)))}))}(e,n),-1)}))}function bx(e,t){return ho((()=>{const n=px(e,-1),r=px(t,-1),a=Su(n,r);return Do(Nc(a,-1))}))}ux.constructors={};const xx={meanSquaredError:dx,meanAbsoluteError:hx,meanAbsolutePercentageError:fx,meanSquaredLogarithmicError:function(e,t){return ho((()=>{const n=Bl(t,my(),Number.MAX_VALUE),r=qc(wu(1,n)),a=Bl(e,my(),Number.MAX_VALUE),i=qc(wu(1,a));return op(Dy(Hu(r,i)),-1)}))},squaredHinge:function(e,t){return ho((()=>{const n=qu(0,Hu(1,Su(e,t)));return op(Dy(n),-1)}))},hinge:function(e,t){return ho((()=>{const n=qu(0,Hu(1,Su(e,t)));return op(n,-1)}))},categoricalHinge:function(e,t){return ho((()=>{const n=Nc(Su(e,t),-1),r=wc(Su(Hu(1,e),t),-1);return qu(0,wu(1,Hu(r,n)))}))},logcosh:function(e,t){return ho((()=>{const n=Math.log(2),r=Hu(t,e),a=Hu(wu(r,Vc(Su(-2,r))),n);return op(a,-1)}))},categoricalCrossentropy:mx,sparseCategoricalCrossentropy:gx,binaryCrossentropy:yx,kullbackLeiblerDivergence:function(e,t){return ho((()=>{const n=Bl(e,my(),1),r=Bl(t,my(),1);return Nc(Su(e,qc(Nu(n,r))),-1)}))},poisson:function(e,t){return ho((()=>{const n=qc(wu(my(),t));return op(Hu(t,Su(e,n)),-1)}))},cosineProximity:bx};function vx(e){if("string"==typeof e){if(e in xx)return xx[e];let t=`Unknown loss ${e}`;throw e.toLowerCase().includes("softmaxcrossentropy")&&(t=`Unknown loss ${e}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new wg(t)}return e}function _x(e,t){return ho((()=>{const n=Su(.5,bp(t)),r=gy(Oc(t,n),e.dtype);return op(oc(e,r),-1)}))}function wx(e,t){return ho((()=>gy(oc(nl(e,-1),nl(t,-1)),"float32")))}function Mx(e,t){return ho((()=>Ls(Nc(Xc(oc(e,1),oc(t,1))),"float32")))}function Nx(e,t){return ho((()=>{const n=Mx(e,t),r=function(e,t){return ho((()=>Ls(Nc(Xc(oc(e,0),oc(t,1))),"float32")))}(e,t),a=wu(n,r);return Ls(uc(Oc(a,0),Nu(n,a),0),"float32")}))}function Sx(e,t){return yx(e,t)}function kx(e,t){return e.rank===t.rank&&(e=dd(e,[e.rank-1])),(t=nl(t,-1)).dtype!==e.dtype&&(t=Ls(t,e.dtype)),Ls(oc(e,t),"float32")}const Dx=mx,Tx=gx,Ix={binaryAccuracy:_x,categoricalAccuracy:wx,precision:Nx,categoricalCrossentropy:Dx,sparseCategoricalCrossentropy:Tx,mse:dx,MSE:dx,mae:hx,MAE:hx,mape:fx,MAPE:fx,cosine:bx};function Ex(e){if("string"==typeof e&&e in Ix)return Ix[e];if("string"!=typeof e&&null!=e)return e;throw new wg(`Unknown metric ${e}`)}function Cx(e){if(Dg(null!==e,`Unknown LossOrMetricFn ${e}`),"string"==typeof e)return e;{let t;for(const n of Object.keys(xx))if(xx[n]===e){t=n;break}if(void 0!==t)return t;for(const n of Object.keys(Ix))if(Ix[n]===e){t=n;break}return void 0!==t?t:e.name}}function Ax(e,t,n=!1){if(null==e||"object"!=typeof e||Object.getPrototypeOf(e)!==Object.prototype||!Lx(e))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){const n=JSON.stringify(e);n.length>1048576&&console.warn(`User-defined metadata of model "${t}" is too large in size (length=${n.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= 1048576.`)}}function Lx(e){if(null===e)return!0;if("object"==typeof e){if(Object.getPrototypeOf(e)===Object.prototype){const t=Object.keys(e);for(const n of t){if("string"!=typeof n)return!1;if(!Lx(e[n]))return!1}return!0}if(Array.isArray(e)){for(const t of e)if(!Lx(t))return!1;return!0}return!1}{const t=typeof e;return"string"===t||"number"===t||"boolean"===t}}function $x(e,t,n=console.log){let r="";for(let n=0;n0&&(r=r.slice(0,r.length-1)+" "),r+=e[n],r=r.slice(0,t[n]),r+=" ".repeat(t[n]-r.length);n(r)}function Ox(e,t,n){let r,a;try{a=e.inboundNodes.map((e=>JSON.stringify(e.inputShapes))).join(",")}catch(e){a="multiple"}try{r=JSON.stringify(e.outputShape)}catch(e){r="multiple"}$x([`${e.name} (${e.getClassName()})`,a,r,e.countParams().toString()],t,n)}function Rx(e,t,n,r){let a,i;try{i=e.inboundNodes.map((e=>JSON.stringify(e.inputShapes))).join(",")}catch(e){i="multiple"}try{a=JSON.stringify(e.outputShape)}catch(e){a="multiple"}const s=[];for(const t of e.inboundNodes)if(!(null!=n&&n.length>0&&-1===n.indexOf(t)))for(let e=0;ee.name))}`);Yg(this.outputs).length!==this.outputs.length&&console.warn(`The list of outputs passed to the model is redundant. All outputs should only appear once. Found: ${this.outputs.map((e=>e.name))}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(const e of this.outputs){const t=e.sourceLayer,n=e.nodeIndex,r=e.tensorIndex;this.outputLayers.push(t),this.outputLayersNodeIndices.push(n),this.outputLayersTensorIndices.push(r)}for(const e of this.inputs){const t=e.sourceLayer,n=e.nodeIndex,r=e.tensorIndex;Dg(0===n,"input layer has >1 nodes"),Dg(0===r,"input layer has >1 tensors"),this.inputLayers.push(t),this.inputLayersNodeIndices.push(n),this.inputLayersTensorIndices.push(r)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let t=0;te.shape)),this.internalOutputShapes=this.outputs.map((e=>e.shape));const t={},n={},r={},a={},i={},s=[],o=(e,t,n,r,a,u)=>{null!=r&&null!=a&&null!=u||(r=e.sourceLayer,a=e.nodeIndex,u=e.tensorIndex);const l=r.inboundNodes[a];if(-1!==n.indexOf(l))throw new _g(`The tensor ${e.name} at layer "${r.name}" is part of a cycle.`);if(-1!==t.indexOf(l))return;this.containerNodes.add(Px.nodeKey(r,a)),r.id in i||(i[r.id]=Object.keys(i).length),-1===n.indexOf(l)&&n.push(l);const c=l.inboundLayers.length;for(let e=0;e=0;)n.splice(n.indexOf(l),1);s.push(l)},u=[],l=[];for(const e of this.outputs)o(e,u,l);const c=s.slice().reverse();for(const e of c){n[e.id]=e,e.id in t||(t[e.id]=0);let i=t[e.id];const s=null==r[e.outboundLayer.id]?0:r[e.outboundLayer.id];i=Math.max(i,s),r[e.outboundLayer.id]=i,a[e.outboundLayer.id]=e.outboundLayer,t[e.id]=i;for(let r=0;rparseInt(e,10))).sort(Fg);this.layers=[];for(const e of h){const t=d[e];t.sort(((e,t)=>{const n=i[e.id],r=i[t.id];return nr?1:0}));for(const e of t)e instanceof Px&&this.internalContainerRefs.push(e),this.layers.push(e)}this.layersByDepth=d,h=Object.keys(p).map((e=>parseInt(e,10))).sort(Fg);const f=this.inputs.slice(),m=[];for(const e of h)for(const t of p[e]){const e=t.outboundLayer;if(null!=e){for(const n of t.inputTensors)if(-1===f.indexOf(n))throw new _g(`Graph disconnected: cannot obtain value for tensor ${n} at layer "${e.name}". The following previous layers were accessed without issue: ${m}`);for(const e of t.outputTensors)f.push(e);m.push(e.name)}}this.nodesByDepth=p;const g=this.layers.map((e=>e.name));for(const e of g){const t=g.filter((t=>t===e)).length;if(1!==t)throw new _g(`The name "${e}" is used ${t} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(g))}this.outboundNodes=[],this.inboundNodes=[],new pb({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map((e=>null)),outputMasks:this.outputs.map((e=>null)),inputShapes:this.inputs.map((e=>e.shape)),outputShapes:this.outputs.map((e=>e.shape))}),this.built=!0,this._refCount=1}assertNotDisposed(){if(0===this._refCount)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();const e={refCountAfterDispose:null,numDisposedVariables:0};if(0==--this._refCount){for(const t of this.layers)e.numDisposedVariables+=t.dispose().numDisposedVariables;for(const t of this.internalContainerRefs)e.numDisposedVariables+=t.dispose().numDisposedVariables}return e.refCountAfterDispose=this._refCount,e}get trainable(){return this.trainable_}set trainable(e){this.layers.forEach((t=>{t._trainableWeights.forEach((t=>t.trainable=e))})),this.trainable_=e}get trainableWeights(){if(this._trainableWeights.length>0)throw new wg("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return[];let e=[];for(const t of this.layers)e=e.concat(t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.layers)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const e of this.layers)t.push(...e.trainableWeights);return t.concat(e)}return e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(e,t=!0){const n={};let r=0;for(const e of this.layers)for(const t of e.weights){if(null!=n[t.originalName])throw new wg(`Duplicate weight name: ${t.originalName}`);n[t.originalName]=t,r++}const a=[];for(const r in e){let i=r;if(null==n[r]){const e=r.split("/");i=e.slice(0,-2).concat([e[e.length-1]]).join("/")}if(null!=n[i])a.push([n[i],e[r]]);else if(t)throw new wg(`Provided weight data has no target variable: ${r}`);delete n[i]}if(t){const e=[];for(const t in n)e.push(t);if(e.length>0)throw new wg(`${e.length} of ${r} weights are not set: ${e}`)}ob(a)}updatedConfig(){const e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion=`tfjs-layers ${Bx}`,t.backend="TensorFlow.js",t}toJSON(e,t=!0){const n=zx(this.updatedConfig());return t?JSON.stringify(n):n}call(e,t){return ho((()=>{e=Eg(e);const n=new yb;for(let t=0;t{let n;return e=Eg(e),n=null==t?kg(null,e.length):Eg(t),this.runInternalGraph(e,n)[1]}))}computeOutputShape(e){const t=tb(e);if(t.length!==this.inputLayers.length)throw new wg(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`);const n={};for(let e=0;eparseInt(e,10))).sort(Fg);if(r.length>1)for(const e of r){const t=this.nodesByDepth[e];for(const e of t){const t=e.outboundLayer;if(-1!==this.inputLayers.map((e=>e.id)).indexOf(t.id))continue;const r=[];for(let t=0;tparseInt(e,10))).sort(Fg);for(const e of r){const t=this.nodesByDepth[e];for(const e of t){const t=e.outboundLayer,r=e.inputTensors,a=e.outputTensors,i=new Array;for(const e of r)e.id in n&&i.push(n[e.id]);if(i.length===r.length){let r,s,o,u,l={};if(null!=e.callArgs&&(l=e.callArgs),1===i.length){const[e,n]=i[0];null==l.mask&&(l.mask=n),o=Eg(t.call(e,l)),u=Eg(t.computeMask(e,n)),r=[e],s=[n]}else r=i.map((e=>e[0])),s=i.map((e=>e[1])),null==l.mask&&(l.mask=s),o=Eg(t.call(r,l)),u=Eg(t.computeMask(r,s));if(t.activityRegularizer)throw new Mg("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let e=0;e{const e=[];for(const t of this.layers)for(let n=0;n0){const e=[];for(let n=0;n0&&e.apply(Ig(n),r)}function u(e){const n=e.name,i=cx(e,null!=t.customObjects?t.customObjects:{});i.setFastWeightInitDuringBuild(r),a[n]=i,e.inboundNodes.forEach((e=>{if(!(e instanceof Array))throw new wg(`Corrupted configuration, expected array for nodeData: ${e}`);s(i,e)}))}const l=t.name,c=t.layers;for(const e of c)u(e);for(;!zg(i);)for(const e of c){const t=a[e.name];if(t.name in i){const e=i[t.name];delete i[t.name];for(const n of e)o(t,n)}}const p=[],d=[],h=t.inputLayers;for(const e of h){const t=e[0],n=e[1],r=e[2];Dg(t in a);const i=a[t].inboundNodes[n].outputTensors;p.push(i[r])}const f=t.outputLayers;for(const e of f){const t=e[0],n=e[1],r=e[2];Dg(t in a);const i=a[t].inboundNodes[n].outputTensors;d.push(i[r])}return new e({inputs:p,outputs:d,name:l})}get stateful(){if(this._stateful)throw new wg("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");for(const e of this.layers)if(e.stateful)return!0;return!1}resetStates(){ho((()=>{this.layers.forEach((e=>{e.stateful&&e.resetStates()}))}))}}function Hx(e,t){return function(e,t,n){const r=t.length;if(null==e||Array.isArray(e)&&0===e.length)return t.map((e=>null));if(1===r)return Array.isArray(e)&&1===e.length?e:"object"==typeof e&&t[0]in e?[e[t[0]]]:[e];if(Array.isArray(e)){if(e.length!==r)throw new Error(`Provided ${n} is an array of ${e.length} element(s), but the model has ${r} outputs. Make sure a set of weights is provided for each model output.`);return e}if("object"==typeof e&&Object.keys(e).length>0&&"object"==typeof e[Object.keys(e)[0]]){const n=[];return t.forEach((t=>{t in e?n.push(e[t]):n.push(null)})),n}throw new Error(`The model has multiple (${r}) outputs, so ${n} must be either an array with ${r} elements or an object with ${t} keys. Provided ${n} not understood: ${JSON.stringify(e)}`)}(e,t,"classWeight")}async function jx(e,t,n,r){if(null!=t||null!=r)throw new Error("Support sampleWeight is not implemented yet");if(null!=n){const t=ho((()=>{if(1===e.shape.length)return $s(e);if(2===e.shape.length){if(e.shape[1]>1)return nl(e,1);if(1===e.shape[1])return Ml(e,[e.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${e.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}throw new Error(`Unexpected rank of target (y) tensor (${e.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)})),r=Array.from(await t.data());fo(t);const a=[];return r.forEach((e=>{if(null==n[e])throw new Error(`classWeight must contain all classes in the training data. The class ${e} exists in the data but not in classWeight`);a.push(n[e])})),yd(a,"float32")}return null}function Ux(e,t){return Su(e,t)}function qx(e,t){let n,r;const a=t;n=a.xs,r=a.ys,se(null!=n&&null!=r,(()=>`A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates ${t}`));const i=Wx("input",e.inputNames,n),s=Wx("output",e.outputNames,r),o=i[0].shape[0];se(i.length===e.inputs.length,(()=>`LayersModel has ${e.inputs.length} inputs, but the dataset provides ${i.length} inputs. (Expected input keys: ${JSON.stringify(e.inputNames)})`)),se(s.length===e.outputs.length,(()=>`LayersModel has ${e.outputs.length} outputs, but the dataset provides ${s.length} outputs. (Expected output keys: ${JSON.stringify(e.outputNames)})`));for(let t=0;t`Batch size mismatch: input ${e.inputNames[t]} has ${i[t].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`));for(let t=0;t`Batch size mismatch: output ${e.outputNames[t]} has ${s[t].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`));return{xs:i,ys:s}}function Wx(e,t,n){if(n instanceof ti)return[n];if(Array.isArray(n))return se(n.length===t.length,(()=>`Received an array of ${n.length} Tensors, but expected ${t.length} to match the ${e} keys ${t}.`)),n;{const r=[];for(const a of t){if(null==n[a])throw new wg(`The feature data generated by the dataset lacks the required ${e} key '${a}'.`);r.push(n[a])}return r}}function Vx(e){return"function"==typeof e.iterator}function Gx(e){se(e>0&&Number.isInteger(e),(()=>`batchSize is required to be a positive integer, but got ${e}`))}function Kx(e,t,n){return null==e?[null]:Array.isArray(e)?e.map((e=>by(e,t,n-t))):by(e,t,n-t)}function Jx(e,t){return ho((()=>null==e?null:Array.isArray(e)?e.map((e=>Jx(e,t))):ky(e,"int32"===t.dtype?t:Ls(t,"int32"))))}function Xx(e,t){const n=[];let r=0,a=null;for(;r=e&&(a=e),n.push([r,a]),r=a;return n}function Zx(e){const t=[];e instanceof ti&&(e=[e]);for(let n=0;nn.push(e.id)));else if(null!=t)for(const e in t){const r=t[e];n.push(r.id)}const r=[];if(e instanceof ti)-1===n.indexOf(e.id)&&r.push(e);else if(Array.isArray(e))e.forEach((e=>{-1===n.indexOf(e.id)&&r.push(e)}));else if(null!=e)for(const t in e){const a=e[t];-1===n.indexOf(a.id)&&r.push(a)}r.forEach((e=>{e.isDisposed||e.dispose()}))}function ev(e){return Array.isArray(e)}function tv(e){return!function(e){return e instanceof ti}(e)&&!ev(e)}function nv(e,t,n,r=!0,a=""){if(null==t||0===t.length){if(null!=e){let t=!1;if(ev(e)&&e.length>0)t=!0;else if(tv(e)){for(const n in e)if(e.hasOwnProperty(n)){t=!0;break}}else t=!0;if(t)throw new wg(`Error when checking model ${a} expected no data, but got ${e}`)}return[]}if(null==e)return t.map((e=>null));let i;if(tv(e)){i=[];for(const n of t){if(null==e[n])throw new wg(`No data provided for "${n}". Need data for each key in: ${t}`);i.push(e[n])}}else if(ev(e)){if(e.length!==t.length)throw new wg(`Error when checking model ${a}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${t.length} Tensor(s), but instead got the following list of Tensor(s): ${e}`);i=e}else{if(t.length>1)throw new wg(`The model ${a} expects ${t.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${e.shape}`);i=[e]}if(i=Zx(i),null!=n)for(let e=0;e=0&&i!==o)throw new wg(`${a} expected a batch of elements where each example has shape [${n[e].slice(1,n[e].length)}] (i.e.,tensor shape [*,${n[e].slice(1,n[e].length)}]) but the ${a} received an input with ${s.shape[0]} examples, each with shape [${s.shape.slice(1,s.shape.length)}] (tensor shape [${s.shape}])`)}}return i}function rv(e,t,n,r=!0,a=""){let i;if(Array.isArray(e)){if(e.length!==t.length)throw new wg(`Error when checking model ${a}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${t.length} Tensor(s), but instead got ${e.length} Tensors(s).`);i=e}else{if(t.length>1)throw new wg(`The model expects ${t.length} ${a} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(e.shape)}.`);i=[e]}if(null!=n)for(let e=0;e1||1===e.length&&e[0].inboundLayers.length>1){t=!1;break}r.push(...e)}if(t)for(const n of e.layers){let e=!1;for(const a of n.inboundNodes)if(-1!==r.indexOf(a)){if(e){t=!1;break}e=!0}if(!t)break}return t}(e),i=["Layer (type)","Input Shape","Output shape","Param #"];let s;if(a?(t=t||90,n=n||[.32,.61,.89,1]):(t=t||115,n=n||[.24,.48,.7,.8,1]),n[n.length-1]<=1&&(n=n.map((e=>Math.floor(t*e)))),!a){i.push("Receives inputs"),s=[];for(const t in e.nodesByDepth)s.push(...e.nodesByDepth[t])}r("_".repeat(t)),$x(i,n,r),r("=".repeat(t));const o=e.layers;for(let e=0;eKh.adagrad(.01),Adadelta:()=>Kh.adadelta(1,.95,my()),Adam:()=>Kh.adam(.001,.9,.999,my()),Adamax:()=>Kh.adamax(.002,.9,.999,my(),0),RMSProp:()=>Kh.rmsprop(.001,.9,0,my()),SGD:()=>Kh.sgd(.01)};if(t.adagrad=t.Adagrad,t.adadelta=t.Adadelta,t.adam=t.Adam,t.adamax=t.Adamax,t.rmsprop=t.RMSProp,t.sgd=t.SGD,e in t)return t[e]();throw new wg(`Unknown Optimizer ${e}`)}(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof Fu))throw new wg("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let t=[];if(Array.isArray(e.loss)||"string"==typeof e.loss||"function"==typeof e.loss)if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new wg(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${e.loss}.`);const n=e.loss;t=n.map((e=>vx(e)))}else{const n=vx(e.loss);this.outputs.forEach((e=>{t.push(n)}))}else{e.loss=e.loss;for(const t in e.loss)if(-1===this.outputNames.indexOf(t))throw new wg(`Unknown entry in loss dictionary: "${t}". Only expected the following keys: ${this.outputNames}`);for(const n of this.outputNames)null==e.loss[n]&&console.warn(`Output "${n}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${n} during training`),t.push(vx(e.loss[n]))}this.lossFunctions=t,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let e=0;e{for(let e=0;e1&&(this.metricsTensors.push([t,e]),this.metricsNames.push(this.outputNames[e]+"_loss"))}}));const r=function(e,t){if(null==e||Array.isArray(e)&&0===e.length)return t.map((e=>[]));let n;if("string"==typeof e||"function"==typeof e)n=[e];else{if(!Array.isArray(e)&&"object"!=typeof e)throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${e}`);n=e}if(Array.isArray(n))return t.map((e=>n));{const e=[];for(const r of t){let t=n.hasOwnProperty(r)?n[r]:[];Array.isArray(t)||(t=[t]),e.push(t)}return e}}(e.metrics,this.outputNames),a=(e,t,n)=>{this.outputNames.length>1&&(t=this.outputNames[e]+"_"+t),this.metricsNames.push(t),this.metricsTensors.push([n,e])};iy("metric",(()=>{for(let e=0;e{let n,r,i;for(const s of t){if("string"==typeof s&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(s)){const t=this.internalOutputShapes[e];let a;1===t[t.length-1]||this.lossFunctions[e]===yx?-1!==["accuracy","acc"].indexOf(s)?r=_x:-1!==["crossentropy","ce"].indexOf(s)&&(r=Sx):this.lossFunctions[e]===gx?-1!==["accuracy","acc"].indexOf(s)?r=kx:-1!==["crossentropy","ce"].indexOf(s)&&(r=Tx):-1!==["accuracy","acc"].indexOf(s)?r=wx:-1!==["crossentropy","ce"].indexOf(s)&&(r=Dx),-1!==["accuracy","acc"].indexOf(s)?a="acc":-1!==["crossentropy","ce"].indexOf(s)&&(a="ce"),i=r,n=""+a}else{const e=Ex(s);i=e,n=""+Cx(s)}let t;iy(n,(()=>{t=i})),a(e,n,t)}})(r[e])})),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){null!=this.collectedTrainableWeights&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")}evaluate(e,t,n={}){const r=null==n.batchSize?32:n.batchSize;Gx(r);const a=this.standardizeUserDataXY(e,t,!0,r);try{const i=a[0].concat(a[1]);this.makeTestFunction();const s=this.testFunction;return Ig(this.testLoop(s,i,r,n.verbose,n.steps))}finally{Qx(a[0],e),Qx(a[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),async function(e,t,n){const r=null!=(n=n||{}).batches,a=e.testFunction;let i=[];if(n.verbose>0)throw new Mg("Verbose mode is not implemented yet.");se(!r||n.batches>0&&Number.isInteger(n.batches),(()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`));const s="function"==typeof t.next?t:await t.iterator();let o=0,u=0;for(;!r||u{if(t.value){const{xs:n,ys:r}=qx(e,t.value),s=n.concat(r),l=ho((()=>a(s)));if(fo(s),0===u)for(let e=0;ewu(i[e],Su(c,t)))),u>0&&fo(n)}fo(l),o+=c,++u}return i})),t.done){r&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${n.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let e=0;ee.name));for(let r=0;r0){const n=[];throw t.forEach(((t,r)=>{null==t&&n.push(e[r])})),new wg(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(n)}`)}return t}predictLoop(e,t=32,n=!1){return ho((()=>{const r=this.checkNumSamples(e);if(n)throw new Mg("Verbose predictLoop() is not implemented yet.");const a=Xx(r,t),i=this.outputs.map((e=>[]));for(let t=0;t{const n=a[t][0],r=a[t][1],i=Kx(e,n,r),s=[];if(Array.isArray(i))for(let e=0;ei[t].push(e)))}return Ig(i.map((e=>kl(e,0))))}))}predict(e,t={}){const n=Zx(e);rv(n,this.inputNames,this.feedInputShapes,!1);try{const r=null==t.batchSize?32:t.batchSize;return Gx(r),this.predictLoop(n,r)}finally{Qx(n,e)}}predictOnBatch(e){rv(e,this.inputNames,this.feedInputShapes,!0);const t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)}standardizeUserDataXY(e,t,n=!0,r){if(null==this.optimizer_)throw new _g("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const a=[];for(let e=0;ee.shape[0])));r.sort();const a=Yg(t.map((e=>e.shape[0])));if(a.sort(),r.length>1)throw new wg(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map((e=>e.shape)))}`);if(a.length>1)throw new wg(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map((e=>e.shape)))}`);if(r.length>0&&a.length>0&&!de(r,a))throw new wg(`Input Tensors should have the same number of samples as target Tensors. Found ${r[0]} input sample(s) and ${a[0]} target sample(s).`)}(e=nv(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=nv(t,this.feedOutputNames,a,!1,"target")),function(e,t,n){const r=[dx,yx,mx];for(let a=0;a0&&e[0].shape[0]%r!=0)throw new wg(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${r}. Found: ${e[0].shape[0]} sample(s).`);return[e,t]}async standardizeUserData(e,t,n,r,a=!0,i){const[s,o]=this.standardizeUserDataXY(e,t,a,i);if(null!=n)throw new Error("sample weight is not supported yet.");let u=null;if(null!=r){const e=Hx(r,this.outputNames);u=[];for(let t=0;t{const i=this.checkNumSamples(t,n,a,"steps"),s=[];if(r>0)throw new Mg("Verbose mode is not implemented yet.");if(null!=a)throw new Mg("steps mode in testLoop() is not implemented yet");{const r=Xx(i,n),a=yd(hy(0,i));for(let n=0;n1&&(a+=`_${Tg(e.slice(0,n),r)}`),t.push(a)}return t}makeTrainFunction(){return e=>{const t=[],n=e.slice(0,this.inputs.length),r=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),a=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+2*this.outputs.length),i=[],s=this.collectedTrainableWeights.map((e=>e.read())),o=this.optimizer_.minimize((()=>{const e=[];for(let t=0;t1&&e{u=wu(u,e)})),u}),!0,s);return[o].concat(i)}}makeTestFunction(){this.testFunction=e=>ho((()=>{const t=[];let n;const r=e.slice(0,this.inputs.length),a=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),i=[];for(let e=0;e0){if(y=!0,2!==r.validationData.length)throw 3===r.validationData.length?new Mg("validationData including sample weights is not supported yet."):new wg(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${r.validationData} is invalid.`);u=r.validationData[0],l=r.validationData[1];const t=!0,n=await e.standardizeUserData(u,l,null,null,t,h);c=n[0],p=n[1],g=c.concat(p)}else if(null!=r.validationSplit&&r.validationSplit>0&&r.validationSplit<1){y=!0;const e=Math.floor(a[0].shape[0]*(1-r.validationSplit)),t=a[0].shape[0];c=Kx(a,e,t),s=a,a=Kx(a,0,e),p=Kx(i,e,t),o=i,i=Kx(i,0,e),g=c.concat(p)}else null!=r.validationSteps&&(y=!0);const b=a.concat(i).concat(d);e.checkTrainableWeightsConsistency();const x=e.makeTrainFunction(),v=e.getDedupedMetricsNames();let _,w;y?(e.makeTestFunction(),_=e.testFunction,w=v.slice().concat(v.map((e=>"val_"+e)))):(_=null,g=[],w=v.slice());const M=ox(r.callbacks,r.yieldEvery),N=await async function(e,t,n,r,a,i,s,o,u,l,c,p,d,h,f){null==a&&(a=32),null==i&&(i=1),null==c&&(c=!0),null==d&&(d=0);let m=!1;null!=u&&null!=l&&(m=!0);const g=e.checkNumSamples(n,a,h,"steps_per_epoch");let y;null!=g&&(y=hy(0,g)),null==s&&(s=1);const{callbackList:b,history:x}=lx(o,s,i,d,g,h,a,m,p);b.setModel(e),e.history=x,await b.onTrainBegin(),e.stopTraining_=!1;for(let s=d;s{const d=o[c][0],h=o[c][1],f=by(s,d,h-d);p.batch=c,p.size=h-d;const g=Jx(n,f),y=t(g);for(let e=0;e"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig).")),se(null!=n,(()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call.")),se(null!=n.epochs&&n.epochs>0&&Number.isInteger(n.epochs),(()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${n.epochs}`)),se(!r||n.batchesPerEpoch>0&&Number.isInteger(n.batchesPerEpoch),(()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${n.batchesPerEpoch}`)),se(null==n.validationSplit,(()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead.")),e.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");e.isTraining=!0;try{const a=null!=n.validationData;let i,s;if(a)if(Vx(n.validationData))se(null==n.validationBatches||n.validationBatches>0&&Number.isInteger(n.validationBatches),(()=>`For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${n.validationBatches}`));else{const e=function(e){if(3===e.length)throw new Mg("Validation with sample weights is not implemented yet.");return{xs:e[0],ys:e[1]}}(n.validationData);i=e.xs,s=e.ys}const o=e.makeTrainFunction(),u=e.getDedupedMetricsNames();let l;l=a?u.slice().concat(u.map((e=>"val_"+e))):u.slice();const c=ox(n.callbacks,n.yieldEvery),p=null==n.verbose?1:n.verbose,{callbackList:d,history:h}=lx(c,p,n.epochs,null,null,function(e,t){let n=null;return null!=t.batchesPerEpoch?n=t.batchesPerEpoch:Number.isFinite(e.size)&&(n=e.size),n}(t,n),null,a,l);d.setModel(e),e.history=h,await d.onTrainBegin(),e.stopTraining_=!1;let f=null==n.initialEpoch?0:n.initialEpoch,m=await t.iterator();for(;f=n.batchesPerEpoch:t.done){if(a){let t;t=Vx(n.validationData)?Eg(await e.evaluateDataset(n.validationData,{batches:n.validationBatches})):Eg(e.evaluate(i,s,{batchSize:null==n.validationBatchSize?32:n.validationBatchSize,verbose:0}));for(let n=0;nCg(e)))}else{const t=Object.keys(this.loss);e={};const n=this.loss;for(const r of t){if("string"!=typeof n[r])throw new Error("Serialization of non-string loss is not supported.");e[r]=Cg(n[r])}}return e}getMetricIdentifiers(){if("string"==typeof this.metrics||"function"==typeof this.metrics)return[Cg(Cx(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map((e=>Cg(Cx(e))));{const e={};for(const t in this.metrics)e[t]=Cg(Cx(this.metrics[t]));return e}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(e){if(null!=e.weighted_metrics)throw new Error("Loading weight_metrics is not supported yet.");if(null!=e.loss_weights)throw new Error("Loading loss_weights is not supported yet.");if(null!=e.sample_weight_mode)throw new Error("Loading sample_weight_mode is not supported yet.");const t=cx(Yx(e.optimizer_config));let n,r;if("string"==typeof e.loss)n=Ag(e.loss);else if(Array.isArray(e.loss))n=e.loss.map((e=>Ag(e)));else if(null!=e.loss){n={};for(const t in e.loss)n[t]=Ag(e.loss[t])}if(Array.isArray(e.metrics))r=e.metrics.map((e=>Ag(e)));else if(null!=e.metrics){r={};for(const t in e.metrics)r[t]=Ag(e.metrics[t])}this.compile({loss:n,metrics:r,optimizer:t})}async save(e,t){if("string"==typeof e){const t=Qi(e);if(0===t.length)throw new wg(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new wg(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw new wg("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const n=await zi(this.getNamedWeights(t)),r={modelTopology:this.toJSON(null,!1),format:"layers-model",generatedBy:`TensorFlow.js tfjs-layers v${Bx}`,convertedBy:null};if(null!=t&&t.includeOptimizer&&null!=this.optimizer){r.trainingConfig=this.getTrainingConfig();const e="optimizer",{data:t,specs:a}=await zi(await this.optimizer.getWeights(),e);n.specs.push(...a),n.data=Ui([n.data,t])}if(null!=this.userDefinedMetadata){const e=!0;Ax(this.userDefinedMetadata,this.name,e),r.userDefinedMetadata=this.userDefinedMetadata}return r.weightData=n.data,r.weightSpecs=n.specs,e.save(r)}setUserDefinedMetadata(e){Ax(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}}av.className="Model",lu(av);class iv extends av{}async function sv(e,t){"modelTopology"in e||(e={modelTopology:e});let n=e.modelTopology;null!=n.model_config&&(n=n.model_config);const r=cx(Yx(n),t);if(null!=e.weightsManifest){const t=await Hs(e.weightsManifest,e.pathPrefix,r.weights.map((e=>e.originalName))),n={};for(const e of r.weights)n[e.originalName]=t[e.originalName];r.loadWeights(n),fo(t)}return r}iv.className="Functional",lu(iv);class ov extends av{constructor(e){if(super({inputs:[],outputs:[]}),e=e||{},this.trainable=!0,this.built=!1,this.name=null!=e.name?e.name:Gg("sequential_"),null!=e.layers)for(const t of e.layers)this.add(t)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some((e=>e<0)))throw new wg(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){const t=e instanceof ov||e instanceof av;let n;if(t){if(n=e,1!==n.outputs.length)throw new wg("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(1!==n.inputs.length)throw new wg("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(0===this.outputs.length){if(0===e.inboundNodes.length){if(null==e.batchInputShape)throw new wg("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");const t=gb({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(t)}if(t)this.outputs=n.outputs,this.inputs=n.inputs;else{if(1!==e.inboundNodes.length)throw new wg(`A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer ${e.name} which has ${e.inboundNodes.length} pre-existing inbound connections.`);if(1!==e.inboundNodes[0].outputTensors.length)throw new wg("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[e.inboundNodes[0].outputTensors[0]],this.inputs=fb(this.outputs[0])}this.inboundNodes=[],new pb({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:kg(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map((e=>e.shape)),outputShapes:this.outputs[0].shape})}else{const t=e.apply(this.outputs[0]);if(Array.isArray(t))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[t],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(0===this.layers.length)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),0===this.layers.length)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{const e=this.layers.length-1;this.layers[e].outboundNodes=[],this.outputs=[this.layers[e].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}}call(e,t){return null==this.model&&this.build(),this.model.call(e,t)}build(e){if(rb(e),0===this.inputs.length||0===this.outputs.length)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new av({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supportsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0}countParams(){return this.built||this.build(),super.countParams()}summary(e,t,n=console.log){this.built||this.build(),super.summary(e,t,n)}setWeights(e){null==this.model&&this.build(),this.model.setWeights(e)}evaluate(e,t,n={}){if(!this.built)throw new _g("The model needs to be compiled before being used.");return this.model.evaluate(e,t,n)}async evaluateDataset(e,t){if(!this.built)throw new _g("The model needs to be compiled before being used.");return this.model.evaluateDataset(e,t)}predict(e,t={}){return null==this.model&&this.build(),this.model.predict(e,t)}predictOnBatch(e){return null==this.model&&this.build(),this.model.predictOnBatch(e)}compile(e){this.build(),this.model.compile(e),this.optimizer_=this.model.optimizer,this.isOptimizerOwned=this.model.isOptimizerOwned,this.loss=this.model.loss,this.metrics=this.model.metrics,this.metricsTensors=this.model.metricsTensors,this.metricsNames=this.model.metricsNames}get optimizer(){return null==this.model?void 0:this.model.optimizer}set optimizer(e){this.model.optimizer=e}async fit(e,t,n={}){if(!this.built)throw new _g("The model needs to be compiled before being used.");return this.model.fit(e,t,n)}async fitDataset(e,t){if(!this.built)throw new _g("The model needs to be compiled before being used.");return this.model.fitDataset(e,t)}async trainOnBatch(e,t){return this.model.trainOnBatch(e,t)}static fromConfig(e,t,n={},r=!1){let a,i={};if(t instanceof Array){if(null==t[0].className||"Merge"===t[0].className)throw new wg("Legacy serialization format not supported yet.");a=t}else se(null!=t.layers,(()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field.")),a=t.layers,delete t.layers,i=t;const s=new e(i);if(!(s instanceof ov))throw new Mg(`Sequential.fromConfig called on non-Sequential input: ${s}`);for(const e of a){const t=cx(e,void 0,r);r&&t.setFastWeightInitDuringBuild(!0),s.add(t)}return s}set stopTraining(e){if(null==this.model)throw new wg("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}get stopTraining(){if(null==this.model)throw new wg("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}getConfig(){const e=[];for(const t of this.layers){const n={};n.className=t.getClassName(),n.config=t.getConfig(),e.push(n)}return{name:this.name,layers:e}}}function uv(e){return new av(e)}function lv(e){return new ov(e)}function cv(e,t){return null==t&&(t={}),async function(e,t){if(null==t&&(t={}),"string"==typeof e){const n=es(e,t);if(0===n.length)n.push(Gs(e,t));else if(n.length>1)throw new wg(`Found more than one (${n.length}) load handlers for URL '${e}'`);e=n[0]}return async function(e,t,n){if(null==n&&(n={}),null==e.load)throw new wg("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const r=await e.load();let a=r.modelTopology;null!=a.model_config&&(a=a.model_config);const i=null==n.strict||n.strict,s=null!=r.weightData&&null!=r.weightSpecs&&i,o=cx(Yx(a),void 0,s),u=r.trainingConfig;if(null!=u&&o.loadTrainingConfig(u),null!=r.userDefinedMetadata&&o.setUserDefinedMetadata(r.userDefinedMetadata),null!=r.weightData){if(null==r.weightSpecs)throw new wg("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");const{modelWeights:e,optimizerWeights:t}=function(e,t){const n=Bi(e,t),r={},a=[];return t.forEach((e=>{"optimizer"===e.group?a.push({name:e.name,tensor:n[e.name]}):r[e.name]=n[e.name]})),{modelWeights:r,optimizerWeights:a}}(r.weightData,r.weightSpecs);o.loadWeights(e,i),null!=o.optimizer&&t.length>0&&await o.optimizer.setWeights(t),fo(e),fo(t.map((e=>e.tensor)))}return o}(e,0,t)}(e,t)}function pv(e){return gb(e)}function dv(e,t){ux.registerCallbackConstructor(e,t)}ov.className="Sequential",lu(ov);class hv extends ou{getConfig(){return{}}}class fv extends hv{apply(e,t=1){return function(e,t=1){if(1!==t)throw new Mg(`Support for alpha values other than 1 (${t}) is not implemented yet.`);return dc(e)}(e,t)}}fv.className="elu",lu(fv);class mv extends hv{apply(e){return Kp(e)}}mv.className="selu",lu(mv);class gv extends hv{apply(e){return Bp(e)}}gv.className="relu",lu(gv);class yv extends hv{apply(e){return ho((()=>pp(6,Bp(e))))}}yv.className="relu6",lu(yv);class bv extends hv{apply(e){return e}}bv.className="linear",lu(bv);class xv extends hv{apply(e){return Dl(e)}}xv.className="sigmoid",lu(xv);class vv extends hv{apply(e){return function(e){return ho((()=>{const t=wu(.5,Su(.2,e));return Bl(t,0,1)}))}(e)}}vv.className="hardSigmoid",lu(vv);class _v extends hv{apply(e){return Vc(e)}}_v.className="softplus",lu(_v);class wv extends hv{apply(e){return function(e){return ho((()=>Nu(e,wu(Uu(e),1))))}(e)}}wv.className="softsign",lu(wv);class Mv extends hv{apply(e){return Il(e)}}Mv.className="tanh",lu(Mv);class Nv extends hv{apply(e,t=-1){return id(e,t)}}Nv.className="softmax",lu(Nv);class Sv extends hv{apply(e,t=-1){return Kc(e,t)}}Sv.className="logSoftmax",lu(Sv);class kv extends hv{apply(e,t=1){return ho((()=>Su(Dl(Su(e,t)),e)))}}kv.className="swish",lu(kv);class Dv extends hv{apply(e){return ho((()=>Su(e,Il(Vc(e)))))}}function Tv(e){return e.getClassName()}function Iv(e,t={}){return Rg(e,uu.getMap().classNameMap,t,"activation")}function Ev(e){if(null==e){return Iv({className:"linear",config:{}})}if("string"==typeof e){const t={};return t.className=e,t.config={},Iv(t)}return e instanceof hv?e:Iv(e)}function Cv(e){if(null!=e&&"object"!=typeof e)throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${e}`)}Dv.className="mish",lu(Dv);class Av extends ou{}class Lv extends Av{constructor(e){super(),Cv(e),this.l1=null==e||null==e.l1?.01:e.l1,this.l2=null==e||null==e.l2?.01:e.l2,this.hasL1=0!==this.l1,this.hasL2=0!==this.l2}apply(e){return ho((()=>{let t=up([1]);return this.hasL1&&(t=wu(t,Nc(Su(this.l1,Uu(e))))),this.hasL2&&(t=wu(t,Nc(Su(this.l2,Dy(e))))),Ml(t,[])}))}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}}Lv.className="L1L2",lu(Lv);const $v={l1l2:"L1L2"};function Ov(e){return $g(e)}function Rv(e,t={}){return Rg(e,uu.getMap().classNameMap,t,"regularizer")}function Fv(e){return null==e?null:"string"==typeof e?Rv({className:e in $v?$v[e]:e,config:{}}):e instanceof Av?e:Rv(e)}class Yv extends hb{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,null!=e&&(this.maxValue=e.maxValue)}call(e,t){e=nb(e);let n=Bp(e);return null!=this.maxValue&&(n=Bl(n,0,this.maxValue)),n}computeOutputShape(e){return e}getConfig(){const e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}}Yv.className="ReLU",lu(Yv);class zv extends hb{constructor(e){super(null==e?{}:e),this.DEFAULT_ALPHA=.3,null==e&&(e={}),this.alpha=null==e.alpha?this.DEFAULT_ALPHA:e.alpha}call(e,t){const n=nb(e);return Bc(n,this.alpha)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}}zv.className="LeakyReLU",lu(zv);class Bv extends hb{constructor(e){if(super(null==e?{}:e),this.DEFAULT_ALPHA_INITIALIZER="zeros",null==e&&(e={}),this.supportsMasking=!0,this.alphaInitializer=Qy(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=Fv(e.alphaRegularizer),this.alphaConstraint=Lb(e.alphaConstraint),null==e.sharedAxes)this.sharedAxes=null;else if(Array.isArray(e.sharedAxes))this.sharedAxes=e.sharedAxes;else{if("number"!=typeof e.sharedAxes)throw new wg(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`);this.sharedAxes=[e.sharedAxes]}}build(e){const t=(e=rb(e)).slice(1);if(null!=this.sharedAxes)for(const e of this.sharedAxes)t[e-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);const n={};if(null!=this.sharedAxes)for(let t=1;t(ty(t),"channelsFirst"===t?Io(e,[0,2,3,1]):e)))}function Gv(e,t){return ho((()=>(ty(t),"channelsFirst"===t?Io(e,[0,2,3,4,1]):e)))}function Kv(e,t,n,r=[1,1],a="valid",i,s,o=null){return ho((()=>{if(null==i&&(i="channelsLast"),ty(i),3!==e.rank&&4!==e.rank)throw new wg(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${e.rank}.`);if(3!==t.rank&&4!==t.rank)throw new wg(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${e.rank}.`);let u=Vv(e,i);if("causal"===a)throw new Mg("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return u=qd({x:u,filter:t,strides:r,pad:"same"===a?"same":"valid",dilations:s,dataFormat:"NHWC",bias:n,activation:o}),"channelsFirst"===i&&(u=Io(u,[0,3,1,2])),u}))}jv.className="Softmax",lu(jv);class Jv extends hb{constructor(e,t){if(super(t),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",Jv.verifyArgs(t),this.rank=e,Hg(this.rank,"rank"),1!==this.rank&&2!==this.rank&&3!==this.rank)throw new Mg(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=Uv(t.kernelSize,e,"kernelSize"),this.strides=Uv(null==t.strides?1:t.strides,e,"strides"),this.padding=null==t.padding?"valid":t.padding,ny(this.padding),this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,ty(this.dataFormat),this.activation=Ev(t.activation),this.useBias=null==t.useBias||t.useBias,this.biasInitializer=Qy(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=Lb(t.biasConstraint),this.biasRegularizer=Fv(t.biasRegularizer),this.activityRegularizer=Fv(t.activityRegularizer),this.dilationRate=Uv(null==t.dilationRate?1:t.dilationRate,e,"dilationRate"),1===this.rank&&Array.isArray(this.dilationRate)&&1!==this.dilationRate.length)throw new wg(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(2===this.rank){if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate];else if(2!==this.dilationRate.length)throw new wg(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(3===this.rank)if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(3!==this.dilationRate.length)throw new wg(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}static verifyArgs(e){if(Dg("kernelSize"in e,"required key 'kernelSize' not in config"),"number"!=typeof e.kernelSize&&!Pg(e.kernelSize,"number",1,3))throw new wg(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(e.kernelSize)}.`)}getConfig(){const e={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:Tv(this.activation),useBias:this.useBias,biasInitializer:Zy(this.biasInitializer),biasRegularizer:Ov(this.biasRegularizer),activityRegularizer:Ov(this.activityRegularizer),biasConstraint:Cb(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}class Xv extends Jv{constructor(e,t){super(e,t),this.kernel=null,Xv.verifyArgs(t),this.filters=t.filters,Hg(this.filters,"filters"),this.kernelInitializer=Qy(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=Lb(t.kernelConstraint),this.kernelRegularizer=Fv(t.kernelRegularizer)}build(e){e=rb(e);const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new wg(`The channel dimension of the input should be defined. Found ${e[t]}`);const n=e[t],r=this.kernelSize.concat([n,this.filters]);this.kernel=this.addWeight("kernel",r,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[t]:n}}],this.built=!0}call(e,t){return ho((()=>{let t;e=nb(e);const n=null==this.bias?null:this.bias.read(),r=Ug(this.activation.getClassName());if(null!=r&&2===this.rank)t=Kv(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate,r);else{if(1===this.rank)t=function(e,t,n,r=1,a="valid",i,s=1){return ho((()=>{if(null==i&&(i="channelsLast"),ty(i),3!==e.shape.length)throw new wg(`The input of a conv1dWithBias operation should be 3, but is ${e.shape.length} instead.`);if(3!==t.shape.length)throw new wg(`The kernel for a conv1dWithBias operation should be 3, but is ${t.shape.length} instead`);if(null!=n&&1!==n.shape.length)throw new wg(`The bias for a conv1dWithBias operation should be 1, but is ${t.shape.length} instead`);if("channelsFirst"===i&&(e=Io(e,[0,2,1])),"causal"===a)throw new Mg("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let o=Wl(e,t,r,"same"===a?"same":"valid","NWC",s);return null!=n&&(o=Iy(o,n)),o}))}(e,this.kernel.read(),n,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(2===this.rank)t=Kv(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate);else{if(3!==this.rank)throw new Mg("convolutions greater than 3D are not implemented yet.");t=function(e,t,n,r=[1,1,1],a="valid",i,s){return ho((()=>{if(null==i&&(i="channelsLast"),ty(i),4!==e.rank&&5!==e.rank)throw new wg(`conv3dWithBias expects input to be of rank 4 or 5, but received ${e.rank}.`);if(4!==t.rank&&5!==t.rank)throw new wg(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${e.rank}.`);let o=Gv(e,i);if("causal"===a)throw new Mg("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return o=Kl(o,t,r,"same"===a?"same":"valid","NDHWC",s),null!=n&&(o=Iy(o,n)),"channelsFirst"===i&&(o=Io(o,[0,4,1,2,3])),o}))}(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate)}null!=this.activation&&(t=this.activation.apply(t))}return t}))}computeOutputShape(e){e=rb(e);const t=[],n="channelsLast"===this.dataFormat?e.slice(1,e.length-1):e.slice(2);for(let e=0;e 0 but got ${JSON.stringify(e.filters)}`)}}class Zv extends Xv{constructor(e){super(2,e),Zv.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&!Pg(e.kernelSize,"number",1,2))throw new wg(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}}Zv.className="Conv2D",lu(Zv);class Qv extends Xv{constructor(e){super(3,e),Qv.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&(!Array.isArray(e.kernelSize)||1!==e.kernelSize.length&&3!==e.kernelSize.length))throw new wg(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}}Qv.className="Conv3D",lu(Qv);class e_ extends Zv{constructor(e){if(super(e),this.inputSpec=[new ub({ndim:4})],"same"!==this.padding&&"valid"!==this.padding)throw new wg(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(4!==(e=rb(e)).length)throw new wg("Input should have rank 4; Received input shape: "+JSON.stringify(e));const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new wg("The channel dimension of the inputs should be defined. Found `None`.");const n=e[t],r=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",r,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new ub({ndim:4,axes:{[t]:n}})],this.built=!0}call(e,t){return ho((()=>{let t=nb(e);if(4!==t.shape.length)throw new wg(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`);const n=t.shape,r=n[0];let a,i;"channelsFirst"===this.dataFormat?(a=2,i=3):(a=1,i=2);const s=n[a],o=n[i],u=this.kernelSize[0],l=this.kernelSize[1],c=this.strides[0],p=this.strides[1],d=[r,Wv(s,c,u,this.padding),Wv(o,p,l,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(t=Io(t,[0,2,3,1]));let h=Gl(t,this.kernel.read(),d,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(h=Io(h,[0,3,1,2])),null!=this.bias&&(h=Iy(h,this.bias.read(),this.dataFormat)),null!=this.activation&&(h=this.activation.apply(h)),h}))}computeOutputShape(e){const t=(e=rb(e)).slice();let n,r,a;"channelsFirst"===this.dataFormat?(n=1,r=2,a=3):(n=3,r=1,a=2);const i=this.kernelSize[0],s=this.kernelSize[1],o=this.strides[0],u=this.strides[1];return t[n]=this.filters,t[r]=Wv(t[r],o,i,this.padding),t[a]=Wv(t[a],u,s,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}e_.className="Conv2DTranspose",lu(e_);class t_ extends Qv{constructor(e){if(super(e),this.inputSpec=[new ub({ndim:5})],"same"!==this.padding&&"valid"!==this.padding)throw new wg(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(5!==(e=rb(e)).length)throw new wg("Input should have rank 5; Received input shape: "+JSON.stringify(e));const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new wg("The channel dimension of the inputs should be defined. Found `None`.");const n=e[t],r=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",r,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new ub({ndim:5,axes:{[t]:n}})],this.built=!0}call(e,t){return ho((()=>{let t=nb(e);if(5!==t.shape.length)throw new wg(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`);const n=t.shape,r=n[0];let a,i,s;"channelsFirst"===this.dataFormat?(s=2,a=3,i=4):(s=1,a=2,i=3);const o=n[s],u=n[a],l=n[i],c=this.kernelSize[0],p=this.kernelSize[1],d=this.kernelSize[2],h=this.strides[0],f=this.strides[1],m=this.strides[2],g=[r,Wv(o,h,c,this.padding),Wv(u,f,p,this.padding),Wv(l,m,d,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(t=Io(t,[0,2,3,4,1]));let y=Xl(t,this.kernel.read(),g,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(y=Io(y,[0,4,1,2,3])),null!==this.bias&&(y=Iy(y,this.bias.read(),this.dataFormat)),null!==this.activation&&(y=this.activation.apply(y)),y}))}computeOutputShape(e){const t=(e=rb(e)).slice();let n,r,a,i;"channelsFirst"===this.dataFormat?(n=1,r=2,a=3,i=4):(n=4,r=1,a=2,i=3);const s=this.kernelSize[0],o=this.kernelSize[1],u=this.kernelSize[2],l=this.strides[0],c=this.strides[1],p=this.strides[2];return t[n]=this.filters,t[r]=Wv(t[r],l,s,this.padding),t[a]=Wv(t[a],c,o,this.padding),t[i]=Wv(t[i],p,u,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}t_.className="Conv3DTranspose",lu(t_);class n_ extends Xv{constructor(e,t){if(super(e,t),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,null==t.filters)throw new wg("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=t.kernelInitializer||null!=t.kernelRegularizer||null!=t.kernelConstraint)throw new wg("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(null!=t.padding&&"same"!==t.padding&&"valid"!==t.padding)throw new wg(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(t.padding)}`);this.depthMultiplier=null==t.depthMultiplier?1:t.depthMultiplier,this.depthwiseInitializer=Qy(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=Fv(t.depthwiseRegularizer),this.depthwiseConstraint=Lb(t.depthwiseConstraint),this.pointwiseInitializer=Qy(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=Fv(t.pointwiseRegularizer),this.pointwiseConstraint=Lb(t.pointwiseConstraint)}build(e){if((e=rb(e)).length{let t;if(e=nb(e),1===this.rank)throw new Mg("1D separable convolution is not implemented yet.");return 2===this.rank&&("channelsFirst"===this.dataFormat&&(e=Io(e,[0,2,3,1])),t=Jp(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(t=Iy(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),"channelsFirst"===this.dataFormat&&(t=Io(t,[0,3,1,2])),t}))}getConfig(){const e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=Zy(this.depthwiseInitializer),e.pointwiseInitializer=Zy(this.pointwiseInitializer),e.depthwiseRegularizer=Ov(this.depthwiseRegularizer),e.pointwiseRegularizer=Ov(this.pointwiseRegularizer),e.depthwiseConstraint=Cb(this.depthwiseConstraint),e.pointwiseConstraint=Cb(this.pointwiseConstraint),e}}n_.className="SeparableConv";class r_ extends n_{constructor(e){super(2,e)}}r_.className="SeparableConv2D",lu(r_);class a_ extends Xv{constructor(e){super(1,e),a_.verifyArgs(e),this.inputSpec=[{ndim:3}]}getConfig(){const e=super.getConfig();return delete e.rank,delete e.dataFormat,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&!Pg(e.kernelSize,"number",1,1))throw new wg(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}}a_.className="Conv1D",lu(a_);class i_ extends hb{constructor(e){super(e),"number"==typeof e.cropping?this.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:"number"==typeof e.cropping[0]?this.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:this.cropping=e.cropping,this.dataFormat=void 0===e.dataFormat?"channelsLast":e.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(e){return"channelsFirst"===this.dataFormat?[e[0],e[1],e[2]-this.cropping[0][0]-this.cropping[0][1],e[3]-this.cropping[1][0]-this.cropping[1][1]]:[e[0],e[1]-this.cropping[0][0]-this.cropping[0][1],e[2]-this.cropping[1][0]-this.cropping[1][1],e[3]]}call(e,t){return ho((()=>{if(e=nb(e),"channelsLast"===this.dataFormat){const t=vy(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return vy(t,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}{const t=vy(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return vy(t,this.cropping[1][0],e.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}}))}getConfig(){const e={cropping:this.cropping,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}i_.className="Cropping2D",lu(i_);class s_ extends hb{constructor(e){var t;super(e),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=null==e.size?this.DEFAULT_SIZE:e.size,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,ty(this.dataFormat),this.interpolation=null==e.interpolation?"nearest":e.interpolation,t=this.interpolation,Bg(Jg,"InterpolationFormat",t)}computeOutputShape(e){if("channelsFirst"===this.dataFormat){const t=null==e[2]?null:this.size[0]*e[2],n=null==e[3]?null:this.size[1]*e[3];return[e[0],e[1],t,n]}{const t=null==e[1]?null:this.size[0]*e[1],n=null==e[2]?null:this.size[1]*e[2];return[e[0],t,n,e[3]]}}call(e,t){return ho((()=>{let t=nb(e);const n=t.shape;if("channelsFirst"===this.dataFormat){t=Io(t,[0,2,3,1]);const e=this.size[0]*n[2],r=this.size[1]*n[3],a="nearest"===this.interpolation?Uh.resizeNearestNeighbor(t,[e,r]):Uh.resizeBilinear(t,[e,r]);return Io(a,[0,3,1,2])}{const e=this.size[0]*n[1],r=this.size[1]*n[2];return"nearest"===this.interpolation?Uh.resizeNearestNeighbor(t,[e,r]):Uh.resizeBilinear(t,[e,r])}}))}getConfig(){const e={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},t=super.getConfig();return Object.assign(e,t),e}}s_.className="UpSampling2D",lu(s_);class o_ extends Jv{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=null==e.depthMultiplier?1:e.depthMultiplier,this.depthwiseInitializer=Qy(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=Lb(e.depthwiseConstraint),this.depthwiseRegularizer=Fv(e.depthwiseRegularizer)}build(e){if((e=rb(e)).length<4)throw new wg(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);const t="channelsFirst"===this.dataFormat?1:3;if(null==e[t]||e[t]<0)throw new wg(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);const n=e[t],r=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",r,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[n*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return ho((()=>{let t=function(e,t,n=[1,1],r="valid",a,i){return ho((()=>{null==a&&(a="channelsLast"),ty(a);let s=Vv(e,a);if(4!==e.rank)throw new wg(`Input for depthwiseConv2d is required to be 4-D, but is instead ${e.rank}-D`);if(4!==t.rank)throw new wg(`depthwiseKernel is required to be 4-D, but is instead ${t.rank}-D`);return s=ac(s,t,n,"same"===r?"same":"valid","NHWC",i),"channelsFirst"===a&&(s=Io(s,[0,3,1,2])),s}))}(e=nb(e),this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(t=Iy(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),t}))}computeOutputShape(e){e=rb(e);const t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],r="channelsFirst"===this.dataFormat?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,a=qv(t,this.kernelSize[0],this.padding,this.strides[0]),i=qv(n,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[e[0],r,a,i]:[e[0],a,i,r]}getConfig(){const e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=Zy(this.depthwiseInitializer),e.depthwiseRegularizer=Ov(this.depthwiseRegularizer),e.depthwiseConstraint=Cb(this.depthwiseRegularizer),e}}function u_(e,t,n,r){if(Array.isArray(e)){if(null!=t||null!=n)throw new wg("When inputs is an array, neither initialState or constants should be provided");null!=r&&(n=e.slice(e.length-r,e.length),e=e.slice(0,e.length-r)),e.length>1&&(t=e.slice(1,e.length)),e=e[0]}function a(e){return null==e||Array.isArray(e)?e:[e]}return{inputs:e,initialState:t=a(t),constants:n=a(n)}}function l_(e,t,n,r=!1,a,i,s=!1,o=!1){return ho((()=>{const u=t.shape.length;if(u<3)throw new wg(`Input should be at least 3D, but is ${u}D.`);const l=[1,0].concat(hy(2,u));if(t=Io(t,l),null!=i)throw new Mg("The rnn() functoin of the deeplearn.js backend does not support constants yet.");s&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),null!=a&&((a=Ls(Ls(a,"bool"),"float32")).rank===u-1&&(a=Ic(a,-1)),a=Io(a,l)),r&&(t=Hp(t,0),null!=a&&(a=Hp(a,0)));const c=[];let p,d=n;const h=t.shape[0],f=kd(t);let m,g;null!=a&&(m=kd(a));for(let t=0;te(n,d)));if(null==a)p=r[0],d=r[1];else{const e=ho((()=>{const e=m[t],n=Hu(bp(e),e),a=wu(Su(r[0],e),Su(d[0],n)),i=d.map(((t,a)=>wu(Su(r[1][a],e),Su(t,n))));return{output:a,newStates:i}}));p=e.output,d=e.newStates}o&&c.push(p)}return o&&(g=hd(c,1)),[p,g,d]}))}o_.className="DepthwiseConv2D",lu(o_);class c_ extends hb{constructor(e){let t;if(super(e),null==e.cell)throw new wg("cell property is missing for the constructor of RNN.");if(t=Array.isArray(e.cell)?new b_({cells:e.cell}):e.cell,null==t.stateSize)throw new wg("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=t,this.returnSequences=null!=e.returnSequences&&e.returnSequences,this.returnState=null!=e.returnState&&e.returnState,this.goBackwards=null!=e.goBackwards&&e.goBackwards,this._stateful=null!=e.stateful&&e.stateful,this.unroll=null!=e.unroll&&e.unroll,this.supportsMasking=!0,this.inputSpec=[new ub({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){return null==this.states_?hy(0,Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1).map((e=>null)):this.states_}setStates(e){this.states_=e}computeOutputShape(e){eb(e)&&(e=e[0]);let t=this.cell.stateSize;Array.isArray(t)||(t=[t]);const n=t[0];let r;if(r=this.returnSequences?[e[0],e[1],n]:[e[0],n],this.returnState){const n=[];for(const r of t)n.push([e[0],r]);return[r].concat(n)}return r}computeMask(e,t){return ho((()=>{Array.isArray(t)&&(t=t[0]);const e=this.returnSequences?t:null;if(this.returnState){const t=this.states.map((e=>null));return[e].concat(t)}return e}))}get states(){if(null==this.states_){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,t=[];for(let n=0;ne.shape[e.shape.length-1])),a))throw new wg(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is ${this.cell.stateSize}`)}else this.stateSpec=a.map((e=>new ub({shape:[null,e]})));this.stateful&&this.resetStates()}resetStates(e,t=!1){ho((()=>{if(!this.stateful)throw new vg("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape[0];if(null==n)throw new wg("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==this.states_)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((e=>up([n,e]))):this.states_=[up([n,this.cell.stateSize])];else if(null==e)fo(this.states_),null!=this.keptStates&&(fo(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((e=>up([n,e]))):this.states_[0]=up([n,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new wg(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);!0===t?this.keptStates.push(this.states_.slice()):fo(this.states_);for(let t=0;tmo(e.clone())))}))}apply(e,t){let n=null==t?null:t.initialState,r=null==t?null:t.constants;null==t&&(t={});const a=u_(e,n,r,this.numConstants);e=a.inputs,n=a.initialState,r=a.constants;let i=[],s=[];if(null!=n){t.initialState=n,i=i.concat(n),this.stateSpec=[];for(const e of n)this.stateSpec.push(new ub({shape:e.shape}));s=s.concat(this.stateSpec)}if(null!=r&&(t.constants=r,i=i.concat(r),this.numConstants=r.length),i[0]instanceof lb){const n=[e].concat(i),r=this.inputSpec.concat(s),a=this.inputSpec;this.inputSpec=r;const o=super.apply(n,t);return this.inputSpec=a,o}return super.apply(e,t)}call(e,t){return ho((()=>{const n=null==t?null:t.mask,r=null==t?null:t.training;let a=null==t?null:t.initialState;e=nb(e),null==a&&(a=this.stateful?this.states_:this.getInitialState(e));const i=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(a.length!==i)throw new wg(`RNN Layer has ${i} state(s) but was passed ${a.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const s={training:r},o=l_(((e,t)=>{const n=this.cell.call([e].concat(t),s);return[n[0],n.slice(1)]}),e,a,this.goBackwards,n,null,this.unroll,this.returnSequences),u=o[0],l=o[1],c=o[2];this.stateful&&this.resetStates(c,r);const p=this.returnSequences?l:u;return this.returnState?[p].concat(c):p}))}getInitialState(e){return ho((()=>{let t=up(e.shape);return t=Nc(t,[1,2]),t=yy(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map((e=>e>1?My(t,[1,e]):t)):this.cell.stateSize>1?[My(t,[1,this.cell.stateSize])]:[t]}))}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),null!=this.cell&&this.cell.setFastWeightInitDuringBuild(e)}getConfig(){const e=super.getConfig(),t={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};null!=this.numConstants&&(t.numConstants=this.numConstants);const n=this.cell.getConfig();return this.getClassName()===c_.className&&(t.cell={className:this.cell.getClassName(),config:n}),Object.assign({},n,e,t)}static fromConfig(e,t,n={}){const r=cx(t.cell,n);return new e(Object.assign(t,{cell:r}))}}c_.className="RNN",lu(c_);class p_ extends hb{}class d_ extends p_{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,Hg(this.units,"units"),this.activation=Ev(null==e.activation?this.DEFAULT_ACTIVATION:e.activation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=Qy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Qy(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Qy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Fv(e.kernelRegularizer),this.recurrentRegularizer=Fv(e.recurrentRegularizer),this.biasRegularizer=Fv(e.biasRegularizer),this.kernelConstraint=Lb(e.kernelConstraint),this.recurrentConstraint=Lb(e.recurrentConstraint),this.biasConstraint=Lb(e.biasConstraint),this.dropout=py([1,dy([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=py([1,dy([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=rb(e),this.kernel=this.addWeight("kernel",[e[e.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return ho((()=>{if(2!==e.length)throw new wg(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let n=e[1];e=e[0];const r=null!=t.training&&t.training;let a;0bp(e),rate:this.dropout,training:r,dropoutFunc:this.dropoutFunc})),0bp(n),rate:this.recurrentDropout,training:r,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,s=this.recurrentDropoutMask;a=Sy(null!=i?Su(e,i):e,this.kernel.read()),null!=this.bias&&(a=Iy(a,this.bias.read())),null!=s&&(n=Su(n,s));let o=wu(a,Sy(n,this.recurrentKernel.read()));return null!=this.activation&&(o=this.activation.apply(o)),[o,o]}))}getConfig(){const e=super.getConfig(),t={units:this.units,activation:Tv(this.activation),useBias:this.useBias,kernelInitializer:Zy(this.kernelInitializer),recurrentInitializer:Zy(this.recurrentInitializer),biasInitializer:Zy(this.biasInitializer),kernelRegularizer:Ov(this.kernelRegularizer),recurrentRegularizer:Ov(this.recurrentRegularizer),biasRegularizer:Ov(this.biasRegularizer),activityRegularizer:Ov(this.activityRegularizer),kernelConstraint:Cb(this.kernelConstraint),recurrentConstraint:Cb(this.recurrentConstraint),biasConstraint:Cb(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign({},e,t)}}d_.className="SimpleRNNCell",lu(d_);class h_ extends c_{constructor(e){e.cell=new d_(e),super(e)}call(e,t){return ho((()=>{null!=this.cell.dropoutMask&&(fo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(fo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}static fromConfig(e,t){return new e(t)}}h_.className="SimpleRNN",lu(h_);class f_ extends p_{constructor(e){if(super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.resetAfter)throw new wg("GRUCell does not support reset_after parameter set to true.");this.units=e.units,Hg(this.units,"units"),this.activation=Ev(void 0===e.activation?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Ev(void 0===e.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=Qy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Qy(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Qy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Fv(e.kernelRegularizer),this.recurrentRegularizer=Fv(e.recurrentRegularizer),this.biasRegularizer=Fv(e.biasRegularizer),this.kernelConstraint=Lb(e.kernelConstraint),this.recurrentConstraint=Lb(e.recurrentConstraint),this.biasConstraint=Lb(e.biasConstraint),this.dropout=py([1,dy([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=py([1,dy([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){const t=(e=rb(e))[e.length-1];this.kernel=this.addWeight("kernel",[t,3*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,3*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[3*this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return ho((()=>{if(2!==e.length)throw new wg(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);const n=null!=t.training&&t.training;let r=e[1];e=e[0],0bp(e),rate:this.dropout,training:n,count:3,dropoutFunc:this.dropoutFunc})),0bp(r),rate:this.recurrentDropout,training:n,count:3,dropoutFunc:this.dropoutFunc}));const a=this.dropoutMask,i=this.recurrentDropoutMask;let s,o,u;0{null!=this.cell.dropoutMask&&(fo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(fo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}static fromConfig(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)}}m_.className="GRU",lu(m_);class g_ extends p_{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,Hg(this.units,"units"),this.activation=Ev(void 0===e.activation?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Ev(void 0===e.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=Qy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Qy(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Qy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=Fv(e.kernelRegularizer),this.recurrentRegularizer=Fv(e.recurrentRegularizer),this.biasRegularizer=Fv(e.biasRegularizer),this.kernelConstraint=Lb(e.kernelConstraint),this.recurrentConstraint=Lb(e.recurrentConstraint),this.biasConstraint=Lb(e.biasConstraint),this.dropout=py([1,dy([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=py([1,dy([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){var t;const n=(e=rb(e))[e.length-1];let r;if(this.kernel=this.addWeight("kernel",[n,4*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,4*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){if(this.unitForgetBias){const e=this.biasInitializer,n=this.units;r=new((t=class extends $y{apply(t,r){const a=e.apply([n]),i=(new Ry).apply([n]),s=e.apply([2*n]);return wy(wy(a,i),s)}}).className="CustomInit",t)}else r=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.units],null,r,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,t){return ho((()=>{const n=null!=t.training&&t.training;if(3!==e.length)throw new wg(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let r=e[1];const a=e[2];e=e[0],0bp(e),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc})),0bp(r),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,s=this.recurrentDropoutMask;let o,u,l,c;0{null!=this.cell.dropoutMask&&(fo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(fo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}static fromConfig(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)}}y_.className="LSTM",lu(y_);class b_ extends p_{constructor(e){super(e),this.cells=e.cells}get stateSize(){const e=[];for(const t of this.cells.slice().reverse())Array.isArray(t.stateSize)?e.push(...t.stateSize):e.push(t.stateSize);return e}call(e,t){return ho((()=>{let n=e.slice(1);const r=[];for(const e of this.cells.slice().reverse())Array.isArray(e.stateSize)?r.push(n.splice(0,e.stateSize.length)):r.push(n.splice(0,1));r.reverse();const a=[];let i;for(let s=0;s{iy(`RNNCell_${r}`,(()=>{n.build(e),t=Array.isArray(n.stateSize)?n.stateSize[0]:n.stateSize,e=[e[0],t]}))})),this.built=!0}getConfig(){const e=super.getConfig(),t={cells:this.cells.map((e=>({className:e.getClassName(),config:e.getConfig()})))};return Object.assign({},e,t)}static fromConfig(e,t,n={}){const r=[];for(const e of t.cells)r.push(cx(e,n));return new e({cells:r})}get trainableWeights(){if(!this.trainable)return[];const e=[];for(const t of this.cells)e.push(...t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.cells)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const e of this.cells)t.push(...e.trainableWeights);return t.concat(e)}return e}getWeights(){const e=[];for(const t of this.cells)e.push(...t.weights);return sb(e)}setWeights(e){const t=[];for(const n of this.cells){const r=n.weights.length,a=e.splice(r);for(let e=0;enull!=i?i(t(),n):Ey(t(),n),o=()=>Cy(s,t,r);return!a||a<=1?mo(o().clone()):Array(a).fill(void 0).map(o).map((e=>mo(e.clone())))}b_.className="StackedRNNCells",lu(b_);class v_ extends c_{constructor(e){if(e.unroll)throw new Mg("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new Mg("It is not possible at the moment to stack convolutional cells.");super(e),this.inputSpec=[new ub({ndim:5})]}call(e,t){return ho((()=>{if(null!=this.cell.dropoutMask&&(fo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(fo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new wg("ConvRNN2D cell does not support constants");const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}computeOutputShape(e){let t=this.computeSingleOutputShape(e);return this.returnSequences||(t=[t[0],...t.slice(2)]),this.returnState&&(t=[t,...Array(2).fill([e[0],...t.slice(-3)])]),t}getInitialState(e){return ho((()=>{const{stateSize:t}=this.cell,n=e.shape,r=this.computeSingleOutputShape(n),a=up([r[0],...r.slice(2)]);return Array.isArray(t)?Array(t.length).fill(a):[a]}))}resetStates(e,t=!1){ho((()=>{if(!this.stateful)throw new vg("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape,r=this.computeSingleOutputShape(n),a=[r[0],...r.slice(2)];if(null==n[0])throw new wg("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==this.getStates())Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>up(a))):this.states_=[up(a)];else if(null==e)fo(this.states_),null!=this.keptStates&&(fo(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>up(a))):this.states_[0]=up(a);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new wg(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t?this.keptStates.push(this.states_.slice()):fo(this.states_);for(let t=0;tmo(e.clone())))}))}computeSingleOutputShape(e){const{dataFormat:t,filters:n,kernelSize:r,padding:a,strides:i,dilationRate:s}=this.cell,o="channelsFirst"===t,u=e[o?3:2],l=e[o?4:3],c=qv(u,r[0],a,i[0],s[0]),p=qv(l,r[1],a,i[1],s[1]);return[...e.slice(0,2),...o?[n,c,p]:[c,p,n]]}}v_.className="ConvRNN2D";class __ extends g_{constructor(e){const{filters:t,kernelSize:n,strides:r,padding:a,dataFormat:i,dilationRate:s}=e;super(Object.assign({},e,{units:t})),this.filters=t,Hg(this.filters,"filters"),this.kernelSize=Uv(n,2,"kernelSize"),this.kernelSize.forEach((e=>Hg(e,"kernelSize"))),this.strides=Uv(r||1,2,"strides"),this.strides.forEach((e=>Hg(e,"strides"))),this.padding=a||"valid",ny(this.padding),this.dataFormat=i||"channelsLast",ty(this.dataFormat),this.dilationRate=Uv(s||1,2,"dilationRate"),this.dilationRate.forEach((e=>Hg(e,"dilationRate")))}build(e){var t;e=rb(e);const n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n])throw new wg(`The channel dimension of the input should be defined. Found ${e[n]}`);const r=e[n],a=this.kernelSize.concat([r,4*this.filters]);this.kernel=this.addWeight("kernel",a,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const i=this.kernelSize.concat([this.filters,4*this.filters]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",i,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let e;if(this.unitForgetBias){const n=this.biasInitializer,r=this.filters;e=new((t=class extends $y{apply(e,t){return _y([n.apply([r]),lp([r]),n.apply([2*r])])}}).className="CustomInit",t)}else e=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.filters],null,e,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return ho((()=>{if(3!==e.length)throw new wg(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);const n=t.training||!1,r=e[0],a=e[1],i=e[2];0bp(r),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const s=this.dropoutMask,o=(e,t,n)=>t&&t[n]?Su(t[n],e):e;let u=o(r,s,0),l=o(r,s,1),c=o(r,s,2),p=o(r,s,3);0bp(a),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const d=this.recurrentDropoutMask;let h=o(a,d,0),f=o(a,d,1),m=o(a,d,2),g=o(a,d,3);const[y,b,x,v]=ld(this.kernel.read(),4,3),[_,w,M,N]=this.useBias?ld(this.bias.read(),4):[null,null,null,null];u=this.inputConv(u,y,_,this.padding),l=this.inputConv(l,b,w,this.padding),c=this.inputConv(c,x,M,this.padding),p=this.inputConv(p,v,N,this.padding);const[S,k,D,T]=ld(this.recurrentKernel.read(),4,3);h=this.recurrentConv(h,S),f=this.recurrentConv(f,k),m=this.recurrentConv(m,D),g=this.recurrentConv(g,T);const I=this.recurrentActivation.apply(wu(u,h)),E=this.recurrentActivation.apply(wu(l,f)),C=wu(Su(E,i),Su(I,this.activation.apply(wu(c,m)))),A=Su(this.recurrentActivation.apply(wu(p,g)),this.activation.apply(C));return[A,A,C]}))}getConfig(){const e=super.getConfig(),{units:t}=e,n=function(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 a=0;for(r=Object.getOwnPropertySymbols(e);a{this.invokeCallHook(e,t);const n=nb(e);if(0Ey(n,this.rate,r,this.seed)),(()=>n),e)}return e}))}getConfig(){const e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},t=super.getConfig();return Object.assign(e,t),e}dispose(){return super.dispose()}}M_.className="Dropout",lu(M_);class N_ extends M_{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){const t=e.shape;return[t[0],1,t[2]]}}N_.className="SpatialDropout1D",lu(N_);class S_ extends hb{constructor(e){if(super(e),this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",null==e.batchInputShape&&null==e.inputShape&&null!=e.inputDim){let t=null;null!=e.batchSize&&(t=e.batchSize),this.batchInputShape=[t,e.inputDim]}this.units=e.units,Hg(this.units,"units"),this.activation=Ev(e.activation),null!=e.useBias&&(this.useBias=e.useBias),this.kernelInitializer=Qy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=Qy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=Lb(e.kernelConstraint),this.biasConstraint=Lb(e.biasConstraint),this.kernelRegularizer=Fv(e.kernelRegularizer),this.biasRegularizer=Fv(e.biasRegularizer),this.activityRegularizer=Fv(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){const t=(e=rb(e))[e.length-1];null==this.kernel&&(this.kernel=this.addWeight("kernel",[t,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:{[-1]:t}}],this.built=!0}computeOutputShape(e){const t=(e=rb(e)).slice();return t[t.length-1]=this.units,t}call(e,t){return ho((()=>{this.invokeCallHook(e,t);const n=nb(e),r=Ug(this.activation.getClassName());let a;return null!=r?a=Sy(n,this.kernel.read(),r,this.bias?this.bias.read():null):(a=Sy(n,this.kernel.read()),null!=this.bias&&(a=Iy(a,this.bias.read())),null!=this.activation&&(a=this.activation.apply(a))),a}))}getConfig(){const e={units:this.units,activation:Tv(this.activation),useBias:this.useBias,kernelInitializer:Zy(this.kernelInitializer),biasInitializer:Zy(this.biasInitializer),kernelRegularizer:Ov(this.kernelRegularizer),biasRegularizer:Ov(this.biasRegularizer),activityRegularizer:Ov(this.activityRegularizer),kernelConstraint:Cb(this.kernelConstraint),biasConstraint:Cb(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}S_.className="Dense",lu(S_);class k_ extends hb{constructor(e){super(e=e||{}),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=rb(e);for(const t of e.slice(1))if(null==t)throw new wg(`The shape of the input to "Flatten" is not fully defined (got ${e.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`);return[e[0],cy(e,1)]}call(e,t){return ho((()=>{this.invokeCallHook(e,t);let n=nb(e);if("channelsFirst"===this.dataFormat&&n.rank>1){const e=[0];for(let t=2;t{this.invokeCallHook(e,t);const n=nb(e);return this.activation.apply(n)}))}getConfig(){const e={activation:Tv(this.activation)},t=super.getConfig();return Object.assign(e,t),e}}D_.className="Activation",lu(D_);class T_ extends hb{constructor(e){super(e),this.n=e.n,this.inputSpec=[{ndim:2}]}computeOutputShape(e){return[e[0],this.n,e[1]]}call(e,t){return ho((()=>function(e,t){return ho((()=>{if(2!==e.shape.length)throw new wg(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`);return My(yy(e,1),[1,t,1])}))}(e=nb(e),this.n)))}getConfig(){const e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}}T_.className="RepeatVector",lu(T_);class I_ extends hb{constructor(e){super(e),this.targetShape=e.targetShape;for(let e=0;e{this.invokeCallHook(e,t);const n=nb(e),r=n.shape,a=r.slice(0,1).concat(this.fixUnknownDimension(r.slice(1),this.targetShape));return Ml(n,a)}))}getConfig(){const e={targetShape:this.targetShape},t=super.getConfig();return Object.assign(e,t),e}}I_.className="Reshape",lu(I_);class E_ extends hb{constructor(e){if(super(e),null==e.dims)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(e.dims))throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`);const t=hy(1,e.dims.length+1);if(!de(e.dims.slice().sort(),t))throw new Error("Invalid permutation `dims`: "+JSON.stringify(e.dims)+" `dims` must contain consecutive integers starting from 1.");this.dims=e.dims,this.dimsIncludingBatch=[0].concat(this.dims),this.inputSpec=[new ub({ndim:this.dims.length+1})]}computeOutputShape(e){const t=(e=rb(e)).slice();return this.dims.forEach(((n,r)=>{t[r+1]=e[n]})),t}call(e,t){return Io(nb(e),this.dimsIncludingBatch)}getConfig(){const e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}}E_.className="Permute",lu(E_);class C_ extends hb{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,this.maskValue=null!=e?null==e.maskValue?0:e.maskValue:0}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={maskValue:this.maskValue};return Object.assign(t,e),t}computeMask(e,t){const n=nb(e);return tl(yp(n,this.maskValue),-1)}call(e,t){return ho((()=>{this.invokeCallHook(e,t);const n=nb(e),r=tl(yp(n,this.maskValue),-1,!0);return Su(n,Ls(r,n.dtype))}))}}C_.className="Masking",lu(C_);class A_ extends hb{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==e.batchInputShape&&null==e.inputShape){let t=null;null!=e.batchSize&&(t=e.batchSize),null==e.inputLength?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(Eg(e.inputLength))}this.inputDim=e.inputDim,Hg(this.inputDim,"inputDim"),this.outputDim=e.outputDim,Hg(this.outputDim,"outputDim"),this.embeddingsInitializer=Qy(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=Fv(e.embeddingsRegularizer),this.activityRegularizer=Fv(e.activityRegularizer),this.embeddingsConstraint=Lb(e.embeddingsConstraint),this.maskZero=e.maskZero,this.supportsMasking=e.maskZero,this.inputLength=e.inputLength}build(e){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0}warnOnIncompatibleInputShape(e){}computeMask(e,t){return ho((()=>this.maskZero?(e=nb(e),yp(e,Tu(e))):null))}computeOutputShape(e){if(e=rb(e),null==this.inputLength)return[...e,this.outputDim];const t=Eg(this.inputLength);if(t.length!==e.length-1)throw new wg(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let n=0;for(let r=0;r{this.invokeCallHook(e,t);let n=nb(e);"int32"!==n.dtype&&(n=gy(n,"int32"));const r=ky(this.embeddings.read(),Ml(n,[n.size]));return Ml(r,rb(this.computeOutputShape(n.shape)))}))}getConfig(){const e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:Zy(this.embeddingsInitializer),embeddingsRegularizer:Ov(this.embeddingsRegularizer),activityRegularizer:Ov(this.activityRegularizer),embeddingsConstraint:Cb(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}}A_.className="Embedding",lu(A_);class L_ extends hb{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new Mg}computeElementwiseOpOutputShape(e,t){if(null==e||null==t)return null;if(e.length1)throw new wg(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let n=null==e[0]?null:e[0].slice(1);for(let t=1;te.length));-1===e.indexOf(null)&&1===Yg(r).length?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return ho((()=>{if(this.reshapeRequired){const t=[],n=e.map((e=>e.rank));if(-1===n.indexOf(null)){const r=dy(n);for(let n of e){const e=n.rank;for(let t=0;t1){const a=hy(1,e).concat([0]);t.push(Io(r,a)),n=!0}else t.push(r)}let r=this.mergeFunction(t);const a=r.rank;if(n)if(null==a){const e=r.shape,t=e[e.length-1],n=[t].concat(e.slice(0,e.length-1));r=Ml(Io(Ml(r,[-1,t]),[1,0]),n)}else if(a>1){const e=[a-1].concat(hy(0,a-1));r=Io(r,e)}return r}}return this.mergeFunction(e)}))}computeOutputShape(e){let t;t=null==e[0]?null:e[0].slice(1);for(let n=1;n{if(null==t)return null;if(!Array.isArray(t))throw new wg("`mask` should be an Array");if(!Array.isArray(e))throw new wg("`inputs` should be an Array");if(t.length!==e.length)throw new wg(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every((e=>null==e)))return null;let n=(t=t.map((e=>null==e?e:Ic(e,0))))[0];for(let e=1;e{let t=e[0].clone();for(let n=1;n{let t=e[0].clone();for(let n=1;n{let t=e[0].clone();for(let n=1;n{let t=e[0];for(let n=1;n{let t=e[0];for(let n=1;n1)throw new wg("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return ho((()=>_y(e,this.axis)))}computeOutputShape(e){if(!Array.isArray(e)||!Array.isArray(e[0]))throw new wg("A `Concatenate` layer should be called on a list of inputs.");const t=e,n=t[0].slice(),r=this.axis<0?n.length+this.axis:this.axis;for(const e of t.slice(1)){if(null==n[r]||null==e[r]){n[r]=null;break}n[r]+=e[r]}return n}computeMask(e,t){if(null==t)return null;if(!Array.isArray(t))throw new wg("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new wg("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new wg(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return ho((()=>{let n=!0;if(t.forEach((e=>{null==e||(n=!1)})),n)return null;const r=[];for(let n=0;n"A `Dot` layer should be called on a list of exactly 2 inputs."));const t=e[0],n=e[1];if(t.length>3||n.length>3)throw new Mg("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(t,n);if(t[r[0]]!==n[r[1]])throw new wg(`Dimension incompatibility: ${t[r[0]]} !== ${n[r[1]]}`)}mergeFunction(e){if(2!==e.length)throw new wg(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let t,n=e[0],r=e[1];return t=Array.isArray(this.axes)?this.axes.map(((t,n)=>B_(t,e[n].shape.length))):[B_(this.axes,n.shape.length),B_(this.axes,r.shape.length)],this.normalize&&(n=px(n,t[0]),r=px(r,t[1])),function(e,t,n){if(e.shape.length>3||t.shape.length>3)throw new Mg("batchDot is not implemented for tensors of 4D or higher rank yet");if(se(e.shape.length>=2,(()=>`batchDot requires the rank of x to be >= 2, but got ${e.shape.length}`)),se(e.shape.length>=2,(()=>`batchDot requires the rank of y to be >= 2, but got ${t.shape.length}`)),"number"==typeof n&&(n=[n,n]),"complex64"===e.dtype||"complex64"===t.dtype)throw new Mg("batchDot is not implemented for complex64-type Tensors yet.");const r=e.shape.length,a=t.shape.length;null==n&&(n=[r-1,a-2]);const i=n;return ho((()=>{let n,s;if(r>a){n=r-a;const e=[];for(let t=0;tr){n=a-r;const t=[];for(let e=0;e0){let e;e=r>a?r+a-3:r-1;const t=[];for(let r=e;r"A `Dot` layer should be called on a list of exactly 2 inputs."));const t=e[0].slice(),n=e[1].slice();if(t.length>3||n.length>3)throw new Mg("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(t,n);t.splice(r[0],1),n.splice(r[1],1),n.splice(0,1);const a=t.concat(n);return 1===a.length&&a.push(1),a}computeMask(e,t){return null}getConfig(){const e={axes:this.axes,normalize:this.normalize},t=super.getConfig();return Object.assign(e,t),e}}P_.className="Dot",lu(P_);class H_ extends hb{constructor(e){super(e),this.supportsMasking=!0,this.stddev=e.stddev}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={stddev:this.stddev};return Object.assign(t,e),t}call(e,t){return ho((()=>{this.invokeCallHook(e,t);const n=nb(e);return Cy((()=>wu(Ny(n.shape,0,this.stddev),n)),(()=>n),t.training||!1)}))}}H_.className="GaussianNoise",lu(H_);class j_ extends hb{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return ho((()=>{this.invokeCallHook(e,t);const n=nb(e);return this.rate>0&&this.rate<1?Cy((()=>{const e=Math.sqrt(this.rate/(1-this.rate));return Su(n,Ny(n.shape,1,e))}),(()=>n),t.training||!1):n}))}}j_.className="GaussianDropout",lu(j_);class U_ extends hb{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||nb(e).shape}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return ho((()=>{if(this.rate<1&&this.rate>0){const n=this._getNoiseShape(e),r=()=>{const t=nb(e),r=-1.7580993408473766;let a=Rc(Fp(n),this.rate);a=gy(a,"float32");const i=((1-this.rate)*(1+this.rate*r**2))**-.5,s=-i*r*this.rate,o=wu(Su(t,a),Su(wu(a,-1),r));return wu(Su(o,i),s)};return Cy(r,(()=>nb(e)),t.training||!1)}return e}))}}function q_(e,t,n,r,a,i=.001){let s;if(2===e.rank)s=Ll(e,t,n,r,a,i);else if(3===e.rank)s=$l(e,t,n,r,a,i);else{if(4!==e.rank)throw new Mg(`batchNormalization is not implemented for array of rank ${e.rank} yet`);s=Ol(e,t,n,r,a,i)}return s}U_.className="AlphaDropout",lu(U_);class W_ extends hb{constructor(e){null==e&&(e={}),super(e),this.supportsMasking=!0,this.axis=null==e.axis?-1:e.axis,this.momentum=null==e.momentum?.99:e.momentum,this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=Qy(e.betaInitializer||"zeros"),this.gammaInitializer=Qy(e.gammaInitializer||"ones"),this.movingMeanInitializer=Qy(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=Qy(e.movingVarianceInitializer||"ones"),this.betaConstraint=Lb(e.betaConstraint),this.gammaConstraint=Lb(e.gammaConstraint),this.betaRegularizer=Fv(e.betaRegularizer),this.gammaRegularizer=Fv(e.gammaRegularizer)}build(e){e=rb(e);const t=this.axis>=0?this.axis:this.axis+e.length,n=e[t];if(null==n)throw new wg(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new ub({ndim:e.length,axes:{[t]:n}})];const r=[n];this.scale&&(this.gamma=this.addWeight("gamma",r,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",r,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",r,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",r,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return ho((()=>{const n=null!=t.training&&t.training,r=nb(e),a=r.shape,i=a.length,s=hy(0,i),o=this.axis>=0?this.axis:this.axis+i;s.splice(o,1);const u=kg(1,i);u[o]=a[o];const l=s.slice();l.sort();const c=!de(l,hy(0,i).slice(0,i-1));if(!n)return(()=>{if(c){const e=Ml(this.movingMean.read(),u),t=Ml(this.movingVariance.read(),u),n=this.center?Ml(this.beta.read(),u):null,a=this.scale?Ml(this.gamma.read(),u):null;return q_(r,e,t,n,a,this.epsilon)}return q_(r,this.movingMean.read(),this.movingVariance.read(),null==this.beta?null:this.beta.read(),null==this.gamma?null:this.gamma.read(),this.epsilon)})();const[p,d,h]=function(e,t,n,r,a=.001){return de(r.slice().sort(),hy(0,e.rank-1))?function(e,t,n,r,a=.001){return ho((()=>{const i=fp(e,r),s=i.mean,o=i.variance;return[q_(e,s,o,n,t,a),s,o]}))}(e,t,n,r,a):function(e,t,n,r,a=.001){return ho((()=>{const i=fp(e,r),s=i.mean,o=i.variance,u=[];for(const t of hy(0,e.rank))-1!==r.indexOf(t)?u.push(1):u.push(e.shape[t]);const l=Ml(s,u),c=Ml(o,u),p=null==t?null:Ml(t,u),d=null==n?null:Ml(n,u);return[q_(e,l,c,d,p,a),s,o]}))}(e,t,n,r,a)}(r,this.gamma.read(),this.beta.read(),s,this.epsilon),f=(e,t,n)=>{ho((()=>{const r=1-n,a=e.read(),i=Su(Hu(a,t),r);e.write(Hu(a,i))}))};return(()=>{f(this.movingMean,d,this.momentum),f(this.movingVariance,h,this.momentum)})(),p}))}getConfig(){const e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Zy(this.betaInitializer),gammaInitializer:Zy(this.gammaInitializer),movingMeanInitializer:Zy(this.movingMeanInitializer),movingVarianceInitializer:Zy(this.movingVarianceInitializer),betaRegularizer:Ov(this.betaRegularizer),gammaRegularizer:Ov(this.gammaRegularizer),betaConstraint:Cb(this.betaConstraint),gammaConstraint:Cb(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}}W_.className="BatchNormalization",lu(W_);class V_ extends hb{constructor(e){if(null==e&&(e={}),super(e),this.axis=null==e.axis?-1:e.axis,"number"==typeof this.axis){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else{if(!Array.isArray(this.axis))throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);for(const e of this.axis)if(!Number.isInteger(e))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=Qy(e.betaInitializer||"zeros"),this.gammaInitializer=Qy(e.gammaInitializer||"ones"),this.betaRegularizer=Fv(e.betaRegularizer),this.gammaRegularizer=Fv(e.gammaRegularizer),this.supportsMasking=!0}build(e){const t=(e=rb(e)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(let e=0;e=t)throw new Error(`Invalid axis: ${e}`);if(this.axis.length!==Yg(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const n=this.axis.map((t=>e[t]));this.scale?this.gamma=this.addWeight("gamma",n,"float32",this.gammaInitializer,this.gammaRegularizer,!0):this.gamma=null,this.center?this.beta=this.addWeight("beta",n,"float32",this.betaInitializer,this.betaRegularizer,!0):this.beta=null,this.built=!0}call(e,t){const n=nb(e),r=n.shape,a=r.length;return ho((()=>{let{mean:e,variance:t}=fp(n,this.axis,!0);const i=kg(1,a);for(const e of this.axis)i[e]=r[e];const s=e=>null!=e&&e.shape.length!==a?Ml(e,i):e;let o=this.scale?s(this.gamma.read()):null,u=this.center?s(this.beta.read()):null;const l=[],c=[];for(let e=0;e=0?e[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[3]&&e[3]>=0?e[3]+this.padding[1][0]+this.padding[1][1]:null,[e[0],e[1],t,n]):(t=null!=e[1]&&e[1]>=0?e[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[2]&&e[2]>=0?e[2]+this.padding[1][0]+this.padding[1][1]:null,[e[0],t,n,e[3]])}call(e,t){return ho((()=>{return t=nb(e),n=this.padding,r=this.dataFormat,ho((()=>{if(4!==t.rank)throw new wg(`temporalPadding expects input tensor to be 4-D, but received a ${t.rank}-D tensor.`);if(null==n&&(n=[[1,1],[1,1]]),2!==n.length||2!==n[0].length||2!==n[1].length)throw new wg("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==r&&(r="channelsLast"),"channelsLast"!==r&&"channelsFirst"!==r)throw new wg(`Unknown data format: ${r}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let e;return e="channelsFirst"===r?[[0,0],[0,0],n[0],n[1]]:[[0,0],n[0],n[1],[0,0]],vp(t,e)}));var t,n,r}))}getConfig(){const e={padding:this.padding,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}function K_(e,t,n,r,a,i){return ho((()=>{let s;ty(a),ry(i),ny(r),null==n&&(n=[1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),e=Vv(e,a);const o="same"===r?"same":"valid";return s="max"===i?ap(e,t,n,o):Nl(e,t,n,o),"channelsFirst"===a&&(s=Io(s,[0,3,1,2])),s}))}function J_(e,t,n,r,a,i){return ho((()=>{let s;ty(a),ry(i),ny(r),null==n&&(n=[1,1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),e=Gv(e,a);const o="same"===r?"same":"valid";return s="max"===i?ip(e,t,n,o):Sl(e,t,n,o),"channelsFirst"===a&&(s=Io(s,[0,4,1,2,3])),s}))}G_.className="ZeroPadding2D",lu(G_);class X_ extends hb{constructor(e){if(null==e.poolSize&&(e.poolSize=2),super(e),"number"==typeof e.poolSize)this.poolSize=[e.poolSize];else{if(!Array.isArray(e.poolSize)||1!==e.poolSize.length||"number"!=typeof e.poolSize[0])throw new wg(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);this.poolSize=e.poolSize}if(Hg(this.poolSize,"poolSize"),null==e.strides)this.strides=this.poolSize;else if("number"==typeof e.strides)this.strides=[e.strides];else{if(!Array.isArray(e.strides)||1!==e.strides.length||"number"!=typeof e.strides[0])throw new wg(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);this.strides=e.strides}Hg(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,ny(this.padding),this.inputSpec=[new ub({ndim:3})]}computeOutputShape(e){const t=qv((e=rb(e))[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return ho((()=>{this.invokeCallHook(e,t),e=yy(nb(e),2);const n=this.poolingFunction(nb(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return dd(n,[2])}))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}}class Z_ extends X_{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),K_(e,t,n,r,a,"max")}}Z_.className="MaxPooling1D",lu(Z_);class Q_ extends X_{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),K_(e,t,n,r,a,"avg")}}Q_.className="AveragePooling1D",lu(Q_);class ew extends hb{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(2!==e.strides.length)throw new wg(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides];Hg(this.poolSize,"poolSize"),Hg(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,ty(this.dataFormat),ny(this.padding),this.inputSpec=[new ub({ndim:4})]}computeOutputShape(e){e=rb(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2];return t=qv(t,this.poolSize[0],this.padding,this.strides[0]),n=qv(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n]:[e[0],t,n,e[3]]}call(e,t){return ho((()=>(this.invokeCallHook(e,t),this.poolingFunction(nb(e),this.poolSize,this.strides,this.padding,this.dataFormat))))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class tw extends ew{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),K_(e,t,n,r,a,"max")}}tw.className="MaxPooling2D",lu(tw);class nw extends ew{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),K_(e,t,n,r,a,"avg")}}nw.className="AveragePooling2D",lu(nw);class rw extends hb{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(3!==e.strides.length)throw new wg(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides,e.strides];Hg(this.poolSize,"poolSize"),Hg(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,ty(this.dataFormat),ny(this.padding),this.inputSpec=[new ub({ndim:5})]}computeOutputShape(e){e=rb(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],r="channelsFirst"===this.dataFormat?e[4]:e[3];return t=qv(t,this.poolSize[0],this.padding,this.strides[0]),n=qv(n,this.poolSize[1],this.padding,this.strides[1]),r=qv(r,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n,r]:[e[0],t,n,r,e[4]]}call(e,t){return ho((()=>(this.invokeCallHook(e,t),this.poolingFunction(nb(e),this.poolSize,this.strides,this.padding,this.dataFormat))))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class aw extends rw{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),J_(e,t,n,r,a,"max")}}aw.className="MaxPooling3D",lu(aw);class iw extends rw{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),J_(e,t,n,r,a,"avg")}}iw.className="AveragePooling3D",lu(iw);class sw extends hb{constructor(e){super(e),this.inputSpec=[new ub({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new Mg}}class ow extends sw{constructor(e){super(e||{})}call(e,t){return ho((()=>{const t=nb(e);return op(t,1)}))}}ow.className="GlobalAveragePooling1D",lu(ow);class uw extends sw{constructor(e){super(e||{})}call(e,t){return ho((()=>{const t=nb(e);return wc(t,1)}))}}uw.className="GlobalMaxPooling1D",lu(uw);class lw extends hb{constructor(e){super(e),this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,ty(this.dataFormat),this.inputSpec=[new ub({ndim:4})]}computeOutputShape(e){return"channelsLast"===this.dataFormat?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new Mg}getConfig(){const e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class cw extends lw{call(e,t){return ho((()=>{const t=nb(e);return"channelsLast"===this.dataFormat?op(t,[1,2]):op(t,[2,3])}))}}cw.className="GlobalAveragePooling2D",lu(cw);class pw extends lw{call(e,t){return ho((()=>{const t=nb(e);return"channelsLast"===this.dataFormat?wc(t,[1,2]):wc(t,[2,3])}))}}pw.className="GlobalMaxPooling2D",lu(pw);class dw extends hb{constructor(e){super(e),this.layer=e.layer}build(e){this.built=!0}get trainable(){return null!=this.layer&&this.layer.trainable}set trainable(e){null!=this.layer&&(this.layer.trainable=e)}get trainableWeights(){return this.layer.trainableWeights}get nonTrainableWeights(){return this.layer.nonTrainableWeights}get updates(){return this.layer._updates}get losses(){return this.layer.losses}getWeights(){return this.layer.getWeights()}setWeights(e){this.layer.setWeights(e)}getConfig(){const e={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},t=super.getConfig();return Object.assign(e,t),e}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(e)}static fromConfig(e,t,n={}){const r=cx(t.layer,n);delete t.layer;const a={layer:r};return Object.assign(a,t),new e(a)}}class hw extends dw{constructor(e){super(e),this.supportsMasking=!0}build(e){if((e=rb(e)).length<3)throw new wg(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(e)}`);this.inputSpec=[{shape:e}];const t=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(t),this.layer.built=!0),super.build(e)}computeOutputShape(e){const t=[(e=rb(e))[0]].concat(e.slice(2)),n=this.layer.computeOutputShape(t),r=e[1];return[n[0],r].concat(n.slice(1))}call(e,t){return ho((()=>l_(((e,n)=>[nb(this.layer.call(e,t)),[]]),e=nb(e),[],!1,null,null,!1,!0)[1]))}}hw.className="TimeDistributed",lu(hw);class fw extends dw{constructor(e){super(e);const t=e.layer.getConfig(),n={};n.className=e.layer.getClassName(),n.config=t,this.forwardLayer=cx(n),t.goBackwards=!0!==t.goBackwards;const r={};var a;if(r.className=e.layer.getClassName(),r.config=t,this.backwardLayer=cx(r),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=void 0===e.mergeMode?"concat":e.mergeMode,a=this.mergeMode,Bg(Qg,"BidirectionalMergeMode",a),e.weights)throw new Mg("weights support is not implemented for Bidirectional layer yet.");this._stateful=e.layer.stateful,this.returnSequences=e.layer.returnSequences,this.returnState=e.layer.returnState,this.supportsMasking=!0,this._trainable=!0,this.inputSpec=e.layer.inputSpec,this.numConstants=null}get trainable(){return this._trainable}set trainable(e){this._trainable=e,null!=this.forwardLayer&&(this.forwardLayer.trainable=e),null!=this.backwardLayer&&(this.backwardLayer.trainable=e)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(e){const t=e.length,n=Math.floor(t/2);this.forwardLayer.setWeights(e.slice(0,n)),this.backwardLayer.setWeights(e.slice(n))}computeOutputShape(e){let t,n,r,a=this.forwardLayer.computeOutputShape(e);return Array.isArray(a)&&Array.isArray(a[0])||(a=[a]),this.returnState?(r=a.slice(1),t=a[0]):t=a[0],"concat"===this.mergeMode?(t[t.length-1]*=2,n=[t]):n=null==this.mergeMode?[t,t.slice()]:[t],this.returnState?null==this.mergeMode?n.concat(r).concat(r.slice()):[t].concat(r).concat(r.slice()):Ig(n)}apply(e,t){let n=null==t?null:t.initialState,r=null==t?null:t.constants;null==t&&(t={});const a=u_(e,n,r,this.numConstants);if(e=a.inputs,n=a.initialState,r=a.constants,Array.isArray(e)&&(n=e.slice(1),e=e[0]),(null==n||0===n.length)&&null==r)return super.apply(e,t);const i=[],s=[];if(null!=n){const e=n.length;if(e%2>0)throw new wg("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");t.initialState=n,i.push(...n);const r=n.map((e=>new ub({shape:e.shape})));this.forwardLayer.stateSpec=r.slice(0,e/2),this.backwardLayer.stateSpec=r.slice(e/2),s.push(...r)}if(null!=r)throw new Mg("Support for constants in Bidirectional layers is not implemented yet.");const o=i[0]instanceof lb;for(const e of i)if(e instanceof lb!==o)throw new wg("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(o){const n=[e].concat(i),r=this.inputSpec.concat(s),a=this.inputSpec;this.inputSpec=r;const o=super.apply(n,t);return this.inputSpec=a,o}return super.apply(e,t)}call(e,t){return ho((()=>{const n=t.initialState;let r,a,i,s;if(null==n)r=this.forwardLayer.call(e,t),a=this.backwardLayer.call(e,t);else{const i=n.slice(0,n.length/2),s=n.slice(n.length/2);r=this.forwardLayer.call(e,Object.assign(t,{initialState:i})),a=this.backwardLayer.call(e,Object.assign(t,{initialState:s}))}return this.returnState&&(Array.isArray(r)&&(i=r.slice(1).concat(a.slice(1))),r=r[0],a=a[0]),this.returnSequences&&(a=Hp(a,1)),"concat"===this.mergeMode?s=_y([r,a]):"sum"===this.mergeMode?s=wu(r,a):"ave"===this.mergeMode?s=Su(.5,wu(r,a)):"mul"===this.mergeMode?s=Su(r,a):null==this.mergeMode&&(s=[r,a]),this.returnState?null==this.mergeMode?s.concat(i):[s].concat(i):s}))}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){iy(this.forwardLayer.name,(()=>{this.forwardLayer.build(e)})),iy(this.backwardLayer.name,(()=>{this.backwardLayer.build(e)})),this.built=!0}computeMask(e,t){let n;if(Array.isArray(t)&&(t=t[0]),n=this.returnSequences?null==this.mergeMode?[t,t]:t:null==this.mergeMode?[null,null]:null,this.returnState){const e=this.forwardLayer.states.map((e=>null));return Array.isArray(n)?n.concat(e).concat(e):[n].concat(e).concat(e)}return n}get trainableWeights(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}get nonTrainableWeights(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),null!=this.forwardLayer&&this.forwardLayer.setFastWeightInitDuringBuild(e),null!=this.backwardLayer&&this.backwardLayer.setFastWeightInitDuringBuild(e)}getConfig(){const e={mergeMode:this.mergeMode},t=super.getConfig();return Object.assign(e,t),e}static fromConfig(e,t){const n=cx(t.layer);if(delete t.layer,null!=t.numConstants)throw new Mg("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");const r=t;return r.layer=n,new e(r)}}function mw(e){return new mb(e)}function gw(e){return new Pv(e)}function yw(e){return new Yv(e)}function bw(e){return new zv(e)}function xw(e){return new Bv(e)}function vw(e){return new jv(e)}function _w(e){return new Hv(e)}function ww(e){return new a_(e)}function Mw(e){return new Zv(e)}function Nw(e){return new e_(e)}function Sw(e){return new Qv(e)}function kw(e){return new t_(e)}function Dw(e){return new r_(e)}function Tw(e){return new i_(e)}function Iw(e){return new s_(e)}function Ew(e){return new o_(e)}function Cw(e){return new D_(e)}function Aw(e){return new S_(e)}function Lw(e){return new M_(e)}function $w(e){return new N_(e)}function Ow(e){return new k_(e)}function Rw(e){return new T_(e)}function Fw(e){return new I_(e)}function Yw(e){return new E_(e)}function zw(e){return new A_(e)}function Bw(e){return new $_(e)}function Pw(e){return new R_(e)}function Hw(e){return new z_(e)}function jw(e){return new F_(e)}function Uw(e){return new Y_(e)}function qw(e){return new O_(e)}function Ww(e){return new P_(e)}function Vw(e){return new W_(e)}function Gw(e){return new V_(e)}function Kw(e){return new G_(e)}function Jw(e){return new Q_(e)}function Xw(e){return Jw(e)}function Zw(e){return Jw(e)}function Qw(e){return new nw(e)}function eM(e){return Qw(e)}function tM(e){return Qw(e)}function nM(e){return new iw(e)}function rM(e){return nM(e)}function aM(e){return nM(e)}function iM(e){return new ow(e)}function sM(e){return new cw(e)}function oM(e){return new uw(e)}function uM(e){return new pw(e)}function lM(e){return new Z_(e)}function cM(e){return new tw(e)}function pM(e){return new aw(e)}function dM(e){return new m_(e)}function hM(e){return new f_(e)}function fM(e){return new y_(e)}function mM(e){return new g_(e)}function gM(e){return new h_(e)}function yM(e){return new d_(e)}function bM(e){return new w_(e)}function xM(e){return new __(e)}function vM(e){return new c_(e)}function _M(e){return new b_(e)}function wM(e){return new fw(e)}function MM(e){return new hw(e)}fw.className="Bidirectional",lu(fw);const NM=oM,SM=uM,kM=lM,DM=cM;function TM(e){return new H_(e)}function IM(e){return new j_(e)}function EM(e){return new U_(e)}function CM(e){return new C_(e)}function AM(e,t){return _x(e,t)}function LM(e,t){return Sx(e,t)}function $M(e,t){return kx(e,t)}function OM(e,t){return wx(e,t)}function RM(e,t){return Dx(e,t)}function FM(e,t){return Nx(e,t)}function YM(e,t){return function(e,t){return ho((()=>{const n=Mx(e,t),r=function(e,t){return ho((()=>Ls(Nc(Xc(oc(e,1),oc(t,0))),"float32")))}(e,t),a=wu(n,r);return Ls(uc(Oc(a,0),Nu(n,a),0),"float32")}))}(e,t)}function zM(e,t){return bx(e,t)}function BM(e,t){return hx(e,t)}function PM(e,t){return fx(e,t)}function HM(e,t){return fx(e,t)}function jM(e,t){return fx(e,t)}function UM(e,t){return dx(e,t)}function qM(e,t){return dx(e,t)}function WM(e,t){return dx(e,t)}function VM(e){return new Lv(e)}function GM(e){return Cv(t=e),new Lv({l1:null!=t?t.l1:null,l2:0});var t}function KM(e){return Cv(t=e),new Lv({l2:null!=t?t.l2:null,l1:0});var t}class JM extends nx{constructor(){super(...arguments),this.model=null}setModel(e){if(!(e instanceof av))throw new Error("model must be a LayersModel, not some other Container");this.model=e}}function XM(e,t){return et}class QM extends JM{constructor(e){if(super(),null==e&&(e={}),e.restoreBestWeights)throw new Mg("restoreBestWeights = True is not implemented in EarlyStopping yet.");this.monitor=e.monitor||"val_loss",this.minDelta=Math.abs(e.minDelta||0),this.patience=e.patience||0,this.verbose=e.verbose||0,this.mode=e.mode||"auto",this.baseline=e.baseline,-1===["auto","min","max"].indexOf(this.mode)&&(console.warn(`EarlyStopping mode '${this.mode}' is invalid. Falling back to mode 'auto'.`),this.mode="auto"),"min"===this.mode?this.monitorFunc=XM:"max"===this.mode||-1!==this.monitor.indexOf("acc")?this.monitorFunc=ZM:this.monitorFunc=XM,this.monitorFunc===XM&&(this.minDelta*=-1)}async onTrainBegin(e){this.wait=0,this.stoppedEpoch=0,null!=this.baseline?this.best=this.baseline:this.best=this.monitorFunc===XM?1/0:-1/0}async onEpochEnd(e,t){await Qb(t);const n=this.getMonitorValue(t);null!=n&&(this.monitorFunc(n-this.minDelta,this.best)?(this.best=n,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=e,this.model.stopTraining=!0)))}async onTrainEnd(e){this.stoppedEpoch>0&&this.verbose&&console.log(`Epoch ${this.stoppedEpoch}: early stopping.`)}getMonitorValue(e){null==e&&(e={});const t=e[this.monitor];return null==t&&console.warn(`Metric for EarlyStopping ${this.monitor} is not available. Available metrics are: ${Object.keys(e)}`),t}}const eN={earlyStopping:function(e){return new QM(e)}};var tN,nN;Ge().registerFlag("KEEP_INTERMEDIATE_TENSORS",(()=>!1),(e=>{e&&console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.")})),function(e){e[e.DT_INVALID=0]="DT_INVALID",e[e.DT_FLOAT=1]="DT_FLOAT",e[e.DT_DOUBLE=2]="DT_DOUBLE",e[e.DT_INT32=3]="DT_INT32",e[e.DT_UINT8=4]="DT_UINT8",e[e.DT_INT16=5]="DT_INT16",e[e.DT_INT8=6]="DT_INT8",e[e.DT_STRING=7]="DT_STRING",e[e.DT_COMPLEX64=8]="DT_COMPLEX64",e[e.DT_INT64=9]="DT_INT64",e[e.DT_BOOL=10]="DT_BOOL",e[e.DT_QINT8=11]="DT_QINT8",e[e.DT_QUINT8=12]="DT_QUINT8",e[e.DT_QINT32=13]="DT_QINT32",e[e.DT_BFLOAT16=14]="DT_BFLOAT16",e[e.DT_QINT16=15]="DT_QINT16",e[e.DT_QUINT16=16]="DT_QUINT16",e[e.DT_UINT16=17]="DT_UINT16",e[e.DT_COMPLEX128=18]="DT_COMPLEX128",e[e.DT_HALF=19]="DT_HALF",e[e.DT_RESOURCE=20]="DT_RESOURCE",e[e.DT_VARIANT=21]="DT_VARIANT",e[e.DT_UINT32=22]="DT_UINT32",e[e.DT_UINT64=23]="DT_UINT64",e[e.DT_FLOAT_REF=101]="DT_FLOAT_REF",e[e.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",e[e.DT_INT32_REF=103]="DT_INT32_REF",e[e.DT_UINT8_REF=104]="DT_UINT8_REF",e[e.DT_INT16_REF=105]="DT_INT16_REF",e[e.DT_INT8_REF=106]="DT_INT8_REF",e[e.DT_STRING_REF=107]="DT_STRING_REF",e[e.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",e[e.DT_INT64_REF=109]="DT_INT64_REF",e[e.DT_BOOL_REF=110]="DT_BOOL_REF",e[e.DT_QINT8_REF=111]="DT_QINT8_REF",e[e.DT_QUINT8_REF=112]="DT_QUINT8_REF",e[e.DT_QINT32_REF=113]="DT_QINT32_REF",e[e.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",e[e.DT_QINT16_REF=115]="DT_QINT16_REF",e[e.DT_QUINT16_REF=116]="DT_QUINT16_REF",e[e.DT_UINT16_REF=117]="DT_UINT16_REF",e[e.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",e[e.DT_HALF_REF=119]="DT_HALF_REF",e[e.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",e[e.DT_VARIANT_REF=121]="DT_VARIANT_REF",e[e.DT_UINT32_REF=122]="DT_UINT32_REF",e[e.DT_UINT64_REF=123]="DT_UINT64_REF"}(tN||(tN={})),function(e){let t;!function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"}(t=e.CheckpointFormatVersion||(e.CheckpointFormatVersion={}))}(nN||(nN={}));const rN={};function aN(e,t){const n={tfOpName:e,category:"custom",inputs:[],attrs:[],customExecutor:t};rN[e]=n}function iN(e){return rN[e]}function sN(e){delete rN[e]}function oN(e,t,n,r,a){const i=t.inputParams[e];if(i&&void 0!==i.inputIndexStart){const e=i.inputIndexStart,s=0===i.inputIndexEnd?void 0:void 0===i.inputIndexEnd?e+1:i.inputIndexEnd;if("tensor"===i.type)return uN(t.inputNames[i.inputIndexStart],n,r,a);if("tensors"===i.type)return t.inputNames.slice(e,s).map((e=>uN(e,n,r,a)));const o=uN(t.inputNames.slice(e)[0],n,r,a),u=o.dataSync();return"number"===i.type?u[0]:Ye(o.shape,u)}const s=t.attrParams[e];return s&&s.value}function uN(e,t,n,r){const[a,i]=pN(e);if(null!=r){const e=r.getHashTableHandleByName(a);if(null!=e)return e}const s=n.currentContextIds.find((e=>!!t[cN(a,e)]));return void 0!==s?t[cN(a,s)][i]:void 0}function lN(e,t){const[n,r,a]=pN(e);return[cN(n,t&&t.currentContextId),r,a]}function cN(e,t){return t?`${e}-${t}`:e}function pN(e){const t=e.split(":");if(1===t.length)return[e,0,void 0];const n=t[0],r=3===t.length?t[1]:void 0;return[n,Number(t[t.length-1]),r]}function dN(e,t,n){let r=oN("pad",e,t,n);if("explicit"===r){r=oN("explicitPaddings",e,t,n);const a=[[0,0],[0,0],[0,0],[0,0]];for(let e=0;e<4;e++)a[e][0]=r[2*e],a[e][1]=r[2*e+1];return a}return r}function hN(e){return e.kept?e:$s(e)}const fN=[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],mN=[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Prod",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axes",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],gN=[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}],yN=[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"Dilation2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"rates",name:"dilations",type:"number[]"},{tfName:"padding",name:"pad",type:"string"}]}],bN=[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomStandardNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}],xN=[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],vN=[{tfOpName:"LowerBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"UpperBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}],_N=[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0},{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}],wN=[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]}],MN=[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]},{tfOpName:"ImageProjectiveTransformV3",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"transforms",type:"tensor"},{start:2,name:"outputShape",type:"number[]"},{start:3,name:"fillValue",type:"number"}],attrs:[{tfName:"interpolation",name:"interpolation",type:"string"},{tfName:"fill_mode",name:"fillMode",type:"string"}]}],NN=[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],SN=[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]}],kN=[{tfOpName:"EuclideanNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",defaultValue:!1}]},{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"SparseToDense",category:"normalization",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!0,notSupported:!0}]}],DN=[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}],TN=[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool[]"}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}],IN=[{tfOpName:"SparseFillEmptyRows",category:"sparse",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"denseShape",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}]},{tfOpName:"SparseReshape",category:"sparse",inputs:[{start:0,name:"inputIndices",type:"tensor"},{start:1,name:"inputShape",type:"tensor"},{start:2,name:"newShape",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SparseSegmentMean",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]},{tfOpName:"SparseSegmentSum",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]}],EN=[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}],CN=[{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}],AN=[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}];class LN{static get Instance(){return this._instance||(this._instance=new this)}constructor(){const e=[].concat(...[N,S,k,D,T,I,E,C,A,L,$,O,R,F,Y,z,B,P,H].map((e=>e.json)));this.opMappers=e.reduce(((e,t)=>(e[t.tfOpName]=t,e)),{})}transformGraph(e,t={}){const n=e.node,r=[],a=[],i=[],s=n.reduce(((e,t)=>(e[t.name]=this.mapNode(t),t.op.startsWith("Placeholder")?r.push(e[t.name]):"Const"===t.op?a.push(e[t.name]):null!=t.input&&0!==t.input.length||i.push(e[t.name]),e)),{});let o=[];const u=[];let l={},c={};null!=t&&(l=this.mapSignatureEntries(t.inputs),c=this.mapSignatureEntries(t.outputs));const p=Object.keys(s);p.forEach((e=>{const t=s[e];t.inputNames.forEach(((e,n)=>{const[r,,a]=lN(e),i=s[r];if(null!=i.outputs){const e=i.outputs.indexOf(a);if(-1!==e){const a=`${r}:${e}`;t.inputNames[n]=a}}t.inputs.push(i),i.children.push(t)}))})),0===Object.keys(c).length?p.forEach((e=>{const t=s[e];0===t.children.length&&u.push(t)})):Object.keys(c).forEach((e=>{const[t]=lN(e),n=s[t];null!=n&&(n.signatureKey=c[e],u.push(n))})),Object.keys(l).length>0?Object.keys(l).forEach((e=>{const[t]=lN(e),n=s[t];n&&(n.signatureKey=l[e],o.push(n))})):o=r;let d={};null!=e.library&&null!=e.library.function&&(d=e.library.function.reduce(((e,t)=>(e[t.signature.name]=this.mapFunction(t),e)),{}));const h={nodes:s,inputs:o,outputs:u,weights:a,placeholders:r,signature:t,functions:d};return i.length>0&&(h.initNodes=i),h}mapSignatureEntries(e){return Object.keys(e||{}).reduce(((t,n)=>(t[e[n].name]=n,t)),{})}mapNode(e){const t=iN(e.op)||this.opMappers[e.op]||{};null==e.attr&&(e.attr={});const n={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map((e=>e.startsWith("^")?e.slice(1):e)),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return null!=t.inputs&&(n.inputParams=t.inputs.reduce(((e,t)=>(e[t.name]={type:t.type,inputIndexStart:t.start,inputIndexEnd:t.end},e)),{})),null!=t.attrs&&(n.attrParams=t.attrs.reduce(((t,n)=>{const r=n.type;let a;switch(n.type){case"string":a=ON(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=ON(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":a=qN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=qN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":a=FN(e.attr,n.tfName,n.defaultValue||0),void 0===a&&n.tfDeprecatedName&&(a=FN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":a=UN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=UN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":a=RN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=RN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":a=VN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=VN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":a=jN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=jN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":a=WN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=WN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":a=BN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=BN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":a=PN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=PN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":a=zN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=zN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${n.type} for op: ${e.op}`)}return t[n.name]={value:a,type:r},t}),{})),n}mapFunction(e){const t=e.nodeDef,n=[];let r={};null!=t&&(r=t.reduce(((e,t)=>(e[t.name]=this.mapNode(t),"Const"===t.op&&n.push(e[t.name]),e)),{}));const a=[],i=[];e.signature.inputArg.forEach((e=>{const[t]=lN(e.name),n={name:t,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:YN(e.type),type:"dtype"}},children:[]};n.signatureKey=e.name,a.push(n),r[t]=n})),Object.keys(r).forEach((e=>{const t=r[e];t.inputNames.forEach(((e,n)=>{const[a,,i]=lN(e),s=r[a];if(null!=s.outputs){const e=s.outputs.indexOf(i);if(-1!==e){const r=`${a}:${e}`;t.inputNames[n]=r}}t.inputs.push(s),s.children.push(t)}))}));const s=e.ret;e.signature.outputArg.forEach((e=>{const[t,n]=lN(s[e.name]),a=r[t];null!=a&&(a.defaultOutput=n,i.push(a))}));const o=this.mapArgsToSignature(e);return{nodes:r,inputs:a,outputs:i,weights:n,placeholders:[],signature:o}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce(((e,t)=>(e[t.name]=this.mapArgToTensorInfo(t),e)),{}),outputs:e.signature.outputArg.reduce(((t,n)=>(t[n.name]=this.mapArgToTensorInfo(n,e.ret),t)),{})}}mapArgToTensorInfo(e,t){let n=e.name;return null!=t&&(n=t[n]),{name:n,dtype:e.type}}}function $N(e,t){const n=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){const t=Ge().global;if(void 0!==t.atob)return t.atob(e);if("undefined"!=typeof Buffer)return new Buffer(e,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(e);return t?n:n.toLowerCase()}function ON(e,t,n,r=!1){const a=e[t];return null!=a?$N(a.s,r):n}function RN(e,t,n){const r=e[t];return r?r.b:n}function FN(e,t,n){const r=e[t]||{},a=null!=r.i?r.i:null!=r.f?r.f:n;return"number"==typeof a?a:parseInt(a,10)}function YN(e){switch("string"==typeof e&&(e=tN[e]),e){case tN.DT_FLOAT:case tN.DT_HALF:return"float32";case tN.DT_INT32:case tN.DT_INT64:case tN.DT_INT8:case tN.DT_UINT8:return"int32";case tN.DT_BOOL:return"bool";case tN.DT_DOUBLE:return"float32";case tN.DT_STRING:return"string";default:return null}}function zN(e,t,n){const r=e[t];return r&&r.func?r.func.name:n}function BN(e,t,n){const r=e[t];return r&&r.type?YN(r.type):n}function PN(e,t,n){const r=e[t];return r&&r.list&&r.list.type?r.list.type.map((e=>YN(e))):n}function HN(e){if(!e.unknownRank)return null!=e.dim?e.dim.map((e=>"number"==typeof e.size?e.size:parseInt(e.size,10))):[]}function jN(e,t,n){const r=e[t];return r&&r.shape?HN(r.shape):n}function UN(e,t,n){const r=e[t];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map((e=>"number"==typeof e?e:parseInt(e,10))):n}function qN(e,t,n,r=!1){const a=e[t];return a&&a.list&&a.list.s?a.list.s.map((e=>$N(e,r))):n}function WN(e,t,n){const r=e[t];return r&&r.list&&r.list.shape?r.list.shape.map((e=>HN(e))):n}function VN(e,t,n){const r=e[t];return r&&r.list&&r.list.b?r.list.b:n}class GN{constructor(e,t,n){this.node=e,this.tensorMap=t,this.context=n,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map((e=>this.getInput(e))),null!=e.rawAttrs&&(this.attrs=Object.keys(e.rawAttrs).reduce(((e,t)=>(e[t]=this.getAttr(t),e)),{}))}getInput(e){return uN(e,this.tensorMap,this.context)}getAttr(e,t){const n=this.node.rawAttrs[e];if(null!=n.tensor)return uN(e,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return FN(this.node.rawAttrs,e,t);if(null!=n.s)return ON(this.node.rawAttrs,e,t);if(null!=n.b)return RN(this.node.rawAttrs,e,t);if(null!=n.shape)return jN(this.node.rawAttrs,e,t);if(null!=n.type)return BN(this.node.rawAttrs,e,t);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return UN(this.node.rawAttrs,e,t);if(null!=n.list.s)return qN(this.node.rawAttrs,e,t);if(null!=n.list.shape)return WN(this.node.rawAttrs,e,t);if(null!=n.list.b)return VN(this.node.rawAttrs,e,t);if(null!=n.list.type)return PN(this.node.rawAttrs,e,t)}return t}}function KN(e,t,n=""){if("number"!=typeof e&&"number"!=typeof t){se(e.length===t.length,(()=>n+` Shapes ${e} and ${t} must match`));for(let r=0;rn+` Shapes ${e} and ${t} must match`))}}}function JN(e){return"number"!=typeof e&&!e.some((e=>e<0))}function XN(e,t,n){let r=ZN(e,n);const a=!JN(r);if(a&&0===t.length)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${r}`);if(a&&t.forEach((e=>{r=ZN(e.shape,r)})),!JN(r))throw new Error(`Non-fully-defined elementShape: ${r}`);return r}function ZN(e,t){if("number"==typeof e)return t;if("number"==typeof t)return e;if(e.length!==t.length)throw new Error(`Incompatible ranks during merge: ${e} vs. ${t}`);const n=[];for(let r=0;r=0&&i>=0&&a!==i)throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`);n[r]=a>=0?a:i}return n}class QN{constructor(e,t,n,r,a,i,s){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=r,this.identicalElementShapes=a,this.dynamicSize=i,this.clearAfterRead=s,this.tensors=[],this.closed_=!1,this.idTensor=Ru(0),mo(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.tensor.id)||t.tensor.dispose()})),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(e){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||e>=this.size())throw new Error(`Tried to read from index ${e}, but array size is: ${this.size()}`);const t=this.tensors[e];if(t.cleared)throw new Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(t.cleared=!0),t.read=!0,t.tensor}readMany(e){return e.map((e=>this.read(e)))}write(e,t){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||!this.dynamicSize&&e>=this.maxSize)throw new Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`);const n=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e},\n because the value dtype is ${t.dtype}, but TensorArray dtype is ${this.dtype}.`);if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=t.shape),KN(this.elementShape,t.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${e}.`),n.read)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`);if(n.written)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`);n.tensor=t,mo(t),n.written=!0,this.tensors[e]=n}writeMany(e,t){if(e.length!==t.length)throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t.length}.`);e.forEach(((e,n)=>this.write(e,t[n])))}gather(e,t){if(t&&t!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`);if(e)e=e.slice(0,this.size());else{e=[];for(let t=0;t=this.maxSize)throw new Error(`Max index must be < array size (${n} vs. ${this.maxSize})`);this.writeMany(e,kd(t,0))}split(e,t){if(t.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);let n=0;const r=e.map((e=>(n+=e,n)));if(n!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${n}, and tensor's shape is: ${t.shape}`);if(!this.dynamicSize&&e.length!==this.maxSize)throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${e.length}), and the TensorArray is not marked as dynamically resizeable`);const a=0===n?0:t.size/n,i=[];ho((()=>{t=Ml(t,[1,n,a]);for(let n=0;n{if(n!==e.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${e.dtype}`);KN(t,e.shape,"TensorList shape mismatch: "),mo(e)})),this.idTensor=Ru(0),this.maxNumElements=r,mo(this.idTensor)}get id(){return this.idTensor.id}copy(){return new eS([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.id)||t.dispose()})),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(e,t,n=-1){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(-1!==n&&this.tensors.length!==n)throw new Error(`Operation expected a list with ${n} elements but got a list with ${this.tensors.length} elements.`);KN(e,this.elementShape,"TensorList shape mismatch: ");const r=XN(this.elementShape,this.tensors,e);return ho((()=>{const e=this.tensors.map((e=>Ml(e,r)));return hd(e,0)}))}popBack(e,t){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(0===this.size())throw new Error("Trying to pop from an empty list.");const n=XN(this.elementShape,this.tensors,e),r=this.tensors.pop();return KN(r.shape,e,"TensorList shape mismatch: "),Ml(r,n)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(KN(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");mo(e),this.tensors.push(e)}resize(e){if(e<0)throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`);if(-1!==this.maxNumElements&&e>this.maxNumElements)throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`);const t=new eS([],this.elementShape,this.elementDtype,this.maxNumElements);t.tensors.length=e;for(let n=0;nthis.tensors.length)throw new Error(`Trying to access element ${e} in a list with ${this.tensors.length} elements.`);if(null==this.tensors[e])throw new Error(`element at index ${e} is null.`);KN(this.tensors[e].shape,t,"TensorList shape mismatch: ");const r=XN(this.elementShape,this.tensors,t);return Ml(this.tensors[e],r)}setItem(e,t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||-1!==this.maxNumElements&&e>=this.maxNumElements)throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);KN(this.elementShape,t.shape,"TensorList shape mismatch: "),mo(t),this.tensors[e]=t}gather(e,t,n){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);KN(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());const r=XN(this.elementShape,this.tensors,n);return 0===e.length?Fi([],[0].concat(r)):ho((()=>{const t=e.map((e=>Ml(this.tensors[e],r)));return hd(t,0)}))}concat(e,t){if(e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);KN(this.elementShape,t,"TensorList shape mismatch: ");const n=XN(this.elementShape,this.tensors,t);return 0===this.size()?Fi([],[0].concat(n)):ho((()=>{const e=this.tensors.map((e=>Ml(e,n)));return kl(e,0)}))}}function tS(e,t,n){const[r,a]=oN("fusedOps",e,t,n),i="biasadd"===r,s=!i,o="prelu"===a,u="fusedbatchnorm"===r,l=oN("numArgs",e,t,n);if(i){if(o&&2!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&i&&1!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(u)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");const c=oN("strides",e,t,n),p=dN(e,t,n),d=oN("dataFormat",e,t,n).toUpperCase(),h=oN("dilations",e,t,n);let[f,m]=oN("args",e,t,n);return s&&(m=f,f=void 0),{stride:c,pad:p,dataFormat:d,dilations:h,biasArg:f,preluArg:m,activationFunc:a,leakyreluAlpha:oN("leakyreluAlpha",e,t,n)}}function nS(e,t,n){return{boxes:oN("boxes",e,t,n),scores:oN("scores",e,t,n),maxOutputSize:oN("maxOutputSize",e,t,n),iouThreshold:oN("iouThreshold",e,t,n),scoreThreshold:oN("scoreThreshold",e,t,n),softNmsSigma:oN("softNmsSigma",e,t,n)}}class rS{constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=Ru(0),this.tensorMap=new Map,mo(this.handle)}get id(){return this.handle.id}clearAndClose(){this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return Ru(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);const n=await e.data();return this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),ho((()=>{const e=kd(t),r=n.length,a=e.length;se(r===a,(()=>`The number of elements doesn't match, keys has ${r} elements, the values has ${a} elements.`));for(let t=0;t{const e=[];for(let r=0;r{switch(e.category){case"arithmetic":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[r.add(oN("a",e,t,n),oN("b",e,t,n))];case"AddN":return[r.addN(oN("tensors",e,t,n))];case"FloorMod":case"Mod":return[r.mod(oN("a",e,t,n),oN("b",e,t,n))];case"Mul":return[r.mul(oN("a",e,t,n),oN("b",e,t,n))];case"RealDiv":case"Div":return[r.div(oN("a",e,t,n),oN("b",e,t,n))];case"DivNoNan":return[r.divNoNan(oN("a",e,t,n),oN("b",e,t,n))];case"FloorDiv":return[r.floorDiv(oN("a",e,t,n),oN("b",e,t,n))];case"Sub":return[r.sub(oN("a",e,t,n),oN("b",e,t,n))];case"Minimum":return[r.minimum(oN("a",e,t,n),oN("b",e,t,n))];case"Maximum":return[r.maximum(oN("a",e,t,n),oN("b",e,t,n))];case"Pow":return[r.pow(oN("a",e,t,n),oN("b",e,t,n))];case"SquaredDifference":return[r.squaredDifference(oN("a",e,t,n),oN("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"basic_math":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Abs":case"ComplexAbs":return[r.abs(oN("x",e,t,n))];case"Acos":return[r.acos(oN("x",e,t,n))];case"Acosh":return[r.acosh(oN("x",e,t,n))];case"Asin":return[r.asin(oN("x",e,t,n))];case"Asinh":return[r.asinh(oN("x",e,t,n))];case"Atan":return[r.atan(oN("x",e,t,n))];case"Atan2":return[r.atan2(oN("x",e,t,n),oN("y",e,t,n))];case"Atanh":return[r.atanh(oN("x",e,t,n))];case"Ceil":return[r.ceil(oN("x",e,t,n))];case"Complex":return[r.complex(oN("real",e,t,n),oN("imag",e,t,n))];case"Cos":return[r.cos(oN("x",e,t,n))];case"Cosh":return[r.cosh(oN("x",e,t,n))];case"Elu":return[r.elu(oN("x",e,t,n))];case"Erf":return[r.erf(oN("x",e,t,n))];case"Exp":return[r.exp(oN("x",e,t,n))];case"Expm1":return[r.expm1(oN("x",e,t,n))];case"Floor":return[r.floor(oN("x",e,t,n))];case"Log":return[r.log(oN("x",e,t,n))];case"Log1p":return[r.log1p(oN("x",e,t,n))];case"Imag":return[r.imag(oN("x",e,t,n))];case"Neg":return[r.neg(oN("x",e,t,n))];case"Reciprocal":return[r.reciprocal(oN("x",e,t,n))];case"Real":return[r.real(oN("x",e,t,n))];case"Relu":return[r.relu(oN("x",e,t,n))];case"Round":return[r.round(oN("x",e,t,n))];case"Selu":return[r.selu(oN("x",e,t,n))];case"Sigmoid":return[r.sigmoid(oN("x",e,t,n))];case"Sin":return[r.sin(oN("x",e,t,n))];case"Sign":return[r.sign(oN("x",e,t,n))];case"Sinh":return[r.sinh(oN("x",e,t,n))];case"Softplus":return[r.softplus(oN("x",e,t,n))];case"Sqrt":return[r.sqrt(oN("x",e,t,n))];case"Square":return[r.square(oN("x",e,t,n))];case"Tanh":return[r.tanh(oN("x",e,t,n))];case"Tan":return[r.tan(oN("x",e,t,n))];case"ClipByValue":return[r.clipByValue(oN("x",e,t,n),oN("clipValueMin",e,t,n),oN("clipValueMax",e,t,n))];case"Relu6":return[r.relu6(oN("x",e,t,n))];case"Rsqrt":return[r.rsqrt(uN(e.inputNames[0],t,n))];case"Prod":return[r.prod(oN("x",e,t,n),oN("axes",e,t,n))];case"LeakyRelu":return[r.leakyRelu(oN("x",e,t,n),oN("alpha",e,t,n))];case"Prelu":return[r.prelu(oN("x",e,t,n),oN("alpha",e,t,n))];case"IsNan":return[r.isNaN(uN(e.inputNames[0],t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"control":return(async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{const r=oN("thenBranch",e,t,n),a=oN("elseBranch",e,t,n),i=oN("cond",e,t,n),s=oN("args",e,t,n);return(await i.data())[0]?n.functionMap[r].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap):n.functionMap[a].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{const r=oN("body",e,t,n),a=oN("cond",e,t,n),i=oN("args",e,t,n),s=await n.functionMap[a].executeFunctionAsync(i,n.tensorArrayMap,n.tensorListMap),o=i.map((e=>e.id));let u=await s[0].data();s.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||e.dispose()}));let l=i;for(;u[0];){const e=l;l=await n.functionMap[r].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);const t=l.map((e=>e.id));e.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}));const i=await n.functionMap[a].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);u=await i[0].data(),i.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}))}return l}case"LoopCond":return[hN(oN("pred",e,t,n))];case"Switch":{const r=oN("pred",e,t,n);let a=oN("data",e,t,n);return a.kept||(a=hN(a)),(await r.data())[0]?[void 0,a]:[a,void 0]}case"Merge":{const r=e.inputNames.find((e=>void 0!==uN(e,t,n)));return r?[hN(uN(r,t,n))]:void 0}case"Enter":{const r=oN("frameName",e,t,n),a=oN("tensor",e,t,n);return n.enterFrame(r),[hN(a)]}case"Exit":{const r=oN("tensor",e,t,n);return n.exitFrame(),[hN(r)]}case"NextIteration":{const r=oN("tensor",e,t,n);return n.nextIteration(),[hN(r)]}case"TensorArrayV3":{const r=oN("size",e,t,n),a=oN("dtype",e,t,n),i=oN("elementShape",e,t,n),s=oN("dynamicSize",e,t,n),o=oN("clearAfterRead",e,t,n),u=oN("identicalElementShapes",e,t,n),l=oN("name",e,t,n),c=new QN(l,a,r,i,u,s,o);return n.addTensorArray(c),[c.idTensor,Ru(1)]}case"TensorArrayWriteV3":{const r=oN("tensorArrayId",e,t,n),a=oN("index",e,t,n),i=oN("tensor",e,t,n),s=n.getTensorArray(r.id);return s.write(a,i),[s.idTensor]}case"TensorArrayReadV3":{const r=oN("tensorArrayId",e,t,n),a=oN("index",e,t,n);return[n.getTensorArray(r.id).read(a)]}case"TensorArrayGatherV3":{const r=oN("tensorArrayId",e,t,n),a=oN("indices",e,t,n),i=oN("dtype",e,t,n);return[n.getTensorArray(r.id).gather(a,i)]}case"TensorArrayScatterV3":{const r=oN("tensorArrayId",e,t,n),a=oN("indices",e,t,n),i=oN("tensor",e,t,n),s=n.getTensorArray(r.id);return s.scatter(a,i),[s.idTensor]}case"TensorArrayConcatV3":{const r=oN("tensorArrayId",e,t,n),a=n.getTensorArray(r.id),i=oN("dtype",e,t,n);return[a.concat(i)]}case"TensorArraySplitV3":{const r=oN("tensorArrayId",e,t,n),a=oN("tensor",e,t,n),i=oN("lengths",e,t,n),s=n.getTensorArray(r.id);return s.split(i,a),[s.idTensor]}case"TensorArraySizeV3":{const r=oN("tensorArrayId",e,t,n);return[Ru(n.getTensorArray(r.id).size(),"int32")]}case"TensorArrayCloseV3":{const r=oN("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return a.clearAndClose(),[a.idTensor]}case"TensorListSetItem":{const r=oN("tensorListId",e,t,n),a=oN("index",e,t,n),i=oN("tensor",e,t,n),s=n.getTensorList(r.id);return s.setItem(a,i),[s.idTensor]}case"TensorListGetItem":{const r=oN("tensorListId",e,t,n),a=oN("index",e,t,n),i=oN("elementShape",e,t,n),s=oN("elementDType",e,t,n);return[n.getTensorList(r.id).getItem(a,i,s)]}case"TensorListScatterV2":case"TensorListScatter":{const r=oN("indices",e,t,n),a=function(e,t,n,r){if(t.length!==e.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);const a=Math.max(...t);if(null!=r&&-1!==r&&a>=r)throw new Error(`Max index must be < array size (${a} vs. ${r})`);const i=new eS([],n,e.dtype,r),s=kd(e,0);return t.forEach(((e,t)=>{i.setItem(e,s[t])})),i}(oN("tensor",e,t,n),r,oN("elementShape",e,t,n),oN("numElements",e,t,n));return n.addTensorList(a),[a.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const r=oN("elementShape",e,t,n),a=oN("elementDType",e,t,n);let i;i="TensorListReserve"===e.op?"numElements":"maxNumElements";const s=oN(i,e,t,n),o=function(e,t,n,r){return new eS([],e,t,r)}(r,a,0,"TensorListReserve"===e.op?-1:s);return n.addTensorList(o),[o.idTensor]}case"TensorListGather":{const r=oN("tensorListId",e,t,n),a=oN("indices",e,t,n),i=oN("elementShape",e,t,n),s=oN("elementDType",e,t,n);return[n.getTensorList(r.id).gather(a,s,i)]}case"TensorListStack":{const r=oN("tensorListId",e,t,n),a=oN("elementShape",e,t,n),i=oN("elementDType",e,t,n),s=oN("numElements",e,t,n);return[n.getTensorList(r.id).stack(a,i,s)]}case"TensorListFromTensor":{const r=function(e,t,n){const r=e.dtype;if(e.shape.length<1)throw new Error(`Tensor must be at least a vector, but saw shape: ${e.shape}`);if(e.dtype!==n)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${n}`);KN(e.shape.slice(1),t,"TensorList shape mismatch: ");const a=kd(e);return new eS(a,t,r)}(oN("tensor",e,t,n),oN("elementShape",e,t,n),oN("elementDType",e,t,n));return n.addTensorList(r),[r.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{const r=oN("tensorListId",e,t,n),a=n.getTensorList(r.id),i=oN("dtype",e,t,n),s=oN("elementShape",e,t,n);return[a.concat(i,s)]}case"TensorListPushBack":{const r=oN("tensorListId",e,t,n),a=oN("tensor",e,t,n),i=n.getTensorList(r.id);return i.pushBack(a),[i.idTensor]}case"TensorListPopBack":{const r=oN("tensorListId",e,t,n),a=oN("elementShape",e,t,n),i=oN("elementDType",e,t,n);return[n.getTensorList(r.id).popBack(a,i)]}case"TensorListSplit":{const r=oN("tensor",e,t,n),a=oN("elementShape",e,t,n),i=function(e,t,n){let r=0;const a=t.map((e=>(r+=e,r)));if(r!==e.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${r}, and tensor's shape is: ${e.shape}`);const i=ZN(e.shape.slice(1),n),s=0===r?0:e.size/r,o=ho((()=>{const n=[];e=Ml(e,[1,r,s]);for(let r=0;r((e,t,n,r=j)=>{switch(e.op){case"Conv1D":{const a=oN("stride",e,t,n),i=oN("pad",e,t,n),s=oN("dataFormat",e,t,n).toUpperCase(),o=oN("dilation",e,t,n);return[r.conv1d(oN("x",e,t,n),oN("filter",e,t,n),a,i,s,o)]}case"Conv2D":{const a=oN("strides",e,t,n),i=dN(e,t,n),s=oN("dataFormat",e,t,n).toUpperCase(),o=oN("dilations",e,t,n);return[r.conv2d(oN("x",e,t,n),oN("filter",e,t,n),[a[1],a[2]],i,s,[o[1],o[2]])]}case"_FusedConv2D":{const{stride:a,pad:i,dataFormat:s,dilations:o,biasArg:u,preluArg:l,activationFunc:c,leakyreluAlpha:p}=tS(e,t,n);return[r.fused.conv2d({x:oN("x",e,t,n),filter:oN("filter",e,t,n),strides:[a[1],a[2]],pad:i,dataFormat:s,dilations:[o[1],o[2]],bias:u,activation:c,preluActivationWeights:l,leakyreluAlpha:p})]}case"FusedDepthwiseConv2dNative":{const{stride:a,pad:i,dataFormat:s,dilations:o,biasArg:u,preluArg:l,activationFunc:c,leakyreluAlpha:p}=tS(e,t,n);return[r.fused.depthwiseConv2d({x:oN("x",e,t,n),filter:oN("filter",e,t,n),strides:[a[1],a[2]],pad:i,dataFormat:s,dilations:[o[1],o[2]],bias:u,activation:c,preluActivationWeights:l,leakyreluAlpha:p})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const a=oN("outputShape",e,t,n),i=oN("strides",e,t,n),s=dN(e,t,n);return[r.conv2dTranspose(oN("x",e,t,n),oN("filter",e,t,n),a,[i[1],i[2]],s)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const a=oN("strides",e,t,n),i=dN(e,t,n),s=oN("dilations",e,t,n),o=oN("dataFormat",e,t,n).toUpperCase();return[r.depthwiseConv2d(oN("input",e,t,n),oN("filter",e,t,n),[a[1],a[2]],i,o,[s[1],s[2]])]}case"Conv3D":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("dataFormat",e,t,n).toUpperCase(),o=oN("dilations",e,t,n);return[r.conv3d(oN("x",e,t,n),oN("filter",e,t,n),[a[1],a[2],a[3]],i,s,[o[1],o[2],o[3]])]}case"AvgPool":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n);return[r.avgPool(oN("x",e,t,n),[s[1],s[2]],[a[1],a[2]],i)]}case"MaxPool":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n);return[r.maxPool(oN("x",e,t,n),[s[1],s[2]],[a[1],a[2]],i)]}case"MaxPoolWithArgmax":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n),o=oN("includeBatchInIndex",e,t,n),{result:u,indexes:l}=r.maxPoolWithArgmax(oN("x",e,t,n),[s[1],s[2]],[a[1],a[2]],i,o);return[u,l]}case"AvgPool3D":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n);return[r.avgPool3d(oN("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],i)]}case"MaxPool3D":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n);return[r.maxPool3d(oN("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],i)]}case"Dilation2D":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("dilations",e,t,n),o=a[1],u=a[2],l=s[1],c=s[2];return[r.dilation2d(oN("x",e,t,n),oN("filter",e,t,n),[o,u],i,[l,c],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"creation":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Fill":{const a=oN("shape",e,t,n),i=oN("dtype",e,t,n),s=oN("value",e,t,n);return[r.fill(a,s,i)]}case"LinSpace":{const a=oN("start",e,t,n),i=oN("stop",e,t,n),s=oN("num",e,t,n);return[r.linspace(a,i,s)]}case"Multinomial":{const a=oN("logits",e,t,n),i=oN("numSamples",e,t,n),s=oN("seed",e,t,n);return[r.multinomial(a,i,s)]}case"OneHot":{const a=oN("indices",e,t,n),i=oN("depth",e,t,n),s=oN("onValue",e,t,n),o=oN("offValue",e,t,n);return[r.oneHot(a,i,s,o)]}case"Ones":return[r.ones(oN("shape",e,t,n),oN("dtype",e,t,n))];case"OnesLike":return[r.onesLike(oN("x",e,t,n))];case"RandomStandardNormal":return[r.randomStandardNormal(oN("shape",e,t,n),oN("dtype",e,t,n),oN("seed",e,t,n))];case"RandomUniform":return[r.randomUniform(oN("shape",e,t,n),oN("minval",e,t,n),oN("maxval",e,t,n),oN("dtype",e,t,n))];case"Range":{const a=oN("start",e,t,n),i=oN("stop",e,t,n),s=oN("step",e,t,n);return[r.range(a,i,s,oN("dtype",e,t,n))]}case"TruncatedNormal":{const a=oN("shape",e,t,n),i=oN("mean",e,t,n),s=oN("stdDev",e,t,n),o=oN("seed",e,t,n);return[r.truncatedNormal(a,i,s,oN("dtype",e,t,n),o)]}case"Zeros":return[r.zeros(oN("shape",e,t,n),oN("dtype",e,t,n))];case"ZerosLike":return[r.zerosLike(oN("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"dynamic":return(async(e,t,n,r,a=j)=>{switch(e.op){case"NonMaxSuppressionV5":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:o,scoreThreshold:u,softNmsSigma:l}=nS(e,t,n),c=await a.image.nonMaxSuppressionWithScoreAsync(r,i,s,o,u,l);return[c.selectedIndices,c.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:o,scoreThreshold:u}=nS(e,t,n),l=oN("padToMaxOutputSize",e,t,n),c=await a.image.nonMaxSuppressionPaddedAsync(r,i,s,o,u,l);return[c.selectedIndices,c.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:o,scoreThreshold:u}=nS(e,t,n);return[await a.image.nonMaxSuppressionAsync(r,i,s,o,u)]}case"Where":{const r=a.cast(oN("condition",e,t,n),"bool"),i=[await a.whereAsync(r)];return r.dispose(),i}case"ListDiff":return a.setdiff1dAsync(oN("x",e,t,n),oN("y",e,t,n));default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n);case"evaluation":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"LowerBound":{const a=oN("sortedSequence",e,t,n),i=oN("values",e,t,n);return[r.lowerBound(a,i)]}case"TopKV2":{const a=oN("x",e,t,n),i=oN("k",e,t,n),s=oN("sorted",e,t,n),o=r.topk(a,i,s);return[o.values,o.indices]}case"UpperBound":{const a=oN("sortedSequence",e,t,n),i=oN("values",e,t,n);return[r.upperBound(a,i)]}case"Unique":{const a=oN("x",e,t,n),i=r.unique(a);return[i.values,i.indices]}case"UniqueV2":{const a=oN("x",e,t,n),i=oN("axis",e,t,n),s=r.unique(a,i);return[s.values,s.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"image":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"ResizeBilinear":{const a=oN("images",e,t,n),i=oN("size",e,t,n),s=oN("alignCorners",e,t,n),o=oN("halfPixelCenters",e,t,n);return[r.image.resizeBilinear(a,[i[0],i[1]],s,o)]}case"ResizeNearestNeighbor":{const a=oN("images",e,t,n),i=oN("size",e,t,n),s=oN("alignCorners",e,t,n),o=oN("halfPixelCenters",e,t,n);return[r.image.resizeNearestNeighbor(a,[i[0],i[1]],s,o)]}case"CropAndResize":{const a=oN("image",e,t,n),i=oN("boxes",e,t,n),s=oN("boxInd",e,t,n),o=oN("cropSize",e,t,n),u=oN("method",e,t,n),l=oN("extrapolationValue",e,t,n);return[r.image.cropAndResize(a,i,s,o,u,l)]}case"ImageProjectiveTransformV3":{const a=oN("images",e,t,n),i=oN("transforms",e,t,n),s=oN("outputShape",e,t,n),o=oN("fillValue",e,t,n),u=oN("interpolation",e,t,n),l=oN("fillMode",e,t,n);return[r.image.transform(a,i,u.toLowerCase(),l.toLowerCase(),o,s)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"graph":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":const a=oN("default",e,t,n);return[uN(e.name,t,n)||a];case"Placeholder":return[uN(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":case"Snapshot":return[hN(oN("x",e,t,n))];case"IdentityN":return oN("x",e,t,n).map((e=>hN(e)));case"Shape":return[r.tensor1d(oN("x",e,t,n).shape,"int32")];case"ShapeN":return oN("x",e,t,n).map((e=>r.tensor1d(e.shape)));case"Size":return[r.scalar(oN("x",e,t,n).size,"int32")];case"Rank":return[r.scalar(oN("x",e,t,n).rank,"int32")];case"NoOp":return[r.scalar(1)];case"Print":const i=oN("x",e,t,n),s=oN("data",e,t,n),o=oN("message",e,t,n),u=oN("summarize",e,t,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(o);for(let e=0;e((e,t,n,r=j)=>{switch(e.op){case"Equal":return[r.equal(oN("a",e,t,n),oN("b",e,t,n))];case"NotEqual":return[r.notEqual(oN("a",e,t,n),oN("b",e,t,n))];case"Greater":return[r.greater(oN("a",e,t,n),oN("b",e,t,n))];case"GreaterEqual":return[r.greaterEqual(oN("a",e,t,n),oN("b",e,t,n))];case"Less":return[r.less(oN("a",e,t,n),oN("b",e,t,n))];case"LessEqual":return[r.lessEqual(oN("a",e,t,n),oN("b",e,t,n))];case"LogicalAnd":return[r.logicalAnd(oN("a",e,t,n),oN("b",e,t,n))];case"LogicalNot":return[r.logicalNot(oN("a",e,t,n))];case"LogicalOr":return[r.logicalOr(oN("a",e,t,n),oN("b",e,t,n))];case"Select":case"SelectV2":return[r.where(oN("condition",e,t,n),oN("a",e,t,n),oN("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"matrices":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[r.matMul(oN("a",e,t,n),oN("b",e,t,n),oN("transposeA",e,t,n),oN("transposeB",e,t,n))];case"Einsum":return[r.einsum(oN("equation",e,t,n),...oN("tensors",e,t,n))];case"Transpose":return[r.transpose(oN("x",e,t,n),oN("perm",e,t,n))];case"_FusedMatMul":const[a,i]=oN("fusedOps",e,t,n),s="biasadd"===a,o="prelu"===i,u=oN("numArgs",e,t,n),l=oN("leakyreluAlpha",e,t,n);if(s){if(o&&2!==u)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&1!==u)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[c,p]=oN("args",e,t,n);return[r.fused.matMul({a:oN("a",e,t,n),b:oN("b",e,t,n),transposeA:oN("transposeA",e,t,n),transposeB:oN("transposeB",e,t,n),bias:c,activation:i,preluActivationWeights:p,leakyreluAlpha:l})];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"normalization":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"EuclideanNorm":return[r.euclideanNorm(oN("x",e,t,n),oN("axis",e,t,n),oN("keepDims",e,t,n))];case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[r.batchNorm(oN("x",e,t,n),oN("mean",e,t,n),oN("variance",e,t,n),oN("offset",e,t,n),oN("scale",e,t,n),oN("epsilon",e,t,n))];case"LRN":return[r.localResponseNormalization(oN("x",e,t,n),oN("radius",e,t,n),oN("bias",e,t,n),oN("alpha",e,t,n),oN("beta",e,t,n))];case"Softmax":return[r.softmax(oN("x",e,t,n))];case"LogSoftmax":return[r.logSoftmax(oN("x",e,t,n))];case"SparseToDense":return[r.sparseToDense(oN("sparseIndices",e,t,n),oN("outputShape",e,t,n),oN("sparseValues",e,t,n),oN("defaultValue",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"reduction":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Max":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.max(oN("x",e,t,n),a,i)]}case"Mean":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.mean(oN("x",e,t,n),a,i)]}case"Min":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.min(oN("x",e,t,n),a,i)]}case"Sum":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.sum(oN("x",e,t,n),a,i)]}case"All":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.all(oN("x",e,t,n),a,i)]}case"Any":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.any(oN("x",e,t,n),a,i)]}case"ArgMax":{const a=oN("axis",e,t,n);return[r.argMax(oN("x",e,t,n),a)]}case"ArgMin":{const a=oN("axis",e,t,n);return[r.argMin(oN("x",e,t,n),a)]}case"Prod":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.prod(oN("x",e,t,n),a,i)]}case"Cumprod":{const a=oN("axis",e,t,n),i=oN("exclusive",e,t,n),s=oN("reverse",e,t,n);return[r.cumprod(oN("x",e,t,n),a,i,s)]}case"Cumsum":{const a=oN("axis",e,t,n),i=oN("exclusive",e,t,n),s=oN("reverse",e,t,n);return[r.cumsum(oN("x",e,t,n),a,i,s)]}case"Bincount":const a=oN("x",e,t,n),i=oN("weights",e,t,n),s=oN("size",e,t,n);return[r.bincount(a,i,s)];case"DenseBincount":{const a=oN("x",e,t,n),i=oN("weights",e,t,n),s=oN("size",e,t,n),o=oN("binaryOutput",e,t,n);return[r.denseBincount(a,i,s,o)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"slice_join":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"ConcatV2":case"Concat":{const a=oN("n",e,t,n),i=oN("axis",e,t,n);let s=oN("tensors",e,t,n);return s=s.slice(0,a),[r.concat(s,i)]}case"Gather":{const a=oN("x",e,t,n),i=oN("indices",e,t,n);return[r.gather(a,r.cast(i,"int32"),0)]}case"GatherV2":{const a=oN("axis",e,t,n),i=oN("batchDims",e,t,n),s=oN("x",e,t,n),o=oN("indices",e,t,n);return[r.gather(s,r.cast(o,"int32"),a,i)]}case"Reverse":{const a=oN("dims",e,t,n),i=[];for(let e=0;e{const a=oN("axis",e,t,n),i=oN("tensors",e,t,n),s=i[0].shape,o=r.squeeze(i[0]).shape,u=i.map((e=>{const t=de(e.shape,s);if(!t&&!de(r.squeeze(e).shape,o))throw new Error("the input tensors shape does not match");return t?e:r.reshape(e,s)}));return[r.stack(u,a)]}));case"Unpack":{const a=oN("axis",e,t,n),i=oN("tensor",e,t,n);return r.unstack(i,a)}case"Tile":{const a=oN("reps",e,t,n);return[r.tile(oN("x",e,t,n),a)]}case"Split":case"SplitV":{const a=oN("axis",e,t,n),i=oN("numOrSizeSplits",e,t,n),s=oN("x",e,t,n);return r.split(s,i,a)}case"ScatterNd":{const a=oN("indices",e,t,n),i=oN("values",e,t,n),s=oN("shape",e,t,n);return[r.scatterND(a,i,s)]}case"GatherNd":{const a=oN("x",e,t,n),i=oN("indices",e,t,n);return[r.gatherND(a,i)]}case"SparseToDense":{const a=oN("sparseIndices",e,t,n),i=oN("outputShape",e,t,n),s=oN("sparseValues",e,t,n),o=oN("defaultValue",e,t,n);return[r.sparseToDense(a,s,i,s.dtype===o.dtype?o:r.cast(o,s.dtype))]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"sparse":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"SparseFillEmptyRows":{const{outputIndices:a,outputValues:i,emptyRowIndicator:s,reverseIndexMap:o}=r.sparse.sparseFillEmptyRows(oN("indices",e,t,n),oN("values",e,t,n),oN("denseShape",e,t,n),oN("defaultValue",e,t,n));return[a,i,s,o]}case"SparseReshape":{const{outputIndices:a,outputShape:i}=r.sparse.sparseReshape(oN("inputIndices",e,t,n),oN("inputShape",e,t,n),oN("newShape",e,t,n));return[a,i]}case"SparseSegmentMean":return[r.sparse.sparseSegmentMean(oN("data",e,t,n),oN("indices",e,t,n),oN("segmentIds",e,t,n))];case"SparseSegmentSum":return[r.sparse.sparseSegmentSum(oN("data",e,t,n),oN("indices",e,t,n),oN("segmentIds",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"spectral":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"FFT":return[r.fft(oN("x",e,t,n))];case"IFFT":return[r.ifft(oN("x",e,t,n))];case"RFFT":return[r.rfft(oN("x",e,t,n))];case"IRFFT":return[r.irfft(oN("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"string":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"StringNGrams":{const{nGrams:a,nGramsSplits:i}=r.string.stringNGrams(oN("data",e,t,n),oN("dataSplits",e,t,n),oN("separator",e,t,n),oN("nGramWidths",e,t,n),oN("leftPad",e,t,n),oN("rightPad",e,t,n),oN("padWidth",e,t,n),oN("preserveShortSequences",e,t,n));return[a,i]}case"StringSplit":{const{indices:a,values:i,shape:s}=r.string.stringSplit(oN("input",e,t,n),oN("delimiter",e,t,n),oN("skipEmpty",e,t,n));return[a,i,s]}case"StringToHashBucketFast":return[r.string.stringToHashBucketFast(oN("input",e,t,n),oN("numBuckets",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"transformation":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Cast":return[r.cast(oN("x",e,t,n),oN("dtype",e,t,n))];case"ExpandDims":{const a=oN("axis",e,t,n);return[r.expandDims(oN("x",e,t,n),a)]}case"Squeeze":{const a=oN("axis",e,t,n);return[r.squeeze(oN("x",e,t,n),a)]}case"Reshape":return[r.reshape(oN("x",e,t,n),oN("shape",e,t,n))];case"MirrorPad":return[r.mirrorPad(oN("x",e,t,n),oN("padding",e,t,n),oN("mode",e,t,n))];case"PadV2":case"Pad":return[r.pad(oN("x",e,t,n),oN("padding",e,t,n),oN("constantValue",e,t,n))];case"SpaceToBatchND":{const a=oN("blockShape",e,t,n),i=oN("paddings",e,t,n);return[r.spaceToBatchND(oN("x",e,t,n),a,i)]}case"BatchToSpaceND":{const a=oN("blockShape",e,t,n),i=oN("crops",e,t,n);return[r.batchToSpaceND(oN("x",e,t,n),a,i)]}case"DepthToSpace":{const a=oN("blockSize",e,t,n),i=oN("dataFormat",e,t,n).toUpperCase();return[r.depthToSpace(oN("x",e,t,n),a,i)]}case"BroadcastTo":return[r.broadcastTo(oN("x",e,t,n),oN("shape",e,t,n))];case"BroadcastArgs":return[r.broadcastArgs(oN("s0",e,t,n),oN("s1",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"hash_table":return(async(e,t,n,r)=>{switch(e.op){case"HashTable":case"HashTableV2":{const a=oN("keyDType",e,t,n),i=oN("valueDType",e,t,n),s=new rS(a,i);return r.addHashTable(e.name,s),[s.handle]}case"LookupTableImport":case"LookupTableImportV2":{const a=oN("tableHandle",e,t,n,r),i=oN("keys",e,t,n),s=oN("values",e,t,n),o=r.getHashTableById(a.id);return[await o.import(i,s)]}case"LookupTableFind":case"LookupTableFindV2":{const a=oN("tableHandle",e,t,n,r),i=oN("keys",e,t,n),s=oN("defaultValue",e,t,n),o=r.getHashTableById(a.id);return[await o.find(i,s)]}case"LookupTableSize":case"LookupTableSizeV2":{const a=oN("tableHandle",e,t,n,r);return[r.getHashTableById(a.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n,r);case"custom":const i=iN(e.op);if(i&&i.customExecutor)return i.customExecutor(new GN(e,t,n));throw TypeError(`Custom op ${e.op} is not registered.`);default:throw TypeError(`Unknown op '${e.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(e,t,n);return qe(i)?i.then((e=>[].concat(e))):[].concat(i)}class iS{constructor(e={},t={},n={},r={}){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=r,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){const e=[];for(let t=0;t0===e.id&&0===e.iterationId?"":`${e.frameName}-${e.iterationId}`)).join("/"):""}enterFrame(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))}exitFrame(){if(!(this.contexts&&this.contexts.length>1))throw new Error("Cannot exit frame, the context is empty");this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift()}nextIteration(){if(!(this.contexts&&this.contexts.length>0))throw new Error("Cannot increase frame iteration, the context is empty");{this.contexts=this.contexts.slice(),this.lastId++;const e=Object.assign({},this.contexts[this.contexts.length-1]);e.iterationId+=1,e.id=this.lastId,this.contexts.splice(-1,1,e),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}}getWeight(e){return this.weightMap[e]}addTensorArray(e){this.tensorArrayMap[e.id]=e}getTensorArray(e){return this.tensorArrayMap[e]}addTensorList(e){this.tensorListMap[e.id]=e}getTensorList(e){return this.tensorListMap[e]}dispose(e){for(const t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(const t in this.tensorListMap)this.tensorListMap[t].clearAndClose(e)}}function sS(e,t,n,r){const a=new Set,i=[];let s=null,o=null;const u=new Set,l=Object.keys(e).map((e=>pN(e)[0]));let c=[];null!=r&&(c=r.map((e=>pN(e.name)[0])));const p=[...t];for(;p.length>0;){const e=p.pop();(cS(e)||pS(e)||dS(e))&&null==s&&(s=e,o=s.children.map((e=>e.name)).filter((e=>a.has(e)))),a.add(e.name),null==n[e.name]&&-1===l.indexOf(e.name)&&-1===c.indexOf(e.name)&&(0!==e.inputs.length?e.inputs.forEach((e=>{u.has(e.name)||(u.add(e.name),p.push(e))})):i.push(e.name))}return{inputs:e,outputs:t,usedNodes:a,missingInputs:i,dynamicNode:s,syncInputs:o}}const oS=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],uS=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],lS=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function cS(e){return oS.indexOf(e.op)>=0}function pS(e){return uS.indexOf(e.op)>=0}function dS(e){return lS.indexOf(e.op)>=0}class hS{constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this.intermediateTensors={},this.keepTensorForDebug=!1,this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,null!=e.functions&&Object.keys(e.functions).forEach((t=>{this._functionExecutorMap[t]=new hS(e.functions[t],this)}))}get weightIds(){return this.parent?this.parent.weightIds:this._weightIds}get functionExecutorMap(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap}get weightMap(){return this.parent?this.parent.weightMap:this._weightMap}set weightMap(e){const t=Object.keys(e).map((t=>e[t].map((e=>e.id))));this._weightIds=[].concat(...t),this._weightMap=e}set resourceManager(e){this._resourceManager=e}get inputs(){return this._inputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get outputs(){return this._outputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get inputNodes(){return this._inputs.map((e=>e.signatureKey||e.name))}get outputNodes(){return this._outputs.map((e=>{const t=e.signatureKey||e.name;return e.defaultOutput?`${t}:${e.defaultOutput}`:t}))}get functions(){return Object.keys(this._functions).reduce(((e,t)=>(e[t]=this._functions[t].signature,e)),{})}getCompilationKey(e,t){const n=e.map((e=>e.name)).sort(),r=t.map((e=>e.name)).sort();return n.join(this.SEPERATOR)+"--"+r.join(this.SEPERATOR)}compile(e,t){const n=sS(e,t,this.weightMap,this._initNodes),{missingInputs:r,dynamicNode:a,syncInputs:i}=n;if(null!=a)throw new Error(`This execution contains the node '${a.name}', which has the dynamic op '${a.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${i}]`);if(r.length>0){const n=t.map((e=>e.name)),a=Object.keys(e);throw new Error(`Cannot compute the outputs [${n}] from the provided inputs [${a}]. Missing the following inputs: [${r}]`)}return function(e,t,n){const{usedNodes:r,inputs:a}=n,i=[],s=Object.keys(a).map((e=>pN(e)[0])).map((t=>e.nodes[t])),o=e.initNodes;s.forEach((e=>{r.has(e.name)&&i.push(e)})),e.weights.forEach((e=>{r.has(e.name)&&i.push(e)})),null!=o&&o.forEach((e=>{r.has(e.name)&&i.push(e)}));const u=new Set,l=[];for(;i.length>0;){const e=i.pop();u.add(e.name),t[e.name]||l.push(e),e.children.forEach((e=>{!u.has(e.name)&&r.has(e.name)&&e.inputs.every((e=>u.has(e.name)))&&i.push(e)}))}return l}(this.graph,this.weightMap,n)}execute(e,t){e=this.mapInputs(e);const n=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);const r=n.map((e=>this.graph.nodes[pN(e)[0]])),a=t.map((e=>pN(e)[0]));let i=a.map((e=>this.graph.nodes[e]));this.resetIntermediateTensors(),0===i.length&&(i=this._outputs);const s=this.getCompilationKey(r,i);let o=this.compiledMap.get(s);null==o&&(o=this.compile(e,i),this.compiledMap.set(s,o));const u={},l={};return ho((()=>{const n=new iS(this.weightMap,u,l,this.functionExecutorMap),r=Object.assign({},this.weightMap);Object.keys(e).forEach((t=>{const[n,a]=pN(t),i=[];i[a]=e[t],r[n]=i}));const i=this.getFrozenTensorIds(r),s={};for(let e=0;euN(e,r,n)))}))}getFrozenTensorIds(e){const t=[].concat.apply([],Object.keys(e).map((t=>e[t])).map((e=>e.map((e=>e.id)))));return new Set(t)}checkTensorForDisposal(e,t,n,r,a,i,s){"control"!==t.category&&-1===i.indexOf(e)&&(n[e].forEach((e=>{null!=e&&(s[e.id]=(s[e.id]||0)+t.children.length)})),t.inputs.forEach((e=>{if("control"!==e.category){const i=function(e,t,n){return t[cN(e,n.currentContextId)]}(e.name,n,r);null!=i&&i.forEach((e=>{if(e&&!e.kept&&!a.has(e.id)){const n=s[e.id];if(1===n){if(this.keepTensorForDebug){const[n,a]=lN(t.name,r);this.intermediateTensors[n]||(this.intermediateTensors[n]=[]),this.intermediateTensors[n][a]=e}else e.dispose();delete s[e.id]}else null!=n&&s[e.id]--}}))}})))}async executeAsync(e,t){return this._executeAsync(e,t)}disposeIntermediateTensors(){this.intermediateTensors&&(Object.keys(this.intermediateTensors).forEach((e=>this.intermediateTensors[e].forEach((e=>e.dispose())))),this.disposeTensorsMap())}disposeTensorsMap(){this.tensorsMap&&Object.keys(this.tensorsMap).forEach((e=>{this.tensorsMap[e].forEach((e=>{!e||e.kept||e.isDisposed||this.keepIds.has(e.id)||e.dispose()}))}))}getIntermediateTensors(){return this.tensorsMap}resetIntermediateTensors(){for(const e in this.intermediateTensors)this.intermediateTensors[e].forEach((e=>e.dispose())),delete this.intermediateTensors[e]}async _executeAsync(e,t,n=!1,r={},a={}){n||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));try{this.keepTensorForDebug=Ge().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){console.warn(e.message)}this.resetIntermediateTensors();const i=new iS(this.weightMap,r,a,this.functionExecutorMap);this.tensorsMap=await this.executeWithControlFlow(e,i,t,n);const s=t.map((e=>uN(e,this.tensorsMap,i))),o=s.map((e=>e.id)),u=Object.keys(e).map((t=>e[t].id));return this.keepIds=new Set([...o,...u,...this.weightIds]),this.keepTensorForDebug||this.disposeTensorsMap(),null==this.parent&&i.dispose(this.keepIds),s}async executeFunctionAsync(e,t,n){const r=e.reduce(((e,t,n)=>(e[this.inputs[n].name]=t,e)),{});return this._executeAsync(r,this.outputNodes,!0,t,n)}async executeWithControlFlow(e,t,n,r){const a=Object.keys(e),i=a.map((e=>this.graph.nodes[pN(e)[0]])),s=n.map((e=>pN(e)[0]));let o=s.map((e=>this.graph.nodes[e]));0===o.length&&(o=this._outputs);const{usedNodes:u,missingInputs:l,dynamicNode:c,syncInputs:p}=sS(e,o,this.weightMap,this._initNodes),d=[...i,...this.graph.weights,...this._initNodes||[]].map((e=>({node:e,contexts:t.currentContext}))),h=Object.assign({},this.weightMap);Object.keys(e).forEach((t=>{const[n,r]=pN(t),a=[];a[r]=e[t],h[n]=a}));const f={},m=this.getFrozenTensorIds(h),g={};for(;d.length>0;){const e=this.processStack(i,d,t,h,g,m,s,f,u);await Promise.all(e)}null!=c||r||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");const y=o.filter((e=>!cS(e)&&!uN(e.name,h,t))).map((e=>e.name));if(y.length>0){let e="";throw null!=c&&(e=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${p}]`),new Error(`Cannot compute the outputs [${y}] from the provided inputs [${a}]. Consider providing the following inputs: [${l}]. ${e}`)}return h}processStack(e,t,n,r,a,i,s,o,u){const l=[];for(;t.length>0;){const e=t.pop();n.currentContext=e.contexts;let c="";if("Enter"===e.node.op&&oN("isConstant",e.node,r,n)&&([c]=lN(e.node.name,n)),null==r[e.node.name]){const p=aS(e.node,r,n,this._resourceManager);c||([c]=lN(e.node.name,n));const d=n.currentContext;qe(p)?l.push(p.then((l=>(r[c]=l,n.currentContext=d,this.checkTensorForDisposal(c,e.node,r,n,i,s,o),this.processChildNodes(e.node,t,n,r,a,u),l)))):(r[c]=p,this.checkTensorForDisposal(c,e.node,r,n,i,s,o),this.processChildNodes(e.node,t,n,r,a,u))}else this.processChildNodes(e.node,t,n,r,a,u)}return l}processChildNodes(e,t,n,r,a,i){e.children.forEach((e=>{const[s]=lN(e.name,n);!a[s]&&i.has(e.name)&&("Merge"===e.op?e.inputNames.some((e=>!!uN(e,r,n)))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})):e.inputNames.every((e=>!!uN(e,r,n)))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})))}))}dispose(){Object.keys(this.weightMap).forEach((e=>this.weightMap[e].forEach((e=>e.dispose()))))}checkInputShapeAndType(e){Object.keys(e).forEach((t=>{const n=e[t],[r]=pN(t),a=this.graph.nodes[r];if(a.attrParams.shape&&a.attrParams.shape.value){const e=a.attrParams.shape.value,t=e.length===n.shape.length&&n.shape.every(((t,n)=>-1===e[n]||e[n]===t));se(t,(()=>`The shape of dict['${a.name}'] provided in model.execute(dict) must be [${e}], but was [${n.shape}]`))}a.attrParams.dtype&&a.attrParams.dtype.value&&se(n.dtype===a.attrParams.dtype.value,(()=>`The dtype of dict['${a.name}'] provided in model.execute(dict) must be ${a.attrParams.dtype.value}, but was ${n.dtype}`))}))}mapInputs(e){const t={};for(const n in e)null!=this._signature&&null!=this._signature.inputs&&null!=this._signature.inputs[n]?t[this._signature.inputs[n].name]=e[n]:t[n]=e[n];return t}checkInputs(e){const t=Object.keys(e).filter((e=>{const[t]=pN(e);return null==this.graph.nodes[t]}));if(t.length>0)throw new Error(`The dict provided in model.execute(dict) has keys: [${t}] that are not part of graph`)}mapOutputs(e){return e.map((e=>null!=this._signature&&null!=this._signature.outputs&&null!=this._signature.outputs[e]?this._signature.outputs[e].name:e),{})}checkOutputs(e){e.forEach((e=>{const[t]=pN(e);if(!this.graph.nodes[t])throw new Error(`The output '${e}' is not found in the graph`)}))}}class fS{constructor(e={},t={}){this.hashTableNameToHandle=e,this.hashTableMap=t}addHashTable(e,t){this.hashTableNameToHandle[e]=t.handle,this.hashTableMap[t.id]=t}getHashTableHandleByName(e){return this.hashTableNameToHandle[e]}getHashTableById(e){return this.hashTableMap[e]}dispose(){for(const e in this.hashTableMap)this.hashTableMap[e].clearAndClose(),delete this.hashTableMap[e];for(const e in this.hashTableNameToHandle)this.hashTableNameToHandle[e].dispose(),delete this.hashTableNameToHandle[e]}}class mS{constructor(e,t={},n=i){this.modelUrl=e,this.loadOptions=t,this.version="n/a",this.io=n,null==t&&(this.loadOptions={}),this.resourceManager=new fS}get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}get modelStructuredOutputKeys(){return this.structuredOutputKeys}findIOHandler(){const e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=this.io.browserHTTPRequest(e,this.loadOptions);else{const t=this.io.getLoadHandlers(e,this.loadOptions);if(0===t.length)t.push(this.io.browserHTTPRequest(e,this.loadOptions));else if(t.length>1)throw new Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`);this.handler=t[0]}}load(){if(this.findIOHandler(),null==this.handler.load)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const e=this.handler.load();return qe(e)?e.then((e=>this.loadSync(e))):this.loadSync(e)}loadSync(e){this.artifacts=e;const t=this.artifacts.modelTopology;let n=this.artifacts.signature;if(null!=this.artifacts.userDefinedMetadata){const e=this.artifacts.userDefinedMetadata;null!=e.signature&&(n=e.signature),null!=e.structuredOutputKeys&&(this.structuredOutputKeys=e.structuredOutputKeys)}this.signature=n,this.version=`${t.versions.producer}.${t.versions.minConsumer}`;const r=this.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new hS(LN.Instance.transformGraph(t,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),this.executor.resourceManager=this.resourceManager,null!=e.modelInitializer&&null!=e.modelInitializer.node){const t=LN.Instance.transformGraph(e.modelInitializer);this.initializer=new hS(t),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0}async save(e,t){if("string"==typeof e){const t=this.io.getSaveHandlers(e);if(0===t.length)throw new Error(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new Error(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return e.save(this.artifacts)}predict(e,t){const n=this.execute(e,this.outputNodes);if(this.structuredOutputKeys){const e={};return(n instanceof ti?[n]:n).forEach(((t,n)=>e[this.structuredOutputKeys[n]]=t)),e}return n}normalizeInputs(e){if(!(e instanceof ti||Array.isArray(e)))return e;if((e=Array.isArray(e)?e:[e]).length!==this.inputNodes.length)throw new Error(`Input tensor count mismatch,the graph model has ${this.inputNodes.length} placeholders, while there are ${e.length} input tensors.`);return this.inputNodes.reduce(((t,n,r)=>(t[n]=e[r],t)),{})}normalizeOutputs(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}execute(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=this.executor.execute(e,t);return n.length>1?n:n[0]}async executeAsync(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=await this.executor.executeAsync(e,t);return n.length>1?n:n[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(e){return Object.keys(e).reduce(((t,n)=>(t[n]=[e[n]],t)),{})}dispose(){this.executor.dispose(),this.initializer&&this.initializer.dispose(),this.resourceManager.dispose()}}async function gS(e,t={},n=i){if(null==e)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");null==t&&(t={}),t.fromTFHub&&"string"==typeof e&&(e=function(e){return e.endsWith("/")||(e+="/"),`${e}model.json?tfjs-format=file`}(e));const r=new mS(e,t,n);return await r.load(),r}function yS(e){if(null==e)throw new Error("modelUrl in loadGraphModelSync() cannot be null. Please provide a url or an IOHandler that loads the model");if(!e.load)throw new Error(`modelUrl IO Handler ${e} has no load function`);const t=new mS(e);return t.load(),t}const bS="3.19.0";function xS(e,t,n=new Map,r=new Set){if(null==e)return null;if("function"==typeof Blob&&e instanceof Blob)return e.slice();if(r.has(e))throw new Error("Circular references are not supported.");if(n.has(e))return n.get(e);const a=t(e);if(a.recurse&&null!==a.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(a.recurse){if(NS(e)){const a=Array.isArray(e)?[]:{};r.add(e);for(const i in e){const s=xS(e[i],t,n,r);a[i]=s}return r.delete(e),e.__proto__&&(a.__proto__=e.__proto__),a}throw new Error(`Can't recurse into non-iterable type: ${e}`)}return n.set(e,a.value),a.value}function vS(e,t=wS){return _S(e,t)}function _S(e,t,n=new Set){const r=e[0];if(n.has(r))throw new Error("Circular references are not supported.");const a=t(e);if(a.recurse&&null!==a.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(a.recurse){if(NS(r)){const a=Array.isArray(r)?[]:{};n.add(r);for(const i in r){const r=_S(e.map((e=>e[i])),t,n);a[i]=r}return n.delete(r),a}throw new Error(`Can't recurse into non-iterable type: ${r}`)}return a.value}function wS(e){return null===e?null:NS(e[0])?{value:null,recurse:!0}:{value:e,recurse:!1}}async function MS(e,t){const n=new Map;xS(e,t,n);for(const e of Array.from(n.keys())){const t=n.get(e);if(qe(t)){const r=await t;n.set(e,r)}}return xS(e,t,n)}function NS(e){let t=!1;if(Ge().get("IS_BROWSER"))t=e instanceof TextDecoder;else{const{StringDecoder:r}=n(4977);t=e instanceof r}return null!=e&&!ArrayBuffer.isView(e)&&(Array.isArray(e)||"object"==typeof e&&!(e instanceof ti)&&!(e instanceof Promise)&&!t)}function SS(e){return e instanceof ti?{value:e.clone(),recurse:!1}:NS(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}class kS{constructor(e){if(this.capacity=e,this.begin=0,this.end=0,null==e)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(e<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(e),this.doubledCapacity=2*e}wrap(e){for(;e<0;)e+=this.doubledCapacity;return e%this.doubledCapacity}get(e){if(e<0)throw new RangeError("Can't get item at a negative index.");return this.data[e%this.capacity]}set(e,t){if(e<0)throw new RangeError("Can't set item at a negative index.");this.data[e%this.capacity]=t}length(){let e=this.end-this.begin;return e<0&&(e=this.doubledCapacity+e),e}isFull(){return this.length()===this.capacity}isEmpty(){return 0===this.length()}push(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,e),this.end=this.wrap(this.end+1)}pushAll(e){for(const t of e)this.push(t)}pop(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);const e=this.get(this.end);return this.set(this.end,void 0),e}unshift(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,e)}shift(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const e=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),e}shuffleExcise(e){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const t=this.wrap(this.begin+e),n=this.get(t);return this.set(t,this.pop()),n}}class DS extends kS{constructor(){super(DS.INITIAL_CAPACITY)}isFull(){return!1}push(e){super.isFull()&&this.expand(),super.push(e)}unshift(e){super.isFull()&&this.expand(),super.unshift(e)}expand(){const e=2*this.capacity,t=new Array(e),n=this.length();for(let e=0;e!0===e))}rowMajorBatch(e,t=!0){return new RS(this,e,t)}columnMajorBatch(e,t=!0,n=wS){return this.rowMajorBatch(e,t).map((e=>vS(e,n)))}concatenate(e,t){return new jS(TS([this,e]),t)}take(e){return e<0||null==e?this:new OS(this,e)}skip(e){return e<0||null==e?this:new $S(this,e)}prefetch(e){return new WS(this,e)}shuffle(e,t){return new VS(this,e,t)}serial(){return new LS(this)}}class CS extends ES{constructor(e){super(),this.items=e,this.trav=0}summary(){return`Array of ${this.items.length} items`}async next(){if(this.trav>=this.items.length)return{value:null,done:!0};const e=this.items[this.trav];return this.trav++,{value:(t=e,function(e,t){return xS(e,t)}(t,SS)),done:!1};var t}}class AS extends ES{constructor(e){super(),this.nextFn=e}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(e){throw e.message=`Error thrown while iterating through a dataset: ${e.message}`,e}}}class LS extends ES{constructor(e){super(),this.upstream=e,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Serial`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){return this.upstream.next()}}class $S extends ES{constructor(e,t){super(),this.upstream=e,this.maxCount=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Skip`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;this.count++ Take`}async next(){return this.count++>=this.maxCount?{value:null,done:!0}:this.upstream.next()}}class RS extends ES{constructor(e,t,n=!0){super(),this.upstream=e,this.batchSize=t,this.enableSmallLastBatch=n,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> RowMajorBatch`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){const e=[];for(;e.length0?{value:e,done:!1}:{value:null,done:!0};e.push(t.value)}return{value:e,done:!1}}}class FS extends ES{constructor(e,t){super(),this.upstream=e,this.predicate=t,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Filter`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;){const e=await this.upstream.next();if(e.done||this.predicate(e.value))return e;fo(e.value)}}}class YS extends ES{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Map`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const t=mi(e.value),n=this.transform(e.value),r=mi(n);for(const e of t)fi(e,r)||e.dispose();return{value:n,done:!1}}}class zS extends ES{constructor(e,t){super(),this.upstream=e,this.handler=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> handleErrors`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;)try{return await this.upstream.next()}catch(e){if(!this.handler(e))return{value:null,done:!0}}}}class BS extends ES{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> AsyncMap`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const t=mi(e.value),n=await this.transform(e.value),r=mi(n);for(const e of t)fi(e,r)||e.dispose();return{value:n,done:!1}}}class PS extends ES{constructor(){super(),this.outputQueue=new DS,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;0===this.outputQueue.length();)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}}class HS extends PS{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Flatmap`}async pump(){const e=await this.upstream.next();if(e.done)return!1;const t=mi(e.value),n=this.transform(e.value),r=mi(n);this.outputQueue.pushAll(n);for(const e of t)fi(e,r)||e.dispose();return!0}}class jS extends ES{constructor(e,t){super(),this.baseErrorHandler=t,this.lastRead=null,this.iterator=null,this.moreIterators=e}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(e){if(await e,null==this.iterator){const e=await this.moreIterators.next();if(e.done)return{value:null,done:!0};this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}const t=await this.iterator.next();return t.done?(this.iterator=null,this.readFromChain(e)):t}}var US;!function(e){e[e.FAIL=0]="FAIL",e[e.SHORTEST=1]="SHORTEST",e[e.LONGEST=2]="LONGEST"}(US||(US={}));class qS extends ES{constructor(e,t=US.FAIL){super(),this.iterators=e,this.mismatchMode=t,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(e){await e;let t=0,n=0;const r=await MS(this.iterators,(function(e){return e instanceof ES?{value:e.next().then((e=>(t++,e.done&&n++,e.value))),recurse:!1}:{value:null,recurse:!0}}));if(t===n)return{value:null,done:!0};if(n>0)switch(this.mismatchMode){case US.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case US.SHORTEST:return{value:null,done:!0};case US.LONGEST:}return this.count++,{value:r,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class WS extends ES{constructor(e,t){super(),this.upstream=e,this.bufferSize=t,this.buffer=new kS(t)}summary(){return`${this.upstream.summary()} -> Prefetch`}refill(){for(;!this.buffer.isFull();){const e=this.upstream.next();this.buffer.push(e)}}next(){return this.refill(),this.buffer.shift()}}class VS extends WS{constructor(e,t,n){super(e,t),this.upstream=e,this.windowSize=t,this.upstreamExhausted=!1,this.random=Ep.alea(n||za().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}randomInt(e){return Math.floor(this.random()*e)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){const e=this.chooseIndex(),t=await this.buffer.shuffleExcise(e);if(!t.done)return this.refill(),t;this.upstreamExhausted=!0}return{value:null,done:!0}}}class GS{constructor(){this.size=null}batch(e,t=!0){const n=this;let r;return se(e>0,(()=>`batchSize needs to be positive, but it is\n ${e}`)),r=this.size===1/0||null==this.size?this.size:t?Math.ceil(this.size/e):Math.floor(this.size/e),KS((async()=>(await n.iterator()).columnMajorBatch(e,t,ZS)),r)}concatenate(e){const t=this;let n;return n=this.size===1/0||e.size===1/0?1/0:null!=this.size&&null!=e.size?this.size+e.size:null,KS((async()=>(await t.iterator()).concatenate(await e.iterator())),n)}filter(e){const t=this;let n;return n=this.size===1/0?1/0:null,KS((async()=>(await t.iterator()).filter((t=>ho((()=>e(t)))))),n)}async forEachAsync(e){return(await this.iterator()).forEachAsync(e)}map(e){const t=this;return KS((async()=>(await t.iterator()).map((t=>ho((()=>e(t)))))),this.size)}mapAsync(e){const t=this;return KS((async()=>(await t.iterator()).mapAsync(e)),this.size)}prefetch(e){if(null==e)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");const t=this;return KS((async()=>(await t.iterator()).prefetch(e)),this.size)}repeat(e){const t=this;let n;return n=null!=this.size&&e>0?this.size*e:0===e?0:null!=this.size&&(void 0===e||e<0)?1/0:null,KS((async()=>{return n=IS((async()=>({value:await t.iterator(),done:!1}))).take(e),new jS(n,r);var n,r}),n)}skip(e){const t=this;let n;return n=null!=this.size&&e>=0&&this.size>=e?this.size-e:null!=this.size&&(this.size(await t.iterator()).skip(e)),n)}shuffle(e,t,n=!0){if(null==e||e<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);const r=this,a=Ep.alea(t||za().toString());return KS((async()=>{let t=a.int32();return n&&(t+=a.int32()),(await r.iterator()).shuffle(e,t.toString())}),this.size)}take(e){const t=this;let n;return n=null!=this.size&&this.size>e?e:null!=this.size&&this.size<=e?this.size:null,KS((async()=>(await t.iterator()).take(e)),n)}async toArray(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}}function KS(e,t=null){return new class extends GS{constructor(){super(...arguments),this.size=t}async iterator(){return e()}}}function JS(e){return KS((async()=>TS(e)),e.length)}function XS(e){if(!NS(e))throw new Error("The argument to zip() must be an object or array.");let t;if(Array.isArray(e))for(let n=0;nfunction(e,t=US.FAIL){return new qS(e,t)}(await MS(e,(e=>{if(e instanceof GS)return{value:e.iterator(),recurse:!1};if(NS(e))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})),US.SHORTEST)),t)}function ZS(e){if(null===e)return null;return null==(t=e[0])||null===(n=t)||"object"!=typeof n&&"function"!=typeof n||Array.isArray(t)||"object"==typeof t&&t instanceof ti||De(t)?{value:function(e){if(0===e.length)throw new Error("Can't make a batch of zero elements.");return e[0]instanceof ti?hd(e):Fi(e)}(e),recurse:!1}:{value:null,recurse:!0};var t,n}GS.MAX_BUFFER_SIZE=1e4;class QS extends GS{constructor(e){super(),this.input=e}async iterator(){const e=(await this.input.iterator()).decodeUTF8().split("\n").map((e=>(e.endsWith("\r")&&(e=e.slice(0,-1)),e)));return e}}const ek='"',tk=Symbol("out"),nk=Symbol("field"),rk=Symbol("quote"),ak=Symbol("quoteafterquote"),ik=Symbol("quoteinquote");class sk extends GS{constructor(e,t){super(),this.input=e,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new QS(e),t||(t={}),this.hasHeader=!1!==t.hasHeader,this.fullColumnNames=t.columnNames,this.columnConfigs=t.columnConfigs,this.configuredColumnsOnly=t.configuredColumnsOnly,t.delimWhitespace?(se(null==t.delimiter,(()=>"Delimiter should not be provided when delimWhitespace is true.")),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=t.delimiter?t.delimiter:","}async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){const e=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!e)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&e&&se(e.length===this.fullColumnNames.length,(()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+e.length.toString()+").")),this.fullColumnNames||(this.fullColumnNames=e);const t=this.fullColumnNames.reduce(((e,t)=>(e[t]=e[t]+1||1,e)),{}),n=Object.keys(t).filter((e=>t[e]>1));if(se(0===n.length,(()=>"Duplicate column names found: "+n.toString())),this.columnConfigs)for(const e of Object.keys(this.columnConfigs))if(-1===this.fullColumnNames.indexOf(e))throw new Error('The key "'+e+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").");this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){const e=await this.base.iterator(),t=await e.next();if(t.done)throw new Error("No data was found for CSV parsing.");const n=t.value;return this.parseRow(n,!1)}return null}async iterator(){this.columnNamesValidated||await this.setColumnNames();let e=await this.base.iterator();return this.hasHeader&&(e=e.skip(1)),e.map((e=>this.makeDataElement(e)))}makeDataElement(e){const t=this.parseRow(e),n={},r={};for(let a=0;a14||!Number.isInteger(t))throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`);if(this.numFrames=e.numFramesPerSpectrogram||43,this.sampleRateHz=e.sampleRateHz,this.columnTruncateLength=e.columnTruncateLength||this.fftSize,this.audioTrackConstraints=e.audioTrackConstraints,this.smoothingTimeConstant=e.smoothingTimeConstant||0,this.includeSpectrogram=!1!==e.includeSpectrogram,this.includeWaveform=!0===e.includeWaveform,!this.includeSpectrogram&&!this.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(e={}){if(!Ge().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");const t=new ok(e);return await t.start(),t}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})}catch(e){throw new Error(`Error thrown while initializing video stream: ${e.message}`)}if(!this.stream)throw new Error("Could not obtain audio from microphone.");const e=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new e,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`)}else this.sampleRateHz=this.audioContext.sampleRate;const t=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,t.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){if(this.isClosed)return{value:null,done:!0};let e,t;const n=await this.getAudioData();if(this.includeSpectrogram){const t=this.flattenQueue(n.freqDataQueue);e=this.getTensorFromAudioDataArray(t,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){const e=this.flattenQueue(n.timeDataQueue);t=this.getTensorFromAudioDataArray(e,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:e,waveform:t},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){const e=[],t=[];let n=0;return new Promise((r=>{const a=setInterval((()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&r({freqDataQueue:e,timeDataQueue:t}),e.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),t.push(this.timeData.slice())),++n===this.numFrames&&(clearInterval(a),r({freqDataQueue:e,timeDataQueue:t}))}),this.fftSize/this.sampleRateHz*1e3)}))}stop(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw new Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(e){const t=e[0].length,n=new Float32Array(e.length*t);return e.forEach(((e,r)=>n.set(e,r*t))),n}getTensorFromAudioDataArray(e,t){const n=new Float32Array(ce(t));return n.set(e,n.length-e.length),Fi(n,t)}}class uk extends ES{constructor(e,t){if(super(),this.webcamVideoElement=e,this.webcamConfig=t,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=yd([0],"int32"),this.webcamConfig.centerCrop){const e=1*this.webcamConfig.resizeWidth/this.webcamVideoElement.width,t=1*this.webcamConfig.resizeHeight/this.webcamVideoElement.height,n=(1-e)/2,r=(1-t)/2,a=n+e,i=t+r;this.cropBox=bd([r,n,i,a],[1,4])}else this.cropBox=bd([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(e,t={}){if(!Ge().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!e){if(e=document.createElement("video"),!t.resizeWidth||!t.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");e.width=t.resizeWidth,e.height=t.resizeHeight}const n=new uk(e,t);return await n.start(),n}async start(){this.webcamConfig.facingMode&&se("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(()=>`Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`));try{this.stream=await navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})}catch(e){throw e.message=`Error thrown while initializing video stream: ${e.message}`,e}if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(e){console.log(e),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise((e=>{this.webcamVideoElement.onloadedmetadata=()=>{e()}}))}async next(){if(this.isClosed)return{value:null,done:!0};let e;try{e=zo(this.webcamVideoElement)}catch(e){throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(e)}`)}if(!this.resize)return{value:e,done:!1};try{return{value:this.cropAndResizeFrame(e),done:!1}}catch(e){throw new Error(`Error thrown cropping the video: ${e.message}`)}finally{e.dispose()}}needToResize(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)}cropAndResizeFrame(e){return ho((()=>{const t=Ic(Ls(e,"float32"),0);let n;n=Uh.cropAndResize(t,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");const r=n.shape;return Ml(n,r.slice(1))}))}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach((e=>e.stop()));try{this.webcamVideoElement.srcObject=null}catch(e){console.log(e),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}}class lk{}class ck extends ES{split(e){return new pk(this,e)}}class pk extends ck{constructor(e,t){super(),this.upstream=e,this.impl=new dk(e,t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class dk extends PS{constructor(e,t){super(),this.upstream=e,this.separator=t,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){const e=await this.upstream.next();if(e.done)return""!==this.carryover&&(this.outputQueue.push(this.carryover),this.carryover="",!0);const t=e.value.split(this.separator);t[0]=this.carryover+t[0];for(const e of t.slice(0,-1))this.outputQueue.push(e);return this.carryover=t[t.length-1],!0}}class hk extends ES{decodeUTF8(){return new fk(this)}}class fk extends ck{constructor(e){super(),this.upstream=e,this.impl=new mk(e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class mk extends PS{constructor(e){if(super(),this.upstream=e,Ge().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{const{StringDecoder:e}=n(1601);this.decoder=new e("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){const e=await this.upstream.next();let t,n;return!e.done&&(t=e.value,n=Ge().get("IS_BROWSER")?this.decoder.decode(t,{stream:!0}):this.decoder.write(Buffer.from(t.buffer)),this.outputQueue.push(n),!0)}}class gk extends hk{constructor(e,t={}){super(),this.file=e,this.options=t,se(e instanceof Uint8Array||!!Ge().get("IS_BROWSER")&&(e instanceof File||e instanceof Blob),(()=>"FileChunkIterator only supports File, Blob and Uint8Array right now.")),this.offset=t.offset||0,this.chunkSize=t.chunkSize||1048576}summary(){return`FileChunks ${this.file}`}async next(){if(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))return{value:null,done:!0};const e=new Promise(((e,t)=>{const n=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)e(new Uint8Array(this.file.slice(this.offset,n)));else{const r=new FileReader;r.onload=n=>{let a=r.result;if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),!(a instanceof Uint8Array))return t(new TypeError("FileReader returned unknown type."));e(a)},r.onabort=e=>t(new Error("Aborted")),r.onerror=e=>t(new Error(e.type));const a=this.file.slice(this.offset,n);r.readAsArrayBuffer(a)}this.offset=n}));return{value:await e,done:!1}}}function yk(e){return"string"==typeof e&&"file://"===e.slice(0,7)}class bk extends lk{constructor(e,t={}){super(),this.input=e,this.options=t}async iterator(){if(yk(this.input)&&Ge().get("IS_NODE")){const e=n(7792);this.input=e.readFileSync(this.input.slice(7))}return new gk(this.input,this.options)}}class xk extends lk{constructor(e,t={}){super(),this.url=e,this.fileOptions=t}async iterator(){return yk(this.url)?new bk(this.url,this.fileOptions).iterator():async function(e,t={},n){let r,a;var i;"string"==typeof e?r=e:(r=e.url,a={method:(i=e).method,headers:i.headers,body:i.body,mode:i.mode,credentials:i.credentials,cache:i.cache,redirect:i.redirect,referrer:i.referrer,integrity:i.integrity});const s=await(n||Ba)(r,a);if(s.ok){const e=new Uint8Array(await s.arrayBuffer());return new gk(e,t)}throw new Error(s.statusText)}(this.url,this.fileOptions)}}function vk(e,t={}){return new sk(new xk(e),t)}function _k(e){const t=IS(e);return KS((async()=>t))}function wk(e){return KS((async()=>{const t=await e();return IS((()=>t.next()))}))}async function Mk(e,t){return uk.create(e,t)}async function Nk(e){return ok.create(e)}const Sk="3.19.0";function kk(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&se("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the CPU backend.`))}))}const Dk=Id;class Tk extends J{constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new K(this,lo())}nextDataId(){return Tk.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,Ge().get("IS_NODE")&&ca("\n============================\nHi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. \n============================"));const r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:n,refCount:1}),r}makeTensorInfo(e,t,n){let r;if("string"===t&&null!=n&&n.length>0&&Ee(n[0])){const a=n.map((e=>Pa(e)));r=this.write(a,e,t)}else r=this.write(n,e,t);return{dataId:r,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){this.data.get(e).refCount++}decRef(e){this.data.has(e)&&this.data.get(e).refCount--}move(e,t,n,r,a){this.data.set(e,{values:t,dtype:r,refCount:a})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:t,complexTensorInfos:n}=this.data.get(e);return"complex64"===t?yf(this.readSync(n.real.dataId),this.readSync(n.imag.dataId)):this.data.get(e).values}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map((e=>Ha(e)));return As(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return As(e.shape,e.dtype,t)}makeOutput(e,t,n){return lo().makeTensorFromTensorInfo(this.makeTensorInfo(t,n,e),this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;const{complexTensorInfos:n}=this.data.get(e);null!=n&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const t=za();return e(),{kernelMs:za()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){kk([e],"where");const t=this.readSync(e.dataId);return Dk(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}function Ik(e,t,n){return({inputs:r,attrs:a,backend:i})=>{const{x:s}=r;if(kk(s,e),"string"===s.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const o=i,u=o.data.get(s.dataId).values,l=ce(s.shape),c=n||s.dtype,p=Me(c,l);for(let e=0;e{const{x:s}=r;if(kk(s,e),"string"===s.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const o=i,u=o.data.get(s.dataId).values,l=n||s.dtype,c=t(u,l,a);return o.makeTensorInfo(s.shape,l,c)}}Tk.nextDataId=0,Mo("cpu",(()=>new Tk),1);const Ck=Ik(Jt,(e=>e>=0?e:Math.exp(e)-1)),Ak={kernelName:Jt,backendName:"cpu",kernelFunc:Ck};function Lk(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const $k={kernelName:fn,backendName:"cpu",kernelFunc:Lk};function Ok(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{alpha:i}=r;kk([a],"leakyRelu");const s=ce(a.shape),o=n.data.get(a.dataId).values,u=we("float32",s);for(let e=0;e{const s=Lo(t,n),o=s.length,u=Re(s),l=we(i,ce(s)),c=t.length,p=n.length,d=Re(t),h=Re(n),f=Co(t,s),m=Co(n,s);if(f.length+m.length===0)for(let t=0;ti[e]=0));const s=je(i,c,d),g=n.slice(-p);m.forEach((e=>g[e]=0));const y=je(g,p,h);l[t]=e(r[s],a[y])}return[l,s]}}const Yk=Fk(((e,t)=>e<0?t*e:e));function zk(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t;kk([r,a],"prelu");const i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,[o,u]=Yk(r.shape,a.shape,i,s,"float32");return n.makeTensorInfo(u,"float32",o)}const Bk={kernelName:ir,backendName:"cpu",kernelFunc:zk},Pk=Ik(cr,(e=>Math.max(0,e))),Hk={kernelName:cr,backendName:"cpu",kernelFunc:Pk},jk=Ik(gr,(e=>Math.min(Math.max(0,e),6))),Uk={kernelName:gr,backendName:"cpu",kernelFunc:jk};function qk(e){return(t,n,r)=>{const a=we(n,t.length);for(let n=0;n1/(1+Math.exp(-e)))),Vk=Ik(Tr,(e=>1/(1+Math.exp(-e)))),Gk={kernelName:Tr,backendName:"cpu",kernelFunc:Vk};function Kk(e,t,n,r,a){if("linear"===n)return Lk({inputs:{x:t},backend:e});if("relu"===n)return Pk({inputs:{x:t},backend:e});if("elu"===n)return Ck({inputs:{x:t},backend:e});if("relu6"===n)return jk({inputs:{x:t},backend:e});if("prelu"===n)return zk({inputs:{x:t,alpha:r},backend:e});if("leakyrelu"===n)return Ok({inputs:{x:t},backend:e,attrs:{alpha:a}});if("sigmoid"===n)return Vk({inputs:{x:t},backend:e});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}function Jk(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,o=n.makeTensorInfo(r.shape,"complex64");return n.data.get(o.dataId).complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",i),imag:n.makeTensorInfo(a.shape,"float32",s)},o}const Xk={kernelName:St,backendName:"cpu",kernelFunc:Jk};function Zk(e,t,n="float32"){if("complex64"===n)return Jk({inputs:{real:Zk(e,t,"float32"),imag:Zk(e,t,"float32")},backend:e});const r=Be(ce(t),n);return e.makeTensorInfo(t,n,r)}function Qk(e){const{inputs:t,backend:n}=e,{input:r}=t,a=n.data.get(r.dataId).complexTensorInfos.real,i=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,i)}const eD={kernelName:ur,backendName:"cpu",kernelFunc:Qk};function tD(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dtype:i}=r;if("complex64"===i){if("complex64"===a.dtype)return Lk({inputs:{x:a},backend:n});const e=Zk(n,a.shape,a.dtype),t=tD({inputs:{x:a},backend:n,attrs:{dtype:"float32"}}),r=Jk({inputs:{real:t,imag:e},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),r}if("complex64"===a.dtype){const e=Qk({inputs:{input:a},backend:n}),t=tD({inputs:{x:e},backend:n,attrs:{dtype:i}});return n.disposeIntermediateTensorInfo(e),t}if(!ke(a.dtype,i)){const e=Lk({inputs:{x:a},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:i}}if("int32"===i){const e=n.data.get(a.dataId).values,t=Int32Array.from(e);return n.makeTensorInfo(a.shape,"int32",t)}if("bool"===i){const e=n.data.get(a.dataId).values,t=Ya([0],a.dtype),[r,i]=Fk(((e,t)=>e!==t?1:0))(a.shape,[],e,t,"bool");return n.makeTensorInfo(i,"bool",r)}throw new Error(`Error in Cast: failed to cast ${a.dtype} to ${i}`)}const nD={kernelName:wt,backendName:"cpu",kernelFunc:tD};function rD(e,t,n,r){return null==n?({inputs:n,backend:a})=>{const{a:i,b:s}=n,o=a;kk([i,s],e);const u=o.data.get(i.dataId).values,l=o.data.get(s.dataId).values,c="string"===i.dtype?Gf(u):u,p="string"===i.dtype?Gf(l):l,d=r||i.dtype,[h,f]=t(i.shape,s.shape,c,p,d);return o.makeTensorInfo(f,d,h)}:({inputs:e,backend:a})=>{const{a:i,b:s}=e,o=a;if("complex64"===i.dtype||"complex64"===s.dtype){const e=tD({inputs:{x:i},backend:o,attrs:{dtype:"complex64"}}),t=o.data.get(e.dataId),r=t.complexTensorInfos.real,a=t.complexTensorInfos.imag,u=o.data.get(r.dataId).values,l=o.data.get(a.dataId).values,c=tD({inputs:{x:s},backend:o,attrs:{dtype:"complex64"}}),p=o.data.get(c.dataId),d=p.complexTensorInfos.real,h=p.complexTensorInfos.imag,f=o.data.get(d.dataId).values,m=o.data.get(h.dataId).values,[g,y,b]=n(i.shape,s.shape,u,l,f,m),x=o.makeTensorInfo(b,"float32",g),v=o.makeTensorInfo(b,"float32",y),_=Jk({inputs:{real:x,imag:v},backend:o});return o.disposeIntermediateTensorInfo(e),o.disposeIntermediateTensorInfo(c),o.disposeIntermediateTensorInfo(x),o.disposeIntermediateTensorInfo(v),_}{const e=o.data.get(i.dataId).values,n=o.data.get(s.dataId).values,a=r||i.dtype,[u,l]=t(i.shape,s.shape,e,n,a);return o.makeTensorInfo(l,a,u)}}}function aD(e){return(t,n,r,a,i,s)=>{const o=Lo(t,n),u=ce(o),l=o.length,c=Re(o),p=we("float32",u),d=we("float32",u),h=Co(t,o),f=Co(n,o),m=yf(r,a),g=yf(i,s),y=t.length,b=Re(t),x=n.length,v=Re(n);if(h.length+f.length===0)for(let t=0;tr[e]=0));const a=je(r,y,b),i=n.slice(-x);f.forEach((e=>i[e]=0));const s=je(i,x,v),o=e(m[2*a],m[2*a+1],g[2*s],g[2*s+1]);p[t]=o.real,d[t]=o.imag}return[p,d,o]}}const iD=Fk(((e,t)=>e+t)),sD=aD(((e,t,n,r)=>({real:e+n,imag:t+r}))),oD=rD(nt,iD,sD),uD={kernelName:nt,backendName:"cpu",kernelFunc:oD};function lD(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{shape:i}=r,s=ce(a.shape),o=xe(i,s),u=ce(o);se(s===u,(()=>`The new shape (${o}) has ${u} elements and the old shape (${a.shape}) has ${s} elements. The new shape and old shape must have the same number of elements.`)),n.incRef(a.dataId);const l=n.data.get(a.dataId);if(null!=l.complexTensorInfos){const e=l.complexTensorInfos.real,t=l.complexTensorInfos.imag;e.shape=o,t.shape=o}return{dataId:a.dataId,shape:o,dtype:a.dtype}}const cD={kernelName:pr,backendName:"cpu",kernelFunc:lD};function pD(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i}=t,{transposeA:s,transposeB:o}=r;kk([a,i],"matMul");const u=a.shape.length,l=i.shape.length,c=s?a.shape[u-2]:a.shape[u-1],p=o?i.shape[l-1]:i.shape[l-2],d=s?a.shape[u-1]:a.shape[u-2],h=o?i.shape[l-2]:i.shape[l-1],f=a.shape.slice(0,-2),m=i.shape.slice(0,-2),g=ce(f),y=ce(m),b=Lo(a.shape.slice(0,-2),i.shape.slice(0,-2)).concat([d,h]);se(c===p,(()=>`Error in matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${a.shape} and ${i.shape} and transposeA=${s} and transposeB=${o} must match.`));const x=o?[y,h,p]:[y,p,h],v=lD({inputs:{x:a},backend:n,attrs:{shape:s?[g,c,d]:[g,d,c]}}),_=lD({inputs:{x:i},backend:n,attrs:{shape:x}}),w=s?v.shape[1]:v.shape[2],M=s?v.shape[2]:v.shape[1],N=o?_.shape[1]:_.shape[2],S=Math.max(g,y),k=n.data.get(v.dataId).values,D=n.data.get(_.dataId).values,T=Re(v.shape),I=Re(_.shape),[E,C,A]=s?[T[0],1,T[1]]:[T[0],T[1],1],[L,$,O]=o?[1,I[1],I[0]]:[I[1],1,I[0]],R=M*N,F=As([S,M,N],v.dtype),Y=F.values,z=n.blockSize;for(let e=0;e{const{x:t}=e.inputs,n=e.backend;kk(t,"abs");let r=new Float32Array(ce(t.shape));return r=fD(n.data.get(t.dataId).values),n.makeOutput(r,t.shape,t.dtype)}},gD=Ik(et,(e=>Math.acos(e))),yD={kernelName:et,backendName:"cpu",kernelFunc:gD},bD=Ik(tt,(e=>Math.acosh(e))),xD={kernelName:tt,backendName:"cpu",kernelFunc:bD},vD={kernelName:rt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,r=t;kk(t,"addN");const a=r.map((e=>n.data.get(e.dataId).values)),i=As(r[0].shape,r[0].dtype),s=i.values;for(let e=0;en&&(n=a,r=e)}d[e]=r}return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(c,"int32",d)}},DD={kernelName:ot,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;kk(a,"argMin");let s=ve(i,a.shape);const o=xc(s,a.shape.length);let u=a;const l=[];null!=o&&(u=wD({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=_c(s.length,u.shape.length)),s=[s[0]],bc("argMin",s,u.shape.length);const[c,p]=gc(u.shape,s),d=Be(ce(c),"int32"),h=ce(p),f=n.data.get(u.dataId).values;for(let e=0;en.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(c,"int32",d)}},TD=Ik(ut,(e=>Math.asin(e))),ID={kernelName:ut,backendName:"cpu",kernelFunc:TD},ED=Ik(lt,(e=>Math.asinh(e))),CD={kernelName:lt,backendName:"cpu",kernelFunc:ED},AD=Ik(ct,(e=>Math.atan(e))),LD={kernelName:ct,backendName:"cpu",kernelFunc:AD},$D=Fk(((e,t)=>Math.atan2(e,t))),OD=rD(dt,$D),RD={kernelName:dt,backendName:"cpu",kernelFunc:OD},FD=Ik(pt,(e=>Math.atanh(e))),YD={kernelName:pt,backendName:"cpu",kernelFunc:FD};function zD(e,t,n,r,a,i){const s=a.strideHeight,o=a.strideWidth,u=a.dilationHeight,l=a.dilationWidth,c=a.effectiveFilterHeight,p=a.effectiveFilterWidth,d=a.padInfo.top,h=a.padInfo.left,f="max"===i?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=As(a.outShape,n),g=m.values,y=a.outShape[1]*a.outShape[2]*a.outShape[3],b=a.outShape[2]*a.outShape[3],x=a.outShape[3];for(let t=0;ty?y=s:"avg"===i&&(b+=s,v++)}if(isNaN(y))break}g[M+n*x+t]="avg"===i?b/v:y}}}return m}function BD(e,t,n,r,a=!1,i=!1){const s=As(r.outShape,"int32"),o=r.strideHeight,u=r.strideWidth,l=r.dilationHeight,c=r.dilationWidth,p=r.effectiveFilterHeight,d=r.effectiveFilterWidth,h=r.padInfo.top,f=r.padInfo.left,m=As(t,n,e);for(let e=0;ev&&(v=l,_=a?i?((e*r.inHeight+n)*r.inWidth+o)*r.inChannels+t:(n*r.inWidth+o)*r.inChannels+t:s*d+u)}}s.set(_,e,n,o,t)}}return s}function PD(e,t,n,r,a,i){const s=a.strideDepth,o=a.strideHeight,u=a.strideWidth,l=a.dilationDepth,c=a.dilationHeight,p=a.dilationWidth,d=a.effectiveFilterDepth,h=a.effectiveFilterHeight,f=a.effectiveFilterWidth,m=a.padInfo.front,g=a.padInfo.top,y=a.padInfo.left,b="max"===i?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,x=As(a.outShape,n),v=x.values,_=a.outShape[1]*a.outShape[2]*a.outShape[3]*a.outShape[4],w=a.outShape[2]*a.outShape[3]*a.outShape[4],M=a.outShape[3]*a.outShape[4],N=a.outShape[4];for(let t=0;tw?w=a:"avg"===i&&(M+=a,S++),isNaN(w))break}if(isNaN(w))break}if(isNaN(w))break}v[g+t]="avg"===i?M/S:w}}}}return x}const HD={kernelName:ht,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;kk(a,"avgPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;se(vl(s,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=cl(a.shape,i,s,1,o,u);let c;if(1===l.filterWidth&&1===l.filterHeight&&de(l.inShape,l.outShape))c=Lk({inputs:{x:a},backend:n});else{const e=n.data.get(a.dataId).values,t=Re(a.shape),r=zD(e,a.shape,a.dtype,t,l,"avg");c=n.makeTensorInfo(l.outShape,a.dtype,r.values)}return c}},jD={kernelName:mt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u,dataFormat:l}=r;kk(a,"avgPool3d");const c=pl(a.shape,i,s,1,o,u,l),p=PD(n.data.get(a.dataId).values,a.shape,a.dtype,Re(a.shape),c,"avg");return n.makeTensorInfo(p.shape,"float32",p.values)}},UD={kernelName:gt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,{filterSize:s,strides:o,pad:u,dimRoundingMode:l}=r;kk([a,i],"avgPool3DGrad");const c=pl(i.shape,s,o,1,u,l),p=c.strideDepth,d=c.strideHeight,h=c.strideWidth,f=c.filterDepth,m=c.filterHeight,g=c.filterWidth,y=c.dilationDepth,b=c.dilationHeight,x=c.dilationWidth,v=c.effectiveFilterDepth,_=c.effectiveFilterHeight,w=c.effectiveFilterWidth,M=v-1-c.padInfo.front,N=w-1-c.padInfo.left,S=_-1-c.padInfo.top,k=As(i.shape,"float32"),D=1/(f*m*g),T=n.bufferSync(a);for(let e=0;e=c.outDepth||Math.floor(r)!==r))for(let n=0;n<_;n+=b){const a=(s+n)/d;if(!(a<0||a>=c.outHeight||Math.floor(a)!==a))for(let n=0;n=c.outWidth||Math.floor(i)!==i||(u+=T.get(e,r,a,i,t))}}}k.set(u*D,e,n,r,a,t)}return n.makeTensorInfo(k.shape,k.dtype,k.values)}},qD={kernelName:ft,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i;kk([a,i],"avgPoolGrad");const{filterSize:o,strides:u,pad:l}=r,c=cl(s.shape,o,u,1,l),p=c.strideHeight,d=c.strideWidth,h=c.filterHeight,f=c.filterWidth,m=c.dilationHeight,g=c.dilationWidth,y=c.effectiveFilterHeight,b=c.effectiveFilterWidth,x=b-1-c.padInfo.left,v=y-1-c.padInfo.top,_=As(s.shape,"float32"),w=1/(h*f),M=n.data.get(a.dataId).values,N=As(a.shape,"float32",M);for(let e=0;e=c.outHeight||Math.floor(r)!==r))for(let n=0;n=c.outWidth||Math.floor(a)!==a||(s+=N.get(e,r,a,t))}}_.set(s*w,e,n,r,t)}return n.makeTensorInfo(_.shape,_.dtype,_.values)}},WD={kernelName:ln,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,scale:i,offset:s,mean:o,variance:u}=t;se(o.shape.length===u.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),se(null==s||o.shape.length===s.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),se(null==i||o.shape.length===i.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks.")),kk([a,o,u,i,s],"batchNorm");let{varianceEpsilon:l}=r;null==l&&(l=.001);const c=n.data.get(a.dataId).values,p=n.data.get(o.dataId).values,d=n.data.get(u.dataId).values,h=i?n.data.get(i.dataId).values:new Float32Array([1]),f=s?n.data.get(s.dataId).values:new Float32Array([0]),m=new Float32Array(c.length),g=f.length,y=h.length,b=d.length,x=p.length;let v=0,_=0,w=0,M=0;for(let e=0;e=g&&(v=0),_>=x&&(_=0),w>=y&&(w=0),M>=b&&(M=0);return n.makeTensorInfo(a.shape,a.dtype,m)}};function VD(e,t,n,r,a){const i=nu(r,t,n),s=ce(n),o=Re(r);if(i){const n=ru(t,o);return"string"===a?e.slice(n,n+s):e.subarray(n,n+s)}const u=As(r,a,"string"===a?Gf(e):e),l=As(n,a);for(let e=0;ee+t[n]));l.set(u.get(...r),...n)}return"string"===a?Kf(l.values):l.values}function GD(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,size:s}=r;kk(a,"slice");const[o,u]=au(a,i,s);Uo(a,o,u);const l=VD(n.data.get(a.dataId).values,o,u,a.shape,a.dtype);return n.makeTensorInfo(u,a.dtype,l)}const KD={kernelName:Nr,backendName:"cpu",kernelFunc:GD},JD={kernelName:bt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,crops:s}=r;kk([a],"batchToSpaceND");const o=i.reduce(((e,t)=>e*t)),u=rf(a.shape,i,o),l=af(u.length,i.length),c=sf(a.shape,i,o),p=of(s,i.length),d=uf(c,s,i.length),h=lD({inputs:{x:a},backend:n,attrs:{shape:u}}),f=wD({inputs:{x:h},backend:n,attrs:{perm:l}}),m=lD({inputs:{x:f},backend:n,attrs:{shape:c}}),g=GD({inputs:{x:m},backend:n,attrs:{begin:p,size:d}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}};function XD(e,t,n,r,a){const i=ce(r),s=Be(a,n);for(let n=0;n=a||(s[r]+=i>0?t[n]:1)}return s}function ZD(e,t,n,r=!1){const a=e.shape[0],i=e.shape[1],s=As([a,n],t.dtype);for(let o=0;o=n||(r?s.set(1,o,i):t.size>0?s.set(s.get(o,i)+t.get(o,a),o,i):s.set(s.get(o,i)+1,o,i))}return s}const QD={kernelName:xt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:i}=t,{size:s}=r,o=XD(n.data.get(a.dataId).values,n.data.get(i.dataId).values,i.dtype,i.shape,s);return n.makeTensorInfo([s],i.dtype,o)}},eT={kernelName:_t,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{s0:r,s1:a}=t,i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,o=Lo(Array.from(i),Array.from(s));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}},tT=qk((e=>Math.ceil(e))),nT=Ek(Mt,tT),rT={kernelName:Mt,backendName:"cpu",kernelFunc:nT},aT=Ik(Nt,((e,t)=>{const n=t;return e>n.clipValueMax?n.clipValueMax:e{const{x:t}=e.inputs,n=e.backend,r=new Float32Array(ce(t.shape)),a=n.data.get(t.dataId),i=a.complexTensorInfos.real,s=a.complexTensorInfos.imag,o=n.data.get(i.dataId).values,u=n.data.get(s.dataId).values;for(let e=0;e{const n=ce(e.shape);a.set(e.vals,t),t+=n}))}else{let r=0;e.forEach((e=>{const i="string"===n?Gf(e.vals):e.vals;let s=0;for(let n=0;ne.shape)),i);if(0===ce(s))return n.makeTensorInfo(s,t[0].dtype,[]);const o=t.filter((e=>ce(e.shape)>0));if(1===o.length)return Lk({inputs:{x:o[0]},backend:n});if(Zh(o.map((e=>e.shape)),i),"complex64"===o[0].dtype){const e=o.map((e=>Qk({inputs:{input:e},backend:n}))),t=o.map((e=>uT({inputs:{input:e},backend:n}))),r=cT({inputs:e,backend:n,attrs:{axis:i}}),a=cT({inputs:t,backend:n,attrs:{axis:i}}),s=Jk({inputs:{real:r,imag:a},backend:n});return e.forEach((e=>n.disposeIntermediateTensorInfo(e))),t.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),s}const u=o.map((e=>{const t=ce(e.shape.slice(i));return lD({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),l=u.map((e=>({vals:n.data.get(e.dataId).values,shape:e.shape})));s=Qh(u.map((e=>e.shape)),1);const c=1===u[0].shape[0],p=oT(l,s,t[0].dtype,c),d=Qh(o.map((e=>e.shape)),i),h=n.makeTensorInfo(d,t[0].dtype,p);return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),h}const pT={kernelName:Dt,backendName:"cpu",kernelFunc:cT};function dT(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dataFormat:u,dilations:l,dimRoundingMode:c}=r;kk([a,i],"conv2d");const p=_l(u),d=dl(a.shape,i.shape,s,l,o,c,!1,p),h=d.filterHeight,f=d.filterWidth,m=d.dilationHeight,g=d.dilationWidth,y=d.padInfo.left,b=d.padInfo.top,x="channelsLast"===d.dataFormat,v=new Xa(d.outShape,a.dtype),_=Re(a.shape),w=Re(i.shape),M=_[0],N=x?_[1]:_[2],S=x?_[2]:1,k=x?1:_[1],D=v.strides[0],T=x?v.strides[1]:v.strides[2],I=x?v.strides[2]:1,E=x?1:v.strides[1],C=n.data.get(a.dataId).values,A=n.data.get(i.dataId).values,L=v.values;for(let e=0;e=d.inHeight)continue;const i=e*w[0],s=t+n*N;for(let e=0;e=d.inWidth)continue;const a=s+r*S;let o=i+e*w[1];for(let e=0;e=l.inDepth)continue;const i=e*S[0],s=t+n*N[1];for(let e=0;e=l.inHeight)continue;const a=i+e*S[1],o=s+r*N[2];for(let e=0;e=l.inWidth)continue;const i=a+e*S[2],s=o+t*l.inChannels;let u=i;for(let e=0;eMath.cos(e))),vT={kernelName:$t,backendName:"cpu",kernelFunc:xT},_T=Ik(Ot,(e=>Math.cosh(e))),wT={kernelName:Ot,backendName:"cpu",kernelFunc:_T},MT={kernelName:Yt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:i,boxInd:s}=t,{cropSize:o,method:u,extrapolationValue:l}=r,[c,p,d,h]=a.shape,f=i.shape[0],[m,g]=o,y=As([f,m,g,h],"float32"),b=n.data.get(i.dataId).values,x=n.data.get(s.dataId).values,v=n.data.get(a.dataId).values,_=Re(a.shape),w=Re(y.shape);for(let e=0;e=c)continue;const o=m>1?(a-n)*(p-1)/(m-1):0,f=g>1?(i-r)*(d-1)/(g-1):0;for(let t=0;t1?n*(p-1)+t*o:.5*(n+a)*(p-1);if(c<0||c>p-1)for(let n=0;n1?r*(d-1)+u*f:.5*(r+i)*(d-1);if(c<0||c>d-1){for(let n=0;n1?r*(d-1)+n*f:.5*(r+i)*(d-1);if(a<0||a>d-1){for(let r=0;re+f-t-1:(e,t)=>e+t;for(let e=0;ee+f-t-1:(e,t)=>e+t;for(let e=0;e`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${s}`));const o=a.shape[0],u=a.shape[1],l=a.shape[2],c=a.shape[3],p=u*i,d=l*i,h=c/(i*i),f=n.data.get(a.dataId).values,m=new Float32Array(o*p*d*h);let g=0;for(let e=0;e`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${d}'`));const h=dl(a.shape,i.shape,s,d,o,l,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:y,padInfo:b}=h,x=b.left,v=b.top,_=h.outChannels/h.inChannels,w=new Xa(h.outShape,a.dtype),M=n.data.get(a.dataId).values,N=n.data.get(i.dataId).values,S=w.values;for(let e=0;e=h.inHeight)continue;const i=e*p[0],s=t+n*c[1];for(let e=0;e=h.inWidth)continue;const a=i+e*p[1],o=s+r*h.inChannels;let u=t,l=a;for(let e=0;e{const{x:r,filter:a}=e,{strides:i,pad:s,dilations:o}=n,u=t,l=u.data.get(r.dataId).values,c=r.shape.length,p=u.data.get(a.dataId).values,d=a.shape.length,{batchSize:h,inHeight:f,inWidth:m,inChannels:g,outHeight:y,outWidth:b,padInfo:x,strideHeight:v,strideWidth:_,filterHeight:w,filterWidth:M,dilationHeight:N,dilationWidth:S,outShape:k}=ll(r.shape,a.shape,i,s,"NHWC",o),D=ce(k),T=k.length,I=Me(r.dtype,D);for(let e=0;e=0&&i=0&&hu&&(u=m)}}}I[je([e,t,i,o],T,Re(k))]=u}}}return{dataId:u.write(Ya(I,r.dtype),k,r.dtype),shape:k,dtype:r.dtype}}},$T={kernelName:Vt,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,filter:a,dy:i}=e,{strides:s,pad:o,dilations:u}=n,l=t,c=Ye(r.shape,l.data.get(r.dataId).values),p=Ye(a.shape,l.data.get(a.dataId).values),{batchSize:d,inHeight:h,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:b,strideHeight:x,strideWidth:v,filterHeight:_,filterWidth:w,dilationHeight:M,dilationWidth:N,outShape:S}=ll(r.shape,a.shape,s,o,"NHWC",u);se(i.rank===S.length,(()=>`Error in ${Vt}, dy must have the same rank as output ${S.length}, but got ${i.rank}`));const k=Ye(S,l.data.get(i.dataId).values),D=Pe(a.shape,a.dtype);for(let e=0;e=0&&r=0&&ls&&(s=a,o=t,u=n)}}}D[o][u][i]+=k[e][t][r][i]}}}return{dataId:l.write(Ya(D,r.dtype),a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},OT={kernelName:Wt,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,filter:a,dy:i}=e,{strides:s,pad:o,dilations:u}=n,l=t,c=Ye(r.shape,l.data.get(r.dataId).values),p=Ye(a.shape,l.data.get(a.dataId).values),{batchSize:d,inHeight:h,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:b,strideHeight:x,strideWidth:v,filterHeight:_,filterWidth:w,dilationHeight:M,dilationWidth:N,outShape:S}=ll(r.shape,a.shape,s,o,"NHWC",u);se(i.rank===S.length,(()=>`Error in ${Wt}, dy must have the same rank as output ${S.length}, but got ${i.rank}`));const k=Ye(S,l.data.get(i.dataId).values),D=Pe(r.shape,r.dtype);for(let e=0;e=0&&r=0&&ls&&(s=a,o=r,u=l)}}}D[e][o][u][i]+=k[e][t][r][i]}}}return{dataId:l.write(Ya(D,r.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},RT=Fk(((e,t)=>e*t)),FT=aD(((e,t,n,r)=>({real:e*n-t*r,imag:e*r+t*n}))),YT=rD(Vn,RT,FT),zT={kernelName:Vn,backendName:"cpu",kernelFunc:YT};function BT(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r;let o;kk(a,"sum"),o="bool"===a.dtype?tD({inputs:{x:a},backend:n,attrs:{dtype:"int32"}}):Lk({inputs:{x:a},backend:n});const u=o.shape.length,l=ve(i,o.shape),c=xc(l,u);let p=l,d=o;null!=c&&(d=wD({inputs:{x:o},backend:n,attrs:{perm:c}}),p=_c(p.length,u)),bc("sum",p,d.shape.length);const[h,f]=gc(d.shape,p);let m=Zk(n,h,ci(d.dtype,"int32"));const g=ce(f),y=n.data.get(m.dataId).values,b=n.data.get(d.dataId).values;for(let e=0;e=0&&(d=BT({inputs:{x:d},backend:n,attrs:{axis:l[e]-(s.length-h),keepDims:!1}}),f.push(d)),h--)}for(const e of f)e!==d&&n.disposeIntermediateTensorInfo(e);return d}},jT={kernelName:Xt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{dy:r,y:a}=t;kk([r,a],"eluGrad");const i=new Float32Array(ce(a.shape)),s=n.data.get(a.dataId).values,o=n.data.get(r.dataId).values;for(let e=0;e=1?o[e]:o[e]*(t+1)}return n.makeTensorInfo(a.shape,"float32",i)}},UT=Fk(((e,t)=>e===t?1:0)),qT=rD(Qt,UT,null,"bool"),WT={kernelName:Qt,backendName:"cpu",kernelFunc:qT},VT=pf,GT=df,KT=hf,JT=ff,XT=mf,ZT=gf,QT=Ik(Zt,(e=>{const t=Math.sign(e),n=Math.abs(e),r=1/(1+VT*n);return t*(1-((((ZT*r+XT)*r+JT)*r+KT)*r+GT)*r*Math.exp(-n*n))})),eI={kernelName:Zt,backendName:"cpu",kernelFunc:QT},tI=qk((e=>Math.exp(e))),nI=Ek(en,tI,"float32"),rI={kernelName:en,backendName:"cpu",kernelFunc:nI};function aI(e){const{inputs:t,backend:n,attrs:r}=e,{input:a}=t,{dim:i}=r,s=a.shape.length,o=a.shape.slice();let u=i;return i<0&&(se(-(s+1)<=i,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+i+1),o.splice(u,0,1),lD({inputs:{x:a},backend:n,attrs:{shape:o}})}const iI={kernelName:tn,backendName:"cpu",kernelFunc:aI},sI=qk((e=>Math.expm1(e))),oI=Ek(nn,sI),uI={kernelName:nn,backendName:"cpu",kernelFunc:oI},lI=Fk(((e,t)=>e/t)),cI=rD(Gt,lI),pI={kernelName:Gt,backendName:"cpu",kernelFunc:cI},dI=Fk(((e,t)=>e-t)),hI=aD(((e,t,n,r)=>({real:e-n,imag:t-r}))),fI=rD(Wr,dI,hI),mI={kernelName:Wr,backendName:"cpu",kernelFunc:fI};function gI(e,t,n){const r=e.shape,a=r[0],i=r[1],s=n.data.get(e.dataId),o=s.complexTensorInfos.real,u=s.complexTensorInfos.imag,l=[a,i],c=ce(l),p=we("float32",c),d=we("float32",c);for(let e=0;e{const{image:r}=e,a=n,i=we(r.dtype,ce(r.shape)),[s,o,u,l]=r.shape,c=a.data.get(r.dataId).values;for(let e=0;e=0&&sMath.floor(e))),NI=Ek(on,MI),SI={kernelName:on,backendName:"cpu",kernelFunc:NI},kI=Fk(((e,t)=>Math.floor(e/t))),DI=rD(un,kI,null,"int32"),TI={kernelName:un,backendName:"cpu",kernelFunc:DI},II={kernelName:ua,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r;let m=dT({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d}});if(s){const e=m;if("NCHW"===c&&1===s.shape.length&&1!==s.shape[0]){const e=lD({inputs:{x:s},backend:n,attrs:{shape:[s.shape[0],1,1]}});m=oD({inputs:{a:m,b:e},backend:n}),n.disposeIntermediateTensorInfo(e)}else m=oD({inputs:{a:m,b:s},backend:n});n.disposeIntermediateTensorInfo(e)}if(h){const e=m;if("NCHW"===c&&"prelu"===h&&1===o.shape.length&&1!==o.shape[0]){const e=lD({inputs:{x:o},backend:n,attrs:{shape:[o.shape[0],1,1]}});m=Kk(n,m,h,e,f),n.disposeIntermediateTensorInfo(e)}else m=Kk(n,m,h,o,f);n.disposeIntermediateTensorInfo(e)}return m}},EI={kernelName:la,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r;let m=TT({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d}});if(s){const e=m;m=oD({inputs:{a:m,b:s},backend:n}),n.disposeIntermediateTensorInfo(e)}if(h){const e=m;m=Kk(n,m,h,o,f),n.disposeIntermediateTensorInfo(e)}return m}};function CI(e,t,n,r,a,i,s,o,u){const l=As([r,i],n);for(let n=0;n=u/i)throw new Error(`Invalid indices: ${r} does not index into ${o}`);for(let e=0;e=0,(()=>`GatherV2: the index value ${t} is not in [0, ${c-1}]`))}let p=o;null==o&&(p=0);const d=ce(i.shape),h=Vf(a,i,u,p),f=lD({inputs:{x:a},backend:n,attrs:{shape:[h.batchSize,h.outerSize,h.dimSize,h.sliceSize]}}),m=lD({inputs:{x:i},backend:n,attrs:{shape:[h.batchSize,d/h.batchSize]}}),g=[h.batchSize,h.outerSize,d/h.batchSize,h.sliceSize],y=n.bufferSync(m),b=LI(n.bufferSync(f),y,g);return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.makeTensorInfo(h.outputShape,b.dtype,b.values)}},OI=Fk(((e,t)=>e>t?1:0)),RI=rD(dn,OI,null,"bool"),FI={kernelName:dn,backendName:"cpu",kernelFunc:RI},YI=Fk(((e,t)=>e>=t?1:0)),zI=rD(hn,YI,null,"bool"),BI={kernelName:hn,backendName:"cpu",kernelFunc:zI},PI={kernelName:mn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t,a=ce(r.shape),i=r.shape[r.shape.length-1],s=lD({inputs:{x:r},backend:n,attrs:{shape:[a/i,i]}}),o=gI(s,!0,n),u=lD({inputs:{x:o},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(o),u}},HI=Ik(yn,(e=>Number.isFinite(e)?1:0),"bool"),jI={kernelName:yn,backendName:"cpu",kernelFunc:HI},UI=Ik(bn,(e=>Math.abs(e)===1/0?1:0),"bool"),qI={kernelName:bn,backendName:"cpu",kernelFunc:UI},WI=Ik(xn,(e=>Number.isNaN(e)?1:0),"bool"),VI={kernelName:xn,backendName:"cpu",kernelFunc:WI},GI=Fk(((e,t)=>ee<=t?1:0)),ZI=rD(wn,XI,null,"bool"),QI={kernelName:wn,backendName:"cpu",kernelFunc:ZI};function eE(e,t,n){const r=(t-e)/(n-1),a=Be(n,"float32");a[0]=e;for(let e=1;eMath.log(e))),rE=Ek(Nn,nE),aE={kernelName:Nn,backendName:"cpu",kernelFunc:rE},iE=Ik(Sn,(e=>Math.log1p(e))),sE={kernelName:Sn,backendName:"cpu",kernelFunc:iE},oE=Fk(((e,t)=>e&&t)),uE=rD(kn,oE,null,"bool"),lE={kernelName:kn,backendName:"cpu",kernelFunc:uE},cE=Ik(Dn,(e=>e?0:1),"bool"),pE={kernelName:Dn,backendName:"cpu",kernelFunc:cE},dE=Fk(((e,t)=>e||t)),hE=rD(Tn,dE,null,"bool"),fE={kernelName:Tn,backendName:"cpu",kernelFunc:hE},mE={kernelName:An,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{depthRadius:i,bias:s,alpha:o,beta:u}=r;kk(a,"LRN");const l=a.shape[3],c=l-1,p=n.data.get(a.dataId).values,d=ce(a.shape),h=new Float32Array(d);function f(e){const t=e%l;let n=e-t+Math.max(0,t-i);const r=e-t+Math.min(t+i,c);let a=0;for(;n<=r;n++){const e=p[n];a+=e*e}return a}for(let e=0;ei)&&(i=t)}a[n]=i}return a}function bE(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reductionIndices:i,keepDims:s}=r,o=n;let u=a.shape;const l=u.length,c=ve(i,u);let p=c;const d=xc(p,l);let h=o.data.get(a.dataId).values;if(null!=d){const e=new Array(l);for(let t=0;tMath.max(e,t))),_E=rD(On,vE),wE={kernelName:On,backendName:"cpu",kernelFunc:_E},ME={kernelName:Rn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;kk(a,"maxPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;se(vl(s,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=cl(a.shape,i,s,1,o,u);let c;if(1===l.filterWidth&&1===l.filterHeight&&de(l.inShape,l.outShape))c=Lk({inputs:{x:a},backend:n});else{const e=n.data.get(a.dataId).values,t=Re(a.shape),r=zD(e,a.shape,a.dtype,t,l,"max");c=n.makeTensorInfo(l.outShape,a.dtype,r.values)}return c}},NE={kernelName:Yn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u,dataFormat:l}=r;kk(a,"maxPool3d");const c=pl(a.shape,i,s,1,o,u,l),p=PD(n.data.get(a.dataId).values,a.shape,a.dtype,Re(a.shape),c,"max");return n.makeTensorInfo(p.shape,"float32",p.values)}},SE={kernelName:zn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,{filterSize:s,strides:o,pad:u,dimRoundingMode:l}=r;kk([a,i],"maxPool3DGrad");const c=pl(i.shape,s,o,1,u,l),p=function(e,t){const n=As(t.outShape,"int32"),r=t.strideDepth,a=t.strideHeight,i=t.strideWidth,s=t.dilationDepth,o=t.dilationHeight,u=t.dilationWidth,l=t.effectiveFilterDepth,c=t.effectiveFilterHeight,p=t.effectiveFilterWidth,d=t.padInfo.front,h=t.padInfo.top,f=t.padInfo.left;for(let m=0;m=N&&(N=o,S=n*c*p+a*c+s)}}}n.set(S,m,y,r,a,g)}}}return n}(n.bufferSync(i),c),d=c.strideDepth,h=c.strideHeight,f=c.strideWidth,m=c.dilationDepth,g=c.dilationHeight,y=c.dilationWidth,b=c.effectiveFilterDepth,x=c.effectiveFilterHeight,v=c.effectiveFilterWidth,_=b-1-c.padInfo.front,w=v-1-c.padInfo.left,M=x-1-c.padInfo.top,N=As(i.shape,"float32"),S=n.bufferSync(a);for(let e=0;e=c.outDepth||Math.floor(r)!==r))for(let a=0;a=c.outHeight||Math.floor(i)!==i))for(let s=0;s=c.outWidth||Math.floor(l)!==l)continue;const d=b*x*v-1-p.get(e,r,i,l,t)===n*x*v+a*v+s?1:0;0!==d&&(u+=S.get(e,r,i,l,t)*d)}}}N.set(u,e,n,r,a,t)}return n.makeTensorInfo(N.shape,N.dtype,N.values)}},kE={kernelName:Fn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i,output:s}=t,o=i;kk([i,s],"maxPoolGrad");const{filterSize:u,strides:l,pad:c,dimRoundingMode:p}=r,d=cl(o.shape,u,l,1,c,p),h=n.data.get(o.dataId).values,f=As(d.outShape,o.dtype,BD(h,o.shape,o.dtype,d).values),m=d.strideHeight,g=d.strideWidth,y=d.dilationHeight,b=d.dilationWidth,x=d.effectiveFilterHeight,v=d.effectiveFilterWidth,_=v-1-d.padInfo.left,w=x-1-d.padInfo.top,M=As(o.shape,"float32"),N=n.data.get(a.dataId).values,S=As(a.shape,"float32",N);for(let e=0;e=d.outHeight||Math.floor(r)!==r))for(let a=0;a=d.outWidth||Math.floor(o)!==o)continue;const u=x*v-1-f.get(e,r,o,t)===n*v+a?1:0;0!==u&&(s+=S.get(e,r,o,t)*u)}}M.set(s,e,n,r,t)}return n.makeTensorInfo(M.shape,M.dtype,M.values)}},DE={kernelName:Bn,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{filterSize:a,strides:i,pad:s,includeBatchInIndex:o}=t,u=n;kk(r,"MaxPoolWithArgmax");const l=u.data.get(r.dataId).values,c=cl(r.shape,a,i,[1,1],s),[p,d]=function(e,t,n,r,a){const i=zD(e,0,n,Re(t),a,"max"),s=BD(e,t,n,a,!0,r);return[i.values,s.values]}(l,r.shape,r.dtype,o,c),h=u.write(p,c.outShape,r.dtype),f=u.write(d,c.outShape,r.dtype);return[{dataId:h,shape:c.outShape,dtype:r.dtype},{dataId:f,shape:c.outShape,dtype:"int32"}]}},TE={kernelName:Pn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=ve(i,a.shape),u=ce(gc(a.shape,o)[1]),l=[],c=n.makeTensorInfo([],"float32",new Float32Array([u]));l.push(c);const p=tD({inputs:{x:a},backend:n,attrs:{dtype:"float32"}});l.push(p);const d=cI({inputs:{a:p,b:c},backend:n});l.push(d);const h=BT({inputs:{x:d},backend:n,attrs:{axis:i,keepDims:s}});return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),h}},IE={kernelName:Hn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r;kk(a,"min");const o=ve(i,a.shape);let u=o;const l=xc(u,a.shape.length);let c=a;null!=l&&(c=wD({inputs:{x:a},backend:n,attrs:{perm:l}}),u=_c(u.length,a.shape.length)),bc("min",u,c.shape.length);const[p,d]=gc(c.shape,u),h=ce(d),f=Be(ce(p),c.dtype),m=n.data.get(c.dataId).values;for(let e=0;eMath.min(e,t))),CE=rD(jn,EE),AE={kernelName:jn,backendName:"cpu",kernelFunc:CE},LE={kernelName:Un,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,mode:s}=r;kk(a,"mirrorPad");const o=i.map(((e,t)=>e[0]+a.shape[t]+e[1])),u=i.map((e=>e[0])),l=i.map(((e,t)=>e[0]+a.shape[t])),c="reflect"===s?0:1,p=n.data.get(a.dataId).values,d=a.shape.length,h=Re(a.shape),f=ce(o),m=o.length,g=Re(o),y=we(a.dtype,f);for(let e=0;e=l[e]&&(t[e]=2*(l[e]-1)-t[e]+c);t=t.map(((e,t)=>e-u[t]));const n=je(t,d,h);y[e]=p[n]}return{dataId:n.write(y,o,a.dtype),shape:o,dtype:a.dtype}}},$E=Fk(((e,t)=>{const n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t})),OE=rD(qn,$E),RE={kernelName:qn,backendName:"cpu",kernelFunc:OE};function FE(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{dim:i}=r,s=a.shape.length;let o=i;if(-1===o&&(o=s-1),o!==s-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${s} and dim was ${o}`);const u=ve([o],a.shape),l=bE({inputs:{x:a},backend:n,attrs:{reductionIndices:u,keepDims:!1}}),c=yc(l.shape,u),p=lD({inputs:{x:l},backend:n,attrs:{shape:c}}),d=fI({inputs:{a,b:p},backend:n}),h=nI({inputs:{x:d},backend:n}),f=BT({inputs:{x:h},backend:n,attrs:{axis:u,keepDims:!1}}),m=lD({inputs:{x:f},backend:n,attrs:{shape:c}}),g=cI({inputs:{a:h,b:m},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}const YE={kernelName:$r,backendName:"cpu",kernelFunc:FE},zE={kernelName:Wn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{numSamples:i,seed:s,normalized:o}=r;kk(a,"multinomial");const u=o?a:FE({inputs:{logits:a},backend:n,attrs:{dim:-1}}),l=u.shape[0],c=u.shape[1],p=n.data.get(u.dataId).values,d=[l,i],h=Be(ce(d),"int32");for(let e=0;ee!==t?1:0)),KE=rD(Kn,GE,null,"bool"),JE={kernelName:Kn,backendName:"cpu",kernelFunc:KE},XE={kernelName:er,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{indices:a}=t,{depth:i,onValue:s,offValue:o}=r;kk(a,"oneHot");const u=ce(a.shape),l=new Float32Array(u*i);l.fill(o);const c=n.data.get(a.dataId).values;for(let e=0;e=0&&c[e]{oe(i,e.shape,"All tensors passed to stack must have matching shapes"),se(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],u=cT({inputs:t.map((e=>{const t=aI({inputs:{input:e},backend:n,attrs:{dim:a}});return o.push(t),t})),backend:n,attrs:{axis:a}});return o.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}const nC={kernelName:tr,backendName:"cpu",kernelFunc:tC},rC={kernelName:nr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,constantValue:s}=r;kk(a,"pad");const o=i.map(((e,t)=>e[0]+a.shape[t]+e[1])),u=i.map((e=>e[0])),l=n.data.get(a.dataId).values,c=ce(a.shape),p=a.shape.length,d=Re(a.shape),h=ce(o),f=o.length,m=Re(o),g=we(a.dtype,h);0!==s&&g.fill(s);for(let e=0;ee+u[t])),f,m)]=l[e];return{dataId:n.write(g,o,a.dtype),shape:o,dtype:a.dtype}}},aC=Fk(((e,t)=>Math.pow(e,t))),iC=rD(ar,aC),sC={kernelName:ar,backendName:"cpu",kernelFunc:iC};function oC(e,t,n,r){const[a,i]=gc(e,r),s=ci(t,"int32"),o=Be(ce(a),s),u=ce(i);for(let e=0;en.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(y,g,f)}};function lC(e,t,n,r){if(e===t||e1)return Be(0,r);const a=Be(Math.abs(Math.ceil((t-e)/n)),r);t1/e)),dC={kernelName:lr,backendName:"cpu",kernelFunc:pC},hC={kernelName:fr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r;kk(a,"resizeBilinear");const u=Re(a.shape),[l,c]=o,[p,d,h,f]=a.shape,m=n.data.get(a.dataId).values,g=new Float32Array(ce([p,l,c,f])),y=[i&&l>1?d-1:d,i&&c>1?h-1:h],b=[i&&l>1?l-1:l,i&&c>1?c-1:c];let x=0;const v=y[0]/b[0],_=y[1]/b[1];for(let e=0;e1?l-1:l,s&&h>1?c-1:c],g=[s&&d>1?d-1:d,s&&h>1?h-1:h],y=m[0]/g[0],b=m[1]/g[1],x=n.data.get(i.dataId).values;let v=0;for(let e=0;e1?d-1:d,i&&c>1?h-1:h],b=[i&&l>1?l-1:l,i&&c>1?c-1:c],x=y[0]/b[0],v=y[1]/b[1];let _=0;for(let e=0;e1?c-1:c,s&&f>1?p-1:p],b=[s&&h>1?h-1:h,s&&f>1?f-1:f],x=y[0]/b[0],v=y[1]/b[1],_=1/x,w=1/v,M=2*Math.ceil(_)+2,N=2*Math.ceil(w)+2;for(let e=0;e=h)continue;const d=t+l*u[1],m=l*x;if(e===Math.min(c-1,s?Math.round(m):Math.floor(m)))for(let e=0;e=f)continue;const a=d+t*u[2],i=t*v;r===Math.min(p-1,s?Math.round(i):Math.floor(i))&&(o+=g[a+n])}}m[i+n]=o}}}}return n.makeTensorInfo(a.shape,a.dtype,m)}},yC={kernelName:yr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:i}=r;kk(a,"reverse");const s=a.shape.length,o=ve(i,a.shape);if(0===s)return Lk({inputs:{x:a},backend:n});const u=new Xa(a.shape,a.dtype),l=n.bufferSync(a);for(let e=0;en[e]=a.shape[e]-1-n[e])),u.set(l.get(...n),...t)}return n.makeTensorInfo(u.shape,u.dtype,u.values)}},bC={kernelName:sa,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:r}=e,{radians:a,fillValue:i,center:s}=t,o=n,u=we(r.dtype,ce(r.shape)),[l,c,p,d]=r.shape,[h,f]=nf(s,c,p),m=Math.sin(a),g=Math.cos(a),y=o.data.get(r.dataId).values;for(let e=0;e=0&&v=0&&_{const t=Math.floor(e);return e-t<.5?Math.floor(e):e-t>.5?Math.ceil(e):t%2==0?t:t+1})),vC={kernelName:br,backendName:"cpu",kernelFunc:xC},_C=qk((e=>1/Math.sqrt(e))),wC=Ek(xr,_C),MC={kernelName:xr,backendName:"cpu",kernelFunc:wC};function NC(e,t,n,r,a,i,s,o,u,l){const c=[r/a,a],p=e.values,d=t.values;if(0===r)return As(n,t.dtype);const h=As(c,t.dtype);"string"==typeof u||"number"==typeof u?h.values.fill(u):"boolean"==typeof u&&h.values.fill(+u);for(let e=0;e=r/a)throw new Error(`Invalid indices: ${i} does not index into ${n}`);for(let n=0;n1||1===a.shape.length?1:ce(a.shape.slice(1));for(let e=0;ee>=0?CC*e:EC*(Math.exp(e)-1))),LC={kernelName:Mr,backendName:"cpu",kernelFunc:AC},$C=Ik(Dr,(e=>e<0?-1:e>0?1:0)),OC={kernelName:Dr,backendName:"cpu",kernelFunc:$C},RC=Ik(Sr,(e=>Math.sin(e))),FC={kernelName:Sr,backendName:"cpu",kernelFunc:RC},YC=Ik(kr,(e=>Math.sinh(e))),zC={kernelName:kr,backendName:"cpu",kernelFunc:YC},BC=Math.log(1.1920928955078125e-7)+2,PC=Ik(Ir,(e=>{const t=e>-BC,n=e=u)throw new Error(Of(t,n,u));++f[n],d=d&&n>=h,h=n}let m=!0;for(let e=0;e0&&(f[e]+=f[e-1])}if(m&&d){const t=e,n=r;for(let e=0;eNumber(e))))),n.makeTensorInfo([m.length],r.dtype,new Int32Array(m))]}};function WC(e,t,n,r,a){const i=ce(r),s=t[0],o=a.length,u=[];let l=1,c=-1;for(let e=0;e0){d[p-1]=1;for(let e=p-2;e>=0;--e)d[e]=d[e+1]*r[e+1]}const h=[];if(o>0){h[o-1]=1;for(let e=o-2;e>=0;--e)h[e]=h[e+1]*u[e+1]}const f=Me(n,s*o);for(let t=0;t0?a[o-1]+1:0;if(c<0)throw new Error("segment ids must be >= 0");const p=t.slice();p[0]=c;const d=p.reduce(((e,t)=>e*t),1),h=Me(n,d);if(0===o)return c>0&&h.fill(s),[h,p];if(c<=0)throw new Error("segment ids must be >= 0");let f=0,m=1,g=0,y=a[f];for(;;){let t=0;if(m=t)throw new Error("segment ids are not increasing")}if(y<0||y>=c)throw new Error(jf(y,c));y>g&&h.fill(s,g*l,y*l);for(let t=f;t=u[0])throw new Error(Uf(t,r[t],u[0]));for(let t=0;to)break}return g{const t=[...c];t[o]=e;const r=GD({inputs:{x:a},backend:n,attrs:{begin:l,size:t}});return l[o]+=e,r}))}},QC=qk((e=>Math.sqrt(e))),eA=Ik(Er,(e=>Math.sqrt(e))),tA={kernelName:Er,backendName:"cpu",kernelFunc:eA},nA={kernelName:Pr,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{const{x:n}=e,r=t;kk(n,"square");const a=r.data.get(n.dataId).values,i=new Float32Array(a.length);for(let e=0;e{const n=e-t;return n*n})),aA=rD(Br,rA),iA={kernelName:Br,backendName:"cpu",kernelFunc:aA},sA=Ik(aa,((e,t)=>{const n=t;return isNaN(e)?NaN:e>0?1:n.alpha})),oA={kernelName:aa,backendName:"cpu",kernelFunc:sA};function uA(e,t,n,r){const a=As(e,t.dtype);for(let e=0;e=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=Wo(b,x,v),t=GD({inputs:{x:a},backend:n,attrs:{begin:b,size:e}});_=lD({inputs:{x:t},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(t)}else{const e=uA(h,n.bufferSync(a),v,b);_=n.makeTensorInfo(f,e.dtype,e.values)}return _}};class cA{constructor(e,t,n,r,a,i){this.separator=Pa(e),this.nGramWidths=t,this.leftPad=Pa(n),this.rightPad=Pa(r),this.padWidth=a,this.preserveShort=i}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){const n=this.getPadWidth(t);return Math.max(0,e+2*n-t+1)}createNGrams(e,t,n,r,a,i){for(let s=0;s0?0:s-o);let d=0;d+=u*this.leftPad.length;for(let t=0;te.forEach((e=>h[f++]=e));for(let e=0;e0){m(e[p+c-1]);for(let e=0;e0){let e=t[0];if(0!==e)throw new Error(`First split value must be 0, got ${e}`);for(let a=1;a=e;if(r=r&&t[a]<=n,!r)throw new Error(`Invalid split value ${t[a]}, must be in [${e}, ${n}]`);e=t[a]}if(e!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${e}`)}const a=r-1,i=Me("int32",r);if(0===n||0===r){const e=new Array(n);for(let e=0;e<=a;++e)i[e]=0;return[e,i]}i[0]=0;for(let e=1;e<=a;++e){const n=t[e]-t[e-1];let r=0;this.nGramWidths.forEach((e=>{r+=this.getNumNGrams(n,e)})),this.preserveShort&&n>0&&0===r&&(r=1),i[e]=i[e-1]+r}const s=new Array(i[a]);for(let n=0;n{const o=t[n+1]-t[n],u=this.getNumNGrams(o,i);this.createNGrams(e,r,s,a,u,i),a+=u})),this.preserveShort&&a===i[n]){const i=t[n+1]-t[n];if(0===i)continue;const o=i+2*this.padWidth,u=1;this.createNGrams(e,r,s,a,u,o)}}return[s,i]}}function pA(e,t,n,r,a,i,s,o){return new cA(n,r,a,i,s,o).compute(e,t)}const dA={kernelName:jr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{separator:a,nGramWidths:i,leftPad:s,rightPad:o,padWidth:u,preserveShortSequences:l}=r,{data:c,dataSplits:p}=t,d=n.data.get(c.dataId).values,h=n.data.get(p.dataId).values,[f,m]=pA(d,h,a,i,s,o,u,l);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}};function hA(e,t,n,r){if(!e.length)return;if(0===t.length){for(let t=0;tMath.tan(e))),xA={kernelName:Vr,backendName:"cpu",kernelFunc:bA},vA=Ik(Gr,(e=>Math.tanh(e)));function _A(e,t){const n=new Array(e.rank);for(let r=0;r{const n=t.value-e.value;return 0===n?e.index-t.index:n};function NA(e,t,n=0,r=e.length-1){for(;r>n;){if(r-n>600){const a=r-n+1,i=t-n+1,s=Math.log(a),o=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*o*(a-o)/a)*Math.sign(i-a/2);NA(e,t,Math.max(n,Math.floor(t-i*o/a+u)),Math.min(r,Math.floor(t+(a-i)*o/a+u)))}const a=e[t];let i=n,s=r;for(ne(e,n,t),MA(e[r],a)>0&&ne(e,n,r);i0;)s-=1}0===MA(e[n],a)?ne(e,n,s):(s+=1,ne(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function SA(e,t,n,r,a){const i=t[t.length-1],[s,o]=[e.length/i,i],u=we(n,s*r),l=we("int32",s*r);for(let t=0;ts[t]={value:e,index:t})),rt-1)if(t<=1)n=0;else{const e=2*t;n-=e*Math.trunc(n/e),n>=t&&(n=e-n-1)}return ee(0,n,t-1)}(e,t);case"wrap":return function(e,t){let n=e;if(n<0)if(t<=1)n=0;else{const e=t-1;n+=t*(Math.trunc(-n/e)+1)}else if(n>t-1)if(t<=1)n=0;else{const e=t-1;n-=t*Math.trunc(n/e)}return ee(0,n,t-1)}(e,t);case"nearest":return function(e,t){return ee(0,e,t-1)}(e,t);default:return function(e,t){return e}(e)}}function IA(e,t,n,r,a,i,s,o,u,l,c){return 0<=o&&o{for(let n=0;nn.disposeIntermediateTensorInfo(e))),p}},RA=[hD,mD,yD,xD,uD,vD,ND,SD,kD,DD,ID,CD,LD,RD,YD,HD,jD,UD,qD,dD,WD,JD,QD,eT,nD,rT,iT,Xk,sT,pT,hT,fT,mT,gT,yT,bT,vT,wT,MT,NT,ST,kT,DT,IT,ET,CT,AT,LT,$T,OT,HT,Ak,jT,WT,eI,rI,iI,uI,xI,_I,wI,SI,TI,II,EI,AI,$I,FI,BI,$k,PI,lT,jI,qI,VI,Rk,JI,QI,tE,aE,sE,lE,pE,fE,mE,gE,xE,wE,ME,NE,SE,kE,DE,TE,IE,AE,LE,RE,zE,zT,PE,jE,qE,VE,JE,XE,eC,nC,rC,sC,Bk,uC,cC,eD,pI,dC,Hk,Uk,cD,hC,fC,mC,gC,yC,bC,vC,MC,SC,TC,IC,LC,Gk,OC,FC,zC,KD,YE,HC,jC,qC,VC,KC,JC,XC,ZC,tA,nA,iA,oA,lA,dA,mA,yA,mI,PT,xA,{kernelName:Gr,backendName:"cpu",kernelFunc:vA},wA,kA,DA,MD,LA,$A,OA,QE];for(const e of RA)ya(e);const FA={},YA={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function zA(e,t){if(!(e in FA)||null!=t){const n=function(e,t){if(1!==e&&2!==e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const n=null==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):t;return n.addEventListener("webglcontextlost",(t=>{t.preventDefault(),delete FA[e]}),!1),1===e?n.getContext("webgl",YA)||n.getContext("experimental-webgl",YA):n.getContext("webgl2",YA)}(e,t);if(null===n)return console.log("Could not get context for WebGL version",e),null;FA[e]=n}const n=FA[e];return null==n||n.isContextLost()?(delete FA[e],zA(e)):(n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.disable(n.BLEND),n.disable(n.DITHER),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SAMPLE_COVERAGE),n.enable(n.SCISSOR_TEST),n.enable(n.CULL_FACE),n.cullFace(n.BACK),FA[e])}var BA,PA,HA;function jA(e,t){return[t,e]}function UA(e){const t=ce(e);return me(Math.ceil(t/4))}function qA(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function WA(e,t){const n=e;let r,a,i,s,o,u,l,c,p,d;return 2===Ge().getNumber("WEBGL_VERSION")?(r=n.R32F,a=n.R16F,i=n.RGBA16F,s=n.RGBA32F,o=n.RED,l=4,c=1,p=n.HALF_FLOAT,d=n.FLOAT,u=n.RGBA8):(r=e.RGBA,a=e.RGBA,i=e.RGBA,s=n.RGBA,o=e.RGBA,l=4,c=4,p=null!=t?t.HALF_FLOAT_OES:null,d=e.FLOAT,u=e.RGBA),{internalFormatFloat:r,internalFormatHalfFloat:a,internalFormatPackedHalfFloat:i,internalFormatPackedFloat:s,textureFormatFloat:o,downloadTextureFormat:u,downloadUnpackNumChannels:l,defaultNumChannels:c,textureTypeHalfFloat:p,textureTypeFloat:d}}function VA(e,t){const n=t();return Ge().getBool("DEBUG")&&function(e){const t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+function(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}`}}(e,t))}(e),n}function GA(e){return!!(Ge().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||5.96e-8e.getExtension(t)),'Extension "'+t+'" not supported on this browser.')}!function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"}(BA||(BA={})),function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"}(PA||(PA={})),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"}(HA||(HA={}));const JA=/ERROR: [0-9]+:([0-9]+):/g;function XA(e,t){const n=JA.exec(t);if(null==n)return console.log(`Couldn't parse line number in error: ${t}`),void console.log(e);const r=+n[1],a=e.split("\n"),i=a.length.toString().length+2,s=a.map(((e,t)=>ye((t+1).toString(),i)+e));let o=0;for(let e=0;ee.validateProgram(t))),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function QA(e,t,n,r,a,i,s){const o=e.getAttribLocation(t,n);return-1!==o&&(VA(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,r))),VA(e,(()=>e.vertexAttribPointer(o,a,e.FLOAT,!1,i,s))),VA(e,(()=>e.enableVertexAttribArray(o))),!0)}function eL(e,t,n,r){VA(e,(()=>function(e,t,n){(function(e,t){const n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+e.TEXTURE0;if(rn)throw new Error(`textureUnit must be in [gl.TEXTURE0, gl.TEXTURE${n}].`)})(e,n),VA(e,(()=>e.activeTexture(e.TEXTURE0+n))),VA(e,(()=>e.bindTexture(e.TEXTURE_2D,t)))}(e,t,r))),VA(e,(()=>e.uniform1i(n,r)))}function tL(e,t,n){VA(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,n))),VA(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)))}function nL(e,t){VA(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,t))),VA(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)))}function rL(e){const t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+function(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}`}}(e,t))}function aL(e,t,n){const r=VA(e,(()=>t()));if(null==r)throw new Error(n);return r}function iL(e,t=2){return ce(e.slice(0,e.length-t))}function sL(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 oL(e){let t=[1,1,1];return 0===e.length||1===e.length&&1===e[0]||(t=[iL(e),...sL(e)]),t}function uL(e){return e%2==0}function lL(e,t){if(de(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){const n=e.slice(-1)[0],r=t.slice(-1)[0];if(n===r)return!0;if(uL(n)&&uL(r)&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&uL(e[0])&&uL(t[0])}let cL,pL;function dL(e,t){return null!=e.getExtension(t)}function hL(e){try{if(null!=zA(e))return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function fL(e){const t=WA(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);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);const a=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),a}function mL(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&se("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the WebGL backend.`))}))}const gL=Ge();function yL(){let e,t,n,r,a,i,s,o,u,l;return 2===Ge().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",n="out",r="in",a="texture",i="outputColor",s="out vec4 outputColor;",o="\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\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="",l="\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",a="texture2D",i="gl_FragColor",s="",o="\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 ",l="\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:a,output:i,defineOutput:s,defineSpecialNaN:o,defineSpecialInf:u,defineRound:l}}function bL(e,t,n="index"){const r=Re(t);return r.map(((t,a)=>`int ${e[a]} = ${n} / ${t}; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * ${t}`:`index -= ${e[a]} * ${t}`};`)).join("")}function xL(e,t,n="index"){const r=Re(t);return r.map(((t,a)=>`int ${e[a]} = ${n} / outShapeStrides[${a}]; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * outShapeStrides[${a}]`:`index -= ${e[a]} * outShapeStrides[${a}]`};`)).join("")}function vL(e){const t=Re(e).map((e=>e.toString()));return`\n int getFlatIndex(ivec3 coords) {\n return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;\n }\n`}gL.registerFlag("HAS_WEBGL",(()=>gL.getNumber("WEBGL_VERSION")>0)),gL.registerFlag("WEBGL_VERSION",(()=>hL(2)?2:hL(1)?1:0)),gL.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",(()=>!1)),gL.registerFlag("WEBGL_BUFFER_SUPPORTED",(()=>2===gL.get("WEBGL_VERSION"))),gL.registerFlag("WEBGL_CPU_FORWARD",(()=>!0)),gL.registerFlag("WEBGL_FORCE_F16_TEXTURES",(()=>!1)),gL.registerFlag("WEBGL_PACK",(()=>gL.getBool("HAS_WEBGL"))),gL.registerFlag("WEBGL_PACK_NORMALIZATION",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_CLIP",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_DEPTHWISECONV",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_REDUCE",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_LAZILY_UNPACK",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_CONV_IM2COL",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(()=>function(e){if(null==cL){const t=zA(e);cL=t.getParameter(t.MAX_TEXTURE_SIZE)}return cL}(gL.getNumber("WEBGL_VERSION")))),gL.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(()=>function(e){if(null==pL){const t=zA(e);pL=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,pL)}(gL.getNumber("WEBGL_VERSION")))),gL.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(()=>{const e=gL.getNumber("WEBGL_VERSION");return 0===e?0:function(e){if(0===e)return 0;let t;const n=zA(e);return t=dL(n,"EXT_disjoint_timer_query_webgl2")&&2===e?2:dL(n,"EXT_disjoint_timer_query")?1:0,t}(e)})),gL.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(()=>gL.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!Si())),gL.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(()=>function(e){if(0===e)return!1;const t=zA(e);if(1===e){if(!dL(t,"OES_texture_float"))return!1}else if(!dL(t,"EXT_color_buffer_float"))return!1;return fL(t)}(gL.getNumber("WEBGL_VERSION")))),gL.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(()=>!gL.getBool("WEBGL_FORCE_F16_TEXTURES")&&gL.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))),gL.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(()=>function(e){if(0===e)return!1;const t=zA(e);if(1!==e){if(dL(t,"EXT_color_buffer_float"))return fL(t);const e="EXT_color_buffer_half_float";if(dL(t,e)){const n=t.getExtension(e);return function(e,t){const n=WA(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);const a=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);const i=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(a),i}(t,n)}return!1}return!!dL(t,"OES_texture_float")&&!!dL(t,"WEBGL_color_buffer_float")&&fL(t)}(gL.getNumber("WEBGL_VERSION")))),gL.registerFlag("WEBGL_FENCE_API_ENABLED",(()=>{return 2===(e=gL.getNumber("WEBGL_VERSION"))&&null!=zA(e).fenceSync;var e})),gL.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(()=>gL.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0)),gL.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",(()=>-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`)})),gL.registerFlag("WEBGL_FLUSH_THRESHOLD",(()=>Si()?1:-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`)})),gL.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",(()=>128)),gL.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",(()=>!1)),gL.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",(()=>1e5)),gL.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",(()=>128));const _L="\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",{getBroadcastDims:wL}=g;function ML(e,t,n){const r=[];if(e.forEach((e=>{const t=ce(e.shapeInfo.logicalShape);if(e.shapeInfo.isUniform?r.push(`uniform float ${e.name}${t>1?`[${t}]`:""};`):(r.push(`uniform sampler2D ${e.name};`),r.push(`uniform int offset${e.name};`)),n.enableShapeUniforms){const{uniformShape:t}=LL(n.packedInputs,e.shapeInfo.logicalShape,e.shapeInfo.texShape);switch(t.length){case 1:r.push(`uniform int ${e.name}Shape;`);break;case 2:r.push(`uniform ivec2 ${e.name}Shape;`);break;case 3:r.push(`uniform ivec3 ${e.name}Shape;`);break;case 4:r.push(`uniform ivec4 ${e.name}Shape;`)}r.push(`uniform ivec2 ${e.name}TexShape;`)}})),n.enableShapeUniforms){switch(t.logicalShape.length){case 1:r.push("uniform int outShape;");break;case 2:r.push("uniform ivec2 outShape;"),r.push("uniform int outShapeStrides;");break;case 3:r.push("uniform ivec3 outShape;"),r.push("uniform ivec2 outShapeStrides;");break;case 4:r.push("uniform ivec4 outShape;"),r.push("uniform ivec3 outShapeStrides;")}r.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach((e=>{r.push(`uniform ${e.type} ${e.name}${e.arrayIndex?`[${e.arrayIndex}]`:""};`)}));const a=r.join("\n"),i=e.map((e=>function(e,t,n=!1,r){let a="";a+=n?SL(e,r):NL(e,r);const i=e.shapeInfo.logicalShape,s=t.logicalShape;return i.length<=s.length&&(a+=n?function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",i=e.shapeInfo.logicalShape.length,s=t.logicalShape.length,o=wL(e.shapeInfo.logicalShape,t.logicalShape),u=AL(s),l=s-i;let c;const p=["x","y","z","w","u","v"];c=0===i?"":s<2&&o.length>=1?"coords = 0;":o.map((e=>`coords.${p[e+l]} = 0;`)).join("\n");let d="";d=s<2&&i>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${p[t+l]}`)).join(", ");let h="return outputValue;";const f=1===ce(e.shapeInfo.logicalShape),m=1===ce(t.logicalShape);if(1!==i||f||m){if(f&&!m)h=1===s?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(o.length){const e=i-2,t=i-1;o.indexOf(e)>-1&&o.indexOf(t)>-1?h="return vec4(outputValue.x);":o.indexOf(e)>-1?h="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":o.indexOf(t)>-1&&(h="return vec4(outputValue.xx, outputValue.zz);")}}else h="\n return vec4(outputValue.xy, outputValue.xy);\n ";return`\n vec4 ${a}() {\n ${u} coords = getOutputCoords();\n ${c}\n vec4 outputValue = get${r}(${d});\n ${h}\n }\n `}(e,t):function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",i=t.texShape,s=e.shapeInfo.texShape,o=e.shapeInfo.logicalShape.length,u=t.logicalShape.length;if(!e.shapeInfo.isUniform&&o===u&&null==e.shapeInfo.flatOffset&&de(s,i))return`\n float ${a}() {\n return sampleTexture(${n}, resultUV);\n }\n `;const l=AL(u),c=wL(e.shapeInfo.logicalShape,t.logicalShape),p=u-o;let d;const h=["x","y","z","w","u","v"];d=0===o?"":u<2&&c.length>=1?"coords = 0;":c.map((e=>`coords.${h[e+p]} = 0;`)).join("\n");let f="";return f=u<2&&o>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${h[t+p]}`)).join(", "),`\n float ${a}() {\n ${l} coords = getOutputCoords();\n ${d}\n return get${r}(${f});\n }\n `}(e,t)),a}(e,t,n.packedInputs,n.enableShapeUniforms))).join("\n"),s=t.texShape,o=yL(),u=function(e){return`\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ${e.texture2D}(textureSampler, uv).r;\n }\n `}(o);let l,c,p=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 ${kL}\n ${DL}\n ${TL}\n `}(o);return t.isPacked?(l=function(e,t,n){switch(e.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return 1===r[0]?n?"\n int getOutputCoords() {\n return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.x * ${r[1]}.0);\n }\n `:1===r[1]?n?"\n int getOutputCoords() {\n return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.y * ${r[0]}.0);\n }\n `:n?"\n int getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);\n }\n ":`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n return 2 * (resTexRC.x * ${r[1]} + resTexRC.y);\n }\n `}(0,t,n);case 2:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(de(e,t))return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n ":`\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2(${r[0]}, ${r[1]}));\n }\n `;const a=Math.ceil(e[1]/2);return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec2(r, c);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec2(r, c);\n }\n `}(e,t,n);case 3:return function(e,t,n){if(n)return"\n ivec3 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec3(b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[2]/2),i=a*Math.ceil(e[1]/2);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[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 `}(e,t,n);default:return function(e,t,n){if(n)return"\n ivec4 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatchN = texelsInBatch * outShape[1];\n\n int b2 = index / texelsInBatchN;\n index -= b2 * texelsInBatchN;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec4(b2, b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[e.length-1]/2),i=a*Math.ceil(e[e.length-2]/2);let s=i,o="",u="b, r, c";for(let t=2;t1&&!de(t,n)&&r.lengthe[t])).join(", ")}function RL(e,t,n){const r={},a={},i={},s=[];let o,u,l,c=null,p=null;p=e.getUniformLocation(n,"NAN",!1),1===Ge().getNumber("WEBGL_VERSION")&&(c=e.getUniformLocation(n,"INFINITY",!1));const d=!1;for(let s=0;s{s[r]=e.getUniformLocation(n,t.name,d)})),{uniformLocations:r,customUniformLocations:s,infLoc:c,nanLoc:p,inShapesLocations:a,inTexShapesLocations:i,outShapeLocation:o,outShapeStridesLocation:l,outTexShapeLocation:u}}function FL(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(((e,n)=>{const r=e.logicalShape,a=t[n],i=a.shape;if(!de(r,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${i} must match`);if(e.isUniform&&a.isUniform)return;const s=e.texShape,o=a.isUniform?null:a.texData.texShape;if(!de(s,o))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${s} and ${o} must match`)}))}function YL(e){return Ge().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}class zL{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=BA.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=yL();this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?xL(["r","c","d"],e):bL(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[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 ${t.output} = result;\n }\n `}}class BL{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=BA.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=yL();this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?xL(["r","c","d"],e):bL(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[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 ${t.output} = result;\n }\n `}}class PL{constructor(e){this.variableNames=["A"],this.outTexUsage=PA.DOWNLOAD;const t=yL();this.outputShape=e,this.userCode=`\n ${_L}\n\n void main() {\n float x = getAAtOutCoords();\n ${t.output} = encode_float(x);\n }\n `}}class HL{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=PA.DOWNLOAD;const t=yL();this.outputShape=e,this.userCode=`\n ${_L}\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 `}}class jL{constructor(e,t=!1){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=yL();this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length);let r="result";t&&(r="floor(result * 255. + 0.5)"),this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":vL(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 / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n vec4 values = ${n.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 ${n.output} = vec4(${r}, 0., 0., 0.);\n }\n `}}class UL{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=yL();this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length);let r="",a="result";t&&(a="floor(result * 255. + 0.5)");for(let t=0;t<=1;t++)for(let a=0;a<=1;a++){const i=2*t+a;r+=`\n localCoords = coords;\n if(localCoords[2] + ${a} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) {\n localCoords[2] += ${a};\n if (localCoords[1] + ${t} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) {\n localCoords[1] += ${t};\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n values = ${n.texture2D}(A, uv);\n\n if (offset == 0) {\n result[${i}] = values[0];\n } else if (offset == 1) {\n result[${i}] = values[1];\n } else if (offset == 2) {\n result[${i}] = values[2];\n } else {\n result[${i}] = values[3];\n }\n }\n }\n `}this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":vL(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 ${r}\n\n ${n.output} = ${a};\n }\n `}}function qL(e,t,n,r,a,i){!function(e,t){const n=Ge().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0)throw new Error(`Requested texture size [${e}x${t}] is invalid.`);if(e>n||t>n)throw new Error(`Requested texture size [${e}x${t}] greater than WebGL maximum on this browser / GPU [${n}x${n}].`)}(t,n);const s=function(e){return aL(e,(()=>e.createTexture()),"Unable to create WebGLTexture.")}(e),o=e.TEXTURE_2D;return VA(e,(()=>e.bindTexture(o,s))),VA(e,(()=>e.texParameteri(o,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE))),VA(e,(()=>e.texParameteri(o,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE))),VA(e,(()=>e.texParameteri(o,e.TEXTURE_MIN_FILTER,e.NEAREST))),VA(e,(()=>e.texParameteri(o,e.TEXTURE_MAG_FILTER,e.NEAREST))),1===Ge().getNumber("WEBGL_VERSION")?VA(e,(()=>e.texImage2D(o,0,r,t,n,0,a,i,null))):VA(e,(()=>e.texStorage2D(o,1,r,t,n))),VA(e,(()=>e.bindTexture(e.TEXTURE_2D,null))),{texture:s,texShape:[n,t]}}function WL(e){return e.internalFormatFloat}function VL(e){return e.internalFormatHalfFloat}function GL(e){return e.downloadTextureFormat}function KL(e){return e.internalFormatPackedFloat}function JL(e){return e.internalFormatPackedHalfFloat}class XL{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];const t=Ge().getNumber("WEBGL_VERSION");null!=e?(this.gl=e,function(e,t){FA[e]=t}(t,e)):this.gl=zA(t);let n="WEBGL_color_buffer_float";const r="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),1===Ge().getNumber("WEBGL_VERSION")){const e="OES_texture_float",t="OES_texture_half_float";if(this.textureFloatExtension=KA(this.gl,e),dL(this.gl,t))this.textureHalfFloatExtension=KA(this.gl,t);else if(Ge().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),dL(this.gl,r))this.colorBufferHalfFloatExtension=KA(this.gl,r);else if(Ge().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",dL(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!dL(this.gl,r))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension(r)}this.vertexBuffer=function(e){return function(e,t){const n=aL(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return VA(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),VA(e,(()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW))),n}(e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}(this.gl),this.indexBuffer=function(e){return function(e,t){const n=aL(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return VA(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n))),VA(e,(()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW))),n}(e,new Uint16Array([0,1,2,2,1,3]))}(this.gl),this.framebuffer=function(e){return aL(e,(()=>e.createFramebuffer()),"Unable to create WebGLFramebuffer.")}(this.gl),this.textureConfig=WA(this.gl,this.textureHalfFloatExtension)}get debug(){return Ge().getBool("DEBUG")}dispose(){if(this.disposed)return;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.");const e=this.gl;VA(e,(()=>e.finish())),VA(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,null))),VA(e,(()=>e.deleteFramebuffer(this.framebuffer))),VA(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,null))),VA(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null))),VA(e,(()=>e.deleteBuffer(this.indexBuffer))),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=jA(t,n);return qL(e,a,i,WL(r),r.textureFormatFloat,e.FLOAT)}(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=jA(t,n);return qL(e,a,i,VL(r),r.textureFormatFloat,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=jA(t,n);return qL(e,a,i,GL(r),e.RGBA,e.UNSIGNED_BYTE)}(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),function(e,t,n){VA(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),n.data instanceof Uint8Array?2===Ge().getNumber("WEBGL_VERSION")?VA(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,e.RGBA,e.UNSIGNED_BYTE,n.data))):VA(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data))):2===Ge().getNumber("WEBGL_VERSION")?VA(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n))):VA(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n))),VA(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,n,r){this.throwIfDisposed(),function(e,t,n,r,a,i){let s,o,u;VA(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),a instanceof Uint8Array?(s=new Uint8Array(n*r*4),o=e.UNSIGNED_BYTE,u=e.RGBA):(s=new Float32Array(n*r*4),o=e.FLOAT,u=i.internalFormatPackedFloat),s.set(a),2===Ge().getNumber("WEBGL_VERSION")?VA(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n,r,e.RGBA,o,s))):VA(e,(()=>e.texImage2D(e.TEXTURE_2D,0,u,n,r,0,e.RGBA,o,s))),VA(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}(this.gl,e,t,n,r,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=qA(t,n);return qL(e,a,i,JL(r),e.RGBA,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=qA(t,n);return qL(e,a,i,KL(r),e.RGBA,e.FLOAT)}(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(nL(this.gl,this.framebuffer),this.outputTexture=null),VA(this.gl,(()=>this.gl.deleteTexture(e)))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>function(e,t,n,r){const[a,i]=jA(t,n),s=new Uint8Array(t*n*4);return VA(e,(()=>e.readPixels(0,0,a,i,r.downloadTextureFormat,e.UNSIGNED_BYTE,s))),new Float32Array(s.buffer)}(this.gl,t,n,this.textureConfig)))}downloadPackedMatrixFromBuffer(e,t,n,r,a,i){return function(e,t,n,r,a,i,s,o){const u=e,l=new Float32Array(function(e,t){const[n,r]=qA(e,t);return n*r*4}(i,s));return u.bindBuffer(u.PIXEL_PACK_BUFFER,t),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,l),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),l}(this.gl,e,0,0,0,a,i,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return function(e,t,n){const r=e,a=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,a),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),a}(this.gl,e,t)}createBufferFromTexture(e,t,n){this.bindTextureToFrameBuffer(e);const r=function(e,t,n,r){const a=e.createBuffer();VA(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,a)));const i=16*t*n;return VA(e,(()=>e.bufferData(e.PIXEL_PACK_BUFFER,i,e.STREAM_READ))),VA(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0))),VA(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null))),a}(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,n;if(Ge().getBool("WEBGL_FENCE_API_ENABLED")){const r=e,a=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=()=>{const e=r.clientWaitSync(a,0,0);return e===r.ALREADY_SIGNALED||e===r.CONDITION_SATISFIED},t=a}else Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(t,Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:t,isFencePassed:n}}downloadMatrixFromPackedTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>function(e,t,n){const r=new Float32Array(t*n*4);return VA(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,r))),r}(this.gl,t,n)))}createProgram(e){this.throwIfDisposed();const t=this.gl;null==this.vertexShader&&(this.vertexShader=function(e){const t=yL();return function(e,t){const n=aL(e,(()=>e.createShader(e.VERTEX_SHADER)),"Unable to create vertex WebGLShader.");if(VA(e,(()=>e.shaderSource(n,t))),VA(e,(()=>e.compileShader(n))),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw console.log(e.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}(e,`${t.version}\n precision highp float;\n ${t.attribute} vec3 clipSpacePos;\n ${t.attribute} vec2 uv;\n ${t.varyingVs} vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }`)}(t));const n=function(e){return aL(e,(()=>e.createProgram()),"Unable to create WebGLProgram.")}(t);return VA(t,(()=>t.attachShader(n,this.vertexShader))),VA(t,(()=>t.attachShader(n,e))),function(e,t){if(VA(e,(()=>e.linkProgram(t))),!Ge().get("ENGINE_COMPILE_ONLY")&&!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")}(t,n),this.debug&&ZA(t,n),this.vertexAttrsAreBound||(this.setProgram(n),this.vertexAttrsAreBound=function(e,t,n){return VA(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),QA(e,t,"clipSpacePos",n,3,20,0)&&QA(e,t,"uv",n,2,20,12)}(t,this.program,this.vertexBuffer)),n}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&VA(this.gl,(()=>this.gl.deleteProgram(e)))}setProgram(e){this.throwIfDisposed(),this.program=e,null!=this.program&&this.debug&&ZA(this.gl,this.program),VA(this.gl,(()=>this.gl.useProgram(e)))}getUniformLocation(e,t,n=!0){return this.throwIfDisposed(),n?function(e,t,n){return aL(e,(()=>e.getUniformLocation(t,n)),'uniform "'+n+'" not present in program.')}(this.gl,e,t):function(e,t,n){return e.getUniformLocation(t,n)}(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),VA(this.gl,(()=>this.gl.getAttribLocation(e,t)))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,n){this.throwIfDisposed(),this.throwIfNoProgram(),eL(this.gl,e,t,n)}setOutputMatrixTexture(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)}setOutputPackedMatrixTexture(e,t,n){this.throwIfDisposed();const[r,a]=qA(t,n);this.setOutputMatrixTextureDriver(e,r,a)}setOutputMatrixWriteRegion(e,t,n,r){this.setOutputMatrixWriteRegionDriver(n,e,r,t)}setOutputPackedMatrixWriteRegion(e,t,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&ZA(this.gl,this.program),rL(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;this.debug&&this.debugValidate(),VA(e,(()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),VA(this.gl,(()=>this.gl.finish()))}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=KA(this.gl,2===Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(2===Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2(),n=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,n),n}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(2===Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2();return void e.endQuery(t.TIME_ELAPSED_EXT)}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await be((()=>this.disposed||this.isQueryAvailable(e,Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")))),this.getQueryTime(e,Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(0===t)return null;if(2===t){const t=this.gl;return t.getQueryParameter(e,t.QUERY_RESULT)/1e6}{const t=this.getQueryTimerExtensionWebGL1();return t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(0===t)return!0;if(2===t){const t=this.gl,n=this.getQueryTimerExtensionWebGL2(),r=t.getQueryParameter(e,t.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),r&&!this.disjoint}{const t=this.getQueryTimerExtensionWebGL1(),n=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(t.GPU_DISJOINT_EXT)),n&&!this.disjoint}}pollFence(e){return new Promise((t=>{this.addItemToPoll((()=>e.isFencePassed()),(()=>t()))}))}pollItems(){const e=function(e){let t=0;for(;te.isDoneFn)));for(let t=0;t<=e;++t){const{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1||be((()=>(this.pollItems(),0===this.itemsToPoll.length)))}bindTextureToFrameBuffer(e){this.throwIfDisposed(),tL(this.gl,e,this.framebuffer),this.debug&&rL(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?(tL(this.gl,this.outputTexture,this.framebuffer),this.debug&&rL(this.gl)):nL(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const n=t();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(e,t,n){this.throwIfDisposed();const r=this.gl;tL(r,e,this.framebuffer),this.debug&&rL(r),this.outputTexture=e,VA(r,(()=>r.viewport(0,0,t,n))),VA(r,(()=>r.scissor(0,0,t,n)))}setOutputMatrixWriteRegionDriver(e,t,n,r){this.throwIfDisposed(),VA(this.gl,(()=>this.gl.scissor(e,t,n,r)))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(null==this.program)throw new Error("No GPU program is currently set.")}}const{addImpl:ZL,bincountImpl:QL,bincountReduceImpl:e$,ceilImpl:t$,concatImpl:n$,equalImpl:r$,expImpl:a$,expm1Impl:i$,floorImpl:s$,gatherNdImpl:o$,gatherV2Impl:u$,greaterImpl:l$,greaterEqualImpl:c$,lessImpl:p$,lessEqualImpl:d$,linSpaceImpl:h$,logImpl:f$,maxImpl:m$,maximumImpl:g$,minimumImpl:y$,multiplyImpl:b$,negImpl:x$,notEqualImpl:v$,prodImpl:_$,rangeImpl:w$,rsqrtImpl:M$,scatterImpl:N$,sigmoidImpl:S$,simpleAbsImpl:k$,sliceImpl:D$,sparseFillEmptyRowsImpl:T$,sparseReshapeImpl:I$,sparseSegmentReductionImpl:E$,sqrtImpl:C$,stridedSliceImpl:A$,stringNGramsImpl:L$,stringSplitImpl:$$,stringToHashBucketFastImpl:O$,subImpl:R$,tileImpl:F$,topKImpl:Y$,transposeImpl:z$,uniqueImpl:B$}=q;function P$(e,t){return["x","y","z","w","u","v"].slice(0,t).map((t=>`${e}.${t}`))}function H$(e,t){return 1===t?[e]:P$(e,t)}class j${constructor(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=YL(this.outputShape.length),0===this.rank)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{const e=H$("rc",this.rank),t=AL(this.rank),n=this.getOutOfBoundsCondition(e),r=this.getSetup(e),a=this.getOutput(e);this.userCode=`\n void main() {\n ${t} rc = getOutputCoords();\n\n if(${n}) {\n setOutput(vec4(0));\n } else {\n ${r}\n\n setOutput(vec4(${a}));\n }\n }\n `}}getSourceCoordsArr(e){const t=[];for(let n=0;n<=1;n++)for(let r=0;r<=1;r++){let a=`${0===n?"r":"rp1"}, ${0===r?"c":"cp1"}`;for(let t=2;t ${this.enableShapeUniforms?"outShape":this.outputShape[0]}`;let t="";for(let n=this.rank-2;n= ${this.enableShapeUniforms?`outShape[${n}]`:this.outputShape[n]}`,n= ${n};\n bool rEdge = rp1 >= ${r};\n `}getOutput(e){const t=this.getSourceCoordsArr(e);return 1===this.rank?`getA(rc), (rc + 1 >= ${this.enableShapeUniforms?"outShape":this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0`:`getA(${t[0]}),\n cEdge ? 0. : getA(${t[1]}),\n rEdge ? 0. : getA(${t[2]}),\n rEdge || cEdge ? 0. : getA(${t[3]})`}}class U${constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length);let n="";for(let e=0;e<4;e++){let t="thisRC = rc;";e%2==1&&(t+="thisRC.z += 1;"),e>1&&(t+="thisRC.y += 1;"),n+=`\n ${t}\n ${e>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[${e}] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n ${e>0?"}":""}\n `}var r,a;this.userCode=`\n ${r=t,a=this.enableShapeUniforms,`\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ${a?function(e,t,n="index"){const r=e.map(((e,t)=>t)),a=function(e,t){const n=e.length,r=e.map((e=>`${t}[${e}]`)),a=new Array(n-1);a[n-2]=r[n-1];for(let e=n-3;e>=0;--e)a[e]=`(${a[e+1]} * ${r[e+1]})`;return a}(r,t);return a.map(((t,r)=>`int ${e[r]} = ${n} / ${a[r]}; ${r===a.length-1?`int ${e[r+1]} = ${n} - ${e[r]} * ${a[r]}`:`index -= ${e[r]} * ${a[r]}`};`)).join("")}(["r","c","d"],"inputShape"):bL(["r","c","d"],r)}\n return ivec3(r, c, d);\n }\n `}\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":vL(e)}\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]};\n int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]};\n\n ${n}\n\n setOutput(result);\n }\n `}}class q${constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}acquireTexture(e,t,n){const r=V$(t,n),a=G$(e,r,n);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);const i=W$(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=i,this.log();const e=this.freeTextures[a].shift();return this.usedTextures[a].push(e),e}let s;return r===HA.PACKED_2X2_FLOAT32?s=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===HA.PACKED_2X2_FLOAT16?s=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===HA.UNPACKED_FLOAT32?s=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===HA.UNPACKED_FLOAT16?s=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===HA.PACKED_4X1_UNSIGNED_BYTE&&(s=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[a].push(s),this.numUsedTextures++,this._numBytesAllocated+=i,this.log(),s}releaseTexture(e,t,n,r){if(null==this.freeTextures)return;const a=V$(n,r),i=G$(t,a,r);i in this.freeTextures||(this.freeTextures[i]=[]);const s=W$(t,a,this.gpgpu.gl,this.gpgpu.textureConfig,r),o=Ge().get("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==o&&this._numBytesAllocated>o?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=s):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=s),this.numUsedTextures--;const u=this.usedTextures[i],l=u.indexOf(e);if(l<0)throw new Error("Cannot release a texture that was never provided by this texture manager");u.splice(l,1),this.log()}log(){if(!this.logEnabled)return;const e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);const t=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*t)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(null!=this.freeTextures){for(const e in this.freeTextures)this.freeTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e.texture)}));for(const e in this.usedTextures)this.usedTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e.texture)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function W$(e,t,n,r,a){const i=function(e,t){switch(e){case HA.PACKED_2X2_FLOAT32:return KL(t);case HA.PACKED_2X2_FLOAT16:return JL(t);case HA.UNPACKED_FLOAT32:return WL(t);case HA.UNPACKED_FLOAT16:return VL(t);case HA.PACKED_4X1_UNSIGNED_BYTE:return GL(t);default:throw new Error(`Unknown physical texture type ${e}`)}}(t,r);let s;if(a){const[t,n]=qA(e[0],e[1]);s=t*n}else{const[t,n]=jA(e[0],e[1]);s=t*n}const o=function(e,t){const n=e;if(t===n.R32F)return 4;if(t===n.R16F)return 2;if(t===n.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===n.RGBA16F)return 8;if(t===n.RGBA8)return 4;throw new Error(`Unknown internal format ${t}`)}(n,i);return s*o}function V$(e,t){if(e===PA.UPLOAD)return HA.PACKED_2X2_FLOAT32;if(e===PA.RENDER||null==e)return function(e){return Ge().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?HA.PACKED_2X2_FLOAT32:HA.UNPACKED_FLOAT32:e?HA.PACKED_2X2_FLOAT16:HA.UNPACKED_FLOAT16}(t);if(e===PA.DOWNLOAD||e===PA.PIXELS)return HA.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function G$(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`}class K${constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length),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 `}}const J$="return abs(x);",X$="return x;";class Z${constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length),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 `}}class Q${constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length);const t=e.length,n=H$("rc",t),r=AL(t),a=function(e,t){if(1===e)return"rc";let n="";for(let r=0;rt.push(e)))}const t=this.texData.get(e),{values:n,shape:r,slice:a,dtype:i,complexTensorInfos:s,isPacked:o}=t;if(null!=a){let t;t=o?new Z$(r,X$):new K$(r,X$);const n=this.runWebGLProgram(t,[{dataId:e,shape:r,dtype:i}],i),a=this.read(n.dataId);return this.disposeIntermediateTensorInfo(n),a}if(null!=n)return this.convertAndCacheOnCPU(e);if(Ge().getBool("DEBUG")&&!Ge().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===Ge().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let u,l,c=null;if("complex64"!==i&&Ge().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);const t=this.texData.get(u.dataId);c=this.gpgpu.createBufferFromTexture(t.texture.texture,...UA(r))}if(this.pendingRead.set(e,[]),"complex64"!==i&&await this.gpgpu.createAndWaitForFence(),"complex64"===i){const e=await Promise.all([this.read(s.real.dataId),this.read(s.imag.dataId)]);l=yf(e[0],e[1])}else if(null==c)l=this.getValuesFromTexture(e);else{const e=ce(r);l=this.gpgpu.downloadFloat32MatrixFromBuffer(c,e)}if(null!=u&&this.disposeIntermediateTensorInfo(u),null!=c){const e=this.gpgpu.gl;VA(e,(()=>e.deleteBuffer(c)))}const p=this.convertAndCacheOnCPU(e,l),d=this.pendingRead.get(e);return this.pendingRead.delete(e),d.forEach((e=>e(p))),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&lo().removeDataId(e,this),this.pendingDeletes--),p}readToGPU(e,t={}){const n=this.texData.get(e),{values:r,shape:a,slice:i,dtype:s,isPacked:o,texture:u}=n;if("complex64"===s)throw new Error("Does not support reading texture for complex64 dtype.");if(null!=i){let n;n=o?new Z$(a,X$):new K$(a,X$);const r=this.runWebGLProgram(n,[{dataId:e,shape:a,dtype:s}],s),i=this.readToGPU(r,t);return this.disposeIntermediateTensorInfo(r),i}if(null==u)throw null!=r?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const l=this.decode(e,t.customTexShape),c=lo().makeTensorFromTensorInfo(l),p=this.texData.get(l.dataId);return Object.assign({tensorRef:c},p.texture)}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map((e=>Ha(e)));return As(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return As(e.shape,e.dtype,t)}checkNumericalProblems(e){if(null!=e)for(let t=0;t0}time(e){const t=this.activeTimers,n=[];let r=!1;null==this.programTimersStack?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,e();const a=le(this.activeTimers.map((e=>e.query))).filter((e=>null!=e)),i=le(this.activeTimers.map((e=>e.name))).filter((e=>null!=e));this.activeTimers=t,r&&(this.programTimersStack=null);const s={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const e=await Promise.all(a);s.kernelMs=re(e),s.getExtraProfileInfo=()=>e.map(((e,t)=>({name:i[t],ms:e}))).map((e=>`${e.name}: ${e.ms}`)).join(", ")}else s.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,s})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:za(),endMs:null}}endTimer(e){return Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=za(),e)}async getQueryTime(e){if(Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(e);const t=e;return t.endMs-t.startMs}disposeData(e,t=!1){if(this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(t?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!t&&this.texData.get(e).refCount>0)return!1;if(this.pendingRead.has(e))return this.pendingDisposal.add(e),this.pendingDeletes++,!1;this.releaseGPUData(e);const{complexTensorInfos:n}=this.texData.get(e);return null!=n&&(this.disposeData(n.real.dataId,t),this.disposeData(n.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:n,texShape:r,usage:a,isPacked:i,slice:s}=this.texData.get(e),o=s&&s.origDataId||e,u=this.dataRefCount.get(o);u>1?this.dataRefCount.set(o,u-1):(this.dataRefCount.delete(o),null!=t&&(this.numBytesInGPU-=this.computeBytes(r,n),this.textureManager.releaseTexture(t,r,a,i)));const l=this.texData.get(e);l.texture=null,l.texShape=null,l.isPacked=!1,l.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=nO){return Ge().getBool("WEBGL_CPU_FORWARD")&&e.every((e=>null==this.texData.get(e.dataId).texture&&ce(e.shape)0&&Ee(n[0])){const a=n.map((e=>Pa(e)));r=this.write(a,e,t)}else r=this.write(n,e,t);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:t}}makeOutput(e,t,n){return lo().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,n),this)}unpackTensor(e){const t=new Q$(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new j$(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const n=[iL(e.shape),...sL(e.shape)],r={dtype:e.dtype,shape:n,dataId:e.dataId},a=[iL(t),...sL(t)],i=new U$(a,n),s=[n],o=this.runWebGLProgram(i,[r],e.dtype,s,!0);return{dataId:o.dataId,shape:t,dtype:o.dtype}}decode(e,t){const n=this.texData.get(e),{isPacked:r,shape:a,dtype:i}=n;null!=t&&se(ce(a)<=t[0]*t[1]*4,(()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data."));const s=oL(a);let o;o=r?new BL(s):new zL(s);const u=[null!=t?t:UA(s)];return{dtype:i,shape:a,dataId:this.runWebGLProgram(o,[{shape:s,dtype:i,dataId:e}],i,u,!0,t).dataId}}runWebGLProgram(e,t,n,r,a=!1,i){const s=this.makeTensorInfo(e.outputShape,n),o=this.texData.get(s.dataId);if(e.packedOutput&&(o.isPacked=!0),e.outPackingScheme===BA.DENSE){const t=null!=i?i:UA(e.outputShape);o.texShape=t.map((e=>2*e))}if(null!=e.outTexUsage&&(o.usage=e.outTexUsage),0===ce(s.shape))return o.values=we(s.dtype,0),s;const u=[],l=t.map((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.");let n=this.texData.get(t.dataId);if(null==n.texture){if(!e.packedInputs&&ce(t.shape)<=Ge().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)}if(this.uploadToGPU(t.dataId),!!n.isPacked!=!!e.packedInputs)t=n.isPacked?this.unpackTensor(t):this.packTensor(t),u.push(t),n=this.texData.get(t.dataId);else if(n.isPacked&&!lL(n.shape,t.shape)){const e=t,r=t.shape;t.shape=n.shape,t=this.packedReshape(t,r),u.push(t),n=this.texData.get(t.dataId),e.shape=r}return{shape:t.shape,texData:n,isUniform:!1}}));this.uploadToGPU(s.dataId);const c={shape:s.shape,texData:o,isUniform:!1},p=function(e,t,n){let r="";t.concat(n).forEach((t=>{const a=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0;if(e.enableShapeUniforms&&!t.isUniform){const i=t.texData.texShape,{useSqueezeShape:s,uniformShape:o,keptDims:u}=LL(e.packedInputs,t.shape,i);let l="",c="",p="";if(1===o.length&&e.packedInputs){const e=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)];l=`${e[0]>1}_${e[1]>1}`}else if(2!==o.length||e.packedInputs){if(o.length>2&&!e.packedInputs){const e=Re(o);p=`${e[0]===i[1]}_${e[e.length-1]===i[1]}`}}else c=`${o[0]>1}_${o[1]>1}`;const d=t.shape.length,h=2===o.length&&de(t.shape,i),f=1===ce(t.shape),m=Co(t.shape,n.shape),g=!e.packedInputs&&d===n.shape.length&&de(i,n.texData.texShape),y=e.packedInputs||o.length>2?"":`${i[0]>1}_${i[1]>1}`;r+=`${d}_${g}_${s?u:""}_${o.length}_${f}_${m}_${h}_${l}_${c}_${p}_${y}_${a}`}else{const e=t.isUniform?"uniform":t.texData.texShape;r+=`${t.shape}_${e}_${a}`}}));const a=e.userCode;let i=e.constructor.name;return i+="_"+r+"_"+a+`${Ge().getNumber("WEBGL_VERSION")}`,i}(e,l,c),d=this.getAndSaveBinary(p,(()=>function(e,t,n,r){const a=n.map(((e,n)=>{const 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((e=>e.shapeInfo)),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},o=ML(a,s,t),u=function(e,t){const n=aL(e,(()=>e.createShader(e.FRAGMENT_SHADER)),"Unable to create fragment WebGLShader.");if(VA(e,(()=>e.shaderSource(n,t))),VA(e,(()=>e.compileShader(n))),Ge().get("ENGINE_COMPILE_ONLY"))return n;if(!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw XA(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}(e.gl,o),l=e.createProgram(u);return Ge().get("ENGINE_COMPILE_ONLY")?{program:t,fragmentShader:u,source:o,webGLProgram:l,inShapeInfos:i,outShapeInfo:s,uniformLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,inShapesLocations:null,inTexShapesLocations:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:Object.assign({program:t,fragmentShader:u,source:o,webGLProgram:l,inShapeInfos:i,outShapeInfo:s},RL(e,t,l))}(this.gpgpu,e,l,c))),h=null!=this.activeTimers;let f;h&&(f=this.startTimer()),Ge().get("ENGINE_COMPILE_ONLY")||function(e,t,n,r,a){t.program.enableShapeUniforms||(FL(t.inShapeInfos,n),FL([t.outShapeInfo],[r]));const i=r.texData.texture,s=r.texData.texShape;r.texData.isPacked?e.setOutputPackedMatrixTexture(i.texture,s[0],s[1]):e.setOutputMatrixTexture(i.texture,s[0],s[1]),e.setProgram(t.webGLProgram),1===Ge().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach(((n,r)=>{const a=t.program.variableNames[r],i=t.uniformLocations[a],s=t.uniformLocations[`offset${a}`],o=t.inShapesLocations[`${a}Shape`],u=t.inTexShapesLocations[`${a}TexShape`];if(o){const{uniformShape:r}=LL(t.program.packedInputs,n.shape,n.texData.texShape);switch(r.length){case 1:e.gl.uniform1iv(o,new Int32Array(r));break;case 2:e.gl.uniform2iv(o,new Int32Array(r));break;case 3:e.gl.uniform3iv(o,new Int32Array(r));break;case 4:e.gl.uniform4iv(o,new Int32Array(r))}}if(u&&e.gl.uniform2i(u,n.texData.texShape[0],n.texData.texShape[1]),null!=i)if(n.isUniform)if(ce(n.shape)<2)e.gl.uniform1f(i,n.uniformValues[0]);else{let t=n.uniformValues;t instanceof Float32Array||(t=new Float32Array(t)),e.gl.uniform1fv(i,t)}else null!=n.texData.slice&&null!=s&&e.gl.uniform1i(s,n.texData.slice.flatOffset),e.setInputMatrixTexture(n.texData.texture.texture,i,r)}));const o=t.outShapeLocation;if(o)switch(r.shape.length){case 1:e.gl.uniform1iv(o,new Int32Array(r.shape));break;case 2:e.gl.uniform2iv(o,new Int32Array(r.shape));break;case 3:e.gl.uniform3iv(o,new Int32Array(r.shape));break;case 4:e.gl.uniform4iv(o,new Int32Array(r.shape))}if(t.outShapeStridesLocation){const n=Re(r.shape);switch(r.shape.length){case 2:e.gl.uniform1iv(t.outShapeStridesLocation,new Int32Array(n));break;case 3:e.gl.uniform2iv(t.outShapeStridesLocation,new Int32Array(n));break;case 4:e.gl.uniform3iv(t.outShapeStridesLocation,new Int32Array(n))}}t.outTexShapeLocation&&e.gl.uniform2i(t.outTexShapeLocation,r.texData.texShape[0],r.texData.texShape[1]),t.program.customUniforms&&a&&t.program.customUniforms.forEach(((n,r)=>{const i=t.customUniformLocations[r],s=a[r];if("float"===n.type)e.gl.uniform1fv(i,s);else if("vec2"===n.type)e.gl.uniform2fv(i,s);else if("vec3"===n.type)e.gl.uniform3fv(i,s);else if("vec4"===n.type)e.gl.uniform4fv(i,s);else if("int"===n.type)e.gl.uniform1iv(i,s);else if("ivec2"===n.type)e.gl.uniform2iv(i,s);else if("ivec3"===n.type)e.gl.uniform3iv(i,s);else{if("ivec4"!==n.type)throw Error(`uniform type ${n.type} is not supported yet.`);e.gl.uniform4iv(i,s)}})),e.executeProgram()}(this.gpgpu,d,l,c,r),u.forEach((e=>this.disposeIntermediateTensorInfo(e))),h&&(f=this.endTimer(f),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(f)}));const m=Ge().get("WEBGL_FLUSH_THRESHOLD");if(m>0){const e=za();e-this.lastGlFlushTime>m&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=e)}if(!Ge().getBool("WEBGL_LAZILY_UNPACK")&&o.isPacked&&!1===a){const e=this.unpackTensor(s);return this.disposeIntermediateTensorInfo(s),e}return s}compileAndRun(e,t,n,r,a=!1){return n=n||t[0].dtype,this.runWebGLProgram(e,t,n,r,a)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(Ge().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach((e=>{this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram),delete this.binaryCache[e]})),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)}floatPrecision(){return null==this.floatPrecisionValue&&(this.floatPrecisionValue=ho((()=>{if(!Ge().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=Ge().getBool("DEBUG");Ge().set("DEBUG",!1);const t=this.abs(Ru(1e-8)).dataSync()[0];if(Ge().set("DEBUG",e),t>0)return 32}return 16}))),this.floatPrecisionValue}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}uploadToGPU(e){const t=this.texData.get(e),{shape:n,dtype:r,values:a,texture:i,usage:s,isPacked:o}=t;if(null!=i)return;const u=null!=this.activeTimers;let l;u&&(l=za());let c=t.texShape;if(null==c&&(c=function(e,t=!1){let n=Ge().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t&&(n*=2,e=e.map(((t,n)=>n>=e.length-2?te(e[n]):e[n])),1===e.length&&(e=[2,e[0]])),2!==e.length){const t=_e(e);e=t.newShape}let r=ce(e);if(e.length<=1&&r<=n)return[1,r];if(2===e.length&&e[0]<=n&&e[1]<=n)return e;if(3===e.length&&e[0]*e[1]<=n&&e[2]<=n)return[e[0]*e[1],e[2]];if(3===e.length&&e[0]<=n&&e[1]*e[2]<=n)return[e[0],e[1]*e[2]];if(4===e.length&&e[0]*e[1]*e[2]<=n&&e[3]<=n)return[e[0]*e[1]*e[2],e[3]];if(4===e.length&&e[0]<=n&&e[1]*e[2]*e[3]<=n)return[e[0],e[1]*e[2]*e[3]];if(t){const t=iL(e);let n=2,a=2;return e.length&&([n,a]=sL(e)),r=t*(n/2)*(a/2),me(r).map((e=>2*e))}return me(r)}(n,o),t.texShape=c),null!=a){const e=oL(n);let i,s=c[1],p=c[0];const d=a instanceof Uint8Array||a instanceof Uint8ClampedArray;!o&&d||([s,p]=qA(c[0],c[1])),i=o?new UL(e,d):new jL(e,d);const h=d?[p,s]:c,f=this.makeTensorInfo(h,r),m=this.texData.get(f.dataId);m.usage=d?PA.PIXELS:PA.UPLOAD,m.texShape=h,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(f.dataId),s,p,a);const g=[[p,s]],y=!0,b=this.runWebGLProgram(i,[f],r,g,y),x=this.texData.get(b.dataId);t.texShape=x.texShape,t.isPacked=x.isPacked,t.usage=x.usage,Ge().get("ENGINE_COMPILE_ONLY")?this.disposeData(b.dataId):(t.texture=x.texture,t.values=null,this.texData.delete(b.dataId)),this.disposeIntermediateTensorInfo(f),u&&(this.uploadWaitMs+=za()-l)}else{const e=this.acquireTexture(c,s,r,o);t.texture=e}}convertAndCacheOnCPU(e,t){const n=this.texData.get(e),{dtype:r}=n;return this.releaseGPUData(e),null!=t&&(n.values=function(e,t){if("float32"===t||"complex64"===t)return e;if("int32"===t||"bool"===t){const n="int32"===t?new Int32Array(e.length):new Uint8Array(e.length);for(let t=0;t1024*this.numMBBeforeWarning*1024){const e=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${e} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,r)}computeBytes(e,t){return e[0]*e[1]*Te(t)}checkCompileCompletion(){for(const[,e]of Object.entries(this.binaryCache))this.checkCompletion_(e)}async checkCompileCompletionAsync(){const e=[];if(this.gpgpu.parallelCompilationExtension){for(const[,t]of Object.entries(this.binaryCache))e.push(this.checkCompletionAsync_(t));return Promise.all(e)}for(const[,t]of Object.entries(this.binaryCache)){const n=new Promise((e=>{try{this.checkCompletion_(t),e(!0)}catch(e){throw e}}));e.push(n)}return Promise.all(e)}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await Xh(),this.checkCompletionAsync_(e))}checkCompletion_(e){if(!1===this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)){if(console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)),!1===this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS))throw XA(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.");throw new Error("Failed to link vertex and fragment shaders.")}return!0}getUniformLocations(){for(const[,e]of Object.entries(this.binaryCache)){const{uniformLocations:t,customUniformLocations:n,infLoc:r,nanLoc:a,inShapesLocations:i,inTexShapesLocations:s,outShapeLocation:o,outShapeStridesLocation:u,outTexShapeLocation:l}=RL(this.gpgpu,e.program,e.webGLProgram);e.uniformLocations=t,e.customUniformLocations=n,e.infLoc=r,e.nanLoc=a,e.inShapesLocations=i,e.inTexShapesLocations=s,e.outShapeLocation=o,e.outShapeStridesLocation=u,e.outTexShapeLocation=l}}}rO.nextDataId=0,ki()&&Mo("webgl",(()=>new rO),2);class aO{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=Lo(t,n),this.enableShapeUniforms=YL(this.outputShape.length),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 `}}class iO{constructor(e,t,n,r=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=Lo(t,n);const a=this.outputShape.length;this.enableShapeUniforms=YL(a);let i="";if(r)if(0===a||1===ce(this.outputShape))i="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else if(i=`\n ${AL(a)} coords = getOutputCoords();\n `,1===a)this.enableShapeUniforms?i+="\n result.y = (coords + 1) >= outShape ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ":i+=`\n result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n `;else{const e=H$("coords",a);this.enableShapeUniforms?i+=`\n bool nextRowOutOfBounds =\n (${e[a-2]} + 1) >= outShape[${a} - 2];\n bool nextColOutOfBounds =\n (${e[a-1]} + 1) >= outShape[${a} - 1];\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `:i+=`\n bool nextRowOutOfBounds =\n (${e[a-2]} + 1) >= ${this.outputShape[a-2]};\n bool nextColOutOfBounds =\n (${e[a-1]} + 1) >= ${this.outputShape[a-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 ${i}\n\n setOutput(result);\n }\n `}}function sO(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const oO={kernelName:fn,backendName:"webgl",kernelFunc:sO};function uO(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,i=n.makeTensorInfo(r.shape,"complex64"),s=n.texData.get(i.dataId),o=sO({inputs:{x:r},backend:n}),u=sO({inputs:{x:a},backend:n});return s.complexTensorInfos={real:o,imag:u},i}const lO={kernelName:St,backendName:"webgl",kernelFunc:uO},cO="return (a < 0.) ? b * a : a;",pO="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",dO={kernelName:vn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{alpha:i}=r,s=n.makeTensorInfo([],"float32",Fa(i,"float32")),o=Ge().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new iO(pO,a.shape,s.shape):new aO(cO,a.shape,s.shape),u=n.runWebGLProgram(o,[a,s],"float32");return n.disposeIntermediateTensorInfo(s),u}},hO="return (a < 0.) ? b * a : a;",fO="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",mO={kernelName:ir,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t,i=Ge().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new iO(fO,r.shape,a.shape):new aO(hO,r.shape,a.shape);return n.runWebGLProgram(i,[r,a],"float32")}};function gO({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:n,dtype:r}){return({inputs:a,backend:i})=>{const{x:s}=a,o=i,u=r||s.dtype;if(o.shouldExecuteOnCPU([s])&&null!=n){const e=o.texData.get(s.dataId),t=n(e.values,u);return o.makeTensorInfo(s.shape,u,t)}let l;return l=Ge().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=t?new Z$(s.shape,t):new K$(s.shape,e),o.runWebGLProgram(l,[s],u)}}function yO({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:r=!1,cpuKernelImpl:a,dtype:i}){return({inputs:s,backend:o})=>{const{a:u,b:l}=s,c=o;if(r&&"complex64"===u.dtype){const t=c.texData.get(u.dataId),n=c.texData.get(l.dataId),[r,a]=[[t.complexTensorInfos.real,n.complexTensorInfos.real],[t.complexTensorInfos.imag,n.complexTensorInfos.imag]].map((t=>{const[n,r]=t,a={dataId:n.dataId,dtype:n.dtype,shape:u.shape},i={dataId:r.dataId,dtype:r.dtype,shape:l.shape},s=new aO(e,u.shape,l.shape);return c.runWebGLProgram(s,[a,i],ci(n.dtype,r.dtype))})),i=uO({inputs:{real:r,imag:a},backend:c});return c.disposeIntermediateTensorInfo(r),c.disposeIntermediateTensorInfo(a),i}const p=i||ci(u.dtype,l.dtype);if(("string"===u.dtype||"string"===l.dtype||c.shouldExecuteOnCPU([u,l]))&&null!=a){const e=c.texData.get(u.dataId).values,t=c.texData.get(l.dataId).values,n="string"===u.dtype?Gf(e):e,r="string"===u.dtype?Gf(t):t,[i,s]=a(u.shape,l.shape,n,r,p),o=c.makeTensorInfo(s,p);return c.texData.get(o.dataId).values=i,o}let d;return d=Ge().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=t?new iO(t,u.shape,l.shape,n):new aO(e,u.shape,l.shape),c.runWebGLProgram(d,[u,l],p)}}function bO(e,t=!1){if("linear"===e)return"return x;";if("relu"===e)return t?"\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":"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : x;\n";if("elu"===e)return t?"\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":"return (x >= 0.0) ? x : (exp(x) - 1.0);";if("relu6"===e)return t?"\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":"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : min(6.0, x);\n";if("prelu"===e)return t?fO:hO;if("leakyrelu"===e)return t?pO:cO;if("sigmoid"===e)return"return 1.0 / (1.0 + exp(-1.0 * x));";throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)}class xO{constructor(e,t,n,r=!1,a=!1,i=!1,s=null,o=!1,u=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n,this.enableShapeUniforms=YL(this.outputShape.length);const l=r?e[1]:e[2],c=Math.ceil(l/2),p=r?"i * 2, rc.y":"rc.y, i * 2",d=a?"rc.z, i * 2":"i * 2, rc.z",h=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let m="",g="";s&&(m=o?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${s}\n }`:u?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${s}\n }`:`vec4 activation(vec4 x) {\n ${s}\n }`,g="result = activation(result);");const y=i?"result += getBiasAtOutCoords();":"";i&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights"),u&&this.variableNames.push("leakyreluAlpha");let b="rc.x",x="rc.x";e[0]`The new shape (${u}) has ${l} elements and the old shape (${a.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`));const c=s.texData.get(a.dataId);return!c.isPacked||lL(a.shape,u)||null!==c.texture&&lL(c.shape,u)?(s.incRef(a.dataId),{dataId:a.dataId,shape:u,dtype:a.dtype}):function(e,t,n){const r=[iL(e.shape),...sL(e.shape)],a={dtype:e.dtype,shape:r,dataId:e.dataId},i=[iL(t),...sL(t)],s=new U$(i,r),o=[r],u=n.runWebGLProgram(s,[a],e.dtype,o,!0);return{dataId:u.dataId,shape:t,dtype:u.dtype}}(a,u,s)}const SO={kernelName:pr,backendName:"webgl",kernelFunc:NO};class kO{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:a,outSize:i}=e;this.outputShape=[r,i];const s=4*Math.floor(n/4),o=n%4;let u="sumValue += dot(values, ones);";if(null!=t){const e=1/t;u=`sumValue += dot(values * ${he(e)?e.toPrecision(2):e}, ones);`}let l="";a%n>0&&(l=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return 0.0;\n }\n `),this.userCode=`\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${l}\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 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 ${u}\n }\n\n int inIdx = inOffset + ${s};\n if (${1===o}) {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n ${u}\n } else if (${2===o}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n ${u}\n } else if (${3===o}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2), 0.0);\n\n ${u}\n }\n setOutput(sumValue);\n }\n `}}class DO{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:a,outSize:i}=e;this.outputShape=[r,i];let s="0.0",o="";"prod"===t?s="1.0":"min"===t?(s="1.0 / 1e-20",o="min"):"max"===t&&(s="-1.0 / 1e-20",o="max");let 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");const l=4*Math.floor(n/4),c=n%4;let p=`\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 = ${o}(values, minMaxValue);\n if (${"min"===t} || ${"max"===t}) {\n minMaxValue = ${o}(values, minMaxValue);\n bvec4 isNaN = isnan(values);\n if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {\n minMaxValue = vec4(NAN);\n }\n }\n }\n `,d="vec4";"all"===t?(s="1.0",p="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",d="bvec4"):"any"===t&&(s="0.0",p="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",d="bvec4");let h="";a%n>0&&(h=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return initializationValue;\n }\n `),this.userCode=`\n const float initializationValue = ${s};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${h}\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(${s});\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 < ${l}; i += 4) {\n int inIdx = inOffset + i;\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${p}\n }\n\n int inIdx = inOffset + ${l};\n if (${1===c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${2===c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${3===c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n ${p}\n }\n setOutput(${u});\n }\n `}}function TO(e,t,n,r){const a=function(e){const t=[];for(;0===t.length||1!==t[t.length-1].outSize;){const n=t.length?t[t.length-1].outSize:e[1],r=tf(n);t.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return t}(e.shape);let i=e;for(let s=0;s6)throw Error(`Transpose for rank ${t} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(t);for(let t=0;t6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const r=AL(this.rank),a=P$("rc",this.rank),i=new Array(this.rank);for(let e=0;e`Error in matMul: inner shapes (${p}) and (${d}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${r} must match.`));const v=n?[y,p,h]:[y,h,p],_=r?[b,f,d]:[b,d,f],w=NO({inputs:{x:e},backend:a,attrs:{shape:v}}),M=NO({inputs:{x:t},backend:a,attrs:{shape:_}}),N=[w,M],S=Math.max(y,b),k=n?w.shape[1]:w.shape[2],D=null!=i,T=null!=s,I="leakyrelu"===u,E=null!=u?bO(u,!0):null;let C;if((1===h||1===f)&&k>1e3&&!1===(D||T||I||null!=E)){let e=w,t=M;n&&(e=$O({inputs:{x:w},backend:a,attrs:{perm:[0,2,1]}}),N.push(e)),r&&(t=$O({inputs:{x:M},backend:a,attrs:{perm:[0,2,1]}}),N.push(t));const i=1===f;let s=e;1!==f&&(s=NO({inputs:{x:e},backend:a,attrs:{shape:[S,k,1]}}),N.push(s));const o=1===f?2:1;let u=t;i&&(u=NO({inputs:{x:t},backend:a,attrs:{shape:[S,1,k]}}),N.push(u));const l=wO({inputs:{a:s,b:u},backend:a});C=AO({inputs:{x:l},backend:a,attrs:{axis:o,keepDims:!0}}),N.push(l)}else{const u=ci(e.dtype,t.dtype),l=new xO(v,_,[S,h,f],n,r,D,E,T,I),c=[w,M];if(null!=i&&c.push(i),T&&c.push(s),I){const e=a.makeTensorInfo([],"float32",Fa(o,"float32"));c.push(e),N.push(e)}C=a.runWebGLProgram(l,c,u)}const A=NO({inputs:{x:C},backend:a,attrs:{shape:x}});N.push(C);for(const e of N)a.disposeIntermediateTensorInfo(e);return A}const FO={kernelName:oa,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i,bias:s,preluActivationWeights:o}=t,{transposeA:u,transposeB:l,activation:c,leakyreluAlpha:p}=r;return RO({a,b:i,transposeA:u,transposeB:l,backend:n,bias:s,preluActivationWeights:o,leakyreluAlpha:p,activation:c})}},YO="return abs(x);",zO={kernelName:Qe,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])&&"complex64"!==r.dtype){const e=n.texData.get(r.dataId),t=k$(e.values);return n.makeTensorInfo(r.shape,r.dtype,t)}let a;return a=Ge().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new Z$(r.shape,YO):new K$(r.shape,YO),n.runWebGLProgram(a,[r],r.dtype)}},BO=gO({opSnippet:"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n"}),PO={kernelName:et,backendName:"webgl",kernelFunc:BO},HO=gO({opSnippet:"if (isnan(x)) return x;\n if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));"}),jO={kernelName:tt,backendName:"webgl",kernelFunc:HO},UO="return a + b;",qO=yO({opSnippet:UO,packedOpSnippet:UO,supportsComplex:!0,cpuKernelImpl:ZL}),WO={kernelName:nt,backendName:"webgl",kernelFunc:qO};class VO{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map(((e,t)=>`T${t}`));const n=[];this.variableNames.forEach((e=>{n.push(`float v${e} = get${e}AtOutCoords();`)}));const r=this.variableNames.map((e=>`v${e}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n float result = ${r};\n setOutput(result);\n }\n `}}class GO{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map(((e,t)=>`T${t}`));const n=[];this.variableNames.forEach((e=>{n.push(`vec4 v${e} = get${e}AtOutCoords();`)}));const r=this.variableNames.map((e=>`v${e}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n vec4 result = ${r};\n setOutput(result);\n }\n `}}const KO={kernelName:rt,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r}=t,a=n;if(1===a.length)return sO({inputs:{x:a[0]},backend:r});if(a.length>Ge().get("WEBGL_MAX_TEXTURES_IN_SHADER")){const t=Math.floor(a.length/2),n=e({inputs:a.slice(0,t),backend:r}),i=e({inputs:a.slice(t),backend:r});return e({inputs:[n,i],backend:r})}const i=a.map((e=>e.dtype)).reduce(((e,t)=>ci(e,t))),s=a.map((e=>e.shape)),o=Ge().getBool("WEBGL_PACK")?new GO(a[0].shape,s):new VO(a[0].shape,s);return r.runWebGLProgram(o,a,i)}},JO={kernelName:at,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=a.shape.length,u=ve(i,a.shape);let l=u;const c=xc(l,o);let p=a;null!=c&&(p=$O({inputs:{x:a},backend:n,attrs:{perm:c}}),l=_c(l.length,o)),bc("all",l,o);const[d,h]=gc(p.shape,l),f=NO({inputs:{x:p},backend:n,attrs:{shape:[-1,ce(h)]}}),m=TO(f,f.dtype,"all",n);let g;return g=NO(s?{inputs:{x:m},backend:n,attrs:{shape:yc(d,u)}}:{inputs:{x:m},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),null!=c&&n.disposeIntermediateTensorInfo(p),g}},XO={kernelName:it,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=a.shape.length,u=ve(i,a.shape);let l=u;const c=xc(l,o);let p=a;null!=c&&(p=$O({inputs:{x:a},backend:n,attrs:{perm:c}}),l=_c(l.length,o)),bc("any",l,o);const[d,h]=gc(p.shape,l),f=NO({inputs:{x:p},backend:n,attrs:{shape:[-1,ce(h)]}}),m=TO(f,f.dtype,"any",n);let g;return g=NO(s?{inputs:{x:m},backend:n,attrs:{shape:yc(d,u)}}:{inputs:{x:m},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),null!=c&&n.disposeIntermediateTensorInfo(p),g}};class ZO{constructor(e,t,n){this.variableNames=["A"];const{windowSize:r,batchSize:a,outSize:i}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[a,i];const s="max"===t?">":"<",o=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 = ${o};\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 `}}class QO{constructor(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,se(e.length>2,(()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`));const a=e[e.length-1],i=Math.ceil(a/t);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),r||this.variableNames.push("bestIndicesA");const s=this.outputShape,o=s.length,u=AL(o),l=H$("coords",o);let c,p;if(1===i){p=o+1;const e=AL(p);c=`\n ${e} sourceLocR = ${e}(${l.join()}, 0);\n ++${l[o-1]};\n ${e} sourceLocG = ${e}(${l.join()}, 0);\n ++${l[o-2]};\n ${e} sourceLocA = ${e}(${l.join()}, 0);\n --${l[o-1]};\n ${e} sourceLocB = ${e}(${l.join()}, 0);\n --${l[o-2]};`}else p=o,c=`\n ${u} sourceLocR = coords;\n ++${l[o-1]};\n ${u} sourceLocG = coords;\n ++${l[o-2]};\n ${u} sourceLocA = coords;\n --${l[o-1]};\n ${u} sourceLocB = coords;\n --${l[o-2]};`;const d=["x","y","z","w","u","v"].slice(0,p),h="."+d[p-1],f=d.map((e=>"int "+e)),m=H$("sourceLocR",p-1).concat("inIdx.r"),g=H$("sourceLocG",p-1).concat("inIdx.g"),y=H$("sourceLocB",p-1).concat("inIdx.b"),b=H$("sourceLocA",p-1).concat("inIdx.a"),x="max"===n?"greaterThan":"lessThan",v=r?"":`\n inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),\n getBestIndicesAChannel(${g.join()}),\n getBestIndicesAChannel(${y.join()}),\n getBestIndicesAChannel(${b.join()})));`,_=`vec4(\n getAChannel(${m.join()}),\n hasNextCol ? getAChannel(${g.join()}) : 0.,\n hasNextRow ? getAChannel(${y.join()}) : 0.,\n hasNextRow && hasNextCol ? getAChannel(${b.join()}) : 0.)`,w=r?"":`\n float getBestIndicesAChannel(${f.join()}) {\n return getChannel(getBestIndicesA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }`;this.userCode=`\n float getAChannel(${f.join()}) {\n return getChannel(getA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }\n ${w}\n void main() {\n ${u} coords = getOutputCoords();\n bool hasNextCol = ${l[o-1]} < ${s[o-1]-1};\n bool hasNextRow = ${l[o-2]} < ${s[o-2]-1};\n ${c}\n ivec4 srcIdx = ivec4(sourceLocR${h}, sourceLocG${h},\n sourceLocB${h}, sourceLocA${h}) * ${t};\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = ${_};\n\n for (int i = 0; i < ${t}; i++) {\n inIdx = srcIdx;\n ${v}\n vec4 candidate = ${_};\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 `}}function eR(e,t,n,r=null){let a=t.shape[0],i=t.shape[1];null!=r&&(a=r.shape[0],i=r.shape[1]);const s=tf(i),o={windowSize:s,inSize:i,batchSize:a,outSize:Math.ceil(i/s)},u=new ZO(o,n,null==r),l=[t];null!=r&&l.push(r);const c=e.runWebGLProgram(u,l,"int32");if(1===c.shape[1])return c;const p=eR(e,t,n,c);return e.disposeIntermediateTensorInfo(c),p}function tR(e,t,n,r=null){const a=null!=r?r.shape:t.shape,i=tf(a[a.length-1]),s=new QO(a,i,n,null==r),o=null==r?[t]:[t,r],u=e.runWebGLProgram(s,o,"int32");if(u.shape.length===t.shape.length){const r=tR(e,t,n,u);return e.disposeIntermediateTensorInfo(u),r}return u}function nR(e,t,n,r){const a=[n];if(bc("arg"+r.charAt(0).toUpperCase()+r.slice(1),a,t.shape.length),!Ge().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){const n=[],i=e.texData.get(t.dataId);let s=t;null!==i&&i.isPacked&&(s=e.unpackTensor(t),n.push(s));const[o,u]=gc(s.shape,a),l=ce(u),c=NO({inputs:{x:s},backend:e,attrs:{shape:[-1,l]}});n.push(c);const p=eR(e,c,r);n.push(p);const d=NO({inputs:{x:p},backend:e,attrs:{shape:o}});return n.forEach((t=>e.disposeIntermediateTensorInfo(t))),d}return tR(e,t,r)}const rR={kernelName:st,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;let s=ve(i,a.shape);const o=xc(s,a.shape.length);let u=a;const l=[];null!=o&&(u=$O({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=_c(s.length,u.shape.length)),bc("argMax",[s[0]],u.shape.length);const c=nR(n,u,s[0],"max");return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}},aR={kernelName:ot,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;let s=ve(i,a.shape);const o=xc(s,a.shape.length);let u=a;const l=[];null!=o&&(u=$O({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=_c(s.length,u.shape.length)),bc("argMin",[s[0]],u.shape.length);const c=nR(n,u,s[0],"min");return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}},iR=gO({opSnippet:"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n"}),sR={kernelName:ut,backendName:"webgl",kernelFunc:iR},oR=gO({opSnippet:"if (isnan(x)) return x;return log(x + sqrt(x * x + 1.0));"}),uR={kernelName:lt,backendName:"webgl",kernelFunc:oR},lR=gO({opSnippet:"if (isnan(x)) return x;\n return atan(x);\n"}),cR={kernelName:ct,backendName:"webgl",kernelFunc:lR},pR=yO({opSnippet:"\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return atan(a, b);\n",packedOpSnippet:"\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"}),dR={kernelName:dt,backendName:"webgl",kernelFunc:pR},hR=gO({opSnippet:"if (isnan(x)) return x;\n if ((x < -1.0) || (x > 1.0)) return NAN;\nreturn (log(1.0 + x) - log(1.0 - x)) / 2.0;"}),fR={kernelName:pt,backendName:"webgl",kernelFunc:hR};class mR{constructor(e,t,n,r=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const i=e.filterWidth,s=e.strideHeight,o=e.strideWidth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterHeight,p=e.effectiveFilterWidth,d=e.padInfo.top,h=e.padInfo.left;this.outputShape=e.outShape;const f="avg"===t,m=`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,g=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`;let y="0.0";if(f||(y="-1.0 / 1e-20"),n){const t=">=";return void(this.userCode=`\n const ivec2 strides = ivec2(${s}, ${o});\n const ivec2 pads = ivec2(${d}, ${h});\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 < ${c};\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 < ${p};\n wC += ${l}) {\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 ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r?a?m:g:`wR * ${p} + wC`};\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let b=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(b="avgValue / count");const x=4*Math.floor(i/4),v=i%4,_=`\n if (${f}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec2 strides = ivec2(${s}, ${o});\n const ivec2 pads = ivec2(${d}, ${h});\n const float initializationValue = ${y};\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(${y});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < ${c};\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 < ${x}; wC += 4) {\n int xC = xCCorner + wC * ${l};\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n getValue(batch, xR, xC + 3 * ${l}, d)\n );\n\n ${_}\n }\n\n int xC = xCCorner + ${x};\n if (${1===v}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${_}\n } else if (${2===v}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n initializationValue,\n initializationValue\n );\n\n ${_}\n } else if (${3===v}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n initializationValue\n );\n\n ${_}\n }\n }\n setOutput(${b});\n }\n `}}class gR{constructor(e,t,n,r=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const i=e.filterWidth,s=e.strideDepth,o=e.strideHeight,u=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,p=e.dilationWidth,d=e.effectiveFilterDepth,h=e.effectiveFilterHeight,f=e.effectiveFilterWidth,m=e.padInfo.front,g=e.padInfo.top,y=e.padInfo.left;this.outputShape=e.outShape;const b="avg"===t;let x="0.0";if(b||(x="-1.0 / 1e-20"),n){const t=">=";return void(this.userCode=`\n const ivec3 strides =\n ivec3(${s}, ${o}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\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 < ${d};\n wD += ${l}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${h};\n wR += ${c}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${f};\n wC += ${p}) {\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 ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r?a?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${h} * ${f} +\n wR * ${f} + wC`};\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let v=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(v="avgValue / count");const _=4*Math.floor(i/4),w=i%4,M=`\n if (${b}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec3 strides =\n ivec3(${s}, ${o}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\n const float initializationValue = ${x};\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(${x});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < ${d};\n wD += ${l}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${h};\n wR += ${c}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${_}; wC += 4) {\n int xC = xCCorner + wC * ${p};\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n getValue(batch, xD, xR, xC + 2 * ${p}, ch),\n getValue(batch, xD, xR, xC + 3 * ${p}, ch)\n );\n\n ${M}\n }\n\n int xC = xCCorner + ${_};\n if (${1===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${M}\n } else if (${2===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n initializationValue,\n initializationValue\n );\n\n ${M}\n } else if (${3===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n getValue(batch, xD, xR, xC + 2 * ${p}, ch),\n initializationValue\n );\n\n ${M}\n }\n }\n setOutput(${v});\n }\n }\n `}}const yR={kernelName:ht,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;mL(a,"avgPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;se(vl(s,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=cl(a.shape,i,s,1,o,u);if(1===l.filterWidth&&1===l.filterHeight&&de(l.inShape,l.outShape))return sO({inputs:{x:a},backend:n});const c=new mR(l,"avg",!1);return n.runWebGLProgram(c,[a],"float32")}},bR={kernelName:mt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u,dataFormat:l}=r,c=pl(a.shape,i,s,[1,1,1],o,u,l),p=new gR(c,"avg",!1);return n.runWebGLProgram(p,[a],"float32")}};class xR{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i=e.dilationHeight,s=e.dilationWidth,o=e.effectiveFilterHeight,u=e.effectiveFilterWidth,l=o-1-e.padInfo.top,c=u-1-e.padInfo.left,p=1/(t*n);this.userCode=`\n const ivec2 pads = ivec2(${l}, ${c});\n const float avgMultiplier = float(${p});\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 += ${i}) {\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+= ${s}) {\n float dyC = float(dyCCorner + wC) / ${a}.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 `}}class vR{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,i=e.strideHeight,s=e.strideWidth,o=e.dilationDepth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterDepth,p=e.effectiveFilterHeight,d=e.effectiveFilterWidth,h=c-1-e.padInfo.front,f=p-1-e.padInfo.top,m=d-1-e.padInfo.left,g=1/(t*n*r);this.userCode=`\n const ivec3 pads = ivec3(${h}, ${f}, ${m});\n const float avgMultiplier = float(${g});\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 < ${c};\n wD += ${o}) {\n float dyD = float(dyDCorner + wD) / ${a}.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 < ${p};\n wR += ${u}) {\n float dyR = float(dyRCorner + wR) / ${i}.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 < ${d};\n wC += ${l}) {\n float dyC = float(dyCCorner + wC) / ${s}.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 `}}const _R={kernelName:gt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i,{filterSize:o,strides:u,pad:l,dimRoundingMode:c}=r,p=pl(s.shape,o,u,[1,1,1],l,c),d=new vR(p);return n.runWebGLProgram(d,[a],s.dtype)}},wR={kernelName:ft,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i;mL([a,i],"avgPoolGrad");const{filterSize:o,strides:u,pad:l}=r,c=cl(s.shape,o,u,1,l),p=new xR(c);return n.runWebGLProgram(p,[a],s.dtype)}},MR={kernelName:yt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i}=t,{transposeA:s,transposeB:o}=r;return RO({a,b:i,transposeA:s,transposeB:o,backend:n})}};class NR{constructor(e,t,n,r,a,i){this.outputShape=[],this.variableNames=["x","mean","variance"],Lo(e,t),Lo(e,n);let s="0.0";null!=r&&(Lo(e,r),this.variableNames.push("offset"),s="getOffsetAtOutCoords()");let o="1.0";null!=a&&(Lo(e,a),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = ${s};\n float scale = ${o};\n float inv = scale * inversesqrt(variance + float(${i}));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n `}}class SR{constructor(e,t,n,r,a,i){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],Lo(e,t),Lo(e,n);let s="vec4(0.0)";null!=r&&(Lo(e,r),this.variableNames.push("offset"),s="getOffsetAtOutCoords()");let o="vec4(1.0)";null!=a&&(Lo(e,a),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n void main() {\n vec4 offset = ${s};\n vec4 scale = ${o};\n\n vec4 x = getXAtOutCoords();\n vec4 mean = getMeanAtOutCoords();\n vec4 variance = getVarianceAtOutCoords();\n\n vec4 inv = scale * inversesqrt(variance + vec4(${i}));\n\n setOutput((x - mean) * inv + offset);\n }\n `}}const kR={kernelName:ln,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,mean:a,variance:i,offset:s,scale:o}=e;se(a.shape.length===i.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),se(null==s||a.shape.length===s.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),se(null==o||a.shape.length===o.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));let{varianceEpsilon:u}=n;null==u&&(u=.001);const l=[r,a,i];let c=null;null!=s&&(c=s.shape,l.push(s));let p=null;null!=o&&(p=o.shape,l.push(o));const d=Ge().getBool("WEBGL_PACK_NORMALIZATION")?new SR(r.shape,a.shape,i.shape,c,p,u):new NR(r.shape,a.shape,i.shape,c,p,u);return t.runWebGLProgram(d,l,l[0].dtype)}};class DR{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=AL(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const n=function(e){if(1===e)return"sourceLoc";if(e<=6)return TR.slice(0,e).map((e=>"sourceLoc."+e)).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}(this.rank);let r;const a=e.map(((e,t)=>`sourceLoc.${TR[t]} = start[${t}] + coords.${TR[t]};`));r=`\n ${t} sourceLoc;\n ${t} coords = getOutputCoords();\n ${a.join("\n")}\n `,this.userCode=`\n void main() {\n ${r}\n setOutput(getSource(${n}));\n }\n `}}const TR=["x","y","z","w","u","v"];class IR{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const t=AL(this.rank),n=H$("coords",this.rank),r=H$("sourceLoc",this.rank),a=1===this.rank?"sourceLoc":`vec2(${r.slice(-2).join()})`,i=`getChannel(getSource(${r.join()}), ${a})`,s=`\n result.x = ${i};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.y = ${i};\n --${r[this.rank-1]};\n }\n `,o=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 = ${i};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.w = ${i};\n }\n }\n `,u=this.rank<=4?`sourceLoc = coords +\n ${t}(${e.map(((e,t)=>`start[${t}]`)).join()});`:e.map(((e,t)=>`${r[t]} = ${n[t]} + start[${t}];`)).join("\n");this.userCode=`\n void main() {\n ${t} coords = getOutputCoords();\n ${t} sourceLoc;\n ${u}\n vec4 result = vec4(0.);\n ${s}\n ${o}\n setOutput(result);\n }\n `}}function ER(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,size:s}=r,[o,u]=au(a,i,s);if(Uo(a,o,u),0===ce(u))return n.makeTensorInfo(u,a.dtype,[]);if(n.shouldExecuteOnCPU([a])||"string"===a.dtype){const e=n.texData.get(a.dataId),t=D$(e.values,o,u,a.shape,a.dtype);return n.makeTensorInfo(u,a.dtype,t)}const{isPacked:l}=n.texData.get(a.dataId),c=nu(a.shape,o,u);if(l||!c){const e=Ge().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new IR(u):new DR(u),t=[o];return n.runWebGLProgram(e,[a],a.dtype,t)}return n.uploadToGPU(a.dataId),function(e,t,n,r){const a=r.texData.get(e.dataId),i=r.makeTensorInfo(n,e.dtype),s=r.texData.get(i.dataId);Object.assign(s,a),s.refCount=1,s.shape=n,s.dtype=e.dtype;let o=ru(t,Re(e.shape));a.slice&&(o+=a.slice.flatOffset),s.slice={flatOffset:o,origDataId:a.slice&&a.slice.origDataId||e.dataId};const u=r.dataRefCount.get(s.slice.origDataId)||1;return r.dataRefCount.set(s.slice.origDataId,u+1),i}(a,o,u,n)}const CR={kernelName:Nr,backendName:"webgl",kernelFunc:ER},AR={kernelName:bt,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,crops:s}=r;se(a.shape.length<=4,(()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"));const o=i.reduce(((e,t)=>e*t)),u=rf(a.shape,i,o),l=af(u.length,i.length),c=sf(a.shape,i,o),p=of(s,i.length),d=uf(c,s,i.length),h=[],f=NO({inputs:{x:a},backend:n,attrs:{shape:u}}),m=$O({inputs:{x:f},backend:n,attrs:{perm:l}}),g=NO({inputs:{x:m},backend:n,attrs:{shape:c}}),y=ER({inputs:{x:g},backend:n,attrs:{begin:p,size:d}});return h.push(f),h.push(m),h.push(g),h.forEach((e=>n.disposeIntermediateTensorInfo(e))),y}},LR={kernelName:xt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:i}=t,{size:s}=r,o=n.readSync(a.dataId),u=n.readSync(i.dataId),l=QL(o,u,i.dtype,i.shape,s);return n.makeTensorInfo([s],i.dtype,l)}},$R={kernelName:_t,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{s0:r,s1:a}=t,i=n.readSync(r.dataId),s=n.readSync(a.dataId),o=Lo(Array.from(i),Array.from(s));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}},OR=yO({opSnippet:"return float(a != b);",cpuKernelImpl:v$,dtype:"bool"}),RR={kernelName:Kn,backendName:"webgl",kernelFunc:OR};function FR(e){const{inputs:t,backend:n}=e,{input:r}=t;return sO({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.real},backend:n})}const YR={kernelName:ur,backendName:"webgl",kernelFunc:FR},zR={kernelName:wt,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r,attrs:a}=t,{x:i}=n,{dtype:s}=a;if("complex64"===s){if("complex64"===i.dtype)return sO({inputs:{x:i},backend:r});const t=up(i.shape),n=e({inputs:{x:i},backend:r,attrs:{dtype:"float32"}}),a=uO({inputs:{real:n,imag:t},backend:r});return t.dispose(),r.disposeIntermediateTensorInfo(n),a}if("complex64"===i.dtype){const t=FR({inputs:{input:i},backend:r}),n=e({inputs:{x:t},backend:r,attrs:{dtype:s}});return r.disposeIntermediateTensorInfo(t),n}if(!ke(i.dtype,s)){const e=sO({inputs:{x:i},backend:r});return{dataId:e.dataId,shape:e.shape,dtype:s}}if("int32"===s)return function(e,t){const n=new K$(e.shape,"return float(int(x));"),r=t.runWebGLProgram(n,[e],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}(i,r);if("bool"===s){const e=r.makeTensorInfo([],"bool",we("bool",1)),t=OR({inputs:{a:i,b:e},backend:r});return r.disposeIntermediateTensorInfo(e),t}throw new Error(`Error in Cast: failed to cast ${i.dtype} to ${s}`)}},BR="return ceil(x);",PR=gO({opSnippet:BR,packedOpSnippet:BR,cpuKernelImpl:t$}),HR={kernelName:Mt,backendName:"webgl",kernelFunc:PR};class jR{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\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 "}}class UR{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\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 "}}const qR={kernelName:Nt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{clipValueMin:i,clipValueMax:s}=r;let o;o=Ge().getBool("WEBGL_PACK_CLIP")?new UR(a.shape):new jR(a.shape);const u=[[i],[s]];return n.runWebGLProgram(o,[a],a.dtype,u)}};class WR{constructor(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 "}}function VR(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}const GR={kernelName:kt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t,a=n.texData.get(r.dataId),i=new WR(r.shape),s=[VR(r,a.complexTensorInfos.real),VR(r,a.complexTensorInfos.imag)];return n.runWebGLProgram(i,s,s[0].dtype)}};class KR{constructor(e){this.outputShape=[],this.outputShape=Qh(e,1),this.variableNames=e.map(((e,t)=>`T${t}`));const t=new Array(e.length-1);t[0]=e[0][1];for(let n=1;n`T${t}`));const o=new Array(e.length-1);o[0]=e[0][t];for(let n=1;n= ${o[e-1]}) {\n return getChannel(\n getT${e}(${XR(s,u,t)}),\n vec2(${XR(l,u,t)}));\n }`}const d=o.length,h=o[o.length-1];p+=`\n return getChannel(\n getT${d}(${XR(s,u,h)}),\n vec2(${XR(l,u,h)}));`,this.userCode=`\n float getValue(${s.map((e=>"int "+e))}) {\n ${p}\n }\n\n void main() {\n ${a} coords = getOutputCoords();\n vec4 result = vec4(getValue(${i}), 0., 0., 0.);\n\n ${i[r-1]} = ${i[r-1]} + 1;\n if (${i[r-1]} < ${n[r-1]}) {\n result.g = getValue(${i});\n }\n\n ${i[r-2]} = ${i[r-2]} + 1;\n if (${i[r-2]} < ${n[r-2]}) {\n result.a = getValue(${i});\n }\n\n ${i[r-1]} = ${i[r-1]} - 1;\n if (${i[r-2]} < ${n[r-2]} &&\n ${i[r-1]} < ${n[r-1]}) {\n result.b = getValue(${i});\n }\n setOutput(result);\n }\n `}}function XR(e,t,n){const r=e.indexOf(t);return e.map(((e,t)=>t===r?`${e} - ${n}`:e)).join()}function ZR(e){const{inputs:t,backend:n}=e,{input:r}=t;return sO({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.imag},backend:n})}const QR={kernelName:gn,backendName:"webgl",kernelFunc:ZR};function eF(e,t,n){const r=e[0].dtype;if("complex64"===r){const r=e.map((e=>FR({inputs:{input:e},backend:n}))),a=e.map((e=>ZR({inputs:{input:e},backend:n}))),i=eF(r,t,n),s=eF(a,t,n),o=uO({inputs:{real:i,imag:s},backend:n});return r.forEach((e=>n.disposeIntermediateTensorInfo(e))),a.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(s),o}let a=n.shouldExecuteOnCPU(e);if("string"===r&&(a=!0),a){const a=e.map((e=>{const r=ce(e.shape.slice(t));return NO({inputs:{x:e},backend:n,attrs:{shape:[-1,r]}})})),i=a.map((e=>({vals:n.readSync(e.dataId),shape:e.shape}))),s=Qh(a.map((e=>e.shape)),1),o=1===a[0].shape[0],u=n$(i,s,r,o),l=Qh(e.map((e=>e.shape)),t),c=n.makeTensorInfo(l,r,u);return a.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}const i=Ge().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(e.length>i){const r=[];for(let a=0;a1){const a=new JR(e.map((e=>e.shape)),t);return n.runWebGLProgram(a,e,r)}const{tensors2D:s,outShape:o}=function(e,t,n){const r=Qh(e.map((e=>e.shape)),t);return{tensors2D:e.map((e=>NO({inputs:{x:e},attrs:{shape:[-1,ce(e.shape.slice(t))]},backend:n}))),outShape:r}}(e,t,n),u=new KR(s.map((e=>e.shape))),l=n.runWebGLProgram(u,s,r);s.forEach((e=>n.disposeIntermediateTensorInfo(e)));const c=NO({inputs:{x:l},attrs:{shape:o},backend:n});return n.disposeIntermediateTensorInfo(l),c}function tF(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r,i=ve(a,t[0].shape)[0],s=Qh(t.map((e=>e.shape)),i);if(0===ce(s))return n.makeTensorInfo(s,t[0].dtype,[]);const o=t.filter((e=>ce(e.shape)>0));return 1===o.length?sO({inputs:{x:o[0]},backend:n}):(Zh(o.map((e=>e.shape)),i),eF(o,i,n))}const nF={kernelName:Dt,backendName:"webgl",kernelFunc:tF};class rF{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const i=e.padInfo.top,s=e.padInfo.left,o=e.strideHeight,u=e.strideWidth,l=e.dilationHeight,c=e.dilationWidth,p=e.filterHeight,d=e.filterWidth,h=4*Math.floor(e.inChannels/4),f=e.inChannels%4,m="channelsLast"===e.dataFormat,g=m?1:2,y=m?2:3,b=m?3:1;let x="",v="";n&&(x=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,v="result = activation(result);");const _=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${x}\n\n const ivec2 strides = ivec2(${o}, ${u});\n const ivec2 pads = ivec2(${i}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[${b}];\n\n ivec2 xRCCorner =\n ivec2(coords[${g}], coords[${y}]) * 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 < ${p}; wR++) {\n int xR = xRCorner + wR * ${l};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${d}; 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 (${m}) {\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===f}) {\n\n if (${m}) {\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===f}) {\n vec2 wValues = vec2(\n getW(wR, wC, ${h}, d2),\n getW(wR, wC, ${h} + 1, d2)\n );\n\n if (${m}) {\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===f}) {\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 (${m}) {\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 ${_}\n ${v}\n setOutput(result);\n }\n `}}class aF{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const t=e.padInfo.front,n=e.padInfo.top,r=e.padInfo.left,a=e.strideDepth,i=e.strideHeight,s=e.strideWidth,o=e.dilationDepth,u=e.dilationHeight,l=e.dilationWidth,c=e.filterDepth,p=e.filterHeight,d=e.filterWidth,h=4*Math.floor(e.inChannels/4),f=e.inChannels%4;this.userCode=`\n const ivec3 strides = ivec3(${a}, ${i}, ${s});\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 < ${c}; wF++) {\n int xF = xFCorner + wF * ${o};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${p}; 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 < ${d}; wC++) {\n int xC = xCCorner + wC * ${l};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${h}; 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===f}) {\n dotProd +=\n getX(batch, xF, xR, xC, ${h}) *\n getW(wF, wR, wC, ${h}, d2);\n } else if (${2===f}) {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, ${h}),\n getX(batch, xF, xR, xC, ${h} + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, ${h}, d2),\n getW(wF, wR, wC, ${h} + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if (${3===f}) {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, ${h}),\n getX(batch, xF, xR, xC, ${h} + 1),\n getX(batch, xF, xR, xC, ${h} + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, ${h}, d2),\n getW(wF, wR, wC, ${h} + 1, d2),\n getW(wF, wR, wC, ${h} + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class iF{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec4"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length);const{dataFormat:n}=t,r=yL(),a="channelsLast"===n,i=a?1:2,s=a?2:3,o=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let u="";for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)u+=`\n blockIndex = rc.z + ${t};\n pos = rc.y + ${e};\n\n ${o}\n offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];\n d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);\n\n if(d0 < inputShape[${i}] && d0 >= 0) {\n // Use custom imod instead mod. On Intel GPU, mod may generate\n // unexpected value.\n // https://github.com/tensorflow/tfjs/issues/5447\n offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1];\n d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /\n inChannels);\n\n if(d1 < inputShape[${s}] && d1 >= 0) {\n\n ch = imod(pos, inChannels);\n\n if (${a}) {\n innerDims = vec2(d1, ch);\n result[${2*e+t}] = getChannel(\n getA(rc.x, d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result[${2*e+t}] = getChannel(\n getA(rc.x, ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n `;this.userCode=`\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n ${u}\n\n ${r.output} = result;\n }\n `}}function sF(e,t){const n=e.length;return n>=3?t?[...e.slice(0,-3),e[n-3]*e[n-2],e[n-1]]:[...e.slice(0,-3),e[n-3],e[n-2]*e[n-1]]:!t&&1===n&&e[0]>1?[e[0],1]:null}function oF({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:i=null,leakyreluAlpha:s=0,activation:o=null}){const u=e.shape,l=r.texData.get(e.dataId),c=n.inChannels,p=u[0]*u[1]*u[2],d=n.outChannels,h="channelsLast"===n.dataFormat;let f;const m=[];if(null!=i){const e=sF(i.shape,h);null!=e&&(i=NO({inputs:{x:i},backend:r,attrs:{shape:e}}),m.push(i))}if(null!=a){const e=sF(a.shape,h);null!=e&&(a=NO({inputs:{x:a},backend:r,attrs:{shape:e}}),m.push(a))}if((1!==p&&1!==d||!(c>1e3))&&l.isPacked&&h&&null!=l.texture&&u[2]%2!=0&&de(l.shape.slice(-3),u.slice(-3))){const c=u[0]*u[1]*(u[2]+1),p={dataId:e.dataId,shape:[1,c,n.inChannels],dtype:e.dtype},d=l.shape;l.shape=l.shape.slice(),l.shape[l.shape.length-2]++,se(lL(l.shape,p.shape),(()=>`packed reshape ${l.shape} to ${p.shape} isn't free`));const h=NO({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}});m.push(h);const g=RO({a:p,b:h,backend:r,transposeA:!1,transposeB:!1,bias:a,activation:o,preluActivationWeights:i,leakyreluAlpha:s}),y=r.texData.get(g.dataId);se(y.isPacked,(()=>"batchMatMul result is expected to be packed")),l.shape=d,y.shape=n.outShape,f=sO({inputs:{x:g},backend:r}),f.shape=n.outShape,m.push(g)}else{const u=n.outHeight*n.outWidth,l=NO({inputs:{x:e},backend:r,attrs:{shape:h?[n.batchSize,u,n.inChannels]:[n.batchSize,n.inChannels,u]}}),c=NO({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}}),p=RO({a:h?l:c,b:h?c:l,transposeA:!h,transposeB:!1,backend:r,bias:a,activation:o,preluActivationWeights:i,leakyreluAlpha:s});f=NO({inputs:{x:p},backend:r,attrs:{shape:n.outShape}}),m.push(l),m.push(c),m.push(p)}for(const e of m)r.disposeIntermediateTensorInfo(e);return f}function uF({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:i=null,leakyreluAlpha:s=0,activation:o=null}){const{filterWidth:u,filterHeight:l,inChannels:c,outWidth:p,outHeight:d,dataFormat:h}=n,f="channelsLast"===h,m=u*l*c,g=d*p,y=[n.batchSize,m,g],b=[];if(null!=i){const e=sF(i.shape,f);null!=e&&(i=NO({inputs:{x:i},backend:r,attrs:{shape:e}}),b.push(i))}if(null!=a){const e=sF(a.shape,f);null!=e&&(a=NO({inputs:{x:a},backend:r,attrs:{shape:e}}),b.push(a))}const x=NO({inputs:{x:t},backend:r,attrs:{shape:[1,m,ce(t.shape)/m]}});b.push(x);const v=new iF(y,n),_=[e.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],w=r.runWebGLProgram(v,[e],"float32",_),M=NO({inputs:{x:w},backend:r,attrs:{shape:y}});b.push(w),b.push(M);const N=null!=a,S=null!=i,k="leakyrelu"===o,D=o?bO(o,!0):null,T=new xO(f?M.shape:x.shape,f?x.shape:M.shape,f?[n.batchSize,g,n.outChannels]:[n.batchSize,n.outChannels,g],!0,!1,N,D,S,k),I=f?[M,x]:[x,M];if(a&&I.push(a),S&&I.push(i),k){const e=r.makeTensorInfo([],"float32",Fa(s,"float32"));I.push(e),b.push(e)}const E=r.runWebGLProgram(T,I,"float32"),C=NO({inputs:{x:E},backend:r,attrs:{shape:n.outShape}});b.push(E);for(const e of b)r.disposeIntermediateTensorInfo(e);return C}const lF={kernelName:Tt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dataFormat:u,dilations:l,dimRoundingMode:c}=r,p=_l(u),d=dl(a.shape,i.shape,s,l,o,c,!1,p);let h;if(1!==d.filterHeight||1!==d.filterWidth||1!==d.dilationHeight||1!==d.dilationWidth||1!==d.strideHeight||1!==d.strideWidth||"SAME"!==d.padInfo.type&&"VALID"!==d.padInfo.type)if(Ge().getBool("WEBGL_CONV_IM2COL"))h=uF({x:a,filter:i,convInfo:d,backend:n});else{const e=new rF(d);h=n.runWebGLProgram(e,[a,i],"float32")}else h=oF({x:a,filter:i,convInfo:d,backend:n});const f=NO({inputs:{x:h},backend:n,attrs:{shape:d.outShape}});return n.disposeIntermediateTensorInfo(h),f}};class cF{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,i="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} - ${a};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n if (${i}) {\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 `}}class pF{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i="channelsLast"===e.dataFormat,s=t-1-e.padInfo.top,o=n-1-e.padInfo.left,u=i?1:2,l=i?2:3,c=i?3:1;this.userCode=`\n const ivec2 pads = ivec2(${s}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[${c}];\n\n ivec2 dyCorner = ivec2(coords[${u}], coords[${l}]) - 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) / ${a}.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 (${i}) {\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 `}}class dF{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.padInfo.front,i=e.padInfo.top,s=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} - ${a};\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} - ${i};\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} - ${s};\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 `}}class hF{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,i=e.strideHeight,s=e.strideWidth,o=t-1-e.padInfo.front,u=n-1-e.padInfo.top,l=r-1-e.padInfo.left;this.userCode=`\n const ivec3 pads = ivec3(${o}, ${u}, ${l});\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) / ${a}.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) / ${i}.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) / ${s}.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 `}}const fF={kernelName:It,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,dy:i}=t,{strides:s,pad:o,dataFormat:u,dimRoundingMode:l,filterShape:c}=r,p=_l(u),d=dl(a.shape,c,s,1,o,l,!1,p),h=new cF(d);return n.runWebGLProgram(h,[a,i],"float32")}},mF={kernelName:Et,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{inputShape:s,strides:o,pad:u,dataFormat:l,dimRoundingMode:c}=r,p=_l(l),d=dl(s,i.shape,o,1,u,c,!1,p),h=new pF(d);return n.runWebGLProgram(h,[a,i],"float32")}},gF={kernelName:Ct,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dilations:u}=r,l=hl(a.shape,i.shape,s,u,o),c=new aF(l);return n.runWebGLProgram(c,[a,i],"float32")}},yF={kernelName:At,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,dy:i}=t,{strides:s,pad:o,filterShape:u}=r,l=hl(a.shape,u,s,1,o),c=new dF(l);return n.runWebGLProgram(c,[a,i],"float32")}},bF={kernelName:Lt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{pad:s,strides:o,inputShape:u}=r,l=hl(u,i.shape,o,1,s),c=new hF(l);return n.runWebGLProgram(c,[a,i],"float32")}},xF=gO({opSnippet:"if (isnan(x)) return x;\n return cos(x);\n"}),vF={kernelName:$t,backendName:"webgl",kernelFunc:xF},_F=gO({opSnippet:"\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n"}),wF={kernelName:Ot,backendName:"webgl",kernelFunc:_F};class MF{constructor(e,t,n,r,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[i,s,o,u]=e,[l]=t,[c,p]=n;this.outputShape=[l,c,p,u];const d="bilinear"===r?1:0,[h,f]=[s-1+".0",o-1+".0"],[m,g,y]=c>1?[""+(s-1)/(c-1),"(y2-y1) * height_ratio",`y1*${h} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${h}`],[b,x,v]=p>1?[""+(o-1)/(p-1),"(x2-x1) * width_ratio",`x1*${f} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${f}`];this.userCode=`\n const float height_ratio = float(${m});\n const float width_ratio = float(${b});\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 >= ${i}) {\n return;\n }\n\n float height_scale = ${g};\n float width_scale = ${x};\n\n float in_y = ${y};\n if( in_y < 0.0 || in_y > ${h} ) {\n setOutput(float(${a}));\n return;\n }\n float in_x = ${v};\n if( in_x < 0.0 || in_x > ${f} ) {\n setOutput(float(${a}));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if(${d} == 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 `}}const NF={kernelName:Yt,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:i,boxInd:s}=t,{cropSize:o,method:u,extrapolationValue:l}=r,c=new MF(a.shape,i.shape,o,u,l);return n.runWebGLProgram(c,[a,i,s],"float32")}};var SF;!function(e){e.Prod="*",e.Sum="+"}(SF||(SF={}));class kF{constructor(e,t,n,r){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const a=this.outputShape.length,i=this.op===SF.Prod?"1.0":"0.0",s=n?i:`getX(${DF(a,"coords",this.op)})`,o=this.outputShape[this.outputShape.length-1];let u="",l="";n?(u=r?"end != "+(o-1):"end != 0",l=r?"end + 1":"end - 1"):(u=r?`end + pow2 < ${o}`:"end >= pow2",l=r?"end + pow2":"end - pow2"),this.userCode=`\n void main() {\n ${AL(a)} coords = getOutputCoords();\n int end = ${TF(a,"coords",this.op)};\n float val = ${s};\n int pow2 = int(pow(2.0, index));\n if (${u}) {\n int idx = ${l};\n ${TF(a,"coords",this.op)} = idx;\n val ${this.op}= getX(${DF(a,"coords",this.op)});\n }\n setOutput(val);\n }\n `}}function DF(e,t,n){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 new Error(`Cumulative ${n} for rank ${e} is not yet supported`)}function TF(e,t,n){if(1===e)return`${t}`;if(2===e)return`${t}.y`;if(3===e)return`${t}.z`;if(4===e)return`${t}.w`;throw new Error(`Cumulative ${n} for rank ${e} is not yet supported`)}function IF(e,t,n,r,a,i){const s=t.shape.length,o=xc([r],s);let u=t;null!=o&&(u=$O({inputs:{x:t},backend:n,attrs:{perm:o}}));const l=_c(1,s)[0];if(l!==s-1)throw new Error(`WebGL cumprod shader expects an inner-most axis=${t.shape.length-1} but got axis=${r}`);const c=u.shape[l];let p=sO({inputs:{x:u},backend:n});for(let t=0;t<=Math.ceil(Math.log2(c))-1;t++){const r=new kF(e,u.shape,!1,i),a=[[t]],s=p;p=n.runWebGLProgram(r,[p],p.dtype,a),n.disposeIntermediateTensorInfo(s)}if(a){const t=new kF(e,u.shape,a,i),r=p;p=n.runWebGLProgram(t,[p],p.dtype),n.disposeIntermediateTensorInfo(r)}if(null!=o){const e=$O({inputs:{x:p},backend:n,attrs:{perm:vc(o)}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(u),e}return p}const EF={kernelName:Rt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,exclusive:s,reverse:o}=r;return IF(SF.Prod,a,n,i,s,o)}},CF={kernelName:Ft,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,exclusive:s,reverse:o}=r;return IF(SF.Sum,a,n,i,s,o)}},AF={kernelName:zt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:i}=t,{size:s,binaryOutput:o}=r;if(1===a.shape.length){const e=n.readSync(a.dataId),t=n.readSync(i.dataId),r=QL(e,t,i.dtype,i.shape,s);return n.makeTensorInfo([s],i.dtype,r)}if(2===a.shape.length){const e=n.bufferSync(a),t=n.bufferSync(i),r=e$(e,t,s,o);return n.makeTensorInfo(r.shape,i.dtype,r.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${a.shape.length}.`)}};class LF{constructor(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 `}getHeightCoordString(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"}getWidthCoordString(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"}getDepthCoordString(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"}getOutputDepthSize(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}}const $F={kernelName:Bt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockSize:i,dataFormat:s}=r,o=a.shape[0],u=("NHWC"===s?a.shape[1]:a.shape[2])*i,l=("NHWC"===s?a.shape[2]:a.shape[3])*i,c=("NHWC"===s?a.shape[3]:a.shape[1])/(i*i),p=new LF("NHWC"===s?[o,u,l,c]:[o,c,u,l],i,s);return n.runWebGLProgram(p,[a],a.dtype)}};class OF{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=YL(this.outputShape.length);const i=e.filterHeight,s=e.filterWidth,o=e.outChannels/e.inChannels;let u="",l="";n&&(u=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,l="result = activation(result);");const c=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${u}\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 / ${o};\n int q = d2 - d1 * ${o};\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 < ${i}; wR++) {\n int xR = xRCorner + wR * dilations[0];\n\n if (xR < 0 || xR >= inDims[0]) {\n continue;\n }\n\n for (int wC = 0; wC < ${s}; wC++) {\n int xC = xCCorner + wC * dilations[1];\n\n if (xC < 0 || xC >= inDims[1]) {\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 ${c}\n ${l}\n setOutput(result);\n }\n `}}class RF{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=YL(this.outputShape.length);const i=e.outChannels/e.inChannels,s=e.padInfo.left,o=e.strideWidth,u=e.dilationWidth,l=e.filterHeight,c=e.filterWidth,p=c;let d="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let e=0;e=0 && xR < inDims[0]) {\n ";for(let e=0;e<(p+1)/2;e++){const t=2*e;if(d+=`\n xC = xCCorner + ${t*u};\n `,1===o){if(t= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n `,d+=1===u&&t>0?`\n xC${t} = vec4(xTexelC${t-2}.zw, xTexelC${t}.xy);\n `:`\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${t} = vec4(previous.zw, xTexelC${t}.xy);\n } else {\n xC${t} = vec4(0.0, 0.0, xTexelC${t}.xy);\n }\n `):d+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xC${t} = xTexelC${t};\n `,t+1= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n `,u>1&&(d+=`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n xTexelC${t}Ready = 1;\n }\n `),d+=`\n xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.xy);\n `):d+=1===e?`\n xC${t+1} = xTexelC${t};\n `:`\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t+1} = xTexelC${t+1};\n `}}else t= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw);\n `,t+1= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${t+1} = vec4(xTexelC${t+1}.xy, final.xy);\n `)):(d+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(\n xTexelC${t}.xy, xTexelC${t+1}.xy);\n `,t+1`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${c}'`));const p=dl(a.shape,i.shape,s,c,o,l,!0);let d;d=Ge().getBool("WEBGL_PACK_DEPTHWISECONV")&&p.strideWidth<=2&&p.outChannels/p.inChannels==1?new RF(p):new OF(p);const h=[[p.padInfo.top,p.padInfo.left],[p.strideHeight,p.strideWidth],[p.dilationHeight,p.dilationWidth],[p.inHeight,p.inWidth]];return n.runWebGLProgram(d,[a,i],"float32",h)}};class YF{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,i=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 * ${i} + 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} - ${a};\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 `}}class zF{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i=t-1-e.padInfo.top,s=n-1-e.padInfo.left,o=e.outChannels/e.inChannels;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[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) / ${a}.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 < ${o}; dm++) {\n int d2 = d1 * ${o} + 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 `}}const BF={kernelName:Ht,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,dy:i}=t,{strides:s,dilations:o,pad:u,dimRoundingMode:l,filterShape:c}=r,p=dl(a.shape,c,s,o,u,l,!0),d=new YF(p);return n.runWebGLProgram(d,[a,i],"float32")}},PF={kernelName:jt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{strides:s,dilations:o,pad:u,dimRoundingMode:l,inputShape:c}=r,p=dl(c,i.shape,s,o,u,l,!0),d=new zF(p);return n.runWebGLProgram(d,[a,i],"float32")}};class HF{constructor(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 "}}const jF={kernelName:Ut,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t,a=[...r.shape,...r.shape],i=ce(r.shape),s=NO({inputs:{x:r},backend:n,attrs:{shape:[i]}}),o=new HF(i),u=n.runWebGLProgram(o,[s],s.dtype),l=NO({inputs:{x:u},backend:n,attrs:{shape:a}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(u),l}};class UF{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:t,inWidth:n,padInfo:r,strideHeight:a,strideWidth:i,filterHeight:s,filterWidth:o,dilationHeight:u,dilationWidth:l}=e,{top:c,left:p}=r;this.userCode=`\n const ivec2 strides = ivec2(${a}, ${i});\n const ivec2 pads = ivec2(${c}, ${p});\n const float neg_infinity = -3.4e38;\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.w;\n ivec2 outTopLeftCorner =\n coords.yz * strides - pads;\n int hBeg = outTopLeftCorner.x;\n int wBeg = outTopLeftCorner.y;\n\n float curVal = neg_infinity;\n for (int h = 0; h < ${s}; h++) {\n int hIn = hBeg + h * ${u};\n\n if (hIn >= 0 && hIn < ${t}) {\n for (int w = 0; w < ${o}; w++) {\n int wIn = wBeg + w * ${l};\n\n if (wIn >= 0 && wIn < ${n}) {\n float xVal = getX(batch, hIn, wIn, d1);\n float wVal = getW(h, w, d1);\n\n float val = xVal + wVal;\n if (val > curVal) {\n curVal = val;\n }\n }\n }\n }\n }\n\n float result = curVal;\n setOutput(result);\n }\n `}}const qF={kernelName:qt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dilations:u}=r,l=ll(a.shape,i.shape,s,o,"NHWC",u);let c;const p=new UF(l);c=n.runWebGLProgram(p,[a,i],"float32");const d=NO({inputs:{x:c},backend:n,attrs:{shape:l.outShape}});return n.disposeIntermediateTensorInfo(c),d}},WF={kernelName:Kt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{equation:a}=r,i=t,{allDims:s,summedDims:o,idDims:u}=kf(a,i.length);Tf(s.length,u,i);const{path:l,steps:c}=If(o,u),p=c.length;let d=null,h=s.length;const f=[];for(let e=0;e=0&&(d=AO({inputs:{x:d},backend:n,attrs:{axis:l[e]-(s.length-h),keepDims:!1}}),f.push(d)),h--)}for(const e of f)e!==d&&n.disposeIntermediateTensorInfo(e);return d}},VF=gO({opSnippet:"return (x >= 0.0) ? x : (exp(x) - 1.0);",packedOpSnippet:"\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"}),GF={kernelName:Jt,backendName:"webgl",kernelFunc:VF},KF={kernelName:Xt,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n}=e,{dy:r,y:a}=t,i=Ge().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new iO("\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",r.shape,a.shape):new aO("return (b >= 1.0) ? a : a * (b + 1.0);",r.shape,a.shape);return n.runWebGLProgram(i,[r,a],r.dtype)}},JF=yO({opSnippet:"return float(a == b);",packedOpSnippet:"\n return vec4(equal(a, b));\n",dtype:"bool",cpuKernelImpl:r$}),XF={kernelName:Qt,backendName:"webgl",kernelFunc:JF},ZF=gO({opSnippet:`\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 = ${pf};\n float a1 = ${df};\n float a2 = ${hf};\n float a3 = ${ff};\n float a4 = ${mf};\n float a5 = ${gf};\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`}),QF={kernelName:Zt,backendName:"webgl",kernelFunc:ZF},eY=gO({opSnippet:"if (isnan(x)) return x;\n return exp(x);\n",packedOpSnippet:"\n vec4 result = exp(x);\n bvec4 isNaN = isnan(x);\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",cpuKernelImpl:a$,dtype:"float32"}),tY={kernelName:en,backendName:"webgl",kernelFunc:eY};function nY(e){const{inputs:t,attrs:n,backend:r}=e,{dim:a}=n,{input:i}=t,s=i.shape.length,o=i.shape.slice();let u=a;return a<0&&(se(-(s+1)<=a,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+a+1),o.splice(u,0,1),NO({inputs:{x:i},backend:r,attrs:{shape:o}})}const rY={kernelName:tn,backendName:"webgl",kernelFunc:nY},aY="return exp(x) - 1.0;",iY=gO({opSnippet:aY,packedOpSnippet:aY,cpuKernelImpl:i$}),sY={kernelName:nn,backendName:"webgl",kernelFunc:iY};class oY{constructor(e,t,n){this.variableNames=["real","imag"];const r=t[1];this.outputShape=t;const a=n?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,i=n?`${r}.0`:"1.0";let s;if("real"===e)s="return real * expR - imag * expI;";else{if("imag"!==e)throw new Error(`FFT component must be either "real" or "imag", got ${e}.`);s="return real * expI + imag * expR;"}this.userCode=`\n const float exponentMultiplier = ${a};\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n ${s}\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) / ${i};\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n `}}function uY(e,t,n){const r=n.texData.get(e.dataId),a=ce(e.shape),i=e.shape[e.shape.length-1],s=NO({inputs:{x:e},backend:n,attrs:{shape:[a/i,i]}}),o=s.shape,u=new oY("real",o,t),l=new oY("imag",o,t),c=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:o},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:o}],p=n.runWebGLProgram(u,c,"float32"),d=n.runWebGLProgram(l,c,"float32"),h=uO({inputs:{real:p,imag:d},backend:n});n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d);const f=NO({inputs:{x:h},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(h),f}const lY={kernelName:rn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t;return uY(r,!1,n)}};class cY{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode="\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "}}function pY(e){const{backend:t,attrs:n}=e,{shape:r,value:a}=n;let{dtype:i}=n;if(i=i||Le(a),"string"===i){const e=Me(i,ce(r));return e.fill(a),t.makeTensorInfo(r,i,e)}{const e=new cY(r,a),n=[[a]];return t.runWebGLProgram(e,[],i,n)}}const dY={kernelName:an,backendName:"webgl",kernelFunc:pY};class hY{constructor(e){this.variableNames=["Image"],this.outputShape=[];const t=e[2];this.outputShape=e,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n\n int coordX = ${t} - x - 1;\n float outputValue;\n if(coordX >= 0 && coordX < ${t}) {\n outputValue = getImage(coords[0], coords[1], coordX, coords[3]);\n } else {\n outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);\n }\n setOutput(outputValue);\n }\n `}}const fY={kernelName:sn,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{const{image:n}=e,r=t,a=new hY(n.shape);return r.runWebGLProgram(a,[n],n.dtype)}},mY="return floor(x);",gY=gO({opSnippet:mY,packedOpSnippet:mY,cpuKernelImpl:s$}),yY={kernelName:on,backendName:"webgl",kernelFunc:gY},bY=yO({opSnippet:"\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",packedOpSnippet:"\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",dtype:"int32"}),xY={kernelName:un,backendName:"webgl",kernelFunc:bY};class vY{constructor(e){this.variableNames=["A"];const t=yL(),[n,r]=e;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 `}}class _Y{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=yL(),[n,r]=e;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 `}}const wY={kernelName:ia,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e;let{pixels:a}=t;const{numChannels:i}=r,s="undefined"!=typeof HTMLVideoElement&&a instanceof HTMLVideoElement,o="undefined"!=typeof HTMLImageElement&&a instanceof HTMLImageElement,[u,l]=s?[a.videoWidth,a.videoHeight]:[a.width,a.height],c=[l,u],p=[l,u,i];(o||s)&&(null==MY&&(MY=document.createElement("canvas").getContext("2d")),MY.canvas.width=u,MY.canvas.height=l,MY.drawImage(a,0,0,u,l),a=MY.canvas);const d=n.makeTensorInfo(c,"int32");n.texData.get(d.dataId).usage=PA.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(d.dataId),a);const h=Ge().getBool("WEBGL_PACK")?new _Y(p):new vY(p),f=n.runWebGLProgram(h,[d],"int32");return n.disposeData(d.dataId),f}};let MY;const NY={kernelName:ua,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r,m=_l(c),g=dl(a.shape,i.shape,u,p,l,d,!1,m);let y;const b=[];if(1!==g.filterHeight||1!==g.filterWidth||1!==g.dilationHeight||1!==g.dilationWidth||1!==g.strideHeight||1!==g.strideWidth||"SAME"!==g.padInfo.type&&"VALID"!==g.padInfo.type)if(Ge().getBool("WEBGL_CONV_IM2COL"))y=uF({x:a,filter:i,convInfo:g,backend:n,bias:s,activation:h,preluActivationWeights:o,leakyreluAlpha:f});else{const e=null!=s,t=null!=o,r="leakyrelu"===h,u=h?bO(h,!1):null,l=new rF(g,e,u,t,r),p=[a,i],d=(e,t)=>{if("NCHW"===t&&1===e.shape.length&&1!==e.shape[0]){const t=NO({inputs:{x:e},backend:n,attrs:{shape:[e.shape[0],1,1]}});return b.push(t),t}return e};if(e&&p.push(d(s,c)),t&&p.push(d(o,c)),r){const e=n.makeTensorInfo([],"float32",Fa(f,"float32"));p.push(e),b.push(e)}y=n.runWebGLProgram(l,p,"float32")}else y=oF({x:a,filter:i,convInfo:g,backend:n,bias:s,activation:h,preluActivationWeights:o,leakyreluAlpha:f});const x=NO({inputs:{x:y},backend:n,attrs:{shape:g.outShape}});return b.push(y),b.forEach((e=>n.disposeIntermediateTensorInfo(e))),x}},SY={kernelName:la,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dilations:c,dimRoundingMode:p,activation:d,leakyreluAlpha:h}=r,f=[];let m=c;null==m&&(m=[1,1]),se(vl(u,m),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${m}'`));const g=dl(a.shape,i.shape,u,m,l,p,!0),y=Ge().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,b=d?bO(d,y):null,x=[a,i],v=null!=s,_=null!=o,w="leakyrelu"===d;if(v&&x.push(s),_&&x.push(o),w){const e=n.makeTensorInfo([],"float32",Fa(h,"float32"));x.push(e),f.push(e)}let M;M=y?new RF(g,v,b,_,w):new OF(g,v,b,_,w);const N=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],S=n.runWebGLProgram(M,x,"float32",N);return f.forEach((e=>n.disposeIntermediateTensorInfo(e))),S}};class kY{constructor(e,t,n,r){this.sliceDim=e,this.strides=t,this.paramsShape=r,this.variableNames=["x","indices"],this.outputShape=n;const a=AL(t.length),i=AL(n.length),s=this.sliceDim>1?"strides[j]":"strides",o=AL(r.length),u=r.length>1?"paramsShape[j]":"paramsShape";this.userCode=`\n ${a} strides = ${a}(${this.strides});\n ${o} paramsShape = ${o}(${this.paramsShape});\n void main() {\n ${i} coords = getOutputCoords();\n int flattenIndex = 0;\n bool out_of_bounds = false;\n for (int j = 0; j < ${this.sliceDim}; j++) {\n int index = round(getIndices(coords[0], j));\n out_of_bounds = out_of_bounds || index < 0;\n out_of_bounds = out_of_bounds || index >= ${u};\n flattenIndex += index * ${s};\n }\n setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1]));\n }\n `}}const DY={kernelName:pn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{params:r,indices:a}=t,i=a.shape,s=i[i.length-1],o=ce(r.shape),[u,l,c,p]=Bo(r,a),d=NO({inputs:{x:a},backend:n,attrs:{shape:[l,s]}}),h=NO({inputs:{x:r},backend:n,attrs:{shape:[ce(r.shape)/c,c]}});if(n.shouldExecuteOnCPU([r,a])||"string"===r.dtype){const e=n.readSync(a.dataId),t=n.bufferSync(r),i=o$(e,t,r.dtype,l,s,c,p,r.shape,o);return n.makeTensorInfo(u,r.dtype,i.values)}const f=new kY(s,p,[l,c],r.shape),m=n.runWebGLProgram(f,[h,d],h.dtype),g=NO({inputs:{x:m},backend:n,attrs:{shape:u}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(m),g}};class TY{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;const n=AL(this.rank),r=function(e,t){const n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[];for(let t=0;t= 0) && (index < ${e[2]}) ? 1.0 : 0.0;\n setOutput(inBounds * getA(${r}));\n }\n `}}function IY(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,indices:i}=t,{axis:s,batchDims:o}=r,u=ve(s,a.shape)[0];if(Ge().get("DEBUG")){const e=n.readSync(i.dataId),t=a.shape[u];for(let n=0;n=0,(()=>`GatherV2: the index value ${r} is not in [0, ${t-1}]`))}}const l=Vf(a,i,u,o),c=ce(i.shape),p=[],d=NO({inputs:{x:a},backend:n,attrs:{shape:[l.batchSize,l.outerSize,l.dimSize,l.sliceSize]}}),h=NO({inputs:{x:i},backend:n,attrs:{shape:[l.batchSize,c/l.batchSize]}});p.push(d),p.push(h);const f=[l.batchSize,l.outerSize,c/l.batchSize,l.sliceSize];if(n.shouldExecuteOnCPU([a,i])||"string"===a.dtype){const e=n.bufferSync(h),t=n.bufferSync(d),r=u$(t,e,f);return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(l.outputShape,r.dtype,r.values)}const m=new TY(d.shape,f),g=n.runWebGLProgram(m,[d,h],d.dtype);p.push(g);const y=NO({inputs:{x:g},backend:n,attrs:{shape:l.outputShape}});return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),y}const EY={kernelName:cn,backendName:"webgl",kernelFunc:IY},CY=yO({opSnippet:"return float(a > b);",packedOpSnippet:"\n return vec4(greaterThan(a, b));\n",cpuKernelImpl:l$,dtype:"bool"}),AY={kernelName:dn,backendName:"webgl",kernelFunc:CY},LY=yO({opSnippet:"return float(a >= b);",packedOpSnippet:"\n return vec4(greaterThanEqual(a, b));\n",dtype:"bool",cpuKernelImpl:c$}),$Y={kernelName:hn,backendName:"webgl",kernelFunc:LY},OY={kernelName:mn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t;return uY(r,!0,n)}},RY=gO({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"}),FY={kernelName:yn,backendName:"webgl",kernelFunc:RY},YY=gO({opSnippet:"return float(isinf(x));",dtype:"bool"}),zY={kernelName:bn,backendName:"webgl",kernelFunc:YY},BY=gO({opSnippet:"return float(isnan(x));",dtype:"bool"}),PY={kernelName:xn,backendName:"webgl",kernelFunc:BY},HY=yO({opSnippet:"return float(a < b);",packedOpSnippet:"\n return vec4(lessThan(a, b));\n",cpuKernelImpl:p$,dtype:"bool"}),jY={kernelName:_n,backendName:"webgl",kernelFunc:HY},UY=yO({opSnippet:"return float(a <= b);",packedOpSnippet:"\n return vec4(lessThanEqual(a, b));\n",cpuKernelImpl:d$,dtype:"bool"}),qY={kernelName:wn,backendName:"webgl",kernelFunc:UY},WY={kernelName:Mn,backendName:"webgl",kernelFunc:function(e){const{backend:t,attrs:n}=e,{start:r,stop:a,num:i}=n,s=h$(r,a,i);return t.makeTensorInfo([s.length],"float32",s)}},VY=gO({opSnippet:"if (isnan(x)) return x;\n return x < 0.0 ? 0./0. : log(x);\n",packedOpSnippet:"\n vec4 result = log(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r);\n result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g);\n result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b);\n result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a);\n return result;\n",cpuKernelImpl:f$}),GY={kernelName:Nn,backendName:"webgl",kernelFunc:VY},KY=gO({opSnippet:"if (isnan(x)) return x;\n return log(1.0 + x);\n"}),JY={kernelName:Sn,backendName:"webgl",kernelFunc:KY},XY=yO({opSnippet:"return float(a >= 1.0 && b >= 1.0);",packedOpSnippet:"\n return vec4(\n vec4(greaterThanEqual(a, vec4(1.0))) *\n vec4(greaterThanEqual(b, vec4(1.0))));\n",dtype:"bool"}),ZY={kernelName:kn,backendName:"webgl",kernelFunc:XY},QY=gO({opSnippet:"return float(!(x >= 1.0));"}),ez={kernelName:Dn,backendName:"webgl",kernelFunc:QY},tz=yO({opSnippet:"return float(a >= 1.0 || b >= 1.0);",packedOpSnippet:"\n return min(\n vec4(greaterThanEqual(a, vec4(1.0))) +\n vec4(greaterThanEqual(b, vec4(1.0))),\n vec4(1.0));\n",dtype:"bool"}),nz={kernelName:Tn,backendName:"webgl",kernelFunc:tz};class rz{constructor(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[];const i=t,s=e[3]-1;let o;this.outputShape=e;const u=`float(${n}) + float(${r}) * sum`;o=.5===a?`inversesqrt(${u})`:1===a?`1.0/(${u})`:`exp(log(${u}) * float(-${a}));`,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 * ${o};\n setOutput(val);\n }\n `}}class az{constructor(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const i=t,s=e[3]-1;let o;this.outputShape=e;const u=`float(${n}) + float(${r}) * sum`;o=.5===a?`inversesqrt(${u})`:1===a?`1.0/(${u})`:`exp(log(${u}) * float(-${a}));`,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 * ${o};\n setOutput(result);\n }\n `}}const iz={kernelName:An,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{depthRadius:i,bias:s,alpha:o,beta:u}=r,l=Ge().getBool("WEBGL_PACK_NORMALIZATION")?new az(a.shape,i,s,o,u):new rz(a.shape,i,s,o,u);return n.runWebGLProgram(l,[a],a.dtype)}};class sz{constructor(e,t,n,r,a){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=a,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(${a})\n * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * ${a});\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 `}}const oz={kernelName:Ln,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a,y:i,dy:s}=t,{depthRadius:o,bias:u,alpha:l,beta:c}=r,p=new sz(a.shape,o,u,l,c);return n.runWebGLProgram(p,[a,i,s],a.dtype)}};function uz(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reductionIndices:i,keepDims:s}=r,o=a.shape.length,u=ve(i,a.shape);let l=u;const c=xc(l,o),p=null!=c,d=n.shouldExecuteOnCPU([a]);let h=a;if(p){if(d){const e=n.texData.get(h.dataId).values,t=new Array(o);for(let e=0;e 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",cpuKernelImpl:g$}),pz={kernelName:On,backendName:"webgl",kernelFunc:cz},dz={kernelName:Rn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;mL(a,"maxPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;se(vl(s,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=cl(a.shape,i,s,1,o,u);if(1===l.filterWidth&&1===l.filterHeight&&de(l.inShape,l.outShape))return sO({inputs:{x:a},backend:n});const c=new mR(l,"max",!1);return n.runWebGLProgram(c,[a],a.dtype)}},hz={kernelName:Yn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dataFormat:u,dimRoundingMode:l}=r,c=pl(a.shape,i,s,[1,1,1],o,l,u),p=new gR(c,"max",!1);return n.runWebGLProgram(p,[a],a.dtype)}};class fz{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideHeight,n=e.strideWidth,r=e.dilationHeight,a=e.effectiveFilterHeight,i=e.effectiveFilterWidth,s=a-1-e.padInfo.top,o=i-1-e.padInfo.left,u=a*i-1;this.userCode=`\n const ivec2 pads = ivec2(${s}, ${o});\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 < ${a};\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 < ${i}; 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 * ${i} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n `}}class mz{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.dilationDepth,i=e.dilationHeight,s=e.dilationWidth,o=e.effectiveFilterDepth,u=e.effectiveFilterHeight,l=e.effectiveFilterWidth,c=o-1-e.padInfo.front,p=u-1-e.padInfo.top,d=l-1-e.padInfo.left,h=o*u*l-1;this.userCode=`\n const ivec3 pads = ivec3(${c}, ${p}, ${d});\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 < ${o};\n wD += ${a}) {\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 += ${i}) {\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 < ${l};\n wC += ${s}) {\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 = ${h} -\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} * ${l} +\n wR * ${l} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const gz={kernelName:zn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i,{filterSize:o,strides:u,pad:l,dimRoundingMode:c}=r,p=pl(s.shape,o,u,[1,1,1],l,c),d=new gR(p,"max",!0),h=n.runWebGLProgram(d,[s],s.dtype),f=new mz(p),m=n.runWebGLProgram(f,[a,h],s.dtype);return n.disposeIntermediateTensorInfo(h),m}},yz={kernelName:Fn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i,output:s}=t,o=i;mL([i,s],"maxPoolGrad");const{filterSize:u,strides:l,pad:c,dimRoundingMode:p}=r,d=cl(o.shape,u,l,1,c,p),h=new mR(d,"max",!0),f=n.runWebGLProgram(h,[o],o.dtype),m=new fz(d),g=n.runWebGLProgram(m,[a,f],o.dtype);return n.disposeIntermediateTensorInfo(f),g}},bz={kernelName:Bn,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{filterSize:a,strides:i,pad:s,includeBatchInIndex:o}=t,u=n;se(4===r.shape.length,(()=>`Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`));const l=[1,1];se(vl(i,l),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${l}'`));const c=cl(r.shape,a,i,l,s),[p,d]=function(e,t,n,r){let a=new mR(n,"max",!1);const i=r.runWebGLProgram(a,[e],"float32");return a=new mR(n,"max",!0,!0,t),[i,r.runWebGLProgram(a,[e],"float32")]}(r,o,c,u);return[p,d]}},xz={kernelName:Pn,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{keepDims:a,axis:i}=t,s=n,o=r.shape.length,u=ve(i,r.shape);let l=u;const c=xc(l,o),p=null!=c,d=s.shouldExecuteOnCPU([r]),h=[];let f=r;if(p){if(d){const e=s.texData.get(f.dataId).values,t=new Array(o);for(let e=0;e 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",cpuKernelImpl:y$}),wz={kernelName:jn,backendName:"webgl",kernelFunc:_z};class Mz{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=AL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),u="reflect"===n?0:1;this.userCode=1!==r?`\n ${a} start = ${a}(${i});\n ${a} end = ${a}(${s});\n\n void main() {\n ${a} outC = getOutputCoords();\n for (int i = 0; i < ${r}; i++) {\n if (outC[i] < start[i]) {\n outC[i] = start[i] * 2 - outC[i] - ${u};\n } else if(outC[i] >= end[i]) {\n outC[i] = (end[i] - 1) * 2 - outC[i] + ${u};\n }\n }\n ${a} coords = outC - start;\n setOutput(getX(${o}));\n }\n `:`\n int start = ${i};\n int end = ${s};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start) {\n outC = start * 2 - outC - ${u};\n } else if(outC >= end) {\n outC = (end - 1) * 2 - outC + ${u};\n }\n setOutput(getX(outC - start));\n }\n `}}class Nz{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=AL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=H$("rc",r),u=H$("source",r),l=`${o[r-1]} < ${this.outputShape[r-1]}`,c=1===r?"source":`vec2(${u.slice(-2).join()})`,p="reflect"===n?0:1;let d="";if(1===r){const e=`\n ${a} source = rc;\n if (source < start) {\n source = start * 2 - source - ${p};\n } else if (source >= end) {\n source = (end - 1) * 2 - source + ${p};\n }\n source -= start;\n `;d=`\n ${a} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${c});\n ${o[r-1]} += 1;\n if(${l}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${c});\n }\n `}else{const e=`\n ${a} source = rc;\n ${a} lt = ${a}(lessThan(source, start));\n ${a} gte = ${a}(greaterThanEqual(source, end));\n ${a} orig = 1 - (lt + gte);\n source = orig * source +\n lt * (start * 2 - source - ${p}) +\n gte * ((end - 1) * 2 - source + ${p});\n source -= start;\n `;d=`\n ${a} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${c});\n ${o[r-1]} += 1;\n if(${l}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${c});\n }\n rc = outputLoc;\n ${o[r-2]} += 1;\n if(${o[r-2]} < ${this.outputShape[r-2]}) {\n ${e}\n result[2] = getChannel(getX(${u.join()}), ${c});\n ${o[r-1]} += 1;\n if(${l}) {\n ${e}\n result[3] = getChannel(getX(${u.join()}), ${c});\n }\n }\n `}this.userCode=`\n const ${a} start = ${a}(${i});\n const ${a} end = ${a}(${s});\n\n void main() {\n ${a} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${d}\n setOutput(result);\n }\n `}}const Sz={kernelName:Un,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r}=e,{paddings:a,mode:i}=n,s=Ge().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Nz(r.shape,a,i):new Mz(r.shape,a,i);return t.runWebGLProgram(s,[r],r.dtype)}},kz=yO({opSnippet:"if (b == 0.0) return NAN;\n return mod(a, b);",packedOpSnippet:"\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"}),Dz={kernelName:qn,backendName:"webgl",kernelFunc:kz};class Tz{constructor(e,t,n){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,n],this.userCode=`\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 `}}const Iz=yO({opSnippet:"\nif (a == b) {\n return 1.0;\n};\nreturn a / b;",packedOpSnippet:"\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",checkOutOfBounds:!0}),Ez={kernelName:Gt,backendName:"webgl",kernelFunc:Iz},Cz="return a - b;",Az=yO({opSnippet:Cz,packedOpSnippet:Cz,supportsComplex:!0,cpuKernelImpl:R$}),Lz={kernelName:Wr,backendName:"webgl",kernelFunc:Az};function $z(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{dim:i}=r,s=ve([i],a.shape),o=uz({inputs:{x:a},backend:n,attrs:{reductionIndices:s,keepDims:!1}}),u=yc(o.shape,s),l=NO({inputs:{x:o},backend:n,attrs:{shape:u}}),c=Az({inputs:{a,b:l},backend:n}),p=eY({inputs:{x:c},backend:n}),d=AO({inputs:{x:p},backend:n,attrs:{axis:s,keepDims:!1}}),h=NO({inputs:{x:d},backend:n,attrs:{shape:u}}),f=Iz({inputs:{a:p,b:h},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),f}const Oz={kernelName:$r,backendName:"webgl",kernelFunc:$z},Rz={kernelName:Wn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{numSamples:i,seed:s,normalized:o}=r,u=o?a:$z({inputs:{logits:a},backend:n,attrs:{dim:a.shape.length-1}}),l=u.shape[0],c=u.shape[1],p=new Tz(l,c,i),d=[[s]],h=n.runWebGLProgram(p,[u],"int32",d);return o||n.disposeIntermediateTensorInfo(u),h}},Fz={kernelName:Gn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])){const e=n.texData.get(r.dataId),[t,a]=x$(e.values,r.shape,r.dtype);return n.makeTensorInfo(a,r.dtype,t)}let a;return a=Ge().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new Z$(r.shape,"\n vec4 result = -x;\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"):new K$(r.shape,"if (isnan(x)) return x;\n return -x;\n"),n.runWebGLProgram(a,[r],r.dtype)}},Yz=uh,zz={kernelName:Jn,backendName:"webgl",kernelFunc:function(e){ca("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:i}=t,{maxOutputSize:s,iouThreshold:o,scoreThreshold:u}=r,l=n.readSync(a.dataId),c=n.readSync(i.dataId),{selectedIndices:p}=Yz(l,c,s,o,u);return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}},Bz=lh,Pz={kernelName:Xn,backendName:"webgl",kernelFunc:function(e){ca("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:i}=t,{maxOutputSize:s,iouThreshold:o,scoreThreshold:u,padToMaxOutputSize:l}=r,c=n.readSync(a.dataId),p=n.readSync(i.dataId),{selectedIndices:d,validOutputs:h}=Bz(c,p,s,o,u,l);return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([h]))]}},Hz=ch,jz={kernelName:Zn,backendName:"webgl",kernelFunc:function(e){ca("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:i}=t,{maxOutputSize:s,iouThreshold:o,scoreThreshold:u,softNmsSigma:l}=r,c=n.readSync(a.dataId),p=n.readSync(i.dataId),d=s,h=o,f=u,m=l,{selectedIndices:g,selectedScores:y}=Hz(c,p,d,h,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([y.length],"float32",new Float32Array(y))]}};class Uz{constructor(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 `}}const qz={kernelName:er,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{indices:a}=t,{depth:i,onValue:s,offValue:o}=r,u=ce(a.shape),l=new Uz(u,i,s,o),c=NO({inputs:{x:a},backend:n,attrs:{shape:[u]}}),p=n.runWebGLProgram(l,[c],a.dtype);n.disposeIntermediateTensorInfo(c);const d=NO({inputs:{x:p},backend:n,attrs:{shape:[...a.shape,i]}});return n.disposeIntermediateTensorInfo(p),d}};function Wz(e){const{inputs:t,backend:n}=e,{x:r}=t;if("complex64"===r.dtype){const e=FR({inputs:{input:r},backend:n}),t=Wz({inputs:{x:e},backend:n}),a=ZR({inputs:{input:r},backend:n}),i=Wz({inputs:{x:a},backend:n}),s=uO({inputs:{real:t,imag:i},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(i),s}return pY({attrs:{shape:r.shape,dtype:r.dtype,value:"string"===r.dtype?"":0},backend:n})}const Vz={kernelName:ra,backendName:"webgl",kernelFunc:Wz},Gz={kernelName:Qn,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r}=t,{x:a}=n;if("string"===a.dtype)throw new Error("onesLike is not supported under string dtype");if("complex64"===a.dtype){const t=FR({inputs:{input:a},backend:r}),n=e({inputs:{x:t},backend:r}),i=ZR({inputs:{input:a},backend:r}),s=Wz({inputs:{x:i},backend:r}),o=uO({inputs:{real:n,imag:s},backend:r});return r.disposeIntermediateTensorInfo(t),r.disposeIntermediateTensorInfo(n),r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(s),o}return pY({attrs:{shape:a.shape,dtype:a.dtype,value:1},backend:r})}},Kz={kernelName:tr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r;if(1===t.length)return nY({inputs:{input:t[0]},backend:n,attrs:{dim:a}});const i=t[0].shape,s=t[0].dtype;t.forEach((e=>{oe(i,e.shape,"All tensors passed to stack must have matching shapes"),se(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],u=tF({inputs:t.map((e=>{const t=nY({inputs:{input:e},backend:n,attrs:{dim:a}});return o.push(t),t})),backend:n,attrs:{axis:a}});return o.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}};class Jz{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=AL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?`\n ${a} start = ${a}(${i});\n ${a} end = ${a}(${s});\n\n void main() {\n ${a} outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(value);\n } else {\n ${a} coords = outC - start;\n setOutput(getX(${o}));\n }\n }\n `:`\n int start = ${i};\n int end = ${s};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(value);\n } else {\n setOutput(getX(outC - start));\n }\n }\n `}}class Xz{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=AL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=H$("rc",r),u=H$("source",r),l=`${o[r-1]} < ${this.outputShape[r-1]}`,c=1===r?"source":`vec2(${u.slice(-2).join()})`,p=[`${a} rc = outputLoc;`,`${o[r-1]} += 1;\n if(${l}) {\n `,1===r?"":`}\n rc = outputLoc;\n ${o[r-2]} += 1;\n if(${o[r-2]} < ${this.outputShape[r-2]}) {`,1===r?"":` ${o[r-1]} += 1;\n if(${l}) {`],d=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let h="";for(let e=0,t=1===r?2:4;e{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,constantValue:s}=r;if(0===ce(a.shape)){const e=i.map(((e,t)=>e[0]+a.shape[t]+e[1]));return pY({backend:n,attrs:{shape:e,value:s,dtype:a.dtype}})}const o=Ge().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Xz(a.shape,i,s):new Jz(a.shape,i,s),u=[[s]];return n.runWebGLProgram(o,[a],a.dtype,u)},Qz={kernelName:nr,backendName:"webgl",kernelFunc:Zz},eB=yO({opSnippet:"\n if(a < 0.0 && floor(b) < b){\n return NAN;\n }\n if (b == 0.0) {\n return 1.0;\n }\n return (round(mod(b, 2.0)) != 1) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",packedOpSnippet:"\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"}),tB={kernelName:ar,backendName:"webgl",kernelFunc:eB},nB={kernelName:sr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=a.shape.length,u=[],l=ve(i,a.shape);let c=l;const p=xc(c,o);let d,h=a;if(null!=p&&(h=$O({inputs:{x:a},backend:n,attrs:{perm:p}}),c=_c(c.length,o),u.push(h)),bc("prod",c,o),n.shouldExecuteOnCPU([h])){const e=n.texData.get(h.dataId).values,{outVals:t,outShape:r,outDtype:a}=_$(h.shape,h.dtype,e,c);d=n.makeTensorInfo(r,a,t)}else{const[e,t]=gc(h.shape,c),r=ce(t),i=NO({inputs:{x:h},backend:n,attrs:{shape:[-1,r]}}),s=TO(i,pi(a.dtype),"prod",n);d=NO({inputs:{x:s},backend:n,attrs:{shape:e}}),u.push(i),u.push(s)}if(s){u.push(d);const e=yc(d.shape,l);d=NO({inputs:{x:d},backend:n,attrs:{shape:e}})}return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),d}},rB=e=>{const{backend:t,attrs:n}=e,{start:r,stop:a,step:i,dtype:s}=n,o=w$(r,a,i,s);return t.makeTensorInfo([o.length],s,o)},aB={kernelName:or,backendName:"webgl",kernelFunc:rB},iB=gO({opSnippet:"return 1.0 / x;"}),sB={kernelName:lr,backendName:"webgl",kernelFunc:iB},oB=gO({opSnippet:"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : x;\n",packedOpSnippet:"\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"}),uB={kernelName:cr,backendName:"webgl",kernelFunc:oB},lB=gO({opSnippet:"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",packedOpSnippet:"\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"}),cB={kernelName:gr,backendName:"webgl",kernelFunc:lB};class pB{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];let p;p=a?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0]/c[0]},\n ${l[1]/c[1]});\n const vec2 inputShapeRC = vec2(${s}.0, ${o}.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 = ${p};\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\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 `}}class dB{constructor(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];let p;p=a?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0]/c[0]},\n ${l[1]/c[1]},\n ${l[1]/c[1]});\n const vec3 inputShapeRC = vec3(${s}.0, ${o}.0,\n ${o}.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 = ${p};\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\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 < ${u-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 `}}const hB={kernelName:fr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r,[u,l]=o,c=Ge().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new dB(a.shape,u,l,i,s):new pB(a.shape,u,l,i,s);return n.runWebGLProgram(c,[a],"float32")}};class fB{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,a]=t,[,i,s]=e,o=[n&&i>1?r-1:r,n&&s>1?a-1:a],u=[n&&i>1?i-1:i,n&&s>1?s-1:s],l=o[0]/u[0],c=o[1]/u[1],p=1/l,d=1/c,h=2*Math.ceil(p)+2,f=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(${l});\n const float widthScale = float(${c});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${h});\n const int winWidth = int(${f});\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 >= ${i}) {\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 >= ${s}) {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), ${r-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 `}}const mB={kernelName:mr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a,dy:i}=t,{alignCorners:s}=r,o=new fB(i.shape,a.shape,s);return n.runWebGLProgram(o,[i],i.dtype)}};class gB{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],p=r?"0.5":"0.0";let d;d=a?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0]/c[0]},\n ${l[1]/c[1]});\n const vec2 inputShapeRC = vec2(${s}.0, ${o}.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 = ${d};\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n `}}class yB{constructor(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],p=r?"0.5":"0.0";let d;d=a?"max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0]/c[0]},\n ${l[1]/c[1]},\n ${l[1]/c[1]});\n const vec3 inputShapeRC = vec3(${s}.0, ${o}.0,\n ${o}.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 = ${d};\n\n // Compute the coordinators of nearest neighbor point.\n ivec3 sourceNearestRC = ivec3(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u-1};\n bool hasNextRow = coords.z < ${n-1};\n\n vec4 newValue = vec4(\n getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d),\n hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0);\n\n setOutput(newValue);\n }\n `}}const bB={kernelName:dr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r,[u,l]=o,c=Ge().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new yB(a.shape,u,l,i,s):new gB(a.shape,u,l,i,s);return n.runWebGLProgram(c,[a],a.dtype)}};class xB{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,a]=t,[,i,s]=e,o=[n&&i>1?r-1:r,n&&s>1?a-1:a],u=[n&&i>1?i-1:i,n&&s>1?s-1:s],l=o[0]/u[0],c=o[1]/u[1],p=1/l,d=1/c,h=2*Math.ceil(p)+2,f=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(${l});\n const float widthScale = float(${c});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${h});\n const int winWidth = int(${f});\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 >= ${i}) {\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 >= ${s}) {\n continue;\n }\n\n float sourceFracRow =\n float(${o[0]}) *\n (float(dyR) / float(${u[0]}));\n\n float sourceFracCol =\n float(${o[1]}) *\n (float(dyC) / float(${u[1]}));\n\n int sourceNearestRow = int(min(\n float(int(${r}) - 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 `}}const vB={kernelName:hr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a,dy:i}=t,{alignCorners:s}=r,o=new xB(i.shape,a.shape,s);return n.runWebGLProgram(o,[i],i.dtype)}};class _B{constructor(e,t){this.variableNames=["x"];const 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)return void(this.userCode=`\n void main() {\n int coord = getOutputCoords();\n setOutput(getX(${e[0]} - coord - 1));\n }\n `);const r=e.map(((n,r)=>(n=>-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - coords[${n}] - 1`:`coords[${n}]`)(r))).join(","),a=AL(n);this.userCode=`\n void main() {\n ${a} coords = getOutputCoords();\n setOutput(getX(${r}));\n }\n `}}class wB{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=e;const r=H$("rc",n),a=`${r[n-1]} + 1 < ${this.outputShape[n-1]}`,i=`${r[n-2]} + 1 < ${this.outputShape[n-2]}`,s=AL(n);function o(n){const r=e.map(((r,a)=>function(n,r){return-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - ${r[n]} - 1`:`${r[n]}`}(a,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(${a}){\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 ${s} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = ${function(e){return o(e)}(r.slice())};\n if(${a}){\n result.g = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",o(e)}(r.slice())};\n }\n if(${i}) {\n result.b = ${function(e){return e[n-2]="("+e[n-2]+" + 1)",o(e)}(r.slice())};\n if(${a}) {\n result.a = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",e[n-2]="("+e[n-2]+" + 1)",o(e)}(r.slice())};\n }\n }\n setOutput(result);\n }\n `}}const MB={kernelName:yr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:i}=r,s=a.shape.length,o=ve(i,a.shape);if(0===s)return sO({inputs:{x:a},backend:n});const u=Ge().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new wB(a.shape,o):new _B(a.shape,o);return n.runWebGLProgram(u,[a],a.dtype)}};class NB{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const n=e[1],r=e[2];this.outputShape=e;let a="";a="number"==typeof t?`float outputValue = ${t.toFixed(2)};`:`\n vec3 fill = vec3(${t.join(",")});\n float outputValue = fill[coords[3]];`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n int y = coords[1];\n float coordXFloat = (float(x) - params[0]) * params[3] -\n (float(y) - params[1]) * params[2];\n float coordYFloat = (float(x) - params[0]) * params[2] +\n (float(y) - params[1]) * params[3];\n int coordX = int(round(coordXFloat + params[0]));\n int coordY = int(round(coordYFloat + params[1]));\n ${a}\n if(coordX >= 0 && coordX < ${r} && coordY >= 0 && coordY < ${n}) {\n outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n }\n setOutput(outputValue);\n }\n `}}const SB={kernelName:sa,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:r}=e,{radians:a,fillValue:i,center:s}=t,o=n,u=new NB(r.shape,i),[l,c]=nf(s,r.shape[1],r.shape[2]),p=[[l,c,Math.sin(a),Math.cos(a)]];return o.runWebGLProgram(u,[r],r.dtype,p)}},kB=gO({opSnippet:"\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"}),DB={kernelName:br,backendName:"webgl",kernelFunc:kB},TB=gO({opSnippet:"return inversesqrt(x);",cpuKernelImpl:M$}),IB={kernelName:xr,backendName:"webgl",kernelFunc:TB};class EB{constructor(e,t,n,r,a,i,s=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=i;const o=AL(a.length),u=AL(i.length);let l="";1===n?l="i":2===n&&(l="i, j");const c=`getIndices(${l})`;let p="";1===r?p="i":2===r&&(p="i, coords[1]");const d=`getUpdates(${p})`,h=t>1?"strides[j]":"strides";this.userCode=`\n ${o} strides = ${o}(${a});\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(${c});\n flattenedIndex += index * ${h};\n }\n if (flattenedIndex == coords[0]) {\n sum += ${d};\n found = true;\n }\n }\n setOutput(mix(getDefaultValue(), sum, float(found)));\n }\n `}}const CB={kernelName:vr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{indices:a,updates:i}=t,{shape:s}=r,{sliceRank:o,numUpdates:u,sliceSize:l,strides:c,outputSize:p}=jo(0,a,s),d=[p/l,l];if(0===p)return n.makeTensorInfo(s,a.dtype);const h=NO({inputs:{x:a},backend:n,attrs:{shape:[u,o]}}),f=NO({inputs:{x:i},backend:n,attrs:{shape:[u,l]}}),m=n.makeTensorInfo([],"float32",new Float32Array([0])),g=new EB(u,o,h.shape.length,f.shape.length,c,d),y=n.runWebGLProgram(g,[f,h,m],f.dtype),b=NO({inputs:{x:y},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(m),b}};class AB{constructor(e,t,n,r){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,n];const a=`for (int i = 0; i < ${Math.ceil(Math.log2(t+1))}; ++i) { if (left >= right) break;`,i=2===Ge().getNumber("WEBGL_VERSION")?"while (left < right) {":a,s="left"===r?"<":"<=";this.userCode=`\n int findBound(int batch, float value) {\n int left = 0;\n int right = numInputs;\n int mid;\n ${i}\n mid = (left + right) / 2;\n if (getSortedSequence(batch, mid) ${s} value) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return right;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int valueIndex = coords[1];\n\n float value = getValues(batch, valueIndex);\n\n setOutput(float(findBound(batch, value)));\n }\n `}}const LB={kernelName:_r,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{sortedSequence:a,values:i}=t,{side:s}=r,o=new AB(a.shape[0],a.shape[1],i.shape[1],s),u=[[a.shape[1]]];return n.runWebGLProgram(o,[a,i],"int32",u)}};class $B{constructor(e,t,n){let r,a;if(this.variableNames=["c","a","b"],this.outputShape=t,n>4)throw Error(`Where for rank ${n} is not yet supported`);if(1===n)a="resRC",r="resRC";else{const n=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[],s=[];for(let r=0;r= 1.0) {\n setOutput(getA(${a}));\n } else {\n setOutput(getB(${a}));\n }\n }\n `}}const OB={kernelName:wr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{condition:r,t:a,e:i}=t,s=new $B(r.shape.length,a.shape,a.shape.length);return n.runWebGLProgram(s,[r,a,i],ci(a.dtype,i.dtype))}},RB=gO({opSnippet:`\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = ${lf};\n float scale = ${cf};\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n`}),FB={kernelName:Mr,backendName:"webgl",kernelFunc:RB},YB=gO({opSnippet:"if (isnan(x)) return x;\n return 1.0 / (1.0 + exp(-1.0 * x));\n",packedOpSnippet:"\n vec4 result = 1.0 / (1.0 + exp(-1.0 * x));\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",cpuKernelImpl:S$}),zB={kernelName:Tr,backendName:"webgl",kernelFunc:YB},BB=gO({opSnippet:"\n if (isnan(x)) { return 0.0; }\n return sign(x);\n"}),PB={kernelName:Dr,backendName:"webgl",kernelFunc:BB},HB=gO({opSnippet:"if (isnan(x)) return x;\n return sin(x);\n"}),jB={kernelName:Sr,backendName:"webgl",kernelFunc:HB},UB=gO({opSnippet:"\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n"}),qB={kernelName:kr,backendName:"webgl",kernelFunc:UB},WB=gO({opSnippet:"\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"}),VB={kernelName:Ir,backendName:"webgl",kernelFunc:WB},GB={kernelName:Ar,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,paddings:s}=r;se(a.shape.length<=4,(()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"));const o=i.reduce(((e,t)=>e*t)),u=[[0,0]];u.push(...s);for(let e=1+i.length;en.disposeIntermediateTensorInfo(e))),g}},KB={kernelName:Or,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{indices:r,values:a,denseShape:i,defaultValue:s}=t;if(1!==i.shape.length)throw new Error(`Dense shape must be a vector, saw:\n ${i.shape}`);if(2!==r.shape.length)throw new Error(`Indices must be a matrix, saw:\n ${r.shape}`);if(1!==a.shape.length)throw new Error(`Values must be a vector, saw:\n ${a.shape}`);if(0!==s.shape.length)throw new Error(`Default value must be a scalar, saw:\n ${s.shape}`);const o=n.readSync(r.dataId),u=n.readSync(a.dataId),l=n.readSync(i.dataId),c=n.readSync(s.dataId)[0],[p,d,h,f,m]=T$(o,r.shape,r.dtype,u,a.dtype,l,c);return[n.makeTensorInfo(d,r.dtype,p),n.makeTensorInfo([d[0]],a.dtype,h),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map((e=>Number(e))))),n.makeTensorInfo([m.length],r.dtype,new Int32Array(m))]}},JB={kernelName:Rr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{inputIndices:r,inputShape:a,newShape:i}=t;if(2!==r.shape.length)throw new Error(`Input indices should be a matrix but received shape ${r.shape}`);if(1!==a.shape.length)throw new Error(`Input shape should be a vector but received shape ${a.shape}`);if(1!==i.shape.length)throw new Error(`Target shape should be a vector but received shape ${i.shape}`);const s=Array.from(n.readSync(a.dataId)),o=n.readSync(r.dataId),u=Array.from(n.readSync(i.dataId)),[l,c,p]=I$(o,r.shape,r.dtype,s,u);return[n.makeTensorInfo(c,r.dtype,l),n.makeTensorInfo([p.length],i.dtype,new Int32Array(p))]}},XB={kernelName:Fr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:i}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error(`Indices should be a vector but received shape\n ${a.shape}`);if(1!==i.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${i.shape}`);const s=n.readSync(r.dataId),o=n.readSync(a.dataId),u=n.readSync(i.dataId),[l,c]=E$(s,r.shape,r.dtype,o,u,!0);return n.makeTensorInfo(c,r.dtype,l)}},ZB={kernelName:Yr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:i}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error(`Indices should be a vector but received shape\n ${a.shape}`);if(1!==i.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${i.shape}`);const s=n.readSync(r.dataId),o=n.readSync(a.dataId),u=n.readSync(i.dataId),[l,c]=E$(s,r.shape,r.dtype,o,u);return n.makeTensorInfo(c,r.dtype,l)}},QB={kernelName:zr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{sparseIndices:a,sparseValues:i,defaultValue:s}=t,{outputShape:o}=r,{sliceRank:u,numUpdates:l,sliceSize:c,strides:p,outputSize:d}=jo(0,a,o);if("string"===i.dtype){const e=n.bufferSync(a),t=n.bufferSync(i),r=Ha(n.readSync(s.dataId)[0]),h=N$(e,t,o,d,c,l,u,p,r,!1);return n.makeTensorInfo(o,h.dtype,h.values)}const h=new EB(l,u,a.shape.length,i.shape.length,p,[d,1],!1),f=n.runWebGLProgram(h,[i,a,s],i.dtype),m=NO({inputs:{x:f},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(f),m}},eP={kernelName:Lr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{numOrSizeSplits:i,axis:s}=r,o=ve(s,a.shape)[0],u=Af(a,i,o),l=a.shape.length,c=new Array(l).fill(0),p=a.shape.slice();return u.map((e=>{const t=[...p];t[o]=e;const r=ER({inputs:{x:a},backend:n,attrs:{begin:c,size:t}});return c[o]+=e,r}))}},tP="return sqrt(x);",nP=gO({opSnippet:tP,packedOpSnippet:tP,cpuKernelImpl:C$}),rP={kernelName:Er,backendName:"webgl",kernelFunc:nP},aP=gO({opSnippet:"return x * x;"}),iP={kernelName:Pr,backendName:"webgl",kernelFunc:aP},sP="return (a - b) * (a - b);",oP=yO({opSnippet:sP,packedOpSnippet:sP}),uP={kernelName:Br,backendName:"webgl",kernelFunc:oP},lP={kernelName:aa,backendName:"webgl",kernelFunc:function({inputs:e,attrs:t,backend:n}){const{x:r}=e,a=`if (isnan(x)) return x;\n return x > 0.0 ? 1.0 : float(${t.alpha});\n `,i=new K$(r.shape,a);return n.runWebGLProgram(i,[r],r.dtype)}};class cP{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;const r=n.length,a=AL(n.length),i=AL(n.length);let s="";if(1===r)s="coords * strides + begin";else{let e=0;s=n.map(((t,r)=>(e++,1===n.length?`coords * strides[${r}] + begin[${r}]`:`coords[${e-1}] * strides[${r}] + begin[${r}]`))).join(",")}this.userCode=`\n ${a} begin = ${a}(${e});\n ${a} strides = ${a}(${t});\n\n void main() {\n ${i} coords = getOutputCoords();\n setOutput(getX(${s}));\n }\n `}}const pP={kernelName:Hr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,end:s,strides:o,beginMask:u,endMask:l,ellipsisMask:c,newAxisMask:p,shrinkAxisMask:d}=r,{finalShapeSparse:h,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:y,begin:b,end:x,strides:v}=iu(a.shape,i,s,o,u,l,c,p,d);let _;if(m)_=NO({inputs:{x:a},backend:n,attrs:{shape:f}});else if(g||y){se(a.shape.length>=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=Wo(b,x,v),t=ER({inputs:{x:a},backend:n,attrs:{begin:b,size:e}});_=NO({inputs:{x:t},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(t)}else if(n.shouldExecuteOnCPU([a])){const e=n.readSync(a.dataId),t=As(a.shape,a.dtype,e),r=A$(h,t,v,b);_=n.makeTensorInfo(f,a.dtype,r.values)}else{const e=new cP(b,v,h);_=n.runWebGLProgram(e,[a],a.dtype)}const w=NO({inputs:{x:_},backend:n,attrs:{shape:f}});return n.disposeIntermediateTensorInfo(_),w}},dP={kernelName:jr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{separator:a,nGramWidths:i,leftPad:s,rightPad:o,padWidth:u,preserveShortSequences:l}=r,{data:c,dataSplits:p}=t,d=n.readSync(c.dataId),h=n.readSync(p.dataId),[f,m]=L$(d,h,a,i,s,o,u,l);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}},hP={kernelName:Ur,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{skipEmpty:a}=r,{input:i,delimiter:s}=t;if("string"!==i.dtype)throw new Error("Input must be of datatype string");if(1!==i.shape.length)throw new Error(`Input must be a vector, got shape: ${i.shape}`);if(0!==s.shape.length)throw new Error(`Delimiter must be a scalar, got shape: ${s.shape}`);const o=n.readSync(i.dataId),u=n.readSync(s.dataId)[0],[l,c,p]=$$(o,u,a),d=c.length;return[n.makeTensorInfo([d,2],"int32",l),n.makeTensorInfo([d],"string",c),n.makeTensorInfo([2],"int32",new Int32Array(p))]}},fP={kernelName:qr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{numBuckets:a}=r,{input:i}=t;if("string"!==i.dtype)throw new Error("Input must be of datatype string");if(a<=0)throw new Error("Number of buckets must be at least 1");const s=n.readSync(i.dataId),o=O$(s,a);return n.makeTensorInfo(i.shape,"int32",o)}},mP=gO({opSnippet:"return tan(x);"}),gP={kernelName:Vr,backendName:"webgl",kernelFunc:mP},yP=gO({opSnippet:"\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n"}),bP={kernelName:Gr,backendName:"webgl",kernelFunc:yP};class xP{constructor(e,t){this.variableNames=["A"];const n=new Array(e.length);for(let r=0;r5)throw Error(`Tile for rank ${t} is not yet supported`);if(1===t)return`imod(resRC, ${e[0]})`;const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[];for(let t=0;t5){const e=n.readSync(a.dataId),t="string"===a.dtype?e.map((e=>Ha(e))):e,r=As(a.shape,a.dtype,t),s=F$(r,i);return n.makeTensorInfo(s.shape,s.dtype,s.values)}const s=new xP(a.shape,i);return n.runWebGLProgram(s,[a],a.dtype)}const _P={kernelName:Kr,backendName:"webgl",kernelFunc:vP};class wP{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"negativeInf",type:"float"},{name:"dir",type:"int"},{name:"inc",type:"int"}],this.outputShape=e,this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // We compare elements pair-wise within a group of size 2 * inc.\n // The comparing rule for each group alternates between ascending\n // and descending. Within each group, we compare each pair at\n // positions i and i+inc. To decide whether an element at position i\n // is x0 or x1, we mod it by 2 * inc, if the result is smaller than\n // inc, it is in the first half of the group, we denote it as x0,\n // otherwise we denote it as x1.\n // For example, as shown in the Bitonic top K paper referenced above,\n // Figure5(a) shows that element[1] is in the\n // second half of the group when group size is 2, but it is in the\n // first half of the group when group size is 4.\n\n bool isFirstInPair = imod(elemIdx, 2 * inc) < inc;\n int i = isFirstInPair ? elemIdx : elemIdx - inc;\n\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc));\n float x0 = i0 < n ? getX(batch, i0) : negativeInf;\n float x1 = i1 < n ? getX(batch, i1) : negativeInf;\n\n // Denotes which direction indices are in (ascending or descending).\n bool reverse = imod(elemIdx, 2 * dir) >= dir;\n bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0);\n if (reverse == isGreater) { // Elements in opposite order of direction\n int iTemp = i0;\n i0 = i1;\n i1 = iTemp;\n }\n if (isFirstInPair) {\n setOutput(float(i0));\n } else {\n setOutput(float(i1));\n }\n }\n "}}class MP{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=e,this.userCode="\n void main() {\n // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ...\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // The output size is half of the previous size.\n // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4),\n // we only need to output the indices at positions |, the indices at\n // positions _ can be thrown away, see Figure5(b) After Phase 2\n // (Merge phase) in the Bitonic Top K paper referenced above.\n // For example, the paper shows we only need to output the orange bars.\n // The output sequence should look like this | | | | | | | |.\n // Because the sequence is halved, to map the output index back\n // to the previous sequence to find the corresponding value,\n // we need to double the index. When we double the index,\n // we basically interpolate a position, so 2i looks like\n // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position\n // of each 2k positions by - elemIdx % k. E.g. for output at\n // index 4,5,6,7, we want to get the corresponding element at\n // original index 8,9,10,11, for output at index 8,9,10,11,\n // we want to get the corresponding element at original index\n // 16,17,18,19, so on and so forth.\n\n int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k));\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k));\n\n float x0 = getX(batch, i0);\n float x1 = i1 < n ? getX(batch, i1) : x0;\n\n setOutput(x0 >= x1 ? float(i0) : float(i1));\n }\n "}}function NP(e,t){null!==t&&e.disposeIntermediateTensorInfo(t)}function SP(e){let t=1;for(;tu){const e=n.readSync(a.dataId),[t,r]=Y$(e,l,a.dtype,i,s);return[n.makeTensorInfo(t.shape,t.dtype,t.values),n.makeTensorInfo(r.shape,r.dtype,r.values)]}if(0===i)return l[l.length-1]=0,[n.makeTensorInfo(l,a.dtype,[]),n.makeTensorInfo(l,"int32",[])];if(1===c)return[a,pY({attrs:{shape:l,dtype:"int32",value:0},backend:n})];const p=n.texData.get(a.dataId),d=null!==p&&p.isPacked,h=d?n.unpackTensor(a):a,f=ce(l)/c,m=NO({inputs:{x:h},attrs:{shape:[f,c]},backend:n});d&&NP(n,h);const g=SP(i),y=SP(c);let b=null;const x=()=>null===b?[m,m]:[m,b],v=(e,t,r)=>{const a=x(),i=new wP(r),s=[[c],[null===b?1:0],[Number.NEGATIVE_INFINITY],[e],[t]],o=b;b=n.runWebGLProgram(i,a,"int32",s),NP(n,o)};for(let e=1;e=1;n/=2)v(t,n,[f,y])}for(let e=y;e>g;e/=2){const t=x(),r=new MP([f,e/2]),a=[[c],[null===b?1:0],[g]],i=b;b=n.runWebGLProgram(r,t,"int32",a),NP(n,i);const s=g/2,o=2*s;for(let e=s;e>=1;e/=2)v(o,e,b.shape)}let _=b;b=ER({inputs:{x:b},backend:n,attrs:{begin:0,size:[f,i]}}),NP(n,_);let w=IY({inputs:{x:m,indices:b},backend:n,attrs:{axis:1,batchDims:1}});NP(n,m);const M=l.slice(0,-1);M.push(i),_=b,b=NO({inputs:{x:b},attrs:{shape:M},backend:n}),NP(n,_);const N=w;return w=NO({inputs:{x:w},attrs:{shape:M},backend:n}),NP(n,N),[w,b]}};class DP{constructor(e,t,n,r,a,i){this.variableNames=["Image","Transforms"],this.outputShape=i;const s="nearest"===n?1:2;let o;switch(r){case"constant":default:o=1;break;case"reflect":o=2;break;case"wrap":o=3;break;case"nearest":o=4}this.userCode=`\n float mapCoord(float outCoord, float len) {\n float inCoord = outCoord;\n if(${o} == 2) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n if (inCoord < sz2) {\n inCoord = sz2 * float(int(float(-inCoord / sz2))) +\n inCoord;\n }\n inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n inCoord -= sz2 * float(int(float(inCoord / sz2)));\n if (inCoord >= len) {\n inCoord = sz2 - inCoord - 1.0;\n }\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${o} == 3) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord -= len * float(int(float(inCoord / sz)));\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${o} == 4) {\n return clamp(outCoord, 0.0, len - 1.0);\n } else {\n return outCoord;\n }\n }\n\n float readWithFillValue(int batch, int coordY, int coordX,\n int channel) {\n float outputValue;\n if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) {\n outputValue = getImage(batch, coordY, coordX, channel);\n } else {\n outputValue = float(${a});\n }\n return outputValue;\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n float outputValue;\n int batch = coords[0];\n int x = coords[2];\n int y = coords[1];\n int channel = coords[3];\n float xf = float(x);\n float yf = float(y);\n float a1 = getTransforms(batch, 0);\n float a2 = getTransforms(batch, 1);\n float a3 = getTransforms(batch, 2);\n float b1 = getTransforms(batch, 3);\n float b2 = getTransforms(batch, 4);\n float b3 = getTransforms(batch, 5);\n float c1 = getTransforms(batch, 6);\n float c2 = getTransforms(batch, 7);\n float projection = c1 * xf + c2 * yf + 1.0;\n if (projection == 0.0) {\n outputValue = float(${a});\n } else {\n float inX = (a1 * xf + a2 * yf + a3) / projection;\n float inY = (b1 * xf + b2 * yf + b3) / projection;\n float mapX = mapCoord(inX, float(${t}));\n float mapY = mapCoord(inY, float(${e}));\n\n if (${s} == 1) {\n int coordY = int(round(mapY));\n int coordX = int(round(mapX));\n outputValue = readWithFillValue(batch, coordY, coordX,\n channel);\n } else {\n float yFloor = floor(mapY);\n float xFloor = floor(mapX);\n float yCeil = yFloor + 1.0;\n float xCeil = xFloor + 1.0;\n float valueYFloor = (xCeil - mapX) *\n readWithFillValue(batch, int(yFloor), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yFloor), int(xCeil), channel);\n float valueYCeil = (xCeil - mapX) *\n readWithFillValue(batch, int(yCeil), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yCeil), int(xCeil), channel);\n outputValue = (yCeil - mapY) * valueYFloor +\n (mapY - yFloor) * valueYCeil;\n }\n }\n setOutput(outputValue);\n }\n `}}const TP={kernelName:Xr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a,transforms:i}=t,{interpolation:s,fillMode:o,fillValue:u,outputShape:l}=r,[c,p,d,h]=a.shape,[f,m]=null!=l?l:[p,d],g=new DP(p,d,s,o,u,[c,f,m,h]);return n.runWebGLProgram(g,[a,i],"float32")}},IP={kernelName:Qr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{axis:a}=n,{x:i}=t;mL(i,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const s=r.readSync(i.dataId),{outputValues:o,outputShape:u,indices:l}=B$(s,a,i.shape,i.dtype);return[r.makeTensorInfo(u,i.dtype,o),r.makeTensorInfo([l.length],"int32",l)]}},EP={kernelName:ea,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{value:a}=t;let{axis:i}=r;i<0&&(i+=a.shape.length);const s=a,o=s.shape.length,u=a.shape[i],l=new Array(o-1);let c=0;for(let e=0;en.disposeIntermediateTensorInfo(e))),f}};class CP{constructor(e,t){this.variableNames=["x","segmentIds"];const n=e.windowSize,r=e.batchSize,a=e.inSize,i=e.numSegments,s=i*Math.ceil(a/n);this.outputShape=[r,s];const o=4*Math.floor(n/4),u=n%4,l="\n sumValue += dot(values, segFilter);\n ";let c="";a%n>0&&(c=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return initializationValue;\n }\n `);let p="";a%n>0&&(p=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return -1.0;\n }\n `),this.userCode=`\n const float initializationValue = 0.0;\n\n float getValue(int batch, int inIdx) {\n ${c}\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n ${p}\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 ${i})) * float(${n}));\n int currentSeg = int(mod(float(outIdx), float(${i})));\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${o}; 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 ${l}\n }\n\n int inIdx = inOffset + ${o};\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 ${l}\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 ${l}\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 ${l}\n }\n setOutput(sumValue);\n }\n `}}const AP={kernelName:ta,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,segmentIds:i}=t,{numSegments:s}=r,o=a.shape.length,u=[];let l=0;const c=xc([l],o);let p=a;null!=c&&(p=$O({inputs:{x:a},backend:n,attrs:{perm:c}}),u.push(p),l=_c(1,o)[0]);const d=Wf(p.shape,l,s),h=ce([p.shape[l]]),f=NO({inputs:{x:p},backend:n,attrs:{shape:[-1,h]}});u.push(f);const m=pi(a.dtype),g=(e,t,r,a,i)=>{const s=e.shape[0],o=e.shape[1],l=qf(o,i),c=new CP({windowSize:l,inSize:o,batchSize:s,numSegments:i},t),p=n.compileAndRun(c,[e,r],a);if(u.push(p),p.shape[1]===i)return p;const d=rB({backend:n,attrs:{start:0,stop:i,step:1,dtype:"float32"}}),h=vP({inputs:{x:d},backend:n,attrs:{reps:[o/l]}});return u.push(d),u.push(h),g(p,t,h,a,i)},y=NO({inputs:{x:g(f,"unsortedSegmentSum",i,m,s)},backend:n,attrs:{shape:d}});let b=y;if(null!=c){u.push(y);const e=vc(c);b=$O({inputs:{x:b},backend:n,attrs:{perm:e}})}return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),b}},LP=[FO,zO,PO,jO,WO,KO,JO,XO,rR,aR,sR,uR,cR,dR,fR,yR,bR,_R,wR,MR,kR,AR,LR,$R,zR,HR,qR,lO,GR,nF,lF,fF,mF,gF,yF,bF,vF,wF,NF,EF,CF,AF,$F,FF,BF,PF,jF,qF,WF,GF,KF,XF,QF,tY,rY,sY,lY,dY,fY,yY,xY,wY,NY,SY,DY,EY,AY,$Y,oO,OY,QR,FY,zY,PY,dO,jY,qY,WY,GY,JY,ZY,ez,nz,iz,oz,lz,pz,dz,hz,gz,yz,bz,xz,vz,wz,Sz,Dz,Rz,MO,Fz,zz,Pz,jz,RR,qz,Gz,Kz,Qz,tB,mO,nB,aB,YR,Ez,sB,uB,cB,SO,hB,mB,bB,vB,MB,SB,DB,IB,CB,LB,OB,FB,zB,PB,jB,qB,CR,Oz,VB,GB,KB,JB,XB,ZB,QB,eP,rP,iP,uP,lP,pP,dP,hP,fP,Lz,LO,gP,bP,_P,kP,TP,OO,IP,EP,AP,Vz];for(const e of LP)ya(e);const $P={"tfjs-core":_u,"tfjs-backend-cpu":"3.19.0","tfjs-backend-webgl":"3.19.0","tfjs-data":Sk,"tfjs-layers":Bx,"tfjs-converter":bS,tfjs:"3.19.0"};function OP(){return OP=Object.assign?Object.assign.bind():function(e){for(var t=1;te[t]))}var AH=["Matrix","Array"],LH=["number","BigNumber","Fraction"];function $H(e,t){function n(n){if(n){var r=MH(e,wH);OH(n,"matrix",AH),OH(n,"number",LH),SH(e,n);var a=MH(e,wH),i=MH(n,wH);return t("config",a,r,i),a}return MH(e,wH)}return n.MATRIX_OPTIONS=AH,n.NUMBER_OPTIONS=LH,Object.keys(RP).forEach((t=>{Object.defineProperty(n,t,{get:()=>e[t],enumerable:!0,configurable:!0})})),n}function OH(e,t,n){void 0===e[t]||function(e,t){return-1!==e.indexOf(t)}(n,e[t])||console.warn('Warning: Unknown value "'+e[t]+'" for configuration option "'+t+'". Available options: '+n.map((e=>JSON.stringify(e))).join(", ")+".")}var RH=function(e){if(e)throw new Error("The global config is readonly. \nPlease create a mathjs instance if you want to change the default configuration. \nExample:\n\n import { create, all } from 'mathjs';\n const mathjs = create(all);\n mathjs.config({ number: 'BigNumber' });\n");return Object.freeze(RP)};OP(RH,RP,{MATRIX_OPTIONS:AH,NUMBER_OPTIONS:LH});var FH=n(3776);function YH(e,t,n,r){function a(r){var a=function(e,t){for(var n={},r=0;r!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==n[e]))){var r=t.filter((e=>void 0===n[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(r.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,t,r),n(a)}return a.isFactory=!0,a.fn=e,a.dependencies=t.slice().sort(),r&&(a.meta=r),a}function zH(e){return"function"==typeof e&&"string"==typeof e.fn&&Array.isArray(e.dependencies)}function BH(e){return e&&"?"===e[0]?e.slice(1):e}var PH=YH("BigNumber",["?on","config"],(e=>{var{on:t,config:n}=e,r=FH.clone({precision:n.precision,modulo:FH.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(e){return new r(e.value)},t&&t("config",(function(e,t){e.precision!==t.precision&&r.config({precision:e.precision})})),r}),{isClass:!0}),HH=n(1977);function jH(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var UH=Math.sign||function(e){return e>0?1:e<0?-1:0},qH=Math.log2||function(e){return Math.log(e)/Math.LN2},WH=Math.log10||function(e){return Math.log(e)/Math.LN10},VH=Math.log1p||function(e){return Math.log(e+1)},GH=Math.cbrt||function(e){if(0===e)return e;var t,n=e<0;return n&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,n?-t:t},KH=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function JH(e,t,n){var r={2:"0b",8:"0o",16:"0x"}[t],a="";if(n){if(n<1)throw new Error("size must be in greater than 0");if(!jH(n))throw new Error("size must be an integer");if(e>2**(n-1)-1||e<-(2**(n-1)))throw new Error("Value must be in range [-2^".concat(n-1,", 2^").concat(n-1,"-1]"));if(!jH(e))throw new Error("Value must be an integer");e<0&&(e+=2**n),a="i".concat(n)}var i="";return e<0&&(e=-e,i="-"),"".concat(i).concat(r).concat(e.toString(t)).concat(a)}function XH(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var n,r,a="auto";if(t&&(t.notation&&(a=t.notation),FP(t)?n=t:FP(t.precision)&&(n=t.precision),t.wordSize&&"number"!=typeof(r=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return QH(e,n);case"exponential":return ej(e,n);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=tj(ZH(e),t),r=n.exponent,a=n.coefficients,i=r%3==0?r:r<0?r-3-r%3:r-r%3;if(FP(t))for(;t>a.length||r-i+1>a.length;)a.push(0);else for(var s=Math.abs(r-i)-(a.length-1),o=0;o0;)l++,u--;var c=a.slice(l).join(""),p=FP(t)&&c.length||c.match(/[1-9]/)?"."+c:"",d=a.slice(0,l).join("")+p+"e"+(r>=0?"+":"")+i.toString();return n.sign+d}(e,n);case"bin":return JH(e,2,r);case"oct":return JH(e,8,r);case"hex":return JH(e,16,r);case"auto":return function(e,t,n){if(isNaN(e)||!isFinite(e))return String(e);var r=n&&void 0!==n.lowerExp?n.lowerExp:-3,a=n&&void 0!==n.upperExp?n.upperExp:5,i=ZH(e),s=t?tj(i,t):i;if(s.exponent=a)return ej(e,t);var o=s.coefficients,u=s.exponent;o.length0?u:0;return l<(o=nj(-u).concat(o)).length-1&&o.splice(l+1,0,"."),s.sign+o.join("")}(e,n,t&&t).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t}));default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ZH(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var n=t[1],r=t[2],a=parseFloat(t[4]||"0"),i=r.indexOf(".");a+=-1!==i?i-1:r.length-1;var s=r.replace(".","").replace(/^0*/,(function(e){return a-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===s.length&&(s.push(0),a++),{sign:n,coefficients:s,exponent:a}}function QH(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=ZH(e),r="number"==typeof t?tj(n,n.exponent+1+t):n,a=r.coefficients,i=r.exponent+1,s=i+(t||0);return a.length0?"."+a.join(""):"")+"e"+(i>=0?"+":"")+i}function tj(e,t){for(var n={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},r=n.coefficients;t<=0;)r.unshift(0),n.exponent++,t++;if(r.length>t&&r.splice(t,r.length-t)[0]>=5){var a=t-1;for(r[a]++;10===r[a];)r.pop(),0===a&&(r.unshift(0),n.exponent++,a++),r[--a]++}return n}function nj(e){for(var t=[],n=0;n(HH.prototype.type="Complex",HH.prototype.isComplex=!0,HH.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},HH.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},HH.prototype.format=function(e){var t=this.im,n=this.re,r=XH(this.re,e),a=XH(this.im,e),i=FP(e)?e:e?e.precision:null;if(null!==i){var s=Math.pow(10,-i);Math.abs(n/t)t.re?1:e.ret.im?1:e.im1&&void 0!==arguments[1]?arguments[1]:{};return n=null==n?Number.POSITIVE_INFINITY:n,t=null==t?JSON.stringify:t,function r(){"object"!=typeof r.cache&&(r.cache={values:new Map,lru:dj(n||Number.POSITIVE_INFINITY)});for(var a=[],i=0;i!0)),Nj=YH("false",[],(()=>!1)),Sj=YH("null",[],(()=>null)),kj=Hj("Infinity",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(1/0):1/0})),Dj=Hj("NaN",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(NaN):NaN})),Tj=Hj("pi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?yj(n):vj})),Ij=Hj("tau",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?bj(n):_j})),Ej=Hj("e",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?mj(n):wj})),Cj=Hj("phi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?gj(n):1.618033988749895})),Aj=Hj("LN2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(2).ln():Math.LN2})),Lj=Hj("LN10",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(10).ln():Math.LN10})),$j=Hj("LOG2E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(1).div(new n(2).ln()):Math.LOG2E})),Oj=Hj("LOG10E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(1).div(new n(10).ln()):Math.LOG10E})),Rj=Hj("SQRT1_2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n("0.5").sqrt():Math.SQRT1_2})),Fj=Hj("SQRT2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(2).sqrt():Math.SQRT2})),Yj=Hj("i",["Complex"],(e=>{var{Complex:t}=e;return t.I})),zj=YH("PI",["pi"],(e=>{var{pi:t}=e;return t})),Bj=YH("E",["e"],(e=>{var{e:t}=e;return t})),Pj=YH("version",[],(()=>"10.6.4"));function Hj(e,t,n){return YH(e,t,n,{recreateOnConfigChange:!0})}var jj=zU("speedOfLight","299792458","m s^-1"),Uj=zU("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),qj=zU("planckConstant","6.62607015e-34","J s"),Wj=zU("reducedPlanckConstant","1.0545718176461565e-34","J s"),Vj=zU("magneticConstant","1.25663706212e-6","N A^-2"),Gj=zU("electricConstant","8.8541878128e-12","F m^-1"),Kj=zU("vacuumImpedance","376.730313667","ohm"),Jj=zU("coulomb","8.987551792261171e9","N m^2 C^-2"),Xj=zU("elementaryCharge","1.602176634e-19","C"),Zj=zU("bohrMagneton","9.2740100783e-24","J T^-1"),Qj=zU("conductanceQuantum","7.748091729863649e-5","S"),eU=zU("inverseConductanceQuantum","12906.403729652257","ohm"),tU=zU("magneticFluxQuantum","2.0678338484619295e-15","Wb"),nU=zU("nuclearMagneton","5.0507837461e-27","J T^-1"),rU=zU("klitzing","25812.807459304513","ohm"),aU=zU("bohrRadius","5.29177210903e-11","m"),iU=zU("classicalElectronRadius","2.8179403262e-15","m"),sU=zU("electronMass","9.1093837015e-31","kg"),oU=zU("fermiCoupling","1.1663787e-5","GeV^-2"),uU=BU("fineStructure",.0072973525693),lU=zU("hartreeEnergy","4.3597447222071e-18","J"),cU=zU("protonMass","1.67262192369e-27","kg"),pU=zU("deuteronMass","3.3435830926e-27","kg"),dU=zU("neutronMass","1.6749271613e-27","kg"),hU=zU("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),fU=zU("rydberg","10973731.568160","m^-1"),mU=zU("thomsonCrossSection","6.6524587321e-29","m^2"),gU=BU("weakMixingAngle",.2229),yU=BU("efimovFactor",22.7),bU=zU("atomicMass","1.66053906660e-27","kg"),xU=zU("avogadro","6.02214076e23","mol^-1"),vU=zU("boltzmann","1.380649e-23","J K^-1"),_U=zU("faraday","96485.33212331001","C mol^-1"),wU=zU("firstRadiation","3.7417718521927573e-16","W m^2"),MU=zU("loschmidt","2.686780111798444e25","m^-3"),NU=zU("gasConstant","8.31446261815324","J K^-1 mol^-1"),SU=zU("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),kU=zU("molarVolume","0.022413969545014137","m^3 mol^-1"),DU=BU("sackurTetrode",-1.16487052358),TU=zU("secondRadiation","0.014387768775039337","m K"),IU=zU("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),EU=zU("wienDisplacement","2.897771955e-3","m K"),CU=zU("molarMass","0.99999999965e-3","kg mol^-1"),AU=zU("molarMassC12","11.9999999958e-3","kg mol^-1"),LU=zU("gravity","9.80665","m s^-2"),$U=zU("planckLength","1.616255e-35","m"),OU=zU("planckMass","2.176435e-8","kg"),RU=zU("planckTime","5.391245e-44","s"),FU=zU("planckCharge","1.87554603778e-18","C"),YU=zU("planckTemperature","1.416785e+32","K");function zU(e,t,n){return YH(e,["config","Unit","BigNumber"],(e=>{var{config:r,Unit:a,BigNumber:i}=e,s=new a("BigNumber"===r.number?new i(t):parseFloat(t),n);return s.fixPrefix=!0,s}))}function BU(e,t){return YH(e,["config","BigNumber"],(e=>{var{config:n,BigNumber:r}=e;return"BigNumber"===n.number?new r(t):t}))}var PU=n(5628),HU=YH("Fraction",[],(()=>(PU.prototype.type="Fraction",PU.prototype.isFraction=!0,PU.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},PU.fromJSON=function(e){return new PU(e)},PU)),{isClass:!0}),jU=YH("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,n){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,n){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0}),UU=YH("Range",[],(()=>{function e(t,n,r){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var a=null!=t,i=null!=n,s=null!=r;if(a)if(YP(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(i)if(YP(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter end must be a number");if(s)if(YP(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter step must be a number");this.start=a?parseFloat(t):0,this.end=i?parseFloat(n):0,this.step=s?parseFloat(r):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if("string"!=typeof t)return null;var n=t.split(":").map((function(e){return parseFloat(e)})),r=n.some((function(e){return isNaN(e)}));if(r)return null;switch(n.length){case 2:return new e(n[0],n[1]);case 3:return new e(n[0],n[2],n[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,n=this.step,r=this.end-t;return UH(n)===UH(r)?e=Math.ceil(r/n):0===r&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var t=this.start,n=this.step,r=this.end,a=0;if(n>0)for(;tr;)e(t,[a],this),t+=n,a++},e.prototype.map=function(e){var t=[];return this.forEach((function(n,r,a){t[r[0]]=e(n,r,a)})),t},e.prototype.toArray=function(){var e=[];return this.forEach((function(t,n){e[n[0]]=t})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=XH(this.start,e);return 1!==this.step&&(t+=":"+XH(this.step,e)),t+":"+XH(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e}),{isClass:!0}),qU=YH("ResultSet",[],(()=>{function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=t||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e}),{isClass:!0});function WU(e,t,n){var r=new(0,e.constructor)(2),a="";if(n){if(n<1)throw new Error("size must be in greater than 0");if(!jH(n))throw new Error("size must be an integer");if(e.greaterThan(r.pow(n-1).sub(1))||e.lessThan(r.pow(n-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(n-1,", 2^").concat(n-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(r.pow(n))),a="i".concat(n)}switch(t){case 2:return"".concat(e.toBinary()).concat(a);case 8:return"".concat(e.toOctal()).concat(a);case 16:return"".concat(e.toHexadecimal()).concat(a);default:throw new Error("Base ".concat(t," not supported "))}}function VU(e,t){return void 0!==t?e.toExponential(t-1):e.toExponential()}function GU(e,t){var n=e.length-t.length,r=e.length;return e.substring(n,r)===t}function KU(e,t){var n=function(e,t){return"number"==typeof e?XH(e,t):YP(e)?function(e,t){if("function"==typeof t)return t(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var n,r,a="auto";if(void 0!==t&&(t.notation&&(a=t.notation),"number"==typeof t?n=t:t.precision&&(n=t.precision),t.wordSize&&"number"!=typeof(r=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return function(e,t){return e.toFixed(t)}(e,n);case"exponential":return VU(e,n);case"engineering":return function(e,t){var n=e.e,r=n%3==0?n:n<0?n-3-n%3:n-n%3,a=e.mul(Math.pow(10,-r)),i=a.toPrecision(t);return-1!==i.indexOf("e")&&(i=a.toString()),i+"e"+(n>=0?"+":"")+r.toString()}(e,n);case"bin":return WU(e,2,r);case"oct":return WU(e,8,r);case"hex":return WU(e,16,r);case"auto":var i=t&&void 0!==t.lowerExp?t.lowerExp:-3,s=t&&void 0!==t.upperExp?t.upperExp:5;if(e.isZero())return"0";var o=e.toSignificantDigits(n),u=o.e;return(u>=i&&u'"'+n+'": '+KU(e[n],t))).join(", ")+"}":String(e)}(e,t);return t&&"object"==typeof t&&"truncate"in t&&n.length>t.truncate?n.substring(0,t.truncate-3)+"...":n}function JU(e){for(var t=String(e),n="",r=0;r/g,">")}function ZU(e,t){if(Array.isArray(e)){for(var n="[",r=e.length,a=0;at?1:-1}function eq(e,t,n){if(!(this instanceof eq))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=n,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function tq(e,t,n){if(!(this instanceof tq))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=n),void 0!==this.min&&this.index=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function nq(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function rq(e,t,n){var r,a=e.length;if(a!==t[n])throw new eq(a,t[n]);if(n")}function aq(e,t){if(0===t.length){if(Array.isArray(e))throw new eq(e.length,0)}else rq(e,t,0)}function iq(e,t){if(!FP(e)||!jH(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new tq(e,t)}function sq(e,t,n){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach((function(e){if(!FP(e)||!jH(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+KU(t)+")")})),oq(e,t,0,void 0!==n?n:0),e}function oq(e,t,n,r){var a,i,s=e.length,o=t[n],u=Math.min(s,o);if(e.length=o,n=0){if(t%n!=0)throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-n);r[a]=-t/n}return r}function cq(e){return e.reduce(((e,t)=>e*t),1)}function pq(e,t){for(var n=t||nq(e);Array.isArray(e)&&1===e.length;)e=e[0],n.shift();for(var r=n.length;1===n[r-1];)r--;return rt.test(e)))}function vq(e,t){return Array.prototype.join.call(e,t)}function _q(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],n=0;t[0]={value:e[0],identifier:0};for(var r=1;r{var{Matrix:t}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!HP(t))throw new Error("Invalid datatype: "+t);if(UP(e))"DenseMatrix"===e.type?(this._data=wH(e._data),this._size=wH(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&jP(e.data)&&jP(e.size))this._data=e.data,this._size=e.size,aq(this._data,this._size),this._datatype=t||e.datatype;else if(jP(e))this._data=l(e),this._size=nq(this._data),aq(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+_H(e)+")");this._data=[],this._size=[0],this._datatype=t}}function r(e,t){if(!KP(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var r=t.size();if(r.length!==e._size.length)throw new eq(r.length,e._size.length);for(var i=t.min(),s=t.max(),o=0,u=e._size.length;o");var p=t.max().map((function(e){return e+1}));u(e,p,r);var d=i.length;s(e._data,t,n,d,0)}return e}function s(e,t,n,r,a){var i=a===r-1,o=t.dimension(a);i?o.forEach((function(t,r){iq(t),e[t]=n[r[0]]})):o.forEach((function(i,o){iq(i),s(e[i],t,n[o[0]],r,a+1)}))}function o(e,t,n){if(0===t.length){for(var r=e._data;jP(r);)r=r[0];return r}return e._size=t.slice(0),e._data=sq(e._data,e._size,n),e}function u(e,t,n){for(var r=e._size.slice(0),a=!1;r.lengthr[i]&&(r[i]=t[i],a=!0);a&&o(e,r,n)}function l(e){for(var t=0,n=e.length;tArray.isArray(e)&&1===e.length?e[0]:e));return o(n?this.clone():this,r,t)},n.prototype.reshape=function(e,t){var n=t?this.clone():this;n._data=uq(n._data,e);var r=n._size.reduce(((e,t)=>e*t));return n._size=lq(e,r),n},n.prototype.clone=function(){return new n({data:wH(this._data),size:wH(this._size),datatype:this._datatype})},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(e){var t=this,r=function n(r,a){return jP(r)?r.map((function(e,t){return n(e,a.concat(t))})):e(r,a,t)}(this._data,[]);return new n(r,void 0!==this._datatype?Mq(r,_H):void 0)},n.prototype.forEach=function(e){var t=this;!function n(r,a){jP(r)?r.forEach((function(e,t){n(e,a.concat(t))})):e(r,a,t)}(this._data,[])},n.prototype[Symbol.iterator]=function*(){yield*function*e(t,n){if(jP(t))for(var r=0;r[e[r]]));t.push(new n(i,e._datatype))},s=0;s0?e:0,r=e<0?-e:0,a=this._size[0],i=this._size[1],s=Math.min(a-r,i-t),o=[],u=0;u0?r:0,o=r<0?-r:0,u=e[0],l=e[1],c=Math.min(u-o,l-s);if(jP(t)){if(t.length!==c)throw new Error("Invalid value array length");i=function(e){return t[e]}}else if(UP(t)){var p=t.size();if(1!==p.length||p[0]!==c)throw new Error("Invalid matrix length");i=function(e){return t.get([e])}}else i=function(){return t};a||(a=YP(i(0))?i(0).mul(0):0);var d=[];if(e.length>0){d=sq(d,e,a);for(var h=0;hfunction(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}})),Dq=n(2287);function Tq(e,t){if(Aq(e)&&Eq(e,t))return e[t];if("function"==typeof e[t]&&Cq(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function Iq(e,t,n){if(Aq(e)&&Eq(e,t))return e[t]=n,n;throw new Error('No access to property "'+t+'"')}function Eq(e,t){return!(!e||"object"!=typeof e||!EH(Lq,t)&&(t in Object.prototype||t in Function.prototype))}function Cq(e,t){return!(null==e||"function"!=typeof e[t]||EH(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)||!EH($q,t)&&(t in Object.prototype||t in Function.prototype))}function Aq(e){return"object"==typeof e&&e&&e.constructor===Object}var Lq={length:!0,name:!0},$q={toString:!0,valueOf:!0,toLocaleString:!0};class Oq{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return Tq(this.wrappedObject,e)}set(e,t){return Iq(this.wrappedObject,e,t),this}has(e){return e in this.wrappedObject}}function Rq(){return new Map}function Fq(e){if(!e)return Rq();if(Yq(e))return e;if(nH(e))return new Oq(e);throw new Error("createMap can create maps from objects or Maps")}function Yq(e){return!!e&&(e instanceof Map||e instanceof Oq||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function zq(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t(e)}},{from:"number",to:"Complex",convert:function(e){return n||jq(e),new n(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return n||jq(e),new n(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return n||jq(e),new n(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){a||Uq(e);var t=new a(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(e){t||Hq(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){a||Uq(e);try{return new a(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){n||jq(e);try{return new n(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return t||Hq(e),new t(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return a||Uq(e),new a(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return r||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new r(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],i}));function Hq(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function jq(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function Uq(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}function qq(e){var t,n,r=e.length,a=e[0].length,i=[];for(n=0;n=r.length)throw new tq(t,r.length);return UP(e)?e.create(Jq(e.valueOf(),t,n)):Jq(e,t,n)}function Jq(e,t,n){var r,a,i,s;if(t<=0){if(Array.isArray(e[0])){for(s=qq(e),a=[],r=0;r0)return e-t*Math.floor(e/t);if(0===t)return e;throw new Error("Cannot calculate mod for a negative divisor")}function fW(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=t<0;if(n&&(t=-t),0===t)throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return n?1/0:0;if(!isFinite(e))return n?0:e;var r=Math.pow(Math.abs(e),1/t);return r=e<0?-r:r,n?1/r:r}function mW(e){return UH(e)}function gW(e){return e*e}function yW(e,t){var n,r,a,i=0,s=1,o=1,u=0;if(!jH(e)||!jH(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)a=e-(r=Math.floor(e/t))*t,n=i,i=s-r*i,s=n,n=o,o=u-r*o,u=n,e=t,t=a;return e<0?[-e,-s,-u]:[e,e?s:0,u]}function bW(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function xW(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!jH(t)||t<0||t>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(QH(e,t))}eW.signature=Zq,tW.signature=Qq,nW.signature=Qq,rW.signature=Zq,aW.signature=Zq,iW.signature=Zq,sW.signature=Zq,oW.signature=Zq,uW.signature=Zq,lW.signature=Qq,cW.signature=Qq,pW.signature=Zq,dW.signature=Zq,hW.signature=Qq,mW.signature=Zq,gW.signature=Zq,yW.signature=Qq,bW.signature=Qq;var vW="unaryPlus",_W=YH(vW,["typed","config","BigNumber"],(e=>{var{typed:t,config:n,BigNumber:r}=e;return t(vW,{number:aW,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return Gq(e,this,!0)},"boolean | string":function(e){return"BigNumber"===n.number?new r(+e):+e}})})),wW=YH("abs",["typed"],(e=>{var{typed:t}=e;return t("abs",{number:eW,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},Fraction:function(e){return e.abs()},"Array | Matrix":function(e){return Gq(e,this,!0)},Unit:function(e){return e.abs()}})})),MW="acos",NW=YH(MW,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(MW,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.acos(e):new r(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return Gq(e,this)}})})),SW="number";function kW(e){return ij(e)}function DW(e){return Math.atan(1/e)}function TW(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function IW(e){return Math.asin(1/e)}function EW(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function CW(e){return Math.acos(1/e)}function AW(e){var t=1/e,n=Math.sqrt(t*t-1);return Math.log(n+t)}function LW(e){return sj(e)}function $W(e){return oj(e)}function OW(e){return 1/Math.tan(e)}function RW(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function FW(e){return 1/Math.sin(e)}function YW(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*UH(e)}function zW(e){return 1/Math.cos(e)}function BW(e){return 2/(Math.exp(e)+Math.exp(-e))}function PW(e){return lj(e)}kW.signature=SW,DW.signature=SW,TW.signature=SW,IW.signature=SW,EW.signature=SW,CW.signature=SW,AW.signature=SW,LW.signature=SW,$W.signature=SW,OW.signature=SW,RW.signature=SW,FW.signature=SW,YW.signature=SW,zW.signature=SW,BW.signature=SW,PW.signature=SW;var HW="acot",jW=YH(HW,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(HW,{number:DW,Complex:function(e){return e.acot()},BigNumber:function(e){return new n(1).div(e).atan()},"Array | Matrix":function(e){return Gq(e,this)}})})),UW="acsc",qW=YH(UW,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(UW,{number:function(e){return e<=-1||e>=1||n.predictable?IW(e):new r(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new a(1).div(e).asin()},"Array | Matrix":function(e){return Gq(e,this)}})})),WW="addScalar",VW=YH(WW,["typed"],(e=>{var{typed:t}=e;return t(WW,{"number, number":tW,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":function(e,t){if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var n=e.clone();return n.value=this(n.value,t.value),n.fixPrefix=!1,n}})})),GW=YH("arg",["typed"],(e=>{var{typed:t}=e;return t("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return Gq(e,this)}})})),KW="asech",JW=YH(KW,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(KW,{number:function(e){if(e<=1&&e>=-1||n.predictable){var t=1/e;if(t>0||n.predictable)return AW(e);var a=Math.sqrt(t*t-1);return new r(Math.log(a-t),Math.PI)}return new r(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new a(1).div(e).acosh()},"Array | Matrix":function(e){return Gq(e,this)}})})),XW=YH("asinh",["typed"],(e=>{var{typed:t}=e;return t("asinh",{number:LW,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),ZW=YH("atan",["typed"],(e=>{var{typed:t}=e;return t("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),QW="atanh",eV=YH(QW,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(QW,{number:function(e){return e<=1&&e>=-1||n.predictable?$W(e):new r(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),tV=YH("bignumber",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("bignumber",{"":function(){return new n(0)},number:function(e){return new n(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var r=t[2],a=n(t[1]),i=new n(2).pow(Number(r));if(a.gt(i.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var s=new n(2).pow(Number(r)-1);return a.gte(s)?a.sub(i):a}return new n(e)},BigNumber:function(e){return e},Fraction:function(e){return new n(e.n).div(e.d).times(e.s)},null:function(e){return new n(0)},"Array | Matrix":function(e){return Gq(e,this)}})}));function nV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new n(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new n(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new n(0):e}return iV(e,t,(function(e,t){return e&t}))}function rV(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,n=t.precision;t.config({precision:1e9});var r=e.plus(new t(1));return r.s=-r.s||null,t.config({precision:n}),r}function aV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);var r=new n(-1);return e.isZero()||t.eq(r)||e.eq(t)?t:t.isZero()||e.eq(r)?e:e.isFinite()&&t.isFinite()?iV(e,t,(function(e,t){return e|t})):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?r:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function iV(e,t,n){var r,a,i,s,o,u=e.constructor,l=+(e.s<0),c=+(t.s<0);if(l){r=sV(rV(e));for(var p=0;p0;)n(i[--h],s[--f])===m&&(g=g.plus(y)),y=y.times(b);for(;f>0;)n(o,s[--f])===m&&(g=g.plus(y)),y=y.times(b);return u.config({precision:x}),0===m&&(g.s=-g.s),g}function sV(e){for(var t=e.d,n=t[0]+"",r=1;r0)if(++o>l)for(o-=l;o--;)u+="0";else o1&&(null!==c[h+1]&&void 0!==c[h+1]||(c[h+1]=0),c[h+1]+=c[h]>>1,c[h]&=1)}return c.reverse()}function oV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new n(0);var r=new n(-1);return e.eq(r)?rV(t):t.eq(r)?rV(e):e.isFinite()&&t.isFinite()?iV(e,t,(function(e,t){return e^t})):e.isFinite()||t.isFinite()?new n(e.isNegative()===t.isNegative()?1/0:-1/0):r}function uV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new n(2).pow(t)):new n(NaN)}function lV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new n(2).pow(t)).floor():e.isNegative()?new n(-1):e.isFinite()?new n(0):new n(NaN)}var cV="number, number";function pV(e,t){if(!jH(e)||!jH(t))throw new Error("Integers expected in function bitAnd");return e&t}function dV(e){if(!jH(e))throw new Error("Integer expected in function bitNot");return~e}function hV(e,t){if(!jH(e)||!jH(t))throw new Error("Integers expected in function bitOr");return e|t}function fV(e,t){if(!jH(e)||!jH(t))throw new Error("Integers expected in function bitXor");return e^t}function mV(e,t){if(!jH(e)||!jH(t))throw new Error("Integers expected in function leftShift");return e<>t}function yV(e,t){if(!jH(e)||!jH(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}pV.signature=cV,dV.signature="number",hV.signature=cV,fV.signature=cV,mV.signature=cV,gV.signature=cV,yV.signature=cV;var bV="bitNot",xV=YH(bV,["typed"],(e=>{var{typed:t}=e;return t(bV,{number:dV,BigNumber:rV,"Array | Matrix":function(e){return Gq(e,this)}})})),vV="boolean",_V=YH(vV,["typed"],(e=>{var{typed:t}=e;return t(vV,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var n=Number(e);if(""!==e&&!isNaN(n))return!!n;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return Gq(e,this)}})})),wV="clone",MV=YH(wV,["typed"],(e=>{var{typed:t}=e;return t(wV,{any:wH})}));function NV(e,t){if(t>1;return NV(e,n)*NV(n+1,t)}function SV(e,t){if(!jH(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!jH(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");for(var n=e-t,r=1,a=2,i=t{var{typed:t}=e;return t(kV,{"number, number":SV,"BigNumber, BigNumber":function(e,t){var n,r,a=e.constructor,i=e.minus(t),s=new a(1);if(!TV(e)||!TV(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(n=s,t.lt(i))for(r=s;r.lte(i);r=r.plus(s))n=n.times(t.plus(r)).dividedBy(r);else for(r=s;r.lte(t);r=r.plus(s))n=n.times(i.plus(r)).dividedBy(r);return n}})}));function TV(e){return e.isInteger()&&e.gte(0)}var IV=YH("complex",["typed","Complex"],(e=>{var{typed:t,Complex:n}=e;return t("complex",{"":function(){return n.ZERO},number:function(e){return new n(e,0)},"number, number":function(e,t){return new n(e,t)},"BigNumber, BigNumber":function(e,t){return new n(e.toNumber(),t.toNumber())},Fraction:function(e){return new n(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return n(e)},null:function(e){return n(0)},Object:function(e){if("re"in e&&"im"in e)return new n(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new n(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return Gq(e,this)}})})),EV="conj",CV=YH(EV,["typed"],(e=>{var{typed:t}=e;return t(EV,{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return Gq(e,this)}})})),AV="cosh",LV=YH(AV,["typed"],(e=>{var{typed:t}=e;return t(AV,{number:uj,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),$V="coth",OV=YH($V,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t($V,{number:RW,Complex:function(e){return e.coth()},BigNumber:function(e){return new n(1).div(e.tanh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),RV=YH("csc",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("csc",{number:FW,Complex:function(e){return e.csc()},BigNumber:function(e){return new n(1).div(e.sin())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),FV="cube",YV=YH(FV,["typed"],(e=>{var{typed:t}=e;return t(FV,{number:sW,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},"Array | Matrix":function(e){return Gq(e,this,!0)},Unit:function(e){return e.pow(3)}})}));function zV(e,t,n){if(null==n)return e.eq(t);if(e.eq(t))return!0;if(e.isNaN()||t.isNaN())return!1;if(e.isFinite()&&t.isFinite()){var r=e.minus(t).abs();if(r.isZero())return!0;var a=e.constructor.max(e.abs(),t.abs());return r.lte(a.times(n))}return!1}var BV="equalScalar",PV=YH(BV,["typed","config"],(e=>{var{typed:t,config:n}=e;return t(BV,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return aj(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||zV(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,n){return aj(e.re,t.re,n)&&aj(e.im,t.im,n)}(e,t,n.epsilon)},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)}})})),HV=(YH(BV,["typed","config"],(e=>{var{typed:t,config:n}=e;return t(BV,{"number, number":function(e,t){return aj(e,t,n.epsilon)}})})),YH("erf",["typed"],(e=>{var{typed:t}=e;return t("name",{number:function(e){var t=Math.abs(e);return t>=VV?UH(e):t<=jV?UH(e)*function(e){var t,n=e*e,r=qV[0][4]*n,a=n;for(t=0;t<3;t+=1)r=(r+qV[0][t])*n,a=(a+WV[0][t])*n;return e*(r+qV[0][3])/(a+WV[0][3])}(t):t<=4?UH(e)*(1-function(e){var t,n=qV[1][8]*e,r=e;for(t=0;t<7;t+=1)n=(n+qV[1][t])*e,r=(r+WV[1][t])*e;var a=(n+qV[1][7])/(r+WV[1][7]),i=parseInt(16*e)/16,s=(e-i)*(e+i);return Math.exp(-i*i)*Math.exp(-s)*a}(t)):UH(e)*(1-function(e){var t,n=1/(e*e),r=qV[2][5]*n,a=n;for(t=0;t<4;t+=1)r=(r+qV[2][t])*n,a=(a+WV[2][t])*n;var i=n*(r+qV[2][4])/(a+WV[2][4]);i=(UV-i)/e;var s=(e-(n=parseInt(16*e)/16))*(e+n);return Math.exp(-n*n)*Math.exp(-s)*i}(t))},"Array | Matrix":function(e){return Gq(e,this)}})}))),jV=.46875,UV=.5641895835477563,qV=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],WV=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],VV=Math.pow(2,53),GV=YH("exp",["typed"],(e=>{var{typed:t}=e;return t("exp",{number:oW,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return Gq(e,this)}})})),KV="expm1",JV=YH(KV,["typed","Complex"],(e=>{var{typed:t,Complex:n}=e;return t(KV,{number:uW,Complex:function(e){var t=Math.exp(e.re);return new n(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)},"Array | Matrix":function(e){return Gq(e,this)}})})),XV=YH("filter",["typed"],(e=>{var{typed:t}=e;return t("filter",{"Array, function":ZV,"Matrix, function":function(e,t){return e.create(ZV(e.toArray(),t))},"Array, RegExp":xq,"Matrix, RegExp":function(e,t){return e.create(xq(e.toArray(),t))}})}));function ZV(e,t){var n=fj(t);return bq(e,(function(e,r,a){return 1===n?t(e):2===n?t(e,[r]):t(e,[r],a)}))}var QV="forEach",eG=YH(QV,["typed"],(e=>{var{typed:t}=e;return t(QV,{"Array, function":tG,"Matrix, function":function(e,t){return e.forEach(t)}})}));function tG(e,t){var n=fj(t);!function r(a,i){Array.isArray(a)?yq(a,(function(e,t){r(e,i.concat(t))})):1===n?t(a):2===n?t(a,i):t(a,i,e)}(e,[])}var nG="format",rG=YH(nG,["typed"],(e=>{var{typed:t}=e;return t(nG,{any:KU,"any, Object | function | number":KU})})),aG="getMatrixDataType",iG=YH(aG,["typed"],(e=>{var{typed:t}=e;return t(aG,{Array:function(e){return Mq(e,_H)},Matrix:function(e){return e.getDataType()}})})),sG=YH("hex",["typed","format"],(e=>{var{typed:t,format:n}=e;return t("hex",{"number | BigNumber":function(e){return n(e,{notation:"hex"})},"number | BigNumber, number":function(e,t){return n(e,{notation:"hex",wordSize:t})}})})),oG=YH("im",["typed"],(e=>{var{typed:t}=e;return t("im",{number:function(e){return 0},BigNumber:function(e){return e.mul(0)},Fraction:function(e){return e.mul(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return Gq(e,this)}})})),uG="isInteger",lG=YH(uG,["typed"],(e=>{var{typed:t}=e;return t(uG,{number:jH,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":function(e){return Gq(e,this)}})})),cG="number";function pG(e){return e<0}function dG(e){return e>0}function hG(e){return 0===e}function fG(e){return Number.isNaN(e)}pG.signature=cG,dG.signature=cG,hG.signature=cG,fG.signature=cG;var mG="isNegative",gG=YH(mG,["typed"],(e=>{var{typed:t}=e;return t(mG,{number:pG,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),yG="isPositive",bG=YH(yG,["typed"],(e=>{var{typed:t}=e;return t(yG,{number:dG,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),xG="isZero",vG=YH(xG,["typed"],(e=>{var{typed:t}=e;return t(xG,{number:hG,BigNumber:function(e){return e.isZero()},Complex:function(e){return 0===e.re&&0===e.im},Fraction:function(e){return 1===e.d&&0===e.n},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})}));function _G(e){var t;if(jH(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:NV(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*_G(1-e));if(e>=171.35)return 1/0;if(e>85){var n=e*e,r=n*e,a=r*e,i=a*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*n)-139/(51840*r)-571/(2488320*a)+163879/(209018880*i)+5246819/(75246796800*i*e))}--e,t=MG[0];for(var s=1;s=1;r--)n+=SG[r]/(e+r);return NG+(e+.5)*Math.log(t)-t+Math.log(n)}kG.signature="number";var DG="lgamma",TG=YH(DG,["Complex","typed"],(e=>{var{Complex:t,typed:n}=e,r=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return n(DG,{number:kG,Complex:function(e){var n,r;if(e.isNaN())return new t(NaN,NaN);if(0===e.im)return new t(kG(e.re),0);if(e.re>=7||Math.abs(e.im)>=7)return a(e);if(e.re<=.1){var s=(n=6.283185307179586,(!0^((r=e.im)>0||!(r<0)&&1/r==1/0)?-n:n)*Math.floor(.5*e.re+.25)),o=e.mul(Math.PI).sin().log(),u=this(new t(1-e.re,-e.im));return new t(1.1447298858494002,s).sub(o).sub(u)}return e.im>=0?i(e):i(e.conjugate()).conjugate()},BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function a(e){for(var n=e.sub(.5).mul(e.log()).sub(e).add(NG),a=new t(1,0).div(e),i=a.div(e),s=r[0],o=r[1],u=2*i.re,l=i.re*i.re+i.im*i.im,c=2;c<8;c++){var p=o;o=-l*s+r[c],s=u*s+p}var d=a.mul(i.mul(s).add(o));return n.add(d)}function i(e){var n=0,r=0,i=e;for(e=e.add(1);e.re<=7;){var s=(i=i.mul(e)).im<0?1:0;0!==s&&0===r&&n++,r=s,e=e.add(1)}return a(e).sub(i.log()).sub(new t(0,2*n*Math.PI*1))}})),IG="log10",EG=YH(IG,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(IG,{number:function(e){return e>=0||n.predictable?pW(e):new r(e,0).log().div(Math.LN10)},Complex:function(e){return new r(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||n.predictable?e.log():new r(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return Gq(e,this)}})})),CG="log2",AG=YH(CG,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(CG,{number:function(e){return e>=0||n.predictable?dW(e):a(new r(e,0))},Complex:a,BigNumber:function(e){return!e.isNegative()||n.predictable?e.log(2):a(new r(e.toNumber(),0))},"Array | Matrix":function(e){return Gq(e,this)}});function a(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new r(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),LG=YH("map",["typed"],(e=>{var{typed:t}=e;return t("map",{"Array, function":$G,"Matrix, function":function(e,t){return e.map(t)}})}));function $G(e,t){var n=fj(t);return function r(a,i){if(Array.isArray(a))return a.map((function(e,t){return r(e,i.concat(t))}));try{return 1===n?t(a):2===n?t(a,i):t(a,i,e)}catch(t){if(t instanceof TypeError&&"data"in t&&"wrongType"===t.data.category){var s="map attempted to call '".concat(t.data.fn,"(").concat(a),o=JSON.stringify(i);throw 2===n?s+=","+o:1!==n&&(s+=",".concat(o,",").concat(e)),s+=")' but argument ".concat(t.data.index+1," of type "),s+="".concat(t.data.actual," does not match expected type "),s+=t.data.expected.join(" or "),new TypeError(s)}throw t}}(e,[])}var OG=YH("multiplyScalar",["typed"],(e=>{var{typed:t}=e;return t("multiplyScalar",{"number, number":nW,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":function(e,t){var n=t.clone();return n.value=null===n.value?n._normalize(e):this(n.value,e),n},"Unit, number | Fraction | BigNumber | Complex":function(e,t){var n=e.clone();return n.value=null===n.value?n._normalize(t):this(n.value,t),n},"Unit, Unit":function(e,t){return e.multiply(t)}})})),RG="number, number";function FG(e){return!e}function YG(e,t){return!(!e&&!t)}function zG(e,t){return!!e!=!!t}function BG(e,t){return!(!e||!t)}FG.signature="number",YG.signature=RG,zG.signature=RG,BG.signature=RG;var PG=YH("not",["typed"],(e=>{var{typed:t}=e;return t("not",{number:FG,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),HG=YH("number",["typed"],(e=>{var{typed:t}=e,n=t("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t=function(e){var t=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);return t?{input:e,radix:{"0b":2,"0o":8,"0x":16}[t[1]],integerPart:t[2],fractionalPart:t[3]}:null}(e);if(t)return function(e){for(var t=parseInt(e.integerPart,e.radix),n=0,r=0;r2**n-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));a>=2**(n-1)&&(a-=2**n)}return a},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return Gq(e,this)}});return n.fromJSON=function(e){return parseFloat(e.value)},n})),jG=YH("oct",["typed","format"],(e=>{var{typed:t,format:n}=e;return t("oct",{"number | BigNumber":function(e){return n(e,{notation:"oct"})},"number | BigNumber, number":function(e,t){return n(e,{notation:"oct",wordSize:t})}})})),UG=Ep(Date.now());function qG(e){var t,n;return t=null===(n=e)?UG:Ep(String(n)),function(){return t()}}var WG="pickRandom",VG=YH(WG,["typed","config","?on"],(e=>{var{typed:t,config:n,on:r}=e,a=qG(n.randomSeed);return r&&r("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=qG(e.randomSeed))})),t(WG,{"Array | Matrix":function(e){return i(e,{})},"Array | Matrix, Object":function(e,t){return i(e,t)},"Array | Matrix, number":function(e,t){return i(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return i(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,n){return i(e,{number:n,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,n){return i(e,{number:t,weights:n})}});function i(e,t){var{number:n,weights:r,elementWise:i=!0}=t,s=void 0===n;s&&(n=1);var o=UP(e)?e.create:UP(r)?r.create:null;e=e.valueOf(),r&&(r=r.valueOf()),!0===i&&(e=mq(e),r=mq(r));var u=0;if(void 0!==r){if(r.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var l=0,c=r.length;l{var{typed:t}=e;return t(GG,{"string, Object | Array":JG,"string, Object | Array, number | Object":JG})}));function JG(e,t,n){return e.replace(/\$([\w.]+)/g,(function(e,r){for(var a=r.split("."),i=t[a.shift()];a.length&&void 0!==i;){var s=a.shift();i=s?i[s]:i+"."}return void 0!==i?HP(i)?i:KU(i,n):e}))}function XG(e,t){var n=[];if((e=e.slice(0)).length>1)for(var r=0,a=e.shift();r{var{typed:t,config:n,on:r}=e,a=qG(n.randomSeed);return r&&r("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=qG(e.randomSeed))})),t(ZG,{"":()=>s(0,1),number:e=>s(0,e),"number, number":(e,t)=>s(e,t),"Array | Matrix":e=>i(e,0,1),"Array | Matrix, number":(e,t)=>i(e,0,t),"Array | Matrix, number, number":(e,t,n)=>i(e,t,n)});function i(e,t,n){var r=XG(e.valueOf(),(()=>s(t,n)));return UP(e)?e.create(r):r}function s(e,t){return e+a()*(t-e)}})),eK=YH("re",["typed"],(e=>{var{typed:t}=e;return t("re",{number:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return Gq(e,this)}})})),tK=YH("sec",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("sec",{number:zW,Complex:function(e){return e.sec()},BigNumber:function(e){return new n(1).div(e.cos())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),nK="sign",rK=YH(nK,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:t,BigNumber:n,complex:r,Fraction:a}=e;return t(nK,{number:mW,Complex:function(e){return 0===e.im?r(mW(e.re)):e.sign()},BigNumber:function(e){return new n(e.cmp(0))},Fraction:function(e){return new a(e.s,1)},"Array | Matrix":function(e){return Gq(e,this,!0)},Unit:function(e){if(!e._isDerived()&&0!==e.units[0].unit.offset)throw new TypeError("sign is ambiguous for units with offset");return this(e.value)}})})),aK=YH("sin",["typed"],(e=>{var{typed:t}=e;return t("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),iK=YH("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:t,equalScalar:n,Matrix:r}=e;function a(e,t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!HP(t))throw new Error("Invalid datatype: "+t);if(UP(e))!function(e,t,n){"SparseMatrix"===t.type?(e._values=t._values?wH(t._values):void 0,e._index=wH(t._index),e._ptr=wH(t._ptr),e._size=wH(t._size),e._datatype=n||t._datatype):i(e,t.valueOf(),n||t._datatype)}(this,e,t);else if(e&&jP(e.index)&&jP(e.ptr)&&jP(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(jP(e))i(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+_H(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}}function i(e,r,a){e._values=[],e._index=[],e._ptr=[],e._datatype=a;var i=r.length,s=0,o=n,u=0;if(HP(a)&&(o=t.find(n,[a,a])||n,u=t.convert(0,a)),i>0){var l=0;do{e._ptr.push(e._index.length);for(var c=0;c");if(1===i.length)t.dimension(0).forEach((function(t,a){iq(t),e.set([t,0],n[a[0]],r)}));else{var l=t.dimension(0),c=t.dimension(1);l.forEach((function(t,a){iq(t),c.forEach((function(i,s){iq(i),e.set([t,i],n[a[0]][s[0]],r)}))}))}}return e}function u(e,t,n,r){if(n-t==0)return n;for(var a=t;af){for(c=f;ch){if(d){var m=0;for(c=0;cr-1&&(e._values.splice(p,1),e._index.splice(p,1),y++)}e._ptr[c]=e._values.length}return e._size[0]=r,e._size[1]=a,e}function p(e,t,n,r,a){var i,s,o=r[0],u=r[1],l=[];for(i=0;io-1||s>p-1)&&(c(this,Math.max(i+1,o),Math.max(s+1,p),a),o=this._size[0],p=this._size[1]),iq(i,o),iq(s,p);var f=u(i,this._ptr[s],this._ptr[s+1],this._index);return fArray.isArray(e)&&1===e.length?e[0]:e));if(2!==r.length)throw new Error("Only two dimensions matrix are supported");return r.forEach((function(e){if(!FP(e)||!jH(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+KU(r)+")")})),c(n?this.clone():this,r[0],r[1],t)},a.prototype.reshape=function(e,t){if(!jP(e))throw new TypeError("Array expected");if(2!==e.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(t){if(!FP(t)||!jH(t)||t<=-2||0===t)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+KU(e)+")")}));var n=this._size[0]*this._size[1];if(n!==(e=lq(e,n))[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var r=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return r;for(var a=[],i=0;i=0&&v<=i&&m(e._values[x],v-0,g-0)}else{for(var _={},w=y;w "+(this._values?KU(this._values[u],e):"X");return a},a.prototype.toString=function(){return KU(this.toArray())},a.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},a.prototype.diagonal=function(e){if(e){if(YP(e)&&(e=e.toNumber()),!FP(e)||!jH(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,n=e<0?-e:0,r=this._size[0],i=this._size[1],s=Math.min(r-n,i-t),o=[],u=[],l=[];l[0]=0;for(var c=t;c0?i:0,d=i<0?-i:0,h=e[0],f=e[1],m=Math.min(h-d,f-p);if(jP(r)){if(r.length!==m)throw new Error("Invalid value array length");c=function(e){return r[e]}}else if(UP(r)){var g=r.size();if(1!==g.length||g[0]!==m)throw new Error("Invalid matrix length");c=function(e){return r.get([e])}}else c=function(){return r};for(var y=[],b=[],x=[],v=0;v=0&&_=l||a[p]!==t)){var h=r?r[c]:void 0;a.splice(p,0,t),r&&r.splice(p,0,h),a.splice(p<=c?c+1:c,1),r&&r.splice(p<=c?c+1:c,1)}else if(p=l||a[c]!==e)){var f=r?r[p]:void 0;a.splice(c,0,e),r&&r.splice(c,0,f),a.splice(c<=p?p+1:p,1),r&&r.splice(c<=p?p+1:p,1)}}},a}),{isClass:!0}),sK="splitUnit",oK=YH(sK,["typed"],(e=>{var{typed:t}=e;return t(sK,{"Unit, Array":function(e,t){return e.splitUnit(t)}})})),uK="square",lK=YH(uK,["typed"],(e=>{var{typed:t}=e;return t(uK,{number:gW,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},"Array | Matrix":function(e){return Gq(e,this,!0)},Unit:function(e){return e.pow(2)}})})),cK="string",pK=YH(cK,["typed"],(e=>{var{typed:t}=e;return t(cK,{"":function(){return""},number:XH,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return Gq(e,this)},any:function(e){return String(e)}})})),dK=YH("tan",["typed"],(e=>{var{typed:t}=e;return t("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),hK="typeOf",fK=YH(hK,["typed"],(e=>{var{typed:t}=e;return t(hK,{any:_H})})),mK="acosh",gK=YH(mK,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(mK,{number:function(e){return e>=1||n.predictable?kW(e):e<=-1?new r(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new r(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return Gq(e,this)}})})),yK="acsch",bK=YH(yK,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(yK,{number:EW,Complex:function(e){return e.acsch()},BigNumber:function(e){return new n(1).div(e).asinh()},"Array | Matrix":function(e){return Gq(e,this)}})})),xK="apply",vK=YH(xK,["typed","isInteger"],(e=>{var{typed:t,isInteger:n}=e;return t(xK,{"Array | Matrix, number | BigNumber, function":function(e,t,r){if(!n(t))throw new TypeError("Integer number expected for dimension");var a=Array.isArray(e)?nq(e):e.size();if(t<0||t>=a.length)throw new tq(t,a.length);return UP(e)?e.create(_K(e.valueOf(),t,r)):_K(e,t,r)}})}));function _K(e,t,n){var r,a,i;if(t<=0){if(Array.isArray(e[0])){for(i=function(e){var t,n,r=e.length,a=e[0].length,i=[];for(n=0;n{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(wK,{number:function(e){return e<=-1||e>=1||n.predictable?CW(e):new r(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new a(1).div(e).acos()},"Array | Matrix":function(e){return Gq(e,this)}})})),NK=YH("bin",["typed","format"],(e=>{var{typed:t,format:n}=e;return t("bin",{"number | BigNumber":function(e){return n(e,{notation:"bin"})},"number | BigNumber, number":function(e,t){return n(e,{notation:"bin",wordSize:t})}})})),SK="combinationsWithRep",kK=YH(SK,["typed"],(e=>{var{typed:t}=e;return t(SK,{"number, number":function(e,t){if(!jH(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!jH(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t{var{typed:t}=e;return t("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),IK="csch",EK=YH(IK,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(IK,{number:YW,Complex:function(e){return e.csch()},BigNumber:function(e){return new n(1).div(e.sinh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),CK="isNaN",AK=YH(CK,["typed"],(e=>{var{typed:t}=e;return t(CK,{number:fG,BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return Gq(e,Number.isNaN)}})})),LK="isPrime",$K=YH(LK,["typed"],(e=>{var{typed:t}=e;return t(LK,{number:function(e){if(0*e!=0)return!1;if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t==0||e%(t+2)==0)return!1;return!0},BigNumber:function(e){if(0*e.toNumber()!=0)return!1;if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(Math.pow(2,32))){for(var t=e.toNumber(),n=5;n*n<=t;n+=6)if(t%n==0||t%(n+2)==0)return!1;return!0}function r(e,t,n){for(var r=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(n)):(t=t.sub(1),r=e.mul(r).mod(n));return r}for(var a=e.constructor.clone({precision:2*e.toFixed(0).length}),i=0,s=(e=new a(e)).sub(1);s.mod(2).eq(0);)s=s.div(2),i+=1;var o=null;if(e.lt("3317044064679887385961981"))o=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((t=>t{var{typed:t,config:n,on:r}=e,a=qG(n.randomSeed);return r&&r("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=qG(e.randomSeed))})),t(OK,{"":()=>s(0,1),number:e=>s(0,e),"number, number":(e,t)=>s(e,t),"Array | Matrix":e=>i(e,0,1),"Array | Matrix, number":(e,t)=>i(e,0,t),"Array | Matrix, number, number":(e,t,n)=>i(e,t,n)});function i(e,t,n){var r=XG(e.valueOf(),(()=>s(t,n)));return UP(e)?e.create(r):r}function s(e,t){return Math.floor(e+a()*(t-e))}})),FK="sech",YK=YH(FK,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(FK,{number:BW,Complex:function(e){return e.sech()},BigNumber:function(e){return new n(1).div(e.cosh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),zK="sinh",BK=YH(zK,["typed"],(e=>{var{typed:t}=e;return t(zK,{number:PW,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),PK="sparse",HK=YH(PK,["typed","SparseMatrix"],(e=>{var{typed:t,SparseMatrix:n}=e;return t(PK,{"":function(){return new n([])},string:function(e){return new n([],e)},"Array | Matrix":function(e){return new n(e)},"Array | Matrix, string":function(e,t){return new n(e,t)}})})),jK=YH("sqrt",["config","typed","Complex"],(e=>{var{config:t,typed:n,Complex:r}=e;return n("sqrt",{number:a,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():a(e.toNumber())},"Array | Matrix":function(e){return Gq(e,this,!0)},Unit:function(e){return e.pow(.5)}});function a(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new r(e,0).sqrt()}})),UK=YH("tanh",["typed"],(e=>{var{typed:t}=e;return t("tanh",{number:cj,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),qK="unaryMinus",WK=YH(qK,["typed"],(e=>{var{typed:t}=e;return t(qK,{number:rW,Complex:function(e){return e.neg()},BigNumber:function(e){return e.neg()},Fraction:function(e){return e.neg()},Unit:function(e){var t=e.clone();return t.value=this(e.value),t},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),VK="acoth",GK=YH(VK,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(VK,{number:function(e){return e>=1||e<=-1||n.predictable?TW(e):new r(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new a(1).div(e).atanh()},"Array | Matrix":function(e){return Gq(e,this)}})})),KK=YH("cot",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("cot",{number:OW,Complex:function(e){return e.cot()},BigNumber:function(e){return new n(1).div(e.tan())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),JK=YH("fraction",["typed","Fraction"],(e=>{var{typed:t,Fraction:n}=e;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new n(e)},string:function(e){return new n(e)},"number, number":function(e,t){return new n(e,t)},null:function(e){return new n(0)},BigNumber:function(e){return new n(e.toString())},Fraction:function(e){return e},Object:function(e){return new n(e)},"Array | Matrix":function(e){return Gq(e,this)}})})),XK="isNumeric",ZK=YH(XK,["typed"],(e=>{var{typed:t}=e;return t(XK,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(e){return Gq(e,this)}})})),QK="matrix",eJ=YH(QK,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,Matrix:n,DenseMatrix:r,SparseMatrix:a}=e;return t(QK,{"":function(){return i([])},string:function(e){return i([],e)},"string, string":function(e,t){return i([],e,t)},Array:function(e){return i(e)},Matrix:function(e){return i(e,e.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(e,t,n){if("dense"===t||"default"===t||void 0===t)return new r(e,n);if("sparse"===t)return new a(e,n);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}})),tJ="matrixFromFunction",nJ=YH(tJ,["typed","matrix","isZero"],(e=>{var{typed:t,matrix:n,isZero:r}=e;return t(tJ,{"Array | Matrix, function, string, string":function(e,t,n,r){return a(e,t,n,r)},"Array | Matrix, function, string":function(e,t,n){return a(e,t,n)},"Matrix, function":function(e,t){return a(e,t,"dense")},"Array, function":function(e,t){return a(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,n){return a(e,n,t)},"Array | Matrix, string, string, function":function(e,t,n,r){return a(e,r,t,n)}});function a(e,t,a,i){var s;return(s=void 0!==i?n(a,i):n(a)).resize(e),s.forEach((function(e,n){var a=t(n);r(a)||s.set(n,a)})),s}})),rJ=YH("algorithm02",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return function(e,r,a,i){var s=e._data,o=e._size,u=e._datatype,l=r._values,c=r._index,p=r._ptr,d=r._size,h=r._datatype;if(o.length!==d.length)throw new eq(o.length,d.length);if(o[0]!==d[0]||o[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+d+")");if(!l)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var f,m=o[0],g=o[1],y=n,b=0,x=a;"string"==typeof u&&u===h&&(f=u,y=t.find(n,[f,f]),b=t.convert(0,f),x=t.find(a,[f,f]));for(var v=[],_=[],w=[],M=0;M{var{typed:t}=e;return function(e,n,r,a){var i=e._data,s=e._size,o=e._datatype,u=n._values,l=n._index,c=n._ptr,p=n._size,d=n._datatype;if(s.length!==p.length)throw new eq(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,f=s[0],m=s[1],g=0,y=r;"string"==typeof o&&o===d&&(h=o,g=t.convert(0,h),y=t.find(r,[h,h]));for(var b=[],x=0;x{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new eq(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");var m,g=u[0],y=u[1],b=n,x=0,v=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),x=t.convert(0,m),v=t.find(a,[m,m]));var _,w,M,N,S=i&&c?[]:void 0,k=[],D=[],T=S?[]:void 0,I=S?[]:void 0,E=[],C=[];for(w=0;w{var{typed:t,equalScalar:n}=e;return function(e,r,a,i){var s=e._values,o=e._index,u=e._ptr,l=e._size,c=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p,d=l[0],h=l[1],f=n,m=0,g=a;"string"==typeof c&&(p=c,f=t.find(n,[p,p]),m=t.convert(0,p),r=t.convert(r,p),g=t.find(a,[p,p]));for(var y=[],b=[],x=[],v=0;v{var{typed:t,DenseMatrix:n}=e;return function(e,r,a,i){var s=e._values,o=e._index,u=e._ptr,l=e._size,c=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p,d=l[0],h=l[1],f=a;"string"==typeof c&&(p=c,r=t.convert(r,p),f=t.find(a,[p,p]));for(var m=[],g=[],y=[],b=0;b{var{typed:t}=e;return function(e,r,a){var i,s=e._data,o=e._size,u=e._datatype,l=r._data,c=r._size,p=r._datatype,d=[];if(o.length!==c.length)throw new eq(o.length,c.length);for(var h=0;h0?n(f,0,d,d[0],s,l):[];return e.createDenseMatrix({data:m,size:d,datatype:i})};function n(e,t,r,a,i,s){var o=[];if(t===r.length-1)for(var u=0;u{var{typed:t}=e;return function(e,r,a,i){var s,o=e._data,u=e._size,l=e._datatype,c=a;"string"==typeof l&&(s=l,r=t.convert(r,s),c=t.find(a,[s,s]));var p=u.length>0?n(c,0,u,u[0],o,r,i):[];return e.createDenseMatrix({data:p,size:wH(u),datatype:s})};function n(e,t,r,a,i,s,o){var u=[];if(t===r.length-1)for(var l=0;l{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=rJ({typed:t,equalScalar:r}),s=aJ({typed:t}),o=iJ({typed:t,equalScalar:r}),u=sJ({typed:t,equalScalar:r}),l=oJ({typed:t,DenseMatrix:a}),c=uJ({typed:t}),p=lJ({typed:t});return t("mod",{"number, number":hW,"BigNumber, BigNumber":function(e,t){if(t.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){if(t.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return e.compare(0)>=0?e.mod(t):e.mod(t).add(t).mod(t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(n(t),e,this,!0).valueOf()}})})),pJ=YH("algorithm01",["typed"],(e=>{var{typed:t}=e;return function(e,n,r,a){var i=e._data,s=e._size,o=e._datatype,u=n._values,l=n._index,c=n._ptr,p=n._size,d=n._datatype;if(s.length!==p.length)throw new eq(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,f,m=s[0],g=s[1],y="string"==typeof o&&o===d?o:void 0,b=y?t.find(r,[y,y]):r,x=[];for(h=0;h{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._size,o=e._datatype,u=r._values,l=r._size,c=r._datatype;if(s.length!==l.length)throw new eq(s.length,l.length);if(s[0]!==l[0]||s[1]!==l[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+l+")");var p,d=s[0],h=s[1],f=n,m=0,g=a;"string"==typeof o&&o===c&&(p=o,f=t.find(n,[p,p]),m=t.convert(0,p),g=t.find(a,[p,p]));for(var y=i&&u?[]:void 0,b=[],x=[],v=y?[]:void 0,_=[],w=[],M=0;M{var{typed:t,matrix:n,equalScalar:r,BigNumber:a}=e,i=pJ({typed:t}),s=rJ({typed:t,equalScalar:r}),o=dJ({typed:t,equalScalar:r}),u=sJ({typed:t,equalScalar:r}),l=uJ({typed:t}),c=lJ({typed:t}),p="Complex number not supported in function nthRoot. Use nthRoots instead.";return t(hJ,{number:fW,"number, number":fW,BigNumber:function(e){return d(e,new a(2))},Complex:function(e){throw new Error(p)},"Complex, number":function(e,t){throw new Error(p)},"BigNumber, BigNumber":d,"Array | Matrix":function(e){return this(e,2)},"SparseMatrix, SparseMatrix":function(e,t){if(1===t.density())return o(e,t,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){if(1===t.density())return i(e,t,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){if(1===t.density())return u(t,e,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}});function d(e,t){var n=a.precision,r=a.clone({precision:n+2}),i=new a(0),s=new r(1),o=t.isNegative();if(o&&(t=t.neg()),t.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return o?new r(1/0):0;if(!e.isFinite())return o?i:e;var u=e.abs().pow(s.div(t));return u=e.isNeg()?u.neg():u,new a((o?s.div(u):u).toPrecision(n))}}));function mJ(){throw new Error('No "bignumber" implementation available')}function gJ(){throw new Error('No "fraction" implementation available')}function yJ(){throw new Error('No "matrix" implementation available')}var bJ=YH("numeric",["number","?bignumber","?fraction"],(e=>{var{number:t,bignumber:n,fraction:r}=e,a={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:e=>t(e),BigNumber:n?e=>n(e):mJ,Fraction:r?e=>r(e):gJ};return function(e,t){var n=_H(e);if(!(n in a))throw new TypeError("Cannot convert "+e+' of type "'+n+'"; valid input types are '+Object.keys(a).join(", "));if(!(t in i))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(i).join(", "));return t===n?e:i[t](e)}})),xJ=YH("or",["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=aJ({typed:t}),s=iJ({typed:t,equalScalar:r}),o=oJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t("or",{"number, number":YG,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,this,!0).valueOf()}})}));function vJ(e,t,n){var r;return-1!==String(e).indexOf("Unexpected type")?(r=arguments.length>2?" (type: "+_H(n)+", value: "+JSON.stringify(n)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):-1!==String(e).indexOf("complex numbers")?(r=arguments.length>2?" (type: "+_H(n)+", value: "+JSON.stringify(n)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):e}var _J="prod",wJ=YH(_J,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:t,config:n,multiplyScalar:r,numeric:a}=e;return t(_J,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return i(e)}});function i(e){var t;if(Vq(e,(function(e){try{t=void 0===t?e:r(t,e)}catch(t){throw vJ(t,"prod",e)}})),"string"==typeof t&&(t=a(t,n.number)),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}})),MJ="reshape",NJ=YH(MJ,["typed","isInteger","matrix"],(e=>{var{typed:t,isInteger:n}=e;return t(MJ,{"Matrix, Array":function(e,t){return e.reshape(t)},"Array, Array":function(e,t){return t.forEach((function(e){if(!n(e))throw new TypeError("Invalid size for dimension: "+e)})),uq(e,t)}})})),SJ="size",kJ=YH(SJ,["typed","config","?matrix"],(e=>{var{typed:t,config:n,matrix:r}=e;return t(SJ,{Matrix:function(e){return e.create(e.size())},Array:nq,string:function(e){return"Array"===n.matrix?[e.length]:r([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===n.matrix?[]:r?r([]):yJ()}})})),DJ=YH("algorithm07",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:n}=e;return function(e,a,i){var s=e._size,o=e._datatype,u=a._size,l=a._datatype;if(s.length!==u.length)throw new eq(s.length,u.length);if(s[0]!==u[0]||s[1]!==u[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+u+")");var c,p,d,h=s[0],f=s[1],m=0,g=i;"string"==typeof o&&o===l&&(c=o,m=t.convert(0,c),g=t.find(i,[c,c]));var y=[];for(p=0;p{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=aJ({typed:t}),s=DJ({typed:t,DenseMatrix:a}),o=oJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t(TJ,{"boolean, boolean":function(e,t){return e{var{typed:t,matrix:n}=e;return t(EJ,{Array:function(e){return pq(wH(e))},Matrix:function(e){var t=pq(e.toArray());return Array.isArray(t)?n(t):t},any:function(e){return wH(e)}})})),AJ="subset",LJ=YH(AJ,["typed","matrix"],(e=>{var{typed:t,matrix:n}=e;return t(AJ,{"Array, Index":function(e,t){var r=n(e).subset(t);return t.isScalar()?r:r.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":RJ,"string, Index":$J,"Array, Index, any":function(e,t,r){return n(wH(e)).subset(t,r,void 0).valueOf()},"Array, Index, any, any":function(e,t,r,a){return n(wH(e)).subset(t,r,a).valueOf()},"Matrix, Index, any":function(e,t,n){return e.clone().subset(t,n)},"Matrix, Index, any, any":function(e,t,n,r){return e.clone().subset(t,n,r)},"string, Index, string":OJ,"string, Index, string, string":OJ,"Object, Index, any":FJ})}));function $J(e,t){if(!KP(t))throw new TypeError("Index expected");if(1!==t.size().length)throw new eq(t.size().length,1);var n=e.length;iq(t.min()[0],n),iq(t.max()[0],n);var r=t.dimension(0),a="";return r.forEach((function(t){a+=e.charAt(t)})),a}function OJ(e,t,n,r){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new eq(t.size().length,1);if(void 0!==r){if("string"!=typeof r||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";var a=t.dimension(0);if(a.size()[0]!==n.length)throw new eq(a.size()[0],n.length);var i=e.length;iq(t.min()[0]),iq(t.max()[0]);for(var s=[],o=0;oi)for(var u=i-1,l=s.length;u{var{typed:t,DenseMatrix:n}=e;return function(e,r,a,i){var s=e._values,o=e._index,u=e._ptr,l=e._size,c=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p,d=l[0],h=l[1],f=a;"string"==typeof c&&(p=c,r=t.convert(r,p),f=t.find(a,[p,p]));for(var m=[],g=[],y=[],b=0;b{var{typed:t,matrix:n,equalScalar:r,addScalar:a,unaryMinus:i,DenseMatrix:s}=e,o=pJ({typed:t}),u=aJ({typed:t}),l=iJ({typed:t,equalScalar:r}),c=YJ({typed:t,DenseMatrix:s}),p=uJ({typed:t}),d=lJ({typed:t});return t(zJ,{"number, number":function(e,t){return e-t},"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":function(e,t){if(null===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var n=e.clone();return n.value=this(n.value,t.value),n.fixPrefix=!1,n},"SparseMatrix, SparseMatrix":function(e,t){return PJ(e,t),l(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return PJ(e,t),u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return PJ(e,t),o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return PJ(e,t),p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return c(e,i(t),a)},"DenseMatrix, any":function(e,t){return d(e,t,this)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return d(t,e,this,!0)},"Array, any":function(e,t){return d(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return d(n(t),e,this,!0).valueOf()}})}));function PJ(e,t){var n=e.size(),r=t.size();if(n.length!==r.length)throw new eq(n.length,r.length)}var HJ=YH("to",["typed","matrix"],(e=>{var{typed:t,matrix:n}=e,r=uJ({typed:t}),a=lJ({typed:t});return t("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return r(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"Matrix, any":function(e,t){return a(e,t,this,!1)},"any, Matrix":function(e,t){return a(t,e,this,!0)},"Array, any":function(e,t){return a(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return a(n(t),e,this,!0).valueOf()}})})),jJ=YH("transpose",["typed","matrix"],(e=>{var{typed:t,matrix:n}=e;return t("transpose",{Array:function(e){return this(n(e)).valueOf()},Matrix:function(e){var t,n=e.size();switch(n.length){case 1:t=e.clone();break;case 2:var r=n[0],a=n[1];if(0===a)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+KU(n)+")");switch(e.storage()){case"dense":t=function(e,t,n){for(var r,a=e._data,i=[],s=0;s{var{typed:t,config:n,matrix:r,BigNumber:a}=e;return t(UJ,{"number, number":function(e,t){var a=yW(e,t);return"Array"===n.matrix?a:r(a)},"BigNumber, BigNumber":function(e,t){var i,s,o,u,l=new a(0),c=new a(1),p=l,d=c,h=c,f=l;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)s=e.div(t).floor(),o=e.mod(t),i=p,p=d.minus(s.times(p)),d=i,i=h,h=f.minus(s.times(h)),f=i,e=t,t=o;return u=e.lt(l)?[e.neg(),d.neg(),f.neg()]:[e,e.isZero()?0:d,f],"Array"===n.matrix?u:r(u)}})})),WJ="zeros",VJ=YH(WJ,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:n,matrix:r,BigNumber:a}=e;return t(WJ,{"":function(){return"Array"===n.matrix?i([]):i([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return i(e,t)}return"Array"===n.matrix?i(e):i(e,"default")},Array:i,Matrix:function(e){var t=e.storage();return i(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return i(e.valueOf(),t)}});function i(e,t){var n=function(e){var t=!1;return e.forEach((function(e,n,r){YP(e)&&(t=!0,r[n]=e.toNumber())})),t}(e),i=n?new a(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!jH(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}))}(e),t){var s=r(t);return e.length>0?s.resize(e,i):s}var o=[];return e.length>0?sq(o,e,i):o}})),GJ=YH("and",["typed","matrix","equalScalar","zeros","not"],(e=>{var{typed:t,matrix:n,equalScalar:r,zeros:a,not:i}=e,s=rJ({typed:t,equalScalar:r}),o=dJ({typed:t,equalScalar:r}),u=sJ({typed:t,equalScalar:r}),l=uJ({typed:t}),c=lJ({typed:t});return t("and",{"number, number":BG,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return i(t)?a(e.size(),e.storage()):u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return i(t)?a(e.size(),e.storage()):c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return i(e)?a(e.size(),e.storage()):u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return i(e)?a(e.size(),e.storage()):c(t,e,this,!0)},"Array, any":function(e,t){return this(n(e),t).valueOf()},"any, Array":function(e,t){return this(e,n(t)).valueOf()}})})),KJ="bitAnd",JJ=YH(KJ,["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:n,equalScalar:r}=e,a=rJ({typed:t,equalScalar:r}),i=dJ({typed:t,equalScalar:r}),s=sJ({typed:t,equalScalar:r}),o=uJ({typed:t}),u=lJ({typed:t});return t(KJ,{"number, number":pV,"BigNumber, BigNumber":nV,"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,this,!0).valueOf()}})})),XJ="bitXor",ZJ=YH(XJ,["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:n,DenseMatrix:r}=e,a=aJ({typed:t}),i=DJ({typed:t,DenseMatrix:r}),s=oJ({typed:t,DenseMatrix:r}),o=uJ({typed:t}),u=lJ({typed:t});return t(XJ,{"number, number":fV,"BigNumber, BigNumber":oV,"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,this,!0).valueOf()}})})),QJ="cbrt",eX=YH(QJ,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:t,typed:n,isNegative:r,unaryMinus:a,matrix:i,Complex:s,BigNumber:o,Fraction:u}=e;return n(QJ,{number:iW,Complex:l,"Complex, boolean":l,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&zP(e.value)){var t=e.clone();return t.value=1,(t=t.pow(1/3)).value=l(e.value),t}var n,i=r(e.value);i&&(e.value=a(e.value)),n=YP(e.value)?new o(1).div(3):BP(e.value)?new u(1,3):1/3;var s=e.pow(n);return i&&(s.value=a(s.value)),s},"Array | Matrix":function(e){return Gq(e,this,!0)}});function l(e,n){var r=e.arg()/3,a=e.abs(),o=new s(iW(a),0).mul(new s(0,r).exp());if(n){var u=[o,new s(iW(a),0).mul(new s(0,r+2*Math.PI/3).exp()),new s(iW(a),0).mul(new s(0,r-2*Math.PI/3).exp())];return"Array"===t.matrix?u:i(u)}return o}})),tX="compare",nX=YH(tX,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],(e=>{var{typed:t,config:n,equalScalar:r,matrix:a,BigNumber:i,Fraction:s,DenseMatrix:o}=e,u=aJ({typed:t}),l=iJ({typed:t,equalScalar:r}),c=oJ({typed:t,DenseMatrix:o}),p=uJ({typed:t}),d=lJ({typed:t});return t(tX,{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"number, number":function(e,t){return aj(e,t,n.epsilon)?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return zV(e,t,n.epsilon)?new i(0):new i(e.cmp(t))},"Fraction, Fraction":function(e,t){return new s(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return l(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return this(a(e),t)},"Matrix, Array":function(e,t){return this(e,a(t))},"SparseMatrix, any":function(e,t){return c(e,t,this,!1)},"DenseMatrix, any":function(e,t){return d(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return d(t,e,this,!0)},"Array, any":function(e,t){return d(a(e),t,this,!1).valueOf()},"any, Array":function(e,t){return d(a(t),e,this,!0).valueOf()}})})),rX="compareText",aX=YH(rX,["typed","matrix"],(e=>{var{typed:t,matrix:n}=e,r=uJ({typed:t}),a=lJ({typed:t});return t(rX,{"any, any":QU,"DenseMatrix, DenseMatrix":function(e,t){return r(e,t,QU)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"DenseMatrix, any":function(e,t){return a(e,t,QU,!1)},"any, DenseMatrix":function(e,t){return a(t,e,QU,!0)},"Array, any":function(e,t){return a(n(e),t,QU,!1).valueOf()},"any, Array":function(e,t){return a(n(t),e,QU,!0).valueOf()}})})),iX="concat",sX=YH(iX,["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:n,isInteger:r}=e;return t(iX,{"...Array | Matrix | number | BigNumber":function(e){var t,a,i=e.length,s=-1,o=!1,u=[];for(t=0;t0&&s>a)throw new tq(s,a+1)}else{var c=wH(l).valueOf(),p=nq(c);if(u[t]=c,a=s,s=p.length-1,t>0&&s!==a)throw new eq(a+1,s+1)}}if(0===u.length)throw new SyntaxError("At least one matrix expected");for(var d=u.shift();u.length;)d=oX(d,u.shift(),s,0);return o?n(d):d},"...string":function(e){return e.join("")}})}));function oX(e,t,n,r){if(r{var{typed:t,size:n,prod:r}=e;return t(uX,{string:function(e){return e.length},"Matrix | Array":function(e){return r(n(e))}})})),cX="ctranspose",pX=YH(cX,["typed","transpose","conj"],(e=>{var{typed:t,transpose:n,conj:r}=e;return t(cX,{any:function(e){return r(n(e))}})})),dX="diag",hX=YH(dX,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:n,DenseMatrix:r,SparseMatrix:a}=e;return t(dX,{Array:function(e){return i(e,0,nq(e),null)},"Array, number":function(e,t){return i(e,t,nq(e),null)},"Array, BigNumber":function(e,t){return i(e,t.toNumber(),nq(e),null)},"Array, string":function(e,t){return i(e,0,nq(e),t)},"Array, number, string":function(e,t,n){return i(e,t,nq(e),n)},"Array, BigNumber, string":function(e,t,n){return i(e,t.toNumber(),nq(e),n)},Matrix:function(e){return i(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return i(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return i(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return i(e,0,e.size(),t)},"Matrix, number, string":function(e,t,n){return i(e,t,e.size(),n)},"Matrix, BigNumber, string":function(e,t,n){return i(e,t.toNumber(),e.size(),n)}});function i(e,t,i,s){if(!jH(t))throw new TypeError("Second parameter in function diag must be an integer");var o=t>0?t:0,u=t<0?-t:0;switch(i.length){case 1:return function(e,t,n,i,s,o){var u=[i+s,i+o];if(n&&"sparse"!==n&&"dense"!==n)throw new TypeError("Unknown matrix type ".concat(n,'"'));var l="sparse"===n?a.diagonal(u,e,t):r.diagonal(u,e,t);return null!==n?l:l.valueOf()}(e,t,s,i[0],u,o);case 2:return function(e,t,r,a,i,s){if(UP(e)){var o=e.diagonal(t);return null!==r?r!==o.storage()?n(o,r):o:o.valueOf()}for(var u=Math.min(a[0]-i,a[1]-s),l=[],c=0;c{var{typed:t,numeric:n}=e;return t(fX,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Fraction | BigNumber":function(e,t){var r=e.clone(),a=n(1,_H(t));return r.value=this(null===r.value?r._normalize(a):r.value,t),r},"number | Fraction | BigNumber, Unit":function(e,t){var r=t.clone();r=r.pow(-1);var a=n(1,_H(e));return r.value=this(e,null===t.value?t._normalize(a):t.value),r},"Unit, Unit":function(e,t){return e.divide(t)}})})),gX="dotDivide",yX=YH(gX,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,divideScalar:a,DenseMatrix:i}=e,s=rJ({typed:t,equalScalar:r}),o=aJ({typed:t}),u=DJ({typed:t,DenseMatrix:i}),l=sJ({typed:t,equalScalar:r}),c=oJ({typed:t,DenseMatrix:i}),p=uJ({typed:t}),d=lJ({typed:t});return t(gX,{"any, any":a,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,a,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,a,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,a,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,a)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return l(e,t,a,!1)},"DenseMatrix, any":function(e,t){return d(e,t,a,!1)},"any, SparseMatrix":function(e,t){return c(t,e,a,!0)},"any, DenseMatrix":function(e,t){return d(t,e,a,!0)},"Array, any":function(e,t){return d(n(e),t,a,!1).valueOf()},"any, Array":function(e,t){return d(n(t),e,a,!0).valueOf()}})})),bX="equal",xX=YH(bX,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=aJ({typed:t}),s=DJ({typed:t,DenseMatrix:a}),o=oJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t(bX,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,r)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,r,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,r,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,r)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,r,!1)},"DenseMatrix, any":function(e,t){return l(e,t,r,!1)},"any, SparseMatrix":function(e,t){return o(t,e,r,!0)},"any, DenseMatrix":function(e,t){return l(t,e,r,!0)},"Array, any":function(e,t){return l(n(e),t,r,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,r,!0).valueOf()}})})),vX=(YH(bX,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return t(bX,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:n(e,t)}})})),YH("fft",["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i"],(e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:a,divideScalar:i,exp:s,tau:o,i:u}=e;return t("fft",{Array:l,Matrix:function(e){return e.create(l(e.toArray()))}});function l(e){var t=nq(e);return 1===t.length?p(e,t[0]):c(e.map((e=>l(e,t.slice(1)))),0)}function c(e,t){var n=nq(e);if(0!==t)return new Array(n[0]).fill(0).map(((n,r)=>c(e[r],t-1)));if(1===n.length)return p(e);function r(e){var t=nq(e);return new Array(t[1]).fill(0).map(((n,r)=>new Array(t[0]).fill(0).map(((t,n)=>e[n][r]))))}return r(c(r(e),1))}function p(e){var t=e.length;if(1===t)return[e[0]];if(t%2==0){for(var n=[...p(e.filter(((e,t)=>t%2==0))),...p(e.filter(((e,t)=>t%2==1)))],l=0;l{var{typed:t,matrix:n}=e;return t(_X,{Array:function(e){return mq(wH(e))},Matrix:function(e){var t=mq(wH(e.toArray()));return n(t)}})})),MX=YH("algorithm04",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new eq(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");var m,g=u[0],y=u[1],b=n,x=0,v=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),x=t.convert(0,m),v=t.find(a,[m,m]));var _,w,M,N,S,k=i&&c?[]:void 0,D=[],T=[],I=i&&c?[]:void 0,E=i&&c?[]:void 0,C=[],A=[];for(w=0;w{var{typed:t,matrix:n,equalScalar:r,BigNumber:a,DenseMatrix:i}=e,s=pJ({typed:t}),o=MX({typed:t,equalScalar:r}),u=YJ({typed:t,DenseMatrix:i}),l=uJ({typed:t}),c=lJ({typed:t});return t("gcd",{"number, number":lW,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var n=new a(0);!t.isZero();){var r=e.mod(t);e=t,t=r}return e.lt(n)?e.neg():e},"Fraction, Fraction":function(e,t){return e.gcd(t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return c(n(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return c(n(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,n){for(var r=this(e,t),a=0;a{var{typed:t,isNumeric:n}=e;return t(SX,{string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return n(e)}})})),DX="hypot",TX=YH(DX,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:t,abs:n,addScalar:r,divideScalar:a,multiplyScalar:i,sqrt:s,smaller:o,isPositive:u}=e;return t(DX,{"... number | BigNumber":function(e){for(var t=0,l=0,c=0;c{var{typed:t,fft:n,dotDivide:r,conj:a}=e;return t(IX,{"Array | Matrix":function(e){var t=UP(e)?e.size():nq(e);return r(a(n(a(e))),t.reduce(((e,t)=>e*t),1))}})})),CX="kron",AX=YH(CX,["typed","matrix","multiplyScalar"],(e=>{var{typed:t,matrix:n,multiplyScalar:r}=e;return t(CX,{"Matrix, Matrix":function(e,t){return n(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(a(e.toArray(),t))},"Array, Matrix":function(e,t){return n(a(e,t.toArray()))},"Array, Array":a});function a(e,t){if(1===nq(e).length&&(e=[e]),1===nq(t).length&&(t=[t]),nq(e).length>2||nq(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(t.length)+")");var n=[],a=[];return e.map((function(e){return t.map((function(t){return a=[],n.push(a),e.map((function(e){return t.map((function(t){return a.push(r(e,t))}))}))}))}))&&n}})),LX="largerEq",$X=YH(LX,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=aJ({typed:t}),s=DJ({typed:t,DenseMatrix:a}),o=oJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t(LX,{"boolean, boolean":function(e,t){return e>=t},"number, number":function(e,t){return e>=t||aj(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)||zV(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return-1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(r(t),e,this,!0).valueOf()}})})),OX=YH("algorithm08",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new eq(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");if(!i||!c)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var m,g=u[0],y=u[1],b=n,x=0,v=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),x=t.convert(0,m),v=t.find(a,[m,m]));for(var _,w,M,N,S=[],k=[],D=[],T=[],I=[],E=0;E{var{typed:t,matrix:n,equalScalar:r,zeros:a,DenseMatrix:i}=e,s=pJ({typed:t}),o=rJ({typed:t,equalScalar:r}),u=OX({typed:t,equalScalar:r}),l=YJ({typed:t,DenseMatrix:i}),c=sJ({typed:t,equalScalar:r}),p=uJ({typed:t}),d=lJ({typed:t});return t(RX,{"number, number":mV,"BigNumber, BigNumber":uV,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():d(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):d(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}})}));function YX(e){var{DenseMatrix:t}=e;return function(e,n,r){var a=e.size();if(2!==a.length)throw new RangeError("Matrix must be two dimensional (size: "+KU(a)+")");var i=a[0];if(i!==a[1])throw new RangeError("Matrix must be square (size: "+KU(a)+")");var s=[];if(UP(n)){var o=n.size(),u=n._data;if(1===o.length){if(o[0]!==i)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var l=0;l{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=YX({DenseMatrix:o});return t(zX,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=(t=u(e,t,!0))._data,l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=[],m=0;mm&&(b.push(p[w]),x.push(M))}if(s(y,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var N=r(g,y),S=0,k=x.length;S{var{typed:t,matrix:n,flatten:r,size:a}=e;return t(PX,{"...Array":function(e){return i(e)},"...Matrix":function(e){return n(i(e.map((e=>e.toArray()))))}});function i(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var t=s(e[0]),n=[],a=0;a{var{typed:t,config:n,numeric:r,smaller:a}=e;return t("min",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return Kq(e,t.valueOf(),i)},"...":function(e){if(Wq(e))throw new TypeError("Scalar values expected in function min");return s(e)}});function i(e,t){try{return a(e,t)?e:t}catch(e){throw vJ(e,"min",t)}}function s(e){var t;if(Vq(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||a(e,t))&&(t=e)}catch(t){throw vJ(t,"min",e)}})),void 0===t)throw new Error("Cannot calculate min of an empty array");return"string"==typeof t&&(t=r(t,n.number)),t}})),UX="mode",qX=YH(UX,["typed","isNaN","isNumeric"],(e=>{var{typed:t,isNaN:n,isNumeric:r}=e;return t(UX,{"Array | Matrix":a,"...":function(e){return a(e)}});function a(e){if(0===(e=mq(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},a=[],i=0,s=0;si&&(i=t[o],a=[o])}return a}})),WX="nthRoots",VX=YH(WX,["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:n,divideScalar:r,Complex:a}=e,i=[function(e){return new a(e,0)},function(e){return new a(0,e)},function(e){return new a(-e,0)},function(e){return new a(0,-e)}];function s(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new a(0,0)];var n,r="number"==typeof e;(r||0===e.re||0===e.im)&&(n=r?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var s=e.arg(),o=e.abs(),u=[],l=Math.pow(o,1/t),c=0;c{var{typed:t,config:n,matrix:r,BigNumber:a}=e;return t("ones",{"":function(){return"Array"===n.matrix?i([]):i([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return i(e,t)}return"Array"===n.matrix?i(e):i(e,"default")},Array:i,Matrix:function(e){var t=e.storage();return i(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return i(e.valueOf(),t)}});function i(e,t){var n=function(e){var t=!1;return e.forEach((function(e,n,r){YP(e)&&(t=!0,r[n]=e.toNumber())})),t}(e),i=n?new a(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!jH(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}))}(e),t){var s=r(t);return e.length>0?s.resize(e,i):s}var o=[];return e.length>0?sq(o,e,i):o}})),KX="partitionSelect",JX=YH(KX,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:t,isNumeric:n,isNaN:r,compare:a}=e,i=a,s=(e,t)=>-a(e,t);return t(KX,{"Array | Matrix, number":function(e,t){return o(e,t,i)},"Array | Matrix, number, string":function(e,t,n){if("asc"===n)return o(e,t,i);if("desc"===n)return o(e,t,s);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":o});function o(e,t,n){if(!jH(t)||t<0)throw new Error("k must be a non-negative integer");if(UP(e)){if(e.size().length>1)throw new Error("Only one dimensional matrices supported");return u(e.valueOf(),t,n)}if(Array.isArray(e))return u(e,t,n)}function u(e,t,a){if(t>=e.length)throw new Error("k out of bounds");for(var i=0;i=0){var p=e[l];e[l]=e[u],e[u]=p,--l}else++u;a(e[u],c)>0&&--u,t<=u?o=u:s=u+1}return e[t]}}));function XX(e,t,n,r){if(!(this instanceof XX))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=n,this.max=r,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+n+(null!=r?"-"+r:"")+" expected)",this.stack=(new Error).stack}XX.prototype=new Error,XX.prototype.constructor=Error,XX.prototype.name="ArgumentsError",XX.prototype.isArgumentsError=!0;var ZX=YH("resize",["config","matrix"],(e=>{var{config:t,matrix:n}=e;return function(e,a,i){if(2!==arguments.length&&3!==arguments.length)throw new XX("resize",arguments.length,2,3);if(UP(a)&&(a=a.valueOf()),YP(a[0])&&(a=a.map((function(e){return YP(e)?e.toNumber():e}))),UP(e))return e.resize(a,i,!0);if("string"==typeof e)return r(e,a,i);var s=!Array.isArray(e)&&"Array"!==t.matrix;if(0===a.length){for(;Array.isArray(e);)e=e[0];return wH(e)}Array.isArray(e)||(e=[e]);var o=sq(e=wH(e),a,i);return s?n(o):o};function r(e,t,n){if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";if(1!==t.length)throw new eq(t.length,1);var r=t[0];if("number"!=typeof r||!jH(r))throw new TypeError("Invalid size, must contain positive integers (size: "+KU(t)+")");if(e.length>r)return e.substring(0,r);if(e.length{var{typed:t,matrix:n,equalScalar:r,zeros:a,DenseMatrix:i}=e,s=pJ({typed:t}),o=rJ({typed:t,equalScalar:r}),u=OX({typed:t,equalScalar:r}),l=YJ({typed:t,DenseMatrix:i}),c=sJ({typed:t,equalScalar:r}),p=uJ({typed:t}),d=lJ({typed:t});return t(QX,{"number, number":gV,"BigNumber, BigNumber":lV,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():d(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):d(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}})})),tZ="Number of decimals in function round must be an integer",nZ="round",rZ=YH(nZ,["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,zeros:a,BigNumber:i,DenseMatrix:s}=e,o=sJ({typed:t,equalScalar:r}),u=oJ({typed:t,DenseMatrix:s}),l=lJ({typed:t});return t(nZ,{number:xW,"number, number":xW,"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(tZ);return new i(e).toDecimalPlaces(t.toNumber())},Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(tZ);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(tZ);var n=t.toNumber();return e.round(n)},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(tZ);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(tZ);return e.round(t)},"Fraction, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(tZ);return e.round(t.toNumber())},"Array | Matrix":function(e){return Gq(e,this,!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"Array, number | BigNumber":function(e,t){return l(n(e),t,this,!1).valueOf()},"number | Complex | BigNumber | Fraction, SparseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):u(t,e,this,!0)},"number | Complex | BigNumber | Fraction, DenseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):l(t,e,this,!0)},"number | Complex | BigNumber | Fraction, Array":function(e,t){return l(n(t),e,this,!0).valueOf()}})})),aZ="smallerEq",iZ=YH(aZ,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=aJ({typed:t}),s=DJ({typed:t,DenseMatrix:a}),o=oJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t(aZ,{"boolean, boolean":function(e,t){return e<=t},"number, number":function(e,t){return e<=t||aj(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)||zV(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return 1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(r(t),e,this,!0).valueOf()}})})),sZ="unequal",oZ=YH(sZ,["typed","config","equalScalar","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,equalScalar:r,matrix:a,DenseMatrix:i}=e,s=aJ({typed:t}),o=DJ({typed:t,DenseMatrix:i}),u=oJ({typed:t,DenseMatrix:i}),l=uJ({typed:t}),c=lJ({typed:t});return t("unequal",{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:p(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,p)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,p,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,p,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,p)},"Array, Array":function(e,t){return this(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return this(a(e),t)},"Matrix, Array":function(e,t){return this(e,a(t))},"SparseMatrix, any":function(e,t){return u(e,t,p,!1)},"DenseMatrix, any":function(e,t){return c(e,t,p,!1)},"any, SparseMatrix":function(e,t){return u(t,e,p,!0)},"any, DenseMatrix":function(e,t){return c(t,e,p,!0)},"Array, any":function(e,t){return c(a(e),t,p,!1).valueOf()},"any, Array":function(e,t){return c(a(t),e,p,!0).valueOf()}});function p(e,t){return!r(e,t)}})),uZ=(YH(sZ,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return t(sZ,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!n(e,t)}})})),"usolve"),lZ=YH(uZ,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=YX({DenseMatrix:o});return t(uZ,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=(t=u(e,t,!0))._data,l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=[],m=c-1;m>=0;m--){var g=n[m][0]||0;if(s(g,0))f[m]=[0];else{for(var y=0,b=[],x=[],v=h[m],_=h[m+1]-1;_>=v;_--){var w=d[_];w===m?y=p[_]:w=0;h--){var f=n[h][0]||0,m=void 0;if(s(f,0))m=0;else{var g=d[h][h];if(s(g,0))throw new Error("Linear system cannot be solved since matrix is singular");m=r(f,g);for(var y=h-1;y>=0;y--)n[y]=[i(n[y][0]||0,a(m,d[y][h]))]}p[h]=[m]}return new o({data:p,size:[l,1]})}})),cZ=YH("xor",["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:n,DenseMatrix:r}=e,a=aJ({typed:t}),i=DJ({typed:t,DenseMatrix:r}),s=oJ({typed:t,DenseMatrix:r}),o=uJ({typed:t}),u=lJ({typed:t});return t("xor",{"number, number":zG,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,this,!0).valueOf()}})})),pZ=YH("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:n,addScalar:r,equalScalar:a,DenseMatrix:i,SparseMatrix:s}=e,o=pJ({typed:t}),u=MX({typed:t,equalScalar:a}),l=YJ({typed:t,DenseMatrix:i}),c=uJ({typed:t}),p=lJ({typed:t});return t("add",NH({"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,r)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,r,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,r,!0)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,r)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"DenseMatrix, any":function(e,t){return p(e,t,r,!1)},"SparseMatrix, any":function(e,t){return l(e,t,r,!1)},"any, DenseMatrix":function(e,t){return p(t,e,r,!0)},"any, SparseMatrix":function(e,t){return l(t,e,r,!0)},"Array, any":function(e,t){return p(n(e),t,r,!1).valueOf()},"any, Array":function(e,t){return p(n(t),e,r,!0).valueOf()},"any, any":r,"any, any, ...any":function(e,t,n){for(var r=this(e,t),a=0;a{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new eq(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");var m,g=u[0],y=u[1],b=n,x=0,v=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),x=t.convert(0,m),v=t.find(a,[m,m]));var _,w,M,N,S,k=i&&c?[]:void 0,D=[],T=[],I=k?[]:void 0,E=[];for(w=0;w{var{typed:t,matrix:n,equalScalar:r,BigNumber:a,DenseMatrix:i}=e,s=rJ({typed:t,equalScalar:r}),o=aJ({typed:t}),u=dZ({typed:t,equalScalar:r}),l=sJ({typed:t,equalScalar:r}),c=oJ({typed:t,DenseMatrix:i}),p=uJ({typed:t}),d=lJ({typed:t});return t(hZ,{"number, number":Math.atan2,"BigNumber, BigNumber":function(e,t){return a.atan2(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return d(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return d(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return d(n(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return d(n(t),e,this,!0).valueOf()}})})),mZ="bitOr",gZ=YH(mZ,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=pJ({typed:t}),s=MX({typed:t,equalScalar:r}),o=YJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t(mZ,{"number, number":hV,"BigNumber, BigNumber":aV,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,this,!0).valueOf()}})})),yZ="catalan",bZ=YH(yZ,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:t,addScalar:n,divideScalar:r,multiplyScalar:a,combinations:i,isNegative:s,isInteger:o}=e;return t(yZ,{"number | BigNumber":function(e){if(!o(e)||s(e))throw new TypeError("Non-negative integer value expected in function catalan");return r(i(a(e,2),e),n(e,1))}})})),xZ=n(3228),vZ="compareNatural",_Z=YH(vZ,["typed","compare"],(e=>{var{typed:t,compare:n}=e,r=n.signatures["boolean,boolean"];return t(vZ,{"any, any":function(e,t){var s,o=_H(e),u=_H(t);if(!("number"!==o&&"BigNumber"!==o&&"Fraction"!==o||"number"!==u&&"BigNumber"!==u&&"Fraction"!==u))return"0"!==(s=n(e,t)).toString()?s>0?1:-1:xZ(o,u);if("Array"===o||"Matrix"===o||"Array"===u||"Matrix"===u)return 0!==(s=a(this,e,t))?s:xZ(o,u);if(o!==u)return xZ(o,u);if("Complex"===o)return function(e,t){return e.re>t.re?1:e.ret.im?1:e.imn.length?1:t.length{var{typed:t,add:n,unaryPlus:r}=e;return t(wZ,{Array:a,Matrix:function(e){return e.create(a(e.valueOf()))},"Array, number | BigNumber":s,"Matrix, number | BigNumber":function(e,t){return e.create(s(e.valueOf(),t))},"...":function(e){if(Wq(e))throw new TypeError("All values expected to be scalar in function cumsum");return a(e)}});function a(e){try{return i(e)}catch(e){throw vJ(e,wZ)}}function i(e){if(0===e.length)return[];for(var t=[r(e[0])],a=1;a=n.length)throw new tq(t,n.length);try{return o(e,t)}catch(e){throw vJ(e,wZ)}}function o(e,t){var n,r,a;if(t<=0){var s=e[0][0];if(Array.isArray(s)){for(a=qq(e),r=[],n=0;n{var{typed:t,equal:n}=e;return t(NZ,{"any, any":function(e,t){return r(e.valueOf(),t.valueOf())}});function r(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var a=e.length;if(a!==t.length)return!1;for(var i=0;i{var{typed:t,matrix:n,subtract:r,number:a}=e;return t(kZ,{"Array | Matrix":function(e){return UP(e)?n(s(e.toArray())):s(e)},"Array | Matrix, number":function(e,t){if(!jH(t))throw new RangeError("Dimension must be a whole number");return UP(e)?n(i(e.toArray(),t)):i(e,t)},"Array | Matrix, BigNumber":function(e,t){return this(e,a(t))}});function i(e,t){if(UP(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(t>0){var n=[];return e.forEach((e=>{n.push(i(e,t-1))})),n}if(0===t)return s(e);throw RangeError("Cannot have negative dimension")}function s(e){var t=[],n=e.length;if(n<2)return e;for(var r=1;r{var{typed:t,addScalar:n,multiplyScalar:r,conj:a,size:i}=e;return t("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,i){var u=s(e,i),l=UP(e)?e._data:e,c=UP(e)?e._datatype:void 0,p=UP(i)?i._data:i,d=UP(i)?i._datatype:void 0,h=2===o(e).length,f=2===o(i).length,m=n,g=r;if(c&&d&&c===d&&"string"==typeof c){var y=c;m=t.find(n,[y,y]),g=t.find(r,[y,y])}if(!h&&!f){for(var b=g(a(l[0]),p[0]),x=1;xm?h++:f===m&&(l=c(l,p(i[d],u[h])),d++,h++)}return l}});function s(e,t){var n,r,a=o(e),i=o(t);if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(1===i.length)r=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");r=i[0]}if(n!==r)throw new RangeError("Vectors must have equal length ("+n+" != "+r+")");if(0===n)throw new RangeError("Cannot calculate the dot product of empty vectors");return n}function o(e){return UP(e)?e.size():i(e)}})),IZ="equalText",EZ=YH(IZ,["typed","compareText","isZero"],(e=>{var{typed:t,compareText:n,isZero:r}=e;return t(IZ,{"any, any":function(e,t){return r(n(e,t))}})})),CZ="floor",AZ=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],LZ=YH(CZ,["typed","config","round"],(e=>{var{typed:t,config:n,round:r}=e;return t(CZ,{number:function(e){return aj(e,r(e),n.epsilon)?r(e):Math.floor(e)},"number, number":function(e,t){if(aj(e,r(e,t),n.epsilon))return r(e,t);var[a,i]="".concat(e,"e").split("e"),s=Math.floor(Number("".concat(a,"e").concat(Number(i)+t)));return[a,i]="".concat(s,"e").split("e"),Number("".concat(a,"e").concat(Number(i)-t))}})})),$Z=YH(CZ,AZ,(e=>{var{typed:t,config:n,round:r,matrix:a,equalScalar:i,zeros:s,DenseMatrix:o}=e,u=sJ({typed:t,equalScalar:i}),l=oJ({typed:t,DenseMatrix:o}),c=lJ({typed:t}),p=LZ({typed:t,config:n,round:r});return t("floor",{number:p.signatures.number,"number,number":p.signatures["number,number"],Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},"Complex, BigNumber":function(e,t){return e.floor(t.toNumber())},BigNumber:function(e){return zV(e,r(e),n.epsilon)?r(e):e.floor()},"BigNumber, BigNumber":function(e,t){return zV(e,r(e,t),n.epsilon)?r(e,t):e.toDecimalPlaces(t.toNumber(),FH.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Fraction, BigNumber":function(e,t){return e.floor(t.toNumber())},"Array | Matrix":function(e){return Gq(e,this,!0)},"Array, number | BigNumber":function(e,t){return Gq(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(e,t){return c(a(t),e,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(e,t){return i(e,0)?s(t.size(),t.storage()):"dense"===t.storage()?c(t,e,this,!0):l(t,e,this,!0)}})})),OZ="identity",RZ=YH(OZ,["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,config:n,matrix:r,BigNumber:a,DenseMatrix:i,SparseMatrix:s}=e;return t(OZ,{"":function(){return"Matrix"===n.matrix?r([]):[]},string:function(e){return r(e)},"number | BigNumber":function(e){return u(e,e,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return u(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return u(e,t,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,n){return u(e,t,n)},Array:function(e){return o(e)},"Array, string":function(e,t){return o(e,t)},Matrix:function(e){return o(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){switch(e.length){case 0:return t?r(t):[];case 1:return u(e[0],e[0],t);case 2:return u(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function u(e,t,n){var r=YP(e)||YP(t)?a:null;if(YP(e)&&(e=e.toNumber()),YP(t)&&(t=t.toNumber()),!jH(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!jH(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var o=r?new a(1):1,u=r?new r(0):0,l=[e,t];if(n){if("sparse"===n)return s.diagonal(l,o,0,u);if("dense"===n)return i.diagonal(l,o,0,u);throw new TypeError('Unknown matrix type "'.concat(n,'"'))}for(var c=sq([],l,u),p=e{var{typed:t,config:n,BigNumber:r,xgcd:a,equal:i,smaller:s,mod:o,add:u,isInteger:l}=e;return t(FZ,{"number, number":c,"BigNumber, BigNumber":c});function c(e,t){if(!l(e)||!l(t))throw new Error("Parameters in function invmod must be integer numbers");if(e=o(e,t),i(t,0))throw new Error("Divisor must be non zero");var n=a(e,t);n=n.valueOf();var[c,p]=n;return i(c,r(1))?(p=o(p,t),s(p,r(0))&&(p=u(p,t)),p):NaN}})),zZ="larger",BZ=YH(zZ,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=aJ({typed:t}),s=DJ({typed:t,DenseMatrix:a}),o=oJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t(zZ,{"boolean, boolean":function(e,t){return e>t},"number, number":function(e,t){return e>t&&!aj(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!zV(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return 1===e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(r(t),e,this,!0).valueOf()}})})),PZ=YH("log",["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:n,divideScalar:r,Complex:a}=e;return t("log",{number:function(e){return e>=0||n.predictable?function(e,t){return Math.log(e)}(e):new a(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||n.predictable?e.ln():new a(e.toNumber(),0).log()},"Array | Matrix":function(e){return Gq(e,this)},"any, any":function(e,t){return r(this(e),this(t))}})})),HZ="lsolveAll",jZ=YH(HZ,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=YX({DenseMatrix:o});return t(HZ,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=0;ff&&(b.push(p[M]),x.push(N))}if(s(w,0))if(s(y[f],0)){if(0===g){var S=[...y];S[f]=1;for(var k=0,D=x.length;knew o({data:e.map((e=>[e])),size:[l,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map((e=>e.valueOf()))}});function l(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._data,c=e._size[0],p=e._size[1],d=0;dnew o({data:e.map((e=>[e])),size:[c,1]})))}})),UZ="matrixFromRows",qZ=YH(UZ,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:n,flatten:r,size:a}=e;return t(UZ,{"...Array":function(e){return i(e)},"...Matrix":function(e){return n(i(e.map((e=>e.toArray()))))}});function i(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var t=s(e[0]),n=[];for(var a of e){var i=s(a);if(i!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|i));n.push(r(a))}return n}function s(e){var t=a(e);if(1===t.length)return t[0];if(2===t.length){if(1===t[0])return t[1];if(1===t[1])return t[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),WZ="multiply",VZ=YH(WZ,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:a,equalScalar:i,dot:s}=e,o=sJ({typed:t,equalScalar:i}),u=lJ({typed:t});function l(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}var c=t("_multiplyMatrixVector",{"DenseMatrix, any":function(e,n){var i,s=e._data,o=e._size,u=e._datatype,l=n._data,c=n._datatype,p=o[0],d=o[1],h=r,f=a;u&&c&&u===c&&"string"==typeof u&&(i=u,h=t.find(r,[i,i]),f=t.find(a,[i,i]));for(var m=[],g=0;gk)for(var T=0,I=0;I{var{typed:t,matrix:n,zeros:r,identity:a,isZero:i,equal:s,sign:o,sqrt:u,conj:l,unaryMinus:c,addScalar:p,divideScalar:d,multiplyScalar:h,subtract:f,complex:m}=e;return OP(t("qr",{DenseMatrix:function(e){return y(e)},SparseMatrix:function(e){return function(e){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var t=y(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t,n,m,g=e._size[0],y=e._size[1],b=a([g],"dense"),x=b._data,v=e.clone(),_=v._data,w=r([g],"");for(m=0;m0)for(var r="Complex"===n[0][0].type?m(0):0,a=0;a{var{typed:t,config:n,matrix:r,bignumber:a,smaller:i,smallerEq:s,larger:o,largerEq:u}=e;return t(KZ,{string:c,"string, boolean":c,"number, number":function(e,t){return l(p(e,t,1))},"number, number, number":function(e,t,n){return l(p(e,t,n))},"number, number, boolean":function(e,t,n){return l(n?d(e,t,1):p(e,t,1))},"number, number, number, boolean":function(e,t,n,r){return l(r?d(e,t,n):p(e,t,n))},"BigNumber, BigNumber":function(e,t){return l(h(e,t,new(0,e.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(e,t,n){return l(h(e,t,n))},"BigNumber, BigNumber, boolean":function(e,t,n){var r=e.constructor;return l(n?f(e,t,new r(1)):h(e,t,new r(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,n,r){return l(r?f(e,t,n):h(e,t,n))}});function l(e){return"Matrix"===n.matrix?r?r(e):yJ():e}function c(e,t){var r=function(e){var t=e.split(":").map((function(e){return Number(e)})),n=t.some((function(e){return isNaN(e)}));if(n)return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(e);if(!r)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===n.number?(void 0===a&&mJ(),l((t?f:h)(a(r.start),a(r.end),a(r.step)))):l((t?d:p)(r.start,r.end,r.step))}function p(e,t,n){var r=[],a=e;if(n>0)for(;i(a,t);)r.push(a),a+=n;else if(n<0)for(;o(a,t);)r.push(a),a+=n;return r}function d(e,t,n){var r=[],a=e;if(n>0)for(;s(a,t);)r.push(a),a+=n;else if(n<0)for(;u(a,t);)r.push(a),a+=n;return r}function h(e,t,n){var r=a(0),s=[],u=e;if(n.gt(r))for(;i(u,t);)s.push(u),u=u.plus(n);else if(n.lt(r))for(;o(u,t);)s.push(u),u=u.plus(n);return s}function f(e,t,n){var r=a(0),i=[],o=e;if(n.gt(r))for(;s(o,t);)i.push(o),o=o.plus(n);else if(n.lt(r))for(;u(o,t);)i.push(o),o=o.plus(n);return i}})),XZ="rightLogShift",ZZ=YH(XZ,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,zeros:a,DenseMatrix:i}=e,s=pJ({typed:t}),o=rJ({typed:t,equalScalar:r}),u=OX({typed:t,equalScalar:r}),l=YJ({typed:t,DenseMatrix:i}),c=sJ({typed:t,equalScalar:r}),p=uJ({typed:t}),d=lJ({typed:t});return t(XZ,{"number, number":yV,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():d(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):d(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}})})),QZ="setSize",eQ=YH(QZ,["typed","compareNatural"],(e=>{var{typed:t,compareNatural:n}=e;return t(QZ,{"Array | Matrix":function(e){return Array.isArray(e)?mq(e).length:mq(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?mq(e).length:mq(e.toArray()).length;for(var r=mq(Array.isArray(e)?e:e.toArray()).sort(n),a=1,i=1;i=0;){var u=n[s+o],l=n[r+u];-1===l?(o--,i[t++]=u):(n[r+u]=n[a+l],n[s+ ++o]=l)}return t}function nQ(e){return-e-2}var rQ=YH("csAmd",["add","multiply","transpose"],(e=>{var{add:t,multiply:n,transpose:r}=e;return function(e,s){if(!s||e<=0||e>3)return null;var o=s._size,u=o[0],l=o[1],c=0,p=Math.max(16,10*Math.sqrt(l)),d=function(e,a,i,s,o){var u=r(a);if(1===e&&s===i)return t(a,u);if(2===e){for(var l=u._index,c=u._ptr,p=0,d=0;do))for(var f=c[d+1];hs)n[o+d]=0,n[a+d]=-1,p++,t[d]=nQ(e),n[o+e]++;else{var f=n[u+h];-1!==f&&(l[f]=d),n[c+d]=n[u+h],n[u+h]=d}}return p}(l,E,L,Y,F,z,p,$,R,P,O),U=0;jq?(b=m,x=G,v=L[0+m]-q):(x=E[b=I[G++]],v=L[0+b]),y=1;y<=v;y++)(_=L[$+(h=I[x++])])<=0||(V+=_,L[$+h]=-_,I[J++]=h,-1!==L[O+h]&&(P[L[O+h]]=P[h]),-1!==P[h]?L[O+P[h]]=L[O+h]:L[R+L[Y+h]]=L[O+h]);b!==m&&(E[b]=nQ(m),L[z+b]=0)}for(0!==q&&(C=J),L[Y+m]=V,E[m]=K,L[0+m]=J-K,L[F+m]=-2,H=a(H,c,L,z,l),w=K;w=H?L[z+b]-=_:0!==L[z+b]&&(L[z+b]=L[Y+b]+X)}for(w=K;w0?(T+=Z,I[k++]=b,D+=b):(E[b]=nQ(m),L[z+b]=0)}L[F+h]=k-N+1;var Q=k,ee=N+L[0+h];for(G=S+1;G=0))for(h=L[B+(D=P[h])],L[B+D]=-1;-1!==h&&-1!==L[O+h];h=L[O+h],H++){for(v=L[0+h],M=L[F+h],G=E[h]+1;G<=E[h]+v-1;G++)L[z+I[G]]=H;var ne=h;for(f=L[O+h];-1!==f;){var re=L[0+f]===v&&L[F+f]===M;for(G=E[f]+1;re&&G<=E[f]+v-1;G++)L[z+I[G]]!==H&&(re=0);re?(E[f]=nQ(h),L[$+h]+=L[$+f],L[$+f]=0,L[F+f]=-1,f=L[O+f],L[O+ne]=f):(ne=f,f=L[O+f])}}for(G=K,w=K;w=0;f--)L[$+f]>0||(L[O+f]=L[R+E[f]],L[R+E[f]]=f);for(b=l;b>=0;b--)L[$+b]<=0||-1!==E[b]&&(L[O+b]=L[R+E[b]],L[R+E[b]]=b);for(m=0,h=0;h<=l;h++)-1===E[h]&&(m=tQ(h,m,L,R,O,A,z));return A.splice(A.length-1,1),A};function a(e,t,n,r,a){if(e<2||e+t<0){for(var i=0;i{var{transpose:t}=e;return function(e,n,r,a){if(!e||!n||!r)return null;var i,s,o,u,l,c,p,d=e._size,h=d[0],f=d[1],m=4*f+(a?f+h+1:0),g=[],y=f,b=2*f,x=3*f,v=4*f,_=5*f+1;for(o=0;o=1&&w[s]++,2===k.jleaf&&w[k.q]--}-1!==n[s]&&(g[0+s]=n[s])}for(s=0;s{var{add:t,multiply:n,transpose:r}=e,a=rQ({add:t,multiply:n,transpose:r}),i=iQ({transpose:r});return function(e,t,n){var r,s=t._ptr,o=t._size[1],u={};if(u.q=a(e,t),e&&!u.q)return null;if(n){var l=e?function(e,t,n,r){for(var a=e._values,i=e._index,s=e._ptr,o=e._size,u=e._datatype,l=o[0],c=o[1],p=null,d=[],h=[],f=0,m=0;m=0;n--)-1!==e[n]&&(i[s+n]=i[0+e[n]],i[0+e[n]]=n);for(n=0;n=0;u--)for(c=n[u],p=n[u+1],l=c;l=0;o--)h[o]=-1,-1!==(u=f[o])&&(0==m[b+u]++&&(m[y+u]=o),m[0+o]=m[g+u],m[g+u]=o);for(t.lnz=0,t.m2=i,u=0;u=0;){e=r[p];var d=a?a[e]:e;oQ(l,e)||(uQ(l,e),r[c+p]=d<0?0:lQ(l[d]));var h=1;for(s=r[c+p],o=d<0?0:lQ(l[d+1]);s{var{divideScalar:t,multiply:n,subtract:r}=e;return function(e,a,i,s,o,u,l){var c,p,d,h,f=e._values,m=e._index,g=e._ptr,y=e._size[1],b=a._values,x=a._index,v=a._ptr,_=function(e,t,n,r,a){var i,s,o,u=e._ptr,l=e._size,c=t._index,p=t._ptr,d=l[1],h=d;for(s=p[n],o=p[n+1],i=s;i{var{abs:t,divideScalar:n,multiply:r,subtract:a,larger:i,largerEq:s,SparseMatrix:o}=e,u=pQ({divideScalar:n,multiply:r,subtract:a});return function(e,a,l){if(!e)return null;var c,p=e._size[1],d=100,h=100;a&&(c=a.q,d=a.lnz||d,h=a.unz||h);var f,m,g=[],y=[],b=[],x=new o({values:g,index:y,ptr:b,size:[p,p]}),v=[],_=[],w=[],M=new o({values:v,index:_,ptr:w,size:[p,p]}),N=[],S=[],k=[];for(f=0;f{var{typed:t,abs:n,add:r,multiply:a,transpose:i,divideScalar:s,subtract:o,larger:u,largerEq:l,SparseMatrix:c}=e,p=sQ({add:r,multiply:a,transpose:i}),d=dQ({abs:n,divideScalar:s,multiply:a,subtract:o,larger:u,largerEq:l,SparseMatrix:c});return t("slu",{"SparseMatrix, number, number":function(e,t,n){if(!jH(t)||t<0||t>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(n<0||n>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var r=p(t,e,!1),a=d(e,r,n);return{L:a.L,U:a.U,p:a.pinv,q:r.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})})),fQ=YH("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:n,add:r,numeric:a}=e;return t("sum",{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{return Kq(e,t,r)}catch(e){throw vJ(e,"sum")}},"...":function(e){if(Wq(e))throw new TypeError("Scalar values expected in function sum");return i(e)}});function i(e){var t;return Vq(e,(function(e){try{t=void 0===t?e:r(t,e)}catch(t){throw vJ(t,"sum",e)}})),void 0===t&&(t=a(0,n.number)),"string"==typeof t&&(t=a(t,n.number)),t}})),mQ=YH("trace",["typed","matrix","add"],(e=>{var{typed:t,matrix:n,add:r}=e;return t("trace",{Array:function(e){return a(n(e))},SparseMatrix:function(e){var t=e._values,n=e._index,a=e._ptr,i=e._size,s=i[0],o=i[1];if(s===o){var u=0;if(t.length>0)for(var l=0;ll)break}return u}throw new RangeError("Matrix must be square (size: "+KU(i)+")")},DenseMatrix:a,any:wH});function a(e){var t=e._size,n=e._data;switch(t.length){case 1:if(1===t[0])return wH(n[0]);throw new RangeError("Matrix must be square (size: "+KU(t)+")");case 2:var a=t[0];if(a===t[1]){for(var i=0,s=0;s{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=YX({DenseMatrix:o});return t(gQ,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=c-1;f>=0;f--)for(var m=n.length,g=0;g=v;w--){var M=d[w];M===f?_=p[w]:Mnew o({data:e.map((e=>[e])),size:[l,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map((e=>e.valueOf()))}});function l(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._data,c=e._size[0],p=e._size[1]-1;p>=0;p--)for(var d=n.length,h=0;h=0;g--)m[g]=i(m[g],l[g][p]);n.push(m)}}else{if(0===h)return[];n.splice(h,1),h-=1,d-=1}else{f[p]=r(f[p],l[p][p]);for(var y=p-1;y>=0;y--)f[y]=i(f[y],a(f[p],l[y][p]))}}return n.map((e=>new o({data:e.map((e=>[e])),size:[c,1]})))}})),bQ="asin",xQ=YH(bQ,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(bQ,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.asin(e):new r(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),vQ="ceil",_Q=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],wQ=YH(vQ,["typed","config","round"],(e=>{var{typed:t,config:n,round:r}=e;return t(vQ,{number:function(e){return aj(e,r(e),n.epsilon)?r(e):Math.ceil(e)},"number, number":function(e,t){if(aj(e,r(e,t),n.epsilon))return r(e,t);var[a,i]="".concat(e,"e").split("e"),s=Math.ceil(Number("".concat(a,"e").concat(Number(i)+t)));return[a,i]="".concat(s,"e").split("e"),Number("".concat(a,"e").concat(Number(i)-t))}})})),MQ=YH(vQ,_Q,(e=>{var{typed:t,config:n,round:r,matrix:a,equalScalar:i,zeros:s,DenseMatrix:o}=e,u=sJ({typed:t,equalScalar:i}),l=oJ({typed:t,DenseMatrix:o}),c=lJ({typed:t}),p=wQ({typed:t,config:n,round:r});return t("ceil",{number:p.signatures.number,"number,number":p.signatures["number,number"],Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},"Complex, BigNumber":function(e,t){return e.ceil(t.toNumber())},BigNumber:function(e){return zV(e,r(e),n.epsilon)?r(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return zV(e,r(e,t),n.epsilon)?r(e,t):e.toDecimalPlaces(t.toNumber(),FH.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Fraction, BigNumber":function(e,t){return e.ceil(t.toNumber())},"Array | Matrix":function(e){return Gq(e,this,!0)},"Array, number | BigNumber":function(e,t){return Gq(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(e,t){return c(a(t),e,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(e,t){return i(e,0)?s(t.size(),t.storage()):"dense"===t.storage()?c(t,e,this,!0):l(t,e,this,!0)}})})),NQ="composition",SQ=YH(NQ,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:t,addScalar:n,combinations:r,isPositive:a,isNegative:i,isInteger:s,larger:o}=e;return t(NQ,{"number | BigNumber, number | BigNumber":function(e,t){if(!(s(e)&&a(e)&&s(t)&&a(t)))throw new TypeError("Positive integer value expected in function composition");if(o(t,e))throw new TypeError("k must be less than or equal to n in function composition");return r(n(e,-1),n(t,-1))}})})),kQ="cross",DQ=YH(kQ,["typed","matrix","subtract","multiply"],(e=>{var{typed:t,matrix:n,subtract:r,multiply:a}=e;return t(kQ,{"Matrix, Matrix":function(e,t){return n(i(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(i(e.toArray(),t))},"Array, Matrix":function(e,t){return n(i(e,t.toArray()))},"Array, Array":i});function i(e,t){var n=Math.max(nq(e).length,nq(t).length);e=pq(e),t=pq(t);var i=nq(e),s=nq(t);if(1!==i.length||1!==s.length||3!==i[0]||3!==s[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+i.join(", ")+"], B = ["+s.join(", ")+"])");var o=[r(a(e[1],t[2]),a(e[2],t[1])),r(a(e[2],t[0]),a(e[0],t[2])),r(a(e[0],t[1]),a(e[1],t[0]))];return n>1?[o]:o}})),TQ=YH("det",["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],(e=>{var{typed:t,matrix:n,subtract:r,multiply:a,divideScalar:i,isZero:s,unaryMinus:o}=e;return t("det",{any:function(e){return wH(e)},"Array | Matrix":function(e){var t;switch((t=UP(e)?e.size():Array.isArray(e)?(e=n(e)).size():[]).length){case 0:return wH(e);case 1:if(1===t[0])return wH(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+KU(t)+")");case 2:var u=t[0];if(u===t[1])return function(e,t,n){if(1===t)return wH(e[0][0]);if(2===t)return r(a(e[0][0],e[1][1]),a(e[1][0],e[0][1]));for(var u=!1,l=new Array(t).fill(0).map(((e,t)=>t)),c=0;c{var{typed:t,addScalar:n,subtract:r,multiplyScalar:a,divideScalar:i,unaryMinus:s,sqrt:o,abs:u}=e;return t(IQ,{"Array, Array, Array":function(e,t,n){if(2===e.length&&2===t.length&&2===n.length){if(!c(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!c(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!c(n))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var o=i(r(n[1],n[0]),r(t[1],t[0])),u=a(a(o,o),t[0]),l=s(a(o,t[0])),p=e[1];return m(e[0],e[1],u,l,p)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,t,n){if(2===Object.keys(e).length&&2===Object.keys(t).length&&2===Object.keys(n).length){if(!c(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!c(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!c(n))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in n&&"lineTwoPtY"in n){var o=i(r(n.lineTwoPtY,n.lineTwoPtX),r(t.lineOnePtY,t.lineOnePtX)),u=a(a(o,o),t.lineOnePtX),l=s(a(o,t.lineOnePtX)),p=e.pointX;return m(e.pointX,e.pointY,u,l,p)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!c(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!p(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return m(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!p(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&e.length>0){if(!d(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!d(t))throw new TypeError("All values of an array should be numbers or BigNumbers");return y(e,t)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!c(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return m(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!h(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!c(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!c(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return y([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return y([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&l(e[0][0])&&l(e[0][1])){if(e.some((e=>2!==e.length||!l(e[0])||!l(e[1]))))return!1}else{if(!(3===e[0].length&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])))return!1;if(e.some((e=>3!==e.length||!l(e[0])||!l(e[1])||!l(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var t=[],n=[],r=[],a=0;a{var{typed:t,matrix:n,equalScalar:r,multiplyScalar:a}=e,i=rJ({typed:t,equalScalar:r}),s=dZ({typed:t,equalScalar:r}),o=sJ({typed:t,equalScalar:r}),u=uJ({typed:t}),l=lJ({typed:t});return t(CQ,{"any, any":a,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,a,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,a,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,a,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,a)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,a,!1)},"DenseMatrix, any":function(e,t){return l(e,t,a,!1)},"any, SparseMatrix":function(e,t){return o(t,e,a,!0)},"any, DenseMatrix":function(e,t){return l(t,e,a,!0)},"Array, any":function(e,t){return l(n(e),t,a,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,a,!0).valueOf()}})})),LQ=YH("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:t,larger:n}=e,r=1/Math.log((1+Math.sqrt(5))/2);function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function i(e,t,n){t.left.right=t.right,t.right.left=t.left,n.degree--,n.child===t&&(n.child=t.right),0===n.degree&&(n.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function s(e,t){var n=t.parent;n&&(t.mark?(i(e,t,n),s(n)):t.mark=!0)}a.prototype.type="FibonacciHeap",a.prototype.isFibonacciHeap=!0,a.prototype.insert=function(e,n){var r={key:e,value:n,degree:0};if(this._minimum){var a=this._minimum;r.left=a,r.right=a.right,a.right=r,r.right.left=r,t(e,a.key)&&(this._minimum=r)}else r.left=r,r.right=r,this._minimum=r;return this._size++,r},a.prototype.size=function(){return this._size},a.prototype.clear=function(){this._minimum=null,this._size=0},a.prototype.isEmpty=function(){return 0===this._size},a.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var a=this._minimum,i=e.degree,s=e.child;i>0;){var u=s.right;s.left.right=s.right,s.right.left=s.left,s.left=a,s.right=a.right,a.right=s,s.right.left=s,s.parent=null,s=u,i--}return e.left.right=e.right,e.right.left=e.left,a=e===e.right?null:function(e,a){var i,s=Math.floor(Math.log(a)*r)+1,u=new Array(s),l=0,c=e;if(c)for(l++,c=c.right;c!==e;)l++,c=c.right;for(;l>0;){for(var p=c.degree,d=c.right;i=u[p];){if(n(c.key,i.key)){var h=i;i=c,c=h}o(i,c),u[p]=null,p++}u[p]=c,c=d,l--}e=null;for(var f=0;f{var{typed:t,ceil:n,floor:r}=e;return t($Q,{number:function(e){return e>0?r(e):n(e)},"number, number":function(e,t){return e>0?r(e,t):n(e,t)}})})),FQ=YH($Q,OQ,(e=>{var{typed:t,Complex:n,matrix:r,ceil:a,floor:i,equalScalar:s,zeros:o,DenseMatrix:u}=e,l=oJ({typed:t,DenseMatrix:u}),c=lJ({typed:t}),p=RQ({typed:t,ceil:a,floor:i});return t("fix",{number:p.signatures.number,"number, number | BigNumber":p.signatures["number,number"],Complex:function(e){return new n(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number":function(e,t){return new n(e.re>0?i(e.re,t):a(e.re,t),e.im>0?i(e.im,t):a(e.im,t))},"Complex, BigNumber":function(e,t){var r=t.toNumber();return new n(e.re>0?i(e.re,r):a(e.re,r),e.im>0?i(e.im,r):a(e.im,r))},BigNumber:function(e){return e.isNegative()?a(e):i(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?a(e,t):i(e,t)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0?a(e,t):i(e,t)},"Array | Matrix":function(e){return Gq(e,this,!0)},"Array | Matrix, number | BigNumber":function(e,t){return Gq(e,(e=>this(e,t)),!0)},"number | Complex | Fraction | BigNumber, Array":function(e,t){return c(r(t),e,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(e,t){return s(e,0)?o(t.size(),t.storage()):"dense"===t.storage()?c(t,e,this,!0):l(t,e,this,!0)}})})),YQ=YH("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:t,DenseMatrix:n}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!HP(t))throw new Error("Invalid datatype: "+t);if(UP(e)||jP(e)){var a=new n(e,t);this._data=a._data,this._size=a._size,this._datatype=a._datatype,this._min=null,this._max=null}else if(e&&jP(e.data)&&jP(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+_H(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return r.prototype=new n,r.prototype.type="ImmutableDenseMatrix",r.prototype.isImmutableDenseMatrix=!0,r.prototype.subset=function(e){switch(arguments.length){case 1:var t=n.prototype.subset.call(this,e);return UP(t)?new r({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},r.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},r.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},r.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},r.prototype.clone=function(){return new r({data:wH(this._data),size:wH(this._size),datatype:this._datatype})},r.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},r.fromJSON=function(e){return new r(e)},r.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},r.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(n){(null===e||t(n,e))&&(e=n)})),this._min=null!==e?e:void 0}return this._min},r.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(n){(null===e||t(e,n))&&(e=n)})),this._max=null!==e?e:void 0}return this._max},r}),{isClass:!0}),zQ=YH("Index",["ImmutableDenseMatrix"],(e=>{var{ImmutableDenseMatrix:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var t=0,a=arguments.length;t{var{typed:t,config:n,abs:r,add:a,addScalar:i,matrix:s,multiply:o,multiplyScalar:u,divideScalar:l,subtract:c,smaller:p,equalScalar:d,flatten:h,isZero:f,isNumeric:m}=e;return t("intersect",{"Array, Array, Array":g,"Array, Array, Array, Array":y,"Matrix, Matrix, Matrix":function(e,t,n){var r=g(e.valueOf(),t.valueOf(),n.valueOf());return null===r?null:s(r)},"Matrix, Matrix, Matrix, Matrix":function(e,t,n,r){var a=y(e.valueOf(),t.valueOf(),n.valueOf(),r.valueOf());return null===a?null:s(a)}});function g(e,t,n){if(e=b(e),t=b(t),n=b(n),!v(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!v(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&m(e[0])&&m(e[1])&&m(e[2])&&m(e[3])}(n))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,t,n,r,a,s,o,p,d,h){var f=u(e,o),m=u(r,o),g=u(t,p),y=u(a,p),b=u(n,d),x=u(s,d),v=c(c(c(h,f),g),b),_=c(c(c(i(i(m,y),x),f),g),b),w=l(v,_);return[i(e,u(w,c(r,e))),i(t,u(w,c(a,t))),i(n,u(w,c(s,n)))]}(e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],n[3])}function y(e,t,s,h){if(e=b(e),t=b(t),s=b(s),h=b(h),2===e.length){if(!x(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!x(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!x(s))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!x(h))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,t,s,d){var h=e,m=s,g=c(h,t),y=c(m,d),b=c(u(g[0],y[1]),u(y[0],g[1]));if(f(b))return null;if(p(r(b),n.epsilon))return null;var x=u(y[0],h[1]),v=u(y[1],h[0]),_=u(y[0],m[1]),w=u(y[1],m[0]),M=l(i(c(c(x,v),_),w),b);return a(o(g,M),h)}(e,t,s,h)}if(3===e.length){if(!v(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!v(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!v(s))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!v(h))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return function(e,t,n,r,a,s,o,p,h,m,g,y){var b=_(e,o,m,o,t,p,g,p,n,h,y,h),x=_(m,o,r,e,g,p,a,t,y,h,s,n),v=_(e,o,r,e,t,p,a,t,n,h,s,n),w=_(m,o,m,o,g,p,g,p,y,h,y,h),M=_(r,e,r,e,a,t,a,t,s,n,s,n),N=c(u(b,x),u(v,w)),S=c(u(M,w),u(x,x));if(f(S))return null;var k=l(N,S),D=l(i(b,u(k,x)),w),T=i(e,u(k,c(r,e))),I=i(t,u(k,c(a,t))),E=i(n,u(k,c(s,n))),C=i(o,u(D,c(m,o))),A=i(p,u(D,c(g,p))),L=i(h,u(D,c(y,h)));return d(T,C)&&d(I,A)&&d(E,L)?[T,I,E]:null}(e[0],e[1],e[2],t[0],t[1],t[2],s[0],s[1],s[2],h[0],h[1],h[2])}throw new TypeError("Arrays with two or thee dimensional points expected")}function b(e){return 1===e.length?e[0]:e.length>1&&Array.isArray(e[0])&&e.every((e=>Array.isArray(e)&&1===e.length))?h(e):e}function x(e){return 2===e.length&&m(e[0])&&m(e[1])}function v(e){return 3===e.length&&m(e[0])&&m(e[1])&&m(e[2])}function _(e,t,n,r,a,s,o,l,p,d,h,f){var m=u(c(e,t),c(n,r)),g=u(c(a,s),c(o,l)),y=u(c(p,d),c(h,f));return i(i(m,g),y)}})),PQ=YH("lcm",["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:n,equalScalar:r}=e,a=rJ({typed:t,equalScalar:r}),i=dJ({typed:t,equalScalar:r}),s=sJ({typed:t,equalScalar:r}),o=uJ({typed:t}),u=lJ({typed:t});return t("lcm",{"number, number":cW,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;for(var n=e.times(t);!t.isZero();){var r=t;t=e.mod(r),e=r}return n.div(e).abs()},"Fraction, Fraction":function(e,t){return e.lcm(t)},"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return s(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return u(n(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return u(n(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,n){for(var r=this(e,t),a=0;a{var{typed:t,config:n,divideScalar:r,log:a,Complex:i}=e;return t(HQ,{number:function(e){return e>=-1||n.predictable?VH(e):s(new i(e,0))},Complex:s,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||n.predictable?t.ln():s(new i(e.toNumber(),0))},"Array | Matrix":function(e){return Gq(e,this)},"any, any":function(e,t){return r(this(e),a(t))}});function s(e){var t=e.re+1;return new i(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}})),UQ=YH("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:n,numeric:r,larger:a}=e;return t("max",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return Kq(e,t.valueOf(),i)},"...":function(e){if(Wq(e))throw new TypeError("Scalar values expected in function max");return s(e)}});function i(e,t){try{return a(e,t)?e:t}catch(e){throw vJ(e,"max",t)}}function s(e){var t;if(Vq(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||a(e,t))&&(t=e)}catch(t){throw vJ(t,"max",e)}})),void 0===t)throw new Error("Cannot calculate max of an empty array");return"string"==typeof t&&(t=r(t,n.number)),t}})),qQ=YH("quantileSeq",["typed","add","multiply","partitionSelect","compare"],(e=>{var{typed:t,add:n,multiply:r,partitionSelect:a,compare:i}=e;function s(e,t,s){var u=mq(e),l=u.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");if(FP(t)){var c=t*(l-1),p=c%1;if(0===p){var d=s?u[c]:a(u,c);return o(d),d}var h,f,m=Math.floor(c);if(s)h=u[m],f=u[m+1];else{f=a(u,m+1),h=u[m];for(var g=0;g0&&(h=u[g])}return o(h),o(f),n(r(h,1-p),r(f,p))}var y=t.times(l-1);if(y.isInteger()){y=y.toNumber();var b=s?u[y]:a(u,y);return o(b),b}var x,v,_=y.floor(),w=y.minus(_),M=_.toNumber();if(s)x=u[M],v=u[M+1];else{v=a(u,M+1),x=u[M];for(var N=0;N0&&(x=u[N])}o(x),o(v);var S=new w.constructor(1);return n(r(x,S.minus(w)),r(v,w))}var o=t({"number | BigNumber | Unit":function(e){return e}});return function(e,t,n){var r,a,i;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(qP(e)){if("boolean"==typeof(n=n||!1)){if(a=e.valueOf(),FP(t)){if(t<0)throw new Error("N/prob must be non-negative");if(t<=1)return s(a,t,n);if(t>1){if(!jH(t))throw new Error("N must be a positive integer");var o=t+1;r=new Array(t);for(var u=0;u4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var p=new l(c+1);r=new Array(c);for(var d=0;d1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!YP(f))throw new TypeError("Unexpected type of argument in function quantileSeq");if(i=new f.constructor(1),f.isNegative()||f.gt(i))throw new Error("Probability must be between 0 and 1, inclusive")}r[h]=s(a,f,n)}return r}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}})),WQ=YH("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e;return t("row",{"Matrix, number":i,"Array, number":function(e,t){return i(r(wH(e)),t).valueOf()}});function i(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");iq(t,e.size()[0]);var r=a(0,e.size()[1]),i=new n(t,r);return e.subset(i)}})),VQ="setCartesian",GQ=YH(VQ,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(VQ,{"Array | Matrix, Array | Matrix":function(e,t){var o=[];if(0!==r(n(e),new i(0))&&0!==r(n(t),new i(0))){var u=mq(Array.isArray(e)?e:e.toArray()).sort(a),l=mq(Array.isArray(t)?t:t.toArray()).sort(a);o=[];for(var c=0;c{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(KQ,{"Array | Matrix":function(e){var t;if(0===r(n(e),new i(0)))t=[];else{var o=mq(Array.isArray(e)?e:e.toArray()).sort(a);(t=[]).push(o[0]);for(var u=1;u{var{typed:t,size:n,subset:r,compareNatural:a,Index:i}=e;return t(XQ,{"Array | Matrix, Array | Matrix":function(e,t){if(0===r(n(e),new i(0)))return!0;if(0===r(n(t),new i(0)))return!1;for(var s,o=_q(mq(Array.isArray(e)?e:e.toArray()).sort(a)),u=_q(mq(Array.isArray(t)?t:t.toArray()).sort(a)),l=0;l{var{typed:t,size:n,subset:r,compareNatural:a,Index:i}=e;return t(QQ,{"Array | Matrix":function(e){if(0===r(n(e),new i(0)))return[];for(var t=mq(Array.isArray(e)?e:e.toArray()).sort(a),o=[],u=0;u.toString(2).length<=t.length;)o.push(s(t,u.toString(2).split("").reverse())),u++;return function(e){for(var t=[],n=e.length-1;n>0;n--)for(var r=0;re[r+1].length&&(t=e[r],e[r]=e[r+1],e[r+1]=t);return e}(o)}});function s(e,t){for(var n=[],r=0;r{var{typed:t,matrix:n,compare:r,compareNatural:a}=e,i=r,s=(e,t)=>-r(e,t);return t(t0,{Array:function(e){return u(e),e.sort(i)},Matrix:function(e){return l(e),n(e.toArray().sort(i),e.storage())},"Array, function":function(e,t){return u(e),e.sort(t)},"Matrix, function":function(e,t){return l(e),n(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return u(e),e.sort(o(t))},"Matrix, string":function(e,t){return l(e),n(e.toArray().sort(o(t)),e.storage())}});function o(e){if("asc"===e)return i;if("desc"===e)return s;if("natural"===e)return a;throw new Error('String "asc", "desc", or "natural" expected')}function u(e){if(1!==nq(e).length)throw new Error("One dimensional array expected")}function l(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}})),r0="column",a0=YH(r0,["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e;return t(r0,{"Matrix, number":i,"Array, number":function(e,t){return i(r(wH(e)),t).valueOf()}});function i(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");iq(t,e.size()[1]);var r=a(0,e.size()[0]),i=new n(r,t);return e.subset(i)}})),i0="index",s0=YH(i0,["typed","Index"],(e=>{var{typed:t,Index:n}=e;return t(i0,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map((function(e){return YP(e)?e.toNumber():Array.isArray(e)||UP(e)?e.map((function(e){return YP(e)?e.toNumber():e})):e})),r=new n;return n.apply(r,t),r}})})),o0=YH("inv",["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],(e=>{var{typed:t,matrix:n,divideScalar:r,addScalar:a,multiply:i,unaryMinus:s,det:o,identity:u,abs:l}=e;return t("inv",{"Array | Matrix":function(e){var t=UP(e)?e.size():nq(e);switch(t.length){case 1:if(1===t[0])return UP(e)?n([r(1,e.valueOf()[0])]):[r(1,e[0])];throw new RangeError("Matrix must be square (size: "+KU(t)+")");case 2:var a=t[0],i=t[1];if(a===i)return UP(e)?n(c(e.valueOf(),a,i),e.storage()):c(e,a,i);throw new RangeError("Matrix must be square (size: "+KU(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+KU(t)+")")}},any:function(e){return r(1,e)}});function c(e,t,n){var c,p,d,h,f;if(1===t){if(0===(h=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,h)]]}if(2===t){var m=o(e);if(0===m)throw Error("Cannot calculate inverse, determinant is zero");return[[r(e[1][1],m),r(s(e[0][1]),m)],[r(s(e[1][0]),m),r(e[0][0],m)]]}var g=e.concat();for(c=0;cx&&(x=l(g[c][b]),v=c),c++;if(0===x)throw Error("Cannot calculate inverse, determinant is zero");(c=v)!==b&&(f=g[b],g[b]=g[c],g[c]=f,f=y[b],y[b]=y[c],y[c]=f);var _=g[b],w=y[b];for(c=0;c{var{typed:t,matrix:n,inv:r,deepEqual:a,equal:i,dotDivide:s,dot:o,ctranspose:u,divideScalar:l,multiply:c,add:p,Complex:d}=e;return t(u0,{"Array | Matrix":function(e){var t=UP(e)?e.size():nq(e);switch(t.length){case 1:return m(e)?u(e):1===t[0]?r(e):s(u(e),o(e,e));case 2:if(m(e))return u(e);var a=t[0],i=t[1];if(a===i)try{return r(e)}catch(e){if(!(e instanceof Error&&e.message.match(/Cannot calculate inverse, determinant is zero/)))throw e}return UP(e)?n(h(e.valueOf(),a,i),e.storage()):h(e,a,i);default:throw new RangeError("Matrix must be two dimensional (size: "+KU(t)+")")}},any:function(e){return i(e,0)?wH(e):l(1,e)}});function h(e,t,n){var{C:a,F:i}=function(e,t,n){var r=function(e,t,n){for(var r=wH(e),a=0,i=0;ie.filter(((e,n)=>n!f(o(r[t],r[t]))));return{C:a,F:i}}(e,t,n),l=c(r(c(u(a),a)),u(a)),d=c(u(i),r(c(i,u(i))));return c(d,l)}function f(e){return i(p(e,d(1,1)),p(0,d(1,1)))}function m(e){return a(p(e,d(1,1)),p(c(e,0),d(1,1)))}})),c0=YH("pow",["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],(e=>{var{typed:t,config:n,identity:r,multiply:a,matrix:i,inv:s,number:o,fraction:u,Complex:l}=e;return t("pow",{"number, number":c,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||n.predictable?e.pow(t):new l(e.toNumber(),0).pow(t.toNumber(),0)},"Fraction, Fraction":function(e,t){var r=e.pow(t);if(null!=r)return r;if(n.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(e.valueOf(),t.valueOf())},"Array, number":p,"Array, BigNumber":function(e,t){return p(e,t.toNumber())},"Matrix, number":d,"Matrix, BigNumber":function(e,t){return d(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function c(e,t){if(n.predictable&&!jH(t)&&e<0)try{var r=u(t),a=o(r);if((t===a||Math.abs((t-a)/t)<1e-14)&&r.d%2==1)return(r.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return n.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:jH(t)||e>=0||n.predictable?bW(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new l(e,0).pow(t,0)}function p(e,t){if(!jH(t))throw new TypeError("For A^b, b must be an integer (value is "+t+")");var n=nq(e);if(2!==n.length)throw new Error("For A^b, A must be 2 dimensional (A has "+n.length+" dimensions)");if(n[0]!==n[1])throw new Error("For A^b, A must be square (size is "+n[0]+"x"+n[1]+")");if(t<0)try{return p(s(e),-t)}catch(e){if("Cannot calculate inverse, determinant is zero"===e.message)throw new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+t+")");throw e}for(var i=r(n[0]).valueOf(),o=e;t>=1;)1==(1&t)&&(i=a(o,i)),t>>=1,o=a(o,o);return i}function d(e,t){return i(p(e.valueOf(),t))}})),p0="setDifference",d0=YH(p0,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(p0,{"Array | Matrix, Array | Matrix":function(e,t){var o;if(0===r(n(e),new i(0)))o=[];else{if(0===r(n(t),new i(0)))return mq(e.toArray());var u,l=_q(mq(Array.isArray(e)?e:e.toArray()).sort(a)),c=_q(mq(Array.isArray(t)?t:t.toArray()).sort(a));o=[];for(var p=0;p{var{typed:t,size:n,subset:r,compareNatural:a,Index:i}=e;return t(h0,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===r(n(t),new i(0)))return 0;for(var s=mq(Array.isArray(t)?t:t.toArray()),o=0,u=0;u{var{addScalar:t,equalScalar:n,FibonacciHeap:r}=e;function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new r}return a.prototype.type="Spa",a.prototype.isSpa=!0,a.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var n=this._heap.insert(e,t);this._values[e]=n}},a.prototype.get=function(e){var t=this._values[e];return t?t.value:0},a.prototype.accumulate=function(e,n){var r=this._values[e];r?r.value=t(r.value,n):(r=this._heap.insert(e,n),this._values[e]=r)},a.prototype.forEach=function(e,t,r){var a=this._heap,i=this._values,s=[],o=a.extractMinimum();for(o&&s.push(o);o&&o.key<=t;)o.key>=e&&(n(o.value,0)||r(o.key,o.value,this)),(o=a.extractMinimum())&&s.push(o);for(var u=0;u{var{typed:t,abs:n,add:r,multiply:a,sqrt:i,subtract:s,inv:o,size:u,max:l,identity:c}=e,p=1e-6;function d(e){var t,i=0,d=e,h=c(u(e));do{var f=d;if(d=a(.5,r(f,o(h))),h=a(.5,r(h,o(f))),(t=l(n(s(d,f))))>p&&++i>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(t>p);return d}return t(g0,{"Array | Matrix":function(e){var t=UP(e)?e.size():nq(e);switch(t.length){case 1:if(1===t[0])return i(e);throw new RangeError("Matrix must be square (size: "+KU(t)+")");case 2:if(t[0]===t[1])return d(e);throw new RangeError("Matrix must be square (size: "+KU(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+KU(t)+")")}}})}));function b0(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function x0(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 v0(e){for(var t=1;t{var t,n,r,{on:a,config:i,addScalar:s,subtract:o,multiplyScalar:u,divideScalar:l,pow:c,abs:p,fix:d,round:h,equal:f,isNumeric:m,format:g,number:y,Complex:b,BigNumber:x,Fraction:v}=e,_=y;function w(e,t){if(!(this instanceof w))throw new Error("Constructor must be called with the new operator");if(null!=e&&!m(e)&&!zP(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==t&&("string"!=typeof t||""===t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==t){var n=w.parse(t);this.units=n.units,this.dimensions=n.dimensions}else{this.units=[{unit:R,prefix:A.NONE,power:0}],this.dimensions=[];for(var r=0;r="0"&&e<="9"}function S(){n++,r=t.charAt(n)}function k(e){n=e,r=t.charAt(n)}function D(){var e="",t=n;if("+"===r?S():"-"===r&&(e+=r,S()),!function(e){return e>="0"&&e<="9"||"."===e}(r))return k(t),null;if("."===r){if(e+=r,S(),!N(r))return k(t),null}else{for(;N(r);)e+=r,S();"."===r&&(e+=r,S())}for(;N(r);)e+=r,S();if("E"===r||"e"===r){var a="",i=n;if(a+=r,S(),"+"!==r&&"-"!==r||(a+=r,S()),!N(r))return k(i),e;for(e+=a;N(r);)e+=r,S()}return e}function T(){for(var e="";N(r)||w.isValidAlpha(r);)e+=r,S();var t=e.charAt(0);return w.isValidAlpha(t)?e:null}function I(e){return r===e?(S(),e):null}w.prototype.type="Unit",w.prototype.isUnit=!0,w.parse=function(e,a){if(a=a||{},n=-1,r="","string"!=typeof(t=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var s=new w;s.units=[];var o=1,u=!1;S(),M();var l=D(),c=null;if(l){if("BigNumber"===i.number)c=new x(l);else if("Fraction"===i.number)try{c=new v(l)}catch(e){c=parseFloat(l)}else c=parseFloat(l);M(),I("*")?(o=1,u=!0):I("/")&&(o=-1,u=!0)}for(var p=[],d=1;;){for(M();"("===r;)p.push(o),d*=o,o=1,S(),M();var h;if(!r)break;var f=r;if(null===(h=T()))throw new SyntaxError('Unexpected "'+f+'" in "'+t+'" at index '+n.toString());var m=E(h);if(null===m)throw new SyntaxError('Unit "'+h+'" not found.');var g=o*d;if(M(),I("^")){M();var y=D();if(null===y)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');g*=y}s.units.push({unit:m.unit,prefix:m.prefix,power:g});for(var b=0;b1||Math.abs(this.units[0].power-1)>1e-15)},w.prototype._normalize=function(e){if(null==e||0===this.units.length)return e;for(var t=e,n=w._getNumberConverter(_H(e)),r=0;r{if(EH(F,e)){var t=F[e];return{unit:t,prefix:t.prefixes[""]}}for(var n in F)if(EH(F,n)&&GU(e,n)){var r=F[n],a=e.length-n.length,i=e.substring(0,a),s=EH(r.prefixes,i)?r.prefixes[i]:void 0;if(void 0!==s)return{unit:r,prefix:s}}return null}),{hasher:e=>e[0],limit:100});function C(e){return e.equalBase($.NONE)&&null!==e.value&&!i.predictable?e.value:e}w.isValuelessUnit=function(e){return null!==E(e)},w.prototype.hasBase=function(e){if("string"==typeof e&&(e=$[e]),!e)return!1;for(var t=0;t1e-12)return!1;return!0},w.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},w.prototype.equals=function(e){return this.equalBase(e)&&f(this.value,e.value)},w.prototype.multiply=function(e){for(var t=this.clone(),n=0;n1e-12&&(EH(P,o)?r.push({unit:P[o].unit,prefix:P[o].prefix,power:n.dimensions[s]||0}):i=!0)}r.length1e-12){if(!EH(B.si,r))throw new Error("Cannot express custom unit "+r+" in SI units");t.push({unit:B.si[r].unit,prefix:B.si[r].prefix,power:e.dimensions[n]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},w.prototype.formatUnits=function(){for(var e="",t="",n=0,r=0,a=0;a0?(n++,e+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power-1)>1e-15&&(e+="^"+this.units[a].power)):this.units[a].power<0&&r++;if(r>0)for(var i=0;i0?(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power+1)>1e-15&&(t+="^"+-this.units[i].power)):(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,t+="^"+this.units[i].power));e=e.substr(1),t=t.substr(1),n>1&&r>0&&(e="("+e+")"),r>1&&n>0&&(t="("+t+")");var s=e;return n>0&&r>0&&(s+=" / "),s+t},w.prototype.format=function(e){var t=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),n=!1;for(var r in void 0!==t.value&&null!==t.value&&zP(t.value)&&(n=Math.abs(t.value.re)<1e-14),t.units)EH(t.units,r)&&t.units[r].unit&&("VA"===t.units[r].unit.name&&n?t.units[r].unit=F.VAR:"VAR"!==t.units[r].unit.name||n||(t.units[r].unit=F.VA));1!==t.units.length||t.fixPrefix||Math.abs(t.units[0].power-Math.round(t.units[0].power))<1e-14&&(t.units[0].prefix=t._bestPrefix());var a=t._denormalize(t.value),i=null!==t.value?g(a,e||{}):"",s=t.formatUnits();return t.value&&zP(t.value)&&(i="("+i+")"),s.length>0&&i.length>0&&(i+=" "),i+s},w.prototype._bestPrefix=function(){if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var e=null!==this.value?p(this.value):0,t=p(this.units[0].unit.value),n=this.units[0].prefix;if(0===e)return n;var r=this.units[0].power,a=Math.log(e/Math.pow(n.value*t,r))/Math.LN10-1.2;if(a>-2.200001&&a<1.800001)return n;a=Math.abs(a);var i=this.units[0].unit.prefixes;for(var s in i)if(EH(i,s)){var o=i[s];if(o.scientific){var u=Math.abs(Math.log(e/Math.pow(o.value*t,r))/Math.LN10-1.2);(u0))},F={meter:{name:"meter",base:$.LENGTH,prefixes:A.LONG,value:1,offset:0},inch:{name:"inch",base:$.LENGTH,prefixes:A.NONE,value:.0254,offset:0},foot:{name:"foot",base:$.LENGTH,prefixes:A.NONE,value:.3048,offset:0},yard:{name:"yard",base:$.LENGTH,prefixes:A.NONE,value:.9144,offset:0},mile:{name:"mile",base:$.LENGTH,prefixes:A.NONE,value:1609.344,offset:0},link:{name:"link",base:$.LENGTH,prefixes:A.NONE,value:.201168,offset:0},rod:{name:"rod",base:$.LENGTH,prefixes:A.NONE,value:5.0292,offset:0},chain:{name:"chain",base:$.LENGTH,prefixes:A.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:$.LENGTH,prefixes:A.NONE,value:1e-10,offset:0},m:{name:"m",base:$.LENGTH,prefixes:A.SHORT,value:1,offset:0},in:{name:"in",base:$.LENGTH,prefixes:A.NONE,value:.0254,offset:0},ft:{name:"ft",base:$.LENGTH,prefixes:A.NONE,value:.3048,offset:0},yd:{name:"yd",base:$.LENGTH,prefixes:A.NONE,value:.9144,offset:0},mi:{name:"mi",base:$.LENGTH,prefixes:A.NONE,value:1609.344,offset:0},li:{name:"li",base:$.LENGTH,prefixes:A.NONE,value:.201168,offset:0},rd:{name:"rd",base:$.LENGTH,prefixes:A.NONE,value:5.02921,offset:0},ch:{name:"ch",base:$.LENGTH,prefixes:A.NONE,value:20.1168,offset:0},mil:{name:"mil",base:$.LENGTH,prefixes:A.NONE,value:254e-7,offset:0},m2:{name:"m2",base:$.SURFACE,prefixes:A.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:$.SURFACE,prefixes:A.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:$.SURFACE,prefixes:A.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:$.SURFACE,prefixes:A.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:$.SURFACE,prefixes:A.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:$.SURFACE,prefixes:A.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:$.SURFACE,prefixes:A.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:$.SURFACE,prefixes:A.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:$.SURFACE,prefixes:A.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:$.SURFACE,prefixes:A.NONE,value:1e4,offset:0},m3:{name:"m3",base:$.VOLUME,prefixes:A.CUBIC,value:1,offset:0},L:{name:"L",base:$.VOLUME,prefixes:A.SHORT,value:.001,offset:0},l:{name:"l",base:$.VOLUME,prefixes:A.SHORT,value:.001,offset:0},litre:{name:"litre",base:$.VOLUME,prefixes:A.LONG,value:.001,offset:0},cuin:{name:"cuin",base:$.VOLUME,prefixes:A.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:$.VOLUME,prefixes:A.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:$.VOLUME,prefixes:A.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:$.VOLUME,prefixes:A.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:$.VOLUME,prefixes:A.NONE,value:15e-6,offset:0},drop:{name:"drop",base:$.VOLUME,prefixes:A.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:$.VOLUME,prefixes:A.NONE,value:5e-8,offset:0},minim:{name:"minim",base:$.VOLUME,prefixes:A.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:$.VOLUME,prefixes:A.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:$.VOLUME,prefixes:A.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:$.VOLUME,prefixes:A.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:$.VOLUME,prefixes:A.NONE,value:1e-6,offset:0},cup:{name:"cup",base:$.VOLUME,prefixes:A.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:$.VOLUME,prefixes:A.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:$.VOLUME,prefixes:A.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:$.VOLUME,prefixes:A.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:$.VOLUME,prefixes:A.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:$.VOLUME,prefixes:A.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:$.VOLUME,prefixes:A.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:$.VOLUME,prefixes:A.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:$.VOLUME,prefixes:A.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:$.VOLUME,prefixes:A.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:$.VOLUME,prefixes:A.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:$.VOLUME,prefixes:A.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:$.VOLUME,prefixes:A.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:$.VOLUME,prefixes:A.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:$.VOLUME,prefixes:A.NONE,value:.1173478,offset:0},obl:{name:"obl",base:$.VOLUME,prefixes:A.NONE,value:.1589873,offset:0},g:{name:"g",base:$.MASS,prefixes:A.SHORT,value:.001,offset:0},gram:{name:"gram",base:$.MASS,prefixes:A.LONG,value:.001,offset:0},ton:{name:"ton",base:$.MASS,prefixes:A.SHORT,value:907.18474,offset:0},t:{name:"t",base:$.MASS,prefixes:A.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:$.MASS,prefixes:A.LONG,value:1e3,offset:0},grain:{name:"grain",base:$.MASS,prefixes:A.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:$.MASS,prefixes:A.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:$.MASS,prefixes:A.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:$.MASS,prefixes:A.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:$.MASS,prefixes:A.NONE,value:45.359237,offset:0},stick:{name:"stick",base:$.MASS,prefixes:A.NONE,value:.115,offset:0},stone:{name:"stone",base:$.MASS,prefixes:A.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:$.MASS,prefixes:A.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:$.MASS,prefixes:A.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:$.MASS,prefixes:A.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:$.MASS,prefixes:A.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:$.MASS,prefixes:A.NONE,value:45.359237,offset:0},s:{name:"s",base:$.TIME,prefixes:A.SHORT,value:1,offset:0},min:{name:"min",base:$.TIME,prefixes:A.NONE,value:60,offset:0},h:{name:"h",base:$.TIME,prefixes:A.NONE,value:3600,offset:0},second:{name:"second",base:$.TIME,prefixes:A.LONG,value:1,offset:0},sec:{name:"sec",base:$.TIME,prefixes:A.LONG,value:1,offset:0},minute:{name:"minute",base:$.TIME,prefixes:A.NONE,value:60,offset:0},hour:{name:"hour",base:$.TIME,prefixes:A.NONE,value:3600,offset:0},day:{name:"day",base:$.TIME,prefixes:A.NONE,value:86400,offset:0},week:{name:"week",base:$.TIME,prefixes:A.NONE,value:604800,offset:0},month:{name:"month",base:$.TIME,prefixes:A.NONE,value:2629800,offset:0},year:{name:"year",base:$.TIME,prefixes:A.NONE,value:31557600,offset:0},decade:{name:"decade",base:$.TIME,prefixes:A.NONE,value:315576e3,offset:0},century:{name:"century",base:$.TIME,prefixes:A.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:$.TIME,prefixes:A.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:$.FREQUENCY,prefixes:A.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:$.FREQUENCY,prefixes:A.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:$.ANGLE,prefixes:A.SHORT,value:1,offset:0},radian:{name:"radian",base:$.ANGLE,prefixes:A.LONG,value:1,offset:0},deg:{name:"deg",base:$.ANGLE,prefixes:A.SHORT,value:null,offset:0},degree:{name:"degree",base:$.ANGLE,prefixes:A.LONG,value:null,offset:0},grad:{name:"grad",base:$.ANGLE,prefixes:A.SHORT,value:null,offset:0},gradian:{name:"gradian",base:$.ANGLE,prefixes:A.LONG,value:null,offset:0},cycle:{name:"cycle",base:$.ANGLE,prefixes:A.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:$.ANGLE,prefixes:A.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:$.ANGLE,prefixes:A.NONE,value:null,offset:0},A:{name:"A",base:$.CURRENT,prefixes:A.SHORT,value:1,offset:0},ampere:{name:"ampere",base:$.CURRENT,prefixes:A.LONG,value:1,offset:0},K:{name:"K",base:$.TEMPERATURE,prefixes:A.NONE,value:1,offset:0},degC:{name:"degC",base:$.TEMPERATURE,prefixes:A.NONE,value:1,offset:273.15},degF:{name:"degF",base:$.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:$.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:$.TEMPERATURE,prefixes:A.NONE,value:1,offset:0},celsius:{name:"celsius",base:$.TEMPERATURE,prefixes:A.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:$.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:$.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:$.AMOUNT_OF_SUBSTANCE,prefixes:A.SHORT,value:1,offset:0},mole:{name:"mole",base:$.AMOUNT_OF_SUBSTANCE,prefixes:A.LONG,value:1,offset:0},cd:{name:"cd",base:$.LUMINOUS_INTENSITY,prefixes:A.SHORT,value:1,offset:0},candela:{name:"candela",base:$.LUMINOUS_INTENSITY,prefixes:A.LONG,value:1,offset:0},N:{name:"N",base:$.FORCE,prefixes:A.SHORT,value:1,offset:0},newton:{name:"newton",base:$.FORCE,prefixes:A.LONG,value:1,offset:0},dyn:{name:"dyn",base:$.FORCE,prefixes:A.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:$.FORCE,prefixes:A.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:$.FORCE,prefixes:A.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:$.FORCE,prefixes:A.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:$.FORCE,prefixes:A.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:$.FORCE,prefixes:A.NONE,value:9.80665,offset:0},J:{name:"J",base:$.ENERGY,prefixes:A.SHORT,value:1,offset:0},joule:{name:"joule",base:$.ENERGY,prefixes:A.SHORT,value:1,offset:0},erg:{name:"erg",base:$.ENERGY,prefixes:A.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:$.ENERGY,prefixes:A.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:$.ENERGY,prefixes:A.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:$.ENERGY,prefixes:A.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:$.ENERGY,prefixes:A.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:$.POWER,prefixes:A.SHORT,value:1,offset:0},watt:{name:"watt",base:$.POWER,prefixes:A.LONG,value:1,offset:0},hp:{name:"hp",base:$.POWER,prefixes:A.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:$.POWER,prefixes:A.SHORT,value:b.I,offset:0},VA:{name:"VA",base:$.POWER,prefixes:A.SHORT,value:1,offset:0},Pa:{name:"Pa",base:$.PRESSURE,prefixes:A.SHORT,value:1,offset:0},psi:{name:"psi",base:$.PRESSURE,prefixes:A.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:$.PRESSURE,prefixes:A.NONE,value:101325,offset:0},bar:{name:"bar",base:$.PRESSURE,prefixes:A.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:$.PRESSURE,prefixes:A.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:$.PRESSURE,prefixes:A.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:$.PRESSURE,prefixes:A.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:$.PRESSURE,prefixes:A.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:$.ELECTRIC_CHARGE,prefixes:A.LONG,value:1,offset:0},C:{name:"C",base:$.ELECTRIC_CHARGE,prefixes:A.SHORT,value:1,offset:0},farad:{name:"farad",base:$.ELECTRIC_CAPACITANCE,prefixes:A.LONG,value:1,offset:0},F:{name:"F",base:$.ELECTRIC_CAPACITANCE,prefixes:A.SHORT,value:1,offset:0},volt:{name:"volt",base:$.ELECTRIC_POTENTIAL,prefixes:A.LONG,value:1,offset:0},V:{name:"V",base:$.ELECTRIC_POTENTIAL,prefixes:A.SHORT,value:1,offset:0},ohm:{name:"ohm",base:$.ELECTRIC_RESISTANCE,prefixes:A.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:$.ELECTRIC_INDUCTANCE,prefixes:A.LONG,value:1,offset:0},H:{name:"H",base:$.ELECTRIC_INDUCTANCE,prefixes:A.SHORT,value:1,offset:0},siemens:{name:"siemens",base:$.ELECTRIC_CONDUCTANCE,prefixes:A.LONG,value:1,offset:0},S:{name:"S",base:$.ELECTRIC_CONDUCTANCE,prefixes:A.SHORT,value:1,offset:0},weber:{name:"weber",base:$.MAGNETIC_FLUX,prefixes:A.LONG,value:1,offset:0},Wb:{name:"Wb",base:$.MAGNETIC_FLUX,prefixes:A.SHORT,value:1,offset:0},tesla:{name:"tesla",base:$.MAGNETIC_FLUX_DENSITY,prefixes:A.LONG,value:1,offset:0},T:{name:"T",base:$.MAGNETIC_FLUX_DENSITY,prefixes:A.SHORT,value:1,offset:0},b:{name:"b",base:$.BIT,prefixes:A.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:$.BIT,prefixes:A.BINARY_LONG,value:1,offset:0},B:{name:"B",base:$.BIT,prefixes:A.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:$.BIT,prefixes:A.BINARY_LONG,value:8,offset:0}},Y={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function z(e){if("BigNumber"===e.number){var t=yj(x);F.rad.value=new x(1),F.deg.value=t.div(180),F.grad.value=t.div(200),F.cycle.value=t.times(2),F.arcsec.value=t.div(648e3),F.arcmin.value=t.div(10800)}else F.rad.value=1,F.deg.value=Math.PI/180,F.grad.value=Math.PI/200,F.cycle.value=2*Math.PI,F.arcsec.value=Math.PI/648e3,F.arcmin.value=Math.PI/10800;F.radian.value=F.rad.value,F.degree.value=F.deg.value,F.gradian.value=F.grad.value}z(i),a&&a("config",(function(e,t){e.number!==t.number&&z(e)}));var B={si:{NONE:{unit:R,prefix:A.NONE[""]},LENGTH:{unit:F.m,prefix:A.SHORT[""]},MASS:{unit:F.g,prefix:A.SHORT.k},TIME:{unit:F.s,prefix:A.SHORT[""]},CURRENT:{unit:F.A,prefix:A.SHORT[""]},TEMPERATURE:{unit:F.K,prefix:A.SHORT[""]},LUMINOUS_INTENSITY:{unit:F.cd,prefix:A.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:F.mol,prefix:A.SHORT[""]},ANGLE:{unit:F.rad,prefix:A.SHORT[""]},BIT:{unit:F.bits,prefix:A.SHORT[""]},FORCE:{unit:F.N,prefix:A.SHORT[""]},ENERGY:{unit:F.J,prefix:A.SHORT[""]},POWER:{unit:F.W,prefix:A.SHORT[""]},PRESSURE:{unit:F.Pa,prefix:A.SHORT[""]},ELECTRIC_CHARGE:{unit:F.C,prefix:A.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:F.F,prefix:A.SHORT[""]},ELECTRIC_POTENTIAL:{unit:F.V,prefix:A.SHORT[""]},ELECTRIC_RESISTANCE:{unit:F.ohm,prefix:A.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:F.H,prefix:A.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:F.S,prefix:A.SHORT[""]},MAGNETIC_FLUX:{unit:F.Wb,prefix:A.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:F.T,prefix:A.SHORT[""]},FREQUENCY:{unit:F.Hz,prefix:A.SHORT[""]}}};B.cgs=JSON.parse(JSON.stringify(B.si)),B.cgs.LENGTH={unit:F.m,prefix:A.SHORT.c},B.cgs.MASS={unit:F.g,prefix:A.SHORT[""]},B.cgs.FORCE={unit:F.dyn,prefix:A.SHORT[""]},B.cgs.ENERGY={unit:F.erg,prefix:A.NONE[""]},B.us=JSON.parse(JSON.stringify(B.si)),B.us.LENGTH={unit:F.ft,prefix:A.NONE[""]},B.us.MASS={unit:F.lbm,prefix:A.NONE[""]},B.us.TEMPERATURE={unit:F.degF,prefix:A.NONE[""]},B.us.FORCE={unit:F.lbf,prefix:A.NONE[""]},B.us.ENERGY={unit:F.BTU,prefix:A.BTU[""]},B.us.POWER={unit:F.hp,prefix:A.NONE[""]},B.us.PRESSURE={unit:F.psi,prefix:A.NONE[""]},B.auto=JSON.parse(JSON.stringify(B.si));var P=B.auto;for(var H in w.setUnitSystem=function(e){if(!EH(B,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(B).join(", "));P=B[e]},w.getUnitSystem=function(){for(var e in B)if(EH(B,e)&&B[e]===P)return e},w.typeConverters={BigNumber:function(e){return new x(e+"")},Fraction:function(e){return new v(e)},Complex:function(e){return e},number:function(e){return e}},w._getNumberConverter=function(e){if(!w.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return w.typeConverters[e]},F)if(EH(F,H)){var j=F[H];j.dimensions=j.base.dimensions}for(var U in Y)if(EH(Y,U)){var q=F[Y[U]],W={};for(var V in q)EH(q,V)&&(W[V]=q[V]);W.name=U,F[U]=W}return w.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},w.createUnit=function(e,t){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var n in e)if(EH(e,n)&&w.deleteUnit(n),e[n].aliases)for(var r=0;r0&&!w.isValidAlpha(r)&&!N(r))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var a,i,s,o=null,u=[],l=0;if(t&&"Unit"===t.type)o=t.clone();else if("string"==typeof t)""!==t&&(a=t);else{if("object"!=typeof t)throw new TypeError('Cannot create unit "'+e+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');a=t.definition,i=t.prefixes,l=t.offset,s=t.baseName,t.aliases&&(u=t.aliases.valueOf())}if(u)for(var c=0;c1e-12){f=!1;break}if(f){d=!0,p.base=$[h];break}}if(!d){s=s||e+"_STUFF";var g={dimensions:o.dimensions.slice(0)};g.key=s,$[s]=g,P[s]={unit:p,prefix:A.NONE[""]},p.base=$[s]}}else{if(s=s||e+"_STUFF",L.indexOf(s)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var y in L.push(s),$)EH($,y)&&($[y].dimensions[L.length-1]=0);for(var b={dimensions:[]},x=0;x{var{typed:t,Unit:n}=e;return t(w0,{"Object, Object":function(e,t){return n.createUnit(e,t)},Object:function(e){return n.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,r){var a={};return a[e]=t,n.createUnit(a,r)},"string, Unit | string | Object":function(e,t){var r={};return r[e]=t,n.createUnit(r,{})},string:function(e){var t={};return t[e]={},n.createUnit(t,{})}})})),N0="dotPow",S0=YH(N0,["typed","equalScalar","matrix","pow","DenseMatrix"],(e=>{var{typed:t,equalScalar:n,matrix:r,pow:a,DenseMatrix:i}=e,s=aJ({typed:t}),o=DJ({typed:t,DenseMatrix:i}),u=sJ({typed:t,equalScalar:n}),l=oJ({typed:t,DenseMatrix:i}),c=uJ({typed:t}),p=lJ({typed:t});return t(N0,{"any, any":a,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,a,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,a,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,a,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,a)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})})),k0="expm",D0=YH(k0,["typed","abs","add","identity","inv","multiply"],(e=>{var{typed:t,abs:n,add:r,identity:a,inv:i,multiply:s}=e;return t(k0,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+KU(t)+")");for(var u=t[0],l=function(e){for(var t=e.size()[0],r=0,a=0;a1&&(y=s(y,h),b=-b),f=r(f,s(g=g*(p-x+1)/((2*p-x+1)*x),y)),m=r(m,s(g*b,y));for(var v=s(i(m),f),_=0;_{var{typed:t,config:n,multiplyScalar:r,pow:a,BigNumber:i,Complex:s}=e;return t(T0,{number:_G,Complex:function(e){if(0===e.im)return this(e.re);if(e.re<.5){var t=new s(1-e.re,-e.im),n=new s(Math.PI*e.re,Math.PI*e.im);return new s(Math.PI).div(n.sin()).div(this(t))}e=new s(e.re-1,e.im);for(var r=new s(MG[0],0),a=1;a2;)u+=a-=2,s=s.times(u);return new i(s.toPrecision(i.precision))}})),E0="setIntersect",C0=YH(E0,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(E0,{"Array | Matrix, Array | Matrix":function(e,t){var o;if(0===r(n(e),new i(0))||0===r(n(t),new i(0)))o=[];else{var u=_q(mq(Array.isArray(e)?e:e.toArray()).sort(a)),l=_q(mq(Array.isArray(t)?t:t.toArray()).sort(a));o=[];for(var c=0;c{var{typed:t,matrix:n,multiply:r,equalScalar:a,divideScalar:i,inv:s}=e,o=sJ({typed:t,equalScalar:a}),u=lJ({typed:t});return t("divide",NH({"Array | Matrix, Array | Matrix":function(e,t){return r(e,s(t))},"DenseMatrix, any":function(e,t){return u(e,t,i,!1)},"SparseMatrix, any":function(e,t){return o(e,t,i,!1)},"Array, any":function(e,t){return u(n(e),t,i,!1).valueOf()},"any, Array | Matrix":function(e,t){return r(e,s(t))}},i.signatures))})),L0="factorial",$0=YH(L0,["typed","gamma"],(e=>{var{typed:t,gamma:n}=e;return t(L0,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return n(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return n(e.plus(1))},"Array | Matrix":function(e){return Gq(e,this)}})})),O0=YH("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:t,matrix:n,abs:r,addScalar:a,divideScalar:i,multiplyScalar:s,subtract:o,larger:u,equalScalar:l,unaryMinus:c,DenseMatrix:p,SparseMatrix:d,Spa:h}=e;return t("lup",{DenseMatrix:function(e){return f(e)},SparseMatrix:function(e){return function(e){var t,n,a,o=e._size[0],p=e._size[1],f=Math.min(o,p),m=e._values,g=e._index,y=e._ptr,b=[],x=[],v=[],_=[o,f],w=[],M=[],N=[],S=[f,p],k=[],D=[];for(t=0;t0&&e.forEach(0,n-1,(function(t,n){d._forEachRow(t,b,x,v,(function(r,a){r>t&&e.accumulate(r,c(s(a,n)))}))}));var T,I,E,C,A=n,L=e.get(n),$=r(L);e.forEach(n+1,o-1,(function(e,t){var n=r(t);u(n,$)&&(A=e,$=n,L=t)})),n!==A&&(d._swapRows(n,A,_[1],b,x,v),d._swapRows(n,A,S[1],w,M,N),e.swap(n,A),I=A,E=D[T=n],C=D[I],k[E]=I,k[C]=T,D[T]=C,D[I]=E),e.forEach(0,o-1,(function(e,t){e<=n?(w.push(t),M.push(e)):(t=i(t,L),l(t,0)||(b.push(t),x.push(e)))}))};for(n=0;n0)for(t=0;t{var{typed:t,add:n,divide:r,multiply:a,factorial:i,isInteger:s,isPositive:o}=e;return t(R0,{"Array | Matrix":function(e){var t=0,u=1;return Vq(e,(function(e){if(!s(e)||!o(e))throw new TypeError("Positive integer value expected in function multinomial");t=n(t,e),u=a(u,i(e))})),r(i(t),u)}})})),Y0="permutations",z0=YH(Y0,["typed","factorial"],(e=>{var{typed:t,factorial:n}=e;return t(Y0,{"number | BigNumber":n,"number, number":function(e,t){if(!jH(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!jH(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");return NV(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var n,r;if(!B0(e)||!B0(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(n=e.mul(0).add(1),r=e.minus(t).plus(1);r.lte(e);r=r.plus(1))n=n.times(r);return n}})}));function B0(e){return e.isInteger()&&e.gte(0)}var P0="stirlingS2",H0=YH(P0,["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],(e=>{var{typed:t,addScalar:n,subtract:r,multiplyScalar:a,divideScalar:i,pow:s,factorial:o,combinations:u,isNegative:l,isInteger:c,number:p,bignumber:d,larger:h}=e,f=[],m=[];return t(P0,{"number | BigNumber, number | BigNumber":function(e,t){if(!c(e)||l(e)||!c(t)||l(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(h(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");var r=!(FP(e)&&FP(t)),i=r?m:f,s=r?d:p,o=p(e),u=p(t);if(i[o]&&i[o].length>u)return i[o][u];for(var g=0;g<=o;++g)if(i[g]||(i[g]=[s(0===g?1:0)]),0!==g)for(var y=i[g],b=i[g-1],x=y.length;x<=g&&x<=u;++x)y[x]=x===g?1:n(a(s(x),b[x]),b[x-1]);return i[o][u]}})})),j0="unit",U0=YH(j0,["typed","Unit"],(e=>{var{typed:t,Unit:n}=e;return t(j0,{Unit:function(e){return e.clone()},string:function(e){return n.isValuelessUnit(e)?new n(null,e):n.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(e,t){return new n(e,t)},"Array | Matrix":function(e){return Gq(e,this)}})})),q0="bellNumbers",W0=YH(q0,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:t,addScalar:n,isNegative:r,isInteger:a,stirlingS2:i}=e;return t(q0,{"number | BigNumber":function(e){if(!a(e)||r(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,s=0;s<=e;s++)t=n(t,i(e,s));return t}})}));var V0=YH("eigs",["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],(e=>{var{config:t,typed:n,matrix:r,addScalar:a,subtract:i,equal:s,abs:o,atan:u,cos:l,sin:c,multiplyScalar:p,divideScalar:d,inv:h,bignumber:f,multiply:m,add:g,larger:y,column:b,flatten:x,number:v,complex:_,sqrt:w,diag:M,qr:N,usolve:S,usolveAll:k,im:D,re:T,smaller:I,matrixFromColumns:E,dot:C}=e,A=function(e){var{config:t,addScalar:n,subtract:r,abs:a,atan:i,cos:s,sin:o,multiplyScalar:u,inv:l,bignumber:c,multiply:p,add:d}=e;function h(e,n){for(var r,a=e.length,i=Math.abs(n/a),s=new Array(a),o=0;o=Math.abs(i);){var l=u[0][0],c=u[0][1];e=b(e,(p=e[l][l],d=e[c][c],h=e[l][c],f=void 0,f=d-p,r=Math.abs(f)<=t.epsilon?Math.PI/4:.5*Math.atan(2*h/(d-p))),l,c),s=m(s,r,l,c),u=x(e)}for(var p,d,h,f,g=w(a,0),y=0;y=a(d);){var b=m[0][0],x=m[0][1];e=y(e,(M=e[b][b],N=e[x][x],S=e[b][x],k=void 0,k=r(N,M),s=a(k)<=t.epsilon?c(-1).acos().div(4):u(.5,i(p(2,S,l(k))))),b,x),h=g(h,s,b,x),m=v(e)}for(var M,N,S,k,D=w(o,0),T=0;T2&&void 0!==arguments[2]?arguments[2]:t.epsilon,a=arguments.length>3?arguments[3]:void 0;if("number"===a)return h(e,r);if("BigNumber"===a)return f(e,r);throw TypeError("Unsupported data type: "+a)}}({config:t,addScalar:a,subtract:i,column:b,flatten:x,equal:s,abs:o,atan:u,cos:l,sin:c,multiplyScalar:p,inv:h,bignumber:f,complex:_,multiply:m,add:g}),L=function(e){var{addScalar:t,subtract:n,flatten:r,multiply:a,multiplyScalar:i,divideScalar:s,sqrt:o,abs:u,bignumber:l,diag:c,inv:p,qr:d,usolve:h,usolveAll:f,equal:m,complex:g,larger:y,smaller:b,matrixFromColumns:x,dot:v}=e;function _(e,t,r,a,i,s,o,c){var p="BigNumber"===c,d="Complex"===c,h=p?l(0):d?g(0):0,f=p?l(1):d?g(1):1;if(b(u(r),o))return[[f,h],[h,f]];if(y(u(n(i,s)),o))return[[n(i,a),n(s,a)],[r,r]];var m=n(e,i),x=n(t,i),v=n(r,i),_=n(a,i);return b(u(x),o)?[[m,f],[v,h]]:[[x,h],[_,f]]}function w(e,t){for(var n=0;n=5)return null;for(o=0;;){var u=h(e,i);if(b(D(k(i,[u])),r))break;if(++o>=10)return null;i=T(u)}return i}function S(e,t,n){var r="BigNumber"===n,a="Complex"===n,i=Array(e).fill(0).map((e=>2*Math.random()-1));return r&&(i=i.map((e=>l(e)))),a&&(i=i.map((e=>g(e)))),T(i=k(i,t),n)}function k(e,t){for(var r of t)e=n(e,a(s(v(r,e),v(r,r)),r));return e}function D(e){return u(o(v(e,e)))}function T(e,t){var n="Complex"===t,r="BigNumber"===t?l(1):n?g(1):1;return a(s(r,D(e)),e)}return function(e,h,v,S,k){void 0===k&&(k=!0);var D=function(e,n,r,a,o){var p,d="BigNumber"===a,h="Complex"===a,f=d?l(0):0,x=d?l(1):h?g(1):1,v=d?l(1):1,_=d?l(10):2,w=i(_,_);o&&(p=Array(n).fill(x));for(var M=!1;!M;){M=!0;for(var N=0;N1&&($=c(Array(C-1).fill(y)))),C-=1,I.pop();for(var B=0;B2&&($=c(Array(C-2).fill(y)))),C-=2,I.pop(),I.pop();for(var H=0;H+n(u(e),u(t)))),O>100){var j=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+E.join(", "));throw j.values=E,j.vectors=[],j}var U=h?a(L,function(e,t){for(var n=[],r=0;ra(m,e))),T.push(...c.map((e=>r(e))))},$=0;${var{typed:t,add:n,divide:r}=e;return t(G0,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){try{var a=Kq(e,t,n),i=Array.isArray(e)?nq(e):e.size();return r(a,i[t])}catch(e){throw vJ(e,"mean")}},"...":function(e){if(Wq(e))throw new TypeError("Scalar values expected in function mean");return a(e)}});function a(e){var t,a=0;if(Vq(e,(function(e){try{t=void 0===t?e:n(t,e),a++}catch(t){throw vJ(t,"mean",e)}})),0===a)throw new Error("Cannot calculate the mean of an empty array");return r(t,a)}})),J0="setSymDifference",X0=YH(J0,["typed","size","concat","subset","setDifference","Index"],(e=>{var{typed:t,size:n,concat:r,subset:a,setDifference:i,Index:s}=e;return t(J0,{"Array | Matrix, Array | Matrix":function(e,t){if(0===a(n(e),new s(0)))return mq(t);if(0===a(n(t),new s(0)))return mq(e);var o=mq(e),u=mq(t);return r(i(o,u),i(u,o))}})}));function Z0(e,t){var n,r=t.length,a=[];if(e)for(n=0;n{var{typed:t,matrix:n,lup:r,slu:a,usolve:i,lsolve:s,DenseMatrix:o}=e,u=YX({DenseMatrix:o});return t(Q0,{"Array, Array | Matrix":function(e,t){e=n(e);var a=r(e);return c(a.L,a.U,a.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var n=r(e);return c(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var n=r(e);return c(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,n,r){var i=a(e,n,r);return c(i.L,i.U,i.p,i.q,t)},"Object, Array | Matrix":function(e,t){return c(e.L,e.U,e.p,e.q,t)}});function l(e){if(UP(e))return e;if(jP(e))return n(e);throw new TypeError("Invalid Matrix LU decomposition")}function c(e,t,n,r,a){e=l(e),t=l(t),n&&((a=u(e,a,!0))._data=Z0(n,a._data));var o=s(e,a),c=i(t,o);return r&&(c._data=Z0(r,c._data)),c}})),n1="median",r1=["typed","add","divide","compare","partitionSelect"],a1=YH(n1,r1,(e=>{var{typed:t,add:n,divide:r,compare:a,partitionSelect:i}=e;function s(e){try{var t=(e=mq(e.valueOf())).length;if(0===t)throw new Error("Cannot calculate median of an empty array");if(t%2==0){for(var n=t/2-1,r=i(e,n+1),s=e[n],l=0;l0&&(s=e[l]);return u(s,r)}var c=i(e,(t-1)/2);return o(c)}catch(e){throw vJ(e,"median")}}var o=t({"number | BigNumber | Complex | Unit":function(e){return e}}),u=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return r(n(e,t),2)}});return t(n1,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(Wq(e))throw new TypeError("Scalar values expected in function median");return s(e)}})})),i1="setUnion",s1=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],o1=YH(i1,s1,(e=>{var{typed:t,size:n,concat:r,subset:a,setIntersect:i,setSymDifference:s,Index:o}=e;return t(i1,{"Array | Matrix, Array | Matrix":function(e,t){if(0===a(n(e),new o(0)))return mq(t);if(0===a(n(t),new o(0)))return mq(e);var u=mq(e),l=mq(t);return r(s(u,l),i(u,l))}})})),u1="unbiased",l1="variance",c1=["typed","add","subtract","multiply","divide","apply","isNaN"],p1=YH(l1,c1,(e=>{var{typed:t,add:n,subtract:r,multiply:a,divide:i,apply:s,isNaN:o}=e;return t(l1,{"Array | Matrix":function(e){return u(e,u1)},"Array | Matrix, string":u,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,u1)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return u(e,u1)}});function u(e,t){var s,u=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Vq(e,(function(e){try{s=void 0===s?e:n(s,e),u++}catch(t){throw vJ(t,"variance",e)}})),0===u)throw new Error("Cannot calculate variance of an empty array");var l=i(s,u);if(s=void 0,Vq(e,(function(e){var t=r(e,l);s=void 0===s?a(t,t):n(s,a(t,t))})),o(s))return s;switch(t){case"uncorrected":return i(s,u);case"biased":return i(s,u+1);case"unbiased":var c=YP(s)?s.mul(0):0;return 1===u?c:i(s,u-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function l(e,t,n){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(e,t,(e=>u(e,n)))}catch(e){throw vJ(e,"variance")}}})),d1="kldivergence",h1=["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],f1=YH(d1,h1,(e=>{var{typed:t,matrix:n,divide:r,sum:a,multiply:i,dotDivide:s,log:o,isNumeric:u}=e;return t(d1,{"Array, Array":function(e,t){return l(n(e),n(t))},"Matrix, Array":function(e,t){return l(e,n(t))},"Array, Matrix":function(e,t){return l(n(e),t)},"Matrix, Matrix":function(e,t){return l(e,t)}});function l(e,t){var n=t.size().length,l=e.size().length;if(n>1)throw new Error("first object must be one dimensional");if(l>1)throw new Error("second object must be one dimensional");if(n!==l)throw new Error("Length of two vectors must be equal");if(0===a(e))throw new Error("Sum of elements in first object must be non zero");if(0===a(t))throw new Error("Sum of elements in second object must be non zero");var c=r(e,a(e)),p=r(t,a(t)),d=a(i(c,o(s(c,p))));return u(d)?d:Number.NaN}})),m1="norm",g1=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],y1=YH(m1,g1,(e=>{var{typed:t,abs:n,add:r,pow:a,conj:i,sqrt:s,multiply:o,equalScalar:u,larger:l,smaller:c,matrix:p,ctranspose:d,eigs:h}=e;return t(m1,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return f(p(e),2)},Matrix:function(e){return f(e,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(e){return this(e)},"Array, number | BigNumber | string":function(e,t){return f(p(e),t)},"Matrix, number | BigNumber | string":function(e,t){return f(e,t)}});function f(e,t){var p=e.size();if(1===p.length)return function(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=0;return e.forEach((function(e){var r=n(e);l(r,t)&&(t=r)}),!0),t}(e);if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return function(e){var t;return e.forEach((function(e){var r=n(e);t&&!c(r,t)||(t=r)}),!0),t||0}(e);if("fro"===t)return f(e,2);if("number"==typeof t&&!isNaN(t)){if(!u(t,0)){var i=0;return e.forEach((function(e){i=r(a(n(e),t),i)}),!0),a(i,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}(e,t);if(2===p.length){if(p[0]&&p[1])return function(e,t){if(1===t)return function(e){var t=[],a=0;return e.forEach((function(e,i){var s=i[1],o=r(t[s]||0,n(e));l(o,a)&&(a=o),t[s]=o}),!0),a}(e);if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=[],a=0;return e.forEach((function(e,i){var s=i[0],o=r(t[s]||0,n(e));l(o,a)&&(a=o),t[s]=o}),!0),a}(e);if("fro"===t)return function(e){var t=0;return e.forEach((function(e,n){t=r(t,o(e,i(e)))})),n(s(t))}(e);if(2===t)return function(e){var t=e.size();if(t[0]!==t[1])throw new RangeError("Invalid matrix dimensions");var r=d(e),a=o(r,e),i=h(a).values.toArray(),u=i[i.length-1];return n(s(u))}(e);throw new Error("Unsupported parameter value "+t)}(e,t);throw new RangeError("Invalid matrix dimensions")}}})),b1="rotationMatrix",x1=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],v1=YH(b1,x1,(e=>{var{typed:t,config:n,multiplyScalar:r,addScalar:a,unaryMinus:i,norm:s,BigNumber:o,matrix:u,DenseMatrix:l,SparseMatrix:c,cos:p,sin:d}=e;return t(b1,{"":function(){return"Matrix"===n.matrix?u([]):[]},string:function(e){return u(e)},"number | BigNumber | Complex | Unit":function(e){return h(e,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return h(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var n=u(t);return f(n),y(e,n,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){f(t);var r=t.storage()||("Matrix"===n.matrix?"dense":void 0);return y(e,t,r)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,n){var r=u(t);return f(r),y(e,r,n)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,n){return f(t),y(e,t,n)}});function h(e,t){var n=YP(e)?new o(-1):-1,a=p(e),i=d(e);return g([[a,r(n,i)],[i,a]],t)}function f(e){var t=e.size();if(t.length<1||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3")}function m(e){return e.reduce(((e,t)=>r(e,t)))}function g(e,t){if(t){if("sparse"===t)return new c(e);if("dense"===t)return new l(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function y(e,t,n){var r=s(t);if(0===r)throw new RangeError("Rotation around zero vector");var u=YP(e)?o:null,l=u?new u(1):1,c=u?new u(-1):-1,h=u?new u(t.get([0])/r):t.get([0])/r,f=u?new u(t.get([1])/r):t.get([1])/r,y=u?new u(t.get([2])/r):t.get([2])/r,b=p(e),x=a(l,i(b)),v=d(e);return g([[a(b,m([h,h,x])),a(m([h,f,x]),m([c,y,v])),a(m([h,y,x]),m([f,v]))],[a(m([h,f,x]),m([y,v])),a(b,m([f,f,x])),a(m([f,y,x]),m([c,h,v]))],[a(m([h,y,x]),m([c,f,v])),a(m([f,y,x]),m([h,v])),a(b,m([y,y,x]))]],n)}})),_1=["typed","sqrt","variance"],w1=YH("std",_1,(e=>{var{typed:t,sqrt:n,variance:r}=e;return t("std",{"Array | Matrix":a,"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":a,"Array | Matrix, number | BigNumber, string":a,"...":function(e){return a(e)}});function a(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return n(r.apply(null,arguments))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),M1=["typed","abs","map","median","subtract"],N1=YH("mad",M1,(e=>{var{typed:t,abs:n,map:r,median:a,subtract:i}=e;return t("mad",{"Array | Matrix":s,"...":function(e){return s(e)}});function s(e){if(0===(e=mq(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=a(e);return a(r(e,(function(e){return n(i(e,t))})))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):vJ(e,"mad")}}})),S1="rotate",k1=["typed","multiply","rotationMatrix"],D1=YH(S1,k1,(e=>{var{typed:t,multiply:n,rotationMatrix:r}=e;return t(S1,{"Array , number | BigNumber | Complex | Unit":function(e,t){return a(e,2),n(r(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return a(e,2),n(r(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,i){return a(e,3),n(r(t,i),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,i){return a(e,3),n(r(t,i),e)}});function a(e,t){var n=Array.isArray(e)?nq(e):e.size();if(n.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(t));if(2===n.length&&1!==n[1])throw new RangeError("Vector must be of dimensions 1x".concat(t));if(n[0]!==t)throw new RangeError("Vector must be of dimensions 1x".concat(t))}})),T1=PH({config:RH}),I1=pj({}),E1=Ej({BigNumber:T1,config:RH}),C1=Nj({}),A1=uU({BigNumber:T1,config:RH}),L1=HU({}),$1=Yj({Complex:I1}),O1=kj({BigNumber:T1,config:RH}),R1=Lj({BigNumber:T1,config:RH}),F1=Oj({BigNumber:T1,config:RH}),Y1=jU({}),z1=Dj({BigNumber:T1,config:RH}),B1=Sj({}),P1=Cj({BigNumber:T1,config:RH}),H1=UU({}),j1=qU({}),U1=Rj({BigNumber:T1,config:RH}),q1=DU({BigNumber:T1,config:RH}),W1=Ij({BigNumber:T1,config:RH}),V1=Mj({}),G1=Pj({}),K1=Sq({Matrix:Y1}),J1=yU({BigNumber:T1,config:RH}),X1=Aj({BigNumber:T1,config:RH}),Z1=Tj({BigNumber:T1,config:RH}),Q1=kq({}),e2=Fj({BigNumber:T1,config:RH}),t2=Pq({BigNumber:T1,Complex:I1,DenseMatrix:K1,Fraction:L1}),n2=_W({BigNumber:T1,config:RH,typed:t2}),r2=gU({BigNumber:T1,config:RH}),a2=wW({typed:t2}),i2=NW({Complex:I1,config:RH,typed:t2}),s2=jW({BigNumber:T1,typed:t2}),o2=qW({BigNumber:T1,Complex:I1,config:RH,typed:t2}),u2=VW({typed:t2}),l2=GW({typed:t2}),c2=JW({BigNumber:T1,Complex:I1,config:RH,typed:t2}),p2=XW({typed:t2}),d2=ZW({typed:t2}),h2=eV({Complex:I1,config:RH,typed:t2}),f2=tV({BigNumber:T1,typed:t2}),m2=xV({typed:t2}),g2=_V({typed:t2}),y2=MV({typed:t2}),b2=DV({typed:t2}),x2=IV({Complex:I1,typed:t2}),v2=CV({typed:t2}),_2=LV({typed:t2}),w2=OV({BigNumber:T1,typed:t2}),M2=RV({BigNumber:T1,typed:t2}),N2=YV({typed:t2}),S2=PV({config:RH,typed:t2}),k2=HV({typed:t2}),D2=GV({typed:t2}),T2=JV({Complex:I1,typed:t2}),I2=XV({typed:t2}),E2=eG({typed:t2}),C2=rG({typed:t2}),A2=iG({typed:t2}),L2=sG({format:C2,typed:t2}),$2=oG({typed:t2}),O2=lG({typed:t2}),R2=gG({typed:t2}),F2=bG({typed:t2}),Y2=vG({typed:t2}),z2=$j({BigNumber:T1,config:RH}),B2=TG({Complex:I1,typed:t2}),P2=EG({Complex:I1,config:RH,typed:t2}),H2=AG({Complex:I1,config:RH,typed:t2}),j2=LG({typed:t2}),U2=OG({typed:t2}),q2=PG({typed:t2}),W2=HG({typed:t2}),V2=jG({format:C2,typed:t2}),G2=VG({config:RH,typed:t2}),K2=KG({typed:t2}),J2=QG({config:RH,typed:t2}),X2=eK({typed:t2}),Z2=tK({BigNumber:T1,typed:t2}),Q2=rK({BigNumber:T1,Fraction:L1,complex:x2,typed:t2}),e3=aK({typed:t2}),t3=iK({Matrix:Y1,equalScalar:S2,typed:t2}),n3=oK({typed:t2}),r3=lK({typed:t2}),a3=pK({typed:t2}),i3=dK({typed:t2}),s3=fK({typed:t2}),o3=gK({Complex:I1,config:RH,typed:t2}),u3=bK({BigNumber:T1,typed:t2}),l3=vK({isInteger:O2,typed:t2}),c3=MK({BigNumber:T1,Complex:I1,config:RH,typed:t2}),p3=NK({format:C2,typed:t2}),d3=kK({typed:t2}),h3=TK({typed:t2}),f3=EK({BigNumber:T1,typed:t2}),m3=AK({typed:t2}),g3=$K({typed:t2}),y3=RK({config:RH,typed:t2}),b3=YK({BigNumber:T1,typed:t2}),x3=BK({typed:t2}),v3=HK({SparseMatrix:t3,typed:t2}),_3=jK({Complex:I1,config:RH,typed:t2}),w3=UK({typed:t2}),M3=WK({typed:t2}),N3=GK({BigNumber:T1,Complex:I1,config:RH,typed:t2}),S3=KK({BigNumber:T1,typed:t2}),k3=JK({Fraction:L1,typed:t2}),D3=ZK({typed:t2}),T3=eJ({DenseMatrix:K1,Matrix:Y1,SparseMatrix:t3,typed:t2}),I3=nJ({isZero:Y2,matrix:T3,typed:t2}),E3=cJ({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2}),C3=fJ({BigNumber:T1,equalScalar:S2,matrix:T3,typed:t2}),A3=bJ({bignumber:f2,fraction:k3,number:W2}),L3=xJ({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2}),$3=wJ({config:RH,multiplyScalar:U2,numeric:A3,typed:t2}),O3=NJ({isInteger:O2,matrix:T3,typed:t2}),R3=kJ({matrix:T3,config:RH,typed:t2}),F3=IJ({DenseMatrix:K1,config:RH,matrix:T3,typed:t2}),Y3=CJ({matrix:T3,typed:t2}),z3=LJ({matrix:T3,typed:t2}),B3=BJ({DenseMatrix:K1,addScalar:u2,equalScalar:S2,matrix:T3,typed:t2,unaryMinus:M3}),P3=HJ({matrix:T3,typed:t2}),H3=jJ({matrix:T3,typed:t2}),j3=qJ({BigNumber:T1,config:RH,matrix:T3,typed:t2}),U3=VJ({BigNumber:T1,config:RH,matrix:T3,typed:t2}),q3=GJ({equalScalar:S2,matrix:T3,not:q2,typed:t2,zeros:U3}),W3=JJ({equalScalar:S2,matrix:T3,typed:t2}),V3=ZJ({DenseMatrix:K1,matrix:T3,typed:t2}),G3=eX({BigNumber:T1,Complex:I1,Fraction:L1,config:RH,isNegative:R2,matrix:T3,typed:t2,unaryMinus:M3}),K3=nX({BigNumber:T1,DenseMatrix:K1,Fraction:L1,config:RH,equalScalar:S2,matrix:T3,typed:t2}),J3=aX({matrix:T3,typed:t2}),X3=sX({isInteger:O2,matrix:T3,typed:t2}),Z3=lX({prod:$3,size:R3,typed:t2}),Q3=pX({conj:v2,transpose:H3,typed:t2}),e4=hX({DenseMatrix:K1,SparseMatrix:t3,matrix:T3,typed:t2}),t4=mX({numeric:A3,typed:t2}),n4=yX({DenseMatrix:K1,divideScalar:t4,equalScalar:S2,matrix:T3,typed:t2}),r4=xX({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2}),a4=vX({addScalar:u2,divideScalar:t4,exp:D2,i:$1,matrix:T3,multiplyScalar:U2,tau:W1,typed:t2}),i4=wX({matrix:T3,typed:t2}),s4=NX({BigNumber:T1,DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2}),o4=kX({isNumeric:D3,typed:t2}),u4=TX({abs:a2,addScalar:u2,divideScalar:t4,isPositive:F2,multiplyScalar:U2,smaller:F3,sqrt:_3,typed:t2}),l4=EX({conj:v2,dotDivide:n4,fft:a4,typed:t2}),c4=AX({matrix:T3,multiplyScalar:U2,typed:t2}),p4=$X({DenseMatrix:K1,config:RH,matrix:T3,typed:t2}),d4=FX({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2,zeros:U3}),h4=BX({DenseMatrix:K1,divideScalar:t4,equalScalar:S2,matrix:T3,multiplyScalar:U2,subtract:B3,typed:t2}),f4=HX({flatten:i4,matrix:T3,size:R3,typed:t2}),m4=jX({config:RH,numeric:A3,smaller:F3,typed:t2}),g4=qX({isNaN:m3,isNumeric:D3,typed:t2}),y4=VX({Complex:I1,config:RH,divideScalar:t4,typed:t2}),b4=GX({BigNumber:T1,config:RH,matrix:T3,typed:t2}),x4=JX({compare:K3,isNaN:m3,isNumeric:D3,typed:t2}),v4=ZX({config:RH,matrix:T3}),_4=eZ({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2,zeros:U3}),w4=rZ({BigNumber:T1,DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2,zeros:U3}),M4=iZ({DenseMatrix:K1,config:RH,matrix:T3,typed:t2}),N4=oZ({DenseMatrix:K1,config:RH,equalScalar:S2,matrix:T3,typed:t2}),S4=lZ({DenseMatrix:K1,divideScalar:t4,equalScalar:S2,matrix:T3,multiplyScalar:U2,subtract:B3,typed:t2}),k4=cZ({DenseMatrix:K1,matrix:T3,typed:t2}),D4=pZ({DenseMatrix:K1,SparseMatrix:t3,addScalar:u2,equalScalar:S2,matrix:T3,typed:t2}),T4=fZ({BigNumber:T1,DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2}),I4=gZ({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2}),E4=bZ({addScalar:u2,combinations:b2,divideScalar:t4,isInteger:O2,isNegative:R2,multiplyScalar:U2,typed:t2}),C4=_Z({compare:K3,typed:t2}),A4=MZ({add:D4,typed:t2,unaryPlus:n2}),L4=SZ({equal:r4,typed:t2}),$4=DZ({matrix:T3,number:W2,subtract:B3,typed:t2}),O4=TZ({addScalar:u2,conj:v2,multiplyScalar:U2,size:R3,typed:t2}),R4=EZ({compareText:J3,isZero:Y2,typed:t2}),F4=$Z({DenseMatrix:K1,config:RH,equalScalar:S2,matrix:T3,round:w4,typed:t2,zeros:U3}),Y4=RZ({BigNumber:T1,DenseMatrix:K1,SparseMatrix:t3,config:RH,matrix:T3,typed:t2}),z4=YZ({BigNumber:T1,add:D4,config:RH,equal:r4,isInteger:O2,mod:E3,smaller:F3,typed:t2,xgcd:j3}),B4=BZ({DenseMatrix:K1,config:RH,matrix:T3,typed:t2}),P4=PZ({Complex:I1,config:RH,divideScalar:t4,typed:t2}),H4=jZ({DenseMatrix:K1,divideScalar:t4,equalScalar:S2,matrix:T3,multiplyScalar:U2,subtract:B3,typed:t2}),j4=qZ({flatten:i4,matrix:T3,size:R3,typed:t2}),U4=VZ({addScalar:u2,dot:O4,equalScalar:S2,matrix:T3,multiplyScalar:U2,typed:t2}),q4=GZ({addScalar:u2,complex:x2,conj:v2,divideScalar:t4,equal:r4,identity:Y4,isZero:Y2,matrix:T3,multiplyScalar:U2,sign:Q2,sqrt:_3,subtract:B3,typed:t2,unaryMinus:M3,zeros:U3}),W4=JZ({bignumber:f2,matrix:T3,config:RH,larger:B4,largerEq:p4,smaller:F3,smallerEq:M4,typed:t2}),V4=ZZ({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2,zeros:U3}),G4=eQ({compareNatural:C4,typed:t2}),K4=hQ({SparseMatrix:t3,abs:a2,add:D4,divideScalar:t4,larger:B4,largerEq:p4,multiply:U4,subtract:B3,transpose:H3,typed:t2}),J4=fQ({add:D4,config:RH,numeric:A3,typed:t2}),X4=mQ({add:D4,matrix:T3,typed:t2}),Z4=yQ({DenseMatrix:K1,divideScalar:t4,equalScalar:S2,matrix:T3,multiplyScalar:U2,subtract:B3,typed:t2}),Q4=xQ({Complex:I1,config:RH,typed:t2}),e5=MQ({DenseMatrix:K1,config:RH,equalScalar:S2,matrix:T3,round:w4,typed:t2,zeros:U3}),t5=SQ({addScalar:u2,combinations:b2,isInteger:O2,isNegative:R2,isPositive:F2,larger:B4,typed:t2}),n5=DQ({matrix:T3,multiply:U4,subtract:B3,typed:t2}),r5=TQ({divideScalar:t4,isZero:Y2,matrix:T3,multiply:U4,subtract:B3,typed:t2,unaryMinus:M3}),a5=EQ({abs:a2,addScalar:u2,divideScalar:t4,multiplyScalar:U2,sqrt:_3,subtract:B3,typed:t2,unaryMinus:M3}),i5=AQ({equalScalar:S2,matrix:T3,multiplyScalar:U2,typed:t2}),s5=LQ({larger:B4,smaller:F3}),o5=FQ({Complex:I1,DenseMatrix:K1,ceil:e5,equalScalar:S2,floor:F4,matrix:T3,typed:t2,zeros:U3}),u5=YQ({DenseMatrix:K1,smaller:F3}),l5=zQ({ImmutableDenseMatrix:u5}),c5=BQ({abs:a2,add:D4,addScalar:u2,config:RH,divideScalar:t4,equalScalar:S2,flatten:i4,isNumeric:D3,isZero:Y2,matrix:T3,multiply:U4,multiplyScalar:U2,smaller:F3,subtract:B3,typed:t2}),d5=PQ({equalScalar:S2,matrix:T3,typed:t2}),h5=jQ({Complex:I1,config:RH,divideScalar:t4,log:P4,typed:t2}),f5=UQ({config:RH,larger:B4,numeric:A3,typed:t2}),m5=qQ({add:D4,compare:K3,multiply:U4,partitionSelect:x4,typed:t2}),g5=WQ({Index:l5,matrix:T3,range:W4,typed:t2}),y5=GQ({DenseMatrix:K1,Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),b5=JQ({DenseMatrix:K1,Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),x5=ZQ({Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),v5=e0({Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),_5=n0({compare:K3,compareNatural:C4,matrix:T3,typed:t2}),w5=a0({Index:l5,matrix:T3,range:W4,typed:t2}),M5=s0({Index:l5,typed:t2}),N5=o0({abs:a2,addScalar:u2,det:r5,divideScalar:t4,identity:Y4,matrix:T3,multiply:U4,typed:t2,unaryMinus:M3}),S5=l0({Complex:I1,add:D4,ctranspose:Q3,deepEqual:L4,divideScalar:t4,dot:O4,dotDivide:n4,equal:r4,inv:N5,matrix:T3,multiply:U4,typed:t2}),k5=c0({Complex:I1,config:RH,fraction:k3,identity:Y4,inv:N5,matrix:T3,multiply:U4,number:W2,typed:t2}),D5=d0({DenseMatrix:K1,Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),T5=f0({Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),I5=m0({FibonacciHeap:s5,addScalar:u2,equalScalar:S2}),E5=y0({abs:a2,add:D4,identity:Y4,inv:N5,max:f5,multiply:U4,size:R3,sqrt:_3,subtract:B3,typed:t2}),C5=_0({BigNumber:T1,Complex:I1,Fraction:L1,abs:a2,addScalar:u2,config:RH,divideScalar:t4,equal:r4,fix:o5,format:C2,isNumeric:D3,multiplyScalar:U2,number:W2,pow:k5,round:w4,subtract:B3}),A5=Kj({BigNumber:T1,Unit:C5,config:RH}),L5=EU({BigNumber:T1,Unit:C5,config:RH}),$5=bU({BigNumber:T1,Unit:C5,config:RH}),O5=Zj({BigNumber:T1,Unit:C5,config:RH}),R5=vU({BigNumber:T1,Unit:C5,config:RH}),F5=Qj({BigNumber:T1,Unit:C5,config:RH}),Y5=M0({Unit:C5,typed:t2}),z5=pU({BigNumber:T1,Unit:C5,config:RH}),B5=S0({DenseMatrix:K1,equalScalar:S2,matrix:T3,pow:k5,typed:t2}),P5=Gj({BigNumber:T1,Unit:C5,config:RH}),H5=Xj({BigNumber:T1,Unit:C5,config:RH}),j5=D0({abs:a2,add:D4,identity:Y4,inv:N5,multiply:U4,typed:t2}),U5=_U({BigNumber:T1,Unit:C5,config:RH}),q5=wU({BigNumber:T1,Unit:C5,config:RH}),W5=I0({BigNumber:T1,Complex:I1,config:RH,multiplyScalar:U2,pow:k5,typed:t2}),V5=Uj({BigNumber:T1,Unit:C5,config:RH}),G5=lU({BigNumber:T1,Unit:C5,config:RH}),K5=rU({BigNumber:T1,Unit:C5,config:RH}),J5=MU({BigNumber:T1,Unit:C5,config:RH}),X5=Vj({BigNumber:T1,Unit:C5,config:RH}),Z5=CU({BigNumber:T1,Unit:C5,config:RH}),Q5=SU({BigNumber:T1,Unit:C5,config:RH}),e6=dU({BigNumber:T1,Unit:C5,config:RH}),t6=nU({BigNumber:T1,Unit:C5,config:RH}),n6=FU({BigNumber:T1,Unit:C5,config:RH}),r6=$U({BigNumber:T1,Unit:C5,config:RH}),a6=YU({BigNumber:T1,Unit:C5,config:RH}),i6=cU({BigNumber:T1,Unit:C5,config:RH}),s6=Wj({BigNumber:T1,Unit:C5,config:RH}),o6=fU({BigNumber:T1,Unit:C5,config:RH}),u6=C0({DenseMatrix:K1,Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),l6=jj({BigNumber:T1,Unit:C5,config:RH}),c6=IU({BigNumber:T1,Unit:C5,config:RH}),p6=mU({BigNumber:T1,Unit:C5,config:RH}),d6=xU({BigNumber:T1,Unit:C5,config:RH}),h6=aU({BigNumber:T1,Unit:C5,config:RH}),f6=Jj({BigNumber:T1,Unit:C5,config:RH}),m6=A0({divideScalar:t4,equalScalar:S2,inv:N5,matrix:T3,multiply:U4,typed:t2}),g6=sU({BigNumber:T1,Unit:C5,config:RH}),y6=$0({gamma:W5,typed:t2}),b6=LU({BigNumber:T1,Unit:C5,config:RH}),x6=eU({BigNumber:T1,Unit:C5,config:RH}),v6=O0({DenseMatrix:K1,Spa:I5,SparseMatrix:t3,abs:a2,addScalar:u2,divideScalar:t4,equalScalar:S2,larger:B4,matrix:T3,multiplyScalar:U2,subtract:B3,typed:t2,unaryMinus:M3}),_6=tU({BigNumber:T1,Unit:C5,config:RH}),w6=AU({BigNumber:T1,Unit:C5,config:RH}),M6=F0({add:D4,divide:m6,factorial:y6,isInteger:O2,isPositive:F2,multiply:U4,typed:t2}),N6=z0({factorial:y6,typed:t2}),S6=OU({BigNumber:T1,Unit:C5,config:RH}),k6=hU({BigNumber:T1,Unit:C5,config:RH}),D6=TU({BigNumber:T1,Unit:C5,config:RH}),T6=H0({bignumber:f2,addScalar:u2,combinations:b2,divideScalar:t4,factorial:y6,isInteger:O2,isNegative:R2,larger:B4,multiplyScalar:U2,number:W2,pow:k5,subtract:B3,typed:t2}),I6=U0({Unit:C5,typed:t2}),E6=W0({addScalar:u2,isInteger:O2,isNegative:R2,stirlingS2:T6,typed:t2}),C6=V0({abs:a2,add:D4,addScalar:u2,atan:d2,bignumber:f2,column:w5,complex:x2,config:RH,cos:h3,diag:e4,divideScalar:t4,dot:O4,equal:r4,flatten:i4,im:$2,inv:N5,larger:B4,matrix:T3,matrixFromColumns:f4,multiply:U4,multiplyScalar:U2,number:W2,qr:q4,re:X2,sin:e3,smaller:F3,sqrt:_3,subtract:B3,typed:t2,usolve:S4,usolveAll:Z4}),A6=oU({BigNumber:T1,Unit:C5,config:RH}),L6=K0({add:D4,divide:m6,typed:t2}),$6=kU({BigNumber:T1,Unit:C5,config:RH}),O6=qj({BigNumber:T1,Unit:C5,config:RH}),R6=X0({Index:l5,concat:X3,setDifference:D5,size:R3,subset:z3,typed:t2}),F6=iU({BigNumber:T1,Unit:C5,config:RH}),Y6=t1({DenseMatrix:K1,lsolve:h4,lup:v6,matrix:T3,slu:K4,typed:t2,usolve:S4}),z6=a1({add:D4,compare:K3,divide:m6,partitionSelect:x4,typed:t2}),B6=o1({Index:l5,concat:X3,setIntersect:u6,setSymDifference:R6,size:R3,subset:z3,typed:t2}),P6=p1({add:D4,apply:l3,divide:m6,isNaN:m3,multiply:U4,subtract:B3,typed:t2}),H6=f1({divide:m6,dotDivide:n4,isNumeric:D3,log:P4,matrix:T3,multiply:U4,sum:J4,typed:t2}),j6=y1({abs:a2,add:D4,conj:v2,ctranspose:Q3,eigs:C6,equalScalar:S2,larger:B4,matrix:T3,multiply:U4,pow:k5,smaller:F3,sqrt:_3,typed:t2}),U6=RU({BigNumber:T1,Unit:C5,config:RH}),q6=v1({BigNumber:T1,DenseMatrix:K1,SparseMatrix:t3,addScalar:u2,config:RH,cos:h3,matrix:T3,multiplyScalar:U2,norm:j6,sin:e3,typed:t2,unaryMinus:M3}),W6=NU({BigNumber:T1,Unit:C5,config:RH}),V6=w1({sqrt:_3,typed:t2,variance:P6}),G6=N1({abs:a2,map:j2,median:z6,subtract:B3,typed:t2}),K6=D1({multiply:U4,rotationMatrix:q6,typed:t2}),J6=YH("Chain",["?on","math"],(e=>{var{on:t,math:n}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");vH(e)?this.value=e.value:this.value=e}function a(e,t){IH(r.prototype,e,(function(){var e=t();if("function"==typeof e)return i(e)}))}function i(e){return function(){for(var t=[this.value],n=0;ne[t]))};for(var o in e)n(o)}var u,l};var s={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return r.createProxy(n),t&&t("import",(function(e,t,n){n||a(e,t)})),r}),{isClass:!0}),X6=new Set(["end"]),Z6=YH("Node",["mathWithTransform"],(e=>{var{mathWithTransform:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator")}return n.prototype.evaluate=function(e){return this.compile().evaluate(e)},n.prototype.type="Node",n.prototype.isNode=!0,n.prototype.comment="",n.prototype.compile=function(){var e=this._compile(t,{}),n={};return{evaluate:function(t){var r=Fq(t);return function(e){for(var t of[...X6])if(e.has(t))throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword')}(r),e(r,n,null)}}},n.prototype._compile=function(e,t){throw new Error("Method _compile should be implemented by type "+this.type)},n.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},n.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},n.prototype._ifNode=function(e){if(!fH(e))throw new TypeError("Callback function must return a Node");return e},n.prototype.traverse=function(e){e(this,null,null),function e(t,n){t.forEach((function(t,r,a){n(t,r,a),e(t,n)}))}(this,e)},n.prototype.transform=function(e){return function t(n,r,a){var i=e(n,r,a);return i!==n?i:n.map(t)}(this,null,null)},n.prototype.filter=function(e){var t=[];return this.traverse((function(n,r,a){e(n,r,a)&&t.push(n)})),t},n.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},n.prototype.cloneDeep=function(){return this.map((function(e){return e.cloneDeep()}))},n.prototype.equals=function(e){return!!e&&kH(this,e)},n.prototype.toString=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)},n.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},n.prototype.toHTML=function(e){var t=this._getCustomString(e);return void 0!==t?t:this.toHTML(e)},n.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},n.prototype.toTex=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)},n.prototype._toTex=function(e){throw new Error("_toTex not implemented for "+this.type)},n.prototype._getCustomString=function(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}},n.prototype.getIdentifier=function(){return this.type},n.prototype.getContent=function(){return this},n}),{isClass:!0,isNode:!0}),Q6=YH("ObjectNode",["Node"],(e=>{var{Node:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(t){return fH(e[t])}))))throw new TypeError("Object containing Nodes expected")}return n.prototype=new t,n.prototype.type="ObjectNode",n.prototype.isObjectNode=!0,n.prototype._compile=function(e,t){var n={};for(var r in this.properties)if(EH(this.properties,r)){var a=JU(r),i=JSON.parse(a);if(!Eq(this.properties,i))throw new Error('No access to property "'+i+'"');n[i]=this.properties[r]._compile(e,t)}return function(e,t,r){var a={};for(var i in n)EH(n,i)&&(a[i]=n[i](e,t,r));return a}},n.prototype.forEach=function(e){for(var t in this.properties)EH(this.properties,t)&&e(this.properties[t],"properties["+JU(t)+"]",this)},n.prototype.map=function(e){var t={};for(var r in this.properties)EH(this.properties,r)&&(t[r]=this._ifNode(e(this.properties[r],"properties["+JU(r)+"]",this)));return new n(t)},n.prototype.clone=function(){var e={};for(var t in this.properties)EH(this.properties,t)&&(e[t]=this.properties[t]);return new n(e)},n.prototype._toString=function(e){var t=[];for(var n in this.properties)EH(this.properties,n)&&t.push(JU(n)+": "+this.properties[n].toString(e));return"{"+t.join(", ")+"}"},n.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},n.fromJSON=function(e){return new n(e.properties)},n.prototype.toHTML=function(e){var t=[];for(var n in this.properties)EH(this.properties,n)&&t.push(''+XU(n)+':'+this.properties[n].toHTML(e));return'{'+t.join(',')+'}'},n.prototype._toTex=function(e){var t=[];for(var n in this.properties)EH(this.properties,n)&&t.push("\\mathbf{"+n+":} & "+this.properties[n].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(t.join("\n"),"\\end{array}\\right\\}")},n}),{isClass:!0,isNode:!0}),e7=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function t7(e,t){var n=e;"keep"!==t&&(n=e.getContent());for(var r=n.getIdentifier(),a=0;a>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},o7={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(s7.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(s7.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(s7.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(s7.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(s7.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(s7.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(s7.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(s7.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(s7.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(s7.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(s7.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(s7.bitAnd,"${args[1]}\\right)")},bitNot:{1:s7.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(s7.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(s7.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(s7.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(s7.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(s7.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(s7.and,"${args[1]}\\right)")},not:{1:s7.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(s7.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(s7.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(s7.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:"{${args[0]}}".concat(s7.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(s7.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(s7.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(s7.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(s7.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(s7.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(s7.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(s7.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(s7.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(s7.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(i7.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},u7={deg:"^\\circ"};function l7(e){return a7(e,{preserveFormatting:!0})}function c7(e,t){return(t=void 0!==t&&t)?EH(u7,e)?u7[e]:"\\mathrm{"+l7(e)+"}":EH(i7,e)?i7[e]:l7(e)}var p7=YH("OperatorNode",["Node"],(e=>{var{Node:t}=e;function n(e,t,r,a,i){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(r)||!r.every(fH))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===a,this.isPercentage=!0===i,this.op=e,this.fn=t,this.args=r||[]}function r(e,t,n,r,a){var i,s=t7(e,t),o=n7(e,t);if("all"===t||r.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return r.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(r.length){case 0:i=[];break;case 1:var u=t7(r[0],t);if(a&&null!==u){var l,c;if("keep"===t?(l=r[0].getIdentifier(),c=e.getIdentifier()):(l=r[0].getContent().getIdentifier(),c=e.getContent().getIdentifier()),!1===e7[s][c].latexLeftParens){i=[!1];break}if(!1===e7[u][l].latexParens){i=[!1];break}}if(null===u){i=[!1];break}if(u<=s){i=[!0];break}i=[!1];break;case 2:var p,d,h=t7(r[0],t),f=r7(e,r[0],t);p=null!==h&&(h===s&&"right"===o&&!f||h=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"auto"===t&&"hide"===n&&(i=r.map((function(e,t){var n="ParenthesisNode"===e.getIdentifier();return!(!i[t]&&!n)}))),i}return n.prototype=new t,n.prototype.type="OperatorNode",n.prototype.isOperatorNode=!0,n.prototype._compile=function(e,t){if("string"!=typeof this.fn||!Cq(e,this.fn))throw e[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var n=Tq(e,this.fn),r=gq(this.args,(function(n){return n._compile(e,t)}));if(1===r.length){var a=r[0];return function(e,t,r){return n(a(e,t,r))}}if(2===r.length){var i=r[0],s=r[1];return function(e,t,r){return n(i(e,t,r),s(e,t,r))}}return function(e,t,a){return n.apply(null,gq(r,(function(n){return n(e,t,a)})))}},n.prototype.forEach=function(e){for(var t=0;t2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var p=a.map((function(t,n){return t=t.toString(e),i[n]&&(t="("+t+")"),t}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?p.join(" "):p.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"},n.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}},n.fromJSON=function(e){return new n(e.op,e.fn,e.args,e.implicit,e.isPercentage)},n.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=e&&e.implicit?e.implicit:"hide",a=this.args,i=r(this,t,n,a,!1);if(1===a.length){var s=n7(this,t),o=a[0].toHTML(e);return i[0]&&(o='('+o+')'),"right"===s?''+XU(this.op)+""+o:o+''+XU(this.op)+""}if(2===a.length){var u=a[0].toHTML(e),l=a[1].toHTML(e);return i[0]&&(u='('+u+')'),i[1]&&(l='('+l+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?u+''+l:u+''+XU(this.op)+""+l}var c=a.map((function(t,n){return t=t.toHTML(e),i[n]&&(t='('+t+')'),t}));return a.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?c.join(''):c.join(''+XU(this.op)+""):''+XU(this.fn)+'('+c.join(',')+')'},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=e&&e.implicit?e.implicit:"hide",a=this.args,i=r(this,t,n,a,!0),s=s7[this.fn];if(s=void 0===s?this.op:s,1===a.length){var o=n7(this,t),u=a[0].toTex(e);return i[0]&&(u="\\left(".concat(u,"\\right)")),"right"===o?s+u:u+s}if(2===a.length){var l=a[0],c=l.toTex(e);i[0]&&(c="\\left(".concat(c,"\\right)"));var p,d=a[1].toTex(e);switch(i[1]&&(d="\\left(".concat(d,"\\right)")),p="keep"===t?l.getIdentifier():l.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return s+"{"+c+"}{"+d+"}";case"OperatorNode:pow":switch(c="{"+c+"}",d="{"+d+"}",p){case"ConditionalNode":case"OperatorNode:divide":c="\\left(".concat(c,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===n)return c+"~"+d}return c+s+d}if(a.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var h=a.map((function(t,n){return t=t.toTex(e),i[n]&&(t="\\left(".concat(t,"\\right)")),t}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit?h.join("~"):h.join(s)}return"\\mathrm{"+this.fn+"}\\left("+a.map((function(t){return t.toTex(e)})).join(",")+"\\right)"},n.prototype.getIdentifier=function(){return this.type+":"+this.fn},n}),{isClass:!0,isNode:!0}),d7=YH("ParenthesisNode",["Node"],(e=>{var{Node:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!fH(e))throw new TypeError('Node expected for parameter "content"');this.content=e}return n.prototype=new t,n.prototype.type="ParenthesisNode",n.prototype.isParenthesisNode=!0,n.prototype._compile=function(e,t){return this.content._compile(e,t)},n.prototype.getContent=function(){return this.content.getContent()},n.prototype.forEach=function(e){e(this.content,"content",this)},n.prototype.map=function(e){return new n(e(this.content,"content",this))},n.prototype.clone=function(){return new n(this.content)},n.prototype._toString=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},n.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},n.fromJSON=function(e){return new n(e.content)},n.prototype.toHTML=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'('+this.content.toHTML(e)+')':this.content.toHTML(e)},n.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},n}),{isClass:!0,isNode:!0}),h7=YH("RelationalNode",["Node"],(e=>{var{Node:t}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return n.prototype=new t,n.prototype.type="RelationalNode",n.prototype.isRelationalNode=!0,n.prototype._compile=function(e,t){var n=this,r=this.params.map((n=>n._compile(e,t)));return function(t,a,i){for(var s,o=r[0](t,a,i),u=0;ue(t,"params["+n+"]",this)),this)},n.prototype.map=function(e){return new n(this.conditionals.slice(),this.params.map(((t,n)=>this._ifNode(e(t,"params["+n+"]",this))),this))},n.prototype.clone=function(){return new n(this.conditionals,this.params)},n.prototype._toString=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",n=t7(this,t),r=this.params.map((function(r,a){var i=t7(r,t);return"all"===t||null!==i&&i<=n?"("+r.toString(e)+")":r.toString(e)})),a={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},i=r[0],s=0;s('+r.toHTML(e)+')':r.toHTML(e)})),a={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},i=r[0],s=0;s'+XU(a[this.conditionals[s]])+""+r[s+1];return i},n.prototype._toTex=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",n=t7(this,t),r=this.params.map((function(r,a){var i=t7(r,t);return"all"===t||null!==i&&i<=n?"\\left("+r.toTex(e)+"\right)":r.toTex(e)})),a=r[0],i=0;i{var{Node:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(fH))throw new TypeError("Array containing Nodes expected")}return n.prototype=new t,n.prototype.type="ArrayNode",n.prototype.isArrayNode=!0,n.prototype._compile=function(e,t){var n=gq(this.items,(function(n){return n._compile(e,t)}));if("Array"!==e.config.matrix){var r=e.matrix;return function(e,t,a){return r(gq(n,(function(n){return n(e,t,a)})))}}return function(e,t,r){return gq(n,(function(n){return n(e,t,r)}))}},n.prototype.forEach=function(e){for(var t=0;t['+this.items.map((function(t){return t.toHTML(e)})).join(',')+']'},n.prototype._toTex=function(e){return function t(n,r){var a=n.some(sH)&&!n.every(sH),i=r||a,s=i?"&":"\\\\",o=n.map((function(n){return n.items?t(n.items,!r):n.toTex(e)})).join(s);return a||!i||i&&!r?"\\begin{bmatrix}"+o+"\\end{bmatrix}":o}(this.items,!1)},n}),{isClass:!0,isNode:!0}),m7=YH("BlockNode",["ResultSet","Node"],(e=>{var{ResultSet:t,Node:n}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map((function(e){var t=e&&e.node,n=!e||void 0===e.visible||e.visible;if(!fH(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof n)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:n}}))}return r.prototype=new n,r.prototype.type="BlockNode",r.prototype.isBlockNode=!0,r.prototype._compile=function(e,n){var r=gq(this.blocks,(function(t){return{evaluate:t.node._compile(e,n),visible:t.visible}}));return function(e,n,a){var i=[];return yq(r,(function(t){var r=t.evaluate(e,n,a);t.visible&&i.push(r)})),new t(i)}},r.prototype.forEach=function(e){for(var t=0;t;')})).join('
')},r.prototype._toTex=function(e){return this.blocks.map((function(t){return t.node.toTex(e)+(t.visible?"":";")})).join("\\;\\;\n")},r}),{isClass:!0,isNode:!0}),g7=YH("ConditionalNode",["Node"],(e=>{var{Node:t}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!fH(e))throw new TypeError("Parameter condition must be a Node");if(!fH(t))throw new TypeError("Parameter trueExpr must be a Node");if(!fH(r))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=r}return n.prototype=new t,n.prototype.type="ConditionalNode",n.prototype.isConditionalNode=!0,n.prototype._compile=function(e,t){var n=this.condition._compile(e,t),r=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,i){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(YP(e))return!e.isZero();if(zP(e))return!(!e.re&&!e.im);if(PP(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+_H(e)+'"')}(n(e,t,i))?r(e,t,i):a(e,t,i)}},n.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},n.prototype.map=function(e){return new n(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},n.prototype.clone=function(){return new n(this.condition,this.trueExpr,this.falseExpr)},n.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=t7(this,t),r=this.condition.toString(e),a=t7(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==a&&a<=n)&&(r="("+r+")");var i=this.trueExpr.toString(e),s=t7(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==s&&s<=n)&&(i="("+i+")");var o=this.falseExpr.toString(e),u=t7(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=n)&&(o="("+o+")"),r+" ? "+i+" : "+o},n.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},n.fromJSON=function(e){return new n(e.condition,e.trueExpr,e.falseExpr)},n.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=t7(this,t),r=this.condition.toHTML(e),a=t7(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==a&&a<=n)&&(r='('+r+')');var i=this.trueExpr.toHTML(e),s=t7(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==s&&s<=n)&&(i='('+i+')');var o=this.falseExpr.toHTML(e),u=t7(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=n)&&(o='('+o+')'),r+'?'+i+':'+o},n.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},n}),{isClass:!0,isNode:!0}),y7=YH("ConstantNode",["Node"],(e=>{var{Node:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return n.prototype=new t,n.prototype.type="ConstantNode",n.prototype.isConstantNode=!0,n.prototype._compile=function(e,t){var n=this.value;return function(){return n}},n.prototype.forEach=function(e){},n.prototype.map=function(e){return this.clone()},n.prototype.clone=function(){return new n(this.value)},n.prototype._toString=function(e){return KU(this.value,e)},n.prototype.toHTML=function(e){var t=this._toString(e);switch(_H(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}},n.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},n.fromJSON=function(e){return new n(e.value)},n.prototype._toTex=function(e){var t=this._toString(e);switch(_H(this.value)){case"string":return"\\mathtt{"+l7(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var n=t.toLowerCase().indexOf("e");return-1!==n?t.substring(0,n)+"\\cdot10^{"+t.substring(n+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},n}),{isClass:!0,isNode:!0}),b7=YH("RangeNode",["Node"],(e=>{var{Node:t}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!fH(e))throw new TypeError("Node expected");if(!fH(t))throw new TypeError("Node expected");if(r&&!fH(r))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=r||null}function r(e,t){var n=t7(e,t),r={},a=t7(e.start,t);if(r.start=null!==a&&a<=n||"all"===t,e.step){var i=t7(e.step,t);r.step=null!==i&&i<=n||"all"===t}var s=t7(e.end,t);return r.end=null!==s&&s<=n||"all"===t,r}return n.prototype=new t,n.prototype.type="RangeNode",n.prototype.isRangeNode=!0,n.prototype.needsEnd=function(){return this.filter((function(e){return xH(e)&&"end"===e.name})).length>0},n.prototype._compile=function(e,t){var n=e.range,r=this.start._compile(e,t),a=this.end._compile(e,t);if(this.step){var i=this.step._compile(e,t);return function(e,t,s){return n(r(e,t,s),a(e,t,s),i(e,t,s))}}return function(e,t,i){return n(r(e,t,i),a(e,t,i))}},n.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},n.prototype.map=function(e){return new n(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},n.prototype.clone=function(){return new n(this.start,this.end,this.step&&this.step)},n.prototype._toString=function(e){var t,n=r(this,e&&e.parenthesis?e.parenthesis:"keep"),a=this.start.toString(e);if(n.start&&(a="("+a+")"),t=a,this.step){var i=this.step.toString(e);n.step&&(i="("+i+")"),t+=":"+i}var s=this.end.toString(e);return n.end&&(s="("+s+")"),t+":"+s},n.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},n.fromJSON=function(e){return new n(e.start,e.end,e.step)},n.prototype.toHTML=function(e){var t,n=r(this,e&&e.parenthesis?e.parenthesis:"keep"),a=this.start.toHTML(e);if(n.start&&(a='('+a+')'),t=a,this.step){var i=this.step.toHTML(e);n.step&&(i='('+i+')'),t+=':'+i}var s=this.end.toHTML(e);return n.end&&(s='('+s+')'),t+':'+s},n.prototype._toTex=function(e){var t=r(this,e&&e.parenthesis?e.parenthesis:"keep"),n=this.start.toTex(e);if(t.start&&(n="\\left(".concat(n,"\\right)")),this.step){var a=this.step.toTex(e);t.step&&(a="\\left(".concat(a,"\\right)")),n+=":"+a}var i=this.end.toTex(e);return t.end&&(i="\\left(".concat(i,"\\right)")),n+":"+i},n}),{isClass:!0,isNode:!0}),x7=YH("reviver",["classes"],(e=>{var{classes:t}=e;return function(e,n){var r=t[n&&n.mathjs];return r&&"function"==typeof r.fromJSON?r.fromJSON(n):n}})),v7="chain",_7=YH(v7,["typed","Chain"],(e=>{var{typed:t,Chain:n}=e;return t(v7,{"":function(){return new n},any:function(e){return new n(e)}})})),w7=YH("FunctionAssignmentNode",["typed","Node"],(e=>{var{typed:t,Node:n}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!fH(n))throw new TypeError('Node expected for parameter "expr"');if(X6.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map((function(e){return e&&e.name||e})),this.types=t.map((function(e){return e&&e.type||"any"})),this.expr=n}function a(e,t){var n=t7(e,t),r=t7(e.expr,t);return"all"===t||null!==r&&r<=n}return r.prototype=new n,r.prototype.type="FunctionAssignmentNode",r.prototype.isFunctionAssignmentNode=!0,r.prototype._compile=function(e,n){var r=Object.create(n);yq(this.params,(function(e){r[e]=!0}));var a=this.expr._compile(e,r),i=this.name,s=this.params,o=vq(this.types,","),u=i+"("+vq(this.params,", ")+")";return function(e,n,r){var l={};l[o]=function(){for(var t=Object.create(n),i=0;i'+XU(this.params[r])+"");var i=this.expr.toHTML(e);return a(this,t)&&(i='('+i+')'),''+XU(this.name)+'('+n.join(',')+')='+i},r.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=this.expr.toTex(e);return a(this,t)&&(n="\\left(".concat(n,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(c7).join(",")+"\\right):="+n},r}),{isClass:!0,isNode:!0});function M7(e){return e&&e.isIndexError?new tq(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function N7(e){var{subset:t}=e;return function(e,n){try{if(Array.isArray(e))return t(e,n);if(e&&"function"==typeof e.subset)return e.subset(n);if("string"==typeof e)return t(e,n);if("object"==typeof e){if(!n.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Tq(e,n.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw M7(e)}}}var S7=YH("AccessorNode",["subset","Node"],(e=>{var{subset:t,Node:n}=e,r=N7({subset:t});function a(e,t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!fH(e))throw new TypeError('Node expected for parameter "object"');if(!hH(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e||null,this.index=t,Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function i(e){return!(iH(e)||sH(e)||cH(e)||dH(e)||mH(e)||yH(e)||xH(e))}return a.prototype=new n,a.prototype.type="AccessorNode",a.prototype.isAccessorNode=!0,a.prototype._compile=function(e,t){var n=this.object._compile(e,t),a=this.index._compile(e,t);if(this.index.isObjectProperty()){var i=this.index.getObjectProperty();return function(e,t,r){return Tq(n(e,t,r),i)}}return function(e,t,i){var s=n(e,t,i),o=a(e,t,s);return r(s,o)}},a.prototype.forEach=function(e){e(this.object,"object",this),e(this.index,"index",this)},a.prototype.map=function(e){return new a(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))},a.prototype.clone=function(){return new a(this.object,this.index)},a.prototype._toString=function(e){var t=this.object.toString(e);return i(this.object)&&(t="("+t+")"),t+this.index.toString(e)},a.prototype.toHTML=function(e){var t=this.object.toHTML(e);return i(this.object)&&(t='('+t+')'),t+this.index.toHTML(e)},a.prototype._toTex=function(e){var t=this.object.toTex(e);return i(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},a.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},a.fromJSON=function(e){return new a(e.object,e.index)},a}),{isClass:!0,isNode:!0}),k7=YH("AssignmentNode",["subset","?matrix","Node"],(e=>{var{subset:t,matrix:n,Node:r}=e,a=N7({subset:t}),i=function(e){var{subset:t,matrix:n}=e;return function(e,r,a){try{if(Array.isArray(e))return n(e).subset(r,a).valueOf();if(e&&"function"==typeof e.subset)return e.subset(r,a);if("string"==typeof e)return t(e,r,a);if("object"==typeof e){if(!r.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return Iq(e,r.getObjectProperty(),a),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw M7(e)}}}({subset:t,matrix:n});function s(e,t,n){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=e,this.index=n?t:null,this.value=n||t,!xH(e)&&!iH(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(xH(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!hH(this.index))throw new TypeError('IndexNode expected as "index"');if(!fH(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function o(e,t){t||(t="keep");var n=t7(e,t),r=t7(e.value,t);return"all"===t||null!==r&&r<=n}return s.prototype=new r,s.prototype.type="AssignmentNode",s.prototype.isAssignmentNode=!0,s.prototype._compile=function(e,t){var n=this.object._compile(e,t),r=this.index?this.index._compile(e,t):null,s=this.value._compile(e,t),o=this.object.name;if(this.index){if(this.index.isObjectProperty()){var u=this.index.getObjectProperty();return function(e,t,r){var a=n(e,t,r),i=s(e,t,r);return Iq(a,u,i),i}}if(xH(this.object))return function(e,t,a){var u=n(e,t,a),l=s(e,t,a),c=r(e,t,u);return e.set(o,i(u,c,l)),l};var l=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var c=this.object.index.getObjectProperty();return function(e,t,n){var a=l(e,t,n),o=Tq(a,c),u=r(e,t,o),p=s(e,t,n);return Iq(a,c,i(o,u,p)),p}}var p=this.object.index._compile(e,t);return function(e,t,n){var o=l(e,t,n),u=p(e,t,o),c=a(o,u),d=r(e,t,c),h=s(e,t,n);return i(o,u,i(c,d,h)),h}}if(!xH(this.object))throw new TypeError("SymbolNode expected as object");return function(e,t,n){var r=s(e,t,n);return e.set(o,r),r}},s.prototype.forEach=function(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)},s.prototype.map=function(e){return new s(this._ifNode(e(this.object,"object",this)),this.index?this._ifNode(e(this.index,"index",this)):null,this._ifNode(e(this.value,"value",this)))},s.prototype.clone=function(){return new s(this.object,this.index,this.value)},s.prototype._toString=function(e){var t=this.object.toString(e),n=this.index?this.index.toString(e):"",r=this.value.toString(e);return o(this,e&&e.parenthesis)&&(r="("+r+")"),t+n+" = "+r},s.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},s.fromJSON=function(e){return new s(e.object,e.index,e.value)},s.prototype.toHTML=function(e){var t=this.object.toHTML(e),n=this.index?this.index.toHTML(e):"",r=this.value.toHTML(e);return o(this,e&&e.parenthesis)&&(r='('+r+')'),t+n+'='+r},s.prototype._toTex=function(e){var t=this.object.toTex(e),n=this.index?this.index.toTex(e):"",r=this.value.toTex(e);return o(this,e&&e.parenthesis)&&(r="\\left(".concat(r,"\\right)")),t+n+":="+r},s}),{isClass:!0,isNode:!0}),D7=YH("IndexNode",["Node","size"],(e=>{var{Node:t,size:n}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(fH))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}return r.prototype=new t,r.prototype.type="IndexNode",r.prototype.isIndexNode=!0,r.prototype._compile=function(e,t){var r=gq(this.dimensions,(function(r,a){if(r.filter((e=>e.isSymbolNode&&"end"===e.name)).length>0){var i=Object.create(t);i.end=!0;var s=r._compile(e,i);return function(e,t,r){if(!UP(r)&&!jP(r)&&!HP(r))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+_H(r));var i=n(r).valueOf(),o=Object.create(t);return o.end=i[a],s(e,o,r)}}return r._compile(e,t)})),a=Tq(e,"index");return function(e,t,n){var i=gq(r,(function(r){return r(e,t,n)}));return a(...i)}},r.prototype.forEach=function(e){for(var t=0;t.'+XU(this.getObjectProperty())+"":'['+t.join(',')+']'},r.prototype._toTex=function(e){var t=this.dimensions.map((function(t){return t.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+t.join(",")+"}"},r}),{isClass:!0,isNode:!0}),T7=YH("SymbolNode",["math","?Unit","Node"],(e=>{var{math:t,Unit:n,Node:r}=e;function a(e){return!!n&&n.isValuelessUnit(e)}function i(e){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}return i.prototype=new r,i.prototype.type="SymbolNode",i.prototype.isSymbolNode=!0,i.prototype._compile=function(e,t){var r=this.name;if(!0===t[r])return function(e,t,n){return t[r]};if(r in e)return function(t,n,a){return t.has(r)?t.get(r):Tq(e,r)};var s=a(r);return function(e,t,a){return e.has(r)?e.get(r):s?new n(null,r):i.onUndefinedSymbol(r)}},i.prototype.forEach=function(e){},i.prototype.map=function(e){return this.clone()},i.onUndefinedSymbol=function(e){throw new Error("Undefined symbol "+e)},i.prototype.clone=function(){return new i(this.name)},i.prototype._toString=function(e){return this.name},i.prototype.toHTML=function(e){var t=XU(this.name);return"true"===t||"false"===t?''+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},i.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},i.fromJSON=function(e){return new i(e.name)},i.prototype._toTex=function(e){var n=!1;void 0===t[this.name]&&a(this.name)&&(n=!0);var r=c7(this.name,n);return"\\"===r[0]?r:" "+r},i}),{isClass:!0,isNode:!0});function I7(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{var{math:t,Node:n,SymbolNode:r}=e;function a(e,t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"==typeof e&&(e=new r(e)),!fH(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(fH))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[],Object.defineProperty(this,"name",{get:function(){return this.fn.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}a.prototype=new n,a.prototype.type="FunctionNode",a.prototype.isFunctionNode=!0;var i=e=>KU(e,{truncate:78});a.prototype._compile=function(e,t){if(!(this instanceof a))throw new TypeError("No valid FunctionNode");var n=this.args.map((n=>n._compile(e,t)));if(!xH(this.fn)){if(iH(this.fn)&&hH(this.fn.index)&&this.fn.index.isObjectProperty()){var r=this.fn.object._compile(e,t),s=this.fn.index.getObjectProperty(),o=this.args;return function(t,a,i){var u=r(t,a,i);if(function(e,t){if(!Cq(e,t))throw new Error('No access to method "'+t+'"')}(u,s),u[s]&&u[s].rawArgs)return u[s](o,e,I7(t,a),t);var l=n.map((e=>e(t,a,i)));return u[s].apply(u,l)}}var u=this.fn.toString(),l=this.fn._compile(e,t),c=this.args;return function(t,r,a){var s=l(t,r,a);if("function"!=typeof s)throw new TypeError("Expression '".concat(u,"' did not evaluate to a function; value is:")+"\n ".concat(i(s)));if(s.rawArgs)return s(c,e,I7(t,r),t);var o=n.map((e=>e(t,r,a)));return s.apply(s,o)}}var p=this.fn.name;if(t[p]){var d=this.args;return function(t,r,a){var s=r[p];if("function"!=typeof s)throw new TypeError("Argument '".concat(p,"' was not a function; received: ").concat(i(s)));if(s.rawArgs)return s(d,e,I7(t,r),t);var o=n.map((e=>e(t,r,a)));return s.apply(s,o)}}var h=p in e?Tq(e,p):void 0,f="function"==typeof h&&!0===h.rawArgs,m=t=>{var n;if(t.has(p))n=t.get(p);else{if(!(p in e))return a.onUndefinedFunction(p);n=Tq(e,p)}if("function"==typeof n)return n;throw new TypeError("'".concat(p,"' is not a function; its value is:\n ").concat(i(n)))};if(f){var g=this.args;return function(t,n,r){return m(t)(g,e,I7(t,n),t)}}switch(n.length){case 0:return function(e,t,n){return m(e)()};case 1:return function(e,t,r){return m(e)((0,n[0])(e,t,r))};case 2:return function(e,t,r){var a=m(e),i=n[0],s=n[1];return a(i(e,t,r),s(e,t,r))};default:return function(e,t,r){return m(e)(...n.map((n=>n(e,t,r))))}}},a.prototype.forEach=function(e){e(this.fn,"fn",this);for(var t=0;t'+XU(this.fn)+'('+t.join(',')+')'};var u=a.prototype.toTex;return a.prototype.toTex=function(e){var t;return e&&"object"==typeof e.handler&&EH(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:u.call(this,e)},a.prototype._toTex=function(e){var n,r,a=this.args.map((function(t){return t.toTex(e)}));switch(o7[this.name]&&(n=o7[this.name]),!t[this.name]||"function"!=typeof t[this.name].toTex&&"object"!=typeof t[this.name].toTex&&"string"!=typeof t[this.name].toTex||(n=t[this.name].toTex),typeof n){case"function":r=n(this,e);break;case"string":r=o(n,this,e);break;case"object":switch(typeof n[a.length]){case"function":r=n[a.length](this,e);break;case"string":r=o(n[a.length],this,e)}}return void 0!==r?r:o("\\mathrm{${name}}\\left(${args}\\right)",this,e)},a.prototype.getIdentifier=function(){return this.type+":"+this.name},a}),{isClass:!0,isNode:!0}),C7="parse",A7=YH(C7,["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],(e=>{var{typed:t,numeric:n,config:r,AccessorNode:a,ArrayNode:i,AssignmentNode:s,BlockNode:o,ConditionalNode:u,ConstantNode:l,FunctionAssignmentNode:c,FunctionNode:p,IndexNode:d,ObjectNode:h,OperatorNode:f,ParenthesisNode:m,RangeNode:g,RelationalNode:y,SymbolNode:b}=e,x=t(C7,{string:function(e){return $(e,{})},"Array | Matrix":function(e){return v(e,{})},"string, Object":function(e,t){return $(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":v});function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=void 0!==t.nodes?t.nodes:{};return Gq(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return $(e,n)}))}var _={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},w={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},M={true:!0,false:!1,null:null,undefined:void 0},N=["NaN","Infinity"];function S(e,t){return e.expression.substr(e.index,t)}function k(e){return S(e,1)}function D(e){e.index++}function T(e){return e.expression.charAt(e.index-1)}function I(e){return e.expression.charAt(e.index+1)}function E(e){for(e.tokenType=0,e.token="",e.comment="";;){if("#"===k(e))for(;"\n"!==k(e)&&""!==k(e);)e.comment+=k(e),D(e);if(!x.isWhitespace(k(e),e.nestingLevel))break;D(e)}if(""!==k(e)){if("\n"===k(e)&&!e.nestingLevel)return e.tokenType=1,e.token=k(e),void D(e);var t=k(e),n=S(e,2),r=S(e,3);if(3===r.length&&_[r])return e.tokenType=1,e.token=r,D(e),D(e),void D(e);if(2===n.length&&_[n])return e.tokenType=1,e.token=n,D(e),void D(e);if(_[t])return e.tokenType=1,e.token=t,void D(e);if(x.isDigitDot(t)){e.tokenType=2;var a=S(e,2);if("0b"===a||"0o"===a||"0x"===a){for(e.token+=k(e),D(e),e.token+=k(e),D(e);x.isHexDigit(k(e));)e.token+=k(e),D(e);if("."===k(e))for(e.token+=".",D(e);x.isHexDigit(k(e));)e.token+=k(e),D(e);else if("i"===k(e))for(e.token+="i",D(e);x.isDigit(k(e));)e.token+=k(e),D(e);return}if("."===k(e)){if(e.token+=k(e),D(e),!x.isDigit(k(e)))return void(e.tokenType=1)}else{for(;x.isDigit(k(e));)e.token+=k(e),D(e);x.isDecimalMark(k(e),I(e))&&(e.token+=k(e),D(e))}for(;x.isDigit(k(e));)e.token+=k(e),D(e);if("E"===k(e)||"e"===k(e))if(x.isDigit(I(e))||"-"===I(e)||"+"===I(e)){if(e.token+=k(e),D(e),"+"!==k(e)&&"-"!==k(e)||(e.token+=k(e),D(e)),!x.isDigit(k(e)))throw ne(e,'Digit expected, got "'+k(e)+'"');for(;x.isDigit(k(e));)e.token+=k(e),D(e);if(x.isDecimalMark(k(e),I(e)))throw ne(e,'Digit expected, got "'+k(e)+'"')}else if("."===I(e))throw D(e),ne(e,'Digit expected, got "'+k(e)+'"')}else{if(!x.isAlpha(k(e),T(e),I(e))){for(e.tokenType=4;""!==k(e);)e.token+=k(e),D(e);throw ne(e,'Syntax error in part "'+e.token+'"')}for(;x.isAlpha(k(e),T(e),I(e))||x.isDigit(k(e));)e.token+=k(e),D(e);EH(w,e.token)?e.tokenType=1:e.tokenType=3}}else e.tokenType=1}function C(e){do{E(e)}while("\n"===e.token)}function A(e){e.nestingLevel++}function L(e){e.nestingLevel--}function $(e,t){var n={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:0,nestingLevel:0,conditionalLevel:null};OP(n,{expression:e,extraNodes:t}),E(n);var r=function(e){var t,n,r=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=O(e)).comment=e.comment);"\n"===e.token||";"===e.token;)0===r.length&&t&&(n=";"!==e.token,r.push({node:t,visible:n})),E(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=O(e)).comment=e.comment,n=";"!==e.token,r.push({node:t,visible:n}));return r.length>0?new o(r):(t||((t=new l(void 0)).comment=e.comment),t)}(n);if(""!==n.token)throw 1===n.tokenType?re(n,"Unexpected operator "+n.token):ne(n,'Unexpected part "'+n.token+'"');return r}function O(e){var t,n,r,a,i=function(e){for(var t=function(e){for(var t=R(e);"or"===e.token;)C(e),t=new f("or","or",[t,R(e)]);return t}(e);"?"===e.token;){var n=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,C(e);var r=t,a=O(e);if(":"!==e.token)throw ne(e,"False part of conditional expression expected");e.conditionalLevel=null,C(e);var i=O(e);t=new u(r,a,i),e.conditionalLevel=n}return t}(e);if("="===e.token){if(xH(i))return t=i.name,C(e),r=O(e),new s(new b(t),r);if(iH(i))return C(e),r=O(e),new s(i.object,i.index,r);if(dH(i)&&xH(i.fn)&&(a=!0,n=[],t=i.name,i.args.forEach((function(e,t){xH(e)?n[t]=e.name:a=!1})),a))return C(e),r=O(e),new c(t,n,r);throw ne(e,"Invalid left hand side of assignment operator =")}return i}function R(e){for(var t=F(e);"xor"===e.token;)C(e),t=new f("xor","xor",[t,F(e)]);return t}function F(e){for(var t=Y(e);"and"===e.token;)C(e),t=new f("and","and",[t,Y(e)]);return t}function Y(e){for(var t=z(e);"|"===e.token;)C(e),t=new f("|","bitOr",[t,z(e)]);return t}function z(e){for(var t=B(e);"^|"===e.token;)C(e),t=new f("^|","bitXor",[t,B(e)]);return t}function B(e){for(var t=P(e);"&"===e.token;)C(e),t=new f("&","bitAnd",[t,P(e)]);return t}function P(e){for(var t=[H(e)],n=[],r={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};EH(r,e.token);){var a={name:e.token,fn:r[e.token]};n.push(a),C(e),t.push(H(e))}return 1===t.length?t[0]:2===t.length?new f(n[0].name,n[0].fn,t):new y(n.map((e=>e.fn)),t)}function H(e){var t,n,r,a;t=j(e);for(var i={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};EH(i,e.token);)r=i[n=e.token],C(e),a=[t,j(e)],t=new f(n,r,a);return t}function j(e){var t,n,r,a;t=U(e);for(var i={to:"to",in:"to"};EH(i,e.token);)r=i[n=e.token],C(e),"in"===n&&""===e.token?t=new f("*","multiply",[t,new b("in")],!0):(a=[t,U(e)],t=new f(n,r,a));return t}function U(e){var t,n=[];if(t=":"===e.token?new l(1):q(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(n.push(t);":"===e.token&&n.length<3;)C(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?n.push(new b("end")):n.push(q(e));t=3===n.length?new g(n[0],n[2],n[1]):new g(n[0],n[1])}return t}function q(e){var t,n,r,a;t=W(e);for(var i={"+":"add","-":"subtract"};EH(i,e.token);){r=i[n=e.token],C(e);var s=W(e);a=s.isPercentage?[t,new f("*","multiply",[t,s])]:[t,s],t=new f(n,r,a)}return t}function W(e){var t,n,r,a;n=t=V(e);for(var i={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};EH(i,e.token);)a=i[r=e.token],C(e),n=V(e),t=new f(r,a,[t,n]);return t}function V(e){var t,n;for(n=t=G(e);3===e.tokenType||"in"===e.token&&cH(t)||!(2!==e.tokenType||cH(n)||gH(n)&&"!"!==n.op)||"("===e.token;)n=G(e),t=new f("*","multiply",[t,n],!0);return t}function G(e){for(var t=K(e),n=t,r=[];"/"===e.token&&cH(n);){if(r.push(OP({},e)),C(e),2!==e.tokenType){OP(e,r.pop());break}if(r.push(OP({},e)),C(e),3!==e.tokenType&&"("!==e.token){r.pop(),OP(e,r.pop());break}OP(e,r.pop()),r.pop(),n=K(e),t=new f("/","divide",[t,n])}return t}function K(e){var t,n,r,a;t=J(e);for(var i={"%":"mod",mod:"mod"};EH(i,e.token);)r=i[n=e.token],C(e),"%"===n&&1===e.tokenType&&"("!==e.token?t=new f("/","divide",[t,new l(100)],!1,!0):(a=[t,J(e)],t=new f(n,r,a));return t}function J(e){var t,a,s,o={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return EH(o,e.token)?(s=o[e.token],t=e.token,C(e),a=[J(e)],new f(t,s,a)):function(e){var t,a,s,o;return t=function(e){var t,a,s;t=function(e){var t=[];if(3===e.tokenType&&EH(e.extraNodes,e.token)){var a=e.extraNodes[e.token];if(E(e),"("===e.token){if(t=[],A(e),E(e),")"!==e.token)for(t.push(O(e));","===e.token;)E(e),t.push(O(e));if(")"!==e.token)throw ne(e,"Parenthesis ) expected");L(e),E(e)}return new a(t)}return function(e){var t;return 3===e.tokenType||1===e.tokenType&&e.token in w?(t=e.token,E(e),X(e,EH(M,t)?new l(M[t]):-1!==N.indexOf(t)?new l(n(t,"number")):new b(t))):function(e){var t;return'"'===e.token?(t=Z(e),X(e,new l(t))):function(e){var t;return"'"===e.token?(t=Q(e),X(e,new l(t))):function(e){var t,a,s,o;if("["===e.token){if(A(e),E(e),"]"!==e.token){var u=ee(e);if(";"===e.token){for(s=1,a=[u];";"===e.token;)E(e),a[s]=ee(e),s++;if("]"!==e.token)throw ne(e,"End of matrix ] expected");L(e),E(e),o=a[0].items.length;for(var c=1;c0},x.isDecimalMark=function(e,t){return"."===e&&"/"!==t&&"*"!==t&&"^"!==t},x.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},x.isDigit=function(e){return e>="0"&&e<="9"},x.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},x})),L7=YH("resolve",["parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{parse:t,ConstantNode:n,FunctionNode:r,OperatorNode:a,ParenthesisNode:i}=e;return function e(s,o){var u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;if(!o)return s;if(Yq(o)||(o=Fq(o)),xH(s)){if(u.has(s.name)){var l=Array.from(u).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(l,"}"))}var c=o.get(s.name);if(fH(c)){var p=new Set(u);return p.add(s.name),e(c,o,p)}return"number"==typeof c?t(String(c)):void 0!==c?new n(c):s}if(gH(s)){var d=s.args.map((function(t){return e(t,o,u)}));return new a(s.op,s.fn,d,s.implicit)}if(yH(s))return new i(e(s.content,o,u));if(dH(s)){var h=s.args.map((function(t){return e(t,o,u)}));return new r(s.name,h)}return s.map((t=>e(t,o,u)))}}));function $7(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 O7(e){for(var t=1;t{var{FunctionNode:t,OperatorNode:n,SymbolNode:r}=e,a=!0,i=!1,s="defaultF",o={add:{trivial:a,total:a,commutative:a,associative:a},unaryPlus:{trivial:a,total:a,commutative:a,associative:a},subtract:{trivial:i,total:a,commutative:i,associative:i},multiply:{trivial:a,total:a,commutative:a,associative:a},divide:{trivial:i,total:a,commutative:i,associative:i},paren:{trivial:a,total:a,commutative:a,associative:i},defaultF:{trivial:i,total:a,commutative:i,associative:i}};function u(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,r=s;if("string"==typeof e?r=e:gH(e)?r=e.fn.toString():dH(e)?r=e.name:yH(e)&&(r="paren"),EH(n,r)){var a=n[r];if(EH(a,t))return a[t];if(EH(o,r))return o[r][t]}if(EH(n,s)){var i=n.defaultF;return EH(i,t)?i[t]:o.defaultF[t]}if(EH(o,r)){var u=o[r];if(EH(u,t))return u[t]}return o.defaultF[t]}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o;return u(e,"associative",t)}function c(e,t){var n,r=[];return l(e,t)?(n=e.op,function e(t){for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:o;return u(e,"commutative",t)},isAssociative:l,mergeContext:function(e,t){var n=O7({},e);for(var r in t)EH(e,r)?n[r]=O7(O7({},t[r]),e[r]):n[r]=t[r];return n},flatten:function e(t,n){if(!t.args||0===t.args.length)return t;t.args=c(t,n);for(var r=0;r2&&l(t,n)){for(var s=t.args.pop();t.args.length>0;)s=r([t.args.pop(),s]);t.args=s.args}}},unflattenl:function e(t,n){if(t.args&&0!==t.args.length){for(var r=p(t),a=t.args.length,i=0;i2&&l(t,n)){for(var s=t.args.shift();t.args.length>0;)s=r([s,t.args.shift()]);t.args=s.args}}},defaultContext:o,realContext:{divide:{total:i},log:{total:i}},positiveContext:{subtract:{total:i},abs:{trivial:a},log:{total:a}}}})),F7=YH("simplifyCore",["equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{equal:t,isZero:n,add:r,subtract:a,multiply:i,divide:s,pow:o,AccessorNode:u,ArrayNode:l,ConstantNode:c,FunctionNode:p,IndexNode:d,ObjectNode:h,OperatorNode:f,ParenthesisNode:m,SymbolNode:g}=e,y=new c(0),b=new c(1),{hasProperty:x,isCommutative:v}=R7({FunctionNode:p,OperatorNode:f,SymbolNode:g});return function e(m,g){var _=g?g.context:void 0;if(x(m,"trivial",_)){if(dH(m)&&1===m.args.length)return e(m.args[0],g);var w=!1,M=0;if(m.forEach((t=>{1==++M&&(w=e(t,g))})),1===M)return w}if(gH(m)&&m.isUnary()){var N=e(m.args[0],g);if("-"===m.op){if(gH(N)){if(N.isUnary()&&"-"===N.op)return N.args[0];if(N.isBinary()&&"subtract"===N.fn)return new f("-","subtract",[N.args[1],N.args[0]])}return new f(m.op,m.fn,[N])}}else{if(gH(m)&&m.isBinary()){var S=e(m.args[0],g),k=e(m.args[1],g);if("+"===m.op){if(cH(S)){if(n(S.value))return k;if(cH(k))return new c(r(S.value,k.value))}return cH(k)&&n(k.value)?S:gH(k)&&k.isUnary()&&"-"===k.op?new f("-","subtract",[S,k.args[0]]):new f(m.op,m.fn,k?[S,k]:[S])}if("-"===m.op){if(cH(S)&&k){if(cH(k))return new c(a(S.value,k.value));if(n(S.value))return new f("-","unaryMinus",[k])}if("subtract"===m.fn)return cH(k)&&n(k.value)?S:gH(k)&&k.isUnary()&&"-"===k.op?e(new f("+","add",[S,k.args[0]]),g):new f(m.op,m.fn,[S,k])}else{if("*"===m.op){if(cH(S)){if(n(S.value))return y;if(t(S.value,1))return k;if(cH(k))return new c(i(S.value,k.value))}if(cH(k)){if(n(k.value))return y;if(t(k.value,1))return S;if(gH(S)&&S.isBinary()&&S.op===m.op&&v(m,_)){var D=S.args[0];if(cH(D)){var T=new c(i(D.value,k.value));return new f(m.op,m.fn,[T,S.args[1]],m.implicit)}}return v(m,_)?new f(m.op,m.fn,[k,S],m.implicit):new f(m.op,m.fn,[S,k],m.implicit)}return new f(m.op,m.fn,[S,k],m.implicit)}if("/"===m.op){if(cH(S)){if(n(S.value))return y;if(cH(k)&&(t(k.value,1)||t(k.value,2)||t(k.value,4)))return new c(s(S.value,k.value))}return new f(m.op,m.fn,[S,k])}if("^"===m.op&&cH(k)){if(n(k.value))return b;if(t(k.value,1))return S;if(cH(S))return new c(o(S.value,k.value));if(gH(S)&&S.isBinary()&&"^"===S.op){var I=S.args[1];if(cH(I))return new f(m.op,m.fn,[S.args[0],new c(i(I.value,k.value))])}}}return new f(m.op,m.fn,[S,k])}if(dH(m))return new p(e(m.fn),m.args.map((t=>e(t,g))));if(sH(m))return new l(m.items.map((t=>e(t,g))));if(iH(m))return new u(e(m.object,g),e(m.index,g));if(hH(m))return new d(m.dimensions.map((t=>e(t,g))));if(mH(m)){var E={};for(var C in m.properties)E[C]=e(m.properties[C],g);return new h(E)}}return m}})),Y7="compile",z7=YH(Y7,["typed","parse"],(e=>{var{typed:t,parse:n}=e;return t(Y7,{string:function(e){return n(e).compile()},"Array | Matrix":function(e){return Gq(e,(function(e){return n(e).compile()}))}})})),B7=YH("Help",["parse"],(e=>{var{parse:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return n.prototype.type="Help",n.prototype.isHelp=!0,n.prototype.toString=function(){var e=this.doc||{},n="\n";if(e.name&&(n+="Name: "+e.name+"\n\n"),e.category&&(n+="Category: "+e.category+"\n\n"),e.description&&(n+="Description:\n "+e.description+"\n\n"),e.syntax&&(n+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){n+="Examples:\n";for(var r={},a=0;a"mathjs"!==e)).forEach((n=>{t[n]=e[n]})),new n(t)},n.prototype.valueOf=n.prototype.toString,n}),{isClass:!0}),P7="leafCount",H7=YH(P7,["parse","typed"],(e=>{var{parse:t,typed:n}=e;function r(e){var t=0;return e.forEach((e=>{t+=r(e)})),t||1}return n(P7,{string:function(e){return this(t(e))},Node:function(e){return r(e)}})})),j7=YH("simplifyConstant",["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],(e=>{var{typed:t,config:n,mathWithTransform:r,matrix:a,fraction:i,bignumber:s,AccessorNode:o,ArrayNode:u,ConstantNode:l,FunctionNode:c,IndexNode:p,ObjectNode:d,OperatorNode:h,SymbolNode:f}=e,{isCommutative:m,isAssociative:g,allChildren:y,createMakeNodeFunction:b}=R7({FunctionNode:c,OperatorNode:h,SymbolNode:f});function x(e,t){return M(T(e,t))}function v(e){return BP(e)?e.valueOf():e instanceof Array?e.map(v):UP(e)?a(v(e.valueOf())):e}function _(e,t,n){try{return r[e].apply(null,t)}catch(a){return t=t.map(v),S(r[e].apply(null,t),n)}}var w=t({Fraction:function(e){var t,n=e.s*e.n;return t=n<0?new h("-","unaryMinus",[new l(-n)]):new l(n),1===e.d?t:new h("/","divide",[t,new l(e.d)])},number:function(e){return e<0?k(new l(-e)):new l(e)},BigNumber:function(e){return e<0?k(new l(-e)):new l(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")},string:function(e){return new l(e)},Matrix:function(e){return new u(e.valueOf().map((e=>w(e))))}});function M(e){return fH(e)?e:w(e)}function N(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&i){var n=i(e),r=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(n.valueOf()===e&&n.nT(e,t)));if(!n.some(fH))try{return _(e.name,n,t)}catch(e){}if("size"===e.name&&1===n.length&&sH(n[0])){for(var i=[],s=n[0];sH(s);)i.push(s.items.length),s=s.items[0];return a(i)}return new c(e.name,n.map(M))}case"OperatorNode":var h,f,v=e.fn.toString(),w=b(e);if(gH(e)&&e.isUnary())f=fH((h=[T(e.args[0],t)])[0])?w(h):_(v,h,t);else if(g(e,t.context))if(h=(h=y(e,t.context)).map((e=>T(e,t))),m(v,t.context)){for(var N=[],k=[],I=0;I1?(f=D(v,N,w,t),k.unshift(f),f=D(v,k,w,t)):f=D(v,h,w,t)}else f=D(v,h,w,t);else h=e.args.map((e=>T(e,t))),f=D(v,h,w,t);return f;case"ParenthesisNode":return T(e.content,t);case"AccessorNode":return function(e,t,n){if(!hH(t))return new o(M(e),M(t));if(sH(e)||UP(e)){for(var r=Array.from(t.dimensions);r.length>0;)if(cH(r[0])&&"string"!=typeof r[0].value){var i=S(r.shift().value,n);sH(e)?e=e.items[i-1]:(e=e.valueOf()[i-1])instanceof Array&&(e=a(e))}else{if(!(r.length>1&&cH(r[1])&&"string"!=typeof r[1].value))break;var s=S(r[1].value,n),c=[],d=sH(e)?e.items:e.valueOf();for(var h of d)if(sH(h))c.push(h.items[s-1]);else{if(!UP(e))break;c.push(h[s-1])}if(c.length!==d.length)break;e=sH(e)?new u(c):a(c),r.splice(1,1)}return r.length===t.dimensions.length?new o(M(e),t):r.length>0?(t=new p(r),new o(M(e),t)):e}if(mH(e)&&1===t.dimensions.length&&cH(t.dimensions[0])){var f=t.dimensions[0].value;return f in e.properties?e.properties[f]:new l}return new o(M(e),t)}(T(e.object,t),T(e.index,t),t);case"ArrayNode":var E=e.items.map((e=>T(e,t)));return E.some(fH)?new u(E.map(M)):a(E);case"IndexNode":return new p(e.dimensions.map((e=>x(e,t))));case"ObjectNode":var C={};for(var A in e.properties)C[A]=x(e.properties[A],t);return new d(C);default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return x})),U7=YH("simplify",["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","resolve","simplifyCore","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{config:t,typed:n,parse:r,add:a,subtract:i,multiply:s,divide:o,pow:u,isZero:l,equal:c,resolve:p,simplifyCore:d,fraction:h,bignumber:f,mathWithTransform:m,matrix:g,AccessorNode:y,ArrayNode:b,ConstantNode:x,FunctionNode:v,IndexNode:_,ObjectNode:w,OperatorNode:M,ParenthesisNode:N,SymbolNode:S}=e,k=j7({typed:n,config:t,mathWithTransform:m,matrix:g,fraction:h,bignumber:f,AccessorNode:y,ArrayNode:b,ConstantNode:x,FunctionNode:v,IndexNode:_,ObjectNode:w,OperatorNode:M,SymbolNode:S}),{hasProperty:D,isCommutative:T,isAssociative:I,mergeContext:E,flatten:C,unflattenr:A,unflattenl:L,createMakeNodeFunction:$,defaultContext:O,realContext:R,positiveContext:F}=R7({FunctionNode:v,OperatorNode:M,SymbolNode:S}),Y=n("simplify",{string:function(e){return this(r(e),this.rules,Rq(),{})},"string, Map | Object":function(e,t){return this(r(e),this.rules,t,{})},"string, Map | Object, Object":function(e,t,n){return this(r(e),this.rules,t,n)},"string, Array":function(e,t){return this(r(e),t,Rq(),{})},"string, Array, Map | Object":function(e,t,n){return this(r(e),t,n,{})},"string, Array, Map | Object, Object":function(e,t,n,a){return this(r(e),t,n,a)},"Node, Map | Object":function(e,t){return this(e,this.rules,t,{})},"Node, Map | Object, Object":function(e,t,n){return this(e,this.rules,t,n)},Node:function(e){return this(e,this.rules,Rq(),{})},"Node, Array":function(e,t){return this(e,t,Rq(),{})},"Node, Array, Map | Object":function(e,t,n){return this(e,t,n,{})},"Node, Array, Object, Object":function(e,t,n,r){return this(e,t,Fq(n),r)},"Node, Array, Map, Object":function(e,t,n,r){var a=r.consoleDebug;t=function(e,t){for(var n=[],r=0;r ").concat(t[l].r.toString()))),a){var d=i.toString({parenthesis:"all"});d!==u&&(console.log("Applying",c,"produced",d),u=d)}L(i,r.context)}o=i.toString({parenthesis:"all"})}return i}});function z(e){return e.transform((function(e,t,n){return yH(e)?z(e.content):e}))}Y.defaultContext=O,Y.realContext=R,Y.positiveContext=F;var B={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};function P(e,t){var n={};if(e.s){var a=e.s.split("->");if(2!==a.length)throw SyntaxError("Could not parse rule: "+e.s);n.l=a[0],n.r=a[1]}else n.l=e.l,n.r=e.r;for(var i of(n.l=z(r(n.l)),n.r=z(r(n.r)),["imposeContext","repeat","assuming"]))i in e&&(n[i]=e[i]);if(e.evaluate&&(n.evaluate=r(e.evaluate)),I(n.l,t)){var s=$(n.l),o=new S("_p"+H++);n.expanded={},n.expanded.l=s([n.l.clone(),o]),C(n.expanded.l,t),A(n.expanded.l,t),n.expanded.r=s([n.r,o])}return n}Y.rules=[d,{l:"log(e)",r:"1"},{s:"n-n1 -> n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(c*v) -> v * (-c)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(c*v) -> (-c) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*c) -> v * (-c)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" v * ( v * n1 + n2)",r:"v^2 * n1 + v * n2"},{s:" v * (v^n4 * n1 + n2) -> v^(1+n4) * n1 + v * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * ( v * n1 + n2) -> v^(n3+1) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * (v^n4 * n1 + n2) -> v^(n3+n4) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},k,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"v*n + v",r:"v*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*v + v -> (n+1)*v",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*c + c",r:"(n+1)*c"},{s:"c*n + c -> c*(n+1)",assuming:{multiply:{commutative:!1}}},k,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"c+v -> v+c",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"v*c -> c*v",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];var H=0;function j(e,t,n){var r=e;if(e)for(var a=0;a=2&&2===e.args.length){for(var i=function(e,t){var n,r,a=[],i=$(e);if(T(e,t))for(var s=0;s1&&(u=i(e.args.slice(0,o))),n=1===(r=e.args.slice(o)).length?r[0]:i(r),a.push(i([u,n]))}return a}(t,n),s=[],o=0;o2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var l=[],p=0;p2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var h=V(e.args[0],t.args[1],n);if(0===h.length)return[];var f=V(e.args[1],t.args[0],n);if(0===f.length)return[];l=[h,f]}a=function(e){if(0===e.length)return e;for(var t=e.reduce(W),n=[],r={},a=0;a{var{parse:t,simplify:n,typed:r,OperatorNode:a}=e;return r(q7,{"string, string":function(e,n){return this(t(e),t(n),{})},"string, string, Object":function(e,n,r){return this(t(e),t(n),r)},"Node, string":function(e,n){return this(e,t(n),{})},"Node, string, Object":function(e,n,r){return this(e,t(n),r)},"string, Node":function(e,n){return this(t(e),n,{})},"string, Node, Object":function(e,n,r){return this(t(e),n,r)},"Node, Node":function(e,t){return this(e,t,{})},"Node, Node, Object":function(e,t,r){var i=new a("-","subtract",[e,t]),s=n(i,{},r);return cH(s)&&!s.value}})})),V7="evaluate",G7=YH(V7,["typed","parse"],(e=>{var{typed:t,parse:n}=e;return t(V7,{string:function(e){var t=Rq();return n(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return n(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=Rq();return Gq(e,(function(e){return n(e).compile().evaluate(t)}))},"Array | Matrix, Map | Object":function(e,t){return Gq(e,(function(e){return n(e).compile().evaluate(t)}))}})})),K7={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},J7={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},X7={bignumber:{name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},boolean:{name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},complex:{name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},index:{name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},matrix:{name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},number:{name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},splitUnit:{name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},string:{name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},unit:{name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},e:K7,E:K7,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},Infinity:{name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},LOG10E:{name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:J7,PI:J7,phi:{name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},SQRT1_2:{name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:{name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},lsolve:{name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},lsolveAll:{name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},lup:{name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},lusolve:{name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},leafCount:{name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},resolve:{name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},simplify:{name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},simplifyCore:{name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","evaluate"]},symbolicEqual:{name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},usolve:{name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},usolveAll:{name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},qr:{name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},cbrt:{name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},cube:{name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},divide:{name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},dotDivide:{name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},dotMultiply:{name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},dotPow:{name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},exp:{name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},expm:{name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},expm1:{name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},gcd:{name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},log:{name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},log2:{name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},log1p:{name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},log10:{name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},mod:{name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},multiply:{name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},norm:{name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)","math.pow([[1, 2], [4, 3]], 2)","math.pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},invmod:{name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","math.invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},count:{name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diff:{name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},pinv:{name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},kron:{name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},ones:{name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]},range:{name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},reshape:{name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]},rotate:{name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},rotationMatrix:{name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},size:{name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},fft:{name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},ifft:{name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},lgamma:{name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(math.i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},cumsum:{name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},print:{name:"print",category:"Utils",syntax:["print(template, values)","print(template, values, precision)"],description:"Interpolate values into a string template.",examples:['print("Lucy is $age years old", {age: 5})','print("The value of pi is $pi", {pi: pi}, 3)','print("Hello, $user.name!", {user: {name: "John"}})','print("Values: $0, $1, $2", [6, 9, 4])'],seealso:["format"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},Z7="help",Q7=YH(Z7,["typed","mathWithTransform","Help"],(e=>{var{typed:t,mathWithTransform:n,Help:r}=e;return t(Z7,{any:function(e){var t,a=e;if("string"!=typeof e)for(t in n)if(EH(n,t)&&e===n[t]){a=t;break}var i=Tq(X7,a);if(!i){var s="function"==typeof a?a.name:a;throw new Error('No documentation found on "'+s+'"')}return new r(i)}})})),e8=YH("Parser",["evaluate"],(e=>{var{evaluate:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:Rq(),writable:!1})}return n.prototype.type="Parser",n.prototype.isParser=!0,n.prototype.evaluate=function(e){return t(e,this.scope)},n.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},n.prototype.getAll=function(){return function(e){if(e instanceof Oq)return e.wrappedObject;var t={};for(var n of e.keys())Iq(t,n,e.get(n));return t}(this.scope)},n.prototype.getAllAsMap=function(){return this.scope},n.prototype.set=function(e,t){return this.scope.set(e,t),t},n.prototype.remove=function(e){this.scope.delete(e)},n.prototype.clear=function(){this.scope.clear()},n}),{isClass:!0}),t8="rationalize",n8=YH(t8,["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],(e=>{var{config:t,typed:n,equal:r,isZero:a,add:i,subtract:s,multiply:o,divide:u,pow:l,parse:c,simplifyCore:p,simplify:d,fraction:h,bignumber:f,mathWithTransform:m,matrix:g,AccessorNode:y,ArrayNode:b,ConstantNode:x,FunctionNode:v,IndexNode:_,ObjectNode:w,OperatorNode:M,SymbolNode:N,ParenthesisNode:S}=e,k=j7({typed:n,config:t,mathWithTransform:m,matrix:g,fraction:h,bignumber:f,AccessorNode:y,ArrayNode:b,ConstantNode:x,FunctionNode:v,IndexNode:_,ObjectNode:w,OperatorNode:M,SymbolNode:N});return n(t8,{string:function(e){return this(c(e),{},!1)},"string, boolean":function(e,t){return this(c(e),{},t)},"string, Object":function(e,t){return this(c(e),t,!1)},"string, Object, boolean":function(e,t,n){return this(c(e),t,n)},Node:function(e){return this(e,{},!1)},"Node, boolean":function(e,t){return this(e,{},t)},"Node, Object":function(e,t){return this(e,t,!1)},"Node, Object, boolean":function(e,t,n){var r=function(){var e=[p,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},k,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],t=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],n=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],r={};return r.firstRules=e.concat(t,n),r.distrDivRules=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],r.sucDivRules=n,r.firstRulesAgain=e.concat(t),r.finalRules=[p,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},k,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],r}(),a=function(e,t,n,r){var a=[],i=d(e,r,t,{exactFractions:!1}),s="+-*"+((n=!!n)?"/":"");!function e(t){var n=t.type;if("FunctionNode"===n)throw new Error("There is an unsolved function call");if("OperatorNode"===n)if("^"===t.op){if("ConstantNode"!==t.args[1].type||!jH(parseFloat(t.args[1].value)))throw new Error("There is a non-integer exponent");e(t.args[0])}else{if(-1===s.indexOf(t.op))throw new Error("Operator "+t.op+" invalid in polynomial expression");for(var r=0;r=1){var u,l;e=D(e);var c,h=!0,f=!1;for(e=d(e,r.firstRules,{},s);l=h?r.distrDivRules:r.sucDivRules,h=!h,(c=(e=d(e,l,{},o)).toString())!==u;)f=!0,u=c;f&&(e=d(e,r.firstRulesAgain,{},s)),e=d(e,r.finalRules,{},s)}var m=[],g={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===i&&(e.args[0]=T(e.args[0],m),e.args[1]=T(e.args[1])),n&&(g.numerator=e.args[0],g.denominator=e.args[1])):(1===i&&(e=T(e,m)),n&&(g.numerator=e,g.denominator=null)),n?(g.coefficients=m,g.variables=a.variables,g.expression=e,g):e}});function D(e,t,n){var r=e.type,a=arguments.length>1;if("OperatorNode"===r&&e.isBinary()){var i,s=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(s=(i=parseFloat(e.args[1].value))>=2&&jH(i))),s){if(i>2){var o=e.args[0],u=new M("^","pow",[e.args[0].cloneDeep(),new x(i-1)]);e=new M("*","multiply",[o,u])}else e=new M("*","multiply",[e.args[0],e.args[0].cloneDeep()]);a&&("content"===n?t.content=e:t.args[n]=e)}}if("ParenthesisNode"===r)D(e.content,e,"content");else if("ConstantNode"!==r&&"SymbolNode"!==r)for(var l=0;ln&&(t[l]=0),t[l]+=s.cte*("+"===s.oper?1:-1),void(n=Math.max(l,n))}s.cte=l,""===s.fire&&(t[0]+=s.cte*("+"===s.oper?1:-1))}}(e,null,{cte:1,oper:"+",fire:""});for(var a,i=!0,s=n=t.length-1;s>=0;s--)if(0!==t[s]){var o=new x(i?t[s]:Math.abs(t[s])),u=t[s]<0?"-":"+";if(s>0){var l=new N(r);if(s>1){var c=new x(s);l=new M("^","pow",[l,c])}o=-1===t[s]&&i?new M("-","unaryMinus",[l]):1===Math.abs(t[s])?l:new M("*","multiply",[o,l])}a=i?o:"+"===u?new M("+","add",[a,o]):new M("-","subtract",[a,o]),i=!1}return i?new x(0):a}})),r8=YH("derivative",["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,config:n,parse:r,simplify:a,equal:i,isZero:s,numeric:o,ConstantNode:u,FunctionNode:l,OperatorNode:c,ParenthesisNode:p,SymbolNode:d}=e,h=t("derivative",{"Node, SymbolNode, Object":function(e,t,n){var r={};m(r,e,t.name);var i=g(e,r);return n.simplify?a(i):i},"Node, SymbolNode":function(e,t){return this(e,t,{simplify:!0})},"string, SymbolNode":function(e,t){return this(r(e),t)},"string, SymbolNode, Object":function(e,t,n){return this(r(e),t,n)},"string, string":function(e,t){return this(r(e),r(t))},"string, string, Object":function(e,t,n){return this(r(e),r(t),n)},"Node, string":function(e,t){return this(e,r(t))},"Node, string, Object":function(e,t,n){return this(e,r(t),n)}});h._simplify=!0,h.toTex=function(e){return f.apply(null,e.args)};var f=t("_derivTex",{"Node, SymbolNode":function(e,t){return cH(e)&&"string"===_H(e.value)?f(r(e.value).toString(),t.toString(),1):f(e.toTex(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===_H(t.value))return f(e,r(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,n){return f(e.toString(),t.name,n.value)},"string, string, number":function(e,t,n){return(1===n?"{d\\over d"+t+"}":"{d^{"+n+"}\\over d"+t+"^{"+n+"}}")+"\\left[".concat(e,"\\right]")}}),m=t("constTag",{"Object, ConstantNode, string":function(e,t){return e[t]=!0,!0},"Object, SymbolNode, string":function(e,t,n){return t.name!==n&&(e[t]=!0,!0)},"Object, ParenthesisNode, string":function(e,t,n){return m(e,t.content,n)},"Object, FunctionAssignmentNode, string":function(e,t,n){return-1===t.params.indexOf(n)?(e[t]=!0,!0):m(e,t.expr,n)},"Object, FunctionNode | OperatorNode, string":function(e,t,n){if(t.args.length>0){for(var r=m(e,t.args[0],n),a=1;a0){var r=e.args.filter((function(e){return void 0===t[e]})),a=1===r.length?r[0]:new c("*","multiply",r),o=n.concat(g(a,t));return new c("*","multiply",o)}return new c("+","add",e.args.map((function(n){return new c("*","multiply",e.args.map((function(e){return e===n?g(e,t):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var u=e.args[0],p=e.args[1];return void 0!==t[p]?new c("/","divide",[g(u,t),p]):void 0!==t[u]?new c("*","multiply",[new c("-","unaryMinus",[u]),new c("/","divide",[g(p,t),new c("^","pow",[p.clone(),y(2)])])]):new c("/","divide",[new c("-","subtract",[new c("*","multiply",[g(u,t),p.clone()]),new c("*","multiply",[u.clone(),g(p,t)])]),new c("^","pow",[p.clone(),y(2)])])}if("^"===e.op&&e.isBinary()){var d=e.args[0],h=e.args[1];if(void 0!==t[d])return cH(d)&&(s(d.value)||i(d.value,1))?y(0):new c("*","multiply",[e,new c("*","multiply",[new l("log",[d.clone()]),g(h.clone(),t)])]);if(void 0!==t[h]){if(cH(h)){if(s(h.value))return y(0);if(i(h.value,1))return g(d,t)}var f=new c("^","pow",[d.clone(),new c("-","subtract",[h,y(1)])]);return new c("*","multiply",[h.clone(),new c("*","multiply",[g(d,t),f])])}return new c("*","multiply",[new c("^","pow",[d.clone(),h.clone()]),new c("+","add",[new c("*","multiply",[g(d,t),new c("/","divide",[h.clone(),d.clone()])]),new c("*","multiply",[g(h,t),new l("log",[d.clone()])])])])}throw new Error('Operator "'+e.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function y(e,t){return new u(o(e,t||n.number))}return h})),a8="parser",i8=YH(a8,["typed","Parser"],(e=>{var{typed:t,Parser:n}=e;return t(a8,{"":function(){return new n}})}));function s8(e,t,n){var r=e.filter((function(e){return xH(e)&&!(e.name in t)&&!n.has(e.name)}))[0];if(!r)throw new Error('No undefined variable found in inline expression "'+e+'"');var a=r.name,i=I7(n),s=e.compile();return function(e){return i.set(a,e),s.evaluate(i)}}var o8=YH("filter",["typed"],(e=>{var{typed:t}=e;function n(e,t,n){var a,i;return e[0]&&(a=e[0].compile().evaluate(n)),e[1]&&(i=xH(e[1])||pH(e[1])?e[1].compile().evaluate(n):s8(e[1],t,n)),r(a,i)}n.rawArgs=!0;var r=t("filter",{"Array, function":u8,"Matrix, function":function(e,t){return e.create(u8(e.toArray(),t))},"Array, RegExp":xq,"Matrix, RegExp":function(e,t){return e.create(xq(e.toArray(),t))}});return n}),{isTransformFunction:!0});function u8(e,t){var n=fj(t);return bq(e,(function(e,r,a){return 1===n?t(e):2===n?t(e,[r+1]):t(e,[r+1],a)}))}var l8=YH("forEach",["typed"],(e=>{var{typed:t}=e;function n(e,t,n){var a,i;return e[0]&&(a=e[0].compile().evaluate(n)),e[1]&&(i=xH(e[1])||pH(e[1])?e[1].compile().evaluate(n):s8(e[1],t,n)),r(a,i)}n.rawArgs=!0;var r=t("forEach",{"Array | Matrix, function":function(e,t){var n=fj(t);!function r(a,i){Array.isArray(a)?yq(a,(function(e,t){r(e,i.concat(t+1))})):1===n?t(a):2===n?t(a,i):t(a,i,e)}(e.valueOf(),[])}});return n}),{isTransformFunction:!0}),c8=YH("map",["typed"],(e=>{var{typed:t}=e;function n(e,t,n){var a,i;return e[0]&&(a=e[0].compile().evaluate(n)),e[1]&&(i=xH(e[1])||pH(e[1])?e[1].compile().evaluate(n):s8(e[1],t,n)),r(a,i)}n.rawArgs=!0;var r=t("map",{"Array, function":function(e,t){return p8(e,t,e)},"Matrix, function":function(e,t){return e.create(p8(e.valueOf(),t,e))}});return n}),{isTransformFunction:!0});function p8(e,t,n){var r=fj(t);return function e(a,i){return Array.isArray(a)?gq(a,(function(t,n){return e(t,i.concat(n+1))})):1===r?t(a):2===r?t(a,i):t(a,i,n)}(e,[])}var d8=YH("apply",["typed","isInteger"],(e=>{var{typed:t,isInteger:n}=e,r=vK({typed:t,isInteger:n});return t("apply",{"...any":function(e){var t=e[1];FP(t)?e[1]=t-1:YP(t)&&(e[1]=t.minus(1));try{return r.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0});function h8(e){if(2===e.length&&qP(e[0])){var t=(e=e.slice())[1];FP(t)?e[1]=t-1:YP(t)&&(e[1]=t.minus(1))}return e}var f8="diff",m8=YH(f8,["typed","matrix","subtract","number","bignumber"],(e=>{var{typed:t,matrix:n,subtract:r,number:a,bignumber:i}=e,s=DZ({typed:t,matrix:n,subtract:r,number:a,bignumber:i});return t(f8,{"...any":function(e){e=h8(e);try{return s.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),g8=YH("subset",["typed","matrix"],(e=>{var{typed:t,matrix:n}=e,r=LJ({typed:t,matrix:n});return t("subset",{"...any":function(e){try{return r.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),y8=YH("concat",["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:n,isInteger:r}=e,a=sX({typed:t,matrix:n,isInteger:r});return t("concat",{"...any":function(e){var t=e.length-1,n=e[t];FP(n)?e[t]=n-1:YP(n)&&(e[t]=n.minus(1));try{return a.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),b8=YH("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:n,numeric:r,larger:a}=e,i=UQ({typed:t,config:n,numeric:r,larger:a});return t("max",{"...any":function(e){e=h8(e);try{return i.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),x8=YH("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:n,numeric:r,smaller:a}=e,i=jX({typed:t,config:n,numeric:r,smaller:a});return t("min",{"...any":function(e){e=h8(e);try{return i.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),v8=YH("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:n,matrix:r,bignumber:a,smaller:i,smallerEq:s,larger:o,largerEq:u}=e,l=JZ({typed:t,config:n,matrix:r,bignumber:a,smaller:i,smallerEq:s,larger:o,largerEq:u});return t("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),l.apply(null,e)}})}),{isTransformFunction:!0}),_8=YH("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:n,add:r,numeric:a}=e,i=fQ({typed:t,config:n,add:r,numeric:a});return t("sum",{"...any":function(e){e=h8(e);try{return i.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),w8="cumsum",M8=YH(w8,["typed","add","unaryPlus"],(e=>{var{typed:t,add:n,unaryPlus:r}=e,a=MZ({typed:t,add:n,unaryPlus:r});return t(w8,{"...any":function(e){if(2===e.length&&qP(e[0])){var t=e[1];FP(t)?e[1]=t-1:YP(t)&&(e[1]=t.minus(1))}try{return a.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),N8=YH("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e,i=WQ({typed:t,Index:n,matrix:r,range:a});return t("row",{"...any":function(e){var t=e.length-1,n=e[t];FP(n)&&(e[t]=n-1);try{return i.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),S8=YH("column",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e,i=a0({typed:t,Index:n,matrix:r,range:a});return t("column",{"...any":function(e){var t=e.length-1,n=e[t];FP(n)&&(e[t]=n-1);try{return i.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),k8=YH("index",["Index"],(e=>{var{Index:t}=e;return function(){for(var e=[],n=0,r=arguments.length;n0?0:2;else if(a&&!0===a.isSet)a=a.map((function(e){return e-1}));else if(jP(a)||UP(a))a=a.map((function(e){return e-1}));else if(FP(a))a--;else if(YP(a))a=a.toNumber()-1;else if("string"!=typeof a)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");e[n]=a}var i=new t;return t.apply(i,e),i}}),{isTransformFunction:!0}),D8=YH("mean",["typed","add","divide"],(e=>{var{typed:t,add:n,divide:r}=e,a=K0({typed:t,add:n,divide:r});return t("mean",{"...any":function(e){e=h8(e);try{return a.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),T8="variance",I8=YH(T8,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:n,subtract:r,multiply:a,divide:i,apply:s,isNaN:o}=e,u=p1({typed:t,add:n,subtract:r,multiply:a,divide:i,apply:s,isNaN:o});return t(T8,{"...any":function(e){e=h8(e);try{return u.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),E8=YH("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:n,variance:r}=e,a=w1({typed:t,sqrt:n,variance:r});return t("std",{"...any":function(e){e=h8(e);try{return a.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),C8={},A8={},L8={},$8=J6({math:C8}),O8=Z6({mathWithTransform:A8}),R8=Q6({Node:O8}),F8=p7({Node:O8}),Y8=d7({Node:O8}),z8=h7({Node:O8}),B8=f7({Node:O8}),P8=m7({Node:O8,ResultSet:j1}),H8=g7({Node:O8}),j8=y7({Node:O8}),U8=b7({Node:O8}),q8=x7({classes:L8}),W8=_7({Chain:$8,typed:t2}),V8=w7({Node:O8,typed:t2}),G8=S7({Node:O8,subset:z3}),K8=k7({matrix:T3,Node:O8,subset:z3}),J8=D7({Node:O8,size:R3}),X8=T7({Unit:C5,Node:O8,math:C8}),Z8=E7({Node:O8,SymbolNode:X8,math:C8}),Q8=A7({AccessorNode:G8,ArrayNode:B8,AssignmentNode:K8,BlockNode:P8,ConditionalNode:H8,ConstantNode:j8,FunctionAssignmentNode:V8,FunctionNode:Z8,IndexNode:J8,ObjectNode:R8,OperatorNode:F8,ParenthesisNode:Y8,RangeNode:U8,RelationalNode:z8,SymbolNode:X8,config:RH,numeric:A3,typed:t2}),e9=L7({ConstantNode:j8,FunctionNode:Z8,OperatorNode:F8,ParenthesisNode:Y8,parse:Q8}),t9=F7({AccessorNode:G8,ArrayNode:B8,ConstantNode:j8,FunctionNode:Z8,IndexNode:J8,ObjectNode:R8,OperatorNode:F8,ParenthesisNode:Y8,SymbolNode:X8,add:D4,divide:m6,equal:r4,isZero:Y2,multiply:U4,pow:k5,subtract:B3}),n9=z7({parse:Q8,typed:t2}),r9=B7({parse:Q8}),a9=H7({parse:Q8,typed:t2}),i9=U7({bignumber:f2,fraction:k3,AccessorNode:G8,ArrayNode:B8,ConstantNode:j8,FunctionNode:Z8,IndexNode:J8,ObjectNode:R8,OperatorNode:F8,ParenthesisNode:Y8,SymbolNode:X8,add:D4,config:RH,divide:m6,equal:r4,isZero:Y2,mathWithTransform:A8,matrix:T3,multiply:U4,parse:Q8,pow:k5,resolve:e9,simplifyCore:t9,subtract:B3,typed:t2}),s9=W7({OperatorNode:F8,parse:Q8,simplify:i9,typed:t2}),o9=G7({parse:Q8,typed:t2}),u9=Q7({Help:r9,mathWithTransform:A8,typed:t2}),l9=e8({evaluate:o9}),c9=n8({bignumber:f2,fraction:k3,AccessorNode:G8,ArrayNode:B8,ConstantNode:j8,FunctionNode:Z8,IndexNode:J8,ObjectNode:R8,OperatorNode:F8,ParenthesisNode:Y8,SymbolNode:X8,add:D4,config:RH,divide:m6,equal:r4,isZero:Y2,mathWithTransform:A8,matrix:T3,multiply:U4,parse:Q8,pow:k5,simplify:i9,simplifyCore:t9,subtract:B3,typed:t2}),p9=r8({ConstantNode:j8,FunctionNode:Z8,OperatorNode:F8,ParenthesisNode:Y8,SymbolNode:X8,config:RH,equal:r4,isZero:Y2,numeric:A3,parse:Q8,simplify:i9,typed:t2}),d9=i8({Parser:l9,typed:t2});OP(C8,{e:E1,false:C1,fineStructure:A1,i:$1,Infinity:O1,LN10:R1,LOG10E:F1,NaN:z1,null:B1,phi:P1,SQRT1_2:U1,sackurTetrode:q1,tau:W1,true:V1,E:E1,version:G1,efimovFactor:J1,LN2:X1,pi:Z1,replacer:Q1,reviver:q8,SQRT2:e2,typed:t2,unaryPlus:n2,PI:Z1,weakMixingAngle:r2,abs:a2,acos:i2,acot:s2,acsc:o2,addScalar:u2,arg:l2,asech:c2,asinh:p2,atan:d2,atanh:h2,bignumber:f2,bitNot:m2,boolean:g2,chain:W8,clone:y2,combinations:b2,complex:x2,conj:v2,cosh:_2,coth:w2,csc:M2,cube:N2,equalScalar:S2,erf:k2,exp:D2,expm1:T2,filter:I2,forEach:E2,format:C2,getMatrixDataType:A2,hex:L2,im:$2,isInteger:O2,isNegative:R2,isPositive:F2,isZero:Y2,LOG2E:z2,lgamma:B2,log10:P2,log2:H2,map:j2,multiplyScalar:U2,not:q2,number:W2,oct:V2,pickRandom:G2,print:K2,random:J2,re:X2,sec:Z2,sign:Q2,sin:e3,splitUnit:n3,square:r3,string:a3,tan:i3,typeOf:s3,acosh:o3,acsch:u3,apply:l3,asec:c3,bin:p3,combinationsWithRep:d3,cos:h3,csch:f3,isNaN:m3,isPrime:g3,randomInt:y3,sech:b3,sinh:x3,sparse:v3,sqrt:_3,tanh:w3,unaryMinus:M3,acoth:N3,cot:S3,fraction:k3,isNumeric:D3,matrix:T3,matrixFromFunction:I3,mod:E3,nthRoot:C3,numeric:A3,or:L3,prod:$3,reshape:O3,size:R3,smaller:F3,squeeze:Y3,subset:z3,subtract:B3,to:P3,transpose:H3,xgcd:j3,zeros:U3,and:q3,bitAnd:W3,bitXor:V3,cbrt:G3,compare:K3,compareText:J3,concat:X3,count:Z3,ctranspose:Q3,diag:e4,divideScalar:t4,dotDivide:n4,equal:r4,fft:a4,flatten:i4,gcd:s4,hasNumericValue:o4,hypot:u4,ifft:l4,kron:c4,largerEq:p4,leftShift:d4,lsolve:h4,matrixFromColumns:f4,min:m4,mode:g4,nthRoots:y4,ones:b4,partitionSelect:x4,resize:v4,rightArithShift:_4,round:w4,smallerEq:M4,unequal:N4,usolve:S4,xor:k4,add:D4,atan2:T4,bitOr:I4,catalan:E4,compareNatural:C4,cumsum:A4,deepEqual:L4,diff:$4,dot:O4,equalText:R4,floor:F4,identity:Y4,invmod:z4,larger:B4,log:P4,lsolveAll:H4,matrixFromRows:j4,multiply:U4,qr:q4,range:W4,rightLogShift:V4,setSize:G4,slu:K4,sum:J4,trace:X4,usolveAll:Z4,asin:Q4,ceil:e5,composition:t5,cross:n5,det:r5,distance:a5,dotMultiply:i5,fix:o5,intersect:c5,lcm:d5,log1p:h5,max:f5,quantileSeq:m5,row:g5,setCartesian:y5,setDistinct:b5,setIsSubset:x5,setPowerset:v5,sort:_5,column:w5,index:M5,inv:N5,pinv:S5,pow:k5,setDifference:D5,setMultiplicity:T5,sqrtm:E5,vacuumImpedance:A5,wienDisplacement:L5,atomicMass:$5,bohrMagneton:O5,boltzmann:R5,conductanceQuantum:F5,createUnit:Y5,deuteronMass:z5,dotPow:B5,electricConstant:P5,elementaryCharge:H5,expm:j5,faraday:U5,firstRadiation:q5,gamma:W5,gravitationConstant:V5,hartreeEnergy:G5,klitzing:K5,loschmidt:J5,magneticConstant:X5,molarMass:Z5,molarPlanckConstant:Q5,neutronMass:e6,nuclearMagneton:t6,planckCharge:n6,planckLength:r6,planckTemperature:a6,protonMass:i6,reducedPlanckConstant:s6,rydberg:o6,setIntersect:u6,speedOfLight:l6,stefanBoltzmann:c6,thomsonCrossSection:p6,avogadro:d6,bohrRadius:h6,coulomb:f6,divide:m6,electronMass:g6,factorial:y6,gravity:b6,inverseConductanceQuantum:x6,lup:v6,magneticFluxQuantum:_6,molarMassC12:w6,multinomial:M6,parse:Q8,permutations:N6,planckMass:S6,quantumOfCirculation:k6,resolve:e9,secondRadiation:D6,simplifyCore:t9,stirlingS2:T6,unit:I6,bellNumbers:E6,compile:n9,eigs:C6,fermiCoupling:A6,leafCount:a9,mean:L6,molarVolume:$6,planckConstant:O6,setSymDifference:R6,simplify:i9,symbolicEqual:s9,classicalElectronRadius:F6,evaluate:o9,help:u9,lusolve:Y6,median:z6,rationalize:c9,setUnion:B6,variance:P6,derivative:p9,kldivergence:H6,norm:j6,planckTime:U6,rotationMatrix:q6,gasConstant:W6,parser:d9,std:V6,mad:G6,rotate:K6,config:RH}),OP(A8,C8,{filter:o8({typed:t2}),forEach:l8({typed:t2}),map:c8({typed:t2}),apply:d8({isInteger:O2,typed:t2}),diff:m8({bignumber:f2,matrix:T3,number:W2,subtract:B3,typed:t2}),subset:g8({matrix:T3,typed:t2}),concat:y8({isInteger:O2,matrix:T3,typed:t2}),max:b8({config:RH,larger:B4,numeric:A3,typed:t2}),min:x8({config:RH,numeric:A3,smaller:F3,typed:t2}),range:v8({bignumber:f2,matrix:T3,config:RH,larger:B4,largerEq:p4,smaller:F3,smallerEq:M4,typed:t2}),sum:_8({add:D4,config:RH,numeric:A3,typed:t2}),cumsum:M8({add:D4,typed:t2,unaryPlus:n2}),row:N8({Index:l5,matrix:T3,range:W4,typed:t2}),column:S8({Index:l5,matrix:T3,range:W4,typed:t2}),index:k8({Index:l5}),mean:D8({add:D4,divide:m6,typed:t2}),variance:I8({add:D4,apply:l3,divide:m6,isNaN:m3,multiply:U4,subtract:B3,typed:t2}),std:E8({sqrt:_3,typed:t2,variance:P6})}),OP(L8,{BigNumber:T1,Chain:$8,Complex:I1,Fraction:L1,Matrix:Y1,Node:O8,ObjectNode:R8,OperatorNode:F8,ParenthesisNode:Y8,Range:H1,RelationalNode:z8,ResultSet:j1,ArrayNode:B8,BlockNode:P8,ConditionalNode:H8,ConstantNode:j8,DenseMatrix:K1,RangeNode:U8,FunctionAssignmentNode:V8,SparseMatrix:t3,AccessorNode:G8,AssignmentNode:K8,IndexNode:J8,FibonacciHeap:s5,ImmutableDenseMatrix:u5,Index:l5,Spa:I5,Unit:C5,SymbolNode:X8,FunctionNode:Z8,Help:r9,Parser:l9}),$8.createProxy(C8);var h9={createBigNumberClass:PH},f9={createComplexClass:pj},m9={createMatrixClass:jU},g9={MatrixDependencies:m9,createDenseMatrixClass:Sq},y9={createFractionClass:HU},b9={BigNumberDependencies:h9,ComplexDependencies:f9,DenseMatrixDependencies:g9,FractionDependencies:y9,createTyped:Pq},x9={typedDependencies:b9,createAbs:wW},v9={createNode:Z6},_9={typedDependencies:b9,createEqualScalar:PV},w9={MatrixDependencies:m9,equalScalarDependencies:_9,typedDependencies:b9,createSparseMatrixClass:iK},M9={DenseMatrixDependencies:g9,MatrixDependencies:m9,SparseMatrixDependencies:w9,typedDependencies:b9,createMatrix:eJ},N9={matrixDependencies:M9,typedDependencies:b9,createSubset:LJ},S9={NodeDependencies:v9,subsetDependencies:N9,createAccessorNode:S7},k9={ComplexDependencies:f9,typedDependencies:b9,createAcos:NW},D9={ComplexDependencies:f9,typedDependencies:b9,createAcosh:gK},T9={BigNumberDependencies:h9,typedDependencies:b9,createAcot:jW},I9={BigNumberDependencies:h9,ComplexDependencies:f9,typedDependencies:b9,createAcoth:GK},E9={BigNumberDependencies:h9,ComplexDependencies:f9,typedDependencies:b9,createAcsc:qW},C9={BigNumberDependencies:h9,typedDependencies:b9,createAcsch:bK},A9={typedDependencies:b9,createAddScalar:VW},L9={DenseMatrixDependencies:g9,SparseMatrixDependencies:w9,addScalarDependencies:A9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createAdd:pZ},$9={typedDependencies:b9,createNot:PG},O9={BigNumberDependencies:h9,matrixDependencies:M9,typedDependencies:b9,createZeros:VJ},R9={equalScalarDependencies:_9,matrixDependencies:M9,notDependencies:$9,typedDependencies:b9,zerosDependencies:O9,createAnd:GJ},F9={typedDependencies:b9,createIsInteger:lG},Y9={isIntegerDependencies:F9,typedDependencies:b9,createApply:vK},z9={isIntegerDependencies:F9,typedDependencies:b9,createApplyTransform:d8},B9={typedDependencies:b9,createArg:GW},P9={NodeDependencies:v9,createArrayNode:f7},H9={BigNumberDependencies:h9,ComplexDependencies:f9,typedDependencies:b9,createAsec:MK},j9={BigNumberDependencies:h9,ComplexDependencies:f9,typedDependencies:b9,createAsech:JW},U9={ComplexDependencies:f9,typedDependencies:b9,createAsin:xQ},q9={typedDependencies:b9,createAsinh:XW},W9={matrixDependencies:M9,NodeDependencies:v9,subsetDependencies:N9,createAssignmentNode:k7},V9={typedDependencies:b9,createAtan:ZW},G9={BigNumberDependencies:h9,DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createAtan2:fZ},K9={ComplexDependencies:f9,typedDependencies:b9,createAtanh:eV},J9={BigNumberDependencies:h9,typedDependencies:b9,createBignumber:tV},X9={FractionDependencies:y9,typedDependencies:b9,createFraction:JK},Z9={typedDependencies:b9,createNumber:HG},Q9={bignumberDependencies:J9,fractionDependencies:X9,numberDependencies:Z9,createNumeric:bJ},eee={numericDependencies:Q9,typedDependencies:b9,createDivideScalar:mX},tee={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createEqual:xX},nee={BigNumberDependencies:h9,DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,zerosDependencies:O9,createRound:rZ},ree={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,roundDependencies:nee,typedDependencies:b9,zerosDependencies:O9,createCeil:MQ},aee={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,roundDependencies:nee,typedDependencies:b9,zerosDependencies:O9,createFloor:$Z},iee={ComplexDependencies:f9,DenseMatrixDependencies:g9,ceilDependencies:ree,equalScalarDependencies:_9,floorDependencies:aee,matrixDependencies:M9,typedDependencies:b9,zerosDependencies:O9,createFix:FQ},see={typedDependencies:b9,createFormat:rG},oee={typedDependencies:b9,createIsNumeric:ZK},uee={typedDependencies:b9,createMultiplyScalar:OG},lee={BigNumberDependencies:h9,DenseMatrixDependencies:g9,SparseMatrixDependencies:w9,matrixDependencies:M9,typedDependencies:b9,createIdentity:RZ},cee={typedDependencies:b9,createIsZero:vG},pee={typedDependencies:b9,createConj:CV},dee={matrixDependencies:M9,typedDependencies:b9,createSize:kJ},hee={addScalarDependencies:A9,conjDependencies:pee,multiplyScalarDependencies:uee,sizeDependencies:dee,typedDependencies:b9,createDot:TZ},fee={addScalarDependencies:A9,dotDependencies:hee,equalScalarDependencies:_9,matrixDependencies:M9,multiplyScalarDependencies:uee,typedDependencies:b9,createMultiply:VZ},mee={typedDependencies:b9,createUnaryMinus:WK},gee={DenseMatrixDependencies:g9,addScalarDependencies:A9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,unaryMinusDependencies:mee,createSubtract:BJ},yee={divideScalarDependencies:eee,isZeroDependencies:cee,matrixDependencies:M9,multiplyDependencies:fee,subtractDependencies:gee,typedDependencies:b9,unaryMinusDependencies:mee,createDet:TQ},bee={absDependencies:x9,addScalarDependencies:A9,detDependencies:yee,divideScalarDependencies:eee,identityDependencies:lee,matrixDependencies:M9,multiplyDependencies:fee,typedDependencies:b9,unaryMinusDependencies:mee,createInv:o0},xee={ComplexDependencies:f9,fractionDependencies:X9,identityDependencies:lee,invDependencies:bee,matrixDependencies:M9,multiplyDependencies:fee,numberDependencies:Z9,typedDependencies:b9,createPow:c0},vee={BigNumberDependencies:h9,ComplexDependencies:f9,FractionDependencies:y9,absDependencies:x9,addScalarDependencies:A9,divideScalarDependencies:eee,equalDependencies:tee,fixDependencies:iee,formatDependencies:see,isNumericDependencies:oee,multiplyScalarDependencies:uee,numberDependencies:Z9,powDependencies:xee,roundDependencies:nee,subtractDependencies:gee,createUnitClass:_0},_ee={BigNumberDependencies:h9,UnitDependencies:vee,createAtomicMass:bU},wee={BigNumberDependencies:h9,UnitDependencies:vee,createAvogadro:xU},Mee={typedDependencies:b9,createIsNegative:gG},Nee={typedDependencies:b9,createCombinations:DV},See={BigNumberDependencies:h9,ComplexDependencies:f9,multiplyScalarDependencies:uee,powDependencies:xee,typedDependencies:b9,createGamma:I0},kee={gammaDependencies:See,typedDependencies:b9,createFactorial:$0},Dee={DenseMatrixDependencies:g9,matrixDependencies:M9,typedDependencies:b9,createLarger:BZ},Tee={bignumberDependencies:J9,addScalarDependencies:A9,combinationsDependencies:Nee,divideScalarDependencies:eee,factorialDependencies:kee,isIntegerDependencies:F9,isNegativeDependencies:Mee,largerDependencies:Dee,multiplyScalarDependencies:uee,numberDependencies:Z9,powDependencies:xee,subtractDependencies:gee,typedDependencies:b9,createStirlingS2:H0},Iee={addScalarDependencies:A9,isIntegerDependencies:F9,isNegativeDependencies:Mee,stirlingS2Dependencies:Tee,typedDependencies:b9,createBellNumbers:W0},Eee={formatDependencies:see,typedDependencies:b9,createBin:NK},Cee={equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createBitAnd:JJ},Aee={typedDependencies:b9,createBitNot:xV},Lee={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createBitOr:gZ},$ee={DenseMatrixDependencies:g9,matrixDependencies:M9,typedDependencies:b9,createBitXor:ZJ},Oee={createResultSet:qU},Ree={NodeDependencies:v9,ResultSetDependencies:Oee,createBlockNode:m7},Fee={BigNumberDependencies:h9,UnitDependencies:vee,createBohrMagneton:Zj},Yee={BigNumberDependencies:h9,UnitDependencies:vee,createBohrRadius:aU},zee={BigNumberDependencies:h9,UnitDependencies:vee,createBoltzmann:vU},Bee={typedDependencies:b9,createBoolean:_V},Pee={addScalarDependencies:A9,combinationsDependencies:Nee,divideScalarDependencies:eee,isIntegerDependencies:F9,isNegativeDependencies:Mee,multiplyScalarDependencies:uee,typedDependencies:b9,createCatalan:bZ},Hee={BigNumberDependencies:h9,ComplexDependencies:f9,FractionDependencies:y9,isNegativeDependencies:Mee,matrixDependencies:M9,typedDependencies:b9,unaryMinusDependencies:mee,createCbrt:eX},jee={createChainClass:J6},Uee={ChainDependencies:jee,typedDependencies:b9,createChain:_7},qee={BigNumberDependencies:h9,UnitDependencies:vee,createClassicalElectronRadius:iU},Wee={typedDependencies:b9,createClone:MV},Vee={DenseMatrixDependencies:g9,matrixDependencies:M9,typedDependencies:b9,createSmaller:IJ},Gee={DenseMatrixDependencies:g9,smallerDependencies:Vee,createImmutableDenseMatrixClass:YQ},Kee={ImmutableDenseMatrixDependencies:Gee,createIndexClass:zQ},Jee={DenseMatrixDependencies:g9,matrixDependencies:M9,typedDependencies:b9,createLargerEq:$X},Xee={DenseMatrixDependencies:g9,matrixDependencies:M9,typedDependencies:b9,createSmallerEq:iZ},Zee={bignumberDependencies:J9,matrixDependencies:M9,largerDependencies:Dee,largerEqDependencies:Jee,smallerDependencies:Vee,smallerEqDependencies:Xee,typedDependencies:b9,createRange:JZ},Qee={IndexDependencies:Kee,matrixDependencies:M9,rangeDependencies:Zee,typedDependencies:b9,createColumn:a0},ete={IndexDependencies:Kee,matrixDependencies:M9,rangeDependencies:Zee,typedDependencies:b9,createColumnTransform:S8},tte={typedDependencies:b9,createCombinationsWithRep:kK},nte={BigNumberDependencies:h9,DenseMatrixDependencies:g9,FractionDependencies:y9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createCompare:nX},rte={compareDependencies:nte,typedDependencies:b9,createCompareNatural:_Z},ate={matrixDependencies:M9,typedDependencies:b9,createCompareText:aX},ite={NodeDependencies:v9,createConditionalNode:g7},ste={NodeDependencies:v9,createConstantNode:y7},ote={NodeDependencies:v9,typedDependencies:b9,createFunctionAssignmentNode:w7},ute={UnitDependencies:vee,NodeDependencies:v9,createSymbolNode:T7},lte={NodeDependencies:v9,SymbolNodeDependencies:ute,createFunctionNode:E7},cte={NodeDependencies:v9,sizeDependencies:dee,createIndexNode:D7},pte={NodeDependencies:v9,createObjectNode:Q6},dte={NodeDependencies:v9,createOperatorNode:p7},hte={NodeDependencies:v9,createParenthesisNode:d7},fte={NodeDependencies:v9,createRangeNode:b7},mte={NodeDependencies:v9,createRelationalNode:h7},gte={AccessorNodeDependencies:S9,ArrayNodeDependencies:P9,AssignmentNodeDependencies:W9,BlockNodeDependencies:Ree,ConditionalNodeDependencies:ite,ConstantNodeDependencies:ste,FunctionAssignmentNodeDependencies:ote,FunctionNodeDependencies:lte,IndexNodeDependencies:cte,ObjectNodeDependencies:pte,OperatorNodeDependencies:dte,ParenthesisNodeDependencies:hte,RangeNodeDependencies:fte,RelationalNodeDependencies:mte,SymbolNodeDependencies:ute,numericDependencies:Q9,typedDependencies:b9,createParse:A7},yte={parseDependencies:gte,typedDependencies:b9,createCompile:z7},bte={ComplexDependencies:f9,typedDependencies:b9,createComplex:IV},xte={typedDependencies:b9,createIsPositive:bG},vte={addScalarDependencies:A9,combinationsDependencies:Nee,isIntegerDependencies:F9,isNegativeDependencies:Mee,isPositiveDependencies:xte,largerDependencies:Dee,typedDependencies:b9,createComposition:SQ},_te={isIntegerDependencies:F9,matrixDependencies:M9,typedDependencies:b9,createConcat:sX},wte={isIntegerDependencies:F9,matrixDependencies:M9,typedDependencies:b9,createConcatTransform:y8},Mte={BigNumberDependencies:h9,UnitDependencies:vee,createConductanceQuantum:Qj},Nte={typedDependencies:b9,createCos:TK},Ste={typedDependencies:b9,createCosh:LV},kte={BigNumberDependencies:h9,typedDependencies:b9,createCot:KK},Dte={BigNumberDependencies:h9,typedDependencies:b9,createCoth:OV},Tte={BigNumberDependencies:h9,UnitDependencies:vee,createCoulomb:Jj},Ite={multiplyScalarDependencies:uee,numericDependencies:Q9,typedDependencies:b9,createProd:wJ},Ete={prodDependencies:Ite,sizeDependencies:dee,typedDependencies:b9,createCount:lX},Cte={UnitDependencies:vee,typedDependencies:b9,createCreateUnit:M0},Ate={matrixDependencies:M9,multiplyDependencies:fee,subtractDependencies:gee,typedDependencies:b9,createCross:DQ},Lte={BigNumberDependencies:h9,typedDependencies:b9,createCsc:RV},$te={BigNumberDependencies:h9,typedDependencies:b9,createCsch:EK},Ote={matrixDependencies:M9,typedDependencies:b9,createTranspose:jJ},Rte={conjDependencies:pee,transposeDependencies:Ote,typedDependencies:b9,createCtranspose:pX},Fte={typedDependencies:b9,createCube:YV},Yte={BigNumberDependencies:h9,typedDependencies:b9,createUnaryPlus:_W},zte={addDependencies:L9,typedDependencies:b9,unaryPlusDependencies:Yte,createCumSum:MZ},Bte={addDependencies:L9,typedDependencies:b9,unaryPlusDependencies:Yte,createCumSumTransform:M8},Pte={equalDependencies:tee,typedDependencies:b9,createDeepEqual:SZ},Hte={divideScalarDependencies:eee,equalScalarDependencies:_9,invDependencies:bee,matrixDependencies:M9,multiplyDependencies:fee,typedDependencies:b9,createDivide:A0},jte={ConstantNodeDependencies:ste,FunctionNodeDependencies:lte,OperatorNodeDependencies:dte,ParenthesisNodeDependencies:hte,parseDependencies:gte,createResolve:L7},Ute={AccessorNodeDependencies:S9,ArrayNodeDependencies:P9,ConstantNodeDependencies:ste,FunctionNodeDependencies:lte,IndexNodeDependencies:cte,ObjectNodeDependencies:pte,OperatorNodeDependencies:dte,ParenthesisNodeDependencies:hte,SymbolNodeDependencies:ute,addDependencies:L9,divideDependencies:Hte,equalDependencies:tee,isZeroDependencies:cee,multiplyDependencies:fee,powDependencies:xee,subtractDependencies:gee,createSimplifyCore:F7},qte={bignumberDependencies:J9,fractionDependencies:X9,AccessorNodeDependencies:S9,ArrayNodeDependencies:P9,ConstantNodeDependencies:ste,FunctionNodeDependencies:lte,IndexNodeDependencies:cte,ObjectNodeDependencies:pte,OperatorNodeDependencies:dte,ParenthesisNodeDependencies:hte,SymbolNodeDependencies:ute,addDependencies:L9,divideDependencies:Hte,equalDependencies:tee,isZeroDependencies:cee,matrixDependencies:M9,multiplyDependencies:fee,parseDependencies:gte,powDependencies:xee,resolveDependencies:jte,simplifyCoreDependencies:Ute,subtractDependencies:gee,typedDependencies:b9,createSimplify:U7},Wte={ConstantNodeDependencies:ste,FunctionNodeDependencies:lte,OperatorNodeDependencies:dte,ParenthesisNodeDependencies:hte,SymbolNodeDependencies:ute,equalDependencies:tee,isZeroDependencies:cee,numericDependencies:Q9,parseDependencies:gte,simplifyDependencies:qte,typedDependencies:b9,createDerivative:r8},Vte={BigNumberDependencies:h9,UnitDependencies:vee,createDeuteronMass:pU},Gte={DenseMatrixDependencies:g9,SparseMatrixDependencies:w9,matrixDependencies:M9,typedDependencies:b9,createDiag:hX},Kte={matrixDependencies:M9,numberDependencies:Z9,subtractDependencies:gee,typedDependencies:b9,createDiff:DZ},Jte={bignumberDependencies:J9,matrixDependencies:M9,numberDependencies:Z9,subtractDependencies:gee,typedDependencies:b9,createDiffTransform:m8},Xte={ComplexDependencies:f9,typedDependencies:b9,createSqrt:jK},Zte={absDependencies:x9,addScalarDependencies:A9,divideScalarDependencies:eee,multiplyScalarDependencies:uee,sqrtDependencies:Xte,subtractDependencies:gee,typedDependencies:b9,unaryMinusDependencies:mee,createDistance:EQ},Qte={DenseMatrixDependencies:g9,divideScalarDependencies:eee,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createDotDivide:yX},ene={equalScalarDependencies:_9,matrixDependencies:M9,multiplyScalarDependencies:uee,typedDependencies:b9,createDotMultiply:AQ},tne={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,powDependencies:xee,typedDependencies:b9,createDotPow:S0},nne={BigNumberDependencies:h9,createE:Ej},rne={BigNumberDependencies:h9,createEfimovFactor:yU},ane={matrixDependencies:M9,typedDependencies:b9,createFlatten:wX},ine={typedDependencies:b9,createIm:oG},sne={flattenDependencies:ane,matrixDependencies:M9,sizeDependencies:dee,typedDependencies:b9,createMatrixFromColumns:HX},one={BigNumberDependencies:h9,FractionDependencies:y9,complexDependencies:bte,typedDependencies:b9,createSign:rK},une={addScalarDependencies:A9,complexDependencies:bte,conjDependencies:pee,divideScalarDependencies:eee,equalDependencies:tee,identityDependencies:lee,isZeroDependencies:cee,matrixDependencies:M9,multiplyScalarDependencies:uee,signDependencies:one,sqrtDependencies:Xte,subtractDependencies:gee,typedDependencies:b9,unaryMinusDependencies:mee,zerosDependencies:O9,createQr:GZ},lne={typedDependencies:b9,createRe:eK},cne={typedDependencies:b9,createSin:aK},pne={DenseMatrixDependencies:g9,divideScalarDependencies:eee,equalScalarDependencies:_9,matrixDependencies:M9,multiplyScalarDependencies:uee,subtractDependencies:gee,typedDependencies:b9,createUsolve:lZ},dne={DenseMatrixDependencies:g9,divideScalarDependencies:eee,equalScalarDependencies:_9,matrixDependencies:M9,multiplyScalarDependencies:uee,subtractDependencies:gee,typedDependencies:b9,createUsolveAll:yQ},hne={absDependencies:x9,addDependencies:L9,addScalarDependencies:A9,atanDependencies:V9,bignumberDependencies:J9,columnDependencies:Qee,complexDependencies:bte,cosDependencies:Nte,diagDependencies:Gte,divideScalarDependencies:eee,dotDependencies:hee,equalDependencies:tee,flattenDependencies:ane,imDependencies:ine,invDependencies:bee,largerDependencies:Dee,matrixDependencies:M9,matrixFromColumnsDependencies:sne,multiplyDependencies:fee,multiplyScalarDependencies:uee,numberDependencies:Z9,qrDependencies:une,reDependencies:lne,sinDependencies:cne,smallerDependencies:Vee,sqrtDependencies:Xte,subtractDependencies:gee,typedDependencies:b9,usolveDependencies:pne,usolveAllDependencies:dne,createEigs:V0},fne={BigNumberDependencies:h9,UnitDependencies:vee,createElectricConstant:Gj},mne={BigNumberDependencies:h9,UnitDependencies:vee,createElectronMass:sU},gne={BigNumberDependencies:h9,UnitDependencies:vee,createElementaryCharge:Xj},yne={compareTextDependencies:ate,isZeroDependencies:cee,typedDependencies:b9,createEqualText:EZ},bne={typedDependencies:b9,createErf:HV},xne={parseDependencies:gte,typedDependencies:b9,createEvaluate:G7},vne={typedDependencies:b9,createExp:GV},_ne={absDependencies:x9,addDependencies:L9,identityDependencies:lee,invDependencies:bee,multiplyDependencies:fee,typedDependencies:b9,createExpm:D0},wne={ComplexDependencies:f9,typedDependencies:b9,createExpm1:JV},Mne={createFalse:Nj},Nne={BigNumberDependencies:h9,UnitDependencies:vee,createFaraday:_U},Sne={BigNumberDependencies:h9,UnitDependencies:vee,createFermiCoupling:oU},kne={ComplexDependencies:f9,createI:Yj},Dne={BigNumberDependencies:h9,createTau:Ij},Tne={addScalarDependencies:A9,divideScalarDependencies:eee,expDependencies:vne,iDependencies:kne,matrixDependencies:M9,multiplyScalarDependencies:uee,tauDependencies:Dne,typedDependencies:b9,createFft:vX},Ine={largerDependencies:Dee,smallerDependencies:Vee,createFibonacciHeapClass:LQ},Ene={typedDependencies:b9,createFilter:XV},Cne={typedDependencies:b9,createFilterTransform:o8},Ane={BigNumberDependencies:h9,createFineStructure:uU},Lne={BigNumberDependencies:h9,UnitDependencies:vee,createFirstRadiation:wU},$ne={typedDependencies:b9,createForEach:eG},One={typedDependencies:b9,createForEachTransform:l8},Rne={BigNumberDependencies:h9,UnitDependencies:vee,createGasConstant:NU},Fne={BigNumberDependencies:h9,DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createGcd:NX},Yne={typedDependencies:b9,createGetMatrixDataType:iG},zne={BigNumberDependencies:h9,UnitDependencies:vee,createGravitationConstant:Uj},Bne={BigNumberDependencies:h9,UnitDependencies:vee,createGravity:LU},Pne={BigNumberDependencies:h9,UnitDependencies:vee,createHartreeEnergy:lU},Hne={isNumericDependencies:oee,typedDependencies:b9,createHasNumericValue:kX},jne={parseDependencies:gte,createHelpClass:B7},Une={HelpDependencies:jne,typedDependencies:b9,createHelp:Q7},qne={formatDependencies:see,typedDependencies:b9,createHex:sG},Wne={absDependencies:x9,addScalarDependencies:A9,divideScalarDependencies:eee,isPositiveDependencies:xte,multiplyScalarDependencies:uee,smallerDependencies:Vee,sqrtDependencies:Xte,typedDependencies:b9,createHypot:TX},Vne={conjDependencies:pee,dotDivideDependencies:Qte,fftDependencies:Tne,typedDependencies:b9,createIfft:EX},Gne={IndexDependencies:Kee,typedDependencies:b9,createIndex:s0},Kne={IndexDependencies:Kee,createIndexTransform:k8},Jne={BigNumberDependencies:h9,createInfinity:kj},Xne={absDependencies:x9,addDependencies:L9,addScalarDependencies:A9,divideScalarDependencies:eee,equalScalarDependencies:_9,flattenDependencies:ane,isNumericDependencies:oee,isZeroDependencies:cee,matrixDependencies:M9,multiplyDependencies:fee,multiplyScalarDependencies:uee,smallerDependencies:Vee,subtractDependencies:gee,typedDependencies:b9,createIntersect:BQ},Zne={BigNumberDependencies:h9,UnitDependencies:vee,createInverseConductanceQuantum:eU},Qne={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createMod:cJ},ere={BigNumberDependencies:h9,matrixDependencies:M9,typedDependencies:b9,createXgcd:qJ},tre={BigNumberDependencies:h9,addDependencies:L9,equalDependencies:tee,isIntegerDependencies:F9,modDependencies:Qne,smallerDependencies:Vee,typedDependencies:b9,xgcdDependencies:ere,createInvmod:YZ},nre={typedDependencies:b9,createIsNaN:AK},rre={typedDependencies:b9,createIsPrime:$K},are={ComplexDependencies:f9,divideScalarDependencies:eee,typedDependencies:b9,createLog:PZ},ire={addDependencies:L9,numericDependencies:Q9,typedDependencies:b9,createSum:fQ},sre={divideDependencies:Hte,dotDivideDependencies:Qte,isNumericDependencies:oee,logDependencies:are,matrixDependencies:M9,multiplyDependencies:fee,sumDependencies:ire,typedDependencies:b9,createKldivergence:f1},ore={BigNumberDependencies:h9,UnitDependencies:vee,createKlitzing:rU},ure={matrixDependencies:M9,multiplyScalarDependencies:uee,typedDependencies:b9,createKron:AX},lre={BigNumberDependencies:h9,createLN10:Lj},cre={BigNumberDependencies:h9,createLN2:Aj},pre={BigNumberDependencies:h9,createLOG10E:Oj},dre={BigNumberDependencies:h9,createLOG2E:$j},hre={equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createLcm:PQ},fre={parseDependencies:gte,typedDependencies:b9,createLeafCount:H7},mre={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,zerosDependencies:O9,createLeftShift:FX},gre={ComplexDependencies:f9,typedDependencies:b9,createLgamma:TG},yre={ComplexDependencies:f9,typedDependencies:b9,createLog10:EG},bre={ComplexDependencies:f9,divideScalarDependencies:eee,logDependencies:are,typedDependencies:b9,createLog1p:jQ},xre={ComplexDependencies:f9,typedDependencies:b9,createLog2:AG},vre={BigNumberDependencies:h9,UnitDependencies:vee,createLoschmidt:MU},_re={DenseMatrixDependencies:g9,divideScalarDependencies:eee,equalScalarDependencies:_9,matrixDependencies:M9,multiplyScalarDependencies:uee,subtractDependencies:gee,typedDependencies:b9,createLsolve:BX},wre={DenseMatrixDependencies:g9,divideScalarDependencies:eee,equalScalarDependencies:_9,matrixDependencies:M9,multiplyScalarDependencies:uee,subtractDependencies:gee,typedDependencies:b9,createLsolveAll:jZ},Mre={FibonacciHeapDependencies:Ine,addScalarDependencies:A9,equalScalarDependencies:_9,createSpaClass:m0},Nre={DenseMatrixDependencies:g9,SpaDependencies:Mre,SparseMatrixDependencies:w9,absDependencies:x9,addScalarDependencies:A9,divideScalarDependencies:eee,equalScalarDependencies:_9,largerDependencies:Dee,matrixDependencies:M9,multiplyScalarDependencies:uee,subtractDependencies:gee,typedDependencies:b9,unaryMinusDependencies:mee,createLup:O0},Sre={SparseMatrixDependencies:w9,absDependencies:x9,addDependencies:L9,divideScalarDependencies:eee,largerDependencies:Dee,largerEqDependencies:Jee,multiplyDependencies:fee,subtractDependencies:gee,transposeDependencies:Ote,typedDependencies:b9,createSlu:hQ},kre={DenseMatrixDependencies:g9,lsolveDependencies:_re,lupDependencies:Nre,matrixDependencies:M9,sluDependencies:Sre,typedDependencies:b9,usolveDependencies:pne,createLusolve:t1},Dre={typedDependencies:b9,createMap:LG},Tre={compareDependencies:nte,isNaNDependencies:nre,isNumericDependencies:oee,typedDependencies:b9,createPartitionSelect:JX},Ire={addDependencies:L9,compareDependencies:nte,divideDependencies:Hte,partitionSelectDependencies:Tre,typedDependencies:b9,createMedian:a1},Ere={absDependencies:x9,mapDependencies:Dre,medianDependencies:Ire,subtractDependencies:gee,typedDependencies:b9,createMad:N1},Cre={BigNumberDependencies:h9,UnitDependencies:vee,createMagneticConstant:Vj},Are={BigNumberDependencies:h9,UnitDependencies:vee,createMagneticFluxQuantum:tU},Lre={typedDependencies:b9,createMapTransform:c8},$re={isZeroDependencies:cee,matrixDependencies:M9,typedDependencies:b9,createMatrixFromFunction:nJ},Ore={flattenDependencies:ane,matrixDependencies:M9,sizeDependencies:dee,typedDependencies:b9,createMatrixFromRows:qZ},Rre={largerDependencies:Dee,numericDependencies:Q9,typedDependencies:b9,createMax:UQ},Fre={largerDependencies:Dee,numericDependencies:Q9,typedDependencies:b9,createMaxTransform:b8},Yre={addDependencies:L9,divideDependencies:Hte,typedDependencies:b9,createMean:K0},zre={addDependencies:L9,divideDependencies:Hte,typedDependencies:b9,createMeanTransform:D8},Bre={numericDependencies:Q9,smallerDependencies:Vee,typedDependencies:b9,createMin:jX},Pre={numericDependencies:Q9,smallerDependencies:Vee,typedDependencies:b9,createMinTransform:x8},Hre={isNaNDependencies:nre,isNumericDependencies:oee,typedDependencies:b9,createMode:qX},jre={BigNumberDependencies:h9,UnitDependencies:vee,createMolarMass:CU},Ure={BigNumberDependencies:h9,UnitDependencies:vee,createMolarMassC12:AU},qre={BigNumberDependencies:h9,UnitDependencies:vee,createMolarPlanckConstant:SU},Wre={BigNumberDependencies:h9,UnitDependencies:vee,createMolarVolume:kU},Vre={addDependencies:L9,divideDependencies:Hte,factorialDependencies:kee,isIntegerDependencies:F9,isPositiveDependencies:xte,multiplyDependencies:fee,typedDependencies:b9,createMultinomial:F0},Gre={BigNumberDependencies:h9,createNaN:Dj},Kre={BigNumberDependencies:h9,UnitDependencies:vee,createNeutronMass:dU},Jre={absDependencies:x9,addDependencies:L9,conjDependencies:pee,ctransposeDependencies:Rte,eigsDependencies:hne,equalScalarDependencies:_9,largerDependencies:Dee,matrixDependencies:M9,multiplyDependencies:fee,powDependencies:xee,smallerDependencies:Vee,sqrtDependencies:Xte,typedDependencies:b9,createNorm:y1},Xre={BigNumberDependencies:h9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createNthRoot:fJ},Zre={ComplexDependencies:f9,divideScalarDependencies:eee,typedDependencies:b9,createNthRoots:VX},Qre={BigNumberDependencies:h9,UnitDependencies:vee,createNuclearMagneton:nU},eae={createNull:Sj},tae={formatDependencies:see,typedDependencies:b9,createOct:jG},nae={BigNumberDependencies:h9,matrixDependencies:M9,typedDependencies:b9,createOnes:GX},rae={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createOr:xJ},aae={evaluateDependencies:xne,createParserClass:e8},iae={ParserDependencies:aae,typedDependencies:b9,createParser:i8},sae={factorialDependencies:kee,typedDependencies:b9,createPermutations:z0},oae={BigNumberDependencies:h9,createPhi:Cj},uae={BigNumberDependencies:h9,createPi:Tj},lae={typedDependencies:b9,createPickRandom:VG},cae={ComplexDependencies:f9,addDependencies:L9,ctransposeDependencies:Rte,deepEqualDependencies:Pte,divideScalarDependencies:eee,dotDependencies:hee,dotDivideDependencies:Qte,equalDependencies:tee,invDependencies:bee,matrixDependencies:M9,multiplyDependencies:fee,typedDependencies:b9,createPinv:l0},pae={BigNumberDependencies:h9,UnitDependencies:vee,createPlanckCharge:FU},dae={BigNumberDependencies:h9,UnitDependencies:vee,createPlanckConstant:qj},hae={BigNumberDependencies:h9,UnitDependencies:vee,createPlanckLength:$U},fae={BigNumberDependencies:h9,UnitDependencies:vee,createPlanckMass:OU},mae={BigNumberDependencies:h9,UnitDependencies:vee,createPlanckTemperature:YU},gae={BigNumberDependencies:h9,UnitDependencies:vee,createPlanckTime:RU},yae={typedDependencies:b9,createPrint:KG},bae={BigNumberDependencies:h9,UnitDependencies:vee,createProtonMass:cU},xae={addDependencies:L9,compareDependencies:nte,multiplyDependencies:fee,partitionSelectDependencies:Tre,typedDependencies:b9,createQuantileSeq:qQ},vae={BigNumberDependencies:h9,UnitDependencies:vee,createQuantumOfCirculation:hU},_ae={typedDependencies:b9,createRandom:QG},wae={typedDependencies:b9,createRandomInt:RK},Mae={createRangeClass:UU},Nae={bignumberDependencies:J9,matrixDependencies:M9,largerDependencies:Dee,largerEqDependencies:Jee,smallerDependencies:Vee,smallerEqDependencies:Xee,typedDependencies:b9,createRangeTransform:v8},Sae={bignumberDependencies:J9,fractionDependencies:X9,AccessorNodeDependencies:S9,ArrayNodeDependencies:P9,ConstantNodeDependencies:ste,FunctionNodeDependencies:lte,IndexNodeDependencies:cte,ObjectNodeDependencies:pte,OperatorNodeDependencies:dte,ParenthesisNodeDependencies:hte,SymbolNodeDependencies:ute,addDependencies:L9,divideDependencies:Hte,equalDependencies:tee,isZeroDependencies:cee,matrixDependencies:M9,multiplyDependencies:fee,parseDependencies:gte,powDependencies:xee,simplifyDependencies:qte,simplifyCoreDependencies:Ute,subtractDependencies:gee,typedDependencies:b9,createRationalize:n8},kae={BigNumberDependencies:h9,UnitDependencies:vee,createReducedPlanckConstant:Wj},Dae={createReplacer:kq},Tae={isIntegerDependencies:F9,matrixDependencies:M9,typedDependencies:b9,createReshape:NJ},Iae={matrixDependencies:M9,createResize:ZX},Eae={createReviver:x7},Cae={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,zerosDependencies:O9,createRightArithShift:eZ},Aae={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,zerosDependencies:O9,createRightLogShift:ZZ},Lae={BigNumberDependencies:h9,DenseMatrixDependencies:g9,SparseMatrixDependencies:w9,addScalarDependencies:A9,cosDependencies:Nte,matrixDependencies:M9,multiplyScalarDependencies:uee,normDependencies:Jre,sinDependencies:cne,typedDependencies:b9,unaryMinusDependencies:mee,createRotationMatrix:v1},$ae={multiplyDependencies:fee,rotationMatrixDependencies:Lae,typedDependencies:b9,createRotate:D1},Oae={IndexDependencies:Kee,matrixDependencies:M9,rangeDependencies:Zee,typedDependencies:b9,createRow:WQ},Rae={IndexDependencies:Kee,matrixDependencies:M9,rangeDependencies:Zee,typedDependencies:b9,createRowTransform:N8},Fae={BigNumberDependencies:h9,UnitDependencies:vee,createRydberg:fU},Yae={BigNumberDependencies:h9,createSQRT1_2:Rj},zae={BigNumberDependencies:h9,createSQRT2:Fj},Bae={BigNumberDependencies:h9,createSackurTetrode:DU},Pae={BigNumberDependencies:h9,typedDependencies:b9,createSec:tK},Hae={BigNumberDependencies:h9,typedDependencies:b9,createSech:YK},jae={BigNumberDependencies:h9,UnitDependencies:vee,createSecondRadiation:TU},Uae={DenseMatrixDependencies:g9,IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetCartesian:GQ},qae={DenseMatrixDependencies:g9,IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetDifference:d0},Wae={DenseMatrixDependencies:g9,IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetDistinct:JQ},Vae={DenseMatrixDependencies:g9,IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetIntersect:C0},Gae={IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetIsSubset:ZQ},Kae={IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetMultiplicity:f0},Jae={IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetPowerset:e0},Xae={compareNaturalDependencies:rte,typedDependencies:b9,createSetSize:eQ},Zae={IndexDependencies:Kee,concatDependencies:_te,setDifferenceDependencies:qae,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetSymDifference:X0},Qae={IndexDependencies:Kee,concatDependencies:_te,setIntersectDependencies:Vae,setSymDifferenceDependencies:Zae,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetUnion:o1},eie={typedDependencies:b9,createSinh:BK},tie={compareDependencies:nte,compareNaturalDependencies:rte,matrixDependencies:M9,typedDependencies:b9,createSort:n0},nie={SparseMatrixDependencies:w9,typedDependencies:b9,createSparse:HK},rie={BigNumberDependencies:h9,UnitDependencies:vee,createSpeedOfLight:jj},aie={typedDependencies:b9,createSplitUnit:oK},iie={absDependencies:x9,addDependencies:L9,identityDependencies:lee,invDependencies:bee,maxDependencies:Rre,multiplyDependencies:fee,sizeDependencies:dee,sqrtDependencies:Xte,subtractDependencies:gee,typedDependencies:b9,createSqrtm:y0},sie={typedDependencies:b9,createSquare:lK},oie={matrixDependencies:M9,typedDependencies:b9,createSqueeze:CJ},uie={addDependencies:L9,applyDependencies:Y9,divideDependencies:Hte,isNaNDependencies:nre,multiplyDependencies:fee,subtractDependencies:gee,typedDependencies:b9,createVariance:p1},lie={sqrtDependencies:Xte,typedDependencies:b9,varianceDependencies:uie,createStd:w1},cie={sqrtDependencies:Xte,typedDependencies:b9,varianceDependencies:uie,createStdTransform:E8},pie={BigNumberDependencies:h9,UnitDependencies:vee,createStefanBoltzmann:IU},die={typedDependencies:b9,createString:pK},hie={matrixDependencies:M9,typedDependencies:b9,createSubsetTransform:g8},fie={addDependencies:L9,numericDependencies:Q9,typedDependencies:b9,createSumTransform:_8},mie={OperatorNodeDependencies:dte,parseDependencies:gte,simplifyDependencies:qte,typedDependencies:b9,createSymbolicEqual:W7},gie={typedDependencies:b9,createTan:dK},yie={typedDependencies:b9,createTanh:UK},bie={BigNumberDependencies:h9,UnitDependencies:vee,createThomsonCrossSection:mU},xie={matrixDependencies:M9,typedDependencies:b9,createTo:HJ},vie={addDependencies:L9,matrixDependencies:M9,typedDependencies:b9,createTrace:mQ},_ie={createTrue:Mj},wie={typedDependencies:b9,createTypeOf:fK},Mie={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createUnequal:oZ},Nie={UnitDependencies:vee,typedDependencies:b9,createUnitFunction:U0},Sie={eDependencies:nne,createUppercaseE:Bj},kie={piDependencies:uae,createUppercasePi:zj},Die={BigNumberDependencies:h9,UnitDependencies:vee,createVacuumImpedance:Kj},Tie={addDependencies:L9,applyDependencies:Y9,divideDependencies:Hte,isNaNDependencies:nre,multiplyDependencies:fee,subtractDependencies:gee,typedDependencies:b9,createVarianceTransform:I8},Iie={createVersion:Pj},Eie={BigNumberDependencies:h9,createWeakMixingAngle:gU},Cie={BigNumberDependencies:h9,UnitDependencies:vee,createWienDisplacement:EU},Aie={DenseMatrixDependencies:g9,matrixDependencies:M9,typedDependencies:b9,createXor:cZ},Lie=V,$ie=n(4279);function Oie(e,t){var n=OP({},RP,t);if("function"!=typeof Object.create)throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");var r,a,i=(r={isNumber:FP,isComplex:zP,isBigNumber:YP,isFraction:BP,isUnit:PP,isString:HP,isArray:jP,isMatrix:UP,isCollection:qP,isDenseMatrix:WP,isSparseMatrix:VP,isRange:GP,isIndex:KP,isBoolean:JP,isResultSet:XP,isHelp:ZP,isFunction:QP,isDate:eH,isRegExp:tH,isObject:nH,isNull:rH,isUndefined:aH,isAccessorNode:iH,isArrayNode:sH,isAssignmentNode:oH,isBlockNode:uH,isConditionalNode:lH,isConstantNode:cH,isFunctionAssignmentNode:pH,isFunctionNode:dH,isIndexNode:hH,isNode:fH,isObjectNode:mH,isOperatorNode:gH,isParenthesisNode:yH,isRangeNode:bH,isSymbolNode:xH,isChain:vH},a=new $ie,r.on=a.on.bind(a),r.off=a.off.bind(a),r.once=a.once.bind(a),r.emit=a.emit.bind(a),r);i.config=$H(n,i.emit),i.expression={transform:{},mathWithTransform:{config:i.config}};var s={},o=function(e,t,n,r){function a(t,a,s){if(s.wrap&&"function"==typeof a&&(u=function(){for(var e=[],t=0,r=arguments.length;t2&&void 0!==arguments[2]?arguments[2]:t.fn;if(Nq(i,"."))throw new Error("Factory name should not contain a nested path. Name: "+JSON.stringify(i));var o=d(t)?n.expression.transform:n,u=i in n.expression.transform,c=EH(o,i)?o[i]:void 0,h=function(){var r={};t.dependencies.map(BH).forEach((e=>{if(Nq(e,"."))throw new Error("Factory dependency should not contain a nested path. Name: "+JSON.stringify(e));"math"===e?r.math=n:"mathWithTransform"===e?r.mathWithTransform=n.expression.mathWithTransform:"classes"===e?r.classes=n:r[e]=n[e]}));var s=t(r);if(s&&"function"==typeof s.transform)throw new Error('Transforms cannot be attached to factory functions. Please create a separate function for it with exports.path="expression.transform"');if(void 0===c||a.override)return s;if(l(c)&&l(s))return e(c,s);if(a.silent)return c;throw new Error('Cannot import "'+i+'": already exists')};t.meta&&!1===t.meta.lazy?(o[i]=h(),c&&u?s(i):(d(t)||p(t))&&IH(n.expression.mathWithTransform,i,(()=>o[i]))):(IH(o,i,h),c&&u?s(i):(d(t)||p(t))&&IH(n.expression.mathWithTransform,i,(()=>o[i]))),r[i]=t,n.emit("import",i,h)}function u(e){return"function"==typeof e||"number"==typeof e||"string"==typeof e||"boolean"==typeof e||null===e||PP(e)||zP(e)||YP(e)||BP(e)||UP(e)||Array.isArray(e)}function l(e){return"function"==typeof e&&"object"==typeof e.signatures}function c(e){return!EH(h,e)}function p(e){return!(-1!==e.fn.indexOf(".")||EH(h,e.fn)||e.meta&&e.meta.isClass)}function d(e){return void 0!==e&&void 0!==e.meta&&!0===e.meta.isTransformFunction||!1}var h={expression:!0,type:!0,docs:!0,error:!0,json:!0,chain:!0};return function(e,t){var n=arguments.length;if(1!==n&&2!==n)throw new XX("import",n,1,2);function r(e,n,a){if(Array.isArray(n))n.forEach((t=>r(e,t)));else if("object"==typeof n)for(var i in n)EH(n,i)&&r(e,n[i],i);else if(zH(n)||void 0!==a){var s=zH(n)?d(n)?n.fn+".transform":n.fn:a;if(EH(e,s)&&e[s]!==n&&!t.silent)throw new Error('Cannot import "'+s+'" twice');e[s]=n}else if(!t.silent)throw new TypeError("Factory, Object, or Array expected")}t||(t={});var i={};for(var s in r(i,e),i)if(EH(i,s)){var l=i[s];if(zH(l))o(l,t);else if(u(l))a(s,l,t);else if(!t.silent)throw new TypeError("Factory, Object, or Array expected")}}}((function(){for(var e=arguments.length,t=new Array(e),n=0;n{CH(s).forEach((e=>{e&&e.meta&&e.meta.recreateOnConfigChange&&o(e,{override:!0})}))})),i.create=Oie.bind(null,e),i.factory=YH,i.import(CH(DH(e))),i.ArgumentsError=XX,i.DimensionError=eq,i.IndexError=tq,i}class Rie{constructor(e){this.pInst=e,this.turtle={},this.home()}home(){this.turtle.x=this.pInst.width/2,this.turtle.y=this.pInst.height/2,this.turtle.angle=0,this.turtle.pen=!0,this.turtle.pencolor="black",this.turtle.penwidth=1}pencolor(e){this.turtle.pencolor=e}pensize(e){this.turtle.penwidth=e}pendown(){this.turtle.pen=!0}penup(){this.turtle.pen=!1}setposition(e,t){this.turtle.x=e,this.turtle.y=t}position(){return[this.turtle.x,this.turtle.y]}left(e){this.turtle.angle-=e}right(e){this.turtle.angle+=e}setheading(e){this.turtle.angle=e}heading(){return this.turtle.angle}forward(e){const t=this._angleMode;this.pInst.angleMode(this.pInst.DEGREES);const n=this.turtle.x+e*this.pInst.cos(this.turtle.angle-90),r=this.turtle.y+e*this.pInst.sin(this.turtle.angle-90);this.pInst.angleMode(t),this.turtle.pen&&(this.pInst.push(),this.pInst.strokeWeight(this.turtle.penwidth),this.pInst.stroke(this.turtle.pencolor),this.pInst.line(this.turtle.x,this.turtle.y,n,r),this.pInst.pop()),this.turtle.x=n,this.turtle.y=r}back(e){this.forward(-e)}circle(e){this.turtle.pen&&(this.pInst.push(),this.pInst.strokeWeight(this.turtle.penwidth),this.pInst.stroke(this.turtle.pencolor),this.pInst.circle(this.turtle.x,this.turtle.y,2*e),this.pInst.pop())}}const Fie=p5.prototype.circle;p5.prototype.circle=function(){Fie&&(1!==arguments.length?Fie.call(this,...arguments):this.getDefaultTurtle().circle(arguments[0]))},p5.prototype.createTurtle=function(){return new Rie(this)},p5.prototype.getDefaultTurtle=function(){return this.defaultTurtle||(this.defaultTurtle=this.createTurtle()),this.defaultTurtle},p5.prototype.home=function(){this.getDefaultTurtle().home()},p5.prototype.pencolor=function(e){this.getDefaultTurtle().pencolor(e)},p5.prototype.pensize=function(e){this.getDefaultTurtle().pensize(e)},p5.prototype.pendown=function(){this.getDefaultTurtle().pendown()},p5.prototype.penup=function(){this.getDefaultTurtle().penup()},p5.prototype.setposition=function(e,t){this.getDefaultTurtle().setposition(e,t)},p5.prototype.position=function(){return this.getDefaultTurtle().position()},p5.prototype.left=function(e){this.getDefaultTurtle().left(e)},p5.prototype.right=function(e){this.getDefaultTurtle().right(e)},p5.prototype.setheading=function(e){this.getDefaultTurtle().setheading(e)},p5.prototype.heading=function(){return this.getDefaultTurtle().heading()},p5.prototype.forward=function(e){this.getDefaultTurtle().forward(e)},p5.prototype.back=function(e){this.getDefaultTurtle().back(e)};var Yie=n9,zie=p9,Bie=o9,Pie=Q8,Hie=i9;const jie=p5;var Uie=jie.prototype.createVector,qie=function(){function e(t){if(this.isComplex=!1,"number"==typeof t)this.tensor=Ru(t);else if(t instanceof Array)this.tensor=Fi(t);else if(t instanceof jie.Vector){var n=t.array();this.tensor=Fi(n)}else if(t instanceof e)this.tensor=t.tensor;else{if(!(t instanceof ti))throw new Error("Tensors must be created from Numbers, Arrays, or p5.Vectors.");this.tensor=t}this.shape=this.tensor.shape}return e.prototype.toString=function(){return this.tensor.toString()},e.prototype.print=function(){this.tensor.print()},e.prototype.array=function(){return function(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}(this,void 0,void 0,(function(){var e,t;return function(e,t){var n,r,a,i,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(i){return function(o){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]100)throw new Error("Percentile must be in the range [0, 100].");r.push(n*(e/100))})),r}if(t<0||t>100)throw new Error("Percentile must be in the range [0, 100].");return n*(t/100)},Xse=function(e,t){var n=Kse(e);if(t instanceof Array){var r=[];return t.forEach((function(e){if(e<0||e>1)throw new Error("Quantile must be in the range [0, 1].");r.push(n*e)})),r}if(t<0||t>1)throw new Error("Quantile must be in the range [0, 1].");return n*t},Zse=function(e,t,n){var r=e.tensor.mean(t,n);return new qie(r)},Qse=function(e,t){if(t instanceof qie){var n=e.mult(t),r=n.sum(),a=t.sum(),i=r.div(a);return n.dispose(),r.dispose(),a.dispose(),i}return Zse(e)},eoe=function(e){var t=ho((function(){var t=Zse(e),n=e.sub(t).sq().sum(),r=e.shape.reduce((function(e,t){return e*t}));return n.div(r).sqrt().tensor}));return new qie(t)},toe=function(e){var t=eoe(e),n=t.sq();return t.dispose(),n};const noe=function(e){var t=e.pg,n=e.originX,r=e.originY,a=e.width,i=e.height,s=e.annotationsPalette;t.push(),t.fill(s.backgroundColor),t.strokeWeight(1),t.stroke(s.backgroundColor),t.rect(n,r,a,-i),t.pop()};var roe=n(7484),aoe=function(e,t,n){void 0===n&&(n=50);for(var r=[],a=(t-e)/(n-1),i=0;it.value?1:e.value100?t.round(x,0):t.round(x,1)),t.text(b,f[y],g)}t.pop()}(this.props):function(e){var t=e.pg,n=e.dataset,r=e.x,a=e.y,i=e.originX,s=e.originY,o=e.majorTicks,u=e.minorTicks,l=e.tickSize,c=e.annotationsPalette,p=e.xRange;t.push(),t.fill(c.fontColor),t.noStroke(),t.textAlign(t.CENTER,t.CENTER),t.translate(i,s);for(var d=n.getSorted(r,a),h=p||d.xRange,f=ioe(e),m=aoe(h.min,h.max,o+1),g=4*l,y=0;y100?t.round(x,0):t.round(x,1)),t.text(b,f[y],g)}t.pop()}(this.props)},e.prototype.yticks=function(e){this.props=Loe(Loe({},this.props),e),function(e){var t,n=e.pg,r=e.dataset,a=e.x,i=e.y,s=e.originX,o=e.originY,u=e.majorTicks,l=e.minorTicks,c=e.tickSize,p=e.annotationsPalette,d=e.numBins,h=e.yRange;n.push(),n.fill(p.fontColor),n.noStroke(),n.textAlign(n.CENTER,n.CENTER),n.translate(s,o),t=h||(d>0?r.getBinned(a,d).xRange:r.getSorted(a,i).yRange);for(var f=soe(e),m=aoe(t.min,t.max,u+1),g=-5*c,y=0;y100?n.round(x,0):n.round(x,1)),n.text(b,g,-f[y])}n.pop()}(this.props)},e.prototype.background=function(e){this.props.annotationsPalette.backgroundColor=e||this.props.annotationsPalette.backgroundColor,this.layers.unshift({props:this.props,operation:noe})},e.prototype.margin=function(e){this.props.annotationsPalette.marginColor=e||this.props.annotationsPalette.marginColor,this.layers.unshift({props:this.props,operation:moe})},e.prototype.bar=function(e){this.props=Loe(Loe({},this.props),e),this.props.numBins=this.props.numBins||20,this.layers.push({props:this.props,operation:Noe})},e.prototype.point=function(e){this.props=Loe(Loe({},this.props),e),this.layers.push({props:this.props,operation:Soe})},e.prototype.line=function(e){this.props=Loe(Loe({},this.props),e),this.layers.push({props:this.props,operation:koe})},e}();p5.prototype.registerMethod("init",(function(){this._plots=[]})),p5.prototype.createPlot=function(e){var t=new $oe(this,e);return this._plots.push(t),t},p5.prototype.registerMethod("post",(function(){this._plots.forEach((function(e){e.clear()}))})),p5.prototype.registerMethod("remove",(function(){this._plots.forEach((function(e){return e.props.pg.remove()})),this._plots=void 0}));var Ooe=n(178);function Roe(e,...t){if("function"==typeof e)throw new Error("You must supply the data as the first argument to tidy()");let n=e;for(const e of t)e&&(n=e(n));return n}function Foe(e){return t=>t.filter(e)}function Yoe(e){return t=>t.map(e)}function zoe(e){return null==e?[]:Array.isArray(e)?e:[e]}function Boe(e,t){return et?1:e>=t?0:NaN}function Poe(e){return t=>{const n=zoe(e).map((e=>"function"==typeof e?1===e.length?Hoe(e):e:Hoe(e)));return t.slice().sort(((e,t)=>{for(const r of n){const n=r(e,t);if(n)return n}return 0}))}}function Hoe(e){const t="function"==typeof e?e:t=>t[e];return function(e,n){return Uoe(t(e),t(n),!1)}}function joe(e){const t="function"==typeof e?e:t=>t[e];return function(e,n){return Uoe(t(e),t(n),!0)}}function Uoe(e,t,n){let r=n?t:e,a=n?e:t;if(qoe(r)&&qoe(a)){const e=(r!=r?0:null===r?1:2)-(a!=a?0:null===a?1:2);return n?-e:e}return qoe(r)?n?-1:1:qoe(a)?n?1:-1:Boe(r,a)}function qoe(e){return null==e||e!=e}function Woe(e,t){return n=>{t=null!=t?t:{};const r={},a=Object.keys(e);for(const t of a)r[t]=e[t](n);if(t.rest&&n.length){const e=Object.keys(n[0]);for(const i of e)a.includes(i)||(r[i]=t.rest(i)(n))}return[r]}}function Voe(e,t,n,r){if(!e.length)return[];const a={};let i;if(null==r)i=Object.keys(e[0]);else{i=[];for(const t of zoe(r))"function"==typeof t?i.push(...t(e)):i.push(t)}for(const r of i)n&&!n(e.map((e=>e[r])))||(a[r]=t(r)(e));return[a]}function Goe(e){return t=>Voe(t,e)}function Koe(e,t){return n=>Voe(n,t,e)}function Joe(e,t){return n=>Voe(n,t,void 0,e)}function Xoe(e){return t=>{const n=[];for(const r of t){const t={...r};for(const n in e){const r=e[n],a="function"==typeof r?r(t):r;t[n]=a}n.push(t)}return n}}class Zoe extends Map{constructor(e,t=eue){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),null!=e)for(const[t,n]of e)this.set(t,n)}get(e){return super.get(Qoe(this,e))}has(e){return super.has(Qoe(this,e))}set(e,t){return super.set(function({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}(this,e),t)}delete(e){return super.delete(function({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(n),e.delete(r)),n}(this,e))}}function Qoe({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function eue(e){return null!==e&&"object"==typeof e?e.valueOf():e}function tue(e){return e}function nue(e,t){if(null==e||"object"!=typeof e||Array.isArray(e))return e;const n=Object.fromEntries(t.filter((e=>"function"!=typeof e[0])));return Object.assign(n,e)}function rue(e,t,n,r,a,i=0){for(const[s,o]of e.entries()){const e=[...n,s];o instanceof Map?rue(o,r(t,e,i),e,r,a,i+1):a(t,e,o,i)}return t}function aue(e,t,n=(e=>e[e.length-1])){const r=new Map;return rue(e,r,[],(function(e,t){const r=new Map;return e.set(n(t),r),r}),(function(e,r,a){e.set(n(r),t(a,r))})),r}Set;const iue=e=>e;function sue(e,t,n){"function"==typeof t?t=[t]:2!==arguments.length||null==t||Array.isArray(t)||(n=t);const r=r=>{const a=oue(uue(r,e),t,null==n?void 0:n.addGroupKeys);if(null==n?void 0:n.export)switch(n.export){case"grouped":return a;case"levels":return pue(a,n);case"entries-obj":case"entriesObject":return pue(a,{...n,export:"levels",levels:["entries-object"]});default:return pue(a,{...n,export:"levels",levels:[n.export]})}return lue(a,null==n?void 0:n.addGroupKeys)};return r}function oue(e,t,n){let r=e;if(!(null==t?void 0:t.length))return r;for(const e of t)e&&(r=aue(r,((t,r)=>{let a=e(t,{groupKeys:r});return!1!==n&&(a=a.map((e=>nue(e,r)))),a})));return r}function uue(e,t){const n=function(e,...t){return function(e,t,n,r){return function e(a,i){if(i>=r.length)return n(a);const s=new Zoe,o=r[i++];let u=-1;for(const e of a){const t=o(e,++u,a),n=s.get(t);n?n.push(e):s.set(t,[e])}for(const[t,n]of s)s.set(t,e(n,i));return t(s)}(e,0)}(e,tue,tue,t)}(e,...zoe(t).map(((e,t)=>{const n="function"==typeof e?e:t=>t[e],r=new Map;return t=>{const a=n(t),i=function(e){const t=typeof e;return null!=e&&("object"===t||"function"===t)}(a)?a.valueOf():a;if(r.has(i))return r.get(i);const s=[e,a];return r.set(i,s),s}})));return n}function lue(e,t){const n=[];return rue(e,n,[],iue,((e,n,r)=>{let a=r;!1!==t&&(a=r.map((e=>nue(e,n)))),e.push(...a)})),n}sue.grouped=e=>({...e,export:"grouped"}),sue.entries=e=>({...e,export:"entries"}),sue.entriesObject=e=>({...e,export:"entries-object"}),sue.object=e=>({...e,export:"object"}),sue.map=e=>({...e,export:"map"}),sue.keys=e=>({...e,export:"keys"}),sue.values=e=>({...e,export:"values"}),sue.levels=e=>({...e,export:"levels"});const cue=e=>e.join("/");function pue(e,t){const{groupFn:n,keyFn:r}=function(e){var t;const{flat:n,single:r,mapLeaf:a=iue,mapLeaves:i=iue,addGroupKeys:s}=e;let o;return e.flat&&(o=null!=(t=e.compositeKey)?t:cue),{groupFn:(e,t)=>r?a(!1===s?e[0]:nue(e[0],t)):i(e.map((e=>a(!1===s?e:nue(e,t))))),keyFn:n?e=>o(e.map((e=>e[1]))):e=>e[e.length-1][1]}}(t);let{mapEntry:a=iue}=t;const{levels:i=["entries"]}=t,s=[];for(const e of i)switch(e){case"entries":case"entries-object":case"entries-obj":case"entriesObject":{const n="entries-object"!==e&&"entries-obj"!==e&&"entriesObject"!==e||null!=t.mapEntry?a:([e,t])=>({key:e,values:t});s.push({id:"entries",createEmptySubgroup:()=>[],addSubgroup:(e,t,r,a)=>{e.push(n([r,t],a))},addLeaf:(e,t,r,a)=>{e.push(n([t,r],a))}});break}case"map":s.push({id:"map",createEmptySubgroup:()=>new Map,addSubgroup:(e,t,n)=>{e.set(n,t)},addLeaf:(e,t,n)=>{e.set(t,n)}});break;case"object":s.push({id:"object",createEmptySubgroup:()=>({}),addSubgroup:(e,t,n)=>{e[n]=t},addLeaf:(e,t,n)=>{e[t]=n}});break;case"keys":s.push({id:"keys",createEmptySubgroup:()=>[],addSubgroup:(e,t,n)=>{e.push([n,t])},addLeaf:(e,t)=>{e.push(t)}});break;case"values":s.push({id:"values",createEmptySubgroup:()=>[],addSubgroup:(e,t)=>{e.push(t)},addLeaf:(e,t,n)=>{e.push(n)}});break;default:"object"==typeof e&&s.push(e)}return rue(e,s[0].createEmptySubgroup(),[],((e,n,a)=>{var i,o;if(t.flat)return e;const u=null!=(i=s[a])?i:s[s.length-1],l=(null!=(o=s[a+1])?o:u).createEmptySubgroup();return u.addSubgroup(e,l,r(n),a),l}),((e,t,a,i)=>{var o;(null!=(o=s[i])?o:s[s.length-1]).addLeaf(e,r(t),n(a,t),i)}))}class due{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){const t=this._partials;let n=0;for(let r=0;r0){for(i=e[--a];a>0&&(t=i,n=e[--a],i=t+n,r=n-(i-t),!r););a>0&&(r<0&&e[a-1]<0||r>0&&e[a-1]>0)&&(n=2*r,t=i+n,n==t-i&&(i=t))}return i}}function hue(e,t){const n=new due;if(void 0===t)for(let t of e)(t=+t)&&n.add(t);else{let r=-1;for(let a of e)(a=+t(a,++r,e))&&n.add(a)}return+n}function fue(e){const t="function"==typeof e?e:t=>t[e];return e=>hue(e,t)}function mue(e){return t=>{const{name:n="n",wt:r}=null!=e?e:{},a=Woe({[n]:null==r?e=>e.length:fue(r)})(t);return a}}const gue=function(e){return function(t,n=0,r=t.length){let a=r-(n=+n);for(;a;){const r=e()*a--|0,i=t[a+n];t[a+n]=t[r+n],t[r+n]=i}return t}}(Math.random);function yue(e,t){return n=>n.slice(e,t)}function bue(e,t){if(0===e.length||0===t.length)return{};const n=Object.keys(e[0]),r=Object.keys(t[0]),a={};for(const e of n)r.includes(e)&&(a[e]=e);return a}function xue(e){if(Array.isArray(e)){const t={};for(const n of e)t[n]=n;return t}return"object"==typeof e?e:{[e]:e}}function vue(e,t,n){for(const r in n)if(e[n[r]]!==t[r])return!1;return!0}function _ue(e,t){return n=>{const r=null==(null==t?void 0:t.by)?bue(n,e):xue(t.by);return n.flatMap((t=>e.filter((e=>vue(t,e,r))).map((e=>({...t,...e})))))}}function wue(e,t){return n=>{if(!e.length)return n;const r=null==(null==t?void 0:t.by)?bue(n,e):xue(t.by),a=Object.keys(e[0]);return n.flatMap((t=>{const n=e.filter((e=>vue(t,e,r)));if(n.length)return n.map((e=>({...t,...e})));const i=Object.fromEntries(a.filter((e=>null==t[e])).map((e=>[e,void 0])));return{...t,...i}}))}}function Mue(e,t){return n=>{if(!e.length)return n;if(!n.length)return e;const r=null==(null==t?void 0:t.by)?bue(n,e):xue(t.by),a=new Map,i=Object.keys(e[0]),s=n.flatMap((t=>{const n=e.filter((e=>{const n=vue(t,e,r);return n&&a.set(e,!0),n}));if(n.length)return n.map((e=>({...t,...e})));const s=Object.fromEntries(i.filter((e=>null==t[e])).map((e=>[e,void 0])));return{...t,...s}}));if(a.size[e,void 0])));for(const n of e)a.has(n)||s.push({...t,...n})}return s}}function Nue(e){return e.length<1?[]:Object.keys(e[0])}function Sue(){return e=>Nue(e)}function kue(e){return t=>{let n=function(e,t){let n=[];for(const r of zoe(t))"function"==typeof r?n.push(...r(e)):n.push(r);n.length&&"-"===n[0][0]&&(n=[...Sue()(e),...n]);const r={},a=[];for(let e=n.length-1;e>=0;e--){const t=n[e];"-"!==t[0]?r[t]?r[t]=!1:a.unshift(t):r[t.substring(1)]=!0}return n=Array.from(new Set(a)),n}(t,e);return n.length?t.map((e=>{const t={};for(const r of n)t[r]=e[r];return t})):t}}function Due(e){return t=>"function"==typeof e?[...t,...zoe(e(t))]:[...t,...zoe(e)]}function Tue(e){return t=>{const n=function(e){if(Array.isArray(e)){const t={};for(const n of e)t[n]=n;return t}return"object"==typeof e?e:{[e]:e}}(e),r=[];for(const e in n){const a=n[e];let i;i="function"==typeof a?a(t):Array.isArray(a)?a:Array.from(new Set(t.map((t=>t[e])))),r.push(i.map((t=>({[e]:t}))))}return function(e){const t=[];return function e(t,n,r){if(!r.length&&null!=n)return void t.push(n);const a=r[0],i=r.slice(1);for(const r of a)e(t,{...n,...r},i)}(t,null,e),t}(r)}}function Iue(e,t){let n,r;if(void 0===t)for(const t of e)null!=t&&(void 0===n?t>=t&&(n=r=t):(n>t&&(n=t),r=i&&(n=r=i):(n>i&&(n=i),r{const n=[];for(const r of t){const t={...r};for(const n in e)null==t[n]&&(t[n]=e[n]);n.push(t)}return n}}function Aue(e){return t=>{const n=zoe(e),r={};return t.map((e=>{const t={...e};for(const e of n)null!=t[e]?r[e]=t[e]:null!=r[e]&&(t[e]=r[e]);return t}))}}function Lue(e,t,n){return null==e||null==t?void 0:0===t&&0===e?0:n||0!==t?e/t:void 0}function $ue(e,t){let n;if(void 0===t)for(const t of e)null!=t&&(n>t||void 0===n&&t>=t)&&(n=t);else{let r=-1;for(let a of e)null!=(a=t(a,++r,e))&&(n>a||void 0===n&&a>=a)&&(n=a)}return n}function Oue(e){const t="function"==typeof e?e:t=>t[e];return e=>$ue(e,t)}function Rue(e,t){let n;if(void 0===t)for(const t of e)null!=t&&(n=t)&&(n=t);else{let r=-1;for(let a of e)null!=(a=t(a,++r,e))&&(n=a)&&(n=a)}return n}function Fue(e){const t="function"==typeof e?e:t=>t[e];return e=>Rue(e,t)}function Yue(e,t,n=0,r=e.length-1,a=Boe){for(;r>n;){if(r-n>600){const i=r-n+1,s=t-n+1,o=Math.log(i),u=.5*Math.exp(2*o/3),l=.5*Math.sqrt(o*u*(i-u)/i)*(s-i/2<0?-1:1);Yue(e,t,Math.max(n,Math.floor(t-s*u/i+l)),Math.min(r,Math.floor(t+(i-s)*u/i+l)),a)}const i=e[t];let s=n,o=r;for(zue(e,n,t),a(e[r],i)>0&&zue(e,n,r);s0;)--o}0===a(e[n],i)?zue(e,n,o):(++o,zue(e,o,r)),o<=t&&(n=o+1),t<=o&&(r=o-1)}return e}function zue(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Bue(e,t,n){if(e=Float64Array.from(function*(e,t){if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)null!=(r=t(r,++n,e))&&(r=+r)>=r&&(yield r)}}(e,n)),r=e.length){if((t=+t)<=0||r<2)return $ue(e);if(t>=1)return Rue(e);var r,a=(r-1)*t,i=Math.floor(a),s=Rue(Yue(e,i).subarray(0,i+1));return s+($ue(e.subarray(i+1))-s)*(a-i)}}function Pue(e,t){let n,r=0,a=0,i=0;if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(n=t-a,a+=n/++r,i+=n*(t-a));else{let s=-1;for(let o of e)null!=(o=t(o,++s,e))&&(o=+o)>=o&&(n=o-a,a+=n/++r,i+=n*(o-a))}if(r>1)return i/(r-1)}var Hue=function(e,t,n){if(n||2===arguments.length)for(var r,a=0,i=t.length;a{const r=Tue(e)(n),a=wue(n)(r);return t?Cue(t)(a):a}},p5.prototype.count=function(e,t){return n=>{t=null!=t?t:{};const{name:r="n",sort:a}=t;return Roe(n,sue(e,[mue(t)]),a?Poe(joe(r)):iue)}},p5.prototype.debug=function(e,t){return(n,r)=>{var a;let i="[tidy.debug";if(null==(a=null==r?void 0:r.groupKeys)?void 0:a.length){const e=r.groupKeys.map((e=>e.join(": "))).join(", ");e.length&&(i+="|"+e)}t=null!=t?t:{};const{limit:s=10,output:o="table"}=t,u="--------------------------------------------------------------------------------";let l=u.length;const c=i+"]"+(null==e?"":" "+e);return l=Math.max(0,l-(c.length+2)),console.log(`${c} ${u.substring(0,l)}`),console[o](null==s||s>=n.length?n:n.slice(0,s)),n}},p5.prototype.distinct=function(e){return t=>{if(!(e=zoe(e)).length){const e=new Set;for(const n of t)e.add(n);return Array.from(e)}const n=new Map,r=[],a=e[e.length-1];for(const i of t){let t=n,s=!1;for(const n of e){const e="function"==typeof n?n(i):i[n];if(n===a){s=t.has(e),s||(r.push(i),t.set(e,!0));break}t.has(e)||t.set(e,new Map),t=t.get(e)}}return r}},p5.prototype.desc=joe,p5.prototype.expand=Tue,p5.prototype._pfill=p5.prototype.fill,p5.prototype.fill=function(){for(var e=[],t=0;t{const n=t.map((e=>({...e})));for(const r in e){const a=e[r],i="function"==typeof a?a(n):a,s=(null==i?void 0:i[Symbol.iterator])&&"string"!=typeof i?i:t.map((()=>i));let o=-1;for(const e of n)e[r]=s[++o]}return n}},p5.prototype.pick=kue,p5.prototype.rename=function(e){return t=>t.map((t=>{var n;const r={},a=Object.keys(t);for(const i of a)r[null!=(n=e[i])?n:i]=t[i];return r}))},p5.prototype.replaceNully=Cue,p5.prototype._pselect=p5.prototype.select,p5.prototype.select=function(){for(var e=[],t=0;tyue(0,e),p5.prototype.sliceTail=e=>yue(-e),p5.prototype.sliceMin=function(e,t){return n=>Poe(t)(n).slice(0,e)},p5.prototype.sliceMax=function(e,t){return n=>"function"==typeof t?Poe(t)(n).slice(-e).reverse():Poe(joe(t))(n).slice(0,e)},p5.prototype.sliceSample=function(e,t){t=null!=t?t:{};const{replace:n}=t;return t=>{if(!t.length)return t.slice();if(n){const n=[];for(let r=0;r{const r=Woe(e)(n),a=Xoe(t)(r);return[...n,...a]}},p5.prototype.totalAll=function(e,t){return n=>{const r=Goe(e)(n),a=Xoe(t)(r);return[...n,...a]}},p5.prototype.totalAt=function(e,t,n){return r=>{const a=Joe(e,t)(r),i=Xoe(n)(a);return[...r,...i]}},p5.prototype.totalIf=function(e,t,n){return r=>{const a=Koe(e,t)(r),i=Xoe(n)(a);return[...r,...i]}},p5.prototype.transmute=function(e){return t=>{const n=Xoe(e)(t);return kue(Object.keys(e))(n)}},p5.prototype.when=function(e,t){return n=>{if("function"==typeof e){if(!e(n))return n}else if(!e)return n;return Roe(n,...t)}},p5.prototype.deviation=function(e){const t="function"==typeof e?e:t=>t[e];return e=>function(e,t){const n=Pue(e,t);return n?Math.sqrt(n):n}(e,t)},p5.prototype.first=function(e){const t="function"==typeof e?e:t=>t[e];return e=>e.length?t(e[0]):void 0},p5.prototype.last=function(e){const t="function"==typeof e?e:t=>t[e];return e=>e.length?t(e[e.length-1]):void 0},p5.prototype._pmax=p5.prototype.max,p5.prototype.max=function(){for(var e=[],t=0;tt[e];return e=>function(e,t){let n=0;for(let r=0;rt[e],r="function"==typeof t?t:e=>e[t];return e=>Lue(hue(e,n),hue(e,r))},p5.prototype.median=function(e){const t="function"==typeof e?e:t=>t[e];return e=>function(e,t){return Bue(e,.5,t)}(e,t)},p5.prototype._pmin=p5.prototype.min,p5.prototype.min=function(){for(var e=[],t=0;te.length},p5.prototype.nDistinct=function(e,t={}){const n="function"==typeof e?e:t=>t[e];return e=>{const r=new Map;let a=0;for(const i of e){const e=n(i);if(!r.has(e)){if(!t.includeUndefined&&void 0===e||!1===t.includeNull&&null===e)continue;a+=1,r.set(e,!0)}}return a}},p5.prototype.sum=fue,p5.prototype.variance=function(e){const t="function"==typeof e?e:t=>t[e];return e=>Pue(e,t)},p5.prototype.cumsum=function(e){const t="function"==typeof e?e:t=>t[e];return e=>function(e,t){let n=new due,r=0;return Float64Array.from(e,(a=>n.add(+(t(a,r++,e)||0))))}(e,t)},p5.prototype.lag=function(e,t){const n="function"==typeof e?e:t=>t[e],{n:r=1,default:a}=null!=t?t:{};return e=>e.map(((t,i)=>{const s=e[i-r];return null==s?a:n(s)}))},p5.prototype.lead=function(e,t){const n="function"==typeof e?e:t=>t[e],{n:r=1,default:a}=null!=t?t:{};return e=>e.map(((t,i)=>{const s=e[i+r];return null==s?a:n(s)}))},p5.prototype.roll=function(e,t,n){const{partial:r=!1,align:a="right"}=null!=n?n:{},i=Math.floor(e/2);return n=>n.map(((s,o)=>{const u="right"===a?o:"center"===a?o+i:o+e-1;if(!r&&(u-e+1<0||u>=n.length))return;const l=Math.max(0,u-e+1),c=n.slice(l,u+1);return t(c,u)}))},p5.prototype.rate=function(e,t,n){const r="function"==typeof e?e:t=>t[e],a="function"==typeof t?t:e=>e[t],{predicate:i,allowDivideByZero:s}=null!=n?n:{};return null==i?e=>{const t=a(e);return Lue(r(e),t,s)}:e=>{if(!i(e))return;const t=a(e);return Lue(r(e),t,s)}},p5.prototype.fullSeq=function(e,t){return function(n){t=null!=t?t:1;const r="function"==typeof e?e:t=>t[e];return function(e,t=1){let[n,r]=Iue(e);const a=[];let i=n;for(;i<=r;)a.push(i),i+=t;return a}(n.map(r),t)}},p5.prototype.fullSeqDate=function(e,t,n){return function(r){t=null!=t?t:"day",n=null!=n?n:1;const a="function"==typeof e?e:t=>t[e];return Eue(r.map(a),t,n)}},p5.prototype.fullSeqDateISOString=function(e,t,n){return function(r){t=null!=t?t:"day",n=null!=n?n:1;const a="function"==typeof e?e:t=>t[e];return Eue(r.map((e=>new Date(a(e)))),t,n).map((e=>e.toISOString()))}},p5.prototype.contains=function(e,t=!0){return n=>{const r=new RegExp(e,t?"i":void 0);return Nue(n).filter((e=>r.test(e)))}},p5.prototype.endsWith=function(e,t=!0){return n=>{const r=new RegExp(`${e}$`,t?"i":void 0);return Nue(n).filter((e=>r.test(e)))}},p5.prototype.everything=Sue,p5.prototype.matches=function(e){return t=>Nue(t).filter((t=>e.test(t)))},p5.prototype.negate=function(e){return t=>{let n=new Set;for(const r of zoe(e))if("function"==typeof r){const e=r(t);for(const t of e)n.add(t)}else n.add(r);return Array.from(n).map((e=>`-${e}`))}},p5.prototype.numRange=function(e,t,n){return r=>{const a=Nue(r),i=[];for(let r=t[0];r<=t[1];++r){const t=null==n?r:new String("00000000"+r).slice(-n);i.push(`${e}${t}`)}return a.filter((e=>i.includes(e)))}},p5.prototype.startsWith=function(e,t=!0){return n=>{const r=new RegExp(`^${e}`,t?"i":void 0);return Nue(n).filter((e=>r.test(e)))}},roe.extend(Ooe),p5.prototype.utc=function(){for(var e=[],t=0;t { + const X = num.scope(() => { const x = num.complex(points.x, points.y); const X = num.fft(x); let re = X.real(); diff --git a/examples/mauna-loa/sketch.js b/examples/mauna-loa/sketch.js index 03c9373..7638bf7 100644 --- a/examples/mauna-loa/sketch.js +++ b/examples/mauna-loa/sketch.js @@ -1,16 +1,14 @@ -let co2; +let data; function preload() { - co2 = loadTable('co2.csv', 'csv', 'header', wrangle); + data = loadTable('co2.csv', 'csv', 'header'); } function setup() { - noCanvas(); - print('Atmospheric Carbon Dioxide at Mauna Loa'); - co2.head(); -} - -function wrangle(table) { - table.parseDates('date'); - table.inferTypes(); + noCanvas() + const results = tidy( + data, + filter((d) => d.mean > 400), + ); + tidy(results, debug('Observations greater than 400ppm CO2')); } diff --git a/examples/tables/sketch.js b/examples/tables/sketch.js index f652142..a37a8df 100644 --- a/examples/tables/sketch.js +++ b/examples/tables/sketch.js @@ -1,18 +1,31 @@ -let iris +let data; function preload() { - iris = loadTable('../plotting/iris.csv', 'csv', 'header') + data = loadTable('../plotting/iris.csv', 'csv', 'header'); } function setup() { - noCanvas() - // iris.print() // raw dataset - iris.inferTypes() - // iris.print() // dataset with types inferred - print('Iris dataset summary by column') - let summary = iris.describe() - summary.print() - print('Mean by species') - let mean = iris.groupby('Species').mean() - mean.print() + noCanvas(); + tidy( + data, + sliceHead(5), + debug('Beginning of Iris dataset'), + ); + tidy( + data, + sliceTail(5), + debug('End of Iris dataset'), + ); + tidy( + data, + groupBy('Species', [ + summarize({ + min: min('PetalLength'), + median: median('PetalLength'), + max: max('PetalLength'), + variance: variance('PetalLength'), + }), + ]), + debug('PetalLength summary by species'), + ); } diff --git a/package-lock.json b/package-lock.json index e9380ba..11a01d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,12 @@ "version": "0.2.4", "license": "MIT", "dependencies": { - "@tensorflow/tfjs": "^3.18.0", + "@tensorflow/tfjs": "^3.19.0", + "@tidyjs/tidy": "^2.4.6", + "d3-array": "^3.2.0", "dayjs": "^1.11.4", - "mathjs": "^10.6.4" + "mathjs": "^10.6.4", + "ts-toolbelt": "^9.6.0" }, "devDependencies": { "@types/chai": "^4.3.1", @@ -209,16 +212,16 @@ } }, "node_modules/@tensorflow/tfjs": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs/-/tfjs-3.18.0.tgz", - "integrity": "sha512-mOzz4jJdgIpqFS7EHndVuxrQnLUDVIKGyTqOPTYps89fZwcOFfTVxi4BHemDNQpqlVE8IaGh9UUxVXpjgPY5+Q==", - "dependencies": { - "@tensorflow/tfjs-backend-cpu": "3.18.0", - "@tensorflow/tfjs-backend-webgl": "3.18.0", - "@tensorflow/tfjs-converter": "3.18.0", - "@tensorflow/tfjs-core": "3.18.0", - "@tensorflow/tfjs-data": "3.18.0", - "@tensorflow/tfjs-layers": "3.18.0", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs/-/tfjs-3.19.0.tgz", + "integrity": "sha512-fZF3HOON8jgKhFk06WIScIXf7j/gkl6cLbU1brFWutBhHlPSzxSWvdJR/TivCK7p+yMBunoyK50TjiwOrcoclA==", + "dependencies": { + "@tensorflow/tfjs-backend-cpu": "3.19.0", + "@tensorflow/tfjs-backend-webgl": "3.19.0", + "@tensorflow/tfjs-converter": "3.19.0", + "@tensorflow/tfjs-core": "3.19.0", + "@tensorflow/tfjs-data": "3.19.0", + "@tensorflow/tfjs-layers": "3.19.0", "argparse": "^1.0.10", "chalk": "^4.1.0", "core-js": "3", @@ -230,101 +233,109 @@ } }, "node_modules/@tensorflow/tfjs-backend-cpu": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-3.18.0.tgz", - "integrity": "sha512-LcSqlylzGtpgngcMFIL3q9Q3eVaPRJ7ITZt7ivhzkCj4R5ZsnPa9qM3DCVihkQ77heAwSw4hPTo2jp5C4mJ4Cg==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-3.19.0.tgz", + "integrity": "sha512-02f+WkiL9gc9G7P8PwfsvuXREcAUdM/3uAL6fTle3xKEj7KOxX+E/mc3jxPY5UzjAsgHVBZrPJ2xi6AG16WPkQ==", "dependencies": { - "@types/seedrandom": "2.4.27", - "seedrandom": "2.4.3" + "@types/seedrandom": "^2.4.28", + "seedrandom": "^3.0.5" }, "engines": { "yarn": ">= 1.3.2" }, "peerDependencies": { - "@tensorflow/tfjs-core": "3.18.0" + "@tensorflow/tfjs-core": "3.19.0" } }, - "node_modules/@tensorflow/tfjs-backend-cpu/node_modules/seedrandom": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.3.tgz", - "integrity": "sha512-2CkZ9Wn2dS4mMUWQaXLsOAfGD+irMlLEeSP3cMxpGbgyOOzJGFa+MWCOMTOCMyZinHRPxyOj/S/C57li/1to6Q==" - }, "node_modules/@tensorflow/tfjs-backend-webgl": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-3.18.0.tgz", - "integrity": "sha512-3NknSzS1oX2BEBOrpjPMZl823S12RgshQthmIbG6QADHb4bCJA8aM4UjWpw+3bNQnRKbRDQdFbuvj10Un79s2A==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-3.19.0.tgz", + "integrity": "sha512-2HTkAE21t3WQTt8P6iK80ni03AzC8UNZmbIB7/pBDYBbhDwZwe/C5fXrJWnP9m6u4hvCdMAJ3o+OP3NeaEL1pw==", "dependencies": { - "@tensorflow/tfjs-backend-cpu": "3.18.0", + "@tensorflow/tfjs-backend-cpu": "3.19.0", "@types/offscreencanvas": "~2019.3.0", - "@types/seedrandom": "2.4.27", + "@types/seedrandom": "^2.4.28", "@types/webgl-ext": "0.0.30", "@types/webgl2": "0.0.6", - "seedrandom": "2.4.3" + "seedrandom": "^3.0.5" }, "engines": { "yarn": ">= 1.3.2" }, "peerDependencies": { - "@tensorflow/tfjs-core": "3.18.0" + "@tensorflow/tfjs-core": "3.19.0" } }, - "node_modules/@tensorflow/tfjs-backend-webgl/node_modules/seedrandom": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.3.tgz", - "integrity": "sha512-2CkZ9Wn2dS4mMUWQaXLsOAfGD+irMlLEeSP3cMxpGbgyOOzJGFa+MWCOMTOCMyZinHRPxyOj/S/C57li/1to6Q==" - }, "node_modules/@tensorflow/tfjs-converter": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-3.18.0.tgz", - "integrity": "sha512-hpChA+zVNQOVwRnCfqDb1WI9jbEAKA6DuEm4m75Zb3dIlE6VVooDmAaHBhlc++z2q2G1sBzF9A4Bv48SUpN6vA==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-3.19.0.tgz", + "integrity": "sha512-B69HQq9/orsM8pGJPjNp1cV+hIcc90mxcRIsQSYGovTUNEcftmz2Sh+mqXDWysKUk0gRfx5CX6eJk6NaE55Xow==", "peerDependencies": { - "@tensorflow/tfjs-core": "3.18.0" + "@tensorflow/tfjs-core": "3.19.0" } }, "node_modules/@tensorflow/tfjs-core": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-core/-/tfjs-core-3.18.0.tgz", - "integrity": "sha512-gMxisZozqsr5sCKlphF/eVBLg91MjlBiN60tjX8hJAu0WlSn6Gi5k65GNIL+Pq6hrxpvImcfdCmTH/2XJVZ0Mg==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-core/-/tfjs-core-3.19.0.tgz", + "integrity": "sha512-znJ+TOJ3NdNL5yjw8M7dn2jO96sokiH1wfFuD7gglCkbZ4SXlFpFj2xelNdRHHmeYanMhJzqeyOW9whUnNcBqw==", "dependencies": { "@types/long": "^4.0.1", "@types/offscreencanvas": "~2019.3.0", - "@types/seedrandom": "2.4.27", + "@types/seedrandom": "^2.4.28", "@types/webgl-ext": "0.0.30", - "@webgpu/types": "^0.1.16", + "@webgpu/types": "0.1.16", "long": "4.0.0", "node-fetch": "~2.6.1", - "seedrandom": "2.4.3" + "seedrandom": "^3.0.5" }, "engines": { "yarn": ">= 1.3.2" } }, - "node_modules/@tensorflow/tfjs-core/node_modules/seedrandom": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.3.tgz", - "integrity": "sha512-2CkZ9Wn2dS4mMUWQaXLsOAfGD+irMlLEeSP3cMxpGbgyOOzJGFa+MWCOMTOCMyZinHRPxyOj/S/C57li/1to6Q==" - }, "node_modules/@tensorflow/tfjs-data": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-data/-/tfjs-data-3.18.0.tgz", - "integrity": "sha512-s43vISJh8K/UN2E2zGRhtj/Kyn8dr4ll8EQkapwzm7fGO9afXCnMsTp6rkZq3fFXouCYA2k1B/j7JssIDr50+w==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-data/-/tfjs-data-3.19.0.tgz", + "integrity": "sha512-rkZv+YZowZwnm4RaedkV44WDrjokRHld9Py/0Fb7IvMyUh37lY0WsAsV94kJ+QuLc6iVNcDLaV29K+dUz57bRA==", "dependencies": { "@types/node-fetch": "^2.1.2", - "node-fetch": "~2.6.1" + "node-fetch": "~2.6.1", + "string_decoder": "^1.3.0" }, "peerDependencies": { - "@tensorflow/tfjs-core": "3.18.0", - "seedrandom": "~2.4.3" + "@tensorflow/tfjs-core": "3.19.0", + "seedrandom": "^3.0.5" } }, "node_modules/@tensorflow/tfjs-layers": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-3.18.0.tgz", - "integrity": "sha512-AV7yDnPlH+RCcq8VPqkX1iyEchObE+e66m0XmJvLj+ncfKHYLa+39ZNroUA+OgB2/cMG6jgq77R4EhZbT6hwJA==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-3.19.0.tgz", + "integrity": "sha512-+sVWjWWyTuT3sImrtNLtMv8/4FS30GAYpTgyJKhCQ3+GSvHUXulxJfncD0QqOg9fTbhtuF1TRAkzDU8v64791g==", "peerDependencies": { - "@tensorflow/tfjs-core": "3.18.0" + "@tensorflow/tfjs-core": "3.19.0" + } + }, + "node_modules/@tidyjs/tidy": { + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/@tidyjs/tidy/-/tidy-2.4.6.tgz", + "integrity": "sha512-yzt03tlX94WELtlL7YfyjCc7+gBhe47hgwzUhtEGnYKrhV2SoIOQ+rfD3jHwwUp5VW3sEyoQ7McukUJmdeHomw==", + "dependencies": { + "d3-array": "^2.9.1", + "ts-toolbelt": "^8.0.7" } }, + "node_modules/@tidyjs/tidy/node_modules/d3-array": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.12.1.tgz", + "integrity": "sha512-B0ErZK/66mHtEsR1TkPEEkwdy+WDesimkM5gpZr5Dsg54BiTA5RXtYW5qTLIAcekaS9xfZrzBLF/OAkB3Qn1YQ==", + "dependencies": { + "internmap": "^1.0.0" + } + }, + "node_modules/@tidyjs/tidy/node_modules/ts-toolbelt": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-8.4.0.tgz", + "integrity": "sha512-hnGJXIgC49ZuF5g5oDthoge8t4cvT0dYg2pYO5C6yV/HmUUy1koooU2U/5K2N+Uw++hcXQpJAToLRa+GRp28Sg==" + }, "node_modules/@types/chai": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.1.tgz", @@ -424,9 +435,9 @@ "dev": true }, "node_modules/@types/seedrandom": { - "version": "2.4.27", - "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-2.4.27.tgz", - "integrity": "sha512-YvMLqFak/7rt//lPBtEHv3M4sRNA+HGxrhFZ+DQs9K2IkYJbNwVIb8avtJfhDiuaUBX/AW0jnjv48FV8h3u9bQ==" + "version": "2.4.30", + "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-2.4.30.tgz", + "integrity": "sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ==" }, "node_modules/@types/webgl-ext": { "version": "0.0.30", @@ -775,9 +786,9 @@ } }, "node_modules/@webgpu/types": { - "version": "0.1.21", - "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.21.tgz", - "integrity": "sha512-pUrWq3V5PiSGFLeLxoGqReTZmiiXwY3jRkIG5sLLKjyqNxrwm/04b4nw7LSmGWJcKk59XOM/YRTUwOzo4MMlow==" + "version": "0.1.16", + "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.16.tgz", + "integrity": "sha512-9E61voMP4+Rze02jlTXud++Htpjyyk8vw5Hyw9FGRrmhHQg2GqbuOfwf5Klrb8vTxc2XWI3EfO7RUHMpxTj26A==" }, "node_modules/@webpack-cli/configtest": { "version": "1.2.0", @@ -1453,6 +1464,17 @@ "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=", "dev": true }, + "node_modules/d3-array": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.0.tgz", + "integrity": "sha512-3yXFQo0oG3QCxbF06rMPFyGRMGJNS7NvsV1+2joOjbBE+9xvWQ8+GcMJAjRCzw06zQ3/arXeJgbPYcjUCuC+3g==", + "dependencies": { + "internmap": "1 - 2" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/date-format": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.3.tgz", @@ -2686,6 +2708,11 @@ "node": ">= 0.4" } }, + "node_modules/internmap": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/internmap/-/internmap-1.0.1.tgz", + "integrity": "sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw==" + }, "node_modules/interpret": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz", @@ -3314,11 +3341,6 @@ "node": ">= 14" } }, - "node_modules/mathjs/node_modules/seedrandom": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.5.tgz", - "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==" - }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -4220,7 +4242,6 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, "funding": [ { "type": "github", @@ -4261,10 +4282,9 @@ } }, "node_modules/seedrandom": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.4.tgz", - "integrity": "sha512-9A+PDmgm+2du77B5i0Ip2cxOqqHjgNxnBgglxLcX78A2D6c2rTo61z4jnVABpF4cKeDMDG+cmXXvdnqse2VqMA==", - "peer": true + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.5.tgz", + "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==" }, "node_modules/semver": { "version": "7.3.7", @@ -4447,6 +4467,14 @@ "node": ">=8.0" } }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, "node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -4676,6 +4704,11 @@ "webpack": "^5.0.0" } }, + "node_modules/ts-toolbelt": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-9.6.0.tgz", + "integrity": "sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==" + }, "node_modules/tsconfig-paths": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", @@ -5375,16 +5408,16 @@ "dev": true }, "@tensorflow/tfjs": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs/-/tfjs-3.18.0.tgz", - "integrity": "sha512-mOzz4jJdgIpqFS7EHndVuxrQnLUDVIKGyTqOPTYps89fZwcOFfTVxi4BHemDNQpqlVE8IaGh9UUxVXpjgPY5+Q==", - "requires": { - "@tensorflow/tfjs-backend-cpu": "3.18.0", - "@tensorflow/tfjs-backend-webgl": "3.18.0", - "@tensorflow/tfjs-converter": "3.18.0", - "@tensorflow/tfjs-core": "3.18.0", - "@tensorflow/tfjs-data": "3.18.0", - "@tensorflow/tfjs-layers": "3.18.0", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs/-/tfjs-3.19.0.tgz", + "integrity": "sha512-fZF3HOON8jgKhFk06WIScIXf7j/gkl6cLbU1brFWutBhHlPSzxSWvdJR/TivCK7p+yMBunoyK50TjiwOrcoclA==", + "requires": { + "@tensorflow/tfjs-backend-cpu": "3.19.0", + "@tensorflow/tfjs-backend-webgl": "3.19.0", + "@tensorflow/tfjs-converter": "3.19.0", + "@tensorflow/tfjs-core": "3.19.0", + "@tensorflow/tfjs-data": "3.19.0", + "@tensorflow/tfjs-layers": "3.19.0", "argparse": "^1.0.10", "chalk": "^4.1.0", "core-js": "3", @@ -5393,84 +5426,88 @@ } }, "@tensorflow/tfjs-backend-cpu": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-3.18.0.tgz", - "integrity": "sha512-LcSqlylzGtpgngcMFIL3q9Q3eVaPRJ7ITZt7ivhzkCj4R5ZsnPa9qM3DCVihkQ77heAwSw4hPTo2jp5C4mJ4Cg==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-3.19.0.tgz", + "integrity": "sha512-02f+WkiL9gc9G7P8PwfsvuXREcAUdM/3uAL6fTle3xKEj7KOxX+E/mc3jxPY5UzjAsgHVBZrPJ2xi6AG16WPkQ==", "requires": { - "@types/seedrandom": "2.4.27", - "seedrandom": "2.4.3" - }, - "dependencies": { - "seedrandom": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.3.tgz", - "integrity": "sha512-2CkZ9Wn2dS4mMUWQaXLsOAfGD+irMlLEeSP3cMxpGbgyOOzJGFa+MWCOMTOCMyZinHRPxyOj/S/C57li/1to6Q==" - } + "@types/seedrandom": "^2.4.28", + "seedrandom": "^3.0.5" } }, "@tensorflow/tfjs-backend-webgl": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-3.18.0.tgz", - "integrity": "sha512-3NknSzS1oX2BEBOrpjPMZl823S12RgshQthmIbG6QADHb4bCJA8aM4UjWpw+3bNQnRKbRDQdFbuvj10Un79s2A==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-3.19.0.tgz", + "integrity": "sha512-2HTkAE21t3WQTt8P6iK80ni03AzC8UNZmbIB7/pBDYBbhDwZwe/C5fXrJWnP9m6u4hvCdMAJ3o+OP3NeaEL1pw==", "requires": { - "@tensorflow/tfjs-backend-cpu": "3.18.0", + "@tensorflow/tfjs-backend-cpu": "3.19.0", "@types/offscreencanvas": "~2019.3.0", - "@types/seedrandom": "2.4.27", + "@types/seedrandom": "^2.4.28", "@types/webgl-ext": "0.0.30", "@types/webgl2": "0.0.6", - "seedrandom": "2.4.3" - }, - "dependencies": { - "seedrandom": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.3.tgz", - "integrity": "sha512-2CkZ9Wn2dS4mMUWQaXLsOAfGD+irMlLEeSP3cMxpGbgyOOzJGFa+MWCOMTOCMyZinHRPxyOj/S/C57li/1to6Q==" - } + "seedrandom": "^3.0.5" } }, "@tensorflow/tfjs-converter": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-3.18.0.tgz", - "integrity": "sha512-hpChA+zVNQOVwRnCfqDb1WI9jbEAKA6DuEm4m75Zb3dIlE6VVooDmAaHBhlc++z2q2G1sBzF9A4Bv48SUpN6vA==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-3.19.0.tgz", + "integrity": "sha512-B69HQq9/orsM8pGJPjNp1cV+hIcc90mxcRIsQSYGovTUNEcftmz2Sh+mqXDWysKUk0gRfx5CX6eJk6NaE55Xow==", "requires": {} }, "@tensorflow/tfjs-core": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-core/-/tfjs-core-3.18.0.tgz", - "integrity": "sha512-gMxisZozqsr5sCKlphF/eVBLg91MjlBiN60tjX8hJAu0WlSn6Gi5k65GNIL+Pq6hrxpvImcfdCmTH/2XJVZ0Mg==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-core/-/tfjs-core-3.19.0.tgz", + "integrity": "sha512-znJ+TOJ3NdNL5yjw8M7dn2jO96sokiH1wfFuD7gglCkbZ4SXlFpFj2xelNdRHHmeYanMhJzqeyOW9whUnNcBqw==", "requires": { "@types/long": "^4.0.1", "@types/offscreencanvas": "~2019.3.0", - "@types/seedrandom": "2.4.27", + "@types/seedrandom": "^2.4.28", "@types/webgl-ext": "0.0.30", - "@webgpu/types": "^0.1.16", + "@webgpu/types": "0.1.16", "long": "4.0.0", "node-fetch": "~2.6.1", - "seedrandom": "2.4.3" - }, - "dependencies": { - "seedrandom": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.3.tgz", - "integrity": "sha512-2CkZ9Wn2dS4mMUWQaXLsOAfGD+irMlLEeSP3cMxpGbgyOOzJGFa+MWCOMTOCMyZinHRPxyOj/S/C57li/1to6Q==" - } + "seedrandom": "^3.0.5" } }, "@tensorflow/tfjs-data": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-data/-/tfjs-data-3.18.0.tgz", - "integrity": "sha512-s43vISJh8K/UN2E2zGRhtj/Kyn8dr4ll8EQkapwzm7fGO9afXCnMsTp6rkZq3fFXouCYA2k1B/j7JssIDr50+w==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-data/-/tfjs-data-3.19.0.tgz", + "integrity": "sha512-rkZv+YZowZwnm4RaedkV44WDrjokRHld9Py/0Fb7IvMyUh37lY0WsAsV94kJ+QuLc6iVNcDLaV29K+dUz57bRA==", "requires": { "@types/node-fetch": "^2.1.2", - "node-fetch": "~2.6.1" + "node-fetch": "~2.6.1", + "string_decoder": "^1.3.0" } }, "@tensorflow/tfjs-layers": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-3.18.0.tgz", - "integrity": "sha512-AV7yDnPlH+RCcq8VPqkX1iyEchObE+e66m0XmJvLj+ncfKHYLa+39ZNroUA+OgB2/cMG6jgq77R4EhZbT6hwJA==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-3.19.0.tgz", + "integrity": "sha512-+sVWjWWyTuT3sImrtNLtMv8/4FS30GAYpTgyJKhCQ3+GSvHUXulxJfncD0QqOg9fTbhtuF1TRAkzDU8v64791g==", "requires": {} }, + "@tidyjs/tidy": { + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/@tidyjs/tidy/-/tidy-2.4.6.tgz", + "integrity": "sha512-yzt03tlX94WELtlL7YfyjCc7+gBhe47hgwzUhtEGnYKrhV2SoIOQ+rfD3jHwwUp5VW3sEyoQ7McukUJmdeHomw==", + "requires": { + "d3-array": "^2.9.1", + "ts-toolbelt": "^8.0.7" + }, + "dependencies": { + "d3-array": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.12.1.tgz", + "integrity": "sha512-B0ErZK/66mHtEsR1TkPEEkwdy+WDesimkM5gpZr5Dsg54BiTA5RXtYW5qTLIAcekaS9xfZrzBLF/OAkB3Qn1YQ==", + "requires": { + "internmap": "^1.0.0" + } + }, + "ts-toolbelt": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-8.4.0.tgz", + "integrity": "sha512-hnGJXIgC49ZuF5g5oDthoge8t4cvT0dYg2pYO5C6yV/HmUUy1koooU2U/5K2N+Uw++hcXQpJAToLRa+GRp28Sg==" + } + } + }, "@types/chai": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.1.tgz", @@ -5570,9 +5607,9 @@ "dev": true }, "@types/seedrandom": { - "version": "2.4.27", - "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-2.4.27.tgz", - "integrity": "sha512-YvMLqFak/7rt//lPBtEHv3M4sRNA+HGxrhFZ+DQs9K2IkYJbNwVIb8avtJfhDiuaUBX/AW0jnjv48FV8h3u9bQ==" + "version": "2.4.30", + "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-2.4.30.tgz", + "integrity": "sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ==" }, "@types/webgl-ext": { "version": "0.0.30", @@ -5832,9 +5869,9 @@ } }, "@webgpu/types": { - "version": "0.1.21", - "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.21.tgz", - "integrity": "sha512-pUrWq3V5PiSGFLeLxoGqReTZmiiXwY3jRkIG5sLLKjyqNxrwm/04b4nw7LSmGWJcKk59XOM/YRTUwOzo4MMlow==" + "version": "0.1.16", + "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.16.tgz", + "integrity": "sha512-9E61voMP4+Rze02jlTXud++Htpjyyk8vw5Hyw9FGRrmhHQg2GqbuOfwf5Klrb8vTxc2XWI3EfO7RUHMpxTj26A==" }, "@webpack-cli/configtest": { "version": "1.2.0", @@ -6342,6 +6379,14 @@ "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=", "dev": true }, + "d3-array": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.0.tgz", + "integrity": "sha512-3yXFQo0oG3QCxbF06rMPFyGRMGJNS7NvsV1+2joOjbBE+9xvWQ8+GcMJAjRCzw06zQ3/arXeJgbPYcjUCuC+3g==", + "requires": { + "internmap": "1 - 2" + } + }, "date-format": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.3.tgz", @@ -7285,6 +7330,11 @@ "side-channel": "^1.0.4" } }, + "internmap": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/internmap/-/internmap-1.0.1.tgz", + "integrity": "sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw==" + }, "interpret": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz", @@ -7746,13 +7796,6 @@ "seedrandom": "^3.0.5", "tiny-emitter": "^2.1.0", "typed-function": "^2.1.0" - }, - "dependencies": { - "seedrandom": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.5.tgz", - "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==" - } } }, "media-typer": { @@ -8385,8 +8428,7 @@ "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" }, "safer-buffer": { "version": "2.1.2", @@ -8406,10 +8448,9 @@ } }, "seedrandom": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.4.tgz", - "integrity": "sha512-9A+PDmgm+2du77B5i0Ip2cxOqqHjgNxnBgglxLcX78A2D6c2rTo61z4jnVABpF4cKeDMDG+cmXXvdnqse2VqMA==", - "peer": true + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.5.tgz", + "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==" }, "semver": { "version": "7.3.7", @@ -8556,6 +8597,14 @@ "fs-extra": "^10.0.0" } }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "requires": { + "safe-buffer": "~5.2.0" + } + }, "string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -8711,6 +8760,11 @@ "semver": "^7.3.4" } }, + "ts-toolbelt": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-9.6.0.tgz", + "integrity": "sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==" + }, "tsconfig-paths": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", diff --git a/package.json b/package.json index 6c5554d..46c51a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "numero", - "version": "0.2.4", + "version": "0.3.0", "description": "A friendly and intuitive math library for p5.js", "main": "index.js", "scripts": { @@ -36,8 +36,11 @@ "webpack-cli": "^4.10.0" }, "dependencies": { - "@tensorflow/tfjs": "^3.18.0", + "@tensorflow/tfjs": "^3.19.0", + "@tidyjs/tidy": "^2.4.6", + "d3-array": "^3.2.0", "dayjs": "^1.11.4", - "mathjs": "^10.6.4" + "mathjs": "^10.6.4", + "ts-toolbelt": "^9.6.0" } } diff --git a/src/index.ts b/src/index.ts index 2913fd6..48a1213 100644 --- a/src/index.ts +++ b/src/index.ts @@ -60,7 +60,7 @@ import { } from './tensor/ufunc'; import { memory, - tidy, + scope, startScope, endScope, keep, @@ -157,7 +157,7 @@ export { sort, fft, memory, - tidy, + scope, startScope, endScope, keep, diff --git a/src/table/groupby.ts b/src/table/groupby.ts deleted file mode 100644 index 1cc12d1..0000000 --- a/src/table/groupby.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { Table, TableRow } from 'p5'; -import './stats'; - -/** - * A class to describe a p5.Table grouped by elements in a given column. - */ -class GroupedTable { - public table: Table; - - public by: string; - - public groups: object; - - private outputColumns: string[]; - - /** - * Constructs a new GroupedTable. - * - * @param table the table to analyze - * @param by the column to use for generating groups - */ - constructor(table: Table, by: string) { - this.table = table; - this.by = by; - this.createGroups(); - } - - /** - * Creates groups of p5.Tables based on unique elements of - * the given column. - */ - createGroups() { - this.groups = {}; - const { columns } = this.table; - this.outputColumns = columns.filter((c) => c !== this.by); - const groupNames: Set = new Set(); - this.table.getColumn(this.by).forEach((el) => groupNames.add(el)); - groupNames.forEach((group) => { - const groupTable: Table = new Table(); - groupTable.columns = columns.slice(); - const rows: TableRow[] = this.table.findRows(group, this.by); - rows.forEach((row) => groupTable.addRow(row)); - groupTable.removeColumn(this.by); - this.groups[group] = groupTable; - }); - } - - /** - * Applies a statistical function to each group and creates a - * summary p5.Table with a row for each group. - * - * @param {string} stat the statistical function to apply - * @returns summary stats for each group - */ - computeStat(stat: string): Table { - const output: Table = new Table(); - output.columns = this.outputColumns.slice(); - const groupNames: string[] = Object.keys(this.groups); - groupNames.forEach((group: string) => { - // @ts-ignore - let statTable: Table; - if (stat === 'count') { - statTable = this.groups[group].count(); - } else if (stat === 'sum') { - statTable = this.groups[group].sum(); - } else if (stat === 'mean') { - statTable = this.groups[group].mean(); - } else if (stat === 'median') { - statTable = this.groups[group].median(); - } else if (stat === 'max') { - statTable = this.groups[group].max(); - } else if (stat === 'min') { - statTable = this.groups[group].min(); - } else if (stat === 'sd') { - statTable = this.groups[group].sd(); - } - const row: TableRow = statTable.getRow(0); - output.addRow(row); - }); - output.addColumn(this.by); - for (let i = 0; i < groupNames.length; i += 1) { - output.set(i, this.by, groupNames[i]); - } - return output; - } - - /** - * Computes the number of cells with values in each group in the - * p5.Table. - * - * @returns the count per group - */ - count(): Table { - return this.computeStat('count'); - } - - /** - * Computes the sum of each group in the p5.Table. - * - * @returns the sum per group - */ - sum(): Table { - return this.computeStat('sum'); - } - - /** - * Computes the mean of each group in the p5.Table. - * - * @returns the mean per group - */ - mean(): Table { - return this.computeStat('mean'); - } - - /** - * Computes the median of each group in the p5.Table. - * - * @returns the median per group - */ - median(): Table { - return this.computeStat('median'); - } - - /** - * Computes the maximum of each group in the p5.Table. - * - * @returns the max per group - */ - max(): Table { - return this.computeStat('max'); - } - - /** - * Computes the minimum of each group in the p5.Table. - * - * @returns the min per group - */ - min(): Table { - return this.computeStat('min'); - } - - /** - * Computes the standard deviation of each group in the p5.Table. - * - * @returns the sd per group - */ - sd(): Table { - return this.computeStat('sd'); - } -} - -declare module 'p5' { - interface Table { - groupby(string: string): GroupedTable; - } -} - -/** - * Splits a p5.Table into unique groups based on the elements - * of a given column. - * - * @param {string} column the column to use for generating groups - * @returns the rows of the table grouped by values in - * the given column - */ -Table.prototype.groupby = function _groupby(column: string): GroupedTable { - const output: GroupedTable = new GroupedTable(this, column); - return output; -}; diff --git a/src/table/index.ts b/src/table/index.ts index 632cbc9..a74385f 100644 --- a/src/table/index.ts +++ b/src/table/index.ts @@ -1,10 +1,273 @@ -import './groupby'; -import './stats'; -import './time'; -import './wrangle'; -import './utils'; -import { createTable } from './utils'; +import 'd3-array'; +import * as dayjs from 'dayjs'; +import * as utc from 'dayjs/plugin/utc'; +// eslint-disable-next-line import/no-extraneous-dependencies +import { Table, TableRow } from 'p5'; +import { + addItems, + addRows, + arrange, + complete, + count, + debug, + distinct, + desc, + expand, + fill, + filter, + fullJoin, + groupBy, + innerJoin, + leftJoin, + map, + mutate, + mutateWithSummary, + pick, + rename, + replaceNully, + select, + slice, + sliceHead, + sliceTail, + sliceMin, + sliceMax, + sliceSample, + summarize, + summarizeAll, + summarizeAt, + summarizeIf, + sort, + tally, + total, + totalAll, + totalAt, + totalIf, + transmute, + when, + // summarizers + deviation, + first, + last, + max, + mean, + meanRate, + median, + min, + n, + nDistinct, + sum, + variance, + // vector functions + cumsum, + lag, + lead, + roll, + // item + rate, + // sequences + fullSeq, + fullSeqDate, + fullSeqDateISOString, + // selectors + contains, + endsWith, + everything, + matches, + negate, + numRange, + startsWith, + tidy, +} from '@tidyjs/tidy'; declare const p5: any; -p5.prototype.createTable = createTable; +p5.prototype.toTidy = function _toTidy(table: Table): object[] { + // @ts-ignore + const array: object[] = table.rows.map((row: TableRow) => row.obj); + return array; +}; + +p5.prototype.toTable = function _toTable(array: object[]): Table { + const table: Table = new Table(); + table.columns = Object.keys(array[0]); + array.forEach((row: object) => { + const newRow: TableRow = table.addRow(); + table.columns.forEach((col: string) => { + newRow.set(col, row[col]); + }); + }); + return table; +}; + +p5.prototype.tidy = function _tidy(data: object[] | Table, ...args: any[]): object[] | Table { + let results: object[] | Table; + if (data instanceof Table) { + const array: object[] = this.toTidy(data); + // @ts-ignore + results = tidy(array, ...args); + results = this.toTable(results); + } + if (data instanceof Array && typeof data[0] === 'object') { + // @ts-ignore + results = tidy(data, ...args); + } + return results; +}; + +p5.prototype.addItems = addItems; +p5.prototype.addRows = addRows; +p5.prototype.arrange = arrange; +p5.prototype.complete = complete; +p5.prototype.count = count; +p5.prototype.debug = debug; +p5.prototype.distinct = distinct; +p5.prototype.desc = desc; +p5.prototype.expand = expand; +// eslint-disable-next-line no-underscore-dangle +p5.prototype._pfill = p5.prototype.fill; +p5.prototype.fill = function _fill(...args) { + if (args[0] instanceof Array) { + // @ts-ignore + return fill(...args); + } + // eslint-disable-next-line no-underscore-dangle + return this._pfill(...args); +}; +// eslint-disable-next-line no-underscore-dangle +p5.prototype._pfilter = p5.prototype.filter; +p5.prototype.filter = function _filter(...args) { + if (args[0] instanceof Function) { + // @ts-ignore + return filter(...args); + } + // eslint-disable-next-line no-underscore-dangle + return this._pfilter(...args); +}; +p5.prototype.fullJoin = function _fullJoin(...args) { + if (args[0] instanceof Table) { + const other: any[] = args.slice(1); + const data: object[] = this.toTidy(args[0]); + return fullJoin(data, ...other); + } + // @ts-ignore + return fullJoin(...args); +}; +p5.prototype.groupBy = groupBy; +p5.prototype.innerJoin = function _innerJoin(...args) { + if (args[0] instanceof Table) { + const other: any[] = args.slice(1); + const data: object[] = this.toTidy(args[0]); + return innerJoin(data, ...other); + } + // @ts-ignore + return innerJoin(...args); +}; +p5.prototype.leftJoin = function _leftJoin(...args) { + if (args[0] instanceof Table) { + const other: any[] = args.slice(1); + const data: object[] = this.toTidy(args[0]); + return leftJoin(data, ...other); + } + // @ts-ignore + return leftJoin(...args); +}; +// eslint-disable-next-line no-underscore-dangle +p5.prototype._pmap = p5.prototype.map; +p5.prototype.map = function _map(...args) { + if (args[0] instanceof Function) { + // @ts-ignore + return map(...args); + } + // eslint-disable-next-line no-underscore-dangle + return this._pmap(...args); +}; +p5.prototype.mutate = mutate; +p5.prototype.mutateWithSummary = mutateWithSummary; +p5.prototype.pick = pick; +p5.prototype.rename = rename; +p5.prototype.replaceNully = replaceNully; +// eslint-disable-next-line no-underscore-dangle +p5.prototype._pselect = p5.prototype.select; +// eslint-disable-next-line consistent-return +p5.prototype.select = function _select(...args) { + if (typeof args[0] === 'string') { + // eslint-disable-next-line no-underscore-dangle + return this._pselect(...args); + } + // @ts-ignore + return select(...args); +}; +p5.prototype.slice = slice; +p5.prototype.sliceHead = sliceHead; +p5.prototype.sliceTail = sliceTail; +p5.prototype.sliceMin = sliceMin; +p5.prototype.sliceMax = sliceMax; +p5.prototype.sliceSample = sliceSample; +p5.prototype.summarize = summarize; +p5.prototype.summarizeAll = summarizeAll; +p5.prototype.summarizeAt = summarizeAt; +p5.prototype.summarizeIf = summarizeIf; +p5.prototype.sort = sort; +p5.prototype.tally = tally; +p5.prototype.total = total; +p5.prototype.totalAll = totalAll; +p5.prototype.totalAt = totalAt; +p5.prototype.totalIf = totalIf; +p5.prototype.transmute = transmute; +p5.prototype.when = when; +// summarizers +p5.prototype.deviation = deviation; +p5.prototype.first = first; +p5.prototype.last = last; +// eslint-disable-next-line no-underscore-dangle +p5.prototype._pmax = p5.prototype.max; +p5.prototype.max = function _max(...args) { + if (typeof args[0] === 'number' || args[0] instanceof Array) { + // eslint-disable-next-line no-underscore-dangle + return this._pmax(...args); + } + // @ts-ignore + return max(...args); +}; +p5.prototype.mean = mean; +p5.prototype.meanRate = meanRate; +p5.prototype.median = median; +// eslint-disable-next-line no-underscore-dangle +p5.prototype._pmin = p5.prototype.min; +p5.prototype.min = function _min(...args) { + if (typeof args[0] === 'number' || args[0] instanceof Array) { + // eslint-disable-next-line no-underscore-dangle + return this._pmin(...args); + } + // @ts-ignore + return min(...args); +}; +p5.prototype.nRows = n; +p5.prototype.nDistinct = nDistinct; +p5.prototype.sum = sum; +p5.prototype.variance = variance; +// vector functions +p5.prototype.cumsum = cumsum; +p5.prototype.lag = lag; +p5.prototype.lead = lead; +p5.prototype.roll = roll; +// item +p5.prototype.rate = rate; +// sequences +p5.prototype.fullSeq = fullSeq; +p5.prototype.fullSeqDate = fullSeqDate; +p5.prototype.fullSeqDateISOString = fullSeqDateISOString; +// selectors +p5.prototype.contains = contains; +p5.prototype.endsWith = endsWith; +p5.prototype.everything = everything; +p5.prototype.matches = matches; +p5.prototype.negate = negate; +p5.prototype.numRange = numRange; +p5.prototype.startsWith = startsWith; +// time +dayjs.extend(utc); +p5.prototype.utc = function _utc(...args) { + // @ts-ignore + return dayjs.utc(...args); +}; diff --git a/src/table/stats.ts b/src/table/stats.ts deleted file mode 100644 index fd49fd9..0000000 --- a/src/table/stats.ts +++ /dev/null @@ -1,250 +0,0 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { Table, TableRow } from 'p5'; - -declare module 'p5' { - interface Table { - count(column: string): number | Table; - sum(column: string): number | Table; - mean(column: string): number | Table; - median(column: string): number | Table; - max(column: string): number | Table; - min(column: string): number | Table; - sd(column: string): number | Table; - describe(): Table; - } -} - -/** - * Creates a new p5.Table with an empty row for summary statistics. - * - * @param {p5.Table} table the table to summarize - * @returns the table and row as an array - */ -const summaryTable = function _summaryTable(table: Table): Table { - const output: Table = new Table(); - output.columns = table.columns.slice(); - output.addRow(); - return output; -}; - -/** - * Computes a summary statistic along a column. - * - * @param {p5.Table} table the table to analyze - * @param {string} column the name of the column to analyze - * @param {Function} func the statistical function to apply - * @param {any[]} [args] positional arguments for func - * @returns the statistic, either as a number or as a table - */ -const computeStat = ( - table: Table, - column: string, - func: Function, - args?: any[], -): number | Table => { - if (column === undefined) { - const output: Table = summaryTable(table); - table.columns.forEach((col: string) => { - const data: any[] = table.getColumn(col); - if (typeof data[0] === 'number') { - const value: number = func(data, ...args); - output.setNum(0, col, value); - } else { - output.set(0, col, undefined); - } - }); - return output; - } - const data: number[] = table.getColumn(column); - return func(data, ...args); -}; - -/** - * Computes the number of cells with values in a column or set of columns. - * - * @param {string} [column] the name of the column to analyze - * @returns the count, either as a number or as a table - */ -Table.prototype.count = function _count(column: string): number | Table { - const count = (array: number[]) => array.filter((x) => x).length; - return computeStat(this, column, count, []); -}; - -/** - * Computes the sum of an array. - * - * @param {number[]} array the array of numbers - * @returns the sum - */ -const sum = (array: number[]): number => { - const defined: number[] = array.filter((x) => x); - return defined.reduce((a, b) => a + b); -}; - -/** - * Computes the sum of a column or set of columns. - * - * @param {string} [column] the name of the column to analyze - * @returns the sum, either as a number or as a table - */ -Table.prototype.sum = function _sum(column: string): number | Table { - return computeStat(this, column, sum, []); -}; - -/** - * Computes the arithmetic mean of an array. - * - * @param {number[]} array the array of numbers - * @returns the mean - */ -const mean = (array: number[]): number => sum(array) / array.length; - -/** - * Computes the mean of a column or set of columns. - * - * @param {string} [column] the name of the column to analyze - * @returns the mean, either as a number or as a table - */ -Table.prototype.mean = function _mean(column: string): number | Table { - return computeStat(this, column, mean, []); -}; - -/** - * Computes the median of an array. - * - * @param {number[]} array the array of numbers - * @returns the median - */ -const median = (array: number[]): number => { - const n: number = array.length; - if (n === 1) { - return array[0]; - } - const a = array.slice(); - a.sort(); - if (n % 2 === 0) { - const left: number = Math.floor(n / 2) - 1; - const right: number = Math.floor(n / 2); - return (a[left] + a[right]) / 2; - } - const middle: number = Math.floor(n / 2); - return a[middle]; -}; - -/** - * Computes the median of a column or set of columns. - * - * @param {string} [column] the name of the column to analyze - * @returns the median, either as a number or as a table - */ -Table.prototype.median = function _median(column: string): number | Table { - return computeStat(this, column, median, []); -}; - -/** - * Computes the maximum of a column or set of columns. - * - * @param {string} [column] the name of the column to analyze - * @returns the maximum, either as a number or as a table - */ -Table.prototype.max = function _max(column: string): number | Table { - const max = (array: number[]) => Math.max(...array); - return computeStat(this, column, max, []); -}; - -/** - * Computes the minimum of a column or set of columns. - * - * @param {string} [column] the name of the column to analyze - * @returns the minimum, either as a number or as a table - */ -Table.prototype.min = function _min(column: string): number | Table { - const min = (array: number[]) => Math.min(...array); - return computeStat(this, column, min, []); -}; - -/** - * Computes the standard deviation of an array. - * - * @param {number[]} array the array of numbers - * @param {number} [ddof] the delta degrees of freedom is used to divide the sum - * of squared errors: sum(se) / (n - ddof) - * @returns the standard deviation - */ -const sd = (array: number[], ddof: number = 0): number => { - const n: number = array.length; - const mu: number = mean(array); - const se: number[] = array.map((a) => (a - mu) ** 2); - const variance = se.reduce((a, b) => a + b) / (n - ddof); - return Math.sqrt(variance); -}; - -/** - * Computes the standard deviation of a column or set of columns. - * - * @param {string} [column] the name of the column to analyze - * @param {number} [ddof] the delta degrees of freedom is used to divide the sum - * of squared errors: sum(se) / (n - ddof) - * @returns the standard deviation, either as a number or as a table - */ -Table.prototype.sd = function _sd(column: string, ddof: number = 0): number | Table { - return computeStat(this, column, sd, [ddof]); -}; - -/** - * Computes the summary statistics of a p5.Table. - * - * @returns the table of summary stats - */ -Table.prototype.describe = function _describe(): Table { - const output: Table = new Table(); - const columns: string[] = []; - this.columns.forEach((col: string) => { - if (typeof this.get(0, col) === 'number') { - columns.push(col); - } - }); - output.columns = ['stat', ...columns]; - const countRow: TableRow = output.addRow(); - countRow.set('stat', 'count'); - const countTable: number | Table = this.count(); - const meanRow: TableRow = output.addRow(); - meanRow.set('stat', 'mean'); - const meanTable: number | Table = this.mean(); - const sdRow: TableRow = output.addRow(); - sdRow.set('stat', 'sd'); - const sdTable: number | Table = this.sd(); - const minRow: TableRow = output.addRow(); - minRow.set('stat', 'min'); - const minTable: number | Table = this.min(); - const row25: TableRow = output.addRow(); - row25.set('stat', '25%'); - const row50: TableRow = output.addRow(); - row50.set('stat', '50%'); - const row75: TableRow = output.addRow(); - row75.set('stat', '75%'); - const maxRow: TableRow = output.addRow(); - maxRow.set('stat', 'max'); - const maxTable: number | Table = this.max(); - columns.forEach((col: string) => { - // @ts-ignore - countRow.set(col, countTable.get(0, col)); - // @ts-ignore - meanRow.set(col, meanTable.get(0, col)); - // @ts-ignore - sdRow.set(col, sdTable.get(0, col)); - // @ts-ignore - minRow.set(col, minTable.get(0, col)); - // @ts-ignore - maxRow.set(col, maxTable.get(0, col)); - }); - columns.forEach((col: string) => { - const min: number = output.getNum(3, col); - const max: number = output.getNum(7, col); - const range: number = max - min; - row25.set(col, min + 0.25 * range); - row50.set(col, min + 0.50 * range); - row75.set(col, min + 0.75 * range); - }); - return output; -}; diff --git a/src/table/time.ts b/src/table/time.ts deleted file mode 100644 index b74118a..0000000 --- a/src/table/time.ts +++ /dev/null @@ -1,299 +0,0 @@ -/* eslint-disable import/prefer-default-export */ -import * as dayjs from 'dayjs'; -import * as dayOfYear from 'dayjs/plugin/dayOfYear'; -import * as customParseFormat from 'dayjs/plugin/customParseFormat'; -import * as localizedFormat from 'dayjs/plugin/localizedFormat'; -import * as localeData from 'dayjs/plugin/localeData'; -import 'dayjs/locale/af'; -import 'dayjs/locale/am'; -import 'dayjs/locale/ar-dz'; -import 'dayjs/locale/ar-iq'; -import 'dayjs/locale/ar-kw'; -import 'dayjs/locale/ar-ly'; -import 'dayjs/locale/ar-ma'; -import 'dayjs/locale/ar-sa'; -import 'dayjs/locale/ar-tn'; -import 'dayjs/locale/ar'; -import 'dayjs/locale/az'; -import 'dayjs/locale/be'; -import 'dayjs/locale/bg'; -import 'dayjs/locale/bi'; -import 'dayjs/locale/bm'; -import 'dayjs/locale/bn'; -import 'dayjs/locale/bo'; -import 'dayjs/locale/br'; -import 'dayjs/locale/bs'; -import 'dayjs/locale/ca'; -import 'dayjs/locale/cs'; -import 'dayjs/locale/cv'; -import 'dayjs/locale/cy'; -import 'dayjs/locale/da'; -import 'dayjs/locale/de-at'; -import 'dayjs/locale/de-ch'; -import 'dayjs/locale/de'; -import 'dayjs/locale/dv'; -import 'dayjs/locale/el'; -import 'dayjs/locale/en-au'; -import 'dayjs/locale/en-ca'; -import 'dayjs/locale/en-gb'; -import 'dayjs/locale/en-ie'; -import 'dayjs/locale/en-il'; -import 'dayjs/locale/en-in'; -import 'dayjs/locale/en-nz'; -import 'dayjs/locale/en-sg'; -import 'dayjs/locale/en-tt'; -import 'dayjs/locale/en'; -import 'dayjs/locale/eo'; -import 'dayjs/locale/es-do'; -import 'dayjs/locale/es-mx'; -import 'dayjs/locale/et'; -import 'dayjs/locale/eu'; -import 'dayjs/locale/fa'; -import 'dayjs/locale/fi'; -import 'dayjs/locale/fo'; -import 'dayjs/locale/fr-ca'; -import 'dayjs/locale/fr-ch'; -import 'dayjs/locale/fr'; -import 'dayjs/locale/fy'; -import 'dayjs/locale/ga'; -import 'dayjs/locale/gd'; -import 'dayjs/locale/gl'; -import 'dayjs/locale/gom-latn'; -import 'dayjs/locale/gu'; -import 'dayjs/locale/he'; -import 'dayjs/locale/hi'; -import 'dayjs/locale/hr'; -import 'dayjs/locale/ht'; -import 'dayjs/locale/hu'; -import 'dayjs/locale/hy-am'; -import 'dayjs/locale/id'; -import 'dayjs/locale/is'; -import 'dayjs/locale/it-ch'; -import 'dayjs/locale/it'; -import 'dayjs/locale/ja'; -import 'dayjs/locale/jv'; -import 'dayjs/locale/ka'; -import 'dayjs/locale/kk'; -import 'dayjs/locale/km'; -import 'dayjs/locale/kn'; -import 'dayjs/locale/ko'; -import 'dayjs/locale/ku'; -import 'dayjs/locale/ky'; -import 'dayjs/locale/lb'; -import 'dayjs/locale/lo'; -import 'dayjs/locale/lt'; -import 'dayjs/locale/lv'; -import 'dayjs/locale/me'; -import 'dayjs/locale/mi'; -import 'dayjs/locale/mk'; -import 'dayjs/locale/ml'; -import 'dayjs/locale/mn'; -import 'dayjs/locale/mr'; -import 'dayjs/locale/ms-my'; -import 'dayjs/locale/ms'; -import 'dayjs/locale/mt'; -import 'dayjs/locale/my'; -import 'dayjs/locale/nb'; -import 'dayjs/locale/ne'; -import 'dayjs/locale/nl-be'; -import 'dayjs/locale/nl'; -import 'dayjs/locale/nn'; -import 'dayjs/locale/oc-lnc'; -import 'dayjs/locale/pa-in'; -import 'dayjs/locale/pl'; -import 'dayjs/locale/pt-br'; -import 'dayjs/locale/pt'; -import 'dayjs/locale/rn'; -import 'dayjs/locale/ro'; -import 'dayjs/locale/ru'; -import 'dayjs/locale/rw'; -import 'dayjs/locale/sd'; -import 'dayjs/locale/se'; -import 'dayjs/locale/si'; -import 'dayjs/locale/sk'; -import 'dayjs/locale/sl'; -import 'dayjs/locale/sq'; -import 'dayjs/locale/sr-cyrl'; -import 'dayjs/locale/sr'; -import 'dayjs/locale/ss'; -import 'dayjs/locale/sv-fi'; -import 'dayjs/locale/sv'; -import 'dayjs/locale/sw'; -import 'dayjs/locale/ta'; -import 'dayjs/locale/te'; -import 'dayjs/locale/tet'; -import 'dayjs/locale/tg'; -import 'dayjs/locale/th'; -import 'dayjs/locale/tk'; -import 'dayjs/locale/tl-ph'; -import 'dayjs/locale/tlh'; -import 'dayjs/locale/tr'; -import 'dayjs/locale/tzl'; -import 'dayjs/locale/tzm-latn'; -import 'dayjs/locale/tzm'; -import 'dayjs/locale/ug-cn'; -import 'dayjs/locale/uk'; -import 'dayjs/locale/ur'; -import 'dayjs/locale/uz-latn'; -import 'dayjs/locale/uz'; -import 'dayjs/locale/vi'; -import 'dayjs/locale/x-pseudo'; -import 'dayjs/locale/yo'; -import 'dayjs/locale/zh-cn'; -import 'dayjs/locale/zh-hk'; -import 'dayjs/locale/zh-tw'; -import 'dayjs/locale/zh'; -import 'dayjs/locale/es-pr'; -import 'dayjs/locale/es-us'; -import 'dayjs/locale/es'; -import { Table, TableRow } from 'p5'; - -declare module 'p5' { - interface TableRow { - getDateTime( - column: number | string, - format?: dayjs.OptionType, - locale?: string, - strict?: boolean, - ): dayjs.Dayjs; - setDateTime( - column: number | string, - date: dayjs.Dayjs, - format?: dayjs.OptionType, - locale?: string, - strict?: boolean, - ): void; - } - interface Table { - getDateTime( - row: number, - column: number | string, - format?: dayjs.OptionType, - locale?: string, - strict?: boolean, - ): dayjs.Dayjs; - setDateTime( - row: number, - column: number | string, - date: dayjs.Dayjs, - format?: dayjs.OptionType, - locale?: string, - strict?: boolean, - ): void; - parseDates( - column: number | string, - format?: dayjs.OptionType, - locale?: string, - strict?: boolean, - ): void; - } -} - -// Enable dayjs plugins -dayjs.extend(dayOfYear); -dayjs.extend(localeData); -dayjs.localeData(); -dayjs.extend(customParseFormat); -dayjs.extend(localizedFormat); - -/** - * Parse a date and convert it to a datetime object. - * - * @param {number} row row ID - * @param {number | string} column column ID - * @param {dayjs.OptionType} [format] the date format - * @param {string} [locale] the date's locale - * @param {boolean} [strict] flag to enforce strict parsing - * @returns a datetime object - */ -Table.prototype.getDateTime = function _getDateTime( - row: number, - column: number | string, - format?: dayjs.OptionType, - locale?: string, - strict?: boolean, -): dayjs.Dayjs { - let date: string | dayjs.Dayjs = this.get(row, column); - date = dayjs(date, format, locale, strict); - return date; -}; - -/** - * Parse a date and convert it to a datetime object. - * - * @param {number | string} column column ID - * @param {dayjs.OptionType} [format] the date format - * @param {string} [locale] the date's locale - * @param {boolean} [strict] flag to enforce strict parsing - * @returns a datetime object - */ -TableRow.prototype.getDateTime = function _getDateTime( - column: number | string, - format?: dayjs.OptionType, - locale?: string, - strict?: boolean, -): dayjs.Dayjs { - let date: string | dayjs.Dayjs = this.get(column); - date = dayjs(date, format, locale, strict); - return date; -}; - -/** - * Set a p5.Table element to a dayjs.Dayjs object. - * - * @param {number} row row ID - * @param {number | string} column column ID - * @param {dayjs.Dayjs} date the date to set - * @param {dayjs.OptionType} [format] the date format - * @param {string} [locale] the date's locale - * @param {boolean} [strict] flag to enforce strict parsing - */ -Table.prototype.setDateTime = function _setDateTime( - row: number, - column: number | string, - date: dayjs.Dayjs, - format?: dayjs.OptionType, - locale?: string, - strict?: boolean, -): void { - this.set(row, column, dayjs(date, format, locale, strict)); -}; - -/** - * Set a p5.TableRow element to a dayjs.Dayjs object. - * - * @param {number | string} column column ID - * @param {dayjs.Dayjs} date the date to set - * @param {dayjs.OptionType} [format] the date format - * @param {string} [locale] the date's locale - * @param {boolean} [strict] flag to enforce strict parsing - */ -TableRow.prototype.setDateTime = function _setDateTime( - column: number | string, - date: dayjs.Dayjs, - format?: dayjs.OptionType, - locale?: string, - strict?: boolean, -): void { - this.set(column, dayjs(date, format, locale, strict)); -}; - -/** - * Parse the values in a given column and convert them to datetime objects. - * - * @param {number | string} column column ID - * @param {dayjs.OptionType} [format] the date format - * @param {string} [locale] the date's locale - * @param {boolean} [strict] flag to enforce strict parsing - */ -Table.prototype.parseDates = function _parseDates( - column: number | string, - format?: dayjs.OptionType, - locale?: string, - strict?: boolean, -): void { - this.rows.forEach((row: TableRow) => { - const date: dayjs.Dayjs = row.getDateTime(column, format, locale, strict); - row.setDateTime(column, date); - }); -}; diff --git a/src/table/utils.ts b/src/table/utils.ts deleted file mode 100644 index 56555f1..0000000 --- a/src/table/utils.ts +++ /dev/null @@ -1,317 +0,0 @@ -import * as dayjs from 'dayjs'; -// eslint-disable-next-line import/no-extraneous-dependencies -import { Table, TableRow } from 'p5'; - -declare module 'p5' { - interface Table { - print(column?: string): void; - head(numRows?: number, column?: string): void; - tail(numRows?: number, column?: string): void; - inferTypes(): void; - isNull(): Table; - notNull(): Table; - any(column?: string): boolean | Table; - all(column?: string): boolean | Table; - map(func: Function, column?: string): Table; - isin(values: any[]): Table; - } -} - -/** - * Prints a p5.Table to the console. - * - * @param {string} [column] the column to print - */ -Table.prototype.print = function _print(column?: string): void { - let tableObject: object; - if (column && dayjs.isDayjs(this.get(0, column))) { - tableObject = {}; - for (let row = 0; row < this.getRowCount(); row += 1) { - tableObject[row] = {}; - tableObject[row][column] = this.get(row, column).toString(); - } - } else { - tableObject = { ...this.getObject() }; - this.columns.forEach((col: string) => { - if (dayjs.isDayjs(this.get(0, col))) { - for (let row = 0; row < this.getRowCount(); row += 1) { - tableObject[row][col] = tableObject[row][col].toString(); - } - } - }); - } - // eslint-disable-next-line no-console - console.table(tableObject); -}; - -/** - * Prints the first n rows of a p5.Table to the console. - * - * @param {number} [numRows] the number of rows to print - * @param {string} [column] the column to print - */ -Table.prototype.head = function _head(numRows?: number, column?: string): void { - let tableObject: object; - const n: number = numRows || 10; - if (column && dayjs.isDayjs(this.get(0, column))) { - tableObject = {}; - for (let row = 0; row < n; row += 1) { - tableObject[row] = {}; - tableObject[row][column] = this.get(row, column).toString(); - } - } else { - tableObject = {}; - for (let row = 0; row < n; row += 1) { - tableObject[row] = {}; - this.columns.forEach((col: string) => { - tableObject[row][col] = this.get(row, col); - if (dayjs.isDayjs(tableObject[row][col])) { - tableObject[row][col] = tableObject[row][col].toString(); - } - }); - } - } - // eslint-disable-next-line no-console - console.table(tableObject); -}; - -/** - * Prints the last n rows of a p5.Table to the console. - * - * @param {number} [numRows] the number of rows to print - * @param {string} [column] the column to print - */ -Table.prototype.tail = function _tail(numRows?: number, column?: string): void { - let tableObject: object; - const last: number = this.rows.length - 1; - const n: number = numRows || 10; - if (column && dayjs.isDayjs(this.get(0, column))) { - tableObject = {}; - for (let row = last; row > last - n; row -= 1) { - tableObject[row] = {}; - tableObject[row][column] = this.get(row, column).toString(); - } - } else { - tableObject = {}; - for (let row = last; row > last - n; row -= 1) { - tableObject[row] = {}; - this.columns.forEach((col: string) => { - tableObject[row][col] = this.get(row, col); - if (dayjs.isDayjs(tableObject[row][col])) { - tableObject[row][col] = tableObject[row][col].toString(); - } - }); - } - } - // eslint-disable-next-line no-console - console.table(tableObject); -}; - -/** - * Converts the table elements to numbers if possible. - * - * @param {Table} table the table to convert - * @param {string} column the column to convert - */ -const asNum = (table: Table, column: string): void => { - table.rows.forEach((row: TableRow) => { - const num: number = row.getNum(column); - row.setNum(column, num); - }); -}; - -/** - * Infers the type of table elements. - */ -Table.prototype.inferTypes = function _inferTypes(): void { - this.columns.forEach((column: string) => { - try { - asNum(this, column); - } catch (error) { - // pass silently - } - }); -}; - -/** - * Checks whether p5.Table elements are null-ish. - * - * @returns a table of booleans showing whether each - * element is null-ish - */ -Table.prototype.isNull = function _isNull(): Table { - const output: Table = new Table(); - output.columns = this.columns.slice(); - this.rows.forEach((row: TableRow) => { - const newRow: TableRow = output.addRow(); - output.columns.forEach((column) => { - const value: any = row.get(column); - if (value === undefined || value === null || Number.isNaN(value)) { - // @ts-ignore - newRow.set(column, true); - } else { - // @ts-ignore - newRow.set(column, false); - } - }); - }); - return output; -}; - -/** - * Checks whether p5.Table elements are defined. - * - * @returns a table of booleans showing whether each - * element is defined - */ -Table.prototype.notNull = function _notNull(): Table { - const output: Table = new Table(); - output.columns = this.columns.slice(); - this.rows.forEach((row: TableRow) => { - const newRow: TableRow = output.addRow(); - output.columns.forEach((column: string) => { - const value: any = row.get(column); - if (value === undefined || value === null || Number.isNaN(value)) { - // @ts-ignore - newRow.set(column, false); - } else { - // @ts-ignore - newRow.set(column, true); - } - }); - }); - return output; -}; - -/** - * Checks whether any of the elements in a column are truthy. - * - * @param {string} [column] the name of the column to analyze - * @returns a boolean or table of booleans showing whether - * each element is defined - */ -Table.prototype.any = function _any(column?: string): boolean | Table { - if (column === undefined) { - const output: Table = new Table(); - output.columns = this.columns.slice(); - const row: TableRow = output.addRow(); - output.columns.forEach((col: string) => { - const c: any[] = this.getColumn(col); - const value: boolean = c.reduce((prev, curr) => prev || curr); - // @ts-ignore - row.set(col, value); - }); - return output; - } - const col: any[] = this.getColumn(column); - const output: boolean = col.reduce((prev, curr) => prev || curr); - return output; -}; - -/** - * Checks whether all of the elements in a column are truthy. - * - * @param {string} [column] the name of the column to analyze - * @returns a boolean or table of booleans showing whether - * each element is defined - */ -Table.prototype.all = function _all(column?: string): boolean | Table { - if (column === undefined) { - const output: Table = new Table(); - output.columns = this.columns.slice(); - const row: TableRow = output.addRow(); - output.columns.forEach((col: string) => { - const c: any[] = this.getColumn(col); - const value: boolean = c.reduce((prev, curr) => prev && curr); - // @ts-ignore - row.set(col, value); - }); - return output; - } - const col: any[] = this.getColumn(column); - const output: boolean = col.reduce((prev, curr) => prev && curr); - return output; -}; - -/** - * Applies a function to each element in a p5.Table. - * - * @param {function} func the function to apply - * @param {string} [column] the column to apply the function - * @returns the transformed table - */ -Table.prototype.map = function _map(func: Function, column?: string): Table { - const output: Table = new Table(); - if (column && this.columns.includes(column)) { - output.columns = [column]; - } else { - output.columns = this.columns.slice(); - } - this.rows.forEach((row: TableRow) => { - const newRow: TableRow = output.addRow(); - output.columns.forEach((col: string) => { - newRow.set(col, func(row.get(col))); - }); - }); - return output; -}; - -/** - * Checks whether values are present in a table. - * - * @param {any[]} values the values to check - * @returns a table of booleans showing whether each - * element is contained in values - */ -Table.prototype.isin = function _isin(values: any[]): Table { - const output: Table = new Table(); - output.columns = this.columns.slice(); - this.rows.forEach((row) => { - const newRow: TableRow = output.addRow(); - output.columns.forEach((col: string) => { - // @ts-ignore - newRow.set(col, false); - const tableVal: any = row.get(col); - values.every((value) => { - if (tableVal === value) { - // @ts-ignore - newRow.set(col, true); - return false; - } - return true; - }); - }); - }); - return output; -}; - -// eslint-disable-next-line import/prefer-default-export -export const createTable = (data: TableRow[] | string[] | object): Table => { - let output: Table; - if (data instanceof Array && data[0] instanceof TableRow) { - // @ts-ignore - output = new Table(data); - } else if (data instanceof Array && typeof data[0] === 'string') { - output = new Table(); - // @ts-ignore - output.columns = data.slice(); - } else if (data instanceof Object) { - output = new Table(); - output.columns = Object.keys(data); - let n: number; - const firstColumn: any = data[output.columns[0]]; - if (firstColumn instanceof Array) { - n = firstColumn.length; - } else if (firstColumn instanceof Object) { - n = Object.keys(firstColumn).length; - } - for (let i = 0; i < n; i += 1) { - const row: TableRow = output.addRow(); - output.columns.forEach((col: string) => { - const value: number | string = data[col][i]; - row.set(col, value); - }); - } - } - return output; -}; diff --git a/src/table/wrangle.ts b/src/table/wrangle.ts deleted file mode 100644 index 59fcc85..0000000 --- a/src/table/wrangle.ts +++ /dev/null @@ -1,155 +0,0 @@ -import { Table, TableRow } from 'p5'; - -declare module 'p5' { - interface Table { - rename(from: string, to: string): void; - slice(columns: string[]): Table; - concat(other: Table, axis: number): Table; - merge(other: Table, key: string): Table; - } -} - -/** - * Changes the name of a column if it is present. - * - * @param {string} from the current column name - * @param {string} to the new column name - */ -Table.prototype.rename = function _rename(from: string, to: string): void { - const index: number = this.columns.indexOf(from); - if (index < 0) { - throw new Error('The original column is not present in the table.'); - } - this.columns[index] = to; - this.rows.forEach((row: TableRow) => { - // @ts-ignore - // eslint-disable-next-line no-param-reassign - row.obj[to] = row.obj[from]; - // @ts-ignore - // eslint-disable-next-line no-param-reassign - delete row.obj[from]; - }); -}; - -/** - * Copies a subset of the columns from an existing p5.Table. - * - * @param {string[]} columns the column(s) to extract from the table - * @returns the new table - */ -Table.prototype.slice = function _slice(columns: string[]): Table { - const output: Table = new Table(); - output.columns = []; - const all: Set = new Set(this.columns); - columns.forEach((col: string) => { - if (all.has(col)) output.columns.push(col); - }); - this.rows.forEach((row: TableRow) => { - const newRow: TableRow = output.addRow(); - output.columns.forEach((col: string) => { - newRow.set(col, row.get(col)); - }); - }); - return output; -}; - -/** - * Concatenates two p5.Tables along a specified axis. - * - * @param {p5.Table} other the other table to concatenate - * @param {number} [axis] the axis along which to concatenate - * @returns the combined table - */ -Table.prototype.concat = function _concat( - other: Table, - axis: number = 0, -): Table { - if (axis === 0) { - const output: Table = new Table(); - const columns: Set = new Set(); - this.columns.forEach((col: string) => columns.add(col)); - other.columns.forEach((col: string) => columns.add(col)); - output.columns = Array.from(columns); - this.rows.forEach((row: TableRow) => { - const newRow: TableRow = output.addRow(); - this.columns.forEach((col: string) => newRow.set(col, row.get(col))); - }); - other.rows.forEach((row: TableRow) => { - const newRow: TableRow = output.addRow(); - other.columns.forEach((col) => newRow.set(col, row.get(col))); - }); - return output; - } - if (axis === 1) { - const output: Table = new Table(); - const columns: string[] = []; - this.columns.forEach((col: string) => columns.push(col)); - other.columns.forEach((col: string) => columns.push(col)); - output.columns = columns; - let shortTable: Table; - let longTable: Table; - if (this.rows.length > other.rows.length) { - longTable = this; - shortTable = other; - } else { - shortTable = this; - longTable = other; - } - for (let i = 0; i < longTable.rows.length; i += 1) { - const newRow: TableRow = output.addRow(); - const longRow: TableRow = longTable.rows[i]; - longTable.columns.forEach((col: string) => { - newRow.set(col, longRow.get(col)); - }); - if (i < shortTable.rows.length) { - const shortRow: TableRow = shortTable.rows[i]; - shortTable.columns.forEach((col: string) => { - newRow.set(col, shortRow.get(col)); - }); - } - } - return output; - } - throw new Error('axis argument must be 0 or 1.'); -}; - -/** - * Merges two p5.Tables on a specified key. - * - * @param {p5.Table} other the other table to merge - * @param {string} key the key upon which to merge - * @returns the merged table - */ -Table.prototype.merge = function _merge( - other: Table, - key: string, -): Table { - const inLeft: boolean = this.columns.indexOf(key) >= 0; - const inRight: boolean = other.columns.indexOf(key) >= 0; - if (!(inLeft && inRight)) { - throw new Error('Both tables must have the same key.'); - } - const output: Table = new Table(); - const leftCols: string[] = this.columns.filter((col: string) => col !== key); - const rightCols: string[] = other.columns.filter((col: string) => col !== key); - output.columns = [key, ...leftCols, ...rightCols]; - this.rows.forEach((leftRow: TableRow) => { - const leftKey: string | number = leftRow.get(key); - other.rows.forEach((rightRow: TableRow) => { - const rightKey: string | number = rightRow.get(key); - if (leftKey !== rightKey) return; - const newRow: TableRow = output.addRow(); - let kval: string | number = leftRow.get(key); - newRow.set(key, kval); - leftCols.forEach((col: string) => { - kval = leftRow.get(col); - newRow.set(col, kval); - }); - rightCols.forEach((col: string) => { - kval = rightRow.get(col); - newRow.set(col, kval); - }); - }); - }); - return output; -}; diff --git a/src/tensor/memory.ts b/src/tensor/memory.ts index 8f468c5..c562335 100644 --- a/src/tensor/memory.ts +++ b/src/tensor/memory.ts @@ -21,7 +21,7 @@ export const { memory } = tf; * @param fn (optional) the function to execute * @returns (optional) tensors */ -export const { tidy } = tf; +export const scope = tf.tidy; /** * Start a scope. Use this with endScope() to diff --git a/test/index.js b/test/index.js index fe01f6f..700aa61 100644 --- a/test/index.js +++ b/test/index.js @@ -18,7 +18,7 @@ describe('hello, número', function () { describe('the math is mathing', function () { it('sure is', function () { - const c = num.tidy(() => { + const c = num.scope(() => { const a = num.tf.tensor1d([0, 1, 2, 3]); const b = num.tf.scalar(2); return a.mul(b).arraySync(); diff --git a/test/unit/image/index.js b/test/unit/image/index.js index 4d24d11..9a141a5 100644 --- a/test/unit/image/index.js +++ b/test/unit/image/index.js @@ -18,7 +18,7 @@ describe('Image', function () { }); it('Should accept a p5.Image argument', function () { - num.tidy(() => { + num.scope(() => { const img = pInst.createImage(100, 100); const t = num.fromImage(img); expect(t).to.be.an.instanceof(num.Tensor); @@ -32,7 +32,7 @@ describe('Image', function () { }); it('Should accept a Tensor argument', function () { - num.tidy(() => { + num.scope(() => { const t = num.random([512, 512, 3]); num.toImage(t).then((img) => { expect(img).to.be.an.instanceof(p5.Image); diff --git a/test/unit/table/groupby.js b/test/unit/table/groupby.js deleted file mode 100644 index b3bc8b3..0000000 --- a/test/unit/table/groupby.js +++ /dev/null @@ -1,196 +0,0 @@ -/* eslint-disable func-names */ -/* eslint-disable prefer-arrow-callback */ - -describe('Grouping', function () { - let pInst; - - beforeEach(function () { - pInst = new p5(function () { }); - }); - - afterEach(function () { - pInst.remove(); - }); - - describe('groupby()', function () { - it('Should return an object with grouped rows', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 5); - row.setNum('c', 6); - row = t1.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 3); - const t2 = t1.groupby('a'); - expect(t2.groups).to.have.keys(1, 7); - }); - - it('Should calculate the count per group', function () { - const t1 = new p5.Table(); - t1.columns = ['Animal', 'Max Speed']; - let row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 380); - row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 370); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 24); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 26); - const t2 = t1.groupby('Animal').count(); - expect(t2.columns).to.eql(['Max Speed', 'Animal']); - expect(t2.get(0, 'Animal')).to.eql('Falcon'); - expect(t2.get(0, 'Max Speed')).to.eql(2); - expect(t2.get(1, 'Animal')).to.eql('Parrot'); - expect(t2.get(1, 'Max Speed')).to.eql(2); - }); - - it('Should calculate the sum per group', function () { - const t1 = new p5.Table(); - t1.columns = ['Animal', 'Max Speed']; - let row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 380); - row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 370); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 24); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 26); - const t2 = t1.groupby('Animal').sum(); - expect(t2.columns).to.eql(['Max Speed', 'Animal']); - expect(t2.get(0, 'Animal')).to.eql('Falcon'); - expect(t2.get(0, 'Max Speed')).to.eql(750); - expect(t2.get(1, 'Animal')).to.eql('Parrot'); - expect(t2.get(1, 'Max Speed')).to.eql(50); - }); - - it('Should calculate the mean per group', function () { - const t1 = new p5.Table(); - t1.columns = ['Animal', 'Max Speed']; - let row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 380); - row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 370); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 24); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 26); - const t2 = t1.groupby('Animal').mean(); - expect(t2.columns).to.eql(['Max Speed', 'Animal']); - expect(t2.get(0, 'Animal')).to.eql('Falcon'); - expect(t2.get(0, 'Max Speed')).to.eql(375); - expect(t2.get(1, 'Animal')).to.eql('Parrot'); - expect(t2.get(1, 'Max Speed')).to.eql(25); - }); - - it('Should calculate the median per group', function () { - const t1 = new p5.Table(); - t1.columns = ['Animal', 'Max Speed']; - let row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 380); - row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 370); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 24); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 26); - const t2 = t1.groupby('Animal').median(); - expect(t2.columns).to.eql(['Max Speed', 'Animal']); - expect(t2.get(0, 'Animal')).to.eql('Falcon'); - expect(t2.get(0, 'Max Speed')).to.eql(375); - expect(t2.get(1, 'Animal')).to.eql('Parrot'); - expect(t2.get(1, 'Max Speed')).to.eql(25); - }); - - it('Should calculate the max per group', function () { - const t1 = new p5.Table(); - t1.columns = ['Animal', 'Max Speed']; - let row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 380); - row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 370); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 24); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 26); - const t2 = t1.groupby('Animal').max(); - expect(t2.columns).to.eql(['Max Speed', 'Animal']); - expect(t2.get(0, 'Animal')).to.eql('Falcon'); - expect(t2.get(0, 'Max Speed')).to.eql(380); - expect(t2.get(1, 'Animal')).to.eql('Parrot'); - expect(t2.get(1, 'Max Speed')).to.eql(26); - }); - - it('Should calculate the min per group', function () { - const t1 = new p5.Table(); - t1.columns = ['Animal', 'Max Speed']; - let row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 380); - row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 370); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 24); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 26); - const t2 = t1.groupby('Animal').min(); - expect(t2.columns).to.eql(['Max Speed', 'Animal']); - expect(t2.get(0, 'Animal')).to.eql('Falcon'); - expect(t2.get(0, 'Max Speed')).to.eql(370); - expect(t2.get(1, 'Animal')).to.eql('Parrot'); - expect(t2.get(1, 'Max Speed')).to.eql(24); - }); - - it('Should calculate the sd per group', function () { - const t1 = new p5.Table(); - t1.columns = ['Animal', 'Max Speed']; - let row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 380); - row = t1.addRow(); - row.setString('Animal', 'Falcon'); - row.setNum('Max Speed', 370); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 24); - row = t1.addRow(); - row.setString('Animal', 'Parrot'); - row.setNum('Max Speed', 26); - const t2 = t1.groupby('Animal').sd(); - expect(t2.columns).to.eql(['Max Speed', 'Animal']); - expect(t2.get(0, 'Animal')).to.eql('Falcon'); - expect(t2.get(0, 'Max Speed')).to.be.closeTo(5, 0.01); - expect(t2.get(1, 'Animal')).to.eql('Parrot'); - expect(t2.get(1, 'Max Speed')).to.be.closeTo(1, 0.01); - }); - }); -}); diff --git a/test/unit/table/index.js b/test/unit/table/index.js new file mode 100644 index 0000000..15db836 --- /dev/null +++ b/test/unit/table/index.js @@ -0,0 +1,81 @@ +/* eslint-disable func-names */ +/* eslint-disable prefer-arrow-callback */ + +describe('Core', function () { + let pInst; + + beforeEach(function () { + pInst = new p5(function () { }); + }); + + afterEach(function () { + pInst.remove(); + }); + + describe('toTable()', function () { + it('Should work with objects', function () { + const data = pInst.toTable([ + { a: 1, b: 10 }, + { a: 3, b: 12 }, + { a: 2, b: 10 }, + ]); + expect(data).to.be.an.instanceOf(p5.Table); + }); + }); + + describe('toTidy()', function () { + it('Should work with p5.Tables', function () { + const data = [ + { a: 1, b: 10 }, + { a: 3, b: 12 }, + { a: 2, b: 10 }, + ]; + const table = pInst.toTable(data); + expect(pInst.toTidy(table)).to.eql(data); + }); + }); + + describe('Conversion', function () { + it('Should work with objects', function () { + const data = [ + { a: 1, b: 10 }, + { a: 3, b: 12 }, + { a: 2, b: 10 }, + ]; + const results = pInst.tidy( + data, + pInst.mutate({ ab: (d) => d.a * d.b }), + pInst.arrange(pInst.desc('ab')), + ); + expect(results).to.eql( + [ + { a: 3, b: 12, ab: 36 }, + { a: 2, b: 10, ab: 20 }, + { a: 1, b: 10, ab: 10 }, + ] + ); + }); + + it('Should work with p5.Tables', function () { + const data = new p5.Table(); + data.columns = ['a', 'b']; + let row = data.addRow(); + row.set('a', 1); + row.set('b', 10); + row = data.addRow(); + row.set('a', 3); + row.set('b', 12); + row = data.addRow(); + row.set('a', 2); + row.set('b', 10); + const results = pInst.tidy( + data, + pInst.mutate({ ab: (d) => d.a * d.b }), + pInst.arrange(pInst.desc('ab')), + ); + expect(results.get(0, 'ab')).to.eql(36); + expect(results.get(1, 'ab')).to.eql(20); + expect(results.get(2, 'ab')).to.eql(10); + }); + }); +}); diff --git a/test/unit/table/joins.js b/test/unit/table/joins.js new file mode 100644 index 0000000..8876422 --- /dev/null +++ b/test/unit/table/joins.js @@ -0,0 +1,314 @@ +/* eslint-disable func-names */ +/* eslint-disable prefer-arrow-callback */ + +describe('Joins', function () { + let pInst; + + beforeEach(function () { + pInst = new p5(function () { }); + }); + + afterEach(function () { + pInst.remove(); + }); + + describe('fullJoin()', function () { + it('Should work with objects', function () { + const data = [{ a: 1, b: 2 }, { a: 2, b: 5 }]; + const joinData = [{ a: 1, c: 3 }, { a: 4, c: 4 }]; + const results = pInst.tidy(data, + pInst.fullJoin( + joinData, + { by: 'a' }, + ) + ) + expect(results).to.eql( + [ + { a: 1, b: 2, c: 3 }, + { a: 2, b: 5, c: undefined }, + { a: 4, b: undefined, c: 4 }, + ] + ); + }); + + it('Should work with p5.Tables', function () { + const data = pInst.toTable([{ a: 1, b: 2 }, { a: 2, b: 5 }]); + const joinData = pInst.toTable([{ a: 1, c: 3 }, { a: 4, c: 4 }]); + let results = pInst.tidy(data, + pInst.fullJoin( + joinData, + { by: 'a' }, + ) + ); + results = pInst.toTidy(results); + expect(results).to.eql( + [ + { a: 1, b: 2, c: 3 }, + { a: 2, b: 5, c: undefined }, + { a: 4, b: undefined, c: 4 }, + ] + ); + }); + + it('Should work with p5.Tables + objects', function () { + const data = pInst.toTable([{ a: 1, b: 2 }, { a: 2, b: 5 }]); + const joinData = [{ a: 1, c: 3 }, { a: 4, c: 4 }]; + let results = pInst.tidy(data, + pInst.fullJoin( + joinData, + { by: 'a' }, + ) + ); + results = pInst.toTidy(results); + expect(results).to.eql( + [ + { a: 1, b: 2, c: 3 }, + { a: 2, b: 5, c: undefined }, + { a: 4, b: undefined, c: 4 }, + ] + ); + }); + + it('Should work with objects + p5.Tables', function () { + const data = [{ a: 1, b: 2 }, { a: 2, b: 5 }]; + const joinData = pInst.toTable([{ a: 1, c: 3 }, { a: 4, c: 4 }]); + const results = pInst.tidy(data, + pInst.fullJoin( + joinData, + { by: 'a' }, + ) + ); + expect(results).to.eql( + [ + { a: 1, b: 2, c: 3 }, + { a: 2, b: 5, c: undefined }, + { a: 4, b: undefined, c: 4 }, + ] + ); + }); + }); + + describe('innerJoin()', function () { + it('Should work with objects', function () { + const data = [ + { a: 1, J: 'j', b: 10, c: 100 }, + { a: 1, J: 'k', b: 60, c: 600 }, + { a: 1, J: 'J', b: 30, c: 300 }, + { a: 2, J: 'j', b: 20, c: 200 }, + { a: 3, J: 'x', b: 50, c: 500 }, + ]; + const joinData = [ + { a: 1, J: 'j', altJ: 'j', x: 'x1', y: 'y1' }, + { a: 1, J: 'J', altJ: 'J', x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', x: 'x2', y: 'y2' }, + ]; + const results = pInst.tidy( + data, + pInst.innerJoin(joinData, { by: ['a', 'J'] }), + ); + expect(results).to.eql( + [ + { a: 1, J: 'j', altJ: 'j', b: 10, c: 100, x: 'x1', y: 'y1' }, + { a: 1, J: 'J', altJ: 'J', b: 30, c: 300, x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', b: 20, c: 200, x: 'x2', y: 'y2' }, + ] + ); + }); + + it('Should work with p5.Tables', function () { + const data = pInst.toTable([ + { a: 1, J: 'j', b: 10, c: 100 }, + { a: 1, J: 'k', b: 60, c: 600 }, + { a: 1, J: 'J', b: 30, c: 300 }, + { a: 2, J: 'j', b: 20, c: 200 }, + { a: 3, J: 'x', b: 50, c: 500 }, + ]); + const joinData = pInst.toTable([ + { a: 1, J: 'j', altJ: 'j', x: 'x1', y: 'y1' }, + { a: 1, J: 'J', altJ: 'J', x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', x: 'x2', y: 'y2' }, + ]); + let results = pInst.tidy( + data, + pInst.innerJoin(joinData, { by: ['a', 'J'] }), + ); + results = pInst.toTidy(results); + expect(results).to.eql( + [ + { a: 1, J: 'j', altJ: 'j', b: 10, c: 100, x: 'x1', y: 'y1' }, + { a: 1, J: 'J', altJ: 'J', b: 30, c: 300, x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', b: 20, c: 200, x: 'x2', y: 'y2' }, + ] + ); + }); + + it('Should work with p5.Tables + objects', function () { + const data = pInst.toTable([ + { a: 1, J: 'j', b: 10, c: 100 }, + { a: 1, J: 'k', b: 60, c: 600 }, + { a: 1, J: 'J', b: 30, c: 300 }, + { a: 2, J: 'j', b: 20, c: 200 }, + { a: 3, J: 'x', b: 50, c: 500 }, + ]); + const joinData = [ + { a: 1, J: 'j', altJ: 'j', x: 'x1', y: 'y1' }, + { a: 1, J: 'J', altJ: 'J', x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', x: 'x2', y: 'y2' }, + ]; + let results = pInst.tidy( + data, + pInst.innerJoin(joinData, { by: ['a', 'J'] }), + ); + results = pInst.toTidy(results); + expect(results).to.eql( + [ + { a: 1, J: 'j', altJ: 'j', b: 10, c: 100, x: 'x1', y: 'y1' }, + { a: 1, J: 'J', altJ: 'J', b: 30, c: 300, x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', b: 20, c: 200, x: 'x2', y: 'y2' }, + ] + ); + }); + + it('Should work with objects + p5.Tables', function () { + const data = [ + { a: 1, J: 'j', b: 10, c: 100 }, + { a: 1, J: 'k', b: 60, c: 600 }, + { a: 1, J: 'J', b: 30, c: 300 }, + { a: 2, J: 'j', b: 20, c: 200 }, + { a: 3, J: 'x', b: 50, c: 500 }, + ]; + const joinData = [ + { a: 1, J: 'j', altJ: 'j', x: 'x1', y: 'y1' }, + { a: 1, J: 'J', altJ: 'J', x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', x: 'x2', y: 'y2' }, + ]; + let results = pInst.tidy( + data, + pInst.innerJoin(joinData, { by: ['a', 'J'] }), + ); + expect(results).to.eql( + [ + { a: 1, J: 'j', altJ: 'j', b: 10, c: 100, x: 'x1', y: 'y1' }, + { a: 1, J: 'J', altJ: 'J', b: 30, c: 300, x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', b: 20, c: 200, x: 'x2', y: 'y2' }, + ] + ); + }); + }); + + describe('leftJoin()', function () { + it('Should work with objects', function () { + const data = [ + { a: 1, J: 'j', b: 10, c: 100 }, + { a: 1, J: 'k', b: 60, c: 600 }, + { a: 1, J: 'J', b: 30, c: 300 }, + { a: 2, J: 'j', b: 20, c: 200 }, + { a: 3, J: 'x', b: 50, c: 500 }, + ]; + const joinData = [ + { a: 1, J: 'j', altJ: 'j', x: 'x1', y: 'y1' }, + { a: 1, J: 'J', altJ: 'J', x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', x: 'x2', y: 'y2' }, + ]; + const results = pInst.tidy( + data, + pInst.leftJoin(joinData, { by: ['a', 'J'] }), + ); + expect(results).to.eql( + [ + { a: 1, J: 'j', altJ: 'j', b: 10, c: 100, x: 'x1', y: 'y1' }, + { a: 1, J: 'k', altJ: undefined, b: 60, c: 600, x: undefined, y: undefined }, + { a: 1, J: 'J', altJ: 'J', b: 30, c: 300, x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', b: 20, c: 200, x: 'x2', y: 'y2' }, + { a: 3, J: 'x', altJ: undefined, b: 50, c: 500, x: undefined, y: undefined }, + ] + ); + }); + + it('Should work with p5.Tables', function () { + const data = pInst.toTable([ + { a: 1, J: 'j', b: 10, c: 100 }, + { a: 1, J: 'k', b: 60, c: 600 }, + { a: 1, J: 'J', b: 30, c: 300 }, + { a: 2, J: 'j', b: 20, c: 200 }, + { a: 3, J: 'x', b: 50, c: 500 }, + ]); + const joinData = pInst.toTable([ + { a: 1, J: 'j', altJ: 'j', x: 'x1', y: 'y1' }, + { a: 1, J: 'J', altJ: 'J', x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', x: 'x2', y: 'y2' }, + ]); + let results = pInst.tidy( + data, + pInst.leftJoin(joinData, { by: ['a', 'J'] }), + ); + results = pInst.toTidy(results); + expect(results).to.eql( + [ + { a: 1, J: 'j', altJ: 'j', b: 10, c: 100, x: 'x1', y: 'y1' }, + { a: 1, J: 'k', altJ: undefined, b: 60, c: 600, x: undefined, y: undefined }, + { a: 1, J: 'J', altJ: 'J', b: 30, c: 300, x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', b: 20, c: 200, x: 'x2', y: 'y2' }, + { a: 3, J: 'x', altJ: undefined, b: 50, c: 500, x: undefined, y: undefined }, + ] + ); + }); + + it('Should work with p5.Tables + objects', function () { + const data = pInst.toTable([ + { a: 1, J: 'j', b: 10, c: 100 }, + { a: 1, J: 'k', b: 60, c: 600 }, + { a: 1, J: 'J', b: 30, c: 300 }, + { a: 2, J: 'j', b: 20, c: 200 }, + { a: 3, J: 'x', b: 50, c: 500 }, + ]); + const joinData = [ + { a: 1, J: 'j', altJ: 'j', x: 'x1', y: 'y1' }, + { a: 1, J: 'J', altJ: 'J', x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', x: 'x2', y: 'y2' }, + ]; + let results = pInst.tidy( + data, + pInst.leftJoin(joinData, { by: ['a', 'J'] }), + ); + results = pInst.toTidy(results); + expect(results).to.eql( + [ + { a: 1, J: 'j', altJ: 'j', b: 10, c: 100, x: 'x1', y: 'y1' }, + { a: 1, J: 'k', altJ: undefined, b: 60, c: 600, x: undefined, y: undefined }, + { a: 1, J: 'J', altJ: 'J', b: 30, c: 300, x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', b: 20, c: 200, x: 'x2', y: 'y2' }, + { a: 3, J: 'x', altJ: undefined, b: 50, c: 500, x: undefined, y: undefined }, + ] + ); + }); + + it('Should work with objects + p5.Tables', function () { + const data = [ + { a: 1, J: 'j', b: 10, c: 100 }, + { a: 1, J: 'k', b: 60, c: 600 }, + { a: 1, J: 'J', b: 30, c: 300 }, + { a: 2, J: 'j', b: 20, c: 200 }, + { a: 3, J: 'x', b: 50, c: 500 }, + ]; + const joinData = pInst.toTable([ + { a: 1, J: 'j', altJ: 'j', x: 'x1', y: 'y1' }, + { a: 1, J: 'J', altJ: 'J', x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', x: 'x2', y: 'y2' }, + ]); + const results = pInst.tidy( + data, + pInst.leftJoin(joinData, { by: ['a', 'J'] }), + ); + expect(results).to.eql( + [ + { a: 1, J: 'j', altJ: 'j', b: 10, c: 100, x: 'x1', y: 'y1' }, + { a: 1, J: 'k', altJ: undefined, b: 60, c: 600, x: undefined, y: undefined }, + { a: 1, J: 'J', altJ: 'J', b: 30, c: 300, x: 'x9', y: 'y9' }, + { a: 2, J: 'j', altJ: 'j', b: 20, c: 200, x: 'x2', y: 'y2' }, + { a: 3, J: 'x', altJ: undefined, b: 50, c: 500, x: undefined, y: undefined }, + ] + ); + }); + }); +}); diff --git a/test/unit/table/stats.js b/test/unit/table/stats.js deleted file mode 100644 index 1ae6cae..0000000 --- a/test/unit/table/stats.js +++ /dev/null @@ -1,411 +0,0 @@ -/* eslint-disable new-cap */ -/* eslint-disable no-undef */ -/* eslint-disable func-names */ -/* eslint-disable prefer-arrow-callback */ - -describe('Statistics', function () { - let pInst; - - beforeEach(function () { - pInst = new p5(function () { }); - }); - - afterEach(function () { - pInst.remove(); - }); - - describe('count()', function () { - it('Should calculate the count of a column', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.count('a')).to.eq(3); - expect(t.count('b')).to.eq(3); - expect(t.count('c')).to.eq(3); - }); - - it('Should should not count undefined', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', undefined); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.count('a')).to.eq(3); - expect(t.count('b')).to.eq(2); - expect(t.count('c')).to.eq(3); - }); - - it('Should should calculate the count of all columns', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', undefined); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.count().getRow(0).arr).to.eql([3, 2, 3]); - }); - }); - - describe('sum()', function () { - it('Should calculate the sum of a column', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.sum('a')).to.eq(12); - expect(t.sum('b')).to.eq(15); - expect(t.sum('c')).to.eq(18); - }); - - it('Should should not add undefined', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', undefined); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.sum('a')).to.eq(12); - expect(t.sum('b')).to.eq(10); - expect(t.sum('c')).to.eq(18); - }); - - it('Should should calculate the sum of all columns', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', undefined); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.sum().getRow(0).arr).to.eql([12, 10, 18]); - }); - }); - - describe('mean()', function () { - it('Should calculate the mean of a column', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.mean('a')).to.eq(4); - expect(t.mean('b')).to.eq(5); - expect(t.mean('c')).to.eq(6); - }); - - it('Should calculate the mean of all columns', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.mean().getRow(0).arr).to.eql([4, 5, 6]); - }); - }); - - describe('median()', function () { - it('Should calculate the median of a column', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.median('a')).to.eq(4); - expect(t.median('b')).to.eq(5); - expect(t.median('c')).to.eq(6); - }); - - it('Should calculate the median of all columns', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.median().getRow(0).arr).to.eql([4, 5, 6]); - }); - }); - - describe('max()', function () { - it('Should calculate the maximum of a column', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.max('a')).to.eq(7); - expect(t.max('b')).to.eq(8); - expect(t.max('c')).to.eq(9); - }); - - it('Should calculate the maximum of all columns', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.max().getRow(0).arr).to.eql([7, 8, 9]); - }); - }); - - describe('min()', function () { - it('Should calculate the minimum of a column', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.min('a')).to.eq(1); - expect(t.min('b')).to.eq(2); - expect(t.min('c')).to.eq(3); - }); - - it('Should calculate the minimum of all columns', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.min().getRow(0).arr).to.eql([1, 2, 3]); - }); - }); - - describe('sd()', function () { - it('Should calculate the standard deviation of a column', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - expect(t.sd('a')).to.be.closeTo(2.449, 0.001); - expect(t.sd('b')).to.be.closeTo(2.449, 0.001); - expect(t.sd('c')).to.be.closeTo(2.449, 0.001); - }); - - it('Should calculate the standard deviation of all columns', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - let row = t.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - t.sd().getRow(0).arr.forEach((sd) => { - expect(sd).to.be.closeTo(2.449, 0.001); - }); - }); - }); - - describe('describe()', function () { - it('Should return a table with row labels', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t1.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t1.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - const t2 = t1.describe(); - expect(t2.getColumn('stat')).to.eql(['count', 'mean', 'sd', 'min', '25%', '50%', '75%', 'max']); - }); - - it('Should return a table with numeric columns', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t1.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t1.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - const t2 = t1.describe(); - expect(t2.columns).to.eql(['stat', 'a', 'b', 'c']); - }); - - it('Should compute summary statistics for each numeric column', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t1.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - row = t1.addRow(); - row.setNum('a', 7); - row.setNum('b', 8); - row.setNum('c', 9); - const t2 = t1.describe(); - let col = t2.getColumn('a'); - let values = [3, 4, 2.449, 1, 2.5, 4, 5.5, 7]; - for (let i = 0; i < values.length; i += 1) { - expect(col[i]).to.be.closeTo(values[i], 0.001); - } - col = t2.getColumn('b'); - values = [3, 5, 2.449, 2, 3.5, 5, 6.5, 8]; - for (let i = 0; i < values.length; i += 1) { - expect(col[i]).to.be.closeTo(values[i], 0.001); - } - col = t2.getColumn('c'); - values = [3, 6, 2.449, 3, 4.5, 6, 7.5, 9]; - for (let i = 0; i < values.length; i += 1) { - expect(col[i]).to.be.closeTo(values[i], 0.001); - } - }); - }); -}); diff --git a/test/unit/table/time.js b/test/unit/table/time.js deleted file mode 100644 index 0d5f479..0000000 --- a/test/unit/table/time.js +++ /dev/null @@ -1,53 +0,0 @@ -/* eslint-disable func-names */ -/* eslint-disable prefer-arrow-callback */ - -describe('Time', function () { - let pInst; - - beforeEach(function () { - pInst = new p5(function () { }); - }); - - afterEach(function () { - pInst.remove(); - }); - - describe('get and set', function () { - it('Should create valid dates', function () { - const t = new p5.Table(); - t.columns = ['date']; - t.addRow(); - t.setDateTime(0, 0, '2013-02-25'); - const d = t.getDateTime(0, 0); - expect(d.isValid()).to.be.true; - }); - - it('Should allow custom parse formats', function () { - const t = new p5.Table(); - t.columns = ['date']; - t.addRow(); - t.setDateTime(0, 0, '2013 二月 25日', 'YYYY MMMM Do', 'zh-cn'); - t.addRow(); - t.setDateTime(1, 0, '2013-02-25'); - const d1 = t.getDateTime(0, 0); - const d2 = t.getDateTime(1, 0); - expect(d1.valueOf()).to.eql(d2.valueOf()); - }); - }); - - describe('parseDates()', function () { - it('Should create valid dates', function () { - const t = new p5.Table(); - t.columns = ['date']; - t.addRow(); - t.setString(0, 0, '2013-02-05'); - t.addRow(); - t.setString(0, 0, '2020-02-29'); - t.parseDates('date'); - const d1 = t.get(0, 0); - expect(d1.isValid()).to.be.true; - const d2 = t.get(1, 0); - expect(d2.isValid()).to.be.true; - }); - }); -}); diff --git a/test/unit/table/utils.js b/test/unit/table/utils.js deleted file mode 100644 index 9c89640..0000000 --- a/test/unit/table/utils.js +++ /dev/null @@ -1,231 +0,0 @@ -/* eslint-disable func-names */ -/* eslint-disable prefer-arrow-callback */ - -describe('Utilities', function () { - let pInst; - - beforeEach(function () { - pInst = new p5(function () { }); - }); - - afterEach(function () { - pInst.remove(); - }); - - describe('isNull()', function () { - it('Should return a table of booleans', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', undefined); - row.setNum('b', 2); - row.setNum('c', 3); - row = t1.addRow(); - row.setNum('a', 4); - row.setNum('b', undefined); - row.setNum('c', 6); - const t2 = t1.isNull(); - expect(t2.get(0, 'a')).to.be.true; - expect(t2.get(0, 'b')).to.be.false; - expect(t2.get(0, 'c')).to.be.false; - expect(t2.get(1, 'a')).to.be.false; - expect(t2.get(1, 'b')).to.be.true; - expect(t2.get(1, 'c')).to.be.false; - }); - }); - - describe('notNull()', function () { - it('Should return a table of booleans', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', undefined); - row.setNum('b', 2); - row.setNum('c', 3); - row = t1.addRow(); - row.setNum('a', 4); - row.setNum('b', undefined); - row.setNum('c', 6); - const t2 = t1.notNull(); - expect(t2.get(0, 'a')).to.be.false; - expect(t2.get(0, 'b')).to.be.true; - expect(t2.get(0, 'c')).to.be.true; - expect(t2.get(1, 'a')).to.be.true; - expect(t2.get(1, 'b')).to.be.false; - expect(t2.get(1, 'c')).to.be.true; - }); - }); - - describe('map()', function () { - it('Should apply a function to each element', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t1.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - const t2 = t1.map((x) => x ** 2); - expect(t2.get(0, 'a')).to.eq(1); - expect(t2.get(0, 'b')).to.eq(4); - expect(t2.get(0, 'c')).to.eq(9); - expect(t2.get(1, 'a')).to.eq(16); - expect(t2.get(1, 'b')).to.eq(25); - expect(t2.get(1, 'c')).to.eq(36); - }); - }); - - describe('isin()', function () { - it('Should return a table of booleans', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t1.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - const t2 = t1.isin([1, 5]); - expect(t2.get(0, 'a')).to.be.true; - expect(t2.get(0, 'b')).to.be.false; - expect(t2.get(0, 'c')).to.be.false; - expect(t2.get(1, 'a')).to.be.false; - expect(t2.get(1, 'b')).to.be.true; - expect(t2.get(1, 'c')).to.be.false; - }); - }); - - describe('any()', function () { - it('Should return a boolean for a single column', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.set('a', true); - row.set('b', false); - row.set('c', true); - row = t1.addRow(); - row.set('a', false); - row.set('b', false); - row.set('c', true); - row = t1.addRow(); - row.set('a', false); - row.set('b', false); - row.set('c', true); - expect(t1.any('a')).to.be.true; - expect(t1.any('b')).to.be.false; - expect(t1.any('c')).to.be.true; - }); - - it('Should return booleans for all columns', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.set('a', true); - row.set('b', false); - row.set('c', true); - row = t1.addRow(); - row.set('a', false); - row.set('b', false); - row.set('c', true); - row = t1.addRow(); - row.set('a', false); - row.set('b', false); - row.set('c', true); - const t2 = t1.any(); - expect(t2.getColumn('a')).to.eql([true]); - expect(t2.getColumn('b')).to.eql([false]); - expect(t2.getColumn('c')).to.eql([true]); - }); - }); - - describe('all()', function () { - it('Should return a boolean for a single column', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.set('a', true); - row.set('b', false); - row.set('c', true); - row = t1.addRow(); - row.set('a', false); - row.set('b', false); - row.set('c', true); - row = t1.addRow(); - row.set('a', false); - row.set('b', false); - row.set('c', true); - expect(t1.all('a')).to.be.false; - expect(t1.all('b')).to.be.false; - expect(t1.all('c')).to.be.true; - }); - - it('Should return booleans for all columns', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.set('a', true); - row.set('b', false); - row.set('c', true); - row = t1.addRow(); - row.set('a', false); - row.set('b', false); - row.set('c', true); - row = t1.addRow(); - row.set('a', false); - row.set('b', false); - row.set('c', true); - const t2 = t1.all(); - expect(t2.getColumn('a')).to.eql([false]); - expect(t2.getColumn('b')).to.eql([false]); - expect(t2.getColumn('c')).to.eql([true]); - }); - }); - - describe('createTable()', function () { - it('Should create a p5.Table with empty columns', function () { - const columns = ['a', 'b', 'c']; - const t = pInst.createTable(columns); - expect(t.columns).to.eql(columns); - expect(t.getRowCount()).to.eq(0); - }); - - it('Should create a p5.Table from an object', function () { - const t = pInst.createTable({ - x: [1, 2, 3], - y: [4, 5, 6], - }); - expect(t.get(0, 'x')).to.eq(1); - expect(t.get(1, 'x')).to.eq(2); - expect(t.get(2, 'x')).to.eq(3); - expect(t.get(0, 'y')).to.eq(4); - expect(t.get(1, 'y')).to.eq(5); - expect(t.get(2, 'y')).to.eq(6); - }); - - it('Should create a p5.Table from JSON', function () { - const t = pInst.createTable({ - x: { - 0: 1, - 1: 2, - 2: 3, - }, - y: { - 0: 4, - 1: 5, - 2: 6, - }, - }); - expect(t.get(0, 'x')).to.eq(1); - expect(t.get(1, 'x')).to.eq(2); - expect(t.get(2, 'x')).to.eq(3); - expect(t.get(0, 'y')).to.eq(4); - expect(t.get(1, 'y')).to.eq(5); - expect(t.get(2, 'y')).to.eq(6); - }); - }); -}); diff --git a/test/unit/table/wrangle.js b/test/unit/table/wrangle.js deleted file mode 100644 index b659d00..0000000 --- a/test/unit/table/wrangle.js +++ /dev/null @@ -1,284 +0,0 @@ -/* eslint-disable func-names */ -/* eslint-disable prefer-arrow-callback */ - -describe('Wrangling', function () { - let pInst; - - beforeEach(function () { - pInst = new p5(function () { }); - }); - - afterEach(function () { - pInst.remove(); - }); - - describe('rename()', function () { - it('Should rename columns in place', function () { - const t = new p5.Table(); - t.columns = ['a', 'b', 'c']; - t.rename('a', 'A'); - expect(t.columns).to.eql(['A', 'b', 'c']); - }); - }); - - describe('slice()', function () { - it('Should create a new p5.Table', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - const r = t1.addRow(); - r.set('a', 1); - r.set('b', 2); - r.set('c', 3); - const t2 = t1.slice(['a', 'b']); - expect(t2.columns).to.eql(['a', 'b']); - expect(t2.get(0, 'a')).to.eq(1); - expect(t2.get(0, 'b')).to.eq(2); - }); - }); - - describe('concat()', function () { - it('Should concatenate two tables vertically', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - const t2 = new p5.Table(); - t2.columns = ['a', 'b', 'c']; - row = t2.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - const t3 = t1.concat(t2); - expect(t3.get(1, 'a')).to.eq(4); - expect(t3.get(1, 'b')).to.eq(5); - expect(t3.get(1, 'c')).to.eq(6); - }); - - it('Should concatenate two tables with overlapping columns', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - const t2 = new p5.Table(); - t2.columns = ['c', 'd', 'e']; - row = t2.addRow(); - row.setNum('c', 4); - row.setNum('d', 5); - row.setNum('e', 6); - const t3 = t1.concat(t2); - expect(t3.get(0, 'a')).to.eq(1); - expect(t3.get(0, 'b')).to.eq(2); - expect(t3.get(0, 'c')).to.eq(3); - expect(t3.get(0, 'd')).to.eq(undefined); - expect(t3.get(0, 'e')).to.eq(undefined); - expect(t3.get(1, 'a')).to.eq(undefined); - expect(t3.get(1, 'b')).to.eq(undefined); - expect(t3.get(1, 'c')).to.eq(4); - expect(t3.get(1, 'd')).to.eq(5); - expect(t3.get(1, 'e')).to.eq(6); - }); - - it('Should concatenate two tables with disjoint columns', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - const t2 = new p5.Table(); - t2.columns = ['d', 'e']; - row = t2.addRow(); - row.setNum('d', 4); - row.setNum('e', 5); - const t3 = t1.concat(t2); - expect(t3.get(0, 'a')).to.eq(1); - expect(t3.get(0, 'b')).to.eq(2); - expect(t3.get(0, 'c')).to.eq(3); - expect(t3.get(0, 'd')).to.eq(undefined); - expect(t3.get(0, 'e')).to.eq(undefined); - expect(t3.get(1, 'a')).to.eq(undefined); - expect(t3.get(1, 'b')).to.eq(undefined); - expect(t3.get(1, 'c')).to.eq(undefined); - expect(t3.get(1, 'd')).to.eq(4); - expect(t3.get(1, 'e')).to.eq(5); - }); - - it('Should concatenate two tables horizontally', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t1.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - const t2 = new p5.Table(); - t2.columns = ['d', 'e']; - row = t2.addRow(); - row.setNum('d', 7); - row.setNum('e', 8); - row = t2.addRow(); - row.setNum('d', 9); - row.setNum('e', 10); - const t3 = t1.concat(t2, 1); - expect(t3.get(0, 'a')).to.eq(1); - expect(t3.get(0, 'b')).to.eq(2); - expect(t3.get(0, 'c')).to.eq(3); - expect(t3.get(0, 'd')).to.eq(7); - expect(t3.get(0, 'e')).to.eq(8); - expect(t3.get(1, 'a')).to.eq(4); - expect(t3.get(1, 'b')).to.eq(5); - expect(t3.get(1, 'c')).to.eq(6); - expect(t3.get(1, 'd')).to.eq(9); - expect(t3.get(1, 'e')).to.eq(10); - }); - - it('Should concatenate two tables with different numbers of rows', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t1.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - const t2 = new p5.Table(); - t2.columns = ['d', 'e']; - row = t2.addRow(); - row.setNum('d', 7); - row.setNum('e', 8); - const t3 = t1.concat(t2, 1); - expect(t3.get(0, 'a')).to.eq(1); - expect(t3.get(0, 'b')).to.eq(2); - expect(t3.get(0, 'c')).to.eq(3); - expect(t3.get(0, 'd')).to.eq(7); - expect(t3.get(0, 'e')).to.eq(8); - expect(t3.get(1, 'a')).to.eq(4); - expect(t3.get(1, 'b')).to.eq(5); - expect(t3.get(1, 'c')).to.eq(6); - expect(t3.get(1, 'd')).to.eq(undefined); - expect(t3.get(1, 'e')).to.eq(undefined); - }); - - it('Should concatenate two tables with overlapping columns (bad idea)', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - const t2 = new p5.Table(); - t2.columns = ['c', 'd', 'e']; - row = t2.addRow(); - row.setNum('c', 4); - row.setNum('d', 5); - row.setNum('e', 6); - const t3 = t1.concat(t2, 1); - expect(t3.columns).to.eql(['a', 'b', 'c', 'c', 'd', 'e']); - }); - - it('Should reject garbage arguments', function () { - const t1 = new p5.Table(); - t1.columns = ['a', 'b', 'c']; - let row = t1.addRow(); - row.setNum('a', 1); - row.setNum('b', 2); - row.setNum('c', 3); - row = t1.addRow(); - row.setNum('a', 4); - row.setNum('b', 5); - row.setNum('c', 6); - const t2 = new p5.Table(); - t2.columns = ['d', 'e']; - row = t2.addRow(); - row.setNum('d', 7); - row.setNum('e', 8); - row = t2.addRow(); - row.setNum('d', 9); - row.setNum('e', 10); - expect(() => t1.concat(t2, 2)).to.throw(Error); - }); - }); - - describe('merge()', function () { - it('Should require matching keys', function () { - const left = new p5.Table(); - left.columns = ['key', 'lval']; - let row = left.addRow(); - row.set('key', 'foo'); - row.set('lval', 1); - const right = new p5.Table(); - right.columns = ['cay', 'rval']; - row = right.addRow(); - row.set('cay', 'foo'); - row.set('rval', 3); - expect(() => left.merge(right, 'key')).to.throw(Error); - }); - - it('Should merge given identical keys', function () { - const left = new p5.Table(); - left.columns = ['key', 'lval']; - let row = left.addRow(); - row.set('key', 'foo'); - row.set('lval', 1); - row = left.addRow(); - row.set('key', 'foo'); - row.set('lval', 2); - const right = new p5.Table(); - right.columns = ['key', 'rval']; - row = right.addRow(); - row.set('key', 'foo'); - row.set('rval', 3); - row = right.addRow(); - row.set('key', 'foo'); - row.set('rval', 4); - const merged = left.merge(right, 'key'); - expect(merged.get(0, 'key')).to.eq('foo'); - expect(merged.get(0, 'lval')).to.eq(1); - expect(merged.get(0, 'rval')).to.eq(3); - expect(merged.get(1, 'key')).to.eq('foo'); - expect(merged.get(1, 'lval')).to.eq(1); - expect(merged.get(1, 'rval')).to.eq(4); - expect(merged.get(2, 'key')).to.eq('foo'); - expect(merged.get(2, 'lval')).to.eq(2); - expect(merged.get(2, 'rval')).to.eq(3); - expect(merged.get(3, 'key')).to.eq('foo'); - expect(merged.get(3, 'lval')).to.eq(2); - expect(merged.get(3, 'rval')).to.eq(4); - }); - - it('Should merge given different keys', function () { - const left = new p5.Table(); - left.columns = ['key', 'lval']; - let row = left.addRow(); - row.set('key', 'foo'); - row.set('lval', 1); - row = left.addRow(); - row.set('key', 'bar'); - row.set('lval', 2); - const right = new p5.Table(); - right.columns = ['key', 'rval']; - row = right.addRow(); - row.set('key', 'foo'); - row.set('rval', 3); - row = right.addRow(); - row.set('key', 'bar'); - row.set('rval', 4); - const merged = left.merge(right, 'key'); - expect(merged.get(0, 'key')).to.eq('foo'); - expect(merged.get(0, 'lval')).to.eq(1); - expect(merged.get(0, 'rval')).to.eq(3); - expect(merged.get(1, 'key')).to.eq('bar'); - expect(merged.get(1, 'lval')).to.eq(2); - expect(merged.get(1, 'rval')).to.eq(4); - }); - }); -}); diff --git a/test/unit/tensor/memory.js b/test/unit/tensor/memory.js index 6741ff7..26db787 100644 --- a/test/unit/tensor/memory.js +++ b/test/unit/tensor/memory.js @@ -36,7 +36,7 @@ describe('Memory', function () { describe('tidy()', function () { it('Should clean up memory', function () { const start = num.tf.memory().numTensors; - num.tidy(() => { + num.scope(() => { const t = num.tf.tensor([1, 2, 3]); }); const end = num.tf.memory().numTensors; @@ -44,7 +44,7 @@ describe('Memory', function () { }); it('Should return tensors', function () { - const t = num.tidy(() => pInst.createTensor([1, 2, 3])); + const t = num.scope(() => pInst.createTensor([1, 2, 3])); expect(t).to.be.an.instanceof(num.Tensor); }); }); diff --git a/test/unit/tensor/ufunc.js b/test/unit/tensor/ufunc.js index 7d01948..f1ea7ef 100644 --- a/test/unit/tensor/ufunc.js +++ b/test/unit/tensor/ufunc.js @@ -15,7 +15,7 @@ describe('Universal Functions', function () { describe('Calculation', function () { describe('add()', function () { it('Should add a Tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2]); const t2 = pInst.createTensor([3, 4]); const t3 = pInst.createTensor([4, 6]); @@ -25,7 +25,7 @@ describe('Universal Functions', function () { }); it('Should add a p5.Vector', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2, 3]); const v = pInst.createVector(4, 5, 6); const t2 = pInst.createTensor([5, 7, 9]); @@ -35,7 +35,7 @@ describe('Universal Functions', function () { }); it('Should add a Number', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor(1); const n = 1; const t2 = pInst.createTensor(2); @@ -45,7 +45,7 @@ describe('Universal Functions', function () { }); it('Should broadcast addition when maintaining rank', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2]); const t2 = pInst.createTensor(1); const t3 = pInst.createTensor([2, 3]); @@ -55,7 +55,7 @@ describe('Universal Functions', function () { }); it('Should broadcast addition when increasing rank', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor(1); const t2 = pInst.createTensor([1, 2]); const t3 = pInst.createTensor([2, 3]); @@ -65,7 +65,7 @@ describe('Universal Functions', function () { }); it('Should work with complex tensors', function () { - num.tidy(() => { + num.scope(() => { const z1 = num.Tensor.complex(2, 5); const z2 = num.Tensor.complex(1, 3); const z3 = num.Tensor.complex(3, 8); @@ -77,7 +77,7 @@ describe('Universal Functions', function () { describe('sub()', function () { it('Should subtract a Tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([3, 4]); const t2 = pInst.createTensor([1, 2]); const t3 = pInst.createTensor([2, 2]); @@ -87,7 +87,7 @@ describe('Universal Functions', function () { }); it('Should subtract a p5.Vector', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([4, 5, 6]); const v = pInst.createVector(1, 2); const t2 = pInst.createTensor([3, 3, 6]); @@ -97,7 +97,7 @@ describe('Universal Functions', function () { }); it('Should subtract a Number', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor(1); const n = 1; const t2 = pInst.createTensor(0); @@ -107,7 +107,7 @@ describe('Universal Functions', function () { }); it('Should broadcast subtraction when maintaining rank', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([2, 3]); const t2 = pInst.createTensor(1); const t3 = pInst.createTensor([1, 2]); @@ -117,7 +117,7 @@ describe('Universal Functions', function () { }); it('Should broadcast subtraction when increasing rank', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor(1); const t2 = pInst.createTensor([2, 3]); const t3 = pInst.createTensor([-1, -2]); @@ -127,7 +127,7 @@ describe('Universal Functions', function () { }); it('Should work with complex tensors', function () { - num.tidy(() => { + num.scope(() => { const z1 = num.Tensor.complex(2, 5); const z2 = num.Tensor.complex(1, 3); const z3 = num.Tensor.complex(1, 2); @@ -139,7 +139,7 @@ describe('Universal Functions', function () { describe('mult()', function () { it('Should multiply by a Tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([[1, 2], [3, 4]]); const t2 = pInst.createTensor([[2, 2], [2, 2]]); const t3 = pInst.createTensor([[2, 4], [6, 8]]); @@ -149,7 +149,7 @@ describe('Universal Functions', function () { }); it('Should multiply by a p5.Vector', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([3, 4, 5]); const v = pInst.createVector(1, 2); const t2 = pInst.createTensor([3, 8, 0]); @@ -159,7 +159,7 @@ describe('Universal Functions', function () { }); it('Should multiply by a Number', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor(1); const n = 2; const t2 = pInst.createTensor(2); @@ -169,7 +169,7 @@ describe('Universal Functions', function () { }); it('Should broadcast multiplication when maintaining rank', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([[1, 2], [3, 4]]); const t2 = pInst.createTensor(2); const t3 = pInst.createTensor([[2, 4], [6, 8]]); @@ -179,7 +179,7 @@ describe('Universal Functions', function () { }); it('Should broadcast multiplication when increasing rank', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor(2); const t2 = pInst.createTensor([[1, 2], [3, 4]]); const t3 = pInst.createTensor([[2, 4], [6, 8]]); @@ -189,7 +189,7 @@ describe('Universal Functions', function () { }); it('Should work with complex tensors', function () { - num.tidy(() => { + num.scope(() => { const z1 = num.Tensor.complex(2, 5); const z2 = num.Tensor.complex(3, -2); const z3 = num.Tensor.complex(16, 11); @@ -201,7 +201,7 @@ describe('Universal Functions', function () { describe('div()', function () { it('Should divide by a Tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([[1, 2], [3, 4]]); const t2 = pInst.createTensor([[2, 2], [2, 2]]); const t3 = pInst.createTensor([[0.5, 1], [1.5, 2]]); @@ -211,7 +211,7 @@ describe('Universal Functions', function () { }); it('Should divide by a p5.Vector', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([2, 4, 6]); const v = pInst.createVector(2, 2, 2); const t2 = pInst.createTensor([1, 2, 3]); @@ -221,7 +221,7 @@ describe('Universal Functions', function () { }); it('Should divide by a Number', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([2, 4]); const n = 2; const t2 = pInst.createTensor([1, 2]); @@ -231,7 +231,7 @@ describe('Universal Functions', function () { }); it('Should broadcast division when maintaining rank', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([[1, 2], [3, 4]]); const t2 = pInst.createTensor(2); const t3 = pInst.createTensor([[0.5, 1], [1.5, 2]]); @@ -241,7 +241,7 @@ describe('Universal Functions', function () { }); it('Should broadcast division when increasing rank', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor(10); const t2 = pInst.createTensor([[1, 2], [4, 5]]); const t3 = pInst.createTensor([[10, 5], [2.5, 2]]); @@ -253,7 +253,7 @@ describe('Universal Functions', function () { describe('dot()', function () { it('Should dot with a Tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([[1, 0], [0, 1]]); const t2 = pInst.createTensor([1, 2]); const t3 = num.dot(t1, t2); @@ -262,7 +262,7 @@ describe('Universal Functions', function () { }); it('Should dot with a p5.Vector', function () { - num.tidy(() => { + num.scope(() => { const a = pInst.createTensor([[2, 0, 0], [0, 2, 0], [0, 0, 2]]); const x = pInst.createVector(1, 2, 0); const b = pInst.createTensor([2, 4, 0]); @@ -274,7 +274,7 @@ describe('Universal Functions', function () { describe('abs()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([-2, 0, 1]); const t2 = pInst.createTensor([2, 0, 1]); const t3 = num.abs(t1); @@ -285,7 +285,7 @@ describe('Universal Functions', function () { describe('ceil()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([0, 0.1, 1.5]); const t2 = pInst.createTensor([0, 1, 2]); const t3 = num.ceil(t1); @@ -296,7 +296,7 @@ describe('Universal Functions', function () { describe('constrain()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([-2, 0, 1, 5]); const t2 = pInst.createTensor([-1, 0, 1, 3]); const t3 = num.constrain(t1, -1, 3); @@ -307,7 +307,7 @@ describe('Universal Functions', function () { describe('exp()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const a = [-2, 0, 1, 5]; const t1 = pInst.createTensor(a); const t2 = pInst.createTensor(a.map((x) => Math.exp(x))); @@ -319,7 +319,7 @@ describe('Universal Functions', function () { describe('floor()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([0, 0.1, 1.5]); const t2 = pInst.createTensor([0, 0, 1]); const t3 = num.floor(t1); @@ -330,7 +330,7 @@ describe('Universal Functions', function () { describe('log()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const a = [1, 2, 3]; const t1 = pInst.createTensor(a); const t2 = pInst.createTensor(a.map((x) => Math.log(x))); @@ -342,7 +342,7 @@ describe('Universal Functions', function () { describe('max()', function () { it('Should return a number', function () { - num.tidy(() => { + num.scope(() => { const t = pInst.createTensor([1, 2, 3]); expect(num.max(t)).to.equal(3); }); @@ -351,7 +351,7 @@ describe('Universal Functions', function () { describe('min()', function () { it('Should return a number', function () { - num.tidy(() => { + num.scope(() => { const t = pInst.createTensor([1, 2, 3]); expect(num.min(t)).to.equal(1); }); @@ -360,7 +360,7 @@ describe('Universal Functions', function () { describe('mod()', function () { it('Should accept Number arguments', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([2, 4, 5]); const t2 = pInst.createTensor([0, 0, 1]); const t3 = num.mod(t1, 2); @@ -369,7 +369,7 @@ describe('Universal Functions', function () { }); it('Should accept Tensor arguments', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([2, 4, 5]); const t2 = pInst.createTensor([2, 2, 2]); const t3 = pInst.createTensor([0, 0, 1]); @@ -381,7 +381,7 @@ describe('Universal Functions', function () { describe('pow()', function () { it('Should accept Number arguments', function () { - num.tidy(() => { + num.scope(() => { const a = [1, 2, 3]; const t1 = pInst.createTensor(a); const t2 = pInst.createTensor(a.map((x) => x ** 2)); @@ -391,7 +391,7 @@ describe('Universal Functions', function () { }); it('Should accept Tensor arguments', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2, 3]); const t2 = pInst.createTensor([1, 2, 3]); const t3 = num.pow(t1, t2); @@ -403,7 +403,7 @@ describe('Universal Functions', function () { describe('round()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([2.2, 0.3, -1.4]); const t2 = pInst.createTensor([2, 0, -1]); const t3 = num.round(t1); @@ -414,7 +414,7 @@ describe('Universal Functions', function () { describe('sq()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2, 3]); const t2 = pInst.createTensor([1, 4, 9]); const t3 = num.sq(t1); @@ -425,7 +425,7 @@ describe('Universal Functions', function () { describe('sqrt()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 4, 9]); const t2 = pInst.createTensor([1, 2, 3]); const t3 = num.sqrt(t1); @@ -456,7 +456,7 @@ describe('Universal Functions', function () { describe('Trigonometry', function () { describe('acos()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor(0); const t2 = pInst.createTensor(Math.PI / 2); const t3 = num.acos(t1); @@ -472,7 +472,7 @@ describe('Universal Functions', function () { describe('asin()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor(1); const t2 = pInst.createTensor(Math.PI / 2); const t3 = num.asin(t1); @@ -488,7 +488,7 @@ describe('Universal Functions', function () { describe('atan()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const a = Math.PI + Math.PI / 3; const t1 = pInst.createTensor(a); const t2 = pInst.createTensor(Math.atan(a)); @@ -500,7 +500,7 @@ describe('Universal Functions', function () { describe('atan2()', function () { it('Should accept Number arguments', function () { - num.tidy(() => { + num.scope(() => { const x = 15; const y = 90; const t1 = pInst.createTensor(y); @@ -511,7 +511,7 @@ describe('Universal Functions', function () { }); it('Should accept Tensor arguments', function () { - num.tidy(() => { + num.scope(() => { const x = 15; const y = 90; const t1 = pInst.createTensor(y); @@ -525,7 +525,7 @@ describe('Universal Functions', function () { describe('cos()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor(Math.PI); const t2 = pInst.createTensor(-1); const t3 = num.cos(t1); @@ -536,7 +536,7 @@ describe('Universal Functions', function () { describe('sin()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor(Math.PI / 2); const t2 = pInst.createTensor(1); const t3 = num.sin(t1); @@ -547,7 +547,7 @@ describe('Universal Functions', function () { describe('tan()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const a = 1; const t1 = pInst.createTensor(a); const t2 = pInst.createTensor(Math.tan(a)); @@ -561,7 +561,7 @@ describe('Universal Functions', function () { describe('Creation Methods', function () { describe('complex()', function () { it('Should accept two Number arguments', function () { - num.tidy(() => { + num.scope(() => { const real = 2; const imag = 5; const z = num.complex(real, imag); @@ -581,7 +581,7 @@ describe('Universal Functions', function () { }); it('Should accept two tensor arguments', function () { - num.tidy(() => { + num.scope(() => { const real = pInst.createTensor(2); const imag = pInst.createTensor(5); const z = num.complex(real, imag); @@ -591,7 +591,7 @@ describe('Universal Functions', function () { }); it('Should reject garbage arguments', function () { - num.tidy(() => { + num.scope(() => { const real = '2'; const imag = '5'; expect(() => num.complex(real, imag)).to.throw(Error); @@ -601,7 +601,7 @@ describe('Universal Functions', function () { describe('copy()', function () { it('Should return a copy of the calling tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2, 3]); const t2 = num.copy(t1); expect(t1.equals(t2)).to.equal(true); @@ -611,7 +611,7 @@ describe('Universal Functions', function () { describe('eye()', function () { it('Should return an identity matrix', function () { - num.tidy(() => { + num.scope(() => { const eye = [[1, 0], [0, 1]]; const t = num.eye(2); const x = t.arraySync(); @@ -620,7 +620,7 @@ describe('Universal Functions', function () { }); it('Should allow for rectangular identity matrices', function () { - num.tidy(() => { + num.scope(() => { const eye = [[1, 0, 0], [0, 1, 0]]; const t = num.eye(2, 3); const x = t.arraySync(); @@ -631,7 +631,7 @@ describe('Universal Functions', function () { describe('fill()', function () { it('Should return a tensor filled with a number', function () { - num.tidy(() => { + num.scope(() => { const a = [[2, 2], [2, 2]]; const t = num.fill([2, 2], 2); const x = t.arraySync(); @@ -642,7 +642,7 @@ describe('Universal Functions', function () { describe('linspace()', function () { it('Should return a tensor filled with evenly spaced numbers', function () { - num.tidy(() => { + num.scope(() => { const a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; const t = num.linspace(0, 9, 10); const x = t.arraySync(); @@ -653,7 +653,7 @@ describe('Universal Functions', function () { describe('ones()', function () { it('Should return a tensor filled with ones', function () { - num.tidy(() => { + num.scope(() => { const a = [[1, 1], [1, 1]]; const t = num.ones([2, 2]); const x = t.arraySync(); @@ -664,7 +664,7 @@ describe('Universal Functions', function () { describe('random()', function () { it('Should return a uniformly distributed tensor', function () { - num.tidy(() => { + num.scope(() => { const n = 100000; const t = num.random([n]); const x = t.arraySync(); @@ -676,7 +676,7 @@ describe('Universal Functions', function () { describe('randomGaussian()', function () { it('Should return a normally distributed tensor', function () { - num.tidy(() => { + num.scope(() => { const n = 100000; const t = num.Tensor.randomGaussian([n]); const x = t.arraySync(); @@ -686,7 +686,7 @@ describe('Universal Functions', function () { }); it('Should accept mean as an argument', function () { - num.tidy(() => { + num.scope(() => { const n = 100000; const t = num.Tensor.randomGaussian([n], 5); const x = t.arraySync(); @@ -696,7 +696,7 @@ describe('Universal Functions', function () { }); it('Should accept mean and sd as arguments', function () { - num.tidy(() => { + num.scope(() => { const n = 100000; const t = num.Tensor.randomGaussian([n], 5, 1); const x = t.arraySync(); @@ -710,7 +710,7 @@ describe('Universal Functions', function () { describe('range()', function () { it('Should return a tensor filled with evenly spaced numbers', function () { - num.tidy(() => { + num.scope(() => { const a = [0, 1, 2, 3, 4, 5, 6, 7, 8]; const t = num.range(0, 9); const x = t.arraySync(); @@ -719,7 +719,7 @@ describe('Universal Functions', function () { }); it('Should control space between numbers', function () { - num.tidy(() => { + num.scope(() => { const a = [0, 2, 4, 6, 8]; const t = num.range(0, 9, 2); const x = t.arraySync(); @@ -730,7 +730,7 @@ describe('Universal Functions', function () { describe('zeros()', function () { it('Should return a tensor filled with zeros', function () { - num.tidy(() => { + num.scope(() => { const a = [[0, 0], [0, 0]]; const t = num.Tensor.zeros([2, 2]); const x = t.arraySync(); @@ -743,7 +743,7 @@ describe('Universal Functions', function () { describe('Transformations', function () { describe('flatten()', function () { it('Should return a 1d tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([[1, 2], [3, 4]]); const t2 = pInst.createTensor([1, 2, 3, 4]); const t3 = num.flatten(t1); @@ -754,7 +754,7 @@ describe('Universal Functions', function () { describe('pad()', function () { it('Should pad with zeros', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2, 3, 4]); const t2 = pInst.createTensor([0, 1, 2, 3, 4, 0, 0]); const t3 = num.pad(t1, [[1, 2]]); @@ -763,7 +763,7 @@ describe('Universal Functions', function () { }); it('Should pad with constant values', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2, 3, 4]); const t2 = pInst.createTensor([2, 1, 2, 3, 4, 2, 2]); const t3 = num.pad(t1, [[1, 2]], 2); @@ -774,7 +774,7 @@ describe('Universal Functions', function () { describe('reshape()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2, 3, 4]); const t2 = pInst.createTensor([[1, 2], [3, 4]]); const t3 = num.reshape(t1, [2, 2]); @@ -787,14 +787,14 @@ describe('Universal Functions', function () { describe('Slicing and Joining', function () { describe('concat()', function () { it('Should fail with too few tensors', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2]); expect(() => num.concat([t1])).to.throw(Error); }); }); it('Should work with 1d tensors', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2]); const t2 = pInst.createTensor([3, 4]); const t3 = pInst.createTensor([1, 2, 3, 4]); @@ -804,7 +804,7 @@ describe('Universal Functions', function () { }); it('Should work with nd tensors', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([[1, 2], [10, 20]]); const t2 = pInst.createTensor([[3, 4], [30, 40]]); const t3 = pInst.createTensor([[1, 2, 3, 4], [10, 20, 30, 40]]); @@ -816,7 +816,7 @@ describe('Universal Functions', function () { describe('reverse()', function () { it('Should work with 1d tensors', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2, 3]); const t2 = pInst.createTensor([3, 2, 1]); const t3 = num.reverse(t1); @@ -825,7 +825,7 @@ describe('Universal Functions', function () { }); it('Should work with nd tensors', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([[1, 2], [3, 4]]); const t2 = pInst.createTensor([[2, 1], [4, 3]]); const t3 = num.reverse(t1, 1); @@ -836,7 +836,7 @@ describe('Universal Functions', function () { describe('slice()', function () { it('Should work with 1d tensors', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2, 3, 4]); const t2 = pInst.createTensor([2, 3]); const t3 = num.slice(t1, [1], [2]); @@ -845,7 +845,7 @@ describe('Universal Functions', function () { }); it('Should work with nd tensors', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([[1, 2], [3, 4]]); const t2 = pInst.createTensor([[3, 4]]); const t3 = num.slice(t1, [1, 0], [1, 2]); @@ -856,7 +856,7 @@ describe('Universal Functions', function () { describe('split()', function () { it('Should return an array of tensors', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([[1, 2, 3, 4], [5, 6, 7, 8]]); const t2 = pInst.createTensor([[1, 2], [5, 6]]); const t3 = pInst.createTensor([[3, 4], [7, 8]]); @@ -867,7 +867,7 @@ describe('Universal Functions', function () { }); it('Should allow axes to be specified', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([[1, 2, 3, 4], [5, 6, 7, 8]]); const t2 = pInst.createTensor([[1], [5]]); const t3 = pInst.createTensor([[2, 3], [6, 7]]); @@ -882,7 +882,7 @@ describe('Universal Functions', function () { describe('stack()', function () { it('Should return a tensor', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2]); const t2 = pInst.createTensor([3, 4]); const t3 = pInst.createTensor([5, 6]); @@ -893,7 +893,7 @@ describe('Universal Functions', function () { }); it('Should allow axes to be specified', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([1, 2]); const t2 = pInst.createTensor([3, 4]); const t3 = pInst.createTensor([5, 6]); @@ -906,7 +906,7 @@ describe('Universal Functions', function () { describe('unstack()', function () { it('Should return an array of tensors', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([[1, 2], [3, 4]]); const t2 = pInst.createTensor([1, 2]); const t3 = pInst.createTensor([3, 4]); @@ -918,7 +918,7 @@ describe('Universal Functions', function () { }); it('Should allow axes to be specified', function () { - num.tidy(() => { + num.scope(() => { const t1 = pInst.createTensor([[1, 2], [3, 4]]); const t2 = pInst.createTensor([1, 3]); const t3 = pInst.createTensor([2, 4]);