Socket
Socket
Sign inDemoInstall

@tensorflow/tfjs-data

Package Overview
Dependencies
Maintainers
11
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tensorflow/tfjs-data - npm Package Compare versions

Comparing version 1.2.8 to 1.2.9

6

dist/dataset.d.ts

@@ -20,4 +20,8 @@ /**

import { LazyIterator } from './iterators/lazy_iterator';
import { DatasetContainer } from './types';
import { Container, DataElement } from './types';
/**
* A nested structure of Datasets, used as the input to zip().
*/
export declare type DatasetContainer = Container<Dataset<DataElement>>;
/**
* Represents a potentially large list of independent data elements (typically

@@ -24,0 +28,0 @@ * 'samples' or 'examples').

@@ -19,6 +19,10 @@ /**

import * as tf from '@tensorflow/tfjs-core';
import { IteratorContainer } from '../types';
import { Container, DataElement } from '../types';
import { DeepMapResult } from '../util/deep_map';
import { RingBuffer } from '../util/ring_buffer';
/**
* A nested structure of LazyIterators, used as the input to zip().
*/
export declare type IteratorContainer = Container<LazyIterator<DataElement>>;
/**
* Create a `LazyIterator` from an array of items.

@@ -25,0 +29,0 @@ */

8

dist/iterators/lazy_iterator.js

@@ -1232,8 +1232,4 @@ "use strict";

return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.currentPromise = this.nextState(this.currentPromise);
return [4 /*yield*/, this.currentPromise];
case 1: return [2 /*return*/, (_a.sent())];
}
this.currentPromise = this.nextState(this.currentPromise);
return [2 /*return*/, this.currentPromise];
});

@@ -1240,0 +1236,0 @@ });

@@ -17,3 +17,3 @@ /**

*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tensorflow/tfjs-core")):"function"==typeof define&&define.amd?define(["exports","@tensorflow/tfjs-core"],e):e((t.tf=t.tf||{},t.tf.data=t.tf.data||{}),t.tf)}(this,function(t,e){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function r(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function i(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){t.done?i(t.value):new n(function(e){e(t.value)}).then(s,u)}a((r=r.apply(t,e||[])).next())})}function o(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function s(t,e){return t(e={exports:{}},e.exports),e.exports}var u=s(function(t){!function(t,e,n){function r(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function i(t,e){var n=new function(t){var e,n=this,r=(e=4022871197,function(t){t=t.toString();for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null}(t),i=e&&e.state,o=n.next;return o.int32=function(){return 4294967296*n.next()|0},o.double=function(){return o()+1.1102230246251565e-16*(2097152*o()|0)},o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.alea=i}(0,t,!1)}),a=s(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function i(t,e){var n=new function(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),e.next()}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xor128=i}(0,t,!1)}),c=s(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next()}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xorwow=i}(0,t,!1)}),h=s(function(t){!function(t,e,n){function r(t,e){return e.x=t.x.slice(),e.i=t.i,e}function i(t,e){null==t&&(t=+new Date);var n=new function(t){var e=this;e.next=function(){var t,n,r=e.x,i=e.i;return t=r[i],n=(t^=t>>>7)^t<<24,n^=(t=r[i+1&7])^t>>>10,n^=(t=r[i+3&7])^t>>>3,n^=(t=r[i+4&7])^t<<7,t=r[i+7&7],n^=(t^=t<<13)^t<<9,r[i]=n,e.i=i+1&7,n},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n)r[7&n]=r[7&n]<<15^e.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n?r[7]=-1:r[n],t.x=r,t.i=0,n=256;n>0;--n)t.next()}(e,t)}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&(i.x&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xorshift7=i}(0,t,!1)}),l=s(function(t){!function(t,e,n){function r(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function i(t,e){null==t&&(t=+new Date);var n=new function(t){var e=this;e.next=function(){var t,n,r=e.w,i=e.X,o=e.i;return e.w=r=r+1640531527|0,n=i[o+34&127],t=i[o=o+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=i[o]=n^t,e.i=o,n+(r^r>>>16)|0},function(t,e){var n,r,i,o,s,u=[],a=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,a=Math.max(a,e.length)),i=0,o=-32;o<a;++o)e&&(r^=e.charCodeAt((o+32)%e.length)),0===o&&(s=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,o>=0&&(s=s+1640531527|0,i=0==(n=u[127&o]^=r+s)?i+1:0);for(i>=128&&(u[127&(e&&e.length||0)]=-1),i=127,o=512;o>0;--o)r=u[i+34&127],n=u[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,u[i]=r^n;t.w=s,t.X=u,t.i=i}(e,t)}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&(i.X&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xor4096=i}(0,t,!1)}),f=s(function(t){!function(t,e,n){function r(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,i=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^i,e.a=i-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++)e.b^=0|n.charCodeAt(r),e.next()}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.tychei=i}(0,t,!1)}),d=s(function(t){!function(e,n){var r,i=this,o=256,s=6,u="random",a=n.pow(o,s),c=n.pow(2,52),h=2*c,l=o-1;function f(t,f,m){var y=[],w=p(function t(e,n){var r,i=[],o=typeof e;if(n&&"object"==o)for(r in e)try{i.push(t(e[r],n-1))}catch(t){}return i.length?i:"string"==o?e:e+"\0"}((f=1==f?{entropy:!0}:f||{}).entropy?[t,v(e)]:null==t?function(){try{var t;return r&&(t=r.randomBytes)?t=t(o):(t=new Uint8Array(o),(i.crypto||i.msCrypto).getRandomValues(t)),v(t)}catch(t){var n=i.navigator,s=n&&n.plugins;return[+new Date,i,s,i.screen,v(e)]}}():t,3),y),b=new function(t){var e,n=t.length,r=this,i=0,s=r.i=r.j=0,u=r.S=[];n||(t=[n++]);for(;i<o;)u[i]=i++;for(i=0;i<o;i++)u[i]=u[s=l&s+t[i%n]+(e=u[i])],u[s]=e;(r.g=function(t){for(var e,n=0,i=r.i,s=r.j,u=r.S;t--;)e=u[i=l&i+1],n=n*o+u[l&(u[i]=u[s=l&s+e])+(u[s]=e)];return r.i=i,r.j=s,n})(o)}(y),g=function(){for(var t=b.g(s),e=a,n=0;t<c;)t=(t+n)*o,e*=o,n=b.g(1);for(;t>=h;)t/=2,e/=2,n>>>=1;return(t+n)/e};return g.int32=function(){return 0|b.g(4)},g.quick=function(){return b.g(4)/4294967296},g.double=g,p(v(b.S),e),(f.pass||m||function(t,e,r,i){return i&&(i.S&&d(i,b),t.state=function(){return d(b,{})}),r?(n[u]=t,e):t})(g,w,"global"in f?f.global:this==n,f.state)}function d(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function p(t,e){for(var n,r=t+"",i=0;i<r.length;)e[l&i]=l&(n^=19*e[l&i])+r.charCodeAt(i++);return v(e)}function v(t){return String.fromCharCode.apply(0,t)}if(n["seed"+u]=f,p(n.random(),e),t.exports){t.exports=f;try{r=require("crypto")}catch(t){}}else 0}([],Math)});d.alea=u,d.xor128=a,d.xorwow=c,d.xorshift7=h,d.xor4096=l,d.tychei=f;var p=d.alea;function v(t,e,n,r){if(void 0===n&&(n=new Map),void 0===r&&(r=new Set),null==t)return null;if(r.has(t))throw new Error("Circular references are not supported.");if(n.has(t))return n.get(t);var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(i.recurse){if(b(t)){var o=Array.isArray(t)?[]:{};for(var s in r.add(t),t){var u=v(t[s],e,n,r);o[s]=u}return r.delete(t),o}throw new Error("Can't recurse into non-iterable type: "+t)}return n.set(t,i.value),i.value}function m(t,e){return void 0===e&&(e=y),function t(e,n,r){void 0===r&&(r=new Set);var i=e[0];if(r.has(i))throw new Error("Circular references are not supported.");var o=n(e);if(o.recurse&&null!==o.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(o.recurse){if(b(i)){var s=Array.isArray(i)?[]:{};r.add(i);var u=function(i){var o=e.map(function(t){return t[i]}),u=t(o,n,r);s[i]=u};for(var a in i)u(a);return r.delete(i),s}throw new Error("Can't recurse into non-iterable type: "+i)}return o.value}(t,e)}function y(t){return null===t?null:b(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}function w(t,e){return i(this,void 0,void 0,function(){var n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:n=new Map,v(t,e,n),r=0,i=Array.from(n.keys()),o.label=1;case 1:return r<i.length?(s=i[r],(u=n.get(s))instanceof Promise?[4,u]:[3,3]):[3,4];case 2:a=o.sent(),n.set(s,a),o.label=3;case 3:return r++,[3,1];case 4:return[2,v(t,e,n)]}})})}function b(t){return null!=t&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof e.Tensor))}function g(t){return v(t,x)}function x(t){return t instanceof e.Tensor?{value:t.clone(),recurse:!1}:b(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}var C=function(){function t(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}return t.prototype.wrap=function(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity},t.prototype.get=function(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]},t.prototype.set=function(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e},t.prototype.length=function(){var t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t},t.prototype.isFull=function(){return this.length()===this.capacity},t.prototype.isEmpty=function(){return 0===this.length()},t.prototype.push=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)},t.prototype.pushAll=function(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];this.push(r)}},t.prototype.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var t=this.get(this.end);return this.set(this.end,void 0),t},t.prototype.unshift=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)},t.prototype.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t},t.prototype.shuffleExcise=function(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.wrap(this.begin+t),n=this.get(e);return this.set(e,this.pop()),n},t}(),z=function(t){function e(){return t.call(this,e.INITIAL_CAPACITY)||this}return r(e,t),e.prototype.isFull=function(){return!1},e.prototype.push=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.push.call(this,e)},e.prototype.unshift=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.unshift.call(this,e)},e.prototype.expand=function(){for(var t=2*this.capacity,e=new Array(t),n=this.length(),r=0;r<n;r++)e[r]=this.get(this.wrap(this.begin+r));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n},e.INITIAL_CAPACITY=32,e}(C);function E(t){return new T(t)}function S(t){return new N(t)}var A,R=function(){function t(){}return t.prototype.toArray=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return t=[],[4,this.next()];case 1:e=n.sent(),n.label=2;case 2:return e.done?[3,4]:(t.push(e.value),[4,this.next()]);case 3:return e=n.sent(),[3,2];case 4:return[2,t]}})})},t.prototype.toArrayForTest=function(){return i(this,void 0,void 0,function(){var t,e,n;return o(this,function(r){switch(r.label){case 0:return t=this.prefetch(100),e=[],[4,t.next()];case 1:n=r.sent(),r.label=2;case 2:return n.done?[3,4]:(e.push(n.value),[4,t.next()]);case 3:return n=r.sent(),[3,2];case 4:return[2,e]}})})},t.prototype.resolveFully=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return[4,this.next()];case 1:t=e.sent(),e.label=2;case 2:return t.done?[3,4]:[4,this.next()];case 3:return t=e.sent(),[3,2];case 4:return[2]}})})},t.prototype.resolveWhile=function(t){return i(this,void 0,void 0,function(){var e,n;return o(this,function(r){switch(r.label){case 0:return[4,this.next()];case 1:e=r.sent(),n=t(e.value),r.label=2;case 2:return e.done||!n?[3,4]:[4,this.next()];case 3:return e=r.sent(),n=t(e.value),[3,2];case 4:return[2]}})})},t.prototype.handleErrors=function(t){return new j(this,t)},t.prototype.filter=function(t){return new O(this,t)},t.prototype.map=function(t){return new M(this,t)},t.prototype.mapAsync=function(t){return new _(this,t)},t.prototype.serialMapAsync=function(t){return new _(this,t).serial()},t.prototype.flatmap=function(t){return new q(this,t)},t.prototype.forEachAsync=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.map(t).resolveFully()]})})},t.prototype.serialForEach=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.serialMapAsync(t).resolveWhile(function(t){return!0===t})]})})},t.prototype.rowMajorBatch=function(t,e){return void 0===e&&(e=!0),new D(this,t,e)},t.prototype.columnMajorBatch=function(t,e,n){return void 0===e&&(e=!0),void 0===n&&(n=y),this.rowMajorBatch(t,e).map(function(t){return m(t,n)})},t.prototype.concatenate=function(t,e){return new H(E([this,t]),e)},t.prototype.take=function(t){return t<0||null==t?this:new I(this,t)},t.prototype.skip=function(t){return t<0||null==t?this:new F(this,t)},t.prototype.prefetch=function(t){return new B(this,t)},t.prototype.shuffle=function(t,e){return new V(this,t,e)},t.prototype.serial=function(){return new k(this)},t}(),T=function(t){function e(e){var n=t.call(this)||this;return n.items=e,n.trav=0,n}return r(e,t),e.prototype.summary=function(){return"Array of "+this.items.length+" items"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){return this.trav>=this.items.length?[2,{value:null,done:!0}]:(t=this.items[this.trav],this.trav++,[2,{value:g(t),done:!1}])})})},e}(R),N=function(t){function e(e){var n=t.call(this)||this;return n.nextFn=e,n}return r(e,t),e.prototype.summary=function(){return"Function call"},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){try{return[2,this.nextFn()]}catch(t){throw t.message="Error thrown while iterating through a dataset: "+t.message,t}return[2]})})},e}(R),k=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.lastRead=Promise.resolve({value:null,done:!1}),n}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Serial"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return[2,this.upstream.next()]})})},e}(R),F=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Skip"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},n.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return this.count++<this.maxCount?[4,this.upstream.next()]:[3,2];case 1:return(t=n.sent()).done?[2,t]:(e.dispose(t.value),[3,0]);case 2:return[2,this.upstream.next()]}})})},n}(R),I=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Take"},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]})})},e}(R),D=function(t){function e(e,n,r){void 0===r&&(r=!0);var i=t.call(this)||this;return i.upstream=e,i.batchSize=n,i.enableSmallLastBatch=r,i.lastRead=Promise.resolve({value:null,done:!1}),i}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> RowMajorBatch"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:t=[],n.label=1;case 1:return t.length<this.batchSize?[4,this.upstream.next()]:[3,3];case 2:return(e=n.sent()).done?this.enableSmallLastBatch&&t.length>0?[2,{value:t,done:!1}]:[2,{value:null,done:!0}]:(t.push(e.value),[3,1]);case 3:return[2,{value:t,done:!1}]}})})},e}(R),O=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.predicate=n,r.lastRead=Promise.resolve({value:null,done:!1}),r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Filter"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},n.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return[4,this.upstream.next()];case 1:return(t=n.sent()).done||this.predicate(t.value)?[2,t]:(e.dispose(t.value),[3,0]);case 2:return[2]}})})},n}(R),M=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Map"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return[2,{value:null,done:!0}];for(n=e.tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),i=e.tensor_util.getTensorsInContainer(r),s=0,u=n;s<u.length;s++)a=u[s],e.tensor_util.isTensorInList(a,i)||a.dispose();return[2,{value:r,done:!1}]}})})},n}(R),j=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.handler=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> handleErrors"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,e.sent()];case 3:return t=e.sent(),this.handler(t)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}})})},e}(R),_=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> AsyncMap"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:return(t=o.sent()).done?[2,{value:null,done:!0}]:(n=e.tensor_util.getTensorsInContainer(t.value),[4,this.transform(t.value)]);case 2:for(r=o.sent(),i=e.tensor_util.getTensorsInContainer(r),s=0,u=n;s<u.length;s++)a=u[s],e.tensor_util.isTensorInList(a,i)||a.dispose();return[2,{value:r,done:!1}]}})})},n}(R),L=function(t){function e(){var e=t.call(this)||this;return e.outputQueue=new z,e.lastRead=Promise.resolve({value:null,done:!1}),e}return r(e,t),e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return 0!==this.outputQueue.length()?[3,2]:[4,this.pump()];case 1:return t.sent()?[3,0]:[2,{value:null,done:!0}];case 2:return[2,{value:this.outputQueue.shift(),done:!1}]}})})},e}(R),q=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Flatmap"},n.prototype.pump=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return[2,!1];for(n=e.tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),i=e.tensor_util.getTensorsInContainer(r),this.outputQueue.pushAll(r),s=0,u=n;s<u.length;s++)a=u[s],e.tensor_util.isTensorInList(a,i)||a.dispose();return[2,!0]}})})},n}(L),H=function(t){function e(e,n){var r=t.call(this)||this;return r.baseErrorHandler=n,r.lastRead=null,r.iterator=null,r.moreIterators=e,r}return r(e,t),e.prototype.summary=function(){return"TODO: fill in upstream of chained summaries -> Chained"},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]})})},e.prototype.readFromChain=function(t){return i(this,void 0,void 0,function(){var e,n;return o(this,function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),null!=this.iterator?[3,3]:[4,this.moreIterators.next()];case 2:if((e=r.sent()).done)return[2,{value:null,done:!0}];this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),r.label=3;case 3:return[4,this.iterator.next()];case 4:return(n=r.sent()).done?(this.iterator=null,[2,this.readFromChain(t)]):[2,n]}})})},e}(R);!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(A||(A={}));var P=function(t){function e(e,n){void 0===n&&(n=A.FAIL);var r=t.call(this)||this;return r.iterators=e,r.mismatchMode=n,r.count=0,r.currentPromise=null,r}return r(e,t),e.prototype.summary=function(){return"{TODO: fill in upstream of zip summaries} -> Zip"},e.prototype.nextState=function(t){return i(this,void 0,void 0,function(){function e(t){return t instanceof R?{value:t.next().then(function(t){return n++,t.done&&r++,t.value}),recurse:!1}:{value:null,recurse:!0}}var n,r,i;return o(this,function(o){switch(o.label){case 0:return[4,t];case 1:return o.sent(),n=0,r=0,[4,w(this.iterators,e)];case 2:if(i=o.sent(),n===r)return[2,{value:null,done:!0}];if(r>0)switch(this.mismatchMode){case A.FAIL:throw new Error("Zipped streams should have the same length. Mismatched at element "+this.count+".");case A.SHORTEST:return[2,{value:null,done:!0}];case A.LONGEST:}return this.count++,[2,{value:i,done:!1}]}})})},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return this.currentPromise=this.nextState(this.currentPromise),[4,this.currentPromise];case 1:return[2,t.sent()]}})})},e}(R),B=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.bufferSize=n,r.buffer=new C(n),r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Prefetch"},e.prototype.refill=function(){for(;!this.buffer.isFull();){var t=this.upstream.next();this.buffer.push(t)}},e.prototype.next=function(){return this.refill(),this.buffer.shift()},e}(R),V=function(t){function n(n,r,i){var o=t.call(this,n,r)||this;return o.upstream=n,o.windowSize=r,o.upstreamExhausted=!1,o.random=p(i||e.util.now().toString()),o.lastRead=Promise.resolve({value:null,done:!1}),o}return r(n,t),n.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},n.prototype.randomInt=function(t){return Math.floor(this.random()*t)},n.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},n.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:this.upstreamExhausted||this.refill(),n.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(t=this.chooseIndex(),[4,this.buffer.shuffleExcise(t)]);case 2:return(e=n.sent()).done?(this.upstreamExhausted=!0,[3,1]):(this.refill(),[2,e]);case 3:return[2,{value:null,done:!0}]}})})},n}(B),W=function(){function t(){this.size=null}return t.prototype.batch=function(t,n){var r=this;void 0===n&&(n=!0);var s=this;return e.util.assert(t>0,function(){return"batchSize needs to be positive, but it is\n "+t}),U(function(){return i(r,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,s.iterator()];case 1:return[2,e.sent().columnMajorBatch(t,n,Q)]}})})},this.size===1/0||null==this.size?this.size:n?Math.ceil(this.size/t):Math.floor(this.size/t))},t.prototype.concatenate=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){var e,r;return o(this,function(i){switch(i.label){case 0:return[4,n.iterator()];case 1:return r=(e=i.sent()).concatenate,[4,t.iterator()];case 2:return[2,r.apply(e,[i.sent()])]}})})},this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null)},t.prototype.filter=function(t){var n=this,r=this;return U(function(){return i(n,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return[4,r.iterator()];case 1:return[2,n.sent().filter(function(n){return e.tidy(function(){return t(n)})})]}})})},this.size===1/0?1/0:null)},t.prototype.forEachAsync=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,this.iterator()];case 1:return[2,e.sent().forEachAsync(t)]}})})},t.prototype.forEach=function(t){return i(this,void 0,void 0,function(){return o(this,function(n){return e.deprecationWarn("dataset.forEach() is deprecated and will be removed. Please use dataset.forEachAsync() instead"),[2,this.forEachAsync(t)]})})},t.prototype.map=function(t){var n=this,r=this;return U(function(){return i(n,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return[4,r.iterator()];case 1:return[2,n.sent().map(function(n){return e.tidy(function(){return t(n)})})]}})})},this.size)},t.prototype.mapAsync=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().mapAsync(t)]}})})},this.size)},t.prototype.prefetch=function(t){var e=this;if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().prefetch(t)]}})})},this.size)},t.prototype.repeat=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){var e,r=this;return o(this,function(s){return e=S(function(){return i(r,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return t={},[4,n.iterator()];case 1:return[2,(t.value=e.sent(),t.done=!1,t)]}})})}),[2,(u=e.take(t),new H(u,a))];var u,a})})},null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null)},t.prototype.skip=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().skip(t)]}})})},null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null)},t.prototype.shuffle=function(t,n,r){var s=this;if(void 0===r&&(r=!0),null==t||t<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)");var u=this,a=p(n||e.util.now().toString());return U(function(){return i(s,void 0,void 0,function(){var e;return o(this,function(n){switch(n.label){case 0:return e=a.int32(),r&&(e+=a.int32()),[4,u.iterator()];case 1:return[2,n.sent().shuffle(t,e.toString())]}})})},this.size)},t.prototype.take=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().take(t)]}})})},null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null)},t.prototype.toArray=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArray()]}})})},t.prototype.toArrayForTest=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArrayForTest()]}})})},t.MAX_BUFFER_SIZE=1e4,t}();function U(t,e){return void 0===e&&(e=null),new(function(n){function s(){var t=null!==n&&n.apply(this,arguments)||this;return t.size=e,t}return r(s,n),s.prototype.iterator=function(){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,t()]})})},s}(W))}function Q(t){return null===t?null:function(t){return null==t||null===(n=t)||"object"!=typeof n&&"function"!=typeof n||Array.isArray(t)||"object"==typeof t&&t instanceof e.Tensor||e.util.isTypedArray(t);var n}(t[0])?{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof e.Tensor?e.stack(t):e.tensor(t)}(t),recurse:!1}:{value:null,recurse:!0}}var X=function(t){function e(e){var n=t.call(this)||this;return n.input=e,n}return r(e,t),e.prototype.iterator=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return[4,this.input.iterator()];case 1:return t=n.sent(),e=t.decodeUTF8(),[2,e.split("\n").map(function(t){return t.endsWith("\r")&&(t=t.slice(0,-1)),t})]}})})},e}(W),G=Symbol("out"),Z=Symbol("field"),J=Symbol("quote"),Y=Symbol("quoteafterquote"),K=Symbol("quoteinquote"),$=function(t){function n(n,r){var i=t.call(this)||this;return i.input=n,i.hasHeader=!0,i.fullColumnNames=null,i.columnNamesValidated=!1,i.columnConfigs=null,i.configuredColumnsOnly=!1,i.delimiter=",",i.delimWhitespace=!1,i.base=new X(n),r||(r={}),i.hasHeader=!1!==r.hasHeader,i.fullColumnNames=r.columnNames,i.columnConfigs=r.columnConfigs,i.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(e.util.assert(null==r.delimiter,function(){return"Delimiter should not be provided when delimWhitespace is true."}),i.delimWhitespace=!0,i.delimiter=" "):i.delimiter=r.delimiter?r.delimiter:",",i}return r(n,t),n.prototype.columnNames=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:t.sent(),t.label=2;case 2:return[2,this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames]}})})},n.prototype.setColumnNames=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a=this;return o(this,function(o){switch(o.label){case 0:return[4,this.maybeReadHeaderLine()];case 1:if(t=o.sent(),!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");if(this.fullColumnNames&&t&&e.util.assert(t.length===this.fullColumnNames.length,function(){return"The length of provided columnNames ("+a.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+")."}),this.fullColumnNames||(this.fullColumnNames=t),n=this.fullColumnNames.reduce(function(t,e){return t[e]=t[e]+1||1,t},{}),r=Object.keys(n).filter(function(t){return n[t]>1}),e.util.assert(0===r.length,function(){return"Duplicate column names found: "+r.toString()}),this.columnConfigs)for(i=0,s=Object.keys(this.columnConfigs);i<s.length;i++)if(u=s[i],-1===this.fullColumnNames.indexOf(u))throw new Error('The key "'+u+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").");return this.columnNamesValidated=!0,[2]}})})},n.prototype.maybeReadHeaderLine=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return this.hasHeader?[4,this.base.iterator()]:[3,3];case 1:return[4,n.sent().next()];case 2:if((t=n.sent()).done)throw new Error("No data was found for CSV parsing.");return e=t.value,[2,this.parseRow(e,!1)];case 3:return[2,null]}})})},n.prototype.iterator=function(){return i(this,void 0,void 0,function(){var t,e=this;return o(this,function(n){switch(n.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:n.sent(),n.label=2;case 2:return[4,this.base.iterator()];case 3:return t=n.sent(),this.hasHeader&&(t=t.skip(1)),[2,t.map(function(t){return e.makeDataElement(t)})]}})})},n.prototype.makeDataElement=function(t){for(var e=this.parseRow(t),n={},r={},i=0;i<this.fullColumnNames.length;i++){var o=this.fullColumnNames[i],s=this.columnConfigs?this.columnConfigs[o]:null;if(!this.configuredColumnsOnly||s){var u=e[i],a=null;if(""===u)if(s&&void 0!==s.default)a=s.default;else{if(s&&(s.required||s.isLabel))throw new Error("Required column "+o+" is empty in this line: "+t);a=void 0}else{var c=Number(u);if(isNaN(c))a=s&&"bool"===s.dtype?this.getBoolean(u):u;else if(s&&s.dtype)switch(s.dtype){case"float32":a=c;break;case"int32":a=Math.floor(c);break;case"bool":a=this.getBoolean(u);break;default:a=c}else a=c}s&&s.isLabel?r[o]=a:n[o]=a}}return 0===Object.keys(r).length?n:{xs:n,ys:r}},n.prototype.getBoolean=function(t){return"1"===t||"true"===t.toLowerCase()?1:0},n.prototype.parseRow=function(t,e){void 0===e&&(e=!0);for(var n=[],r=0,i=t.length,o=G,s=0;s<i;s++)switch(o){case G:switch(t.charAt(s)){case'"':r=s+1,o=J;break;case this.delimiter:if(r=s+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),o=G;break;default:o=Z,r=s}break;case Z:switch(t.charAt(s)){case this.delimiter:n.push(t.substring(r,s)),o=G,r=s+1}break;case J:switch(t.charAt(s)){case'"':o=Y}break;case Y:switch(t.charAt(s)){case this.delimiter:n.push(t.substring(r,s-1)),o=G,r=s+1;break;case'"':o=J;break;default:o=K}break;case K:switch(t.charAt(s)){case'"':o=J}}if(o===Y?n.push(t.substring(r,i-1)):n.push(t.substring(r)),e&&n.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have "+this.fullColumnNames.length+" elements in a row, but got "+n);return n},n}(W),tt=function(t){function n(e){var n=t.call(this)||this;n.microphoneConfig=e,n.isClosed=!1,n.fftSize=e.fftSize||1024;var r=Math.log2(n.fftSize);if(n.fftSize<0||r<4||r>14||!Number.isInteger(r))throw new Error("Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got "+n.fftSize);if(n.numFrames=e.numFramesPerSpectrogram||43,n.sampleRateHz=e.sampleRateHz,n.columnTruncateLength=e.columnTruncateLength||n.fftSize,n.audioTrackConstraints=e.audioTrackConstraints,n.smoothingTimeConstant=e.smoothingTimeConstant||0,n.includeSpectrogram=!1!==e.includeSpectrogram,n.includeWaveform=!0===e.includeWaveform,!n.includeSpectrogram&&!n.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return n}return r(n,t),n.prototype.summary=function(){return"microphone"},n.create=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,function(){var r;return o(this,function(i){switch(i.label){case 0:if(e.ENV.get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");return[4,(r=new n(t)).start()];case 1:return i.sent(),[2,r]}})})},n.prototype.start=function(){return i(this,void 0,void 0,function(){var t,e,n,r;return o(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=this,[4,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})];case 1:return t.stream=i.sent(),[3,3];case 2:throw e=i.sent(),new Error("Error thrown while initializing video stream: "+e.message);case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(n=window.AudioContext||window.webkitAudioContext,this.audioContext=new n,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;return r=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,r.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2]}})})},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,e,n,r,i;return o(this,function(o){switch(o.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return n=o.sent(),this.includeSpectrogram&&(r=this.flattenQueue(n.freqDataQueue),t=this.getTensorFromAudioDataArray(r,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(n.timeDataQueue),e=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:t,waveform:e},done:!1}]}})})},n.prototype.capture=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}})})},n.prototype.getAudioData=function(){return i(this,void 0,void 0,function(){var t,e,n,r=this;return o(this,function(i){return t=[],e=[],n=0,[2,new Promise(function(i){var o=setInterval(function(){r.includeSpectrogram&&(r.analyser.getFloatFrequencyData(r.freqData),r.freqData[0]===-1/0&&i({freqDataQueue:t,timeDataQueue:e}),t.push(r.freqData.slice(0,r.columnTruncateLength))),r.includeWaveform&&(r.analyser.getFloatTimeDomainData(r.timeData),e.push(r.timeData.slice())),++n===r.numFrames&&(clearInterval(o),i({freqDataQueue:t,timeDataQueue:e}))},r.fftSize/r.sampleRateHz*1e3)})]})})},n.prototype.stop=function(){this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop()},n.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},n.prototype.getSampleRate=function(){return this.sampleRateHz},n.prototype.flattenQueue=function(t){var e=t[0].length,n=new Float32Array(t.length*e);return t.forEach(function(t,r){return n.set(t,r*e)}),n},n.prototype.getTensorFromAudioDataArray=function(t,n){var r=new Float32Array(e.util.sizeFromShape(n));return r.set(t,r.length-t.length),e.tensor(r,n)},n}(R),et=function(t){function n(n,r){var i=t.call(this)||this;if(i.webcamVideoElement=n,i.webcamConfig=r,i.isClosed=!0,i.resize=!1,i.needToResize())if(i.resize=!0,i.cropSize=[i.webcamConfig.resizeHeight,i.webcamConfig.resizeWidth],i.cropBoxInd=e.tensor1d([0],"int32"),i.webcamConfig.centerCrop){var o=1*i.webcamConfig.resizeWidth/i.webcamVideoElement.width,s=1*i.webcamConfig.resizeHeight/i.webcamVideoElement.height,u=(1-o)/2,a=(1-s)/2,c=u+o,h=s+a;i.cropBox=e.tensor2d([a,u,h,c],[1,4])}else i.cropBox=e.tensor2d([0,0,1,1],[1,4]);return i}return r(n,t),n.prototype.summary=function(){return"webcam"},n.create=function(t,r){return void 0===r&&(r={}),i(this,void 0,void 0,function(){var i;return o(this,function(o){switch(o.label){case 0:if(e.ENV.get("IS_NODE"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!r.resizeWidth||!r.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=r.resizeWidth,t.height=r.resizeHeight}return[4,(i=new n(t,r)).start()];case 1:return o.sent(),[2,i]}})})},n.prototype.start=function(){return i(this,void 0,void 0,function(){var t,n,r=this;return o(this,function(i){switch(i.label){case 0:this.webcamConfig.facingMode&&e.util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,function(){return"Invalid webcam facing mode: "+r.webcamConfig.facingMode+". Please provide 'user' or 'environment'"}),i.label=1;case 1:return i.trys.push([1,3,,4]),t=this,[4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})];case 2:return t.stream=i.sent(),[3,4];case 3:throw(n=i.sent()).message="Error thrown while initializing video stream: "+n.message,n;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise(function(t){r.webcamVideoElement.onloadedmetadata=function(){t()}})]}})})},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){if(this.isClosed)return[2,{value:null,done:!0}];try{t=e.browser.fromPixels(this.webcamVideoElement)}catch(t){throw new Error("Error thrown converting video to pixels: "+JSON.stringify(t))}if(!this.resize)return[2,{value:t,done:!1}];try{return[2,{value:this.cropAndResizeFrame(t),done:!1}]}catch(t){throw new Error("Error thrown cropping the video: "+t.message)}finally{t.dispose()}return[2]})})},n.prototype.needToResize=function(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)},n.prototype.cropAndResizeFrame=function(t){var n=this;return e.tidy(function(){var r,i=t.toFloat().expandDims(0),o=(r=e.image.cropAndResize(i,n.cropBox,n.cropBoxInd,n.cropSize,"bilinear")).shape;return r.reshape(o.slice(1))})},n.prototype.capture=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}})})},n.prototype.stop=function(){this.stream.getTracks().forEach(function(t){return t.stop()});try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0},n.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},n}(R),nt=function(){return function(){}}(),rt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.split=function(t){return new it(this,t)},e}(R),it=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.impl=new ot(e,n),r}return r(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return[2,this.impl.next()]})})},e}(rt),ot=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.separator=n,r.carryover="",r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')"},e.prototype.pump=function(){return i(this,void 0,void 0,function(){var t,e,n,r,i;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return""===this.carryover?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);for((e=t.value.split(this.separator))[0]=this.carryover+e[0],n=0,r=e.slice(0,-1);n<r.length;n++)i=r[n],this.outputQueue.push(i);return this.carryover=e[e.length-1],[2,!0]}})})},e}(L),st=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.decodeUTF8=function(){return new ut(this)},e}(R),ut=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.impl=new at(e),n}return r(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return[2,this.impl.next()]})})},e}(rt),at=function(t){function n(n){var r=t.call(this)||this;if(r.upstream=n,e.ENV.get("IS_BROWSER"))r.decoder=new TextDecoder("utf-8");else{var i=require("string_decoder").StringDecoder;r.decoder=new i("utf8")}return r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Utf8"},n.prototype.pump=function(){return i(this,void 0,void 0,function(){var t,n,r;return o(this,function(i){switch(i.label){case 0:return[4,this.upstream.next()];case 1:return(t=i.sent()).done?[2,!1]:(n=t.value,r=e.ENV.get("IS_BROWSER")?this.decoder.decode(n,{stream:!0}):this.decoder.write(Buffer.from(n.buffer)),this.outputQueue.push(r),[2,!0])}})})},n}(L),ct=function(t){function n(n,r){void 0===r&&(r={});var i=t.call(this)||this;return i.file=n,i.options=r,e.util.assert(n instanceof Uint8Array||!!e.ENV.get("IS_BROWSER")&&(n instanceof File||n instanceof Blob),function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."}),i.offset=r.offset||0,i.chunkSize=r.chunkSize||1048576,i}return r(n,t),n.prototype.summary=function(){return"FileChunks "+this.file},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,e,n=this;return o(this,function(r){switch(r.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(t=new Promise(function(t,e){var r=n.offset+n.chunkSize;if(n.file instanceof Uint8Array)t(new Uint8Array(n.file.slice(n.offset,r)));else{var i=new FileReader;i.onload=function(n){var r=i.result;if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),!(r instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(r)},i.onabort=function(t){return e(new Error("Aborted"))},i.onerror=function(t){return e(new Error(t.type))};var o=n.file.slice(n.offset,r);i.readAsArrayBuffer(o)}n.offset=r}),e={},[4,t]);case 1:return[2,(e.value=r.sent(),e.done=!1,e)]}})})},n}(st);var ht=function(t){return{method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity}};function lt(t){return"string"==typeof t&&"file://"===t.substr(0,7)}var ft=function(t){function n(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.input=e,r.options=n,r}return r(n,t),n.prototype.iterator=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){return lt(this.input)&&e.ENV.get("IS_NODE")&&(t=require("fs"),this.input=t.readFileSync(this.input.substr(7))),[2,new ct(this.input,this.options)]})})},n}(nt),dt=function(t){function n(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.url=e,r.fileOptions=n,r}return r(n,t),n.prototype.iterator=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return lt(this.url)?[2,new ft(this.url,this.fileOptions).iterator()]:[2,function(t,n){return void 0===n&&(n={}),i(this,void 0,void 0,function(){var r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return"string"==typeof t?r=t:(r=t.url,i=ht(t)),[4,e.util.fetch(r,i)];case 1:return(s=o.sent()).ok?(a=Uint8Array.bind,[4,s.arrayBuffer()]):[3,3];case 2:return u=new(a.apply(Uint8Array,[void 0,o.sent()])),[2,new ct(u,n)];case 3:throw new Error(s.statusText)}})})}(this.url,this.fileOptions)]})})},n}(nt);t.array=function(t){var e=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){return[2,E(t)]})})},t.length)},t.Dataset=W,t.zip=function(t){var e,n=this;if(!b(t))throw new Error("The argument to zip() must be an object or array.");if(Array.isArray(t))for(var r=0;r<t.length;r++)e=null==e?t[r].size:Math.min(e,t[r].size);else if(t instanceof Object)for(var s in t)e=null==e?t[s].size:Math.min(e,t[s].size);return U(function(){return i(n,void 0,void 0,function(){var e;return o(this,function(n){switch(n.label){case 0:return[4,w(t,function(t){if(t instanceof W)return{value:t.iterator(),recurse:!1};if(b(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})];case 1:return e=n.sent(),[2,(r=e,i=A.SHORTEST,void 0===i&&(i=A.FAIL),new P(r,i))]}var r,i})})},e)},t.CSVDataset=$,t.TextLineDataset=X,t.csv=function(t,e){return void 0===e&&(e={}),new $(new dt(t),e)},t.func=function(t){var e=this,n=S(t);return U(function(){return i(e,void 0,void 0,function(){return o(this,function(t){return[2,n]})})})},t.generator=function(t){var e=this;return U(function(){return i(e,void 0,void 0,function(){var e;return o(this,function(n){switch(n.label){case 0:return[4,t()];case 1:return e=n.sent(),[2,S(function(){return e.next()})]}})})})},t.microphone=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,tt.create(t)]})})},t.webcam=function(t,e){return i(this,void 0,void 0,function(){return o(this,function(n){return[2,et.create(t,e)]})})},t.FileDataSource=ft,t.URLDataSource=dt,t.version_data="1.2.8",Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tensorflow/tfjs-core")):"function"==typeof define&&define.amd?define(["exports","@tensorflow/tfjs-core"],e):e((t.tf=t.tf||{},t.tf.data=t.tf.data||{}),t.tf)}(this,function(t,e){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function r(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function i(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){t.done?i(t.value):new n(function(e){e(t.value)}).then(s,u)}a((r=r.apply(t,e||[])).next())})}function o(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function s(t,e){return t(e={exports:{}},e.exports),e.exports}var u=s(function(t){!function(t,e,n){function r(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function i(t,e){var n=new function(t){var e,n=this,r=(e=4022871197,function(t){t=t.toString();for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null}(t),i=e&&e.state,o=n.next;return o.int32=function(){return 4294967296*n.next()|0},o.double=function(){return o()+1.1102230246251565e-16*(2097152*o()|0)},o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.alea=i}(0,t,!1)}),a=s(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function i(t,e){var n=new function(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),e.next()}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xor128=i}(0,t,!1)}),c=s(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next()}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xorwow=i}(0,t,!1)}),h=s(function(t){!function(t,e,n){function r(t,e){return e.x=t.x.slice(),e.i=t.i,e}function i(t,e){null==t&&(t=+new Date);var n=new function(t){var e=this;e.next=function(){var t,n,r=e.x,i=e.i;return t=r[i],n=(t^=t>>>7)^t<<24,n^=(t=r[i+1&7])^t>>>10,n^=(t=r[i+3&7])^t>>>3,n^=(t=r[i+4&7])^t<<7,t=r[i+7&7],n^=(t^=t<<13)^t<<9,r[i]=n,e.i=i+1&7,n},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n)r[7&n]=r[7&n]<<15^e.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n?r[7]=-1:r[n],t.x=r,t.i=0,n=256;n>0;--n)t.next()}(e,t)}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&(i.x&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xorshift7=i}(0,t,!1)}),l=s(function(t){!function(t,e,n){function r(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function i(t,e){null==t&&(t=+new Date);var n=new function(t){var e=this;e.next=function(){var t,n,r=e.w,i=e.X,o=e.i;return e.w=r=r+1640531527|0,n=i[o+34&127],t=i[o=o+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=i[o]=n^t,e.i=o,n+(r^r>>>16)|0},function(t,e){var n,r,i,o,s,u=[],a=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,a=Math.max(a,e.length)),i=0,o=-32;o<a;++o)e&&(r^=e.charCodeAt((o+32)%e.length)),0===o&&(s=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,o>=0&&(s=s+1640531527|0,i=0==(n=u[127&o]^=r+s)?i+1:0);for(i>=128&&(u[127&(e&&e.length||0)]=-1),i=127,o=512;o>0;--o)r=u[i+34&127],n=u[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,u[i]=r^n;t.w=s,t.X=u,t.i=i}(e,t)}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&(i.X&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xor4096=i}(0,t,!1)}),f=s(function(t){!function(t,e,n){function r(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,i=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^i,e.a=i-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++)e.b^=0|n.charCodeAt(r),e.next()}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.tychei=i}(0,t,!1)}),d=s(function(t){!function(e,n){var r,i=this,o=256,s=6,u="random",a=n.pow(o,s),c=n.pow(2,52),h=2*c,l=o-1;function f(t,f,m){var y=[],w=p(function t(e,n){var r,i=[],o=typeof e;if(n&&"object"==o)for(r in e)try{i.push(t(e[r],n-1))}catch(t){}return i.length?i:"string"==o?e:e+"\0"}((f=1==f?{entropy:!0}:f||{}).entropy?[t,v(e)]:null==t?function(){try{var t;return r&&(t=r.randomBytes)?t=t(o):(t=new Uint8Array(o),(i.crypto||i.msCrypto).getRandomValues(t)),v(t)}catch(t){var n=i.navigator,s=n&&n.plugins;return[+new Date,i,s,i.screen,v(e)]}}():t,3),y),b=new function(t){var e,n=t.length,r=this,i=0,s=r.i=r.j=0,u=r.S=[];n||(t=[n++]);for(;i<o;)u[i]=i++;for(i=0;i<o;i++)u[i]=u[s=l&s+t[i%n]+(e=u[i])],u[s]=e;(r.g=function(t){for(var e,n=0,i=r.i,s=r.j,u=r.S;t--;)e=u[i=l&i+1],n=n*o+u[l&(u[i]=u[s=l&s+e])+(u[s]=e)];return r.i=i,r.j=s,n})(o)}(y),g=function(){for(var t=b.g(s),e=a,n=0;t<c;)t=(t+n)*o,e*=o,n=b.g(1);for(;t>=h;)t/=2,e/=2,n>>>=1;return(t+n)/e};return g.int32=function(){return 0|b.g(4)},g.quick=function(){return b.g(4)/4294967296},g.double=g,p(v(b.S),e),(f.pass||m||function(t,e,r,i){return i&&(i.S&&d(i,b),t.state=function(){return d(b,{})}),r?(n[u]=t,e):t})(g,w,"global"in f?f.global:this==n,f.state)}function d(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function p(t,e){for(var n,r=t+"",i=0;i<r.length;)e[l&i]=l&(n^=19*e[l&i])+r.charCodeAt(i++);return v(e)}function v(t){return String.fromCharCode.apply(0,t)}if(n["seed"+u]=f,p(n.random(),e),t.exports){t.exports=f;try{r=require("crypto")}catch(t){}}else 0}([],Math)});d.alea=u,d.xor128=a,d.xorwow=c,d.xorshift7=h,d.xor4096=l,d.tychei=f;var p=d.alea;function v(t,e,n,r){if(void 0===n&&(n=new Map),void 0===r&&(r=new Set),null==t)return null;if(r.has(t))throw new Error("Circular references are not supported.");if(n.has(t))return n.get(t);var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(i.recurse){if(b(t)){var o=Array.isArray(t)?[]:{};for(var s in r.add(t),t){var u=v(t[s],e,n,r);o[s]=u}return r.delete(t),o}throw new Error("Can't recurse into non-iterable type: "+t)}return n.set(t,i.value),i.value}function m(t,e){return void 0===e&&(e=y),function t(e,n,r){void 0===r&&(r=new Set);var i=e[0];if(r.has(i))throw new Error("Circular references are not supported.");var o=n(e);if(o.recurse&&null!==o.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(o.recurse){if(b(i)){var s=Array.isArray(i)?[]:{};r.add(i);var u=function(i){var o=e.map(function(t){return t[i]}),u=t(o,n,r);s[i]=u};for(var a in i)u(a);return r.delete(i),s}throw new Error("Can't recurse into non-iterable type: "+i)}return o.value}(t,e)}function y(t){return null===t?null:b(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}function w(t,e){return i(this,void 0,void 0,function(){var n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:n=new Map,v(t,e,n),r=0,i=Array.from(n.keys()),o.label=1;case 1:return r<i.length?(s=i[r],(u=n.get(s))instanceof Promise?[4,u]:[3,3]):[3,4];case 2:a=o.sent(),n.set(s,a),o.label=3;case 3:return r++,[3,1];case 4:return[2,v(t,e,n)]}})})}function b(t){return null!=t&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof e.Tensor))}function g(t){return v(t,x)}function x(t){return t instanceof e.Tensor?{value:t.clone(),recurse:!1}:b(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}var C=function(){function t(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}return t.prototype.wrap=function(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity},t.prototype.get=function(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]},t.prototype.set=function(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e},t.prototype.length=function(){var t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t},t.prototype.isFull=function(){return this.length()===this.capacity},t.prototype.isEmpty=function(){return 0===this.length()},t.prototype.push=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)},t.prototype.pushAll=function(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];this.push(r)}},t.prototype.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var t=this.get(this.end);return this.set(this.end,void 0),t},t.prototype.unshift=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)},t.prototype.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t},t.prototype.shuffleExcise=function(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.wrap(this.begin+t),n=this.get(e);return this.set(e,this.pop()),n},t}(),z=function(t){function e(){return t.call(this,e.INITIAL_CAPACITY)||this}return r(e,t),e.prototype.isFull=function(){return!1},e.prototype.push=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.push.call(this,e)},e.prototype.unshift=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.unshift.call(this,e)},e.prototype.expand=function(){for(var t=2*this.capacity,e=new Array(t),n=this.length(),r=0;r<n;r++)e[r]=this.get(this.wrap(this.begin+r));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n},e.INITIAL_CAPACITY=32,e}(C);function E(t){return new T(t)}function S(t){return new N(t)}var A,R=function(){function t(){}return t.prototype.toArray=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return t=[],[4,this.next()];case 1:e=n.sent(),n.label=2;case 2:return e.done?[3,4]:(t.push(e.value),[4,this.next()]);case 3:return e=n.sent(),[3,2];case 4:return[2,t]}})})},t.prototype.toArrayForTest=function(){return i(this,void 0,void 0,function(){var t,e,n;return o(this,function(r){switch(r.label){case 0:return t=this.prefetch(100),e=[],[4,t.next()];case 1:n=r.sent(),r.label=2;case 2:return n.done?[3,4]:(e.push(n.value),[4,t.next()]);case 3:return n=r.sent(),[3,2];case 4:return[2,e]}})})},t.prototype.resolveFully=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return[4,this.next()];case 1:t=e.sent(),e.label=2;case 2:return t.done?[3,4]:[4,this.next()];case 3:return t=e.sent(),[3,2];case 4:return[2]}})})},t.prototype.resolveWhile=function(t){return i(this,void 0,void 0,function(){var e,n;return o(this,function(r){switch(r.label){case 0:return[4,this.next()];case 1:e=r.sent(),n=t(e.value),r.label=2;case 2:return e.done||!n?[3,4]:[4,this.next()];case 3:return e=r.sent(),n=t(e.value),[3,2];case 4:return[2]}})})},t.prototype.handleErrors=function(t){return new j(this,t)},t.prototype.filter=function(t){return new O(this,t)},t.prototype.map=function(t){return new M(this,t)},t.prototype.mapAsync=function(t){return new _(this,t)},t.prototype.serialMapAsync=function(t){return new _(this,t).serial()},t.prototype.flatmap=function(t){return new q(this,t)},t.prototype.forEachAsync=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.map(t).resolveFully()]})})},t.prototype.serialForEach=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.serialMapAsync(t).resolveWhile(function(t){return!0===t})]})})},t.prototype.rowMajorBatch=function(t,e){return void 0===e&&(e=!0),new D(this,t,e)},t.prototype.columnMajorBatch=function(t,e,n){return void 0===e&&(e=!0),void 0===n&&(n=y),this.rowMajorBatch(t,e).map(function(t){return m(t,n)})},t.prototype.concatenate=function(t,e){return new H(E([this,t]),e)},t.prototype.take=function(t){return t<0||null==t?this:new I(this,t)},t.prototype.skip=function(t){return t<0||null==t?this:new F(this,t)},t.prototype.prefetch=function(t){return new B(this,t)},t.prototype.shuffle=function(t,e){return new V(this,t,e)},t.prototype.serial=function(){return new k(this)},t}(),T=function(t){function e(e){var n=t.call(this)||this;return n.items=e,n.trav=0,n}return r(e,t),e.prototype.summary=function(){return"Array of "+this.items.length+" items"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){return this.trav>=this.items.length?[2,{value:null,done:!0}]:(t=this.items[this.trav],this.trav++,[2,{value:g(t),done:!1}])})})},e}(R),N=function(t){function e(e){var n=t.call(this)||this;return n.nextFn=e,n}return r(e,t),e.prototype.summary=function(){return"Function call"},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){try{return[2,this.nextFn()]}catch(t){throw t.message="Error thrown while iterating through a dataset: "+t.message,t}return[2]})})},e}(R),k=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.lastRead=Promise.resolve({value:null,done:!1}),n}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Serial"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return[2,this.upstream.next()]})})},e}(R),F=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Skip"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},n.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return this.count++<this.maxCount?[4,this.upstream.next()]:[3,2];case 1:return(t=n.sent()).done?[2,t]:(e.dispose(t.value),[3,0]);case 2:return[2,this.upstream.next()]}})})},n}(R),I=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Take"},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]})})},e}(R),D=function(t){function e(e,n,r){void 0===r&&(r=!0);var i=t.call(this)||this;return i.upstream=e,i.batchSize=n,i.enableSmallLastBatch=r,i.lastRead=Promise.resolve({value:null,done:!1}),i}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> RowMajorBatch"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:t=[],n.label=1;case 1:return t.length<this.batchSize?[4,this.upstream.next()]:[3,3];case 2:return(e=n.sent()).done?this.enableSmallLastBatch&&t.length>0?[2,{value:t,done:!1}]:[2,{value:null,done:!0}]:(t.push(e.value),[3,1]);case 3:return[2,{value:t,done:!1}]}})})},e}(R),O=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.predicate=n,r.lastRead=Promise.resolve({value:null,done:!1}),r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Filter"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},n.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return[4,this.upstream.next()];case 1:return(t=n.sent()).done||this.predicate(t.value)?[2,t]:(e.dispose(t.value),[3,0]);case 2:return[2]}})})},n}(R),M=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Map"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return[2,{value:null,done:!0}];for(n=e.tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),i=e.tensor_util.getTensorsInContainer(r),s=0,u=n;s<u.length;s++)a=u[s],e.tensor_util.isTensorInList(a,i)||a.dispose();return[2,{value:r,done:!1}]}})})},n}(R),j=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.handler=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> handleErrors"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,e.sent()];case 3:return t=e.sent(),this.handler(t)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}})})},e}(R),_=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> AsyncMap"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:return(t=o.sent()).done?[2,{value:null,done:!0}]:(n=e.tensor_util.getTensorsInContainer(t.value),[4,this.transform(t.value)]);case 2:for(r=o.sent(),i=e.tensor_util.getTensorsInContainer(r),s=0,u=n;s<u.length;s++)a=u[s],e.tensor_util.isTensorInList(a,i)||a.dispose();return[2,{value:r,done:!1}]}})})},n}(R),L=function(t){function e(){var e=t.call(this)||this;return e.outputQueue=new z,e.lastRead=Promise.resolve({value:null,done:!1}),e}return r(e,t),e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return 0!==this.outputQueue.length()?[3,2]:[4,this.pump()];case 1:return t.sent()?[3,0]:[2,{value:null,done:!0}];case 2:return[2,{value:this.outputQueue.shift(),done:!1}]}})})},e}(R),q=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Flatmap"},n.prototype.pump=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return[2,!1];for(n=e.tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),i=e.tensor_util.getTensorsInContainer(r),this.outputQueue.pushAll(r),s=0,u=n;s<u.length;s++)a=u[s],e.tensor_util.isTensorInList(a,i)||a.dispose();return[2,!0]}})})},n}(L),H=function(t){function e(e,n){var r=t.call(this)||this;return r.baseErrorHandler=n,r.lastRead=null,r.iterator=null,r.moreIterators=e,r}return r(e,t),e.prototype.summary=function(){return"TODO: fill in upstream of chained summaries -> Chained"},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]})})},e.prototype.readFromChain=function(t){return i(this,void 0,void 0,function(){var e,n;return o(this,function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),null!=this.iterator?[3,3]:[4,this.moreIterators.next()];case 2:if((e=r.sent()).done)return[2,{value:null,done:!0}];this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),r.label=3;case 3:return[4,this.iterator.next()];case 4:return(n=r.sent()).done?(this.iterator=null,[2,this.readFromChain(t)]):[2,n]}})})},e}(R);!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(A||(A={}));var P=function(t){function e(e,n){void 0===n&&(n=A.FAIL);var r=t.call(this)||this;return r.iterators=e,r.mismatchMode=n,r.count=0,r.currentPromise=null,r}return r(e,t),e.prototype.summary=function(){return"{TODO: fill in upstream of zip summaries} -> Zip"},e.prototype.nextState=function(t){return i(this,void 0,void 0,function(){function e(t){return t instanceof R?{value:t.next().then(function(t){return n++,t.done&&r++,t.value}),recurse:!1}:{value:null,recurse:!0}}var n,r,i;return o(this,function(o){switch(o.label){case 0:return[4,t];case 1:return o.sent(),n=0,r=0,[4,w(this.iterators,e)];case 2:if(i=o.sent(),n===r)return[2,{value:null,done:!0}];if(r>0)switch(this.mismatchMode){case A.FAIL:throw new Error("Zipped streams should have the same length. Mismatched at element "+this.count+".");case A.SHORTEST:return[2,{value:null,done:!0}];case A.LONGEST:}return this.count++,[2,{value:i,done:!1}]}})})},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return this.currentPromise=this.nextState(this.currentPromise),[2,this.currentPromise]})})},e}(R),B=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.bufferSize=n,r.buffer=new C(n),r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Prefetch"},e.prototype.refill=function(){for(;!this.buffer.isFull();){var t=this.upstream.next();this.buffer.push(t)}},e.prototype.next=function(){return this.refill(),this.buffer.shift()},e}(R),V=function(t){function n(n,r,i){var o=t.call(this,n,r)||this;return o.upstream=n,o.windowSize=r,o.upstreamExhausted=!1,o.random=p(i||e.util.now().toString()),o.lastRead=Promise.resolve({value:null,done:!1}),o}return r(n,t),n.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},n.prototype.randomInt=function(t){return Math.floor(this.random()*t)},n.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},n.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:this.upstreamExhausted||this.refill(),n.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(t=this.chooseIndex(),[4,this.buffer.shuffleExcise(t)]);case 2:return(e=n.sent()).done?(this.upstreamExhausted=!0,[3,1]):(this.refill(),[2,e]);case 3:return[2,{value:null,done:!0}]}})})},n}(B),W=function(){function t(){this.size=null}return t.prototype.batch=function(t,n){var r=this;void 0===n&&(n=!0);var s=this;return e.util.assert(t>0,function(){return"batchSize needs to be positive, but it is\n "+t}),U(function(){return i(r,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,s.iterator()];case 1:return[2,e.sent().columnMajorBatch(t,n,Q)]}})})},this.size===1/0||null==this.size?this.size:n?Math.ceil(this.size/t):Math.floor(this.size/t))},t.prototype.concatenate=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){var e,r;return o(this,function(i){switch(i.label){case 0:return[4,n.iterator()];case 1:return r=(e=i.sent()).concatenate,[4,t.iterator()];case 2:return[2,r.apply(e,[i.sent()])]}})})},this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null)},t.prototype.filter=function(t){var n=this,r=this;return U(function(){return i(n,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return[4,r.iterator()];case 1:return[2,n.sent().filter(function(n){return e.tidy(function(){return t(n)})})]}})})},this.size===1/0?1/0:null)},t.prototype.forEachAsync=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,this.iterator()];case 1:return[2,e.sent().forEachAsync(t)]}})})},t.prototype.forEach=function(t){return i(this,void 0,void 0,function(){return o(this,function(n){return e.deprecationWarn("dataset.forEach() is deprecated and will be removed. Please use dataset.forEachAsync() instead"),[2,this.forEachAsync(t)]})})},t.prototype.map=function(t){var n=this,r=this;return U(function(){return i(n,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return[4,r.iterator()];case 1:return[2,n.sent().map(function(n){return e.tidy(function(){return t(n)})})]}})})},this.size)},t.prototype.mapAsync=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().mapAsync(t)]}})})},this.size)},t.prototype.prefetch=function(t){var e=this;if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().prefetch(t)]}})})},this.size)},t.prototype.repeat=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){var e,r=this;return o(this,function(s){return e=S(function(){return i(r,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return t={},[4,n.iterator()];case 1:return[2,(t.value=e.sent(),t.done=!1,t)]}})})}),[2,(u=e.take(t),new H(u,a))];var u,a})})},null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null)},t.prototype.skip=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().skip(t)]}})})},null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null)},t.prototype.shuffle=function(t,n,r){var s=this;if(void 0===r&&(r=!0),null==t||t<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)");var u=this,a=p(n||e.util.now().toString());return U(function(){return i(s,void 0,void 0,function(){var e;return o(this,function(n){switch(n.label){case 0:return e=a.int32(),r&&(e+=a.int32()),[4,u.iterator()];case 1:return[2,n.sent().shuffle(t,e.toString())]}})})},this.size)},t.prototype.take=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().take(t)]}})})},null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null)},t.prototype.toArray=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArray()]}})})},t.prototype.toArrayForTest=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArrayForTest()]}})})},t.MAX_BUFFER_SIZE=1e4,t}();function U(t,e){return void 0===e&&(e=null),new(function(n){function s(){var t=null!==n&&n.apply(this,arguments)||this;return t.size=e,t}return r(s,n),s.prototype.iterator=function(){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,t()]})})},s}(W))}function Q(t){return null===t?null:function(t){return null==t||null===(n=t)||"object"!=typeof n&&"function"!=typeof n||Array.isArray(t)||"object"==typeof t&&t instanceof e.Tensor||e.util.isTypedArray(t);var n}(t[0])?{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof e.Tensor?e.stack(t):e.tensor(t)}(t),recurse:!1}:{value:null,recurse:!0}}var X=function(t){function e(e){var n=t.call(this)||this;return n.input=e,n}return r(e,t),e.prototype.iterator=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return[4,this.input.iterator()];case 1:return t=n.sent(),e=t.decodeUTF8(),[2,e.split("\n").map(function(t){return t.endsWith("\r")&&(t=t.slice(0,-1)),t})]}})})},e}(W),G=Symbol("out"),Z=Symbol("field"),J=Symbol("quote"),Y=Symbol("quoteafterquote"),K=Symbol("quoteinquote"),$=function(t){function n(n,r){var i=t.call(this)||this;return i.input=n,i.hasHeader=!0,i.fullColumnNames=null,i.columnNamesValidated=!1,i.columnConfigs=null,i.configuredColumnsOnly=!1,i.delimiter=",",i.delimWhitespace=!1,i.base=new X(n),r||(r={}),i.hasHeader=!1!==r.hasHeader,i.fullColumnNames=r.columnNames,i.columnConfigs=r.columnConfigs,i.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(e.util.assert(null==r.delimiter,function(){return"Delimiter should not be provided when delimWhitespace is true."}),i.delimWhitespace=!0,i.delimiter=" "):i.delimiter=r.delimiter?r.delimiter:",",i}return r(n,t),n.prototype.columnNames=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:t.sent(),t.label=2;case 2:return[2,this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames]}})})},n.prototype.setColumnNames=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a=this;return o(this,function(o){switch(o.label){case 0:return[4,this.maybeReadHeaderLine()];case 1:if(t=o.sent(),!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");if(this.fullColumnNames&&t&&e.util.assert(t.length===this.fullColumnNames.length,function(){return"The length of provided columnNames ("+a.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+")."}),this.fullColumnNames||(this.fullColumnNames=t),n=this.fullColumnNames.reduce(function(t,e){return t[e]=t[e]+1||1,t},{}),r=Object.keys(n).filter(function(t){return n[t]>1}),e.util.assert(0===r.length,function(){return"Duplicate column names found: "+r.toString()}),this.columnConfigs)for(i=0,s=Object.keys(this.columnConfigs);i<s.length;i++)if(u=s[i],-1===this.fullColumnNames.indexOf(u))throw new Error('The key "'+u+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").");return this.columnNamesValidated=!0,[2]}})})},n.prototype.maybeReadHeaderLine=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return this.hasHeader?[4,this.base.iterator()]:[3,3];case 1:return[4,n.sent().next()];case 2:if((t=n.sent()).done)throw new Error("No data was found for CSV parsing.");return e=t.value,[2,this.parseRow(e,!1)];case 3:return[2,null]}})})},n.prototype.iterator=function(){return i(this,void 0,void 0,function(){var t,e=this;return o(this,function(n){switch(n.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:n.sent(),n.label=2;case 2:return[4,this.base.iterator()];case 3:return t=n.sent(),this.hasHeader&&(t=t.skip(1)),[2,t.map(function(t){return e.makeDataElement(t)})]}})})},n.prototype.makeDataElement=function(t){for(var e=this.parseRow(t),n={},r={},i=0;i<this.fullColumnNames.length;i++){var o=this.fullColumnNames[i],s=this.columnConfigs?this.columnConfigs[o]:null;if(!this.configuredColumnsOnly||s){var u=e[i],a=null;if(""===u)if(s&&void 0!==s.default)a=s.default;else{if(s&&(s.required||s.isLabel))throw new Error("Required column "+o+" is empty in this line: "+t);a=void 0}else{var c=Number(u);if(isNaN(c))a=s&&"bool"===s.dtype?this.getBoolean(u):u;else if(s&&s.dtype)switch(s.dtype){case"float32":a=c;break;case"int32":a=Math.floor(c);break;case"bool":a=this.getBoolean(u);break;default:a=c}else a=c}s&&s.isLabel?r[o]=a:n[o]=a}}return 0===Object.keys(r).length?n:{xs:n,ys:r}},n.prototype.getBoolean=function(t){return"1"===t||"true"===t.toLowerCase()?1:0},n.prototype.parseRow=function(t,e){void 0===e&&(e=!0);for(var n=[],r=0,i=t.length,o=G,s=0;s<i;s++)switch(o){case G:switch(t.charAt(s)){case'"':r=s+1,o=J;break;case this.delimiter:if(r=s+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),o=G;break;default:o=Z,r=s}break;case Z:switch(t.charAt(s)){case this.delimiter:n.push(t.substring(r,s)),o=G,r=s+1}break;case J:switch(t.charAt(s)){case'"':o=Y}break;case Y:switch(t.charAt(s)){case this.delimiter:n.push(t.substring(r,s-1)),o=G,r=s+1;break;case'"':o=J;break;default:o=K}break;case K:switch(t.charAt(s)){case'"':o=J}}if(o===Y?n.push(t.substring(r,i-1)):n.push(t.substring(r)),e&&n.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have "+this.fullColumnNames.length+" elements in a row, but got "+n);return n},n}(W),tt=function(t){function n(e){var n=t.call(this)||this;n.microphoneConfig=e,n.isClosed=!1,n.fftSize=e.fftSize||1024;var r=Math.log2(n.fftSize);if(n.fftSize<0||r<4||r>14||!Number.isInteger(r))throw new Error("Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got "+n.fftSize);if(n.numFrames=e.numFramesPerSpectrogram||43,n.sampleRateHz=e.sampleRateHz,n.columnTruncateLength=e.columnTruncateLength||n.fftSize,n.audioTrackConstraints=e.audioTrackConstraints,n.smoothingTimeConstant=e.smoothingTimeConstant||0,n.includeSpectrogram=!1!==e.includeSpectrogram,n.includeWaveform=!0===e.includeWaveform,!n.includeSpectrogram&&!n.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return n}return r(n,t),n.prototype.summary=function(){return"microphone"},n.create=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,function(){var r;return o(this,function(i){switch(i.label){case 0:if(e.ENV.get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");return[4,(r=new n(t)).start()];case 1:return i.sent(),[2,r]}})})},n.prototype.start=function(){return i(this,void 0,void 0,function(){var t,e,n,r;return o(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=this,[4,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})];case 1:return t.stream=i.sent(),[3,3];case 2:throw e=i.sent(),new Error("Error thrown while initializing video stream: "+e.message);case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(n=window.AudioContext||window.webkitAudioContext,this.audioContext=new n,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;return r=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,r.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2]}})})},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,e,n,r,i;return o(this,function(o){switch(o.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return n=o.sent(),this.includeSpectrogram&&(r=this.flattenQueue(n.freqDataQueue),t=this.getTensorFromAudioDataArray(r,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(n.timeDataQueue),e=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:t,waveform:e},done:!1}]}})})},n.prototype.capture=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}})})},n.prototype.getAudioData=function(){return i(this,void 0,void 0,function(){var t,e,n,r=this;return o(this,function(i){return t=[],e=[],n=0,[2,new Promise(function(i){var o=setInterval(function(){r.includeSpectrogram&&(r.analyser.getFloatFrequencyData(r.freqData),r.freqData[0]===-1/0&&i({freqDataQueue:t,timeDataQueue:e}),t.push(r.freqData.slice(0,r.columnTruncateLength))),r.includeWaveform&&(r.analyser.getFloatTimeDomainData(r.timeData),e.push(r.timeData.slice())),++n===r.numFrames&&(clearInterval(o),i({freqDataQueue:t,timeDataQueue:e}))},r.fftSize/r.sampleRateHz*1e3)})]})})},n.prototype.stop=function(){this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop()},n.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},n.prototype.getSampleRate=function(){return this.sampleRateHz},n.prototype.flattenQueue=function(t){var e=t[0].length,n=new Float32Array(t.length*e);return t.forEach(function(t,r){return n.set(t,r*e)}),n},n.prototype.getTensorFromAudioDataArray=function(t,n){var r=new Float32Array(e.util.sizeFromShape(n));return r.set(t,r.length-t.length),e.tensor(r,n)},n}(R),et=function(t){function n(n,r){var i=t.call(this)||this;if(i.webcamVideoElement=n,i.webcamConfig=r,i.isClosed=!0,i.resize=!1,i.needToResize())if(i.resize=!0,i.cropSize=[i.webcamConfig.resizeHeight,i.webcamConfig.resizeWidth],i.cropBoxInd=e.tensor1d([0],"int32"),i.webcamConfig.centerCrop){var o=1*i.webcamConfig.resizeWidth/i.webcamVideoElement.width,s=1*i.webcamConfig.resizeHeight/i.webcamVideoElement.height,u=(1-o)/2,a=(1-s)/2,c=u+o,h=s+a;i.cropBox=e.tensor2d([a,u,h,c],[1,4])}else i.cropBox=e.tensor2d([0,0,1,1],[1,4]);return i}return r(n,t),n.prototype.summary=function(){return"webcam"},n.create=function(t,r){return void 0===r&&(r={}),i(this,void 0,void 0,function(){var i;return o(this,function(o){switch(o.label){case 0:if(e.ENV.get("IS_NODE"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!r.resizeWidth||!r.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=r.resizeWidth,t.height=r.resizeHeight}return[4,(i=new n(t,r)).start()];case 1:return o.sent(),[2,i]}})})},n.prototype.start=function(){return i(this,void 0,void 0,function(){var t,n,r=this;return o(this,function(i){switch(i.label){case 0:this.webcamConfig.facingMode&&e.util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,function(){return"Invalid webcam facing mode: "+r.webcamConfig.facingMode+". Please provide 'user' or 'environment'"}),i.label=1;case 1:return i.trys.push([1,3,,4]),t=this,[4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})];case 2:return t.stream=i.sent(),[3,4];case 3:throw(n=i.sent()).message="Error thrown while initializing video stream: "+n.message,n;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise(function(t){r.webcamVideoElement.onloadedmetadata=function(){t()}})]}})})},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){if(this.isClosed)return[2,{value:null,done:!0}];try{t=e.browser.fromPixels(this.webcamVideoElement)}catch(t){throw new Error("Error thrown converting video to pixels: "+JSON.stringify(t))}if(!this.resize)return[2,{value:t,done:!1}];try{return[2,{value:this.cropAndResizeFrame(t),done:!1}]}catch(t){throw new Error("Error thrown cropping the video: "+t.message)}finally{t.dispose()}return[2]})})},n.prototype.needToResize=function(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)},n.prototype.cropAndResizeFrame=function(t){var n=this;return e.tidy(function(){var r,i=t.toFloat().expandDims(0),o=(r=e.image.cropAndResize(i,n.cropBox,n.cropBoxInd,n.cropSize,"bilinear")).shape;return r.reshape(o.slice(1))})},n.prototype.capture=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}})})},n.prototype.stop=function(){this.stream.getTracks().forEach(function(t){return t.stop()});try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0},n.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},n}(R),nt=function(){return function(){}}(),rt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.split=function(t){return new it(this,t)},e}(R),it=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.impl=new ot(e,n),r}return r(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return[2,this.impl.next()]})})},e}(rt),ot=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.separator=n,r.carryover="",r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')"},e.prototype.pump=function(){return i(this,void 0,void 0,function(){var t,e,n,r,i;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return""===this.carryover?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);for((e=t.value.split(this.separator))[0]=this.carryover+e[0],n=0,r=e.slice(0,-1);n<r.length;n++)i=r[n],this.outputQueue.push(i);return this.carryover=e[e.length-1],[2,!0]}})})},e}(L),st=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.decodeUTF8=function(){return new ut(this)},e}(R),ut=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.impl=new at(e),n}return r(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return[2,this.impl.next()]})})},e}(rt),at=function(t){function n(n){var r=t.call(this)||this;if(r.upstream=n,e.ENV.get("IS_BROWSER"))r.decoder=new TextDecoder("utf-8");else{var i=require("string_decoder").StringDecoder;r.decoder=new i("utf8")}return r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Utf8"},n.prototype.pump=function(){return i(this,void 0,void 0,function(){var t,n,r;return o(this,function(i){switch(i.label){case 0:return[4,this.upstream.next()];case 1:return(t=i.sent()).done?[2,!1]:(n=t.value,r=e.ENV.get("IS_BROWSER")?this.decoder.decode(n,{stream:!0}):this.decoder.write(Buffer.from(n.buffer)),this.outputQueue.push(r),[2,!0])}})})},n}(L),ct=function(t){function n(n,r){void 0===r&&(r={});var i=t.call(this)||this;return i.file=n,i.options=r,e.util.assert(n instanceof Uint8Array||!!e.ENV.get("IS_BROWSER")&&(n instanceof File||n instanceof Blob),function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."}),i.offset=r.offset||0,i.chunkSize=r.chunkSize||1048576,i}return r(n,t),n.prototype.summary=function(){return"FileChunks "+this.file},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,e,n=this;return o(this,function(r){switch(r.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(t=new Promise(function(t,e){var r=n.offset+n.chunkSize;if(n.file instanceof Uint8Array)t(new Uint8Array(n.file.slice(n.offset,r)));else{var i=new FileReader;i.onload=function(n){var r=i.result;if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),!(r instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(r)},i.onabort=function(t){return e(new Error("Aborted"))},i.onerror=function(t){return e(new Error(t.type))};var o=n.file.slice(n.offset,r);i.readAsArrayBuffer(o)}n.offset=r}),e={},[4,t]);case 1:return[2,(e.value=r.sent(),e.done=!1,e)]}})})},n}(st);var ht=function(t){return{method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity}};function lt(t){return"string"==typeof t&&"file://"===t.substr(0,7)}var ft=function(t){function n(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.input=e,r.options=n,r}return r(n,t),n.prototype.iterator=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){return lt(this.input)&&e.ENV.get("IS_NODE")&&(t=require("fs"),this.input=t.readFileSync(this.input.substr(7))),[2,new ct(this.input,this.options)]})})},n}(nt),dt=function(t){function n(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.url=e,r.fileOptions=n,r}return r(n,t),n.prototype.iterator=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return lt(this.url)?[2,new ft(this.url,this.fileOptions).iterator()]:[2,function(t,n){return void 0===n&&(n={}),i(this,void 0,void 0,function(){var r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return"string"==typeof t?r=t:(r=t.url,i=ht(t)),[4,e.util.fetch(r,i)];case 1:return(s=o.sent()).ok?(a=Uint8Array.bind,[4,s.arrayBuffer()]):[3,3];case 2:return u=new(a.apply(Uint8Array,[void 0,o.sent()])),[2,new ct(u,n)];case 3:throw new Error(s.statusText)}})})}(this.url,this.fileOptions)]})})},n}(nt);t.array=function(t){var e=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){return[2,E(t)]})})},t.length)},t.Dataset=W,t.zip=function(t){var e,n=this;if(!b(t))throw new Error("The argument to zip() must be an object or array.");if(Array.isArray(t))for(var r=0;r<t.length;r++)e=null==e?t[r].size:Math.min(e,t[r].size);else if(t instanceof Object)for(var s in t)e=null==e?t[s].size:Math.min(e,t[s].size);return U(function(){return i(n,void 0,void 0,function(){var e;return o(this,function(n){switch(n.label){case 0:return[4,w(t,function(t){if(t instanceof W)return{value:t.iterator(),recurse:!1};if(b(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})];case 1:return e=n.sent(),[2,(r=e,i=A.SHORTEST,void 0===i&&(i=A.FAIL),new P(r,i))]}var r,i})})},e)},t.CSVDataset=$,t.TextLineDataset=X,t.csv=function(t,e){return void 0===e&&(e={}),new $(new dt(t),e)},t.func=function(t){var e=this,n=S(t);return U(function(){return i(e,void 0,void 0,function(){return o(this,function(t){return[2,n]})})})},t.generator=function(t){var e=this;return U(function(){return i(e,void 0,void 0,function(){var e;return o(this,function(n){switch(n.label){case 0:return[4,t()];case 1:return e=n.sent(),[2,S(function(){return e.next()})]}})})})},t.microphone=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,tt.create(t)]})})},t.webcam=function(t,e){return i(this,void 0,void 0,function(){return o(this,function(n){return[2,et.create(t,e)]})})},t.FileDataSource=ft,t.URLDataSource=dt,t.version_data="1.2.9",Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=tf-data.min.js.map

@@ -17,3 +17,3 @@ /**

*/
import{util,tidy,deprecationWarn,Tensor,stack,tensor,ENV,dispose,tensor_util,tensor1d,tensor2d,browser,image}from"@tensorflow/tfjs-core";var extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function __extends(t,e){function r(){this.constructor=t}extendStatics(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function __awaiter(t,e,r,n){return new(r||(r=Promise))(function(i,o){function a(t){try{u(n.next(t))}catch(t){o(t)}}function s(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){t.done?i(t.value):new r(function(e){e(t.value)}).then(a,s)}u((n=n.apply(t,e||[])).next())})}function __generator(t,e){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e){return t(e={exports:{}},e.exports),e.exports}var alea=createCommonjsModule(function(t){!function(t,e,r){function n(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function i(t,e){var r=new function(t){var e,r=this,n=(e=4022871197,function(t){t=t.toString();for(var r=0;r<t.length;r++){var n=.02519603282416938*(e+=t.charCodeAt(r));n-=e=n>>>0,e=(n*=e)>>>0,e+=4294967296*(n-=e)}return 2.3283064365386963e-10*(e>>>0)});r.next=function(){var t=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=t-(r.c=0|t)},r.c=1,r.s0=n(" "),r.s1=n(" "),r.s2=n(" "),r.s0-=n(t),r.s0<0&&(r.s0+=1),r.s1-=n(t),r.s1<0&&(r.s1+=1),r.s2-=n(t),r.s2<0&&(r.s2+=1),n=null}(t),i=e&&e.state,o=r.next;return o.int32=function(){return 4294967296*r.next()|0},o.double=function(){return o()+1.1102230246251565e-16*(2097152*o()|0)},o.quick=o,i&&("object"==typeof i&&n(i,r),o.state=function(){return n(r,{})}),o}e&&e.exports?e.exports=i:r&&r.amd?r(function(){return i}):this.alea=i}(0,t,!1)}),xor128=createCommonjsModule(function(t){!function(t,e,r){function n(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function i(t,e){var r=new function(t){var e=this,r="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:r+=t;for(var n=0;n<r.length+64;n++)e.x^=0|r.charCodeAt(n),e.next()}(t),i=e&&e.state,o=function(){return(r.next()>>>0)/4294967296};return o.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=r.next,o.quick=o,i&&("object"==typeof i&&n(i,r),o.state=function(){return n(r,{})}),o}e&&e.exports?e.exports=i:r&&r.amd?r(function(){return i}):this.xor128=i}(0,t,!1)}),xorwow=createCommonjsModule(function(t){!function(t,e,r){function n(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function i(t,e){var r=new function(t){var e=this,r="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:r+=t;for(var n=0;n<r.length+64;n++)e.x^=0|r.charCodeAt(n),n==r.length&&(e.d=e.x<<10^e.x>>>4),e.next()}(t),i=e&&e.state,o=function(){return(r.next()>>>0)/4294967296};return o.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=r.next,o.quick=o,i&&("object"==typeof i&&n(i,r),o.state=function(){return n(r,{})}),o}e&&e.exports?e.exports=i:r&&r.amd?r(function(){return i}):this.xorwow=i}(0,t,!1)}),xorshift7=createCommonjsModule(function(t){!function(t,e,r){function n(t,e){return e.x=t.x.slice(),e.i=t.i,e}function i(t,e){null==t&&(t=+new Date);var r=new function(t){var e=this;e.next=function(){var t,r,n=e.x,i=e.i;return t=n[i],r=(t^=t>>>7)^t<<24,r^=(t=n[i+1&7])^t>>>10,r^=(t=n[i+3&7])^t>>>3,r^=(t=n[i+4&7])^t<<7,t=n[i+7&7],r^=(t^=t<<13)^t<<9,n[i]=r,e.i=i+1&7,r},function(t,e){var r,n=[];if(e===(0|e))n[0]=e;else for(e=""+e,r=0;r<e.length;++r)n[7&r]=n[7&r]<<15^e.charCodeAt(r)+n[r+1&7]<<13;for(;n.length<8;)n.push(0);for(r=0;r<8&&0===n[r];++r);for(8==r?n[7]=-1:n[r],t.x=n,t.i=0,r=256;r>0;--r)t.next()}(e,t)}(t),i=e&&e.state,o=function(){return(r.next()>>>0)/4294967296};return o.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=r.next,o.quick=o,i&&(i.x&&n(i,r),o.state=function(){return n(r,{})}),o}e&&e.exports?e.exports=i:r&&r.amd?r(function(){return i}):this.xorshift7=i}(0,t,!1)}),xor4096=createCommonjsModule(function(t){!function(t,e,r){function n(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function i(t,e){null==t&&(t=+new Date);var r=new function(t){var e=this;e.next=function(){var t,r,n=e.w,i=e.X,o=e.i;return e.w=n=n+1640531527|0,r=i[o+34&127],t=i[o=o+1&127],r^=r<<13,t^=t<<17,r^=r>>>15,t^=t>>>12,r=i[o]=r^t,e.i=o,r+(n^n>>>16)|0},function(t,e){var r,n,i,o,a,s=[],u=128;for(e===(0|e)?(n=e,e=null):(e+="\0",n=0,u=Math.max(u,e.length)),i=0,o=-32;o<u;++o)e&&(n^=e.charCodeAt((o+32)%e.length)),0===o&&(a=n),n^=n<<10,n^=n>>>15,n^=n<<4,n^=n>>>13,o>=0&&(a=a+1640531527|0,i=0==(r=s[127&o]^=n+a)?i+1:0);for(i>=128&&(s[127&(e&&e.length||0)]=-1),i=127,o=512;o>0;--o)n=s[i+34&127],r=s[i=i+1&127],n^=n<<13,r^=r<<17,n^=n>>>15,r^=r>>>12,s[i]=n^r;t.w=a,t.X=s,t.i=i}(e,t)}(t),i=e&&e.state,o=function(){return(r.next()>>>0)/4294967296};return o.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=r.next,o.quick=o,i&&(i.X&&n(i,r),o.state=function(){return n(r,{})}),o}e&&e.exports?e.exports=i:r&&r.amd?r(function(){return i}):this.xor4096=i}(0,t,!1)}),tychei=createCommonjsModule(function(t){!function(t,e,r){function n(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function i(t,e){var r=new function(t){var e=this,r="";e.next=function(){var t=e.b,r=e.c,n=e.d,i=e.a;return t=t<<25^t>>>7^r,r=r-n|0,n=n<<24^n>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^r,e.c=r=r-n|0,e.d=n<<16^r>>>16^i,e.a=i-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):r+=t;for(var n=0;n<r.length+20;n++)e.b^=0|r.charCodeAt(n),e.next()}(t),i=e&&e.state,o=function(){return(r.next()>>>0)/4294967296};return o.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=r.next,o.quick=o,i&&("object"==typeof i&&n(i,r),o.state=function(){return n(r,{})}),o}e&&e.exports?e.exports=i:r&&r.amd?r(function(){return i}):this.tychei=i}(0,t,!1)}),seedrandom=createCommonjsModule(function(t){!function(e,r){var n,i=this,o=256,a=6,s="random",u=r.pow(o,a),c=r.pow(2,52),l=2*c,h=o-1;function f(t,f,v){var _=[],w=p(function t(e,r){var n,i=[],o=typeof e;if(r&&"object"==o)for(n in e)try{i.push(t(e[n],r-1))}catch(t){}return i.length?i:"string"==o?e:e+"\0"}((f=1==f?{entropy:!0}:f||{}).entropy?[t,m(e)]:null==t?function(){try{var t;return n&&(t=n.randomBytes)?t=t(o):(t=new Uint8Array(o),(i.crypto||i.msCrypto).getRandomValues(t)),m(t)}catch(t){var r=i.navigator,a=r&&r.plugins;return[+new Date,i,a,i.screen,m(e)]}}():t,3),_),y=new function(t){var e,r=t.length,n=this,i=0,a=n.i=n.j=0,s=n.S=[];r||(t=[r++]);for(;i<o;)s[i]=i++;for(i=0;i<o;i++)s[i]=s[a=h&a+t[i%r]+(e=s[i])],s[a]=e;(n.g=function(t){for(var e,r=0,i=n.i,a=n.j,s=n.S;t--;)e=s[i=h&i+1],r=r*o+s[h&(s[i]=s[a=h&a+e])+(s[a]=e)];return n.i=i,n.j=a,r})(o)}(_),g=function(){for(var t=y.g(a),e=u,r=0;t<c;)t=(t+r)*o,e*=o,r=y.g(1);for(;t>=l;)t/=2,e/=2,r>>>=1;return(t+r)/e};return g.int32=function(){return 0|y.g(4)},g.quick=function(){return y.g(4)/4294967296},g.double=g,p(m(y.S),e),(f.pass||v||function(t,e,n,i){return i&&(i.S&&d(i,y),t.state=function(){return d(y,{})}),n?(r[s]=t,e):t})(g,w,"global"in f?f.global:this==r,f.state)}function d(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function p(t,e){for(var r,n=t+"",i=0;i<n.length;)e[h&i]=h&(r^=19*e[h&i])+n.charCodeAt(i++);return m(e)}function m(t){return String.fromCharCode.apply(0,t)}if(r["seed"+s]=f,p(r.random(),e),t.exports){t.exports=f;try{n=require("crypto")}catch(t){}}else 0}([],Math)});seedrandom.alea=alea,seedrandom.xor128=xor128,seedrandom.xorwow=xorwow,seedrandom.xorshift7=xorshift7,seedrandom.xor4096=xor4096,seedrandom.tychei=tychei;var seedrandom$1=seedrandom,seedrandom_1=seedrandom$1.alea;function deepMap(t,e){return deepMapInternal(t,e)}function deepMapInternal(t,e,r,n){if(void 0===r&&(r=new Map),void 0===n&&(n=new Set),null==t)return null;if(n.has(t))throw new Error("Circular references are not supported.");if(r.has(t))return r.get(t);var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(i.recurse){if(isIterable(t)){var o=Array.isArray(t)?[]:{};for(var a in n.add(t),t){var s=deepMapInternal(t[a],e,r,n);o[a]=s}return n.delete(t),o}throw new Error("Can't recurse into non-iterable type: "+t)}return r.set(t,i.value),i.value}function deepZip(t,e){return void 0===e&&(e=zipToList),deepZipInternal(t,e)}function deepZipInternal(t,e,r){void 0===r&&(r=new Set);var n=t[0];if(r.has(n))throw new Error("Circular references are not supported.");var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(i.recurse){if(isIterable(n)){var o=Array.isArray(n)?[]:{};r.add(n);var a=function(n){var i=deepZipInternal(t.map(function(t){return t[n]}),e,r);o[n]=i};for(var s in n)a(s);return r.delete(n),o}throw new Error("Can't recurse into non-iterable type: "+n)}return i.value}function zipToList(t){return null===t?null:isIterable(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}function deepMapAndAwaitAll(t,e){return __awaiter(this,void 0,void 0,function(){var r,n,i,o,a,s;return __generator(this,function(u){switch(u.label){case 0:r=new Map,deepMapInternal(t,e,r),n=0,i=Array.from(r.keys()),u.label=1;case 1:return n<i.length?(o=i[n],(a=r.get(o))instanceof Promise?[4,a]:[3,3]):[3,4];case 2:s=u.sent(),r.set(o,s),u.label=3;case 3:return n++,[3,1];case 4:return[2,deepMapInternal(t,e,r)]}})})}function isIterable(t){return null!=t&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof Tensor))}function canTensorify(t){return null==t||isPrimitive(t)||Array.isArray(t)||"object"==typeof t&&t instanceof Tensor||util.isTypedArray(t)}function isPrimitive(t){return null===t||"object"!=typeof t&&"function"!=typeof t}function deepClone(t){return deepMap(t,cloneIfTensor)}function cloneIfTensor(t){return t instanceof Tensor?{value:t.clone(),recurse:!1}:isIterable(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}var RingBuffer=function(){function t(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}return t.prototype.wrap=function(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity},t.prototype.get=function(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]},t.prototype.set=function(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e},t.prototype.length=function(){var t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t},t.prototype.isFull=function(){return this.length()===this.capacity},t.prototype.isEmpty=function(){return 0===this.length()},t.prototype.push=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)},t.prototype.pushAll=function(t){for(var e=0,r=t;e<r.length;e++){var n=r[e];this.push(n)}},t.prototype.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var t=this.get(this.end);return this.set(this.end,void 0),t},t.prototype.unshift=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)},t.prototype.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t},t.prototype.shuffleExcise=function(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.wrap(this.begin+t),r=this.get(e);return this.set(e,this.pop()),r},t}(),GrowingRingBuffer=function(t){function e(){return t.call(this,e.INITIAL_CAPACITY)||this}return __extends(e,t),e.prototype.isFull=function(){return!1},e.prototype.push=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.push.call(this,e)},e.prototype.unshift=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.unshift.call(this,e)},e.prototype.expand=function(){for(var t=2*this.capacity,e=new Array(t),r=this.length(),n=0;n<r;n++)e[n]=this.get(this.wrap(this.begin+n));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=r},e.INITIAL_CAPACITY=32,e}(RingBuffer);function iteratorFromItems(t){return new ArrayIterator(t)}function iteratorFromFunction(t){return new FunctionCallIterator(t)}function iteratorFromConcatenated(t,e){return new ChainedIterator(t,e)}function iteratorFromZipped(t,e){return void 0===e&&(e=ZipMismatchMode.FAIL),new ZipIterator(t,e)}var ZipMismatchMode,LazyIterator=function(){function t(){}return t.prototype.toArray=function(){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(r){switch(r.label){case 0:return t=[],[4,this.next()];case 1:e=r.sent(),r.label=2;case 2:return e.done?[3,4]:(t.push(e.value),[4,this.next()]);case 3:return e=r.sent(),[3,2];case 4:return[2,t]}})})},t.prototype.toArrayForTest=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r;return __generator(this,function(n){switch(n.label){case 0:return t=this.prefetch(100),e=[],[4,t.next()];case 1:r=n.sent(),n.label=2;case 2:return r.done?[3,4]:(e.push(r.value),[4,t.next()]);case 3:return r=n.sent(),[3,2];case 4:return[2,e]}})})},t.prototype.resolveFully=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,this.next()];case 1:t=e.sent(),e.label=2;case 2:return t.done?[3,4]:[4,this.next()];case 3:return t=e.sent(),[3,2];case 4:return[2]}})})},t.prototype.resolveWhile=function(t){return __awaiter(this,void 0,void 0,function(){var e,r;return __generator(this,function(n){switch(n.label){case 0:return[4,this.next()];case 1:e=n.sent(),r=t(e.value),n.label=2;case 2:return e.done||!r?[3,4]:[4,this.next()];case 3:return e=n.sent(),r=t(e.value),[3,2];case 4:return[2]}})})},t.prototype.handleErrors=function(t){return new ErrorHandlingLazyIterator(this,t)},t.prototype.filter=function(t){return new FilterIterator(this,t)},t.prototype.map=function(t){return new MapIterator(this,t)},t.prototype.mapAsync=function(t){return new AsyncMapIterator(this,t)},t.prototype.serialMapAsync=function(t){return new AsyncMapIterator(this,t).serial()},t.prototype.flatmap=function(t){return new FlatmapIterator(this,t)},t.prototype.forEachAsync=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,this.map(t).resolveFully()]})})},t.prototype.serialForEach=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,this.serialMapAsync(t).resolveWhile(function(t){return!0===t})]})})},t.prototype.rowMajorBatch=function(t,e){return void 0===e&&(e=!0),new RowMajorBatchIterator(this,t,e)},t.prototype.columnMajorBatch=function(t,e,r){return void 0===e&&(e=!0),void 0===r&&(r=zipToList),this.rowMajorBatch(t,e).map(function(t){return deepZip(t,r)})},t.prototype.concatenate=function(t,e){return new ChainedIterator(iteratorFromItems([this,t]),e)},t.prototype.take=function(t){return t<0||null==t?this:new TakeIterator(this,t)},t.prototype.skip=function(t){return t<0||null==t?this:new SkipIterator(this,t)},t.prototype.prefetch=function(t){return new PrefetchIterator(this,t)},t.prototype.shuffle=function(t,e){return new ShuffleIterator(this,t,e)},t.prototype.serial=function(){return new SerialIterator(this)},t}(),ArrayIterator=function(t){function e(e){var r=t.call(this)||this;return r.items=e,r.trav=0,r}return __extends(e,t),e.prototype.summary=function(){return"Array of "+this.items.length+" items"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){return this.trav>=this.items.length?[2,{value:null,done:!0}]:(t=this.items[this.trav],this.trav++,[2,{value:deepClone(t),done:!1}])})})},e}(LazyIterator),FunctionCallIterator=function(t){function e(e){var r=t.call(this)||this;return r.nextFn=e,r}return __extends(e,t),e.prototype.summary=function(){return"Function call"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){try{return[2,this.nextFn()]}catch(t){throw t.message="Error thrown while iterating through a dataset: "+t.message,t}return[2]})})},e}(LazyIterator),SerialIterator=function(t){function e(e){var r=t.call(this)||this;return r.upstream=e,r.lastRead=Promise.resolve({value:null,done:!1}),r}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Serial"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2,this.upstream.next()]})})},e}(LazyIterator),SkipIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.maxCount=r,n.count=0,n.lastRead=Promise.resolve({value:null,done:!1}),n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Skip"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return this.count++<this.maxCount?[4,this.upstream.next()]:[3,2];case 1:return(t=e.sent()).done?[2,t]:(dispose(t.value),[3,0]);case 2:return[2,this.upstream.next()]}})})},e}(LazyIterator),TakeIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.maxCount=r,n.count=0,n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Take"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]})})},e}(LazyIterator),RowMajorBatchIterator=function(t){function e(e,r,n){void 0===n&&(n=!0);var i=t.call(this)||this;return i.upstream=e,i.batchSize=r,i.enableSmallLastBatch=n,i.lastRead=Promise.resolve({value:null,done:!1}),i}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> RowMajorBatch"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(r){switch(r.label){case 0:t=[],r.label=1;case 1:return t.length<this.batchSize?[4,this.upstream.next()]:[3,3];case 2:return(e=r.sent()).done?this.enableSmallLastBatch&&t.length>0?[2,{value:t,done:!1}]:[2,{value:null,done:!0}]:(t.push(e.value),[3,1]);case 3:return[2,{value:t,done:!1}]}})})},e}(LazyIterator),FilterIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.predicate=r,n.lastRead=Promise.resolve({value:null,done:!1}),n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Filter"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,this.upstream.next()];case 1:return(t=e.sent()).done||this.predicate(t.value)?[2,t]:(dispose(t.value),[3,0]);case 2:return[2]}})})},e}(LazyIterator),MapIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.transform=r,n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Map"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n,i,o,a;return __generator(this,function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return[2,{value:null,done:!0}];for(e=tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),n=tensor_util.getTensorsInContainer(r),i=0,o=e;i<o.length;i++)a=o[i],tensor_util.isTensorInList(a,n)||a.dispose();return[2,{value:r,done:!1}]}})})},e}(LazyIterator),ErrorHandlingLazyIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.handler=r,n.count=0,n.lastRead=Promise.resolve({value:null,done:!1}),n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> handleErrors"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,e.sent()];case 3:return t=e.sent(),this.handler(t)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}})})},e}(LazyIterator),AsyncMapIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.transform=r,n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> AsyncMap"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n,i,o,a;return __generator(this,function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:return(t=s.sent()).done?[2,{value:null,done:!0}]:(e=tensor_util.getTensorsInContainer(t.value),[4,this.transform(t.value)]);case 2:for(r=s.sent(),n=tensor_util.getTensorsInContainer(r),i=0,o=e;i<o.length;i++)a=o[i],tensor_util.isTensorInList(a,n)||a.dispose();return[2,{value:r,done:!1}]}})})},e}(LazyIterator),OneToManyIterator=function(t){function e(){var e=t.call(this)||this;return e.outputQueue=new GrowingRingBuffer,e.lastRead=Promise.resolve({value:null,done:!1}),e}return __extends(e,t),e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return 0!==this.outputQueue.length()?[3,2]:[4,this.pump()];case 1:return t.sent()?[3,0]:[2,{value:null,done:!0}];case 2:return[2,{value:this.outputQueue.shift(),done:!1}]}})})},e}(LazyIterator),FlatmapIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.transform=r,n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Flatmap"},e.prototype.pump=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n,i,o,a;return __generator(this,function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return[2,!1];for(e=tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),n=tensor_util.getTensorsInContainer(r),this.outputQueue.pushAll(r),i=0,o=e;i<o.length;i++)a=o[i],tensor_util.isTensorInList(a,n)||a.dispose();return[2,!0]}})})},e}(OneToManyIterator),ChainedIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.baseErrorHandler=r,n.lastRead=null,n.iterator=null,n.moreIterators=e,n}return __extends(e,t),e.prototype.summary=function(){return"TODO: fill in upstream of chained summaries -> Chained"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]})})},e.prototype.readFromChain=function(t){return __awaiter(this,void 0,void 0,function(){var e,r;return __generator(this,function(n){switch(n.label){case 0:return[4,t];case 1:return n.sent(),null!=this.iterator?[3,3]:[4,this.moreIterators.next()];case 2:if((e=n.sent()).done)return[2,{value:null,done:!0}];this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),n.label=3;case 3:return[4,this.iterator.next()];case 4:return(r=n.sent()).done?(this.iterator=null,[2,this.readFromChain(t)]):[2,r]}})})},e}(LazyIterator);!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(ZipMismatchMode||(ZipMismatchMode={}));var ZipIterator=function(t){function e(e,r){void 0===r&&(r=ZipMismatchMode.FAIL);var n=t.call(this)||this;return n.iterators=e,n.mismatchMode=r,n.count=0,n.currentPromise=null,n}return __extends(e,t),e.prototype.summary=function(){return"{TODO: fill in upstream of zip summaries} -> Zip"},e.prototype.nextState=function(t){return __awaiter(this,void 0,void 0,function(){function e(t){return t instanceof LazyIterator?{value:t.next().then(function(t){return r++,t.done&&n++,t.value}),recurse:!1}:{value:null,recurse:!0}}var r,n,i;return __generator(this,function(o){switch(o.label){case 0:return[4,t];case 1:return o.sent(),r=0,n=0,[4,deepMapAndAwaitAll(this.iterators,e)];case 2:if(i=o.sent(),r===n)return[2,{value:null,done:!0}];if(n>0)switch(this.mismatchMode){case ZipMismatchMode.FAIL:throw new Error("Zipped streams should have the same length. Mismatched at element "+this.count+".");case ZipMismatchMode.SHORTEST:return[2,{value:null,done:!0}];case ZipMismatchMode.LONGEST:}return this.count++,[2,{value:i,done:!1}]}})})},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return this.currentPromise=this.nextState(this.currentPromise),[4,this.currentPromise];case 1:return[2,t.sent()]}})})},e}(LazyIterator),PrefetchIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.bufferSize=r,n.buffer=new RingBuffer(r),n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Prefetch"},e.prototype.refill=function(){for(;!this.buffer.isFull();){var t=this.upstream.next();this.buffer.push(t)}},e.prototype.next=function(){return this.refill(),this.buffer.shift()},e}(LazyIterator),ShuffleIterator=function(t){function e(e,r,n){var i=t.call(this,e,r)||this;return i.upstream=e,i.windowSize=r,i.upstreamExhausted=!1,i.random=seedrandom_1(n||util.now().toString()),i.lastRead=Promise.resolve({value:null,done:!1}),i}return __extends(e,t),e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.randomInt=function(t){return Math.floor(this.random()*t)},e.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(r){switch(r.label){case 0:this.upstreamExhausted||this.refill(),r.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(t=this.chooseIndex(),[4,this.buffer.shuffleExcise(t)]);case 2:return(e=r.sent()).done?(this.upstreamExhausted=!0,[3,1]):(this.refill(),[2,e]);case 3:return[2,{value:null,done:!0}]}})})},e}(PrefetchIterator),Dataset=function(){function t(){this.size=null}return t.prototype.batch=function(t,e){var r=this;void 0===e&&(e=!0);var n=this;return util.assert(t>0,function(){return"batchSize needs to be positive, but it is\n "+t}),datasetFromIteratorFn(function(){return __awaiter(r,void 0,void 0,function(){return __generator(this,function(r){switch(r.label){case 0:return[4,n.iterator()];case 1:return[2,r.sent().columnMajorBatch(t,e,deepBatchConcat)]}})})},this.size===1/0||null==this.size?this.size:e?Math.ceil(this.size/t):Math.floor(this.size/t))},t.prototype.concatenate=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){var e,n;return __generator(this,function(i){switch(i.label){case 0:return[4,r.iterator()];case 1:return n=(e=i.sent()).concatenate,[4,t.iterator()];case 2:return[2,n.apply(e,[i.sent()])]}})})},this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null)},t.prototype.filter=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,r.iterator()];case 1:return[2,e.sent().filter(function(e){return tidy(function(){return t(e)})})]}})})},this.size===1/0?1/0:null)},t.prototype.forEachAsync=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,this.iterator()];case 1:return[2,e.sent().forEachAsync(t)]}})})},t.prototype.forEach=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return deprecationWarn("dataset.forEach() is deprecated and will be removed. Please use dataset.forEachAsync() instead"),[2,this.forEachAsync(t)]})})},t.prototype.map=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,r.iterator()];case 1:return[2,e.sent().map(function(e){return tidy(function(){return t(e)})})]}})})},this.size)},t.prototype.mapAsync=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,r.iterator()];case 1:return[2,e.sent().mapAsync(t)]}})})},this.size)},t.prototype.prefetch=function(t){var e=this;if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,r.iterator()];case 1:return[2,e.sent().prefetch(t)]}})})},this.size)},t.prototype.repeat=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){var e=this;return __generator(this,function(n){return[2,iteratorFromConcatenated(iteratorFromFunction(function(){return __awaiter(e,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return t={},[4,r.iterator()];case 1:return[2,(t.value=e.sent(),t.done=!1,t)]}})})}).take(t))]})})},null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null)},t.prototype.skip=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,r.iterator()];case 1:return[2,e.sent().skip(t)]}})})},null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null)},t.prototype.shuffle=function(t,e,r){var n=this;if(void 0===r&&(r=!0),null==t||t<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)");var i=this,o=seedrandom_1(e||util.now().toString());return datasetFromIteratorFn(function(){return __awaiter(n,void 0,void 0,function(){var e;return __generator(this,function(n){switch(n.label){case 0:return e=o.int32(),r&&(e+=o.int32()),[4,i.iterator()];case 1:return[2,n.sent().shuffle(t,e.toString())]}})})},this.size)},t.prototype.take=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,r.iterator()];case 1:return[2,e.sent().take(t)]}})})},null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null)},t.prototype.toArray=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArray()]}})})},t.prototype.toArrayForTest=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArrayForTest()]}})})},t.MAX_BUFFER_SIZE=1e4,t}();function datasetFromIteratorFn(t,e){return void 0===e&&(e=null),new(function(r){function n(){var t=null!==r&&r.apply(this,arguments)||this;return t.size=e,t}return __extends(n,r),n.prototype.iterator=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,t()]})})},n}(Dataset))}function array(t){var e=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){return[2,iteratorFromItems(t)]})})},t.length)}function zip(t){var e,r=this;if(!isIterable(t))throw new Error("The argument to zip() must be an object or array.");if(Array.isArray(t))for(var n=0;n<t.length;n++)e=null==e?t[n].size:Math.min(e,t[n].size);else if(t instanceof Object)for(var i in t)e=null==e?t[i].size:Math.min(e,t[i].size);return datasetFromIteratorFn(function(){return __awaiter(r,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,deepMapAndAwaitAll(t,function(t){if(t instanceof Dataset)return{value:t.iterator(),recurse:!1};if(isIterable(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})];case 1:return[2,iteratorFromZipped(e.sent(),ZipMismatchMode.SHORTEST)]}})})},e)}function deepBatchConcat(t){return null===t?null:canTensorify(t[0])?{value:batchConcat(t),recurse:!1}:{value:null,recurse:!0}}function batchConcat(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof Tensor?stack(t):tensor(t)}var TextLineDataset=function(t){function e(e){var r=t.call(this)||this;return r.input=e,r}return __extends(e,t),e.prototype.iterator=function(){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(r){switch(r.label){case 0:return[4,this.input.iterator()];case 1:return t=r.sent(),e=t.decodeUTF8(),[2,e.split("\n").map(function(t){return t.endsWith("\r")&&(t=t.slice(0,-1)),t})]}})})},e}(Dataset),CODE_QUOTE='"',STATE_OUT=Symbol("out"),STATE_FIELD=Symbol("field"),STATE_QUOTE=Symbol("quote"),STATE_QUOTE_AFTER_QUOTE=Symbol("quoteafterquote"),STATE_WITHIN_QUOTE_IN_QUOTE=Symbol("quoteinquote"),CSVDataset=function(t){function e(e,r){var n=t.call(this)||this;return n.input=e,n.hasHeader=!0,n.fullColumnNames=null,n.columnNamesValidated=!1,n.columnConfigs=null,n.configuredColumnsOnly=!1,n.delimiter=",",n.delimWhitespace=!1,n.base=new TextLineDataset(e),r||(r={}),n.hasHeader=!1!==r.hasHeader,n.fullColumnNames=r.columnNames,n.columnConfigs=r.columnConfigs,n.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(util.assert(null==r.delimiter,function(){return"Delimiter should not be provided when delimWhitespace is true."}),n.delimWhitespace=!0,n.delimiter=" "):n.delimiter=r.delimiter?r.delimiter:",",n}return __extends(e,t),e.prototype.columnNames=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:t.sent(),t.label=2;case 2:return[2,this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames]}})})},e.prototype.setColumnNames=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n,i,o,a=this;return __generator(this,function(s){switch(s.label){case 0:return[4,this.maybeReadHeaderLine()];case 1:if(t=s.sent(),!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");if(this.fullColumnNames&&t&&util.assert(t.length===this.fullColumnNames.length,function(){return"The length of provided columnNames ("+a.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+")."}),this.fullColumnNames||(this.fullColumnNames=t),e=this.fullColumnNames.reduce(function(t,e){return t[e]=t[e]+1||1,t},{}),r=Object.keys(e).filter(function(t){return e[t]>1}),util.assert(0===r.length,function(){return"Duplicate column names found: "+r.toString()}),this.columnConfigs)for(n=0,i=Object.keys(this.columnConfigs);n<i.length;n++)if(o=i[n],-1===this.fullColumnNames.indexOf(o))throw new Error('The key "'+o+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").");return this.columnNamesValidated=!0,[2]}})})},e.prototype.maybeReadHeaderLine=function(){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(r){switch(r.label){case 0:return this.hasHeader?[4,this.base.iterator()]:[3,3];case 1:return[4,r.sent().next()];case 2:if((t=r.sent()).done)throw new Error("No data was found for CSV parsing.");return e=t.value,[2,this.parseRow(e,!1)];case 3:return[2,null]}})})},e.prototype.iterator=function(){return __awaiter(this,void 0,void 0,function(){var t,e=this;return __generator(this,function(r){switch(r.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:r.sent(),r.label=2;case 2:return[4,this.base.iterator()];case 3:return t=r.sent(),this.hasHeader&&(t=t.skip(1)),[2,t.map(function(t){return e.makeDataElement(t)})]}})})},e.prototype.makeDataElement=function(t){for(var e=this.parseRow(t),r={},n={},i=0;i<this.fullColumnNames.length;i++){var o=this.fullColumnNames[i],a=this.columnConfigs?this.columnConfigs[o]:null;if(!this.configuredColumnsOnly||a){var s=e[i],u=null;if(""===s)if(a&&void 0!==a.default)u=a.default;else{if(a&&(a.required||a.isLabel))throw new Error("Required column "+o+" is empty in this line: "+t);u=void 0}else{var c=Number(s);if(isNaN(c))u=a&&"bool"===a.dtype?this.getBoolean(s):s;else if(a&&a.dtype)switch(a.dtype){case"float32":u=c;break;case"int32":u=Math.floor(c);break;case"bool":u=this.getBoolean(s);break;default:u=c}else u=c}a&&a.isLabel?n[o]=u:r[o]=u}}return 0===Object.keys(n).length?r:{xs:r,ys:n}},e.prototype.getBoolean=function(t){return"1"===t||"true"===t.toLowerCase()?1:0},e.prototype.parseRow=function(t,e){void 0===e&&(e=!0);for(var r=[],n=0,i=t.length,o=STATE_OUT,a=0;a<i;a++)switch(o){case STATE_OUT:switch(t.charAt(a)){case CODE_QUOTE:n=a+1,o=STATE_QUOTE;break;case this.delimiter:if(n=a+1," "===this.delimiter&&this.delimWhitespace)break;r.push(""),o=STATE_OUT;break;default:o=STATE_FIELD,n=a}break;case STATE_FIELD:switch(t.charAt(a)){case this.delimiter:r.push(t.substring(n,a)),o=STATE_OUT,n=a+1}break;case STATE_QUOTE:switch(t.charAt(a)){case CODE_QUOTE:o=STATE_QUOTE_AFTER_QUOTE}break;case STATE_QUOTE_AFTER_QUOTE:switch(t.charAt(a)){case this.delimiter:r.push(t.substring(n,a-1)),o=STATE_OUT,n=a+1;break;case CODE_QUOTE:o=STATE_QUOTE;break;default:o=STATE_WITHIN_QUOTE_IN_QUOTE}break;case STATE_WITHIN_QUOTE_IN_QUOTE:switch(t.charAt(a)){case CODE_QUOTE:o=STATE_QUOTE}}if(o===STATE_QUOTE_AFTER_QUOTE?r.push(t.substring(n,i-1)):r.push(t.substring(n)),e&&r.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have "+this.fullColumnNames.length+" elements in a row, but got "+r);return r},e}(Dataset),MicrophoneIterator=function(t){function e(e){var r=t.call(this)||this;r.microphoneConfig=e,r.isClosed=!1,r.fftSize=e.fftSize||1024;var n=Math.log2(r.fftSize);if(r.fftSize<0||n<4||n>14||!Number.isInteger(n))throw new Error("Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got "+r.fftSize);if(r.numFrames=e.numFramesPerSpectrogram||43,r.sampleRateHz=e.sampleRateHz,r.columnTruncateLength=e.columnTruncateLength||r.fftSize,r.audioTrackConstraints=e.audioTrackConstraints,r.smoothingTimeConstant=e.smoothingTimeConstant||0,r.includeSpectrogram=!1!==e.includeSpectrogram,r.includeWaveform=!0===e.includeWaveform,!r.includeSpectrogram&&!r.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return r}return __extends(e,t),e.prototype.summary=function(){return"microphone"},e.create=function(t){return void 0===t&&(t={}),__awaiter(this,void 0,void 0,function(){var r;return __generator(this,function(n){switch(n.label){case 0:if(ENV.get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");return[4,(r=new e(t)).start()];case 1:return n.sent(),[2,r]}})})},e.prototype.start=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n;return __generator(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=this,[4,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})];case 1:return t.stream=i.sent(),[3,3];case 2:throw e=i.sent(),new Error("Error thrown while initializing video stream: "+e.message);case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(r=window.AudioContext||window.webkitAudioContext,this.audioContext=new r,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;return n=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,n.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2]}})})},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n,i;return __generator(this,function(o){switch(o.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return r=o.sent(),this.includeSpectrogram&&(n=this.flattenQueue(r.freqDataQueue),t=this.getTensorFromAudioDataArray(n,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(r.timeDataQueue),e=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:t,waveform:e},done:!1}]}})})},e.prototype.capture=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}})})},e.prototype.getAudioData=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n=this;return __generator(this,function(i){return t=[],e=[],r=0,[2,new Promise(function(i){var o=setInterval(function(){n.includeSpectrogram&&(n.analyser.getFloatFrequencyData(n.freqData),n.freqData[0]===-1/0&&i({freqDataQueue:t,timeDataQueue:e}),t.push(n.freqData.slice(0,n.columnTruncateLength))),n.includeWaveform&&(n.analyser.getFloatTimeDomainData(n.timeData),e.push(n.timeData.slice())),++r===n.numFrames&&(clearInterval(o),i({freqDataQueue:t,timeDataQueue:e}))},n.fftSize/n.sampleRateHz*1e3)})]})})},e.prototype.stop=function(){this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop()},e.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},e.prototype.getSampleRate=function(){return this.sampleRateHz},e.prototype.flattenQueue=function(t){var e=t[0].length,r=new Float32Array(t.length*e);return t.forEach(function(t,n){return r.set(t,n*e)}),r},e.prototype.getTensorFromAudioDataArray=function(t,e){var r=new Float32Array(util.sizeFromShape(e));return r.set(t,r.length-t.length),tensor(r,e)},e}(LazyIterator),WebcamIterator=function(t){function e(e,r){var n=t.call(this)||this;if(n.webcamVideoElement=e,n.webcamConfig=r,n.isClosed=!0,n.resize=!1,n.needToResize())if(n.resize=!0,n.cropSize=[n.webcamConfig.resizeHeight,n.webcamConfig.resizeWidth],n.cropBoxInd=tensor1d([0],"int32"),n.webcamConfig.centerCrop){var i=1*n.webcamConfig.resizeWidth/n.webcamVideoElement.width,o=1*n.webcamConfig.resizeHeight/n.webcamVideoElement.height,a=(1-i)/2,s=(1-o)/2,u=a+i,c=o+s;n.cropBox=tensor2d([s,a,c,u],[1,4])}else n.cropBox=tensor2d([0,0,1,1],[1,4]);return n}return __extends(e,t),e.prototype.summary=function(){return"webcam"},e.create=function(t,r){return void 0===r&&(r={}),__awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(i){switch(i.label){case 0:if(ENV.get("IS_NODE"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!r.resizeWidth||!r.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=r.resizeWidth,t.height=r.resizeHeight}return[4,(n=new e(t,r)).start()];case 1:return i.sent(),[2,n]}})})},e.prototype.start=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r=this;return __generator(this,function(n){switch(n.label){case 0:this.webcamConfig.facingMode&&util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,function(){return"Invalid webcam facing mode: "+r.webcamConfig.facingMode+". Please provide 'user' or 'environment'"}),n.label=1;case 1:return n.trys.push([1,3,,4]),t=this,[4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})];case 2:return t.stream=n.sent(),[3,4];case 3:throw(e=n.sent()).message="Error thrown while initializing video stream: "+e.message,e;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise(function(t){r.webcamVideoElement.onloadedmetadata=function(){t()}})]}})})},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){if(this.isClosed)return[2,{value:null,done:!0}];try{t=browser.fromPixels(this.webcamVideoElement)}catch(t){throw new Error("Error thrown converting video to pixels: "+JSON.stringify(t))}if(!this.resize)return[2,{value:t,done:!1}];try{return[2,{value:this.cropAndResizeFrame(t),done:!1}]}catch(t){throw new Error("Error thrown cropping the video: "+t.message)}finally{t.dispose()}return[2]})})},e.prototype.needToResize=function(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)},e.prototype.cropAndResizeFrame=function(t){var e=this;return tidy(function(){var r,n=t.toFloat().expandDims(0),i=(r=image.cropAndResize(n,e.cropBox,e.cropBoxInd,e.cropSize,"bilinear")).shape;return r.reshape(i.slice(1))})},e.prototype.capture=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}})})},e.prototype.stop=function(){this.stream.getTracks().forEach(function(t){return t.stop()});try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0},e.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},e}(LazyIterator),DataSource=function(){return function(){}}(),StringIterator=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.split=function(t){return new SplitIterator(this,t)},e}(LazyIterator),SplitIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.impl=new SplitIteratorImpl(e,r),n}return __extends(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2,this.impl.next()]})})},e}(StringIterator),SplitIteratorImpl=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.separator=r,n.carryover="",n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')"},e.prototype.pump=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n,i;return __generator(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return""===this.carryover?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);for((e=t.value.split(this.separator))[0]=this.carryover+e[0],r=0,n=e.slice(0,-1);r<n.length;r++)i=n[r],this.outputQueue.push(i);return this.carryover=e[e.length-1],[2,!0]}})})},e}(OneToManyIterator),ByteChunkIterator=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.decodeUTF8=function(){return new Utf8Iterator(this)},e}(LazyIterator),Utf8Iterator=function(t){function e(e){var r=t.call(this)||this;return r.upstream=e,r.impl=new Utf8IteratorImpl(e),r}return __extends(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2,this.impl.next()]})})},e}(StringIterator),Utf8IteratorImpl=function(t){function e(e){var r=t.call(this)||this;if(r.upstream=e,ENV.get("IS_BROWSER"))r.decoder=new TextDecoder("utf-8");else{var n=require("string_decoder").StringDecoder;r.decoder=new n("utf8")}return r}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Utf8"},e.prototype.pump=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r;return __generator(this,function(n){switch(n.label){case 0:return[4,this.upstream.next()];case 1:return(t=n.sent()).done?[2,!1]:(e=t.value,r=ENV.get("IS_BROWSER")?this.decoder.decode(e,{stream:!0}):this.decoder.write(Buffer.from(e.buffer)),this.outputQueue.push(r),[2,!0])}})})},e}(OneToManyIterator),FileChunkIterator=function(t){function e(e,r){void 0===r&&(r={});var n=t.call(this)||this;return n.file=e,n.options=r,util.assert(e instanceof Uint8Array||!!ENV.get("IS_BROWSER")&&(e instanceof File||e instanceof Blob),function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."}),n.offset=r.offset||0,n.chunkSize=r.chunkSize||1048576,n}return __extends(e,t),e.prototype.summary=function(){return"FileChunks "+this.file},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r=this;return __generator(this,function(n){switch(n.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(t=new Promise(function(t,e){var n=r.offset+r.chunkSize;if(r.file instanceof Uint8Array)t(new Uint8Array(r.file.slice(r.offset,n)));else{var i=new FileReader;i.onload=function(r){var n=i.result;if(n instanceof ArrayBuffer&&(n=new Uint8Array(n)),!(n instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(n)},i.onabort=function(t){return e(new Error("Aborted"))},i.onerror=function(t){return e(new Error(t.type))};var o=r.file.slice(r.offset,n);i.readAsArrayBuffer(o)}r.offset=n}),e={},[4,t]);case 1:return[2,(e.value=n.sent(),e.done=!1,e)]}})})},e}(ByteChunkIterator);function urlChunkIterator(t,e){return void 0===e&&(e={}),__awaiter(this,void 0,void 0,function(){var r,n,i,o,a;return __generator(this,function(s){switch(s.label){case 0:return"string"==typeof t?r=t:(r=t.url,n=getRequestInitFromRequest(t)),[4,util.fetch(r,n)];case 1:return(i=s.sent()).ok?(a=Uint8Array.bind,[4,i.arrayBuffer()]):[3,3];case 2:return o=new(a.apply(Uint8Array,[void 0,s.sent()])),[2,new FileChunkIterator(o,e)];case 3:throw new Error(i.statusText)}})})}var getRequestInitFromRequest=function(t){return{method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity}};function isLocalPath(t){return"string"==typeof t&&"file://"===t.substr(0,7)}var FileDataSource=function(t){function e(e,r){void 0===r&&(r={});var n=t.call(this)||this;return n.input=e,n.options=r,n}return __extends(e,t),e.prototype.iterator=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){return isLocalPath(this.input)&&ENV.get("IS_NODE")&&(t=require("fs"),this.input=t.readFileSync(this.input.substr(7))),[2,new FileChunkIterator(this.input,this.options)]})})},e}(DataSource),URLDataSource=function(t){function e(e,r){void 0===r&&(r={});var n=t.call(this)||this;return n.url=e,n.fileOptions=r,n}return __extends(e,t),e.prototype.iterator=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return isLocalPath(this.url)?[2,new FileDataSource(this.url,this.fileOptions).iterator()]:[2,urlChunkIterator(this.url,this.fileOptions)]})})},e}(DataSource);function csv(t,e){return void 0===e&&(e={}),new CSVDataset(new URLDataSource(t),e)}function func(t){var e=this,r=iteratorFromFunction(t);return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(t){return[2,r]})})})}function generator(t){var e=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){var e;return __generator(this,function(r){switch(r.label){case 0:return[4,t()];case 1:return e=r.sent(),[2,iteratorFromFunction(function(){return e.next()})]}})})})}function webcam(t,e){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(r){return[2,WebcamIterator.create(t,e)]})})}function microphone(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,MicrophoneIterator.create(t)]})})}var version="1.2.8";export{array,Dataset,zip,CSVDataset,TextLineDataset,csv,func,generator,microphone,webcam,FileDataSource,URLDataSource,version as version_data};
import{util,tidy,deprecationWarn,Tensor,stack,tensor,ENV,dispose,tensor_util,tensor1d,tensor2d,browser,image}from"@tensorflow/tfjs-core";var extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function __extends(t,e){function r(){this.constructor=t}extendStatics(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function __awaiter(t,e,r,n){return new(r||(r=Promise))(function(i,o){function a(t){try{u(n.next(t))}catch(t){o(t)}}function s(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){t.done?i(t.value):new r(function(e){e(t.value)}).then(a,s)}u((n=n.apply(t,e||[])).next())})}function __generator(t,e){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e){return t(e={exports:{}},e.exports),e.exports}var alea=createCommonjsModule(function(t){!function(t,e,r){function n(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function i(t,e){var r=new function(t){var e,r=this,n=(e=4022871197,function(t){t=t.toString();for(var r=0;r<t.length;r++){var n=.02519603282416938*(e+=t.charCodeAt(r));n-=e=n>>>0,e=(n*=e)>>>0,e+=4294967296*(n-=e)}return 2.3283064365386963e-10*(e>>>0)});r.next=function(){var t=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=t-(r.c=0|t)},r.c=1,r.s0=n(" "),r.s1=n(" "),r.s2=n(" "),r.s0-=n(t),r.s0<0&&(r.s0+=1),r.s1-=n(t),r.s1<0&&(r.s1+=1),r.s2-=n(t),r.s2<0&&(r.s2+=1),n=null}(t),i=e&&e.state,o=r.next;return o.int32=function(){return 4294967296*r.next()|0},o.double=function(){return o()+1.1102230246251565e-16*(2097152*o()|0)},o.quick=o,i&&("object"==typeof i&&n(i,r),o.state=function(){return n(r,{})}),o}e&&e.exports?e.exports=i:r&&r.amd?r(function(){return i}):this.alea=i}(0,t,!1)}),xor128=createCommonjsModule(function(t){!function(t,e,r){function n(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function i(t,e){var r=new function(t){var e=this,r="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:r+=t;for(var n=0;n<r.length+64;n++)e.x^=0|r.charCodeAt(n),e.next()}(t),i=e&&e.state,o=function(){return(r.next()>>>0)/4294967296};return o.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=r.next,o.quick=o,i&&("object"==typeof i&&n(i,r),o.state=function(){return n(r,{})}),o}e&&e.exports?e.exports=i:r&&r.amd?r(function(){return i}):this.xor128=i}(0,t,!1)}),xorwow=createCommonjsModule(function(t){!function(t,e,r){function n(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function i(t,e){var r=new function(t){var e=this,r="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:r+=t;for(var n=0;n<r.length+64;n++)e.x^=0|r.charCodeAt(n),n==r.length&&(e.d=e.x<<10^e.x>>>4),e.next()}(t),i=e&&e.state,o=function(){return(r.next()>>>0)/4294967296};return o.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=r.next,o.quick=o,i&&("object"==typeof i&&n(i,r),o.state=function(){return n(r,{})}),o}e&&e.exports?e.exports=i:r&&r.amd?r(function(){return i}):this.xorwow=i}(0,t,!1)}),xorshift7=createCommonjsModule(function(t){!function(t,e,r){function n(t,e){return e.x=t.x.slice(),e.i=t.i,e}function i(t,e){null==t&&(t=+new Date);var r=new function(t){var e=this;e.next=function(){var t,r,n=e.x,i=e.i;return t=n[i],r=(t^=t>>>7)^t<<24,r^=(t=n[i+1&7])^t>>>10,r^=(t=n[i+3&7])^t>>>3,r^=(t=n[i+4&7])^t<<7,t=n[i+7&7],r^=(t^=t<<13)^t<<9,n[i]=r,e.i=i+1&7,r},function(t,e){var r,n=[];if(e===(0|e))n[0]=e;else for(e=""+e,r=0;r<e.length;++r)n[7&r]=n[7&r]<<15^e.charCodeAt(r)+n[r+1&7]<<13;for(;n.length<8;)n.push(0);for(r=0;r<8&&0===n[r];++r);for(8==r?n[7]=-1:n[r],t.x=n,t.i=0,r=256;r>0;--r)t.next()}(e,t)}(t),i=e&&e.state,o=function(){return(r.next()>>>0)/4294967296};return o.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=r.next,o.quick=o,i&&(i.x&&n(i,r),o.state=function(){return n(r,{})}),o}e&&e.exports?e.exports=i:r&&r.amd?r(function(){return i}):this.xorshift7=i}(0,t,!1)}),xor4096=createCommonjsModule(function(t){!function(t,e,r){function n(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function i(t,e){null==t&&(t=+new Date);var r=new function(t){var e=this;e.next=function(){var t,r,n=e.w,i=e.X,o=e.i;return e.w=n=n+1640531527|0,r=i[o+34&127],t=i[o=o+1&127],r^=r<<13,t^=t<<17,r^=r>>>15,t^=t>>>12,r=i[o]=r^t,e.i=o,r+(n^n>>>16)|0},function(t,e){var r,n,i,o,a,s=[],u=128;for(e===(0|e)?(n=e,e=null):(e+="\0",n=0,u=Math.max(u,e.length)),i=0,o=-32;o<u;++o)e&&(n^=e.charCodeAt((o+32)%e.length)),0===o&&(a=n),n^=n<<10,n^=n>>>15,n^=n<<4,n^=n>>>13,o>=0&&(a=a+1640531527|0,i=0==(r=s[127&o]^=n+a)?i+1:0);for(i>=128&&(s[127&(e&&e.length||0)]=-1),i=127,o=512;o>0;--o)n=s[i+34&127],r=s[i=i+1&127],n^=n<<13,r^=r<<17,n^=n>>>15,r^=r>>>12,s[i]=n^r;t.w=a,t.X=s,t.i=i}(e,t)}(t),i=e&&e.state,o=function(){return(r.next()>>>0)/4294967296};return o.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=r.next,o.quick=o,i&&(i.X&&n(i,r),o.state=function(){return n(r,{})}),o}e&&e.exports?e.exports=i:r&&r.amd?r(function(){return i}):this.xor4096=i}(0,t,!1)}),tychei=createCommonjsModule(function(t){!function(t,e,r){function n(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function i(t,e){var r=new function(t){var e=this,r="";e.next=function(){var t=e.b,r=e.c,n=e.d,i=e.a;return t=t<<25^t>>>7^r,r=r-n|0,n=n<<24^n>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^r,e.c=r=r-n|0,e.d=n<<16^r>>>16^i,e.a=i-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):r+=t;for(var n=0;n<r.length+20;n++)e.b^=0|r.charCodeAt(n),e.next()}(t),i=e&&e.state,o=function(){return(r.next()>>>0)/4294967296};return o.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=r.next,o.quick=o,i&&("object"==typeof i&&n(i,r),o.state=function(){return n(r,{})}),o}e&&e.exports?e.exports=i:r&&r.amd?r(function(){return i}):this.tychei=i}(0,t,!1)}),seedrandom=createCommonjsModule(function(t){!function(e,r){var n,i=this,o=256,a=6,s="random",u=r.pow(o,a),c=r.pow(2,52),l=2*c,h=o-1;function f(t,f,v){var _=[],w=p(function t(e,r){var n,i=[],o=typeof e;if(r&&"object"==o)for(n in e)try{i.push(t(e[n],r-1))}catch(t){}return i.length?i:"string"==o?e:e+"\0"}((f=1==f?{entropy:!0}:f||{}).entropy?[t,m(e)]:null==t?function(){try{var t;return n&&(t=n.randomBytes)?t=t(o):(t=new Uint8Array(o),(i.crypto||i.msCrypto).getRandomValues(t)),m(t)}catch(t){var r=i.navigator,a=r&&r.plugins;return[+new Date,i,a,i.screen,m(e)]}}():t,3),_),y=new function(t){var e,r=t.length,n=this,i=0,a=n.i=n.j=0,s=n.S=[];r||(t=[r++]);for(;i<o;)s[i]=i++;for(i=0;i<o;i++)s[i]=s[a=h&a+t[i%r]+(e=s[i])],s[a]=e;(n.g=function(t){for(var e,r=0,i=n.i,a=n.j,s=n.S;t--;)e=s[i=h&i+1],r=r*o+s[h&(s[i]=s[a=h&a+e])+(s[a]=e)];return n.i=i,n.j=a,r})(o)}(_),g=function(){for(var t=y.g(a),e=u,r=0;t<c;)t=(t+r)*o,e*=o,r=y.g(1);for(;t>=l;)t/=2,e/=2,r>>>=1;return(t+r)/e};return g.int32=function(){return 0|y.g(4)},g.quick=function(){return y.g(4)/4294967296},g.double=g,p(m(y.S),e),(f.pass||v||function(t,e,n,i){return i&&(i.S&&d(i,y),t.state=function(){return d(y,{})}),n?(r[s]=t,e):t})(g,w,"global"in f?f.global:this==r,f.state)}function d(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function p(t,e){for(var r,n=t+"",i=0;i<n.length;)e[h&i]=h&(r^=19*e[h&i])+n.charCodeAt(i++);return m(e)}function m(t){return String.fromCharCode.apply(0,t)}if(r["seed"+s]=f,p(r.random(),e),t.exports){t.exports=f;try{n=require("crypto")}catch(t){}}else 0}([],Math)});seedrandom.alea=alea,seedrandom.xor128=xor128,seedrandom.xorwow=xorwow,seedrandom.xorshift7=xorshift7,seedrandom.xor4096=xor4096,seedrandom.tychei=tychei;var seedrandom$1=seedrandom,seedrandom_1=seedrandom$1.alea;function deepMap(t,e){return deepMapInternal(t,e)}function deepMapInternal(t,e,r,n){if(void 0===r&&(r=new Map),void 0===n&&(n=new Set),null==t)return null;if(n.has(t))throw new Error("Circular references are not supported.");if(r.has(t))return r.get(t);var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(i.recurse){if(isIterable(t)){var o=Array.isArray(t)?[]:{};for(var a in n.add(t),t){var s=deepMapInternal(t[a],e,r,n);o[a]=s}return n.delete(t),o}throw new Error("Can't recurse into non-iterable type: "+t)}return r.set(t,i.value),i.value}function deepZip(t,e){return void 0===e&&(e=zipToList),deepZipInternal(t,e)}function deepZipInternal(t,e,r){void 0===r&&(r=new Set);var n=t[0];if(r.has(n))throw new Error("Circular references are not supported.");var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(i.recurse){if(isIterable(n)){var o=Array.isArray(n)?[]:{};r.add(n);var a=function(n){var i=deepZipInternal(t.map(function(t){return t[n]}),e,r);o[n]=i};for(var s in n)a(s);return r.delete(n),o}throw new Error("Can't recurse into non-iterable type: "+n)}return i.value}function zipToList(t){return null===t?null:isIterable(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}function deepMapAndAwaitAll(t,e){return __awaiter(this,void 0,void 0,function(){var r,n,i,o,a,s;return __generator(this,function(u){switch(u.label){case 0:r=new Map,deepMapInternal(t,e,r),n=0,i=Array.from(r.keys()),u.label=1;case 1:return n<i.length?(o=i[n],(a=r.get(o))instanceof Promise?[4,a]:[3,3]):[3,4];case 2:s=u.sent(),r.set(o,s),u.label=3;case 3:return n++,[3,1];case 4:return[2,deepMapInternal(t,e,r)]}})})}function isIterable(t){return null!=t&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof Tensor))}function canTensorify(t){return null==t||isPrimitive(t)||Array.isArray(t)||"object"==typeof t&&t instanceof Tensor||util.isTypedArray(t)}function isPrimitive(t){return null===t||"object"!=typeof t&&"function"!=typeof t}function deepClone(t){return deepMap(t,cloneIfTensor)}function cloneIfTensor(t){return t instanceof Tensor?{value:t.clone(),recurse:!1}:isIterable(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}var RingBuffer=function(){function t(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}return t.prototype.wrap=function(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity},t.prototype.get=function(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]},t.prototype.set=function(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e},t.prototype.length=function(){var t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t},t.prototype.isFull=function(){return this.length()===this.capacity},t.prototype.isEmpty=function(){return 0===this.length()},t.prototype.push=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)},t.prototype.pushAll=function(t){for(var e=0,r=t;e<r.length;e++){var n=r[e];this.push(n)}},t.prototype.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var t=this.get(this.end);return this.set(this.end,void 0),t},t.prototype.unshift=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)},t.prototype.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t},t.prototype.shuffleExcise=function(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.wrap(this.begin+t),r=this.get(e);return this.set(e,this.pop()),r},t}(),GrowingRingBuffer=function(t){function e(){return t.call(this,e.INITIAL_CAPACITY)||this}return __extends(e,t),e.prototype.isFull=function(){return!1},e.prototype.push=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.push.call(this,e)},e.prototype.unshift=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.unshift.call(this,e)},e.prototype.expand=function(){for(var t=2*this.capacity,e=new Array(t),r=this.length(),n=0;n<r;n++)e[n]=this.get(this.wrap(this.begin+n));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=r},e.INITIAL_CAPACITY=32,e}(RingBuffer);function iteratorFromItems(t){return new ArrayIterator(t)}function iteratorFromFunction(t){return new FunctionCallIterator(t)}function iteratorFromConcatenated(t,e){return new ChainedIterator(t,e)}function iteratorFromZipped(t,e){return void 0===e&&(e=ZipMismatchMode.FAIL),new ZipIterator(t,e)}var ZipMismatchMode,LazyIterator=function(){function t(){}return t.prototype.toArray=function(){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(r){switch(r.label){case 0:return t=[],[4,this.next()];case 1:e=r.sent(),r.label=2;case 2:return e.done?[3,4]:(t.push(e.value),[4,this.next()]);case 3:return e=r.sent(),[3,2];case 4:return[2,t]}})})},t.prototype.toArrayForTest=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r;return __generator(this,function(n){switch(n.label){case 0:return t=this.prefetch(100),e=[],[4,t.next()];case 1:r=n.sent(),n.label=2;case 2:return r.done?[3,4]:(e.push(r.value),[4,t.next()]);case 3:return r=n.sent(),[3,2];case 4:return[2,e]}})})},t.prototype.resolveFully=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,this.next()];case 1:t=e.sent(),e.label=2;case 2:return t.done?[3,4]:[4,this.next()];case 3:return t=e.sent(),[3,2];case 4:return[2]}})})},t.prototype.resolveWhile=function(t){return __awaiter(this,void 0,void 0,function(){var e,r;return __generator(this,function(n){switch(n.label){case 0:return[4,this.next()];case 1:e=n.sent(),r=t(e.value),n.label=2;case 2:return e.done||!r?[3,4]:[4,this.next()];case 3:return e=n.sent(),r=t(e.value),[3,2];case 4:return[2]}})})},t.prototype.handleErrors=function(t){return new ErrorHandlingLazyIterator(this,t)},t.prototype.filter=function(t){return new FilterIterator(this,t)},t.prototype.map=function(t){return new MapIterator(this,t)},t.prototype.mapAsync=function(t){return new AsyncMapIterator(this,t)},t.prototype.serialMapAsync=function(t){return new AsyncMapIterator(this,t).serial()},t.prototype.flatmap=function(t){return new FlatmapIterator(this,t)},t.prototype.forEachAsync=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,this.map(t).resolveFully()]})})},t.prototype.serialForEach=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,this.serialMapAsync(t).resolveWhile(function(t){return!0===t})]})})},t.prototype.rowMajorBatch=function(t,e){return void 0===e&&(e=!0),new RowMajorBatchIterator(this,t,e)},t.prototype.columnMajorBatch=function(t,e,r){return void 0===e&&(e=!0),void 0===r&&(r=zipToList),this.rowMajorBatch(t,e).map(function(t){return deepZip(t,r)})},t.prototype.concatenate=function(t,e){return new ChainedIterator(iteratorFromItems([this,t]),e)},t.prototype.take=function(t){return t<0||null==t?this:new TakeIterator(this,t)},t.prototype.skip=function(t){return t<0||null==t?this:new SkipIterator(this,t)},t.prototype.prefetch=function(t){return new PrefetchIterator(this,t)},t.prototype.shuffle=function(t,e){return new ShuffleIterator(this,t,e)},t.prototype.serial=function(){return new SerialIterator(this)},t}(),ArrayIterator=function(t){function e(e){var r=t.call(this)||this;return r.items=e,r.trav=0,r}return __extends(e,t),e.prototype.summary=function(){return"Array of "+this.items.length+" items"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){return this.trav>=this.items.length?[2,{value:null,done:!0}]:(t=this.items[this.trav],this.trav++,[2,{value:deepClone(t),done:!1}])})})},e}(LazyIterator),FunctionCallIterator=function(t){function e(e){var r=t.call(this)||this;return r.nextFn=e,r}return __extends(e,t),e.prototype.summary=function(){return"Function call"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){try{return[2,this.nextFn()]}catch(t){throw t.message="Error thrown while iterating through a dataset: "+t.message,t}return[2]})})},e}(LazyIterator),SerialIterator=function(t){function e(e){var r=t.call(this)||this;return r.upstream=e,r.lastRead=Promise.resolve({value:null,done:!1}),r}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Serial"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2,this.upstream.next()]})})},e}(LazyIterator),SkipIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.maxCount=r,n.count=0,n.lastRead=Promise.resolve({value:null,done:!1}),n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Skip"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return this.count++<this.maxCount?[4,this.upstream.next()]:[3,2];case 1:return(t=e.sent()).done?[2,t]:(dispose(t.value),[3,0]);case 2:return[2,this.upstream.next()]}})})},e}(LazyIterator),TakeIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.maxCount=r,n.count=0,n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Take"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]})})},e}(LazyIterator),RowMajorBatchIterator=function(t){function e(e,r,n){void 0===n&&(n=!0);var i=t.call(this)||this;return i.upstream=e,i.batchSize=r,i.enableSmallLastBatch=n,i.lastRead=Promise.resolve({value:null,done:!1}),i}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> RowMajorBatch"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(r){switch(r.label){case 0:t=[],r.label=1;case 1:return t.length<this.batchSize?[4,this.upstream.next()]:[3,3];case 2:return(e=r.sent()).done?this.enableSmallLastBatch&&t.length>0?[2,{value:t,done:!1}]:[2,{value:null,done:!0}]:(t.push(e.value),[3,1]);case 3:return[2,{value:t,done:!1}]}})})},e}(LazyIterator),FilterIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.predicate=r,n.lastRead=Promise.resolve({value:null,done:!1}),n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Filter"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,this.upstream.next()];case 1:return(t=e.sent()).done||this.predicate(t.value)?[2,t]:(dispose(t.value),[3,0]);case 2:return[2]}})})},e}(LazyIterator),MapIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.transform=r,n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Map"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n,i,o,a;return __generator(this,function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return[2,{value:null,done:!0}];for(e=tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),n=tensor_util.getTensorsInContainer(r),i=0,o=e;i<o.length;i++)a=o[i],tensor_util.isTensorInList(a,n)||a.dispose();return[2,{value:r,done:!1}]}})})},e}(LazyIterator),ErrorHandlingLazyIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.handler=r,n.count=0,n.lastRead=Promise.resolve({value:null,done:!1}),n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> handleErrors"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,e.sent()];case 3:return t=e.sent(),this.handler(t)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}})})},e}(LazyIterator),AsyncMapIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.transform=r,n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> AsyncMap"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n,i,o,a;return __generator(this,function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:return(t=s.sent()).done?[2,{value:null,done:!0}]:(e=tensor_util.getTensorsInContainer(t.value),[4,this.transform(t.value)]);case 2:for(r=s.sent(),n=tensor_util.getTensorsInContainer(r),i=0,o=e;i<o.length;i++)a=o[i],tensor_util.isTensorInList(a,n)||a.dispose();return[2,{value:r,done:!1}]}})})},e}(LazyIterator),OneToManyIterator=function(t){function e(){var e=t.call(this)||this;return e.outputQueue=new GrowingRingBuffer,e.lastRead=Promise.resolve({value:null,done:!1}),e}return __extends(e,t),e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return 0!==this.outputQueue.length()?[3,2]:[4,this.pump()];case 1:return t.sent()?[3,0]:[2,{value:null,done:!0}];case 2:return[2,{value:this.outputQueue.shift(),done:!1}]}})})},e}(LazyIterator),FlatmapIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.transform=r,n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Flatmap"},e.prototype.pump=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n,i,o,a;return __generator(this,function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return[2,!1];for(e=tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),n=tensor_util.getTensorsInContainer(r),this.outputQueue.pushAll(r),i=0,o=e;i<o.length;i++)a=o[i],tensor_util.isTensorInList(a,n)||a.dispose();return[2,!0]}})})},e}(OneToManyIterator),ChainedIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.baseErrorHandler=r,n.lastRead=null,n.iterator=null,n.moreIterators=e,n}return __extends(e,t),e.prototype.summary=function(){return"TODO: fill in upstream of chained summaries -> Chained"},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]})})},e.prototype.readFromChain=function(t){return __awaiter(this,void 0,void 0,function(){var e,r;return __generator(this,function(n){switch(n.label){case 0:return[4,t];case 1:return n.sent(),null!=this.iterator?[3,3]:[4,this.moreIterators.next()];case 2:if((e=n.sent()).done)return[2,{value:null,done:!0}];this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),n.label=3;case 3:return[4,this.iterator.next()];case 4:return(r=n.sent()).done?(this.iterator=null,[2,this.readFromChain(t)]):[2,r]}})})},e}(LazyIterator);!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(ZipMismatchMode||(ZipMismatchMode={}));var ZipIterator=function(t){function e(e,r){void 0===r&&(r=ZipMismatchMode.FAIL);var n=t.call(this)||this;return n.iterators=e,n.mismatchMode=r,n.count=0,n.currentPromise=null,n}return __extends(e,t),e.prototype.summary=function(){return"{TODO: fill in upstream of zip summaries} -> Zip"},e.prototype.nextState=function(t){return __awaiter(this,void 0,void 0,function(){function e(t){return t instanceof LazyIterator?{value:t.next().then(function(t){return r++,t.done&&n++,t.value}),recurse:!1}:{value:null,recurse:!0}}var r,n,i;return __generator(this,function(o){switch(o.label){case 0:return[4,t];case 1:return o.sent(),r=0,n=0,[4,deepMapAndAwaitAll(this.iterators,e)];case 2:if(i=o.sent(),r===n)return[2,{value:null,done:!0}];if(n>0)switch(this.mismatchMode){case ZipMismatchMode.FAIL:throw new Error("Zipped streams should have the same length. Mismatched at element "+this.count+".");case ZipMismatchMode.SHORTEST:return[2,{value:null,done:!0}];case ZipMismatchMode.LONGEST:}return this.count++,[2,{value:i,done:!1}]}})})},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return this.currentPromise=this.nextState(this.currentPromise),[2,this.currentPromise]})})},e}(LazyIterator),PrefetchIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.bufferSize=r,n.buffer=new RingBuffer(r),n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Prefetch"},e.prototype.refill=function(){for(;!this.buffer.isFull();){var t=this.upstream.next();this.buffer.push(t)}},e.prototype.next=function(){return this.refill(),this.buffer.shift()},e}(LazyIterator),ShuffleIterator=function(t){function e(e,r,n){var i=t.call(this,e,r)||this;return i.upstream=e,i.windowSize=r,i.upstreamExhausted=!1,i.random=seedrandom_1(n||util.now().toString()),i.lastRead=Promise.resolve({value:null,done:!1}),i}return __extends(e,t),e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.randomInt=function(t){return Math.floor(this.random()*t)},e.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},e.prototype.serialNext=function(){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(r){switch(r.label){case 0:this.upstreamExhausted||this.refill(),r.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(t=this.chooseIndex(),[4,this.buffer.shuffleExcise(t)]);case 2:return(e=r.sent()).done?(this.upstreamExhausted=!0,[3,1]):(this.refill(),[2,e]);case 3:return[2,{value:null,done:!0}]}})})},e}(PrefetchIterator),Dataset=function(){function t(){this.size=null}return t.prototype.batch=function(t,e){var r=this;void 0===e&&(e=!0);var n=this;return util.assert(t>0,function(){return"batchSize needs to be positive, but it is\n "+t}),datasetFromIteratorFn(function(){return __awaiter(r,void 0,void 0,function(){return __generator(this,function(r){switch(r.label){case 0:return[4,n.iterator()];case 1:return[2,r.sent().columnMajorBatch(t,e,deepBatchConcat)]}})})},this.size===1/0||null==this.size?this.size:e?Math.ceil(this.size/t):Math.floor(this.size/t))},t.prototype.concatenate=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){var e,n;return __generator(this,function(i){switch(i.label){case 0:return[4,r.iterator()];case 1:return n=(e=i.sent()).concatenate,[4,t.iterator()];case 2:return[2,n.apply(e,[i.sent()])]}})})},this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null)},t.prototype.filter=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,r.iterator()];case 1:return[2,e.sent().filter(function(e){return tidy(function(){return t(e)})})]}})})},this.size===1/0?1/0:null)},t.prototype.forEachAsync=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,this.iterator()];case 1:return[2,e.sent().forEachAsync(t)]}})})},t.prototype.forEach=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return deprecationWarn("dataset.forEach() is deprecated and will be removed. Please use dataset.forEachAsync() instead"),[2,this.forEachAsync(t)]})})},t.prototype.map=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,r.iterator()];case 1:return[2,e.sent().map(function(e){return tidy(function(){return t(e)})})]}})})},this.size)},t.prototype.mapAsync=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,r.iterator()];case 1:return[2,e.sent().mapAsync(t)]}})})},this.size)},t.prototype.prefetch=function(t){var e=this;if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,r.iterator()];case 1:return[2,e.sent().prefetch(t)]}})})},this.size)},t.prototype.repeat=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){var e=this;return __generator(this,function(n){return[2,iteratorFromConcatenated(iteratorFromFunction(function(){return __awaiter(e,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return t={},[4,r.iterator()];case 1:return[2,(t.value=e.sent(),t.done=!1,t)]}})})}).take(t))]})})},null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null)},t.prototype.skip=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,r.iterator()];case 1:return[2,e.sent().skip(t)]}})})},null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null)},t.prototype.shuffle=function(t,e,r){var n=this;if(void 0===r&&(r=!0),null==t||t<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)");var i=this,o=seedrandom_1(e||util.now().toString());return datasetFromIteratorFn(function(){return __awaiter(n,void 0,void 0,function(){var e;return __generator(this,function(n){switch(n.label){case 0:return e=o.int32(),r&&(e+=o.int32()),[4,i.iterator()];case 1:return[2,n.sent().shuffle(t,e.toString())]}})})},this.size)},t.prototype.take=function(t){var e=this,r=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,r.iterator()];case 1:return[2,e.sent().take(t)]}})})},null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null)},t.prototype.toArray=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArray()]}})})},t.prototype.toArrayForTest=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArrayForTest()]}})})},t.MAX_BUFFER_SIZE=1e4,t}();function datasetFromIteratorFn(t,e){return void 0===e&&(e=null),new(function(r){function n(){var t=null!==r&&r.apply(this,arguments)||this;return t.size=e,t}return __extends(n,r),n.prototype.iterator=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,t()]})})},n}(Dataset))}function array(t){var e=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){return[2,iteratorFromItems(t)]})})},t.length)}function zip(t){var e,r=this;if(!isIterable(t))throw new Error("The argument to zip() must be an object or array.");if(Array.isArray(t))for(var n=0;n<t.length;n++)e=null==e?t[n].size:Math.min(e,t[n].size);else if(t instanceof Object)for(var i in t)e=null==e?t[i].size:Math.min(e,t[i].size);return datasetFromIteratorFn(function(){return __awaiter(r,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,deepMapAndAwaitAll(t,function(t){if(t instanceof Dataset)return{value:t.iterator(),recurse:!1};if(isIterable(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})];case 1:return[2,iteratorFromZipped(e.sent(),ZipMismatchMode.SHORTEST)]}})})},e)}function deepBatchConcat(t){return null===t?null:canTensorify(t[0])?{value:batchConcat(t),recurse:!1}:{value:null,recurse:!0}}function batchConcat(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof Tensor?stack(t):tensor(t)}var TextLineDataset=function(t){function e(e){var r=t.call(this)||this;return r.input=e,r}return __extends(e,t),e.prototype.iterator=function(){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(r){switch(r.label){case 0:return[4,this.input.iterator()];case 1:return t=r.sent(),e=t.decodeUTF8(),[2,e.split("\n").map(function(t){return t.endsWith("\r")&&(t=t.slice(0,-1)),t})]}})})},e}(Dataset),CODE_QUOTE='"',STATE_OUT=Symbol("out"),STATE_FIELD=Symbol("field"),STATE_QUOTE=Symbol("quote"),STATE_QUOTE_AFTER_QUOTE=Symbol("quoteafterquote"),STATE_WITHIN_QUOTE_IN_QUOTE=Symbol("quoteinquote"),CSVDataset=function(t){function e(e,r){var n=t.call(this)||this;return n.input=e,n.hasHeader=!0,n.fullColumnNames=null,n.columnNamesValidated=!1,n.columnConfigs=null,n.configuredColumnsOnly=!1,n.delimiter=",",n.delimWhitespace=!1,n.base=new TextLineDataset(e),r||(r={}),n.hasHeader=!1!==r.hasHeader,n.fullColumnNames=r.columnNames,n.columnConfigs=r.columnConfigs,n.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(util.assert(null==r.delimiter,function(){return"Delimiter should not be provided when delimWhitespace is true."}),n.delimWhitespace=!0,n.delimiter=" "):n.delimiter=r.delimiter?r.delimiter:",",n}return __extends(e,t),e.prototype.columnNames=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:t.sent(),t.label=2;case 2:return[2,this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames]}})})},e.prototype.setColumnNames=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n,i,o,a=this;return __generator(this,function(s){switch(s.label){case 0:return[4,this.maybeReadHeaderLine()];case 1:if(t=s.sent(),!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");if(this.fullColumnNames&&t&&util.assert(t.length===this.fullColumnNames.length,function(){return"The length of provided columnNames ("+a.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+")."}),this.fullColumnNames||(this.fullColumnNames=t),e=this.fullColumnNames.reduce(function(t,e){return t[e]=t[e]+1||1,t},{}),r=Object.keys(e).filter(function(t){return e[t]>1}),util.assert(0===r.length,function(){return"Duplicate column names found: "+r.toString()}),this.columnConfigs)for(n=0,i=Object.keys(this.columnConfigs);n<i.length;n++)if(o=i[n],-1===this.fullColumnNames.indexOf(o))throw new Error('The key "'+o+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").");return this.columnNamesValidated=!0,[2]}})})},e.prototype.maybeReadHeaderLine=function(){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(r){switch(r.label){case 0:return this.hasHeader?[4,this.base.iterator()]:[3,3];case 1:return[4,r.sent().next()];case 2:if((t=r.sent()).done)throw new Error("No data was found for CSV parsing.");return e=t.value,[2,this.parseRow(e,!1)];case 3:return[2,null]}})})},e.prototype.iterator=function(){return __awaiter(this,void 0,void 0,function(){var t,e=this;return __generator(this,function(r){switch(r.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:r.sent(),r.label=2;case 2:return[4,this.base.iterator()];case 3:return t=r.sent(),this.hasHeader&&(t=t.skip(1)),[2,t.map(function(t){return e.makeDataElement(t)})]}})})},e.prototype.makeDataElement=function(t){for(var e=this.parseRow(t),r={},n={},i=0;i<this.fullColumnNames.length;i++){var o=this.fullColumnNames[i],a=this.columnConfigs?this.columnConfigs[o]:null;if(!this.configuredColumnsOnly||a){var s=e[i],u=null;if(""===s)if(a&&void 0!==a.default)u=a.default;else{if(a&&(a.required||a.isLabel))throw new Error("Required column "+o+" is empty in this line: "+t);u=void 0}else{var c=Number(s);if(isNaN(c))u=a&&"bool"===a.dtype?this.getBoolean(s):s;else if(a&&a.dtype)switch(a.dtype){case"float32":u=c;break;case"int32":u=Math.floor(c);break;case"bool":u=this.getBoolean(s);break;default:u=c}else u=c}a&&a.isLabel?n[o]=u:r[o]=u}}return 0===Object.keys(n).length?r:{xs:r,ys:n}},e.prototype.getBoolean=function(t){return"1"===t||"true"===t.toLowerCase()?1:0},e.prototype.parseRow=function(t,e){void 0===e&&(e=!0);for(var r=[],n=0,i=t.length,o=STATE_OUT,a=0;a<i;a++)switch(o){case STATE_OUT:switch(t.charAt(a)){case CODE_QUOTE:n=a+1,o=STATE_QUOTE;break;case this.delimiter:if(n=a+1," "===this.delimiter&&this.delimWhitespace)break;r.push(""),o=STATE_OUT;break;default:o=STATE_FIELD,n=a}break;case STATE_FIELD:switch(t.charAt(a)){case this.delimiter:r.push(t.substring(n,a)),o=STATE_OUT,n=a+1}break;case STATE_QUOTE:switch(t.charAt(a)){case CODE_QUOTE:o=STATE_QUOTE_AFTER_QUOTE}break;case STATE_QUOTE_AFTER_QUOTE:switch(t.charAt(a)){case this.delimiter:r.push(t.substring(n,a-1)),o=STATE_OUT,n=a+1;break;case CODE_QUOTE:o=STATE_QUOTE;break;default:o=STATE_WITHIN_QUOTE_IN_QUOTE}break;case STATE_WITHIN_QUOTE_IN_QUOTE:switch(t.charAt(a)){case CODE_QUOTE:o=STATE_QUOTE}}if(o===STATE_QUOTE_AFTER_QUOTE?r.push(t.substring(n,i-1)):r.push(t.substring(n)),e&&r.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have "+this.fullColumnNames.length+" elements in a row, but got "+r);return r},e}(Dataset),MicrophoneIterator=function(t){function e(e){var r=t.call(this)||this;r.microphoneConfig=e,r.isClosed=!1,r.fftSize=e.fftSize||1024;var n=Math.log2(r.fftSize);if(r.fftSize<0||n<4||n>14||!Number.isInteger(n))throw new Error("Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got "+r.fftSize);if(r.numFrames=e.numFramesPerSpectrogram||43,r.sampleRateHz=e.sampleRateHz,r.columnTruncateLength=e.columnTruncateLength||r.fftSize,r.audioTrackConstraints=e.audioTrackConstraints,r.smoothingTimeConstant=e.smoothingTimeConstant||0,r.includeSpectrogram=!1!==e.includeSpectrogram,r.includeWaveform=!0===e.includeWaveform,!r.includeSpectrogram&&!r.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return r}return __extends(e,t),e.prototype.summary=function(){return"microphone"},e.create=function(t){return void 0===t&&(t={}),__awaiter(this,void 0,void 0,function(){var r;return __generator(this,function(n){switch(n.label){case 0:if(ENV.get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");return[4,(r=new e(t)).start()];case 1:return n.sent(),[2,r]}})})},e.prototype.start=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n;return __generator(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=this,[4,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})];case 1:return t.stream=i.sent(),[3,3];case 2:throw e=i.sent(),new Error("Error thrown while initializing video stream: "+e.message);case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(r=window.AudioContext||window.webkitAudioContext,this.audioContext=new r,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;return n=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,n.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2]}})})},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n,i;return __generator(this,function(o){switch(o.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return r=o.sent(),this.includeSpectrogram&&(n=this.flattenQueue(r.freqDataQueue),t=this.getTensorFromAudioDataArray(n,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(r.timeDataQueue),e=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:t,waveform:e},done:!1}]}})})},e.prototype.capture=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}})})},e.prototype.getAudioData=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n=this;return __generator(this,function(i){return t=[],e=[],r=0,[2,new Promise(function(i){var o=setInterval(function(){n.includeSpectrogram&&(n.analyser.getFloatFrequencyData(n.freqData),n.freqData[0]===-1/0&&i({freqDataQueue:t,timeDataQueue:e}),t.push(n.freqData.slice(0,n.columnTruncateLength))),n.includeWaveform&&(n.analyser.getFloatTimeDomainData(n.timeData),e.push(n.timeData.slice())),++r===n.numFrames&&(clearInterval(o),i({freqDataQueue:t,timeDataQueue:e}))},n.fftSize/n.sampleRateHz*1e3)})]})})},e.prototype.stop=function(){this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop()},e.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},e.prototype.getSampleRate=function(){return this.sampleRateHz},e.prototype.flattenQueue=function(t){var e=t[0].length,r=new Float32Array(t.length*e);return t.forEach(function(t,n){return r.set(t,n*e)}),r},e.prototype.getTensorFromAudioDataArray=function(t,e){var r=new Float32Array(util.sizeFromShape(e));return r.set(t,r.length-t.length),tensor(r,e)},e}(LazyIterator),WebcamIterator=function(t){function e(e,r){var n=t.call(this)||this;if(n.webcamVideoElement=e,n.webcamConfig=r,n.isClosed=!0,n.resize=!1,n.needToResize())if(n.resize=!0,n.cropSize=[n.webcamConfig.resizeHeight,n.webcamConfig.resizeWidth],n.cropBoxInd=tensor1d([0],"int32"),n.webcamConfig.centerCrop){var i=1*n.webcamConfig.resizeWidth/n.webcamVideoElement.width,o=1*n.webcamConfig.resizeHeight/n.webcamVideoElement.height,a=(1-i)/2,s=(1-o)/2,u=a+i,c=o+s;n.cropBox=tensor2d([s,a,c,u],[1,4])}else n.cropBox=tensor2d([0,0,1,1],[1,4]);return n}return __extends(e,t),e.prototype.summary=function(){return"webcam"},e.create=function(t,r){return void 0===r&&(r={}),__awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(i){switch(i.label){case 0:if(ENV.get("IS_NODE"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!r.resizeWidth||!r.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=r.resizeWidth,t.height=r.resizeHeight}return[4,(n=new e(t,r)).start()];case 1:return i.sent(),[2,n]}})})},e.prototype.start=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r=this;return __generator(this,function(n){switch(n.label){case 0:this.webcamConfig.facingMode&&util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,function(){return"Invalid webcam facing mode: "+r.webcamConfig.facingMode+". Please provide 'user' or 'environment'"}),n.label=1;case 1:return n.trys.push([1,3,,4]),t=this,[4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})];case 2:return t.stream=n.sent(),[3,4];case 3:throw(e=n.sent()).message="Error thrown while initializing video stream: "+e.message,e;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise(function(t){r.webcamVideoElement.onloadedmetadata=function(){t()}})]}})})},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){if(this.isClosed)return[2,{value:null,done:!0}];try{t=browser.fromPixels(this.webcamVideoElement)}catch(t){throw new Error("Error thrown converting video to pixels: "+JSON.stringify(t))}if(!this.resize)return[2,{value:t,done:!1}];try{return[2,{value:this.cropAndResizeFrame(t),done:!1}]}catch(t){throw new Error("Error thrown cropping the video: "+t.message)}finally{t.dispose()}return[2]})})},e.prototype.needToResize=function(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)},e.prototype.cropAndResizeFrame=function(t){var e=this;return tidy(function(){var r,n=t.toFloat().expandDims(0),i=(r=image.cropAndResize(n,e.cropBox,e.cropBoxInd,e.cropSize,"bilinear")).shape;return r.reshape(i.slice(1))})},e.prototype.capture=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}})})},e.prototype.stop=function(){this.stream.getTracks().forEach(function(t){return t.stop()});try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0},e.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},e}(LazyIterator),DataSource=function(){return function(){}}(),StringIterator=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.split=function(t){return new SplitIterator(this,t)},e}(LazyIterator),SplitIterator=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.impl=new SplitIteratorImpl(e,r),n}return __extends(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2,this.impl.next()]})})},e}(StringIterator),SplitIteratorImpl=function(t){function e(e,r){var n=t.call(this)||this;return n.upstream=e,n.separator=r,n.carryover="",n}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')"},e.prototype.pump=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r,n,i;return __generator(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return""===this.carryover?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);for((e=t.value.split(this.separator))[0]=this.carryover+e[0],r=0,n=e.slice(0,-1);r<n.length;r++)i=n[r],this.outputQueue.push(i);return this.carryover=e[e.length-1],[2,!0]}})})},e}(OneToManyIterator),ByteChunkIterator=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.decodeUTF8=function(){return new Utf8Iterator(this)},e}(LazyIterator),Utf8Iterator=function(t){function e(e){var r=t.call(this)||this;return r.upstream=e,r.impl=new Utf8IteratorImpl(e),r}return __extends(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2,this.impl.next()]})})},e}(StringIterator),Utf8IteratorImpl=function(t){function e(e){var r=t.call(this)||this;if(r.upstream=e,ENV.get("IS_BROWSER"))r.decoder=new TextDecoder("utf-8");else{var n=require("string_decoder").StringDecoder;r.decoder=new n("utf8")}return r}return __extends(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Utf8"},e.prototype.pump=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r;return __generator(this,function(n){switch(n.label){case 0:return[4,this.upstream.next()];case 1:return(t=n.sent()).done?[2,!1]:(e=t.value,r=ENV.get("IS_BROWSER")?this.decoder.decode(e,{stream:!0}):this.decoder.write(Buffer.from(e.buffer)),this.outputQueue.push(r),[2,!0])}})})},e}(OneToManyIterator),FileChunkIterator=function(t){function e(e,r){void 0===r&&(r={});var n=t.call(this)||this;return n.file=e,n.options=r,util.assert(e instanceof Uint8Array||!!ENV.get("IS_BROWSER")&&(e instanceof File||e instanceof Blob),function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."}),n.offset=r.offset||0,n.chunkSize=r.chunkSize||1048576,n}return __extends(e,t),e.prototype.summary=function(){return"FileChunks "+this.file},e.prototype.next=function(){return __awaiter(this,void 0,void 0,function(){var t,e,r=this;return __generator(this,function(n){switch(n.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(t=new Promise(function(t,e){var n=r.offset+r.chunkSize;if(r.file instanceof Uint8Array)t(new Uint8Array(r.file.slice(r.offset,n)));else{var i=new FileReader;i.onload=function(r){var n=i.result;if(n instanceof ArrayBuffer&&(n=new Uint8Array(n)),!(n instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(n)},i.onabort=function(t){return e(new Error("Aborted"))},i.onerror=function(t){return e(new Error(t.type))};var o=r.file.slice(r.offset,n);i.readAsArrayBuffer(o)}r.offset=n}),e={},[4,t]);case 1:return[2,(e.value=n.sent(),e.done=!1,e)]}})})},e}(ByteChunkIterator);function urlChunkIterator(t,e){return void 0===e&&(e={}),__awaiter(this,void 0,void 0,function(){var r,n,i,o,a;return __generator(this,function(s){switch(s.label){case 0:return"string"==typeof t?r=t:(r=t.url,n=getRequestInitFromRequest(t)),[4,util.fetch(r,n)];case 1:return(i=s.sent()).ok?(a=Uint8Array.bind,[4,i.arrayBuffer()]):[3,3];case 2:return o=new(a.apply(Uint8Array,[void 0,s.sent()])),[2,new FileChunkIterator(o,e)];case 3:throw new Error(i.statusText)}})})}var getRequestInitFromRequest=function(t){return{method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity}};function isLocalPath(t){return"string"==typeof t&&"file://"===t.substr(0,7)}var FileDataSource=function(t){function e(e,r){void 0===r&&(r={});var n=t.call(this)||this;return n.input=e,n.options=r,n}return __extends(e,t),e.prototype.iterator=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){return isLocalPath(this.input)&&ENV.get("IS_NODE")&&(t=require("fs"),this.input=t.readFileSync(this.input.substr(7))),[2,new FileChunkIterator(this.input,this.options)]})})},e}(DataSource),URLDataSource=function(t){function e(e,r){void 0===r&&(r={});var n=t.call(this)||this;return n.url=e,n.fileOptions=r,n}return __extends(e,t),e.prototype.iterator=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return isLocalPath(this.url)?[2,new FileDataSource(this.url,this.fileOptions).iterator()]:[2,urlChunkIterator(this.url,this.fileOptions)]})})},e}(DataSource);function csv(t,e){return void 0===e&&(e={}),new CSVDataset(new URLDataSource(t),e)}function func(t){var e=this,r=iteratorFromFunction(t);return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(t){return[2,r]})})})}function generator(t){var e=this;return datasetFromIteratorFn(function(){return __awaiter(e,void 0,void 0,function(){var e;return __generator(this,function(r){switch(r.label){case 0:return[4,t()];case 1:return e=r.sent(),[2,iteratorFromFunction(function(){return e.next()})]}})})})}function webcam(t,e){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(r){return[2,WebcamIterator.create(t,e)]})})}function microphone(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,MicrophoneIterator.create(t)]})})}var version="1.2.9";export{array,Dataset,zip,CSVDataset,TextLineDataset,csv,func,generator,microphone,webcam,FileDataSource,URLDataSource,version as version_data};
//# sourceMappingURL=tf-data.esm.js.map

@@ -17,3 +17,3 @@ /**

*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tensorflow/tfjs-core")):"function"==typeof define&&define.amd?define(["exports","@tensorflow/tfjs-core"],e):e((t.tf=t.tf||{},t.tf.data=t.tf.data||{}),t.tf)}(this,function(t,e){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function r(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function i(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){t.done?i(t.value):new n(function(e){e(t.value)}).then(s,u)}a((r=r.apply(t,e||[])).next())})}function o(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function s(t,e){return t(e={exports:{}},e.exports),e.exports}var u=s(function(t){!function(t,e,n){function r(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function i(t,e){var n=new function(t){var e,n=this,r=(e=4022871197,function(t){t=t.toString();for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null}(t),i=e&&e.state,o=n.next;return o.int32=function(){return 4294967296*n.next()|0},o.double=function(){return o()+1.1102230246251565e-16*(2097152*o()|0)},o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.alea=i}(0,t,!1)}),a=s(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function i(t,e){var n=new function(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),e.next()}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xor128=i}(0,t,!1)}),c=s(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next()}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xorwow=i}(0,t,!1)}),h=s(function(t){!function(t,e,n){function r(t,e){return e.x=t.x.slice(),e.i=t.i,e}function i(t,e){null==t&&(t=+new Date);var n=new function(t){var e=this;e.next=function(){var t,n,r=e.x,i=e.i;return t=r[i],n=(t^=t>>>7)^t<<24,n^=(t=r[i+1&7])^t>>>10,n^=(t=r[i+3&7])^t>>>3,n^=(t=r[i+4&7])^t<<7,t=r[i+7&7],n^=(t^=t<<13)^t<<9,r[i]=n,e.i=i+1&7,n},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n)r[7&n]=r[7&n]<<15^e.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n?r[7]=-1:r[n],t.x=r,t.i=0,n=256;n>0;--n)t.next()}(e,t)}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&(i.x&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xorshift7=i}(0,t,!1)}),l=s(function(t){!function(t,e,n){function r(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function i(t,e){null==t&&(t=+new Date);var n=new function(t){var e=this;e.next=function(){var t,n,r=e.w,i=e.X,o=e.i;return e.w=r=r+1640531527|0,n=i[o+34&127],t=i[o=o+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=i[o]=n^t,e.i=o,n+(r^r>>>16)|0},function(t,e){var n,r,i,o,s,u=[],a=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,a=Math.max(a,e.length)),i=0,o=-32;o<a;++o)e&&(r^=e.charCodeAt((o+32)%e.length)),0===o&&(s=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,o>=0&&(s=s+1640531527|0,i=0==(n=u[127&o]^=r+s)?i+1:0);for(i>=128&&(u[127&(e&&e.length||0)]=-1),i=127,o=512;o>0;--o)r=u[i+34&127],n=u[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,u[i]=r^n;t.w=s,t.X=u,t.i=i}(e,t)}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&(i.X&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xor4096=i}(0,t,!1)}),f=s(function(t){!function(t,e,n){function r(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,i=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^i,e.a=i-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++)e.b^=0|n.charCodeAt(r),e.next()}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.tychei=i}(0,t,!1)}),d=s(function(t){!function(e,n){var r,i=this,o=256,s=6,u="random",a=n.pow(o,s),c=n.pow(2,52),h=2*c,l=o-1;function f(t,f,m){var y=[],w=p(function t(e,n){var r,i=[],o=typeof e;if(n&&"object"==o)for(r in e)try{i.push(t(e[r],n-1))}catch(t){}return i.length?i:"string"==o?e:e+"\0"}((f=1==f?{entropy:!0}:f||{}).entropy?[t,v(e)]:null==t?function(){try{var t;return r&&(t=r.randomBytes)?t=t(o):(t=new Uint8Array(o),(i.crypto||i.msCrypto).getRandomValues(t)),v(t)}catch(t){var n=i.navigator,s=n&&n.plugins;return[+new Date,i,s,i.screen,v(e)]}}():t,3),y),b=new function(t){var e,n=t.length,r=this,i=0,s=r.i=r.j=0,u=r.S=[];n||(t=[n++]);for(;i<o;)u[i]=i++;for(i=0;i<o;i++)u[i]=u[s=l&s+t[i%n]+(e=u[i])],u[s]=e;(r.g=function(t){for(var e,n=0,i=r.i,s=r.j,u=r.S;t--;)e=u[i=l&i+1],n=n*o+u[l&(u[i]=u[s=l&s+e])+(u[s]=e)];return r.i=i,r.j=s,n})(o)}(y),g=function(){for(var t=b.g(s),e=a,n=0;t<c;)t=(t+n)*o,e*=o,n=b.g(1);for(;t>=h;)t/=2,e/=2,n>>>=1;return(t+n)/e};return g.int32=function(){return 0|b.g(4)},g.quick=function(){return b.g(4)/4294967296},g.double=g,p(v(b.S),e),(f.pass||m||function(t,e,r,i){return i&&(i.S&&d(i,b),t.state=function(){return d(b,{})}),r?(n[u]=t,e):t})(g,w,"global"in f?f.global:this==n,f.state)}function d(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function p(t,e){for(var n,r=t+"",i=0;i<r.length;)e[l&i]=l&(n^=19*e[l&i])+r.charCodeAt(i++);return v(e)}function v(t){return String.fromCharCode.apply(0,t)}if(n["seed"+u]=f,p(n.random(),e),t.exports){t.exports=f;try{r=require("crypto")}catch(t){}}else 0}([],Math)});d.alea=u,d.xor128=a,d.xorwow=c,d.xorshift7=h,d.xor4096=l,d.tychei=f;var p=d.alea;function v(t,e,n,r){if(void 0===n&&(n=new Map),void 0===r&&(r=new Set),null==t)return null;if(r.has(t))throw new Error("Circular references are not supported.");if(n.has(t))return n.get(t);var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(i.recurse){if(b(t)){var o=Array.isArray(t)?[]:{};for(var s in r.add(t),t){var u=v(t[s],e,n,r);o[s]=u}return r.delete(t),o}throw new Error("Can't recurse into non-iterable type: "+t)}return n.set(t,i.value),i.value}function m(t,e){return void 0===e&&(e=y),function t(e,n,r){void 0===r&&(r=new Set);var i=e[0];if(r.has(i))throw new Error("Circular references are not supported.");var o=n(e);if(o.recurse&&null!==o.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(o.recurse){if(b(i)){var s=Array.isArray(i)?[]:{};r.add(i);var u=function(i){var o=e.map(function(t){return t[i]}),u=t(o,n,r);s[i]=u};for(var a in i)u(a);return r.delete(i),s}throw new Error("Can't recurse into non-iterable type: "+i)}return o.value}(t,e)}function y(t){return null===t?null:b(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}function w(t,e){return i(this,void 0,void 0,function(){var n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:n=new Map,v(t,e,n),r=0,i=Array.from(n.keys()),o.label=1;case 1:return r<i.length?(s=i[r],(u=n.get(s))instanceof Promise?[4,u]:[3,3]):[3,4];case 2:a=o.sent(),n.set(s,a),o.label=3;case 3:return r++,[3,1];case 4:return[2,v(t,e,n)]}})})}function b(t){return null!=t&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof e.Tensor))}function g(t){return v(t,x)}function x(t){return t instanceof e.Tensor?{value:t.clone(),recurse:!1}:b(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}var C=function(){function t(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}return t.prototype.wrap=function(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity},t.prototype.get=function(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]},t.prototype.set=function(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e},t.prototype.length=function(){var t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t},t.prototype.isFull=function(){return this.length()===this.capacity},t.prototype.isEmpty=function(){return 0===this.length()},t.prototype.push=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)},t.prototype.pushAll=function(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];this.push(r)}},t.prototype.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var t=this.get(this.end);return this.set(this.end,void 0),t},t.prototype.unshift=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)},t.prototype.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t},t.prototype.shuffleExcise=function(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.wrap(this.begin+t),n=this.get(e);return this.set(e,this.pop()),n},t}(),z=function(t){function e(){return t.call(this,e.INITIAL_CAPACITY)||this}return r(e,t),e.prototype.isFull=function(){return!1},e.prototype.push=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.push.call(this,e)},e.prototype.unshift=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.unshift.call(this,e)},e.prototype.expand=function(){for(var t=2*this.capacity,e=new Array(t),n=this.length(),r=0;r<n;r++)e[r]=this.get(this.wrap(this.begin+r));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n},e.INITIAL_CAPACITY=32,e}(C);function E(t){return new T(t)}function S(t){return new N(t)}var A,R=function(){function t(){}return t.prototype.toArray=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return t=[],[4,this.next()];case 1:e=n.sent(),n.label=2;case 2:return e.done?[3,4]:(t.push(e.value),[4,this.next()]);case 3:return e=n.sent(),[3,2];case 4:return[2,t]}})})},t.prototype.toArrayForTest=function(){return i(this,void 0,void 0,function(){var t,e,n;return o(this,function(r){switch(r.label){case 0:return t=this.prefetch(100),e=[],[4,t.next()];case 1:n=r.sent(),r.label=2;case 2:return n.done?[3,4]:(e.push(n.value),[4,t.next()]);case 3:return n=r.sent(),[3,2];case 4:return[2,e]}})})},t.prototype.resolveFully=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return[4,this.next()];case 1:t=e.sent(),e.label=2;case 2:return t.done?[3,4]:[4,this.next()];case 3:return t=e.sent(),[3,2];case 4:return[2]}})})},t.prototype.resolveWhile=function(t){return i(this,void 0,void 0,function(){var e,n;return o(this,function(r){switch(r.label){case 0:return[4,this.next()];case 1:e=r.sent(),n=t(e.value),r.label=2;case 2:return e.done||!n?[3,4]:[4,this.next()];case 3:return e=r.sent(),n=t(e.value),[3,2];case 4:return[2]}})})},t.prototype.handleErrors=function(t){return new j(this,t)},t.prototype.filter=function(t){return new O(this,t)},t.prototype.map=function(t){return new M(this,t)},t.prototype.mapAsync=function(t){return new _(this,t)},t.prototype.serialMapAsync=function(t){return new _(this,t).serial()},t.prototype.flatmap=function(t){return new q(this,t)},t.prototype.forEachAsync=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.map(t).resolveFully()]})})},t.prototype.serialForEach=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.serialMapAsync(t).resolveWhile(function(t){return!0===t})]})})},t.prototype.rowMajorBatch=function(t,e){return void 0===e&&(e=!0),new D(this,t,e)},t.prototype.columnMajorBatch=function(t,e,n){return void 0===e&&(e=!0),void 0===n&&(n=y),this.rowMajorBatch(t,e).map(function(t){return m(t,n)})},t.prototype.concatenate=function(t,e){return new H(E([this,t]),e)},t.prototype.take=function(t){return t<0||null==t?this:new I(this,t)},t.prototype.skip=function(t){return t<0||null==t?this:new F(this,t)},t.prototype.prefetch=function(t){return new B(this,t)},t.prototype.shuffle=function(t,e){return new V(this,t,e)},t.prototype.serial=function(){return new k(this)},t}(),T=function(t){function e(e){var n=t.call(this)||this;return n.items=e,n.trav=0,n}return r(e,t),e.prototype.summary=function(){return"Array of "+this.items.length+" items"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){return this.trav>=this.items.length?[2,{value:null,done:!0}]:(t=this.items[this.trav],this.trav++,[2,{value:g(t),done:!1}])})})},e}(R),N=function(t){function e(e){var n=t.call(this)||this;return n.nextFn=e,n}return r(e,t),e.prototype.summary=function(){return"Function call"},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){try{return[2,this.nextFn()]}catch(t){throw t.message="Error thrown while iterating through a dataset: "+t.message,t}return[2]})})},e}(R),k=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.lastRead=Promise.resolve({value:null,done:!1}),n}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Serial"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return[2,this.upstream.next()]})})},e}(R),F=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Skip"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},n.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return this.count++<this.maxCount?[4,this.upstream.next()]:[3,2];case 1:return(t=n.sent()).done?[2,t]:(e.dispose(t.value),[3,0]);case 2:return[2,this.upstream.next()]}})})},n}(R),I=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Take"},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]})})},e}(R),D=function(t){function e(e,n,r){void 0===r&&(r=!0);var i=t.call(this)||this;return i.upstream=e,i.batchSize=n,i.enableSmallLastBatch=r,i.lastRead=Promise.resolve({value:null,done:!1}),i}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> RowMajorBatch"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:t=[],n.label=1;case 1:return t.length<this.batchSize?[4,this.upstream.next()]:[3,3];case 2:return(e=n.sent()).done?this.enableSmallLastBatch&&t.length>0?[2,{value:t,done:!1}]:[2,{value:null,done:!0}]:(t.push(e.value),[3,1]);case 3:return[2,{value:t,done:!1}]}})})},e}(R),O=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.predicate=n,r.lastRead=Promise.resolve({value:null,done:!1}),r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Filter"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},n.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return[4,this.upstream.next()];case 1:return(t=n.sent()).done||this.predicate(t.value)?[2,t]:(e.dispose(t.value),[3,0]);case 2:return[2]}})})},n}(R),M=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Map"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return[2,{value:null,done:!0}];for(n=e.tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),i=e.tensor_util.getTensorsInContainer(r),s=0,u=n;s<u.length;s++)a=u[s],e.tensor_util.isTensorInList(a,i)||a.dispose();return[2,{value:r,done:!1}]}})})},n}(R),j=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.handler=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> handleErrors"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,e.sent()];case 3:return t=e.sent(),this.handler(t)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}})})},e}(R),_=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> AsyncMap"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:return(t=o.sent()).done?[2,{value:null,done:!0}]:(n=e.tensor_util.getTensorsInContainer(t.value),[4,this.transform(t.value)]);case 2:for(r=o.sent(),i=e.tensor_util.getTensorsInContainer(r),s=0,u=n;s<u.length;s++)a=u[s],e.tensor_util.isTensorInList(a,i)||a.dispose();return[2,{value:r,done:!1}]}})})},n}(R),L=function(t){function e(){var e=t.call(this)||this;return e.outputQueue=new z,e.lastRead=Promise.resolve({value:null,done:!1}),e}return r(e,t),e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return 0!==this.outputQueue.length()?[3,2]:[4,this.pump()];case 1:return t.sent()?[3,0]:[2,{value:null,done:!0}];case 2:return[2,{value:this.outputQueue.shift(),done:!1}]}})})},e}(R),q=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Flatmap"},n.prototype.pump=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return[2,!1];for(n=e.tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),i=e.tensor_util.getTensorsInContainer(r),this.outputQueue.pushAll(r),s=0,u=n;s<u.length;s++)a=u[s],e.tensor_util.isTensorInList(a,i)||a.dispose();return[2,!0]}})})},n}(L),H=function(t){function e(e,n){var r=t.call(this)||this;return r.baseErrorHandler=n,r.lastRead=null,r.iterator=null,r.moreIterators=e,r}return r(e,t),e.prototype.summary=function(){return"TODO: fill in upstream of chained summaries -> Chained"},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]})})},e.prototype.readFromChain=function(t){return i(this,void 0,void 0,function(){var e,n;return o(this,function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),null!=this.iterator?[3,3]:[4,this.moreIterators.next()];case 2:if((e=r.sent()).done)return[2,{value:null,done:!0}];this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),r.label=3;case 3:return[4,this.iterator.next()];case 4:return(n=r.sent()).done?(this.iterator=null,[2,this.readFromChain(t)]):[2,n]}})})},e}(R);!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(A||(A={}));var P=function(t){function e(e,n){void 0===n&&(n=A.FAIL);var r=t.call(this)||this;return r.iterators=e,r.mismatchMode=n,r.count=0,r.currentPromise=null,r}return r(e,t),e.prototype.summary=function(){return"{TODO: fill in upstream of zip summaries} -> Zip"},e.prototype.nextState=function(t){return i(this,void 0,void 0,function(){function e(t){return t instanceof R?{value:t.next().then(function(t){return n++,t.done&&r++,t.value}),recurse:!1}:{value:null,recurse:!0}}var n,r,i;return o(this,function(o){switch(o.label){case 0:return[4,t];case 1:return o.sent(),n=0,r=0,[4,w(this.iterators,e)];case 2:if(i=o.sent(),n===r)return[2,{value:null,done:!0}];if(r>0)switch(this.mismatchMode){case A.FAIL:throw new Error("Zipped streams should have the same length. Mismatched at element "+this.count+".");case A.SHORTEST:return[2,{value:null,done:!0}];case A.LONGEST:}return this.count++,[2,{value:i,done:!1}]}})})},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return this.currentPromise=this.nextState(this.currentPromise),[4,this.currentPromise];case 1:return[2,t.sent()]}})})},e}(R),B=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.bufferSize=n,r.buffer=new C(n),r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Prefetch"},e.prototype.refill=function(){for(;!this.buffer.isFull();){var t=this.upstream.next();this.buffer.push(t)}},e.prototype.next=function(){return this.refill(),this.buffer.shift()},e}(R),V=function(t){function n(n,r,i){var o=t.call(this,n,r)||this;return o.upstream=n,o.windowSize=r,o.upstreamExhausted=!1,o.random=p(i||e.util.now().toString()),o.lastRead=Promise.resolve({value:null,done:!1}),o}return r(n,t),n.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},n.prototype.randomInt=function(t){return Math.floor(this.random()*t)},n.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},n.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:this.upstreamExhausted||this.refill(),n.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(t=this.chooseIndex(),[4,this.buffer.shuffleExcise(t)]);case 2:return(e=n.sent()).done?(this.upstreamExhausted=!0,[3,1]):(this.refill(),[2,e]);case 3:return[2,{value:null,done:!0}]}})})},n}(B),W=function(){function t(){this.size=null}return t.prototype.batch=function(t,n){var r=this;void 0===n&&(n=!0);var s=this;return e.util.assert(t>0,function(){return"batchSize needs to be positive, but it is\n "+t}),U(function(){return i(r,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,s.iterator()];case 1:return[2,e.sent().columnMajorBatch(t,n,Q)]}})})},this.size===1/0||null==this.size?this.size:n?Math.ceil(this.size/t):Math.floor(this.size/t))},t.prototype.concatenate=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){var e,r;return o(this,function(i){switch(i.label){case 0:return[4,n.iterator()];case 1:return r=(e=i.sent()).concatenate,[4,t.iterator()];case 2:return[2,r.apply(e,[i.sent()])]}})})},this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null)},t.prototype.filter=function(t){var n=this,r=this;return U(function(){return i(n,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return[4,r.iterator()];case 1:return[2,n.sent().filter(function(n){return e.tidy(function(){return t(n)})})]}})})},this.size===1/0?1/0:null)},t.prototype.forEachAsync=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,this.iterator()];case 1:return[2,e.sent().forEachAsync(t)]}})})},t.prototype.forEach=function(t){return i(this,void 0,void 0,function(){return o(this,function(n){return e.deprecationWarn("dataset.forEach() is deprecated and will be removed. Please use dataset.forEachAsync() instead"),[2,this.forEachAsync(t)]})})},t.prototype.map=function(t){var n=this,r=this;return U(function(){return i(n,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return[4,r.iterator()];case 1:return[2,n.sent().map(function(n){return e.tidy(function(){return t(n)})})]}})})},this.size)},t.prototype.mapAsync=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().mapAsync(t)]}})})},this.size)},t.prototype.prefetch=function(t){var e=this;if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().prefetch(t)]}})})},this.size)},t.prototype.repeat=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){var e,r=this;return o(this,function(s){return e=S(function(){return i(r,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return t={},[4,n.iterator()];case 1:return[2,(t.value=e.sent(),t.done=!1,t)]}})})}),[2,(u=e.take(t),new H(u,a))];var u,a})})},null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null)},t.prototype.skip=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().skip(t)]}})})},null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null)},t.prototype.shuffle=function(t,n,r){var s=this;if(void 0===r&&(r=!0),null==t||t<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)");var u=this,a=p(n||e.util.now().toString());return U(function(){return i(s,void 0,void 0,function(){var e;return o(this,function(n){switch(n.label){case 0:return e=a.int32(),r&&(e+=a.int32()),[4,u.iterator()];case 1:return[2,n.sent().shuffle(t,e.toString())]}})})},this.size)},t.prototype.take=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().take(t)]}})})},null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null)},t.prototype.toArray=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArray()]}})})},t.prototype.toArrayForTest=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArrayForTest()]}})})},t.MAX_BUFFER_SIZE=1e4,t}();function U(t,e){return void 0===e&&(e=null),new(function(n){function s(){var t=null!==n&&n.apply(this,arguments)||this;return t.size=e,t}return r(s,n),s.prototype.iterator=function(){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,t()]})})},s}(W))}function Q(t){return null===t?null:function(t){return null==t||null===(n=t)||"object"!=typeof n&&"function"!=typeof n||Array.isArray(t)||"object"==typeof t&&t instanceof e.Tensor||e.util.isTypedArray(t);var n}(t[0])?{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof e.Tensor?e.stack(t):e.tensor(t)}(t),recurse:!1}:{value:null,recurse:!0}}var X=function(t){function e(e){var n=t.call(this)||this;return n.input=e,n}return r(e,t),e.prototype.iterator=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return[4,this.input.iterator()];case 1:return t=n.sent(),e=t.decodeUTF8(),[2,e.split("\n").map(function(t){return t.endsWith("\r")&&(t=t.slice(0,-1)),t})]}})})},e}(W),G=Symbol("out"),Z=Symbol("field"),J=Symbol("quote"),Y=Symbol("quoteafterquote"),K=Symbol("quoteinquote"),$=function(t){function n(n,r){var i=t.call(this)||this;return i.input=n,i.hasHeader=!0,i.fullColumnNames=null,i.columnNamesValidated=!1,i.columnConfigs=null,i.configuredColumnsOnly=!1,i.delimiter=",",i.delimWhitespace=!1,i.base=new X(n),r||(r={}),i.hasHeader=!1!==r.hasHeader,i.fullColumnNames=r.columnNames,i.columnConfigs=r.columnConfigs,i.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(e.util.assert(null==r.delimiter,function(){return"Delimiter should not be provided when delimWhitespace is true."}),i.delimWhitespace=!0,i.delimiter=" "):i.delimiter=r.delimiter?r.delimiter:",",i}return r(n,t),n.prototype.columnNames=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:t.sent(),t.label=2;case 2:return[2,this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames]}})})},n.prototype.setColumnNames=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a=this;return o(this,function(o){switch(o.label){case 0:return[4,this.maybeReadHeaderLine()];case 1:if(t=o.sent(),!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");if(this.fullColumnNames&&t&&e.util.assert(t.length===this.fullColumnNames.length,function(){return"The length of provided columnNames ("+a.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+")."}),this.fullColumnNames||(this.fullColumnNames=t),n=this.fullColumnNames.reduce(function(t,e){return t[e]=t[e]+1||1,t},{}),r=Object.keys(n).filter(function(t){return n[t]>1}),e.util.assert(0===r.length,function(){return"Duplicate column names found: "+r.toString()}),this.columnConfigs)for(i=0,s=Object.keys(this.columnConfigs);i<s.length;i++)if(u=s[i],-1===this.fullColumnNames.indexOf(u))throw new Error('The key "'+u+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").");return this.columnNamesValidated=!0,[2]}})})},n.prototype.maybeReadHeaderLine=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return this.hasHeader?[4,this.base.iterator()]:[3,3];case 1:return[4,n.sent().next()];case 2:if((t=n.sent()).done)throw new Error("No data was found for CSV parsing.");return e=t.value,[2,this.parseRow(e,!1)];case 3:return[2,null]}})})},n.prototype.iterator=function(){return i(this,void 0,void 0,function(){var t,e=this;return o(this,function(n){switch(n.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:n.sent(),n.label=2;case 2:return[4,this.base.iterator()];case 3:return t=n.sent(),this.hasHeader&&(t=t.skip(1)),[2,t.map(function(t){return e.makeDataElement(t)})]}})})},n.prototype.makeDataElement=function(t){for(var e=this.parseRow(t),n={},r={},i=0;i<this.fullColumnNames.length;i++){var o=this.fullColumnNames[i],s=this.columnConfigs?this.columnConfigs[o]:null;if(!this.configuredColumnsOnly||s){var u=e[i],a=null;if(""===u)if(s&&void 0!==s.default)a=s.default;else{if(s&&(s.required||s.isLabel))throw new Error("Required column "+o+" is empty in this line: "+t);a=void 0}else{var c=Number(u);if(isNaN(c))a=s&&"bool"===s.dtype?this.getBoolean(u):u;else if(s&&s.dtype)switch(s.dtype){case"float32":a=c;break;case"int32":a=Math.floor(c);break;case"bool":a=this.getBoolean(u);break;default:a=c}else a=c}s&&s.isLabel?r[o]=a:n[o]=a}}return 0===Object.keys(r).length?n:{xs:n,ys:r}},n.prototype.getBoolean=function(t){return"1"===t||"true"===t.toLowerCase()?1:0},n.prototype.parseRow=function(t,e){void 0===e&&(e=!0);for(var n=[],r=0,i=t.length,o=G,s=0;s<i;s++)switch(o){case G:switch(t.charAt(s)){case'"':r=s+1,o=J;break;case this.delimiter:if(r=s+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),o=G;break;default:o=Z,r=s}break;case Z:switch(t.charAt(s)){case this.delimiter:n.push(t.substring(r,s)),o=G,r=s+1}break;case J:switch(t.charAt(s)){case'"':o=Y}break;case Y:switch(t.charAt(s)){case this.delimiter:n.push(t.substring(r,s-1)),o=G,r=s+1;break;case'"':o=J;break;default:o=K}break;case K:switch(t.charAt(s)){case'"':o=J}}if(o===Y?n.push(t.substring(r,i-1)):n.push(t.substring(r)),e&&n.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have "+this.fullColumnNames.length+" elements in a row, but got "+n);return n},n}(W),tt=function(t){function n(e){var n=t.call(this)||this;n.microphoneConfig=e,n.isClosed=!1,n.fftSize=e.fftSize||1024;var r=Math.log2(n.fftSize);if(n.fftSize<0||r<4||r>14||!Number.isInteger(r))throw new Error("Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got "+n.fftSize);if(n.numFrames=e.numFramesPerSpectrogram||43,n.sampleRateHz=e.sampleRateHz,n.columnTruncateLength=e.columnTruncateLength||n.fftSize,n.audioTrackConstraints=e.audioTrackConstraints,n.smoothingTimeConstant=e.smoothingTimeConstant||0,n.includeSpectrogram=!1!==e.includeSpectrogram,n.includeWaveform=!0===e.includeWaveform,!n.includeSpectrogram&&!n.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return n}return r(n,t),n.prototype.summary=function(){return"microphone"},n.create=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,function(){var r;return o(this,function(i){switch(i.label){case 0:if(e.ENV.get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");return[4,(r=new n(t)).start()];case 1:return i.sent(),[2,r]}})})},n.prototype.start=function(){return i(this,void 0,void 0,function(){var t,e,n,r;return o(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=this,[4,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})];case 1:return t.stream=i.sent(),[3,3];case 2:throw e=i.sent(),new Error("Error thrown while initializing video stream: "+e.message);case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(n=window.AudioContext||window.webkitAudioContext,this.audioContext=new n,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;return r=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,r.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2]}})})},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,e,n,r,i;return o(this,function(o){switch(o.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return n=o.sent(),this.includeSpectrogram&&(r=this.flattenQueue(n.freqDataQueue),t=this.getTensorFromAudioDataArray(r,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(n.timeDataQueue),e=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:t,waveform:e},done:!1}]}})})},n.prototype.capture=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}})})},n.prototype.getAudioData=function(){return i(this,void 0,void 0,function(){var t,e,n,r=this;return o(this,function(i){return t=[],e=[],n=0,[2,new Promise(function(i){var o=setInterval(function(){r.includeSpectrogram&&(r.analyser.getFloatFrequencyData(r.freqData),r.freqData[0]===-1/0&&i({freqDataQueue:t,timeDataQueue:e}),t.push(r.freqData.slice(0,r.columnTruncateLength))),r.includeWaveform&&(r.analyser.getFloatTimeDomainData(r.timeData),e.push(r.timeData.slice())),++n===r.numFrames&&(clearInterval(o),i({freqDataQueue:t,timeDataQueue:e}))},r.fftSize/r.sampleRateHz*1e3)})]})})},n.prototype.stop=function(){this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop()},n.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},n.prototype.getSampleRate=function(){return this.sampleRateHz},n.prototype.flattenQueue=function(t){var e=t[0].length,n=new Float32Array(t.length*e);return t.forEach(function(t,r){return n.set(t,r*e)}),n},n.prototype.getTensorFromAudioDataArray=function(t,n){var r=new Float32Array(e.util.sizeFromShape(n));return r.set(t,r.length-t.length),e.tensor(r,n)},n}(R),et=function(t){function n(n,r){var i=t.call(this)||this;if(i.webcamVideoElement=n,i.webcamConfig=r,i.isClosed=!0,i.resize=!1,i.needToResize())if(i.resize=!0,i.cropSize=[i.webcamConfig.resizeHeight,i.webcamConfig.resizeWidth],i.cropBoxInd=e.tensor1d([0],"int32"),i.webcamConfig.centerCrop){var o=1*i.webcamConfig.resizeWidth/i.webcamVideoElement.width,s=1*i.webcamConfig.resizeHeight/i.webcamVideoElement.height,u=(1-o)/2,a=(1-s)/2,c=u+o,h=s+a;i.cropBox=e.tensor2d([a,u,h,c],[1,4])}else i.cropBox=e.tensor2d([0,0,1,1],[1,4]);return i}return r(n,t),n.prototype.summary=function(){return"webcam"},n.create=function(t,r){return void 0===r&&(r={}),i(this,void 0,void 0,function(){var i;return o(this,function(o){switch(o.label){case 0:if(e.ENV.get("IS_NODE"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!r.resizeWidth||!r.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=r.resizeWidth,t.height=r.resizeHeight}return[4,(i=new n(t,r)).start()];case 1:return o.sent(),[2,i]}})})},n.prototype.start=function(){return i(this,void 0,void 0,function(){var t,n,r=this;return o(this,function(i){switch(i.label){case 0:this.webcamConfig.facingMode&&e.util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,function(){return"Invalid webcam facing mode: "+r.webcamConfig.facingMode+". Please provide 'user' or 'environment'"}),i.label=1;case 1:return i.trys.push([1,3,,4]),t=this,[4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})];case 2:return t.stream=i.sent(),[3,4];case 3:throw(n=i.sent()).message="Error thrown while initializing video stream: "+n.message,n;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise(function(t){r.webcamVideoElement.onloadedmetadata=function(){t()}})]}})})},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){if(this.isClosed)return[2,{value:null,done:!0}];try{t=e.browser.fromPixels(this.webcamVideoElement)}catch(t){throw new Error("Error thrown converting video to pixels: "+JSON.stringify(t))}if(!this.resize)return[2,{value:t,done:!1}];try{return[2,{value:this.cropAndResizeFrame(t),done:!1}]}catch(t){throw new Error("Error thrown cropping the video: "+t.message)}finally{t.dispose()}return[2]})})},n.prototype.needToResize=function(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)},n.prototype.cropAndResizeFrame=function(t){var n=this;return e.tidy(function(){var r,i=t.toFloat().expandDims(0),o=(r=e.image.cropAndResize(i,n.cropBox,n.cropBoxInd,n.cropSize,"bilinear")).shape;return r.reshape(o.slice(1))})},n.prototype.capture=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}})})},n.prototype.stop=function(){this.stream.getTracks().forEach(function(t){return t.stop()});try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0},n.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},n}(R),nt=function(){return function(){}}(),rt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.split=function(t){return new it(this,t)},e}(R),it=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.impl=new ot(e,n),r}return r(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return[2,this.impl.next()]})})},e}(rt),ot=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.separator=n,r.carryover="",r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')"},e.prototype.pump=function(){return i(this,void 0,void 0,function(){var t,e,n,r,i;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return""===this.carryover?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);for((e=t.value.split(this.separator))[0]=this.carryover+e[0],n=0,r=e.slice(0,-1);n<r.length;n++)i=r[n],this.outputQueue.push(i);return this.carryover=e[e.length-1],[2,!0]}})})},e}(L),st=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.decodeUTF8=function(){return new ut(this)},e}(R),ut=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.impl=new at(e),n}return r(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return[2,this.impl.next()]})})},e}(rt),at=function(t){function n(n){var r=t.call(this)||this;if(r.upstream=n,e.ENV.get("IS_BROWSER"))r.decoder=new TextDecoder("utf-8");else{var i=require("string_decoder").StringDecoder;r.decoder=new i("utf8")}return r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Utf8"},n.prototype.pump=function(){return i(this,void 0,void 0,function(){var t,n,r;return o(this,function(i){switch(i.label){case 0:return[4,this.upstream.next()];case 1:return(t=i.sent()).done?[2,!1]:(n=t.value,r=e.ENV.get("IS_BROWSER")?this.decoder.decode(n,{stream:!0}):this.decoder.write(Buffer.from(n.buffer)),this.outputQueue.push(r),[2,!0])}})})},n}(L),ct=function(t){function n(n,r){void 0===r&&(r={});var i=t.call(this)||this;return i.file=n,i.options=r,e.util.assert(n instanceof Uint8Array||!!e.ENV.get("IS_BROWSER")&&(n instanceof File||n instanceof Blob),function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."}),i.offset=r.offset||0,i.chunkSize=r.chunkSize||1048576,i}return r(n,t),n.prototype.summary=function(){return"FileChunks "+this.file},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,e,n=this;return o(this,function(r){switch(r.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(t=new Promise(function(t,e){var r=n.offset+n.chunkSize;if(n.file instanceof Uint8Array)t(new Uint8Array(n.file.slice(n.offset,r)));else{var i=new FileReader;i.onload=function(n){var r=i.result;if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),!(r instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(r)},i.onabort=function(t){return e(new Error("Aborted"))},i.onerror=function(t){return e(new Error(t.type))};var o=n.file.slice(n.offset,r);i.readAsArrayBuffer(o)}n.offset=r}),e={},[4,t]);case 1:return[2,(e.value=r.sent(),e.done=!1,e)]}})})},n}(st);var ht=function(t){return{method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity}};function lt(t){return"string"==typeof t&&"file://"===t.substr(0,7)}var ft=function(t){function n(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.input=e,r.options=n,r}return r(n,t),n.prototype.iterator=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){return lt(this.input)&&e.ENV.get("IS_NODE")&&(t=require("fs"),this.input=t.readFileSync(this.input.substr(7))),[2,new ct(this.input,this.options)]})})},n}(nt),dt=function(t){function n(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.url=e,r.fileOptions=n,r}return r(n,t),n.prototype.iterator=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return lt(this.url)?[2,new ft(this.url,this.fileOptions).iterator()]:[2,function(t,n){return void 0===n&&(n={}),i(this,void 0,void 0,function(){var r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return"string"==typeof t?r=t:(r=t.url,i=ht(t)),[4,e.util.fetch(r,i)];case 1:return(s=o.sent()).ok?(a=Uint8Array.bind,[4,s.arrayBuffer()]):[3,3];case 2:return u=new(a.apply(Uint8Array,[void 0,o.sent()])),[2,new ct(u,n)];case 3:throw new Error(s.statusText)}})})}(this.url,this.fileOptions)]})})},n}(nt);t.array=function(t){var e=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){return[2,E(t)]})})},t.length)},t.Dataset=W,t.zip=function(t){var e,n=this;if(!b(t))throw new Error("The argument to zip() must be an object or array.");if(Array.isArray(t))for(var r=0;r<t.length;r++)e=null==e?t[r].size:Math.min(e,t[r].size);else if(t instanceof Object)for(var s in t)e=null==e?t[s].size:Math.min(e,t[s].size);return U(function(){return i(n,void 0,void 0,function(){var e;return o(this,function(n){switch(n.label){case 0:return[4,w(t,function(t){if(t instanceof W)return{value:t.iterator(),recurse:!1};if(b(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})];case 1:return e=n.sent(),[2,(r=e,i=A.SHORTEST,void 0===i&&(i=A.FAIL),new P(r,i))]}var r,i})})},e)},t.CSVDataset=$,t.TextLineDataset=X,t.csv=function(t,e){return void 0===e&&(e={}),new $(new dt(t),e)},t.func=function(t){var e=this,n=S(t);return U(function(){return i(e,void 0,void 0,function(){return o(this,function(t){return[2,n]})})})},t.generator=function(t){var e=this;return U(function(){return i(e,void 0,void 0,function(){var e;return o(this,function(n){switch(n.label){case 0:return[4,t()];case 1:return e=n.sent(),[2,S(function(){return e.next()})]}})})})},t.microphone=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,tt.create(t)]})})},t.webcam=function(t,e){return i(this,void 0,void 0,function(){return o(this,function(n){return[2,et.create(t,e)]})})},t.FileDataSource=ft,t.URLDataSource=dt,t.version_data="1.2.8",Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tensorflow/tfjs-core")):"function"==typeof define&&define.amd?define(["exports","@tensorflow/tfjs-core"],e):e((t.tf=t.tf||{},t.tf.data=t.tf.data||{}),t.tf)}(this,function(t,e){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function r(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function i(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){t.done?i(t.value):new n(function(e){e(t.value)}).then(s,u)}a((r=r.apply(t,e||[])).next())})}function o(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function s(t,e){return t(e={exports:{}},e.exports),e.exports}var u=s(function(t){!function(t,e,n){function r(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function i(t,e){var n=new function(t){var e,n=this,r=(e=4022871197,function(t){t=t.toString();for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null}(t),i=e&&e.state,o=n.next;return o.int32=function(){return 4294967296*n.next()|0},o.double=function(){return o()+1.1102230246251565e-16*(2097152*o()|0)},o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.alea=i}(0,t,!1)}),a=s(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function i(t,e){var n=new function(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),e.next()}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xor128=i}(0,t,!1)}),c=s(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next()}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xorwow=i}(0,t,!1)}),h=s(function(t){!function(t,e,n){function r(t,e){return e.x=t.x.slice(),e.i=t.i,e}function i(t,e){null==t&&(t=+new Date);var n=new function(t){var e=this;e.next=function(){var t,n,r=e.x,i=e.i;return t=r[i],n=(t^=t>>>7)^t<<24,n^=(t=r[i+1&7])^t>>>10,n^=(t=r[i+3&7])^t>>>3,n^=(t=r[i+4&7])^t<<7,t=r[i+7&7],n^=(t^=t<<13)^t<<9,r[i]=n,e.i=i+1&7,n},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n)r[7&n]=r[7&n]<<15^e.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n?r[7]=-1:r[n],t.x=r,t.i=0,n=256;n>0;--n)t.next()}(e,t)}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&(i.x&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xorshift7=i}(0,t,!1)}),l=s(function(t){!function(t,e,n){function r(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function i(t,e){null==t&&(t=+new Date);var n=new function(t){var e=this;e.next=function(){var t,n,r=e.w,i=e.X,o=e.i;return e.w=r=r+1640531527|0,n=i[o+34&127],t=i[o=o+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=i[o]=n^t,e.i=o,n+(r^r>>>16)|0},function(t,e){var n,r,i,o,s,u=[],a=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,a=Math.max(a,e.length)),i=0,o=-32;o<a;++o)e&&(r^=e.charCodeAt((o+32)%e.length)),0===o&&(s=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,o>=0&&(s=s+1640531527|0,i=0==(n=u[127&o]^=r+s)?i+1:0);for(i>=128&&(u[127&(e&&e.length||0)]=-1),i=127,o=512;o>0;--o)r=u[i+34&127],n=u[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,u[i]=r^n;t.w=s,t.X=u,t.i=i}(e,t)}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&(i.X&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.xor4096=i}(0,t,!1)}),f=s(function(t){!function(t,e,n){function r(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,i=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^i,e.a=i-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++)e.b^=0|n.charCodeAt(r),e.next()}(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&r(i,n),o.state=function(){return r(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n(function(){return i}):this.tychei=i}(0,t,!1)}),d=s(function(t){!function(e,n){var r,i=this,o=256,s=6,u="random",a=n.pow(o,s),c=n.pow(2,52),h=2*c,l=o-1;function f(t,f,m){var y=[],w=p(function t(e,n){var r,i=[],o=typeof e;if(n&&"object"==o)for(r in e)try{i.push(t(e[r],n-1))}catch(t){}return i.length?i:"string"==o?e:e+"\0"}((f=1==f?{entropy:!0}:f||{}).entropy?[t,v(e)]:null==t?function(){try{var t;return r&&(t=r.randomBytes)?t=t(o):(t=new Uint8Array(o),(i.crypto||i.msCrypto).getRandomValues(t)),v(t)}catch(t){var n=i.navigator,s=n&&n.plugins;return[+new Date,i,s,i.screen,v(e)]}}():t,3),y),b=new function(t){var e,n=t.length,r=this,i=0,s=r.i=r.j=0,u=r.S=[];n||(t=[n++]);for(;i<o;)u[i]=i++;for(i=0;i<o;i++)u[i]=u[s=l&s+t[i%n]+(e=u[i])],u[s]=e;(r.g=function(t){for(var e,n=0,i=r.i,s=r.j,u=r.S;t--;)e=u[i=l&i+1],n=n*o+u[l&(u[i]=u[s=l&s+e])+(u[s]=e)];return r.i=i,r.j=s,n})(o)}(y),g=function(){for(var t=b.g(s),e=a,n=0;t<c;)t=(t+n)*o,e*=o,n=b.g(1);for(;t>=h;)t/=2,e/=2,n>>>=1;return(t+n)/e};return g.int32=function(){return 0|b.g(4)},g.quick=function(){return b.g(4)/4294967296},g.double=g,p(v(b.S),e),(f.pass||m||function(t,e,r,i){return i&&(i.S&&d(i,b),t.state=function(){return d(b,{})}),r?(n[u]=t,e):t})(g,w,"global"in f?f.global:this==n,f.state)}function d(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function p(t,e){for(var n,r=t+"",i=0;i<r.length;)e[l&i]=l&(n^=19*e[l&i])+r.charCodeAt(i++);return v(e)}function v(t){return String.fromCharCode.apply(0,t)}if(n["seed"+u]=f,p(n.random(),e),t.exports){t.exports=f;try{r=require("crypto")}catch(t){}}else 0}([],Math)});d.alea=u,d.xor128=a,d.xorwow=c,d.xorshift7=h,d.xor4096=l,d.tychei=f;var p=d.alea;function v(t,e,n,r){if(void 0===n&&(n=new Map),void 0===r&&(r=new Set),null==t)return null;if(r.has(t))throw new Error("Circular references are not supported.");if(n.has(t))return n.get(t);var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(i.recurse){if(b(t)){var o=Array.isArray(t)?[]:{};for(var s in r.add(t),t){var u=v(t[s],e,n,r);o[s]=u}return r.delete(t),o}throw new Error("Can't recurse into non-iterable type: "+t)}return n.set(t,i.value),i.value}function m(t,e){return void 0===e&&(e=y),function t(e,n,r){void 0===r&&(r=new Set);var i=e[0];if(r.has(i))throw new Error("Circular references are not supported.");var o=n(e);if(o.recurse&&null!==o.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(o.recurse){if(b(i)){var s=Array.isArray(i)?[]:{};r.add(i);var u=function(i){var o=e.map(function(t){return t[i]}),u=t(o,n,r);s[i]=u};for(var a in i)u(a);return r.delete(i),s}throw new Error("Can't recurse into non-iterable type: "+i)}return o.value}(t,e)}function y(t){return null===t?null:b(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}function w(t,e){return i(this,void 0,void 0,function(){var n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:n=new Map,v(t,e,n),r=0,i=Array.from(n.keys()),o.label=1;case 1:return r<i.length?(s=i[r],(u=n.get(s))instanceof Promise?[4,u]:[3,3]):[3,4];case 2:a=o.sent(),n.set(s,a),o.label=3;case 3:return r++,[3,1];case 4:return[2,v(t,e,n)]}})})}function b(t){return null!=t&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof e.Tensor))}function g(t){return v(t,x)}function x(t){return t instanceof e.Tensor?{value:t.clone(),recurse:!1}:b(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}var C=function(){function t(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}return t.prototype.wrap=function(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity},t.prototype.get=function(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]},t.prototype.set=function(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e},t.prototype.length=function(){var t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t},t.prototype.isFull=function(){return this.length()===this.capacity},t.prototype.isEmpty=function(){return 0===this.length()},t.prototype.push=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)},t.prototype.pushAll=function(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];this.push(r)}},t.prototype.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var t=this.get(this.end);return this.set(this.end,void 0),t},t.prototype.unshift=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)},t.prototype.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t},t.prototype.shuffleExcise=function(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.wrap(this.begin+t),n=this.get(e);return this.set(e,this.pop()),n},t}(),z=function(t){function e(){return t.call(this,e.INITIAL_CAPACITY)||this}return r(e,t),e.prototype.isFull=function(){return!1},e.prototype.push=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.push.call(this,e)},e.prototype.unshift=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.unshift.call(this,e)},e.prototype.expand=function(){for(var t=2*this.capacity,e=new Array(t),n=this.length(),r=0;r<n;r++)e[r]=this.get(this.wrap(this.begin+r));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n},e.INITIAL_CAPACITY=32,e}(C);function E(t){return new T(t)}function S(t){return new N(t)}var A,R=function(){function t(){}return t.prototype.toArray=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return t=[],[4,this.next()];case 1:e=n.sent(),n.label=2;case 2:return e.done?[3,4]:(t.push(e.value),[4,this.next()]);case 3:return e=n.sent(),[3,2];case 4:return[2,t]}})})},t.prototype.toArrayForTest=function(){return i(this,void 0,void 0,function(){var t,e,n;return o(this,function(r){switch(r.label){case 0:return t=this.prefetch(100),e=[],[4,t.next()];case 1:n=r.sent(),r.label=2;case 2:return n.done?[3,4]:(e.push(n.value),[4,t.next()]);case 3:return n=r.sent(),[3,2];case 4:return[2,e]}})})},t.prototype.resolveFully=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return[4,this.next()];case 1:t=e.sent(),e.label=2;case 2:return t.done?[3,4]:[4,this.next()];case 3:return t=e.sent(),[3,2];case 4:return[2]}})})},t.prototype.resolveWhile=function(t){return i(this,void 0,void 0,function(){var e,n;return o(this,function(r){switch(r.label){case 0:return[4,this.next()];case 1:e=r.sent(),n=t(e.value),r.label=2;case 2:return e.done||!n?[3,4]:[4,this.next()];case 3:return e=r.sent(),n=t(e.value),[3,2];case 4:return[2]}})})},t.prototype.handleErrors=function(t){return new j(this,t)},t.prototype.filter=function(t){return new O(this,t)},t.prototype.map=function(t){return new M(this,t)},t.prototype.mapAsync=function(t){return new _(this,t)},t.prototype.serialMapAsync=function(t){return new _(this,t).serial()},t.prototype.flatmap=function(t){return new q(this,t)},t.prototype.forEachAsync=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.map(t).resolveFully()]})})},t.prototype.serialForEach=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.serialMapAsync(t).resolveWhile(function(t){return!0===t})]})})},t.prototype.rowMajorBatch=function(t,e){return void 0===e&&(e=!0),new D(this,t,e)},t.prototype.columnMajorBatch=function(t,e,n){return void 0===e&&(e=!0),void 0===n&&(n=y),this.rowMajorBatch(t,e).map(function(t){return m(t,n)})},t.prototype.concatenate=function(t,e){return new H(E([this,t]),e)},t.prototype.take=function(t){return t<0||null==t?this:new I(this,t)},t.prototype.skip=function(t){return t<0||null==t?this:new F(this,t)},t.prototype.prefetch=function(t){return new B(this,t)},t.prototype.shuffle=function(t,e){return new V(this,t,e)},t.prototype.serial=function(){return new k(this)},t}(),T=function(t){function e(e){var n=t.call(this)||this;return n.items=e,n.trav=0,n}return r(e,t),e.prototype.summary=function(){return"Array of "+this.items.length+" items"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){return this.trav>=this.items.length?[2,{value:null,done:!0}]:(t=this.items[this.trav],this.trav++,[2,{value:g(t),done:!1}])})})},e}(R),N=function(t){function e(e){var n=t.call(this)||this;return n.nextFn=e,n}return r(e,t),e.prototype.summary=function(){return"Function call"},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){try{return[2,this.nextFn()]}catch(t){throw t.message="Error thrown while iterating through a dataset: "+t.message,t}return[2]})})},e}(R),k=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.lastRead=Promise.resolve({value:null,done:!1}),n}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Serial"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return[2,this.upstream.next()]})})},e}(R),F=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Skip"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},n.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return this.count++<this.maxCount?[4,this.upstream.next()]:[3,2];case 1:return(t=n.sent()).done?[2,t]:(e.dispose(t.value),[3,0]);case 2:return[2,this.upstream.next()]}})})},n}(R),I=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Take"},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]})})},e}(R),D=function(t){function e(e,n,r){void 0===r&&(r=!0);var i=t.call(this)||this;return i.upstream=e,i.batchSize=n,i.enableSmallLastBatch=r,i.lastRead=Promise.resolve({value:null,done:!1}),i}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> RowMajorBatch"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:t=[],n.label=1;case 1:return t.length<this.batchSize?[4,this.upstream.next()]:[3,3];case 2:return(e=n.sent()).done?this.enableSmallLastBatch&&t.length>0?[2,{value:t,done:!1}]:[2,{value:null,done:!0}]:(t.push(e.value),[3,1]);case 3:return[2,{value:t,done:!1}]}})})},e}(R),O=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.predicate=n,r.lastRead=Promise.resolve({value:null,done:!1}),r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Filter"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},n.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return[4,this.upstream.next()];case 1:return(t=n.sent()).done||this.predicate(t.value)?[2,t]:(e.dispose(t.value),[3,0]);case 2:return[2]}})})},n}(R),M=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Map"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return[2,{value:null,done:!0}];for(n=e.tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),i=e.tensor_util.getTensorsInContainer(r),s=0,u=n;s<u.length;s++)a=u[s],e.tensor_util.isTensorInList(a,i)||a.dispose();return[2,{value:r,done:!1}]}})})},n}(R),j=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.handler=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> handleErrors"},e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,e.sent()];case 3:return t=e.sent(),this.handler(t)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}})})},e}(R),_=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> AsyncMap"},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:return(t=o.sent()).done?[2,{value:null,done:!0}]:(n=e.tensor_util.getTensorsInContainer(t.value),[4,this.transform(t.value)]);case 2:for(r=o.sent(),i=e.tensor_util.getTensorsInContainer(r),s=0,u=n;s<u.length;s++)a=u[s],e.tensor_util.isTensorInList(a,i)||a.dispose();return[2,{value:r,done:!1}]}})})},n}(R),L=function(t){function e(){var e=t.call(this)||this;return e.outputQueue=new z,e.lastRead=Promise.resolve({value:null,done:!1}),e}return r(e,t),e.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},e.prototype.serialNext=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return 0!==this.outputQueue.length()?[3,2]:[4,this.pump()];case 1:return t.sent()?[3,0]:[2,{value:null,done:!0}];case 2:return[2,{value:this.outputQueue.shift(),done:!1}]}})})},e}(R),q=function(t){function n(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Flatmap"},n.prototype.pump=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return[2,!1];for(n=e.tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),i=e.tensor_util.getTensorsInContainer(r),this.outputQueue.pushAll(r),s=0,u=n;s<u.length;s++)a=u[s],e.tensor_util.isTensorInList(a,i)||a.dispose();return[2,!0]}})})},n}(L),H=function(t){function e(e,n){var r=t.call(this)||this;return r.baseErrorHandler=n,r.lastRead=null,r.iterator=null,r.moreIterators=e,r}return r(e,t),e.prototype.summary=function(){return"TODO: fill in upstream of chained summaries -> Chained"},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]})})},e.prototype.readFromChain=function(t){return i(this,void 0,void 0,function(){var e,n;return o(this,function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),null!=this.iterator?[3,3]:[4,this.moreIterators.next()];case 2:if((e=r.sent()).done)return[2,{value:null,done:!0}];this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),r.label=3;case 3:return[4,this.iterator.next()];case 4:return(n=r.sent()).done?(this.iterator=null,[2,this.readFromChain(t)]):[2,n]}})})},e}(R);!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(A||(A={}));var P=function(t){function e(e,n){void 0===n&&(n=A.FAIL);var r=t.call(this)||this;return r.iterators=e,r.mismatchMode=n,r.count=0,r.currentPromise=null,r}return r(e,t),e.prototype.summary=function(){return"{TODO: fill in upstream of zip summaries} -> Zip"},e.prototype.nextState=function(t){return i(this,void 0,void 0,function(){function e(t){return t instanceof R?{value:t.next().then(function(t){return n++,t.done&&r++,t.value}),recurse:!1}:{value:null,recurse:!0}}var n,r,i;return o(this,function(o){switch(o.label){case 0:return[4,t];case 1:return o.sent(),n=0,r=0,[4,w(this.iterators,e)];case 2:if(i=o.sent(),n===r)return[2,{value:null,done:!0}];if(r>0)switch(this.mismatchMode){case A.FAIL:throw new Error("Zipped streams should have the same length. Mismatched at element "+this.count+".");case A.SHORTEST:return[2,{value:null,done:!0}];case A.LONGEST:}return this.count++,[2,{value:i,done:!1}]}})})},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return this.currentPromise=this.nextState(this.currentPromise),[2,this.currentPromise]})})},e}(R),B=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.bufferSize=n,r.buffer=new C(n),r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Prefetch"},e.prototype.refill=function(){for(;!this.buffer.isFull();){var t=this.upstream.next();this.buffer.push(t)}},e.prototype.next=function(){return this.refill(),this.buffer.shift()},e}(R),V=function(t){function n(n,r,i){var o=t.call(this,n,r)||this;return o.upstream=n,o.windowSize=r,o.upstreamExhausted=!1,o.random=p(i||e.util.now().toString()),o.lastRead=Promise.resolve({value:null,done:!1}),o}return r(n,t),n.prototype.next=function(){return i(this,void 0,void 0,function(){var t=this;return o(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext()}),[2,this.lastRead]})})},n.prototype.randomInt=function(t){return Math.floor(this.random()*t)},n.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},n.prototype.serialNext=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:this.upstreamExhausted||this.refill(),n.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(t=this.chooseIndex(),[4,this.buffer.shuffleExcise(t)]);case 2:return(e=n.sent()).done?(this.upstreamExhausted=!0,[3,1]):(this.refill(),[2,e]);case 3:return[2,{value:null,done:!0}]}})})},n}(B),W=function(){function t(){this.size=null}return t.prototype.batch=function(t,n){var r=this;void 0===n&&(n=!0);var s=this;return e.util.assert(t>0,function(){return"batchSize needs to be positive, but it is\n "+t}),U(function(){return i(r,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,s.iterator()];case 1:return[2,e.sent().columnMajorBatch(t,n,Q)]}})})},this.size===1/0||null==this.size?this.size:n?Math.ceil(this.size/t):Math.floor(this.size/t))},t.prototype.concatenate=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){var e,r;return o(this,function(i){switch(i.label){case 0:return[4,n.iterator()];case 1:return r=(e=i.sent()).concatenate,[4,t.iterator()];case 2:return[2,r.apply(e,[i.sent()])]}})})},this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null)},t.prototype.filter=function(t){var n=this,r=this;return U(function(){return i(n,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return[4,r.iterator()];case 1:return[2,n.sent().filter(function(n){return e.tidy(function(){return t(n)})})]}})})},this.size===1/0?1/0:null)},t.prototype.forEachAsync=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,this.iterator()];case 1:return[2,e.sent().forEachAsync(t)]}})})},t.prototype.forEach=function(t){return i(this,void 0,void 0,function(){return o(this,function(n){return e.deprecationWarn("dataset.forEach() is deprecated and will be removed. Please use dataset.forEachAsync() instead"),[2,this.forEachAsync(t)]})})},t.prototype.map=function(t){var n=this,r=this;return U(function(){return i(n,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return[4,r.iterator()];case 1:return[2,n.sent().map(function(n){return e.tidy(function(){return t(n)})})]}})})},this.size)},t.prototype.mapAsync=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().mapAsync(t)]}})})},this.size)},t.prototype.prefetch=function(t){var e=this;if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().prefetch(t)]}})})},this.size)},t.prototype.repeat=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){var e,r=this;return o(this,function(s){return e=S(function(){return i(r,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return t={},[4,n.iterator()];case 1:return[2,(t.value=e.sent(),t.done=!1,t)]}})})}),[2,(u=e.take(t),new H(u,a))];var u,a})})},null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null)},t.prototype.skip=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().skip(t)]}})})},null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null)},t.prototype.shuffle=function(t,n,r){var s=this;if(void 0===r&&(r=!0),null==t||t<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)");var u=this,a=p(n||e.util.now().toString());return U(function(){return i(s,void 0,void 0,function(){var e;return o(this,function(n){switch(n.label){case 0:return e=a.int32(),r&&(e+=a.int32()),[4,u.iterator()];case 1:return[2,n.sent().shuffle(t,e.toString())]}})})},this.size)},t.prototype.take=function(t){var e=this,n=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().take(t)]}})})},null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null)},t.prototype.toArray=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArray()]}})})},t.prototype.toArrayForTest=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArrayForTest()]}})})},t.MAX_BUFFER_SIZE=1e4,t}();function U(t,e){return void 0===e&&(e=null),new(function(n){function s(){var t=null!==n&&n.apply(this,arguments)||this;return t.size=e,t}return r(s,n),s.prototype.iterator=function(){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,t()]})})},s}(W))}function Q(t){return null===t?null:function(t){return null==t||null===(n=t)||"object"!=typeof n&&"function"!=typeof n||Array.isArray(t)||"object"==typeof t&&t instanceof e.Tensor||e.util.isTypedArray(t);var n}(t[0])?{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof e.Tensor?e.stack(t):e.tensor(t)}(t),recurse:!1}:{value:null,recurse:!0}}var X=function(t){function e(e){var n=t.call(this)||this;return n.input=e,n}return r(e,t),e.prototype.iterator=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return[4,this.input.iterator()];case 1:return t=n.sent(),e=t.decodeUTF8(),[2,e.split("\n").map(function(t){return t.endsWith("\r")&&(t=t.slice(0,-1)),t})]}})})},e}(W),G=Symbol("out"),Z=Symbol("field"),J=Symbol("quote"),Y=Symbol("quoteafterquote"),K=Symbol("quoteinquote"),$=function(t){function n(n,r){var i=t.call(this)||this;return i.input=n,i.hasHeader=!0,i.fullColumnNames=null,i.columnNamesValidated=!1,i.columnConfigs=null,i.configuredColumnsOnly=!1,i.delimiter=",",i.delimWhitespace=!1,i.base=new X(n),r||(r={}),i.hasHeader=!1!==r.hasHeader,i.fullColumnNames=r.columnNames,i.columnConfigs=r.columnConfigs,i.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(e.util.assert(null==r.delimiter,function(){return"Delimiter should not be provided when delimWhitespace is true."}),i.delimWhitespace=!0,i.delimiter=" "):i.delimiter=r.delimiter?r.delimiter:",",i}return r(n,t),n.prototype.columnNames=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:t.sent(),t.label=2;case 2:return[2,this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames]}})})},n.prototype.setColumnNames=function(){return i(this,void 0,void 0,function(){var t,n,r,i,s,u,a=this;return o(this,function(o){switch(o.label){case 0:return[4,this.maybeReadHeaderLine()];case 1:if(t=o.sent(),!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");if(this.fullColumnNames&&t&&e.util.assert(t.length===this.fullColumnNames.length,function(){return"The length of provided columnNames ("+a.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+")."}),this.fullColumnNames||(this.fullColumnNames=t),n=this.fullColumnNames.reduce(function(t,e){return t[e]=t[e]+1||1,t},{}),r=Object.keys(n).filter(function(t){return n[t]>1}),e.util.assert(0===r.length,function(){return"Duplicate column names found: "+r.toString()}),this.columnConfigs)for(i=0,s=Object.keys(this.columnConfigs);i<s.length;i++)if(u=s[i],-1===this.fullColumnNames.indexOf(u))throw new Error('The key "'+u+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").");return this.columnNamesValidated=!0,[2]}})})},n.prototype.maybeReadHeaderLine=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return this.hasHeader?[4,this.base.iterator()]:[3,3];case 1:return[4,n.sent().next()];case 2:if((t=n.sent()).done)throw new Error("No data was found for CSV parsing.");return e=t.value,[2,this.parseRow(e,!1)];case 3:return[2,null]}})})},n.prototype.iterator=function(){return i(this,void 0,void 0,function(){var t,e=this;return o(this,function(n){switch(n.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:n.sent(),n.label=2;case 2:return[4,this.base.iterator()];case 3:return t=n.sent(),this.hasHeader&&(t=t.skip(1)),[2,t.map(function(t){return e.makeDataElement(t)})]}})})},n.prototype.makeDataElement=function(t){for(var e=this.parseRow(t),n={},r={},i=0;i<this.fullColumnNames.length;i++){var o=this.fullColumnNames[i],s=this.columnConfigs?this.columnConfigs[o]:null;if(!this.configuredColumnsOnly||s){var u=e[i],a=null;if(""===u)if(s&&void 0!==s.default)a=s.default;else{if(s&&(s.required||s.isLabel))throw new Error("Required column "+o+" is empty in this line: "+t);a=void 0}else{var c=Number(u);if(isNaN(c))a=s&&"bool"===s.dtype?this.getBoolean(u):u;else if(s&&s.dtype)switch(s.dtype){case"float32":a=c;break;case"int32":a=Math.floor(c);break;case"bool":a=this.getBoolean(u);break;default:a=c}else a=c}s&&s.isLabel?r[o]=a:n[o]=a}}return 0===Object.keys(r).length?n:{xs:n,ys:r}},n.prototype.getBoolean=function(t){return"1"===t||"true"===t.toLowerCase()?1:0},n.prototype.parseRow=function(t,e){void 0===e&&(e=!0);for(var n=[],r=0,i=t.length,o=G,s=0;s<i;s++)switch(o){case G:switch(t.charAt(s)){case'"':r=s+1,o=J;break;case this.delimiter:if(r=s+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),o=G;break;default:o=Z,r=s}break;case Z:switch(t.charAt(s)){case this.delimiter:n.push(t.substring(r,s)),o=G,r=s+1}break;case J:switch(t.charAt(s)){case'"':o=Y}break;case Y:switch(t.charAt(s)){case this.delimiter:n.push(t.substring(r,s-1)),o=G,r=s+1;break;case'"':o=J;break;default:o=K}break;case K:switch(t.charAt(s)){case'"':o=J}}if(o===Y?n.push(t.substring(r,i-1)):n.push(t.substring(r)),e&&n.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have "+this.fullColumnNames.length+" elements in a row, but got "+n);return n},n}(W),tt=function(t){function n(e){var n=t.call(this)||this;n.microphoneConfig=e,n.isClosed=!1,n.fftSize=e.fftSize||1024;var r=Math.log2(n.fftSize);if(n.fftSize<0||r<4||r>14||!Number.isInteger(r))throw new Error("Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got "+n.fftSize);if(n.numFrames=e.numFramesPerSpectrogram||43,n.sampleRateHz=e.sampleRateHz,n.columnTruncateLength=e.columnTruncateLength||n.fftSize,n.audioTrackConstraints=e.audioTrackConstraints,n.smoothingTimeConstant=e.smoothingTimeConstant||0,n.includeSpectrogram=!1!==e.includeSpectrogram,n.includeWaveform=!0===e.includeWaveform,!n.includeSpectrogram&&!n.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return n}return r(n,t),n.prototype.summary=function(){return"microphone"},n.create=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,function(){var r;return o(this,function(i){switch(i.label){case 0:if(e.ENV.get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");return[4,(r=new n(t)).start()];case 1:return i.sent(),[2,r]}})})},n.prototype.start=function(){return i(this,void 0,void 0,function(){var t,e,n,r;return o(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=this,[4,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})];case 1:return t.stream=i.sent(),[3,3];case 2:throw e=i.sent(),new Error("Error thrown while initializing video stream: "+e.message);case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(n=window.AudioContext||window.webkitAudioContext,this.audioContext=new n,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;return r=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,r.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2]}})})},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,e,n,r,i;return o(this,function(o){switch(o.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return n=o.sent(),this.includeSpectrogram&&(r=this.flattenQueue(n.freqDataQueue),t=this.getTensorFromAudioDataArray(r,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(n.timeDataQueue),e=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:t,waveform:e},done:!1}]}})})},n.prototype.capture=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}})})},n.prototype.getAudioData=function(){return i(this,void 0,void 0,function(){var t,e,n,r=this;return o(this,function(i){return t=[],e=[],n=0,[2,new Promise(function(i){var o=setInterval(function(){r.includeSpectrogram&&(r.analyser.getFloatFrequencyData(r.freqData),r.freqData[0]===-1/0&&i({freqDataQueue:t,timeDataQueue:e}),t.push(r.freqData.slice(0,r.columnTruncateLength))),r.includeWaveform&&(r.analyser.getFloatTimeDomainData(r.timeData),e.push(r.timeData.slice())),++n===r.numFrames&&(clearInterval(o),i({freqDataQueue:t,timeDataQueue:e}))},r.fftSize/r.sampleRateHz*1e3)})]})})},n.prototype.stop=function(){this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop()},n.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},n.prototype.getSampleRate=function(){return this.sampleRateHz},n.prototype.flattenQueue=function(t){var e=t[0].length,n=new Float32Array(t.length*e);return t.forEach(function(t,r){return n.set(t,r*e)}),n},n.prototype.getTensorFromAudioDataArray=function(t,n){var r=new Float32Array(e.util.sizeFromShape(n));return r.set(t,r.length-t.length),e.tensor(r,n)},n}(R),et=function(t){function n(n,r){var i=t.call(this)||this;if(i.webcamVideoElement=n,i.webcamConfig=r,i.isClosed=!0,i.resize=!1,i.needToResize())if(i.resize=!0,i.cropSize=[i.webcamConfig.resizeHeight,i.webcamConfig.resizeWidth],i.cropBoxInd=e.tensor1d([0],"int32"),i.webcamConfig.centerCrop){var o=1*i.webcamConfig.resizeWidth/i.webcamVideoElement.width,s=1*i.webcamConfig.resizeHeight/i.webcamVideoElement.height,u=(1-o)/2,a=(1-s)/2,c=u+o,h=s+a;i.cropBox=e.tensor2d([a,u,h,c],[1,4])}else i.cropBox=e.tensor2d([0,0,1,1],[1,4]);return i}return r(n,t),n.prototype.summary=function(){return"webcam"},n.create=function(t,r){return void 0===r&&(r={}),i(this,void 0,void 0,function(){var i;return o(this,function(o){switch(o.label){case 0:if(e.ENV.get("IS_NODE"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!r.resizeWidth||!r.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=r.resizeWidth,t.height=r.resizeHeight}return[4,(i=new n(t,r)).start()];case 1:return o.sent(),[2,i]}})})},n.prototype.start=function(){return i(this,void 0,void 0,function(){var t,n,r=this;return o(this,function(i){switch(i.label){case 0:this.webcamConfig.facingMode&&e.util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,function(){return"Invalid webcam facing mode: "+r.webcamConfig.facingMode+". Please provide 'user' or 'environment'"}),i.label=1;case 1:return i.trys.push([1,3,,4]),t=this,[4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})];case 2:return t.stream=i.sent(),[3,4];case 3:throw(n=i.sent()).message="Error thrown while initializing video stream: "+n.message,n;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise(function(t){r.webcamVideoElement.onloadedmetadata=function(){t()}})]}})})},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){if(this.isClosed)return[2,{value:null,done:!0}];try{t=e.browser.fromPixels(this.webcamVideoElement)}catch(t){throw new Error("Error thrown converting video to pixels: "+JSON.stringify(t))}if(!this.resize)return[2,{value:t,done:!1}];try{return[2,{value:this.cropAndResizeFrame(t),done:!1}]}catch(t){throw new Error("Error thrown cropping the video: "+t.message)}finally{t.dispose()}return[2]})})},n.prototype.needToResize=function(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)},n.prototype.cropAndResizeFrame=function(t){var n=this;return e.tidy(function(){var r,i=t.toFloat().expandDims(0),o=(r=e.image.cropAndResize(i,n.cropBox,n.cropBoxInd,n.cropSize,"bilinear")).shape;return r.reshape(o.slice(1))})},n.prototype.capture=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}})})},n.prototype.stop=function(){this.stream.getTracks().forEach(function(t){return t.stop()});try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0},n.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},n}(R),nt=function(){return function(){}}(),rt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.split=function(t){return new it(this,t)},e}(R),it=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.impl=new ot(e,n),r}return r(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return[2,this.impl.next()]})})},e}(rt),ot=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.separator=n,r.carryover="",r}return r(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')"},e.prototype.pump=function(){return i(this,void 0,void 0,function(){var t,e,n,r,i;return o(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if((t=o.sent()).done)return""===this.carryover?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);for((e=t.value.split(this.separator))[0]=this.carryover+e[0],n=0,r=e.slice(0,-1);n<r.length;n++)i=r[n],this.outputQueue.push(i);return this.carryover=e[e.length-1],[2,!0]}})})},e}(L),st=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.decodeUTF8=function(){return new ut(this)},e}(R),ut=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.impl=new at(e),n}return r(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return[2,this.impl.next()]})})},e}(rt),at=function(t){function n(n){var r=t.call(this)||this;if(r.upstream=n,e.ENV.get("IS_BROWSER"))r.decoder=new TextDecoder("utf-8");else{var i=require("string_decoder").StringDecoder;r.decoder=new i("utf8")}return r}return r(n,t),n.prototype.summary=function(){return this.upstream.summary()+" -> Utf8"},n.prototype.pump=function(){return i(this,void 0,void 0,function(){var t,n,r;return o(this,function(i){switch(i.label){case 0:return[4,this.upstream.next()];case 1:return(t=i.sent()).done?[2,!1]:(n=t.value,r=e.ENV.get("IS_BROWSER")?this.decoder.decode(n,{stream:!0}):this.decoder.write(Buffer.from(n.buffer)),this.outputQueue.push(r),[2,!0])}})})},n}(L),ct=function(t){function n(n,r){void 0===r&&(r={});var i=t.call(this)||this;return i.file=n,i.options=r,e.util.assert(n instanceof Uint8Array||!!e.ENV.get("IS_BROWSER")&&(n instanceof File||n instanceof Blob),function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."}),i.offset=r.offset||0,i.chunkSize=r.chunkSize||1048576,i}return r(n,t),n.prototype.summary=function(){return"FileChunks "+this.file},n.prototype.next=function(){return i(this,void 0,void 0,function(){var t,e,n=this;return o(this,function(r){switch(r.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(t=new Promise(function(t,e){var r=n.offset+n.chunkSize;if(n.file instanceof Uint8Array)t(new Uint8Array(n.file.slice(n.offset,r)));else{var i=new FileReader;i.onload=function(n){var r=i.result;if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),!(r instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(r)},i.onabort=function(t){return e(new Error("Aborted"))},i.onerror=function(t){return e(new Error(t.type))};var o=n.file.slice(n.offset,r);i.readAsArrayBuffer(o)}n.offset=r}),e={},[4,t]);case 1:return[2,(e.value=r.sent(),e.done=!1,e)]}})})},n}(st);var ht=function(t){return{method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity}};function lt(t){return"string"==typeof t&&"file://"===t.substr(0,7)}var ft=function(t){function n(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.input=e,r.options=n,r}return r(n,t),n.prototype.iterator=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(n){return lt(this.input)&&e.ENV.get("IS_NODE")&&(t=require("fs"),this.input=t.readFileSync(this.input.substr(7))),[2,new ct(this.input,this.options)]})})},n}(nt),dt=function(t){function n(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.url=e,r.fileOptions=n,r}return r(n,t),n.prototype.iterator=function(){return i(this,void 0,void 0,function(){return o(this,function(t){return lt(this.url)?[2,new ft(this.url,this.fileOptions).iterator()]:[2,function(t,n){return void 0===n&&(n={}),i(this,void 0,void 0,function(){var r,i,s,u,a;return o(this,function(o){switch(o.label){case 0:return"string"==typeof t?r=t:(r=t.url,i=ht(t)),[4,e.util.fetch(r,i)];case 1:return(s=o.sent()).ok?(a=Uint8Array.bind,[4,s.arrayBuffer()]):[3,3];case 2:return u=new(a.apply(Uint8Array,[void 0,o.sent()])),[2,new ct(u,n)];case 3:throw new Error(s.statusText)}})})}(this.url,this.fileOptions)]})})},n}(nt);t.array=function(t){var e=this;return U(function(){return i(e,void 0,void 0,function(){return o(this,function(e){return[2,E(t)]})})},t.length)},t.Dataset=W,t.zip=function(t){var e,n=this;if(!b(t))throw new Error("The argument to zip() must be an object or array.");if(Array.isArray(t))for(var r=0;r<t.length;r++)e=null==e?t[r].size:Math.min(e,t[r].size);else if(t instanceof Object)for(var s in t)e=null==e?t[s].size:Math.min(e,t[s].size);return U(function(){return i(n,void 0,void 0,function(){var e;return o(this,function(n){switch(n.label){case 0:return[4,w(t,function(t){if(t instanceof W)return{value:t.iterator(),recurse:!1};if(b(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})];case 1:return e=n.sent(),[2,(r=e,i=A.SHORTEST,void 0===i&&(i=A.FAIL),new P(r,i))]}var r,i})})},e)},t.CSVDataset=$,t.TextLineDataset=X,t.csv=function(t,e){return void 0===e&&(e={}),new $(new dt(t),e)},t.func=function(t){var e=this,n=S(t);return U(function(){return i(e,void 0,void 0,function(){return o(this,function(t){return[2,n]})})})},t.generator=function(t){var e=this;return U(function(){return i(e,void 0,void 0,function(){var e;return o(this,function(n){switch(n.label){case 0:return[4,t()];case 1:return e=n.sent(),[2,S(function(){return e.next()})]}})})})},t.microphone=function(t){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,tt.create(t)]})})},t.webcam=function(t,e){return i(this,void 0,void 0,function(){return o(this,function(n){return[2,et.create(t,e)]})})},t.FileDataSource=ft,t.URLDataSource=dt,t.version_data="1.2.9",Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=tf-data.min.js.map

@@ -19,4 +19,2 @@ /**

import { DataType, TensorContainer } from '@tensorflow/tfjs-core';
import { Dataset } from './dataset';
import { LazyIterator } from './iterators/lazy_iterator';
/**

@@ -36,10 +34,2 @@ * @deprecated Use `TensorContainer` from `@tensorflow/tfjs-core` instead.

/**
* A nested structure of Datasets, used as the input to zip().
*/
export declare type DatasetContainer = Container<Dataset<DataElement>>;
/**
* A nested structure of LazyIterators, used as the input to zip().
*/
export declare type IteratorContainer = Container<LazyIterator<DataElement>>;
/**
* Types supported by FileChunkIterator in both Browser and Node Environment.

@@ -46,0 +36,0 @@ */

@@ -19,2 +19,3 @@ /**

export declare function setupFakeVideoStream(): void;
export declare function replaceHTMLVideoElementSource(videoElement: HTMLVideoElement): Promise<void>;
export declare function describeAllEnvs(testName: string, tests: () => void): void;

@@ -21,0 +22,0 @@ export declare function describeBrowserEnvs(testName: string, tests: () => void): void;

/** @license See the LICENSE file. */
declare const version = "1.2.8";
declare const version = "1.2.9";
export { version };

@@ -5,4 +5,4 @@ "use strict";

// This code is auto-generated, do not modify this file!
var version = '1.2.8';
var version = '1.2.9';
exports.version = version;
//# sourceMappingURL=version.js.map
{
"name": "@tensorflow/tfjs-data",
"version": "1.2.8",
"version": "1.2.9",
"description": "TensorFlow Data API in JavaScript",

@@ -15,4 +15,4 @@ "private": false,

"devDependencies": {
"@tensorflow/tfjs-core": "1.2.8",
"@tensorflow/tfjs-layers": "1.2.1",
"@tensorflow/tfjs-core": "1.2.9",
"@tensorflow/tfjs-layers": "1.2.8",
"@types/jasmine": "~2.5.53",

@@ -39,3 +39,4 @@ "@types/seedrandom": "^2.4.27",

"tslint": "~5.11.0",
"typescript": "3.3.3333",
"tslint-no-circular-imports": "^0.7.0",
"typescript": "3.5.3",
"yalc": "^1.0.0-pre.23"

@@ -57,3 +58,3 @@ },

"peerDependencies": {
"@tensorflow/tfjs-core": "1.2.8",
"@tensorflow/tfjs-core": "1.2.9",
"seedrandom": "~2.4.3"

@@ -60,0 +61,0 @@ },

@@ -23,5 +23,10 @@ /**

import {iteratorFromConcatenated, iteratorFromFunction, iteratorFromItems, iteratorFromZipped, LazyIterator, ZipMismatchMode} from './iterators/lazy_iterator';
import {DatasetContainer} from './types';
import {Container, DataElement} from './types';
import {canTensorify, deepMapAndAwaitAll, DeepMapResult, isIterable} from './util/deep_map';
/**
* A nested structure of Datasets, used as the input to zip().
*/
export type DatasetContainer = Container<Dataset<DataElement>>;
// TODO(soergel): consider vectorized operations within the pipeline.

@@ -28,0 +33,0 @@

@@ -242,3 +242,3 @@ /**

// Set value as string
parsedValue = value as string;
parsedValue = value;
}

@@ -245,0 +245,0 @@ } else if (!config || !config.dtype) {

@@ -22,3 +22,3 @@ /**

import {IteratorContainer} from '../types';
import {Container, DataElement} from '../types';
import {deepClone} from '../util/deep_clone';

@@ -29,2 +29,7 @@ import {deepMapAndAwaitAll, DeepMapAsyncResult, DeepMapResult, deepZip, zipToList} from '../util/deep_map';

/**
* A nested structure of LazyIterators, used as the input to zip().
*/
export type IteratorContainer = Container<LazyIterator<DataElement>>;
// Here we implement a simple asynchronous iterator.

@@ -1082,3 +1087,3 @@ // This lets us avoid using either third-party stream libraries or

this.currentPromise = this.nextState(this.currentPromise);
return (await this.currentPromise);
return this.currentPromise;
}

@@ -1085,0 +1090,0 @@ }

@@ -20,4 +20,2 @@ /**

import {DataType, TensorContainer} from '@tensorflow/tfjs-core';
import {Dataset} from './dataset';
import {LazyIterator} from './iterators/lazy_iterator';

@@ -42,12 +40,2 @@ /**

/**
* A nested structure of Datasets, used as the input to zip().
*/
export type DatasetContainer = Container<Dataset<DataElement>>;
/**
* A nested structure of LazyIterators, used as the input to zip().
*/
export type IteratorContainer = Container<LazyIterator<DataElement>>;
/**
* Types supported by FileChunkIterator in both Browser and Node Environment.

@@ -54,0 +42,0 @@ */

@@ -23,4 +23,4 @@ /**

export function setupFakeVideoStream() {
const width = 500;
const height = 500;
const width = 100;
const height = 200;
const canvasElement = document.createElement('canvas');

@@ -37,2 +37,18 @@ const ctx = canvasElement.getContext('2d');

export async function replaceHTMLVideoElementSource(videoElement:HTMLVideoElement) {
const source = document.createElement('source');
// tslint:disable:max-line-length
source.src = 'data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAAu1tZGF0AAACrQYF//+p3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE1NSByMjkwMSA3ZDBmZjIyIC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxOCAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTMgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MzoweDExMyBtZT1oZXggc3VibWU9NyBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0xIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MSA4eDhkY3Q9MSBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0tMiB0aHJlYWRzPTMgbG9va2FoZWFkX3RocmVhZHM9MSBzbGljZWRfdGhyZWFkcz0wIG5yPTAgZGVjaW1hdGU9MSBpbnRlcmxhY2VkPTAgYmx1cmF5X2NvbXBhdD0wIGNvbnN0cmFpbmVkX2ludHJhPTAgYmZyYW1lcz0zIGJfcHlyYW1pZD0yIGJfYWRhcHQ9MSBiX2JpYXM9MCBkaXJlY3Q9MSB3ZWlnaHRiPTEgb3Blbl9nb3A9MCB3ZWlnaHRwPTIga2V5aW50PTI1MCBrZXlpbnRfbWluPTEgc2NlbmVjdXQ9NDAgaW50cmFfcmVmcmVzaD0wIHJjX2xvb2thaGVhZD00MCByYz1jcmYgbWJ0cmVlPTEgY3JmPTI4LjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IGlwX3JhdGlvPTEuNDAgYXE9MToxLjAwAIAAAAAwZYiEAD//8m+P5OXfBeLGOfKE3xkODvFZuBflHv/+VwJIta6cbpIo4ABLoKBaYTkTAAAC7m1vb3YAAABsbXZoZAAAAAAAAAAAAAAAAAAAA+gAAAPoAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAIYdHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAPoAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAACgAAAAWgAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAD6AAAAAAAAQAAAAABkG1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAQAAAAEAAVcQAAAAAAC1oZGxyAAAAAAAAAAB2aWRlAAAAAAAAAAAAAAAAVmlkZW9IYW5kbGVyAAAAATttaW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAD7c3RibAAAAJdzdHNkAAAAAAAAAAEAAACHYXZjMQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAACgAFoASAAAAEgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABj//wAAADFhdmNDAWQACv/hABhnZAAKrNlCjfkhAAADAAEAAAMAAg8SJZYBAAZo6+JLIsAAAAAYc3R0cwAAAAAAAAABAAAAAQAAQAAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAAFHN0c3oAAAAAAAAC5QAAAAEAAAAUc3RjbwAAAAAAAAABAAAAMAAAAGJ1ZHRhAAAAWm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALWlsc3QAAAAlqXRvbwAAAB1kYXRhAAAAAQAAAABMYXZmNTguMTIuMTAw';
source.type = 'video/mp4';
videoElement.srcObject=null;
videoElement.appendChild(source);
videoElement.play();
if (videoElement.readyState < 2) {
await new Promise(resolve => {
videoElement.addEventListener('loadeddata', () => resolve());
});
}
}
// Register backends.

@@ -39,0 +55,0 @@ registerTestEnv({name: 'cpu', backendName: 'cpu'});

/** @license See the LICENSE file. */
// This code is auto-generated, do not modify this file!
const version = '1.2.8';
const version = '1.2.9';
export {version};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc